ShaderLang
ShaderLang copied to clipboard
[Compilation] Improve sanization and optimization of options
Currently, options are treated like unknown values, or even unknown types.
However, it would be pretty simple to handle cases where the value is known and validation / optimization can be done.
option enabled: bool;
fn main()
{
const if (enabled)
{
// enabled is known to be true here
}
}
option value: i32;
fn main() -> i32
{
const if (value == 42)
return value + 5; //< optimized by return 47
else
return value; //< kept as is
}
Theses examples may seem a bit silly, but will become more interesting once we have function inlining