Fix Compressed 3D Textures failing on Android and Meta Quest #29566
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixed #29539
Description
On Android and Oculus devices, calling gl.compressedTexSubImage3D with the extra srcOffset and srcLengthOverride parameters to default (0,0) results in the following error:
[.WebGL-0x2032d0d00]GL ERROR :GL_INVALID_VALUE : glCompressedTexSubImage3D: size is not correct for dimensions
The function
gl.compressedTexSubImage3D
was being called with two extra parameters (0, 0) at the end:When supplying image data directly via an ArrayBufferView (e.g., mipmap.data), the function's signature does not require srcOffset and srcLengthOverride parameters. These extra parameters are only valid when specifying a sub-range of the source data. Including them with default values (0, 0) can cause issues on platforms that strictly adhere to the OpenGL ES specification, which does not support these parameters in the same way based on my understanding of the code: https://chromium.googlesource.com/chromium/src/+/6682b1c4aac00aee61b09ba8f6084f1790429315/gpu/command_buffer/service/gles2_cmd_decoder.cc
While some platforms may read these extra parameters as offset and length override, Android and Oculus implementations probably strictly follow the OpenGL ES standards, leading to a GL_INVALID_VALUE error.
The gl.compressedTexSubImage3D API can be confusing due to the multiple ways to call it between WebGL and OpenGL ES, which might have caused this issue. More here:
https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/compressedTexSubImage3D
https://registry.khronos.org/OpenGL-Refpages/es3.0/html/glCompressedTexSubImage3D.xhtml
Since both optional parameters were not currently being used I believe it should be safe for the moment to simply remove them in order to fix #29539.
This contribution is funded by Utsubo