ColorCopyWideningComputeShaderSource.comp
1 #version 450 core 2 3 layout (std140, binding = 0) uniform ratio_in 4 { 5 int ratio; 6 }; 7 8 layout (set = 2, binding = 0) uniform usampler2D src; 9 layout (set = 3, binding = 0) writeonly uniform uimage2D dst; 10 11 layout (local_size_x = 32, local_size_y = 32, local_size_z = 1) in; 12 13 void main() 14 { 15 uvec2 coords = gl_GlobalInvocationID.xy; 16 ivec2 imageSz = imageSize(dst); 17 18 if (int(coords.x) >= imageSz.x || int(coords.y) >= imageSz.y) 19 { 20 return; 21 } 22 23 uvec2 srcCoords = uvec2(coords.x << ratio, coords.y); 24 25 uint r = texelFetchOffset(src, ivec2(srcCoords), 0, ivec2(0, 0)).r; 26 uint g = texelFetchOffset(src, ivec2(srcCoords), 0, ivec2(1, 0)).r; 27 uint b = texelFetchOffset(src, ivec2(srcCoords), 0, ivec2(2, 0)).r; 28 uint a = texelFetchOffset(src, ivec2(srcCoords), 0, ivec2(3, 0)).r; 29 30 imageStore(dst, ivec2(coords), uvec4(r, g, b, a)); 31 }