From 22b2118e97e1bfccb072072b5e5faebc9179de90 Mon Sep 17 00:00:00 2001 From: chyyran Date: Fri, 13 Sep 2024 00:48:28 -0400 Subject: [PATCH] rt(mtl): don't resize if the requested format differs from optimal format --- librashader-runtime-mtl/src/texture.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/librashader-runtime-mtl/src/texture.rs b/librashader-runtime-mtl/src/texture.rs index abad665..ad4d853 100644 --- a/librashader-runtime-mtl/src/texture.rs +++ b/librashader-runtime-mtl/src/texture.rs @@ -74,7 +74,7 @@ impl OwnedTexture { MTLTextureUsage::ShaderRead | MTLTextureUsage::ShaderWrite | MTLTextureUsage::RenderTarget - | MTLTextureUsage::PixelFormatView, + | MTLTextureUsage::PixelFormatView, ); descriptor @@ -104,9 +104,14 @@ impl OwnedTexture { if self.size != size || (mipmap && self.max_miplevels == 1) || (!mipmap && self.max_miplevels != 1) - || format != select_optimal_pixel_format(format) + || self.texture.pixelFormat() != select_optimal_pixel_format(format) { - let mut new = OwnedTexture::new(device, size, self.max_miplevels, select_optimal_pixel_format(format))?; + let mut new = OwnedTexture::new( + device, + size, + self.max_miplevels, + select_optimal_pixel_format(format), + )?; std::mem::swap(self, &mut new); } Ok(size)