[Mesa-dev] [PATCH 02/18] mesa: Add a _BoundTextures field in gl_texture_unit

Brian Paul brianp at vmware.com
Wed Jan 22 09:00:04 PST 2014


On 01/21/2014 03:35 PM, Fredrik Höglund wrote:
> This will be used by glBindTextures() when unbinding textures,
> to avoid having to loop over all the targets.
> ---
>   src/mesa/main/mtypes.h   |    3 +++
>   src/mesa/main/texobj.c   |    6 ++++++
>   src/mesa/main/texstate.c |    3 +++
>   3 files changed, 12 insertions(+)
>
> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
> index 2fe47c4..c1a17b8 100644
> --- a/src/mesa/main/mtypes.h
> +++ b/src/mesa/main/mtypes.h
> @@ -1368,6 +1368,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 4d97275..fbbc577 100644
> --- a/src/mesa/main/texobj.c
> +++ b/src/mesa/main/texobj.c
> @@ -1093,6 +1093,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);

I'd prefer:
unit->_BoundTextures &= ~(1 << tex);

since it tells the reader that we want to clear the bit, not just toggle it.


>               break;
>            }
>         }
> @@ -1348,6 +1349,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 7720965..c86324f 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);
>         }
>      }
> @@ -798,6 +799,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