Hi,
Does the WGSL compiler (tint?) do much in the way of optimization?
I did a quick test to see if a simple function call was being inlined and it appears not - according to the output of the dump_shader logging and my *very* limited understanding of SPIRV anyway.
The code I tested was...
fn evaluateFragment() -> vec4f {
return vec4f(1.0, 0.0, 0.0, 1.0);
}
@fragment fn fragmentMain() -> @location(0) vec4f {
return evaluateFragment();
}
...vs a fragmentMain() that directly returned the same vec4f. The more complex version appears to involve an extra function call in the SPIRV disassembly, where-as I was kind of expecting/hoping it to be inlined. Perhaps this stuff is optimized further down the pipeline somewhere?
If not, it'd be nice to know what we can do to help the compiler out, eg: should we be inlining stuff by hand in cases like the above?
Bye!
Mark