From d06a01040cd7614a6951d6e6e350135a05ddb9c2 Mon Sep 17 00:00:00 2001 From: Andreas Grois Date: Thu, 22 Mar 2018 21:40:31 +0100 Subject: Divide et impera *is* faster. Finally. --- BuddhaTest/Shaders/BuddhaCompute.glsl | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'BuddhaTest') diff --git a/BuddhaTest/Shaders/BuddhaCompute.glsl b/BuddhaTest/Shaders/BuddhaCompute.glsl index 93f5704..0ce19f7 100644 --- a/BuddhaTest/Shaders/BuddhaCompute.glsl +++ b/BuddhaTest/Shaders/BuddhaCompute.glsl @@ -49,9 +49,15 @@ void uintMaxIP(inout uvec3 modified, const uvec3 constant) void addToColorOfCell(uvec2 cell, uvec3 toAdd) { uint firstIndex = 3*(cell.x + cell.y * width); - uintMaxIP(brightnesses[gl_LocalInvocationIndex].x, atomicAdd(counts_SSBO[firstIndex],toAdd.x)); - uintMaxIP(brightnesses[gl_LocalInvocationIndex].y, atomicAdd(counts_SSBO[firstIndex+1],toAdd.y)); - uintMaxIP(brightnesses[gl_LocalInvocationIndex].z, atomicAdd(counts_SSBO[firstIndex+2],toAdd.z)); + uvec3 b; + b.x = atomicAdd(counts_SSBO[firstIndex],toAdd.x); + b.y = atomicAdd(counts_SSBO[firstIndex+1],toAdd.y); + b.z = atomicAdd(counts_SSBO[firstIndex+2],toAdd.z); + for(int i = 0; i < 3;++i) + { + if(brightnesses[gl_LocalInvocationIndex][i] < b[i]) + brightnesses[gl_LocalInvocationIndex][i] = b[i]; + } } uvec2 getCell(vec2 complex) -- cgit v1.2.3