From 03b037a0e361ec984bebd032d1957122bdc08eb3 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Thu, 2 Jan 2025 11:45:22 +0100 Subject: [PATCH] radv: disable logic op for float/srgb formats MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Vulkan spec says: "The application can enable a logical operation between the fragment’s color values and the existing value in the framebuffer attachment. This logical operation is applied prior to updating the framebuffer attachment. Logical operations are applied only for signed and unsigned integer and normalized integer framebuffers. Logical operations are not applied to floating-point or sRGB format color attachments." Missing VKCTS coverage has been reported. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/12345 Cc: mesa-stable Signed-off-by: Samuel Pitoiset Part-of: --- src/amd/vulkan/radv_cmd_buffer.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c index 7823caf7a43..ae8a78aa43c 100644 --- a/src/amd/vulkan/radv_cmd_buffer.c +++ b/src/amd/vulkan/radv_cmd_buffer.c @@ -5183,6 +5183,7 @@ radv_emit_color_blend(struct radv_cmd_buffer *cmd_buffer) { struct radv_device *device = radv_cmd_buffer_device(cmd_buffer); const struct radv_physical_device *pdev = radv_device_physical(device); + const struct radv_rendering_state *render = &cmd_buffer->state.render; const enum amd_gfx_level gfx_level = pdev->info.gfx_level; const struct radv_dynamic_state *d = &cmd_buffer->state.dynamic; unsigned cb_blend_control[MAX_RTS], sx_mrt_blend_opt[MAX_RTS]; @@ -5206,6 +5207,12 @@ radv_emit_color_blend(struct radv_cmd_buffer *cmd_buffer) continue; if (!d->vk.cb.attachments[i].blend_enable) { + /* Disable logic op for float/srgb formats when blending isn't enabled. Otherwise it's + * implicitly disabled. + */ + if (vk_format_is_float(render->color_att[i].format) || vk_format_is_srgb(render->color_att[i].format)) + cb_blend_control[i] |= S_028780_DISABLE_ROP3(1); + sx_mrt_blend_opt[i] |= S_028760_COLOR_COMB_FCN(V_028760_OPT_COMB_BLEND_DISABLED) | S_028760_ALPHA_COMB_FCN(V_028760_OPT_COMB_BLEND_DISABLED); continue; @@ -9311,7 +9318,8 @@ radv_CmdBeginRendering(VkCommandBuffer commandBuffer, const VkRenderingInfo *pRe if (pdev->info.rbplus_allowed) cmd_buffer->state.dirty |= RADV_CMD_DIRTY_RBPLUS; - cmd_buffer->state.dirty_dynamic |= RADV_DYNAMIC_DEPTH_BIAS | RADV_DYNAMIC_STENCIL_TEST_ENABLE; + cmd_buffer->state.dirty_dynamic |= + RADV_DYNAMIC_DEPTH_BIAS | RADV_DYNAMIC_STENCIL_TEST_ENABLE | RADV_DYNAMIC_COLOR_BLEND_ENABLE; if (pdev->info.gfx_level >= GFX12) cmd_buffer->state.dirty_dynamic |= RADV_DYNAMIC_RASTERIZATION_SAMPLES;