radeonsi: export mrtz before color exports

Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14266>
This commit is contained in:
Marek Olšák 2021-12-17 15:18:54 -05:00 committed by Marge Bot
parent e762bc751e
commit ca5f11ccd3

View file

@ -843,7 +843,6 @@ void si_llvm_build_ps_prolog(struct si_shader_context *ctx, union si_shader_part
*/
void si_llvm_build_ps_epilog(struct si_shader_context *ctx, union si_shader_part_key *key)
{
LLVMValueRef depth = NULL, stencil = NULL, samplemask = NULL;
int i;
struct si_ps_exports exp = {};
@ -872,6 +871,24 @@ void si_llvm_build_ps_epilog(struct si_shader_context *ctx, union si_shader_part
/* Disable elimination of unused inputs. */
ac_llvm_add_target_dep_function_attr(ctx->main_fn, "InitialPSInputAddr", 0xffffff);
/* Prepare the mrtz export. */
if (key->ps_epilog.writes_z ||
key->ps_epilog.writes_stencil ||
key->ps_epilog.writes_samplemask) {
LLVMValueRef depth = NULL, stencil = NULL, samplemask = NULL;
unsigned vgpr_index = ctx->args.num_sgprs_used +
util_bitcount(key->ps_epilog.colors_written) * 4;
if (key->ps_epilog.writes_z)
depth = LLVMGetParam(ctx->main_fn, vgpr_index++);
if (key->ps_epilog.writes_stencil)
stencil = LLVMGetParam(ctx->main_fn, vgpr_index++);
if (key->ps_epilog.writes_samplemask)
samplemask = LLVMGetParam(ctx->main_fn, vgpr_index++);
ac_export_mrt_z(&ctx->ac, depth, stencil, samplemask, false, &exp.args[exp.num++]);
}
/* Process colors. */
unsigned vgpr = ctx->args.num_sgprs_used;
unsigned num_compacted_mrts = 0;
@ -898,17 +915,6 @@ void si_llvm_build_ps_epilog(struct si_shader_context *ctx, union si_shader_part
ctx->args.arg_count - 1, color_type, &exp);
}
/* Process depth, stencil, samplemask. */
if (key->ps_epilog.writes_z)
depth = LLVMGetParam(ctx->main_fn, vgpr++);
if (key->ps_epilog.writes_stencil)
stencil = LLVMGetParam(ctx->main_fn, vgpr++);
if (key->ps_epilog.writes_samplemask)
samplemask = LLVMGetParam(ctx->main_fn, vgpr++);
if (depth || stencil || samplemask)
ac_export_mrt_z(&ctx->ac, depth, stencil, samplemask, false, &exp.args[exp.num++]);
if (exp.num) {
exp.args[exp.num - 1].valid_mask = 1; /* whether the EXEC mask is valid */
exp.args[exp.num - 1].done = 1; /* DONE bit */