From 335938cffd10a7285b98999ad7a6bc8a4ed92ba1 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sat, 21 Mar 2020 06:54:26 +1000 Subject: [PATCH] llvmpipe: move color storing earlier in frag shader Move the color storage before the late Z test as for sample shading it needs to be inside a loop with the fragment shader. Reviewed-by: Roland Scheidegger Part-of: --- src/gallium/drivers/llvmpipe/lp_state_fs.c | 47 +++++++++++----------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index f09c49a1ff3..34ed257b5b0 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -726,6 +726,30 @@ generate_fs_loop(struct gallivm_state *gallivm, LLVMBuildStore(builder, output_smask, out_sample_mask_storage); } + /* Color write */ + for (attrib = 0; attrib < shader->info.base.num_outputs; ++attrib) + { + unsigned cbuf = shader->info.base.output_semantic_index[attrib]; + if ((shader->info.base.output_semantic_name[attrib] == TGSI_SEMANTIC_COLOR) && + ((cbuf < key->nr_cbufs) || (cbuf == 1 && dual_source_blend))) + { + for(chan = 0; chan < TGSI_NUM_CHANNELS; ++chan) { + if(outputs[attrib][chan]) { + /* XXX: just initialize outputs to point at colors[] and + * skip this. + */ + LLVMValueRef out = LLVMBuildLoad(builder, outputs[attrib][chan], ""); + LLVMValueRef color_ptr; + color_ptr = LLVMBuildGEP(builder, out_color[cbuf][chan], + &loop_state.counter, 1, ""); + lp_build_name(out, "color%u.%c", attrib, "rgba"[chan]); + LLVMBuildStore(builder, out, color_ptr); + } + } + } + } + + if (key->multisample) { /* execute depth test for each sample */ lp_build_for_loop_begin(&sample_loop_state, gallivm, @@ -841,29 +865,6 @@ generate_fs_loop(struct gallivm_state *gallivm, lp_build_for_loop_end(&sample_loop_state); } - /* Color write */ - for (attrib = 0; attrib < shader->info.base.num_outputs; ++attrib) - { - unsigned cbuf = shader->info.base.output_semantic_index[attrib]; - if ((shader->info.base.output_semantic_name[attrib] == TGSI_SEMANTIC_COLOR) && - ((cbuf < key->nr_cbufs) || (cbuf == 1 && dual_source_blend))) - { - for(chan = 0; chan < TGSI_NUM_CHANNELS; ++chan) { - if(outputs[attrib][chan]) { - /* XXX: just initialize outputs to point at colors[] and - * skip this. - */ - LLVMValueRef out = LLVMBuildLoad(builder, outputs[attrib][chan], ""); - LLVMValueRef color_ptr; - color_ptr = LLVMBuildGEP(builder, out_color[cbuf][chan], - &loop_state.counter, 1, ""); - lp_build_name(out, "color%u.%c", attrib, "rgba"[chan]); - LLVMBuildStore(builder, out, color_ptr); - } - } - } - } - if (key->occlusion_count) { LLVMValueRef counter = lp_jit_thread_data_counter(gallivm, thread_data_ptr); lp_build_name(counter, "counter");