[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Public WebGL] createTextures vs. genTexture 2^32 limit

In OpenGL ES, genTexture appears to be underdefined after the first 2^32 calls:

> void GenTextures( sizei n, uint *textures ); returns n previously unused texture object names in textures. These names are marked as used, for the purposes of GenTextures only, ...

That is, even after a glDeleteTextures() call on a texture, glGenTextures will never return the same value again.  However, the ES spec doesn't appear to say what happens if it runs out--if you overflow uint.

It's definitely possible to call createTexture() 2^32 times; in Chrome 18 on my system, it takes about three hours.  This shouldn't happen in well-written programs, but it still needs to be defined.

I'm not actually concerned about ES's behavior here, since WebGL's texture objects don't expose integer texture IDs.  However, the underdefined overflow problem is inherited by WebGL, since createTexture is defined in terms of genTextures.

WebGL can avoid this by not defining createTexture() in terms of glGenTextures.  Instead, say: "Create a WebGLTexture object and initialize it with a texture object name not in use by any other WebGLTexture in this context."  That's still valid, since OpenGL doesn't actually require that you use glGenTextures.

The same applies to the other create* functions as well, of course.

(I'd call this one low-priority, but a good thing to tighten up.)

Glenn Maynard