Fix Metal usage on iOS
Also enable the two Metal-specific scenegraph examples on iOS. Change-Id: I0e1e6d527544ea4a5bfb0d08ca2d32c762d3c699 Reviewed-by: Andy Nichols <andy.nichols@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
f6e90ba533
commit
df0cb0edac
|
@ -1,4 +1,4 @@
|
||||||
!macos: error("This example requires macOS")
|
!macos:!ios: error("This example requires macOS or iOS")
|
||||||
|
|
||||||
QT += qml quick
|
QT += qml quick
|
||||||
|
|
||||||
|
@ -6,7 +6,8 @@ HEADERS += metaltextureimport.h
|
||||||
SOURCES += metaltextureimport.mm main.cpp
|
SOURCES += metaltextureimport.mm main.cpp
|
||||||
RESOURCES += metaltextureimport.qrc
|
RESOURCES += metaltextureimport.qrc
|
||||||
|
|
||||||
LIBS += -framework Metal -framework AppKit
|
LIBS += -framework Metal
|
||||||
|
macos: LIBS += -framework AppKit
|
||||||
|
|
||||||
target.path = $$[QT_INSTALL_EXAMPLES]/quick/scenegraph/metaltextureimport
|
target.path = $$[QT_INSTALL_EXAMPLES]/quick/scenegraph/metaltextureimport
|
||||||
INSTALLS += target
|
INSTALLS += target
|
||||||
|
|
|
@ -349,10 +349,13 @@ void SquircleRenderer::init(int framesInFlight)
|
||||||
rpDesc.colorAttachments[0].destinationRGBBlendFactor = MTLBlendFactorOne;
|
rpDesc.colorAttachments[0].destinationRGBBlendFactor = MTLBlendFactorOne;
|
||||||
rpDesc.colorAttachments[0].destinationAlphaBlendFactor = MTLBlendFactorOne;
|
rpDesc.colorAttachments[0].destinationAlphaBlendFactor = MTLBlendFactorOne;
|
||||||
|
|
||||||
|
#ifdef Q_OS_MACOS
|
||||||
if (m_device.depth24Stencil8PixelFormatSupported) {
|
if (m_device.depth24Stencil8PixelFormatSupported) {
|
||||||
rpDesc.depthAttachmentPixelFormat = MTLPixelFormatDepth24Unorm_Stencil8;
|
rpDesc.depthAttachmentPixelFormat = MTLPixelFormatDepth24Unorm_Stencil8;
|
||||||
rpDesc.stencilAttachmentPixelFormat = MTLPixelFormatDepth24Unorm_Stencil8;
|
rpDesc.stencilAttachmentPixelFormat = MTLPixelFormatDepth24Unorm_Stencil8;
|
||||||
} else {
|
} else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
rpDesc.depthAttachmentPixelFormat = MTLPixelFormatDepth32Float_Stencil8;
|
rpDesc.depthAttachmentPixelFormat = MTLPixelFormatDepth32Float_Stencil8;
|
||||||
rpDesc.stencilAttachmentPixelFormat = MTLPixelFormatDepth32Float_Stencil8;
|
rpDesc.stencilAttachmentPixelFormat = MTLPixelFormatDepth32Float_Stencil8;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
!macos: error("This example requires macOS")
|
!macos:!ios: error("This example requires macOS or iOS")
|
||||||
|
|
||||||
QT += qml quick
|
QT += qml quick
|
||||||
|
|
||||||
|
@ -6,7 +6,8 @@ HEADERS += metalsquircle.h
|
||||||
SOURCES += metalsquircle.mm main.cpp
|
SOURCES += metalsquircle.mm main.cpp
|
||||||
RESOURCES += metalunderqml.qrc
|
RESOURCES += metalunderqml.qrc
|
||||||
|
|
||||||
LIBS += -framework Metal -framework AppKit
|
LIBS += -framework Metal
|
||||||
|
macos: LIBS += -framework AppKit
|
||||||
|
|
||||||
target.path = $$[QT_INSTALL_EXAMPLES]/quick/scenegraph/metalunderqml
|
target.path = $$[QT_INSTALL_EXAMPLES]/quick/scenegraph/metalunderqml
|
||||||
INSTALLS += target
|
INSTALLS += target
|
||||||
|
|
|
@ -16,7 +16,7 @@ SUBDIRS += \
|
||||||
rendernode \
|
rendernode \
|
||||||
threadedanimation
|
threadedanimation
|
||||||
|
|
||||||
macos {
|
macos|ios {
|
||||||
SUBDIRS += \
|
SUBDIRS += \
|
||||||
metalunderqml \
|
metalunderqml \
|
||||||
metaltextureimport
|
metaltextureimport
|
||||||
|
|
|
@ -159,7 +159,7 @@ void QSGRhiSupport::applySettings()
|
||||||
} else {
|
} else {
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
m_rhiBackend = QRhi::D3D11;
|
m_rhiBackend = QRhi::D3D11;
|
||||||
#elif defined(Q_OS_DARWIN)
|
#elif defined(Q_OS_MACOS) || defined(Q_OS_IOS)
|
||||||
m_rhiBackend = QRhi::Metal;
|
m_rhiBackend = QRhi::Metal;
|
||||||
#else
|
#else
|
||||||
m_rhiBackend = QRhi::OpenGLES2;
|
m_rhiBackend = QRhi::OpenGLES2;
|
||||||
|
@ -350,7 +350,7 @@ static const void *qsgrhi_d3d11_rifResource(QSGRendererInterface::Resource res,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Q_OS_DARWIN
|
#if defined(Q_OS_MACOS) || defined(Q_OS_IOS)
|
||||||
static const void *qsgrhi_mtl_rifResource(QSGRendererInterface::Resource res, const QRhiNativeHandles *nat,
|
static const void *qsgrhi_mtl_rifResource(QSGRendererInterface::Resource res, const QRhiNativeHandles *nat,
|
||||||
const QRhiNativeHandles *cbNat)
|
const QRhiNativeHandles *cbNat)
|
||||||
{
|
{
|
||||||
|
@ -408,7 +408,7 @@ const void *QSGRhiSupport::rifResource(QSGRendererInterface::Resource res, const
|
||||||
case QRhi::D3D11:
|
case QRhi::D3D11:
|
||||||
return qsgrhi_d3d11_rifResource(res, nat);
|
return qsgrhi_d3d11_rifResource(res, nat);
|
||||||
#endif
|
#endif
|
||||||
#ifdef Q_OS_DARWIN
|
#if defined(Q_OS_MACOS) || defined(Q_OS_IOS)
|
||||||
case QRhi::Metal:
|
case QRhi::Metal:
|
||||||
{
|
{
|
||||||
QRhiCommandBuffer *cb = rc->currentFrameCommandBuffer();
|
QRhiCommandBuffer *cb = rc->currentFrameCommandBuffer();
|
||||||
|
@ -507,7 +507,7 @@ QRhi *QSGRhiSupport::createRhi(QWindow *window, QOffscreenSurface *offscreenSurf
|
||||||
rhi = QRhi::create(backend, &rhiParams, flags);
|
rhi = QRhi::create(backend, &rhiParams, flags);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef Q_OS_DARWIN
|
#if defined(Q_OS_MACOS) || defined(Q_OS_IOS)
|
||||||
if (backend == QRhi::Metal) {
|
if (backend == QRhi::Metal) {
|
||||||
QRhiMetalInitParams rhiParams;
|
QRhiMetalInitParams rhiParams;
|
||||||
rhi = QRhi::create(backend, &rhiParams, flags);
|
rhi = QRhi::create(backend, &rhiParams, flags);
|
||||||
|
|
|
@ -70,7 +70,7 @@
|
||||||
#include <QtGui/private/qrhid3d11_p.h>
|
#include <QtGui/private/qrhid3d11_p.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Q_OS_DARWIN
|
#if defined(Q_OS_MACOS) || defined(Q_OS_IOS)
|
||||||
#include <QtGui/private/qrhimetal_p.h>
|
#include <QtGui/private/qrhimetal_p.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ void QSGRhiNativeTextureImporter::buildWrapper(QRhi *rhi, QRhiTexture *t,
|
||||||
#if !QT_CONFIG(vulkan)
|
#if !QT_CONFIG(vulkan)
|
||||||
Q_UNUSED(nativeLayout);
|
Q_UNUSED(nativeLayout);
|
||||||
#endif
|
#endif
|
||||||
#if !QT_CONFIG(opengl) && !QT_CONFIG(vulkan) && !defined(Q_OS_WIN) && !defined(Q_OS_DARWIN)
|
#if !QT_CONFIG(opengl) && !QT_CONFIG(vulkan) && !defined(Q_OS_WIN) && !defined(Q_OS_MACOS) && !defined(Q_OS_IOS)
|
||||||
Q_UNUSED(nativeObjectPtr);
|
Q_UNUSED(nativeObjectPtr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ void QSGRhiNativeTextureImporter::buildWrapper(QRhi *rhi, QRhiTexture *t,
|
||||||
break;
|
break;
|
||||||
case QRhi::Metal:
|
case QRhi::Metal:
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_DARWIN
|
#if defined(Q_OS_MACOS) || defined(Q_OS_IOS)
|
||||||
QRhiMetalTextureNativeHandles h;
|
QRhiMetalTextureNativeHandles h;
|
||||||
h.texture = *reinterpret_cast<void * const *>(nativeObjectPtr);
|
h.texture = *reinterpret_cast<void * const *>(nativeObjectPtr);
|
||||||
t->buildFrom(&h);
|
t->buildFrom(&h);
|
||||||
|
|
Loading…
Reference in New Issue