gallivm/draw/gs: pass vertex stream count into shader build
authorDave Airlie <airlied@redhat.com>
Fri, 19 Jun 2020 04:54:16 +0000 (14:54 +1000)
committerDave Airlie <airlied@redhat.com>
Tue, 7 Jul 2020 20:06:05 +0000 (06:06 +1000)
The shader builder can avoid iterations using this info.

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

src/gallium/auxiliary/draw/draw_llvm.c
src/gallium/auxiliary/gallivm/lp_bld_nir.h
src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c
src/gallium/auxiliary/gallivm/lp_bld_tgsi.h

index 41018e82dcf55078288a61d2dc1253fdc279be7a..529b1b7f0c33525c20cb53bc4f4166c7c9906be3 100644 (file)
@@ -2855,6 +2855,7 @@ draw_gs_llvm_generate(struct draw_llvm *llvm,
    params.ssbo_ptr = ssbos_ptr;
    params.ssbo_sizes_ptr = num_ssbos_ptr;
    params.image = image;
+   params.gs_vertex_streams = variant->shader->base.num_vertex_streams;
 
    if (llvm->draw->gs.geometry_shader->state.type == PIPE_SHADER_IR_TGSI)
       lp_build_tgsi_soa(variant->gallivm,
index c124cd59ba8f7724a270dc6bea770236edc6707c..7f29575bad553283310de5460df517c131943d10 100644 (file)
@@ -235,6 +235,7 @@ struct lp_build_nir_soa_context
    LLVMValueRef inputs_array;
 
    LLVMValueRef kernel_args_ptr;
+   unsigned gs_vertex_streams;
 };
 
 bool
index 1a28e21f457d8cd883be875f2842a631157d1839..c6119c509f8f3ebdd3bfde5a7f207b0279f94f30 100644 (file)
@@ -1879,9 +1879,10 @@ void lp_build_nir_soa(struct gallivm_state *gallivm,
    if (bld.gs_iface) {
       struct lp_build_context *uint_bld = &bld.bld_base.uint_bld;
 
+      bld.gs_vertex_streams = params->gs_vertex_streams;
       bld.max_output_vertices_vec = lp_build_const_int_vec(gallivm, bld.bld_base.int_bld.type,
                                                            shader->info.gs.vertices_out);
-      for (int i = 0; i < PIPE_MAX_VERTEX_STREAMS; i++) {
+      for (int i = 0; i < params->gs_vertex_streams; i++) {
          bld.emitted_prims_vec_ptr[i] =
             lp_build_alloca(gallivm, uint_bld->vec_type, "emitted_prims_ptr");
          bld.emitted_vertices_vec_ptr[i] =
@@ -1904,7 +1905,7 @@ void lp_build_nir_soa(struct gallivm_state *gallivm,
       LLVMValueRef total_emitted_vertices_vec;
       LLVMValueRef emitted_prims_vec;
 
-      for (int i = 0; i < PIPE_MAX_VERTEX_STREAMS; i++) {
+      for (int i = 0; i < params->gs_vertex_streams; i++) {
          end_primitive_masked(&bld.bld_base, lp_build_mask_value(bld.mask), i);
 
          total_emitted_vertices_vec =
index de5cd4187ddb7acdbaa10aca547a0ab447af524f..4333e6d8e94a4f281b4701a3748d1f3c8147bd44 100644 (file)
@@ -279,6 +279,7 @@ struct lp_build_tgsi_params {
    const struct lp_build_coro_suspend_info *coro;
    LLVMValueRef kernel_args;
    const struct lp_build_fs_iface *fs_iface;
+   unsigned gs_vertex_streams;
 };
 
 void