draw: stop using CULLDIST semantic.
authorDave Airlie <airlied@redhat.com>
Fri, 13 May 2016 05:42:19 +0000 (15:42 +1000)
committerDave Airlie <airlied@redhat.com>
Mon, 23 May 2016 01:03:40 +0000 (11:03 +1000)
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.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
src/gallium/auxiliary/draw/draw_cliptest_tmp.h
src/gallium/auxiliary/draw/draw_context.c
src/gallium/auxiliary/draw/draw_gs.c
src/gallium/auxiliary/draw/draw_gs.h
src/gallium/auxiliary/draw/draw_llvm.c
src/gallium/auxiliary/draw/draw_pipe_clip.c
src/gallium/auxiliary/draw/draw_pipe_cull.c
src/gallium/auxiliary/draw/draw_private.h
src/gallium/auxiliary/draw/draw_vs.c
src/gallium/auxiliary/draw/draw_vs.h
src/gallium/auxiliary/tgsi/tgsi_scan.c

index 34add8293532d053a915e3a5c944eeaf3ed2c51d..6fbefa56bf16baa70963cf72484f9a7258ad865f 100644 (file)
@@ -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;
index 3f36b347ddabf3c1addf8076718f9643cc33ec8d..6305761f2dbd05ce5c250e7c272861ec7d1fd93f 100644 (file)
@@ -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)
 {
index 6cf8846627bdfe2e3cd497fce64d277c1606afe1..18af1d9066762a87a726f7b59287d140bd91dfd9 100644 (file)
@@ -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;
       }
    }
 
index d256a05d16eb6b5add7a39ab08921c5128280b7c..149278dd080c2163d5cd14d2bcb724a7be236dbf 100644 (file)
@@ -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;
index c1460cc91c05e2ec1fa90017e519737dd08244a5..b098132033adb37efaa6bd4e107150e9a2fc8a44 100644 (file)
@@ -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;
index 2d92d650ab6212eafdb7a1625dcdfb818da61cf7..78845ac04505a7777d5ff6d24b854949610f0a42 100644 (file)
@@ -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
index 240f55190f5f93553dba1339917fdfa448680e05..3e8e45895973a9b3d0e5ab8934648a69358d404b 100644 (file)
@@ -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];
index a18f6632124cbae9822fe6c4c5cea6d1e5949ee4..a6aa61052648a5dfb20330040d63ec2035ef165d 100644 (file)
@@ -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);
index ae94421ed4c4a570d6e4462762c588b0d25dd29f..415c4fa949aacb6d9080ce2782e952994d7bea36 100644 (file)
@@ -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);
index 24b29e70dd92e599f9dd88b8a822ade9f9c92192..6a900224c110d006ba927b780cdf1df0fe318f5d 100644 (file)
@@ -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];
index e07148d6783736418f6988492906bda19edadcfe..1baf031d73e42ffd133a2e67e2ec86dfa86c3249 100644 (file)
@@ -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: