Don't create shader-clear program on GLES if it's not needed #5348
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.
Connections
n/a
Description
We've noticed this before in Ruffle, that the built in "shader clear program" can contribute to the startup times on webgl. We've seen each shader program take as much as 100ms to compile before, and they really add up.
wgpu doesn't actually need this in most cases though, so it's wasteful to spend the time creating it. This reduces it down to an
Option
, that's only populated if the workaround flag is enabled.I was contemplating removing
Workarounds.MESA_I915_SRGB_SHADER_CLEAR
and having it simply be "this value isSome()
if needed,None
if not", which feels much more natural - but the workaround is stored per Adapter and the program per Queue right now, so I opted to leave it*. I'm also unsure if wgpu prefers to have these things listed as clear workarounds instead, as I do see the merit there.*though this did leave me to question: why are we making so many resources per Queue on gles, rather than Adapter? If you opened up two queues you have two shader clear programs, two zero buffers, two draw fbos, etc. I feel like we can move those to Adapter and save some potential waste, in a future PR.
Testing
It passes tests and seems to run fine!
Checklist
cargo fmt
.cargo clippy
. If applicable, add:--target wasm32-unknown-unknown
--target wasm32-unknown-emscripten
cargo xtask test
to run tests.CHANGELOG.md
. See simple instructions inside file.