draw/gs: track emitted prims + verts per stream.
authorDave Airlie <airlied@redhat.com>
Thu, 23 Jan 2020 06:18:29 +0000 (16:18 +1000)
committerMarge Bot <eric+marge@anholt.net>
Fri, 7 Feb 2020 00:54:42 +0000 (00:54 +0000)
This adds tracking of the emitted prims/verts per-stream.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3530>

src/gallium/auxiliary/draw/draw_gs.c
src/gallium/auxiliary/draw/draw_llvm.c

index 9f526ebb33c688a8e6f600c77194a0f19c042bd7..9cfec4dcf114244afb7d8c20e831bccfc2546b96 100644 (file)
@@ -326,18 +326,18 @@ llvm_fetch_gs_outputs(struct draw_geometry_shader *shader,
    unsigned next_prim_boundary = shader->primitive_boundary;
 
    for (i = 0; i < shader->vector_length; ++i) {
-      int prims = shader->llvm_emitted_primitives[i];
+      int prims = shader->llvm_emitted_primitives[i + (stream * shader->vector_length)];
       total_prims += prims;
       max_prims_per_invocation = MAX2(max_prims_per_invocation, prims);
    }
    for (i = 0; i < shader->vector_length; ++i) {
-      total_verts += shader->llvm_emitted_vertices[i];
+      total_verts += shader->llvm_emitted_vertices[i + (stream * shader->vector_length)];
    }
 
-   output_ptr += shader->stream[0].emitted_vertices * shader->vertex_size;
+   output_ptr += shader->stream[stream].emitted_vertices * shader->vertex_size;
    for (i = 0; i < shader->vector_length - 1; ++i) {
       int current_verts = shader->llvm_emitted_vertices[i];
-      int next_verts = shader->llvm_emitted_vertices[i + 1];
+      int next_verts = shader->llvm_emitted_vertices[i + 1 + (stream * shader->vector_length)];
 #if 0
       int j; 
       for (j = 0; j < current_verts; ++j) {
@@ -377,18 +377,18 @@ llvm_fetch_gs_outputs(struct draw_geometry_shader *shader,
 
    prim_idx = 0;
    for (i = 0; i < shader->vector_length; ++i) {
-      int num_prims = shader->llvm_emitted_primitives[i];
+      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->stream[0].primitive_lengths[shader->stream[0].emitted_primitives + prim_idx] =
+         shader->stream[stream].primitive_lengths[shader->stream[stream].emitted_primitives + prim_idx] =
             prim_length;
          ++prim_idx;
       }
    }
 
-   shader->stream[0].emitted_primitives += total_prims;
-   shader->stream[0].emitted_vertices += total_verts;
+   shader->stream[stream].emitted_primitives += total_prims;
+   shader->stream[stream].emitted_vertices += total_verts;
 }
 
 static void
@@ -878,8 +878,8 @@ draw_create_geometry_shader(struct draw_context *draw,
       memset(gs->gs_input, 0, sizeof(struct draw_gs_inputs));
       gs->llvm_prim_lengths = 0;
 
-      gs->llvm_emitted_primitives = align_malloc(vector_size, vector_size);
-      gs->llvm_emitted_vertices = align_malloc(vector_size, vector_size);
+      gs->llvm_emitted_primitives = align_malloc(vector_size * PIPE_MAX_VERTEX_STREAMS, vector_size);
+      gs->llvm_emitted_vertices = align_malloc(vector_size * PIPE_MAX_VERTEX_STREAMS, vector_size);
       gs->llvm_prim_ids = align_malloc(vector_size, vector_size);
 
       gs->fetch_outputs = llvm_fetch_gs_outputs;
index d8831187eeb4338fe8194274ef93a0f4e68a3968..0960124bafec27ce1b1727ee30fd4c02aa574b1a 100644 (file)
@@ -1609,13 +1609,10 @@ draw_gs_llvm_epilogue(const struct lp_build_gs_iface *gs_base,
       draw_gs_jit_emitted_vertices(gallivm, variant->context_ptr);
    LLVMValueRef emitted_prims_ptr =
       draw_gs_jit_emitted_prims(gallivm, variant->context_ptr);
-   LLVMValueRef zero = lp_build_const_int32(gallivm, 0);
-
-   if (stream > 0)
-      return;
-
-   emitted_verts_ptr = LLVMBuildGEP(builder, emitted_verts_ptr, &zero, 0, "");
-   emitted_prims_ptr = LLVMBuildGEP(builder, emitted_prims_ptr, &zero, 0, "");
+   LLVMValueRef stream_val = lp_build_const_int32(gallivm, stream);
+   
+   emitted_verts_ptr = LLVMBuildGEP(builder, emitted_verts_ptr, &stream_val, 1, "");
+   emitted_prims_ptr = LLVMBuildGEP(builder, emitted_prims_ptr, &stream_val, 1, "");
 
    LLVMBuildStore(builder, total_emitted_vertices_vec, emitted_verts_ptr);
    LLVMBuildStore(builder, emitted_prims_vec, emitted_prims_ptr);