yum-mirror/slang

Making it easier to work with shaders

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

James Helferty (NVIDIA)render-test: Change D3D12 default to sm_6_5 (#8320)f02b08490

master
957 B42 linesraw
1// Test tuple construction syntax.
2
3#language 2026
4
5//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-shaderobj
6//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -shaderobj
7//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -shaderobj
8//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -shaderobj
9
10//TEST_INPUT:ubuffer(data=[1 2 3 4], stride=4):out,name=outputBuffer
11RWStructuredBuffer<int> outputBuffer;
12
13void store(inout Tuple<int, float, uint> t)
14{
15    t._1_2 = (3.0, 4u);
16}
17
18struct MyType
19{
20    int x;
21    int y;
22    __init(Tuple<int, int> t){
23        x = t._0;
24        y = t._1;
25    }
26}
27
28[numthreads(1, 1, 1)]
29void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
30{
31    var t = (1, 2.0, 3u);
32    store(t);
33    let y = t._1_2_0;
34
35    // CHECK: 4
36    outputBuffer[0] = y._1;
37
38    // This should mean cast<MyType>(makeTuple(1,2))
39    let m = (MyType)(1,2);
40    // CHECK: 3
41    outputBuffer[1] = m.x + m.y;
42}