summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2013-04-26 13:49:35 -0600
committerIan Romanick <[email protected]>2013-05-23 11:12:38 -0700
commitda3f29d8ec2380e2dcfd623581ad6125e1943fb6 (patch)
tree1265a5648e2e16068ede2acff4ca4c497e116aae /src/mesa/main
parent870c357847b5b79e1c7f81aa289990ca6bc30fe0 (diff)
mesa: fix the compressed TexSubImage size checking code
Before, we'd incorrectly generate an error if we we tried to replace a non-4x4 block near the edge of a NPOT compressed texture. For example, if the dest image was 15 texels wide and xoffset=12 and width=3 we'd incorrectly generate GL_INVALID_OPERATION. Verified with new tests added to piglit s3tc-errors test. Note: This is a candidate for the stable branches. Reviewed-by: Roland Scheidegger <[email protected]> (cherry picked from commit 49dda2d92f7563057601091e084d0fe154d00d25)
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/teximage.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index f95807c485d..e18b98bbd20 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -1536,14 +1536,20 @@ error_check_subtexture_dimensions(struct gl_context *ctx,
return GL_TRUE;
}
- /* size must be multiple of bw by bh or equal to whole texture size */
- if ((subWidth % bw != 0) && subWidth != (GLint) destImage->Width) {
+ /* The size must be a multiple of bw x bh, or we must be using a
+ * offset+size that exactly hits the edge of the image. This
+ * is important for small mipmap levels (1x1, 2x1, etc) and for
+ * NPOT textures.
+ */
+ if ((subWidth % bw != 0) &&
+ (xoffset + subWidth != (GLint) destImage->Width)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"%s%dD(width = %d)", function, dims, subWidth);
return GL_TRUE;
}
- if ((subHeight % bh != 0) && subHeight != (GLint) destImage->Height) {
+ if ((subHeight % bh != 0) &&
+ (yoffset + subHeight != (GLint) destImage->Height)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"%s%dD(height = %d)", function, dims, subHeight);
return GL_TRUE;