summaryrefslogtreecommitdiff
path: root/shaders/shader.frag
diff options
context:
space:
mode:
Diffstat (limited to 'shaders/shader.frag')
-rw-r--r--shaders/shader.frag25
1 files changed, 22 insertions, 3 deletions
diff --git a/shaders/shader.frag b/shaders/shader.frag
index a4ce603..eb255e3 100644
--- a/shaders/shader.frag
+++ b/shaders/shader.frag
@@ -1,8 +1,27 @@
#version 450
-layout(location = 0) in vec4 fragColor;
-layout(location = 0) out vec4 outColor;
+layout(location = 0) in vec4 color;
+
+layout(set = 0, binding = 0) uniform mvp {
+ mat4 model;
+ mat4 view;
+ mat4 proj;
+ uint count;
+} ubo;
+
+layout(binding = 1) buffer fragment_buffer {
+ uvec3 fragments[];
+};
+layout(binding = 2, r32ui) uniform uimage2D head;
+layout(binding = 3) buffer counter {
+ uint data;
+};
void main() {
- outColor = fragColor;
+ const uint idx = atomicAdd(data, 1);
+ if (idx >= ubo.count) {
+ discard;
+ }
+ const uint prev_idx = imageAtomicExchange(head, ivec2(gl_FragCoord.xy), idx);
+ fragments[idx] = uvec3(prev_idx, packUnorm4x8(color), floatBitsToUint(gl_FragCoord.z));
}