aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/svga
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2011-04-25 10:26:19 -0600
committerBrian Paul <[email protected]>2011-04-27 11:51:30 -0600
commit0be6ae74e9a56e84df088392ef3b09229508404f (patch)
treea56fb646fe9afa5de3d36f65030711df526a58bd /src/gallium/drivers/svga
parent33afdf835654cc21377fd1f57af03b3fa34f97f8 (diff)
svga: emit user-defined clip plane state
User-defined clip planes were a swtnl fallback before.
Diffstat (limited to 'src/gallium/drivers/svga')
-rw-r--r--src/gallium/drivers/svga/svga_state_framebuffer.c23
-rw-r--r--src/gallium/drivers/svga/svga_state_need_swtnl.c8
-rw-r--r--src/gallium/drivers/svga/svga_state_rss.c6
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 cc4819431ad..502f21fc42c 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 68c02578789..5a37f9fc287 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 ab13f3fdf19..28f32793742 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 |