Advertisement
Guest User

Compute GLSL

a guest
Oct 4th, 2022
2,001
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #[compute]
  2. #version 450
  3.  
  4. // Invocations in the (x, y, z) dimension
  5. layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
  6.  
  7. // A binding to the buffer we create in our script
  8. layout(set = 0, binding = 0, std430) buffer MyDataBuffer {
  9.     int data[];
  10. }
  11. my_data_buffer;
  12.  
  13. layout(set = 0, binding = 1) uniform sampler2D tex;
  14.  
  15. void main() {
  16.     if (texture(tex, vec2(gl_GlobalInvocationID.x, gl_GlobalInvocationID.y)).r > 0.0) {
  17.         atomicAdd(my_data_buffer.data[0], 1);
  18.     }
  19.  
  20.     if (texture(tex, vec2(gl_GlobalInvocationID.x, gl_GlobalInvocationID.y)).b > 0.0) {
  21.         atomicAdd(my_data_buffer.data[1], 1);
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement