Files
filament/libs
Eliza Velasquez dc74aa4c0d matc: treat DYN DIR and SRE as spec constants
This commit does not exhaustively replace these variants with spec constants.
Rather, this is a necessary first step into full replacement.

As was the case before this commit, all combinations of variants are still
generated as their own individual sources. However, matc has been changed in the
way that it generates these variants, such that it will be trivial to later
remove them.

Firstly, instead of matc selectively generating specific uniform buffers and
structs specific to these variants per-specialization, generates them *always*
as long as the specialization "has lighting". Specifically, a specialization
"has lighting" if all of the following conditions are true:

- It's a lit material, or it's an unlit material with a shadow multiplier.
- It's not an SSR variant.

As a result, there is some redundant, potentially unused code generated in all
variants.

Additionally, all shader code has been refactored to replace `#if VARIANT_X`
preprocessor directives with `if (MATERIAL_HAS_X)` statements, where
`MATERIAL_HAS_X` is a spec constant. The *only difference* the code generated
between a specialization with DYN, DIR, and SRE turned on or off is the *default
value* of this spec constant.

Technically, assuming that all shader code optimizations are deterministic, we
should see some reduction of material file sizes, since only one line of code
would differ between these variants being turned on and left off. However, we
may add to some of that size given the redundant information added to all other
variants.

I tested this experimentally by compiling gltf_viewer at this commit and the
commit before it in release mode and totalling the size of all of the filamat
files generated.

- Parent commit: 44.44 MiB
- This commit: 36.67 MiB

So we have a reduction of about 8 MiB, which is around 20% of the original file
size.

(Note that I took these measurements a long time ago and they might not be still
accurate...)
2026-03-05 16:06:58 +09:00
..