yum-mirror/slang

Making it easier to work with shaders

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

DarrenEnable exprs for all supported GLSL layout qualifiers (#5857)83f4bd5dc

master
1.6 KiB54 linesraw
1//TEST:SIMPLE(filecheck=CHECK): -target spirv -stage fragment -entry fragmentMain -allow-glsl
2//TEST:SIMPLE(filecheck=CHECK_GLSL): -target glsl -stage fragment -entry fragmentMain -allow-glsl
3
4#version 450
5
6static const uint BINDING_BASE = 3;
7static const uint BINDING_STRIDE = 2;
8static const uint SET_BASE = 1;
9static const uint SET_STRIDE = 4;
10static const uint BASE_IN_LOC = 3;
11static const uint BASE_IN_INDEX = 24;
12static const uint BASE_OUT_LOC = 2;
13static const uint INPUT_ATT_BASE = 16;
14
15// CHECK_GLSL: binding = 18
16// CHECK_GLSL: set = 9
17layout(set = SET_BASE + SET_STRIDE * 2, binding = BINDING_BASE * BINDING_STRIDE * 3) buffer Output {
18    float result[];
19};
20
21layout(set = SET_BASE, binding = BINDING_BASE * BINDING_STRIDE) buffer InputA {
22    float a[];
23};
24
25layout(set = SET_BASE + SET_STRIDE, binding = BINDING_BASE * BINDING_STRIDE * 2) buffer InputB {
26    float b[];
27};
28
29// CHECK_GLSL: binding = 3
30// CHECK_GLSL: set = 6
31// CHECK_GLSL: input_attachment_index = 10
32layout(input_attachment_index = (INPUT_ATT_BASE + 4) / 2, set = SET_BASE + 5, binding = BINDING_BASE) uniform subpassInput inputAttachment0;
33
34// CHECK_GLSL: constant_id = 27
35layout(constant_id = 3 * 9) const float specConst = 0.2;
36
37// CHECK_GLSL: location = 6
38[vk_location(BASE_OUT_LOC + 4)]
39out vec4 fragColor;
40
41// CHECK_GLSL: location = 7
42layout(location = (BASE_IN_LOC * 2) + 1, index = BASE_IN_INDEX / 3 ) in float inParam;
43
44void fragmentMain() {
45    uint index = gl_FragCoord.x;
46    result[index] = a[index] * b[index];
47
48    vec4 attachmentData = subpassLoad(inputAttachment0);
49    fragColor = vec4(attachmentData.rgb, 1.0) * specConst * inParam;
50
51    // CHECK: OpEntryPoint
52    // CHECK_GLSL: main
53}
54