From 092f6226ea677812f0292cc96d0424067fa0c94e Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Mon, 8 Jun 2020 17:02:11 +1000 Subject: [PATCH] draw/gs: fix emitting inactive primitives crash Fixes dEQP-GLES31.functional.geometry_shading.emit.line_strip_emit_1_end_1 This test only emits 1 primitive, but the stores don't respect the current mask, which might only have one lane active, for that single primitive. Also fix the final emit path to use the emitted_mask rather than the current execution mask. Reviewed-by: Roland Scheidegger Part-of: --- src/gallium/auxiliary/draw/draw_llvm.c | 5 +++++ src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c index d4e0838..9fa9c7b 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.c +++ b/src/gallium/auxiliary/draw/draw_llvm.c @@ -1838,6 +1838,7 @@ draw_gs_llvm_end_primitive(const struct lp_build_gs_iface *gs_base, draw_gs_jit_prim_lengths(variant->gallivm, variant->context_ptr); unsigned i; + LLVMValueRef cond = LLVMBuildICmp(gallivm->builder, LLVMIntNE, mask_vec, lp_build_const_int_vec(gallivm, bld->type, 0), ""); for (i = 0; i < bld->type.length; ++i) { LLVMValueRef ind = lp_build_const_int32(gallivm, i); LLVMValueRef prims_emitted = @@ -1846,10 +1847,14 @@ draw_gs_llvm_end_primitive(const struct lp_build_gs_iface *gs_base, LLVMValueRef num_vertices = LLVMBuildExtractElement(builder, verts_per_prim_vec, ind, ""); + LLVMValueRef this_cond = LLVMBuildExtractElement(gallivm->builder, cond, ind, ""); + struct lp_build_if_state ifthen; + lp_build_if(&ifthen, gallivm, this_cond); store_ptr = LLVMBuildGEP(builder, prim_lengts_ptr, &prims_emitted, 1, ""); store_ptr = LLVMBuildLoad(builder, store_ptr, ""); store_ptr = LLVMBuildGEP(builder, store_ptr, &ind, 1, ""); LLVMBuildStore(builder, num_vertices, store_ptr); + lp_build_endif(&ifthen); } } diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c index 09ba529..542fd02 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c @@ -1555,7 +1555,7 @@ end_primitive_masked(struct lp_build_nir_context * bld_base, if (stream_id == 0) bld->gs_iface->end_primitive(bld->gs_iface, &bld->bld_base.base, total_emitted_vertices_vec, - emitted_vertices_vec, emitted_prims_vec, mask_vec(bld_base)); + emitted_vertices_vec, emitted_prims_vec, mask); increment_vec_ptr_by_mask(bld_base, bld->emitted_prims_vec_ptr[stream_id], mask); clear_uint_vec_ptr_from_mask(bld_base, bld->emitted_vertices_vec_ptr[stream_id], -- 2.7.4