yum-mirror/slang

Making it easier to work with shaders

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

Yong HeFix SPIRV for mesh shaders, checks for invalid target code&recursion. (#3788)f96a3fea6

master
1.2 KiB56 linesraw
1// scalar-buffer-packing.slang
2//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-vk -compute
3//TEST:SIMPLE(filecheck=SPIRV): -stage compute -entry computeMain -target spirv -emit-spirv-directly -force-glsl-scalar-layout
4// Test ability to directly output SPIR-V
5
6//TEST_INPUT:set Uniforms.v0 = 1
7//TEST_INPUT:set Uniforms.v1 = { 1.0, 2.0, 3.0}
8
9cbuffer Uniforms
10{
11    bool v0;
12    float3 v1[3];
13}
14
15struct Val
16{
17    bool x;
18    int3 v1[2];
19    [mutating]
20    void set(bool v)
21    {
22        x = v;
23        v1[0].x = 1;
24        v1[0].y = 2;
25        v1[0].z = 3;
26        v1[1].x = 4;
27        v1[1].y = 5;
28        v1[1].z = 6;
29    }
30}
31
32//TEST_INPUT:set result = out ubuffer(data=[0 0 0 0 0 0 0 0 0 0 0 0], stride=4)
33RWStructuredBuffer<Val> result;
34[numthreads(1,1,1)]
35void computeMain()
36{
37    // CHECK: 1
38    // CHECK: 0
39    // CHECK: 0
40    // CHECK: 0
41    // CHECK: 1
42    // CHECK: 2
43    // CHECK: 3
44    // CHECK: 0
45    // CHECK: 4
46    // CHECK: 5
47    // CHECK: 6
48
49    result[0].set(v0);
50}
51
52// SPIRV: OpEntryPoint GLCompute
53
54// SPIRV-DAG: %[[STRUCTNAME:[A-Za-z0-9_]+]]  = OpTypeStruct %int %_Array_natural_vector_int_3_2
55
56// SPIRV-DAG: OpMemberDecorate %[[STRUCTNAME:[A-Za-z0-9_]+]] 1 Offset 4