Skip to content

Commit

Permalink
[OpenGL] Don't forget the bound ResourceSets when a new Pipeline is set.
Browse files Browse the repository at this point in the history
  • Loading branch information
mellinoe committed Mar 24, 2018
1 parent 6b9692e commit 05f110b
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/Veldrid/OpenGL/OpenGLCommandExecutor.cs
Expand Up @@ -350,7 +350,15 @@ private void ActivateGraphicsPipeline()
{
_graphicsPipelineActive = true;
_graphicsPipeline.EnsureResourcesCreated();
Util.ClearArray(_graphicsResourceSets); // Invalidate resource set bindings -- they may be invalid.

Util.EnsureArrayMinimumSize(ref _graphicsResourceSets, (uint)_graphicsPipeline.ResourceLayouts.Length);
Util.EnsureArrayMinimumSize(ref _newGraphicsResourceSets, (uint)_graphicsPipeline.ResourceLayouts.Length);

// Force ResourceSets to be re-bound.
for (int i = 0; i < _graphicsPipeline.ResourceLayouts.Length; i++)
{
_newGraphicsResourceSets[i] = true;
}

// Blend State

Expand Down Expand Up @@ -496,19 +504,21 @@ private void ActivateGraphicsPipeline()
totalVertexElements += (uint)_graphicsPipeline.VertexLayouts[i].Elements.Length;
}
Util.EnsureArrayMinimumSize(ref _vertexAttribDivisors, totalVertexElements);

Util.EnsureArrayMinimumSize(ref _graphicsResourceSets, (uint)_graphicsPipeline.ResourceLayouts.Length);
Util.EnsureArrayMinimumSize(ref _newGraphicsResourceSets, (uint)_graphicsPipeline.ResourceLayouts.Length);
}

private void ActivateComputePipeline()
{
_graphicsPipelineActive = false;
_computePipeline.EnsureResourcesCreated();
Util.ClearArray(_computeResourceSets); // Invalidate resource set bindings -- they may be invalid.
Util.EnsureArrayMinimumSize(ref _computeResourceSets, (uint)_computePipeline.ResourceLayouts.Length);
Util.EnsureArrayMinimumSize(ref _newComputeResourceSets, (uint)_computePipeline.ResourceLayouts.Length);

// Force ResourceSets to be re-bound.
for (int i = 0; i < _computePipeline.ResourceLayouts.Length; i++)
{
_newComputeResourceSets[i] = true;
}

// Shader Set
glUseProgram(_computePipeline.Program);
CheckLastError();
Expand Down

0 comments on commit 05f110b

Please sign in to comment.