Write-only `glMapBuffer`, what if I don't write all this?

Let's say I have a buffer object with some data.

I use glMapBufferc GL_WRITE_ONLYand write every second byte (think alternating vertex attributes).

Then I have a glUnmapBufferbuffer.

Are bytes that I did not write to save, or are they now undefined?

I am interested, because the main goal GL_WRITE_ONLYis to avoid transferring the previous contents of the buffer from the memory of the card to main memory. However, the driver does not know for what bytes I actually wrote something to partially update the buffer.

Thus, either the driver first transfers the contents to the main memory, and makes rendering GL_WRITE_ONLYpointless on almost every platform that I could think of. Or it’s supposed that I am writing the full displayed area. However, the manual does not mention such a commitment.

+4
source share
1 answer

Short answer: data is saved.

I'm interested because the main purpose of GL_WRITE_ONLY seems to be to avoid transferring the previous contents of the buffer from the memory card to main memory.

Well, there are many potential ways to fill out this request, and access flags can help you decide which path to take. For example, a driver may decide to perform a direct mapping of the buffer I / O in VRAM instead of using system RAM for mapping.

, , glMapBufferRange() API, GL_ARB_map_buffer_range. , , glMapBuffer() . , GL_MAP_INVALIDATE_RANGE_BIT GL_MAP_INVALIDATE_BUFFER_BIT , GL_WRITE_ONLY. , , .

+4

All Articles