This commit is contained in:
Бранимир Караџић
2020-09-16 20:03:04 -07:00
parent cce003c99f
commit 9b7f950cd6

View File

@@ -508,15 +508,15 @@ namespace bgfx { namespace mtl
g_caps.limits.maxFBAttachments = uint8_t(bx::uint32_min(m_device.supportsFeatureSet( (MTLFeatureSet)1 /* MTLFeatureSet_iOS_GPUFamily2_v1 */) ? 8 : 4, BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS) );
if ( m_device.supportsFeatureSet( (MTLFeatureSet)4 /* MTLFeatureSet_iOS_GPUFamily3_v1 */ ))
{
g_caps.supported |= BGFX_CAPS_DRAW_INDIRECT;
}
g_caps.supported |= m_device.supportsFeatureSet( (MTLFeatureSet)4 /* MTLFeatureSet_iOS_GPUFamily3_v1 */)
? BGFX_CAPS_DRAW_INDIRECT
| 0
;
if ( m_device.supportsFeatureSet( (MTLFeatureSet)11 /* MTLFeatureSet_iOS_GPUFamily4_v1 */ ))
{
g_caps.supported |= BGFX_CAPS_TEXTURE_CUBE_ARRAY;
}
g_caps.supported |= m_device.supportsFeatureSet( (MTLFeatureSet)11 /* MTLFeatureSet_iOS_GPUFamily4_v1 */)
? BGFX_CAPS_TEXTURE_CUBE_ARRAY
| 0
;
}
else if (BX_ENABLED(BX_PLATFORM_OSX) )
{
@@ -524,10 +524,10 @@ namespace bgfx { namespace mtl
g_caps.limits.maxFBAttachments = 8;
g_caps.supported |= BGFX_CAPS_TEXTURE_CUBE_ARRAY;
if ( m_device.supportsFeatureSet( (MTLFeatureSet)10001 /* MTLFeatureSet_macOS_GPUFamily1_v2 */ ))
{
g_caps.supported |= BGFX_CAPS_DRAW_INDIRECT;
}
g_caps.supported |= m_device.supportsFeatureSet( (MTLFeatureSet)10001 /* MTLFeatureSet_macOS_GPUFamily1_v2 */)
? BGFX_CAPS_DRAW_INDIRECT
: 0
;
}
g_caps.limits.maxTextureLayers = 2048;
@@ -542,14 +542,15 @@ namespace bgfx { namespace mtl
;
m_hasStoreActionStoreAndMultisampleResolve = false
|| (BX_ENABLED(BX_PLATFORM_OSX) && macOSVersionEqualOrGreater(10,12,0))
|| (BX_ENABLED(BX_PLATFORM_IOS) && iOSVersionEqualOrGreater("10.0.0") )
;
|| (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)
&& macOSVersionEqualOrGreater(10, 11, 0)
;
m_iOS9Runtime = true
&& BX_ENABLED(BX_PLATFORM_IOS)
&& iOSVersionEqualOrGreater("9.0.0")
@@ -1220,7 +1221,7 @@ namespace bgfx { namespace mtl
{
MTL_RELEASE(frameBuffer.m_swapChain->m_drawableTexture);
if ( NULL != frameBuffer.m_swapChain->m_drawable)
if (NULL != frameBuffer.m_swapChain->m_drawable)
{
m_commandBuffer.presentDrawable(frameBuffer.m_swapChain->m_drawable);
MTL_RELEASE(frameBuffer.m_swapChain->m_drawable);
@@ -1593,23 +1594,21 @@ namespace bgfx { namespace mtl
for (uint32_t ii = 0; ii < numMrt; ++ii)
{
bx::memCopy( mrtClearColor[ii]
, rgba
, 16
);
bx::memCopy(mrtClearColor[ii], rgba, 16);
}
}
bx::memCopy( (uint8_t*)m_uniformBuffer.contents() + m_uniformBufferVertexOffset
, mrtClearDepth
, bx::uint32_min(vertexUniformBufferSize, sizeof(mrtClearDepth) )
);
bx::memCopy( (uint8_t*)m_uniformBuffer.contents() + m_uniformBufferFragmentOffset
, mrtClearColor
, bx::uint32_min(fragmentUniformBufferSize, sizeof(mrtClearColor) )
);
bx::memCopy(
(uint8_t*)m_uniformBuffer.contents() + m_uniformBufferVertexOffset
, mrtClearDepth
, bx::uint32_min(vertexUniformBufferSize, sizeof(mrtClearDepth) )
);
bx::memCopy(
(uint8_t*)m_uniformBuffer.contents() + m_uniformBufferFragmentOffset
, mrtClearColor
, bx::uint32_min(fragmentUniformBufferSize, sizeof(mrtClearColor) )
);
m_uniformBufferFragmentOffset += fragmentUniformBufferSize;
m_uniformBufferVertexOffset = m_uniformBufferFragmentOffset;
@@ -1624,18 +1623,28 @@ namespace bgfx { namespace mtl
void setAttachment(MTLRenderPassAttachmentDescriptor* _attachmentDescriptor, const Attachment& _at, uint8_t _textureType, bool _resolve)
{
_attachmentDescriptor.level = _at.mip;
if ( _textureType == TextureMtl::Texture3D )
_attachmentDescriptor.depthPlane = _at.layer;
else
_attachmentDescriptor.slice = _at.layer;
if ( _resolve )
if (TextureMtl::Texture3D == _textureType)
{
_attachmentDescriptor.depthPlane = _at.layer;
}
else
{
_attachmentDescriptor.slice = _at.layer;
}
if (_resolve)
{
_attachmentDescriptor.resolveLevel = _at.mip;
if ( _textureType == TextureMtl::Texture3D )
if (TextureMtl::Texture3D == _textureType)
{
_attachmentDescriptor.resolveDepthPlane = _at.layer;
}
else
{
_attachmentDescriptor.resolveSlice = _at.layer;
}
}
}
@@ -1813,8 +1822,8 @@ namespace bgfx { namespace mtl
if (arg.type == MTLArgumentTypeBuffer
&& 0 == bx::strCmp(utf8String(arg.name), SHADER_UNIFORM_NAME) )
{
BX_ASSERT( arg.index == 0, "Uniform buffer must be in the buffer slot 0.");
BX_ASSERT( MTLDataTypeStruct == arg.bufferDataType, "%s's type must be a struct",SHADER_UNIFORM_NAME );
BX_ASSERT(arg.index == 0, "Uniform buffer must be in the buffer slot 0.");
BX_ASSERT(MTLDataTypeStruct == arg.bufferDataType, "%s's type must be a struct",SHADER_UNIFORM_NAME );
if (MTLDataTypeStruct == arg.bufferDataType)
{
@@ -1883,7 +1892,9 @@ namespace bgfx { namespace mtl
}
}
}
else if ( arg.type == MTLArgumentTypeBuffer && arg.index > 0 && NULL != arg.bufferStructType)
else if (arg.type == MTLArgumentTypeBuffer
&& arg.index > 0
&& NULL != arg.bufferStructType)
{
const char* name = utf8String(arg.name);
@@ -2465,7 +2476,7 @@ namespace bgfx { namespace mtl
uint16_t regCount;
bx::read(&reader, regCount);
if (!isShaderVerLess(magic, 8) )
{
uint16_t texInfo = 0;
@@ -2561,7 +2572,7 @@ namespace bgfx { namespace mtl
{
m_vsh = NULL;
m_fsh = NULL;
if ( NULL != m_computePS )
if (NULL != m_computePS)
{
BX_DELETE(g_allocator, m_computePS);
m_computePS = NULL;
@@ -2572,8 +2583,8 @@ namespace bgfx { namespace mtl
{
BX_UNUSED(_stride);
m_size = _size;
m_flags = _flags;
m_size = _size;
m_flags = _flags;
m_vertex = _vertex;
if (NULL == _data)
@@ -2590,16 +2601,17 @@ namespace bgfx { namespace mtl
{
BlitCommandEncoder bce = s_renderMtl->getBlitCommandEncoder();
if (!m_vertex && !_discard)
if (!m_vertex
&& !_discard)
{
if ( m_dynamic == NULL )
if (NULL == m_dynamic)
{
m_dynamic = (uint8_t*)BX_ALLOC(g_allocator, m_size);
}
bx::memCopy(m_dynamic + _offset, _data, _size);
uint32_t start = _offset & 4;
uint32_t end = bx::strideAlign(_offset + _size, 4);
uint32_t end = bx::strideAlign(_offset + _size, 4);
Buffer temp = s_renderMtl->m_device.newBufferWithBytes(m_dynamic, end - start, 0);
bce.copyFromBuffer(temp, 0, m_ptr, start, end - start);
@@ -3933,9 +3945,9 @@ namespace bgfx { namespace mtl
desc.loadAction = MTLLoadActionLoad;
}
if ( NULL != m_capture &&
!isValid(fbh) &&
m_hasStoreActionStoreAndMultisampleResolve)
if (NULL != m_capture
&& !isValid(fbh)
&& m_hasStoreActionStoreAndMultisampleResolve)
{
desc.storeAction = desc.texture.sampleCount > 1 ? MTLStoreActionStoreAndMultisampleResolve : MTLStoreActionStore;