Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

igl | opengl | The glUniformBlockBinding() function only needs to be called once for each program #190

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions src/igl/opengl/RenderPipelineState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,13 @@ void RenderPipelineState::bind() {
if (desc_.shaderStages) {
const auto& shaderStages = std::static_pointer_cast<ShaderStages>(desc_.shaderStages);
shaderStages->bind();
for (const auto& binding : uniformBlockBindingMap_) {
const auto& blockIndex = binding.first;
const auto& bindingIndex = binding.second;
getContext().uniformBlockBinding(shaderStages->getProgramID(), blockIndex, bindingIndex);
if (!uniformBlockBindingPointSet_){
for (const auto& binding : uniformBlockBindingMap_) {
const auto& blockIndex = binding.first;
const auto& bindingIndex = binding.second;
getContext().uniformBlockBinding(shaderStages->getProgramID(), blockIndex, bindingIndex);
}
uniformBlockBindingPointSet_ = true;
}
}

Expand Down Expand Up @@ -389,8 +392,4 @@ void RenderPipelineState::setRenderPipelineReflection(
(void)renderPipelineReflection;
}

std::unordered_map<int, size_t>& RenderPipelineState::uniformBlockBindingMap() {
return uniformBlockBindingMap_;
}

} // namespace igl::opengl
3 changes: 1 addition & 2 deletions src/igl/opengl/RenderPipelineState.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ class RenderPipelineState final : public WithContext, public IRenderPipelineStat
return desc_.polygonFillMode;
}

std::unordered_map<int, size_t>& uniformBlockBindingMap();

const ShaderStages* getShaderStages() const {
return static_cast<ShaderStages*>(desc_.shaderStages.get());
}
Expand All @@ -87,6 +85,7 @@ class RenderPipelineState final : public WithContext, public IRenderPipelineStat
std::vector<int> activeAttributesLocations_;
BlendMode blendMode_ = {GL_FUNC_ADD, GL_FUNC_ADD, GL_ONE, GL_ZERO, GL_ONE, GL_ZERO};
bool blendEnabled_ = false;
bool uniformBlockBindingPointSet_ = false;
};

} // namespace igl::opengl