From 1c9bf586e7b92a1918c3e379a96381c2dea85c12 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Fri, 19 Jun 2020 15:04:19 +1000 Subject: [PATCH] draw: account primitive lengths for all streams. For correct XFB queries all streams must get primitive lengths recorded. This allocates larger memory for per-stream lengths and the shader write into them. Fixes: GTF-GL41.gtf40.GL3Tests.transform_feedback3.transform_feedback3_streams_queried GTF-GL41.gtf40.GL3Tests.transform_feedback3.transform_feedback3_streams_overflow Reviewed-by: Roland Scheidegger Part-of: --- src/gallium/auxiliary/draw/draw_gs.c | 10 +++++----- src/gallium/auxiliary/draw/draw_llvm.c | 2 ++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/gallium/auxiliary/draw/draw_gs.c b/src/gallium/auxiliary/draw/draw_gs.c index f701e82b056..f648a96db7b 100644 --- a/src/gallium/auxiliary/draw/draw_gs.c +++ b/src/gallium/auxiliary/draw/draw_gs.c @@ -380,7 +380,7 @@ llvm_fetch_gs_outputs(struct draw_geometry_shader *shader, int num_prims = shader->llvm_emitted_primitives[i + (stream * shader->vector_length)]; for (j = 0; j < num_prims; ++j) { int prim_length = - shader->llvm_prim_lengths[j][i]; + shader->llvm_prim_lengths[j * shader->num_vertex_streams + stream][i]; shader->stream[stream].primitive_lengths[shader->stream[stream].emitted_primitives + prim_idx] = prim_length; ++prim_idx; @@ -645,14 +645,14 @@ int draw_geometry_shader_run(struct draw_geometry_shader *shader, if (max_out_prims > shader->max_out_prims) { unsigned i; if (shader->llvm_prim_lengths) { - for (i = 0; i < shader->max_out_prims; ++i) { + for (i = 0; i < shader->num_vertex_streams * shader->max_out_prims; ++i) { align_free(shader->llvm_prim_lengths[i]); } FREE(shader->llvm_prim_lengths); } - shader->llvm_prim_lengths = MALLOC(max_out_prims * sizeof(unsigned*)); - for (i = 0; i < max_out_prims; ++i) { + shader->llvm_prim_lengths = MALLOC(shader->num_vertex_streams * max_out_prims * sizeof(unsigned*)); + for (i = 0; i < shader->num_vertex_streams * max_out_prims; ++i) { int vector_size = shader->vector_length * sizeof(unsigned); shader->llvm_prim_lengths[i] = align_malloc(vector_size, vector_size); @@ -948,7 +948,7 @@ void draw_delete_geometry_shader(struct draw_context *draw, if (dgs->llvm_prim_lengths) { unsigned i; - for (i = 0; i < dgs->max_out_prims; ++i) { + for (i = 0; i < dgs->num_vertex_streams * dgs->max_out_prims; ++i) { align_free(dgs->llvm_prim_lengths[i]); } FREE(dgs->llvm_prim_lengths); diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c index 49abd6434c7..862c570efbf 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.c +++ b/src/gallium/auxiliary/draw/draw_llvm.c @@ -1850,6 +1850,8 @@ draw_gs_llvm_end_primitive(const struct lp_build_gs_iface *gs_base, LLVMValueRef this_cond = LLVMBuildExtractElement(gallivm->builder, cond, ind, ""); struct lp_build_if_state ifthen; lp_build_if(&ifthen, gallivm, this_cond); + prims_emitted = LLVMBuildMul(gallivm->builder, prims_emitted, lp_build_const_int32(gallivm, variant->shader->base.num_vertex_streams), ""); + prims_emitted = LLVMBuildAdd(gallivm->builder, prims_emitted, lp_build_const_int32(gallivm, stream), ""); store_ptr = LLVMBuildGEP(builder, prim_lengts_ptr, &prims_emitted, 1, ""); store_ptr = LLVMBuildLoad(builder, store_ptr, ""); store_ptr = LLVMBuildGEP(builder, store_ptr, &ind, 1, ""); -- 2.30.2