From 2eb7f9925315989735b4fb746cbd7bda6c9bd5bb Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Sun, 16 Dec 2018 13:58:20 +0100 Subject: Parametrize lattice resolution --- src/shader/wrap/compute_shader.cc | 12 ++++++++++-- src/shader/wrap/compute_shader.h | 3 ++- 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'src/shader/wrap') diff --git a/src/shader/wrap/compute_shader.cc b/src/shader/wrap/compute_shader.cc index c90c370..ab5d4c4 100644 --- a/src/shader/wrap/compute_shader.cc +++ b/src/shader/wrap/compute_shader.cc @@ -40,12 +40,20 @@ GLuint ComputeShader::setUniform(const std::string& name, float x, float y) cons return id; } +GLuint ComputeShader::setUniform(const std::string& name, unsigned int value) const { + GLuint id = util::getUniform(_id, name); + glUniform1ui(id, value); + return id; +} + void ComputeShader::workOn(GLuint bufferA, GLuint bufferB, GLuint bufferC) const { glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, bufferA); glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, bufferB); glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 3, bufferC); } -void ComputeShader::dispatch() const { - glDispatchCompute(128, 128, 1); +void ComputeShader::dispatch(GLuint nX, GLuint nY) const { + setUniform("nX", nX); + setUniform("nY", nY); + glDispatchCompute(nX, nY, 1); } diff --git a/src/shader/wrap/compute_shader.h b/src/shader/wrap/compute_shader.h index 74c8270..816b925 100644 --- a/src/shader/wrap/compute_shader.h +++ b/src/shader/wrap/compute_shader.h @@ -26,7 +26,8 @@ public: bool isGood() const; GLuint setUniform(const std::string& name, float x, float y) const; + GLuint setUniform(const std::string& name, unsigned int value) const; void workOn(GLuint bufferA, GLuint bufferB, GLuint bufferC) const; - void dispatch() const; + void dispatch(GLuint nX, GLuint nY) const; }; -- cgit v1.2.3