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>
(cherry picked from commit 03b037a0e3)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33113>
This commit is contained in:
Samuel Pitoiset 2025-01-02 11:45:22 +01:00 committed by Dylan Baker
parent 2f364fa240
commit ded1ec58f7
2 changed files with 10 additions and 2 deletions

View file

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

View file

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