aboutsummaryrefslogtreecommitdiff
path: root/BuddhaTest/Shaders/BuddhaCompute.glsl
diff options
context:
space:
mode:
authorAndreas Grois <andi@grois.info>2018-03-11 21:27:11 +0100
committerAndreas Grois <andi@grois.info>2018-03-11 21:27:11 +0100
commit627aa610fc93398ac51129096ce8fb30731af341 (patch)
tree54c38179129a32bbe85753af63fc8b8e49b4c89c /BuddhaTest/Shaders/BuddhaCompute.glsl
parentbc666e3edcbd53f3bbe5446f0c4bc23e83c044a0 (diff)
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.
Diffstat (limited to 'BuddhaTest/Shaders/BuddhaCompute.glsl')
-rw-r--r--BuddhaTest/Shaders/BuddhaCompute.glsl20
1 files changed, 14 insertions, 6 deletions
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)