Resource: optimize shader and material compile times#868
Merged
dbartolini merged 7 commits intoJun 2, 2026
Merged
Conversation
d8059cf to
05b870b
Compare
Sort shader defines before building variant names so differently ordered define lists describe the same shader variant. Materials use the canonical variant ID returned by shader compilation, and static shader compile entries are de-duplicated after sorting.
Avoid launching shaderc's preprocess pass when a shader compile does not need uniform metadata and has no sampler-stage metadata to discover. In that case the generated vertex and fragment sources are written directly and only the binary compile remains.
Cache material metadata-only shader variant compiles for the duration of a data-compiler run. Cache hits restore the shader library, uniform metadata and sampler metadata, then replay the original source dependencies so invalidation still observes the same inputs.
Cache shader-name to shader-library lookups for the duration of a data-compiler run. Material metadata compilation can retry cache lookup with a known library and avoid repeatedly scanning every shader resource when materials omit the library name.
When a full static shader compile already has to run the preprocess pass for sampler metadata, collect uniform metadata at the same time and store the result in the material metadata cache. Later matching material compiles can reuse that metadata instead of preprocessing the same variant again.
Spawn shaderc processes for every backend target before running the preprocess metadata pass, using distinct temp output paths so concurrent jobs do not race. While those processes run, the compiler parses sampler and uniform metadata.
0b9c91e to
6ebbcbd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.