From ded1ec58f7db302d117d2204615ea2a5b0d6d3e1 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 (cherry picked from commit 03b037a0e361ec984bebd032d1957122bdc08eb3) Part-of: --- .pick_status.json | 2 +- src/amd/vulkan/radv_cmd_buffer.c | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 2e12dccad00..a89de072ab9 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -234,7 +234,7 @@ "description": "radv: disable logic op for float/srgb formats", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c index d08aa5e38d5..ac18de3d76e 100644 --- a/src/amd/vulkan/radv_cmd_buffer.c +++ b/src/amd/vulkan/radv_cmd_buffer.c @@ -5228,6 +5228,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]; @@ -5251,6 +5252,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; @@ -9332,7 +9339,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;