Apply Eric's stencil wrap patch (Eric Anholt)
authorAlex Deucher <agd5f@yahoo.com>
Fri, 8 Oct 2004 00:31:51 +0000 (00:31 +0000)
committerAlex Deucher <agd5f@yahoo.com>
Fri, 8 Oct 2004 00:31:51 +0000 (00:31 +0000)
src/mesa/drivers/dri/savage/savage_xmesa.c
src/mesa/drivers/dri/savage/savagecontext.h
src/mesa/drivers/dri/savage/savagedd.c
src/mesa/drivers/dri/savage/savagedd.h
src/mesa/drivers/dri/savage/savageioctl.c
src/mesa/drivers/dri/savage/savagespan.c
src/mesa/drivers/dri/savage/savagestate.c

index a6ef167a7d6c17727f846f1adb074519ebcc6142..adb7f2c82db2e87db4d7c478d0a849e5900165e9 100644 (file)
@@ -85,6 +85,14 @@ unsigned long time_sum=0;
 struct timeval tv_s1,tv_f1;
 #endif
 
+static const char *const card_extensions[] =
+{
+    "GL_ARB_multitexture",
+    "GL_EXT_texture_lod_bias",
+    "GL_EXT_texture_env_add",
+    NULL
+};
+
 /* this is first function called in dirver*/
 
 static GLboolean
@@ -404,10 +412,7 @@ savageCreateContext( const __GLcontextModes *mesaVis,
      make_empty_list(&imesa->SwappedOut);
    }
 
-   imesa->hw_stencil = GL_FALSE;
-#if HW_STENCIL
    imesa->hw_stencil = mesaVis->stencilBits && mesaVis->depthBits == 24;
-#endif
    imesa->depth_scale = (imesa->savageScreen->zpp == 2) ?
        (1.0F/0x10000):(1.0F/0x1000000);
 
@@ -457,7 +462,7 @@ savageCreateContext( const __GLcontextModes *mesaVis,
    if (savageDMAInit(imesa) == GL_FALSE)
        return GL_FALSE;  
    
-   savageDDExtensionsInit( ctx );
+   driInitExtensions( ctx, card_extensions, GL_TRUE );
 
    savageDDInitStateFuncs( ctx );
    savageDDInitSpanFuncs( ctx );
@@ -518,11 +523,7 @@ savageCreateBuffer( __DRIscreenPrivate *driScrnPriv,
       return GL_FALSE; /* not implemented */
    }
    else {
-#if HW_STENCIL
        GLboolean swStencil = mesaVis->stencilBits > 0 && mesaVis->depthBits != 24;
-#else
-       GLboolean swStencil = mesaVis->stencilBits > 0;
-#endif
       driDrawPriv->driverPrivate = (void *) 
          _mesa_create_framebuffer(mesaVis,
                                   GL_FALSE,  /* software depth buffer? */
index 370bceb753161223ea24ea9750ece798d430ea82..5ea40cea4b6a32a413cdf883bc4aa703c20bbe86 100644 (file)
@@ -59,7 +59,6 @@ typedef struct savage_texture_object_t *savageTextureObjectPtr;
 #define SAVAGE_FALLBACK_BLEND_EQ       0x200
 
 
-#define HW_STENCIL 1
 #define HW_CULL    1
 
 /* for savagectx.new_state - manage GL->driver state changes
index 90acab86be8ee536f71d0456dac12bda0d2b2e6f..dddc6d9a650ed4d778cec737c4a629857d4579c7 100644 (file)
@@ -39,9 +39,6 @@
 #include "extensions.h"
 
 
-extern int xf86VTSema;
-
-
 /***************************************
  * Mesa's Driver Functions
  ***************************************/
@@ -87,18 +84,6 @@ static void savageBufferSize(GLframebuffer *buffer, GLuint *width, GLuint *heigh
 }
 
 
-
-
-void savageDDExtensionsInit( GLcontext *ctx )
-{
-   _mesa_enable_extension( ctx, "GL_ARB_multitexture" );
-   _mesa_enable_extension( ctx, "GL_EXT_texture_lod_bias" );
-   _mesa_enable_extension( ctx, "GL_EXT_texture_env_add" );
-}
-
-
-
-
 void savageDDInitDriverFuncs( GLcontext *ctx )
 {
    ctx->Driver.GetBufferSize = savageBufferSize;
index 8d058f3de1a889a623d3622653d2d2ce6f0022fa..ae167be700890aba27f1705457a723417f9fc498 100644 (file)
@@ -28,6 +28,5 @@
 
 #include "context.h"
 
-void savageDDExtensionsInit( GLcontext *ctx );
 void savageDDInitDriverFuncs( GLcontext *ctx );
 #endif
index 46f836ebc717994a72eb8d467eb0a15380fc575d..6d77eb408e7b379243ebdc23738d92de7d498f86 100644 (file)
@@ -94,7 +94,6 @@ static void savage_BCI_clear(GLcontext *ctx, drm_savage_clear_t *pclear)
                
                if ( pclear->flags & (SAVAGE_DEPTH |SAVAGE_STENCIL) ) {
                        uint32_t writeMask = 0x0;
-#if HW_STENCIL         
                        if(imesa->hw_stencil)
                        {        
                            if(pclear->flags & SAVAGE_STENCIL)
@@ -107,7 +106,6 @@ static void savage_BCI_clear(GLcontext *ctx, drm_savage_clear_t *pclear)
                                 writeMask |= 0x00FFFFFF;
                            }
                         }
-#endif
                        if(imesa->IsFullScreen && imesa->NotFirstFrame &&
                           imesa->savageScreen->chipset >= S3_SAVAGE4)
                        {
@@ -122,7 +120,6 @@ static void savage_BCI_clear(GLcontext *ctx, drm_savage_clear_t *pclear)
                            if(imesa->IsFullScreen)
                                imesa->NotFirstFrame = GL_TRUE;
                                
-#if HW_STENCIL
                            if(imesa->hw_stencil)
                            {
                                bciptr = savageDMAAlloc (imesa, 10);
@@ -133,7 +130,6 @@ static void savage_BCI_clear(GLcontext *ctx, drm_savage_clear_t *pclear)
                                 }
                             }
                            else
-#endif              
                            {
                                bciptr = savageDMAAlloc (imesa, 6);
                            }
@@ -144,7 +140,6 @@ static void savage_BCI_clear(GLcontext *ctx, drm_savage_clear_t *pclear)
                            WRITE_CMD((bciptr) , pclear->clear_depth,uint32_t);
                            WRITE_CMD((bciptr) , (y <<16) | x,uint32_t);
                            WRITE_CMD((bciptr) , (height << 16) | width,uint32_t);
-#if HW_STENCIL                     
                            if(imesa->hw_stencil)
                            {
                                if(writeMask != 0xFFFFFFFF)
@@ -153,7 +148,6 @@ static void savage_BCI_clear(GLcontext *ctx, drm_savage_clear_t *pclear)
                                    WRITE_CMD((bciptr) , 0xFFFFFFFF,uint32_t);  
                                }
                            }
-#endif
                            savageDMACommit (imesa, bciptr);
                        }
                }
index 0369988ad247a3189909932c339106faac64ed21..b6412d2983a1c620d165c89368805d54a3edc88c 100644 (file)
@@ -286,12 +286,10 @@ void savageDDInitSpanFuncs( GLcontext *ctx )
        swdd->WriteDepthSpan = savageWriteDepthSpan_8_24;
        swdd->ReadDepthPixels = savageReadDepthPixels_8_24;
        swdd->WriteDepthPixels = savageWriteDepthPixels_8_24;    
-#if HW_STENCIL
        swdd->ReadStencilSpan = savageReadStencilSpan_8_24;
        swdd->WriteStencilSpan = savageWriteStencilSpan_8_24;
        swdd->ReadStencilPixels = savageReadStencilPixels_8_24;
        swdd->WriteStencilPixels = savageWriteStencilPixels_8_24;
-#endif       
        break;   
    
    }
index e03c2e340cc54796aca5cb266ce18af09498fea8..c6545fbcca39b5e7deee9e004c5a8b3e9ca67c9a 100644 (file)
@@ -483,22 +483,14 @@ static void savageDDDepthFunc_s4(GLcontext *ctx, GLenum func)
 
        imesa->regs.s4.zBufCtrl.ni.zBufEn = GL_TRUE;
     }
-    else if (imesa->glCtx->Stencil.Enabled &&
-             !imesa->glCtx->DrawBuffer->UseSoftwareStencilBuffer)
+    else if (imesa->glCtx->Stencil.Enabled && imesa->hw_stencil)
     {
-#define STENCIL (0x27)
-
-        /* by Jiayo, tempory disable HW stencil in 24 bpp */
-#if HW_STENCIL
-        if(imesa->hw_stencil)
-        {
-           imesa->regs.s4.zBufCtrl.ni.zCmpFunc = CF_Always;
-           imesa->regs.s4.zBufCtrl.ni.zBufEn   = GL_TRUE;
-           imesa->regs.s4.drawLocalCtrl.ni.zUpdateEn = GL_FALSE;
-           imesa->regs.s4.drawLocalCtrl.ni.flushPdZbufWrites = GL_FALSE;
-           imesa->regs.s4.zWatermarks.ni.wLow        = 8;
-        }
-#endif /* end #if HW_STENCIL */
+        /* Need to keep Z on for Stencil. */
+       imesa->regs.s4.zBufCtrl.ni.zCmpFunc = CF_Always;
+       imesa->regs.s4.zBufCtrl.ni.zBufEn   = GL_TRUE;
+       imesa->regs.s4.drawLocalCtrl.ni.zUpdateEn = GL_FALSE;
+       imesa->regs.s4.drawLocalCtrl.ni.flushPdZbufWrites = GL_FALSE;
+       imesa->regs.s4.zWatermarks.ni.wLow        = 8;
     }
     else
     {
@@ -988,165 +980,139 @@ static void savageDDFogfv(GLcontext *ctx, GLenum pname, const GLfloat *param)
 }
 
 
-#if HW_STENCIL
 static void savageStencilFunc(GLcontext *);
 
 static void savageDDStencilFunc(GLcontext *ctx, GLenum func, GLint ref,
                                 GLuint mask)
 {
-    savageStencilFunc(ctx);
+    savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+    SCmpFunc a=0;
+
+    imesa->regs.s4.zBufCtrl.ni.stencilRefVal = ctx->Stencil.Ref[0];
+    imesa->regs.s4.stencilCtrl.ni.readMask  = ctx->Stencil.ValueMask[0];
+
+    switch (ctx->Stencil.Function[0])
+    {
+    case GL_NEVER: a = CF_Never; break;
+    case GL_ALWAYS: a = CF_Always; break;
+    case GL_LESS: a = CF_Less; break; 
+    case GL_LEQUAL: a = CF_LessEqual; break;
+    case GL_EQUAL: a = CF_Equal; break;
+    case GL_GREATER: a = CF_Greater; break;
+    case GL_GEQUAL: a = CF_GreaterEqual; break;
+    case GL_NOTEQUAL: a = CF_NotEqual; break;
+    default:
+        break;
+    }
+
+    imesa->regs.s4.stencilCtrl.ni.cmpFunc = a;
+
+    imesa->dirty |= SAVAGE_UPLOAD_CTX;
 }
 
 static void savageDDStencilMask(GLcontext *ctx, GLuint mask)
 {
-    savageStencilFunc(ctx);
+    savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+
+    imesa->regs.s4.stencilCtrl.ni.writeMask = ctx->Stencil.WriteMask[0];
+
+    imesa->dirty |= SAVAGE_UPLOAD_CTX;
 }
 
 static void savageDDStencilOp(GLcontext *ctx, GLenum fail, GLenum zfail,
                               GLenum zpass)
-{
-    savageStencilFunc(ctx);  
-}
-
-static void savageStencilFunc(GLcontext *ctx)
 {
     savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
-    SCmpFunc a=0;
-    
-    if (ctx->Stencil.Enabled)
-    {
-       imesa->regs.s4.stencilCtrl.ui = 0x0; 
 
-        switch (ctx->Stencil.Function[0])
-        {
-       case GL_NEVER: a = CF_Never; break;
-       case GL_ALWAYS: a = CF_Always; break;
-       case GL_LESS: a = CF_Less; break; 
-       case GL_LEQUAL: a = CF_LessEqual; break;
-       case GL_EQUAL: a = CF_Equal; break;
-       case GL_GREATER: a = CF_Greater; break;
-       case GL_GEQUAL: a = CF_GreaterEqual; break;
-       case GL_NOTEQUAL: a = CF_NotEqual; break;
-       default:
-           break;
-        }
-
-        imesa->regs.s4.stencilCtrl.ni.cmpFunc     = a;
-        imesa->regs.s4.stencilCtrl.ni.stencilEn   = GL_TRUE;
-        imesa->regs.s4.stencilCtrl.ni.readMask    = ctx->Stencil.ValueMask[0];
-        imesa->regs.s4.stencilCtrl.ni.writeMask   = ctx->Stencil.WriteMask[0];
-
-        switch (ctx->Stencil.FailFunc[0])
-        {
-            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;
-#if GL_EXT_stencil_wrap
-            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;
-#endif
-        }
-
-        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;
-#if GL_EXT_stencil_wrap
-            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;
-#endif
-        }
-
-        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;
-#if GL_EXT_stencil_wrap
-            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;
-#endif
-        }
-
-
-       imesa->regs.s4.zBufCtrl.ni.stencilRefVal = ctx->Stencil.Ref[0];
+    switch (ctx->Stencil.FailFunc[0])
+    {
+    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;
+    }
 
-        /*
-         * force Z on, HW limitation
-         */
 
-        if (imesa->regs.s4.zBufCtrl.ni.zBufEn != GL_TRUE)
-        {
-            imesa->regs.s4.zBufCtrl.ni.zCmpFunc       = CF_Always;
-            imesa->regs.s4.zBufCtrl.ni.zBufEn         = GL_TRUE;
-            imesa->regs.s4.drawLocalCtrl.ni.zUpdateEn = GL_FALSE;
-        }
+    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;
     }
-    else
+
+    switch (ctx->Stencil.ZPassFunc[0])
     {
-       imesa->regs.s4.stencilCtrl.ni.stencilEn = GL_FALSE;
+    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->dirty |= SAVAGE_UPLOAD_CTX;
 }
-#endif /* end #if HW_STENCIL */
+
+
 /* =============================================================
  */
 
@@ -1186,11 +1152,18 @@ static void savageDDEnable_s4(GLcontext *ctx, GLenum cap, GLboolean state)
             imesa->dirty |= SAVAGE_UPLOAD_CTX;
            if (!imesa->hw_stencil)
                FALLBACK (ctx, SAVAGE_FALLBACK_STENCIL, state);
-#if HW_STENCIL
-           else
-               imesa->regs.s4.stencilCtrl.ni.stencilEn =
-                   state ? GL_TRUE : GL_FALSE;
-#endif
+           else {
+               imesa->regs.s4.stencilCtrl.ni.stencilEn = state;
+               if (ctx->Stencil.Enabled &&
+                   imesa->regs.s4.zBufCtrl.ni.zBufEn != GL_TRUE)
+               {
+                   /* Stencil buffer requires Z enabled. */
+                   imesa->regs.s4.zBufCtrl.ni.zCmpFunc       = CF_Always;
+                   imesa->regs.s4.zBufCtrl.ni.zBufEn         = GL_TRUE;
+                   imesa->regs.s4.drawLocalCtrl.ni.zUpdateEn = GL_FALSE;
+               }
+               imesa->dirty |= SAVAGE_UPLOAD_CTX;
+           }
             break;
         case GL_FOG:
             imesa->dirty |= SAVAGE_UPLOAD_CTX;
@@ -1693,6 +1666,15 @@ static void savageDDInitState_s3d( savageContextPtr imesa )
     imesa->regs.s3d.zBufCtrl.ni.drawUpdateEn     = GL_TRUE;
     imesa->regs.s3d.zBufCtrl.ni.wrZafterAlphaTst = GL_FALSE;
     imesa->regs.s3d.zBufCtrl.ni.zUpdateEn        = GL_TRUE;
+    imesa->regs.s4.zBufCtrl.ni.stencilRefVal      = 0x00;
+
+    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.writeMask       = 0xff;
+    imesa->regs.s4.stencilCtrl.ni.readMask        = 0xff;
 
     imesa->regs.s3d.drawCtrl.ni.srcAlphaMode      = SAM_One;
     imesa->regs.s3d.drawCtrl.ni.flushPdZbufWrites = GL_TRUE;
@@ -1883,15 +1865,9 @@ void savageDDInitStateFuncs(GLcontext *ctx)
        ctx->Driver.ColorMask = savageDDColorMask_s4;
        ctx->Driver.ShadeModel = savageDDShadeModel_s4;
        ctx->Driver.LightModelfv = savageDDLightModelfv_s4;
-#if HW_STENCIL
        ctx->Driver.StencilFunc = savageDDStencilFunc;
        ctx->Driver.StencilMask = savageDDStencilMask;
        ctx->Driver.StencilOp = savageDDStencilOp;
-#else
-       ctx->Driver.StencilFunc = 0;
-       ctx->Driver.StencilMask = 0;
-       ctx->Driver.StencilOp = 0;
-#endif /* end #if HW_STENCIL */
     } else {
        ctx->Driver.Enable = savageDDEnable_s3d;
        ctx->Driver.AlphaFunc = savageDDAlphaFunc_s3d;