gallivm: fix texture-mapping with 16-bit result
authorErik Faye-Lund <erik.faye-lund@collabora.com>
Tue, 17 Aug 2021 13:30:39 +0000 (15:30 +0200)
committerMarge Bot <eric+marge@anholt.net>
Wed, 18 Aug 2021 07:55:34 +0000 (07:55 +0000)
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@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12413>

src/gallium/auxiliary/gallivm/lp_bld_nir.c
src/gallium/drivers/llvmpipe/ci/deqp-llvmpipe-fails.txt

index 981db1f..e53e0fd 100644 (file)
@@ -2151,6 +2151,26 @@ static void visit_tex(struct lp_build_nir_context *bld_base, nir_tex_instr *inst
    params.ms_index = ms_index;
    params.aniso_filter_table = bld_base->aniso_filter_table;
    bld_base->tex(bld_base, &params);
+
+   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);
 }
 
index 1660d2e..4bbd9a6 100644 (file)
@@ -61,69 +61,3 @@ KHR-GL45.transform_feedback.draw_xfb_instanced_test,Crash
 KHR-GL45.transform_feedback.draw_xfb_stream_instanced_test,Crash
 KHR-GL45.transform_feedback.query_vertex_interleaved_test,Fail
 KHR-GL45.transform_feedback.query_vertex_separate_test,Fail
-KHR-GLES31.core.compute_shader.resource-image,Crash
-KHR-GLES31.core.geometry_shader.limits.max_texture_units,Fail
-KHR-GLES31.core.texture_gather.offset-gather-int-2darray,Crash
-KHR-GLES31.core.texture_gather.offset-gather-int-2d,Crash
-KHR-GLES31.core.texture_gather.offset-gather-uint-2darray,Crash
-KHR-GLES31.core.texture_gather.offset-gather-uint-2d,Crash
-KHR-GLES31.core.texture_gather.plain-gather-int-2darray,Crash
-KHR-GLES31.core.texture_gather.plain-gather-int-2d,Crash
-KHR-GLES31.core.texture_gather.plain-gather-int-cube-rgba,Crash
-KHR-GLES31.core.texture_gather.plain-gather-uint-2darray,Crash
-KHR-GLES31.core.texture_gather.plain-gather-uint-2d,Crash
-KHR-GLES31.core.texture_gather.plain-gather-uint-cube,Crash
-KHR-GLES3.texture_repeat_mode.r32ui_11x131_0_clamp_to_edge,Crash
-KHR-GLES3.texture_repeat_mode.r32ui_11x131_0_mirrored_repeat,Crash
-KHR-GLES3.texture_repeat_mode.r32ui_11x131_0_repeat,Crash
-KHR-GLES3.texture_repeat_mode.r32ui_11x131_1_clamp_to_edge,Crash
-KHR-GLES3.texture_repeat_mode.r32ui_11x131_1_mirrored_repeat,Crash
-KHR-GLES3.texture_repeat_mode.r32ui_11x131_1_repeat,Crash
-KHR-GLES3.texture_repeat_mode.r32ui_11x131_2_clamp_to_edge,Crash
-KHR-GLES3.texture_repeat_mode.r32ui_11x131_2_mirrored_repeat,Crash
-KHR-GLES3.texture_repeat_mode.r32ui_11x131_2_repeat,Crash
-KHR-GLES3.texture_repeat_mode.r32ui_49x23_0_clamp_to_edge,Crash
-KHR-GLES3.texture_repeat_mode.r32ui_49x23_0_mirrored_repeat,Crash
-KHR-GLES3.texture_repeat_mode.r32ui_49x23_0_repeat,Crash
-KHR-GLES3.texture_repeat_mode.r32ui_49x23_1_clamp_to_edge,Crash
-KHR-GLES3.texture_repeat_mode.r32ui_49x23_1_mirrored_repeat,Crash
-KHR-GLES3.texture_repeat_mode.r32ui_49x23_1_repeat,Crash
-KHR-GLES3.texture_repeat_mode.r32ui_49x23_2_clamp_to_edge,Crash
-KHR-GLES3.texture_repeat_mode.r32ui_49x23_2_mirrored_repeat,Crash
-KHR-GLES3.texture_repeat_mode.r32ui_49x23_2_repeat,Crash
-KHR-GLES3.texture_repeat_mode.rg32ui_11x131_0_clamp_to_edge,Crash
-KHR-GLES3.texture_repeat_mode.rg32ui_11x131_0_mirrored_repeat,Crash
-KHR-GLES3.texture_repeat_mode.rg32ui_11x131_0_repeat,Crash
-KHR-GLES3.texture_repeat_mode.rg32ui_11x131_1_clamp_to_edge,Crash
-KHR-GLES3.texture_repeat_mode.rg32ui_11x131_1_mirrored_repeat,Crash
-KHR-GLES3.texture_repeat_mode.rg32ui_11x131_1_repeat,Crash
-KHR-GLES3.texture_repeat_mode.rg32ui_11x131_2_clamp_to_edge,Crash
-KHR-GLES3.texture_repeat_mode.rg32ui_11x131_2_mirrored_repeat,Crash
-KHR-GLES3.texture_repeat_mode.rg32ui_11x131_2_repeat,Crash
-KHR-GLES3.texture_repeat_mode.rg32ui_49x23_0_clamp_to_edge,Crash
-KHR-GLES3.texture_repeat_mode.rg32ui_49x23_0_mirrored_repeat,Crash
-KHR-GLES3.texture_repeat_mode.rg32ui_49x23_0_repeat,Crash
-KHR-GLES3.texture_repeat_mode.rg32ui_49x23_1_clamp_to_edge,Crash
-KHR-GLES3.texture_repeat_mode.rg32ui_49x23_1_mirrored_repeat,Crash
-KHR-GLES3.texture_repeat_mode.rg32ui_49x23_1_repeat,Crash
-KHR-GLES3.texture_repeat_mode.rg32ui_49x23_2_clamp_to_edge,Crash
-KHR-GLES3.texture_repeat_mode.rg32ui_49x23_2_mirrored_repeat,Crash
-KHR-GLES3.texture_repeat_mode.rg32ui_49x23_2_repeat,Crash
-KHR-GLES3.texture_repeat_mode.rgba32ui_11x131_0_clamp_to_edge,Crash
-KHR-GLES3.texture_repeat_mode.rgba32ui_11x131_0_mirrored_repeat,Crash
-KHR-GLES3.texture_repeat_mode.rgba32ui_11x131_0_repeat,Crash
-KHR-GLES3.texture_repeat_mode.rgba32ui_11x131_1_clamp_to_edge,Crash
-KHR-GLES3.texture_repeat_mode.rgba32ui_11x131_1_mirrored_repeat,Crash
-KHR-GLES3.texture_repeat_mode.rgba32ui_11x131_1_repeat,Crash
-KHR-GLES3.texture_repeat_mode.rgba32ui_11x131_2_clamp_to_edge,Crash
-KHR-GLES3.texture_repeat_mode.rgba32ui_11x131_2_mirrored_repeat,Crash
-KHR-GLES3.texture_repeat_mode.rgba32ui_11x131_2_repeat,Crash
-KHR-GLES3.texture_repeat_mode.rgba32ui_49x23_0_clamp_to_edge,Crash
-KHR-GLES3.texture_repeat_mode.rgba32ui_49x23_0_mirrored_repeat,Crash
-KHR-GLES3.texture_repeat_mode.rgba32ui_49x23_0_repeat,Crash
-KHR-GLES3.texture_repeat_mode.rgba32ui_49x23_1_clamp_to_edge,Crash
-KHR-GLES3.texture_repeat_mode.rgba32ui_49x23_1_mirrored_repeat,Crash
-KHR-GLES3.texture_repeat_mode.rgba32ui_49x23_1_repeat,Crash
-KHR-GLES3.texture_repeat_mode.rgba32ui_49x23_2_clamp_to_edge,Crash
-KHR-GLES3.texture_repeat_mode.rgba32ui_49x23_2_mirrored_repeat,Crash
-KHR-GLES3.texture_repeat_mode.rgba32ui_49x23_2_repeat,Crash