From 2077421437038e3bd73544c34f567601b912ce09 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Thu, 2 Apr 2020 07:09:50 +0200 Subject: [PATCH] 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 Reviewed-by: Brian Paul Tested-by: Marge Bot Part-of: --- 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); -- 2.30.2