radv,aco: adjust the sample mask only if per-sample shading is enabled
When per-sample shading isn't enabled, we can just load the samplemask from the hardware which is always the coverage of the entire pixel/fragment. fossilds-db (VEGA10): Totals from 131 (0.10% of 136546) affected shaders: SGPRs: 5056 -> 5048 (-0.16%) VGPRs: 2600 -> 2372 (-8.77%) CodeSize: 115788 -> 112560 (-2.79%) MaxWaves: 1266 -> 1274 (+0.63%) Instrs: 20620 -> 20071 (-2.66%) Cycles: 82416 -> 80220 (-2.66%) VMEM: 51567 -> 35532 (-31.10%); split: +0.24%, -31.34% SMEM: 8952 -> 8258 (-7.75%); split: +0.11%, -7.86% SClause: 1223 -> 1199 (-1.96%); split: -2.62%, +0.65% Copies: 1247 -> 1124 (-9.86%); split: -10.18%, +0.32% PreVGPRs: 2112 -> 1981 (-6.20%) Helps Britannia, Shadow of the Tomb Raider, Warhammer II and Control. Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Reviewed-by: Timur Kristóf <timur.kristof@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7377>
This commit is contained in:
@@ -6810,12 +6810,17 @@ void visit_load_sample_mask_in(isel_context *ctx, nir_intrinsic_instr *instr) {
|
||||
|
||||
Builder bld(ctx->program, ctx->block);
|
||||
|
||||
Temp dst = get_ssa_temp(ctx, &instr->dest.ssa);
|
||||
|
||||
if (log2_ps_iter_samples) {
|
||||
Temp sample_id = bld.vop3(aco_opcode::v_bfe_u32, bld.def(v1),
|
||||
get_arg(ctx, ctx->args->ac.ancillary), Operand(8u), Operand(4u));
|
||||
Temp ps_iter_mask = bld.copy(bld.def(v1), Operand(ps_iter_masks[log2_ps_iter_samples]));
|
||||
Temp mask = bld.vop2(aco_opcode::v_lshlrev_b32, bld.def(v1), sample_id, ps_iter_mask);
|
||||
Temp dst = get_ssa_temp(ctx, &instr->dest.ssa);
|
||||
bld.vop2(aco_opcode::v_and_b32, Definition(dst), mask, get_arg(ctx, ctx->args->ac.sample_coverage));
|
||||
} else {
|
||||
bld.copy(Definition(dst), get_arg(ctx, ctx->args->ac.sample_coverage));
|
||||
}
|
||||
}
|
||||
|
||||
unsigned gs_outprim_vertices(unsigned outprim)
|
||||
|
@@ -758,10 +758,15 @@ static LLVMValueRef load_sample_mask_in(struct ac_shader_abi *abi)
|
||||
uint32_t ps_iter_mask = ps_iter_masks[log2_ps_iter_samples];
|
||||
|
||||
LLVMValueRef result, sample_id;
|
||||
if (log2_ps_iter_samples) {
|
||||
sample_id = ac_unpack_param(&ctx->ac, ac_get_arg(&ctx->ac, ctx->args->ac.ancillary), 8, 4);
|
||||
sample_id = LLVMBuildShl(ctx->ac.builder, LLVMConstInt(ctx->ac.i32, ps_iter_mask, false), sample_id, "");
|
||||
result = LLVMBuildAnd(ctx->ac.builder, sample_id,
|
||||
ac_get_arg(&ctx->ac, ctx->args->ac.sample_coverage), "");
|
||||
} else {
|
||||
result = ac_get_arg(&ctx->ac, ctx->args->ac.sample_coverage);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user