From 5405c9ed5057c5f1e8dc2a362afeda2078abec0f Mon Sep 17 00:00:00 2001 From: Connor Abbott Date: Mon, 3 Apr 2023 18:45:05 +0200 Subject: [PATCH] vk/graphics_state: Fix some assertions when copying state On turnip we support dynamic vertex input, but static vertex input is precompiled and so we will copy from a source without VI to a destination with VI and it's valid in this case to do nothing. On the other hand, it should never be valid if VI state is set but the pointer isn't there, which the code previously silently skipped over. There's a similar issue with sample locations. Reviewed-by: Lionel Landwerlin Part-of: --- src/vulkan/runtime/vk_graphics_state.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/vulkan/runtime/vk_graphics_state.c b/src/vulkan/runtime/vk_graphics_state.c index 037c07c4c59..0563e792afa 100644 --- a/src/vulkan/runtime/vk_graphics_state.c +++ b/src/vulkan/runtime/vk_graphics_state.c @@ -1739,8 +1739,8 @@ vk_dynamic_graphics_state_copy(struct vk_dynamic_graphics_state *dst, #define COPY_IF_SET(STATE, state) \ if (IS_SET_IN_SRC(STATE)) SET_DYN_VALUE(dst, STATE, state, src->state) - assert((dst->vi != NULL) == (src->vi != NULL)); - if (dst->vi != NULL && IS_SET_IN_SRC(VI)) { + if (IS_SET_IN_SRC(VI)) { + assert(dst->vi != NULL); COPY_MEMBER(VI, vi->bindings_valid); u_foreach_bit(b, src->vi->bindings_valid) { COPY_MEMBER(VI, vi->bindings[b].stride); @@ -1827,10 +1827,8 @@ vk_dynamic_graphics_state_copy(struct vk_dynamic_graphics_state *dst, COPY_IF_SET(MS_ALPHA_TO_ONE_ENABLE, ms.alpha_to_one_enable); COPY_IF_SET(MS_SAMPLE_LOCATIONS_ENABLE, ms.sample_locations_enable); - assert((dst->ms.sample_locations == NULL) == - (src->ms.sample_locations == NULL)); - if (dst->ms.sample_locations != NULL && - IS_SET_IN_SRC(MS_SAMPLE_LOCATIONS)) { + if (IS_SET_IN_SRC(MS_SAMPLE_LOCATIONS)) { + assert(dst->ms.sample_locations != NULL); COPY_MEMBER(MS_SAMPLE_LOCATIONS, ms.sample_locations->per_pixel); COPY_MEMBER(MS_SAMPLE_LOCATIONS, ms.sample_locations->grid_size.width); COPY_MEMBER(MS_SAMPLE_LOCATIONS, ms.sample_locations->grid_size.height);