From f6d433f4ff5182c51043315071326b2a799c9815 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Wed, 21 Oct 2015 21:23:17 -0700 Subject: [PATCH] Cleanup. --- src/renderer_mtl.mm | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/renderer_mtl.mm b/src/renderer_mtl.mm index a6d88a0c..6aa66200 100644 --- a/src/renderer_mtl.mm +++ b/src/renderer_mtl.mm @@ -332,7 +332,6 @@ namespace bgfx { namespace mtl , m_rtMsaa(false) , m_drawable(NULL) { - m_fbh.idx = invalidHandle; } ~RendererContextMtl() @@ -343,6 +342,10 @@ namespace bgfx { namespace mtl { BX_TRACE("Init."); + m_fbh.idx = invalidHandle; + memset(m_uniforms, 0, sizeof(m_uniforms) ); + memset(&m_resolution, 0, sizeof(m_resolution) ); + if (NULL != NSClassFromString(@"CAMetalLayer") ) { //on iOS we need the layer as CAmetalLayer @@ -397,8 +400,6 @@ namespace bgfx { namespace mtl m_uniformBufferVertexOffset = 0; m_uniformBufferFragmentOffset = 0; - memset(m_uniforms, 0, sizeof(m_uniforms) ); - g_caps.supported |= (0 | BGFX_CAPS_TEXTURE_COMPARE_LEQUAL | BGFX_CAPS_TEXTURE_3D @@ -886,10 +887,16 @@ namespace bgfx { namespace mtl //TODO: there should be a way to specify if backbuffer needs stencil/depth. //TODO: support msaa - if (NULL == m_backBufferDepth + if (NULL == m_backBufferDepth || width != m_backBufferDepth.width() - || height != m_backBufferDepth.height() ) + || height != m_backBufferDepth.height() + || m_resolution.m_width != _resolution.m_width + || m_resolution.m_height != _resolution.m_height + || m_resolution.m_flags != _resolution.m_flags) { + m_resolution = _resolution; + m_resolution.m_flags &= ~BGFX_RESET_FORCE; + m_textureDescriptor.textureType = MTLTextureType2D; m_textureDescriptor.pixelFormat = MTLPixelFormatDepth32Float_Stencil8; @@ -1220,6 +1227,8 @@ namespace bgfx { namespace mtl FrameBufferHandle m_fbh; bool m_rtMsaa; + Resolution m_resolution; + // descriptors RenderPipelineDescriptor m_renderPipelineDescriptor; DepthStencilDescriptor m_depthStencilDescriptor; @@ -1857,14 +1866,17 @@ namespace bgfx { namespace mtl MTLPixelFormat format = MTLPixelFormatInvalid; if (srgb) { - format = s_textureFormat[m_textureFormat].m_fmtSrgb; - BX_WARN(format != MTLPixelFormatInvalid, "sRGB not supported for texture format %d", m_textureFormat); + format = s_textureFormat[m_textureFormat].m_fmtSrgb; + BX_WARN(format != MTLPixelFormatInvalid + , "sRGB not supported for texture format %d" + , m_textureFormat + ); } if (format == MTLPixelFormatInvalid) { // not swizzled and not sRGB, or sRGB unsupported - format = s_textureFormat[m_textureFormat].m_fmt; + format = s_textureFormat[m_textureFormat].m_fmt; } desc.pixelFormat = format;