From 05f110b996d231ada3cc548ee080a650a64bf66a Mon Sep 17 00:00:00 2001 From: Eric Mellino Date: Fri, 23 Mar 2018 23:59:08 -0700 Subject: [PATCH] [OpenGL] Don't forget the bound ResourceSets when a new Pipeline is set. --- src/Veldrid/OpenGL/OpenGLCommandExecutor.cs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/Veldrid/OpenGL/OpenGLCommandExecutor.cs b/src/Veldrid/OpenGL/OpenGLCommandExecutor.cs index 62144c89d..6857b8e0b 100644 --- a/src/Veldrid/OpenGL/OpenGLCommandExecutor.cs +++ b/src/Veldrid/OpenGL/OpenGLCommandExecutor.cs @@ -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 @@ -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();