-
-
Notifications
You must be signed in to change notification settings - Fork 22.1k
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
WebGL 2.0: Force decompressing non power-of-2 textures with repeat/mipmap #33059
Conversation
This is probably not the right fix as discussed with @reduz. OpenGL ES 3.0 and WebGL 2.0 should support NPOT textures as per specification: https://www.khronos.org/registry/webgl/specs/latest/2.0/#4.1.3 But the problem seems to be that mobile hardware (and thus likely browser WebGL implementation for consistency) don't all support compressed NPOT textures, which is a badly specified hole in the spec. So here we are. An option would be to add some code only for WebGL that would just uncompress NPOT textures (resizing them might not be necessary).
This would still be the better option though IMO. |
…pmap While OpenGL ES 3.0 and WebGL 2.0 both support non power-of-2 (NPOT) textures in their specification, the situation seems to be less clear about *compressed* NPOT textures using repeat or mipmap flags. At least Chrome on Linux doesn't seem to support this combination, and a variety of mobile hardware have similar limitations. As a workaround, we force decompressing such textures when running on WebGL 2.0, at the cost of loading time and memory usage. Fixes godotengine#33058.
074e24f
to
6900345
Compare
I pushed an update to do that. |
Tested successfully on Firefox Beta and Chrome on Android (current versions), and Chrom(ium) on Linux. Firefox can't be tested on Linux due to #33058. |
@@ -753,13 +767,9 @@ void RasterizerStorageGLES3::texture_set_data(RID p_texture, const Ref<Image> &p | |||
if (config.keep_original_textures && !(texture->flags & VS::TEXTURE_FLAG_USED_FOR_STREAMING)) { | |||
texture->images.write[p_layer] = p_image; | |||
} | |||
#ifndef GLES_OVER_GL | |||
if (p_image->is_compressed() && p_image->has_mipmaps() && !p_image->is_size_po2()) { | |||
ERR_PRINTS("Texuture '" + texture->path + "' is compressed, has mipmaps but is not of powerf-of-2 size. This does not work on OpenGL ES 3.0."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed this as AFAIK, we force resizing to power of 2 sizes when compressing to ETC, ETC2 or PVRTC. So S3TC on WebGL was the only situation where this would not happen, and it should now be fixed by this forced decompression.
While OpenGL ES 3.0 and WebGL 2.0 both support non power-of-2 (NPOT)
textures in their specification, the situation seems to be less clear
about compressed NPOT textures using repeat or mipmap flags.
At least Chrome on Linux doesn't seem to support this combination,
and a variety of mobile hardware have similar limitations.
As a workaround, we force decompressing such textures when running on
WebGL 2.0, at the cost of loading time and memory usage.
Fixes #33058.