While OpenGL ES 2.0 provides glGetTexLevelParameteriv(), it lacks support for several very basic, useful pname queries. In particular, GL_TEXTURE_WIDTH and GL_TEXTURE_HEIGHT. There is no other way in the GLES2 API to query for a texture's width/height. Note that GLES3 *does* support this, but Chromium does not provide that level of API support.
Proposal: Introduce a glGetTexLevelParameterivCHROMIUM() that supports some additional pnames. GL_TEXTURE_WIDTH/HEIGHT for sure, but we might as well plumb-in any other "low-hanging fruit" around that. Ideally, everything supported by GLES3 could be supported by our CHROMIUM extension API.
Rationale: Having this would clean up a whole bunch of client-side code throughout the Chromium code base. We currently have to pass around texture sizes alongside texture names in cases where there are shaders that need to compute texel coordinates. This burdens the clients of public APIs with having to separately track this extra information. Instead, we should be able to pass around just texture names and let implementations query for the texture size if that is needed.
Background: The need for this became very clear while working on a major change to some GLHelper code: https://chromium-review.googlesource.com/c/chromium/src/+/669918 In that change, the fragment shaders need to know the pixel size of an entire source texture in order to compute texel coordinates, and this extra information had to be plumbed in through dozens of call points and in the public API. Even worse, the extra texture size arguments in method calls has already confused readers of the code: They easily assumed this instead represented the source rect for scaling, or some kind of crop region; but it is neither.
FWIW, there also is no GLSL capability for this either, as GLES2 does not support the built-in textureSize() call that was introduced as of #version 130.
Comment 1 by benhenry@chromium.org
, Aug 1