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.
This commit is contained in:
Clément Foucault
2023-07-04 12:18:28 +02:00
parent 445d71a577
commit 3d76a75d9f
2 changed files with 2 additions and 13 deletions

View File

@@ -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;

View File

@@ -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. */