From f19f3f5496de7e65a937ccf88812d303d0054a8f Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Wed, 26 May 2021 15:53:46 +1000 Subject: [PATCH] draw/tess: write correct primitive id into vertices The code was using a prim assembler after the tess stage, however tess prims aren't necessarily the output prim types, so just put the prim ids into the vertices at tess stage, and skip prim assembly. Reviewed-by: Roland Scheidegger Part-of: --- src/gallium/auxiliary/draw/draw_llvm.c | 19 ++++++++++++++++++- src/gallium/auxiliary/draw/draw_llvm.h | 2 ++ .../draw/draw_pt_fetch_shade_pipeline_llvm.c | 2 +- .../llvmpipe/ci/llvmpipe-quick_shader.txt | 1 - 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c index 357314268f4..05d2390ee13 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.c +++ b/src/gallium/auxiliary/draw/draw_llvm.c @@ -3992,6 +3992,14 @@ draw_tes_llvm_generate(struct draw_llvm *llvm, system_values.view_index = view_index; system_values.vertices_in = lp_build_broadcast_scalar(&bldvec, patch_vertices_in); + + if (variant->key.primid_needed) { + int slot = variant->key.primid_output; + for (unsigned i = 0; i < 4; i++) { + outputs[slot][i] = lp_build_alloca(gallivm, lp_build_int_vec_type(gallivm, tes_type), "primid"); + LLVMBuildStore(builder, system_values.prim_id, outputs[slot][i]); + } + } struct lp_build_loop_state lp_loop; lp_build_loop_begin(&lp_loop, gallivm, bld.zero); { @@ -4048,7 +4056,7 @@ draw_tes_llvm_generate(struct draw_llvm *llvm, lp_int_type(tes_type), 0); convert_to_aos(gallivm, io, NULL, outputs, clipmask, - params.info->num_outputs, tes_type, FALSE); + draw_total_tes_outputs(llvm->draw), tes_type, FALSE); } lp_build_loop_end_cond(&lp_loop, num_tess_coord, step, LLVMIntUGE); sampler->destroy(sampler); @@ -4161,6 +4169,12 @@ draw_tes_llvm_make_variant_key(struct draw_llvm *llvm, char *store) memset(key, 0, offsetof(struct draw_tes_llvm_variant_key, samplers[0])); + int primid_output = draw_find_shader_output(llvm->draw, TGSI_SEMANTIC_PRIMID, 0); + if (primid_output >= 0) { + key->primid_output = primid_output; + key->primid_needed = true; + } + /* All variants of this shader will have the same value for * nr_samplers. Not yet trying to compact away holes in the * sampler array. @@ -4205,6 +4219,9 @@ draw_tes_llvm_dump_variant_key(struct draw_tes_llvm_variant_key *key) unsigned i; struct draw_sampler_static_state *sampler = key->samplers; struct draw_image_static_state *image = draw_tes_llvm_variant_key_images(key); + + if (key->primid_needed) + debug_printf("prim id output %d\n", key->primid_output); for (i = 0 ; i < key->nr_sampler_views; i++) { debug_printf("sampler[%i].src_format = %s\n", i, util_format_name(sampler[i].texture_state.format)); diff --git a/src/gallium/auxiliary/draw/draw_llvm.h b/src/gallium/auxiliary/draw/draw_llvm.h index 9fbcbc2e5ac..bafb71ed8a6 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.h +++ b/src/gallium/auxiliary/draw/draw_llvm.h @@ -522,6 +522,8 @@ struct draw_tes_llvm_variant_key unsigned nr_samplers:8; unsigned nr_sampler_views:8; unsigned nr_images:8; + unsigned primid_output:7; + unsigned primid_needed:1; struct draw_sampler_static_state samplers[1]; /* Followed by variable number of images.*/ }; diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c index 421af232e48..88cd954a1b9 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c @@ -719,7 +719,7 @@ llvm_pipeline_generic(struct draw_pt_middle_end *middle, opt |= PT_PIPELINE; } } else { - if (draw_prim_assembler_is_required(draw, prim_info, vert_info)) { + if (!tes_shader && draw_prim_assembler_is_required(draw, prim_info, vert_info)) { draw_prim_assembler_run(draw, prim_info, vert_info, &ia_prim_info, &ia_vert_info); diff --git a/src/gallium/drivers/llvmpipe/ci/llvmpipe-quick_shader.txt b/src/gallium/drivers/llvmpipe/ci/llvmpipe-quick_shader.txt index 34d2a2bddad..4df080ed46e 100644 --- a/src/gallium/drivers/llvmpipe/ci/llvmpipe-quick_shader.txt +++ b/src/gallium/drivers/llvmpipe/ci/llvmpipe-quick_shader.txt @@ -114,7 +114,6 @@ spec/arb_tessellation_shader/execution/compatibility/tes-clip-vertex-different-f spec/arb_tessellation_shader/execution/compatibility/vs-tcs-tes-clip-vertex-different-from-position: skip spec/arb_tessellation_shader/execution/compatibility/vs-tcs-tes-clip-vertex-enables: skip spec/arb_tessellation_shader/execution/compatibility/vs-tcs-tes-gs-clip-vertex-different-from-position: skip -spec/arb_tessellation_shader/execution/fs-primitiveid-instanced: fail spec/arb_tessellation_shader/execution/gs-primitiveid-instanced: fail spec/arb_tessellation_shader/execution/tcs-tes-vertex-dlist: skip spec/arb_tessellation_shader/execution/vs-tes-tessinner-tessouter-inputs-quads-dlist: skip