From 54c5ea9c13be9af13c16efec6147157a6c0a6455 Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Tue, 19 Dec 2023 19:29:06 +0100 Subject: [PATCH] texture-mipmap: Handle textures with width or height of 1 Calculating the mipmap width as half of the texture width leads to a mipmap width of zero for textures with width of 1 which leads to an early exit instead of a mipmap texture. Fixes: 16fa2100d ("shaped-texture: Stop using MetaTextureTower and use GL mipmapping instead") Part-of: --- src/compositor/meta-texture-mipmap.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/compositor/meta-texture-mipmap.c b/src/compositor/meta-texture-mipmap.c index 63802aff6..54873ccb9 100644 --- a/src/compositor/meta-texture-mipmap.c +++ b/src/compositor/meta-texture-mipmap.c @@ -151,8 +151,8 @@ ensure_mipmap_texture (MetaTextureMipmap *mipmap) * then just use the original texture instead of mipmap texture, which is * faster anyway. */ - width = meta_multi_texture_get_width (mipmap->base_texture) / 2; - height = meta_multi_texture_get_height (mipmap->base_texture) / 2; + width = meta_multi_texture_get_width (mipmap->base_texture); + height = meta_multi_texture_get_height (mipmap->base_texture); if (!width || !height) { @@ -160,6 +160,9 @@ ensure_mipmap_texture (MetaTextureMipmap *mipmap) return; } + width = MAX (width / 2, 1); + height = MAX (height / 2, 1); + if (!mipmap->mipmap_texture || meta_multi_texture_get_width (mipmap->mipmap_texture) != width || meta_multi_texture_get_height (mipmap->mipmap_texture) != height)