r600: Add support for ARB_depth_clamp
authorAlex Deucher <alexdeucher@gmail.com>
Thu, 29 Oct 2009 23:42:12 +0000 (19:42 -0400)
committerAlex Deucher <alexdeucher@gmail.com>
Thu, 29 Oct 2009 23:42:52 +0000 (19:42 -0400)
src/mesa/drivers/dri/r600/r600_context.c
src/mesa/drivers/dri/r600/r700_state.c

index 6de151d51b9ea10be8064d9d33b9c63673a10577..dbd233729c01113d579151970227f9bdf3ba5f37 100644 (file)
@@ -94,6 +94,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 static const struct dri_extension card_extensions[] = {
   /* *INDENT-OFF* */
+  {"GL_ARB_depth_clamp",                NULL},
   {"GL_ARB_depth_texture",             NULL},
   {"GL_ARB_fragment_program",          NULL},
   {"GL_ARB_occlusion_query",            GL_ARB_occlusion_query_functions},
index 2b42bfa3f955b29513b71b7123bff1ef89cced72..b2788872666e0bb10ea4bbb9e195f22fe3c2d785 100644 (file)
@@ -1030,6 +1030,7 @@ static void r700UpdateWindow(GLcontext * ctx, int id) //--------------------
        GLfloat tz = v[MAT_TZ] * depthScale;
 
        R600_STATECHANGE(context, vpt);
+       R600_STATECHANGE(context, cl);
 
        r700->viewport[id].PA_CL_VPORT_XSCALE.f32All  = sx;
        r700->viewport[id].PA_CL_VPORT_XOFFSET.f32All = tx;
@@ -1040,6 +1041,18 @@ static void r700UpdateWindow(GLcontext * ctx, int id) //--------------------
        r700->viewport[id].PA_CL_VPORT_ZSCALE.f32All  = sz;
        r700->viewport[id].PA_CL_VPORT_ZOFFSET.f32All = tz;
 
+       if (ctx->Transform.DepthClamp) {
+               r700->viewport[id].PA_SC_VPORT_ZMIN_0.f32All = MIN2(ctx->Viewport.Near, ctx->Viewport.Far);
+               r700->viewport[id].PA_SC_VPORT_ZMAX_0.f32All = MAX2(ctx->Viewport.Near, ctx->Viewport.Far);
+               SETbit(r700->PA_CL_CLIP_CNTL.u32All, ZCLIP_NEAR_DISABLE_bit);
+               SETbit(r700->PA_CL_CLIP_CNTL.u32All, ZCLIP_FAR_DISABLE_bit);
+       } else {
+               r700->viewport[id].PA_SC_VPORT_ZMIN_0.f32All = 0.0;
+               r700->viewport[id].PA_SC_VPORT_ZMAX_0.f32All = 1.0;
+               CLEARbit(r700->PA_CL_CLIP_CNTL.u32All, ZCLIP_NEAR_DISABLE_bit);
+               CLEARbit(r700->PA_CL_CLIP_CNTL.u32All, ZCLIP_FAR_DISABLE_bit);
+       }
+
        r700->viewport[id].enabled = GL_TRUE;
 
        r700SetScissor(context);
@@ -1345,8 +1358,6 @@ void r700SetScissor(context_t *context) //---------------
        SETfield(r700->viewport[id].PA_SC_VPORT_SCISSOR_0_BR.u32All, y2,
                 PA_SC_VPORT_SCISSOR_0_BR__BR_Y_shift, PA_SC_VPORT_SCISSOR_0_BR__BR_Y_mask);
 
-       r700->viewport[id].PA_SC_VPORT_ZMIN_0.u32All = 0;
-       r700->viewport[id].PA_SC_VPORT_ZMAX_0.u32All = 0x3F800000;
        r700->viewport[id].enabled = GL_TRUE;
 }