[Mesa-dev] [RFC] gallium: add support for rectangle primitives

Marek Olšák maraeo at gmail.com
Thu Aug 21 09:44:31 PDT 2014


From: Marek Olšák <marek.olsak at amd.com>

This is already supported by r600g and radeonsi.
Alex suggested this could be useful for video acceleration state trackers.
---
 src/gallium/auxiliary/tgsi/tgsi_strings.c     | 3 ++-
 src/gallium/auxiliary/util/u_prim.h           | 1 +
 src/gallium/docs/source/screen.rst            | 6 ++++++
 src/gallium/drivers/r600/r600_pipe.c          | 1 +
 src/gallium/drivers/radeon/r600_pipe_common.h | 2 +-
 src/gallium/drivers/radeonsi/si_pipe.c        | 1 +
 src/gallium/include/pipe/p_defines.h          | 4 +++-
 7 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_strings.c b/src/gallium/auxiliary/tgsi/tgsi_strings.c
index 3c108a8..ddc23c1 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_strings.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_strings.c
@@ -164,7 +164,8 @@ const char *tgsi_primitive_names[PIPE_PRIM_MAX] =
    "LINES_ADJACENCY",
    "LINE_STRIP_ADJACENCY",
    "TRIANGLES_ADJACENCY",
-   "TRIANGLE_STRIP_ADJACENCY"
+   "TRIANGLE_STRIP_ADJACENCY",
+   "RECTANGLES"
 };
 
 const char *tgsi_fs_coord_origin_names[2] =
diff --git a/src/gallium/auxiliary/util/u_prim.h b/src/gallium/auxiliary/util/u_prim.h
index cf1a18f..d631dc1 100644
--- a/src/gallium/auxiliary/util/u_prim.h
+++ b/src/gallium/auxiliary/util/u_prim.h
@@ -131,6 +131,7 @@ u_prim_vertex_count(unsigned prim)
       { 4, 1 }, /* PIPE_PRIM_LINE_STRIP_ADJACENCY */
       { 6, 6 }, /* PIPE_PRIM_TRIANGLES_ADJACENCY */
       { 6, 2 }, /* PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY */
+      { 3, 3 }  /* PIPE_PRIM_RECTANGLES */
    };
 
    return (likely(prim < PIPE_PRIM_MAX)) ? &prim_table[prim] : NULL;
diff --git a/src/gallium/docs/source/screen.rst b/src/gallium/docs/source/screen.rst
index eee254e..f162ec0 100644
--- a/src/gallium/docs/source/screen.rst
+++ b/src/gallium/docs/source/screen.rst
@@ -26,6 +26,12 @@ The integer capabilities:
   normalized coordinates, and mipmaps.
 * ``PIPE_CAP_TWO_SIDED_STENCIL``: Whether the stencil test can also affect back-facing
   polygons.
+* ``PIPE_CAP_PRIM_TYPE_RECTANGLES``: Whether rectangle primitives are supported.
+  Rectangles are like quads, but they are only specified by the first 3 vertices.
+  The 4th vertex is computed from the first three by hardware. Rectangles must
+  be parallel with screen borders, which means they can only be rotated with
+  90-degree increments. Rectangles bypass clipping and therefore can be specified
+  in screen coordinates.
 * ``PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS``: How many dual-source blend RTs are support.
   :ref:`Blend` for more information.
 * ``PIPE_CAP_ANISOTROPIC_FILTER``: Whether textures can be filtered anisotropically.
diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c
index 3d07864..7294c8c 100644
--- a/src/gallium/drivers/r600/r600_pipe.c
+++ b/src/gallium/drivers/r600/r600_pipe.c
@@ -262,6 +262,7 @@ static int r600_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
 	case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT:
 	case PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION:
 	case PIPE_CAP_TGSI_VS_LAYER_VIEWPORT:
+	case PIPE_CAP_PRIM_TYPE_RECTANGLES:
 		return 1;
 
 	case PIPE_CAP_COMPUTE:
diff --git a/src/gallium/drivers/radeon/r600_pipe_common.h b/src/gallium/drivers/radeon/r600_pipe_common.h
index ed16e1a..903395d 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.h
+++ b/src/gallium/drivers/radeon/r600_pipe_common.h
@@ -76,7 +76,7 @@
 #define R600_CONTEXT_VGT_STREAMOUT_SYNC		(1 << 20)
 
 /* special primitive types */
-#define R600_PRIM_RECTANGLE_LIST	PIPE_PRIM_MAX
+#define R600_PRIM_RECTANGLE_LIST	PIPE_PRIM_RECTANGLES
 
 /* Debug flags. */
 /* logging */
diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c
index ae1d043..9431ea4 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.c
+++ b/src/gallium/drivers/radeonsi/si_pipe.c
@@ -216,6 +216,7 @@ static int si_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
 	case PIPE_CAP_CUBE_MAP_ARRAY:
 	case PIPE_CAP_SAMPLE_SHADING:
 	case PIPE_CAP_DRAW_INDIRECT:
+	case PIPE_CAP_PRIM_TYPE_RECTANGLES:
 		return 1;
 
 	case PIPE_CAP_TEXTURE_MULTISAMPLE:
diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h
index 04e4798..d92261c 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -419,7 +419,8 @@ enum pipe_flush_flags {
 #define PIPE_PRIM_LINE_STRIP_ADJACENCY    11
 #define PIPE_PRIM_TRIANGLES_ADJACENCY      12
 #define PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY 13
-#define PIPE_PRIM_MAX                      14
+#define PIPE_PRIM_RECTANGLES               14
+#define PIPE_PRIM_MAX                      15
 
 
 /**
@@ -479,6 +480,7 @@ enum pipe_flush_flags {
 enum pipe_cap {
    PIPE_CAP_NPOT_TEXTURES = 1,
    PIPE_CAP_TWO_SIDED_STENCIL = 2,
+   PIPE_CAP_PRIM_TYPE_RECTANGLES = 3,
    PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS = 4,
    PIPE_CAP_ANISOTROPIC_FILTER = 5,
    PIPE_CAP_POINT_SPRITE = 6,
-- 
1.9.1



More information about the mesa-dev mailing list