yum-mirror/slang

Making it easier to work with shaders

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

Simon Kallweitupdate slang-rhi (#6587)ae1a5e408

master
4.5 KiB132 linesraw
1//TEST:SIMPLE(filecheck=CHECK_GLSL):  -allow-glsl -stage compute -entry computeMain -target glsl
2//TEST:SIMPLE(filecheck=CHECK_SPV):  -allow-glsl -stage compute -entry computeMain -target spirv -emit-spirv-directly
3
4// not testing hlsl due to missing impl
5//DISABLE_TEST:SIMPLE(filecheck=CHECK_HLSL): -allow-glsl -stage compute -entry computeMain -target hlsl -DTARGET_HLSL
6// not testing cuda due to missing impl
7//DISABLE_TEST:SIMPLE(filecheck=CHECK_CUDA): -allow-glsl -stage compute -entry computeMain -target cuda -DTARGET_CUDA 
8// not testing cpp due to missing impl
9//DISABLE_TEST:SIMPLE(filecheck=CHECK_CPP):  -allow-glsl -stage compute -entry computeMain -target cpp -DTARGET_CPP
10
11//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl
12//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl -emit-spirv-directly
13//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUF):-wgpu -compute -entry computeMain -allow-glsl -xslang -DWGPU -render-feature half
14//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUF):-metal -compute -entry computeMain -allow-glsl -xslang -DMETAL
15
16#version 430
17
18//TEST_INPUT:ubuffer(data=[0], stride=4):out,name=outputBuffer
19buffer MyBlockName2 
20{
21    uint data[];
22} outputBuffer;
23
24layout(local_size_x = 32) in;
25
26__generic<T : __BuiltinLogicalType>
27bool test1ShuffleX() {
28    return true
29        & subgroupShuffleUp(T(1), 1) == T(1)
30        & subgroupShuffleDown(T(1), 1) == T(1)
31        ;
32}
33__generic<T : __BuiltinLogicalType, let N : int>
34bool testVShuffleX() {
35    typealias gvec = vector<T, N>;
36
37    return true
38        & subgroupShuffleUp(gvec(T(1)), 1) == gvec(T(1))
39        & subgroupShuffleDown(gvec(T(1)), 1) == gvec(T(1))
40        ;
41}
42
43__generic<T : __BuiltinFloatingPointType>
44bool test1ShuffleX() {
45    return true
46        & subgroupShuffleUp(T(1), 1) == T(1)
47        & subgroupShuffleDown(T(1), 1) == T(1)
48        ;
49}
50__generic<T : __BuiltinFloatingPointType, let N : int>
51bool testVShuffleX() {
52    typealias gvec = vector<T, N>;
53
54    return true
55        & subgroupShuffleUp(gvec(T(1)), 1) == gvec(T(1))
56        & subgroupShuffleDown(gvec(T(1)), 1) == gvec(T(1))
57        ;
58}
59bool testShuffleX() {
60    return true
61        & test1ShuffleX<float>()
62        & testVShuffleX<float, 2>()
63        & testVShuffleX<float, 3>()
64        & testVShuffleX<float, 4>()
65        & test1ShuffleX<half>() 
66        & testVShuffleX<half, 2>()
67        & testVShuffleX<half, 3>()
68        & testVShuffleX<half, 4>()
69        & test1ShuffleX<int>()
70        & testVShuffleX<int, 2>()
71        & testVShuffleX<int, 3>()
72        & testVShuffleX<int, 4>()
73        & test1ShuffleX<uint>()
74        & testVShuffleX<uint, 2>()
75        & testVShuffleX<uint, 3>()
76        & testVShuffleX<uint, 4>()
77
78// Disabled on WGPU and Metal as these built-in types are not supported as of time of writing.
79#if !defined(WGPU) && !defined(METAL)
80        & test1ShuffleX<double>() // WARNING: intel GPU's lack FP64 support
81        & testVShuffleX<double, 2>()
82        & testVShuffleX<double, 3>()
83        & testVShuffleX<double, 4>()
84        & test1ShuffleX<int8_t>() 
85        & testVShuffleX<int8_t, 2>()
86        & testVShuffleX<int8_t, 3>()
87        & testVShuffleX<int8_t, 4>()
88        & test1ShuffleX<int64_t>() 
89        & testVShuffleX<int64_t, 2>()
90        & testVShuffleX<int64_t, 3>()
91        & testVShuffleX<int64_t, 4>()
92        & test1ShuffleX<uint8_t>() 
93        & testVShuffleX<uint8_t, 2>()
94        & testVShuffleX<uint8_t, 3>()
95        & testVShuffleX<uint8_t, 4>()
96        & test1ShuffleX<uint64_t>() 
97        & testVShuffleX<uint64_t, 2>()
98        & testVShuffleX<uint64_t, 3>()
99        & testVShuffleX<uint64_t, 4>()
100        & test1ShuffleX<bool>()
101        & testVShuffleX<bool, 2>()
102        & testVShuffleX<bool, 3>()
103        & testVShuffleX<bool, 4>()
104#endif
105
106        // Disabled on WGPU as these built-in types are not supported as of time of writing.
107#if !defined(WGPU)
108        & test1ShuffleX<int16_t>()
109        & testVShuffleX<int16_t, 2>()
110        & testVShuffleX<int16_t, 3>()
111        & testVShuffleX<int16_t, 4>()
112        & test1ShuffleX<uint16_t>()
113        & testVShuffleX<uint16_t, 2>()
114        & testVShuffleX<uint16_t, 3>()
115        & testVShuffleX<uint16_t, 4>()
116#endif
117        ;
118}
119
120void computeMain()
121{
122    outputBuffer.data[0] = true
123        & testShuffleX()
124        ;
125
126    // CHECK_GLSL: void main(
127    // CHECK_SPV: OpEntryPoint
128    // CHECK_HLSL: void computeMain(
129    // CHECK_CUDA: void computeMain(
130    // CHECK_CPP: void _computeMain(
131    // BUF: 1
132}