3 ms·
I don't think I fully understand the point about metaprogramming facilities. Sure, it would be nice to have compile-time ifs that get eliminated from the genera
by nice_byte 10y ago
I don't think I fully understand the point about metaprogramming facilities.
Sure, it would be nice to have compile-time ifs that get eliminated from the generated code if the condition isn't met. But I don't think this necessarily solves the problem of "combinatoric explosion" of different shader variants - you still have to generate a separate chunk of code for each possible combination of compile-time conditions. Unless a corresponding change is proposed at the level of shader bytecode (SPIR-V), which probably leads to opening a can of worms.
- AlphaSite 10y agoIm fairly certain shaders can and do eliminate compile time if statements, you can observer this by seeing which uniforms are defined (for example in WebGL).
- nice_byte 10y agoYou mean if we write if (some_constant_expression) { //...code... } and some_constant_expression evaluates to false, the entire code block will be stripped from the result? That may be true, but it's not standardized behavior, is it?
- JoeAltmaier 10y agoTrue for many compilers for many years. Its a way to integrate 'conditional compilation' into the normal program flow. It can make the code easier (or harder) to read. Use judiciously.