Skip to content

Commit

Permalink
rt(mtl): don't resize if the requested format differs from optimal fo…
Browse files Browse the repository at this point in the history
…rmat
  • Loading branch information
chyyran committed Sep 13, 2024
1 parent 856f691 commit 22b2118
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions librashader-runtime-mtl/src/texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl OwnedTexture {
MTLTextureUsage::ShaderRead
| MTLTextureUsage::ShaderWrite
| MTLTextureUsage::RenderTarget
| MTLTextureUsage::PixelFormatView,
| MTLTextureUsage::PixelFormatView,
);

descriptor
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 22b2118

Please sign in to comment.