Browse Source

metal: fix a crash when the window has no depth or stencil.

Sasha Szpakowski 10 months ago
parent
commit
a16db4fb72
1 changed files with 4 additions and 1 deletions
  1. 4 1
      src/modules/graphics/metal/Graphics.mm

+ 4 - 1
src/modules/graphics/metal/Graphics.mm

@@ -696,7 +696,10 @@ id<MTLRenderCommandEncoder> Graphics::useRenderEncoder()
 
 
 			auto &key = lastRenderPipelineKey;
 			auto &key = lastRenderPipelineKey;
 			key.colorRenderTargetFormats = isGammaCorrect() ? PIXELFORMAT_BGRA8_sRGB : PIXELFORMAT_BGRA8_UNORM;
 			key.colorRenderTargetFormats = isGammaCorrect() ? PIXELFORMAT_BGRA8_sRGB : PIXELFORMAT_BGRA8_UNORM;
-			key.depthStencilFormat = backbufferDepthStencil->getPixelFormat();
+			if (backbufferDepthStencil.get())
+				key.depthStencilFormat = backbufferDepthStencil->getPixelFormat();
+			else
+				key.depthStencilFormat = PIXELFORMAT_UNKNOWN;
 			key.msaa = backbufferMSAA ? (uint8) backbufferMSAA->getMSAA() : 1;
 			key.msaa = backbufferMSAA ? (uint8) backbufferMSAA->getMSAA() : 1;
 		}
 		}