[Mesa-dev] [PATCH 1/9] radv/meta: add support for save/restore meta without vertex data.
Bas Nieuwenhuizen
bas at basnieuwenhuizen.nl
Tue Apr 18 23:46:27 UTC 2017
Nice cleanup.
Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
On Wed, Apr 19, 2017 at 1:27 AM, Dave Airlie <airlied at gmail.com> wrote:
> From: Dave Airlie <airlied at redhat.com>
>
> Some of the shaders could just generate the vertex data in the
> shader, so add helpers to allow us to move to doing that.
>
> Signed-off-by: Dave Airlie <airlied at redhat.com>
> ---
> src/amd/vulkan/radv_meta.c | 39 +++++++++++++++++++++++++++++++--------
> src/amd/vulkan/radv_meta.h | 7 +++++++
> 2 files changed, 38 insertions(+), 8 deletions(-)
>
> diff --git a/src/amd/vulkan/radv_meta.c b/src/amd/vulkan/radv_meta.c
> index 0098e08..feb2ab8 100644
> --- a/src/amd/vulkan/radv_meta.c
> +++ b/src/amd/vulkan/radv_meta.c
> @@ -31,20 +31,30 @@
> #include <sys/stat.h>
>
> void
> -radv_meta_save(struct radv_meta_saved_state *state,
> +radv_meta_save_novertex(struct radv_meta_saved_state *state,
> const struct radv_cmd_buffer *cmd_buffer,
> uint32_t dynamic_mask)
> {
> state->old_pipeline = cmd_buffer->state.pipeline;
> - state->old_descriptor_set0 = cmd_buffer->state.descriptors[0];
> - memcpy(state->old_vertex_bindings, cmd_buffer->state.vertex_bindings,
> - sizeof(state->old_vertex_bindings));
>
> state->dynamic_mask = dynamic_mask;
> radv_dynamic_state_copy(&state->dynamic, &cmd_buffer->state.dynamic,
> dynamic_mask);
>
> memcpy(state->push_constants, cmd_buffer->push_constants, MAX_PUSH_CONSTANTS_SIZE);
> + state->vertex_saved = false;
> +}
> +
> +void
> +radv_meta_save(struct radv_meta_saved_state *state,
> + const struct radv_cmd_buffer *cmd_buffer,
> + uint32_t dynamic_mask)
> +{
> + radv_meta_save_novertex(state, cmd_buffer, dynamic_mask);
> + state->old_descriptor_set0 = cmd_buffer->state.descriptors[0];
> + memcpy(state->old_vertex_bindings, cmd_buffer->state.vertex_bindings,
> + sizeof(state->old_vertex_bindings));
> + state->vertex_saved = true;
> }
>
> void
> @@ -52,11 +62,13 @@ radv_meta_restore(const struct radv_meta_saved_state *state,
> struct radv_cmd_buffer *cmd_buffer)
> {
> cmd_buffer->state.pipeline = state->old_pipeline;
> - radv_bind_descriptor_set(cmd_buffer, state->old_descriptor_set0, 0);
> - memcpy(cmd_buffer->state.vertex_bindings, state->old_vertex_bindings,
> - sizeof(state->old_vertex_bindings));
> + if (state->vertex_saved) {
> + radv_bind_descriptor_set(cmd_buffer, state->old_descriptor_set0, 0);
> + memcpy(cmd_buffer->state.vertex_bindings, state->old_vertex_bindings,
> + sizeof(state->old_vertex_bindings));
> + cmd_buffer->state.vb_dirty |= (1 << RADV_META_VERTEX_BINDING_COUNT) - 1;
> + }
>
> - cmd_buffer->state.vb_dirty |= (1 << RADV_META_VERTEX_BINDING_COUNT) - 1;
> cmd_buffer->state.dirty |= RADV_CMD_DIRTY_PIPELINE;
>
> radv_dynamic_state_copy(&cmd_buffer->state.dynamic, &state->dynamic,
> @@ -393,3 +405,14 @@ radv_meta_save_graphics_reset_vport_scissor(struct radv_meta_saved_state *saved_
> cmd_buffer->state.dynamic.scissor.count = 0;
> cmd_buffer->state.dirty |= dirty_state;
> }
> +
> +void
> +radv_meta_save_graphics_reset_vport_scissor_novertex(struct radv_meta_saved_state *saved_state,
> + struct radv_cmd_buffer *cmd_buffer)
> +{
> + uint32_t dirty_state = (1 << VK_DYNAMIC_STATE_VIEWPORT) | (1 << VK_DYNAMIC_STATE_SCISSOR);
> + radv_meta_save_novertex(saved_state, cmd_buffer, dirty_state);
> + cmd_buffer->state.dynamic.viewport.count = 0;
> + cmd_buffer->state.dynamic.scissor.count = 0;
> + cmd_buffer->state.dirty |= dirty_state;
> +}
> diff --git a/src/amd/vulkan/radv_meta.h b/src/amd/vulkan/radv_meta.h
> index 6cfc613..8702ca4 100644
> --- a/src/amd/vulkan/radv_meta.h
> +++ b/src/amd/vulkan/radv_meta.h
> @@ -35,6 +35,7 @@ extern "C" {
> #define RADV_META_VERTEX_BINDING_COUNT 2
>
> struct radv_meta_saved_state {
> + bool vertex_saved;
> struct radv_vertex_binding old_vertex_bindings[RADV_META_VERTEX_BINDING_COUNT];
> struct radv_descriptor_set *old_descriptor_set0;
> struct radv_pipeline *old_pipeline;
> @@ -94,6 +95,10 @@ void radv_meta_save(struct radv_meta_saved_state *state,
> const struct radv_cmd_buffer *cmd_buffer,
> uint32_t dynamic_mask);
>
> +void radv_meta_save_novertex(struct radv_meta_saved_state *state,
> + const struct radv_cmd_buffer *cmd_buffer,
> + uint32_t dynamic_mask);
> +
> void radv_meta_restore(const struct radv_meta_saved_state *state,
> struct radv_cmd_buffer *cmd_buffer);
>
> @@ -202,6 +207,8 @@ void radv_fast_clear_flush_image_inplace(struct radv_cmd_buffer *cmd_buffer,
>
> void radv_meta_save_graphics_reset_vport_scissor(struct radv_meta_saved_state *saved_state,
> struct radv_cmd_buffer *cmd_buffer);
> +void radv_meta_save_graphics_reset_vport_scissor_novertex(struct radv_meta_saved_state *saved_state,
> + struct radv_cmd_buffer *cmd_buffer);
>
> void radv_meta_resolve_compute_image(struct radv_cmd_buffer *cmd_buffer,
> struct radv_image *src_image,
> --
> 2.9.3
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list