Module: Mesa Branch: main Commit: 418299c120eaa034926780335c7207d9611cf30c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=418299c120eaa034926780335c7207d9611cf30c
Author: Tapani Pälli <tapani.pa...@intel.com> Date: Tue Oct 31 15:25:40 2023 +0200 anv: refactor state emission Add a helper that only emits hw_state, this makes it easier to modify dirty state and call helper to emit only wanted state. Signed-off-by: Tapani Pälli <tapani.pa...@intel.com> Reviewed-by: Lionel Landwerlin <lionel.g.landwer...@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25987> --- src/intel/vulkan/genX_gfx_state.c | 79 +++++++++++++++++++++++---------------- 1 file changed, 46 insertions(+), 33 deletions(-) diff --git a/src/intel/vulkan/genX_gfx_state.c b/src/intel/vulkan/genX_gfx_state.c index b31888d1b38..a50b846d1e4 100644 --- a/src/intel/vulkan/genX_gfx_state.c +++ b/src/intel/vulkan/genX_gfx_state.c @@ -1300,10 +1300,10 @@ genX(cmd_buffer_flush_gfx_runtime_state)(struct anv_cmd_buffer *cmd_buffer) } /** - * This function emits the dirty instructions in the batch buffer. + * This function handles dirty state emission to the batch buffer. */ -void -genX(cmd_buffer_flush_gfx_hw_state)(struct anv_cmd_buffer *cmd_buffer) +static void +cmd_buffer_gfx_state_emission(struct anv_cmd_buffer *cmd_buffer) { struct anv_device *device = cmd_buffer->device; struct anv_cmd_graphics_state *gfx = &cmd_buffer->state.gfx; @@ -1313,36 +1313,6 @@ genX(cmd_buffer_flush_gfx_hw_state)(struct anv_cmd_buffer *cmd_buffer) &cmd_buffer->vk.dynamic_graphics_state; struct anv_gfx_dynamic_state *hw_state = &gfx->dyn_state; - if (INTEL_DEBUG(DEBUG_REEMIT)) { - BITSET_OR(gfx->dyn_state.dirty, gfx->dyn_state.dirty, - device->gfx_dirty_state); - } - - /** - * Put potential workarounds here if you need to reemit an instruction - * because of another one is changing. - */ - - /* Since Wa_16011773973 will disable 3DSTATE_STREAMOUT, we need to reemit - * it after. - */ - if (intel_needs_workaround(device->info, 16011773973) && - pipeline->uses_xfb && - BITSET_TEST(hw_state->dirty, ANV_GFX_STATE_SO_DECL_LIST)) { - BITSET_SET(hw_state->dirty, ANV_GFX_STATE_STREAMOUT); - } - - /* Gfx11 undocumented issue : - * https://gitlab.freedesktop.org/mesa/mesa/-/issues/9781 - */ -#if GFX_VER == 11 - if (BITSET_TEST(hw_state->dirty, ANV_GFX_STATE_WM)) - BITSET_SET(hw_state->dirty, ANV_GFX_STATE_MULTISAMPLE); -#endif - - /** - * State emission - */ if (BITSET_TEST(hw_state->dirty, ANV_GFX_STATE_URB)) anv_batch_emit_pipeline_state(&cmd_buffer->batch, pipeline, final.urb); @@ -1908,6 +1878,49 @@ genX(cmd_buffer_flush_gfx_hw_state)(struct anv_cmd_buffer *cmd_buffer) BITSET_ZERO(hw_state->dirty); } +/** + * This function handles possible state workarounds and emits the dirty + * instructions to the batch buffer. + */ +void +genX(cmd_buffer_flush_gfx_hw_state)(struct anv_cmd_buffer *cmd_buffer) +{ + struct anv_device *device = cmd_buffer->device; + struct anv_cmd_graphics_state *gfx = &cmd_buffer->state.gfx; + struct anv_graphics_pipeline *pipeline = + anv_pipeline_to_graphics(cmd_buffer->state.gfx.base.pipeline); + struct anv_gfx_dynamic_state *hw_state = &gfx->dyn_state; + + if (INTEL_DEBUG(DEBUG_REEMIT)) { + BITSET_OR(gfx->dyn_state.dirty, gfx->dyn_state.dirty, + device->gfx_dirty_state); + } + + /** + * Put potential workarounds here if you need to reemit an instruction + * because of another one is changing. + */ + + /* Since Wa_16011773973 will disable 3DSTATE_STREAMOUT, we need to reemit + * it after. + */ + if (intel_needs_workaround(device->info, 16011773973) && + pipeline->uses_xfb && + BITSET_TEST(hw_state->dirty, ANV_GFX_STATE_SO_DECL_LIST)) { + BITSET_SET(hw_state->dirty, ANV_GFX_STATE_STREAMOUT); + } + + /* Gfx11 undocumented issue : + * https://gitlab.freedesktop.org/mesa/mesa/-/issues/9781 + */ +#if GFX_VER == 11 + if (BITSET_TEST(hw_state->dirty, ANV_GFX_STATE_WM)) + BITSET_SET(hw_state->dirty, ANV_GFX_STATE_MULTISAMPLE); +#endif + + cmd_buffer_gfx_state_emission(cmd_buffer); +} + void genX(cmd_buffer_enable_pma_fix)(struct anv_cmd_buffer *cmd_buffer, bool enable) {