From 0c77007c9db74c3859f75dcd5161396ae5c16772 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Thu, 23 Jan 2020 16:17:25 +1000 Subject: [PATCH] draw: change geom shader output to an array of outputs. Instead of a single output ptr, pass in one per output stream. Reviewed-by: Roland Scheidegger Part-of: --- src/gallium/auxiliary/draw/draw_gs.c | 24 +++++++++++++++--------- src/gallium/auxiliary/draw/draw_gs.h | 2 +- src/gallium/auxiliary/draw/draw_llvm.c | 4 +++- src/gallium/auxiliary/draw/draw_llvm.h | 2 +- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/gallium/auxiliary/draw/draw_gs.c b/src/gallium/auxiliary/draw/draw_gs.c index 2d0a4773cbc..9f526ebb33c 100644 --- a/src/gallium/auxiliary/draw/draw_gs.c +++ b/src/gallium/auxiliary/draw/draw_gs.c @@ -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) { diff --git a/src/gallium/auxiliary/draw/draw_gs.h b/src/gallium/auxiliary/draw/draw_gs.h index 9a86910c1e6..0078f909c3a 100644 --- a/src/gallium/auxiliary/draw/draw_gs.h +++ b/src/gallium/auxiliary/draw/draw_gs.h @@ -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; diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c index f1ca2dbd5a0..d8831187eeb 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.c +++ b/src/gallium/auxiliary/draw/draw_llvm.c @@ -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( diff --git a/src/gallium/auxiliary/draw/draw_llvm.h b/src/gallium/auxiliary/draw/draw_llvm.h index 6edc89b63ba..aa5c374a647 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.h +++ b/src/gallium/auxiliary/draw/draw_llvm.h @@ -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, -- 2.30.2