mesa: add 2D support to compressed_tex_sub_image() helper
authorTimothy Arceri <tarceri@itsqueeze.com>
Thu, 11 May 2017 07:14:06 +0000 (17:14 +1000)
committerTimothy Arceri <tarceri@itsqueeze.com>
Wed, 17 May 2017 00:12:03 +0000 (10:12 +1000)
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/mesa/main/teximage.c

index 722d8809d393255da93def88b19fd2451a9477b2..718af573be8b5500738c8b6df5aa735a92c76ac7 100644 (file)
@@ -4531,7 +4531,8 @@ compressed_texture_sub_image(struct gl_context *ctx, GLuint dims,
 
 static ALWAYS_INLINE void
 compressed_tex_sub_image(unsigned dim, GLenum target, GLuint texture,
-                         GLint level, GLint xoffset, GLsizei width,
+                         GLint level, GLint xoffset, GLint yoffset,
+                         GLsizei width, GLsizei height,
                          GLenum format, GLsizei imageSize, const GLvoid *data,
                          bool dsa, bool no_error, const char *caller)
 {
@@ -4566,7 +4567,8 @@ compressed_tex_sub_image(unsigned dim, GLenum target, GLuint texture,
 
    if (!no_error &&
        compressed_subtexture_error_check(ctx, dim, texObj, target, level,
-                                         xoffset, 0, 0, width, 1, 1, format,
+                                         xoffset, yoffset, 0, width, height,
+                                         1, format,
                                          imageSize, data, caller)) {
       return;
    }
@@ -4575,8 +4577,8 @@ compressed_tex_sub_image(unsigned dim, GLenum target, GLuint texture,
    assert(texImage);
 
    compressed_texture_sub_image(ctx, dim, texObj, texImage, target, level,
-                                xoffset, 0, 0, width, 1, 1, format, imageSize,
-                                data);
+                                xoffset, yoffset, 0, width, height, 1, format,
+                                imageSize, data);
 }
 
 
@@ -4586,7 +4588,7 @@ _mesa_CompressedTexSubImage1D_no_error(GLenum target, GLint level,
                                        GLenum format, GLsizei imageSize,
                                        const GLvoid *data)
 {
-   compressed_tex_sub_image(1, target, 0, level, xoffset, width, format,
+   compressed_tex_sub_image(1, target, 0, level, xoffset, 0, width, 1, format,
                             imageSize, data, false, true,
                             "glCompressedTexSubImage1D");
 }
@@ -4597,7 +4599,7 @@ _mesa_CompressedTexSubImage1D(GLenum target, GLint level, GLint xoffset,
                               GLsizei width, GLenum format,
                               GLsizei imageSize, const GLvoid *data)
 {
-   compressed_tex_sub_image(1, target, 0, level, xoffset, width, format,
+   compressed_tex_sub_image(1, target, 0, level, xoffset, 0, width, 1, format,
                             imageSize, data, false, false,
                             "glCompressedTexSubImage1D");
 }
@@ -4609,7 +4611,7 @@ _mesa_CompressedTextureSubImage1D_no_error(GLuint texture, GLint level,
                                            GLenum format, GLsizei imageSize,
                                            const GLvoid *data)
 {
-   compressed_tex_sub_image(1, 0, texture, level, xoffset, width,
+   compressed_tex_sub_image(1, 0, texture, level, xoffset, 0, width, 1,
                             format, imageSize, data, true, true,
                             "glCompressedTextureSubImage1D");
 }
@@ -4620,47 +4622,20 @@ _mesa_CompressedTextureSubImage1D(GLuint texture, GLint level, GLint xoffset,
                                   GLsizei width, GLenum format,
                                   GLsizei imageSize, const GLvoid *data)
 {
-   compressed_tex_sub_image(1, 0, texture, level, xoffset, width,
+   compressed_tex_sub_image(1, 0, texture, level, xoffset, 0, width, 1,
                             format, imageSize, data, true, false,
                             "glCompressedTextureSubImage1D");
 }
 
-
 void GLAPIENTRY
 _mesa_CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset,
                               GLint yoffset, GLsizei width, GLsizei height,
                               GLenum format, GLsizei imageSize,
                               const GLvoid *data)
 {
-   struct gl_texture_object *texObj;
-   struct gl_texture_image *texImage;
-
-   GET_CURRENT_CONTEXT(ctx);
-
-   if (compressed_subtexture_target_check(ctx, target, 2, format, false,
-                                          "glCompressedTexSubImage2D")) {
-      return;
-   }
-
-   texObj = _mesa_get_current_tex_object(ctx, target);
-   if (!texObj)
-      return;
-
-   if (compressed_subtexture_error_check(ctx, 2, texObj, target,
-                                         level, xoffset, yoffset, 0,
-                                         width, height, 1,
-                                         format, imageSize, data,
-                                         "glCompressedTexSubImage2D")) {
-      return;
-   }
-
-
-   texImage = _mesa_select_tex_image(texObj, target, level);
-   assert(texImage);
-
-   compressed_texture_sub_image(ctx, 2, texObj, texImage, target, level,
-                                xoffset, yoffset, 0, width, height, 1,
-                                format, imageSize, data);
+   compressed_tex_sub_image(2, target, 0, level, xoffset, yoffset, width,
+                            height, format, imageSize, data, false, false,
+                            "glCompressedTexSubImage2D");
 }
 
 void GLAPIENTRY
@@ -4670,35 +4645,9 @@ _mesa_CompressedTextureSubImage2D(GLuint texture, GLint level, GLint xoffset,
                                   GLenum format, GLsizei imageSize,
                                   const GLvoid *data)
 {
-   struct gl_texture_object *texObj;
-   struct gl_texture_image *texImage;
-
-   GET_CURRENT_CONTEXT(ctx);
-
-   texObj = _mesa_lookup_texture_err(ctx, texture,
-                                 "glCompressedTextureSubImage2D");
-   if (!texObj)
-      return;
-
-   if (compressed_subtexture_target_check(ctx, texObj->Target, 2, format, true,
-                                          "glCompressedTextureSubImage2D")) {
-      return;
-   }
-
-   if (compressed_subtexture_error_check(ctx, 2, texObj, texObj->Target,
-                                         level, xoffset, yoffset, 0,
-                                         width, height, 1,
-                                         format, imageSize, data,
-                                         "glCompressedTextureSubImage2D")) {
-      return;
-   }
-
-   texImage = _mesa_select_tex_image(texObj, texObj->Target, level);
-   assert(texImage);
-
-   compressed_texture_sub_image(ctx, 2, texObj, texImage, texObj->Target,
-                                level, xoffset, yoffset, 0, width, height, 1,
-                                format, imageSize, data);
+   compressed_tex_sub_image(2, 0, texture, level, xoffset, yoffset, width,
+                            height, format, imageSize, data, true, false,
+                            "glCompressedTextureSubImage2D");
 }
 
 void GLAPIENTRY