Skip to content

Commit

Permalink
Add reporting if uniform block in not found by binding index
Browse files Browse the repository at this point in the history
Summary: `at(0)` can raise exception if exceptions are enabled, otherwise result is undefined.

Reviewed By: francoiscoulombe

Differential Revision: D49685003

fbshipit-source-id: 6f72ecde3b1825492ded3ff0c69eb1a8ff5eda71
  • Loading branch information
Roman Kuznetsov authored and facebook-github-bot committed Sep 27, 2023
1 parent 71f5789 commit e6a0d2f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/igl/opengl/RenderPipelineState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ Result RenderPipelineState::create(const RenderPipelineDesc& desc) {
if (blockIndex >= 0) {
uniformBlockBindingMap_[blockIndex] = bindingIndex;
} else {
IGL_LOG_ERROR("uniform block (%s) not found in shader.\n", blockName.toConstChar());
IGL_LOG_ERROR("Uniform block (%s) not found in shader.\n", blockName.toConstChar());
}
}

Expand Down Expand Up @@ -364,7 +364,14 @@ int RenderPipelineState::getIndexByName(const std::string& name, ShaderStage /*s

int RenderPipelineState::getUniformBlockBindingPoint(const NameHandle& uniformBlockName) const {
const int blockIndex = getIndexByName(uniformBlockName, ShaderStage::Fragment);
return uniformBlockBindingMap_.at(blockIndex);
auto it = uniformBlockBindingMap_.find(blockIndex);
if (it == uniformBlockBindingMap_.end()) {
IGL_LOG_ERROR("Uniform block (%s) with index (%d) not found in the block binding map.\n",
uniformBlockName.toConstChar(),
blockIndex);
return -1;
}
return it->second;
}

std::shared_ptr<IRenderPipelineReflection> RenderPipelineState::renderPipelineReflection() {
Expand Down

0 comments on commit e6a0d2f

Please sign in to comment.