From ed34f91545e9fe85fa12f53db6aa11e69c94bb0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tapani=20P=C3=A4lli?= Date: Mon, 1 Sep 2025 15:47:37 +0300 Subject: [PATCH] anv: implement autostrip disable for Wa_14024997852 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Note that currently autostrip is disabled globally with Wa_14021490052 for some gfx versions and steppings. Signed-off-by: Tapani Pälli Reviewed-by: Lionel Landwerlin Part-of: --- src/intel/vulkan/anv_device.c | 2 ++ src/intel/vulkan/anv_genX.h | 3 ++ src/intel/vulkan/anv_private.h | 6 ++++ src/intel/vulkan/genX_cmd_buffer.c | 6 ++++ src/intel/vulkan/genX_gfx_state.c | 47 ++++++++++++++++++++++++++++++ 5 files changed, 64 insertions(+) diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index 432136c2d7a..d43d5da37ae 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -972,6 +972,8 @@ VkResult anv_CreateDevice( if (device->info->ver > 9) BITSET_CLEAR(device->gfx_dirty_state, ANV_GFX_STATE_PMA_FIX); + BITSET_CLEAR(device->gfx_dirty_state, ANV_GFX_STATE_WA_14024997852); + device->queue_count = 0; for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; i++) { const VkDeviceQueueCreateInfo *queueCreateInfo = diff --git a/src/intel/vulkan/anv_genX.h b/src/intel/vulkan/anv_genX.h index 6812e2dbb2d..d47e1473912 100644 --- a/src/intel/vulkan/anv_genX.h +++ b/src/intel/vulkan/anv_genX.h @@ -190,6 +190,9 @@ genX(cmd_buffer_state_cache_inval_wa_14025112257)( } } +void +genX(setup_autostrip_state)(struct anv_cmd_buffer *cmd_buffer, bool enable); + void genX(emit_so_memcpy_init)(struct anv_memcpy_state *state, struct anv_device *device, struct anv_cmd_buffer *cmd_buffer, diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index c50c26d22ef..1d31d1519ad 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -1870,6 +1870,7 @@ enum anv_gfx_state_bits { ANV_GFX_STATE_WA_18019816803, /* Fake state to implement workaround */ ANV_GFX_STATE_WA_14018283232, /* Fake state to implement workaround */ ANV_GFX_STATE_WA_18038825448, /* Fake state to implement workaround */ + ANV_GFX_STATE_WA_14024997852, /* Fake state to implement workaround */ ANV_GFX_STATE_TBIMR_TILE_PASS_INFO, ANV_GFX_STATE_FS_MSAA_FLAGS, ANV_GFX_STATE_TESS_CONFIG, @@ -2308,6 +2309,11 @@ struct anv_gfx_dynamic_state { */ enum anv_coarse_pixel_state coarse_state; + /** + * State tracking for Wa_14024997852. + */ + bool autostrip_disabled; + /** Dirty bits of what needs to be repacked */ BITSET_DECLARE(pack_dirty, ANV_GFX_STATE_MAX); diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c index 184bde75231..7bdba356b3a 100644 --- a/src/intel/vulkan/genX_cmd_buffer.c +++ b/src/intel/vulkan/genX_cmd_buffer.c @@ -3427,6 +3427,12 @@ end_command_buffer(struct anv_cmd_buffer *cmd_buffer) */ genX(cmd_buffer_enable_pma_fix)(cmd_buffer, false); +#if INTEL_WA_14024997852_GFX_VER + /* Toggle autostrip on if we disabled it. */ + if (cmd_buffer->state.gfx.dyn_state.autostrip_disabled) + genX(setup_autostrip_state)(cmd_buffer, true); +#endif + /* Wa_14015814527 * * Apply task URB workaround in the end of primary or secondary cmd_buffer. diff --git a/src/intel/vulkan/genX_gfx_state.c b/src/intel/vulkan/genX_gfx_state.c index d4f7f9eeb7e..56c04d868f5 100644 --- a/src/intel/vulkan/genX_gfx_state.c +++ b/src/intel/vulkan/genX_gfx_state.c @@ -2530,6 +2530,20 @@ cmd_buffer_flush_gfx_runtime_state(struct anv_gfx_dynamic_state *hw_state, } #endif +#if INTEL_WA_14024997852_GFX_VER + /* Wa_14024997852: When Draw Cut Index or primitive id is enabled + * and topology is tri list, we need to disable autostrip. + * + * Note that we do not take primitive id in to account because it + * is mentioned only in xe2 clone of this wa and autostrip has been + * disabled globally on xe2 (+xe3 a0) by kernel due to 14021490052 + * workaround. + */ + SET(WA_14024997852, autostrip_disabled, + hw_state->vft.PrimitiveTopologyType == _3DPRIM_TRILIST && + dyn->ia.primitive_restart_enable); +#endif + /* If the pipeline uses a dynamic value of patch_control_points or the * tessellation domain is dynamic and either the pipeline change or the * dynamic value change, check the value and reemit if needed. @@ -2579,6 +2593,32 @@ cmd_buffer_flush_gfx_runtime_state(struct anv_gfx_dynamic_state *hw_state, #undef SET_STAGE #undef SETUP_PROVOKING_VERTEX +#if INTEL_WA_14024997852_GFX_VER +void +genX(setup_autostrip_state)(struct anv_cmd_buffer *cmd_buffer, bool enable) +{ + /* Add CS stall before writing registers. */ + genx_batch_emit_pipe_control(&cmd_buffer->batch, + cmd_buffer->device->info, + cmd_buffer->state.current_pipeline, + ANV_PIPE_CS_STALL_BIT); + + /* VF */ + anv_batch_write_reg(&cmd_buffer->batch, GENX(VFL_SCRATCH_PAD), vfl) { + vfl.AutostripDisable = !enable; + vfl.PartialAutostripDisable = !enable; + vfl.AutostripDisableMask = true; + vfl.PartialAutostripDisableMask = true; + } + /* TE and Mesh. */ + anv_batch_write_reg(&cmd_buffer->batch, GENX(FF_MODE), ff) { + ff.TEAutostripDisable = !enable; + ff.MeshShaderAutostripDisable = !enable; + ff.MeshShaderPartialAutostripDisable = !enable; + } +} +#endif /* INTEL_WA_14024997852_GFX_VER */ + static void cmd_buffer_repack_gfx_state(struct anv_gfx_dynamic_state *hw_state, struct anv_cmd_buffer *cmd_buffer, @@ -3601,6 +3641,13 @@ cmd_buffer_gfx_state_emission(struct anv_cmd_buffer *cmd_buffer) gfx->base.push_constants_data_dirty = true; } +#if INTEL_WA_14024997852_GFX_VER + if (IS_DIRTY(WA_14024997852) && + intel_needs_workaround(device->info, 14024997852)) { + genX(setup_autostrip_state)(cmd_buffer, !hw_state->autostrip_disabled); + } +#endif + #if INTEL_WA_18019110168_GFX_VER if (IS_DIRTY(MESH_PROVOKING_VERTEX)) cmd_buffer->state.push_constants_dirty |= VK_SHADER_STAGE_MESH_BIT_EXT;