diff options
author | Timothy Arceri <[email protected]> | 2017-05-12 10:36:54 +1000 |
---|---|---|
committer | Timothy Arceri <[email protected]> | 2017-05-17 10:12:03 +1000 |
commit | d1033cd1eb11105730b423723bda5038787145c9 (patch) | |
tree | 9cc152a7c72b6c17a679c54820c41a0a698ae7ed /src/mesa | |
parent | 7cc190aae828de97b3669c37229f36ae558f2488 (diff) |
mesa: add 3D support to compressed_tex_sub_image() helper
Reviewed-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/main/teximage.c | 185 |
1 files changed, 66 insertions, 119 deletions
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 887740ad35c..2f9ff309428 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -4532,9 +4532,10 @@ 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, GLint yoffset, - GLsizei width, GLsizei height, - GLenum format, GLsizei imageSize, const GLvoid *data, - bool dsa, bool no_error, const char *caller) + GLint zoffset, GLsizei width, GLsizei height, + GLsizei depth, GLenum format, GLsizei imageSize, + const GLvoid *data, bool dsa, bool no_error, + const char *caller) { struct gl_texture_object *texObj; struct gl_texture_image *texImage; @@ -4567,18 +4568,53 @@ compressed_tex_sub_image(unsigned dim, GLenum target, GLuint texture, if (!no_error && compressed_subtexture_error_check(ctx, dim, texObj, target, level, - xoffset, yoffset, 0, width, height, - 1, format, + xoffset, yoffset, zoffset, width, + height, depth, format, imageSize, data, caller)) { return; } - texImage = _mesa_select_tex_image(texObj, target, level); - assert(texImage); + /* Must handle special case GL_TEXTURE_CUBE_MAP. */ + if (dim == 3 && dsa && texObj->Target == GL_TEXTURE_CUBE_MAP) { + const char *pixels = data; + GLint image_stride; + + /* Make sure the texture object is a proper cube. + * (See texturesubimage in teximage.c for details on why this check is + * performed.) + */ + if (!_mesa_cube_level_complete(texObj, level)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glCompressedTextureSubImage3D(cube map incomplete)"); + return; + } + + /* Copy in each face. */ + for (int i = 0; i < 6; ++i) { + texImage = texObj->Image[i][level]; + assert(texImage); + + compressed_texture_sub_image(ctx, 3, texObj, texImage, + texObj->Target, level, xoffset, yoffset, + zoffset, width, height, 1, format, + imageSize, pixels); + + /* Compressed images don't have a client format */ + image_stride = _mesa_format_image_size(texImage->TexFormat, + texImage->Width, + texImage->Height, 1); + + pixels += image_stride; + imageSize -= image_stride; + } + } else { + texImage = _mesa_select_tex_image(texObj, target, level); + assert(texImage); - compressed_texture_sub_image(ctx, dim, texObj, texImage, target, level, - xoffset, yoffset, 0, width, height, 1, format, - imageSize, data); + compressed_texture_sub_image(ctx, dim, texObj, texImage, target, level, + xoffset, yoffset, zoffset, width, height, + depth, format, imageSize, data); + } } @@ -4588,8 +4624,8 @@ _mesa_CompressedTexSubImage1D_no_error(GLenum target, GLint level, GLenum format, GLsizei imageSize, const GLvoid *data) { - compressed_tex_sub_image(1, target, 0, level, xoffset, 0, width, 1, format, - imageSize, data, false, true, + compressed_tex_sub_image(1, target, 0, level, xoffset, 0, 0, width, + 1, 1, format, imageSize, data, false, true, "glCompressedTexSubImage1D"); } @@ -4599,8 +4635,8 @@ _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, 0, width, 1, format, - imageSize, data, false, false, + compressed_tex_sub_image(1, target, 0, level, xoffset, 0, 0, width, 1, 1, + format, imageSize, data, false, false, "glCompressedTexSubImage1D"); } @@ -4611,7 +4647,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, 0, width, 1, + compressed_tex_sub_image(1, 0, texture, level, xoffset, 0, 0, width, 1, 1, format, imageSize, data, true, true, "glCompressedTextureSubImage1D"); } @@ -4622,7 +4658,7 @@ _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, 0, width, 1, + compressed_tex_sub_image(1, 0, texture, level, xoffset, 0, 0, width, 1, 1, format, imageSize, data, true, false, "glCompressedTextureSubImage1D"); } @@ -4634,8 +4670,8 @@ _mesa_CompressedTexSubImage2D_no_error(GLenum target, GLint level, GLenum format, GLsizei imageSize, const GLvoid *data) { - compressed_tex_sub_image(2, target, 0, level, xoffset, yoffset, width, - height, format, imageSize, data, false, true, + compressed_tex_sub_image(2, target, 0, level, xoffset, yoffset, 0, width, + height, 1, format, imageSize, data, false, true, "glCompressedTexSubImage2D"); } @@ -4646,8 +4682,8 @@ _mesa_CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLenum format, GLsizei imageSize, const GLvoid *data) { - compressed_tex_sub_image(2, target, 0, level, xoffset, yoffset, width, - height, format, imageSize, data, false, false, + compressed_tex_sub_image(2, target, 0, level, xoffset, yoffset, 0, width, + height, 1, format, imageSize, data, false, false, "glCompressedTexSubImage2D"); } @@ -4659,8 +4695,8 @@ _mesa_CompressedTextureSubImage2D_no_error(GLuint texture, GLint level, GLenum format, GLsizei imageSize, const GLvoid *data) { - compressed_tex_sub_image(2, 0, texture, level, xoffset, yoffset, width, - height, format, imageSize, data, true, true, + compressed_tex_sub_image(2, 0, texture, level, xoffset, yoffset, 0, width, + height, 1, format, imageSize, data, true, true, "glCompressedTextureSubImage2D"); } @@ -4672,8 +4708,8 @@ _mesa_CompressedTextureSubImage2D(GLuint texture, GLint level, GLint xoffset, GLenum format, GLsizei imageSize, const GLvoid *data) { - compressed_tex_sub_image(2, 0, texture, level, xoffset, yoffset, width, - height, format, imageSize, data, true, false, + compressed_tex_sub_image(2, 0, texture, level, xoffset, yoffset, 0, width, + height, 1, format, imageSize, data, true, false, "glCompressedTextureSubImage2D"); } @@ -4683,35 +4719,9 @@ _mesa_CompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLsizei height, GLsizei depth, 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, 3, format, false, - "glCompressedTexSubImage3D")) { - return; - } - - texObj = _mesa_get_current_tex_object(ctx, target); - if (!texObj) - return; - - if (compressed_subtexture_error_check(ctx, 3, texObj, target, - level, xoffset, yoffset, zoffset, - width, height, depth, - format, imageSize, data, - "glCompressedTexSubImage3D")) { - return; - } - - - texImage = _mesa_select_tex_image(texObj, target, level); - assert(texImage); - - compressed_texture_sub_image(ctx, 3, texObj, texImage, target, level, - xoffset, yoffset, zoffset, width, height, - depth, format, imageSize, data); + compressed_tex_sub_image(3, target, 0, level, xoffset, yoffset, zoffset, + width, height, depth, format, imageSize, data, + false, false, "glCompressedTexSubImage3D"); } void GLAPIENTRY @@ -4721,72 +4731,9 @@ _mesa_CompressedTextureSubImage3D(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, - "glCompressedTextureSubImage3D"); - if (!texObj) - return; - - if (compressed_subtexture_target_check(ctx, texObj->Target, 3, format, true, - "glCompressedTextureSubImage3D")) { - return; - } - - if (compressed_subtexture_error_check(ctx, 3, texObj, texObj->Target, - level, xoffset, yoffset, zoffset, - width, height, depth, - format, imageSize, data, - "glCompressedTextureSubImage3D")) { - return; - } - - /* Must handle special case GL_TEXTURE_CUBE_MAP. */ - if (texObj->Target == GL_TEXTURE_CUBE_MAP) { - const char *pixels = data; - int i; - GLint image_stride; - - /* Make sure the texture object is a proper cube. - * (See texturesubimage in teximage.c for details on why this check is - * performed.) - */ - if (!_mesa_cube_level_complete(texObj, level)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glCompressedTextureSubImage3D(cube map incomplete)"); - return; - } - - /* Copy in each face. */ - for (i = 0; i < 6; ++i) { - texImage = texObj->Image[i][level]; - assert(texImage); - - compressed_texture_sub_image(ctx, 3, texObj, texImage, - texObj->Target, level, xoffset, yoffset, - zoffset, width, height, 1, format, - imageSize, pixels); - - /* Compressed images don't have a client format */ - image_stride = _mesa_format_image_size(texImage->TexFormat, - texImage->Width, - texImage->Height, 1); - - pixels += image_stride; - imageSize -= image_stride; - } - } - else { - texImage = _mesa_select_tex_image(texObj, texObj->Target, level); - assert(texImage); - - compressed_texture_sub_image(ctx, 3, texObj, texImage, texObj->Target, - level, xoffset, yoffset, zoffset, width, - height, depth, format, imageSize, data); - } + compressed_tex_sub_image(3, 0, texture, level, xoffset, yoffset, zoffset, + width, height, depth, format, imageSize, data, + true, false, "glCompressedTextureSubImage3D"); } static mesa_format |