diff options
author | Jason Ekstrand <[email protected]> | 2015-10-16 12:04:13 -0700 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2015-10-16 16:30:02 -0700 |
commit | 368e703a01c631f04f2a2a1f5f62f61c06838fae (patch) | |
tree | 222a6c3edbd795578db67c1232dc34f2145952e9 /src/vulkan/anv_pipeline.c | |
parent | 8ed23654c9f7fed77bc706fbfd1d25edf0d7020e (diff) |
anv/pipeline: Rework dynamic state handling
Aparently, we had the dynamic state array in the pipeline backwards.
Instead of enabling the bits in the pipeline, it disables them and marks
them as "dynamic".
Diffstat (limited to 'src/vulkan/anv_pipeline.c')
-rw-r--r-- | src/vulkan/anv_pipeline.c | 137 |
1 files changed, 64 insertions, 73 deletions
diff --git a/src/vulkan/anv_pipeline.c b/src/vulkan/anv_pipeline.c index 84e023c781a..c7f0e6b1b4b 100644 --- a/src/vulkan/anv_pipeline.c +++ b/src/vulkan/anv_pipeline.c @@ -181,92 +181,83 @@ static void anv_pipeline_init_dynamic_state(struct anv_pipeline *pipeline, const VkGraphicsPipelineCreateInfo *pCreateInfo) { - pipeline->dynamic_state_mask = 0; + uint32_t states = ANV_DYNAMIC_STATE_DIRTY_MASK; - if (pCreateInfo->pDynamicState == NULL) - return; + if (pCreateInfo->pDynamicState) { + /* Remove all of the states that are marked as dynamic */ + uint32_t count = pCreateInfo->pDynamicState->dynamicStateCount; + for (uint32_t s = 0; s < count; s++) + states &= ~(1 << pCreateInfo->pDynamicState->pDynamicStates[s]); + } - uint32_t count = pCreateInfo->pDynamicState->dynamicStateCount; struct anv_dynamic_state *dynamic = &pipeline->dynamic_state; - for (uint32_t s = 0; s < count; s++) { - VkDynamicState state = pCreateInfo->pDynamicState->pDynamicStates[s]; - - assert(state < 32); - pipeline->dynamic_state_mask |= (1u << state); - - switch (state) { - case VK_DYNAMIC_STATE_VIEWPORT: - assert(pCreateInfo->pViewportState); - dynamic->viewport.count = pCreateInfo->pViewportState->viewportCount; - typed_memcpy(dynamic->viewport.viewports, - pCreateInfo->pViewportState->pViewports, - pCreateInfo->pViewportState->viewportCount); - break; - - case VK_DYNAMIC_STATE_SCISSOR: - assert(pCreateInfo->pViewportState); - dynamic->scissor.count = pCreateInfo->pViewportState->scissorCount; - typed_memcpy(dynamic->scissor.scissors, - pCreateInfo->pViewportState->pScissors, - pCreateInfo->pViewportState->scissorCount); - break; + dynamic->viewport.count = pCreateInfo->pViewportState->viewportCount; + if (states & (1 << VK_DYNAMIC_STATE_VIEWPORT)) { + typed_memcpy(dynamic->viewport.viewports, + pCreateInfo->pViewportState->pViewports, + pCreateInfo->pViewportState->viewportCount); + } - case VK_DYNAMIC_STATE_LINE_WIDTH: - assert(pCreateInfo->pRasterState); - dynamic->line_width = pCreateInfo->pRasterState->lineWidth; - break; + dynamic->scissor.count = pCreateInfo->pViewportState->scissorCount; + if (states & (1 << VK_DYNAMIC_STATE_SCISSOR)) { + typed_memcpy(dynamic->scissor.scissors, + pCreateInfo->pViewportState->pScissors, + pCreateInfo->pViewportState->scissorCount); + } - case VK_DYNAMIC_STATE_DEPTH_BIAS: - assert(pCreateInfo->pRasterState); - dynamic->depth_bias.bias = pCreateInfo->pRasterState->depthBias; - dynamic->depth_bias.clamp = pCreateInfo->pRasterState->depthBiasClamp; - dynamic->depth_bias.slope_scaled = - pCreateInfo->pRasterState->slopeScaledDepthBias; - break; + if (states & (1 << VK_DYNAMIC_STATE_LINE_WIDTH)) { + assert(pCreateInfo->pRasterState); + dynamic->line_width = pCreateInfo->pRasterState->lineWidth; + } - case VK_DYNAMIC_STATE_BLEND_CONSTANTS: - assert(pCreateInfo->pColorBlendState); - typed_memcpy(dynamic->blend_constants, - pCreateInfo->pColorBlendState->blendConst, 4); - break; + if (states & (1 << VK_DYNAMIC_STATE_DEPTH_BIAS)) { + assert(pCreateInfo->pRasterState); + dynamic->depth_bias.bias = pCreateInfo->pRasterState->depthBias; + dynamic->depth_bias.clamp = pCreateInfo->pRasterState->depthBiasClamp; + dynamic->depth_bias.slope_scaled = + pCreateInfo->pRasterState->slopeScaledDepthBias; + } - case VK_DYNAMIC_STATE_DEPTH_BOUNDS: - assert(pCreateInfo->pDepthStencilState); - dynamic->depth_bounds.min = - pCreateInfo->pDepthStencilState->minDepthBounds; - dynamic->depth_bounds.max = - pCreateInfo->pDepthStencilState->maxDepthBounds; - break; + if (states & (1 << VK_DYNAMIC_STATE_BLEND_CONSTANTS)) { + assert(pCreateInfo->pColorBlendState); + typed_memcpy(dynamic->blend_constants, + pCreateInfo->pColorBlendState->blendConst, 4); + } - case VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK: - assert(pCreateInfo->pDepthStencilState); - dynamic->stencil_compare_mask.front = - pCreateInfo->pDepthStencilState->front.stencilCompareMask; - dynamic->stencil_compare_mask.back = - pCreateInfo->pDepthStencilState->back.stencilCompareMask; - break; + if (states & (1 << VK_DYNAMIC_STATE_DEPTH_BOUNDS)) { + assert(pCreateInfo->pDepthStencilState); + dynamic->depth_bounds.min = + pCreateInfo->pDepthStencilState->minDepthBounds; + dynamic->depth_bounds.max = + pCreateInfo->pDepthStencilState->maxDepthBounds; + } - case VK_DYNAMIC_STATE_STENCIL_WRITE_MASK: - assert(pCreateInfo->pDepthStencilState); - dynamic->stencil_write_mask.front = - pCreateInfo->pDepthStencilState->front.stencilWriteMask; - dynamic->stencil_write_mask.back = - pCreateInfo->pDepthStencilState->back.stencilWriteMask; - break; + if (states & (1 << VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK)) { + assert(pCreateInfo->pDepthStencilState); + dynamic->stencil_compare_mask.front = + pCreateInfo->pDepthStencilState->front.stencilCompareMask; + dynamic->stencil_compare_mask.back = + pCreateInfo->pDepthStencilState->back.stencilCompareMask; + } - case VK_DYNAMIC_STATE_STENCIL_REFERENCE: - assert(pCreateInfo->pDepthStencilState); - dynamic->stencil_reference.front = - pCreateInfo->pDepthStencilState->front.stencilReference; - dynamic->stencil_reference.back = - pCreateInfo->pDepthStencilState->back.stencilReference; - break; + if (states & (1 << VK_DYNAMIC_STATE_STENCIL_WRITE_MASK)) { + assert(pCreateInfo->pDepthStencilState); + dynamic->stencil_write_mask.front = + pCreateInfo->pDepthStencilState->front.stencilWriteMask; + dynamic->stencil_write_mask.back = + pCreateInfo->pDepthStencilState->back.stencilWriteMask; + } - default: - assert(!"Invalid dynamic state"); - } + if (states & (1 << VK_DYNAMIC_STATE_STENCIL_REFERENCE)) { + assert(pCreateInfo->pDepthStencilState); + dynamic->stencil_reference.front = + pCreateInfo->pDepthStencilState->front.stencilReference; + dynamic->stencil_reference.back = + pCreateInfo->pDepthStencilState->back.stencilReference; } + + pipeline->dynamic_state_mask = states; } VkResult |