yum-mirror/slang

Making it easier to work with shaders

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

Yong HeRewriting the lower-buffer-element-type pass to avoid unnecessary packing/unpacking. (#8526)a6deb5ed8

master
1.1 KiB42 linesraw
1// TEST:SIMPLE(filecheck=SPV): -target spirv
2
3// TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-vk -compute -shaderobj -output-using-type -emit-spirv-directly
4
5struct DoubleNested
6{
7    int4x3 matrix;
8    int getMatVal(int i, int j) { return matrix[i][j]; }
9}
10
11struct Nested
12{
13    bool values[4];
14    DoubleNested doubleNested;
15    int getVal(int id) { return (int)values[0] + doubleNested.getMatVal(0, 1); }
16}
17
18struct Params
19{
20    Nested nested;
21
22    int getVal(int id) { return nested.getVal(id) + nested.getVal(id + 1); }
23}
24
25// TEST_INPUT: set outputBuffer = out ubuffer(data=[0], stride=4)
26RWStructuredBuffer<int4> outputBuffer;
27
28// TEST_INPUT:set gParams = cbuffer(data=[1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1])
29ConstantBuffer<Params> gParams;
30
31// TEST_INPUT: set gDoubleNested = ubuffer(data=[1 2 3 4 5 6 7 8 9 10 11 12])
32uniform DoubleNested *gDoubleNested;
33
34// CHECK: 9
35
36[numthreads(1,1,1)]
37void computeMain(int id: SV_DispatchThreadID)
38{
39    outputBuffer[0].xyz = gParams.getVal(id) + gDoubleNested.getMatVal(1, 1);
40}
41
42// SPV-NOT: OpCompositeConstruct