generated from Persson-dev/OpenGLComputeShader
optimize dispatch calls
This commit is contained in:
14
src/Main.cpp
14
src/Main.cpp
@@ -139,7 +139,7 @@ int main()
|
||||
GLuint vertexBuffer;
|
||||
glCreateBuffers(1, &vertexBuffer);
|
||||
|
||||
constexpr int DEPTH = 13;
|
||||
constexpr int DEPTH = 14;
|
||||
|
||||
auto vertices = GetPoints(DEPTH);
|
||||
|
||||
@@ -155,6 +155,8 @@ int main()
|
||||
glVertexArrayAttribBinding(vertexArray, 0, 0);
|
||||
glVertexArrayAttribBinding(vertexArray, 1, 0);
|
||||
|
||||
Timer timer;
|
||||
|
||||
GLuint ssbo;
|
||||
glGenBuffers(1, &ssbo);
|
||||
glBindBuffer(GL_SHADER_STORAGE_BUFFER, ssbo);
|
||||
@@ -173,7 +175,13 @@ int main()
|
||||
std::size_t count = 1;
|
||||
for (std::size_t i = 0; i < DEPTH; i++)
|
||||
{
|
||||
glDispatchCompute(count, 1, 1);
|
||||
glUniform1ui(0, count);
|
||||
std::cout << count << std::endl;
|
||||
|
||||
int dispatchCount = (count - 1) / 64 + 1;
|
||||
std::cout << "DC : " <<dispatchCount<< std::endl;
|
||||
|
||||
glDispatchCompute(dispatchCount, 1, 1);
|
||||
|
||||
// Ensure all writes to the image are complete
|
||||
glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);
|
||||
@@ -181,6 +189,8 @@ int main()
|
||||
count *= 3;
|
||||
}
|
||||
|
||||
std::cout << "Generated points in " << timer.ElapsedMillis() << " ms\n";
|
||||
|
||||
while (!glfwWindowShouldClose(window))
|
||||
{
|
||||
// ScopedTimer timer("Main Loop");
|
||||
|
||||
Reference in New Issue
Block a user