28 lines
766 B
GLSL
28 lines
766 B
GLSL
#version 430 core
|
|
|
|
layout (local_size_x = 128, local_size_y = 1, local_size_z = 1) in;
|
|
|
|
layout (r16i, binding = 0) readonly uniform iimageBuffer ImageIn;
|
|
layout (rg16i, binding = 1) writeonly uniform iimageBuffer ImageOut;
|
|
|
|
layout (location = 0) uniform int GlobalOffset;
|
|
layout (location = 1) uniform int WindowLength;
|
|
|
|
void main()
|
|
{
|
|
int x = int(gl_GlobalInvocationID.x);
|
|
|
|
int offset = GlobalOffset + x * WindowLength;
|
|
|
|
vec2 sum = vec2(0, 0);
|
|
|
|
float scale = 1.0 / float(WindowLength);
|
|
for (int i = 0; i < WindowLength; i++) {
|
|
ivec4 v = imageLoad(ImageIn, offset + i);
|
|
float value = float(v.x);
|
|
sum += vec2(clamp(value, 0.0, 32767.0), clamp(value, -32768.0, 0.0)) * scale;
|
|
}
|
|
|
|
imageStore(ImageOut, x, ivec4(int(sum.x), int(sum.y), 0, 0));
|
|
}
|