From 0fbe075570673ea578e3b764b309a326a17def39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=80=D0=B0=D0=BD=D0=B8=D0=BC=D0=B8=D1=80=20=D0=9A?= =?UTF-8?q?=D0=B0=D1=80=D0=B0=D1=9F=D0=B8=D1=9B?= Date: Sun, 2 Apr 2023 09:00:18 -0700 Subject: [PATCH] =?UTF-8?q?=EF=BB=BFFixed=20issue=20#3067.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer_mtl.mm | 67 ++++++++++++++++----------------------------- 1 file changed, 24 insertions(+), 43 deletions(-) diff --git a/src/renderer_mtl.mm b/src/renderer_mtl.mm index 7c90de2168..d3d0fdc769 100644 --- a/src/renderer_mtl.mm +++ b/src/renderer_mtl.mm @@ -553,19 +553,23 @@ bool init(const Init& _init) { if ([m_device respondsToSelector: @selector(supportsFamily:)]) { - if ([m_device supportsFamily: MTLGPUFamily(1004) /*MTLGPUFamilyApple4*/]) + if ([m_device supportsFamily: MTLGPUFamilyApple4]) { g_caps.vendorId = BGFX_PCI_ID_APPLE; - if ([m_device supportsFamily: MTLGPUFamily(1007) /*MTLGPUFamilyApple7*/]) + if ([m_device supportsFamily: MTLGPUFamilyApple8]) + { + g_caps.deviceId = 1008; + } + else if ([m_device supportsFamily: MTLGPUFamilyApple7]) { g_caps.deviceId = 1007; } - else if ([m_device supportsFamily: MTLGPUFamily(1006) /*MTLGPUFamilyApple6*/]) + else if ([m_device supportsFamily: MTLGPUFamilyApple6]) { g_caps.deviceId = 1006; } - else if ([m_device supportsFamily: MTLGPUFamily(1005) /*MTLGPUFamilyApple5*/]) + else if ([m_device supportsFamily: MTLGPUFamilyApple5]) { g_caps.deviceId = 1005; } @@ -622,8 +626,6 @@ bool init(const Init& _init) | BGFX_CAPS_TEXTURE_2D_ARRAY | BGFX_CAPS_TEXTURE_3D | BGFX_CAPS_TEXTURE_BLIT - | BGFX_CAPS_TEXTURE_COMPARE_ALL - | BGFX_CAPS_TEXTURE_COMPARE_LEQUAL | BGFX_CAPS_TEXTURE_READ_BACK | BGFX_CAPS_VERTEX_ATTRIB_HALF | BGFX_CAPS_VERTEX_ATTRIB_UINT10 @@ -632,40 +634,17 @@ bool init(const Init& _init) g_caps.supported |= m_device.supportsShaderBarycentricCoordinates() ? BGFX_CAPS_FRAGMENT_BARYCENTRIC : 0; - if (BX_ENABLED(BX_PLATFORM_IOS) ) - { - if (iOSVersionEqualOrGreater("9.0.0") ) - { - g_caps.limits.maxTextureSize = m_device.supportsFamily( (MTLGPUFamily)4 /* iOS_GPUFamily3_v1 */) ? 16384 : 8192; - } - else - { - g_caps.limits.maxTextureSize = 4096; - } - - g_caps.limits.maxFBAttachments = uint8_t(bx::uint32_min(m_device.supportsFamily( (MTLGPUFamily)1 /* MTLGPUFamily_iOS_GPUFamily2_v1 */) ? 8 : 4, BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS) ); - - g_caps.supported |= m_device.supportsFamily( (MTLGPUFamily)4 /* MTLGPUFamily_iOS_GPUFamily3_v1 */) - ? BGFX_CAPS_DRAW_INDIRECT - : 0 - ; - - g_caps.supported |= m_device.supportsFamily( (MTLGPUFamily)11 /* MTLGPUFamily_iOS_GPUFamily4_v1 */) - ? BGFX_CAPS_TEXTURE_CUBE_ARRAY - : 0 - ; - } - else if (BX_ENABLED(BX_PLATFORM_OSX) ) - { - g_caps.limits.maxTextureSize = 16384; - g_caps.limits.maxFBAttachments = 8; - g_caps.supported |= BGFX_CAPS_TEXTURE_CUBE_ARRAY; - - g_caps.supported |= m_device.supportsFamily( (MTLGPUFamily)10001 /* MTLGPUFamily_macOS_GPUFamily1_v2 */) - ? BGFX_CAPS_DRAW_INDIRECT - : 0 - ; - } + // Reference(s): + // - Metal feature set tables + // https://web.archive.org/web/20230330111145/https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf + g_caps.limits.maxTextureSize = m_device.supportsFamily(MTLGPUFamilyApple3) ? 16384 : 8192; + g_caps.limits.maxFBAttachments = 8; + g_caps.supported |= m_device.supportsFamily(MTLGPUFamilyCommon2) + ? BGFX_CAPS_DRAW_INDIRECT + | BGFX_CAPS_TEXTURE_CUBE_ARRAY + | BGFX_CAPS_TEXTURE_COMPARE_ALL + : 0 + ; g_caps.limits.maxTextureLayers = 2048; g_caps.limits.maxVertexStreams = BGFX_CONFIG_MAX_VERTEX_STREAMS; @@ -2434,10 +2413,12 @@ SamplerState getSamplerState(uint32_t _flags) m_samplerDescriptor.lodMinClamp = 0; m_samplerDescriptor.lodMaxClamp = FLT_MAX; m_samplerDescriptor.normalizedCoordinates = TRUE; - m_samplerDescriptor.maxAnisotropy = (0 != (_flags & (BGFX_SAMPLER_MIN_ANISOTROPIC|BGFX_SAMPLER_MAG_ANISOTROPIC) ) ) ? m_mainFrameBuffer.m_swapChain->m_maxAnisotropy : 1; + m_samplerDescriptor.maxAnisotropy = (0 != (_flags & (BGFX_SAMPLER_MIN_ANISOTROPIC|BGFX_SAMPLER_MAG_ANISOTROPIC) ) ) + ? m_mainFrameBuffer.m_swapChain->m_maxAnisotropy + : 1 + ; - if (m_macOS11Runtime - || [m_device supportsFamily:(MTLGPUFamily)4 /*MTLGPUFamily_iOS_GPUFamily3_v1*/]) + if (0 != (g_caps.supported & BGFX_CAPS_TEXTURE_COMPARE_ALL) ) { const uint32_t cmpFunc = (_flags&BGFX_SAMPLER_COMPARE_MASK)>>BGFX_SAMPLER_COMPARE_SHIFT; m_samplerDescriptor.compareFunction = 0 == cmpFunc