From cf76ad166e14c1bdc24aa2d9051d0a0e0c90ae86 Mon Sep 17 00:00:00 2001 From: Tobin Ehlis Date: Thu, 1 Oct 2015 09:24:40 -0600 Subject: layers: Fix DrawState to correctly handle dynamic state from PSO and CmdSet* calls Track which dynamic states are set via PSO and merge that with dynamic state set by CmdSet* cmds. Updated viewport not set test to pass when scissor is flagged as missing. Currently scissor and viewport set together so scissor error masks viewport error. --- layers/draw_state.cpp | 25 +++++++++++++++---------- layers/draw_state.h | 1 + 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/layers/draw_state.cpp b/layers/draw_state.cpp index 30e4ade9..646fff77 100644 --- a/layers/draw_state.cpp +++ b/layers/draw_state.cpp @@ -1151,41 +1151,46 @@ static void set_cb_pso_status(GLOBAL_CB_NODE* pCB, const PIPELINE_NODE* pPipe) pCB->status |= CBSTATUS_STENCIL_TEST_ENABLE; } if (pPipe->dynStateCI.dynamicStateCount) { - // Account for any dynamic state set via this PSO + // Account for any dynamic state not set via this PSO + // First consider all state on + // Then unset any state that's noted as dynamic in PSO + // Finally OR that into CB statemask + CBStatusFlags psoDynStateMask = CBSTATUS_ALL; for (uint32_t i=0; i < pPipe->dynStateCI.dynamicStateCount; i++) { switch (pPipe->dynStateCI.pDynamicStates[i]) { case VK_DYNAMIC_STATE_VIEWPORT: - pCB->status |= CBSTATUS_VIEWPORT_SET; + psoDynStateMask &= ~CBSTATUS_VIEWPORT_SET; break; case VK_DYNAMIC_STATE_SCISSOR: - pCB->status |= CBSTATUS_SCISSOR_SET; + psoDynStateMask &= ~CBSTATUS_SCISSOR_SET; break; case VK_DYNAMIC_STATE_LINE_WIDTH: - pCB->status |= CBSTATUS_LINE_WIDTH_SET; + psoDynStateMask &= ~CBSTATUS_LINE_WIDTH_SET; break; case VK_DYNAMIC_STATE_DEPTH_BIAS: - pCB->status |= CBSTATUS_DEPTH_BIAS_SET; + psoDynStateMask &= ~CBSTATUS_DEPTH_BIAS_SET; break; case VK_DYNAMIC_STATE_BLEND_CONSTANTS: - pCB->status |= CBSTATUS_BLEND_SET; + psoDynStateMask &= ~CBSTATUS_BLEND_SET; break; case VK_DYNAMIC_STATE_DEPTH_BOUNDS: - pCB->status |= CBSTATUS_DEPTH_BOUNDS_SET; + psoDynStateMask &= ~CBSTATUS_DEPTH_BOUNDS_SET; break; case VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK: - pCB->status |= CBSTATUS_STENCIL_READ_MASK_SET; + psoDynStateMask &= ~CBSTATUS_STENCIL_READ_MASK_SET; break; case VK_DYNAMIC_STATE_STENCIL_WRITE_MASK: - pCB->status |= CBSTATUS_STENCIL_WRITE_MASK_SET; + psoDynStateMask &= ~CBSTATUS_STENCIL_WRITE_MASK_SET; break; case VK_DYNAMIC_STATE_STENCIL_REFERENCE: - pCB->status |= CBSTATUS_STENCIL_REFERENCE_SET; + psoDynStateMask &= ~CBSTATUS_STENCIL_REFERENCE_SET; break; default: // TODO : Flag error here break; } } + pCB->status |= psoDynStateMask; } } // Print the last bound Gfx Pipeline diff --git a/layers/draw_state.h b/layers/draw_state.h index c84eb2e7..8f583cec 100644 --- a/layers/draw_state.h +++ b/layers/draw_state.h @@ -246,6 +246,7 @@ typedef enum _CBStatusFlagBits CBSTATUS_STENCIL_REFERENCE_SET = 0x00000400, // Stencil reference has been set CBSTATUS_INDEX_BUFFER_BOUND = 0x00000800, // Index buffer has been set CBSTATUS_SCISSOR_SET = 0x00001000, // Scissor has been set + CBSTATUS_ALL = 0x00001FFF, // All dynamic state set } CBStatusFlagBits; typedef struct stencil_data { -- cgit v1.2.3