Add support for GL_EXT_stencil_wrap, from hearing that the windows drivers did
authorEric Anholt <anholt@FreeBSD.org>
Thu, 27 Oct 2005 21:21:05 +0000 (21:21 +0000)
committerEric Anholt <anholt@FreeBSD.org>
Thu, 27 Oct 2005 21:21:05 +0000 (21:21 +0000)
it, and guessing that the two remaining entries in the 3-bit values were the
new funcs.  Tested with modified stencilwrap test.  Also, remove the commented
fallback stuff -- more modification to stencilwrap suggests that those issues
were just from span readback, not stencil implementation.

src/mesa/drivers/dri/r128/r128_context.c
src/mesa/drivers/dri/r128/r128_state.c
src/mesa/drivers/dri/r128/server/r128_reg.h

index 7909951f0ba2ad22147f0a9cb78f8e3c01a9d9b6..73bd3bebd68193a097301cf8edb723d12e3a5a7b 100644 (file)
@@ -84,6 +84,7 @@ const struct dri_extension card_extensions[] =
     { "GL_EXT_fog_coord",                  GL_EXT_fog_coord_functions },
     { "GL_EXT_texture_edge_clamp",         NULL },
     { "GL_EXT_secondary_color",            GL_EXT_secondary_color_functions },
+    { "GL_EXT_stencil_wrap",               NULL },
     { "GL_MESA_ycbcr_texture",             NULL },
     { "GL_NV_blend_square",                NULL },
     { "GL_SGIS_generate_mipmap",           NULL },
index 80771ae29bab446bfe20ade926d1b3dca94f1600..e9149306d87f2c6280675b28ae0d1eab0732d170 100644 (file)
@@ -322,7 +322,6 @@ static void r128DDStencilOpSeparate( GLcontext *ctx, GLenum face, GLenum fail,
 {
    r128ContextPtr rmesa = R128_CONTEXT(ctx);
    GLuint z = rmesa->setup.z_sten_cntl_c;
-   GLboolean ok = 1;
 
    if (!( ctx->Visual.stencilBits > 0 && ctx->Visual.depthBits == 24 ))
       return;
@@ -336,11 +335,9 @@ static void r128DDStencilOpSeparate( GLcontext *ctx, GLenum face, GLenum fail,
       break;
    case GL_ZERO:
       z |= R128_STENCIL_S_FAIL_ZERO;
-      ok = 0; /* Hardware bug?  ZERO maps to KEEP */
       break;
    case GL_REPLACE:
       z |= R128_STENCIL_S_FAIL_REPLACE;
-      ok = 0; /* Hardware bug?  REPLACE maps to KEEP */
       break;
    case GL_INCR:
       z |= R128_STENCIL_S_FAIL_INC;
@@ -350,14 +347,18 @@ static void r128DDStencilOpSeparate( GLcontext *ctx, GLenum face, GLenum fail,
       break;
    case GL_INVERT:
       z |= R128_STENCIL_S_FAIL_INV;
-      ok = 0; /* Hardware bug?  INV maps to ZERO */
+      break;
+   case GL_INCR_WRAP:
+      z |= R128_STENCIL_S_FAIL_INC_WRAP;
+      break;
+   case GL_DECR_WRAP:
+      z |= R128_STENCIL_S_FAIL_DEC_WRAP;
       break;
    }
 
    switch ( ctx->Stencil.ZFailFunc[0] ) {
    case GL_KEEP:
       z |= R128_STENCIL_ZFAIL_KEEP;
-      ok = 0; /* Hardware bug?  KEEP maps to ZERO */
       break;
    case GL_ZERO:
       z |= R128_STENCIL_ZFAIL_ZERO;
@@ -373,14 +374,18 @@ static void r128DDStencilOpSeparate( GLcontext *ctx, GLenum face, GLenum fail,
       break;
    case GL_INVERT:
       z |= R128_STENCIL_ZFAIL_INV;
-      ok = 0; /* Hardware bug?  INV maps to ZERO */
+      break;
+   case GL_INCR_WRAP:
+      z |= R128_STENCIL_ZFAIL_INC_WRAP;
+      break;
+   case GL_DECR_WRAP:
+      z |= R128_STENCIL_ZFAIL_DEC_WRAP;
       break;
    }
 
    switch ( ctx->Stencil.ZPassFunc[0] ) {
    case GL_KEEP:
       z |= R128_STENCIL_ZPASS_KEEP;
-      ok = 0; /* Hardware bug?  KEEP maps to ZERO */
       break;
    case GL_ZERO:
       z |= R128_STENCIL_ZPASS_ZERO;
@@ -393,22 +398,18 @@ static void r128DDStencilOpSeparate( GLcontext *ctx, GLenum face, GLenum fail,
       break;
    case GL_DECR:
       z |= R128_STENCIL_ZPASS_DEC;
-      ok = 0; /* Hardware bug?  DEC maps to INCR_WRAP */
       break;
    case GL_INVERT:
       z |= R128_STENCIL_ZPASS_INV;
-      ok = 0; /* Hardware bug?  INV maps to ZERO */
+      break;
+   case GL_INCR_WRAP:
+      z |= R128_STENCIL_ZPASS_INC_WRAP;
+      break;
+   case GL_DECR_WRAP:
+      z |= R128_STENCIL_ZPASS_DEC_WRAP;
       break;
    }
 
-   /* XXX: Now that we know whether we can do the given funcs successfully
-    * (according to testing done with a modified stencilwrap test), go
-    * ahead and drop that knowledge on the floor.  While fallbacks remain
-    * broken, they make the situation even worse (in test apps, at least) than
-    * failing in just the stencil part.
-    */
-   /*FALLBACK( rmesa, R128_FALLBACK_STENCIL, !ok );*/
-
    if ( rmesa->setup.z_sten_cntl_c != z ) {
       rmesa->setup.z_sten_cntl_c = z;
       rmesa->dirty |= R128_UPLOAD_CONTEXT;
index cb979cb70d43db0ae6d8bb474f18fb9cadb4e9ec..5669452d74e11e43245aa84b37d4ba112939e577 100644 (file)
 #       define R128_STENCIL_S_FAIL_INC        (3 << 16)
 #       define R128_STENCIL_S_FAIL_DEC        (4 << 16)
 #       define R128_STENCIL_S_FAIL_INV        (5 << 16)
+#       define R128_STENCIL_S_FAIL_INC_WRAP   (6 << 16)        /* GUESS */
+#       define R128_STENCIL_S_FAIL_DEC_WRAP   (7 << 16)        /* GUESS */
 #       define R128_STENCIL_S_FAIL_MASK       (7 << 16)
 #       define R128_STENCIL_ZPASS_KEEP        (0 << 20)
 #       define R128_STENCIL_ZPASS_ZERO        (1 << 20)
 #       define R128_STENCIL_ZPASS_INC         (3 << 20)
 #       define R128_STENCIL_ZPASS_DEC         (4 << 20)
 #       define R128_STENCIL_ZPASS_INV         (5 << 20)
+#       define R128_STENCIL_ZPASS_INC_WRAP    (6 << 20)        /* GUESS */
+#       define R128_STENCIL_ZPASS_DEC_WRAP    (7 << 20)        /* GUESS */
 #       define R128_STENCIL_ZPASS_MASK        (7 << 20)
 #       define R128_STENCIL_ZFAIL_KEEP        (0 << 24)
 #       define R128_STENCIL_ZFAIL_ZERO        (1 << 24)
 #       define R128_STENCIL_ZFAIL_INC         (3 << 24)
 #       define R128_STENCIL_ZFAIL_DEC         (4 << 24)
 #       define R128_STENCIL_ZFAIL_INV         (5 << 24)
+#       define R128_STENCIL_ZFAIL_INC_WRAP    (6 << 24)        /* GUESS */
+#       define R128_STENCIL_ZFAIL_DEC_WRAP    (7 << 24)        /* GUESS */
 #       define R128_STENCIL_ZFAIL_MASK        (7 << 24)
 #define R128_TEX_CNTL_C                   0x1c9c
 #       define R128_Z_ENABLE                   (1 <<  0)