mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-03 05:00:09 +01:00
ac/nir: return 0x76543210 for NULL FMASK fetch
This can replace several v_cndmask_b32 with a single v_cndmask_b32. fossil-db (Sienna Cichlid): Totals from 1169 (0.78% of 150170) affected shaders: SGPRs: 82032 -> 81984 (-0.06%); split: -0.19%, +0.13% VGPRs: 68368 -> 68280 (-0.13%); split: -0.30%, +0.18% SpillSGPRs: 8754 -> 8609 (-1.66%); split: -4.06%, +2.40% CodeSize: 5460132 -> 5446308 (-0.25%); split: -0.42%, +0.17% MaxWaves: 24456 -> 24462 (+0.02%); split: +0.03%, -0.01% Signed-off-by: Rhys Perry <pendingchaos02@gmail.com> Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12214>
This commit is contained in:
parent
bf0cc05227
commit
91a5c9fdf2
2 changed files with 20 additions and 13 deletions
|
|
@ -3348,6 +3348,16 @@ void ac_apply_fmask_to_sample(struct ac_llvm_context *ac, LLVMValueRef fmask, LL
|
|||
LLVMValueRef fmask_value = ac_build_image_opcode(ac, &fmask_load);
|
||||
fmask_value = LLVMBuildExtractElement(ac->builder, fmask_value, ac->i32_0, "");
|
||||
|
||||
/* Don't rewrite the sample index if WORD1.DATA_FORMAT of the FMASK
|
||||
* resource descriptor is 0 (invalid).
|
||||
*/
|
||||
LLVMValueRef tmp;
|
||||
tmp = LLVMBuildBitCast(ac->builder, fmask, ac->v8i32, "");
|
||||
tmp = LLVMBuildExtractElement(ac->builder, tmp, ac->i32_1, "");
|
||||
tmp = LLVMBuildICmp(ac->builder, LLVMIntNE, tmp, ac->i32_0, "");
|
||||
fmask_value =
|
||||
LLVMBuildSelect(ac->builder, tmp, fmask_value, LLVMConstInt(ac->i32, 0x76543210, false), "");
|
||||
|
||||
/* Apply the formula. */
|
||||
unsigned sample_chan = is_array_tex ? 3 : 2;
|
||||
LLVMValueRef final_sample;
|
||||
|
|
@ -3357,20 +3367,9 @@ void ac_apply_fmask_to_sample(struct ac_llvm_context *ac, LLVMValueRef fmask, LL
|
|||
LLVMBuildZExt(ac->builder, final_sample, ac->i32, ""), "");
|
||||
/* Mask the sample index by 0x7, because 0x8 means an unknown value
|
||||
* with EQAA, so those will map to 0. */
|
||||
final_sample = LLVMBuildAnd(ac->builder, final_sample, LLVMConstInt(ac->i32, 0x7, 0), "");
|
||||
addr[sample_chan] = LLVMBuildAnd(ac->builder, final_sample, LLVMConstInt(ac->i32, 0x7, 0), "");
|
||||
if (fmask_load.a16)
|
||||
final_sample = LLVMBuildTrunc(ac->builder, final_sample, ac->i16, "");
|
||||
|
||||
/* Don't rewrite the sample index if WORD1.DATA_FORMAT of the FMASK
|
||||
* resource descriptor is 0 (invalid).
|
||||
*/
|
||||
LLVMValueRef tmp;
|
||||
tmp = LLVMBuildBitCast(ac->builder, fmask, ac->v8i32, "");
|
||||
tmp = LLVMBuildExtractElement(ac->builder, tmp, ac->i32_1, "");
|
||||
tmp = LLVMBuildICmp(ac->builder, LLVMIntNE, tmp, ac->i32_0, "");
|
||||
|
||||
/* Replace the MSAA sample index. */
|
||||
addr[sample_chan] = LLVMBuildSelect(ac->builder, tmp, final_sample, addr[sample_chan], "");
|
||||
addr[sample_chan] = LLVMBuildTrunc(ac->builder, final_sample, ac->i16, "");
|
||||
}
|
||||
|
||||
static LLVMValueRef _ac_build_readlane(struct ac_llvm_context *ctx, LLVMValueRef src,
|
||||
|
|
|
|||
|
|
@ -4850,6 +4850,14 @@ static void visit_tex(struct ac_nir_context *ctx, nir_tex_instr *instr)
|
|||
LLVMValueRef two = LLVMConstInt(ctx->ac.i32, 2, false);
|
||||
LLVMValueRef layers = LLVMBuildExtractElement(ctx->ac.builder, result, two, "");
|
||||
result = LLVMBuildInsertElement(ctx->ac.builder, result, layers, ctx->ac.i32_1, "");
|
||||
} else if (instr->op == nir_texop_fragment_mask_fetch_amd) {
|
||||
/* Use 0x76543210 if the image doesn't have FMASK. */
|
||||
LLVMValueRef tmp = LLVMBuildBitCast(ctx->ac.builder, args.resource, ctx->ac.v8i32, "");
|
||||
tmp = LLVMBuildExtractElement(ctx->ac.builder, tmp, ctx->ac.i32_1, "");
|
||||
tmp = LLVMBuildICmp(ctx->ac.builder, LLVMIntNE, tmp, ctx->ac.i32_0, "");
|
||||
result = LLVMBuildSelect(ctx->ac.builder, tmp,
|
||||
LLVMBuildExtractElement(ctx->ac.builder, result, ctx->ac.i32_0, ""),
|
||||
LLVMConstInt(ctx->ac.i32, 0x76543210, false), "");
|
||||
} else if (nir_tex_instr_result_size(instr) != 4)
|
||||
result = ac_trim_vector(&ctx->ac, result, instr->dest.ssa.num_components);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue