aboutsummaryrefslogtreecommitdiff
path: root/BuddhaTest/Shaders/BuddhaCompute.glsl
diff options
context:
space:
mode:
authorAndreas Grois <andi@grois.info>2018-03-09 21:36:10 +0100
committerAndreas Grois <andi@grois.info>2018-03-09 21:36:10 +0100
commit3b734f0d6b9e28c1f2c4ae54e3f46e573e02f4a5 (patch)
tree444542870666e41594e7b493f625ade81d64f885 /BuddhaTest/Shaders/BuddhaCompute.glsl
Initial Commit
Diffstat (limited to 'BuddhaTest/Shaders/BuddhaCompute.glsl')
-rw-r--r--BuddhaTest/Shaders/BuddhaCompute.glsl27
1 files changed, 27 insertions, 0 deletions
diff --git a/BuddhaTest/Shaders/BuddhaCompute.glsl b/BuddhaTest/Shaders/BuddhaCompute.glsl
new file mode 100644
index 0000000..49209ae
--- /dev/null
+++ b/BuddhaTest/Shaders/BuddhaCompute.glsl
@@ -0,0 +1,27 @@
+#version 430
+
+layout(std430, binding=2) buffer renderedData
+{
+ uint width;
+ uint height;
+ uint counts_SSBO[];
+};
+
+uniform uint iterationCount;
+
+void addToColorAt(uvec2 cell, uvec3 toAdd)
+{
+ uint firstIndex = 3*(cell.x + cell.y * width);
+ atomicAdd(counts_SSBO[firstIndex],toAdd.x);
+ atomicAdd(counts_SSBO[firstIndex+1],toAdd.y);
+ atomicAdd(counts_SSBO[firstIndex+2],toAdd.z);
+}
+
+
+layout (local_size_x = 1, local_size_y = 1) in;
+void main() {
+ if(iterationCount < 1024)
+ addToColorAt(uvec2(iterationCount%width,iterationCount/width),uvec3(1,0,0));
+ else
+ addToColorAt(uvec2(iterationCount%width,iterationCount/width),uvec3(0,1,0));
+}