[Mesa-dev] [PATCHv2 2/3] meta: Handle bitmaps with alpha test enabled.
Francisco Jerez
currojerez at riseup.net
Mon Nov 1 19:06:31 PDT 2010
---
src/mesa/drivers/common/meta.c | 45 ++++++++++++++++++++++++++++++++++-----
1 files changed, 39 insertions(+), 6 deletions(-)
diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 7ad1e72..f96e931 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -1980,13 +1980,43 @@ _mesa_meta_DrawPixels(struct gl_context *ctx,
_mesa_meta_end(ctx);
}
+static GLboolean
+alpha_test_bitmap(struct gl_context *ctx)
+{
+ struct gl_colorbuffer_attrib *color = &ctx->Color;
+ GLenum func = (color->AlphaEnabled ? color->AlphaFunc : GL_ALWAYS);
+ GLubyte ref, alpha;
+
+ CLAMPED_FLOAT_TO_UBYTE(ref, color->AlphaRef);
+ CLAMPED_FLOAT_TO_UBYTE(alpha, ctx->Current.RasterColor[ACOMP]);
+
+ switch (func) {
+ case GL_NEVER:
+ return GL_FALSE;
+ case GL_LESS:
+ return alpha < ref;
+ case GL_EQUAL:
+ return alpha == ref;
+ case GL_LEQUAL:
+ return alpha <= ref;
+ case GL_GREATER:
+ return alpha > ref;
+ case GL_NOTEQUAL:
+ return alpha != ref;
+ case GL_GEQUAL:
+ return alpha >= ref;
+ case GL_ALWAYS:
+ return GL_TRUE;
+ default:
+ assert(0);
+ return GL_FALSE;
+ }
+}
/**
- * Do glBitmap with a alpha texture quad. Use the alpha test to
- * cull the 'off' bits. If alpha test is already enabled, fall back
- * to swrast (should be a rare case).
- * A bitmap cache as in the gallium/mesa state tracker would
- * improve performance a lot.
+ * Do glBitmap with a alpha texture quad. Use the alpha test to cull
+ * the 'off' bits. A bitmap cache as in the gallium/mesa state
+ * tracker would improve performance a lot.
*/
void
_mesa_meta_Bitmap(struct gl_context *ctx,
@@ -2009,7 +2039,7 @@ _mesa_meta_Bitmap(struct gl_context *ctx,
* Check if swrast fallback is needed.
*/
if (ctx->_ImageTransferState ||
- ctx->Color.AlphaEnabled ||
+ ctx->FragmentProgram._Enabled ||
ctx->Fog.Enabled ||
ctx->Texture._EnabledUnits ||
width > tex->MaxSize ||
@@ -2018,6 +2048,9 @@ _mesa_meta_Bitmap(struct gl_context *ctx,
return;
}
+ if (!alpha_test_bitmap(ctx))
+ return;
+
/* Most GL state applies to glBitmap (like blending, stencil, etc),
* but a there's a few things we need to override:
*/
--
1.6.4.4
More information about the mesa-dev
mailing list