diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2019-09-26 09:37:49 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2019-09-26 17:02:12 +0200 |
commit | 22d22eb2824fb06f69f87bda27b1cfdf45efbc1f (patch) | |
tree | 50b6c23af4266d259ff6ad14c8dbfe8f357c905d /tests | |
parent | 30e27328e3d6446a343107c96f41324197ed7ef1 (diff) |
rhi: Add a --transparent option to manual tests
This will also cause clearing to 0,0,0,0.
Essential in order to allow fast testing of window transparency
issues in combination with QRhi and the various backends.
Change-Id: Iee2763c1d06f1d3e5d59a9142abaf30fab1dc543
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/manual/rhi/compressedtexture_bc1/compressedtexture_bc1.cpp | 2 | ||||
-rw-r--r-- | tests/manual/rhi/compressedtexture_bc1_subupload/compressedtexture_bc1_subupload.cpp | 2 | ||||
-rw-r--r-- | tests/manual/rhi/computebuffer/computebuffer.cpp | 2 | ||||
-rw-r--r-- | tests/manual/rhi/computeimage/computeimage.cpp | 2 | ||||
-rw-r--r-- | tests/manual/rhi/cubemap/cubemap.cpp | 2 | ||||
-rw-r--r-- | tests/manual/rhi/cubemap_scissor/cubemap_scissor.cpp | 2 | ||||
-rw-r--r-- | tests/manual/rhi/floattexture/floattexture.cpp | 2 | ||||
-rw-r--r-- | tests/manual/rhi/instancing/instancing.cpp | 2 | ||||
-rw-r--r-- | tests/manual/rhi/mrt/mrt.cpp | 2 | ||||
-rw-r--r-- | tests/manual/rhi/msaarenderbuffer/msaarenderbuffer.cpp | 2 | ||||
-rw-r--r-- | tests/manual/rhi/msaatexture/msaatexture.cpp | 2 | ||||
-rw-r--r-- | tests/manual/rhi/shadowmap/shadowmap.cpp | 2 | ||||
-rw-r--r-- | tests/manual/rhi/shared/examplefw.h | 16 | ||||
-rw-r--r-- | tests/manual/rhi/texuploads/texuploads.cpp | 2 | ||||
-rw-r--r-- | tests/manual/rhi/triquadcube/triquadcube.cpp | 2 |
15 files changed, 30 insertions, 14 deletions
diff --git a/tests/manual/rhi/compressedtexture_bc1/compressedtexture_bc1.cpp b/tests/manual/rhi/compressedtexture_bc1/compressedtexture_bc1.cpp index 27dd8097ad..bb3722bec5 100644 --- a/tests/manual/rhi/compressedtexture_bc1/compressedtexture_bc1.cpp +++ b/tests/manual/rhi/compressedtexture_bc1/compressedtexture_bc1.cpp @@ -182,7 +182,7 @@ void Window::customRender() QRhiCommandBuffer *cb = m_sc->currentFrameCommandBuffer(); const QSize outputSizeInPixels = m_sc->currentPixelSize(); - cb->beginPass(m_sc->currentFrameRenderTarget(), QColor::fromRgbF(0.4f, 0.7f, 0.0f, 1.0f), { 1.0f, 0 }, u); + cb->beginPass(m_sc->currentFrameRenderTarget(), m_clearColor, { 1.0f, 0 }, u); cb->setGraphicsPipeline(d.ps); cb->setViewport({ 0, 0, float(outputSizeInPixels.width()), float(outputSizeInPixels.height()) }); diff --git a/tests/manual/rhi/compressedtexture_bc1_subupload/compressedtexture_bc1_subupload.cpp b/tests/manual/rhi/compressedtexture_bc1_subupload/compressedtexture_bc1_subupload.cpp index 87d1e7646a..4931c8eaa1 100644 --- a/tests/manual/rhi/compressedtexture_bc1_subupload/compressedtexture_bc1_subupload.cpp +++ b/tests/manual/rhi/compressedtexture_bc1_subupload/compressedtexture_bc1_subupload.cpp @@ -197,7 +197,7 @@ void Window::customRender() QRhiCommandBuffer *cb = m_sc->currentFrameCommandBuffer(); const QSize outputSizeInPixels = m_sc->currentPixelSize(); - cb->beginPass(m_sc->currentFrameRenderTarget(), QColor::fromRgbF(0.4f, 0.7f, 0.0f, 1.0f), { 1.0f, 0 }, u); + cb->beginPass(m_sc->currentFrameRenderTarget(), m_clearColor, { 1.0f, 0 }, u); cb->setGraphicsPipeline(d.ps); cb->setViewport({ 0, 0, float(outputSizeInPixels.width()), float(outputSizeInPixels.height()) }); diff --git a/tests/manual/rhi/computebuffer/computebuffer.cpp b/tests/manual/rhi/computebuffer/computebuffer.cpp index 2a3e0b92b5..c991a11438 100644 --- a/tests/manual/rhi/computebuffer/computebuffer.cpp +++ b/tests/manual/rhi/computebuffer/computebuffer.cpp @@ -195,7 +195,7 @@ void Window::customRender() cb->endComputePass(); // graphics pass - cb->beginPass(m_sc->currentFrameRenderTarget(), QColor::fromRgbF(0.4f, 0.7f, 0.0f, 1.0f), { 1.0f, 0 }); + cb->beginPass(m_sc->currentFrameRenderTarget(), m_clearColor, { 1.0f, 0 }); cb->setGraphicsPipeline(d.graphicsPipeline); cb->setViewport({ 0, 0, float(outputSizeInPixels.width()), float(outputSizeInPixels.height()) }); QRhiCommandBuffer::VertexInput vbufBinding(d.sbuf, 0); diff --git a/tests/manual/rhi/computeimage/computeimage.cpp b/tests/manual/rhi/computeimage/computeimage.cpp index 51bf216c5a..a6c860f8ee 100644 --- a/tests/manual/rhi/computeimage/computeimage.cpp +++ b/tests/manual/rhi/computeimage/computeimage.cpp @@ -217,7 +217,7 @@ void Window::customRender() cb->dispatch(d.imageSize.width() / 16, d.imageSize.height() / 16, 1); cb->endComputePass(); - cb->beginPass(m_sc->currentFrameRenderTarget(), QColor::fromRgbF(0.4f, 0.7f, 0.0f, 1.0f), { 1.0f, 0 }); + cb->beginPass(m_sc->currentFrameRenderTarget(), m_clearColor, { 1.0f, 0 }); cb->setGraphicsPipeline(d.ps); cb->setViewport({ 0, 0, float(outputSizeInPixels.width()), float(outputSizeInPixels.height()) }); cb->setShaderResources(); diff --git a/tests/manual/rhi/cubemap/cubemap.cpp b/tests/manual/rhi/cubemap/cubemap.cpp index df302736a2..fe6ac9762e 100644 --- a/tests/manual/rhi/cubemap/cubemap.cpp +++ b/tests/manual/rhi/cubemap/cubemap.cpp @@ -168,7 +168,7 @@ void Window::customRender() // no translation u->updateDynamicBuffer(d.ubuf, 0, 64, mvp.constData()); - cb->beginPass(m_sc->currentFrameRenderTarget(), QColor::fromRgbF(0.4f, 0.7f, 0.0f, 1.0f), { 1.0f, 0 }, u); + cb->beginPass(m_sc->currentFrameRenderTarget(), m_clearColor, { 1.0f, 0 }, u); cb->setGraphicsPipeline(d.ps); cb->setViewport(QRhiViewport(0, 0, outputSizeInPixels.width(), outputSizeInPixels.height())); cb->setShaderResources(); diff --git a/tests/manual/rhi/cubemap_scissor/cubemap_scissor.cpp b/tests/manual/rhi/cubemap_scissor/cubemap_scissor.cpp index 4281c78793..25a7c64c8a 100644 --- a/tests/manual/rhi/cubemap_scissor/cubemap_scissor.cpp +++ b/tests/manual/rhi/cubemap_scissor/cubemap_scissor.cpp @@ -221,7 +221,7 @@ void Window::customRender() // no translation u->updateDynamicBuffer(d.ubuf, 0, 64, mvp.constData()); - cb->beginPass(m_sc->currentFrameRenderTarget(), QColor::fromRgbF(0.4f, 0.7f, 0.0f, 1.0f), { 1.0f, 0 }, u); + cb->beginPass(m_sc->currentFrameRenderTarget(), m_clearColor, { 1.0f, 0 }, u); cb->setGraphicsPipeline(d.ps); cb->setViewport(QRhiViewport(0, 0, outputSizeInPixels.width(), outputSizeInPixels.height())); diff --git a/tests/manual/rhi/floattexture/floattexture.cpp b/tests/manual/rhi/floattexture/floattexture.cpp index 16e58ff00f..0d24860c78 100644 --- a/tests/manual/rhi/floattexture/floattexture.cpp +++ b/tests/manual/rhi/floattexture/floattexture.cpp @@ -317,7 +317,7 @@ void Window::customRender() } const QSize outputSizeInPixels = m_sc->currentPixelSize(); - cb->beginPass(m_sc->currentFrameRenderTarget(), QColor::fromRgbF(0.4f, 0.7f, 0.0f, 1.0f), { 1.0f, 0 }, u); + cb->beginPass(m_sc->currentFrameRenderTarget(), m_clearColor, { 1.0f, 0 }, u); cb->setGraphicsPipeline(d.ps); cb->setViewport({ 0, 0, float(outputSizeInPixels.width()), float(outputSizeInPixels.height()) }); cb->setShaderResources(); diff --git a/tests/manual/rhi/instancing/instancing.cpp b/tests/manual/rhi/instancing/instancing.cpp index 87029e541c..bdafbd81bc 100644 --- a/tests/manual/rhi/instancing/instancing.cpp +++ b/tests/manual/rhi/instancing/instancing.cpp @@ -161,7 +161,7 @@ void Window::customRender() u->updateDynamicBuffer(d.ubuf, 0, 64, mvp.constData()); } - cb->beginPass(m_sc->currentFrameRenderTarget(), QColor::fromRgbF(0.4f, 0.7f, 0.0f, 1.0f), { 1.0f, 0 }, u); + cb->beginPass(m_sc->currentFrameRenderTarget(), m_clearColor, { 1.0f, 0 }, u); cb->setGraphicsPipeline(d.ps); cb->setViewport({ 0, 0, float(outputSizeInPixels.width()), float(outputSizeInPixels.height()) }); cb->setShaderResources(); diff --git a/tests/manual/rhi/mrt/mrt.cpp b/tests/manual/rhi/mrt/mrt.cpp index b80af7ac87..258871f9b3 100644 --- a/tests/manual/rhi/mrt/mrt.cpp +++ b/tests/manual/rhi/mrt/mrt.cpp @@ -283,7 +283,7 @@ void Window::customRender() } const QSize outputSizeInPixels = m_sc->currentPixelSize(); - cb->beginPass(m_sc->currentFrameRenderTarget(), QColor::fromRgbF(0.4f, 0.7f, 0.0f, 1.0f), { 1.0f, 0 }, u); + cb->beginPass(m_sc->currentFrameRenderTarget(), m_clearColor, { 1.0f, 0 }, u); cb->setGraphicsPipeline(d.ps); cb->setViewport({ 0, 0, float(outputSizeInPixels.width()), float(outputSizeInPixels.height()) }); vbufBinding.second = 0; diff --git a/tests/manual/rhi/msaarenderbuffer/msaarenderbuffer.cpp b/tests/manual/rhi/msaarenderbuffer/msaarenderbuffer.cpp index b77a27b1b5..27dabb2276 100644 --- a/tests/manual/rhi/msaarenderbuffer/msaarenderbuffer.cpp +++ b/tests/manual/rhi/msaarenderbuffer/msaarenderbuffer.cpp @@ -248,7 +248,7 @@ void Window::customRender() // onscreen (quad) const QSize outputSizeInPixels = m_sc->currentPixelSize(); - cb->beginPass(m_sc->currentFrameRenderTarget(), QColor::fromRgbF(0.4f, 0.7f, 0.0f, 1.0f), { 1.0f, 0 }); + cb->beginPass(m_sc->currentFrameRenderTarget(), m_clearColor, { 1.0f, 0 }); cb->setGraphicsPipeline(d.ps); cb->setViewport({ 0, 0, float(outputSizeInPixels.width()), float(outputSizeInPixels.height()) }); cb->setShaderResources(); diff --git a/tests/manual/rhi/msaatexture/msaatexture.cpp b/tests/manual/rhi/msaatexture/msaatexture.cpp index 46a9b2830c..d23a4a8d47 100644 --- a/tests/manual/rhi/msaatexture/msaatexture.cpp +++ b/tests/manual/rhi/msaatexture/msaatexture.cpp @@ -315,7 +315,7 @@ void Window::customRender() // onscreen const QSize outputSizeInPixels = m_sc->currentPixelSize(); - cb->beginPass(m_sc->currentFrameRenderTarget(), QColor::fromRgbF(0.4f, 0.7f, 0.0f, 1.0f), { 1.0f, 0 }); + cb->beginPass(m_sc->currentFrameRenderTarget(), m_clearColor, { 1.0f, 0 }); cb->setGraphicsPipeline(d.psLeft); // showing the non-msaa version cb->setViewport({ 0, 0, float(outputSizeInPixels.width()), float(outputSizeInPixels.height()) }); cb->setShaderResources(); diff --git a/tests/manual/rhi/shadowmap/shadowmap.cpp b/tests/manual/rhi/shadowmap/shadowmap.cpp index 9146be5cc9..424a8b3783 100644 --- a/tests/manual/rhi/shadowmap/shadowmap.cpp +++ b/tests/manual/rhi/shadowmap/shadowmap.cpp @@ -296,7 +296,7 @@ void Window::customRender() cb->endPass(); // main pass - cb->beginPass(m_sc->currentFrameRenderTarget(), QColor::fromRgbF(0.4f, 0.7f, 0.0f, 1.0f), { 1.0f, 0 }); + cb->beginPass(m_sc->currentFrameRenderTarget(), m_clearColor, { 1.0f, 0 }); cb->setGraphicsPipeline(d.ps); cb->setViewport({ 0, 0, float(outputSizeInPixels.width()), float(outputSizeInPixels.height()) }); enqueueScene(cb, d.srb, oneRoundedUniformBlockSize, 0); diff --git a/tests/manual/rhi/shared/examplefw.h b/tests/manual/rhi/shared/examplefw.h index 4bd087473b..220c3d0ff2 100644 --- a/tests/manual/rhi/shared/examplefw.h +++ b/tests/manual/rhi/shared/examplefw.h @@ -127,6 +127,7 @@ QRhiSwapChain::Flags scFlags = 0; QRhi::BeginFrameFlags beginFrameFlags = 0; QRhi::EndFrameFlags endFrameFlags = 0; int framesUntilTdr = -1; +bool transparentBackground = false; class Window : public QWindow { @@ -167,6 +168,8 @@ protected: QOffscreenSurface *m_fallbackSurface = nullptr; #endif + QColor m_clearColor; + friend int main(int, char**); }; @@ -194,6 +197,8 @@ Window::Window() default: break; } + + m_clearColor = transparentBackground ? Qt::transparent : QColor::fromRgbF(0.4f, 0.7f, 0.0f, 1.0f); } Window::~Window() @@ -477,6 +482,9 @@ int main(int argc, char **argv) QCommandLineOption swOption(QLatin1String("software"), QLatin1String("Prefer a software renderer when choosing the adapter. " "Only applicable with some APIs and platforms.")); cmdLineParser.addOption(swOption); + // Allow testing having a semi-transparent window. + QCommandLineOption transparentOption(QLatin1String("transparent"), QLatin1String("Make background transparent")); + cmdLineParser.addOption(transparentOption); cmdLineParser.process(app); if (cmdLineParser.isSet(nullOption)) @@ -493,6 +501,11 @@ int main(int argc, char **argv) qDebug("Selected graphics API is %s", qPrintable(graphicsApiName())); qDebug("This is a multi-api example, use command line arguments to override:\n%s", qPrintable(cmdLineParser.helpText())); + if (cmdLineParser.isSet(transparentOption)) { + transparentBackground = true; + scFlags |= QRhiSwapChain::SurfaceHasPreMulAlpha; + } + #ifdef EXAMPLEFW_PREINIT void preInit(); preInit(); @@ -508,6 +521,9 @@ int main(int argc, char **argv) fmt.setSwapInterval(0); if (scFlags.testFlag(QRhiSwapChain::sRGB)) fmt.setColorSpace(QSurfaceFormat::sRGBColorSpace); + // Exception: The alpha size is not necessarily OpenGL specific. + if (transparentBackground) + fmt.setAlphaBufferSize(8); QSurfaceFormat::setDefaultFormat(fmt); // Vulkan setup. diff --git a/tests/manual/rhi/texuploads/texuploads.cpp b/tests/manual/rhi/texuploads/texuploads.cpp index dc20ffb1fc..f29a989187 100644 --- a/tests/manual/rhi/texuploads/texuploads.cpp +++ b/tests/manual/rhi/texuploads/texuploads.cpp @@ -296,7 +296,7 @@ void Window::customRender() QRhiCommandBuffer *cb = m_sc->currentFrameCommandBuffer(); const QSize outputSizeInPixels = m_sc->currentPixelSize(); - cb->beginPass(m_sc->currentFrameRenderTarget(), QColor::fromRgbF(0.4f, 0.7f, 0.0f, 1.0f), { 1.0f, 0 }, u); + cb->beginPass(m_sc->currentFrameRenderTarget(), m_clearColor, { 1.0f, 0 }, u); cb->setGraphicsPipeline(d.ps); cb->setViewport({ 0, 0, float(outputSizeInPixels.width()), float(outputSizeInPixels.height()) }); diff --git a/tests/manual/rhi/triquadcube/triquadcube.cpp b/tests/manual/rhi/triquadcube/triquadcube.cpp index 76dbe558ab..252ec63e21 100644 --- a/tests/manual/rhi/triquadcube/triquadcube.cpp +++ b/tests/manual/rhi/triquadcube/triquadcube.cpp @@ -230,7 +230,7 @@ void Window::customRender() if (!d.onScreenOnly) d.liveTexCubeRenderer.queueResourceUpdates(u); - cb->beginPass(m_sc->currentFrameRenderTarget(), QColor::fromRgbF(0.4f, 0.7f, 0.0f, 1.0f), { 1.0f, 0 }, u); + cb->beginPass(m_sc->currentFrameRenderTarget(), m_clearColor, { 1.0f, 0 }, u); cb->debugMarkBegin(QByteArrayLiteral("Triangle")); d.triRenderer.queueDraw(cb, outputSize); cb->debugMarkEnd(); |