yum-mirror/slang

Making it easier to work with shaders

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

Jay KwakFix potential test failures due to SPIRV validation failure (#6047)6437f2d37

master
1.9 KiB120 linesraw
1//TEST:SIMPLE(filecheck=CHK): -target spirv -entry computeMain
2
3// Both out and inout parameters
4// should have this treated as writes
5void out_test(int tmp, out int x)
6{
7    x = tmp;
8}
9
10// Permuting arguments to ensure that
11// the correct argument is checked
12void inout_test(inout int x, int tmp)
13{
14    x = tmp;
15}
16
17// __ref parameters should also be fine
18void ref_test(__ref int x, int tmp)
19{
20    x = tmp;
21}
22
23void undefined_function_use()
24{
25    int x;
26    int tmp = 1;
27
28    //CHK-DAG: warning 41016: use of uninitialized variable 'x'
29    out_test(x, tmp);
30    
31    //CHK-DAG: warning 41016: use of uninitialized variable 'x'
32    inout_test(tmp, x);
33}
34
35void out_function_use()
36{
37    int x;
38    int tmp = 1;
39
40    // Acts as a write
41    out_test(tmp, x);
42
43    // Rest are fine now
44    out_test(x, tmp);
45    inout_test(tmp, x);
46}
47
48void inout_function_use()
49{
50    int x;
51    int tmp = 1;
52
53    // Acts as a write
54    inout_test(x, tmp);
55
56    // Rest are fine now
57    out_test(x, tmp);
58    inout_test(tmp, x);
59}
60
61void ref_function_use()
62{
63    int x;
64    int tmp = 1;
65
66    // Acts as a write
67    ref_test(x, tmp);
68
69    // Rest are fine now
70    out_test(x, tmp);
71    inout_test(tmp, x);
72}
73
74// Likewise for generic functions
75static int ord_gen_result;
76
77__generic<T>
78void ordinary_generic(T x)
79{
80    ord_gen_result = __slang_noop_cast<int, T>(x);
81}
82
83__generic<T>
84void unordinary_generic(out T x)
85{
86    x = __slang_noop_cast<T, int>(1);
87}
88
89void undefined_generic_use()
90{
91    int x;
92
93    //CHK-DAG: warning 41016: use of uninitialized variable 'x'
94    ordinary_generic(x);
95}
96
97void ok_generic_use()
98{
99    int x;
100    unordinary_generic(x);
101    ordinary_generic(x);
102}
103
104// Check proper handling of aliases passed
105void f()
106{
107    int3 dim;
108
109    // Should have no warnings
110    out_test(1, dim.x);
111}
112
113//CHK-NOT: warning 41016
114
115[Shader("compute")]
116[NumThreads(4, 1, 1)]
117void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
118{
119}
120