From e2ccd638a811b75660adf6e8b5d4f93435e728b8 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Wed, 5 Feb 2025 13:40:47 -0500 Subject: [PATCH] radv: roll line topology dynamic state changes into existing rast samples flag this eliminates uploading rast samples whenever prim type changes even when rast samples will not be changed Part-of: --- src/amd/vulkan/radv_cmd_buffer.c | 18 ++++++++++++++---- src/amd/vulkan/radv_pipeline_graphics.h | 9 +++++++-- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c index c57ae41bec8..a5e31d117f3 100644 --- a/src/amd/vulkan/radv_cmd_buffer.c +++ b/src/amd/vulkan/radv_cmd_buffer.c @@ -2877,8 +2877,13 @@ radv_emit_graphics_pipeline(struct radv_cmd_buffer *cmd_buffer) radv_rast_prim_is_points_or_lines(pipeline->rast_prim)) cmd_buffer->state.dirty |= RADV_CMD_DIRTY_GUARDBAND; - if (cmd_buffer->state.emitted_graphics_pipeline->rast_prim != pipeline->rast_prim) - cmd_buffer->state.dirty_dynamic |= RADV_DYNAMIC_PRIMITIVE_TOPOLOGY | RADV_DYNAMIC_RASTERIZATION_SAMPLES; + if (cmd_buffer->state.emitted_graphics_pipeline->rast_prim != pipeline->rast_prim) { + cmd_buffer->state.dirty_dynamic |= RADV_DYNAMIC_PRIMITIVE_TOPOLOGY; + + if (radv_rast_prim_is_line(cmd_buffer->state.emitted_graphics_pipeline->rast_prim) != + radv_rast_prim_is_line(pipeline->rast_prim)) + cmd_buffer->state.dirty_dynamic |= RADV_DYNAMIC_RASTERIZATION_SAMPLES; + } if (cmd_buffer->state.emitted_graphics_pipeline->ms.min_sample_shading != pipeline->ms.min_sample_shading || cmd_buffer->state.emitted_graphics_pipeline->uses_out_of_order_rast != pipeline->uses_out_of_order_rast || @@ -5551,13 +5556,13 @@ radv_cmd_buffer_flush_dynamic_state(struct radv_cmd_buffer *cmd_buffer, const ui radv_emit_color_blend(cmd_buffer); if (states & (RADV_DYNAMIC_RASTERIZATION_SAMPLES | RADV_DYNAMIC_LINE_RASTERIZATION_MODE | - RADV_DYNAMIC_PRIMITIVE_TOPOLOGY | RADV_DYNAMIC_POLYGON_MODE | RADV_DYNAMIC_SAMPLE_LOCATIONS_ENABLE)) + RADV_DYNAMIC_POLYGON_MODE | RADV_DYNAMIC_SAMPLE_LOCATIONS_ENABLE)) radv_emit_rasterization_samples(cmd_buffer); if (states & (RADV_DYNAMIC_LINE_STIPPLE_ENABLE | RADV_DYNAMIC_CONSERVATIVE_RAST_MODE | RADV_DYNAMIC_SAMPLE_LOCATIONS | RADV_DYNAMIC_SAMPLE_LOCATIONS_ENABLE | RADV_DYNAMIC_RASTERIZATION_SAMPLES | - RADV_DYNAMIC_LINE_RASTERIZATION_MODE | RADV_DYNAMIC_PRIMITIVE_TOPOLOGY | RADV_DYNAMIC_POLYGON_MODE)) + RADV_DYNAMIC_LINE_RASTERIZATION_MODE | RADV_DYNAMIC_POLYGON_MODE)) radv_emit_msaa_state(cmd_buffer); /* RADV_DYNAMIC_ATTACHMENT_FEEDBACK_LOOP_ENABLE is handled by radv_emit_db_shader_control. */ @@ -8151,6 +8156,11 @@ radv_CmdSetPrimitiveTopology(VkCommandBuffer commandBuffer, VkPrimitiveTopology radv_prim_is_points_or_lines(primitive_topology)) state->dirty |= RADV_CMD_DIRTY_GUARDBAND; + /* for line stipple/mode */ + if (radv_prim_is_lines(state->dynamic.vk.ia.primitive_topology) != + radv_prim_is_lines(primitive_topology)) + state->dirty |= RADV_DYNAMIC_RASTERIZATION_SAMPLES; + state->dynamic.vk.ia.primitive_topology = primitive_topology; state->dirty_dynamic |= RADV_DYNAMIC_PRIMITIVE_TOPOLOGY; diff --git a/src/amd/vulkan/radv_pipeline_graphics.h b/src/amd/vulkan/radv_pipeline_graphics.h index 5005e6b5f66..abf7cd22c14 100644 --- a/src/amd/vulkan/radv_pipeline_graphics.h +++ b/src/amd/vulkan/radv_pipeline_graphics.h @@ -260,10 +260,9 @@ radv_translate_prim(unsigned topology) } static inline bool -radv_prim_is_points_or_lines(unsigned topology) +radv_prim_is_lines(unsigned topology) { switch (topology) { - case V_008958_DI_PT_POINTLIST: case V_008958_DI_PT_LINELIST: case V_008958_DI_PT_LINESTRIP: case V_008958_DI_PT_LINELIST_ADJ: @@ -274,6 +273,12 @@ radv_prim_is_points_or_lines(unsigned topology) } } +static inline bool +radv_prim_is_points_or_lines(unsigned topology) +{ + return topology == V_008958_DI_PT_POINTLIST || radv_prim_is_lines(topology); +} + static inline bool radv_rast_prim_is_point(unsigned rast_prim) {