diff options
Diffstat (limited to 'tests/manual/rhi/shared/examplefw.h')
-rw-r--r-- | tests/manual/rhi/shared/examplefw.h | 37 |
1 files changed, 12 insertions, 25 deletions
diff --git a/tests/manual/rhi/shared/examplefw.h b/tests/manual/rhi/shared/examplefw.h index 9879e8c5ba..f2ca57341c 100644 --- a/tests/manual/rhi/shared/examplefw.h +++ b/tests/manual/rhi/shared/examplefw.h @@ -1,5 +1,5 @@ // Copyright (C) 2018 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only // Adapted from hellominimalcrossgfxtriangle with the frame rendering stripped out. // Include this file and implement Window::customInit, release and render. @@ -13,28 +13,9 @@ #include <QTimer> #include <QLoggingCategory> #include <QColorSpace> - -#include <QtGui/private/qshader_p.h> #include <QFile> -#include <QtGui/private/qrhinull_p.h> - -#ifndef QT_NO_OPENGL -#include <QtGui/private/qrhigles2_p.h> #include <QOffscreenSurface> -#endif - -#if QT_CONFIG(vulkan) -#include <QtGui/private/qrhivulkan_p.h> -#endif - -#ifdef Q_OS_WIN -#include <QtGui/private/qrhid3d11_p.h> -#include <QtGui/private/qrhid3d12_p.h> -#endif - -#if defined(Q_OS_MACOS) || defined(Q_OS_IOS) -#include <QtGui/private/qrhimetal_p.h> -#endif +#include <rhi/qrhi.h> #ifdef EXAMPLEFW_IMGUI #include "qrhiimgui_p.h" @@ -92,13 +73,15 @@ QString graphicsApiName() return QString(); } -QRhi::Flags rhiFlags = QRhi::EnableDebugMarkers; +QRhi::Flags rhiFlags = QRhi::EnableDebugMarkers | QRhi::EnableTimestamps; int sampleCount = 1; QRhiSwapChain::Flags scFlags; QRhi::BeginFrameFlags beginFrameFlags; QRhi::EndFrameFlags endFrameFlags; bool transparentBackground = false; bool debugLayer = true; +QRhiSwapChain::Format swapchainFormat = QRhiSwapChain::SDR; +float imguiHDRMultiplier = 0.0f; class Window : public QWindow { @@ -278,7 +261,7 @@ void Window::init() } #endif -#if defined(Q_OS_MACOS) || defined(Q_OS_IOS) +#if QT_CONFIG(metal) if (graphicsApi == Metal) { QRhiMetalInitParams params; m_r = QRhi::create(QRhi::Metal, ¶ms, rhiFlags); @@ -299,6 +282,10 @@ void Window::init() m_sc->setDepthStencil(m_ds); m_sc->setSampleCount(sampleCount); m_sc->setFlags(scFlags); + if (!m_sc->isFormatSupported(swapchainFormat)) + qWarning("Swapchain reports that requested format %d is not supported", int(swapchainFormat)); + else + m_sc->setFormat(swapchainFormat); m_rp = m_sc->newCompatibleRenderPassDescriptor(); m_sc->setRenderPassDescriptor(m_rp); @@ -417,7 +404,7 @@ void Window::render() QMatrix4x4 guiMvp = m_r->clipSpaceCorrMatrix(); guiMvp.ortho(0, outputSizeInPixels.width() / dpr, outputSizeInPixels.height() / dpr, 0, 1, -1); - m_imguiRenderer->prepare(m_r, rt, cb, guiMvp, 1.0f); + m_imguiRenderer->prepare(m_r, rt, cb, guiMvp, 1.0f, imguiHDRMultiplier); #endif customRender(); @@ -439,7 +426,7 @@ int main(int argc, char **argv) // Defaults. #if defined(Q_OS_WIN) graphicsApi = D3D11; -#elif defined(Q_OS_MACOS) || defined(Q_OS_IOS) +#elif QT_CONFIG(metal) graphicsApi = Metal; #elif QT_CONFIG(vulkan) graphicsApi = Vulkan; |