rt(mtl): don't resize if the requested format differs from optimal format

This commit is contained in:
chyyran 2024-09-13 00:48:28 -04:00 committed by Ronny Chan
parent 856f69113d
commit 22b2118e97

View file

@ -74,7 +74,7 @@ impl OwnedTexture {
MTLTextureUsage::ShaderRead MTLTextureUsage::ShaderRead
| MTLTextureUsage::ShaderWrite | MTLTextureUsage::ShaderWrite
| MTLTextureUsage::RenderTarget | MTLTextureUsage::RenderTarget
| MTLTextureUsage::PixelFormatView, | MTLTextureUsage::PixelFormatView,
); );
descriptor descriptor
@ -104,9 +104,14 @@ impl OwnedTexture {
if self.size != size if self.size != size
|| (mipmap && self.max_miplevels == 1) || (mipmap && self.max_miplevels == 1)
|| (!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); std::mem::swap(self, &mut new);
} }
Ok(size) Ok(size)