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.5 KiB79 linesraw
1//TEST:SIMPLE(filecheck=CHK): -allow-glsl -target spirv -entry computeMain
2
3// Using groupshared variables
4groupshared float4 gsUninitialized;
5
6float use_undefined_gs()
7{
8    //CHK-DAG: ([[# @LINE + 1]]): warning 41017: use of uninitialized global variable 'gsUninitialized'
9    return gsUninitialized.x;
10}
11
12// Using static variables
13static const float cexprInitialized = 1.0f;
14static float writtenNever;
15static float writtenLater;
16
17// OK
18float use_initialized_static()
19{
20    return cexprInitialized;
21}
22
23// Should detect this and treat it as a store
24void write_to_later()
25{
26    writtenLater = 1.0f;
27}
28
29float use_never_written()
30{
31    //CHK-DAG: ([[# @LINE + 1]]): warning 41017: use of uninitialized global variable 'writtenNever'
32    return writtenNever;
33}
34
35// OK because of prior store
36float use_later_writte()
37{
38    return writtenLater;
39}
40
41// Varying inputs never warn
42layout(location = 0) in vec4 data;
43
44vec4 glsl_layout_in_ok()
45{
46    return data;
47}
48
49// Layout outputs should still be written to at some point
50layout(location = 1) out vec4 x;
51
52vec4 glsl_layout_out_undefined()
53{
54    //CHK-DAG: ([[# @LINE + 1]]): warning 41017: use of uninitialized global variable 'x'
55    return x;
56}
57
58layout(location = 2) out vec4 y;
59
60void glsl_layout_out_store(vec4 data)
61{
62    // Written to here...
63    y = data;
64}
65
66vec4 glsl_layout_out_ok()
67{
68    // ...so read here is treated as OK
69    return y;
70}
71
72//CHK-NOT: warning 41017
73
74[Shader("compute")]
75[NumThreads(4, 1, 1)]
76void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
77{
78}
79