From 8147108590c996fc6e303d11b2e337e21ef854ac Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Mon, 17 Nov 2025 11:20:56 +0200 Subject: [PATCH] anv: optimize pipeline switching with secondaries 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/genX_cmd_buffer.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c index 77f22449c92..4e298b61ab9 100644 --- a/src/intel/vulkan/genX_cmd_buffer.c +++ b/src/intel/vulkan/genX_cmd_buffer.c @@ -3193,8 +3193,16 @@ genX(BeginCommandBuffer)( * secondary command buffer is considered to be entirely inside a render * pass. If this is a primary command buffer, then this bit is ignored. */ - if (cmd_buffer->vk.level == VK_COMMAND_BUFFER_LEVEL_PRIMARY) + if (cmd_buffer->vk.level == VK_COMMAND_BUFFER_LEVEL_PRIMARY) { cmd_buffer->usage_flags &= ~VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; + } else if (cmd_buffer->usage_flags & + VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT) { + /* For secondary, if we have RENDER_PASS_CONTINUE_BIT, we can assume the + * pipeline mode is 3D. This avoid some stalling/state-emission. + */ + cmd_buffer->state.current_pipeline = _3D; + } + #if GFX_VER >= 12 /* Reenable prefetching at the beginning of secondary command buffers. We @@ -3676,6 +3684,11 @@ genX(CmdExecuteCommands)( } db_mode = secondary->state.current_db_mode; + + /* Set the current pipeline state to the secondary's state if it did + * program the PIPELINE_SELECT instruction. */ + if (secondary->state.current_pipeline != UINT32_MAX) + container->state.current_pipeline = secondary->state.current_pipeline; } /* The secondary isn't counted in our VF cache tracking so we need to @@ -3699,7 +3712,6 @@ genX(CmdExecuteCommands)( * where we do any draws or compute dispatches from the container after the * secondary has returned. */ - container->state.current_pipeline = UINT32_MAX; container->state.current_l3_config = NULL; container->state.current_hash_scale = 0; container->state.gfx.push_constant_stages = 0;