[Mesa-dev] [PATCH 3/7] mesa: implement glBindTextures()

Marek Olšák maraeo at gmail.com
Fri Jan 3 05:04:01 PST 2014


On Fri, Jan 3, 2014 at 1:27 AM, Maxence Le Doré
<maxence.ledore at gmail.com> wrote:
> ---
>  src/mesa/main/texobj.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  src/mesa/main/texobj.h |  3 +++
>  2 files changed, 55 insertions(+)
>
> diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
> index bddbc50..66e2fb0 100644
> --- a/src/mesa/main/texobj.c
> +++ b/src/mesa/main/texobj.c
> @@ -1686,4 +1686,56 @@ _mesa_InvalidateTexImage(GLuint texture, GLint level)
>     return;
>  }
>
> +/** ARB_multi_bind / OpenGL 4.4 */
> +
> +void GLAPIENTRY
> +_mesa_BindTextures(GLuint first, GLsizei count, const GLuint *textures)
> +{
> +   GET_CURRENT_CONTEXT(ctx);
> +   struct GLuint currentTexUnit = 0;
> +   int i = 0;
> +
> +   currentTexUnit = ctx->Texture.CurrentUnit;
> +
> +   if(first + count > ctx->Const.MaxCombinedTextureImageUnits) {
> +      _mesa_error(ctx, GL_INVALID_OPERATION, "glBindTextures(first+count)");
> +      return;
> +   }
> +
> +   for(i = 0 ; i < count ; i++) {
> +      GLuint texture;
> +      struct gl_texture_object *texObj;
> +      GLenum texTarget;
> +      int j = 0;
> +
> +      if(textures == NULL)
> +        texture = 0;
> +      else
> +        texture = textures[i];
> +
> +      _mesa_ActiveTexture(GL_TEXTURE0 + first + i);
> +      if(texture != 0) {
> +        texObj = _mesa_lookup_texture(ctx, texture);
> +        if(texObj) {
> +          texTarget = texObj->Target;
> +          _mesa_BindTexture(texTarget, texture);
> +        }
> +        else
> +          _mesa_error(ctx, GL_INVALID_OPERATION,
> +                      "glBindTextures(textures[%i])", i);

This error is set too late. It should be done before changing textures.

Marek


More information about the mesa-dev mailing list