summaryrefslogtreecommitdiffstats
path: root/tests/compute/parameter-block.slang
blob: 1806d95a889aa021fe7cb6ad27043a4e844fa0bb (plain)
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
//TEST(compute):COMPARE_COMPUTE:-cpu -shaderobj
//TEST(compute):COMPARE_COMPUTE:-cuda -shaderobj
//TEST(compute):COMPARE_COMPUTE:-vk -shaderobj
//TEST(compute):COMPARE_COMPUTE:-shaderobj
//TEST(compute):COMPARE_COMPUTE:-slang -shaderobj -mtl -render-features argument-buffer-tier-2
//TEST(compute):COMPARE_COMPUTE:-wgpu

// Ensure that Slang `ParameterBlock` type is lowered
// to HLSL in the fashion that we expect.

struct P
{
	RWStructuredBuffer<int> buffer;
};

//TEST_INPUT: set block0 = new{ out ubuffer(data=[0 0 0 0], stride=4) }
ParameterBlock<P> block0;

//TEST_INPUT: set block1 = new{ ubuffer(data=[0 1 2 3], stride=4) }
ParameterBlock<P> block1;

[numthreads(4, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
	uint tid = dispatchThreadID.x;

	int inVal = block1.buffer[tid];

	int outVal = inVal;

	block0.buffer[tid] = outVal;
}