From 627aa610fc93398ac51129096ce8fb30731af341 Mon Sep 17 00:00:00 2001 From: Andreas Grois Date: Sun, 11 Mar 2018 21:27:11 +0100 Subject: Split buffer in three, one per color (as OpenGL guarantees that one can at least have 8 SSBOs), to allow three times larger images. Also make it possible to ignore maximum buffer size reported by the driver. The maximum buffer size limitation is rather strict on radeonsi, so I decided to split the buffer in three, effectively increasing the maximum image size by a factor of three. While doing so I realized that at least on radeonsi the reported maximum buffer size seems to be off. For this reason I added a new command line switch, that allows to ignore the maximum buffer size check. For those curious: radeonsi reports a maximum buffer size of 128 MB, but I had no problems when using three buffers of 1098 MB each. --- BuddhaTest/Shaders/BuddhaCompute.glsl | 20 ++++++++++++++------ BuddhaTest/Shaders/BuddhaFragment.glsl | 16 ++++++++++++---- 2 files changed, 26 insertions(+), 10 deletions(-) (limited to 'BuddhaTest/Shaders') diff --git a/BuddhaTest/Shaders/BuddhaCompute.glsl b/BuddhaTest/Shaders/BuddhaCompute.glsl index 9d8301a..ddcbace 100644 --- a/BuddhaTest/Shaders/BuddhaCompute.glsl +++ b/BuddhaTest/Shaders/BuddhaCompute.glsl @@ -2,9 +2,17 @@ //#version 430 //layout (local_size_x = 1024) in; //to be safe, we limit our local work group size to 1024. That's the minimum a GL 4.3 capable driver must support. -layout(std430, binding=2) buffer renderedData +layout(std430, binding=2) buffer renderedDataRed { - uint counts_SSBO[]; + uint counts_SSBORed[]; +}; +layout(std430, binding=3) buffer renderedDataGreen +{ + uint counts_SSBOGreen[]; +}; +layout(std430, binding=4) buffer renderedDataBlue +{ + uint counts_SSBOBlue[]; }; uniform uint width; @@ -15,10 +23,10 @@ uniform uvec3 orbitLength; void addToColorOfCell(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); + uint firstIndex = (cell.x + cell.y * width); + atomicAdd(counts_SSBORed[firstIndex],toAdd.x); + atomicAdd(counts_SSBOGreen[firstIndex],toAdd.y); + atomicAdd(counts_SSBOBlue[firstIndex],toAdd.z); } uvec2 getCell(vec2 complex) diff --git a/BuddhaTest/Shaders/BuddhaFragment.glsl b/BuddhaTest/Shaders/BuddhaFragment.glsl index 1556065..24fb6a7 100644 --- a/BuddhaTest/Shaders/BuddhaFragment.glsl +++ b/BuddhaTest/Shaders/BuddhaFragment.glsl @@ -4,9 +4,17 @@ in vec2 uv; out vec3 color; -layout(std430, binding=2) buffer renderedData +layout(std430, binding=2) buffer renderedDataRed { - uint counts_SSBO[]; + uint counts_SSBORed[]; +}; +layout(std430, binding=3) buffer renderedDataGreen +{ + uint counts_SSBOGreen[]; +}; +layout(std430, binding=4) buffer renderedDataBlue +{ + uint counts_SSBOBlue[]; }; uniform uint width; @@ -16,8 +24,8 @@ uvec3 getColorAt(vec2 fragCoord) { uint xIndex = uint(max(0.0,(fragCoord.x+1.0)*0.5*width)); uint yIndex = uint(max(0.0,abs(fragCoord.y)*height)); - uint firstIndex = 3*(xIndex + yIndex * width); - return uvec3(counts_SSBO[firstIndex],counts_SSBO[firstIndex+1],counts_SSBO[firstIndex+2]); + uint firstIndex = (xIndex + yIndex * width); + return uvec3(counts_SSBORed[firstIndex],counts_SSBOGreen[firstIndex],counts_SSBOBlue[firstIndex]); } void main(){ -- cgit v1.2.3