diff options
author | Andreas Grois <andi@grois.info> | 2018-03-18 16:24:50 +0100 |
---|---|---|
committer | Andreas Grois <andi@grois.info> | 2018-03-18 16:24:50 +0100 |
commit | 385dd0dcf8fd003db604355341b00baa1fe1c1a0 (patch) | |
tree | 865d70f26341a019df54cf7492a5fb943eac3325 | |
parent | f3f67518d7eb74c868b523851ec482cd2177c3ce (diff) |
Add option to skip short orbits. Add option to print debug output.
-rw-r--r-- | BuddhaTest/Shaders/BuddhaCompute.glsl | 4 | ||||
-rw-r--r-- | BuddhaTest/include/Helpers.h | 2 | ||||
-rw-r--r-- | BuddhaTest/src/BuddhaTest.cpp | 16 | ||||
-rw-r--r-- | BuddhaTest/src/Helpers.cpp | 6 |
4 files changed, 24 insertions, 4 deletions
diff --git a/BuddhaTest/Shaders/BuddhaCompute.glsl b/BuddhaTest/Shaders/BuddhaCompute.glsl index 025f5de..10ed77f 100644 --- a/BuddhaTest/Shaders/BuddhaCompute.glsl +++ b/BuddhaTest/Shaders/BuddhaCompute.glsl @@ -31,7 +31,7 @@ layout(packed, binding=5) restrict buffer statusBuffer uniform uint width; uniform uint height; -uniform uvec3 orbitLength; +uniform uvec4 orbitLength; uniform uint iterationsPerDispatch; @@ -156,9 +156,9 @@ bool isGoingToBeDrawn(in vec2 offset, in uint totalIterations, inout vec2 lastVa lastVal = compSqr(lastVal) + offset; if(dot(lastVal,lastVal) > 4.0) { - result = true; iterationsLeftThisFrame -= ((i+1)-doneIterations); doneIterations = i+1; + result = orbitLength.w < doneIterations; return true; } } diff --git a/BuddhaTest/include/Helpers.h b/BuddhaTest/include/Helpers.h index d89c97e..b4954c0 100644 --- a/BuddhaTest/include/Helpers.h +++ b/BuddhaTest/include/Helpers.h @@ -34,6 +34,7 @@ namespace Helpers unsigned int windowWidth = 1024; unsigned int windowHeight = 576; + unsigned int orbitLengthSkip = 0; unsigned int orbitLengthRed = 10; unsigned int orbitLengthGreen = 100; unsigned int orbitLengthBlue = 1000; @@ -53,6 +54,7 @@ namespace Helpers double pngColorScale = 2.0; unsigned int ignoreMaxBufferSize = 0; + unsigned int printDebugOutput = 0; bool CheckValidity(); bool ParseCommandLine(int argc, char * argv[]); diff --git a/BuddhaTest/src/BuddhaTest.cpp b/BuddhaTest/src/BuddhaTest.cpp index 63720ed..1a960cb 100644 --- a/BuddhaTest/src/BuddhaTest.cpp +++ b/BuddhaTest/src/BuddhaTest.cpp @@ -4,6 +4,7 @@ #include <iostream> #include <vector> #include <chrono> +#include <iomanip> #include <algorithm> void error_callback(int error, const char* description) @@ -150,7 +151,7 @@ int main(int argc, char * argv[]) GLint widthUniformComputeHandle = glGetUniformLocation(ComputeShader, "width"); GLint heightUniformComputeHandle = glGetUniformLocation(ComputeShader, "height"); GLint iterationsPerDispatchHandle = glGetUniformLocation(ComputeShader, "iterationsPerDispatch"); - glUniform3ui(orbitLengthUniformHandle,settings.orbitLengthRed,settings.orbitLengthGreen,settings.orbitLengthBlue); + glUniform4ui(orbitLengthUniformHandle,settings.orbitLengthRed,settings.orbitLengthGreen,settings.orbitLengthBlue,settings.orbitLengthSkip); glUniform1ui(widthUniformComputeHandle, settings.imageWidth); glUniform1ui(heightUniformComputeHandle, bufferHeight); @@ -166,10 +167,15 @@ int main(int argc, char * argv[]) Helpers::PIDController<float, std::chrono::high_resolution_clock::time_point::rep> pid{0.0f,0.0f,1e-4f}; const uint32_t targetFrameDuration{1000000/settings.targetFrameRate}; + 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)) { auto frameStart{std::chrono::high_resolution_clock::now()}; + totalIterationCount += iterationsPerFrame; //let the compute shader do something glUseProgram(ComputeShader); glUniform1ui(iterationsPerDispatchHandle, iterationsPerFrame); @@ -212,6 +218,14 @@ int main(int argc, char * argv[]) //std::cout << iterationsPerFrame << " " << pidOutput << std::endl; } + if(settings.printDebugOutput != 0 && totalIterationCount/maxOrbitlength > lastMessage) + { + lastMessage = totalIterationCount/maxOrbitlength; + const auto ctime = std::chrono::high_resolution_clock::to_time_t(frameStop); + std::cout << "Iteration count next frame: " << iterationsPerFrame << std::endl; + std::cout << std::put_time(std::localtime(&ctime),"%X") << ": Iteration count per worker higher than: " << lastMessage*maxOrbitlength << std::endl; + std::cout << std::put_time(std::localtime(&ctime),"%X") << ": Total iteration count higher than: " << lastMessage*maxOrbitlength*workersPerFrame << std::endl; + } } if(!settings.pngFilename.empty()) diff --git a/BuddhaTest/src/Helpers.cpp b/BuddhaTest/src/Helpers.cpp index 5385866..e499f0c 100644 --- a/BuddhaTest/src/Helpers.cpp +++ b/BuddhaTest/src/Helpers.cpp @@ -323,6 +323,7 @@ namespace Helpers {"--imageHeight",&imageHeight}, {"--windowWidth",&windowWidth}, {"--windowHeight",&windowHeight}, + {"--orbitLengthSkip",&orbitLengthSkip}, {"--orbitLengthRed",&orbitLengthRed}, {"--orbitLengthGreen",&orbitLengthGreen}, {"--orbitLengthBlue",&orbitLengthBlue}, @@ -336,7 +337,8 @@ namespace Helpers {"--imageGamma",&pngGamma}, {"--imageColorScale",&pngColorScale}, {"--output", &pngFilename}, - {"--ignoreMaxBufferSize", &ignoreMaxBufferSize} + {"--ignoreMaxBufferSize", &ignoreMaxBufferSize}, + {"--printDebugOutput", &printDebugOutput} }; for(int i=1; i < argc;++i) @@ -353,6 +355,7 @@ namespace Helpers "--imageColorScale [float] : Image brightness is scaled by the brightest pixel. The result is multiplied by this value. 2.0 by default, as 1.0 leaves very little dynamic range." << std::endl << "--windowWidth [integer] : Width of the preview window. 1024 by default." << std::endl << "--windowHeight [integer] : Height of the preview window. 576 by default." << std::endl << + "--orbitLengthSkip [integer] : Minimum lengths for escaping orbits to be drawn at all. Default 0." << std::endl << "--orbitLengthRed [integer] : Maximum number of iterations for escaping orbits to color red. 10 by default." << std::endl << "--orbitLengthGreen [integer] : Maximum number of iterations for escaping orbits to color green. 100 by default." << std::endl << "--orbitLengthBlue [integer] : Maximum number of iterations for escaping orbits to color blue. 1000 by default." << std::endl << @@ -364,6 +367,7 @@ namespace Helpers "--globalWorkgroupSizeY [integer] : How often the local work group should be invoked per frame. Values up to 65535 are guaranteed to work. Default is 64." << 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 << "--targetFrameRate [integer] : The number of iterations per frame will dynamically adjust to approximately reach this framerate. Default: 60." << std::endl << + "--printDebugOutput [0,1] : If set to 1, every orbitLength a message will be printed to stdout. Default 0." << 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; } |