MTL: Allow null fragment shader for depth only programs.

This commit is contained in:
Branimir Karadžić 2018-03-06 09:49:04 -08:00
parent 9422aec753
commit 6fe21f1019
1 changed files with 7 additions and 12 deletions

View File

@ -485,7 +485,7 @@ namespace bgfx { namespace mtl
reset(m_renderPipelineDescriptor); reset(m_renderPipelineDescriptor);
m_renderPipelineDescriptor.colorAttachments[0].pixelFormat = m_metalLayer.pixelFormat; 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_renderPipelineDescriptor.fragmentFunction = m_screenshotBlitProgram.m_fsh->m_function;
m_screenshotBlitRenderPipelineState = m_device.newRenderPipelineStateWithDescriptor(m_renderPipelineDescriptor); 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); RenderPipelineState pipelineState = program.getRenderPipelineState(state, 0, fbh, _blitter.m_vb->decl, 0);
rce.setRenderPipelineState(pipelineState); rce.setRenderPipelineState(pipelineState);
uint32_t vertexUniformBufferSize = program.m_vshConstantBufferSize; uint32_t vertexUniformBufferSize = program.m_vshConstantBufferSize;
uint32_t fragmentUniformBufferSize = program.m_fshConstantBufferSize; uint32_t fragmentUniformBufferSize = program.m_fshConstantBufferSize;
if (vertexUniformBufferSize ) if (vertexUniformBufferSize )
@ -1235,7 +1235,7 @@ namespace bgfx { namespace mtl
MTL_RELEASE(m_screenshotBlitRenderPipelineState) MTL_RELEASE(m_screenshotBlitRenderPipelineState)
reset(m_renderPipelineDescriptor); reset(m_renderPipelineDescriptor);
m_renderPipelineDescriptor.colorAttachments[0].pixelFormat = m_metalLayer.pixelFormat; 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_renderPipelineDescriptor.fragmentFunction = m_screenshotBlitProgram.m_fsh->m_function;
m_screenshotBlitRenderPipelineState = m_device.newRenderPipelineStateWithDescriptor(m_renderPipelineDescriptor); 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."); BX_CHECK(NULL != _vsh->m_function.m_obj, "Vertex shader doesn't exist.");
m_vsh = _vsh; m_vsh = _vsh;
m_fsh = _fsh;
if (NULL != _fsh)
{
BX_CHECK(NULL != _fsh->m_function.m_obj, "Fragment shader doesn't exist.");
m_fsh = _fsh;
}
// get attributes // get attributes
bx::memSet(m_attributes, 0xff, sizeof(m_attributes) ); bx::memSet(m_attributes, 0xff, sizeof(m_attributes) );
@ -2193,7 +2188,7 @@ namespace bgfx { namespace mtl
} }
pd.vertexFunction = m_vsh->m_function; 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) ) if (isValid(_declHandle) )
{ {
@ -3721,14 +3716,14 @@ namespace bgfx { namespace mtl
uint32_t vertexUniformBufferSize = program.m_vshConstantBufferSize; uint32_t vertexUniformBufferSize = program.m_vshConstantBufferSize;
uint32_t fragmentUniformBufferSize = program.m_fshConstantBufferSize; uint32_t fragmentUniformBufferSize = program.m_fshConstantBufferSize;
if (vertexUniformBufferSize) if (0 != vertexUniformBufferSize)
{ {
m_uniformBufferVertexOffset = BX_ALIGN_MASK(m_uniformBufferVertexOffset, program.m_vshConstantBufferAlignmentMask); m_uniformBufferVertexOffset = BX_ALIGN_MASK(m_uniformBufferVertexOffset, program.m_vshConstantBufferAlignmentMask);
rce.setVertexBuffer(m_uniformBuffer, m_uniformBufferVertexOffset, 0); rce.setVertexBuffer(m_uniformBuffer, m_uniformBufferVertexOffset, 0);
} }
m_uniformBufferFragmentOffset = m_uniformBufferVertexOffset + vertexUniformBufferSize; m_uniformBufferFragmentOffset = m_uniformBufferVertexOffset + vertexUniformBufferSize;
if (fragmentUniformBufferSize) if (0 != fragmentUniformBufferSize)
{ {
m_uniformBufferFragmentOffset = BX_ALIGN_MASK(m_uniformBufferFragmentOffset, program.m_fshConstantBufferAlignmentMask); m_uniformBufferFragmentOffset = BX_ALIGN_MASK(m_uniformBufferFragmentOffset, program.m_fshConstantBufferAlignmentMask);
rce.setFragmentBuffer(m_uniformBuffer, m_uniformBufferFragmentOffset, 0); rce.setFragmentBuffer(m_uniformBuffer, m_uniformBufferFragmentOffset, 0);