From: Roland Scheidegger Date: Thu, 2 Apr 2020 05:09:50 +0000 (+0200) Subject: gallivm: fix stream id fetch X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2077421437038e3bd73544c34f567601b912ce09;p=mesa.git 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: --- 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);