From 8a47ae456cbae85508ec8bff73c9ec0020edd552 Mon Sep 17 00:00:00 2001 From: John Anthony Date: Wed, 12 Mar 2025 10:21:21 +0100 Subject: [PATCH] panvk: Avoid division by zero for vkCmdCopyQueryPoolResults Stride can be zero if there are less than two queries to copy. Reviewed-by: Erik Faye-Lund Reviewed-by: Boris Brezillon Fixes: 7755c41b3ef ("panvk/csf: Rework the occlusion query logic to avoid draw flushes") Part-of: --- src/panfrost/vulkan/csf/panvk_vX_cmd_query.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/panfrost/vulkan/csf/panvk_vX_cmd_query.c b/src/panfrost/vulkan/csf/panvk_vX_cmd_query.c index f7b5d7f7290..1cd444d5205 100644 --- a/src/panfrost/vulkan/csf/panvk_vX_cmd_query.c +++ b/src/panfrost/vulkan/csf/panvk_vX_cmd_query.c @@ -258,9 +258,11 @@ panvk_copy_occlusion_query_results(struct panvk_cmd_buffer *cmd, struct cs_index scratch_regs = cs_scratch_reg_tuple(b, 0, 11); uint32_t queries_per_batch = scratch_regs.size / regs_per_copy; - /* Store offset is a 16-bit signed integer, so we might be limited by the - * stride here. */ - queries_per_batch = MIN2(((1u << 15) / stride) + 1, queries_per_batch); + if (stride > 0) { + /* Store offset is a 16-bit signed integer, so we might be limited by the + * stride here. */ + queries_per_batch = MIN2(((1u << 15) / stride) + 1, queries_per_batch); + } /* Stop unrolling the loop when it takes more than 2 steps to copy the * queries. */