diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/library/export-library-generics.slang | 11 | ||||
| -rw-r--r-- | tests/modules/multi-target-module.slang | 45 |
2 files changed, 55 insertions, 1 deletions
diff --git a/tests/library/export-library-generics.slang b/tests/library/export-library-generics.slang index 3f17e0664..de683031e 100644 --- a/tests/library/export-library-generics.slang +++ b/tests/library/export-library-generics.slang @@ -1,4 +1,6 @@ -//TEST_IGNORE_FILE: +// This test checks the SPIR-V output when compiling a library containing generics with embedded downstream IR. + +//TEST:SIMPLE(filecheck=CHECK): -o tests/library/export-library-generics-test.slang-module -target spirv -embed-downstream-ir -profile lib_6_6 -incomplete-library -dump-ir -verbose-paths // export-library-generics.slang @@ -37,3 +39,10 @@ public int normalFunc(int a, float b) { return a - floor(b); } + +// CHECK:[availableInDownstreamIR(6 : Int)] +// CHECK:EmbeddedDownstreamIR(6 : Int, +// CHECK: OpCapability Linkage +// CHECK:OpDecorate %SLANG_ParameterGroup_Constants__init LinkageAttributes "_SR29export_2Dxlibrary_2Dxgenerics30SLANG_ParameterGroup_ConstantsR8_24xinitp2pi_fi_f" Export +// CHECK: OpDecorate %MyType_myMethod LinkageAttributes "_SR29export_2Dxlibrary_2Dxgenerics6MyType8myMethodp1pi_ii" Export +// CHECK: OpDecorate %normalFuncUsesGeneric LinkageAttributes "_SR29export_2Dxlibrary_2Dxgenerics21normalFuncUsesGenericp1pi_ii" Export
\ No newline at end of file diff --git a/tests/modules/multi-target-module.slang b/tests/modules/multi-target-module.slang new file mode 100644 index 000000000..68b774b87 --- /dev/null +++ b/tests/modules/multi-target-module.slang @@ -0,0 +1,45 @@ +// multi-target-module.slang + // Test that a slang-module can store both SPIR-V and DXIL blobs separately + + //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 + + module multi_target_module; + + // Simple function that will work on both SPIR-V and DXIL targets + public float4 addVectors(float4 a, float4 b) + { + return a + b; + } + + // Another function that should be compatible with both targets + public float3 normalizeVector(float3 v) + { + return normalize(v); + } + + [shader("compute")] + [numthreads(8, 8, 1)] + void main(uint3 dispatchThreadID : SV_DispatchThreadID) + { + float4 a = float4(1.0, 2.0, 3.0, 4.0); + float4 b = float4(5.0, 6.0, 7.0, 8.0); + + float4 result = addVectors(a, b); + + float3 v = float3(1.0, 1.0, 1.0); + float3 n = normalizeVector(v); + } + + // Check for the first occurrence of availableInDownstreamIR for addVectors in this section + // Check that there are two entries, one for dxil and one for spirv. + // CHECK: [availableInDownstreamIR(6 : Int)] + // CHECK: [availableInDownstreamIR(10 : Int)] + // CHECK: [public] + // CHECK: [export("_S19multi_target_module10addVectorsp2pi_v4fi_v4fv4f")] + + // Check for the second occurrence of availableInDownstreamIR for normalizeVector in this section + // Check that there are two entries, one for dxil and one for spirv. + // CHECK: [availableInDownstreamIR(6 : Int)] + // CHECK: [availableInDownstreamIR(10 : Int)] + // CHECK: [public] + // CHECK: [export("_S19multi_target_module15normalizeVectorp1pi_v3fv3f")]
\ No newline at end of file |
