yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

James Helferty (NVIDIA)Enable metal tests (#8446)8086adc90

master
1.7 KiB60 linesraw
1//TEST:SIMPLE(filecheck=METAL): -target metal -fvk-use-entrypoint-name
2//TEST:SIMPLE(filecheck=METALLIB): -target metallib -fvk-use-entrypoint-name
3
4struct FirstStruct {
5    uint a;
6}
7
8struct SecondStruct {
9    uint a;
10}
11
12struct ThirdStruct {
13    uint a;
14}
15
16struct FourthStruct {
17    uint a;
18}
19
20StructuredBuffer<uint> globalScopeBuffer;
21
22RWStructuredBuffer<uint> outBuffer;
23
24//
25// Checks for the following:
26//  - Output entry points will only contain parameters that they originally have from the Slang source. 
27//  - Binding offset calculation for global params originating from entry point parameters are done per-whole file.
28//  - Binding offset for global params in global scope are the same for each generated entry point.
29//
30
31// METAL: main1({{.*}}globalScopeBuffer{{.*}}buffer(0)]], FirstStruct{{.*}}buffer(2)]], SecondStruct{{.*}}buffer(3)]], float{{.*}}buffer(4)]])
32// METALLIB: @main1
33[shader("compute")]
34[numthreads(5, 1, 1)]
35void main1(
36    uint3 dispatchThreadID: SV_DispatchThreadID,
37    RWStructuredBuffer<FirstStruct> custom,
38    RWStructuredBuffer<SecondStruct> other,
39    ConstantBuffer<float> factor
40) {
41    uint index = dispatchThreadID.x;
42    outBuffer[index] = globalScopeBuffer[index] * custom[index].a * other[index].a * uint(factor);
43}
44
45
46// METAL-NOT: FirstStruct
47// METAL-NOT: SecondStruct
48// METAL: main2({{.*}}globalScopeBuffer{{.*}}buffer(0)]], ThirdStruct{{.*}}buffer(5)]], FourthStruct{{.*}}buffer(6)]])
49// METALLIB: @main2
50[shader("compute")]
51[numthreads(5, 1, 1)]
52void main2(
53    uint3 dispatchThreadID: SV_DispatchThreadID,
54    RWStructuredBuffer<ThirdStruct> custom,
55    RWStructuredBuffer<FourthStruct> other,
56) {
57    uint index = dispatchThreadID.x;
58    outBuffer[index] = globalScopeBuffer[index] * custom[index].a * other[index].a;
59}
60