Module: Mesa Branch: staging/23.1 Commit: 32609de1da8658c553f14ee4a6c55116a05e9495 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=32609de1da8658c553f14ee4a6c55116a05e9495
Author: Samuel Pitoiset <[email protected]> Date: Tue Sep 26 16:37:28 2023 +0200 radv: stop skip emitting CB states when there is no color attachment This is actually wrong. For example, if there is a DCC decompress draw followed by a draw without any color attachments, CB_COLOR_CONTROL.MODE is still CB_DCC_DECOMPRESS but it should be CB_DISABLED. For some reasons, this hangs on RDNA3 (VM faults are also reported through dmesg). This fixes GPU hangs with Resident Evil 6, Star Wars The Old Republic and probably more games on RDNA3. Strictly speaking, I don't think this dynamic state optimization is worth a try, even for other states, and I think it would be safer to remove it completely. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/9335 Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/8327 Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/9878 Fixes: c08082e8615 ("radv: ignore all CB dynamic states when there is no color attachments") Signed-off-by: Samuel Pitoiset <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25402> (cherry picked from commit af2a96bb37b099067adb490d189399b46324b46f) --- .pick_status.json | 2 +- src/amd/vulkan/radv_pipeline_graphics.c | 59 ++++++++++++++++----------------- 2 files changed, 30 insertions(+), 31 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 776f90682bf..c833019b7bf 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -355,7 +355,7 @@ "description": "radv: stop skip emitting CB states when there is no color attachment", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "c08082e86151e88c1a0677914bc365910c82714a" }, diff --git a/src/amd/vulkan/radv_pipeline_graphics.c b/src/amd/vulkan/radv_pipeline_graphics.c index 6670d64396a..3cfb5acd504 100644 --- a/src/amd/vulkan/radv_pipeline_graphics.c +++ b/src/amd/vulkan/radv_pipeline_graphics.c @@ -629,9 +629,6 @@ radv_pipeline_needed_dynamic_state(const struct radv_device *device, if (!has_color_att || !radv_pipeline_is_blend_enabled(pipeline, state->cb)) states &= ~RADV_DYNAMIC_BLEND_CONSTANTS; - if (!has_color_att) - states &= ~RADV_DYNAMIC_CB_STATES; - if (!(pipeline->active_stages & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT)) states &= ~(RADV_DYNAMIC_PATCH_CONTROL_POINTS | RADV_DYNAMIC_TESS_DOMAIN_ORIGIN); @@ -1135,42 +1132,44 @@ radv_pipeline_init_dynamic_state(const struct radv_device *device, typed_memcpy(dynamic->vk.cb.blend_constants, state->cb->blend_constants, 4); } - if (states & RADV_DYNAMIC_LOGIC_OP) { - if ((pipeline->dynamic_states & RADV_DYNAMIC_LOGIC_OP_ENABLE) || state->cb->logic_op_enable) { - dynamic->vk.cb.logic_op = si_translate_blend_logic_op(state->cb->logic_op); + if (radv_pipeline_has_color_attachments(state->rp)) { + if (states & RADV_DYNAMIC_LOGIC_OP) { + if ((pipeline->dynamic_states & RADV_DYNAMIC_LOGIC_OP_ENABLE) || state->cb->logic_op_enable) { + dynamic->vk.cb.logic_op = si_translate_blend_logic_op(state->cb->logic_op); + } } - } - if (states & RADV_DYNAMIC_COLOR_WRITE_ENABLE) { - dynamic->vk.cb.color_write_enables = state->cb->color_write_enables; - } + if (states & RADV_DYNAMIC_COLOR_WRITE_ENABLE) { + dynamic->vk.cb.color_write_enables = state->cb->color_write_enables; + } - if (states & RADV_DYNAMIC_LOGIC_OP_ENABLE) { - dynamic->vk.cb.logic_op_enable = state->cb->logic_op_enable; - } + if (states & RADV_DYNAMIC_LOGIC_OP_ENABLE) { + dynamic->vk.cb.logic_op_enable = state->cb->logic_op_enable; + } - if (states & RADV_DYNAMIC_COLOR_WRITE_MASK) { - for (unsigned i = 0; i < state->cb->attachment_count; i++) { - dynamic->vk.cb.attachments[i].write_mask = state->cb->attachments[i].write_mask; + if (states & RADV_DYNAMIC_COLOR_WRITE_MASK) { + for (unsigned i = 0; i < state->cb->attachment_count; i++) { + dynamic->vk.cb.attachments[i].write_mask = state->cb->attachments[i].write_mask; + } } - } - if (states & RADV_DYNAMIC_COLOR_BLEND_ENABLE) { - for (unsigned i = 0; i < state->cb->attachment_count; i++) { - dynamic->vk.cb.attachments[i].blend_enable = state->cb->attachments[i].blend_enable; + if (states & RADV_DYNAMIC_COLOR_BLEND_ENABLE) { + for (unsigned i = 0; i < state->cb->attachment_count; i++) { + dynamic->vk.cb.attachments[i].blend_enable = state->cb->attachments[i].blend_enable; + } } - } - if (states & RADV_DYNAMIC_COLOR_BLEND_EQUATION) { - for (unsigned i = 0; i < state->cb->attachment_count; i++) { - const struct vk_color_blend_attachment_state *att = &state->cb->attachments[i]; + if (states & RADV_DYNAMIC_COLOR_BLEND_EQUATION) { + for (unsigned i = 0; i < state->cb->attachment_count; i++) { + const struct vk_color_blend_attachment_state *att = &state->cb->attachments[i]; - dynamic->vk.cb.attachments[i].src_color_blend_factor = att->src_color_blend_factor; - dynamic->vk.cb.attachments[i].dst_color_blend_factor = att->dst_color_blend_factor; - dynamic->vk.cb.attachments[i].color_blend_op = att->color_blend_op; - dynamic->vk.cb.attachments[i].src_alpha_blend_factor = att->src_alpha_blend_factor; - dynamic->vk.cb.attachments[i].dst_alpha_blend_factor = att->dst_alpha_blend_factor; - dynamic->vk.cb.attachments[i].alpha_blend_op = att->alpha_blend_op; + dynamic->vk.cb.attachments[i].src_color_blend_factor = att->src_color_blend_factor; + dynamic->vk.cb.attachments[i].dst_color_blend_factor = att->dst_color_blend_factor; + dynamic->vk.cb.attachments[i].color_blend_op = att->color_blend_op; + dynamic->vk.cb.attachments[i].src_alpha_blend_factor = att->src_alpha_blend_factor; + dynamic->vk.cb.attachments[i].dst_alpha_blend_factor = att->dst_alpha_blend_factor; + dynamic->vk.cb.attachments[i].alpha_blend_op = att->alpha_blend_op; + } } }
