diff options
author | Brian Paul <[email protected]> | 2013-03-20 09:58:18 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2013-03-21 09:24:35 -0600 |
commit | 8bd5692a5dfb88e4a4831b32be7784a82886c225 (patch) | |
tree | ab0acff5135acd08c79cb5b6a337b9e37aeae885 /src | |
parent | a940c93aacd4efc3b5d5632011ba94c58b888604 (diff) |
meta: fix incorrect slice, r coordinate computation
The arithmetic to convert a 3D texture slice to an R coordinate was
incorrect. Found when MSVC warned of a divide by zero.
Note that we don't actually ever hit this path. We don't decompress
slices of 3D textures and we don't support 3D mipmap generation yet.
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/drivers/common/meta.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c index 1a1fd285957..8114550ba73 100644 --- a/src/mesa/drivers/common/meta.c +++ b/src/mesa/drivers/common/meta.c @@ -3118,6 +3118,7 @@ setup_texture_coords(GLenum faceTarget, GLint slice, GLint width, GLint height, + GLint depth, GLfloat coords0[3], GLfloat coords1[3], GLfloat coords2[3], @@ -3134,8 +3135,11 @@ setup_texture_coords(GLenum faceTarget, case GL_TEXTURE_2D: case GL_TEXTURE_3D: case GL_TEXTURE_2D_ARRAY: - if (faceTarget == GL_TEXTURE_3D) - r = 1.0F / slice; + if (faceTarget == GL_TEXTURE_3D) { + assert(slice < depth); + assert(depth >= 1); + r = (slice + 0.5f) / depth; + } else if (faceTarget == GL_TEXTURE_2D_ARRAY) r = slice; else @@ -3574,7 +3578,7 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target, /* Setup texture coordinates */ setup_texture_coords(faceTarget, slice, - 0, 0, /* width, height never used here */ + 0, 0, 1, /* width, height never used here */ verts[0].tex, verts[1].tex, verts[2].tex, @@ -3840,6 +3844,7 @@ decompress_texture_image(struct gl_context *ctx, struct gl_texture_object *texObj = texImage->TexObject; const GLint width = texImage->Width; const GLint height = texImage->Height; + const GLint depth = texImage->Height; const GLenum target = texObj->Target; GLenum faceTarget; struct vertex { @@ -3935,7 +3940,7 @@ decompress_texture_image(struct gl_context *ctx, _mesa_BindSampler(ctx->Texture.CurrentUnit, decompress->Sampler); } - setup_texture_coords(faceTarget, slice, width, height, + setup_texture_coords(faceTarget, slice, width, height, depth, verts[0].tex, verts[1].tex, verts[2].tex, |