Module: Mesa Branch: staging/23.0 Commit: b7a419389936bbd1b2ce0e9bc9765df3898e4fc8 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b7a419389936bbd1b2ce0e9bc9765df3898e4fc8
Author: Mike Blumenkrantz <[email protected]> Date: Thu Mar 23 12:48:53 2023 -0400 llvmpipe: fix handling of unused color attachments if an attachment doesn't have blending or color output from the shader, nothing should touch the attachment this is consistent with vulkan spec and needed for upcoming cts coverage cc: mesa-stable Reviewed-by: Roland Scheidegger <[email protected]> Reviewed-by: Brian Paul <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22135> (cherry picked from commit db1371cce1d4e0f0f4fa2518379db78efde53ea4) --- .pick_status.json | 2 +- src/gallium/drivers/llvmpipe/lp_state_fs.c | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index ce38d8cb112..8515dedd473 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -1453,7 +1453,7 @@ "description": "llvmpipe: fix handling of unused color attachments", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null }, diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index 61bbbf43d59..2a74b8a695a 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -3466,7 +3466,9 @@ generate_fragment(struct llvmpipe_context *lp, /* Loop over color outputs / color buffers to do blending */ for (unsigned cbuf = 0; cbuf < key->nr_cbufs; cbuf++) { - if (key->cbuf_format[cbuf] != PIPE_FORMAT_NONE) { + if (key->cbuf_format[cbuf] != PIPE_FORMAT_NONE && + (key->blend.rt[cbuf].blend_enable || key->blend.logicop_enable || + find_output_by_semantic(&shader->info.base, TGSI_SEMANTIC_COLOR, cbuf) != -1)) { LLVMValueRef color_ptr; LLVMValueRef stride; LLVMValueRef sample_stride = NULL; @@ -3971,7 +3973,12 @@ llvmpipe_create_fs_state(struct pipe_context *pipe, shader->base.tokens = tgsi_dup_tokens(templ->tokens); } else { shader->base.ir.nir = templ->ir.nir; - nir_tgsi_scan_shader(templ->ir.nir, &shader->info.base, true); + + /* lower FRAG_RESULT_COLOR -> DATA[0-7] to correctly handle unused attachments */ + nir_shader *nir = shader->base.ir.nir; + NIR_PASS_V(nir, nir_lower_fragcolor, nir->info.fs.color_is_dual_source ? 1 : 8); + + nir_tgsi_scan_shader(nir, &shader->info.base, true); } shader->draw_data = draw_create_fragment_shader(llvmpipe->draw, templ);
