yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

Tim FoleyConvert more tests to use shader objects (#1659)2a5d5b323

master
854 B34 linesraw
1// ssa-reduce-bug.slang
2//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj
3//TEST(compute):COMPARE_COMPUTE_EX:-cpu -slang -compute -shaderobj
4
5//TEST_INPUT:ubuffer(data=[0 3 1 2 6 4 7 6], stride=4):name=inputBuffer
6RWStructuredBuffer<int> inputBuffer;
7//TEST_INPUT:ubuffer(data=[8 8 8 8 8 8 8 8], stride=4):out,name=outputBuffer
8RWStructuredBuffer<int> outputBuffer;
9
10int2 reduce(int2 val)
11{
12	for(int ii = 0; ii < 4; ++ii)
13	{
14		if(inputBuffer[ii] != 8)
15		{
16			val.x = max(val.x, inputBuffer[ii]);
17			val.y = min(val.y, inputBuffer[ii + 4]);
18		}
19	}
20	return val;
21}
22
23[numthreads(4, 1, 1)]
24void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
25{
26	uint tid = dispatchThreadID.x;
27
28	int2 inVal = int2(inputBuffer[tid], inputBuffer[tid + 4]);
29
30	int2 outVal = reduce(inVal);
31
32	outputBuffer[tid] = outVal.x;
33	outputBuffer[tid + 4] = outVal.y;
34}