From 3d76a75d9ff5256ce19234bf110fa52b990135bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Tue, 4 Jul 2023 12:18:28 +0200 Subject: [PATCH] GPU: Metal: Make 32bit depth promotion backend side Doing the promotion on the internal GPU texture format created a bug in `draw::Texture::ensure_impl` where the texture would be constantly being recreated. --- source/blender/gpu/metal/mtl_texture.mm | 10 ---------- source/blender/gpu/metal/mtl_texture_util.mm | 5 ++--- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/source/blender/gpu/metal/mtl_texture.mm b/source/blender/gpu/metal/mtl_texture.mm index 36470493400..3767b0b30a2 100644 --- a/source/blender/gpu/metal/mtl_texture.mm +++ b/source/blender/gpu/metal/mtl_texture.mm @@ -1807,22 +1807,12 @@ uint gpu::MTLTexture::gl_bindcode_get() const bool gpu::MTLTexture::init_internal() { - if (format_ == GPU_DEPTH24_STENCIL8) { - /* Apple Silicon requires GPU_DEPTH32F_STENCIL8 instead of GPU_DEPTH24_STENCIL8. */ - format_ = GPU_DEPTH32F_STENCIL8; - } - this->prepare_internal(); return true; } bool gpu::MTLTexture::init_internal(GPUVertBuf *vbo) { - if (this->format_ == GPU_DEPTH24_STENCIL8) { - /* Apple Silicon requires GPU_DEPTH32F_STENCIL8 instead of GPU_DEPTH24_STENCIL8. */ - this->format_ = GPU_DEPTH32F_STENCIL8; - } - MTLPixelFormat mtl_format = gpu_texture_format_to_metal(this->format_); mtl_max_mips_ = 1; mipmaps_ = 0; diff --git a/source/blender/gpu/metal/mtl_texture_util.mm b/source/blender/gpu/metal/mtl_texture_util.mm index 3664ad04dc0..44469d94507 100644 --- a/source/blender/gpu/metal/mtl_texture_util.mm +++ b/source/blender/gpu/metal/mtl_texture_util.mm @@ -103,11 +103,10 @@ MTLPixelFormat gpu_texture_format_to_metal(eGPUTextureFormat tex_format) return MTLPixelFormatRGB10A2Uint; case GPU_R11F_G11F_B10F: return MTLPixelFormatRG11B10Float; + case GPU_DEPTH24_STENCIL8: + /* NOTE(fclem): DEPTH24_STENCIL8 not supported by Apple Silicon. Fallback to Depth32F8S. */ case GPU_DEPTH32F_STENCIL8: return MTLPixelFormatDepth32Float_Stencil8; - case GPU_DEPTH24_STENCIL8: - BLI_assert_msg(false, "GPU_DEPTH24_STENCIL8 not supported by Apple Silicon."); - return MTLPixelFormatDepth24Unorm_Stencil8; case GPU_SRGB8_A8: return MTLPixelFormatRGBA8Unorm_sRGB; /* Texture only formats. */