aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Grois <andi@grois.info>2018-03-18 20:45:26 +0100
committerAndreas Grois <andi@grois.info>2018-03-18 20:45:26 +0100
commitdb2ea861c688aadf59fc35ff6cfca69149a1a94c (patch)
treeeb26538f895916698c75dbf71d0b1b20d16fa767
parentc6ba30d76aca396ce5a3975f4625e05e8cf915ee (diff)
Move totaliterations calculation to CPU. This frees 4 VGPRs.
Now the code is back to the limit of 32 VGPRs without the need to directly operate on the state buffer. This means that now it's bound by memory access.
-rw-r--r--BuddhaTest/Shaders/BuddhaCompute.glsl5
-rw-r--r--BuddhaTest/src/BuddhaTest.cpp5
2 files changed, 5 insertions, 5 deletions
diff --git a/BuddhaTest/Shaders/BuddhaCompute.glsl b/BuddhaTest/Shaders/BuddhaCompute.glsl
index 10dfe23..7cd4efe 100644
--- a/BuddhaTest/Shaders/BuddhaCompute.glsl
+++ b/BuddhaTest/Shaders/BuddhaCompute.glsl
@@ -34,6 +34,7 @@ uniform uint height;
uniform uvec4 orbitLength;
uniform uint iterationsPerDispatch;
+uniform uint totalIterations;
void addToColorOfCell(uvec2 cell, uvec3 toAdd)
{
@@ -202,15 +203,11 @@ vec2 getCurrentOrbitOffset(const uint orbitNumber, const uint totalWorkers, cons
void main() {
//we need to know how many total work groups are running this iteration
-
const uvec3 totalWorkersPerDimension = gl_WorkGroupSize * gl_NumWorkGroups;
const uint totalWorkers = totalWorkersPerDimension.x*totalWorkersPerDimension.y*totalWorkersPerDimension.z;
const uint uniqueWorkerID = gl_GlobalInvocationID.x + gl_GlobalInvocationID.y*totalWorkersPerDimension.x + gl_GlobalInvocationID.z*(totalWorkersPerDimension.x * totalWorkersPerDimension.y);
- const uint _totalIterations = orbitLength.x > orbitLength.y ? orbitLength.x : orbitLength.y;
- const uint totalIterations = _totalIterations > orbitLength.z ? _totalIterations : orbitLength.z;
-
individualData state = stateArray[uniqueWorkerID];
//getIndividualState(in uint CellID, out vec2 offset, out vec2 coordinates, out uint phase, out uint orbitNumber, out uint doneIterations)
diff --git a/BuddhaTest/src/BuddhaTest.cpp b/BuddhaTest/src/BuddhaTest.cpp
index 3b99169..0a99fee 100644
--- a/BuddhaTest/src/BuddhaTest.cpp
+++ b/BuddhaTest/src/BuddhaTest.cpp
@@ -148,6 +148,7 @@ int main(int argc, char * argv[])
glUseProgram(ComputeShader);
GLint orbitLengthUniformHandle = glGetUniformLocation(ComputeShader, "orbitLength");
+ GLint totalIterationsUniformHandle = glGetUniformLocation(ComputeShader, "totalIterations");
GLint widthUniformComputeHandle = glGetUniformLocation(ComputeShader, "width");
GLint heightUniformComputeHandle = glGetUniformLocation(ComputeShader, "height");
GLint iterationsPerDispatchHandle = glGetUniformLocation(ComputeShader, "iterationsPerDispatch");
@@ -155,6 +156,9 @@ int main(int argc, char * argv[])
glUniform1ui(widthUniformComputeHandle, settings.imageWidth);
glUniform1ui(heightUniformComputeHandle, bufferHeight);
+ const uint32_t maxOrbitlength = std::max(std::max(settings.orbitLengthBlue,settings.orbitLengthGreen),settings.orbitLengthRed);
+ glUniform1ui(totalIterationsUniformHandle, maxOrbitlength);
+
glUseProgram(VertexAndFragmentShaders);
GLint widthUniformFragmentHandle = glGetUniformLocation(VertexAndFragmentShaders, "width");
GLint heightUniformFragmentHandle = glGetUniformLocation(VertexAndFragmentShaders, "height");
@@ -169,7 +173,6 @@ int main(int argc, char * argv[])
uint64_t totalIterationCount{0};
uint64_t lastMessage{0};
- const uint64_t maxOrbitlength = std::max(std::max(settings.orbitLengthBlue,settings.orbitLengthGreen),settings.orbitLengthRed);
/* Loop until the user closes the window */
while (!glfwWindowShouldClose(window))