From: Roland Scheidegger Date: Tue, 1 Jun 2004 23:04:10 +0000 (+0000) Subject: add support for GL_ARB_texture_env_crossbar X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7a6eda7137b4b4a384022b7e0e7db7f9ef98fbbc;p=mesa.git add support for GL_ARB_texture_env_crossbar --- diff --git a/src/mesa/drivers/dri/radeon/radeon_context.c b/src/mesa/drivers/dri/radeon/radeon_context.c index 2889a7d1042..7fbcbaf1966 100644 --- a/src/mesa/drivers/dri/radeon/radeon_context.c +++ b/src/mesa/drivers/dri/radeon/radeon_context.c @@ -126,6 +126,7 @@ static const char * const card_extensions[] = "GL_ARB_texture_compression", "GL_ARB_texture_env_add", "GL_ARB_texture_env_combine", + "GL_ARB_texture_env_crossbar", "GL_ARB_texture_env_dot3", "GL_ARB_texture_mirrored_repeat", "GL_EXT_blend_logic_op", diff --git a/src/mesa/drivers/dri/radeon/radeon_texstate.c b/src/mesa/drivers/dri/radeon/radeon_texstate.c index a3be9280c80..128d3153cce 100644 --- a/src/mesa/drivers/dri/radeon/radeon_texstate.c +++ b/src/mesa/drivers/dri/radeon/radeon_texstate.c @@ -383,6 +383,13 @@ static GLboolean radeonUpdateTextureEnv( GLcontext *ctx, int unit ) radeonContextPtr rmesa = RADEON_CONTEXT(ctx); const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; GLuint color_combine, alpha_combine; + const GLuint color_combine0 = RADEON_COLOR_ARG_A_ZERO | RADEON_COLOR_ARG_B_ZERO + | RADEON_COLOR_ARG_C_CURRENT_COLOR | RADEON_BLEND_CTL_ADD + | RADEON_SCALE_1X | RADEON_CLAMP_TX; + const GLuint alpha_combine0 = RADEON_ALPHA_ARG_A_ZERO | RADEON_ALPHA_ARG_B_ZERO + | RADEON_ALPHA_ARG_C_CURRENT_ALPHA | RADEON_BLEND_CTL_ADD + | RADEON_SCALE_1X | RADEON_CLAMP_TX; + /* texUnit->_Current can be NULL if and only if the texture unit is * not actually enabled. @@ -400,17 +407,14 @@ static GLboolean radeonUpdateTextureEnv( GLcontext *ctx, int unit ) * reduces the amount of special-casing we have to do, alpha-only * textures being a notable exception. */ + /* Don't cache these results. + */ + rmesa->state.texture.unit[unit].format = 0; + rmesa->state.texture.unit[unit].envMode = 0; + if ( !texUnit->_ReallyEnabled ) { - /* Don't cache these results. - */ - rmesa->state.texture.unit[unit].format = 0; - rmesa->state.texture.unit[unit].envMode = 0; - color_combine = RADEON_COLOR_ARG_A_ZERO | RADEON_COLOR_ARG_B_ZERO - | RADEON_COLOR_ARG_C_CURRENT_COLOR | RADEON_BLEND_CTL_ADD - | RADEON_SCALE_1X | RADEON_CLAMP_TX; - alpha_combine = RADEON_ALPHA_ARG_A_ZERO | RADEON_ALPHA_ARG_B_ZERO - | RADEON_ALPHA_ARG_C_CURRENT_ALPHA | RADEON_BLEND_CTL_ADD - | RADEON_SCALE_1X | RADEON_CLAMP_TX; + color_combine = color_combine0; + alpha_combine = alpha_combine0; } else { GLuint color_arg[3], alpha_arg[3]; @@ -420,20 +424,16 @@ static GLboolean radeonUpdateTextureEnv( GLcontext *ctx, int unit ) GLuint RGBshift = texUnit->_CurrentCombine->ScaleShiftRGB; GLuint Ashift = texUnit->_CurrentCombine->ScaleShiftA; - /* Don't cache these results. - */ - rmesa->state.texture.unit[unit].format = 0; - rmesa->state.texture.unit[unit].envMode = 0; - /* Step 1: * Extract the color and alpha combine function arguments. */ for ( i = 0 ; i < numColorArgs ; i++ ) { const GLuint op = texUnit->_CurrentCombine->OperandRGB[i] - GL_SRC_COLOR; + const GLuint srcRGBi = texUnit->_CurrentCombine->SourceRGB[i]; assert(op >= 0); assert(op <= 3); - switch ( texUnit->_CurrentCombine->SourceRGB[i] ) { + switch ( srcRGBi ) { case GL_TEXTURE: color_arg[i] = radeon_texture_color[op][unit]; break; @@ -452,6 +452,17 @@ static GLboolean radeonUpdateTextureEnv( GLcontext *ctx, int unit ) case GL_ONE: color_arg[i] = radeon_zero_color[op+1]; break; + case GL_TEXTURE0: + case GL_TEXTURE1: + case GL_TEXTURE2: + if (ctx->Texture.Unit[srcRGBi - GL_TEXTURE0]._ReallyEnabled) + color_arg[i] = radeon_texture_color[op][srcRGBi - GL_TEXTURE0]; + else { + color_combine = color_combine0; + alpha_combine = alpha_combine0; + goto write_txblend; + } + break; default: return GL_FALSE; } @@ -459,9 +470,10 @@ static GLboolean radeonUpdateTextureEnv( GLcontext *ctx, int unit ) for ( i = 0 ; i < numAlphaArgs ; i++ ) { const GLuint op = texUnit->_CurrentCombine->OperandA[i] - GL_SRC_ALPHA; + const GLuint srcAi = texUnit->_CurrentCombine->SourceA[i]; assert(op >= 0); assert(op <= 1); - switch ( texUnit->_CurrentCombine->SourceA[i] ) { + switch ( srcAi ) { case GL_TEXTURE: alpha_arg[i] = radeon_texture_alpha[op][unit]; break; @@ -480,6 +492,17 @@ static GLboolean radeonUpdateTextureEnv( GLcontext *ctx, int unit ) case GL_ONE: alpha_arg[i] = radeon_zero_alpha[op+1]; break; + case GL_TEXTURE0: + case GL_TEXTURE1: + case GL_TEXTURE2: + if (ctx->Texture.Unit[srcAi - GL_TEXTURE0]._ReallyEnabled) + alpha_arg[i] = radeon_texture_alpha[op][srcAi - GL_TEXTURE0]; + else { + color_combine = color_combine0; + alpha_combine = alpha_combine0; + goto write_txblend; + } + break; default: return GL_FALSE; } @@ -676,6 +699,7 @@ static GLboolean radeonUpdateTextureEnv( GLcontext *ctx, int unit ) */ } +write_txblend: if ( rmesa->hw.tex[unit].cmd[TEX_PP_TXCBLEND] != color_combine || rmesa->hw.tex[unit].cmd[TEX_PP_TXABLEND] != alpha_combine ) { RADEON_STATECHANGE( rmesa, tex[unit] );