55 lines
1.4 KiB
Plaintext
55 lines
1.4 KiB
Plaintext
#version 440 core
|
|
layout(std430) buffer;
|
|
#ifdef INT
|
|
layout(set=0, binding=0) uniform isampler2D uInput;
|
|
|
|
layout(set=0, binding=1) writeonly buffer destBuffer{
|
|
ivec4 data[];
|
|
} uOutBuffer;
|
|
#else
|
|
layout(set=0, binding=0) uniform sampler2D uInput;
|
|
|
|
layout(set=0, binding=1) writeonly buffer destBuffer{
|
|
vec4 data[];
|
|
} uOutBuffer;
|
|
#endif
|
|
|
|
layout(set=0, binding=2) uniform constBuffer{
|
|
ivec4 size; // w, h, c, n
|
|
ivec4 stride;
|
|
} uConstant;
|
|
|
|
layout(set=0, binding=3) uniform offsetBuffer {
|
|
ivec4 offset; // Offset x, y, 0, 0
|
|
ivec4 size;//w, h, 0, w*h
|
|
} uOffset;
|
|
layout (local_size_x = 256, local_size_y = 1, local_size_z = 1) in;
|
|
|
|
void main()
|
|
{
|
|
int posX = ivec3(gl_GlobalInvocationID).x;
|
|
|
|
if (posX < uOffset.size.w)
|
|
{
|
|
ivec2 pos;
|
|
pos.x = posX % uOffset.size.x;
|
|
pos.y = posX / uOffset.size.x;
|
|
#ifdef INT
|
|
ivec4 color = texelFetch(uInput, pos, 0);
|
|
#else
|
|
vec4 color = texelFetch(uInput, pos, 0);
|
|
#endif
|
|
ivec2 spos = pos + uOffset.offset.xy;
|
|
int n = spos.y / uConstant.size.y;
|
|
int h = spos.y % uConstant.size.y;
|
|
int c = spos.x / uConstant.size.x;
|
|
int w = spos.x % uConstant.size.x;
|
|
int basicOffset = 0
|
|
+ n * uConstant.size.x * uConstant.size.y
|
|
+ c * uConstant.size.x * uConstant.size.y * uConstant.size.w
|
|
+ h * uConstant.size.x
|
|
+ w;
|
|
uOutBuffer.data[basicOffset] = color;
|
|
}
|
|
}
|