From fe5a8e1ace61cead276d0293c595536b1b9e48c8 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Mon, 6 Apr 2020 16:40:04 +1000 Subject: [PATCH] draw/tess: fix TES patch vertices in. Fixes CTS KHR-GL45.tessellation_shader.single.max_patch_vertices Reviewed-by: Roland Scheidegger Part-of: --- src/gallium/auxiliary/draw/draw_llvm.c | 9 +++++++-- src/gallium/auxiliary/draw/draw_llvm.h | 2 +- src/gallium/auxiliary/draw/draw_tess.c | 5 +++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c index 3cfed5e65d8..765cd1d84e1 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.c +++ b/src/gallium/auxiliary/draw/draw_llvm.c @@ -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); { diff --git a/src/gallium/auxiliary/draw/draw_llvm.h b/src/gallium/auxiliary/draw/draw_llvm.h index d376a84c073..b1c498631d2 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.h +++ b/src/gallium/auxiliary/draw/draw_llvm.h @@ -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 diff --git a/src/gallium/auxiliary/draw/draw_tess.c b/src/gallium/auxiliary/draw/draw_tess.c index 8bca7e25f61..f025d955f02 100644 --- a/src/gallium/auxiliary/draw/draw_tess.c +++ b/src/gallium/auxiliary/draw/draw_tess.c @@ -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; -- 2.30.2