static FOO: Foo = ..;
#[spirv(fragment)]
fn frag(color: Vec4<f32>, ) -> Vec4<f32> {
let f = FOO;
color
}
That should work but it is too easy to add and remove statics inside an entry point. Commenting out let f = FOO; would change the shader signature. Maybe it is not too bad?
#[spirv(fragment)]
fn frag(color: Vec4<f32>, ) -> Vec4<f32> {
static FOO: Foo = ..;
let f = FOO;
color
}
Maybe statics should be defined inside the entry point? But that also doesn't feel quite right.
static FOO: Foo = ..;
#[spirv(fragment)]
#[spirv(constant = FOO)]
fn frag(color: Vec4<f32>, ) -> Vec4<f32> {
let f = FOO; // Now FOO is a specialization constant
color
}
Maybe specialization constants should be added as an attribute?
Maybe this still works if I force Constants to implement Default or a similar trait? that doesn't seem straight forward to implement. I would have to evaluate it manually with miri.
My first idea was
but that doesn't work because Rust does not have default arguments.
That doesn't work because
const
is compiled away.That should work but it is too easy to add and remove statics inside an entry point. Commenting out
let f = FOO;
would change the shader signature. Maybe it is not too bad?Maybe statics should be defined inside the entry point? But that also doesn't feel quite right.
Maybe specialization constants should be added as an attribute?
Maybe this still works if I force Constants to implement
Default
or a similar trait? that doesn't seem straight forward to implement. I would have to evaluate it manually with miri.