mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-20 14:31:08 +01:00
Instead allow the const to be converted and each time it is const evaluated as part of another expression. This allows an abstract const to be used as a different type depending on the context. A consequence of this is that abstract types may now find their way to the validation stage, which we don't want. We therefore additionally now ensure that the compact pass removes global constants of abstract types. This will have no *functional* effect on shaders generated by the backends, as the expressions belonging to the abstract consts in the IR will not actually be used, as any usage in the input shader will have been const-evaluated away. Certain unused const declarations will now be removed, however, as can be seen by the effect on the snapshot outputs.
31 lines
1.0 KiB
WebGPU Shading Language
31 lines
1.0 KiB
WebGPU Shading Language
struct Foo {
|
|
a: vec4<f32>,
|
|
b: i32,
|
|
}
|
|
|
|
const const3_: mat2x2<f32> = mat2x2<f32>(vec2<f32>(0f, 1f), vec2<f32>(2f, 3f));
|
|
const const4_: array<mat2x2<f32>, 1> = array<mat2x2<f32>, 1>(mat2x2<f32>(vec2<f32>(0f, 1f), vec2<f32>(2f, 3f)));
|
|
const cz0_: bool = bool();
|
|
const cz1_: i32 = i32();
|
|
const cz2_: u32 = u32();
|
|
const cz3_: f32 = f32();
|
|
const cz4_: vec2<u32> = vec2<u32>();
|
|
const cz5_: mat2x2<f32> = mat2x2<f32>();
|
|
const cz6_: array<Foo, 3> = array<Foo, 3>();
|
|
const cz7_: Foo = Foo();
|
|
|
|
@compute @workgroup_size(1, 1, 1)
|
|
fn main() {
|
|
var foo: Foo;
|
|
|
|
foo = Foo(vec4(1f), 1i);
|
|
const m0_ = mat2x2<f32>(vec2<f32>(1f, 0f), vec2<f32>(0f, 1f));
|
|
const m1_ = mat4x4<f32>(vec4<f32>(1f, 0f, 0f, 0f), vec4<f32>(0f, 1f, 0f, 0f), vec4<f32>(0f, 0f, 1f, 0f), vec4<f32>(0f, 0f, 0f, 1f));
|
|
const cit0_ = vec2(0u);
|
|
const cit1_ = mat2x2<f32>(vec2(0f), vec2(0f));
|
|
const cit2_ = array<i32, 4>(0i, 1i, 2i, 3i);
|
|
const ic4_ = vec2<u32>(0u, 0u);
|
|
const ic5_ = mat2x3<f32>(vec3<f32>(0f, 0f, 0f), vec3<f32>(0f, 0f, 0f));
|
|
return;
|
|
}
|