diff options
author | Jason Ekstrand <[email protected]> | 2017-12-15 13:47:53 -0800 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2018-01-23 21:10:30 -0800 |
commit | b9e1ca16f84016f1d40efa9bfee89db48a7702b4 (patch) | |
tree | 8552722de56c88e7a192a867c160177e4c6937b6 | |
parent | 90cceaa9dd3b12e039a131a50c6866dce04e7fb2 (diff) |
anv/cmd_buffer: Add a helper for binding descriptor sets
This lets us unify some code between push descriptors and regular
descriptors. It doesn't do much for us yet but it will.
Tested-by: Józef Kucia <[email protected]>
Reviewed-by: Topi Pohjolainen <[email protected]>
Cc: "18.0" <[email protected]>
-rw-r--r-- | src/intel/vulkan/anv_cmd_buffer.c | 70 |
1 files changed, 42 insertions, 28 deletions
diff --git a/src/intel/vulkan/anv_cmd_buffer.c b/src/intel/vulkan/anv_cmd_buffer.c index e5366fd95c0..636f5150f22 100644 --- a/src/intel/vulkan/anv_cmd_buffer.c +++ b/src/intel/vulkan/anv_cmd_buffer.c @@ -493,6 +493,40 @@ void anv_CmdSetStencilReference( cmd_buffer->state.dirty |= ANV_CMD_DIRTY_DYNAMIC_STENCIL_REFERENCE; } +static void +anv_cmd_buffer_bind_descriptor_set(struct anv_cmd_buffer *cmd_buffer, + struct anv_pipeline_layout *layout, + uint32_t set_index, + struct anv_descriptor_set *set, + uint32_t *dynamic_offset_count, + const uint32_t **dynamic_offsets) +{ + struct anv_descriptor_set_layout *set_layout = + layout->set[set_index].layout; + + cmd_buffer->state.descriptors[set_index] = set; + + if (dynamic_offsets) { + if (set_layout->dynamic_offset_count > 0) { + uint32_t dynamic_offset_start = + layout->set[set_index].dynamic_offset_start; + + /* Assert that everything is in range */ + assert(set_layout->dynamic_offset_count <= *dynamic_offset_count); + assert(dynamic_offset_start + set_layout->dynamic_offset_count <= + ARRAY_SIZE(cmd_buffer->state.dynamic_offsets)); + + typed_memcpy(&cmd_buffer->state.dynamic_offsets[dynamic_offset_start], + *dynamic_offsets, set_layout->dynamic_offset_count); + + *dynamic_offsets += set_layout->dynamic_offset_count; + *dynamic_offset_count -= set_layout->dynamic_offset_count; + } + } + + cmd_buffer->state.descriptors_dirty |= set_layout->shader_stages; +} + void anv_CmdBindDescriptorSets( VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, @@ -505,35 +539,15 @@ void anv_CmdBindDescriptorSets( { ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer); ANV_FROM_HANDLE(anv_pipeline_layout, layout, _layout); - struct anv_descriptor_set_layout *set_layout; assert(firstSet + descriptorSetCount < MAX_SETS); - uint32_t dynamic_slot = 0; for (uint32_t i = 0; i < descriptorSetCount; i++) { ANV_FROM_HANDLE(anv_descriptor_set, set, pDescriptorSets[i]); - set_layout = layout->set[firstSet + i].layout; - - cmd_buffer->state.descriptors[firstSet + i] = set; - - if (set_layout->dynamic_offset_count > 0) { - uint32_t dynamic_offset_start = - layout->set[firstSet + i].dynamic_offset_start; - - /* Assert that everything is in range */ - assert(dynamic_offset_start + set_layout->dynamic_offset_count <= - ARRAY_SIZE(cmd_buffer->state.dynamic_offsets)); - assert(dynamic_slot + set_layout->dynamic_offset_count <= - dynamicOffsetCount); - - typed_memcpy(&cmd_buffer->state.dynamic_offsets[dynamic_offset_start], - &pDynamicOffsets[dynamic_slot], - set_layout->dynamic_offset_count); - - dynamic_slot += set_layout->dynamic_offset_count; - } - - cmd_buffer->state.descriptors_dirty |= set_layout->shader_stages; + anv_cmd_buffer_bind_descriptor_set(cmd_buffer, layout, + firstSet + i, set, + &dynamicOffsetCount, + &pDynamicOffsets); } } @@ -944,8 +958,8 @@ void anv_CmdPushDescriptorSetKHR( } } - cmd_buffer->state.descriptors[_set] = set; - cmd_buffer->state.descriptors_dirty |= set_layout->shader_stages; + anv_cmd_buffer_bind_descriptor_set(cmd_buffer, layout, _set, + set, NULL, NULL); } void anv_CmdPushDescriptorSetWithTemplateKHR( @@ -983,6 +997,6 @@ void anv_CmdPushDescriptorSetWithTemplateKHR( template, pData); - cmd_buffer->state.descriptors[_set] = set; - cmd_buffer->state.descriptors_dirty |= set_layout->shader_stages; + anv_cmd_buffer_bind_descriptor_set(cmd_buffer, layout, _set, + set, NULL, NULL); } |