From 4cffc6e4ec64642a2ca144ada7a4cbdae58a5f3f Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Sun, 11 Sep 2016 19:28:54 -1000 Subject: [PATCH] Metal viewport restore fix --- lib/graphicsdev/Metal.mm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/graphicsdev/Metal.mm b/lib/graphicsdev/Metal.mm index 9904ef7..fc36456 100644 --- a/lib/graphicsdev/Metal.mm +++ b/lib/graphicsdev/Metal.mm @@ -239,7 +239,7 @@ class MetalTextureR : public ITextureR { m_width = width; m_height = height; - + @autoreleasepool { MTLTextureDescriptor* desc = @@ -719,6 +719,8 @@ struct MetalCommandQueue : IGraphicsCommandQueue m_enc = [m_cmdBuf renderCommandEncoderWithDescriptor:ctarget->m_passDesc]; [m_enc setFrontFacingWinding:MTLWindingCounterClockwise]; } + if (ctarget == m_boundTarget && (m_boundVp.width || m_boundVp.height)) + [m_enc setViewport:m_boundVp]; m_boundTarget = ctarget; } @@ -726,7 +728,7 @@ struct MetalCommandQueue : IGraphicsCommandQueue { _setRenderTarget(target, false, false); } - + MTLViewport m_boundVp = {}; void setViewport(const SWindowRect& rect, float znear, float zfar) { @@ -832,7 +834,7 @@ struct MetalCommandQueue : IGraphicsCommandQueue [blitEnc endEncoding]; m_enc = [m_cmdBuf renderCommandEncoderWithDescriptor:tex->m_passDesc]; [m_enc setFrontFacingWinding:MTLWindingCounterClockwise]; - + if (m_boundVp.width || m_boundVp.height) [m_enc setViewport:m_boundVp]; if (m_boundScissor.width || m_boundScissor.height)