Fra
Fra

Reputation: 423

Max Buffer Sizes Opengl ES 2.0

I know this has been discussed before but I still haven't found a decent answer relevant to 2014. Is there a max size to Vertex Buffer Objects in OpenGL ES 2.0? I am writing a graphics engine to run on Android.

I am using gldrawarrays() to draw bunch of lines with GL_LINE_STRIP. So, I am not using any index arrays so I am not capped by the max value of a short integer which comes up with Index Buffer Objects.

I would like to load in excess of 2 million X,Y,Z float values so around 24mb of data to the GPU.

Am I way out short or way far of the limits? Is there a way to query this?

Upvotes: 1

Views: 1814

Answers (1)

Andon M. Coleman
Andon M. Coleman

Reputation: 43359

As far as the API is concerned, the size of GLsizeiptr is the upper-bound.

That means 4 GiB generally speaking (32-bit pointer being the most common case); of course no integrated device actually has that much GPU memory yet, that is the largest address you can deal with. Consequently, it is the largest number of bytes you can allocate with a function such as glBufferData (...).

Consider the prototype for glBufferData:

void glBufferData (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage);

Now let us look at the definition of GLsizeiptr:

                     OpenGL ES 2.0 Specification - Basic GL Operation - p. 12

              Specification sample

There is no operational limit defined by OpenGL or OpenGL ES. About the best you could portably do is call glBufferData (...) with a certain size and NULL for the data pointer to see if it raises a GL_OUT_OF_MEMORY error. That is very roughly equivalent to a "proxy texture," which is intended to check if there is enough memory to fit a texture with certain dimensions before trying to upload it. It is an extremely crude approach to the problem, but it is one that has been around in GL for ages.

Upvotes: 1

Related Questions