From 0d5b76113e6edb95acc485c8117b166380f29e41 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Wed, 18 Sep 2024 11:00:50 -0400 Subject: [PATCH] hk: optimize out empty VDM batches Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/vulkan/hk_cmd_buffer.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/asahi/vulkan/hk_cmd_buffer.c b/src/asahi/vulkan/hk_cmd_buffer.c index 3deb5d14e8d..13ea4dfcf67 100644 --- a/src/asahi/vulkan/hk_cmd_buffer.c +++ b/src/asahi/vulkan/hk_cmd_buffer.c @@ -271,6 +271,19 @@ hk_EndCommandBuffer(VkCommandBuffer commandBuffer) hk_cmd_buffer_end_compute(cmd); hk_cmd_buffer_end_compute_internal(&cmd->current_cs.post_gfx); + /* With rasterizer discard, we might end up with empty VDM batches. + * It is difficult to avoid creating these empty batches, but it's easy to + * optimize them out at record-time. Do so now. + */ + list_for_each_entry_safe(struct hk_cs, cs, &cmd->control_streams, node) { + if (cs->type == HK_CS_VDM && cs->stats.cmds == 0 && + !cs->cr.process_empty_tiles) { + + list_del(&cs->node); + hk_cs_destroy(cs); + } + } + return vk_command_buffer_get_record_result(&cmd->vk); }