draw/tess: fix TES patch vertices in.
authorDave Airlie <airlied@redhat.com>
Mon, 6 Apr 2020 06:40:04 +0000 (16:40 +1000)
committerDave Airlie <airlied@redhat.com>
Mon, 27 Apr 2020 02:35:24 +0000 (12:35 +1000)
Fixes CTS KHR-GL45.tessellation_shader.single.max_patch_vertices

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

src/gallium/auxiliary/draw/draw_llvm.c
src/gallium/auxiliary/draw/draw_llvm.h
src/gallium/auxiliary/draw/draw_tess.c

index 3cfed5e65d874993c2848124d5d461d50150cb24..765cd1d84e1b6754857eee72c06e7c0e0c1c8c99 100644 (file)
@@ -3711,12 +3711,12 @@ draw_tes_llvm_generate(struct draw_llvm *llvm,
    LLVMContextRef context = gallivm->context;
    LLVMTypeRef int32_type = LLVMInt32TypeInContext(context);
    LLVMTypeRef flt_type = LLVMFloatTypeInContext(context);
-   LLVMTypeRef arg_types[9];
+   LLVMTypeRef arg_types[10];
    LLVMTypeRef func_type;
    LLVMValueRef variant_func;
    LLVMValueRef context_ptr;
    LLVMValueRef tess_coord[2], io_ptr, input_array, num_tess_coord;
-   LLVMValueRef tess_inner, tess_outer, prim_id;
+   LLVMValueRef tess_inner, tess_outer, prim_id, patch_vertices_in;
    LLVMBasicBlockRef block;
    LLVMBuilderRef builder;
    LLVMValueRef mask_val;
@@ -3750,6 +3750,7 @@ draw_tes_llvm_generate(struct draw_llvm *llvm,
    arg_types[6] = LLVMPointerType(flt_type, 0);
    arg_types[7] = LLVMPointerType(LLVMArrayType(flt_type, 4), 0);
    arg_types[8] = LLVMPointerType(LLVMArrayType(flt_type, 2), 0);
+   arg_types[9] = int32_type;
 
    func_type = LLVMFunctionType(int32_type, arg_types, ARRAY_SIZE(arg_types), 0);
    variant_func = LLVMAddFunction(gallivm->module, func_name, func_type);
@@ -3770,6 +3771,7 @@ draw_tes_llvm_generate(struct draw_llvm *llvm,
    tess_coord[1]             = LLVMGetParam(variant_func, 6);
    tess_outer                = LLVMGetParam(variant_func, 7);
    tess_inner                = LLVMGetParam(variant_func, 8);
+   patch_vertices_in         = LLVMGetParam(variant_func, 9);
 
    lp_build_name(context_ptr, "context");
    lp_build_name(input_array, "input");
@@ -3780,6 +3782,7 @@ draw_tes_llvm_generate(struct draw_llvm *llvm,
    lp_build_name(tess_coord[1], "tess_coord[1]");
    lp_build_name(tess_outer, "tess_outer");
    lp_build_name(tess_inner, "tess_inner");
+   lp_build_name(patch_vertices_in, "patch_vertices_in");
 
    tes_iface.base.fetch_vertex_input = draw_tes_llvm_fetch_vertex_input;
    tes_iface.base.fetch_patch_input = draw_tes_llvm_fetch_patch_input;
@@ -3815,6 +3818,8 @@ draw_tes_llvm_generate(struct draw_llvm *llvm,
    system_values.tess_inner = LLVMBuildLoad(builder, tess_inner, "");
 
    system_values.prim_id = lp_build_broadcast_scalar(&bldvec, prim_id);
+
+   system_values.vertices_in = lp_build_broadcast_scalar(&bldvec, patch_vertices_in);
    struct lp_build_loop_state lp_loop;
    lp_build_loop_begin(&lp_loop, gallivm, bld.zero);
    {
index d376a84c073b7c00aef1248aecd299358ca40ab9..b1c498631d28769008bcf6ef3bd137c236c7e997 100644 (file)
@@ -453,7 +453,7 @@ typedef int
                      struct vertex_header *io,
                      uint32_t prim_id, uint32_t num_tess_coord,
                      float *tess_coord_x, float *tess_coord_y, float *tess_outer,
-                     float *tess_inner);
+                     float *tess_inner, uint32_t patch_vertices_in);
 
 
 struct draw_llvm_variant_key
index 8bca7e25f61fbc4c0664a13835b03aac657a3fe4..f025d955f02c85228c19d1d69a8438a8b42efeab 100644 (file)
@@ -302,13 +302,14 @@ llvm_fetch_tess_factors(struct draw_tess_eval_shader *shader,
 static void
 llvm_tes_run(struct draw_tess_eval_shader *shader,
              uint32_t prim_id,
+             uint32_t patch_vertices_in,
              struct pipe_tessellator_data *tess_data,
              struct pipe_tessellation_factors *tess_factors,
              struct vertex_header *output)
 {
    shader->current_variant->jit_func(shader->jit_context, shader->tes_input->data, output, prim_id,
                                      tess_data->num_domain_points, tess_data->domain_points_u, tess_data->domain_points_v,
-                                     tess_factors->outer_tf, tess_factors->inner_tf);
+                                     tess_factors->outer_tf, tess_factors->inner_tf, patch_vertices_in);
 }
 #endif
 
@@ -391,7 +392,7 @@ int draw_tess_eval_shader_run(struct draw_tess_eval_shader *shader,
       /* run once per primitive? */
       char *output = (char *)output_verts->verts;
       output += vert_start * vertex_size;
-      llvm_tes_run(shader, i, &data, &factors, (struct vertex_header *)output);
+      llvm_tes_run(shader, i, num_input_vertices_per_patch, &data, &factors, (struct vertex_header *)output);
 
       uint32_t prim_len = u_prim_vertex_count(output_prims->prim)->min;
       output_prims->primitive_count += data.num_indices / prim_len;