Commit ec60b3da authored by Anuj Phogat's avatar Anuj Phogat
Browse files

mesa: Handle 3d block sizes in getteximage error checks


Signed-off-by: Anuj Phogat's avatarAnuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Brian Paul's avatarBrian Paul <brianp@vmware.com>
parent 5713461a
...@@ -1037,9 +1037,9 @@ dimensions_error_check(struct gl_context *ctx, ...@@ -1037,9 +1037,9 @@ dimensions_error_check(struct gl_context *ctx,
/* Extra checks for compressed textures */ /* Extra checks for compressed textures */
{ {
GLuint bw, bh; GLuint bw, bh, bd;
_mesa_get_format_block_size(texImage->TexFormat, &bw, &bh); _mesa_get_format_block_size_3d(texImage->TexFormat, &bw, &bh, &bd);
if (bw > 1 || bh > 1) { if (bw > 1 || bh > 1 || bd > 1) {
/* offset must be multiple of block size */ /* offset must be multiple of block size */
if (xoffset % bw != 0) { if (xoffset % bw != 0) {
_mesa_error(ctx, GL_INVALID_VALUE, _mesa_error(ctx, GL_INVALID_VALUE,
...@@ -1054,7 +1054,13 @@ dimensions_error_check(struct gl_context *ctx, ...@@ -1054,7 +1054,13 @@ dimensions_error_check(struct gl_context *ctx,
} }
} }
/* The size must be a multiple of bw x bh, or we must be using a if (zoffset % bd != 0) {
_mesa_error(ctx, GL_INVALID_VALUE,
"%s(zoffset = %d)", caller, zoffset);
return true;
}
/* The size must be a multiple of bw x bh x bd, or we must be using a
* offset+size that exactly hits the edge of the image. * offset+size that exactly hits the edge of the image.
*/ */
if ((width % bw != 0) && if ((width % bw != 0) &&
...@@ -1070,6 +1076,13 @@ dimensions_error_check(struct gl_context *ctx, ...@@ -1070,6 +1076,13 @@ dimensions_error_check(struct gl_context *ctx,
"%s(height = %d)", caller, height); "%s(height = %d)", caller, height);
return true; return true;
} }
if ((depth % bd != 0) &&
(zoffset + depth != (GLint) texImage->Depth)) {
_mesa_error(ctx, GL_INVALID_VALUE,
"%s(depth = %d)", caller, depth);
return true;
}
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment