• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#version 450 core
2#define PRECISION ${PRECISION}
3#define FORMAT ${FORMAT}
4
5layout(std430) buffer;
6
7/* Qualifiers: layout - storage - precision - memory */
8
9layout(set = 0, binding = 0, FORMAT) uniform PRECISION restrict writeonly image3D   uOutput;
10layout(set = 0, binding = 1)         uniform PRECISION                    sampler3D uInput;
11layout(set = 0, binding = 2)         uniform PRECISION restrict           Block {
12  ivec4 size;
13  ivec4 kernel;
14  ivec2 stride;
15  ivec2 padding;
16  ivec2 dilate;
17} uBlock;
18
19layout(local_size_x_id = 0, local_size_y_id = 1, local_size_z_id = 2) in;
20
21#define FLT_MIN -3.402823466e+38
22
23void main() {
24  const ivec3 pos = ivec3(gl_GlobalInvocationID);
25
26  if (all(lessThan(pos, uBlock.size.xyz))) {
27    const ivec2 ipos = pos.xy * uBlock.stride - uBlock.padding;
28
29    const ivec2 start = ipos;
30    const ivec2 end = ipos + uBlock.kernel.xy * uBlock.dilate.xy;
31
32    vec4 outtex = vec4(FLT_MIN);
33
34    for (int y = start.y; y < end.y; y += uBlock.dilate.y) {
35      for (int x = start.x; x < end.x; x += uBlock.dilate.x) {
36        if ((x >= 0 && x < uBlock.kernel.z) && (y >= 0 && y < uBlock.kernel.w)) {
37          outtex = max(texelFetch(uInput, ivec3(x, y, pos.z), 0), outtex);
38        }
39        else {
40          outtex = max(vec4(0), outtex);
41        }
42      }
43    }
44
45    imageStore(uOutput, pos, outtex);
46  }
47}
48