From e0029b33effd299bb6b659ffd4309f8fa5c7afcf Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 18 Aug 2005 22:27:37 +0000 Subject: [PATCH] Add support for NV_blend_square. This was tested with progs/tests/blendsquare. --- src/mesa/drivers/dri/i810/i810context.c | 1 + src/mesa/drivers/dri/i810/i810state.c | 24 ++++++++++++++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/mesa/drivers/dri/i810/i810context.c b/src/mesa/drivers/dri/i810/i810context.c index ef693da1558..8389321924e 100644 --- a/src/mesa/drivers/dri/i810/i810context.c +++ b/src/mesa/drivers/dri/i810/i810context.c @@ -128,6 +128,7 @@ const struct dri_extension card_extensions[] = { "GL_EXT_texture_edge_clamp", NULL }, { "GL_EXT_texture_lod_bias", NULL }, { "GL_MESA_ycbcr_texture", NULL }, + { "GL_NV_blend_square", NULL }, { "GL_SGIS_generate_mipmap", NULL }, { NULL, NULL } }; diff --git a/src/mesa/drivers/dri/i810/i810state.c b/src/mesa/drivers/dri/i810/i810state.c index ec9f07ada35..62dc819b32b 100644 --- a/src/mesa/drivers/dri/i810/i810state.c +++ b/src/mesa/drivers/dri/i810/i810state.c @@ -103,14 +103,23 @@ static void i810BlendFuncSeparate( GLcontext *ctx, GLenum sfactorRGB, switch (ctx->Color.BlendSrcRGB) { case GL_ZERO: a |= SDM_SRC_ZERO; break; - case GL_SRC_ALPHA: a |= SDM_SRC_SRC_ALPHA; break; case GL_ONE: a |= SDM_SRC_ONE; break; - case GL_DST_COLOR: a |= SDM_SRC_DST_COLOR; break; - case GL_ONE_MINUS_DST_COLOR: a |= SDM_SRC_INV_DST_COLOR; break; + case GL_SRC_COLOR: a |= SDM_SRC_SRC_COLOR; break; + case GL_ONE_MINUS_SRC_COLOR: a |= SDM_SRC_INV_SRC_COLOR; break; + case GL_SRC_ALPHA: a |= SDM_SRC_SRC_ALPHA; break; case GL_ONE_MINUS_SRC_ALPHA: a |= SDM_SRC_INV_SRC_ALPHA; break; case GL_DST_ALPHA: a |= SDM_SRC_ONE; break; case GL_ONE_MINUS_DST_ALPHA: a |= SDM_SRC_ZERO; break; - case GL_SRC_ALPHA_SATURATE: /*a |= SDM_SRC_SRC_ALPHA; break;*/ + case GL_DST_COLOR: a |= SDM_SRC_DST_COLOR; break; + case GL_ONE_MINUS_DST_COLOR: a |= SDM_SRC_INV_DST_COLOR; break; + + /* (f, f, f, 1), f = min(As, 1 - Ad) = min(As, 1 - 1) = 0 + * So (f, f, f, 1) = (0, 0, 0, 1). Since there is no destination alpha and + * the only supported alpha operation is GL_FUNC_ADD, the result modulating + * the source alpha with the alpha factor is largely irrelevant. + */ + case GL_SRC_ALPHA_SATURATE: a |= SDM_SRC_ZERO; break; + case GL_CONSTANT_COLOR: case GL_ONE_MINUS_CONSTANT_COLOR: case GL_CONSTANT_ALPHA: @@ -122,14 +131,17 @@ static void i810BlendFuncSeparate( GLcontext *ctx, GLenum sfactorRGB, } switch (ctx->Color.BlendDstRGB) { - case GL_SRC_ALPHA: a |= SDM_DST_SRC_ALPHA; break; - case GL_ONE_MINUS_SRC_ALPHA: a |= SDM_DST_INV_SRC_ALPHA; break; case GL_ZERO: a |= SDM_DST_ZERO; break; case GL_ONE: a |= SDM_DST_ONE; break; case GL_SRC_COLOR: a |= SDM_DST_SRC_COLOR; break; case GL_ONE_MINUS_SRC_COLOR: a |= SDM_DST_INV_SRC_COLOR; break; + case GL_SRC_ALPHA: a |= SDM_DST_SRC_ALPHA; break; + case GL_ONE_MINUS_SRC_ALPHA: a |= SDM_DST_INV_SRC_ALPHA; break; case GL_DST_ALPHA: a |= SDM_DST_ONE; break; case GL_ONE_MINUS_DST_ALPHA: a |= SDM_DST_ZERO; break; + case GL_DST_COLOR: a |= SDM_DST_DST_COLOR; break; + case GL_ONE_MINUS_DST_COLOR: a |= SDM_DST_INV_DST_COLOR; break; + case GL_CONSTANT_COLOR: case GL_ONE_MINUS_CONSTANT_COLOR: case GL_CONSTANT_ALPHA: -- 2.30.2