Mesa (master): svga: emit user-defined clip plane state

Brian Paul brianp at kemper.freedesktop.org
Wed Apr 27 17:53:51 UTC 2011


Module: Mesa
Branch: master
Commit: 0be6ae74e9a56e84df088392ef3b09229508404f
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=0be6ae74e9a56e84df088392ef3b09229508404f

Author: Brian Paul <brianp at vmware.com>
Date:   Mon Apr 25 10:26:19 2011 -0600

svga: emit user-defined clip plane state

User-defined clip planes were a swtnl fallback before.

---

 src/gallium/drivers/svga/svga_state_framebuffer.c |   23 ++++++++++++++++++--
 src/gallium/drivers/svga/svga_state_need_swtnl.c  |    8 -------
 src/gallium/drivers/svga/svga_state_rss.c         |    6 +++++
 3 files changed, 26 insertions(+), 11 deletions(-)

diff --git a/src/gallium/drivers/svga/svga_state_framebuffer.c b/src/gallium/drivers/svga/svga_state_framebuffer.c
index cc48194..502f21f 100644
--- a/src/gallium/drivers/svga/svga_state_framebuffer.c
+++ b/src/gallium/drivers/svga/svga_state_framebuffer.c
@@ -474,9 +474,26 @@ static int emit_clip_planes( struct svga_context *svga,
    /* TODO: just emit directly from svga_set_clip_state()?
     */
    for (i = 0; i < svga->curr.clip.nr; i++) {
-      ret = SVGA3D_SetClipPlane( svga->swc,
-                                 i,
-                                 svga->curr.clip.ucp[i] );
+      /* need to express the plane in D3D-style coordinate space.
+       * GL coords get converted to D3D coords with the matrix:
+       * [ 1  0  0  0 ]
+       * [ 0 -1  0  0 ]
+       * [ 0  0  2  0 ]
+       * [ 0  0 -1  1 ]
+       * Apply that matrix to our plane equation, and invert Y.
+       */
+      float a = svga->curr.clip.ucp[i][0];
+      float b = svga->curr.clip.ucp[i][1];
+      float c = svga->curr.clip.ucp[i][2];
+      float d = svga->curr.clip.ucp[i][3];
+      float plane[4];
+
+      plane[0] = a;
+      plane[1] = b;
+      plane[2] = 2.0f * c;
+      plane[3] = d - c;
+
+      ret = SVGA3D_SetClipPlane(svga->swc, i, plane);
       if(ret != PIPE_OK)
          return ret;
    }
diff --git a/src/gallium/drivers/svga/svga_state_need_swtnl.c b/src/gallium/drivers/svga/svga_state_need_swtnl.c
index 68c0257..5a37f9f 100644
--- a/src/gallium/drivers/svga/svga_state_need_swtnl.c
+++ b/src/gallium/drivers/svga/svga_state_need_swtnl.c
@@ -139,13 +139,6 @@ static int update_need_pipeline( struct svga_context *svga,
       need_pipeline = TRUE;
    }
 
-   /* SVGA_NEW_CLIP 
-    */
-   if (svga->curr.clip.nr) {
-      SVGA_DBG(DEBUG_SWTNL, "%s: userclip\n", __FUNCTION__);
-      need_pipeline = TRUE;
-   }
-
    if (need_pipeline != svga->state.sw.need_pipeline) {
       svga->state.sw.need_pipeline = need_pipeline;
       svga->dirty |= SVGA_NEW_NEED_PIPELINE;
@@ -163,7 +156,6 @@ struct svga_tracked_state svga_update_need_pipeline =
 {
    "need pipeline",
    (SVGA_NEW_RAST |
-    SVGA_NEW_CLIP |
     SVGA_NEW_VS |
     SVGA_NEW_REDUCED_PRIMITIVE),
    update_need_pipeline
diff --git a/src/gallium/drivers/svga/svga_state_rss.c b/src/gallium/drivers/svga/svga_state_rss.c
index ab13f3f..28f3279 100644
--- a/src/gallium/drivers/svga/svga_state_rss.c
+++ b/src/gallium/drivers/svga/svga_state_rss.c
@@ -240,6 +240,11 @@ static int emit_rss( struct svga_context *svga,
       EMIT_RS_FLOAT( svga, bias, DEPTHBIAS, fail );
    }
 
+   if (dirty & SVGA_NEW_CLIP) {
+      /* the number of clip planes is how many planes to enable */
+      unsigned enabled = (1 << svga->curr.clip.nr) - 1;
+      EMIT_RS( svga, enabled, CLIPPLANEENABLE, fail );
+   }
 
    if (queue.rs_count) {
       SVGA3dRenderState *rs;
@@ -276,6 +281,7 @@ struct svga_tracked_state svga_hw_rss =
 
    (SVGA_NEW_BLEND |
     SVGA_NEW_BLEND_COLOR |
+    SVGA_NEW_CLIP |
     SVGA_NEW_DEPTH_STENCIL |
     SVGA_NEW_STENCIL_REF |
     SVGA_NEW_RAST |




More information about the mesa-commit mailing list