From f48fed8e915afe29f8aca3e878550cb30c23d62d Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sun, 15 Aug 2021 06:19:52 +1000 Subject: [PATCH] draw/gs: add clipvertex support for compatibility Reviewed-by: Emma Anholt Reviewed-by: Roland Scheidegger Reviewed-by: Adam Jackson Part-of: --- src/gallium/auxiliary/draw/draw_context.c | 2 +- src/gallium/auxiliary/draw/draw_gs.c | 10 ++++++++++ src/gallium/auxiliary/draw/draw_gs.h | 1 + src/gallium/auxiliary/draw/draw_private.h | 1 + 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c index ab6fbba..52f6bff 100644 --- a/src/gallium/auxiliary/draw/draw_context.c +++ b/src/gallium/auxiliary/draw/draw_context.c @@ -1003,7 +1003,7 @@ uint draw_current_shader_clipvertex_output(const struct draw_context *draw) { if (draw->gs.geometry_shader) - return draw->gs.position_output; + return draw->gs.clipvertex_output; if (draw->tes.tess_eval_shader) return draw->tes.position_output; return draw->vs.clipvertex_output; diff --git a/src/gallium/auxiliary/draw/draw_gs.c b/src/gallium/auxiliary/draw/draw_gs.c index ed698e9..90e66b6 100644 --- a/src/gallium/auxiliary/draw/draw_gs.c +++ b/src/gallium/auxiliary/draw/draw_gs.c @@ -834,12 +834,18 @@ draw_create_geometry_shader(struct draw_context *draw, gs->primitive_boundary = gs->max_output_vertices + 1; gs->position_output = -1; + bool found_clipvertex = false; for (i = 0; i < gs->info.num_outputs; i++) { if (gs->info.output_semantic_name[i] == TGSI_SEMANTIC_POSITION && gs->info.output_semantic_index[i] == 0) gs->position_output = i; if (gs->info.output_semantic_name[i] == TGSI_SEMANTIC_VIEWPORT_INDEX) gs->viewport_index_output = i; + if (gs->info.output_semantic_name[i] == TGSI_SEMANTIC_CLIPVERTEX && + gs->info.output_semantic_index[i] == 0) { + found_clipvertex = true; + gs->clipvertex_output = i; + } if (gs->info.output_semantic_name[i] == TGSI_SEMANTIC_CLIPDIST) { debug_assert(gs->info.output_semantic_index[i] < PIPE_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT); @@ -847,6 +853,9 @@ draw_create_geometry_shader(struct draw_context *draw, } } + if (!found_clipvertex) + gs->clipvertex_output = gs->position_output; + gs->machine = draw->gs.tgsi.machine; gs->num_vertex_streams = 1; @@ -900,6 +909,7 @@ void draw_bind_geometry_shader(struct draw_context *draw, draw->gs.geometry_shader = dgs; draw->gs.num_gs_outputs = dgs->info.num_outputs; draw->gs.position_output = dgs->position_output; + draw->gs.clipvertex_output = dgs->clipvertex_output; draw_geometry_shader_prepare(dgs, draw); } else { diff --git a/src/gallium/auxiliary/draw/draw_gs.h b/src/gallium/auxiliary/draw/draw_gs.h index 9449ec5..1096942 100644 --- a/src/gallium/auxiliary/draw/draw_gs.h +++ b/src/gallium/auxiliary/draw/draw_gs.h @@ -75,6 +75,7 @@ struct draw_geometry_shader { struct tgsi_shader_info info; unsigned position_output; unsigned viewport_index_output; + unsigned clipvertex_output; unsigned ccdistance_output[PIPE_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT]; unsigned max_output_vertices; diff --git a/src/gallium/auxiliary/draw/draw_private.h b/src/gallium/auxiliary/draw/draw_private.h index d252856..7e4a390 100644 --- a/src/gallium/auxiliary/draw/draw_private.h +++ b/src/gallium/auxiliary/draw/draw_private.h @@ -330,6 +330,7 @@ struct draw_context struct draw_geometry_shader *geometry_shader; uint num_gs_outputs; /**< convenience, from geometry_shader */ uint position_output; + uint clipvertex_output; /** Fields for TGSI interpreter / execution */ struct { -- 2.7.4