Support wgpu skybox example on webgl#3773
Conversation
| } | ||
| if info.is_supported(&[ | ||
| Es(3, 0), | ||
| Ext("WEBGL_compressed_texture_s3tc"), |
There was a problem hiding this comment.
Currently, extensions list is empty for Webgl.
gfx/src/backend/gl/src/info.rs
Lines 302 to 304 in 0a0cdaa
There was a problem hiding this comment.
Oh I see. It worked for me because the is_supported is an "or" of passed requirements, and Es 3.0 is always satisfied. That means this code is indeed wrong. I need to populate the extension list.
There was a problem hiding this comment.
First we need to expose extension list from glow somehow. Or copy-paste extensions checking from glow codebase:
https://github.com/grovesNL/glow/blob/7775e74363877347b2210d91277646a09d70dd08/src/web_sys.rs#L105-L109
There was a problem hiding this comment.
I've exposed the extensions in grovesNL/glow#165. Let's wait for it to be in.
| (glow::BYTE, glow::SHORT, glow::INT), | ||
| C::Uint | C::Unorm => | ||
| (glow::UNSIGNED_BYTE, glow::UNSIGNED_SHORT, glow::UNSIGNED_INT), | ||
| C::Float => (glow::ZERO, glow::HALF_FLOAT, glow::FLOAT), |
There was a problem hiding this comment.
Yes, though the commented out code shouldn't really be here in the first place. We have git for that.
There was a problem hiding this comment.
Maybe it would be better to remove all commented code?
| } | ||
| } | ||
|
|
||
| pub const COMPRESSED_RGB_S3TC_DXT1_EXT: u32 = 0x83F0; |
There was a problem hiding this comment.
I think it would be better to expose this on glow side.
This changesets adds necessary features to GL backend in order to support skybox example from wgpu repository in webgl.
Most notable is adding support for cubemaps. Unfortunately due to the complexity of emulating image views in GL and the fact that you can't use a single gl texture in multiple ways, the support is very limited. Every 6-layer square image is assumed to be a cubemap, and creating other than cubemap views to it will fail. Further work on that should be done eventually, but I want to get the basic support first.
Another thing is support for compressed textures, specifically S3TC formats. This was added, because skybox example texture format fallback ise BGRA, which is not supported on webgl at all. Adding support for compressed format allowed me to run the example unmodified. Further work here is adding more formats and adding a downlevel flag for BGRA texture format, which is for some reason not supported on GLES.