diff options
Diffstat (limited to 'src/gui/rhi')
-rw-r--r-- | src/gui/rhi/qrhid3d11.cpp | 14 | ||||
-rw-r--r-- | src/gui/rhi/qrhimetal.mm | 45 | ||||
-rw-r--r-- | src/gui/rhi/qrhivulkan.cpp | 8 |
3 files changed, 52 insertions, 15 deletions
diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp index 65f0a2262b..ac6c43693b 100644 --- a/src/gui/rhi/qrhid3d11.cpp +++ b/src/gui/rhi/qrhid3d11.cpp @@ -131,7 +131,7 @@ QRhiD3D11::QRhiD3D11(QRhiD3D11InitParams *params, QRhiD3D11NativeHandles *import dev = reinterpret_cast<ID3D11Device *>(importDevice->dev); if (dev) { ID3D11DeviceContext *ctx = reinterpret_cast<ID3D11DeviceContext *>(importDevice->context); - if (SUCCEEDED(ctx->QueryInterface(IID_ID3D11DeviceContext1, reinterpret_cast<void **>(&context)))) { + if (SUCCEEDED(ctx->QueryInterface(__uuidof(ID3D11DeviceContext1), reinterpret_cast<void **>(&context)))) { // get rid of the ref added by QueryInterface ctx->Release(); } else { @@ -171,7 +171,7 @@ static IDXGIFactory1 *createDXGIFactory2() using PtrCreateDXGIFactory2 = HRESULT (WINAPI *)(UINT, REFIID, void **); QSystemLibrary dxgilib(QStringLiteral("dxgi")); if (auto createDXGIFactory2 = reinterpret_cast<PtrCreateDXGIFactory2>(dxgilib.resolve("CreateDXGIFactory2"))) { - const HRESULT hr = createDXGIFactory2(0, IID_IDXGIFactory2, reinterpret_cast<void **>(&result)); + const HRESULT hr = createDXGIFactory2(0, __uuidof(IDXGIFactory2), reinterpret_cast<void **>(&result)); if (FAILED(hr)) { qWarning("CreateDXGIFactory2() failed to create DXGI factory: %s", qPrintable(comErrorMessage(hr))); result = nullptr; @@ -186,7 +186,7 @@ static IDXGIFactory1 *createDXGIFactory2() static IDXGIFactory1 *createDXGIFactory1() { IDXGIFactory1 *result = nullptr; - const HRESULT hr = CreateDXGIFactory1(IID_IDXGIFactory1, reinterpret_cast<void **>(&result)); + const HRESULT hr = CreateDXGIFactory1(__uuidof(IDXGIFactory1), reinterpret_cast<void **>(&result)); if (FAILED(hr)) { qWarning("CreateDXGIFactory1() failed to create DXGI factory: %s", qPrintable(comErrorMessage(hr))); result = nullptr; @@ -269,7 +269,7 @@ bool QRhiD3D11::create(QRhi::Flags flags) qWarning("Failed to create D3D11 device and context: %s", qPrintable(comErrorMessage(hr))); return false; } - if (SUCCEEDED(ctx->QueryInterface(IID_ID3D11DeviceContext1, reinterpret_cast<void **>(&context)))) { + if (SUCCEEDED(ctx->QueryInterface(__uuidof(ID3D11DeviceContext1), reinterpret_cast<void **>(&context)))) { ctx->Release(); } else { qWarning("ID3D11DeviceContext1 not supported"); @@ -280,7 +280,7 @@ bool QRhiD3D11::create(QRhi::Flags flags) featureLevel = dev->GetFeatureLevel(); } - if (FAILED(context->QueryInterface(IID_ID3DUserDefinedAnnotation, reinterpret_cast<void **>(&annotations)))) + if (FAILED(context->QueryInterface(__uuidof(ID3DUserDefinedAnnotation), reinterpret_cast<void **>(&annotations)))) annotations = nullptr; deviceLost = false; @@ -336,7 +336,7 @@ void QRhiD3D11::reportLiveObjects(ID3D11Device *device) { // this works only when params.enableDebugLayer was true ID3D11Debug *debug; - if (SUCCEEDED(device->QueryInterface(IID_ID3D11Debug, reinterpret_cast<void **>(&debug)))) { + if (SUCCEEDED(device->QueryInterface(__uuidof(ID3D11Debug), reinterpret_cast<void **>(&debug)))) { debug->ReportLiveDeviceObjects(D3D11_RLDO_DETAIL); debug->Release(); } @@ -4197,7 +4197,7 @@ bool QD3D11SwapChain::buildOrResize() // swapchain." // So just query index 0 once (per resize) and be done with it. - HRESULT hr = swapChain->GetBuffer(0, IID_ID3D11Texture2D, reinterpret_cast<void **>(&backBufferTex)); + HRESULT hr = swapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), reinterpret_cast<void **>(&backBufferTex)); if (FAILED(hr)) { qWarning("Failed to query swapchain backbuffer: %s", qPrintable(comErrorMessage(hr))); return false; diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm index 0806c8a052..acd53b3dfd 100644 --- a/src/gui/rhi/qrhimetal.mm +++ b/src/gui/rhi/qrhimetal.mm @@ -75,6 +75,7 @@ QT_BEGIN_NAMESPACE /*! \class QRhiMetalInitParams \inmodule QtRhi + \internal \brief Metal specific initialization parameters. A Metal-based QRhi needs no special parameters for initialization. @@ -106,6 +107,7 @@ QT_BEGIN_NAMESPACE /*! \class QRhiMetalNativeHandles \inmodule QtRhi + \internal \brief Holds the Metal device used by the QRhi. \note The class uses \c{void *} as the type since including the Objective C @@ -116,6 +118,7 @@ QT_BEGIN_NAMESPACE /*! \class QRhiMetalCommandBufferNativeHandles \inmodule QtRhi + \internal \brief Holds the MTLCommandBuffer and MTLRenderCommandEncoder objects that are backing a QRhiCommandBuffer. \note The command buffer object is only guaranteed to be valid while @@ -3735,10 +3738,42 @@ QRhiRenderTarget *QMetalSwapChain::currentFrameRenderTarget() return &rtWrapper; } +#ifdef TARGET_IPHONE_SIMULATOR +API_AVAILABLE(ios(13.0)) +#endif +static inline CAMetalLayer *layerForWindow(QWindow *window) +{ + Q_ASSERT(window); +#ifdef Q_OS_MACOS + NSView *view = reinterpret_cast<NSView *>(window->winId()); +#else + UIView *view = reinterpret_cast<UIView *>(window->winId()); +#endif + Q_ASSERT(view); + return static_cast<CAMetalLayer *>(view.layer); +} + QSize QMetalSwapChain::surfacePixelSize() { +#ifdef TARGET_IPHONE_SIMULATOR + if (@available(ios 13.0, *)) { +#endif + Q_ASSERT(m_window); - return m_window->size() * m_window->devicePixelRatio(); + CAMetalLayer *layer = d->layer; + if (!layer) + layer = layerForWindow(m_window); + + CGSize layerSize = layer.bounds.size; + layerSize.width *= layer.contentsScale; + layerSize.height *= layer.contentsScale; + return QSizeF::fromCGSize(layerSize).toSize(); + +#ifdef TARGET_IPHONE_SIMULATOR + } else { + return QSize(); + } +#endif } QRhiRenderPassDescriptor *QMetalSwapChain::newCompatibleRenderPassDescriptor() @@ -3797,13 +3832,7 @@ bool QMetalSwapChain::buildOrResize() return false; } -#ifdef Q_OS_MACOS - NSView *view = reinterpret_cast<NSView *>(window->winId()); -#else - UIView *view = reinterpret_cast<UIView *>(window->winId()); -#endif - Q_ASSERT(view); - d->layer = static_cast<CAMetalLayer *>(view.layer); + d->layer = layerForWindow(window); Q_ASSERT(d->layer); chooseFormats(); diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index 26c153afff..57998119e0 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -540,6 +540,14 @@ bool QRhiVulkan::create(QRhi::Flags flags) devInfo.enabledExtensionCount = uint32_t(requestedDevExts.count()); devInfo.ppEnabledExtensionNames = requestedDevExts.constData(); + // Enable all supported 1.0 core features, except ones that likely + // involve a performance penalty. + VkPhysicalDeviceFeatures features; + memset(&features, 0, sizeof(features)); + f->vkGetPhysicalDeviceFeatures(physDev, &features); + features.robustBufferAccess = VK_FALSE; + devInfo.pEnabledFeatures = &features; + err = f->vkCreateDevice(physDev, &devInfo, nullptr, &dev); if (err != VK_SUCCESS) { qWarning("Failed to create device: %d", err); |