From 7b8a6af222b2caf87982c2abd786ce31b12ff4bf Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Thu, 27 Mar 2025 14:32:44 +0200 Subject: [PATCH] anv: move 3DSTATE_SF dynamic emission path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Lionel Landwerlin Reviewed-by: Tapani Pälli Part-of: --- src/intel/vulkan/anv_cmd_buffer.c | 1 - src/intel/vulkan/anv_private.h | 4 ++-- src/intel/vulkan/genX_gfx_state.c | 23 +++++++++++++++++++++-- src/intel/vulkan/genX_pipeline.c | 23 ----------------------- 4 files changed, 23 insertions(+), 28 deletions(-) diff --git a/src/intel/vulkan/anv_cmd_buffer.c b/src/intel/vulkan/anv_cmd_buffer.c index 2988c191575..b44c3467c75 100644 --- a/src/intel/vulkan/anv_cmd_buffer.c +++ b/src/intel/vulkan/anv_cmd_buffer.c @@ -565,7 +565,6 @@ anv_cmd_buffer_flush_pipeline_hw_state(struct anv_cmd_buffer *cmd_buffer, diff_fix_state(DS, final.ds); diff_fix_state(CLIP, partial.clip); - diff_fix_state(SF, partial.sf); diff_fix_state(WM, partial.wm); diff_fix_state(STREAMOUT, partial.so); diff_fix_state(GS, partial.gs); diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index 23c3b64415d..5c1220581b9 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -1794,6 +1794,7 @@ struct anv_gfx_dynamic_state { /* 3DSTATE_SF */ struct { uint32_t DerefBlockSize; + uint32_t PointWidthSource; float LineWidth; uint32_t TriangleStripListProvokingVertexSelect; uint32_t LineStripListProvokingVertexSelect; @@ -5172,7 +5173,6 @@ struct anv_graphics_pipeline { */ struct { struct anv_gfx_state_ptr clip; - struct anv_gfx_state_ptr sf; struct anv_gfx_state_ptr ps_extra; struct anv_gfx_state_ptr wm; struct anv_gfx_state_ptr so; @@ -5399,7 +5399,7 @@ get_gfx_last_vue_map(const struct anv_cmd_graphics_state *gfx) return &((const struct brw_vs_prog_data *) gfx->shaders[MESA_SHADER_VERTEX]->prog_data)->base.vue_map; } - return NULL; + UNREACHABLE("Invalid bound shaders"); } static inline const struct brw_cs_prog_data * diff --git a/src/intel/vulkan/genX_gfx_state.c b/src/intel/vulkan/genX_gfx_state.c index b989ad81f7a..25990e57cfd 100644 --- a/src/intel/vulkan/genX_gfx_state.c +++ b/src/intel/vulkan/genX_gfx_state.c @@ -1176,6 +1176,15 @@ update_line_width(struct anv_gfx_dynamic_state *hw_state, SET(SF, sf.LineWidth, dyn->rs.line.width); } +ALWAYS_INLINE static void +update_sf_point_width_source(struct anv_gfx_dynamic_state *hw_state, + const struct anv_cmd_graphics_state *gfx) +{ + SET(SF, sf.PointWidthSource, + (get_gfx_last_vue_map(gfx)->slots_valid & VARYING_BIT_PSIZ) ? + Vertex : State); +} + ALWAYS_INLINE static void update_sf_global_depth_bias(struct anv_gfx_dynamic_state *hw_state, const struct vk_dynamic_graphics_state *dyn) @@ -2050,6 +2059,9 @@ cmd_buffer_flush_gfx_runtime_state(struct anv_gfx_dynamic_state *hw_state, if (BITSET_TEST(dyn->dirty, MESA_VK_DYNAMIC_RS_LINE_WIDTH)) update_line_width(hw_state, dyn); + if (gfx->dirty & ANV_CMD_DIRTY_PRERASTER_SHADERS) + update_sf_point_width_source(hw_state, gfx); + if (BITSET_TEST(dyn->dirty, MESA_VK_DYNAMIC_RS_DEPTH_BIAS_FACTORS)) update_sf_global_depth_bias(hw_state, dyn); @@ -2833,11 +2845,18 @@ cmd_buffer_gfx_state_emission(struct anv_cmd_buffer *cmd_buffer) #endif /* GFX_VER >= 30 */ if (BITSET_TEST(hw_state->dirty, ANV_GFX_STATE_SF)) { - anv_batch_emit_merge(&cmd_buffer->batch, GENX(3DSTATE_SF), - pipeline, partial.sf, sf) { + anv_batch_emit(&cmd_buffer->batch, GENX(3DSTATE_SF), sf) { + /* Fixed values */ + sf.ViewportTransformEnable = true; + sf.StatisticsEnable = true; + sf.VertexSubPixelPrecisionSelect = _8Bit; + sf.AALineDistanceMode = true; + sf.PointWidth = 1.0; + #if GFX_VER >= 12 SET(sf, sf, DerefBlockSize); #endif + SET(sf, sf, PointWidthSource); SET(sf, sf, LineWidth); SET(sf, sf, TriangleStripListProvokingVertexSelect); SET(sf, sf, LineStripListProvokingVertexSelect); diff --git a/src/intel/vulkan/genX_pipeline.c b/src/intel/vulkan/genX_pipeline.c index d1ac3900341..9582d2e2f4c 100644 --- a/src/intel/vulkan/genX_pipeline.c +++ b/src/intel/vulkan/genX_pipeline.c @@ -612,28 +612,6 @@ emit_3dstate_sbe(struct anv_graphics_pipeline *pipeline) } } -static void -emit_rs_state(struct anv_graphics_pipeline *pipeline) -{ - anv_pipeline_emit(pipeline, partial.sf, GENX(3DSTATE_SF), sf) { - sf.ViewportTransformEnable = true; - sf.StatisticsEnable = true; - sf.VertexSubPixelPrecisionSelect = _8Bit; - sf.AALineDistanceMode = true; - - const struct intel_vue_map *vue_map = - anv_pipeline_is_primitive(pipeline) ? - &anv_pipeline_get_last_vue_prog_data(pipeline)->vue_map : - &get_pipeline_mesh_prog_data(pipeline)->map.vue_map; - if (vue_map->slots_valid & VARYING_BIT_PSIZ) { - sf.PointWidthSource = Vertex; - } else { - sf.PointWidthSource = State; - sf.PointWidth = 1.0; - } - } -} - static void emit_3dstate_clip(struct anv_graphics_pipeline *pipeline, const struct vk_input_assembly_state *ia, @@ -1697,7 +1675,6 @@ void genX(graphics_pipeline_emit)(struct anv_graphics_pipeline *pipeline, const struct vk_graphics_pipeline_state *state) { - emit_rs_state(pipeline); compute_kill_pixel(pipeline, state->ms, state); emit_3dstate_clip(pipeline, state->ia, state->vp, state->rs);