yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
84148b80b
master
1//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): 2//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -vk 3 4public struct ContextND<let N: int> 5{ 6 public uint3 thread_id; 7 public int[N] call_id; 8 9 public ContextND<0> map(int) 10 { 11 return { thread_id }; 12 } 13 14 public ContextND<M> map<let M : int>(int[M] mapping) 15 { 16 ContextND<M> result; 17 result.thread_id = thread_id; 18 for (int i = 0; i < M; ++i) 19 result.call_id[i] = call_id[mapping[i]]; 20 return result; 21 } 22} 23 24typealias Context = ContextND<0>; 25 26//TEST_INPUT: set value = out ubuffer(data=[0 0 0 0], stride=4) 27RWStructuredBuffer<int> value; 28 29void store(Context context, in int v) { value[0] = v; } 30 31[shader("compute")] 32[numthreads(1, 1, 1)] 33void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID) 34{ 35 Context context = {dispatchThreadID}; 36 int c = 1; 37 int m_c = 0; 38 // CHECK: 1 39 store(context.map(m_c), c); 40}