yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
f59e0ef40
master
1// multi-target-module.slang 2 // Test that a slang-module can store both SPIR-V and DXIL blobs separately 3 4 //TEST:SIMPLE(filecheck=CHECK): -o tests/modules/multi-target-module.slang-module -target dxil -embed-downstream-ir -target spirv -embed-downstream-ir -profile lib_6_6 -incomplete-library -dump-ir -verbose-paths 5 6 module multi_target_module; 7 8 // Simple function that will work on both SPIR-V and DXIL targets 9 public float4 addVectors(float4 a, float4 b) 10 { 11 return a + b; 12 } 13 14 // Another function that should be compatible with both targets 15 public float3 normalizeVector(float3 v) 16 { 17 return normalize(v); 18 } 19 20 [shader("compute")] 21 [numthreads(8, 8, 1)] 22 void main(uint3 dispatchThreadID : SV_DispatchThreadID) 23 { 24 float4 a = float4(1.0, 2.0, 3.0, 4.0); 25 float4 b = float4(5.0, 6.0, 7.0, 8.0); 26 27 float4 result = addVectors(a, b); 28 29 float3 v = float3(1.0, 1.0, 1.0); 30 float3 n = normalizeVector(v); 31 } 32 33 // Check for the first occurrence of availableInDownstreamIR for addVectors in this section 34 // Check that there are two entries, one for dxil and one for spirv. 35 // CHECK: [availableInDownstreamIR(6 : Int)] 36 // CHECK: [availableInDownstreamIR(10 : Int)] 37 // CHECK: [public] 38 // CHECK: [export("_S19multi_target_module10addVectorsp2pi_v4fi_v4fv4f")] 39 40 // Check for the second occurrence of availableInDownstreamIR for normalizeVector in this section 41 // Check that there are two entries, one for dxil and one for spirv. 42 // CHECK: [availableInDownstreamIR(6 : Int)] 43 // CHECK: [availableInDownstreamIR(10 : Int)] 44 // CHECK: [public] 45 // CHECK: [export("_S19multi_target_module15normalizeVectorp1pi_v3fv3f")]