[Mesa-dev] [PATCH 08/11] draw: stop using CULLDIST semantic.

Dave Airlie airlied at gmail.com
Fri May 13 21:10:19 UTC 2016


From: Dave Airlie <airlied at redhat.com>

The way the HW works doesn't really fit with having
two semantics for this.

The GLSL compiler emits 2 vec4s and two properties,
this makes draw use those instead of CULLDIST semantics.

Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 src/gallium/auxiliary/draw/draw_cliptest_tmp.h |  4 ++--
 src/gallium/auxiliary/draw/draw_context.c      | 16 +++-------------
 src/gallium/auxiliary/draw/draw_gs.c           |  7 +------
 src/gallium/auxiliary/draw/draw_gs.h           |  3 +--
 src/gallium/auxiliary/draw/draw_llvm.c         |  4 ++--
 src/gallium/auxiliary/draw/draw_pipe_clip.c    |  2 +-
 src/gallium/auxiliary/draw/draw_pipe_cull.c    | 25 +++++++++++++++----------
 src/gallium/auxiliary/draw/draw_private.h      |  5 ++---
 src/gallium/auxiliary/draw/draw_vs.c           | 10 +++-------
 src/gallium/auxiliary/draw/draw_vs.h           |  3 +--
 src/gallium/auxiliary/tgsi/tgsi_scan.c         |  3 +--
 11 files changed, 32 insertions(+), 50 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_cliptest_tmp.h b/src/gallium/auxiliary/draw/draw_cliptest_tmp.h
index 34add82..6fbefa5 100644
--- a/src/gallium/auxiliary/draw/draw_cliptest_tmp.h
+++ b/src/gallium/auxiliary/draw/draw_cliptest_tmp.h
@@ -49,8 +49,8 @@ static boolean TAG(do_cliptest)( struct pt_post_vs *pvs,
    int num_written_clipdistance =
       draw_current_shader_num_written_clipdistances(pvs->draw);
 
-   cd[0] = draw_current_shader_clipdistance_output(pvs->draw, 0);
-   cd[1] = draw_current_shader_clipdistance_output(pvs->draw, 1);
+   cd[0] = draw_current_shader_ccdistance_output(pvs->draw, 0);
+   cd[1] = draw_current_shader_ccdistance_output(pvs->draw, 1);
 
    if (cd[0] != pos || cd[1] != pos)
       have_cd = true;
diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c
index 3f36b34..6305761 100644
--- a/src/gallium/auxiliary/draw/draw_context.c
+++ b/src/gallium/auxiliary/draw/draw_context.c
@@ -887,12 +887,12 @@ draw_current_shader_clipvertex_output(const struct draw_context *draw)
 }
 
 uint
-draw_current_shader_clipdistance_output(const struct draw_context *draw, int index)
+draw_current_shader_ccdistance_output(const struct draw_context *draw, int index)
 {
    debug_assert(index < PIPE_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT);
    if (draw->gs.geometry_shader)
-      return draw->gs.geometry_shader->clipdistance_output[index];
-   return draw->vs.clipdistance_output[index];
+      return draw->gs.geometry_shader->ccdistance_output[index];
+   return draw->vs.ccdistance_output[index];
 }
 
 
@@ -904,16 +904,6 @@ draw_current_shader_num_written_clipdistances(const struct draw_context *draw)
    return draw->vs.vertex_shader->info.num_written_clipdistance;
 }
 
-
-uint
-draw_current_shader_culldistance_output(const struct draw_context *draw, int index)
-{
-   debug_assert(index < PIPE_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT);
-   if (draw->gs.geometry_shader)
-      return draw->gs.geometry_shader->culldistance_output[index];
-   return draw->vs.vertex_shader->culldistance_output[index];
-}
-
 uint
 draw_current_shader_num_written_culldistances(const struct draw_context *draw)
 {
diff --git a/src/gallium/auxiliary/draw/draw_gs.c b/src/gallium/auxiliary/draw/draw_gs.c
index 6cf8846..18af1d9 100644
--- a/src/gallium/auxiliary/draw/draw_gs.c
+++ b/src/gallium/auxiliary/draw/draw_gs.c
@@ -803,12 +803,7 @@ draw_create_geometry_shader(struct draw_context *draw,
       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);
-         gs->clipdistance_output[gs->info.output_semantic_index[i]] = i;
-      }
-      if (gs->info.output_semantic_name[i] == TGSI_SEMANTIC_CULLDIST) {
-         debug_assert(gs->info.output_semantic_index[i] <
-                      PIPE_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT);
-         gs->culldistance_output[gs->info.output_semantic_index[i]] = i;
+         gs->ccdistance_output[gs->info.output_semantic_index[i]] = i;
       }
    }
 
diff --git a/src/gallium/auxiliary/draw/draw_gs.h b/src/gallium/auxiliary/draw/draw_gs.h
index d256a05..149278d 100644
--- a/src/gallium/auxiliary/draw/draw_gs.h
+++ b/src/gallium/auxiliary/draw/draw_gs.h
@@ -68,8 +68,7 @@ struct draw_geometry_shader {
    struct tgsi_shader_info info;
    unsigned position_output;
    unsigned viewport_index_output;
-   unsigned clipdistance_output[PIPE_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT];
-   unsigned culldistance_output[PIPE_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT];
+   unsigned ccdistance_output[PIPE_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT];
 
    unsigned max_output_vertices;
    unsigned primitive_boundary;
diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c
index c1460cc..b098132 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_llvm.c
@@ -1164,8 +1164,8 @@ generate_clipmask(struct draw_llvm *llvm,
    unsigned ucp_enable = key->ucp_enable;
    unsigned cd[2];
 
-   cd[0] = llvm->draw->vs.clipdistance_output[0];
-   cd[1] = llvm->draw->vs.clipdistance_output[1];
+   cd[0] = llvm->draw->vs.ccdistance_output[0];
+   cd[1] = llvm->draw->vs.ccdistance_output[1];
 
    if (cd[0] != pos || cd[1] != pos)
       have_cd = true;
diff --git a/src/gallium/auxiliary/draw/draw_pipe_clip.c b/src/gallium/auxiliary/draw/draw_pipe_clip.c
index 2d92d65..78845ac 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_clip.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_clip.c
@@ -368,7 +368,7 @@ static inline float getclipdist(const struct clip_stage *clipper,
       int _idx = plane_idx - 6;
       int cdi = _idx >= 4;
       int vidx = cdi ? _idx - 4 : _idx;
-      dp = vert->data[draw_current_shader_clipdistance_output(clipper->stage.draw, cdi)][vidx];
+      dp = vert->data[draw_current_shader_ccdistance_output(clipper->stage.draw, cdi)][vidx];
    } else {
       /*
        * legacy user clip planes or gl_ClipVertex
diff --git a/src/gallium/auxiliary/draw/draw_pipe_cull.c b/src/gallium/auxiliary/draw/draw_pipe_cull.c
index 240f551..3e8e458 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_cull.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_cull.c
@@ -68,15 +68,17 @@ static void cull_point( struct draw_stage *stage,
 {
    const unsigned num_written_culldistances =
       draw_current_shader_num_written_culldistances(stage->draw);
+   const unsigned num_written_clipdistances =
+      draw_current_shader_num_written_clipdistances(stage->draw);
    unsigned i;
 
    debug_assert(num_written_culldistances);
 
    for (i = 0; i < num_written_culldistances; ++i) {
-      unsigned cull_idx = i / 4;
+      unsigned cull_idx = (num_written_clipdistances + i) / 4;
       unsigned out_idx =
-         draw_current_shader_culldistance_output(stage->draw, cull_idx);
-      unsigned idx = i % 4;
+         draw_current_shader_ccdistance_output(stage->draw, cull_idx);
+      unsigned idx = (num_written_clipdistances + i) % 4;
       float cull1 = header->v[0]->data[out_idx][idx];
       boolean vert1_out = cull_distance_is_out(cull1);
       if (vert1_out)
@@ -96,15 +98,17 @@ static void cull_line( struct draw_stage *stage,
 {
    const unsigned num_written_culldistances =
       draw_current_shader_num_written_culldistances(stage->draw);
+   const unsigned num_written_clipdistances =
+      draw_current_shader_num_written_clipdistances(stage->draw);
    unsigned i;
 
    debug_assert(num_written_culldistances);
 
    for (i = 0; i < num_written_culldistances; ++i) {
-      unsigned cull_idx = i / 4;
+      unsigned cull_idx = (num_written_clipdistances + i) / 4;
       unsigned out_idx =
-         draw_current_shader_culldistance_output(stage->draw, cull_idx);
-      unsigned idx = i % 4;
+         draw_current_shader_ccdistance_output(stage->draw, cull_idx);
+      unsigned idx = (num_written_clipdistances + i) % 4;
       float cull1 = header->v[0]->data[out_idx][idx];
       float cull2 = header->v[1]->data[out_idx][idx];
       boolean vert1_out = cull_distance_is_out(cull1);
@@ -125,15 +129,16 @@ static void cull_tri( struct draw_stage *stage,
 {
    const unsigned num_written_culldistances =
       draw_current_shader_num_written_culldistances(stage->draw);
-
+   const unsigned num_written_clipdistances =
+      draw_current_shader_num_written_clipdistances(stage->draw);
    /* Do the distance culling */
    if (num_written_culldistances) {
       unsigned i;
       for (i = 0; i < num_written_culldistances; ++i) {
-         unsigned cull_idx = i / 4;
+         unsigned cull_idx = (num_written_clipdistances + i) / 4;
          unsigned out_idx =
-            draw_current_shader_culldistance_output(stage->draw, cull_idx);
-         unsigned idx = i % 4;
+            draw_current_shader_ccdistance_output(stage->draw, cull_idx);
+         unsigned idx = (num_written_clipdistances + i) % 4;
          float cull1 = header->v[0]->data[out_idx][idx];
          float cull2 = header->v[1]->data[out_idx][idx];
          float cull3 = header->v[2]->data[out_idx][idx];
diff --git a/src/gallium/auxiliary/draw/draw_private.h b/src/gallium/auxiliary/draw/draw_private.h
index a18f663..a6aa610 100644
--- a/src/gallium/auxiliary/draw/draw_private.h
+++ b/src/gallium/auxiliary/draw/draw_private.h
@@ -262,7 +262,7 @@ struct draw_context
       uint position_output;
       uint edgeflag_output;
       uint clipvertex_output;
-      uint clipdistance_output[2];
+      uint ccdistance_output[2];
 
       /** Fields for TGSI interpreter / execution */
       struct {
@@ -406,9 +406,8 @@ uint draw_current_shader_outputs(const struct draw_context *draw);
 uint draw_current_shader_position_output(const struct draw_context *draw);
 uint draw_current_shader_viewport_index_output(const struct draw_context *draw);
 uint draw_current_shader_clipvertex_output(const struct draw_context *draw);
-uint draw_current_shader_clipdistance_output(const struct draw_context *draw, int index);
+uint draw_current_shader_ccdistance_output(const struct draw_context *draw, int index);
 uint draw_current_shader_num_written_clipdistances(const struct draw_context *draw);
-uint draw_current_shader_culldistance_output(const struct draw_context *draw, int index);
 uint draw_current_shader_num_written_culldistances(const struct draw_context *draw);
 int draw_alloc_extra_vertex_attrib(struct draw_context *draw,
                                    uint semantic_name, uint semantic_index);
diff --git a/src/gallium/auxiliary/draw/draw_vs.c b/src/gallium/auxiliary/draw/draw_vs.c
index ae94421..415c4fa 100644
--- a/src/gallium/auxiliary/draw/draw_vs.c
+++ b/src/gallium/auxiliary/draw/draw_vs.c
@@ -90,11 +90,7 @@ draw_create_vertex_shader(struct draw_context *draw,
          else if (vs->info.output_semantic_name[i] == TGSI_SEMANTIC_CLIPDIST) {
             debug_assert(vs->info.output_semantic_index[i] <
                          PIPE_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT);
-            vs->clipdistance_output[vs->info.output_semantic_index[i]] = i;
-         } else if (vs->info.output_semantic_name[i] == TGSI_SEMANTIC_CULLDIST) {
-            debug_assert(vs->info.output_semantic_index[i] <
-                         PIPE_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT);
-            vs->culldistance_output[vs->info.output_semantic_index[i]] = i;
+            vs->ccdistance_output[vs->info.output_semantic_index[i]] = i;
          }
       }
       if (!found_clipvertex)
@@ -119,8 +115,8 @@ draw_bind_vertex_shader(struct draw_context *draw,
       draw->vs.position_output = dvs->position_output;
       draw->vs.edgeflag_output = dvs->edgeflag_output;
       draw->vs.clipvertex_output = dvs->clipvertex_output;
-      draw->vs.clipdistance_output[0] = dvs->clipdistance_output[0];
-      draw->vs.clipdistance_output[1] = dvs->clipdistance_output[1];
+      draw->vs.ccdistance_output[0] = dvs->ccdistance_output[0];
+      draw->vs.ccdistance_output[1] = dvs->ccdistance_output[1];
       dvs->prepare( dvs, draw );
       draw_update_clip_flags(draw);
       draw_update_viewport_flags(draw);
diff --git a/src/gallium/auxiliary/draw/draw_vs.h b/src/gallium/auxiliary/draw/draw_vs.h
index 24b29e7..6a90022 100644
--- a/src/gallium/auxiliary/draw/draw_vs.h
+++ b/src/gallium/auxiliary/draw/draw_vs.h
@@ -113,8 +113,7 @@ struct draw_vertex_shader {
    unsigned viewport_index_output;
    unsigned edgeflag_output;
    unsigned clipvertex_output;
-   unsigned clipdistance_output[PIPE_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT];
-   unsigned culldistance_output[PIPE_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT];
+   unsigned ccdistance_output[PIPE_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT];
    /* Extracted from shader:
     */
    const float (*immediates)[4];
diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.c b/src/gallium/auxiliary/tgsi/tgsi_scan.c
index e07148d..1baf031 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_scan.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_scan.c
@@ -336,8 +336,7 @@ scan_declaration(struct tgsi_shader_info *info,
              semName == TGSI_SEMANTIC_COLOR ||
              semName == TGSI_SEMANTIC_BCOLOR ||
              semName == TGSI_SEMANTIC_FOG ||
-             semName == TGSI_SEMANTIC_CLIPDIST ||
-             semName == TGSI_SEMANTIC_CULLDIST) {
+             semName == TGSI_SEMANTIC_CLIPDIST) {
             switch (fulldecl->Interp.Interpolate) {
             case TGSI_INTERPOLATE_COLOR:
             case TGSI_INTERPOLATE_PERSPECTIVE:
-- 
2.5.5



More information about the mesa-dev mailing list