| 1 |
#[compute] |
| 2 |
|
| 3 |
#version 450 |
| 4 |
|
| 5 |
#VERSION_DEFINES |
| 6 |
|
| 7 |
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in; |
| 8 |
|
| 9 |
layout(set = 0, binding = 0) uniform sampler2D source; |
| 10 |
layout(r32f, set = 0, binding = 1) uniform restrict writeonly image2D dest; |
| 11 |
|
| 12 |
layout(push_constant, std430) uniform Params { |
| 13 |
ivec2 screen_size; |
| 14 |
} |
| 15 |
params; |
| 16 |
|
| 17 |
void main() { |
| 18 |
ivec2 pixel_pos = ivec2(gl_GlobalInvocationID.xy); |
| 19 |
|
| 20 |
if (any(greaterThanEqual(pixel_pos, params.screen_size))) { |
| 21 |
return; |
| 22 |
} |
| 23 |
|
| 24 |
float depth = texelFetch(source, pixel_pos * 2 + ivec2(0, 0), 0).x; |
| 25 |
depth = max(depth, texelFetch(source, pixel_pos * 2 + ivec2(1, 0), 0).x); |
| 26 |
depth = max(depth, texelFetch(source, pixel_pos * 2 + ivec2(0, 1), 0).x); |
| 27 |
depth = max(depth, texelFetch(source, pixel_pos * 2 + ivec2(1, 1), 0).x); |
| 28 |
|
| 29 |
#ifdef MODE_ODD_WIDTH |
| 30 |
depth = max(depth, texelFetch(source, pixel_pos * 2 + ivec2(2, 0), 0).x); |
| 31 |
depth = max(depth, texelFetch(source, pixel_pos * 2 + ivec2(2, 1), 0).x); |
| 32 |
#endif |
| 33 |
|
| 34 |
#ifdef MODE_ODD_HEIGHT |
| 35 |
depth = max(depth, texelFetch(source, pixel_pos * 2 + ivec2(0, 2), 0).x); |
| 36 |
depth = max(depth, texelFetch(source, pixel_pos * 2 + ivec2(1, 2), 0).x); |
| 37 |
#endif |
| 38 |
|
| 39 |
#if defined(MODE_ODD_WIDTH) && defined(MODE_ODD_HEIGHT) |
| 40 |
depth = max(depth, texelFetch(source, pixel_pos * 2 + ivec2(2, 2), 0).x); |
| 41 |
#endif |
| 42 |
|
| 43 |
imageStore(dest, pixel_pos, vec4(depth, 0.0, 0.0, 0.0)); |
| 44 |
} |