diff options
author | Daniel Borca <[email protected]> | 2004-05-19 08:16:44 +0000 |
---|---|---|
committer | Daniel Borca <[email protected]> | 2004-05-19 08:16:44 +0000 |
commit | fc332f008c8de215de59436c0ff5550b7ffd08e2 (patch) | |
tree | 39359829249a1619a92db78d2f7389fda5e42511 /src/mesa | |
parent | 73f59b01eacf62c2e0ba720d4fbf250773aeabf2 (diff) |
added GL_NV_blend_square
fixed alpha blending modes for Napalm
minor fix in compressed texture aspectratio adjust
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/drivers/glide/fxdd.c | 1 | ||||
-rw-r--r-- | src/mesa/drivers/glide/fxddtex.c | 6 | ||||
-rw-r--r-- | src/mesa/drivers/glide/fxsetup.c | 132 |
3 files changed, 57 insertions, 82 deletions
diff --git a/src/mesa/drivers/glide/fxdd.c b/src/mesa/drivers/glide/fxdd.c index 14d6ff8948f..77b98793ec3 100644 --- a/src/mesa/drivers/glide/fxdd.c +++ b/src/mesa/drivers/glide/fxdd.c @@ -1487,6 +1487,7 @@ fxDDInitExtensions(GLcontext * ctx) _mesa_enable_extension(ctx, "GL_3DFX_texture_compression_FXT1"); _mesa_enable_extension(ctx, "GL_EXT_texture_compression_s3tc"); _mesa_enable_extension(ctx, "GL_S3_s3tc"); + _mesa_enable_extension(ctx, "GL_NV_blend_square"); } if (fxMesa->HaveCmbExt) { diff --git a/src/mesa/drivers/glide/fxddtex.c b/src/mesa/drivers/glide/fxddtex.c index c2d4af9d7db..1fbeb8d252d 100644 --- a/src/mesa/drivers/glide/fxddtex.c +++ b/src/mesa/drivers/glide/fxddtex.c @@ -1212,8 +1212,8 @@ adjust2DRatio (GLcontext *ctx, return GL_FALSE; } /* unpack image, apply transfer ops and store in rawImage */ - _mesa_texstore_argb8888(ctx, 2, GL_RGBA, - &_mesa_texformat_argb8888, rawImage, + _mesa_texstore_rgba8888(ctx, 2, GL_RGBA, + &_mesa_texformat_rgba8888_rev, rawImage, 0, 0, 0, /* dstX/Y/Zoffset */ width * rawBytes, /* dstRowStride */ 0, /* dstImageStride */ @@ -1230,7 +1230,7 @@ adjust2DRatio (GLcontext *ctx, dstRowStride, 0, /* dstImageStride */ newWidth, newHeight, 1, - GL_BGRA, CHAN_TYPE, tempImage, &ctx->DefaultPacking); + GL_RGBA, CHAN_TYPE, tempImage, &ctx->DefaultPacking); FREE(rawImage); } diff --git a/src/mesa/drivers/glide/fxsetup.c b/src/mesa/drivers/glide/fxsetup.c index 5b09dce24f7..6ebdb717d0b 100644 --- a/src/mesa/drivers/glide/fxsetup.c +++ b/src/mesa/drivers/glide/fxsetup.c @@ -1313,48 +1313,32 @@ fxDDBlendFuncSeparate(GLcontext * ctx, GLenum sfactor, GLenum dfactor, GLenum as { fxMesaContext fxMesa = FX_CONTEXT(ctx); tfxUnitsState *us = &fxMesa->unitsState; + GLboolean isNapalm = (fxMesa->type >= GR_SSTTYPE_Voodoo4); GLboolean have32bpp = (fxMesa->colDepth == 32); GLboolean haveAlpha = fxMesa->haveHwAlpha; GrAlphaBlendFnc_t sfact, dfact, asfact, adfact; /* [dBorca] Hack alert: - * We should condition *DST_ALPHA* modes - * by the boolean `haveAlpha' above! - * It indicates whether we really have HW alpha buffer... + * 15/16 BPP alpha channel alpha blending modes + * 0x0 AZERO Zero + * 0x4 AONE One + * + * 32 BPP alpha channel alpha blending modes + * 0x0 AZERO Zero + * 0x1 ASRC_ALPHA Source alpha + * 0x3 ADST_ALPHA Destination alpha + * 0x4 AONE One + * 0x5 AOMSRC_ALPHA 1 - Source alpha + * 0x7 AOMDST_ALPHA 1 - Destination alpha + * + * If we don't have HW alpha buffer: + * DST_ALPHA == 1 + * ONE_MINUS_DST_ALPHA == 0 + * Unsupported modes are: + * 1 if used as src blending factor + * 0 if used as dst blending factor */ -/* Use the text below to implement GL_NV_blend_square! -When the value A_COLOR is selected as the destination alpha blending factor, -the source pixel color is used as the destination blending factor. When the -value A_COLOR is selected as the source alpha blending factor, the destination -pixel color is used as the source blending factor. When the value A_SAMECOLOR -is selected as the destination alpha blending factor, the destination pixel -color is used as the destination blending factor. When the value A_SAMECOLOR -is selected as the source alpha blending factor, the source pixel color is -used as the source blending factor. Note also that the alpha blending -function 0xf (A_COLORBEFOREFOG/ASATURATE) is different depending upon whether -it is being used as a source or destination alpha blending function. When the -value 0xf is selected as the destination alpha blending factor, the source -color before the fog unit ("unfogged" color) is used as the destination -blending factor -- this alpha blending function is useful for multi-pass -rendering with atmospheric effects. When the value 0xf is selected as the -source alpha blending factor, the alpha-saturate anti-aliasing algorithm is -selected -- this MIN function performs polygonal anti-aliasing for polygons -which are drawn front-to-back. - -15/16 BPP alpha channel alpha blending modes - 0x0 AZERO Zero - 0x4 AONE One - -32 BPP alpha channel alpha blending modes - 0x0 AZERO Zero - 0x1 ASRC_ALPHA Source alpha - 0x3 ADST_ALPHA Destination alpha - 0x4 AONE One - 0x5 AOMSRC_ALPHA 1 - Source alpha - 0x7 AOMDST_ALPHA 1 - Destination alpha -*/ - switch (sfactor) { case GL_ZERO: sfact = GR_BLEND_ZERO; @@ -1375,19 +1359,24 @@ which are drawn front-to-back. sfact = GR_BLEND_ONE_MINUS_SRC_ALPHA; break; case GL_DST_ALPHA: - sfact = GR_BLEND_DST_ALPHA; + sfact = haveAlpha ? GR_BLEND_DST_ALPHA : GR_BLEND_ONE/*bad*/; break; case GL_ONE_MINUS_DST_ALPHA: - sfact = GR_BLEND_ONE_MINUS_DST_ALPHA; + sfact = haveAlpha ? GR_BLEND_ONE_MINUS_DST_ALPHA : GR_BLEND_ZERO/*bad*/; break; case GL_SRC_ALPHA_SATURATE: sfact = GR_BLEND_ALPHA_SATURATE; break; case GL_SRC_COLOR: + if (isNapalm) { + sfact = GR_BLEND_SAME_COLOR_EXT; + break; + } case GL_ONE_MINUS_SRC_COLOR: - /* USELESS */ - sfact = GR_BLEND_ONE; - break; + if (isNapalm) { + sfact = GR_BLEND_ONE_MINUS_SAME_COLOR_EXT; + break; + } default: sfact = GR_BLEND_ONE; break; @@ -1400,34 +1389,27 @@ which are drawn front-to-back. case GL_ONE: asfact = GR_BLEND_ONE; break; - case GL_DST_COLOR: - asfact = GR_BLEND_ONE/*bad*/; - break; - case GL_ONE_MINUS_DST_COLOR: - asfact = GR_BLEND_ONE/*bad*/; - break; + case GL_SRC_COLOR: case GL_SRC_ALPHA: asfact = have32bpp ? GR_BLEND_SRC_ALPHA : GR_BLEND_ONE/*bad*/; break; + case GL_ONE_MINUS_SRC_COLOR: case GL_ONE_MINUS_SRC_ALPHA: asfact = have32bpp ? GR_BLEND_ONE_MINUS_SRC_ALPHA : GR_BLEND_ONE/*bad*/; break; + case GL_DST_COLOR: case GL_DST_ALPHA: - asfact = have32bpp ? GR_BLEND_DST_ALPHA : GR_BLEND_ONE/*bad*/; + asfact = (have32bpp && haveAlpha) ? GR_BLEND_DST_ALPHA : GR_BLEND_ONE/*bad*/; break; + case GL_ONE_MINUS_DST_COLOR: case GL_ONE_MINUS_DST_ALPHA: - asfact = have32bpp ? GR_BLEND_ONE_MINUS_DST_ALPHA : GR_BLEND_ONE/*bad*/; + asfact = (have32bpp && haveAlpha) ? GR_BLEND_ONE_MINUS_DST_ALPHA : GR_BLEND_ZERO/*bad*/; break; case GL_SRC_ALPHA_SATURATE: - asfact = GR_BLEND_ONE/*bad*/; - break; - case GL_SRC_COLOR: - case GL_ONE_MINUS_SRC_COLOR: - /* USELESS */ - asfact = GR_BLEND_ONE/*bad*/; + asfact = GR_BLEND_ONE; break; default: - asfact = GR_BLEND_ONE/*bad*/; + asfact = GR_BLEND_ONE; break; } @@ -1451,21 +1433,21 @@ which are drawn front-to-back. dfact = GR_BLEND_ONE_MINUS_SRC_ALPHA; break; case GL_DST_ALPHA: - /* dfact=GR_BLEND_DST_ALPHA; */ - /* We can't do DST_ALPHA */ - dfact = GR_BLEND_ONE; + dfact = haveAlpha ? GR_BLEND_DST_ALPHA : GR_BLEND_ONE/*bad*/; break; case GL_ONE_MINUS_DST_ALPHA: - /* dfact=GR_BLEND_ONE_MINUS_DST_ALPHA; */ - /* We can't do DST_ALPHA */ - dfact = GR_BLEND_ZERO; + dfact = haveAlpha ? GR_BLEND_ONE_MINUS_DST_ALPHA : GR_BLEND_ZERO/*bad*/; break; - case GL_SRC_ALPHA_SATURATE: case GL_DST_COLOR: + if (isNapalm) { + dfact = GR_BLEND_SAME_COLOR_EXT; + break; + } case GL_ONE_MINUS_DST_COLOR: - /* USELESS */ - dfact = GR_BLEND_ZERO; - break; + if (isNapalm) { + dfact = GR_BLEND_ONE_MINUS_SAME_COLOR_EXT; + break; + } default: dfact = GR_BLEND_ZERO; break; @@ -1479,31 +1461,23 @@ which are drawn front-to-back. adfact = GR_BLEND_ONE; break; case GL_SRC_COLOR: - adfact = GR_BLEND_ZERO/*bad*/; - break; - case GL_ONE_MINUS_SRC_COLOR: - adfact = GR_BLEND_ZERO/*bad*/; - break; case GL_SRC_ALPHA: adfact = have32bpp ? GR_BLEND_SRC_ALPHA : GR_BLEND_ZERO/*bad*/; break; + case GL_ONE_MINUS_SRC_COLOR: case GL_ONE_MINUS_SRC_ALPHA: adfact = have32bpp ? GR_BLEND_ONE_MINUS_SRC_ALPHA : GR_BLEND_ZERO/*bad*/; break; + case GL_DST_COLOR: case GL_DST_ALPHA: - adfact = have32bpp ? GR_BLEND_DST_ALPHA : GR_BLEND_ZERO/*bad*/; - break; - case GL_ONE_MINUS_DST_ALPHA: - adfact = have32bpp ? GR_BLEND_ONE_MINUS_DST_ALPHA : GR_BLEND_ZERO/*bad*/; + adfact = (have32bpp && haveAlpha) ? GR_BLEND_DST_ALPHA : GR_BLEND_ONE/*bad*/; break; - case GL_SRC_ALPHA_SATURATE: - case GL_DST_COLOR: case GL_ONE_MINUS_DST_COLOR: - /* USELESS */ - adfact = GR_BLEND_ZERO/*bad*/; + case GL_ONE_MINUS_DST_ALPHA: + adfact = (have32bpp && haveAlpha) ? GR_BLEND_ONE_MINUS_DST_ALPHA : GR_BLEND_ZERO/*bad*/; break; default: - adfact = GR_BLEND_ZERO/*bad*/; + adfact = GR_BLEND_ZERO; break; } |