diff options
author | Alex Deucher <[email protected]> | 2004-10-08 00:31:51 +0000 |
---|---|---|
committer | Alex Deucher <[email protected]> | 2004-10-08 00:31:51 +0000 |
commit | cb1642a75cc5fd795d43d15f79118162d922f429 (patch) | |
tree | d9f6e2e74f38baf9682246a6b876c4456f6f0ae8 /src | |
parent | d09209f5530e8bba78e4e0ec62b2027c588cc8f3 (diff) |
Apply Eric's stencil wrap patch (Eric Anholt)
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/drivers/dri/savage/savage_xmesa.c | 17 | ||||
-rw-r--r-- | src/mesa/drivers/dri/savage/savagecontext.h | 1 | ||||
-rw-r--r-- | src/mesa/drivers/dri/savage/savagedd.c | 15 | ||||
-rw-r--r-- | src/mesa/drivers/dri/savage/savagedd.h | 1 | ||||
-rw-r--r-- | src/mesa/drivers/dri/savage/savageioctl.c | 6 | ||||
-rw-r--r-- | src/mesa/drivers/dri/savage/savagespan.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/savage/savagestate.c | 300 |
7 files changed, 147 insertions, 195 deletions
diff --git a/src/mesa/drivers/dri/savage/savage_xmesa.c b/src/mesa/drivers/dri/savage/savage_xmesa.c index a6ef167a7d6..adb7f2c82db 100644 --- a/src/mesa/drivers/dri/savage/savage_xmesa.c +++ b/src/mesa/drivers/dri/savage/savage_xmesa.c @@ -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? */ diff --git a/src/mesa/drivers/dri/savage/savagecontext.h b/src/mesa/drivers/dri/savage/savagecontext.h index 370bceb7531..5ea40cea4b6 100644 --- a/src/mesa/drivers/dri/savage/savagecontext.h +++ b/src/mesa/drivers/dri/savage/savagecontext.h @@ -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 diff --git a/src/mesa/drivers/dri/savage/savagedd.c b/src/mesa/drivers/dri/savage/savagedd.c index 90acab86be8..dddc6d9a650 100644 --- a/src/mesa/drivers/dri/savage/savagedd.c +++ b/src/mesa/drivers/dri/savage/savagedd.c @@ -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; diff --git a/src/mesa/drivers/dri/savage/savagedd.h b/src/mesa/drivers/dri/savage/savagedd.h index 8d058f3de1a..ae167be7008 100644 --- a/src/mesa/drivers/dri/savage/savagedd.h +++ b/src/mesa/drivers/dri/savage/savagedd.h @@ -28,6 +28,5 @@ #include "context.h" -void savageDDExtensionsInit( GLcontext *ctx ); void savageDDInitDriverFuncs( GLcontext *ctx ); #endif diff --git a/src/mesa/drivers/dri/savage/savageioctl.c b/src/mesa/drivers/dri/savage/savageioctl.c index 46f836ebc71..6d77eb408e7 100644 --- a/src/mesa/drivers/dri/savage/savageioctl.c +++ b/src/mesa/drivers/dri/savage/savageioctl.c @@ -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); } } diff --git a/src/mesa/drivers/dri/savage/savagespan.c b/src/mesa/drivers/dri/savage/savagespan.c index 0369988ad24..b6412d2983a 100644 --- a/src/mesa/drivers/dri/savage/savagespan.c +++ b/src/mesa/drivers/dri/savage/savagespan.c @@ -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; } diff --git a/src/mesa/drivers/dri/savage/savagestate.c b/src/mesa/drivers/dri/savage/savagestate.c index e03c2e340cc..c6545fbcca3 100644 --- a/src/mesa/drivers/dri/savage/savagestate.c +++ b/src/mesa/drivers/dri/savage/savagestate.c @@ -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; |