--- a/src/backend/renderer/gles/mod.rs +++ b/src/backend/renderer/gles/mod.rs @@ -883,6 +883,8 @@ // why not store a `GlesTexture`? because the user might do so. // this is guaranteed a non-public internal type, so we are good. type CacheMap = HashMap, Arc>; + static SHM_FORMAT_CHANGE_LOGS: std::sync::atomic::AtomicUsize = + std::sync::atomic::AtomicUsize::new(0); let mut surface_lock = surface.as_ref().map(|surface_data| { surface_data @@ -937,7 +939,33 @@ surface_lock .as_ref() .and_then(|cache| cache.get(&id).cloned()) - .filter(|texture| texture.size == (width, height).into()) + .filter(|texture| { + let format_matches = + texture.format == Some(internal_format) && texture.has_alpha == has_alpha; + if !format_matches + && tracing::enabled!(tracing::Level::DEBUG) + && SHM_FORMAT_CHANGE_LOGS + .fetch_update( + std::sync::atomic::Ordering::Relaxed, + std::sync::atomic::Ordering::Relaxed, + |count| (count < 16).then_some(count + 1), + ) + .is_ok() + { + tracing::debug!( + old_width = texture.size.w, + old_height = texture.size.h, + new_width = width, + new_height = height, + old_internal_format = texture.format.unwrap_or(0), + new_internal_format = internal_format, + old_has_alpha = texture.has_alpha, + new_has_alpha = has_alpha, + "SHM texture cache format changed" + ); + } + texture.size == (width, height).into() && format_matches + }) .unwrap_or_else(|| { let mut tex = 0; unsafe { self.gl.GenTextures(1, &mut tex) };