Skip to content

Resource: optimize shader and material compile times#868

Merged
dbartolini merged 7 commits into
crownengine:masterfrom
dbartolini:resource-optimize-shader-and-material-compile-times
Jun 2, 2026
Merged

Resource: optimize shader and material compile times#868
dbartolini merged 7 commits into
crownengine:masterfrom
dbartolini:resource-optimize-shader-and-material-compile-times

Conversation

@dbartolini
Copy link
Copy Markdown
Collaborator

No description provided.

@dbartolini dbartolini force-pushed the resource-optimize-shader-and-material-compile-times branch 2 times, most recently from d8059cf to 05b870b Compare June 2, 2026 20:03
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.
@dbartolini dbartolini force-pushed the resource-optimize-shader-and-material-compile-times branch from 0b9c91e to 6ebbcbd Compare June 2, 2026 21:36
@dbartolini dbartolini merged commit e17fbf7 into crownengine:master Jun 2, 2026
6 checks passed
@dbartolini dbartolini deleted the resource-optimize-shader-and-material-compile-times branch June 2, 2026 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant