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/compute/generics-constrained.slang | 3 +-- tests/spirv/specialization-constant.slang | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/compute/generics-constrained.slang b/tests/compute/generics-constrained.slang index 04a9c59b7..ccb8413f8 100644 --- a/tests/compute/generics-constrained.slang +++ b/tests/compute/generics-constrained.slang @@ -28,8 +28,7 @@ float testHelp(T helper) } //TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer -[vk::binding(0, 0)] -RWStructuredBuffer outputBuffer : register(u0); +RWStructuredBuffer outputBuffer; [numthreads(4, 1, 1)] 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