radv: disable logic op for float/srgb formats

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 <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32826>
This commit is contained in:
Samuel Pitoiset 2025-01-02 11:45:22 +01:00 committed by Marge Bot
parent 0019900312
commit 03b037a0e3

View file

@ -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;