Extracting all "mattered" macros from the shader source code helps avoid unnecessary compilation of shader variants.
The definition for "mattered" macro in version 1.3 is simple: macros defined after #if, #ifdef, #ifndef, and defined operator.
The macros defined by the above standards are not actually "mattered" macros. For example, the following conditional macro expansion is a variable declaration, but it may not be referenced by the entry main function, so it should not be defined as a "mattered" macro.
Why
Extracting all "mattered" macros from the shader source code helps avoid unnecessary compilation of shader variants.
The definition for "mattered" macro in version 1.3 is simple: macros defined after
#if
,#ifdef
,#ifndef
, anddefined
operator.The macros defined by the above standards are not actually "mattered" macros. For example, the following conditional macro expansion is a variable declaration, but it may not be referenced by the entry main function, so it should not be defined as a "mattered" macro.
Future optimization
TODO: Use a seperate compiler to analyze and extract the real list of all "mattered" macros after
Shader.create
but before shader variant compilation.