anv: enable preemption setting on command/batch correctly

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 <lionel.g.landwerlin@intel.com>
Cc: mesa-stable
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35030>
(cherry picked from commit c570740272)
This commit is contained in:
Lionel Landwerlin 2025-05-16 09:10:47 +03:00 committed by Eric Engestrom
parent c8f0e53a90
commit 35d535c762
4 changed files with 16 additions and 11 deletions

View file

@ -3794,7 +3794,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

View file

@ -144,10 +144,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;

View file

@ -101,12 +101,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;
@ -283,6 +277,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));
@ -291,6 +288,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);
@ -357,8 +360,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);

View file

@ -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 =