From 8ce7c6f6958f9f5ed750ef1a823b9e9ed8c042d8 Mon Sep 17 00:00:00 2001 From: Yong He Date: Fri, 6 Dec 2024 00:55:35 -0800 Subject: Support specialization constant on WGSL and Metal. (#5780) --- tests/spirv/specialization-constant.slang | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tests/spirv') diff --git a/tests/spirv/specialization-constant.slang b/tests/spirv/specialization-constant.slang index dbf315926..44a7e4432 100644 --- a/tests/spirv/specialization-constant.slang +++ b/tests/spirv/specialization-constant.slang @@ -1,8 +1,27 @@ +//TEST:SIMPLE(filecheck=METAL): -target metal +//TEST:SIMPLE(filecheck=WGSL): -target wgsl -entry computeMain -stage compute //TEST:SIMPLE(filecheck=GLSL): -target glsl -allow-glsl //TEST:SIMPLE(filecheck=GLSL): -target glsl //TEST:SIMPLE(filecheck=CHECK): -target spirv -allow-glsl //TEST:SIMPLE(filecheck=CHECK): -target spirv +// METAL-DAG: constant bool fc_constValue2{{.*}} {{\[\[}}function_constant(1){{\]\]}}; +// METAL-DAG: constant bool constValue2{{.*}} = is_function_constant_defined(fc_constValue2{{.*}}) ? fc_constValue2{{.*}} : true; + +// METAL-DAG: constant float fc_constValue1{{.*}} {{\[\[}}function_constant(7){{\]\]}}; + +// METAL-DAG: constant int fc_constValue0{{.*}} {{\[\[}}function_constant(0){{\]\]}}; + +// METAL-DAG: constant int fc_constValue3{{.*}} {{\[\[}}function_constant(9){{\]\]}}; + +// WGSL-DAG: @id(0) override constValue0{{.*}} = {{.*}} + +// WGSL-DAG: @id(7) override constValue1{{.*}} = {{.*}} + +// WGSL-DAG: @id(1) override constValue2{{.*}} = {{.*}} + +// WGSL-DAG: @id(9) override constValue3{{.*}} = {{.*}} + // CHECK-DAG: OpDecorate %[[C0:[0-9A-Za-z_]+]] SpecId 0 // CHECK-DAG: %[[C0]] = OpSpecConstant %int 1 -- cgit v1.2.3