From 0b141f56a32b18c3d2736d531a3c3074ee1d874f Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Fri, 16 May 2025 09:10:47 +0300 Subject: [PATCH] anv: enable preemption setting on command/batch correctly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The 2 helpers we're using for doing internal operations (copies, command generation, etc...) can work on command buffers or lower level batches. When working with command buffers, the helpers should set the preemption using genX(cmd_buffer_set_preemption) so that whatever operation comes after toggles the state back to what it needs and we minimize the toggles. When working with batchs, the helpers should disable preemption using genX(batch_set_preemption) and turn it back on when done. Signed-off-by: Lionel Landwerlin Cc: mesa-stable Reviewed-by: Tapani Pälli Part-of: (cherry picked from commit c57074027260c0db3b7fc04150a5b46333a17f28) --- .pick_status.json | 2 +- src/intel/vulkan/genX_gfx_state.c | 4 ---- src/intel/vulkan/genX_gpu_memcpy.c | 18 ++++++++++++------ src/intel/vulkan/genX_simple_shader.c | 3 +++ 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index c92e318fcb2..0bea6a5e594 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -624,7 +624,7 @@ "description": "anv: enable preemption setting on command/batch correctly", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/intel/vulkan/genX_gfx_state.c b/src/intel/vulkan/genX_gfx_state.c index cd8c585bc67..9ba0ae97c39 100644 --- a/src/intel/vulkan/genX_gfx_state.c +++ b/src/intel/vulkan/genX_gfx_state.c @@ -193,10 +193,6 @@ genX(streamout_prologue)(struct anv_cmd_buffer *cmd_buffer) #if INTEL_WA_16013994831_GFX_VER /* Wa_16013994831 - Disable preemption during streamout, enable back * again if XFB not used by the current pipeline. - * - * Although this workaround applies to Gfx12+, we already disable object - * level preemption for another reason in genX_state.c so we can skip this - * for Gfx12. */ if (!intel_needs_workaround(cmd_buffer->device->info, 16013994831)) return; diff --git a/src/intel/vulkan/genX_gpu_memcpy.c b/src/intel/vulkan/genX_gpu_memcpy.c index 81d6eac655a..7848df273c7 100644 --- a/src/intel/vulkan/genX_gpu_memcpy.c +++ b/src/intel/vulkan/genX_gpu_memcpy.c @@ -110,12 +110,6 @@ emit_common_so_memcpy(struct anv_memcpy_state *state, } #endif -#if INTEL_WA_16013994831_GFX_VER - /* Wa_16013994831 - Disable preemption during streamout. */ - if (intel_needs_workaround(device->info, 16013994831)) - genX(batch_set_preemption)(batch, device, _3D, false); -#endif - anv_batch_emit(batch, GENX(3DSTATE_SBE), sbe) { sbe.VertexURBEntryReadOffset = 1; sbe.NumberofSFOutputAttributes = 1; @@ -292,6 +286,9 @@ genX(emit_so_memcpy_init)(struct anv_memcpy_state *state, state->device = device; if (state->cmd_buffer) { + /* Wa_16013994831 - Disable preemption during streamout. */ + genX(cmd_buffer_set_preemption)(cmd_buffer, false); + if (!cmd_buffer->state.current_l3_config) { genX(cmd_buffer_config_l3)(cmd_buffer, intel_get_default_l3_config(device->info)); @@ -300,6 +297,12 @@ genX(emit_so_memcpy_init)(struct anv_memcpy_state *state, &state->cmd_buffer->state.gfx.urb_cfg, cmd_buffer->state.current_l3_config); } else { +#if INTEL_WA_16013994831_GFX_VER + /* Wa_16013994831 - Disable preemption during streamout. */ + if (intel_needs_workaround(device->info, 16013994831)) + genX(batch_set_preemption)(batch, device, _3D, false); +#endif + const struct intel_l3_config *cfg = intel_get_default_l3_config(device->info); genX(emit_l3_config)(batch, device, cfg); genX(emit_pipeline_select)(batch, _3D, device); @@ -367,8 +370,11 @@ genX(emit_so_memcpy_fini)(struct anv_memcpy_state *state) void genX(emit_so_memcpy_end)(struct anv_memcpy_state *state) { +#if INTEL_WA_16013994831_GFX_VER + /* Turn preemption back on when we're done */ if (intel_needs_workaround(state->device->info, 16013994831)) genX(batch_set_preemption)(state->batch, state->device, _3D, true); +#endif anv_batch_emit(state->batch, GENX(MI_BATCH_BUFFER_END), end); diff --git a/src/intel/vulkan/genX_simple_shader.c b/src/intel/vulkan/genX_simple_shader.c index 50b24906574..abd91c617b7 100644 --- a/src/intel/vulkan/genX_simple_shader.c +++ b/src/intel/vulkan/genX_simple_shader.c @@ -38,6 +38,9 @@ genX(emit_simpler_shader_init_fragment)(struct anv_simple_shader *state) { assert(state->cmd_buffer && state->cmd_buffer->state.current_pipeline == _3D); + /* Wa_16013994831 - Turn preemption on if it was previous left disabled. */ + genX(cmd_buffer_set_preemption)(state->cmd_buffer, true); + struct anv_batch *batch = state->batch; struct anv_device *device = state->device; const struct brw_wm_prog_data *prog_data =