Skip to content

Commit

Permalink
igl | opengl : fix IGL_VERTEX_BUFFER_MAX usage
Browse files Browse the repository at this point in the history
Reviewed By: EricGriffith, corporateshark, rameshviswanathan

Differential Revision: D66681480

fbshipit-source-id: 92bdd1ebd3355291a3929d3455a0b84d1551a9fb
  • Loading branch information
Dev Mannemela authored and facebook-github-bot committed Dec 9, 2024
1 parent ea29724 commit fca4dbf
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/igl/opengl/RenderCommandAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ void RenderCommandAdapter::setVertexBuffer(Buffer& buffer,
size_t offset,
size_t index,
Result* outResult) {
IGL_DEBUG_ASSERT(index < IGL_VERTEX_BUFFER_MAX,
IGL_DEBUG_ASSERT(index < IGL_BUFFER_BINDINGS_MAX,
"Buffer index is beyond max, may want to increase limit");
if (index < IGL_VERTEX_BUFFER_MAX) {
if (index < IGL_BUFFER_BINDINGS_MAX) {
vertexBuffers_[index] = {&buffer, offset};
SET_DIRTY(vertexBuffersDirty_, index);
Result::setOk(outResult);
Expand Down Expand Up @@ -343,7 +343,7 @@ void RenderCommandAdapter::willDraw() {
// Vertex Buffers must be bound before pipelineState->bind()
if (pipelineState) {
pipelineState->clearActiveAttributesLocations();
for (size_t bufferIndex = 0; bufferIndex < IGL_VERTEX_BUFFER_MAX; ++bufferIndex) {
for (size_t bufferIndex = 0; bufferIndex < IGL_BUFFER_BINDINGS_MAX; ++bufferIndex) {
if (IS_DIRTY(vertexBuffersDirty_, bufferIndex)) {
auto& bufferState = vertexBuffers_[bufferIndex];
bindBufferWithShaderStorageBufferOverride((*bufferState.resource), GL_ARRAY_BUFFER);
Expand Down
4 changes: 2 additions & 2 deletions src/igl/opengl/RenderCommandAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ class RenderCommandAdapter final : public WithContext {
[[nodiscard]] GLenum toMockWireframeMode(GLenum mode) const;

private:
std::array<BufferState, IGL_VERTEX_BUFFER_MAX> vertexBuffers_;
std::bitset<IGL_VERTEX_BUFFER_MAX> vertexBuffersDirty_;
std::array<BufferState, IGL_BUFFER_BINDINGS_MAX> vertexBuffers_;
std::bitset<IGL_BUFFER_BINDINGS_MAX> vertexBuffersDirty_;
std::bitset<IGL_TEXTURE_SAMPLERS_MAX> vertexTextureStatesDirty_;
std::bitset<IGL_TEXTURE_SAMPLERS_MAX> fragmentTextureStatesDirty_;
TextureStates vertexTextureStates_;
Expand Down
4 changes: 2 additions & 2 deletions src/igl/opengl/RenderPipelineState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ Result RenderPipelineState::create() {
if (loc < 0) {
IGL_LOG_ERROR("Vertex attribute (%s) not found in shader.", attrib.name.c_str());
}
IGL_DEBUG_ASSERT(index < IGL_VERTEX_BUFFER_MAX);
if (index < IGL_VERTEX_BUFFER_MAX) {
IGL_DEBUG_ASSERT(index < IGL_BUFFER_BINDINGS_MAX);
if (index < IGL_BUFFER_BINDINGS_MAX) {
bufferAttribLocations_[index].push_back(loc);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/igl/opengl/RenderPipelineState.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class RenderPipelineState final : public WithContext, public IRenderPipelineStat

private:
// Tracks a list of attribute locations associated with a bufferIndex
std::vector<int> bufferAttribLocations_[IGL_VERTEX_BUFFER_MAX];
std::vector<int> bufferAttribLocations_[IGL_BUFFER_BINDINGS_MAX];

std::shared_ptr<RenderPipelineReflection> reflection_;
std::unordered_map<size_t, size_t> vertexTextureUnitRemap;
Expand Down

0 comments on commit fca4dbf

Please sign in to comment.