From: Faith Ekstrand Date: Tue, 31 Jan 2023 02:11:53 +0000 (-0600) Subject: vulkan: Allow scissors or viewports to be set without counts X-Git-Tag: upstream/23.3.3~4379 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e1b12b49e6af928ca86f35dd5c3cc4007e85080a;p=platform%2Fupstream%2Fmesa.git vulkan: Allow scissors or viewports to be set without counts This is unlikely but can happen if you have the following sequence: 1. vkCmdSetScissors() 2. No pipeline bind 3. vkCmdClearImage() which causes a meta save 4. Meta restore with vk_cmd_set_dynamic_graphics_state() In that case, we don't have scissor counts but need to restore the scissors set with `vkCmdSetScissors()` before the meta save. We can safely copy all of them, it's just more memory traffic than maybe we'd like. Fortunately, this can only happen at the start of a command buffer and only with a fairly silly sequence of commands. Part-of: --- diff --git a/src/vulkan/runtime/vk_graphics_state.c b/src/vulkan/runtime/vk_graphics_state.c index 04114fe..1074fce 100644 --- a/src/vulkan/runtime/vk_graphics_state.c +++ b/src/vulkan/runtime/vk_graphics_state.c @@ -1882,14 +1882,18 @@ vk_dynamic_graphics_state_copy(struct vk_dynamic_graphics_state *dst, COPY_IF_SET(VP_VIEWPORT_COUNT, vp.viewport_count); if (IS_SET_IN_SRC(VP_VIEWPORTS)) { - assert(IS_SET_IN_SRC(VP_VIEWPORT_COUNT)); - COPY_ARRAY(VP_VIEWPORTS, vp.viewports, src->vp.viewport_count); + if (likely(IS_SET_IN_SRC(VP_VIEWPORT_COUNT))) + COPY_ARRAY(VP_VIEWPORTS, vp.viewports, src->vp.viewport_count); + else + COPY_ARRAY(VP_VIEWPORTS, vp.viewports, MESA_VK_MAX_VIEWPORTS); } COPY_IF_SET(VP_SCISSOR_COUNT, vp.scissor_count); if (IS_SET_IN_SRC(VP_SCISSORS)) { - assert(IS_SET_IN_SRC(VP_SCISSOR_COUNT)); - COPY_ARRAY(VP_SCISSORS, vp.scissors, src->vp.scissor_count); + if (likely(IS_SET_IN_SRC(VP_SCISSOR_COUNT))) + COPY_ARRAY(VP_SCISSORS, vp.scissors, src->vp.scissor_count); + else + COPY_ARRAY(VP_SCISSORS, vp.scissors, MESA_VK_MAX_SCISSORS); } COPY_IF_SET(VP_DEPTH_CLIP_NEGATIVE_ONE_TO_ONE,