Merge branch 'lp-offset-twoside'
[mesa.git] / src / mesa / drivers / dri / i965 / gen6_clip_state.c
index f34e5f32ccc8c7f835db3c27407e97f399acfbfd..c65b41e2b6bf9c71c30d707bdc67fddd54657e2b 100644 (file)
 #include "brw_state.h"
 #include "brw_defines.h"
 #include "brw_util.h"
-#include "main/macros.h"
-#include "main/enums.h"
 #include "intel_batchbuffer.h"
 
 static void
 upload_clip_state(struct brw_context *brw)
 {
    struct intel_context *intel = &brw->intel;
-   GLcontext *ctx = &intel->ctx;
+   struct gl_context *ctx = &intel->ctx;
    uint32_t depth_clamp = 0;
-   uint32_t provoking;
+   uint32_t provoking, userclip;
 
    if (!ctx->Transform.DepthClamp)
       depth_clamp = GEN6_CLIP_Z_TEST;
@@ -53,16 +51,20 @@ upload_clip_state(struct brw_context *brw)
         (1 << GEN6_CLIP_LINE_PROVOKE_SHIFT);
    }
 
+   /* _NEW_TRANSFORM */
+   userclip = (1 << brw_count_bits(ctx->Transform.ClipPlanesEnabled)) - 1;
+
    BEGIN_BATCH(4);
    OUT_BATCH(CMD_3D_CLIP_STATE << 16 | (4 - 2));
-   OUT_BATCH(0);
+   OUT_BATCH(GEN6_CLIP_STATISTICS_ENABLE);
    OUT_BATCH(GEN6_CLIP_ENABLE |
             GEN6_CLIP_API_OGL |
-            GEN6_CLIP_MODE_REJECT_ALL | /* XXX: debug: get VS working */
+            GEN6_CLIP_MODE_NORMAL |
             GEN6_CLIP_XY_TEST |
+            userclip << GEN6_USER_CLIP_CLIP_DISTANCES_SHIFT |
             depth_clamp |
             provoking);
-   OUT_BATCH(0);
+   OUT_BATCH(GEN6_CLIP_FORCE_ZERO_RTAINDEX);
    ADVANCE_BATCH();
 }