mirror of https://github.com/bkaradzic/bgfx
Cleanup.
This commit is contained in:
parent
3195593d8d
commit
530a558b11
|
@ -420,38 +420,47 @@ namespace bgfx { namespace mtl
|
|||
}
|
||||
#endif // BX_PLATFORM_OSX
|
||||
|
||||
|
||||
static const char* s_accessNames[] = {
|
||||
"Access::Read",
|
||||
"Access::Write",
|
||||
"Access::ReadWrite",
|
||||
};
|
||||
|
||||
BX_STATIC_ASSERT(BX_COUNTOF(s_accessNames) == Access::Count, "Invalid s_accessNames count");
|
||||
|
||||
#ifndef __IPHONE_OS_VERSION_MAX_ALLOWED
|
||||
#define __IPHONE_OS_VERSION_MAX_ALLOWED 0
|
||||
# define __IPHONE_OS_VERSION_MAX_ALLOWED 0
|
||||
#endif
|
||||
#ifndef __MAC_OS_X_VERSION_MAX_ALLOWED
|
||||
#define __MAC_OS_X_VERSION_MAX_ALLOWED 0
|
||||
# define __MAC_OS_X_VERSION_MAX_ALLOWED 0
|
||||
#endif
|
||||
|
||||
#ifndef BX_XCODE_15
|
||||
# define BX_XCODE_15 ((__MAC_OS_X_VERSION_MAX_ALLOWED >= 140000) || \
|
||||
(__IPHONE_OS_VERSION_MAX_ALLOWED >= 170000))
|
||||
#endif
|
||||
# define BX_XCODE_15 (0 \
|
||||
|| (__MAC_OS_X_VERSION_MAX_ALLOWED >= 140000) \
|
||||
|| (__IPHONE_OS_VERSION_MAX_ALLOWED >= 170000) \
|
||||
)
|
||||
#endif // BX_XCODE_15
|
||||
|
||||
#ifndef BX_XCODE_14
|
||||
# define BX_XCODE_14 ((__MAC_OS_X_VERSION_MAX_ALLOWED >= 130000) || \
|
||||
(__IPHONE_OS_VERSION_MAX_ALLOWED >= 160000))
|
||||
#endif
|
||||
# define BX_XCODE_14 (0 \
|
||||
|| (__MAC_OS_X_VERSION_MAX_ALLOWED >= 130000) \
|
||||
|| (__IPHONE_OS_VERSION_MAX_ALLOWED >= 160000) \
|
||||
)
|
||||
#endif // BX_XCODE_14
|
||||
|
||||
#ifndef BX_XCODE_13
|
||||
# define BX_XCODE_13 ((__MAC_OS_X_VERSION_MAX_ALLOWED >= 120000) || \
|
||||
(__IPHONE_OS_VERSION_MAX_ALLOWED >= 150000))
|
||||
#endif
|
||||
# define BX_XCODE_13 (0 \
|
||||
|| (__MAC_OS_X_VERSION_MAX_ALLOWED >= 120000) \
|
||||
|| (__IPHONE_OS_VERSION_MAX_ALLOWED >= 150000) \
|
||||
)
|
||||
#endif // BX_XCODE_13
|
||||
|
||||
#ifndef BX_XCODE_12
|
||||
# define BX_XCODE_12 ((__MAC_OS_X_VERSION_MAX_ALLOWED >= 110000) || \
|
||||
(__IPHONE_OS_VERSION_MAX_ALLOWED >= 140000))
|
||||
#endif
|
||||
# define BX_XCODE_12 (0 \
|
||||
|| (__MAC_OS_X_VERSION_MAX_ALLOWED >= 110000) \
|
||||
|| (__IPHONE_OS_VERSION_MAX_ALLOWED >= 140000) \
|
||||
)
|
||||
#endif // BX_XCODE_12
|
||||
|
||||
#if BX_XCODE_15
|
||||
# define VISION_OS_MINIMUM visionOS 1.0,
|
||||
|
@ -524,11 +533,11 @@ BX_STATIC_ASSERT(BX_COUNTOF(s_accessNames) == Access::Count, "Invalid s_accessNa
|
|||
);
|
||||
m_numWindows = 1;
|
||||
|
||||
#if BX_PLATFORM_VISIONOS
|
||||
#if BX_PLATFORM_VISIONOS
|
||||
if (NULL == m_mainFrameBuffer.m_swapChain->m_layerRenderer)
|
||||
#else // BX_PLATFORM_VISIONOS
|
||||
#else
|
||||
if (NULL == m_mainFrameBuffer.m_swapChain->m_metalLayer)
|
||||
#endif // BX_PLATFORM_VISIONOS
|
||||
#endif // BX_PLATFORM_VISIONOS
|
||||
{
|
||||
release(m_device);
|
||||
return false;
|
||||
|
@ -1029,13 +1038,14 @@ BX_STATIC_ASSERT(BX_COUNTOF(s_accessNames) == Access::Count, "Invalid s_accessNa
|
|||
{
|
||||
}
|
||||
|
||||
MTLPixelFormat getSwapChainPixelFormat(SwapChainMtl *swapChain) {
|
||||
MTLPixelFormat getSwapChainPixelFormat(SwapChainMtl *swapChain)
|
||||
{
|
||||
#if BX_PLATFORM_VISIONOS
|
||||
return MTLPixelFormatBGRA8Unorm_sRGB;
|
||||
return MTLPixelFormatBGRA8Unorm_sRGB;
|
||||
#else
|
||||
return swapChain->m_metalLayer.pixelFormat;
|
||||
#endif
|
||||
}
|
||||
return swapChain->m_metalLayer.pixelFormat;
|
||||
#endif // BX_PLATFORM_VISIONOS
|
||||
}
|
||||
|
||||
void readTexture(TextureHandle _handle, void* _data, uint8_t _mip) override
|
||||
{
|
||||
|
@ -1424,7 +1434,7 @@ BX_STATIC_ASSERT(BX_COUNTOF(s_accessNames) == Access::Count, "Invalid s_accessNa
|
|||
cp_frame_start_submission(frameBuffer.m_swapChain->m_frame);
|
||||
cp_drawable_encode_present(frameBuffer.m_swapChain->m_drawable, m_commandBuffer);
|
||||
cp_frame_end_submission(frameBuffer.m_swapChain->m_frame);
|
||||
#else // BX_PLATFORM_VISIONOS
|
||||
#else
|
||||
m_commandBuffer.presentDrawable(frameBuffer.m_swapChain->m_drawable);
|
||||
MTL_RELEASE(frameBuffer.m_swapChain->m_drawable);
|
||||
#endif // BX_PLATFORM_VISIONOS
|
||||
|
@ -3306,10 +3316,11 @@ BX_STATIC_ASSERT(BX_COUNTOF(s_accessNames) == Access::Count, "Invalid s_accessNa
|
|||
{
|
||||
#if BX_PLATFORM_VISIONOS
|
||||
MTL_RELEASE(m_layerRenderer);
|
||||
#else // BX_PLATFORM_VISIONOS
|
||||
#else
|
||||
MTL_RELEASE(m_metalLayer);
|
||||
MTL_RELEASE(m_drawable);
|
||||
#endif // BX_PLATFORM_VISIONOS
|
||||
|
||||
MTL_RELEASE(m_drawableTexture);
|
||||
|
||||
MTL_RELEASE(m_backBufferDepth);
|
||||
|
@ -3324,15 +3335,24 @@ BX_STATIC_ASSERT(BX_COUNTOF(s_accessNames) == Access::Count, "Invalid s_accessNa
|
|||
|
||||
void SwapChainMtl::init(void* _nwh)
|
||||
{
|
||||
#if !BX_PLATFORM_VISIONOS
|
||||
#if BX_PLATFORM_VISIONOS
|
||||
{
|
||||
cp_layer_renderer_t layerRenderer = (cp_layer_renderer_t)_nwh;
|
||||
m_layerRenderer = layerRenderer;
|
||||
retain(m_layerRenderer);
|
||||
}
|
||||
#else
|
||||
if (m_metalLayer)
|
||||
{
|
||||
release(m_metalLayer);
|
||||
}
|
||||
|
||||
if (NULL != NSClassFromString(@"MTKView") )
|
||||
{
|
||||
MTKView *view = (MTKView *)_nwh;
|
||||
if (NULL != view && [view isKindOfClass:NSClassFromString(@"MTKView")])
|
||||
|
||||
if (NULL != view
|
||||
&& [view isKindOfClass:NSClassFromString(@"MTKView")])
|
||||
{
|
||||
m_metalLayer = (CAMetalLayer *)view.layer;
|
||||
}
|
||||
|
@ -3341,7 +3361,7 @@ BX_STATIC_ASSERT(BX_COUNTOF(s_accessNames) == Access::Count, "Invalid s_accessNa
|
|||
if (NULL != NSClassFromString(@"CAMetalLayer") )
|
||||
{
|
||||
if (NULL == m_metalLayer)
|
||||
#if BX_PLATFORM_IOS
|
||||
# if BX_PLATFORM_IOS
|
||||
{
|
||||
CAMetalLayer* metalLayer = (CAMetalLayer*)_nwh;
|
||||
if (NULL == metalLayer
|
||||
|
@ -3353,7 +3373,7 @@ BX_STATIC_ASSERT(BX_COUNTOF(s_accessNames) == Access::Count, "Invalid s_accessNa
|
|||
|
||||
m_metalLayer = metalLayer;
|
||||
}
|
||||
#elif BX_PLATFORM_OSX
|
||||
# elif BX_PLATFORM_OSX
|
||||
{
|
||||
NSObject* nvh = (NSObject*)_nwh;
|
||||
if ([nvh isKindOfClass:[CAMetalLayer class]])
|
||||
|
@ -3413,7 +3433,7 @@ BX_STATIC_ASSERT(BX_COUNTOF(s_accessNames) == Access::Count, "Invalid s_accessNa
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif // BX_PLATFORM_*
|
||||
# endif // BX_PLATFORM_*
|
||||
}
|
||||
|
||||
if (NULL == m_metalLayer)
|
||||
|
@ -3426,13 +3446,8 @@ BX_STATIC_ASSERT(BX_COUNTOF(s_accessNames) == Access::Count, "Invalid s_accessNa
|
|||
m_metalLayer.pixelFormat = MTLPixelFormatBGRA8Unorm;
|
||||
m_metalLayer.magnificationFilter = kCAFilterNearest;
|
||||
retain(m_metalLayer);
|
||||
#else // BX_PLATFORM_VISIONOS
|
||||
{
|
||||
cp_layer_renderer_t layerRenderer = (cp_layer_renderer_t)_nwh;
|
||||
m_layerRenderer = layerRenderer;
|
||||
retain(m_layerRenderer);
|
||||
}
|
||||
#endif // BX_PLATFORM_VISIONOS
|
||||
|
||||
m_nwh = _nwh;
|
||||
}
|
||||
|
||||
|
@ -3460,7 +3475,7 @@ BX_STATIC_ASSERT(BX_COUNTOF(s_accessNames) == Access::Count, "Invalid s_accessNa
|
|||
|
||||
#if !BX_PLATFORM_VISIONOS
|
||||
m_metalLayer.drawableSize = CGSizeMake(_width, _height);
|
||||
m_metalLayer.pixelFormat = (_flags & BGFX_RESET_SRGB_BACKBUFFER)
|
||||
m_metalLayer.pixelFormat = (_flags & BGFX_RESET_SRGB_BACKBUFFER)
|
||||
? MTLPixelFormatBGRA8Unorm_sRGB
|
||||
: MTLPixelFormatBGRA8Unorm
|
||||
;
|
||||
|
@ -3528,7 +3543,7 @@ BX_STATIC_ASSERT(BX_COUNTOF(s_accessNames) == Access::Count, "Invalid s_accessNa
|
|||
desc.pixelFormat = MTLPixelFormatBGRA8Unorm_sRGB;
|
||||
#else
|
||||
desc.pixelFormat = m_metalLayer.pixelFormat;
|
||||
#endif
|
||||
#endif // BX_PLATFORM_VISIONOS
|
||||
m_backBufferColorMsaa = s_renderMtl->m_device.newTextureWithDescriptor(desc);
|
||||
}
|
||||
|
||||
|
@ -3537,7 +3552,7 @@ BX_STATIC_ASSERT(BX_COUNTOF(s_accessNames) == Access::Count, "Invalid s_accessNa
|
|||
murmur.add(1);
|
||||
#if !BX_PLATFORM_VISIONOS
|
||||
murmur.add( (uint32_t)m_metalLayer.pixelFormat);
|
||||
#endif // BX_PLATFORM_VISIONOS
|
||||
#endif // !BX_PLATFORM_VISIONOS
|
||||
murmur.add( (uint32_t)m_backBufferDepth.pixelFormat() );
|
||||
murmur.add( (uint32_t)m_backBufferStencil.pixelFormat() );
|
||||
murmur.add( (uint32_t)sampleCount);
|
||||
|
@ -3550,33 +3565,38 @@ BX_STATIC_ASSERT(BX_COUNTOF(s_accessNames) == Access::Count, "Invalid s_accessNa
|
|||
{
|
||||
#if BX_PLATFORM_VISIONOS
|
||||
m_frame = cp_layer_renderer_query_next_frame(m_layerRenderer);
|
||||
if (m_frame) {
|
||||
if (m_frame)
|
||||
{
|
||||
m_drawable = cp_frame_query_drawable(m_frame);
|
||||
}
|
||||
#else // BX_PLATFORM_VISIONOS
|
||||
#else
|
||||
m_drawable = m_metalLayer.nextDrawable;
|
||||
#endif // BX_PLATFORM_VISIONOS
|
||||
|
||||
if (m_drawable != NULL)
|
||||
{
|
||||
#if BX_PLATFORM_VISIONOS
|
||||
m_drawableTexture = cp_drawable_get_color_texture(m_drawable, 0);
|
||||
#else // BX_PLATFORM_VISIONOS
|
||||
#else
|
||||
m_drawableTexture = m_drawable.texture;
|
||||
retain(m_drawable); // keep alive to be useable at 'flip'
|
||||
#endif // BX_PLATFORM_VISIONOS
|
||||
|
||||
retain(m_drawableTexture);
|
||||
}
|
||||
else
|
||||
{
|
||||
TextureDescriptor desc = s_renderMtl->m_textureDescriptor;
|
||||
desc.textureType = MTLTextureType2D;
|
||||
#if !BX_PLATFORM_VISIONOS
|
||||
|
||||
#if BX_PLATFORM_VISIONOS
|
||||
desc.pixelFormat = MTLPixelFormatBGRA8Unorm_sRGB;
|
||||
#else
|
||||
desc.pixelFormat = m_metalLayer.pixelFormat;
|
||||
desc.width = m_metalLayer.drawableSize.width;
|
||||
desc.height = m_metalLayer.drawableSize.height;
|
||||
#else // BX_PLATFORM_VISIONOS
|
||||
desc.pixelFormat = MTLPixelFormatBGRA8Unorm_sRGB;
|
||||
#endif // BX_PLATFORM_VISIONOS
|
||||
|
||||
desc.depth = 1;
|
||||
desc.mipmapLevelCount = 1;
|
||||
desc.sampleCount = 1;
|
||||
|
|
Loading…
Reference in New Issue