forked from shader-slang/slang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgh-3834.slang
33 lines (28 loc) · 967 Bytes
/
gh-3834.slang
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//TEST:SIMPLE(filecheck=CHECK): -stage compute -entry computeMain -target glsl -allow-glsl
//TEST:SIMPLE(filecheck=CHECK): -stage compute -entry computeMain -target glsl -allow-glsl -DUSE_GENERIC
// This tests an issue that "const" variable was losing the
// const-ness when they are in a generic function
uniform sampler2D uniform_sampler2D;
RWStructuredBuffer<float> outputBuffer;
#ifdef USE_GENERIC
__generic<T:__BuiltinArithmeticType>
#endif
vec4 MyFunc()
{
//CHECK: const ivec2 offset0
//CHECK: const ivec2 offset1
const ivec2 offset0 = ivec2(0,0);
const ivec2 offset1 = ivec2(1,1);
const ivec2[4] offsets = { offset0, offset0, offset1, offset1 };
return textureGatherOffsets(uniform_sampler2D, vec2(0), offsets);
}
[numthreads(4, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
#ifdef USE_GENERIC
vec4 result = MyFunc<float>();
#else
vec4 result = MyFunc();
#endif
outputBuffer[0] = result[0];
}