<div dir="ltr">I've addressed Brian Paul's comment about dsa ? "ture" : "" in this patch.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Dec 30, 2014 at 1:25 PM, Laura Ekstrand <span dir="ltr"><<a href="mailto:laura@jlekstrand.net" target="_blank">laura@jlekstrand.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Mon, Dec 29, 2014 at 3:02 PM, Anuj Phogat <span dir="ltr"><<a href="mailto:anuj.phogat@gmail.com" target="_blank">anuj.phogat@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div>On Tue, Dec 16, 2014 at 6:52 AM, Laura Ekstrand <<a href="mailto:laura@jlekstrand.net" target="_blank">laura@jlekstrand.net</a>> wrote:<br>
> ---<br>
>  src/mapi/glapi/gen/ARB_direct_state_access.xml |  36 +++<br>
>  src/mesa/main/teximage.c                       | 343 +++++++++++++++++++------<br>
>  src/mesa/main/teximage.h                       |  30 +++<br>
>  3 files changed, 333 insertions(+), 76 deletions(-)<br>
><br>
> diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml<br>
> index 37aac7e..4c5005f 100644<br>
> --- a/src/mapi/glapi/gen/ARB_direct_state_access.xml<br>
> +++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml<br>
> @@ -39,5 +39,41 @@<br>
>        <param name="depth" type="GLsizei" /><br>
>     </function><br>
><br>
> +   <function name="TextureSubImage1D" offset="assign"><br>
> +      <param name="texture" type="GLuint" /><br>
> +      <param name="level" type="GLint" /><br>
> +      <param name="xoffset" type="GLint" /><br>
> +      <param name="width" type="GLsizei" /><br>
> +      <param name="format" type="GLenum" /><br>
> +      <param name="type" type="GLenum" /><br>
> +      <param name="pixels" type="const GLvoid *" /><br>
> +   </function><br>
> +<br>
> +   <function name="TextureSubImage2D" offset="assign"><br>
> +      <param name="texture" type="GLuint" /><br>
> +      <param name="level" type="GLint" /><br>
> +      <param name="xoffset" type="GLint" /><br>
> +      <param name="yoffset" type="GLint" /><br>
> +      <param name="width" type="GLsizei" /><br>
> +      <param name="height" type="GLsizei" /><br>
> +      <param name="format" type="GLenum" /><br>
> +      <param name="type" type="GLenum" /><br>
> +      <param name="pixels" type="const GLvoid *" /><br>
> +   </function><br>
> +<br>
> +   <function name="TextureSubImage3D" offset="assign"><br>
> +      <param name="texture" type="GLuint" /><br>
> +      <param name="level" type="GLint" /><br>
> +      <param name="xoffset" type="GLint" /><br>
> +      <param name="yoffset" type="GLint" /><br>
> +      <param name="zoffset" type="GLint" /><br>
> +      <param name="width" type="GLsizei" /><br>
> +      <param name="height" type="GLsizei" /><br>
> +      <param name="depth" type="GLsizei" /><br>
> +      <param name="format" type="GLenum" /><br>
> +      <param name="type" type="GLenum" /><br>
> +      <param name="pixels" type="const GLvoid *" /><br>
> +   </function><br>
> +<br>
>  </category><br>
>  </OpenGLAPI><br>
> diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c<br>
> index 08070cd..cfb6297 100644<br>
> --- a/src/mesa/main/teximage.c<br>
> +++ b/src/mesa/main/teximage.c<br>
> @@ -1523,12 +1523,11 @@ _mesa_legal_texture_dimensions(struct gl_context *ctx, GLenum target,<br>
>   * \return GL_TRUE if error found, GL_FALSE otherwise.<br>
>   */<br>
>  static GLboolean<br>
> -error_check_subtexture_dimensions(struct gl_context *ctx,<br>
> -                                  const char *function, GLuint dims,<br>
> +error_check_subtexture_dimensions(struct gl_context *ctx, GLuint dims,<br>
>                                    const struct gl_texture_image *destImage,<br>
>                                    GLint xoffset, GLint yoffset, GLint zoffset,<br>
>                                    GLsizei subWidth, GLsizei subHeight,<br>
> -                                  GLsizei subDepth)<br>
> +                                  GLsizei subDepth, const char *func)<br>
>  {<br>
>     const GLenum target = destImage->TexObject->Target;<br>
>     GLuint bw, bh;<br>
> @@ -1536,32 +1535,32 @@ error_check_subtexture_dimensions(struct gl_context *ctx,<br>
>     /* Check size */<br>
>     if (subWidth < 0) {<br>
>        _mesa_error(ctx, GL_INVALID_VALUE,<br>
> -                  "%s%dD(width=%d)", function, dims, subWidth);<br>
> +                  "%s%dD(width=%d)", func, dims, subWidth);<br>
>        return GL_TRUE;<br>
>     }<br>
><br>
>     if (dims > 1 && subHeight < 0) {<br>
>        _mesa_error(ctx, GL_INVALID_VALUE,<br>
> -                  "%s%dD(height=%d)", function, dims, subHeight);<br>
> +                  "%s%dD(height=%d)", func, dims, subHeight);<br>
>        return GL_TRUE;<br>
>     }<br>
><br>
>     if (dims > 2 && subDepth < 0) {<br>
>        _mesa_error(ctx, GL_INVALID_VALUE,<br>
> -                  "%s%dD(depth=%d)", function, dims, subDepth);<br>
> +                  "%s%dD(depth=%d)", func, dims, subDepth);<br>
>        return GL_TRUE;<br>
>     }<br>
><br>
>     /* check xoffset and width */<br>
>     if (xoffset < - (GLint) destImage->Border) {<br>
>        _mesa_error(ctx, GL_INVALID_VALUE, "%s%dD(xoffset)",<br>
> -                  function, dims);<br>
> +                  func, dims);<br>
>        return GL_TRUE;<br>
>     }<br>
><br>
>     if (xoffset + subWidth > (GLint) destImage->Width) {<br>
>        _mesa_error(ctx, GL_INVALID_VALUE, "%s%dD(xoffset+width)",<br>
> -                  function, dims);<br>
> +                  func, dims);<br>
>        return GL_TRUE;<br>
>     }<br>
><br>
> @@ -1570,28 +1569,33 @@ error_check_subtexture_dimensions(struct gl_context *ctx,<br>
>        GLint yBorder = (target == GL_TEXTURE_1D_ARRAY) ? 0 : destImage->Border;<br>
>        if (yoffset < -yBorder) {<br>
>           _mesa_error(ctx, GL_INVALID_VALUE, "%s%dD(yoffset)",<br>
> -                     function, dims);<br>
> +                     func, dims);<br>
>           return GL_TRUE;<br>
>        }<br>
>        if (yoffset + subHeight > (GLint) destImage->Height) {<br>
>           _mesa_error(ctx, GL_INVALID_VALUE, "%s%dD(yoffset+height)",<br>
> -                     function, dims);<br>
> +                     func, dims);<br>
>           return GL_TRUE;<br>
>        }<br>
>     }<br>
><br>
>     /* check zoffset and depth */<br>
>     if (dims > 2) {<br>
> +      GLint depth;<br>
>        GLint zBorder = (target == GL_TEXTURE_2D_ARRAY ||<br>
>                         target == GL_TEXTURE_CUBE_MAP_ARRAY) ?<br>
>                           0 : destImage->Border;<br>
><br>
>        if (zoffset < -zBorder) {<br>
> -         _mesa_error(ctx, GL_INVALID_VALUE, "%s3D(zoffset)", function);<br>
> +         _mesa_error(ctx, GL_INVALID_VALUE, "%s3D(zoffset)", func);<br>
>           return GL_TRUE;<br>
>        }<br>
> -      if (zoffset + subDepth  > (GLint) destImage->Depth) {<br>
> -         _mesa_error(ctx, GL_INVALID_VALUE, "%s3D(zoffset+depth)", function);<br>
> +<br>
> +      depth = (GLint) destImage->Depth;<br>
> +      if (target == GL_TEXTURE_CUBE_MAP)<br>
> +         depth = 6;<br>
> +      if (zoffset + subDepth  > depth) {<br>
> +         _mesa_error(ctx, GL_INVALID_VALUE, "%s3D(zoffset+depth)", func);<br>
>           return GL_TRUE;<br>
>        }<br>
>     }<br>
> @@ -1610,7 +1614,7 @@ error_check_subtexture_dimensions(struct gl_context *ctx,<br>
>        if ((xoffset % bw != 0) || (yoffset % bh != 0)) {<br>
>           _mesa_error(ctx, GL_INVALID_OPERATION,<br>
>                       "%s%dD(xoffset = %d, yoffset = %d)",<br>
> -                     function, dims, xoffset, yoffset);<br>
> +                     func, dims, xoffset, yoffset);<br>
>           return GL_TRUE;<br>
>        }<br>
><br>
> @@ -1622,14 +1626,14 @@ error_check_subtexture_dimensions(struct gl_context *ctx,<br>
>        if ((subWidth % bw != 0) &&<br>
>            (xoffset + subWidth != (GLint) destImage->Width)) {<br>
>           _mesa_error(ctx, GL_INVALID_OPERATION,<br>
> -                     "%s%dD(width = %d)", function, dims, subWidth);<br>
> +                     "%s%dD(width = %d)", func, dims, subWidth);<br>
>           return GL_TRUE;<br>
>        }<br>
><br>
>        if ((subHeight % bh != 0) &&<br>
>            (yoffset + subHeight != (GLint) destImage->Height)) {<br>
>           _mesa_error(ctx, GL_INVALID_OPERATION,<br>
> -                     "%s%dD(height = %d)", function, dims, subHeight);<br>
> +                     "%s%dD(height = %d)", func, dims, subHeight);<br>
>           return GL_TRUE;<br>
>        }<br>
>     }<br>
> @@ -1808,7 +1812,8 @@ legal_teximage_target(struct gl_context *ctx, GLuint dims, GLenum target)<br>
>   * proxy targets are not supported.<br>
>   */<br>
>  static GLboolean<br>
> -legal_texsubimage_target(struct gl_context *ctx, GLuint dims, GLenum target)<br>
> +legal_texsubimage_target(struct gl_context *ctx, GLuint dims, GLenum target,<br>
> +                         bool dsa)<br>
>  {<br>
>     switch (dims) {<br>
>     case 1:<br>
> @@ -1842,6 +1847,13 @@ legal_texsubimage_target(struct gl_context *ctx, GLuint dims, GLenum target)<br>
>        case GL_TEXTURE_CUBE_MAP_ARRAY:<br>
>        case GL_PROXY_TEXTURE_CUBE_MAP_ARRAY:<br>
>           return ctx->Extensions.ARB_texture_cube_map_array;<br>
> +<br>
> +      /* Table 8.15 of the OpenGL 4.5 core profile spec<br>
> +       * (20141030) says that TEXTURE_CUBE_MAP is valid for TextureSubImage3D<br>
> +       * and CopyTextureSubImage3D.<br>
> +       */<br>
> +      case GL_TEXTURE_CUBE_MAP:<br>
> +         return dsa;<br>
>        default:<br>
>           return GL_FALSE;<br>
>        }<br>
> @@ -2350,25 +2362,34 @@ error:<br>
>   */<br>
>  static GLboolean<br>
>  texsubimage_error_check(struct gl_context *ctx, GLuint dimensions,<br>
> +                        struct gl_texture_object *texObj,<br>
>                          GLenum target, GLint level,<br>
>                          GLint xoffset, GLint yoffset, GLint zoffset,<br>
>                          GLint width, GLint height, GLint depth,<br>
> -                        GLenum format, GLenum type)<br>
> +                        GLenum format, GLenum type, bool dsa)<br>
>  {<br>
> -   struct gl_texture_object *texObj;<br>
>     struct gl_texture_image *texImage;<br>
>     GLenum err;<br>
><br>
> +   if (!texObj) {<br>
> +      /* must be out of memory */<br>
> +      _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTex%sSubImage%dD()",<br>
> +                  dsa ? "ture" : "", dimensions);<br>
> +      return GL_TRUE;<br>
> +   }<br>
> +<br>
>     /* check target (proxies not allowed) */<br>
> -   if (!legal_texsubimage_target(ctx, dimensions, target)) {<br>
> -      _mesa_error(ctx, GL_INVALID_ENUM, "glTexSubImage%uD(target=%s)",<br>
> +   if (!legal_texsubimage_target(ctx, dimensions, target, dsa)) {<br>
> +      _mesa_error(ctx, GL_INVALID_ENUM, "glTex%sSubImage%uD(target=%s)",<br>
> +                  dsa ? "ture" : "",<br>
>                    dimensions, _mesa_lookup_enum_by_nr(target));<br>
>        return GL_TRUE;<br>
>     }<br>
><br>
>     /* level check */<br>
>     if (level < 0 || level >= _mesa_max_texture_levels(ctx, target)) {<br>
> -      _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage%uD(level=%d)",<br>
> +      _mesa_error(ctx, GL_INVALID_VALUE, "glTex%sSubImage%uD(level=%d)",<br>
> +                  dsa ? "ture" : "",<br>
>                    dimensions, level);<br>
>        return GL_TRUE;<br>
>     }<br>
> @@ -2382,7 +2403,8 @@ texsubimage_error_check(struct gl_context *ctx, GLuint dimensions,<br>
>        err = _mesa_es_error_check_format_and_type(format, type, dimensions);<br>
>        if (err != GL_NO_ERROR) {<br>
>           _mesa_error(ctx, err,<br>
> -                     "glTexSubImage%dD(format = %s, type = %s)",<br>
> +                     "glTex%sSubImage%dD(format = %s, type = %s)",<br>
> +                     dsa ? "ture" : "",<br>
>                       dimensions,<br>
>                       _mesa_lookup_enum_by_nr(format),<br>
>                       _mesa_lookup_enum_by_nr(type));<br>
> @@ -2393,38 +2415,35 @@ texsubimage_error_check(struct gl_context *ctx, GLuint dimensions,<br>
>     err = _mesa_error_check_format_and_type(ctx, format, type);<br>
>     if (err != GL_NO_ERROR) {<br>
>        _mesa_error(ctx, err,<br>
> -                  "glTexSubImage%dD(incompatible format = %s, type = %s)",<br>
> +                  "glTex%sSubImage%dD(incompatible format = %s, type = %s)",<br>
> +                  dsa ? "ture" : "",<br>
>                    dimensions, _mesa_lookup_enum_by_nr(format),<br>
>                    _mesa_lookup_enum_by_nr(type));<br>
>        return GL_TRUE;<br>
>     }<br>
><br>
> -   /* Get dest texture object / image pointers */<br>
> -   texObj = _mesa_get_current_tex_object(ctx, target);<br>
> -   if (!texObj) {<br>
> -      /* must be out of memory */<br>
> -      _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage%dD()", dimensions);<br>
> -      return GL_TRUE;<br>
> -   }<br>
> -<br>
>     texImage = _mesa_select_tex_image(ctx, texObj, target, level);<br>
>     if (!texImage) {<br>
>        /* non-existant texture level */<br>
>        _mesa_error(ctx, GL_INVALID_OPERATION,<br>
> -                  "glTexSubImage%dD(invalid texture image)", dimensions);<br>
> +                  "glTex%sSubImage%dD(invalid texture image)",<br>
> +                  dsa ? "ture" : "", dimensions);<br>
>        return GL_TRUE;<br>
>     }<br>
><br>
> -   if (error_check_subtexture_dimensions(ctx, "glTexSubImage", dimensions,<br>
> +   if (error_check_subtexture_dimensions(ctx, dimensions,<br>
>                                           texImage, xoffset, yoffset, 0,<br>
> -                                         width, height, 1)) {<br>
> +                                         width, height, 1,<br>
> +                                         dsa ? "glTextureSubImage" :<br>
> +                                         "glTexSubImage")) {<br>
>        return GL_TRUE;<br>
>     }<br>
><br>
>     if (_mesa_is_format_compressed(texImage->TexFormat)) {<br>
>        if (compressedteximage_only_format(ctx, texImage->InternalFormat)) {<br>
>           _mesa_error(ctx, GL_INVALID_OPERATION,<br>
> -               "glTexSubImage%dD(no compression for format)", dimensions);<br>
> +               "glTex%sSubImage%dD(no compression for format)",<br>
> +               dsa ? "ture" : "", dimensions);<br>
>           return GL_TRUE;<br>
>        }<br>
>     }<br>
> @@ -2434,8 +2453,8 @@ texsubimage_error_check(struct gl_context *ctx, GLuint dimensions,<br>
>        if (_mesa_is_format_integer_color(texImage->TexFormat) !=<br>
>            _mesa_is_enum_format_integer(format)) {<br>
>           _mesa_error(ctx, GL_INVALID_OPERATION,<br>
> -                     "glTexSubImage%dD(integer/non-integer format mismatch)",<br>
> -                     dimensions);<br>
> +                     "glTex%sSubImage%dD(integer/non-integer format mismatch)",<br>
> +                     dsa ? "ture" : "", dimensions);<br>
>           return GL_TRUE;<br>
>        }<br>
>     }<br>
> @@ -2473,7 +2492,7 @@ copytexture_error_check( struct gl_context *ctx, GLuint dimensions,<br>
>     GLenum rb_internal_format;<br>
><br>
>     /* check target */<br>
> -   if (!legal_texsubimage_target(ctx, dimensions, target)) {<br>
> +   if (!legal_texsubimage_target(ctx, dimensions, target, false)) {<br>
>        _mesa_error(ctx, GL_INVALID_ENUM, "glCopyTexImage%uD(target=%s)",<br>
>                    dimensions, _mesa_lookup_enum_by_nr(target));<br>
>        return GL_TRUE;<br>
> @@ -2717,6 +2736,7 @@ copytexsubimage_error_check(struct gl_context *ctx, GLuint dimensions,<br>
>     struct gl_texture_object *texObj;<br>
>     struct gl_texture_image *texImage;<br>
><br>
> +<br>
>     /* Check that the source buffer is complete */<br>
>     if (_mesa_is_user_fbo(ctx->ReadBuffer)) {<br>
>        if (ctx->ReadBuffer->_Status == 0) {<br>
> @@ -2737,8 +2757,8 @@ copytexsubimage_error_check(struct gl_context *ctx, GLuint dimensions,<br>
>     }<br>
><br>
>     /* check target (proxies not allowed) */<br>
> -   if (!legal_texsubimage_target(ctx, dimensions, target)) {<br>
> -      _mesa_error(ctx, GL_INVALID_ENUM, "glCopyTexSubImage%uD(target=%s)",<br>
> +   if (!legal_texsubimage_target(ctx, dimensions, target, false)) {<br>
> +      _mesa_error(ctx, GL_INVALID_ENUM, "glCopyTexImage%uD(target=%s)",<br>
>                    dimensions, _mesa_lookup_enum_by_nr(target));<br>
>        return GL_TRUE;<br>
>     }<br>
> @@ -2765,10 +2785,10 @@ copytexsubimage_error_check(struct gl_context *ctx, GLuint dimensions,<br>
>        return GL_TRUE;<br>
>     }<br>
><br>
> -   if (error_check_subtexture_dimensions(ctx, "glCopyTexSubImage",<br>
> -                                         dimensions, texImage,<br>
> +   if (error_check_subtexture_dimensions(ctx, dimensions, texImage,<br>
>                                           xoffset, yoffset, zoffset,<br>
> -                                         width, height, 1)) {<br>
> +                                         width, height, 1,<br>
> +                                         "glCopyTexSubImage")) {<br>
>        return GL_TRUE;<br>
>     }<br>
><br>
> @@ -2888,7 +2908,6 @@ static inline void<br>
>  check_gen_mipmap(struct gl_context *ctx, GLenum target,<br>
>                   struct gl_texture_object *texObj, GLint level)<br>
>  {<br>
> -   ASSERT(target != GL_TEXTURE_CUBE_MAP);<br>
>     if (texObj->GenerateMipmap &&<br>
>         level == texObj->BaseLevel &&<br>
>         level < texObj->MaxLevel) {<br>
> @@ -3377,32 +3396,26 @@ _mesa_EGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image)<br>
>  }<br>
><br>
><br>
> -<br>
>  /**<br>
> - * Implement all the glTexSubImage1/2/3D() functions.<br>
> + * Helper that implements the glTexSubImage1/2/3D()<br>
> + * and glTextureSubImage1/2/3D() functions.<br>
>   */<br>
> -static void<br>
> -texsubimage(struct gl_context *ctx, GLuint dims, GLenum target, GLint level,<br>
> -            GLint xoffset, GLint yoffset, GLint zoffset,<br>
> -            GLsizei width, GLsizei height, GLsizei depth,<br>
> -            GLenum format, GLenum type, const GLvoid *pixels )<br>
> +void<br>
> +_mesa_texture_sub_image(struct gl_context *ctx, GLuint dims,<br>
> +                        struct gl_texture_object *texObj,<br>
> +                        struct gl_texture_image *texImage,<br>
> +                        GLenum target, GLint level,<br>
> +                        GLint xoffset, GLint yoffset, GLint zoffset,<br>
> +                        GLsizei width, GLsizei height, GLsizei depth,<br>
> +                        GLenum format, GLenum type, const GLvoid *pixels,<br>
> +                        bool dsa)<br>
>  {<br>
> -   struct gl_texture_object *texObj;<br>
> -   struct gl_texture_image *texImage;<br>
> -<br>
>     FLUSH_VERTICES(ctx, 0);<br>
><br>
> -   if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))<br>
> -      _mesa_debug(ctx, "glTexSubImage%uD %s %d %d %d %d %d %d %d %s %s %p\n",<br>
> -                  dims,<br>
> -                  _mesa_lookup_enum_by_nr(target), level,<br>
> -                  xoffset, yoffset, zoffset, width, height, depth,<br>
> -                  _mesa_lookup_enum_by_nr(format),<br>
> -                  _mesa_lookup_enum_by_nr(type), pixels);<br>
> -<br>
>     /* check target (proxies not allowed) */<br>
> -   if (!legal_texsubimage_target(ctx, dims, target)) {<br>
> -      _mesa_error(ctx, GL_INVALID_ENUM, "glTexSubImage%uD(target=%s)",<br>
> +   if (!legal_texsubimage_target(ctx, dims, target, dsa)) {<br>
> +      _mesa_error(ctx, GL_INVALID_ENUM, "glTex%sSubImage%uD(target=%s)",<br>
> +                  dsa ? "ture" : "",<br>
>                    dims, _mesa_lookup_enum_by_nr(target));<br>
>        return;<br>
>     }<br>
> @@ -3410,17 +3423,8 @@ texsubimage(struct gl_context *ctx, GLuint dims, GLenum target, GLint level,<br>
>     if (ctx->NewState & _NEW_PIXEL)<br>
>        _mesa_update_state(ctx);<br>
><br>
> -   if (texsubimage_error_check(ctx, dims, target, level,<br>
> -                               xoffset, yoffset, zoffset,<br>
> -                               width, height, depth, format, type)) {<br>
> -      return;   /* error was detected */<br>
> -   }<br>
> -<br>
> -   texObj = _mesa_get_current_tex_object(ctx, target);<br>
> -<br>
>     _mesa_lock_texture(ctx, texObj);<br>
>     {<br>
> -      texImage = _mesa_select_tex_image(ctx, texObj, target, level);<br>
><br>
>        if (width > 0 && height > 0 && depth > 0) {<br>
>           /* If we have a border, offset=-1 is legal.  Bias by border width. */<br>
> @@ -3452,6 +3456,150 @@ texsubimage(struct gl_context *ctx, GLuint dims, GLenum target, GLint level,<br>
>     _mesa_unlock_texture(ctx, texObj);<br>
>  }<br>
><br>
> +/**<br>
> + * Implement all the glTexSubImage1/2/3D() functions.<br>
> + * Must split this out this way because of GL_TEXTURE_CUBE_MAP.<br>
> + */<br>
> +static void<br>
> +texsubimage(struct gl_context *ctx, GLuint dims, GLenum target, GLint level,<br>
> +            GLint xoffset, GLint yoffset, GLint zoffset,<br>
> +            GLsizei width, GLsizei height, GLsizei depth,<br>
> +            GLenum format, GLenum type, const GLvoid *pixels )<br>
> +{<br>
> +   struct gl_texture_object *texObj;<br>
> +   struct gl_texture_image *texImage;<br>
> +   texObj = _mesa_get_current_tex_object(ctx, target);<br>
> +   if (texsubimage_error_check(ctx, dims, texObj, target, level,<br>
> +                               xoffset, yoffset, zoffset,<br>
> +                               width, height, depth, format, type, false)) {<br>
> +      return;   /* error was detected */<br>
> +   }<br>
> +<br>
> +   texImage = _mesa_select_tex_image(ctx, texObj, target, level);<br>
> +   if (!texImage) {<br>
> +      /* non-existant texture level<br>
> +       *<br>
> +       * Why is this invalid operation and not invalid value?<br>
> +       * Maybe: Look at errors for CompressedTexSubImage*D.<br>
> +       * In the gl 4.5 spec section 8.7 Compressed Texture Images<br>
> +       * (30.10.2014):<br>
> +       * "An INVALID_OPERATION error is generated if xoffset, yoffset,<br>
> +       * or zoffset are not equal to zero, or if width, height, and<br>
> +       * depth do not match the corresponding dimensions of the texture<br>
> +       * level."<br>
> +       */<br>
</div></div>Use below format to provide spec reference. This is to keep it uniform<br>
 across Mesa.<br>
>From page xxx of OpenGL x.x spec:<br>
   ".................<br>
    .........." <br></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span>> +      _mesa_error(ctx, GL_INVALID_OPERATION,<br>
> +                  "glTexSubImage%uD(level)", dims);<br>
> +      return;<br>
> +   }<br>
</span>Above error check is not required. Isn't it already done in<br>
texsubimage_error_check()?<br></blockquote><div><br></div></div></div><div>This was already done in the error check, so this block was replaced with "/* texsubimage_error_check ensures that texImage is not NULL */." <br></div><div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div><br>
> +<br>
> +   if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))<br>
> +      _mesa_debug(ctx, "glTexSubImage%uD %s %d %d %d %d %d %d %d %s %s %p\n",<br>
> +                  dims,<br>
> +                  _mesa_lookup_enum_by_nr(target), level,<br>
> +                  xoffset, yoffset, zoffset, width, height, depth,<br>
> +                  _mesa_lookup_enum_by_nr(format),<br>
> +                  _mesa_lookup_enum_by_nr(type), pixels);<br>
> +<br>
> +   _mesa_texture_sub_image(ctx, dims, texObj, texImage, target, level,<br>
> +                           xoffset, yoffset, zoffset, width, height, depth,<br>
> +                           format, type, pixels, false);<br>
> +}<br>
> +<br>
> +<br>
> +/**<br>
> + * Implement all the glTextureSubImage1/2/3D() functions.<br>
> + * Must split this out this way because of GL_TEXTURE_CUBE_MAP.<br>
> + */<br>
> +static void<br>
> +texturesubimage(struct gl_context *ctx, GLuint dims,<br>
> +                GLuint texture, GLint level,<br>
> +                GLint xoffset, GLint yoffset, GLint zoffset,<br>
> +                GLsizei width, GLsizei height, GLsizei depth,<br>
> +                GLenum format, GLenum type, const GLvoid *pixels )<br>
> +{<br>
> +   struct gl_texture_object *texObj;<br>
> +   struct gl_texture_image *texImage;<br>
> +   int i;<br>
> +<br>
> +   /* Get the texture object by Name. */<br>
> +   texObj = _mesa_lookup_texture(ctx, texture);<br>
> +   if (!texObj) {<br>
> +      _mesa_error(ctx, GL_INVALID_OPERATION, "glTextureSubImage%uD(texture)",<br>
> +                  dims);<br>
> +      return;<br>
> +   }<br>
</div></div>I think same error check is needed in texsubimage() ?<br></blockquote></div></div><div>It's added in patch 38 in the form "if (!texObj)\n return;"  (The invalid operation error does not need to be thrown for texsubimage because it does not use the user's texture_name to look up the texture object in the hash table.)<br></div><span class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span>> +<br>
> +   if (texsubimage_error_check(ctx, dims, texObj, texObj->Target, level,<br>
> +                               xoffset, yoffset, zoffset,<br>
> +                               width, height, depth, format, type, true)) {<br>
> +      return;   /* error was detected */<br>
> +   }<br>
> +<br>
> +   if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))<br>
> +      _mesa_debug(ctx,<br>
> +                  "glTextureSubImage%uD %s %d %d %d %d %d %d %d %s %s %p\n",<br>
> +                  dims,<br>
> +                  _mesa_lookup_enum_by_nr(texObj->Target), level,<br>
> +                  xoffset, yoffset, zoffset, width, height, depth,<br>
> +                  _mesa_lookup_enum_by_nr(format),<br>
> +                  _mesa_lookup_enum_by_nr(type), pixels);<br>
> +<br>
> +<br>
> +   /* Must special case GL_TEXTURE_CUBE_MAP. */<br>
</span>Must handle special case ...?<br></blockquote></span><div>Fixed <br></div><div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div>> +   if (texObj->Target == GL_TEXTURE_CUBE_MAP) {<br>
> +<br>
> +      /* Error checking */<br>
> +      if (texObj->NumLayers < 6) {<br>
> +         /* Not enough image planes for a cube map.  The spec does not say<br>
> +          * what should happen in this case because the user has always<br>
> +          * specified each cube face separately (using<br>
> +          * GL_TEXTURE_CUBE_MAP_POSITIVE_X+i) in previous GL versions.<br>
> +          * This is addressed in Khronos Bug 13223.<br>
> +          */<br>
> +         _mesa_error(ctx, GL_INVALID_OPERATION,<br>
> +                     "glTextureSubImage%uD(insufficient cube map storage)",<br>
> +                     dims);<br>
> +         return;<br>
> +      }<br>
> +      for (i = 0; i < 6; ++i) { /* For each face. */<br>
> +         if (!texObj->Image[i][level]) {<br>
> +            /* Not enough image planes for a cube map.  The spec does not say<br>
> +             * what should happen in this case because the user has always<br>
> +             * specified each cube face separately (using<br>
> +             * GL_TEXTURE_CUBE_MAP_POSITIVE_X+i) in previous GL versions.<br>
> +             * This is addressed in Khronos Bug 13223.<br>
> +             */<br>
> +            _mesa_error(ctx, GL_INVALID_OPERATION,<br>
> +                        "glTextureSubImage%uD(insufficient cube map storage)",<br>
> +                        dims);<br>
> +            return;<br>
> +         }<br>
> +      }<br>
> +<br>
> +      /* Copy in each face. */<br>
> +      for (i = 0; i < 6; ++i) { /* For each face. */<br>
</div></div>Get rid of duplicate comment.<br></blockquote></div></div><div>Done. <br></div><div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div>> +         texImage = texObj->Image[i][level];<br>
> +         _mesa_texture_sub_image(ctx, 3, texObj, texImage, texObj->Target,<br>
> +                                 level, xoffset, yoffset, zoffset,<br>
> +                                 width, height, 1, format,<br>
> +                                 type, pixels, true);<br>
> +         pixels += _mesa_image_image_stride(&ctx->Unpack, width, height,<br>
> +                                            format, type);<br>
> +      }<br>
> +   }<br>
> +   else {<br>
> +      texImage = _mesa_select_tex_image(ctx, texObj, texObj->Target, level);<br>
> +      if (!texImage)<br>
> +         return;<br>
> +<br>
> +      _mesa_texture_sub_image(ctx, dims, texObj, texImage, texObj->Target,<br>
> +                              level, xoffset, yoffset, zoffset,<br>
> +                              width, height, depth, format,<br>
> +                              type, pixels, true);<br>
> +   }<br>
> +}<br>
> +<br>
><br>
>  void GLAPIENTRY<br>
>  _mesa_TexSubImage1D( GLenum target, GLint level,<br>
> @@ -3497,6 +3645,48 @@ _mesa_TexSubImage3D( GLenum target, GLint level,<br>
>                 format, type, pixels);<br>
>  }<br>
><br>
> +void GLAPIENTRY<br>
> +_mesa_TextureSubImage1D( GLuint texture, GLint level,<br>
> +                         GLint xoffset, GLsizei width,<br>
> +                         GLenum format, GLenum type,<br>
> +                         const GLvoid *pixels )<br>
> +{<br>
> +   GET_CURRENT_CONTEXT(ctx);<br>
> +   texturesubimage(ctx, 1, texture, level,<br>
> +                   xoffset, 0, 0,<br>
> +                   width, 1, 1,<br>
> +                   format, type, pixels);<br>
> +}<br>
> +<br>
> +<br>
> +void GLAPIENTRY<br>
> +_mesa_TextureSubImage2D( GLuint texture, GLint level,<br>
> +                         GLint xoffset, GLint yoffset,<br>
> +                         GLsizei width, GLsizei height,<br>
> +                         GLenum format, GLenum type,<br>
> +                         const GLvoid *pixels )<br>
> +{<br>
> +   GET_CURRENT_CONTEXT(ctx);<br>
> +   texturesubimage(ctx, 2, texture, level,<br>
> +                   xoffset, yoffset, 0,<br>
> +                   width, height, 1,<br>
> +                   format, type, pixels);<br>
> +}<br>
> +<br>
> +<br>
> +void GLAPIENTRY<br>
> +_mesa_TextureSubImage3D( GLuint texture, GLint level,<br>
> +                         GLint xoffset, GLint yoffset, GLint zoffset,<br>
> +                         GLsizei width, GLsizei height, GLsizei depth,<br>
> +                         GLenum format, GLenum type,<br>
> +                         const GLvoid *pixels )<br>
> +{<br>
> +   GET_CURRENT_CONTEXT(ctx);<br>
> +   texturesubimage(ctx, 3, texture, level,<br>
> +                   xoffset, yoffset, zoffset,<br>
> +                   width, height, depth,<br>
> +                   format, type, pixels);<br>
> +}<br>
><br>
><br>
>  /**<br>
> @@ -4202,9 +4392,10 @@ compressed_subtexture_error_check(struct gl_context *ctx, GLint dims,<br>
>        return GL_TRUE;<br>
>     }<br>
><br>
> -   if (error_check_subtexture_dimensions(ctx, "glCompressedTexSubImage", dims,<br>
> +   if (error_check_subtexture_dimensions(ctx, dims,<br>
>                                           texImage, xoffset, yoffset, zoffset,<br>
> -                                         width, height, depth)) {<br>
> +                                         width, height, depth,<br>
> +                                         "glCompressedTexSubImage")) {<br>
>        return GL_TRUE;<br>
>     }<br>
><br>
> diff --git a/src/mesa/main/teximage.h b/src/mesa/main/teximage.h<br>
> index b9da8ae..705410d 100644<br>
> --- a/src/mesa/main/teximage.h<br>
> +++ b/src/mesa/main/teximage.h<br>
> @@ -156,6 +156,15 @@ _mesa_legal_texture_base_format_for_target(struct gl_context *ctx,<br>
>                                             unsigned dimensions,<br>
>                                             const char *caller);<br>
><br>
> +extern void<br>
> +_mesa_texture_sub_image( struct gl_context *ctx, GLuint dims,<br>
> +                         struct gl_texture_object *texObj,<br>
> +                         struct gl_texture_image *texImage,<br>
> +                         GLenum target, GLint level,<br>
> +                         GLint xoffset, GLint yoffset, GLint zoffset,<br>
> +                         GLsizei width, GLsizei height, GLsizei depth,<br>
> +                         GLenum format, GLenum type, const GLvoid *pixels,<br>
> +                         bool dsa );<br>
>  /*@}*/<br>
><br>
><br>
> @@ -211,6 +220,27 @@ _mesa_TexSubImage3D( GLenum target, GLint level,<br>
>                       GLenum format, GLenum type,<br>
>                       const GLvoid *pixels );<br>
><br>
> +extern void GLAPIENTRY<br>
> +_mesa_TextureSubImage1D( GLuint texture, GLint level, GLint xoffset,<br>
> +                         GLsizei width,<br>
> +                         GLenum format, GLenum type,<br>
> +                         const GLvoid *pixels );<br>
> +<br>
> +<br>
> +extern void GLAPIENTRY<br>
> +_mesa_TextureSubImage2D( GLuint texture, GLint level,<br>
> +                         GLint xoffset, GLint yoffset,<br>
> +                         GLsizei width, GLsizei height,<br>
> +                         GLenum format, GLenum type,<br>
> +                         const GLvoid *pixels );<br>
> +<br>
> +extern void GLAPIENTRY<br>
> +_mesa_TextureSubImage3D( GLuint texture, GLint level,<br>
> +                         GLint xoffset, GLint yoffset, GLint zoffset,<br>
> +                         GLsizei width, GLsizei height, GLsizei depth,<br>
> +                         GLenum format, GLenum type,<br>
> +                         const GLvoid *pixels );<br>
> +<br>
><br>
>  extern void GLAPIENTRY<br>
>  _mesa_CopyTexImage1D( GLenum target, GLint level, GLenum internalformat,<br>
> --<br>
> 2.1.0<br>
><br>
</div></div>> _______________________________________________<br>
> mesa-dev mailing list<br>
> <a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
> <a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</blockquote></div></div></div><br></div></div>
</blockquote></div><br></div>