mesa: consolidate _mesa_CompressedTexSubImage[123]DARB() functions
This commit is contained in:
@@ -3554,10 +3554,14 @@ _mesa_CompressedTexImage3DARB(GLenum target, GLint level,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GLAPIENTRY
|
/**
|
||||||
_mesa_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset,
|
* Common helper for glCompressedTexSubImage1/2/3D().
|
||||||
GLsizei width, GLenum format,
|
*/
|
||||||
GLsizei imageSize, const GLvoid *data)
|
static void
|
||||||
|
compressed_tex_sub_image(GLuint dims, GLenum target, GLint level,
|
||||||
|
GLint xoffset, GLint yoffset, GLint zoffset,
|
||||||
|
GLsizei width, GLsizei height, GLsizei depth,
|
||||||
|
GLenum format, GLsizei imageSize, const GLvoid *data)
|
||||||
{
|
{
|
||||||
struct gl_texture_object *texObj;
|
struct gl_texture_object *texObj;
|
||||||
struct gl_texture_image *texImage;
|
struct gl_texture_image *texImage;
|
||||||
@@ -3565,12 +3569,12 @@ _mesa_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset,
|
|||||||
GET_CURRENT_CONTEXT(ctx);
|
GET_CURRENT_CONTEXT(ctx);
|
||||||
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
|
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
|
||||||
|
|
||||||
error = compressed_subtexture_error_check(ctx, 1, target, level,
|
error = compressed_subtexture_error_check(ctx, dims, target, level,
|
||||||
xoffset, 0, 0, /* pos */
|
xoffset, 0, 0, /* pos */
|
||||||
width, 1, 1, /* size */
|
width, height, depth, /* size */
|
||||||
format, imageSize);
|
format, imageSize);
|
||||||
if (error) {
|
if (error) {
|
||||||
_mesa_error(ctx, error, "glCompressedTexSubImage1D");
|
_mesa_error(ctx, error, "glCompressedTexSubImage%uD", dims);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3581,17 +3585,41 @@ _mesa_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset,
|
|||||||
texImage = _mesa_select_tex_image(ctx, texObj, target, level);
|
texImage = _mesa_select_tex_image(ctx, texObj, target, level);
|
||||||
assert(texImage);
|
assert(texImage);
|
||||||
|
|
||||||
if (compressed_subtexture_error_check2(ctx, 1, width, 1, 1,
|
if (compressed_subtexture_error_check2(ctx, dims, width, height, depth,
|
||||||
format, texImage)) {
|
format, texImage)) {
|
||||||
/* error was recorded */
|
/* error was recorded */
|
||||||
}
|
}
|
||||||
else if (width > 0) {
|
else if (width > 0 && height > 0 && depth > 0) {
|
||||||
|
switch (dims) {
|
||||||
|
case 1:
|
||||||
if (ctx->Driver.CompressedTexSubImage1D) {
|
if (ctx->Driver.CompressedTexSubImage1D) {
|
||||||
ctx->Driver.CompressedTexSubImage1D(ctx, target, level,
|
ctx->Driver.CompressedTexSubImage1D(ctx, target, level,
|
||||||
xoffset, width,
|
xoffset, width,
|
||||||
format, imageSize, data,
|
format, imageSize, data,
|
||||||
texObj, texImage);
|
texObj, texImage);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
if (ctx->Driver.CompressedTexSubImage2D) {
|
||||||
|
ctx->Driver.CompressedTexSubImage2D(ctx, target, level,
|
||||||
|
xoffset, yoffset,
|
||||||
|
width, height,
|
||||||
|
format, imageSize, data,
|
||||||
|
texObj, texImage);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
if (ctx->Driver.CompressedTexSubImage3D) {
|
||||||
|
ctx->Driver.CompressedTexSubImage3D(ctx, target, level,
|
||||||
|
xoffset, yoffset, zoffset,
|
||||||
|
width, height, depth,
|
||||||
|
format, imageSize, data,
|
||||||
|
texObj, texImage);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
check_gen_mipmap(ctx, target, texObj, level);
|
check_gen_mipmap(ctx, target, texObj, level);
|
||||||
|
|
||||||
@@ -3602,53 +3630,24 @@ _mesa_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GLAPIENTRY
|
||||||
|
_mesa_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset,
|
||||||
|
GLsizei width, GLenum format,
|
||||||
|
GLsizei imageSize, const GLvoid *data)
|
||||||
|
{
|
||||||
|
compressed_tex_sub_image(1, target, level, xoffset, 0, 0, width, 1, 1,
|
||||||
|
format, imageSize, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void GLAPIENTRY
|
void GLAPIENTRY
|
||||||
_mesa_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset,
|
_mesa_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset,
|
||||||
GLint yoffset, GLsizei width, GLsizei height,
|
GLint yoffset, GLsizei width, GLsizei height,
|
||||||
GLenum format, GLsizei imageSize,
|
GLenum format, GLsizei imageSize,
|
||||||
const GLvoid *data)
|
const GLvoid *data)
|
||||||
{
|
{
|
||||||
struct gl_texture_object *texObj;
|
compressed_tex_sub_image(2, target, level, xoffset, yoffset, 0,
|
||||||
struct gl_texture_image *texImage;
|
width, height, 1, format, imageSize, data);
|
||||||
GLenum error;
|
|
||||||
GET_CURRENT_CONTEXT(ctx);
|
|
||||||
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
|
|
||||||
|
|
||||||
error = compressed_subtexture_error_check(ctx, 2, target, level,
|
|
||||||
xoffset, yoffset, 0, /* pos */
|
|
||||||
width, height, 1, /* size */
|
|
||||||
format, imageSize);
|
|
||||||
if (error) {
|
|
||||||
/* XXX proxy target? */
|
|
||||||
_mesa_error(ctx, error, "glCompressedTexSubImage2D");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
texObj = get_current_tex_object(ctx, target);
|
|
||||||
|
|
||||||
_mesa_lock_texture(ctx, texObj);
|
|
||||||
{
|
|
||||||
texImage = _mesa_select_tex_image(ctx, texObj, target, level);
|
|
||||||
assert(texImage);
|
|
||||||
|
|
||||||
if (compressed_subtexture_error_check2(ctx, 2, width, height, 1,
|
|
||||||
format, texImage)) {
|
|
||||||
/* error was recorded */
|
|
||||||
}
|
|
||||||
else if (width > 0 && height > 0) {
|
|
||||||
if (ctx->Driver.CompressedTexSubImage2D) {
|
|
||||||
ctx->Driver.CompressedTexSubImage2D(ctx, target, level,
|
|
||||||
xoffset, yoffset, width, height,
|
|
||||||
format, imageSize, data,
|
|
||||||
texObj, texImage);
|
|
||||||
}
|
|
||||||
|
|
||||||
check_gen_mipmap(ctx, target, texObj, level);
|
|
||||||
|
|
||||||
ctx->NewState |= _NEW_TEXTURE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_mesa_unlock_texture(ctx, texObj);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -3658,47 +3657,8 @@ _mesa_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset,
|
|||||||
GLsizei height, GLsizei depth, GLenum format,
|
GLsizei height, GLsizei depth, GLenum format,
|
||||||
GLsizei imageSize, const GLvoid *data)
|
GLsizei imageSize, const GLvoid *data)
|
||||||
{
|
{
|
||||||
struct gl_texture_object *texObj;
|
compressed_tex_sub_image(3, target, level, xoffset, yoffset, zoffset,
|
||||||
struct gl_texture_image *texImage;
|
width, height, depth, format, imageSize, data);
|
||||||
GLenum error;
|
|
||||||
GET_CURRENT_CONTEXT(ctx);
|
|
||||||
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
|
|
||||||
|
|
||||||
error = compressed_subtexture_error_check(ctx, 3, target, level,
|
|
||||||
xoffset, yoffset, zoffset,/*pos*/
|
|
||||||
width, height, depth, /*size*/
|
|
||||||
format, imageSize);
|
|
||||||
if (error) {
|
|
||||||
_mesa_error(ctx, error, "glCompressedTexSubImage3D");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
texObj = get_current_tex_object(ctx, target);
|
|
||||||
|
|
||||||
_mesa_lock_texture(ctx, texObj);
|
|
||||||
{
|
|
||||||
texImage = _mesa_select_tex_image(ctx, texObj, target, level);
|
|
||||||
assert(texImage);
|
|
||||||
|
|
||||||
if (compressed_subtexture_error_check2(ctx, 3, width, height, depth,
|
|
||||||
format, texImage)) {
|
|
||||||
/* error was recorded */
|
|
||||||
}
|
|
||||||
else if (width > 0 && height > 0 && depth > 0) {
|
|
||||||
if (ctx->Driver.CompressedTexSubImage3D) {
|
|
||||||
ctx->Driver.CompressedTexSubImage3D(ctx, target, level,
|
|
||||||
xoffset, yoffset, zoffset,
|
|
||||||
width, height, depth,
|
|
||||||
format, imageSize, data,
|
|
||||||
texObj, texImage);
|
|
||||||
}
|
|
||||||
|
|
||||||
check_gen_mipmap(ctx, target, texObj, level);
|
|
||||||
|
|
||||||
ctx->NewState |= _NEW_TEXTURE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_mesa_unlock_texture(ctx, texObj);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user