Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect internal format used when allocating texure to be used as framebuffer #469

Open
AnyOldName3 opened this issue Aug 20, 2024 · 0 comments

Comments

@AnyOldName3
Copy link

AnyOldName3 commented Aug 20, 2024

I'll start by saying there might be some slight inaccuracies here as this has been diagnosed with discussion rather than reproduced on my machine, but the gist should be correct.

Some code like this is used to allocate texture storage for a framebuffer:

             glTexImage2D( GL_TEXTURE_2D, 0, _internalFormat,
                      _textureWidth, _textureHeight, _borderWidth,
                      internalFormat,
                      _sourceType ? _sourceType : GL_UNSIGNED_BYTE,
                      0);

When _internalFormat is GL_RGB16F, and _sourceType is explicitly GL_HALF_FLOAT, GL4ES creates a GL_RGB16F texture that seems to work as it should. When _sourceType is zero, so GL_UNSIGNED_BYTE is passed as a default, a different internal format is given (I guess GL_RGB8 - it's a normalised integer format, not a half float one).

Based on the spec, as the data argument is a null pointer, and no texture data actually gets uploaded, the format and type arguments aren't supposed to do anything, and we should get a texture with allocated storage and the requested internal format.

From a look at the gl4es_glTexImage2D I'm unsure whether this is because the internal format isn't being converted from GL_RGB16F to something GLES likes (I see that it's a constant in GLES 3, but GLES 2's glTexImage2D documentation doesn't have the internal format table I'm used to from desktop GL), or whether GL4ES is mistakenly thinking we're uploading unsigned byte data and that a half float internal format would be wasted.

Edit: this issue originally discussed GL_R16F, but apparently that doesn't work whether or not the source type is explicitly passed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant