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 | Fix memory leak in RenderPipelineState::activeAttributesLocations_ #187

Closed
wants to merge 4 commits into from
Closed
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
11 changes: 6 additions & 5 deletions src/igl/opengl/RenderCommandAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,11 @@ void RenderCommandAdapter::clearDependentResources(
clearFragmentTexture();
}

if (!newStateOpenGL || !curStateOpenGL->matchesVertexInputState(*newStateOpenGL)) {
// We do need to clear vertex attributes, when pipelinestate is modified.
// If we don't, subsequent draw calls might try to read from these locations
// and crashes might happen.
unbindVertexAttributes();
if (curStateOpenGL && newStateOpenGL){
newStateOpenGL->savePrevPipelineStateAttributesLocations(*curStateOpenGL);
}

if (!newStateOpenGL || !curStateOpenGL->matchesVertexInputState(*newStateOpenGL)) {
// Don't reuse previously set vertex buffers.
clearVertexBuffers();
}
Expand Down Expand Up @@ -343,6 +342,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) {
if (IS_DIRTY(vertexBuffersDirty_, bufferIndex)) {
auto& bufferState = vertexBuffers_[bufferIndex];
Expand All @@ -352,6 +352,7 @@ void RenderCommandAdapter::willDraw() {
CLEAR_DIRTY(vertexBuffersDirty_, bufferIndex);
}
}
pipelineState->unbindPrevPipelineVertexAttributes();
if (isDirty(StateMask::PIPELINE)) {
pipelineState->bind();
clearDirty(StateMask::PIPELINE);
Expand Down
Loading