layers: Invalidate old pipeline's static state when binding
authorChris Forbes <chrisforbes@google.com>
Tue, 15 Aug 2017 19:28:16 +0000 (12:28 -0700)
committerChris Forbes <chrisf@ijw.co.nz>
Wed, 16 Aug 2017 17:39:46 +0000 (10:39 -0700)
Previously we'd only ever or in new bits, causing us to miss cases where
some state changes from static to dynamic within a CB.

Also only fiddle with the state masks when binding a graphics pipeline
-- previously we'd miss some other cases because binding a compute
pipeline would set all the state bits.

layers/core_validation.cpp

index 2bd6b8a..855c132 100644 (file)
@@ -5130,10 +5130,18 @@ VKAPI_ATTR void VKAPI_CALL CmdBindPipeline(VkCommandBuffer commandBuffer, VkPipe
         }
         // TODO: VALIDATION_ERROR_18000612 VALIDATION_ERROR_18000616
 
-        PIPELINE_STATE *pipe_state = getPipelineState(dev_data, pipeline);
+        auto pipe_state = getPipelineState(dev_data, pipeline);
+        if (VK_PIPELINE_BIND_POINT_GRAPHICS == pipelineBindPoint) {
+            auto old_pipe_state = cb_state->lastBound[pipelineBindPoint].pipeline_state;
+            if (old_pipe_state) {
+                cb_state->status &= ~MakeStaticStateMask(old_pipe_state->graphicsPipelineCI.ptr()->pDynamicState);
+            }
+            if (pipe_state) {
+                cb_state->status |= MakeStaticStateMask(pipe_state->graphicsPipelineCI.ptr()->pDynamicState);
+            }
+        }
         if (pipe_state) {
             cb_state->lastBound[pipelineBindPoint].pipeline_state = pipe_state;
-            pCB->status |= MakeStaticStateMask(pipe_state->graphicsPipelineCI.ptr()->pDynamicState);
             set_pipeline_state(pipe_state);
             skip |= validate_dual_src_blend_feature(dev_data, pipe_state);
         } else {