[Mesa-dev] [PATCH 02/19] mesa: Add a _BoundTextures field in gl_texture_unit
Fredrik Höglund
fredrik at kde.org
Tue Apr 29 17:28:01 PDT 2014
On Monday 28 April 2014, Ian Romanick wrote:
> On 04/21/2014 02:57 PM, Fredrik Höglund wrote:
> > This will be used by glBindTextures() when unbinding textures,
> > to avoid having to loop over all the targets.
> > ---
> >
> > v2: Use &= ~(1 << index) to clear bits
> >
> > src/mesa/main/mtypes.h | 6 +++++-
> > src/mesa/main/texobj.c | 6 ++++++
> > src/mesa/main/texstate.c | 3 +++
> > 3 files changed, 14 insertions(+), 1 deletion(-)
> >
> > diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
> > index b07ad58..ac5e7ac 100644
> > --- a/src/mesa/main/mtypes.h
> > +++ b/src/mesa/main/mtypes.h
> > @@ -1195,7 +1195,8 @@ struct gl_texture_object
> > GLuint Name; /**< the user-visible texture object ID */
> > GLchar *Label; /**< GL_KHR_debug */
> > GLenum Target; /**< GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */
> > - gl_texture_index TargetIndex; /**< The gl_texture_unit::CurrentTex index */
> > + gl_texture_index TargetIndex; /**< The gl_texture_unit::CurrentTex index.
> > + Only valid when Target is valid. */
>
> Should this comment have been in the previous patch?
Good catch :)
> > struct gl_sampler_object Sampler;
> >
> > @@ -1370,6 +1371,9 @@ struct gl_texture_unit
> >
> > /** Points to highest priority, complete and enabled texture object */
> > struct gl_texture_object *_Current;
> > +
> > + /** Texture targets that have a non-default texture bound */
> > + GLbitfield _BoundTextures;
> > };
> >
> >
> > diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
> > index 7909907..054b41b 100644
> > --- a/src/mesa/main/texobj.c
> > +++ b/src/mesa/main/texobj.c
> > @@ -1102,6 +1102,7 @@ unbind_texobj_from_texunits(struct gl_context *ctx,
> > _mesa_reference_texobj(&unit->CurrentTex[tex],
> > ctx->Shared->DefaultTex[tex]);
> > ASSERT(unit->CurrentTex[tex]);
> > + unit->_BoundTextures &= ~(1 << tex);
> > break;
> > }
> > }
> > @@ -1357,6 +1358,11 @@ _mesa_BindTexture( GLenum target, GLuint texName )
> > _mesa_reference_texobj(&texUnit->CurrentTex[targetIndex], newTexObj);
> > ASSERT(texUnit->CurrentTex[targetIndex]);
> >
> > + if (texName != 0)
> > + texUnit->_BoundTextures |= (1 << targetIndex);
> > + else
> > + texUnit->_BoundTextures &= ~(1 << targetIndex);
> > +
> > /* Pass BindTexture call to device driver */
> > if (ctx->Driver.BindTexture)
> > ctx->Driver.BindTexture(ctx, target, newTexObj);
> > diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
> > index b68920c..b31e2c4 100644
> > --- a/src/mesa/main/texstate.c
> > +++ b/src/mesa/main/texstate.c
> > @@ -109,6 +109,7 @@ _mesa_copy_texture_state( const struct gl_context *src, struct gl_context *dst )
> > _mesa_reference_texobj(&dst->Texture.Unit[u].CurrentTex[tex],
> > src->Texture.Unit[u].CurrentTex[tex]);
> > }
> > + dst->Texture.Unit[u]._BoundTextures = src->Texture.Unit[u]._BoundTextures;
> > _mesa_unlock_context_textures(dst);
> > }
> > }
> > @@ -783,6 +784,8 @@ init_texture_unit( struct gl_context *ctx, GLuint unit )
> > _mesa_reference_texobj(&texUnit->CurrentTex[tex],
> > ctx->Shared->DefaultTex[tex]);
> > }
> > +
> > + texUnit->_BoundTextures = 0;
> > }
> >
> >
> >
>
>
More information about the mesa-dev
mailing list