yum-mirror/slang

Making it easier to work with shaders

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

Harsh Aggarwal (NVIDIA)Fix 7441: CUDA boolean vector layout to use 1-byte elements (#7862)bdda8a90c

master
2.6 KiB74 linesraw
1//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUFFER):-cuda -compute -output-using-type
2//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUFFER-MTL):-metal -compute -output-using-type
3//TEST:REFLECTION(filecheck=REFLECT):-stage compute -entry computeMain -target cuda -no-codegen
4//TEST:REFLECTION(filecheck=REFLECT-MTL):-stage compute -entry computeMain -target metal -no-codegen
5
6
7// Test struct for bool layout analysis
8struct TestType
9{
10    uint value;
11    bool f_bool;
12    bool1 f_bool1;
13    bool pad1;
14    bool2 f_bool2;
15    bool pad2;
16    bool3 f_bool3;
17    bool4 f_bool4;
18    uint END;
19};
20
21//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0], stride=4):out,name=buffer
22RWStructuredBuffer<TestType> buffer;
23
24[shader("compute")]
25[numthreads(1, 1, 1)]
26void computeMain(uint3 tid: SV_DispatchThreadID)
27{
28    uint i = tid.x;
29
30    // Initialize test data
31    buffer[i].value = 7;
32    buffer[i].f_bool = true;
33    buffer[i].f_bool1 = bool1(true);
34    buffer[i].pad1 = false;
35    buffer[i].f_bool2 = bool2(true, true);
36    buffer[i].pad2 = false;
37    buffer[i].f_bool3 = bool3(true, false, true);
38    buffer[i].f_bool4 = bool4(true, false, true, false);
39    buffer[i].END = 0x12345678;
40}
41
42// BUFFER: 7
43// BUFFER-NEXT: 101
44// BUFFER-NEXT: 1000101
45// BUFFER-NEXT: 100
46// BUFFER-NEXT: 10001
47// BUFFER-NEXT: 12345678
48
49// Expected output for Metal (different struct layout)
50// BUFFER-MTL: 7
51// BUFFER-MTL-NEXT: 101
52// BUFFER-MTL-NEXT: 101
53// BUFFER-MTL-NEXT: 10001
54// BUFFER-MTL-NEXT: 10001
55// BUFFER-MTL-NEXT: 12345678
56
57// REFLECT:         "name": "f_bool1",
58// REFLECT:         "binding": {"kind": "uniform", "offset": 5, "size": 1, "elementStride": 1}
59// REFLECT:         "name": "f_bool2",
60// REFLECT:         "binding": {"kind": "uniform", "offset": 8, "size": 2, "elementStride": 1}
61// REFLECT:         "name": "f_bool3",
62// REFLECT:         "binding": {"kind": "uniform", "offset": 11, "size": 3, "elementStride": 1}
63// REFLECT:         "name": "f_bool4",
64// REFLECT:         "binding": {"kind": "uniform", "offset": 16, "size": 4, "elementStride": 1}
65
66// Metal-specific reflection (different bool3 layout)
67// REFLECT-MTL:         "name": "f_bool1",
68// REFLECT-MTL:         "binding": {"kind": "uniform", "offset": 5, "size": 1, "elementStride": 1}
69// REFLECT-MTL:         "name": "f_bool2",
70// REFLECT-MTL:         "binding": {"kind": "uniform", "offset": 8, "size": 2, "elementStride": 1}
71// REFLECT-MTL:         "name": "f_bool3",
72// REFLECT-MTL:         "binding": {"kind": "uniform", "offset": 12, "size": 4, "elementStride": 1}
73// REFLECT-MTL:         "name": "f_bool4",
74// REFLECT-MTL:         "binding": {"kind": "uniform", "offset": 16, "size": 4, "elementStride": 1}