From d322a80170f605e16a09b7034dc0e4a86340b71f Mon Sep 17 00:00:00 2001 From: Connor Abbott Date: Mon, 3 Jul 2023 11:21:20 +0200 Subject: [PATCH] radv: Fix radv_pipeline_is_blend_enabled This was relying on cb being NULL instead of just gracefully handling it, and it will stop being NULL once we start tracking attachment count as state. Moreover is was broken in the case where only the blend enable is dynamic. Reviewed-by: Tatsuyuki Ishi Part-of: --- src/amd/vulkan/radv_pipeline_graphics.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/amd/vulkan/radv_pipeline_graphics.c b/src/amd/vulkan/radv_pipeline_graphics.c index fdc8bd0bbc7..5ca0732a427 100644 --- a/src/amd/vulkan/radv_pipeline_graphics.c +++ b/src/amd/vulkan/radv_pipeline_graphics.c @@ -493,15 +493,18 @@ radv_dynamic_state_mask(VkDynamicState state) static bool radv_pipeline_is_blend_enabled(const struct radv_graphics_pipeline *pipeline, const struct vk_color_blend_state *cb) { + /* If we don't know then we have to assume that blend may be enabled. cb may also be NULL in this + * case. + */ + if (pipeline->dynamic_states & (RADV_DYNAMIC_COLOR_BLEND_ENABLE | RADV_DYNAMIC_COLOR_WRITE_MASK)) + return true; + + /* If we have the blend enable state, then cb being NULL indicates no attachments are written. */ if (cb) { for (uint32_t i = 0; i < cb->attachment_count; i++) { if (cb->attachments[i].write_mask && cb->attachments[i].blend_enable) return true; } - } else { - /* When all color blend states are dynamic, it's allowed to be NULL. */ - if ((pipeline->dynamic_states & RADV_DYNAMIC_CB_STATES) == RADV_DYNAMIC_CB_STATES) - return true; } return false;