Mesa (staging/21.2): gallivm: fix texture-mapping with 16-bit result
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Aug 19 18:16:09 UTC 2021
Module: Mesa
Branch: staging/21.2
Commit: 1133671ea3b207975c1df761c2c5a6516f7ef1be
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1133671ea3b207975c1df761c2c5a6516f7ef1be
Author: Erik Faye-Lund <erik.faye-lund at collabora.com>
Date: Tue Aug 17 15:30:39 2021 +0200
gallivm: fix texture-mapping with 16-bit result
16bit integer support also implies using 16-bit results when sampling
textures.
Because we're returning the results in float SSA values instead of int,
we need to bitcast back to integers before truncating the values.
Fixes: 00ff60f799c ("gallivm: add 16-bit integer support")
Reviewed-by: Roland Scheidegger <sroland at vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12413>
(cherry picked from commit 45a61f1782561da9a7905bf584cd188d7b108c98)
---
.pick_status.json | 2 +-
src/gallium/auxiliary/gallivm/lp_bld_nir.c | 20 ++++++++++++++++++++
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/.pick_status.json b/.pick_status.json
index 546b523a52c..9823a8c4fe4 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -121,7 +121,7 @@
"description": "gallivm: fix texture-mapping with 16-bit result",
"nominated": true,
"nomination_type": 1,
- "resolution": 0,
+ "resolution": 1,
"main_sha": null,
"because_sha": "00ff60f799c3e8a2d0c4d7933b60b3f8f69f092c"
},
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir.c b/src/gallium/auxiliary/gallivm/lp_bld_nir.c
index 6795090053e..249e8f63a8e 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_nir.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_nir.c
@@ -2110,6 +2110,26 @@ static void visit_tex(struct lp_build_nir_context *bld_base, nir_tex_instr *inst
params.lod = explicit_lod;
params.ms_index = ms_index;
bld_base->tex(bld_base, ¶ms);
+
+ if (nir_dest_bit_size(instr->dest) != 32) {
+ assert(nir_dest_bit_size(instr->dest) == 16);
+ LLVMTypeRef vec_type;
+ switch (nir_alu_type_get_base_type(instr->dest_type)) {
+ case nir_type_int:
+ vec_type = bld_base->int16_bld.vec_type;
+ break;
+ case nir_type_uint:
+ vec_type = bld_base->uint16_bld.vec_type;
+ break;
+ default:
+ unreachable("unexpected alu type");
+ }
+ for (int i = 0; i < nir_dest_num_components(instr->dest); ++i) {
+ texel[i] = LLVMBuildBitCast(builder, texel[i], bld_base->int_bld.vec_type, "");
+ texel[i] = LLVMBuildTrunc(builder, texel[i], vec_type, "");
+ }
+ }
+
assign_dest(bld_base, &instr->dest, texel);
}
More information about the mesa-commit
mailing list