radv: add private push descriptors for meta
authorFredrik Höglund <fredrik@kde.org>
Thu, 13 Apr 2017 22:26:58 +0000 (00:26 +0200)
committerBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Fri, 14 Apr 2017 21:21:24 +0000 (23:21 +0200)
This allows meta to use push descriptors without disturbing user
push descriptors.

radv_meta_push_descriptor_set differs from vkCmdPushDescriptorSetKHR
in that partial updates are not supported; all descriptors used in
subsequent draw commands must be pushed at the same time.

Signed-off-by: Fredrik Höglund <fredrik@kde.org>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/vulkan/radv_cmd_buffer.c
src/amd/vulkan/radv_private.h

index f03e3dff3490c292d0064db718b70dbdd6e98f52..31d04e535dc0f45db92ea38510b265027c75e2ec 100644 (file)
@@ -1981,6 +1981,39 @@ static bool radv_init_push_descriptor_set(struct radv_cmd_buffer *cmd_buffer,
        return true;
 }
 
+void radv_meta_push_descriptor_set(
+       struct radv_cmd_buffer*              cmd_buffer,
+       VkPipelineBindPoint                  pipelineBindPoint,
+       VkPipelineLayout                     _layout,
+       uint32_t                             set,
+       uint32_t                             descriptorWriteCount,
+       const VkWriteDescriptorSet*          pDescriptorWrites)
+{
+       RADV_FROM_HANDLE(radv_pipeline_layout, layout, _layout);
+       struct radv_descriptor_set *push_set = &cmd_buffer->meta_push_descriptors;
+       unsigned bo_offset;
+
+       assert(layout->set[set].layout->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR);
+
+       push_set->size = layout->set[set].layout->size;
+       push_set->layout = layout->set[set].layout;
+
+       if (!radv_cmd_buffer_upload_alloc(cmd_buffer, push_set->size, 32,
+                                         &bo_offset,
+                                         (void**) &push_set->mapped_ptr))
+               return;
+
+       push_set->va = cmd_buffer->device->ws->buffer_get_va(cmd_buffer->upload.upload_bo);
+       push_set->va += bo_offset;
+
+       radv_update_descriptor_sets(cmd_buffer->device, cmd_buffer,
+                                   radv_descriptor_set_to_handle(push_set),
+                                   descriptorWriteCount, pDescriptorWrites, 0, NULL);
+
+       cmd_buffer->state.descriptors[set] = push_set;
+       cmd_buffer->state.descriptors_dirty |= (1 << set);
+}
+
 void radv_CmdPushDescriptorSetKHR(
        VkCommandBuffer                             commandBuffer,
        VkPipelineBindPoint                         pipelineBindPoint,
index 2afc0cbedfc01bc1f209173940c5e79aa3c214b3..bff8845bc73cfe6098b02c6986f4df0087b3f35f 100644 (file)
@@ -787,6 +787,7 @@ struct radv_cmd_buffer {
        uint32_t dynamic_buffers[4 * MAX_DYNAMIC_BUFFERS];
        VkShaderStageFlags push_constant_stages;
        struct radv_push_descriptor_set push_descriptors;
+       struct radv_descriptor_set meta_push_descriptors;
 
        struct radv_cmd_buffer_upload upload;
 
@@ -1410,6 +1411,13 @@ radv_update_descriptor_set_with_template(struct radv_device *device,
                                          VkDescriptorUpdateTemplateKHR descriptorUpdateTemplate,
                                          const void *pData);
 
+void radv_meta_push_descriptor_set(struct radv_cmd_buffer *cmd_buffer,
+                                   VkPipelineBindPoint pipelineBindPoint,
+                                   VkPipelineLayout _layout,
+                                   uint32_t set,
+                                   uint32_t descriptorWriteCount,
+                                   const VkWriteDescriptorSet *pDescriptorWrites);
+
 void radv_initialise_cmask(struct radv_cmd_buffer *cmd_buffer,
                           struct radv_image *image, uint32_t value);
 void radv_initialize_dcc(struct radv_cmd_buffer *cmd_buffer,