summaryrefslogtreecommitdiffstats
path: root/tests/manual/rhi/shared/examplefw.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/manual/rhi/shared/examplefw.h')
-rw-r--r--tests/manual/rhi/shared/examplefw.h14
1 files changed, 10 insertions, 4 deletions
diff --git a/tests/manual/rhi/shared/examplefw.h b/tests/manual/rhi/shared/examplefw.h
index 2bab0a9e68..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.
@@ -80,6 +80,8 @@ 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
{
@@ -259,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, &params, rhiFlags);
@@ -280,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);
@@ -398,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();
@@ -420,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;