Recently upgraded a project from 2019.3.0f6 to 2021.3.3f1, and now get many compute shader compile errors for ‘undeclared identifier’ for functions and variables defined in include files.
For example:
In file Assets/Shaders/SomeInclude.cginc:
int tableLength;
float CalculateSomething()
{
...
return someFloat;
}
Then in a compute shader file:
#pragma kernel _main
#include "Assets/Shaders/SomeInclude.cginc"
[numthreads(16, 1, 1)]
void _main(uint3 id : SV_DispatchThreadID)
{
if (id.x < tableLength) <-- This line sometimes causes 'undeclared identifier' compile error
{...}
float someValue = CalculateSomething(); <-- This line sometimes causes 'undeclared identifier' compile error
There are many compute shaders in the project, most using includes for commonly defined functions and variables. Yet only some files get the compile errors.
Does anyone know what causes some included functions and variables to be undefined?
More generally, is there information available about the shader compiler and what it is doing? Like documentation somewhere, or some output logs from it’s compiles with a little more verbose information.