Skip to content

Commit 9d0022b

Browse files
committed
Added more tests
1 parent 177c5dc commit 9d0022b

File tree

14 files changed

+330
-43
lines changed

14 files changed

+330
-43
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#pragma wave shader_stage(compute)
2+
#include "common.hlsl"
3+
4+
[[vk::binding(0,0)]] RWByteAddressBuffer output[10];
5+
6+
[numthreads(WorkgroupSize, 1, 1)]
7+
void main(uint32_t3 ID : SV_DispatchThreadID)
8+
{
9+
const uint32_t index = ID.x;
10+
const uint32_t byteOffset = sizeof(uint32_t)*index;
11+
12+
output[index].Store<uint32_t>(byteOffset, index);
13+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// This is a magical header that provides most HLSL types and intrinsics in C++
2+
#include "nbl/builtin/hlsl/cpp_compat.hlsl"
3+
4+
struct PSInput
5+
{
6+
[[vk::location(2)]] nointerpolation uint4 data1 : COLOR1;
7+
[[vk::location(5)]] float2 data2 : COLOR2;
8+
};
9+
10+
struct SomeType
11+
{
12+
uint32_t a;
13+
uint32_t b[5];
14+
uint32_t c[10];
15+
};
16+
17+
NBL_CONSTEXPR uint32_t WorkgroupSize = 256;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#pragma wave shader_stage(compute)
2+
#include "common.hlsl"
3+
4+
[[vk::binding(0,0)]] RWStructuredBuffer<SomeType> asdf;
5+
[[vk::binding(0,1)]] RWByteAddressBuffer output;
6+
[[vk::binding(1,1)]] RWByteAddressBuffer output2[2];
7+
8+
[numthreads(WorkgroupSize, 1, 1)]
9+
void main(uint32_t3 ID : SV_DispatchThreadID)
10+
{
11+
const uint32_t index = ID.x;
12+
const uint32_t byteOffset = sizeof(uint32_t)*index;
13+
14+
output.Store<uint32_t>(byteOffset, asdf[index].a + asdf[index].b[2] + asdf[index].c[3]);
15+
output2[1].Store<uint32_t>(byteOffset, asdf[index].a + asdf[index].b[2] - asdf[index].c[3]);
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#pragma wave shader_stage(compute)
2+
#include "common.hlsl"
3+
4+
[[vk::binding(0,0)]] RWStructuredBuffer<SomeType> asdf;
5+
[[vk::binding(0,1)]] RWByteAddressBuffer output;
6+
[[vk::binding(0,2)]] RWByteAddressBuffer output2[2];
7+
[[vk::binding(1,2)]] RWByteAddressBuffer output3[];
8+
9+
[numthreads(WorkgroupSize, 1, 1)]
10+
void main(uint32_t3 ID : SV_DispatchThreadID)
11+
{
12+
const uint32_t index = ID.x;
13+
const uint32_t byteOffset = sizeof(uint32_t)*index;
14+
15+
output.Store<uint32_t>(byteOffset, asdf[index].a);
16+
output2[1].Store<uint32_t>(byteOffset, asdf[index].b[1]);
17+
output3[5].Store<uint32_t>(byteOffset, asdf[index].c[2]);
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#pragma wave shader_stage(compute)
2+
#include "common.hlsl"
3+
4+
[[vk::binding(0,0)]] RWStructuredBuffer<SomeType> asdf;
5+
[[vk::binding(0,1)]] RWByteAddressBuffer output;
6+
[[vk::binding(1,1)]] RWByteAddressBuffer output2[2];
7+
[[vk::binding(0,2)]] RWByteAddressBuffer output3;
8+
9+
[numthreads(WorkgroupSize, 1, 1)]
10+
void main(uint32_t3 ID : SV_DispatchThreadID)
11+
{
12+
const uint32_t index = ID.x;
13+
const uint32_t byteOffset = sizeof(uint32_t)*index;
14+
15+
output.Store<uint32_t>(byteOffset, asdf[index].a + asdf[index].b[2] + asdf[index].c[3]);
16+
output2[1].Store<uint32_t>(byteOffset, asdf[index].a + asdf[index].b[2] - asdf[index].c[3]);
17+
output3.Store<uint32_t>(byteOffset, asdf[index].a + asdf[index].b[2] - asdf[index].c[3]);
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#pragma wave shader_stage(compute)
2+
#include "common.hlsl"
3+
4+
[[vk::binding(0,0)]] RWStructuredBuffer<SomeType> asdf;
5+
[[vk::binding(0,1)]] RWTexture2D<float> outputTex;
6+
[[vk::binding(1,1)]] RWByteAddressBuffer output[2];
7+
8+
[numthreads(WorkgroupSize, 1, 1)]
9+
void main(uint32_t3 ID : SV_DispatchThreadID)
10+
{
11+
const uint32_t index = ID.x;
12+
const uint32_t byteOffset = sizeof(uint32_t)*index;
13+
14+
outputTex[ID.xy] = (byteOffset, asdf[index].a + asdf[index].b[2] - asdf[index].c[3]);
15+
output[1].Store<uint32_t>(byteOffset, asdf[index].a + asdf[index].b[2] - asdf[index].c[3]);
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#pragma wave shader_stage(compute)
2+
3+
layout(local_size_x = 16, local_size_y = 1, local_size_z = 1) in;
4+
5+
layout(constant_id = 0) uint32_t SPEC_CONSTANT_VALUE = 10;
6+
layout(binding = 0, set = 0) buffer OutputBuff
7+
{
8+
int data[];
9+
}
10+
11+
[numthreads(WorkgroupSize, 1, 1)]
12+
void main(uint32_t3 ID : SV_DispatchThreadID)
13+
{
14+
uint index = gl_GlobalInvocationID.x;
15+
data[index] = SPEC_CONSTANT_VALUE;
16+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#pragma wave shader_stage(compute)
2+
#include "common.hlsl"
3+
4+
[[vk::binding(0,0)]] RWStructuredBuffer<SomeType> asdf;
5+
[[vk::binding(1,0)]] RWByteAddressBuffer output[3];
6+
[[vk::binding(2,0)]] RWByteAddressBuffer output2[];
7+
8+
struct PushConstants
9+
{
10+
int a;
11+
};
12+
[[vk::push_constant]]
13+
PushConstants pc;
14+
15+
[numthreads(WorkgroupSize, 1, 1)]
16+
void main(uint32_t3 ID : SV_DispatchThreadID)
17+
{
18+
const uint32_t index = ID.x;
19+
const uint32_t byteOffset = sizeof(uint32_t)*index;
20+
21+
output[0].Store<uint32_t>(byteOffset, asdf[index].a + asdf[index].b[2] + asdf[index].c[3]);
22+
output[1].Store<uint32_t>(byteOffset, asdf[index].a + asdf[index].b[2] + asdf[index].c[3]);
23+
output[2].Store<uint32_t>(byteOffset, asdf[index].a + asdf[index].b[2] + asdf[index].c[3]);
24+
output2[1].Store<uint32_t>(byteOffset, asdf[index].a + asdf[index].b[2] - asdf[index].c[3]);
25+
}
Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,14 @@
11
#pragma wave shader_stage(compute)
22
#include "common.hlsl"
33

4-
[[vk::binding(0,0)]] RWStructuredBuffer<SomeType> asdf;
5-
[[vk::binding(1,0)]] RWByteAddressBuffer output[3];
6-
[[vk::binding(2,0)]] RWByteAddressBuffer output2[];
7-
8-
struct PushConstants
9-
{
10-
int a;
11-
};
12-
[[vk::push_constant]]
13-
PushConstants pc;
4+
[[vk::binding(4,2)]] RWStructuredBuffer<SomeType> asdf;
5+
[[vk::binding(6,3)]] RWByteAddressBuffer outputBuff;
146

157
[numthreads(WorkgroupSize, 1, 1)]
168
void main(uint32_t3 ID : SV_DispatchThreadID)
179
{
1810
const uint32_t index = ID.x;
1911
const uint32_t byteOffset = sizeof(uint32_t)*index;
2012

21-
output[0].Store<uint32_t>(byteOffset, asdf[index].a + asdf[index].b[2] + asdf[index].c[3]);
22-
output[1].Store<uint32_t>(byteOffset, asdf[index].a + asdf[index].b[2] + asdf[index].c[3]);
23-
output[2].Store<uint32_t>(byteOffset, asdf[index].a + asdf[index].b[2] + asdf[index].c[3]);
24-
output2[1].Store<uint32_t>(byteOffset, asdf[index].a + asdf[index].b[2] - asdf[index].c[3]);
13+
outputBuff.Store<uint32_t>(byteOffset, asdf[index].a);
2514
}
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
#pragma wave shader_stage(compute)
22
#include "common.hlsl"
33

4-
[[vk::binding(4,2)]] RWStructuredBuffer<SomeType> asdf;
5-
[[vk::binding(6,3)]] RWByteAddressBuffer outputBuff;
4+
[[vk::binding(0,0)]] RWStructuredBuffer<SomeType> asdf;
5+
[[vk::binding(1,0)]] RWStructuredBuffer<SomeType> fdsa;
6+
[[vk::binding(2,0)]] RWByteAddressBuffer output;
67

78
[numthreads(WorkgroupSize, 1, 1)]
89
void main(uint32_t3 ID : SV_DispatchThreadID)
910
{
1011
const uint32_t index = ID.x;
1112
const uint32_t byteOffset = sizeof(uint32_t)*index;
1213

13-
outputBuff.Store<uint32_t>(byteOffset, asdf[index].a);
14+
output.Store<uint32_t>(byteOffset, asdf[index].a + fdsa[index].b[2]);
1415
}

0 commit comments

Comments
 (0)