diff options
author | Jason Ekstrand <[email protected]> | 2015-07-14 14:26:10 -0700 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2015-07-14 14:26:10 -0700 |
commit | 30445f8f7a27b80cb344343dc193b5276fc1e1ca (patch) | |
tree | 2817423bc626d0ed7da8d16b893c29db7f4f6cde | |
parent | d2c0870ff319665871d019e2edbcb831f02a9391 (diff) |
vk: Split the dynamic state binding function into one per state
-rw-r--r-- | include/vulkan/vulkan.h | 33 | ||||
-rw-r--r-- | src/vulkan/device.c | 61 | ||||
-rw-r--r-- | src/vulkan/meta.c | 41 |
3 files changed, 72 insertions, 63 deletions
diff --git a/include/vulkan/vulkan.h b/include/vulkan/vulkan.h index 2a1e484cd8e..a2410d1ff5c 100644 --- a/include/vulkan/vulkan.h +++ b/include/vulkan/vulkan.h @@ -832,17 +832,6 @@ typedef enum { } VkCmdBufferLevel; typedef enum { - VK_STATE_BIND_POINT_VIEWPORT = 0, - VK_STATE_BIND_POINT_RASTER = 1, - VK_STATE_BIND_POINT_COLOR_BLEND = 2, - VK_STATE_BIND_POINT_DEPTH_STENCIL = 3, - VK_STATE_BIND_POINT_BEGIN_RANGE = VK_STATE_BIND_POINT_VIEWPORT, - VK_STATE_BIND_POINT_END_RANGE = VK_STATE_BIND_POINT_DEPTH_STENCIL, - VK_STATE_BIND_POINT_NUM = (VK_STATE_BIND_POINT_DEPTH_STENCIL - VK_STATE_BIND_POINT_VIEWPORT + 1), - VK_STATE_BIND_POINT_MAX_ENUM = 0x7FFFFFFF -} VkStateBindPoint; - -typedef enum { VK_INDEX_TYPE_UINT16 = 0, VK_INDEX_TYPE_UINT32 = 1, VK_INDEX_TYPE_BEGIN_RANGE = VK_INDEX_TYPE_UINT16, @@ -2118,7 +2107,10 @@ typedef VkResult (VKAPI *PFN_vkBeginCommandBuffer)(VkCmdBuffer cmdBuffer, const typedef VkResult (VKAPI *PFN_vkEndCommandBuffer)(VkCmdBuffer cmdBuffer); typedef VkResult (VKAPI *PFN_vkResetCommandBuffer)(VkCmdBuffer cmdBuffer); typedef void (VKAPI *PFN_vkCmdBindPipeline)(VkCmdBuffer cmdBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline); -typedef void (VKAPI *PFN_vkCmdBindDynamicStateObject)(VkCmdBuffer cmdBuffer, VkStateBindPoint stateBindPoint, VkDynamicStateObject dynamicState); +typedef void (VKAPI *PFN_vkCmdBindDynamicViewportState)(VkCmdBuffer cmdBuffer, VkDynamicViewportState dynamicViewportState); +typedef void (VKAPI *PFN_vkCmdBindDynamicRasterState)(VkCmdBuffer cmdBuffer, VkDynamicRasterState dynamicRasterState); +typedef void (VKAPI *PFN_vkCmdBindDynamicColorBlendState)(VkCmdBuffer cmdBuffer, VkDynamicColorBlendState dynamicColorBlendState); +typedef void (VKAPI *PFN_vkCmdBindDynamicDepthStencilState)(VkCmdBuffer cmdBuffer, VkDynamicDepthStencilState dynamicDepthStencilState); typedef void (VKAPI *PFN_vkCmdBindDescriptorSets)(VkCmdBuffer cmdBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, uint32_t firstSet, uint32_t setCount, const VkDescriptorSet* pDescriptorSets, uint32_t dynamicOffsetCount, const uint32_t* pDynamicOffsets); typedef void (VKAPI *PFN_vkCmdBindIndexBuffer)(VkCmdBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset, VkIndexType indexType); typedef void (VKAPI *PFN_vkCmdBindVertexBuffers)(VkCmdBuffer cmdBuffer, uint32_t startBinding, uint32_t bindingCount, const VkBuffer* pBuffers, const VkDeviceSize* pOffsets); @@ -2652,10 +2644,21 @@ void VKAPI vkCmdBindPipeline( VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline); -void VKAPI vkCmdBindDynamicStateObject( +void VKAPI vkCmdBindDynamicViewportState( + VkCmdBuffer cmdBuffer, + VkDynamicViewportState dynamicViewportState); + +void VKAPI vkCmdBindDynamicRasterState( + VkCmdBuffer cmdBuffer, + VkDynamicRasterState dynamicRasterState); + +void VKAPI vkCmdBindDynamicColorBlendState( + VkCmdBuffer cmdBuffer, + VkDynamicColorBlendState dynamicColorBlendState); + +void VKAPI vkCmdBindDynamicDepthStencilState( VkCmdBuffer cmdBuffer, - VkStateBindPoint stateBindPoint, - VkDynamicStateObject dynamicState); + VkDynamicDepthStencilState dynamicDepthStencilState); void VKAPI vkCmdBindDescriptorSets( VkCmdBuffer cmdBuffer, diff --git a/src/vulkan/device.c b/src/vulkan/device.c index 90ac956c040..d29e35ba20c 100644 --- a/src/vulkan/device.c +++ b/src/vulkan/device.c @@ -2882,33 +2882,48 @@ void anv_CmdBindPipeline( } } -void anv_CmdBindDynamicStateObject( +void anv_CmdBindDynamicViewportState( VkCmdBuffer cmdBuffer, - VkStateBindPoint stateBindPoint, - VkDynamicStateObject dynamicState) + VkDynamicViewportState dynamicViewportState) { ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, cmdBuffer); + ANV_FROM_HANDLE(anv_dynamic_vp_state, vp_state, dynamicViewportState); - switch (stateBindPoint) { - case VK_STATE_BIND_POINT_VIEWPORT: - cmd_buffer->vp_state = anv_dynamic_vp_state_from_handle(dynamicState); - cmd_buffer->dirty |= ANV_CMD_BUFFER_VP_DIRTY; - break; - case VK_STATE_BIND_POINT_RASTER: - cmd_buffer->rs_state = anv_dynamic_rs_state_from_handle(dynamicState); - cmd_buffer->dirty |= ANV_CMD_BUFFER_RS_DIRTY; - break; - case VK_STATE_BIND_POINT_COLOR_BLEND: - cmd_buffer->cb_state = anv_dynamic_cb_state_from_handle(dynamicState); - cmd_buffer->dirty |= ANV_CMD_BUFFER_CB_DIRTY; - break; - case VK_STATE_BIND_POINT_DEPTH_STENCIL: - cmd_buffer->ds_state = anv_dynamic_ds_state_from_handle(dynamicState); - cmd_buffer->dirty |= ANV_CMD_BUFFER_DS_DIRTY; - break; - default: - break; - }; + cmd_buffer->vp_state = vp_state; + cmd_buffer->dirty |= ANV_CMD_BUFFER_VP_DIRTY; +} + +void anv_CmdBindDynamicRasterState( + VkCmdBuffer cmdBuffer, + VkDynamicRasterState dynamicRasterState) +{ + ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, cmdBuffer); + ANV_FROM_HANDLE(anv_dynamic_rs_state, rs_state, dynamicRasterState); + + cmd_buffer->rs_state = rs_state; + cmd_buffer->dirty |= ANV_CMD_BUFFER_RS_DIRTY; +} + +void anv_CmdBindDynamicColorBlendState( + VkCmdBuffer cmdBuffer, + VkDynamicColorBlendState dynamicColorBlendState) +{ + ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, cmdBuffer); + ANV_FROM_HANDLE(anv_dynamic_cb_state, cb_state, dynamicColorBlendState); + + cmd_buffer->cb_state = cb_state; + cmd_buffer->dirty |= ANV_CMD_BUFFER_CB_DIRTY; +} + +void anv_CmdBindDynamicDepthStencilState( + VkCmdBuffer cmdBuffer, + VkDynamicDepthStencilState dynamicDepthStencilState) +{ + ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, cmdBuffer); + ANV_FROM_HANDLE(anv_dynamic_ds_state, ds_state, dynamicDepthStencilState); + + cmd_buffer->ds_state = ds_state; + cmd_buffer->dirty |= ANV_CMD_BUFFER_DS_DIRTY; } static struct anv_state diff --git a/src/vulkan/meta.c b/src/vulkan/meta.c index 0844565a996..140b6418377 100644 --- a/src/vulkan/meta.c +++ b/src/vulkan/meta.c @@ -240,24 +240,20 @@ meta_emit_clear(struct anv_cmd_buffer *cmd_buffer, /* We don't need anything here, only set if not already set. */ if (cmd_buffer->rs_state == NULL) - anv_CmdBindDynamicStateObject(anv_cmd_buffer_to_handle(cmd_buffer), - VK_STATE_BIND_POINT_RASTER, + anv_CmdBindDynamicRasterState(anv_cmd_buffer_to_handle(cmd_buffer), device->meta_state.shared.rs_state); if (cmd_buffer->vp_state == NULL) - anv_CmdBindDynamicStateObject(anv_cmd_buffer_to_handle(cmd_buffer), - VK_STATE_BIND_POINT_VIEWPORT, - cmd_buffer->framebuffer->vp_state); + anv_CmdBindDynamicViewportState(anv_cmd_buffer_to_handle(cmd_buffer), + cmd_buffer->framebuffer->vp_state); if (cmd_buffer->ds_state == NULL) - anv_CmdBindDynamicStateObject(anv_cmd_buffer_to_handle(cmd_buffer), - VK_STATE_BIND_POINT_DEPTH_STENCIL, - device->meta_state.shared.ds_state); + anv_CmdBindDynamicDepthStencilState(anv_cmd_buffer_to_handle(cmd_buffer), + device->meta_state.shared.ds_state); if (cmd_buffer->cb_state == NULL) - anv_CmdBindDynamicStateObject(anv_cmd_buffer_to_handle(cmd_buffer), - VK_STATE_BIND_POINT_COLOR_BLEND, - device->meta_state.shared.cb_state); + anv_CmdBindDynamicColorBlendState(anv_cmd_buffer_to_handle(cmd_buffer), + device->meta_state.shared.cb_state); anv_CmdDraw(anv_cmd_buffer_to_handle(cmd_buffer), 0, 3, 0, num_instances); } @@ -499,18 +495,15 @@ meta_prepare_blit(struct anv_cmd_buffer *cmd_buffer, /* We don't need anything here, only set if not already set. */ if (cmd_buffer->rs_state == NULL) - anv_CmdBindDynamicStateObject(anv_cmd_buffer_to_handle(cmd_buffer), - VK_STATE_BIND_POINT_RASTER, + anv_CmdBindDynamicRasterState(anv_cmd_buffer_to_handle(cmd_buffer), device->meta_state.shared.rs_state); if (cmd_buffer->ds_state == NULL) - anv_CmdBindDynamicStateObject(anv_cmd_buffer_to_handle(cmd_buffer), - VK_STATE_BIND_POINT_DEPTH_STENCIL, - device->meta_state.shared.ds_state); + anv_CmdBindDynamicDepthStencilState(anv_cmd_buffer_to_handle(cmd_buffer), + device->meta_state.shared.ds_state); saved_state->cb_state = anv_dynamic_cb_state_to_handle(cmd_buffer->cb_state); - anv_CmdBindDynamicStateObject(anv_cmd_buffer_to_handle(cmd_buffer), - VK_STATE_BIND_POINT_COLOR_BLEND, - device->meta_state.shared.cb_state); + anv_CmdBindDynamicColorBlendState(anv_cmd_buffer_to_handle(cmd_buffer), + device->meta_state.shared.cb_state); } struct blit_region { @@ -683,9 +676,8 @@ meta_emit_blit(struct anv_cmd_buffer *cmd_buffer, .pAttachmentClearValues = NULL, }, VK_RENDER_PASS_CONTENTS_INLINE); - anv_CmdBindDynamicStateObject(anv_cmd_buffer_to_handle(cmd_buffer), - VK_STATE_BIND_POINT_VIEWPORT, - anv_framebuffer_from_handle(fb)->vp_state); + anv_CmdBindDynamicViewportState(anv_cmd_buffer_to_handle(cmd_buffer), + anv_framebuffer_from_handle(fb)->vp_state); anv_CmdBindDescriptorSets(anv_cmd_buffer_to_handle(cmd_buffer), VK_PIPELINE_BIND_POINT_GRAPHICS, @@ -712,9 +704,8 @@ meta_finish_blit(struct anv_cmd_buffer *cmd_buffer, const struct anv_saved_state *saved_state) { anv_cmd_buffer_restore(cmd_buffer, saved_state); - anv_CmdBindDynamicStateObject(anv_cmd_buffer_to_handle(cmd_buffer), - VK_STATE_BIND_POINT_COLOR_BLEND, - saved_state->cb_state); + anv_CmdBindDynamicColorBlendState(anv_cmd_buffer_to_handle(cmd_buffer), + saved_state->cb_state); } static VkFormat |