[Mesa-dev] [PATCH v3 08/11] mesa/st: Add support for GL_ARB_cull_distance

Tobias Klausmann tobias.johannes.klausmann at mni.thm.de
Sun May 8 20:44:08 UTC 2016


Signed-off-by: Tobias Klausmann <tobias.johannes.klausmann at mni.thm.de>
---
 src/mesa/state_tracker/st_extensions.c |  1 +
 src/mesa/state_tracker/st_program.c    | 40 ++++++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+)

diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index 746f4fc..4b9a3bd 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -574,6 +574,7 @@ void st_init_extensions(struct pipe_screen *screen,
       { o(ARB_color_buffer_float),           PIPE_CAP_VERTEX_COLOR_UNCLAMPED           },
       { o(ARB_conditional_render_inverted),  PIPE_CAP_CONDITIONAL_RENDER_INVERTED      },
       { o(ARB_copy_image),                   PIPE_CAP_COPY_BETWEEN_COMPRESSED_AND_PLAIN_FORMATS },
+      { o(ARB_cull_distance),                PIPE_CAP_CULL_DISTANCE                    },
       { o(ARB_depth_clamp),                  PIPE_CAP_DEPTH_CLIP_DISABLE               },
       { o(ARB_depth_texture),                PIPE_CAP_TEXTURE_SHADOW_MAP               },
       { o(ARB_derivative_control),           PIPE_CAP_TGSI_FS_FINE_DERIVATIVE          },
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
index 444e5aa..02dbf2d 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -310,6 +310,14 @@ st_translate_vertex_program(struct st_context *st,
             output_semantic_name[slot] = TGSI_SEMANTIC_CLIPDIST;
             output_semantic_index[slot] = 1;
             break;
+         case VARYING_SLOT_CULL_DIST0:
+            output_semantic_name[slot] = TGSI_SEMANTIC_CULLDIST;
+            output_semantic_index[slot] = 0;
+            break;
+         case VARYING_SLOT_CULL_DIST1:
+            output_semantic_name[slot] = TGSI_SEMANTIC_CULLDIST;
+            output_semantic_index[slot] = 1;
+            break;
          case VARYING_SLOT_EDGE:
             assert(0);
             break;
@@ -366,6 +374,9 @@ st_translate_vertex_program(struct st_context *st,
    if (stvp->Base.Base.ClipDistanceArraySize)
       ureg_property(ureg, TGSI_PROPERTY_NUM_CLIPDIST_ENABLED,
                     stvp->Base.Base.ClipDistanceArraySize);
+   if (stvp->Base.Base.CullDistanceArraySize)
+      ureg_property(ureg, TGSI_PROPERTY_NUM_CULLDIST_ENABLED,
+                    stvp->Base.Base.CullDistanceArraySize);
 
    if (ST_DEBUG & DEBUG_MESA) {
       _mesa_print_program(&stvp->Base.Base);
@@ -627,6 +638,16 @@ st_translate_fragment_program(struct st_context *st,
             input_semantic_index[slot] = 1;
             interpMode[slot] = TGSI_INTERPOLATE_PERSPECTIVE;
             break;
+         case VARYING_SLOT_CULL_DIST0:
+            input_semantic_name[slot] = TGSI_SEMANTIC_CULLDIST;
+            input_semantic_index[slot] = 0;
+            interpMode[slot] = TGSI_INTERPOLATE_PERSPECTIVE;
+            break;
+         case VARYING_SLOT_CULL_DIST1:
+            input_semantic_name[slot] = TGSI_SEMANTIC_CULLDIST;
+            input_semantic_index[slot] = 1;
+            interpMode[slot] = TGSI_INTERPOLATE_PERSPECTIVE;
+            break;
             /* In most cases, there is nothing special about these
              * inputs, so adopt a convention to use the generic
              * semantic name and the mesa VARYING_SLOT_ number as the
@@ -1044,6 +1065,9 @@ st_translate_program_common(struct st_context *st,
    if (prog->ClipDistanceArraySize)
       ureg_property(ureg, TGSI_PROPERTY_NUM_CLIPDIST_ENABLED,
                     prog->ClipDistanceArraySize);
+   if (prog->CullDistanceArraySize)
+      ureg_property(ureg, TGSI_PROPERTY_NUM_CULLDIST_ENABLED,
+                    prog->CullDistanceArraySize);
 
    /*
     * Convert Mesa program inputs to TGSI input register semantics.
@@ -1089,6 +1113,14 @@ st_translate_program_common(struct st_context *st,
             input_semantic_name[slot] = TGSI_SEMANTIC_CLIPDIST;
             input_semantic_index[slot] = 1;
             break;
+         case VARYING_SLOT_CULL_DIST0:
+            input_semantic_name[slot] = TGSI_SEMANTIC_CULLDIST;
+            input_semantic_index[slot] = 0;
+            break;
+         case VARYING_SLOT_CULL_DIST1:
+            input_semantic_name[slot] = TGSI_SEMANTIC_CULLDIST;
+            input_semantic_index[slot] = 1;
+            break;
          case VARYING_SLOT_PSIZ:
             input_semantic_name[slot] = TGSI_SEMANTIC_PSIZE;
             input_semantic_index[slot] = 0;
@@ -1191,6 +1223,14 @@ st_translate_program_common(struct st_context *st,
             output_semantic_name[slot] = TGSI_SEMANTIC_CLIPDIST;
             output_semantic_index[slot] = 1;
             break;
+         case VARYING_SLOT_CULL_DIST0:
+            output_semantic_name[slot] = TGSI_SEMANTIC_CULLDIST;
+            output_semantic_index[slot] = 0;
+            break;
+         case VARYING_SLOT_CULL_DIST1:
+            output_semantic_name[slot] = TGSI_SEMANTIC_CULLDIST;
+            output_semantic_index[slot] = 1;
+            break;
          case VARYING_SLOT_LAYER:
             output_semantic_name[slot] = TGSI_SEMANTIC_LAYER;
             output_semantic_index[slot] = 0;
-- 
2.8.2



More information about the mesa-dev mailing list