[Mesa-stable] [Mesa-dev] [PATCH] radv: use separate bind points for the dynamic buffers

Bas Nieuwenhuizen bas at basnieuwenhuizen.nl
Tue Jun 26 23:09:16 UTC 2018


Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>

On Tue, Jun 26, 2018 at 11:19 AM, Samuel Pitoiset
<samuel.pitoiset at gmail.com> wrote:
> The Vulkan spec says:
>
>    "pipelineBindPoint is a VkPipelineBindPoint indicating whether
>     the descriptors will be used by graphics pipelines or compute
>     pipelines. There is a separate set of bind points for each of
>     graphics and compute, so binding one does not disturb the other."
>
> CC: <mesa-stable at lists.freedesktop.org>
> Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
> ---
>  src/amd/vulkan/radv_cmd_buffer.c | 12 ++++++++++--
>  src/amd/vulkan/radv_private.h    |  2 +-
>  2 files changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c
> index 0388e4b6e0..63d7db41c1 100644
> --- a/src/amd/vulkan/radv_cmd_buffer.c
> +++ b/src/amd/vulkan/radv_cmd_buffer.c
> @@ -1764,6 +1764,11 @@ radv_flush_constants(struct radv_cmd_buffer *cmd_buffer,
>         struct radv_pipeline *pipeline = stages & VK_SHADER_STAGE_COMPUTE_BIT
>                                          ? cmd_buffer->state.compute_pipeline
>                                          : cmd_buffer->state.pipeline;
> +       VkPipelineBindPoint bind_point = stages & VK_SHADER_STAGE_COMPUTE_BIT ?
> +                                        VK_PIPELINE_BIND_POINT_COMPUTE :
> +                                        VK_PIPELINE_BIND_POINT_GRAPHICS;
> +       struct radv_descriptor_state *descriptors_state =
> +               radv_get_descriptors_state(cmd_buffer, bind_point);
>         struct radv_pipeline_layout *layout = pipeline->layout;
>         struct radv_shader_variant *shader, *prev_shader;
>         unsigned offset;
> @@ -1781,7 +1786,8 @@ radv_flush_constants(struct radv_cmd_buffer *cmd_buffer,
>                 return;
>
>         memcpy(ptr, cmd_buffer->push_constants, layout->push_constant_size);
> -       memcpy((char*)ptr + layout->push_constant_size, cmd_buffer->dynamic_buffers,
> +       memcpy((char*)ptr + layout->push_constant_size,
> +              descriptors_state->dynamic_buffers,
>                16 * layout->dynamic_offset_count);
>
>         va = radv_buffer_get_va(cmd_buffer->upload.upload_bo);
> @@ -2414,6 +2420,8 @@ void radv_CmdBindDescriptorSets(
>         unsigned dyn_idx = 0;
>
>         const bool no_dynamic_bounds = cmd_buffer->device->instance->debug_flags & RADV_DEBUG_NO_DYNAMIC_BOUNDS;
> +       struct radv_descriptor_state *descriptors_state =
> +               radv_get_descriptors_state(cmd_buffer, pipelineBindPoint);
>
>         for (unsigned i = 0; i < descriptorSetCount; ++i) {
>                 unsigned idx = i + firstSet;
> @@ -2422,7 +2430,7 @@ void radv_CmdBindDescriptorSets(
>
>                 for(unsigned j = 0; j < set->layout->dynamic_offset_count; ++j, ++dyn_idx) {
>                         unsigned idx = j + layout->set[i + firstSet].dynamic_offset_start;
> -                       uint32_t *dst = cmd_buffer->dynamic_buffers + idx * 4;
> +                       uint32_t *dst = descriptors_state->dynamic_buffers + idx * 4;
>                         assert(dyn_idx < dynamicOffsetCount);
>
>                         struct radv_descriptor_range *range = set->dynamic_descriptors + j;
> diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h
> index f001b836c8..dae5977e33 100644
> --- a/src/amd/vulkan/radv_private.h
> +++ b/src/amd/vulkan/radv_private.h
> @@ -930,6 +930,7 @@ struct radv_descriptor_state {
>         uint32_t valid;
>         struct radv_push_descriptor_set push_set;
>         bool push_dirty;
> +       uint32_t dynamic_buffers[4 * MAX_DYNAMIC_BUFFERS];
>  };
>
>  struct radv_cmd_state {
> @@ -1015,7 +1016,6 @@ struct radv_cmd_buffer {
>         uint32_t queue_family_index;
>
>         uint8_t push_constants[MAX_PUSH_CONSTANTS_SIZE];
> -       uint32_t dynamic_buffers[4 * MAX_DYNAMIC_BUFFERS];
>         VkShaderStageFlags push_constant_stages;
>         struct radv_descriptor_set meta_push_descriptors;
>
> --
> 2.18.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-stable mailing list