r600: add user clip plane support
authorAlex Deucher <alexdeucher@gmail.com>
Mon, 20 Jul 2009 21:22:59 +0000 (17:22 -0400)
committerAlex Deucher <alexdeucher@gmail.com>
Mon, 20 Jul 2009 23:00:57 +0000 (19:00 -0400)
src/mesa/drivers/dri/r600/r700_chip.c
src/mesa/drivers/dri/r600/r700_render.c
src/mesa/drivers/dri/r600/r700_state.c

index 087d17312e92c9ed7408404e40b25562d3080cdc..91aa8fc8fc65b05aab80a46df7f60b38e93755e8 100644 (file)
@@ -722,3 +722,25 @@ GLboolean r700SendSQConfig(context_t *context)
        return GL_TRUE;
 }
 
+GLboolean r700SendUCPState(context_t *context)
+{
+       R700_CHIP_CONTEXT *r700 = R700_CONTEXT_STATES(context);
+       BATCH_LOCALS(&context->radeon);
+       int i;
+
+       for (i = 0; i < R700_MAX_UCP; i++) {
+               if (r700->ucp[i].enabled) {
+                       BEGIN_BATCH_NO_AUTOSTATE(6);
+                       R600_OUT_BATCH_REGSEQ(PA_CL_UCP_0_X + (16 * i), 4);
+                       R600_OUT_BATCH(r700->ucp[i].PA_CL_UCP_0_X.u32All);
+                       R600_OUT_BATCH(r700->ucp[i].PA_CL_UCP_0_Y.u32All);
+                       R600_OUT_BATCH(r700->ucp[i].PA_CL_UCP_0_Z.u32All);
+                       R600_OUT_BATCH(r700->ucp[i].PA_CL_UCP_0_W.u32All);
+                       END_BATCH();
+                       COMMIT_BATCH();
+               }
+       }
+
+       return GL_TRUE;
+}
+
index f1e467a317f4f1e84e09c3d47405b1be6a0ea982..77cbe3cfd0f06393f287224e7b57ff6f6b7815db 100644 (file)
@@ -322,6 +322,7 @@ static GLboolean r700RunRender(GLcontext * ctx,
     r700SendPSState(context);
     r700SendVSState(context);
 
+    r700SendUCPState(context);
     r700SendContextStates(context);
     r700SendViewportState(context, 0);
     r700SendRenderTargetState(context, 0);
index 1ccd793512b9157a97d71a310aca8e8d7b8493c8..1d6d398f63ee8a922ce157df6ebf4c4695ca0610 100644 (file)
@@ -56,6 +56,8 @@
 #include "r700_vertprog.h"
 
 
+static void r700SetClipPlaneState(GLcontext * ctx, GLenum cap, GLboolean state);
+
 void r700SetDefaultStates(context_t *context) //--------------------
 {
     
@@ -446,7 +448,7 @@ static void r700Enable(GLcontext * ctx, GLenum cap, GLboolean state) //---------
        case GL_CLIP_PLANE3:
        case GL_CLIP_PLANE4:
        case GL_CLIP_PLANE5:
-               //r700SetClipPlaneState(ctx, cap, state);
+               r700SetClipPlaneState(ctx, cap, state);
                break;
        case GL_DEPTH_TEST:
                r700SetDepthState(ctx);
@@ -675,8 +677,37 @@ static void r700RenderMode(GLcontext * ctx, GLenum mode) //---------------------
 {
 }
 
-static void r700ClipPlane( GLcontext *ctx, GLenum plane, const GLfloat *eq ) //-----------------
+static void r700ClipPlane( GLcontext *ctx, GLenum plane, const GLfloat *eq )
 {
+       context_t *context = R700_CONTEXT(ctx);
+       R700_CHIP_CONTEXT *r700 = (R700_CHIP_CONTEXT*)(&context->hw);
+       GLint p;
+       GLint *ip;
+
+       p = (GLint) plane - (GLint) GL_CLIP_PLANE0;
+       ip = (GLint *)ctx->Transform._ClipUserPlane[p];
+
+       r700->ucp[p].PA_CL_UCP_0_X.u32All = ip[0];
+       r700->ucp[p].PA_CL_UCP_0_Y.u32All = ip[1];
+       r700->ucp[p].PA_CL_UCP_0_Z.u32All = ip[2];
+       r700->ucp[p].PA_CL_UCP_0_W.u32All = ip[3];
+}
+
+static void r700SetClipPlaneState(GLcontext * ctx, GLenum cap, GLboolean state)
+{
+       context_t *context = R700_CONTEXT(ctx);
+       R700_CHIP_CONTEXT *r700 = (R700_CHIP_CONTEXT*)(&context->hw);
+       GLuint p;
+
+       p = cap - GL_CLIP_PLANE0;
+       if (state) {
+               r700->PA_CL_CLIP_CNTL.u32All |= (UCP_ENA_0_bit << p);
+               r700->ucp[p].enabled = GL_TRUE;
+               r700ClipPlane(ctx, cap, NULL);
+       } else {
+               r700->PA_CL_CLIP_CNTL.u32All &= ~(UCP_ENA_0_bit << p);
+               r700->ucp[p].enabled = GL_FALSE;
+       }
 }
 
 void r700SetScissor(context_t *context) //---------------