mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 11:48:06 +02:00
ac/llvm: rework component trimming in visit_tex
The referenced commit was a step in the right direction, but not complete. ac_build_image_opcode returns a vec<4> or a struct<vec<4>, int> so we can simplify visit_tex. We just need to map these 4/5 values to the expected layout from NIR. eg: depth + TFE would produces "<d, x, x, x>, t" so it has to be transformed into <d, t>. nir_texop_fragment_mask_fetch_amd + sparse doesn't exist, so it's another opportunity for simplification. This is required to get KHR-GL46.sparse_texture2_tests.SparseTexture2Lookup_texture_2d_depth_component16 working properly. The same test fails with ACO so it probably needs a change in the same area. Fixes:c0ef2aa7f8("DEPENDENCY: ac/llvm: fix sparse code handling") Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35206> (cherry picked from commit4a84ebfcb1)
This commit is contained in:
parent
49d98e15ba
commit
e5e959b0fd
2 changed files with 14 additions and 16 deletions
|
|
@ -3374,7 +3374,7 @@
|
|||
"description": "ac/llvm: rework component trimming in visit_tex",
|
||||
"nominated": true,
|
||||
"nomination_type": 2,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": "c0ef2aa7f8b34f17ce1907b9a16eb0df46067206",
|
||||
"notes": null
|
||||
|
|
|
|||
|
|
@ -3726,16 +3726,7 @@ static void visit_tex(struct ac_nir_context *ctx, nir_tex_instr *instr)
|
|||
|
||||
result = build_tex_intrinsic(ctx, instr, &args);
|
||||
|
||||
LLVMValueRef code = NULL;
|
||||
if (instr->is_sparse) {
|
||||
unsigned num_color_components = num_components - 1;
|
||||
code = ac_llvm_extract_elem(&ctx->ac, result, num_color_components);
|
||||
result = ac_trim_vector(&ctx->ac, result, num_color_components);
|
||||
}
|
||||
|
||||
if (is_new_style_shadow)
|
||||
result = LLVMBuildExtractElement(ctx->ac.builder, result, ctx->ac.i32_0, "");
|
||||
else if (instr->op == nir_texop_fragment_mask_fetch_amd) {
|
||||
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, "");
|
||||
|
|
@ -3744,12 +3735,19 @@ static void visit_tex(struct ac_nir_context *ctx, nir_tex_instr *instr)
|
|||
LLVMBuildExtractElement(ctx->ac.builder, result, ctx->ac.i32_0, ""),
|
||||
LLVMConstInt(ctx->ac.i32, 0x76543210, false), "");
|
||||
} else {
|
||||
unsigned num_color_components = num_components - (instr->is_sparse ? 1 : 0);
|
||||
result = ac_trim_vector(&ctx->ac, result, num_color_components);
|
||||
}
|
||||
/* ac_build_image_opcode always returns 4 components plus 1 optional value
|
||||
* containing residency information. Adjust result to match the output expected by
|
||||
* the NIR instruction.
|
||||
*/
|
||||
LLVMValueRef code = NULL;
|
||||
if (instr->is_sparse)
|
||||
code = ac_llvm_extract_elem(&ctx->ac, result, 4);
|
||||
|
||||
if (instr->is_sparse)
|
||||
result = ac_build_concat(&ctx->ac, result, code);
|
||||
result = ac_trim_vector(&ctx->ac, result, num_components - (instr->is_sparse ? 1 : 0));
|
||||
|
||||
if (code)
|
||||
result = ac_build_concat(&ctx->ac, result, code);
|
||||
}
|
||||
|
||||
if (result) {
|
||||
result = ac_to_integer(&ctx->ac, result);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue