📄 r128_texstate.c
字号:
case GL_COLOR_INDEX: default: return GL_FALSE; } break; } /* Rage 128 has to fake some cases of GL_BLEND, otherwise fallback * to software rendering. */ if ( rmesa->blend_flags ) { return GL_FALSE; } switch ( format ) { case GL_RGBA: case GL_LUMINANCE_ALPHA: switch ( rmesa->env_color & 0x00ffffff ) { case 0x00000000: combine |= (COLOR_COMB_MODULATE_NTEX | /* C = Cf(1-Ct) */ ALPHA_COMB_MODULATE); /* A = AfAt */ break;#if 0 /* This isn't right - BP */ case 0x00ffffff: if ( unit == 0 ) { combine |= (COLOR_COMB_MODULATE_NTEX | /* C = Cf(1-Ct) */ ALPHA_COMB_MODULATE); /* A = AfAt */ } else { combine |= (COLOR_COMB_ADD | /* C = Cf+Ct */ ALPHA_COMB_COPY_INPUT); /* A = Af */ } break;#endif default: combine |= (COLOR_COMB_MODULATE | /* C = fallback */ ALPHA_COMB_MODULATE); /* A = fallback */ return GL_FALSE; } break; case GL_RGB: case GL_LUMINANCE: switch ( rmesa->env_color & 0x00ffffff ) { case 0x00000000: combine |= (COLOR_COMB_MODULATE_NTEX | /* C = Cf(1-Ct) */ ALPHA_COMB_COPY_INPUT); /* A = Af */ break;#if 0 /* This isn't right - BP */ case 0x00ffffff: if ( unit == 0 ) { combine |= (COLOR_COMB_MODULATE_NTEX | /* C = Cf(1-Ct) */ ALPHA_COMB_COPY_INPUT); /* A = Af */ } else { combine |= (COLOR_COMB_ADD | /* C = Cf+Ct */ ALPHA_COMB_COPY_INPUT); /* A = Af */ } break;#endif default: combine |= (COLOR_COMB_MODULATE | /* C = fallback */ ALPHA_COMB_COPY_INPUT); /* A = fallback */ return GL_FALSE; } break; case GL_ALPHA: if ( unit == 0 ) { combine |= (COLOR_COMB_COPY_INPUT | /* C = Cf */ ALPHA_COMB_MODULATE); /* A = AfAt */ } else { combine |= (COLOR_COMB_COPY_INPUT | /* C = Cf */ ALPHA_COMB_COPY_INPUT); /* A = Af */ } break; case GL_INTENSITY: switch ( rmesa->env_color & 0x00ffffff ) { case 0x00000000: combine |= COLOR_COMB_MODULATE_NTEX; /* C = Cf(1-It) */ break;#if 0 /* This isn't right - BP */ case 0x00ffffff: if ( unit == 0 ) { combine |= COLOR_COMB_MODULATE_NTEX; /* C = Cf(1-It) */ } else { combine |= COLOR_COMB_ADD; /* C = Cf+It */ } break;#endif default: combine |= (COLOR_COMB_MODULATE | /* C = fallback */ ALPHA_COMB_MODULATE); /* A = fallback */ return GL_FALSE; } switch ( rmesa->env_color & 0xff000000 ) { case 0x00000000: combine |= ALPHA_COMB_MODULATE_NTEX; /* A = Af(1-It) */ break;#if 0 /* This isn't right - BP */ case 0xff000000: if ( unit == 0 ) { combine |= ALPHA_COMB_MODULATE_NTEX; /* A = Af(1-It) */ } else { combine |= ALPHA_COMB_ADD; /* A = Af+It */ } break;#endif default: combine |= (COLOR_COMB_MODULATE | /* C = fallback */ ALPHA_COMB_MODULATE); /* A = fallback */ return GL_FALSE; } break; case GL_COLOR_INDEX: default: return GL_FALSE; } break; case GL_ADD: switch ( format ) { case GL_RGBA: case GL_LUMINANCE_ALPHA: combine |= (COLOR_COMB_ADD | /* C = Cf+Ct */ ALPHA_COMB_MODULATE); /* A = AfAt */ break; case GL_RGB: case GL_LUMINANCE: combine |= (COLOR_COMB_ADD | /* C = Cf+Ct */ ALPHA_COMB_COPY_INPUT); /* A = Af */ break; case GL_ALPHA: combine |= (COLOR_COMB_COPY_INPUT | /* C = Cf */ ALPHA_COMB_MODULATE); /* A = AfAt */ break; case GL_INTENSITY: combine |= (COLOR_COMB_ADD | /* C = Cf+Ct */ ALPHA_COMB_ADD); /* A = Af+At */ break; case GL_COLOR_INDEX: default: return GL_FALSE; } break; default: return GL_FALSE; } if ( rmesa->tex_combine[unit] != combine ) { rmesa->tex_combine[unit] = combine; rmesa->dirty |= R128_UPLOAD_TEX0 << unit; } return GL_TRUE;}static void disable_tex( GLcontext *ctx, int unit ){ r128ContextPtr rmesa = R128_CONTEXT(ctx); FLUSH_BATCH( rmesa ); if ( rmesa->CurrentTexObj[unit] ) { rmesa->CurrentTexObj[unit]->base.bound &= ~(1 << unit); rmesa->CurrentTexObj[unit] = NULL; } rmesa->setup.tex_cntl_c &= ~(R128_TEXMAP_ENABLE << unit); rmesa->setup.tex_size_pitch_c &= ~(R128_TEX_SIZE_PITCH_MASK << (R128_SEC_TEX_SIZE_PITCH_SHIFT * unit)); rmesa->dirty |= R128_UPLOAD_CONTEXT; /* If either texture unit is disabled, then multitexturing is not * happening. */ rmesa->blend_flags &= ~R128_BLEND_MULTITEX;}static GLboolean enable_tex_2d( GLcontext *ctx, int unit ){ r128ContextPtr rmesa = R128_CONTEXT(ctx); const int source = rmesa->tmu_source[unit]; const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[source]; const struct gl_texture_object *tObj = texUnit->_Current; r128TexObjPtr t = (r128TexObjPtr) tObj->DriverData; /* Need to load the 2d images associated with this unit. */ if ( t->base.dirty_images[0] ) { /* FIXME: For Radeon, RADEON_FIREVERTICES is called here. Should * FIXME: something similar be done for R128? */ /* FLUSH_BATCH( rmesa ); */ r128SetTexImages( rmesa, tObj ); r128UploadTexImages( rmesa, t ); if ( !t->base.memBlock ) return GL_FALSE; } return GL_TRUE;}static GLboolean update_tex_common( GLcontext *ctx, int unit ){ r128ContextPtr rmesa = R128_CONTEXT(ctx); const int source = rmesa->tmu_source[unit]; const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[source]; const struct gl_texture_object *tObj = texUnit->_Current; r128TexObjPtr t = (r128TexObjPtr) tObj->DriverData; /* Fallback if there's a texture border */ if ( tObj->Image[0][tObj->BaseLevel]->Border > 0 ) { return GL_FALSE; } /* Update state if this is a different texture object to last * time. */ if ( rmesa->CurrentTexObj[unit] != t ) { if ( rmesa->CurrentTexObj[unit] != NULL ) { /* The old texture is no longer bound to this texture unit. * Mark it as such. */ rmesa->CurrentTexObj[unit]->base.bound &= ~(1UL << unit); } rmesa->CurrentTexObj[unit] = t; t->base.bound |= (1UL << unit); rmesa->dirty |= R128_UPLOAD_TEX0 << unit; driUpdateTextureLRU( (driTextureObject *) t ); /* XXX: should be locked! */ } /* FIXME: We need to update the texture unit if any texture parameters have * changed, but this texture was already bound. This could be changed to * work like the Radeon driver where the texture object has it's own * dirty state flags */ rmesa->dirty |= R128_UPLOAD_TEX0 << unit; /* register setup */ rmesa->setup.tex_size_pitch_c &= ~(R128_TEX_SIZE_PITCH_MASK << (R128_SEC_TEX_SIZE_PITCH_SHIFT * unit)); if ( unit == 0 ) { rmesa->setup.tex_cntl_c |= R128_TEXMAP_ENABLE; rmesa->setup.tex_size_pitch_c |= t->setup.tex_size_pitch << 0; rmesa->setup.scale_3d_cntl &= ~R128_TEX_CACHE_SPLIT; t->setup.tex_cntl &= ~R128_SEC_SELECT_SEC_ST; } else { rmesa->setup.tex_cntl_c |= R128_SEC_TEXMAP_ENABLE; rmesa->setup.tex_size_pitch_c |= t->setup.tex_size_pitch << 16; rmesa->setup.scale_3d_cntl |= R128_TEX_CACHE_SPLIT; t->setup.tex_cntl |= R128_SEC_SELECT_SEC_ST; /* If the second TMU is enabled, then multitexturing is happening. */ if ( R128_IS_PLAIN( rmesa ) ) rmesa->blend_flags |= R128_BLEND_MULTITEX; } rmesa->dirty |= R128_UPLOAD_CONTEXT; /* FIXME: The Radeon has some cached state so that it can avoid calling * FIXME: UpdateTextureEnv in some cases. Is that possible here? */ return r128UpdateTextureEnv( ctx, unit );}static GLboolean updateTextureUnit( GLcontext *ctx, int unit ){ r128ContextPtr rmesa = R128_CONTEXT(ctx); const int source = rmesa->tmu_source[unit]; const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[source]; if (texUnit->_ReallyEnabled & (TEXTURE_1D_BIT | TEXTURE_2D_BIT)) { return (enable_tex_2d( ctx, unit ) && update_tex_common( ctx, unit )); } else if ( texUnit->_ReallyEnabled ) { return GL_FALSE; } else { disable_tex( ctx, unit ); return GL_TRUE; }}void r128UpdateTextureState( GLcontext *ctx ){ r128ContextPtr rmesa = R128_CONTEXT(ctx); GLboolean ok; /* This works around a quirk with the R128 hardware. If only OpenGL * TEXTURE1 is enabled, then the hardware TEXTURE0 must be used. The * hardware TEXTURE1 can ONLY be used when hardware TEXTURE0 is also used. */ rmesa->tmu_source[0] = 0; rmesa->tmu_source[1] = 1; if ((ctx->Texture._EnabledUnits & 0x03) == 0x02) { /* only texture 1 enabled */ rmesa->tmu_source[0] = 1; rmesa->tmu_source[1] = 0; } ok = (updateTextureUnit( ctx, 0 ) && updateTextureUnit( ctx, 1 )); FALLBACK( rmesa, R128_FALLBACK_TEXTURE, !ok );}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -