I'm probably not the only person that has tried to kill _ReallyEnabled.
This does the mechanical part of the work, and cleans _ReallyEnabled from
i965.
I think that using _Current makes texture management clearer: You can't
have multiple targets in use in the same texture image unit at the same
time, because there's just that one pointer.
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
GLfloat s, t, s1, t1;
GLuint tw, th;
- if (!ctx->Texture.Unit[i]._ReallyEnabled) {
+ if (!ctx->Texture.Unit[i]._Current) {
GLuint j;
for (j = 0; j < 4; j++) {
verts[j].st[i][0] = 0.0f;
if (ctx->Texture._MaxEnabledTexImageUnit != -1) {
for (unit = 0; unit < ctx->Texture._MaxEnabledTexImageUnit; unit++)
- if (ctx->Texture.Unit[unit]._ReallyEnabled)
+ if (ctx->Texture.Unit[unit]._Current)
emit_texblend(i830, unit, blendunit++,
unit == ctx->Texture._MaxEnabledTexImageUnit);
} else {
/* Resolve depth buffer and render cache of each enabled texture. */
int maxEnabledUnit = ctx->Texture._MaxEnabledTexImageUnit;
for (int i = 0; i <= maxEnabledUnit; i++) {
- if (!ctx->Texture.Unit[i]._ReallyEnabled)
+ if (!ctx->Texture.Unit[i]._Current)
continue;
tex_obj = intel_texture_object(ctx->Texture.Unit[i]._Current);
if (!tex_obj || !tex_obj->mt)
for (i = 0; i <= maxEnabledUnit; i++) {
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i];
- if (texUnit->_ReallyEnabled) {
+ if (texUnit->_Current) {
intel_finalize_mipmap_tree(brw, i);
}
}
int unit_id = prog->SamplerUnits[s];
const struct gl_texture_unit *unit = &ctx->Texture.Unit[unit_id];
- if (unit->_ReallyEnabled && unit->_Current->Target != GL_TEXTURE_BUFFER) {
+ if (unit->_Current && unit->_Current->Target != GL_TEXTURE_BUFFER) {
const struct gl_texture_object *t = unit->_Current;
const struct gl_texture_image *img = t->Image[0][t->BaseLevel];
struct gl_sampler_object *sampler = _mesa_get_samplerobj(ctx, unit_id);
for (unsigned s = 0; s < sampler_count; s++) {
if (SamplersUsed & (1 << s)) {
const unsigned unit = prog->SamplerUnits[s];
- if (ctx->Texture.Unit[unit]._ReallyEnabled)
+ if (ctx->Texture.Unit[unit]._Current)
brw_update_sampler_state(brw, unit, s, &samplers[s],
*sst_offset, &sdc_offset[s]);
}
const unsigned unit = prog->SamplerUnits[s];
/* _NEW_TEXTURE */
- if (ctx->Texture.Unit[unit]._ReallyEnabled) {
+ if (ctx->Texture.Unit[unit]._Current) {
brw->vtbl.update_texture_surface(ctx, unit, surf_offset + s, for_gather);
}
}
for (unsigned s = 0; s < sampler_count; s++) {
if (SamplersUsed & (1 << s)) {
const unsigned unit = prog->SamplerUnits[s];
- if (ctx->Texture.Unit[unit]._ReallyEnabled)
+ if (ctx->Texture.Unit[unit]._Current)
gen7_update_sampler_state(brw, unit, s, &samplers[s],
&sdc_offset[s]);
}
struct nouveau_pushbuf *push = context_push(ctx);
struct nouveau_object *fahrenheit;
- if ((ctx->Texture.Unit[0]._ReallyEnabled &&
+ if ((ctx->Texture.Unit[0]._Current &&
texunit_needs_combiners(&ctx->Texture.Unit[0])) ||
- ctx->Texture.Unit[1]._ReallyEnabled ||
+ ctx->Texture.Unit[1]._Current ||
ctx->Stencil.Enabled ||
!(ctx->Color.ColorMask[0][RCOMP] &&
ctx->Color.ColorMask[0][GCOMP] &&
struct combiner_state rc_a = {}, rc_c = {};
/* Compute the new combiner state. */
- if (ctx->Texture.Unit[i]._ReallyEnabled) {
+ if (ctx->Texture.Unit[i]._Current) {
INIT_COMBINER(A, ctx, &rc_a, i);
setup_combiner(&rc_a);
struct nouveau_surface *s;
uint32_t format = 0xa0, filter = 0x1010;
- if (ctx->Texture.Unit[i]._ReallyEnabled) {
+ if (ctx->Texture.Unit[i]._Current) {
struct gl_texture_object *t = ctx->Texture.Unit[i]._Current;
struct gl_texture_image *ti = t->Image[0][t->BaseLevel];
const struct gl_sampler_object *sa = _mesa_get_samplerobj(ctx, i);
{
struct combiner_state rc_a, rc_c;
- if (ctx->Texture.Unit[i]._ReallyEnabled) {
+ if (ctx->Texture.Unit[i]._Current) {
INIT_COMBINER(RGB, ctx, &rc_c, i);
if (rc_c.mode == GL_DOT3_RGBA)
PUSH_RESET(push, BUFCTX_TEX(i));
- if (!ctx->Texture.Unit[i]._ReallyEnabled) {
+ if (!ctx->Texture.Unit[i]._Current) {
BEGIN_NV04(push, NV10_3D(TEX_ENABLE(i)), 1);
PUSH_DATA (push, 0);
return;
PUSH_RESET(push, BUFCTX_TEX(i));
- if (!ctx->Texture.Unit[i]._ReallyEnabled) {
+ if (!ctx->Texture.Unit[i]._Current) {
BEGIN_NV04(push, NV20_3D(TEX_ENABLE(i)), 1);
PUSH_DATA (push, 0);
int i;
for (i = 0; i < NV20_TEXTURE_UNITS; i++) {
- if (!ctx->Texture.Unit[i]._ReallyEnabled)
+ if (!ctx->Texture.Unit[i]._Current)
continue;
tx_shader_op |= NV20_3D_TEX_SHADER_OP_TX0_TEXTURE_2D << 5 * i;
rmesa->TexMatCompSel = 0;
for (unit = 0 ; unit < ctx->Const.MaxTextureUnits; unit++) {
- if (!ctx->Texture.Unit[unit]._ReallyEnabled)
+ if (!ctx->Texture.Unit[unit]._Current)
continue;
if (ctx->TextureMatrixStack[unit].Top->type != MATRIX_IDENTITY) {
for (i = 0; i < ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits; ++i) {
radeonTexObj *t;
- if (!ctx->Texture.Unit[i]._ReallyEnabled)
+ if (!ctx->Texture.Unit[i]._Current)
continue;
t = radeon_tex_obj(ctx->Texture.Unit[i]._Current);
}
for (i = 0 ; i < ctx->Const.MaxTextureUnits; i++) {
- if (ctx->Texture.Unit[i]._ReallyEnabled) {
+ if (ctx->Texture.Unit[i]._Current) {
if (rmesa->TexGenNeedNormals[i]) {
map_rev_fixed[2] = VERT_ATTRIB_NORMAL;
}
~(R200_TXA_DOT_ALPHA | R200_TXA_SCALE_MASK | R200_TXA_OUTPUT_REG_MASK |
R200_TXA_TFACTOR_SEL_MASK | R200_TXA_TFACTOR1_SEL_MASK);
- /* texUnit->_Current can be NULL if and only if the texture unit is
- * not actually enabled.
- */
- assert( (texUnit->_ReallyEnabled == 0)
- || (texUnit->_Current != NULL) );
-
if ( R200_DEBUG & RADEON_TEXTURE ) {
fprintf( stderr, "%s( %p, %d )\n", __FUNCTION__, (void *)ctx, unit );
}
(unit << R200_TXA_TFACTOR_SEL_SHIFT) |
(replaceargs << R200_TXA_TFACTOR1_SEL_SHIFT);
- if ( !texUnit->_ReallyEnabled ) {
+ if ( !texUnit->_Current ) {
assert( unit == 0);
color_combine = R200_TXC_ARG_A_ZERO | R200_TXC_ARG_B_ZERO
| R200_TXC_ARG_C_DIFFUSE_COLOR | R200_TXC_OP_MADD;
/* find highest used unit */
for ( j = 0; j < R200_MAX_TEXTURE_UNITS; j++) {
- if (ctx->Texture.Unit[j]._ReallyEnabled) {
+ if (ctx->Texture.Unit[j]._Current) {
maxunitused = j;
}
}
nextunit[j] = currentnext;
- if (!texUnit->_ReallyEnabled) {
+ if (!texUnit->_Current) {
/* the not enabled stages are referenced "indirectly",
must not cut off the lower stages */
stageref[j] = REF_COLOR | REF_ALPHA;
i = 0;
while ((i <= maxunitused) && (i >= 0)) {
/* only output instruction if the results are referenced */
- if (ctx->Texture.Unit[i]._ReallyEnabled && stageref[i+1]) {
+ if (ctx->Texture.Unit[i]._Current && stageref[i+1]) {
GLuint replaceunit = i;
/* try to optimize GL_REPLACE away (only one level deep though) */
if ( (ctx->Texture.Unit[i]._CurrentCombine->ModeRGB == GL_REPLACE) &&
rmesa->TexMatColSwap = 0;
for (unit = 0 ; unit < ctx->Const.MaxTextureUnits; unit++) {
- if (ctx->Texture.Unit[unit]._ReallyEnabled) {
+ if (ctx->Texture.Unit[unit]._Current) {
GLboolean needMatrix = GL_FALSE;
if (ctx->TextureMatrixStack[unit].Top->type != MATRIX_IDENTITY) {
needMatrix = GL_TRUE;
for (i = 0; i < ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits; ++i) {
radeonTexObj *t;
- if (!ctx->Texture.Unit[i]._ReallyEnabled)
+ if (!ctx->Texture.Unit[i]._Current)
continue;
t = rmesa->state.texture.unit[i].texobj;
CHECK( cube2_mm, (ctx->Texture.Unit[2]._ReallyEnabled & TEXTURE_CUBE_BIT), 2 + 4*5 - CUBE_STATE_SIZE )
CHECK( fog_add4, ctx->Fog.Enabled, 4 )
TCL_CHECK( tcl_add4, GL_TRUE, 4 )
-TCL_CHECK( tcl_tex0_add4, ctx->Texture.Unit[0]._ReallyEnabled, 4 )
-TCL_CHECK( tcl_tex1_add4, ctx->Texture.Unit[1]._ReallyEnabled, 4 )
-TCL_CHECK( tcl_tex2_add4, ctx->Texture.Unit[2]._ReallyEnabled, 4 )
+TCL_CHECK( tcl_tex0_add4, ctx->Texture.Unit[0]._Current, 4 )
+TCL_CHECK( tcl_tex1_add4, ctx->Texture.Unit[1]._Current, 4 )
+TCL_CHECK( tcl_tex2_add4, ctx->Texture.Unit[2]._Current, 4 )
TCL_CHECK( tcl_lighting, ctx->Light.Enabled, 0 )
TCL_CHECK( tcl_lighting_add4, ctx->Light.Enabled, 4 )
TCL_CHECK( tcl_eyespace_or_lighting_add4, ctx->_NeedEyeCoords || ctx->Light.Enabled, 4 )
}
for (i = 0 ; i < ctx->Const.MaxTextureUnits; i++) {
- if (ctx->Texture.Unit[i]._ReallyEnabled) {
+ if (ctx->Texture.Unit[i]._Current) {
/* TODO: probably should not emit texture coords when texgen is enabled */
if (rmesa->TexGenNeedNormals[i]) {
inputs |= VERT_BIT_NORMAL;
| RADEON_SCALE_1X | RADEON_CLAMP_TX;
- /* texUnit->_Current can be NULL if and only if the texture unit is
- * not actually enabled.
- */
- assert( (texUnit->_ReallyEnabled == 0)
- || (texUnit->_Current != NULL) );
-
if ( RADEON_DEBUG & RADEON_TEXTURE ) {
fprintf( stderr, "%s( %p, %d )\n", __FUNCTION__, (void *)ctx, unit );
}
rmesa->state.texture.unit[unit].format = 0;
rmesa->state.texture.unit[unit].envMode = 0;
- if ( !texUnit->_ReallyEnabled ) {
+ if ( !texUnit->_Current ) {
color_combine = color_combine0;
alpha_combine = alpha_combine0;
}
{
r100ContextPtr rmesa = R100_CONTEXT(ctx);
- if (ctx->Texture.Unit[unit]._ReallyEnabled & TEXTURE_3D_BIT) {
+ if (ctx->Texture.Unit[unit]._Current &&
+ ctx->Texture.Unit[unit]._Current->Target == GL_TEXTURE_3D) {
disable_tex_obj_state(rmesa, unit);
rmesa->state.texture.unit[unit].texobj = NULL;
return GL_FALSE;
}
- if (!ctx->Texture.Unit[unit]._ReallyEnabled) {
+ if (!ctx->Texture.Unit[unit]._Current) {
/* disable the unit */
disable_tex_obj_state(rmesa, unit);
rmesa->state.texture.unit[unit].texobj = NULL;
const struct gl_sampler_object *samp;
GLenum format;
- if (!texUnit->_ReallyEnabled || !texUnit->Enabled)
+ if (!texUnit->_Current || !texUnit->Enabled)
continue;
samp = _mesa_get_samplerobj(ctx, i);
for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) {
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i];
- if (texUnit->_ReallyEnabled)
+ if (texUnit->_Current)
key->unit[i].texunit_really_enabled = 1;
if (ctx->Point.PointSprite)
if (_math_matrix_is_dirty(ctx->TextureMatrixStack[u].Top)) {
_math_matrix_analyse( ctx->TextureMatrixStack[u].Top );
- if (ctx->Texture.Unit[u]._ReallyEnabled &&
+ if (ctx->Texture.Unit[u]._Current &&
ctx->TextureMatrixStack[u].Top->type != MATRIX_IDENTITY)
ctx->Texture._TexMatEnabled |= ENABLE_TEXMAT(u);
}
v->attrib[VARYING_SLOT_POS][3]);
for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++)
- if (ctx->Texture.Unit[i]._ReallyEnabled)
+ if (ctx->Texture.Unit[i]._Current)
_mesa_debug(ctx, "texcoord[%d] %f %f %f %f\n", i,
v->attrib[VARYING_SLOT_TEX0 + i][0],
v->attrib[VARYING_SLOT_TEX0 + i][1],
{
const GLuint srcUnit = srcRGB - GL_TEXTURE0;
ASSERT(srcUnit < ctx->Const.MaxTextureUnits);
- if (!ctx->Texture.Unit[srcUnit]._ReallyEnabled)
+ if (!ctx->Texture.Unit[srcUnit]._Current)
goto end;
argRGB[term] = get_texel_array(swrast, srcUnit);
}
{
const GLuint srcUnit = srcA - GL_TEXTURE0;
ASSERT(srcUnit < ctx->Const.MaxTextureUnits);
- if (!ctx->Texture.Unit[srcUnit]._ReallyEnabled)
+ if (!ctx->Texture.Unit[srcUnit]._Current)
goto end;
argA[term] = get_texel_array(swrast, srcUnit);
}
for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
- if (texUnit->_ReallyEnabled &&
+ if (texUnit->_Current &&
texUnit->_CurrentCombine->ModeRGB == GL_BUMP_ENVMAP_ATI) {
const GLfloat (*texcoords)[4] = (const GLfloat (*)[4])
span->array->attribs[VARYING_SLOT_TEX0 + unit];
*/
for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
- if (texUnit->_ReallyEnabled &&
+ if (texUnit->_Current &&
texUnit->_CurrentCombine->ModeRGB != GL_BUMP_ENVMAP_ATI) {
const GLfloat (*texcoords)[4] = (const GLfloat (*)[4])
span->array->attribs[VARYING_SLOT_TEX0 + unit];
* We modify the span->color.rgba values.
*/
for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
- if (ctx->Texture.Unit[unit]._ReallyEnabled)
+ if (ctx->Texture.Unit[unit]._Current)
texture_combine(ctx, unit, primary_rgba, swrast->TexelBuffer, span);
}
int unit;
for (unit = 0; unit <= ctx->Texture._MaxEnabledTexImageUnit; unit++) {
- if (ctx->Texture.Unit[unit]._ReallyEnabled) {
- struct gl_texture_object *texObj = ctx->Texture.Unit[unit]._Current;
+ struct gl_texture_object *texObj = ctx->Texture.Unit[unit]._Current;
+ if (texObj)
_swrast_map_texture(ctx, texObj);
- }
}
}
{
int unit;
for (unit = 0; unit <= ctx->Texture._MaxEnabledTexImageUnit; unit++) {
- if (ctx->Texture.Unit[unit]._ReallyEnabled) {
- struct gl_texture_object *texObj = ctx->Texture.Unit[unit]._Current;
+ struct gl_texture_object *texObj = ctx->Texture.Unit[unit]._Current;
+ if (texObj)
_swrast_unmap_texture(ctx, texObj);
- }
}
}