#version 450

layout(
  local_size_x = 8,
  local_size_y = 8,
  local_size_z = 1) in;

layout(binding = 0) writeonly uniform uimageBuffer u_dst;
layout(binding = 1) uniform usamplerBuffer u_src;

layout(push_constant)
uniform u_info_t {
  uvec3 dst_offset;
  uvec3 src_offset;
  uvec3 extent;
  uvec2 dst_size;
  uvec2 src_size;
} u_info;

void main() {
  if (all(lessThan(gl_GlobalInvocationID, u_info.extent))) {
    uvec3 dst_coord = u_info.dst_offset + gl_GlobalInvocationID;
    uvec3 src_coord = u_info.src_offset + gl_GlobalInvocationID;

    uint dst_index = dst_coord.x + u_info.dst_size.x * (dst_coord.y + u_info.dst_size.y * dst_coord.z);
    uint src_index = src_coord.x + u_info.src_size.x * (src_coord.y + u_info.src_size.y * src_coord.z);

    imageStore(u_dst, int(dst_index), texelFetch(u_src, int(src_index)));
  }
}