aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Grois <andi@grois.info>2018-03-15 08:35:32 +0100
committerAndreas Grois <andi@grois.info>2018-03-15 08:35:32 +0100
commit85e8b5336debbbe7a88a8016ba8922e06386de21 (patch)
tree7339addcd96c56075902fdc83cffb7de464d1c2b
parent598e425e2bb50586c9aec400308727aa1075f69b (diff)
Prevent even more waiting by storing a more complete state
-rw-r--r--BuddhaTest/Shaders/BuddhaCompute.glsl74
-rw-r--r--BuddhaTest/include/Helpers.h2
-rw-r--r--BuddhaTest/src/Helpers.cpp2
3 files changed, 43 insertions, 35 deletions
diff --git a/BuddhaTest/Shaders/BuddhaCompute.glsl b/BuddhaTest/Shaders/BuddhaCompute.glsl
index 8eb925b..044cd01 100644
--- a/BuddhaTest/Shaders/BuddhaCompute.glsl
+++ b/BuddhaTest/Shaders/BuddhaCompute.glsl
@@ -187,33 +187,36 @@ vec2 getStartValue(uint seed, uint yDecoupler)
return retval;
}
-bool isGoingToBeDrawn(in vec2 offset, in uint totalIterations, inout vec2 lastVal, inout uint doneIterations, out bool result)
+bool isGoingToBeDrawn(in vec2 offset, in uint totalIterations, inout vec2 lastVal, inout uint iterationsLeftThisFrame, inout uint doneIterations, out bool result)
{
- uint endCount = doneIterations + iterationsPerDispatch > totalIterations ? totalIterations : doneIterations + iterationsPerDispatch;
+ uint endCount = doneIterations + iterationsLeftThisFrame > totalIterations ? totalIterations : doneIterations + iterationsLeftThisFrame;
for(uint i = doneIterations; i < endCount;++i)
{
lastVal = compSqr(lastVal) + offset;
if(dot(lastVal,lastVal) > 4.0)
{
result = true;
+ iterationsLeftThisFrame -= i+1-doneIterations;
doneIterations = i+1;
return true;
}
}
doneIterations = endCount;
+ iterationsLeftThisFrame = 0;
result = false;
return endCount == totalIterations;
}
-bool drawOrbit(in vec2 offset, in uint totalIterations, inout vec2 lastVal, inout uint doneIterations)
+bool drawOrbit(in vec2 offset, in uint totalIterations, inout vec2 lastVal, inout uint iterationsLeftThisFrame, inout uint doneIterations)
{
- uint endCount = doneIterations + iterationsPerDispatch > totalIterations ? totalIterations : doneIterations + iterationsPerDispatch;
+ uint endCount = doneIterations + iterationsLeftThisFrame > totalIterations ? totalIterations : doneIterations + iterationsLeftThisFrame;
for(uint i = doneIterations; i < endCount;++i)
{
lastVal = compSqr(lastVal) + offset;
if(dot(lastVal,lastVal) > 20.0)
{
doneIterations = i+1;
+ iterationsLeftThisFrame -= i+1-doneIterations;
return true; //done.
}
if(lastVal.x > -2.5 && lastVal.x < 1.0 && lastVal.y > -1.0 && lastVal.y < 1.0)
@@ -222,6 +225,7 @@ bool drawOrbit(in vec2 offset, in uint totalIterations, inout vec2 lastVal, inou
}
}
doneIterations = endCount;
+ iterationsLeftThisFrame = 0;
return endCount == totalIterations;
}
@@ -245,45 +249,49 @@ void main() {
vec2 offset;
//getIndividualState(in uint CellID, out vec2 offset, out vec2 coordinates, out uint phase, out uint orbitNumber, out uint doneIterations)
getIndividualState(uniqueWorkerID, offset, lastPosition, phase, orbitNumber, doneIterations);
- if(phase == 0)
+ uint iterationsLeftToDo = iterationsPerDispatch;
+ while(iterationsLeftToDo != 0)
{
- //new orbit:
- uint seed = orbitNumber * totalWorkers + uniqueWorkerID;
- uint yDecoupler = orbitNumber;
- offset = getStartValue(seed, yDecoupler);
- lastPosition = vec2(0);
- phase = 1;
- doneIterations = 0;
- }
- if(phase == 1)
- {
- //check if this orbit is going to be drawn
- bool result;
- if(isGoingToBeDrawn(offset,totalIterations, lastPosition, doneIterations , result))
+ if(phase == 0)
{
- if(result)
+ //new orbit:
+ uint seed = orbitNumber * totalWorkers + uniqueWorkerID;
+ uint yDecoupler = orbitNumber;
+ offset = getStartValue(seed, yDecoupler);
+ lastPosition = vec2(0);
+ phase = 1;
+ doneIterations = 0;
+ }
+ if(phase == 1)
+ {
+ //check if this orbit is going to be drawn
+ bool result;
+ if(isGoingToBeDrawn(offset,totalIterations, lastPosition, iterationsLeftToDo, doneIterations , result))
{
- //on to step 2: drawing
- phase = 2;
- lastPosition = vec2(0);
- doneIterations = 0;
+ if(result)
+ {
+ //on to step 2: drawing
+ phase = 2;
+ lastPosition = vec2(0);
+ doneIterations = 0;
+ }
+ else
+ {
+ //back to step 0
+ ++orbitNumber;
+ phase = 0;
+ }
}
- else
+ }
+ else if(phase == 2)
+ {
+ if(drawOrbit(offset, totalIterations, lastPosition, iterationsLeftToDo, doneIterations))
{
- //back to step 0
++orbitNumber;
phase = 0;
}
}
}
- else if(phase == 2)
- {
- if(drawOrbit(offset, totalIterations, lastPosition, doneIterations))
- {
- ++orbitNumber;
- phase = 0;
- }
- }
setIndividualState(uniqueWorkerID, offset, lastPosition, phase, orbitNumber, doneIterations);
diff --git a/BuddhaTest/include/Helpers.h b/BuddhaTest/include/Helpers.h
index ee5b07f..fc63103 100644
--- a/BuddhaTest/include/Helpers.h
+++ b/BuddhaTest/include/Helpers.h
@@ -46,7 +46,7 @@ namespace Helpers
unsigned int globalWorkGroupSizeY = 1;
unsigned int globalWorkGroupSizeZ = 1;
- unsigned int iterationsPerFrame = 1000;
+ unsigned int iterationsPerFrame = 10;
std::string pngFilename = "";
double pngGamma = 1.0;
diff --git a/BuddhaTest/src/Helpers.cpp b/BuddhaTest/src/Helpers.cpp
index 5197421..02cc309 100644
--- a/BuddhaTest/src/Helpers.cpp
+++ b/BuddhaTest/src/Helpers.cpp
@@ -363,7 +363,7 @@ namespace Helpers
"--globalWorkgroupSizeX [integer] : How often the local work group should be invoked per frame. Values up to 65535 are guaranteed to work. Default is 1024." << std::endl <<
"--globalWorkgroupSizeY [integer] : How often the local work group should be invoked per frame. Values up to 65535 are guaranteed to work. Default is 1." << std::endl <<
"--globalWorkgroupSizeZ [integer] : How often the local work group should be invoked per frame. Values up to 65535 are guaranteed to work. Default is 1." << std::endl <<
- "--iterationsPerFrame [integer] : Limit how many iteration steps the shader may make per frame. Use this to keep the desktop responsive while rendering high iteration count images. Default: 1000." << std::endl <<
+ "--iterationsPerFrame [integer] : Limit how many iteration steps the shader may make per frame. Use this to keep the desktop responsive while rendering high iteration count images. Default: 10." << std::endl <<
"--ignoreMaxBufferSize [0,1] : If set to 1, a failed maximum buffer size check is not treated as error. Some graphics drivers report lower values than their absolute limit. Do this on your own risk, though." << std::endl;
return false;
}