Skip to content

Commit

Permalink
ShaderUniforms utility for checking if a certain interface block me…
Browse files Browse the repository at this point in the history
…mber exists

Summary: Utility for checking if a certain interface block member exists

Reviewed By: syeh1

Differential Revision: D48415067

fbshipit-source-id: db989b41f9c361aef7f6d6f23c1434432fecb513
  • Loading branch information
AmesingFlank authored and facebook-github-bot committed Aug 21, 2023
1 parent 90f3ffe commit fd91f8f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
13 changes: 13 additions & 0 deletions IGLU/simple_renderer/ShaderUniforms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -910,4 +910,17 @@ igl::Result ShaderUniforms::setSuballocationIndex(const igl::NameHandle& name, i
"Could not update suballocation index for " + name.toString());
}
}

bool ShaderUniforms::containsUniform(const igl::NameHandle& blockTypeName,
const igl::NameHandle& blockInstanceName,
const igl::NameHandle& memberName) {
auto bufferName = getBufferName(blockTypeName, blockInstanceName, memberName);
auto bufferDescIt = _bufferDescs.find(bufferName);
if (bufferDescIt == _bufferDescs.end()) {
return false;
}
auto& bufferDesc = bufferDescIt->second;
auto bufferMemberName = getBufferMemberName(blockTypeName, blockInstanceName, memberName);
return bufferDesc->memberIndices.find(bufferMemberName) != bufferDesc->memberIndices.end();
}
} // namespace iglu::material
4 changes: 4 additions & 0 deletions IGLU/simple_renderer/ShaderUniforms.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ class ShaderUniforms final {
return _allUniformsByName.count(uniformName) > 0;
}

bool containsUniform(const igl::NameHandle& blockTypeName,
const igl::NameHandle& blockInstanceName,
const igl::NameHandle& memberName);

static igl::NameHandle getQualifiedMemberName(const igl::NameHandle& blockTypeName,
const igl::NameHandle& blockInstanceName,
const igl::NameHandle& memberName);
Expand Down

0 comments on commit fd91f8f

Please sign in to comment.