}
}
+static bool
+error_check_subtexture_negative_dimensions(struct gl_context *ctx,
+ GLuint dims,
+ GLsizei subWidth,
+ GLsizei subHeight,
+ GLsizei subDepth,
+ const char *func)
+{
+ /* Check size */
+ if (subWidth < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "%s(width=%d)", func, subWidth);
+ return true;
+ }
+
+ if (dims > 1 && subHeight < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "%s(height=%d)", func, subHeight);
+ return true;
+ }
+
+ if (dims > 2 && subDepth < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "%s(depth=%d)", func, subDepth);
+ return true;
+ }
+
+ return false;
+}
/**
* Do error checking of xoffset, yoffset, zoffset, width, height and depth
const GLenum target = destImage->TexObject->Target;
GLuint bw, bh, bd;
- /* Check size */
- if (subWidth < 0) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "%s(width=%d)", func, subWidth);
- return GL_TRUE;
- }
-
- if (dims > 1 && subHeight < 0) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "%s(height=%d)", func, subHeight);
- return GL_TRUE;
- }
-
- if (dims > 2 && subDepth < 0) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "%s(depth=%d)", func, subDepth);
- return GL_TRUE;
- }
-
/* check xoffset and width */
if (xoffset < - (GLint) destImage->Border) {
_mesa_error(ctx, GL_INVALID_VALUE, "%s(xoffset)", func);
return GL_TRUE;
}
+ if (error_check_subtexture_negative_dimensions(ctx, dimensions,
+ width, height, depth,
+ callerName)) {
+ return GL_TRUE;
+ }
+
texImage = _mesa_select_tex_image(texObj, target, level);
if (!texImage) {
/* non-existant texture level */
return GL_TRUE;
}
+ if (error_check_subtexture_negative_dimensions(ctx, dimensions,
+ width, height, 1, caller)) {
+ return GL_TRUE;
+ }
+
if (error_check_subtexture_dimensions(ctx, dimensions, texImage,
xoffset, yoffset, zoffset,
width, height, 1, caller)) {
return GL_TRUE;
}
+ if (error_check_subtexture_negative_dimensions(ctx, dims,
+ width, height, depth,
+ callerName)) {
+ return GL_TRUE;
+ }
+
if (error_check_subtexture_dimensions(ctx, dims,
texImage, xoffset, yoffset, zoffset,
width, height, depth,