yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
8ce7c6f69
master
1//TEST:SIMPLE(filecheck=METAL): -target metal 2//TEST:SIMPLE(filecheck=WGSL): -target wgsl -entry computeMain -stage compute 3//TEST:SIMPLE(filecheck=GLSL): -target glsl -allow-glsl 4//TEST:SIMPLE(filecheck=GLSL): -target glsl 5//TEST:SIMPLE(filecheck=CHECK): -target spirv -allow-glsl 6//TEST:SIMPLE(filecheck=CHECK): -target spirv 7 8// METAL-DAG: constant bool fc_constValue2{{.*}} {{\[\[}}function_constant(1){{\]\]}}; 9// METAL-DAG: constant bool constValue2{{.*}} = is_function_constant_defined(fc_constValue2{{.*}}) ? fc_constValue2{{.*}} : true; 10 11// METAL-DAG: constant float fc_constValue1{{.*}} {{\[\[}}function_constant(7){{\]\]}}; 12 13// METAL-DAG: constant int fc_constValue0{{.*}} {{\[\[}}function_constant(0){{\]\]}}; 14 15// METAL-DAG: constant int fc_constValue3{{.*}} {{\[\[}}function_constant(9){{\]\]}}; 16 17// WGSL-DAG: @id(0) override constValue0{{.*}} = {{.*}} 18 19// WGSL-DAG: @id(7) override constValue1{{.*}} = {{.*}} 20 21// WGSL-DAG: @id(1) override constValue2{{.*}} = {{.*}} 22 23// WGSL-DAG: @id(9) override constValue3{{.*}} = {{.*}} 24 25// CHECK-DAG: OpDecorate %[[C0:[0-9A-Za-z_]+]] SpecId 0 26// CHECK-DAG: %[[C0]] = OpSpecConstant %int 1 27 28// CHECK-DAG: OpDecorate %[[C1:[0-9A-Za-z_]+]] SpecId 7 29// CHECK-DAG: %[[C1]] = OpSpecConstant %float 3 30 31// CHECK-DAG: OpDecorate %[[C2:[0-9A-Za-z_]+]] SpecId 1 32// CHECK-DAG: %[[C2]] = OpSpecConstantTrue %bool 33 34// CHECK-DAG: OpDecorate %[[C3:[0-9A-Za-z_]+]] SpecId 9 35// CHECK-DAG: %[[C3]] = OpSpecConstant %int 111 36 37// GLSL-DAG: layout(constant_id = 0) 38// GLSL-DAG: int constValue0_0 = 1; 39 40// GLSL-DAG: layout(constant_id = 7) 41// GLSL-DAG: float constValue1_0 = 3.0; 42 43// GLSL-DAG: layout(constant_id = 1) 44// GLSL-DAG: bool constValue2_0 = true; 45 46// GLSL-DAG: layout(constant_id = 9) 47// GLSL-DAG: int constValue3_0 = 111; 48 49[vk::specialization_constant] 50const int constValue0 = 1; 51 52[vk::constant_id(7)] 53const float constValue1 = 3.0f; 54 55[SpecializationConstant] 56const bool constValue2 = true; 57 58layout(constant_id = 9) const int constValue3 = 111; 59 60RWStructuredBuffer<float> outputBuffer; 61 62[numthreads(1, 1, 1)] 63void computeMain() 64{ 65 if (constValue2) 66 outputBuffer[0] = constValue0 + (int)constValue1; 67 else 68 outputBuffer[0] = constValue3; 69}