From: Samuel Pitoiset Date: Tue, 30 Jun 2020 08:38:11 +0000 (+0200) Subject: radv: rework dynamic viewports/scissors support X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ac575f4215d7477bbfba13bae161dc9600586f4e;p=mesa.git radv: rework dynamic viewports/scissors support The number of viewports/scissors is currently static because it can only be specified at pipeline creation, but it doesn't hurt to assume it's dynamic. Will help for supporting setting the number of viewports/scissors dynamically. Signed-off-by: Samuel Pitoiset Reviewed-by: Bas Nieuwenhuizen Part-of: --- diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c index fd8400e9b7e..723a94c8192 100644 --- a/src/amd/vulkan/radv_cmd_buffer.c +++ b/src/amd/vulkan/radv_cmd_buffer.c @@ -106,15 +106,11 @@ radv_bind_dynamic_state(struct radv_cmd_buffer *cmd_buffer, uint32_t copy_mask = src->mask; uint32_t dest_mask = 0; - /* Make sure to copy the number of viewports/scissors because they can - * only be specified at pipeline creation time. - */ - dest->viewport.count = src->viewport.count; - dest->scissor.count = src->scissor.count; dest->discard_rectangle.count = src->discard_rectangle.count; dest->sample_location.count = src->sample_location.count; if (copy_mask & RADV_DYNAMIC_VIEWPORT) { + dest->viewport.count = src->viewport.count; if (memcmp(&dest->viewport.viewports, &src->viewport.viewports, src->viewport.count * sizeof(VkViewport))) { typed_memcpy(dest->viewport.viewports, @@ -125,6 +121,7 @@ radv_bind_dynamic_state(struct radv_cmd_buffer *cmd_buffer, } if (copy_mask & RADV_DYNAMIC_SCISSOR) { + dest->scissor.count = src->scissor.count; if (memcmp(&dest->scissor.scissors, &src->scissor.scissors, src->scissor.count * sizeof(VkRect2D))) { typed_memcpy(dest->scissor.scissors, @@ -3956,11 +3953,15 @@ void radv_CmdSetViewport( assert(firstViewport < MAX_VIEWPORTS); assert(total_count >= 1 && total_count <= MAX_VIEWPORTS); - if (!memcmp(state->dynamic.viewport.viewports + firstViewport, + if (total_count <= state->dynamic.viewport.count && + !memcmp(state->dynamic.viewport.viewports + firstViewport, pViewports, viewportCount * sizeof(*pViewports))) { return; } + if (state->dynamic.viewport.count < total_count) + state->dynamic.viewport.count = total_count; + memcpy(state->dynamic.viewport.viewports + firstViewport, pViewports, viewportCount * sizeof(*pViewports)); @@ -3980,11 +3981,15 @@ void radv_CmdSetScissor( assert(firstScissor < MAX_SCISSORS); assert(total_count >= 1 && total_count <= MAX_SCISSORS); - if (!memcmp(state->dynamic.scissor.scissors + firstScissor, pScissors, + if (total_count <= state->dynamic.scissor.count && + !memcmp(state->dynamic.scissor.scissors + firstScissor, pScissors, scissorCount * sizeof(*pScissors))) { return; } + if (state->dynamic.scissor.count < total_count) + state->dynamic.scissor.count = total_count; + memcpy(state->dynamic.scissor.scissors + firstScissor, pScissors, scissorCount * sizeof(*pScissors)); diff --git a/src/amd/vulkan/radv_meta.c b/src/amd/vulkan/radv_meta.c index f0156829526..1fb32f94621 100644 --- a/src/amd/vulkan/radv_meta.c +++ b/src/amd/vulkan/radv_meta.c @@ -62,15 +62,6 @@ radv_meta_save(struct radv_meta_saved_state *state, typed_memcpy(state->scissor.scissors, cmd_buffer->state.dynamic.scissor.scissors, MAX_SCISSORS); - - /* The most common meta operations all want to have the - * viewport reset and any scissors disabled. The rest of the - * dynamic state should have no effect. - */ - cmd_buffer->state.dynamic.viewport.count = 0; - cmd_buffer->state.dynamic.scissor.count = 0; - cmd_buffer->state.dirty |= 1 << VK_DYNAMIC_STATE_VIEWPORT | - 1 << VK_DYNAMIC_STATE_SCISSOR; } if (state->flags & RADV_META_SAVE_SAMPLE_LOCATIONS) {