Commit 580c2bfb by Philipp Adolf

Add offset to vertex shader

parent acbf4ac4
...@@ -745,7 +745,8 @@ Subdivision::Result Subdivision::runShader(Input input, Tables &tables) { ...@@ -745,7 +745,8 @@ Subdivision::Result Subdivision::runShader(Input input, Tables &tables) {
runEdgeShader(tables.edge_indices.size() / 4, input.vb_handle, edge_indices_handle, output_handle, edge_offset); runEdgeShader(tables.edge_indices.size() / 4, input.vb_handle, edge_indices_handle, output_handle, edge_offset);
int edgeTime = timer.elapsed(); int edgeTime = timer.elapsed();
timer.restart(); timer.restart();
runVertexShader(input.vertex_buffer.size(), input.vb_handle, vertex_indices_handle, vertex_offsets_handle, output_handle); int vertex_offset = 0;
runVertexShader(input.vertex_buffer.size(), input.vb_handle, vertex_indices_handle, vertex_offsets_handle, output_handle, vertex_offset);
int vertexTime = timer.elapsed(); int vertexTime = timer.elapsed();
timer.restart(); timer.restart();
...@@ -796,13 +797,13 @@ void Subdivision::runCopyShader(GLuint size, GLuint vb_in, GLuint vb_out) { ...@@ -796,13 +797,13 @@ void Subdivision::runCopyShader(GLuint size, GLuint vb_in, GLuint vb_out) {
copyShader->release(); copyShader->release();
} }
void Subdivision::runVertexShader(GLuint size, GLuint vb_handle, GLuint vertex_indices_handle, GLuint vertex_offsets_handle, GLuint output_handle) { void Subdivision::runVertexShader(GLuint size, GLuint vb_handle, GLuint vertex_indices_handle, GLuint vertex_offsets_handle, GLuint output_handle, GLuint offset) {
vertexShader->bind(); vertexShader->bind();
f->glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, vb_handle); f->glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, vb_handle);
f->glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, vertex_indices_handle); f->glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, vertex_indices_handle);
f->glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, vertex_offsets_handle); f->glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, vertex_offsets_handle);
f->glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 3, output_handle); f->glBindBufferRange(GL_SHADER_STORAGE_BUFFER, 3, output_handle, offset * sizeof(Vertex), size * sizeof(Vertex));
// Run the shader // Run the shader
f->glDispatchCompute(size, 1, 1); f->glDispatchCompute(size, 1, 1);
......
...@@ -63,7 +63,7 @@ private: ...@@ -63,7 +63,7 @@ private:
void findRegular(QVector<unsigned int> index_buffer, QVector<Vertex> vertex_buffer, QVector<unsigned int> &regular, QVector<unsigned int> &irregular); 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); Result runShader(Input input, Tables &tables);
void runCopyShader(GLuint size, GLuint vb_in, GLuint vb_out); 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 runVertexShader(GLuint size, GLuint vb_handle, GLuint vertex_indices_handle, GLuint vertex_offsets_handle, GLuint output_handle, GLuint offset);
void runEdgeShader(GLuint size, GLuint vb_handle, GLuint edge_indices_handle, GLuint output_handle, GLuint offset); void runEdgeShader(GLuint size, GLuint vb_handle, GLuint edge_indices_handle, GLuint output_handle, GLuint offset);
QVector<unsigned int> patchIBToTriangleIB(QVector<unsigned int> ib); QVector<unsigned int> patchIBToTriangleIB(QVector<unsigned int> ib);
......
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