Metal: Fixed msaa capture

This commit is contained in:
Attila Kocsis
2020-02-10 20:19:03 +01:00
committed by Бранимир Караџић
parent 248c7a88df
commit 6f168f0ca2

View File

@@ -540,6 +540,12 @@ namespace bgfx { namespace mtl
|| BX_ENABLED(BX_PLATFORM_OSX)
|| (BX_ENABLED(BX_PLATFORM_IOS) && iOSVersionEqualOrGreater("9.0.0") )
;
m_hasStoreActionStoreAndMultisampleResolve = false
|| (BX_ENABLED(BX_PLATFORM_OSX) && macOSVersionEqualOrGreater(10,12,0))
|| (BX_ENABLED(BX_PLATFORM_IOS) && iOSVersionEqualOrGreater("10.0.0") )
;
m_macOS11Runtime = true
&& BX_ENABLED(BX_PLATFORM_OSX)
&& macOSVersionEqualOrGreater(10,11,0)
@@ -1333,6 +1339,9 @@ namespace bgfx { namespace mtl
if (NULL != desc.texture)
{
desc.loadAction = MTLLoadActionLoad;
desc.storeAction = desc.resolveTexture == nil ?
MTLStoreActionStore :
MTLStoreActionMultisampleResolve;
}
}
@@ -1340,14 +1349,18 @@ namespace bgfx { namespace mtl
if (NULL != depthAttachment.texture)
{
depthAttachment.loadAction = MTLLoadActionLoad;
depthAttachment.storeAction = MTLStoreActionStore;
depthAttachment.storeAction = depthAttachment.resolveTexture == nil ?
MTLStoreActionStore :
MTLStoreActionMultisampleResolve;
}
RenderPassStencilAttachmentDescriptor stencilAttachment = renderPassDescriptor.stencilAttachment;
if (NULL != stencilAttachment.texture)
{
stencilAttachment.loadAction = MTLLoadActionLoad;
stencilAttachment.storeAction = MTLStoreActionStore;
stencilAttachment.storeAction = stencilAttachment.resolveTexture == nil ?
MTLStoreActionStore :
MTLStoreActionMultisampleResolve;
}
m_renderCommandEncoder = m_commandBuffer.renderCommandEncoderWithDescriptor(renderPassDescriptor);
@@ -2292,6 +2305,7 @@ namespace bgfx { namespace mtl
bool m_iOS9Runtime;
bool m_macOS11Runtime;
bool m_hasPixelFormatDepth32Float_Stencil8;
bool m_hasStoreActionStoreAndMultisampleResolve;
Buffer m_uniformBuffer;
Buffer m_uniformBuffers[MTL_MAX_FRAMES_IN_FLIGHT];
@@ -3891,7 +3905,17 @@ namespace bgfx { namespace mtl
desc.loadAction = MTLLoadActionLoad;
}
desc.storeAction = desc.texture.sampleCount > 1 ? MTLStoreActionMultisampleResolve : MTLStoreActionStore;
if ( NULL != m_capture &&
!isValid(fbh) &&
m_hasStoreActionStoreAndMultisampleResolve)
{
desc.storeAction = desc.texture.sampleCount > 1 ? MTLStoreActionStoreAndMultisampleResolve : MTLStoreActionStore;
}
else
{
desc.storeAction = desc.texture.sampleCount > 1 ? MTLStoreActionMultisampleResolve : MTLStoreActionStore;
}
}
}