summaryrefslogtreecommitdiff
path: root/src/mesa
diff options
context:
space:
mode:
authorWill Dyson <will.dyson@gmail.com>2010-05-25 01:10:20 -0400
committerAlex Deucher <alexdeucher@gmail.com>2010-05-26 18:17:28 -0400
commita9ee95651131e27d5acf3d10909b5b7e5c8d3e92 (patch)
tree726a794471697d3bdad2887dc7c88237105bdf50 /src/mesa
parentf49da110a81cc964100efa6a09e0fcdc7a35a935 (diff)
Fix image_matches_texture_obj() MaxLevel check
When generating or uploading a new (higher) mipmap level for an image, we can need to allocate a miptree for a level greater than texObj->MaxLevel. Signed-off-by: Maciej Cencora <m.cencora@gmail.com> Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_texture.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/mesa/drivers/dri/radeon/radeon_texture.c b/src/mesa/drivers/dri/radeon/radeon_texture.c
index 2b655fbd95..5cb33a4751 100644
--- a/src/mesa/drivers/dri/radeon/radeon_texture.c
+++ b/src/mesa/drivers/dri/radeon/radeon_texture.c
@@ -588,7 +588,12 @@ static int image_matches_texture_obj(struct gl_texture_object *texObj,
if (!baseImage)
return 0;
- if (level < texObj->BaseLevel || level > texObj->MaxLevel)
+ /* Check image level against object BaseLevel, but not MaxLevel. MaxLevel is not
+ * the highest level that can be assigned to the miptree.
+ */
+ const unsigned maxLevel = texObj->BaseLevel + baseImage->MaxLog2;
+ if (level < texObj->BaseLevel || level > maxLevel
+ || level > RADEON_MIPTREE_MAX_TEXTURE_LEVELS)
return 0;
const unsigned levelDiff = level - texObj->BaseLevel;
@@ -610,9 +615,7 @@ static void teximage_assign_miptree(radeonContextPtr rmesa,
radeonTexObj *t = radeon_tex_obj(texObj);
radeon_texture_image* image = get_radeon_texture_image(texImage);
- /* Since miptree holds only images for levels <BaseLevel..MaxLevel>
- * don't allocate the miptree if the teximage won't fit.
- */
+ /* check image for dimension and level compatibility with texture */
if (!image_matches_texture_obj(texObj, texImage, level))
return;