aboutsummaryrefslogtreecommitdiff
path: root/src/shader/wrap
diff options
context:
space:
mode:
Diffstat (limited to 'src/shader/wrap')
-rw-r--r--src/shader/wrap/compute_shader.cc12
-rw-r--r--src/shader/wrap/compute_shader.h3
2 files changed, 12 insertions, 3 deletions
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;
};