radeon: Invert front face winding when rendering to FBO.
authorMichel Dänzer <daenzer@vmware.com>
Tue, 14 Jul 2009 06:00:49 +0000 (08:00 +0200)
committerMichel Dänzer <daenzer@vmware.com>
Tue, 14 Jul 2009 06:00:49 +0000 (08:00 +0200)
Fixes fgl_glxgears and progs/demos/fbotexture after pressing 'c'.

Tested with r300, radeon and r200 compile tested only.

src/mesa/drivers/dri/r200/r200_state.c
src/mesa/drivers/dri/r300/r300_state.c
src/mesa/drivers/dri/radeon/radeon_state.c

index c7c1a39316ac6be322d1f5f3184cb7c9aff8369f..5a6fd20d8c2db1bede3e5a1877fe31964a99deec 100644 (file)
@@ -574,6 +574,10 @@ static void r200FrontFace( GLcontext *ctx, GLenum mode )
    R200_STATECHANGE( rmesa, tcl );
    rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] &= ~R200_CULL_FRONT_IS_CCW;
 
+   /* Winding is inverted when rendering to FBO */
+   if (ctx->DrawBuffer && ctx->DrawBuffer->Name)
+      mode = (mode == GL_CW) ? GL_CCW : GL_CW;
+
    switch ( mode ) {
    case GL_CW:
       rmesa->hw.set.cmd[SET_SE_CNTL] |= R200_FFACE_CULL_CW;
index 4d504d14e36cda7d2636cf1e8232560aee9b8408..12fbf281d991bc4c41b9d0905826ef7d25e1b1e3 100644 (file)
@@ -434,6 +434,10 @@ static void r300UpdateCulling(GLcontext * ctx)
                break;
        }
 
+       /* Winding is inverted when rendering to FBO */
+       if (ctx->DrawBuffer && ctx->DrawBuffer->Name)
+               val ^= R300_FRONT_FACE_CW;
+
        R300_STATECHANGE(r300, cul);
        r300->hw.cul.cmd[R300_CUL_CULL] = val;
 }
index 78f7e9d633fa09d55b8cae5ef24b79e644d62cf4..0d1728b747a38a50aeb022aea725e057d8bbe9ab 100644 (file)
@@ -458,6 +458,10 @@ static void radeonFrontFace( GLcontext *ctx, GLenum mode )
    RADEON_STATECHANGE( rmesa, tcl );
    rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] &= ~RADEON_CULL_FRONT_IS_CCW;
 
+   /* Winding is inverted when rendering to FBO */
+   if (ctx->DrawBuffer && ctx->DrawBuffer->Name)
+      mode = (mode == GL_CW) ? GL_CCW : GL_CW;
+
    switch ( mode ) {
    case GL_CW:
       rmesa->hw.set.cmd[SET_SE_CNTL] |= RADEON_FFACE_CULL_CW;