[Mesa-dev] [PATCH 1/2] gallium: add support for clip distances

Bryan Cain bryancain3 at gmail.com
Tue Dec 13 11:47:54 PST 2011


---
 src/gallium/auxiliary/tgsi/tgsi_dump.c     |    6 ++++--
 src/gallium/auxiliary/tgsi/tgsi_text.c     |    3 ++-
 src/gallium/auxiliary/tgsi/tgsi_ureg.c     |   14 ++++++++++++++
 src/gallium/auxiliary/tgsi/tgsi_ureg.h     |    3 +++
 src/gallium/include/pipe/p_shader_tokens.h |    6 ++++--
 5 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump.c b/src/gallium/auxiliary/tgsi/tgsi_dump.c
index e830aa5..4534731 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_dump.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_dump.c
@@ -129,7 +129,8 @@ static const char *semantic_names[] =
    "PRIM_ID",
    "INSTANCEID",
    "VERTEXID",
-   "STENCIL"
+   "STENCIL",
+   "CLIPDIST"
 };
 
 static const char *immediate_type_names[] =
@@ -174,7 +175,8 @@ const char *tgsi_property_names[TGSI_PROPERTY_COUNT] =
    "FS_COORD_ORIGIN",
    "FS_COORD_PIXEL_CENTER",
    "FS_COLOR0_WRITES_ALL_CBUFS",
-   "FS_DEPTH_LAYOUT"
+   "FS_DEPTH_LAYOUT",
+   "NUM_CLIP_DISTANCES"
 };
 
 static const char *tgsi_type_names[] =
diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.c b/src/gallium/auxiliary/tgsi/tgsi_text.c
index eb9190c..f46ba19 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_text.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_text.c
@@ -1024,7 +1024,8 @@ static const char *semantic_names[TGSI_SEMANTIC_COUNT] =
    "PRIM_ID",
    "INSTANCEID",
    "VERTEXID",
-   "STENCIL"
+   "STENCIL",
+   "CLIPDIST"
 };
 
 static const char *interpolate_names[TGSI_INTERPOLATE_COUNT] =
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
index ee013a5..5966c8c 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
@@ -162,6 +162,7 @@ struct ureg_program
    unsigned char property_fs_coord_pixel_center; /* = TGSI_FS_COORD_PIXEL_CENTER_* */
    unsigned char property_fs_color0_writes_all_cbufs; /* = TGSI_FS_COLOR0_WRITES_ALL_CBUFS * */
    unsigned char property_fs_depth_layout; /* TGSI_FS_DEPTH_LAYOUT */
+   unsigned char property_num_clip_distances;
 
    unsigned nr_addrs;
    unsigned nr_preds;
@@ -312,6 +313,13 @@ ureg_property_fs_depth_layout(struct ureg_program *ureg,
    ureg->property_fs_depth_layout = fs_depth_layout;
 }
 
+void
+ureg_property_num_clip_distances(struct ureg_program *ureg,
+                                 unsigned num_clip_distances)
+{
+   ureg->property_num_clip_distances = num_clip_distances;
+}
+
 struct ureg_src
 ureg_DECL_fs_input_cyl_centroid(struct ureg_program *ureg,
                        unsigned semantic_name,
@@ -1404,6 +1412,12 @@ static void emit_decls( struct ureg_program *ureg )
                     ureg->property_fs_depth_layout);
    }
 
+   if (ureg->property_num_clip_distances) {
+      emit_property(ureg,
+                    TGSI_PROPERTY_NUM_CLIP_DISTANCES,
+                    ureg->property_num_clip_distances);
+   }
+
    if (ureg->processor == TGSI_PROCESSOR_VERTEX) {
       for (i = 0; i < UREG_MAX_INPUT; i++) {
          if (ureg->vs_inputs[i/32] & (1 << (i%32))) {
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
index a70d30f..f313a6f 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
@@ -161,6 +161,9 @@ void
 ureg_property_fs_depth_layout(struct ureg_program *ureg,
                               unsigned fs_depth_layout);
 
+void
+ureg_property_num_clip_distances(struct ureg_program *ureg,
+                                 unsigned num_clip_distances);
 
 /***********************************************************************
  * Build shader declarations:
diff --git a/src/gallium/include/pipe/p_shader_tokens.h b/src/gallium/include/pipe/p_shader_tokens.h
index 10cfaf6..e5e6d46 100644
--- a/src/gallium/include/pipe/p_shader_tokens.h
+++ b/src/gallium/include/pipe/p_shader_tokens.h
@@ -146,7 +146,8 @@ struct tgsi_declaration_dimension
 #define TGSI_SEMANTIC_INSTANCEID 10
 #define TGSI_SEMANTIC_VERTEXID   11
 #define TGSI_SEMANTIC_STENCIL    12
-#define TGSI_SEMANTIC_COUNT      13 /**< number of semantic values */
+#define TGSI_SEMANTIC_CLIPDIST   13
+#define TGSI_SEMANTIC_COUNT      14 /**< number of semantic values */
 
 struct tgsi_declaration_semantic
 {
@@ -189,7 +190,8 @@ union tgsi_immediate_data
 #define TGSI_PROPERTY_FS_COORD_PIXEL_CENTER  4
 #define TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS 5
 #define TGSI_PROPERTY_FS_DEPTH_LAYOUT        6
-#define TGSI_PROPERTY_COUNT                  7
+#define TGSI_PROPERTY_NUM_CLIP_DISTANCES     7
+#define TGSI_PROPERTY_COUNT                  8
 
 struct tgsi_property {
    unsigned Type         : 4;  /**< TGSI_TOKEN_TYPE_PROPERTY */
-- 
1.7.1



More information about the mesa-dev mailing list