Mesa (master): gallivm: fix stream id fetch

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Apr 2 16:15:45 UTC 2020


Module: Mesa
Branch: master
Commit: 2077421437038e3bd73544c34f567601b912ce09
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=2077421437038e3bd73544c34f567601b912ce09

Author: Roland Scheidegger <sroland at vmware.com>
Date:   Thu Apr  2 07:09:50 2020 +0200

gallivm: fix stream id fetch

Fetching the stream id directly can crash since bld->immediates may not
exist (if there's too many immediates or we use the array due to indirect
accesses). So just call emit_fetch_immediate instead.

v2: fix the swizzle

Reviewed-by: Dave Airlie <airlied at redhat.com>
Reviewed-by: Brian Paul <brianp at vmware.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4416>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4416>

---

 src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
index 0ab1aa1fe02..67c7cc7b270 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
@@ -3946,14 +3946,13 @@ emit_vertex(
    LLVMBuilderRef builder = bld->bld_base.base.gallivm->builder;
 
    if (bld->gs_iface->emit_vertex) {
-      uint32_t stream_reg_idx = emit_data->inst->Src[0].Register.Index;
-      uint32_t stream_reg_swiz = emit_data->inst->Src[0].Register.SwizzleX;
-      LLVMValueRef stream_id = bld->immediates[stream_reg_idx][stream_reg_swiz];
+      LLVMValueRef stream_id = emit_fetch_immediate(bld_base, &emit_data->inst->Src[0],
+                                                    TGSI_TYPE_UNSIGNED,
+                                                    emit_data->inst->Src[0].Register.SwizzleX);
       LLVMValueRef mask = mask_vec(bld_base);
       LLVMValueRef total_emitted_vertices_vec =
          LLVMBuildLoad(builder, bld->total_emitted_vertices_vec_ptr, "");
 
-      stream_id = LLVMBuildBitCast(builder, stream_id, bld_base->uint_bld.vec_type, "");
       mask = clamp_mask_to_max_output_vertices(bld, mask,
                                                total_emitted_vertices_vec);
       gather_outputs(bld);



More information about the mesa-commit mailing list