19 minutes ago, ferreiradaselva said:
Could this be only a safety measure or does it improve performance?
I wouldn't think so..glMapBuffer maps the entire buffer into the address space of the process, while glMapBufferRange maps only a range. Now, lets consider you have a buffer thats several 100 MBs in size ( just an extreme though possible ), now when you map this buffer using glMapBuffer, whenever the buffer is unmapped, there is the potential that this entire region is now dirty and will have to be flushed back to the source. In reality its a little more involved than this as the mapped memory should be backed by paged memory so at least only dirty pages should be flush ( don't really know if this is how the driver does it ). However, if you have some knowledge of how the buffer is being used, then glMapBufferRange makes more sense as now you limit how much data that has to be synchronized with the server upon unmapping/invalidation. I have not personally measured and compared the performance of both, but the voice in my head keep telling me that glMapBufferRange should be more performant..lol. Hope that helps.