Usage hint for buffer object

Hello Everyone!

I’m trying to properly set up the usage hint of a uniform buffer, but I’m a bit unsure since I don’t fully understand the documentation of the hints.

The first hint group (STREAM, STATIC, DYNAMIC) is understandable to me.
My use case is a uniform buffer I will update frequently using orphaning.
STREAM should be the appropriate hint.

But the documentation of the second group (DRAW, READ, COPY) i don’t understand. Specifcally the phrase ‘The data store contents are modified by reading data from the GL’ . What does that mean?

Could someone explain me what the hints really mean? Maybe by giving an example? And what should I use?

The documentation says:

DRAW

The data store contents are modified by the application, and used as the source for GL drawing and image specification commands.

READ

The data store contents are modified by reading data from the GL, and used to return that data when queried by the application.

COPY

The data store contents are modified by reading data from the GL, and used as the source for GL drawing and image specification commands.

It means that the buffer is used to transfer data from the GPU to the CPU. E.g. a buffer which will be bound to GL_PIXEL_PACK_BUFFER or GL_TRANSFORM_FEEDBACK_BUFFER, or one bound to GL_SHADER_STORAGE_BUFFER to provide storage for variables which are written (but not read) by the shader.

What “the documentation” are you referring to? I can’t find any of those quotations in the OpenGL specification.

Personally, I prefer the OpenGL Wiki’s description:

  • DRAW: The user will be writing data to the buffer, but the user will not read it.
  • READ: The user will not be writing data, but the user will be reading it back.
  • COPY: The user will be neither writing nor reading the data.

Personally, I would avoid using the usage hints entirely, and instead use immutable storage buffers. If that’s not viable for you, then the usage hint will have to depend on your… well, usage of the buffer. That is, what you’re using it for.

For “a uniform buffer I will update frequently using orphaning,” you are writing the buffer’s contents from the CPU, so DRAW is the correct usage.

Thank you, both of you! This clears my misunderstandings.

I used the reference pages:
https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glBufferData.xhtml

Thanks for the tip! I will look into it.