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 <sroland@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22135>
This commit is contained in:
Mike Blumenkrantz
2023-03-23 12:48:53 -04:00
committed by Marge Bot
parent 6a5dcd2776
commit db1371cce1

View File

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