07bc4e2f96
I couldn't find a tool that enforces it, so I went the manual route: ``` find -name "thirdparty" -prune \ -o -name "*.cpp" -o -name "*.h" -o -name "*.m" -o -name "*.mm" \ -o -name "*.glsl" > files perl -0777 -pi -e 's/\n}\n([^#])/\n}\n\n\1/g' $(cat files) misc/scripts/fix_style.sh -c ``` This adds a newline after all `}` on the first column, unless they are followed by `#` (typically `#endif`). This leads to having lots of places with two lines between function/class definitions, but clang-format then fixes it as we enforce max one line of separation. This doesn't fix potential occurrences of function definitions which are indented (e.g. for a helper class defined in a .cpp), but it's better than nothing. Also can't be made to run easily on CI/hooks so we'll have to be careful with new code. Part of #33027.
48 lines
1.2 KiB
GLSL
48 lines
1.2 KiB
GLSL
/* clang-format off */
|
|
[compute]
|
|
|
|
#version 450
|
|
|
|
VERSION_DEFINES
|
|
|
|
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
|
|
/* clang-format on */
|
|
|
|
layout(push_constant, binding = 1, std430) uniform Params {
|
|
vec2 pixel_size;
|
|
float z_far;
|
|
float z_near;
|
|
ivec2 source_size;
|
|
bool orthogonal;
|
|
uint pad;
|
|
}
|
|
|
|
params;
|
|
|
|
#ifdef MINIFY_START
|
|
layout(set = 0, binding = 0) uniform sampler2D source_texture;
|
|
#else
|
|
layout(r32f, set = 0, binding = 0) uniform restrict readonly image2D source_image;
|
|
#endif
|
|
layout(r32f, set = 1, binding = 0) uniform restrict writeonly image2D dest_image;
|
|
|
|
void main() {
|
|
ivec2 pos = ivec2(gl_GlobalInvocationID.xy);
|
|
|
|
if (any(greaterThan(pos, params.source_size >> 1))) { //too large, do nothing
|
|
return;
|
|
}
|
|
|
|
#ifdef MINIFY_START
|
|
float depth = texelFetch(source_texture, pos << 1, 0).r * 2.0 - 1.0;
|
|
if (params.orthogonal) {
|
|
depth = ((depth + (params.z_far + params.z_near) / (params.z_far - params.z_near)) * (params.z_far - params.z_near)) / 2.0;
|
|
} else {
|
|
depth = 2.0 * params.z_near * params.z_far / (params.z_far + params.z_near - depth * (params.z_far - params.z_near));
|
|
}
|
|
#else
|
|
float depth = imageLoad(source_image, pos << 1).r;
|
|
#endif
|
|
|
|
imageStore(dest_image, pos, vec4(depth));
|
|
}
|