Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #[compute]
- #version 450
- // Invocations in the (x, y, z) dimension
- layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
- // A binding to the buffer we create in our script
- layout(set = 0, binding = 0, std430) buffer MyDataBuffer {
- int data[];
- }
- my_data_buffer;
- layout(set = 0, binding = 1) uniform sampler2D tex;
- void main() {
- if (texture(tex, vec2(gl_GlobalInvocationID.x, gl_GlobalInvocationID.y)).r > 0.0) {
- atomicAdd(my_data_buffer.data[0], 1);
- }
- if (texture(tex, vec2(gl_GlobalInvocationID.x, gl_GlobalInvocationID.y)).b > 0.0) {
- atomicAdd(my_data_buffer.data[1], 1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement