yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
ed0681164
master
1//TEST:SIMPLE(filecheck=CHECK): -stage compute -entry computeMain -target glsl -allow-glsl 2//TEST:SIMPLE(filecheck=CHECK): -stage compute -entry computeMain -target glsl -allow-glsl -DUSE_GENERIC 3 4// This tests an issue that "const" variable was losing the 5// const-ness when they are in a generic function 6 7uniform sampler2D uniform_sampler2D; 8RWStructuredBuffer<float> outputBuffer; 9 10#ifdef USE_GENERIC 11__generic<T:__BuiltinArithmeticType> 12#endif 13vec4 MyFunc() 14{ 15 //CHECK: const ivec2 offset0 16 //CHECK: const ivec2 offset1 17 const ivec2 offset0 = ivec2(0,0); 18 const ivec2 offset1 = ivec2(1,1); 19 const ivec2[4] offsets = { offset0, offset0, offset1, offset1 }; 20 return textureGatherOffsets(uniform_sampler2D, vec2(0), offsets); 21} 22 23[numthreads(4, 1, 1)] 24void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 25{ 26#ifdef USE_GENERIC 27 vec4 result = MyFunc<float>(); 28#else 29 vec4 result = MyFunc(); 30#endif 31 32 outputBuffer[0] = result[0]; 33}