aboutsummaryrefslogtreecommitdiff
path: root/BuddhaTest/Shaders/BuddhaFragment.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/BuddhaFragment.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/BuddhaFragment.glsl')
-rw-r--r--BuddhaTest/Shaders/BuddhaFragment.glsl16
1 files changed, 12 insertions, 4 deletions
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(){