Enable support for EXT_stencil_wrap. The code was already there, but the
authorIan Romanick <idr@us.ibm.com>
Sat, 13 Aug 2005 01:43:28 +0000 (01:43 +0000)
committerIan Romanick <idr@us.ibm.com>
Sat, 13 Aug 2005 01:43:28 +0000 (01:43 +0000)
extension wasn't enabled.  I have verified its correct function with Mesa's
stencil_wrap test.  It is enabled on both Savage4 and Savage3D.  Since
Savage3D uses a software fallback for *all* stencil operations, this is safe.

src/mesa/drivers/dri/savage/savage_bci.h
src/mesa/drivers/dri/savage/savage_xmesa.c
src/mesa/drivers/dri/savage/savagestate.c

index 591235c4bd00700036dea7a00a0f30e453e23ad0..33cfac32c71bfa6de9953d5c0ba3e9e536061549 100644 (file)
@@ -431,43 +431,17 @@ typedef enum
  * stencil control
  */
 
-typedef ZCmpFunc SCmpFunc;
-
-typedef enum
-{
-    STC_FAIL_Keep,
-    STC_FAIL_Zero,
-    STC_FAIL_Equal,
-    STC_FAIL_IncClamp,
-    STC_FAIL_DecClamp,
-    STC_FAIL_Invert,
-    STC_FAIL_Inc,
-    STC_FAIL_Dec
-} StencilFailOp;
-
-typedef enum
-{
-    STC_ZPASS_Keep,
-    STC_ZPASS_Zero,
-    STC_ZPASS_Equal,
-    STC_ZPASS_IncClamp,
-    STC_ZPASS_DecClamp,
-    STC_ZPASS_Invert,
-    STC_ZPASS_Inc,
-    STC_ZPASS_Dec
-} StencilZPassOp;
-
 typedef enum
 {
-    STC_ZFAIL_Keep,
-    STC_ZFAIL_Zero,
-    STC_ZFAIL_Equal,
-    STC_ZFAIL_IncClamp,
-    STC_ZFAIL_DecClamp,
-    STC_ZFAIL_Invert,
-    STC_ZFAIL_Inc,
-    STC_ZFAIL_Dec
-} StencilZFailOp;
+    STENCIL_Keep,
+    STENCIL_Zero,
+    STENCIL_Equal,
+    STENCIL_IncClamp,
+    STENCIL_DecClamp,
+    STENCIL_Invert,
+    STENCIL_Inc,
+    STENCIL_Dec
+} StencilOp;
 
 /***************************************************************
 *** Bitfield Structures for Programming Interface **************
index fa20d10edb3f95e3c76d4623d886fd32860766df..d57b2c52d4594ef58b11fb71ec13564aad52ab3f 100644 (file)
@@ -133,6 +133,7 @@ static const struct dri_extension card_extensions[] =
     { "GL_ARB_multisample",                GL_ARB_multisample_functions },
     { "GL_ARB_multitexture",               NULL },
     { "GL_ARB_texture_compression",        GL_ARB_texture_compression_functions },
+    { "GL_EXT_stencil_wrap",               NULL },
     { "GL_EXT_texture_lod_bias",           NULL },
     { NULL,                                NULL }
 };
index 567b9797336c8187f27b2266822312f212ed9a1e..996d5b917177338a7a7fa778faa4d087a54d9cea 100644 (file)
@@ -1001,9 +1001,9 @@ static void savageDDStencilFunc(GLcontext *ctx, GLenum func, GLint ref,
                                 GLuint mask)
 {
     savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
-    SCmpFunc a=0;
-    u_int32_t zBufCtrl = imesa->regs.s4.zBufCtrl.ui;
-    u_int32_t stencilCtrl = imesa->regs.s4.stencilCtrl.ui;
+    unsigned a=0;
+    const u_int32_t zBufCtrl = imesa->regs.s4.zBufCtrl.ui;
+    const u_int32_t stencilCtrl = imesa->regs.s4.stencilCtrl.ui;
 
     imesa->regs.s4.zBufCtrl.ni.stencilRefVal = ctx->Stencil.Ref[0];
     imesa->regs.s4.stencilCtrl.ni.readMask  = ctx->Stencil.ValueMask[0];
@@ -1039,96 +1039,33 @@ static void savageDDStencilMask(GLcontext *ctx, GLuint mask)
     }
 }
 
-static void savageDDStencilOp(GLcontext *ctx, GLenum fail, GLenum zfail,
-                              GLenum zpass)
+static unsigned get_stencil_op_value( GLenum op )
 {
-    savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
-    u_int32_t stencilCtrl = imesa->regs.s4.stencilCtrl.ui;
-
-    switch (ctx->Stencil.FailFunc[0])
+    switch (op)
     {
-    case GL_KEEP:
-       imesa->regs.s4.stencilCtrl.ni.failOp = STC_FAIL_Keep;
-       break;
-    case GL_ZERO:
-       imesa->regs.s4.stencilCtrl.ni.failOp = STC_FAIL_Zero;
-       break;
-    case GL_REPLACE:
-       imesa->regs.s4.stencilCtrl.ni.failOp = STC_FAIL_Equal;
-       break;
-    case GL_INCR:
-       imesa->regs.s4.stencilCtrl.ni.failOp = STC_FAIL_IncClamp;
-       break;
-    case GL_DECR:
-       imesa->regs.s4.stencilCtrl.ni.failOp = STC_FAIL_DecClamp;
-       break;
-    case GL_INVERT:
-       imesa->regs.s4.stencilCtrl.ni.failOp = STC_FAIL_Invert;
-       break;
-    case GL_INCR_WRAP_EXT:
-       imesa->regs.s4.stencilCtrl.ni.failOp = STC_FAIL_Inc;
-       break;
-    case GL_DECR_WRAP_EXT:
-       imesa->regs.s4.stencilCtrl.ni.failOp = STC_FAIL_Dec;
-       break;
+    case GL_KEEP:      return STENCIL_Keep;
+    case GL_ZERO:      return STENCIL_Zero;
+    case GL_REPLACE:   return STENCIL_Equal;
+    case GL_INCR:      return STENCIL_IncClamp;
+    case GL_DECR:      return STENCIL_DecClamp;
+    case GL_INVERT:    return STENCIL_Invert;
+    case GL_INCR_WRAP: return STENCIL_Inc;
+    case GL_DECR_WRAP: return STENCIL_Dec;
     }
 
+    /* Should *never* get here. */
+    return STENCIL_Keep;
+}
 
-    switch (ctx->Stencil.ZFailFunc[0])
-    {
-    case GL_KEEP:
-       imesa->regs.s4.stencilCtrl.ni.passZfailOp = STC_FAIL_Keep;
-       break;
-    case GL_ZERO:
-       imesa->regs.s4.stencilCtrl.ni.passZfailOp = STC_FAIL_Zero;
-       break;
-    case GL_REPLACE:
-       imesa->regs.s4.stencilCtrl.ni.passZfailOp = STC_FAIL_Equal;
-       break;
-    case GL_INCR:
-       imesa->regs.s4.stencilCtrl.ni.passZfailOp = STC_FAIL_IncClamp;
-       break;
-    case GL_DECR:
-       imesa->regs.s4.stencilCtrl.ni.passZfailOp = STC_FAIL_DecClamp;
-       break;
-    case GL_INVERT:
-       imesa->regs.s4.stencilCtrl.ni.passZfailOp = STC_FAIL_Invert;
-       break;
-    case GL_INCR_WRAP_EXT:
-       imesa->regs.s4.stencilCtrl.ni.passZfailOp = STC_FAIL_Inc;
-       break;
-    case GL_DECR_WRAP_EXT:
-       imesa->regs.s4.stencilCtrl.ni.passZfailOp = STC_FAIL_Dec;
-       break;
-    }
+static void savageDDStencilOp(GLcontext *ctx, GLenum fail, GLenum zfail,
+                              GLenum zpass)
+{
+    savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+    const u_int32_t stencilCtrl = imesa->regs.s4.stencilCtrl.ui;
 
-    switch (ctx->Stencil.ZPassFunc[0])
-    {
-    case GL_KEEP:
-       imesa->regs.s4.stencilCtrl.ni.passZpassOp = STC_FAIL_Keep;
-       break;
-    case GL_ZERO:
-       imesa->regs.s4.stencilCtrl.ni.passZpassOp = STC_FAIL_Zero;
-       break;
-    case GL_REPLACE:
-       imesa->regs.s4.stencilCtrl.ni.passZpassOp = STC_FAIL_Equal;
-       break;
-    case GL_INCR:
-       imesa->regs.s4.stencilCtrl.ni.passZpassOp = STC_FAIL_IncClamp;
-       break;
-    case GL_DECR:
-       imesa->regs.s4.stencilCtrl.ni.passZpassOp = STC_FAIL_DecClamp;
-       break;
-    case GL_INVERT:
-       imesa->regs.s4.stencilCtrl.ni.passZpassOp = STC_FAIL_Invert;
-       break;
-    case GL_INCR_WRAP_EXT:
-       imesa->regs.s4.stencilCtrl.ni.passZpassOp = STC_FAIL_Inc;
-       break;
-    case GL_DECR_WRAP_EXT:
-       imesa->regs.s4.stencilCtrl.ni.passZpassOp = STC_FAIL_Dec;
-       break;
-    }
+    imesa->regs.s4.stencilCtrl.ni.failOp = get_stencil_op_value( ctx->Stencil.FailFunc[0] );
+    imesa->regs.s4.stencilCtrl.ni.passZfailOp = get_stencil_op_value( ctx->Stencil.ZFailFunc[0] );
+    imesa->regs.s4.stencilCtrl.ni.passZpassOp = get_stencil_op_value( ctx->Stencil.ZPassFunc[0] );
 
     if (stencilCtrl != imesa->regs.s4.stencilCtrl.ui)
        imesa->dirty |= SAVAGE_UPLOAD_GLOBAL;
@@ -1586,9 +1523,9 @@ static void savageDDInitState_s4( savageContextPtr imesa )
 
     imesa->regs.s4.stencilCtrl.ni.stencilEn       = GL_FALSE;
     imesa->regs.s4.stencilCtrl.ni.cmpFunc         = CF_Always;
-    imesa->regs.s4.stencilCtrl.ni.failOp          = STC_FAIL_Keep;
-    imesa->regs.s4.stencilCtrl.ni.passZfailOp     = STC_FAIL_Keep;
-    imesa->regs.s4.stencilCtrl.ni.passZpassOp     = STC_FAIL_Keep;
+    imesa->regs.s4.stencilCtrl.ni.failOp          = STENCIL_Keep;
+    imesa->regs.s4.stencilCtrl.ni.passZfailOp     = STENCIL_Keep;
+    imesa->regs.s4.stencilCtrl.ni.passZpassOp     = STENCIL_Keep;
     imesa->regs.s4.stencilCtrl.ni.writeMask       = 0xff;
     imesa->regs.s4.stencilCtrl.ni.readMask        = 0xff;