yum-mirror/slang

Making it easier to work with shaders

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

venkataram-nvWarn when inout parameter is never written (#4777)20bd48659

master
1.8 KiB72 linesraw
1
2//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -shaderobj
3//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj
4//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -shaderobj
5//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj
6//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -shaderobj
7
8//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0], stride=4):out,name outputBuffer
9
10RWStructuredBuffer<int> outputBuffer;
11
12
13int getParamSize(uint3 v)
14{
15    return sizeof(v);
16}
17
18// On some targets inout might be passed via a pointer. 
19// With "natural" layout size must be the same across all targets.
20// The parameter passing semantic is "value in/value out", so the size 
21// will always be the size of the *value* regardless. So uint3 in this case.
22int getParamSizeWithDirection(uint3 v)
23{
24    return sizeof(v);
25}
26
27struct TestThis : IDefaultInitializable
28{
29    int getSize()
30    {
31        return sizeof(This);
32    }
33
34    float a;
35    int b[2];
36};
37
38static const float4 staticConstValueA = float4(-1);
39
40[numthreads(8, 1, 1)]
41void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
42{
43    const int idx = asint(dispatchThreadID.x);
44
45    double doub = 13.0;
46    uint16_t u16 = 10;
47
48    uint3 vec = uint3(0);
49
50    int size = 0;
51    switch (idx)
52    {   
53        case 0:     size = sizeof(doub); break;
54        case 1:     size = sizeof(u16); break;
55        case 2:     size = sizeof(nullptr); break;
56        case 3:     size = sizeof(void); break;
57        
58        case 4:     size = getParamSizeWithDirection(vec); break;
59        case 5:     size = getParamSize(vec); break;
60        
61        case 6:     size = sizeof(staticConstValueA); break;
62        case 7:
63        {
64            TestThis t;
65            size = t.getSize(); 
66            break;
67        }
68        default:    size = -1; break;
69    }
70
71    outputBuffer[idx] = size;
72}