draw: change geom shader output to an array of outputs.
authorDave Airlie <airlied@redhat.com>
Thu, 23 Jan 2020 06:17:25 +0000 (16:17 +1000)
committerMarge Bot <eric+marge@anholt.net>
Fri, 7 Feb 2020 00:54:42 +0000 (00:54 +0000)
Instead of a single output ptr, pass in one per output 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_gs.h
src/gallium/auxiliary/draw/draw_llvm.c
src/gallium/auxiliary/draw/draw_llvm.h

index 2d0a4773cbca262d987a1c95add007bae94d4fb9..9f526ebb33c688a8e6f600c77194a0f19c042bd7 100644 (file)
@@ -321,7 +321,7 @@ llvm_fetch_gs_outputs(struct draw_geometry_shader *shader,
    int vertex_count = 0;
    int total_prims = 0;
    int max_prims_per_invocation = 0;
-   char *output_ptr = (char*)shader->gs_output;
+   char *output_ptr = (char*)shader->gs_output[stream];
    int i, j, prim_idx;
    unsigned next_prim_boundary = shader->primitive_boundary;
 
@@ -402,20 +402,24 @@ static void
 llvm_gs_run(struct draw_geometry_shader *shader,
             unsigned input_primitives, unsigned *out_prims)
 {
-   unsigned ret;
-   char *input = (char*)shader->gs_output;
-
-   input += (shader->stream[0].emitted_vertices * shader->vertex_size);
+   struct vertex_header *input[PIPE_MAX_VERTEX_STREAMS];
+   for (unsigned i = 0; i < shader->num_vertex_streams; i++) {
+      char *tmp = (char *)shader->gs_output[i];
+      tmp += shader->stream[i].emitted_vertices * shader->vertex_size;
+      input[i] = (struct vertex_header *)tmp;
+   }
 
-   ret = shader->current_variant->jit_func(
+   shader->current_variant->jit_func(
       shader->jit_context, shader->gs_input->data,
-      (struct vertex_header*)input,
+      input,
       input_primitives,
       shader->draw->instance_id,
       shader->llvm_prim_ids,
       shader->invocation_id);
 
-   *out_prims = ret;
+   for (unsigned i = 0; i < shader->num_vertex_streams; i++) {
+      out_prims[i] = shader->jit_context->emitted_prims[i];
+   }
 }
 
 #endif
@@ -634,7 +638,9 @@ int draw_geometry_shader_run(struct draw_geometry_shader *shader,
 
 #ifdef LLVM_AVAILABLE
    if (shader->draw->llvm) {
-      shader->gs_output = output_verts[0].verts;
+      for (i = 0; i < shader->num_vertex_streams; i++) {
+         shader->gs_output[i] = output_verts[i].verts;
+      }
       if (max_out_prims > shader->max_out_prims) {
          unsigned i;
          if (shader->llvm_prim_lengths) {
index 9a86910c1e6f01cd00199b24450125acf089d40a..0078f909c3af4453f98c49e5be89e699afeb194b 100644 (file)
@@ -100,7 +100,7 @@ struct draw_geometry_shader {
    struct draw_gs_inputs *gs_input;
    struct draw_gs_jit_context *jit_context;
    struct draw_gs_llvm_variant *current_variant;
-   struct vertex_header *gs_output;
+   struct vertex_header *gs_output[PIPE_MAX_VERTEX_STREAMS];
 
    int **llvm_prim_lengths;
    int *llvm_emitted_primitives;
index f1ca2dbd5a09d6e16bd5b4f9b35240ea7eafc045..d8831187eeb4338fe8194274ef93a0f4e68a3968 100644 (file)
@@ -1557,6 +1557,8 @@ draw_gs_llvm_emit_vertex(const struct lp_build_gs_iface *gs_base,
       indices[i] = LLVMBuildAdd(builder, indices[i], currently_emitted, "");
    }
 
+   io = lp_build_pointer_get(builder, io, LLVMBuildExtractElement(builder, stream_id, lp_build_const_int32(gallivm, 0), ""));
+
    convert_to_aos(gallivm, io, indices,
                   outputs, clipmask,
                   gs_info->num_outputs, gs_type,
@@ -2432,7 +2434,7 @@ draw_gs_llvm_generate(struct draw_llvm *llvm,
 
    arg_types[0] = get_gs_context_ptr_type(variant);    /* context */
    arg_types[1] = variant->input_array_type;           /* input */
-   arg_types[2] = variant->vertex_header_ptr_type;     /* vertex_header */
+   arg_types[2] = LLVMPointerType(variant->vertex_header_ptr_type, 0);     /* vertex_header */
    arg_types[3] = int32_type;                          /* num_prims */
    arg_types[4] = int32_type;                          /* instance_id */
    arg_types[5] = LLVMPointerType(
index 6edc89b63bacc9d9810f4d48a3f4e01553816cdf..aa5c374a647e35abe4c3a39680ee90e302dc8e2e 100644 (file)
@@ -335,7 +335,7 @@ typedef boolean
 typedef int
 (*draw_gs_jit_func)(struct draw_gs_jit_context *context,
                     float inputs[6][PIPE_MAX_SHADER_INPUTS][TGSI_NUM_CHANNELS][TGSI_NUM_CHANNELS],
-                    struct vertex_header *output,
+                    struct vertex_header **output,
                     unsigned num_prims,
                     unsigned instance_id,
                     int *prim_ids,