layers: Fix DrawState to correctly handle dynamic state from PSO and CmdSet* calls
authorTobin Ehlis <tobin@lunarg.com>
Thu, 1 Oct 2015 15:24:40 +0000 (09:24 -0600)
committerTobin Ehlis <tobin@lunarg.com>
Thu, 1 Oct 2015 16:11:10 +0000 (10:11 -0600)
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
layers/draw_state.h

index 30e4ade9456beae1699abfe01a2a425ed95f0316..646fff775ce879cf6aa0c678d5944f924a424221 100644 (file)
@@ -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
index c84eb2e77511cd1d21589e99ee67256cbb4c4ec7..8f583cecc79b65a0f03fb57898a2fe058a721a44 100644 (file)
@@ -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 {