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 <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5379>
This commit is contained in:
Dave Airlie
2020-06-08 17:02:11 +10:00
parent cc13ffffba
commit 092f6226ea
2 changed files with 6 additions and 1 deletions

View File

@@ -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);
}
}

View File

@@ -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],