From 6fe21f101908bd44a7120861cfd00214487155ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Tue, 6 Mar 2018 09:49:04 -0800 Subject: [PATCH] MTL: Allow null fragment shader for depth only programs. --- src/renderer_mtl.mm | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/renderer_mtl.mm b/src/renderer_mtl.mm index 9977a5b3e..4bba38282 100644 --- a/src/renderer_mtl.mm +++ b/src/renderer_mtl.mm @@ -485,7 +485,7 @@ namespace bgfx { namespace mtl reset(m_renderPipelineDescriptor); m_renderPipelineDescriptor.colorAttachments[0].pixelFormat = m_metalLayer.pixelFormat; - m_renderPipelineDescriptor.vertexFunction = m_screenshotBlitProgram.m_vsh->m_function; + m_renderPipelineDescriptor.vertexFunction = m_screenshotBlitProgram.m_vsh->m_function; m_renderPipelineDescriptor.fragmentFunction = m_screenshotBlitProgram.m_fsh->m_function; m_screenshotBlitRenderPipelineState = m_device.newRenderPipelineStateWithDescriptor(m_renderPipelineDescriptor); @@ -1062,7 +1062,7 @@ namespace bgfx { namespace mtl RenderPipelineState pipelineState = program.getRenderPipelineState(state, 0, fbh, _blitter.m_vb->decl, 0); rce.setRenderPipelineState(pipelineState); - uint32_t vertexUniformBufferSize = program.m_vshConstantBufferSize; + uint32_t vertexUniformBufferSize = program.m_vshConstantBufferSize; uint32_t fragmentUniformBufferSize = program.m_fshConstantBufferSize; if (vertexUniformBufferSize ) @@ -1235,7 +1235,7 @@ namespace bgfx { namespace mtl MTL_RELEASE(m_screenshotBlitRenderPipelineState) reset(m_renderPipelineDescriptor); m_renderPipelineDescriptor.colorAttachments[0].pixelFormat = m_metalLayer.pixelFormat; - m_renderPipelineDescriptor.vertexFunction = m_screenshotBlitProgram.m_vsh->m_function; + m_renderPipelineDescriptor.vertexFunction = m_screenshotBlitProgram.m_vsh->m_function; m_renderPipelineDescriptor.fragmentFunction = m_screenshotBlitProgram.m_fsh->m_function; m_screenshotBlitRenderPipelineState = m_device.newRenderPipelineStateWithDescriptor(m_renderPipelineDescriptor); } @@ -1949,12 +1949,7 @@ namespace bgfx { namespace mtl { BX_CHECK(NULL != _vsh->m_function.m_obj, "Vertex shader doesn't exist."); m_vsh = _vsh; - - if (NULL != _fsh) - { - BX_CHECK(NULL != _fsh->m_function.m_obj, "Fragment shader doesn't exist."); - m_fsh = _fsh; - } + m_fsh = _fsh; // get attributes bx::memSet(m_attributes, 0xff, sizeof(m_attributes) ); @@ -2193,7 +2188,7 @@ namespace bgfx { namespace mtl } pd.vertexFunction = m_vsh->m_function; - pd.fragmentFunction = m_fsh->m_function; + pd.fragmentFunction = m_fsh != NULL ? m_fsh->m_function : NULL; if (isValid(_declHandle) ) { @@ -3721,14 +3716,14 @@ namespace bgfx { namespace mtl uint32_t vertexUniformBufferSize = program.m_vshConstantBufferSize; uint32_t fragmentUniformBufferSize = program.m_fshConstantBufferSize; - if (vertexUniformBufferSize) + if (0 != vertexUniformBufferSize) { m_uniformBufferVertexOffset = BX_ALIGN_MASK(m_uniformBufferVertexOffset, program.m_vshConstantBufferAlignmentMask); rce.setVertexBuffer(m_uniformBuffer, m_uniformBufferVertexOffset, 0); } m_uniformBufferFragmentOffset = m_uniformBufferVertexOffset + vertexUniformBufferSize; - if (fragmentUniformBufferSize) + if (0 != fragmentUniformBufferSize) { m_uniformBufferFragmentOffset = BX_ALIGN_MASK(m_uniformBufferFragmentOffset, program.m_fshConstantBufferAlignmentMask); rce.setFragmentBuffer(m_uniformBuffer, m_uniformBufferFragmentOffset, 0);