Limits on Vertex Buffer Object (VBO) Size in OpenGL 4.6
0 reputation · 02 Nov 2021, 02:33 UTC
0 reputation · 02 Nov 2021, 02:33 UTC
Determine the maximum size of a vertex buffer object that can be allocated in a given OpenGL 4.6 context.
The maximum buffer size is implementation‑dependent; the specification does not prescribe a single value, and drivers expose it through various queries. It is unclear whether the limit is identical for GL_ARRAY_BUFFER and GL_ELEMENT_ARRAY_BUFFER, or if it is affected by the chosen memory usage hint (GL_STATIC_DRAW, GL_DYNAMIC_DRAW, etc.). Additionally, the token used to query the limit is not consistently documented across driver releases.
glGet token(s) should be used to retrieve this limit reliably across drivers?GL_ARRAY_BUFFER and GL_ELEMENT_ARRAY_BUFFER bindings?35275 reputation · 02 Nov 2021, 04:51 UTC
The OpenGL 4.6 specification does not prescribe a single maximum VBO size; the limit is implementation‑dependent and must be queried at runtime.
GL_MAX_ARRAY_BUFFER_BINDING returns the maximum size in bytes that can be passed to glBufferData or glBufferStorage for any buffer target.GL_ARRAY_BUFFER and GL_ELEMENT_ARRAY_BUFFER; the spec does not distinguish them.GL_STATIC_DRAW, GL_DYNAMIC_DRAW, …) do not affect the size limit; they only influence performance hints.On current desktop GPUs (e.g., NVIDIA RTX 30‑series, AMD Radeon RX 6000, Intel Iris Xe) the queried value usually falls between 16 GB and 32 GB. Mobile or integrated GPUs often report a few hundred megabytes. The exact number varies with driver version and hardware generation.
GLint64 maxSize; // OpenGL 4.6 guarantees 64‑bit integer return
glGetInteger64v(GL_MAX_ARRAY_BUFFER_BINDING, &maxSize);
GL_MAX_ELEMENT_ARRAY_BUFFER_BINDING if you want to confirm the element‑array limit; it should be >= the array‑buffer limit.glBindBuffer(GL_ARRAY_BUFFER, 0);
glBufferData(GL_ARRAY_BUFFER, maxSize, NULL, GL_STATIC_DRAW);
GLenum err = glGetError();
// err should be GL_NO_ERROR; if it is GL_OUT_OF_MEMORY the limit is lower than reported.
If you observe GL_OUT_OF_MEMORY, reduce the size (e.g., by half) and repeat until allocation succeeds; the successful size is the practical limit for that driver.
If you need to know whether the limit differs between GL_ARRAY_BUFFER and GL_ELEMENT_ARRAY_BUFFER on a specific driver, you must query both tokens on that hardware; otherwise the generic query suffices.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.