gfx-rs / gfx

[maintenance mode] A low-overhead Vulkan-like GPU API for Rust.
http://gfx-rs.github.io/
Apache License 2.0
5.35k stars 551 forks source link

Support wgpu skybox example on webgl #3773

Open Frizi opened 3 years ago

Frizi commented 3 years ago

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.