diff options
author | Ian Romanick <idr@us.ibm.com> | 2004-06-04 00:46:23 +0000 |
---|---|---|
committer | Ian Romanick <idr@us.ibm.com> | 2004-06-04 00:46:23 +0000 |
commit | 98e7d810e1dc67405075efef83a46504c35b8a19 (patch) | |
tree | cfe36c168cc33a1f9a0ad8659cc4320715bfec8c /src/mesa/drivers/dri/r128 | |
parent | d672f38709352da01b5a4a04a1777f3a40d09180 (diff) |
Enable GL_EXT_blend_subtract and GL_NV_blend_square.
GL_EXT_blend_subtract was already enabled via GL_ARB_imaging, but now
one of the added modes is supported in hardware. GL_NV_blend_square
was tested with progs/tests/blendsquare on an Rage128 Pro with PCI ID
1002:5046. I know there are some differences with some versions of
the chip.
Diffstat (limited to 'src/mesa/drivers/dri/r128')
-rw-r--r-- | src/mesa/drivers/dri/r128/r128_context.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r128/r128_state.c | 153 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r128/server/r128_reg.h | 95 |
3 files changed, 121 insertions, 129 deletions
diff --git a/src/mesa/drivers/dri/r128/r128_context.c b/src/mesa/drivers/dri/r128/r128_context.c index 012840effe..8075270a8c 100644 --- a/src/mesa/drivers/dri/r128/r128_context.c +++ b/src/mesa/drivers/dri/r128/r128_context.c @@ -74,8 +74,10 @@ static const char * const card_extensions[] = "GL_ARB_texture_compression", "GL_ARB_texture_env_add", "GL_ARB_texture_mirrored_repeat", + "GL_EXT_blend_subtract", "GL_EXT_texture_edge_clamp", "GL_MESA_ycbcr_texture", + "GL_NV_blend_square", "GL_SGIS_generate_mipmap", NULL }; diff --git a/src/mesa/drivers/dri/r128/r128_state.c b/src/mesa/drivers/dri/r128/r128_state.c index e27e542a7d..f7b30dead2 100644 --- a/src/mesa/drivers/dri/r128/r128_state.c +++ b/src/mesa/drivers/dri/r128/r128_state.c @@ -56,6 +56,76 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. * Alpha blending */ + +/** + * Calculate the hardware blend factor setting. This same function is used + * for source and destination of both alpha and RGB. + * + * \returns + * The hardware register value for the specified blend factor. This value + * will need to be shifted into the correct position for either source or + * destination factor. + * + * \todo + * Since the two cases where source and destination are handled differently + * are essentially error cases, they should never happen. Determine if these + * cases can be removed. + */ +static int blend_factor( r128ContextPtr rmesa, GLenum factor, GLboolean is_src ) +{ + int func; + + switch ( factor ) { + case GL_ZERO: + func = R128_ALPHA_BLEND_ZERO; + break; + case GL_ONE: + func = R128_ALPHA_BLEND_ONE; + break; + + case GL_SRC_COLOR: + func = R128_ALPHA_BLEND_SRCCOLOR; + break; + case GL_ONE_MINUS_SRC_COLOR: + func = R128_ALPHA_BLEND_INVSRCCOLOR; + break; + case GL_SRC_ALPHA: + func = R128_ALPHA_BLEND_SRCALPHA; + break; + case GL_ONE_MINUS_SRC_ALPHA: + func = R128_ALPHA_BLEND_INVSRCALPHA; + break; + case GL_SRC_ALPHA_SATURATE: + func = (is_src) ? R128_ALPHA_BLEND_SAT : R128_ALPHA_BLEND_ZERO; + break; + + case GL_DST_COLOR: + func = R128_ALPHA_BLEND_DSTCOLOR; + break; + case GL_ONE_MINUS_DST_COLOR: + func = R128_ALPHA_BLEND_INVDSTCOLOR; + break; + case GL_DST_ALPHA: + func = R128_ALPHA_BLEND_DSTALPHA; + break; + case GL_ONE_MINUS_DST_ALPHA: + func = R128_ALPHA_BLEND_INVDSTALPHA; + break; + + case GL_CONSTANT_COLOR: + case GL_ONE_MINUS_CONSTANT_COLOR: + case GL_CONSTANT_ALPHA: + case GL_ONE_MINUS_CONSTANT_ALPHA: + default: + FALLBACK( rmesa, R128_FALLBACK_BLEND_FUNC, GL_TRUE ); + func = (is_src) ? R128_ALPHA_BLEND_ONE : R128_ALPHA_BLEND_ZERO; + break; + } + + return func; +} + + static void r128UpdateAlphaMode( GLcontext *ctx ) { r128ContextPtr rmesa = R128_CONTEXT(ctx); @@ -105,67 +175,24 @@ static void r128UpdateAlphaMode( GLcontext *ctx ) FALLBACK( rmesa, R128_FALLBACK_BLEND_FUNC, GL_FALSE ); if ( ctx->Color.BlendEnabled ) { - a &= ~(R128_ALPHA_BLEND_SRC_MASK | R128_ALPHA_BLEND_DST_MASK); - - switch ( ctx->Color.BlendSrcRGB ) { - case GL_ZERO: - a |= R128_ALPHA_BLEND_SRC_ZERO; - break; - case GL_ONE: - a |= R128_ALPHA_BLEND_SRC_ONE; - break; - case GL_DST_COLOR: - a |= R128_ALPHA_BLEND_SRC_DESTCOLOR; - break; - case GL_ONE_MINUS_DST_COLOR: - a |= R128_ALPHA_BLEND_SRC_INVDESTCOLOR; - break; - case GL_SRC_ALPHA: - a |= R128_ALPHA_BLEND_SRC_SRCALPHA; - break; - case GL_ONE_MINUS_SRC_ALPHA: - a |= R128_ALPHA_BLEND_SRC_INVSRCALPHA; - break; - case GL_DST_ALPHA: - a |= R128_ALPHA_BLEND_SRC_DESTALPHA; - break; - case GL_ONE_MINUS_DST_ALPHA: - a |= R128_ALPHA_BLEND_SRC_INVDESTALPHA; - break; - case GL_SRC_ALPHA_SATURATE: - a |= R128_ALPHA_BLEND_SRC_SRCALPHASAT; - break; - default: - FALLBACK( rmesa, R128_FALLBACK_BLEND_FUNC, GL_TRUE ); - } - - switch ( ctx->Color.BlendDstRGB ) { - case GL_ZERO: - a |= R128_ALPHA_BLEND_DST_ZERO; - break; - case GL_ONE: - a |= R128_ALPHA_BLEND_DST_ONE; - break; - case GL_SRC_COLOR: - a |= R128_ALPHA_BLEND_DST_SRCCOLOR; - break; - case GL_ONE_MINUS_SRC_COLOR: - a |= R128_ALPHA_BLEND_DST_INVSRCCOLOR; - break; - case GL_SRC_ALPHA: - a |= R128_ALPHA_BLEND_DST_SRCALPHA; - break; - case GL_ONE_MINUS_SRC_ALPHA: - a |= R128_ALPHA_BLEND_DST_INVSRCALPHA; - break; - case GL_DST_ALPHA: - a |= R128_ALPHA_BLEND_DST_DESTALPHA; + a &= ~((R128_ALPHA_BLEND_MASK << R128_ALPHA_BLEND_SRC_SHIFT) | + (R128_ALPHA_BLEND_MASK << R128_ALPHA_BLEND_DST_SHIFT) + | R128_ALPHA_COMB_FCN_MASK); + + a |= blend_factor( rmesa, ctx->Color.BlendSrcRGB, GL_TRUE ) + << R128_ALPHA_BLEND_SRC_SHIFT; + a |= blend_factor( rmesa, ctx->Color.BlendDstRGB, GL_FALSE ) + << R128_ALPHA_BLEND_DST_SHIFT; + + switch (ctx->Color.BlendEquationRGB) { + case GL_FUNC_ADD: + a |= R128_ALPHA_COMB_ADD_CLAMP; break; - case GL_ONE_MINUS_DST_ALPHA: - a |= R128_ALPHA_BLEND_DST_INVDESTALPHA; + case GL_FUNC_SUBTRACT: + a |= R128_ALPHA_COMB_SUB_SRC_DST_CLAMP; break; default: - FALLBACK( rmesa, R128_FALLBACK_BLEND_FUNC, GL_TRUE ); + FALLBACK( rmesa, R128_FALLBACK_BLEND_EQ, GL_TRUE ); } t |= R128_ALPHA_ENABLE; @@ -208,7 +235,7 @@ static void r128DDBlendEquationSeparate( GLcontext *ctx, /* Can only do blend addition, not min, max, subtract, etc. */ FALLBACK( R128_CONTEXT(ctx), R128_FALLBACK_BLEND_EQ, - modeRGB != GL_FUNC_ADD); + (modeRGB != GL_FUNC_ADD) && (modeRGB != GL_FUNC_SUBTRACT)); rmesa->new_state |= R128_NEW_ALPHA; } @@ -1119,8 +1146,8 @@ void r128DDInitState( r128ContextPtr rmesa ) R128_MISC_SCALE_PIX_REPLICATE | R128_ALPHA_COMB_ADD_CLAMP | R128_FOG_VERTEX | - R128_ALPHA_BLEND_SRC_ONE | - R128_ALPHA_BLEND_DST_ZERO | + (R128_ALPHA_BLEND_ONE << R128_ALPHA_BLEND_SRC_SHIFT) | + (R128_ALPHA_BLEND_ZERO << R128_ALPHA_BLEND_DST_SHIFT) | R128_ALPHA_TEST_ALWAYS); rmesa->setup.texture_clr_cmp_clr_c = 0x00000000; @@ -1165,8 +1192,8 @@ void r128DDInitState( r128ContextPtr rmesa ) R128_SCALE_PIX_REPLICATE | R128_ALPHA_COMB_ADD_CLAMP | R128_FOG_VERTEX | - R128_ALPHA_BLEND_SRC_ONE | - R128_ALPHA_BLEND_DST_ZERO | + (R128_ALPHA_BLEND_ONE << R128_ALPHA_BLEND_SRC_SHIFT) | + (R128_ALPHA_BLEND_ZERO << R128_ALPHA_BLEND_DST_SHIFT) | R128_ALPHA_TEST_ALWAYS | R128_COMPOSITE_SHADOW_CMP_EQUAL | R128_TEX_MAP_ALPHA_IN_TEXTURE | diff --git a/src/mesa/drivers/dri/r128/server/r128_reg.h b/src/mesa/drivers/dri/r128/server/r128_reg.h index 7ec4004492..00f5041c11 100644 --- a/src/mesa/drivers/dri/r128/server/r128_reg.h +++ b/src/mesa/drivers/dri/r128/server/r128_reg.h @@ -970,33 +970,31 @@ # define R128_TEX_CACHE_PALLETE_MODE (1 << 11) # define R128_ALPHA_COMB_ADD_CLAMP (0 << 12) # define R128_ALPHA_COMB_ADD_NCLAMP (1 << 12) -# define R128_ALPHA_COMB_SUB_DST_SRC_CLAMP (2 << 12) -# define R128_ALPHA_COMB_SUB_DST_SRC_NCLAMP (3 << 12) +# define R128_ALPHA_COMB_SUB_SRC_DST_CLAMP (2 << 12) +# define R128_ALPHA_COMB_SUB_SRC_DST_NCLAMP (3 << 12) +# define R128_ALPHA_COMB_FCN_MASK (3 << 12) +# define R128_FOG_VERTEX (0 << 14) # define R128_FOG_TABLE (1 << 14) # define R128_SIGNED_DST_CLAMP (1 << 15) -# define R128_ALPHA_BLEND_SRC_ZERO (0 << 16) -# define R128_ALPHA_BLEND_SRC_ONE (1 << 16) -# define R128_ALPHA_BLEND_SRC_SRCCOLOR (2 << 16) -# define R128_ALPHA_BLEND_SRC_INVSRCCOLOR (3 << 16) -# define R128_ALPHA_BLEND_SRC_SRCALPHA (4 << 16) -# define R128_ALPHA_BLEND_SRC_INVSRCALPHA (5 << 16) -# define R128_ALPHA_BLEND_SRC_DSTALPHA (6 << 16) -# define R128_ALPHA_BLEND_SRC_INVDSTALPHA (7 << 16) -# define R128_ALPHA_BLEND_SRC_DSTCOLOR (8 << 16) -# define R128_ALPHA_BLEND_SRC_INVDSTCOLOR (9 << 16) -# define R128_ALPHA_BLEND_SRC_SAT (10 << 16) -# define R128_ALPHA_BLEND_SRC_BLEND (11 << 16) -# define R128_ALPHA_BLEND_SRC_INVBLEND (12 << 16) -# define R128_ALPHA_BLEND_DST_ZERO (0 << 20) -# define R128_ALPHA_BLEND_DST_ONE (1 << 20) -# define R128_ALPHA_BLEND_DST_SRCCOLOR (2 << 20) -# define R128_ALPHA_BLEND_DST_INVSRCCOLOR (3 << 20) -# define R128_ALPHA_BLEND_DST_SRCALPHA (4 << 20) -# define R128_ALPHA_BLEND_DST_INVSRCALPHA (5 << 20) -# define R128_ALPHA_BLEND_DST_DSTALPHA (6 << 20) -# define R128_ALPHA_BLEND_DST_INVDSTALPHA (7 << 20) -# define R128_ALPHA_BLEND_DST_DSTCOLOR (8 << 20) -# define R128_ALPHA_BLEND_DST_INVDSTCOLOR (9 << 20) + +# define R128_ALPHA_BLEND_ZERO (0 ) +# define R128_ALPHA_BLEND_ONE (1 ) +# define R128_ALPHA_BLEND_SRCCOLOR (2 ) +# define R128_ALPHA_BLEND_INVSRCCOLOR (3 ) +# define R128_ALPHA_BLEND_SRCALPHA (4 ) +# define R128_ALPHA_BLEND_INVSRCALPHA (5 ) +# define R128_ALPHA_BLEND_DSTALPHA (6 ) +# define R128_ALPHA_BLEND_INVDSTALPHA (7 ) +# define R128_ALPHA_BLEND_DSTCOLOR (8 ) +# define R128_ALPHA_BLEND_INVDSTCOLOR (9 ) +# define R128_ALPHA_BLEND_SAT (10) /* aka SRCALPHASAT */ +# define R128_ALPHA_BLEND_BLEND (11) /* aka BOTHSRCALPHA */ +# define R128_ALPHA_BLEND_INVBLEND (12) /* aka BOTHINVSRCALPHA */ +# define R128_ALPHA_BLEND_MASK (15) + +# define R128_ALPHA_BLEND_SRC_SHIFT (16) +# define R128_ALPHA_BLEND_DST_SHIFT (20) + # define R128_ALPHA_TEST_NEVER (0 << 24) # define R128_ALPHA_TEST_LESS (1 << 24) # define R128_ALPHA_TEST_LESSEQUAL (2 << 24) @@ -1005,6 +1003,7 @@ # define R128_ALPHA_TEST_GREATER (5 << 24) # define R128_ALPHA_TEST_NEQUAL (6 << 24) # define R128_ALPHA_TEST_ALWAYS (7 << 24) +# define R128_ALPHA_TEST_MASK (7 << 24) # define R128_COMPOSITE_SHADOW_CMP_EQUAL (0 << 28) # define R128_COMPOSITE_SHADOW_CMP_NEQUAL (1 << 28) # define R128_COMPOSITE_SHADOW (1 << 29) @@ -1125,47 +1124,11 @@ # define R128_MISC_SCALE_3D_TEXMAP_SHADE (2 << 8) # define R128_MISC_SCALE_PIX_BLEND (0 << 10) # define R128_MISC_SCALE_PIX_REPLICATE (1 << 10) -# define R128_ALPHA_COMB_ADD_CLAMP (0 << 12) -# define R128_ALPHA_COMB_ADD_NO_CLAMP (1 << 12) -# define R128_ALPHA_COMB_SUB_SRC_DST_CLAMP (2 << 12) -# define R128_ALPHA_COMB_SUB_SRC_DST_NO_CLAMP (3 << 12) -# define R128_FOG_VERTEX (0 << 14) -# define R128_FOG_TABLE (1 << 14) -# define R128_ALPHA_BLEND_SRC_ZERO (0 << 16) -# define R128_ALPHA_BLEND_SRC_ONE (1 << 16) -# define R128_ALPHA_BLEND_SRC_SRCCOLOR (2 << 16) -# define R128_ALPHA_BLEND_SRC_INVSRCCOLOR (3 << 16) -# define R128_ALPHA_BLEND_SRC_SRCALPHA (4 << 16) -# define R128_ALPHA_BLEND_SRC_INVSRCALPHA (5 << 16) -# define R128_ALPHA_BLEND_SRC_DESTALPHA (6 << 16) -# define R128_ALPHA_BLEND_SRC_INVDESTALPHA (7 << 16) -# define R128_ALPHA_BLEND_SRC_DESTCOLOR (8 << 16) -# define R128_ALPHA_BLEND_SRC_INVDESTCOLOR (9 << 16) -# define R128_ALPHA_BLEND_SRC_SRCALPHASAT (10 << 16) -# define R128_ALPHA_BLEND_SRC_BOTHSRCALPHA (11 << 16) -# define R128_ALPHA_BLEND_SRC_BOTHINVSRCALPHA (12 << 16) -# define R128_ALPHA_BLEND_SRC_MASK (15 << 16) -# define R128_ALPHA_BLEND_DST_ZERO (0 << 20) -# define R128_ALPHA_BLEND_DST_ONE (1 << 20) -# define R128_ALPHA_BLEND_DST_SRCCOLOR (2 << 20) -# define R128_ALPHA_BLEND_DST_INVSRCCOLOR (3 << 20) -# define R128_ALPHA_BLEND_DST_SRCALPHA (4 << 20) -# define R128_ALPHA_BLEND_DST_INVSRCALPHA (5 << 20) -# define R128_ALPHA_BLEND_DST_DESTALPHA (6 << 20) -# define R128_ALPHA_BLEND_DST_INVDESTALPHA (7 << 20) -# define R128_ALPHA_BLEND_DST_DESTCOLOR (8 << 20) -# define R128_ALPHA_BLEND_DST_INVDESTCOLOR (9 << 20) -# define R128_ALPHA_BLEND_DST_SRCALPHASAT (10 << 20) -# define R128_ALPHA_BLEND_DST_MASK (15 << 20) -# define R128_ALPHA_TEST_NEVER (0 << 24) -# define R128_ALPHA_TEST_LESS (1 << 24) -# define R128_ALPHA_TEST_LESSEQUAL (2 << 24) -# define R128_ALPHA_TEST_EQUAL (3 << 24) -# define R128_ALPHA_TEST_GREATEREQUAL (4 << 24) -# define R128_ALPHA_TEST_GREATER (5 << 24) -# define R128_ALPHA_TEST_NEQUAL (6 << 24) -# define R128_ALPHA_TEST_ALWAYS (7 << 24) -# define R128_ALPHA_TEST_MASK (7 << 24) +/* Bits [14:12] are the same as R128_SCALE_3D_CNTL */ +/* Bit [15] is unknown */ +/* Bits [26:16] are the same as R128_SCALE_3D_CNTL */ +/* Bits [31:27] are unknown */ + #define R128_TEXTURE_CLR_CMP_CLR_C 0x1ca4 #define R128_TEXTURE_CLR_CMP_MSK_C 0x1ca8 #define R128_FOG_COLOR_C 0x1cac |