yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
77d3630ee
master
1// array-size-static-const-2.hlsl 2//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -output-using-type 3 4//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer 5RWStructuredBuffer<uint> outputBuffer; 6 7interface IA 8{ 9 static const int M; 10} 11struct B : IA 12{ 13 static const int M = 2; 14} 15struct GenType<T : __BuiltinIntegerType, A: IA, let N : int> 16{ 17 static const int HalfN = N > 1? N / A.M : 1; 18 T sum(T arr[HalfN]) 19 { 20 T rs = T(0); 21 for (int i = 0; i < HalfN; i++) 22 rs += arr[i]; 23 return rs; 24 } 25} 26 27[numthreads(1, 1, 1)] 28void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID) 29{ 30 int arr[2] = { 1, 2 }; 31 GenType<int, B, 4> obj; 32 outputBuffer[0] = obj.sum(arr); 33}