ClearTextureCompute.ankiprog 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright (C) 2009-2020, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. // A slow compute program to clear an image with a contant color
  6. #pragma anki mutator IS_2D 0 1
  7. #pragma anki start comp
  8. #include <shaders/Common.glsl>
  9. layout(local_size_x = 8, local_size_y = 8, local_size_z = (IS_2D == 1) ? 1 : 8) in;
  10. layout(push_constant) uniform pc_
  11. {
  12. Vec4 u_clearColor;
  13. };
  14. #if IS_2D
  15. layout(set = 0, binding = 0) uniform writeonly image2D u_img2d;
  16. #else
  17. layout(set = 0, binding = 0) uniform writeonly image3D u_img3d;
  18. #endif
  19. void main()
  20. {
  21. #if IS_2D
  22. const UVec2 size = UVec2(imageSize(u_img2d));
  23. if(gl_GlobalInvocationID.x >= size.x || gl_GlobalInvocationID.y >= size.y)
  24. {
  25. return;
  26. }
  27. imageStore(u_img2d, IVec2(gl_GlobalInvocationID.xy), u_clearColor);
  28. #else
  29. const UVec3 size = UVec3(imageSize(u_img3d));
  30. if(gl_GlobalInvocationID.x >= size.x || gl_GlobalInvocationID.y >= size.y || gl_GlobalInvocationID.z >= size.z)
  31. {
  32. return;
  33. }
  34. imageStore(u_img3d, IVec3(gl_GlobalInvocationID), u_clearColor);
  35. #endif
  36. }
  37. #pragma anki end