yum-mirror/glslang

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

Wint3rNightAllow sampler and image assignment under GL_ARB_bindless_texture2ff6f609

main
1.1 KiB42 linesraw
1#version 460 core
2
3#extension GL_ARB_bindless_texture: require
4
5// These two are declared before any other bindless construct in the file, so only
6// the extension itself can enable the opaque out and inout parameters.
7void setSampler(out sampler2D s, uvec2 handle)
8{
9    s = sampler2D(handle);
10}
11
12void copyBuffers(inout samplerBuffer bufs[2], samplerBuffer src)
13{
14    bufs[0] = src;
15    bufs[1] = src;
16}
17
18uniform sampler2D tex;
19uniform samplerBuffer buf;
20uniform uvec2 handle;
21uniform vec2 coord;
22layout(rgba8) uniform image2D img;
23
24out vec4 color0;
25out vec4 color1;
26out uvec2 handleOut;
27
28void main()
29{
30    sampler2D local = tex;                      // sampler as a temporary
31    setSampler(local, handle);                  // written through an out parameter
32    color0 = texture(local, coord);
33
34    samplerBuffer bufs[2];
35    copyBuffers(bufs, buf);                     // array of samplers through inout
36    color1 = texelFetch(bufs[1], 0);
37
38    image2D localImage = img;                   // images are handles too
39    color1 += imageLoad(localImage, ivec2(0, 0));
40
41    handleOut = uvec2(tex);                     // handle out of a sampler
42}