Commit 4046895f by Philipp Adolf

Run copyShader

parent f7c76418
......@@ -738,6 +738,9 @@ Subdivision::Result Subdivision::runShader(Input input, Tables &tables) {
f->glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0);
QTime timer;
timer.start();
runCopyShader(input.vertex_buffer.size(), input.vb_handle, output_handle);
int copyTime = timer.elapsed();
timer.restart();
runVertexShader(input.vertex_buffer.size(), input.vb_handle, vertex_indices_handle, vertex_offsets_handle, output_handle);
int vertexTime = timer.elapsed();
timer.restart();
......@@ -770,10 +773,29 @@ Subdivision::Result Subdivision::runShader(Input input, Tables &tables) {
f->glDeleteBuffers(1, &vertex_offsets_handle);
f->glDeleteBuffers(1, &edge_indices_handle);
qCDebug(log_timing)<<"Compute Shader done. Vertexshader"<<vertexTime<<"ms; EdgeShader"<<edgeTime<<" BufferToCPU"<<bufferbildTime<<"ms";
qCDebug(log_timing)<<"Compute Shader done. Copyshader"<<copyTime<<"ms; Vertexshader"<<vertexTime<<"ms; EdgeShader"<<edgeTime<<" BufferToCPU"<<bufferbildTime<<"ms";
return result;
}
void Subdivision::runCopyShader(GLuint size, GLuint vb_in, GLuint vb_out) {
copyShader->bind();
f->glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, vb_in);
f->glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, vb_out);
// Run the shader
f->glDispatchCompute(size, 1, 1);
// Wait for the shader to complete and the data to be written back to the global memory
f->glMemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT);
// Unbind the buffers from the shader
f->glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, 0);
f->glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, 0);
copyShader->release();
}
void Subdivision::runVertexShader(GLuint size, GLuint vb_handle, GLuint vertex_indices_handle, GLuint vertex_offsets_handle, GLuint output_handle) {
vertexShader->bind();
......
......@@ -62,6 +62,7 @@ private:
void updateIndexBuffer(QVector<unsigned int> &index_buffer, QMap<unsigned int, unsigned int> map);
void findRegular(QVector<unsigned int> index_buffer, QVector<Vertex> vertex_buffer, QVector<unsigned int> &regular, QVector<unsigned int> &irregular);
Result runShader(Input input, Tables &tables);
void runCopyShader(GLuint size, GLuint vb_in, GLuint vb_out);
void runVertexShader(GLuint size, GLuint vb_handle, GLuint vertex_indices_handle, GLuint vertex_offsets_handle, GLuint output_handle);
void runEdgeShader(GLuint size, GLuint vb_handle, GLuint edge_indices_handle, GLuint output_handle, GLuint offset);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment