ColorCopyWideningComputeShaderSource.comp 867 B

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