yum-mirror/slang

Making it easier to work with shaders

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

Yong HeEnhance buffer load specialization pass to specialize past field extracts. (#8547)e4611e2e3

master
1.8 KiB56 linesraw
1//TEST:SIMPLE(filecheck=METAL): -target metal
2//TEST:SIMPLE(filecheck=METALLIB): -target metallib
3//TEST(compute, metal):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-metal -compute -output-using-type
4//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -output-using-type
5
6// Test that we can specailize mutable parameters based on the argument
7// address space when generating code for Metal.
8
9//TEST_INPUT: ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer
10RWStructuredBuffer<int> outputBuffer;
11
12// CHECK-DAG: void Test_out_param{{.*}}(int thread* value{{.*}})
13// CHECK-DAG: void Test_out_param{{.*}}(int threadgroup* value{{.*}})
14// CHECK-DAG: void Test_out_param{{.*}}(int {{.*}}, KernelContext{{.*}} thread* {{.*}})
15
16// CHECK-DAG: void Test_out_param_wrapper{{.*}}(int {{.*}}, KernelContext{{.*}} thread* {{.*}})
17// CHECK-DAG: void Test_out_param_wrapper{{.*}}(int thread* value{{.*}})
18// CHECK-DAG: void Test_out_param_wrapper{{.*}}(int threadgroup* value{{.*}})
19
20// METAL-DAG: void Test_out_param{{.*}}(int thread* value{{.*}})
21// METAL-DAG: void Test_out_param{{.*}}(int threadgroup* value{{.*}})
22
23// METAL-DAG: void Test_out_param_wrapper{{.*}}(int thread* value{{.*}})
24// METAL-DAG: void Test_out_param_wrapper{{.*}}(int threadgroup* value{{.*}})
25
26
27void Test_out_param(out int value)
28{
29    value = 1;
30}
31
32void Test_out_param_wrapper(out int value)
33{
34    Test_out_param(value);
35}
36
37[numthreads(1,1,1)]
38void computeMain()
39{
40    // METALLIB: define void @computeMain
41
42    int value = 0;
43    Test_out_param_wrapper(value);
44    outputBuffer[0] = value;
45
46    Test_out_param_wrapper(outputBuffer[1]);
47
48    static groupshared int sharedValue[2];
49    Test_out_param_wrapper(sharedValue[0]);
50    outputBuffer[2] = sharedValue[0];
51
52    outputBuffer[0]++;
53    // BUF: 2
54    // BUF: 1
55    // BUF: 1
56}