diff options
author | Keith Whitwell <[email protected]> | 2005-01-19 12:09:33 +0000 |
---|---|---|
committer | Keith Whitwell <[email protected]> | 2005-01-19 12:09:33 +0000 |
commit | 2aa34ea98430047e28b4ac47d09421d53c4b77a2 (patch) | |
tree | a64dc912375a697028646320132c1f5a4f3073df /src/mesa/drivers/dri/unichrome | |
parent | bdb5725bab0fdfffb20bbfb4f2c3d7aa3482c1bc (diff) |
Bring the texcombine fixes to the trunk.
Diffstat (limited to 'src/mesa/drivers/dri/unichrome')
-rw-r--r-- | src/mesa/drivers/dri/unichrome/via_3d_reg.h | 8 | ||||
-rw-r--r-- | src/mesa/drivers/dri/unichrome/via_context.c | 6 | ||||
-rw-r--r-- | src/mesa/drivers/dri/unichrome/via_context.h | 5 | ||||
-rw-r--r-- | src/mesa/drivers/dri/unichrome/via_state.c | 25 | ||||
-rw-r--r-- | src/mesa/drivers/dri/unichrome/via_tex.h | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/unichrome/via_texcombine.c | 218 | ||||
-rw-r--r-- | src/mesa/drivers/dri/unichrome/via_tris.c | 17 |
7 files changed, 185 insertions, 96 deletions
diff --git a/src/mesa/drivers/dri/unichrome/via_3d_reg.h b/src/mesa/drivers/dri/unichrome/via_3d_reg.h index 7e4536d70bf..77b24dc6156 100644 --- a/src/mesa/drivers/dri/unichrome/via_3d_reg.h +++ b/src/mesa/drivers/dri/unichrome/via_3d_reg.h @@ -1038,8 +1038,8 @@ #define HC_HTXnTBA_MASK 0x000000ff #define HC_HTXnTRAH_SHIFT 16 #define HC_HTXnTRAL_SHIFT 8 -/* HC_SubA_HTXnTBLCsat 0x0080 - *-- Define the input texture. + +/*-- Define the input texture, for below */ #define HC_XTC_TOPC 0x00000000 #define HC_XTC_InvTOPC 0x00000010 @@ -1057,7 +1057,7 @@ #define HC_XTC_Acur 0x00000008 #define HC_XTC_HTXnTBLRC 0x00000009 #define HC_XTC_Ctexnext 0x0000000a -/*-- +/** HC_SubA_HTXnTBLCsat 0x0080 */ #define HC_HTXnTBLCsat_MASK 0x00800000 #define HC_HTXnTBLCa_MASK 0x000fc000 @@ -1137,8 +1137,6 @@ #define HC_HTXnTBLCshift_2 0x00000800 #define HC_HTXnTBLCshift_No 0x00001000 #define HC_HTXnTBLCshift_DotP 0x00001800 -/*=* John Sheng [2003.7.18] texture combine *=*/ - #define HC_HTXnTBLAop_Add 0x00000000 #define HC_HTXnTBLAop_Sub 0x00000080 #define HC_HTXnTBLAop_Min 0x00000100 diff --git a/src/mesa/drivers/dri/unichrome/via_context.c b/src/mesa/drivers/dri/unichrome/via_context.c index b82ffb669a9..297bf697752 100644 --- a/src/mesa/drivers/dri/unichrome/via_context.c +++ b/src/mesa/drivers/dri/unichrome/via_context.c @@ -250,11 +250,11 @@ static const char * const card_extensions[] = "GL_ARB_point_parameters", "GL_ARB_texture_env_add", "GL_ARB_texture_env_combine", - "GL_ARB_texture_env_dot3", +/* "GL_ARB_texture_env_dot3", */ "GL_ARB_texture_mirrored_repeat", "GL_EXT_stencil_wrap", "GL_EXT_texture_env_combine", - "GL_EXT_texture_env_dot3", +/* "GL_EXT_texture_env_dot3", */ "GL_EXT_texture_lod_bias", "GL_EXT_secondary_color", "GL_EXT_fog_coord", @@ -273,7 +273,9 @@ static const struct tnl_pipeline_stage *via_pipeline[] = { &_tnl_texgen_stage, &_tnl_texture_transform_stage, /* REMOVE: point attenuation stage */ +#if 0 &_via_fastrender_stage, /* ADD: unclipped rastersetup-to-dma */ +#endif &_tnl_render_stage, 0, }; diff --git a/src/mesa/drivers/dri/unichrome/via_context.h b/src/mesa/drivers/dri/unichrome/via_context.h index 09494cd3adf..28da220029d 100644 --- a/src/mesa/drivers/dri/unichrome/via_context.h +++ b/src/mesa/drivers/dri/unichrome/via_context.h @@ -355,8 +355,9 @@ extern void viaXMesaSetFrontClipRects(viaContextPtr vmesa); extern void viaReAllocateBuffers(GLframebuffer *drawbuffer); extern void viaXMesaWindowMoved(viaContextPtr vmesa); -extern void viaTexCombineState(viaContextPtr vmesa, - const struct gl_tex_env_combine_state * combine, unsigned unit ); +extern GLboolean viaTexCombineState(viaContextPtr vmesa, + const struct gl_tex_env_combine_state * combine, + unsigned unit ); /* Via hw already adjusted for GL pixel centers: */ diff --git a/src/mesa/drivers/dri/unichrome/via_state.c b/src/mesa/drivers/dri/unichrome/via_state.c index 2d7a2a3b109..97f9a030436 100644 --- a/src/mesa/drivers/dri/unichrome/via_state.c +++ b/src/mesa/drivers/dri/unichrome/via_state.c @@ -325,6 +325,16 @@ void viaEmitState(viaContextPtr vmesa) OUT_RING( (HC_SubA_HTXnTBLRCa << 24) | vmesa->regHTXnTBLRCa_0 ); OUT_RING( (HC_SubA_HTXnTBLRCc << 24) | vmesa->regHTXnTBLRCc_0 ); OUT_RING( (HC_SubA_HTXnTBLRCbias << 24) | vmesa->regHTXnTBLRCbias_0 ); + + if (0) { + fprintf(stderr, "emitted Ca_0 %08x\n", vmesa->regHTXnTBLRCa_0); + fprintf(stderr, "emitted Cb_0 %08x\n", vmesa->regHTXnTBLRCb_0); + fprintf(stderr, "emitted Cc_0 %08x\n", vmesa->regHTXnTBLRCc_0); + fprintf(stderr, "emitted Cbias_0 %08x\n", vmesa->regHTXnTBLRCbias_0); + fprintf(stderr, "emitted Aa_0 %08x\n", vmesa->regHTXnTBLRAa_0); + fprintf(stderr, "emitted Fog_0 %08x\n", vmesa->regHTXnTBLRFog_0); + } + ADVANCE_RING(); if (t->regTexFM == HC_HTXnFM_Index8) { @@ -841,7 +851,7 @@ get_wrap_mode( GLenum sWrap, GLenum tWrap ) } -static void viaChooseTextureState(GLcontext *ctx) +static GLboolean viaChooseTextureState(GLcontext *ctx) { viaContextPtr vmesa = VIA_CONTEXT(ctx); struct gl_texture_unit *texUnit0 = &ctx->Texture.Unit[0]; @@ -928,7 +938,8 @@ static void viaChooseTextureState(GLcontext *ctx) if (VIA_DEBUG) fprintf(stderr, "texUnit0->EnvMode %x\n",texUnit0->EnvMode); - viaTexCombineState( vmesa, texUnit0->_CurrentCombine, 0 ); + if (!viaTexCombineState( vmesa, texUnit0->_CurrentCombine, 0 )) + return GL_FALSE; } if (texUnit1->_ReallyEnabled) { @@ -986,7 +997,8 @@ static void viaChooseTextureState(GLcontext *ctx) vmesa->regHTXnMPMD_1 |= get_wrap_mode( texObj->WrapS, texObj->WrapT ); - viaTexCombineState( vmesa, texUnit1->_CurrentCombine, 1 ); + if (!viaTexCombineState( vmesa, texUnit1->_CurrentCombine, 1 )) + return GL_FALSE; } if (VIA_DEBUG) { @@ -1007,6 +1019,7 @@ static void viaChooseTextureState(GLcontext *ctx) } if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__); + return GL_TRUE; } static void viaChooseColorState(GLcontext *ctx) @@ -1533,8 +1546,10 @@ void viaValidateState( GLcontext *ctx ) viaContextPtr vmesa = VIA_CONTEXT(ctx); if (vmesa->newState & _NEW_TEXTURE) { - viaChooseTextureState(ctx); - viaUpdateTextureState(ctx); /* May modify vmesa->Fallback */ + GLboolean ok = (viaChooseTextureState(ctx) && + viaUpdateTextureState(ctx)); + + FALLBACK(vmesa, VIA_FALLBACK_TEXTURE, !ok); } if (vmesa->newState & _NEW_COLOR) diff --git a/src/mesa/drivers/dri/unichrome/via_tex.h b/src/mesa/drivers/dri/unichrome/via_tex.h index 6a5c959c4cb..1b5611a2158 100644 --- a/src/mesa/drivers/dri/unichrome/via_tex.h +++ b/src/mesa/drivers/dri/unichrome/via_tex.h @@ -92,7 +92,7 @@ struct via_texture_object_t { }; viaTextureObjectPtr viaAllocTextureObject(struct gl_texture_object *texObj); -void viaUpdateTextureState(GLcontext *ctx); +GLboolean viaUpdateTextureState(GLcontext *ctx); void viaInitTextureFuncs(struct dd_function_table * functions); void viaInitTextures(GLcontext *ctx); diff --git a/src/mesa/drivers/dri/unichrome/via_texcombine.c b/src/mesa/drivers/dri/unichrome/via_texcombine.c index b0afb57364e..d30cc056290 100644 --- a/src/mesa/drivers/dri/unichrome/via_texcombine.c +++ b/src/mesa/drivers/dri/unichrome/via_texcombine.c @@ -58,7 +58,6 @@ #define INPUT_B_SHIFT 7 #define INPUT_C_SHIFT 0 #define INPUT_CBias_SHIFT 14 -#define INPUT_ABias_SHIFT 3 #define CONST_ONE (HC_XTC_0 | HC_XTC_InvTOPC) @@ -73,6 +72,11 @@ static const unsigned alpha_operand_modifier[2] = { 0, HC_XTA_InvTOPA }; +static const unsigned bias_alpha_operand_modifier[2] = { + 0, HC_HTXnTBLAbias_Inv +}; + + static const unsigned c_shift_table[3] = { HC_HTXnTBLCshift_No, HC_HTXnTBLCshift_1, HC_HTXnTBLCshift_2 }; @@ -102,15 +106,16 @@ static const unsigned a_shift_table[3] = { * KW: needs attention to the case where texunit 1 is enabled but * texunit 0 is not. */ -void +GLboolean viaTexCombineState( viaContextPtr vmesa, const struct gl_tex_env_combine_state * combine, unsigned unit ) { unsigned color_arg[3]; unsigned alpha_arg[3]; - unsigned color = 0; - unsigned alpha = 0; + unsigned bias_alpha_arg[3]; + unsigned color = HC_HTXnTBLCsat_MASK; + unsigned alpha = HC_HTXnTBLAsat_MASK; unsigned bias = 0; unsigned op = 0; unsigned a_shift = combine->ScaleShiftA; @@ -118,11 +123,18 @@ viaTexCombineState( viaContextPtr vmesa, unsigned i; unsigned constant_color[3]; unsigned ordered_constant_color[4]; - unsigned constant_alpha = 0; + unsigned constant_alpha[3]; unsigned bias_alpha = 0; + unsigned abc_alpha = 0; const struct gl_texture_unit const * texUnit = & vmesa->glCtx->Texture.Unit[unit]; unsigned env_color[4]; + /* It seems that the color clamping can be overwhelmed at the 4x + * scale settings, necessitating this fallback: + */ + if (c_shift == 2 || a_shift == 2) { + return GL_FALSE; + } CLAMPED_FLOAT_TO_UBYTE(env_color[0], texUnit->EnvColor[0]); CLAMPED_FLOAT_TO_UBYTE(env_color[1], texUnit->EnvColor[1]); @@ -131,6 +143,7 @@ viaTexCombineState( viaContextPtr vmesa, (void) memset( constant_color, 0, sizeof( constant_color ) ); (void) memset( ordered_constant_color, 0, sizeof( ordered_constant_color ) ); + (void) memset( constant_alpha, 0, sizeof( constant_alpha ) ); for ( i = 0 ; i < combine->_NumArgsRGB ; i++ ) { const GLint op = combine->OperandRGB[i] - GL_SRC_COLOR; @@ -177,30 +190,6 @@ viaTexCombineState( viaContextPtr vmesa, } } - for ( i = 0 ; i < combine->_NumArgsA ; i++ ) { - const GLint op = combine->OperandA[i] - GL_SRC_ALPHA; - - switch ( combine->SourceA[i] ) { - case GL_TEXTURE: - alpha_arg[i] = HC_XTA_Atex; - alpha_arg[i] += alpha_operand_modifier[op]; - break; - case GL_CONSTANT: - alpha_arg[i] = HC_XTA_HTXnTBLRA; - constant_alpha = (op == 0) - ? env_color[3] : ~(env_color[3]) & 0x000000ff; - break; - case GL_PRIMARY_COLOR: - alpha_arg[i] = HC_XTA_Adif; - alpha_arg[i] += alpha_operand_modifier[op]; - break; - case GL_PREVIOUS: - alpha_arg[i] = (unit == 0) ? HC_XTA_Adif : HC_XTA_Acur; - alpha_arg[i] += alpha_operand_modifier[op]; - break; - } - } - /* On the Unichrome, all combine operations take on some form of: * @@ -210,30 +199,32 @@ viaTexCombineState( viaContextPtr vmesa, * and mask modes are currently unused. With the exception of DOT3, all * standard GL_COMBINE modes can be implemented simply by selecting the * correct inputs for A, B, C, and Bias and the correct operation for op. + * + * NOTE: xBias (when read from the constant registers) is signed, + * and scaled to fit -255..255 in 8 bits, ie 0x1 == 2. */ - color = HC_HTXnTBLCsat_MASK; - alpha = HC_HTXnTBLAsat_MASK; - switch( combine->ModeRGB ) { - /* Ca = 0, Cb = 0, Cc = 0, Cbias = arg0 + /* Ca = 1.0, Cb = arg0, Cc = 0, Cbias = 0 */ case GL_REPLACE: - bias |= (color_arg[0] << INPUT_CBias_SHIFT); - ordered_constant_color[3] = constant_color[0]; + color |= ((CONST_ONE << INPUT_A_SHIFT) | + (color_arg[0] << INPUT_B_SHIFT)); + + ordered_constant_color[1] = constant_color[0]; break; /* Ca = arg[0], Cb = arg[1], Cc = 0, Cbias = 0 */ case GL_MODULATE: - color |= (color_arg[0] << INPUT_A_SHIFT) - | (color_arg[1] << INPUT_B_SHIFT); + color |= ((color_arg[0] << INPUT_A_SHIFT) | + (color_arg[1] << INPUT_B_SHIFT)); ordered_constant_color[0] = constant_color[0]; ordered_constant_color[1] = constant_color[1]; break; - /* Ca = 1.0, Cb = arg[0], Cc = 0, Cbias = arg[1] + /* Ca = 1.0, Cb = arg[0], Cc = arg[1], Cbias = 0 */ case GL_ADD: case GL_SUBTRACT: @@ -241,25 +232,26 @@ viaTexCombineState( viaContextPtr vmesa, op |= HC_HTXnTBLCop_Sub; } - color |= (color_arg[0] << INPUT_B_SHIFT) - | (CONST_ONE << INPUT_A_SHIFT); + color |= ((CONST_ONE << INPUT_A_SHIFT) | + (color_arg[0] << INPUT_B_SHIFT) | + (color_arg[1] << INPUT_C_SHIFT)); - bias |= (color_arg[1] << INPUT_CBias_SHIFT); ordered_constant_color[1] = constant_color[0]; - ordered_constant_color[3] = constant_color[1]; + ordered_constant_color[2] = constant_color[1]; break; - /* Ca = 0, Cb = arg[0], Cc = arg[1], Cbias = 0.5 + /* Ca = 1.0, Cb = arg[0], Cc = arg[1], Cbias = -0.5 */ case GL_ADD_SIGNED: - color |= (color_arg[0] << INPUT_B_SHIFT) - | (color_arg[1] << INPUT_C_SHIFT); + color |= ((CONST_ONE << INPUT_A_SHIFT) | + (color_arg[0] << INPUT_B_SHIFT) | + (color_arg[1] << INPUT_C_SHIFT)); + bias |= HC_HTXnTBLCbias_HTXnTBLRC; - op |= HC_HTXnTBLCop_Sub; ordered_constant_color[1] = constant_color[0]; ordered_constant_color[2] = constant_color[1]; - ordered_constant_color[3] = 0x00808080; + ordered_constant_color[3] = 0x00bfbfbf; /* -.5 */ break; /* Ca = arg[2], Cb = arg[0], Cc = arg[1], Cbias = arg[1] @@ -267,17 +259,19 @@ viaTexCombineState( viaContextPtr vmesa, case GL_INTERPOLATE: op |= HC_HTXnTBLCop_Sub; - color |= (color_arg[2] << INPUT_A_SHIFT) | - (color_arg[0] << INPUT_B_SHIFT) | - (color_arg[1] << INPUT_C_SHIFT); + color |= ((color_arg[2] << INPUT_A_SHIFT) | + (color_arg[0] << INPUT_B_SHIFT) | + (color_arg[1] << INPUT_C_SHIFT)); + bias |= (color_arg[1] << INPUT_CBias_SHIFT); ordered_constant_color[0] = constant_color[2]; ordered_constant_color[1] = constant_color[0]; ordered_constant_color[2] = constant_color[1]; - ordered_constant_color[3] = constant_color[1]; + ordered_constant_color[3] = (constant_color[1] >> 1) & 0x7f7f7f; break; +#if 0 /* At this point this code is completely untested. It appears that the * Unichrome has the same limitation as the Radeon R100. The only * supported post-scale when doing DOT3 bumpmapping is 1x. @@ -288,41 +282,88 @@ viaTexCombineState( viaContextPtr vmesa, case GL_DOT3_RGBA: c_shift = 2; a_shift = 2; - color |= (color_arg[0] << INPUT_A_SHIFT) | - (color_arg[1] << INPUT_B_SHIFT); + color |= ((color_arg[0] << INPUT_A_SHIFT) | + (color_arg[1] << INPUT_B_SHIFT)); op |= HC_HTXnTBLDOT4; break; +#endif + + default: + assert(0); + break; } + + /* The alpha blend stage has the annoying quirk of not having a * hard-wired 0 input, like the color stage. As a result, we have * to program the constant register with 0 and use that as our * 0 input. + * + * (xA * (xB op xC) + xBias) << xShift + * */ + for ( i = 0 ; i < combine->_NumArgsA ; i++ ) { + const GLint op = combine->OperandA[i] - GL_SRC_ALPHA; + + switch ( combine->SourceA[i] ) { + case GL_TEXTURE: + alpha_arg[i] = HC_XTA_Atex; + alpha_arg[i] += alpha_operand_modifier[op]; + bias_alpha_arg[i] = HC_HTXnTBLAbias_Atex; + bias_alpha_arg[i] += bias_alpha_operand_modifier[op]; + break; + case GL_CONSTANT: + alpha_arg[i] = HC_XTA_HTXnTBLRA; + bias_alpha_arg[i] = HC_HTXnTBLAbias_HTXnTBLRAbias; + constant_alpha[i] = (op == 0) ? env_color[3] : (~env_color[3] & 0xff); + break; + case GL_PRIMARY_COLOR: + alpha_arg[i] = HC_XTA_Adif; + alpha_arg[i] += alpha_operand_modifier[op]; + bias_alpha_arg[i] = HC_HTXnTBLAbias_Adif; + bias_alpha_arg[i] += bias_alpha_operand_modifier[op]; + break; + case GL_PREVIOUS: + alpha_arg[i] = (unit == 0) ? HC_XTA_Adif : HC_XTA_Acur; + alpha_arg[i] += alpha_operand_modifier[op]; + bias_alpha_arg[i] = (unit == 0) ? HC_HTXnTBLAbias_Adif : HC_HTXnTBLAbias_Acur; + bias_alpha_arg[i] += bias_alpha_operand_modifier[op]; + break; + } + } + switch( combine->ModeA ) { /* Aa = 0, Ab = 0, Ac = 0, Abias = arg0 */ case GL_REPLACE: - bias |= (alpha_arg[0] << INPUT_ABias_SHIFT); + alpha |= ((HC_XTA_HTXnTBLRA << INPUT_A_SHIFT) | + (HC_XTA_HTXnTBLRA << INPUT_B_SHIFT) | + (HC_XTA_HTXnTBLRA << INPUT_C_SHIFT)); + abc_alpha = 0; - alpha |= (HC_XTA_HTXnTBLRA << INPUT_A_SHIFT) | - (HC_XTA_HTXnTBLRA << INPUT_B_SHIFT) | - (HC_XTA_HTXnTBLRA << INPUT_C_SHIFT); + bias |= bias_alpha_arg[0]; + bias_alpha = constant_alpha[0] >> 1; break; /* Aa = arg[0], Ab = arg[1], Ac = 0, Abias = 0 */ case GL_MODULATE: - alpha |= (alpha_arg[1] << INPUT_A_SHIFT) - | (alpha_arg[0] << INPUT_B_SHIFT) - | (HC_XTA_HTXnTBLRA << INPUT_C_SHIFT); + alpha |= ((alpha_arg[1] << INPUT_A_SHIFT) | + (alpha_arg[0] << INPUT_B_SHIFT) | + (HC_XTA_HTXnTBLRA << INPUT_C_SHIFT)); + + abc_alpha = ((constant_alpha[1] << HC_HTXnTBLRAa_SHIFT) | + (constant_alpha[0] << HC_HTXnTBLRAb_SHIFT) | + (0 << HC_HTXnTBLRAc_SHIFT)); - bias |= (HC_XTA_HTXnTBLRA << INPUT_ABias_SHIFT); + bias |= HC_HTXnTBLAbias_HTXnTBLRAbias; + bias_alpha = 0; break; - /* Aa = 0, Ab = arg[0], Ac = 0, Abias = arg[1] + /* Aa = 1.0, Ab = arg[0], Ac = arg[1], Abias = 0 */ case GL_ADD: case GL_SUBTRACT: @@ -330,22 +371,30 @@ viaTexCombineState( viaContextPtr vmesa, op |= HC_HTXnTBLAop_Sub; } - alpha |= (HC_XTA_HTXnTBLRA << INPUT_A_SHIFT) | - (alpha_arg[0] << INPUT_B_SHIFT) | - (HC_XTA_HTXnTBLRA << INPUT_C_SHIFT); - bias |= (alpha_arg[1] << INPUT_ABias_SHIFT); + alpha |= ((HC_XTA_HTXnTBLRA << INPUT_A_SHIFT) | + (alpha_arg[0] << INPUT_B_SHIFT) | + (alpha_arg[1] << INPUT_C_SHIFT)); + + abc_alpha = ((0xff << HC_HTXnTBLRAa_SHIFT) | + (constant_alpha[0] << HC_HTXnTBLRAb_SHIFT) | + (constant_alpha[1] << HC_HTXnTBLRAc_SHIFT)); + + bias |= HC_HTXnTBLAbias_HTXnTBLRAbias; + bias_alpha = 0; break; - /* Aa = 0, Ab = arg[0], Ac = arg[1], Abias = 0.5 + /* Aa = 1.0, Ab = arg[0], Ac = arg[1], Abias = -0.5 */ case GL_ADD_SIGNED: - op |= HC_HTXnTBLAop_Sub; - - alpha |= (alpha_arg[0] << INPUT_B_SHIFT) - | (alpha_arg[1] << INPUT_C_SHIFT); - bias |= (HC_XTA_HTXnTBLRA << INPUT_ABias_SHIFT); - - bias_alpha = 0x00000080; + alpha |= ((HC_XTA_HTXnTBLRA << INPUT_A_SHIFT) | + (alpha_arg[0] << INPUT_B_SHIFT) | + (alpha_arg[1] << INPUT_C_SHIFT)); + abc_alpha = ((0xff << HC_HTXnTBLRAa_SHIFT) | + (constant_alpha[0] << HC_HTXnTBLRAb_SHIFT) | + (constant_alpha[1] << HC_HTXnTBLRAc_SHIFT)); + + bias |= HC_HTXnTBLAbias_HTXnTBLRAbias; + bias_alpha = 0xbf; break; /* Aa = arg[2], Ab = arg[0], Ac = arg[1], Abias = arg[1] @@ -353,10 +402,15 @@ viaTexCombineState( viaContextPtr vmesa, case GL_INTERPOLATE: op |= HC_HTXnTBLAop_Sub; - alpha |= (alpha_arg[2] << INPUT_A_SHIFT) | - (alpha_arg[0] << INPUT_B_SHIFT) | - (alpha_arg[1] << INPUT_C_SHIFT); - bias |= (alpha_arg[1] << INPUT_ABias_SHIFT); + alpha |= ((alpha_arg[2] << INPUT_A_SHIFT) | + (alpha_arg[0] << INPUT_B_SHIFT) | + (alpha_arg[1] << INPUT_C_SHIFT)); + abc_alpha = ((constant_alpha[2] << HC_HTXnTBLRAa_SHIFT) | + (constant_alpha[0] << HC_HTXnTBLRAb_SHIFT) | + (constant_alpha[1] << HC_HTXnTBLRAc_SHIFT)); + + bias |= bias_alpha_arg[1]; + bias_alpha = constant_alpha[1] >> 1; break; } @@ -370,7 +424,8 @@ viaTexCombineState( viaContextPtr vmesa, vmesa->regHTXnTBLCsat_0 = color; vmesa->regHTXnTBLAsat_0 = alpha; vmesa->regHTXnTBLCop_0 = op | bias; - vmesa->regHTXnTBLRAa_0 = bias_alpha | (constant_alpha << 16); + vmesa->regHTXnTBLRAa_0 = abc_alpha; + vmesa->regHTXnTBLRFog_0 = bias_alpha; vmesa->regHTXnTBLRCa_0 = ordered_constant_color[0]; vmesa->regHTXnTBLRCb_0 = ordered_constant_color[1]; @@ -383,12 +438,15 @@ viaTexCombineState( viaContextPtr vmesa, vmesa->regHTXnTBLCsat_1 = color; vmesa->regHTXnTBLAsat_1 = alpha; vmesa->regHTXnTBLCop_1 = op | bias; - vmesa->regHTXnTBLRAa_1 = bias_alpha | (constant_alpha << 16); + vmesa->regHTXnTBLRAa_1 = abc_alpha; + vmesa->regHTXnTBLRFog_1 = bias_alpha; vmesa->regHTXnTBLRCa_1 = ordered_constant_color[0]; vmesa->regHTXnTBLRCb_1 = ordered_constant_color[1]; vmesa->regHTXnTBLRCc_1 = ordered_constant_color[2]; vmesa->regHTXnTBLRCbias_1 = ordered_constant_color[3]; } + + return GL_TRUE; } diff --git a/src/mesa/drivers/dri/unichrome/via_tris.c b/src/mesa/drivers/dri/unichrome/via_tris.c index b49449137a5..2d9bf37f039 100644 --- a/src/mesa/drivers/dri/unichrome/via_tris.c +++ b/src/mesa/drivers/dri/unichrome/via_tris.c @@ -1052,6 +1052,7 @@ void viaFallback(viaContextPtr vmesa, GLuint bit, GLboolean mode) vmesa->Fallback |= bit; if (oldfallback == 0) { VIA_FLUSH_DMA(vmesa); + if (0) fprintf(stderr, "ENTER FALLBACK %x\n", bit); _swsetup_Wakeup(ctx); vmesa->renderIndex = ~0; } @@ -1061,6 +1062,8 @@ void viaFallback(viaContextPtr vmesa, GLuint bit, GLboolean mode) if (oldfallback == bit) { _swrast_flush( ctx ); + if (0) fprintf(stderr, "LEAVE FALLBACK %x\n", bit); + tnl->Driver.Render.Start = viaRenderStart; tnl->Driver.Render.PrimitiveNotify = viaRenderPrimitive; tnl->Driver.Render.Finish = viaRenderFinish; @@ -1082,6 +1085,18 @@ void viaFallback(viaContextPtr vmesa, GLuint bit, GLboolean mode) } } +static void viaRunPipeline( GLcontext *ctx ) +{ + viaContextPtr vmesa = VIA_CONTEXT(ctx); + + if (vmesa->newState) { + vmesa->newRenderState |= vmesa->newState; + viaValidateState( ctx ); + } + + _tnl_run_pipeline( ctx ); +} + /**********************************************************************/ /* Initialization. */ @@ -1099,7 +1114,7 @@ void viaInitTriFuncs(GLcontext *ctx) firsttime = 0; } - tnl->Driver.RunPipeline = _tnl_run_pipeline; + tnl->Driver.RunPipeline = viaRunPipeline; tnl->Driver.Render.Start = viaRenderStart; tnl->Driver.Render.Finish = viaRenderFinish; tnl->Driver.Render.PrimitiveNotify = viaRenderPrimitive; |