summaryrefslogtreecommitdiffstats
path: root/src/gui/rhi/qrhinull.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/rhi/qrhinull.cpp')
-rw-r--r--src/gui/rhi/qrhinull.cpp355
1 files changed, 249 insertions, 106 deletions
diff --git a/src/gui/rhi/qrhinull.cpp b/src/gui/rhi/qrhinull.cpp
index a81f885d5a..566b922c1b 100644
--- a/src/gui/rhi/qrhinull.cpp
+++ b/src/gui/rhi/qrhinull.cpp
@@ -1,40 +1,7 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the Qt Gui module
-**
-** $QT_BEGIN_LICENSE:LGPL3$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPLv3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or later as published by the Free
-** Software Foundation and appearing in the file LICENSE.GPL included in
-** the packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 2.0 requirements will be
-** met: http://www.gnu.org/licenses/gpl-2.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qrhinull_p_p.h"
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#include "qrhinull_p.h"
#include <qmath.h>
#include <QPainter>
@@ -42,10 +9,13 @@ QT_BEGIN_NAMESPACE
/*!
\class QRhiNullInitParams
- \internal
\inmodule QtGui
+ \since 6.6
\brief Null backend specific initialization parameters.
+ \note This is a RHI API with limited compatibility guarantees, see \l QRhi
+ for details.
+
A Null QRhi needs no special parameters for initialization.
\badcode
@@ -56,15 +26,17 @@ QT_BEGIN_NAMESPACE
The Null backend does not issue any graphics calls and creates no
resources. All QRhi operations will succeed as normal so applications can
still be run, albeit potentially at an unthrottled speed, depending on
- their frame rendering strategy. The backend reports resources to
- QRhiProfiler as usual.
+ their frame rendering strategy.
*/
/*!
\class QRhiNullNativeHandles
- \internal
\inmodule QtGui
+ \since 6.6
\brief Empty.
+
+ \note This is a RHI API with limited compatibility guarantees, see \l QRhi
+ for details.
*/
QRhiNull::QRhiNull(QRhiNullInitParams *params)
@@ -93,7 +65,7 @@ QRhiSwapChain *QRhiNull::createSwapChain()
return new QNullSwapChain(this);
}
-QRhiBuffer *QRhiNull::createBuffer(QRhiBuffer::Type type, QRhiBuffer::UsageFlags usage, int size)
+QRhiBuffer *QRhiNull::createBuffer(QRhiBuffer::Type type, QRhiBuffer::UsageFlags usage, quint32 size)
{
return new QNullBuffer(this, type, usage, size);
}
@@ -149,10 +121,27 @@ int QRhiNull::resourceLimit(QRhi::ResourceLimit limit) const
return 1;
case QRhi::MaxAsyncReadbackFrames:
return 1;
- default:
- Q_UNREACHABLE();
+ case QRhi::MaxThreadGroupsPerDimension:
+ return 0;
+ case QRhi::MaxThreadsPerThreadGroup:
+ return 0;
+ case QRhi::MaxThreadGroupX:
+ return 0;
+ case QRhi::MaxThreadGroupY:
return 0;
+ case QRhi::MaxThreadGroupZ:
+ return 0;
+ case QRhi::TextureArraySizeMax:
+ return 2048;
+ case QRhi::MaxUniformBufferRange:
+ return 65536;
+ case QRhi::MaxVertexInputs:
+ return 32;
+ case QRhi::MaxVertexOutputs:
+ return 32;
}
+
+ Q_UNREACHABLE_RETURN(0);
}
const QRhiNativeHandles *QRhiNull::nativeHandles()
@@ -160,9 +149,16 @@ const QRhiNativeHandles *QRhiNull::nativeHandles()
return &nativeHandlesStruct;
}
-void QRhiNull::sendVMemStatsToProfiler()
+QRhiDriverInfo QRhiNull::driverInfo() const
{
- // nothing to do here
+ QRhiDriverInfo info;
+ info.deviceName = QByteArrayLiteral("Null");
+ return info;
+}
+
+QRhiStats QRhiNull::statistics()
+{
+ return {};
}
bool QRhiNull::makeThreadLocalNativeContextCurrent()
@@ -181,6 +177,16 @@ bool QRhiNull::isDeviceLost() const
return false;
}
+QByteArray QRhiNull::pipelineCacheData()
+{
+ return QByteArray();
+}
+
+void QRhiNull::setPipelineCacheData(const QByteArray &data)
+{
+ Q_UNUSED(data);
+}
+
QRhiRenderBuffer *QRhiNull::createRenderBuffer(QRhiRenderBuffer::Type type, const QSize &pixelSize,
int sampleCount, QRhiRenderBuffer::Flags flags,
QRhiTexture::Format backingFormatHint)
@@ -188,10 +194,11 @@ QRhiRenderBuffer *QRhiNull::createRenderBuffer(QRhiRenderBuffer::Type type, cons
return new QNullRenderBuffer(this, type, pixelSize, sampleCount, flags, backingFormatHint);
}
-QRhiTexture *QRhiNull::createTexture(QRhiTexture::Format format, const QSize &pixelSize,
+QRhiTexture *QRhiNull::createTexture(QRhiTexture::Format format,
+ const QSize &pixelSize, int depth, int arraySize,
int sampleCount, QRhiTexture::Flags flags)
{
- return new QNullTexture(this, format, pixelSize, sampleCount, flags);
+ return new QNullTexture(this, format, pixelSize, depth, arraySize, sampleCount, flags);
}
QRhiSampler *QRhiNull::createSampler(QRhiSampler::Filter magFilter, QRhiSampler::Filter minFilter,
@@ -343,12 +350,16 @@ void QRhiNull::endExternal(QRhiCommandBuffer *cb)
Q_UNUSED(cb);
}
+double QRhiNull::lastCompletedGpuTime(QRhiCommandBuffer *cb)
+{
+ Q_UNUSED(cb);
+ return 0;
+}
+
QRhi::FrameOpResult QRhiNull::beginFrame(QRhiSwapChain *swapChain, QRhi::BeginFrameFlags flags)
{
Q_UNUSED(flags);
currentSwapChain = swapChain;
- QRhiProfilerPrivate *rhiP = profilerPrivateOrNull();
- QRHI_PROF_F(beginSwapChainFrame(swapChain));
return QRhi::FrameOpSuccess;
}
@@ -356,9 +367,6 @@ QRhi::FrameOpResult QRhiNull::endFrame(QRhiSwapChain *swapChain, QRhi::EndFrameF
{
Q_UNUSED(flags);
QNullSwapChain *swapChainD = QRHI_RES(QNullSwapChain, swapChain);
- QRhiProfilerPrivate *rhiP = profilerPrivateOrNull();
- QRHI_PROF_F(endSwapChainFrame(swapChain, swapChainD->frameCount + 1));
- QRHI_PROF_F(swapChainFrameGpuTime(swapChain, 0.000666f));
swapChainD->frameCount += 1;
currentSwapChain = nullptr;
return QRhi::FrameOpSuccess;
@@ -385,9 +393,9 @@ QRhi::FrameOpResult QRhiNull::finish()
void QRhiNull::simulateTextureUpload(const QRhiResourceUpdateBatchPrivate::TextureOp &u)
{
QNullTexture *texD = QRHI_RES(QNullTexture, u.dst);
- for (int layer = 0; layer < QRhi::MAX_LAYERS; ++layer) {
- for (int level = 0; level < QRhi::MAX_LEVELS; ++level) {
- for (const QRhiTextureSubresourceUploadDescription &subresDesc : qAsConst(u.subresDesc[layer][level])) {
+ for (int layer = 0, maxLayer = u.subresDesc.size(); layer < maxLayer; ++layer) {
+ for (int level = 0; level < QRhi::MAX_MIP_LEVELS; ++level) {
+ for (const QRhiTextureSubresourceUploadDescription &subresDesc : std::as_const(u.subresDesc[layer][level])) {
if (!subresDesc.image().isNull()) {
const QImage src = subresDesc.image();
QPainter painter(&texD->image[layer][level]);
@@ -407,12 +415,15 @@ void QRhiNull::simulateTextureUpload(const QRhiResourceUpdateBatchPrivate::Textu
// sourceTopLeft is not supported on this path as per QRhi docs
const char *src = subresDesc.data().constData();
const int srcBpl = w * 4;
+ int srcStride = srcBpl;
+ if (subresDesc.dataStride())
+ srcStride = subresDesc.dataStride();
const QPoint dstOffset = subresDesc.destinationTopLeft();
uchar *dst = texD->image[layer][level].bits();
const int dstBpl = texD->image[layer][level].bytesPerLine();
for (int y = 0; y < h; ++y) {
memcpy(dst + dstOffset.x() * 4 + (y + dstOffset.y()) * dstBpl,
- src + y * srcBpl,
+ src + y * srcStride,
size_t(srcBpl));
}
}
@@ -449,22 +460,24 @@ void QRhiNull::resourceUpdate(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *re
{
Q_UNUSED(cb);
QRhiResourceUpdateBatchPrivate *ud = QRhiResourceUpdateBatchPrivate::get(resourceUpdates);
- for (const QRhiResourceUpdateBatchPrivate::BufferOp &u : ud->bufferOps) {
+ for (int opIdx = 0; opIdx < ud->activeBufferOpCount; ++opIdx) {
+ const QRhiResourceUpdateBatchPrivate::BufferOp &u(ud->bufferOps[opIdx]);
if (u.type == QRhiResourceUpdateBatchPrivate::BufferOp::DynamicUpdate
|| u.type == QRhiResourceUpdateBatchPrivate::BufferOp::StaticUpload)
{
QNullBuffer *bufD = QRHI_RES(QNullBuffer, u.buf);
- memcpy(bufD->data.data() + u.offset, u.data.constData(), size_t(u.data.size()));
+ memcpy(bufD->data + u.offset, u.data.constData(), size_t(u.data.size()));
} else if (u.type == QRhiResourceUpdateBatchPrivate::BufferOp::Read) {
- QRhiBufferReadbackResult *result = u.result;
+ QRhiReadbackResult *result = u.result;
result->data.resize(u.readSize);
QNullBuffer *bufD = QRHI_RES(QNullBuffer, u.buf);
- memcpy(result->data.data(), bufD->data.constData() + u.offset, size_t(u.readSize));
+ memcpy(result->data.data(), bufD->data + u.offset, size_t(u.readSize));
if (result->completed)
result->completed();
}
}
- for (const QRhiResourceUpdateBatchPrivate::TextureOp &u : ud->textureOps) {
+ for (int opIdx = 0; opIdx < ud->activeTextureOpCount; ++opIdx) {
+ const QRhiResourceUpdateBatchPrivate::TextureOp &u(ud->textureOps[opIdx]);
if (u.type == QRhiResourceUpdateBatchPrivate::TextureOp::Upload) {
if (u.dst->format() == QRhiTexture::RGBA8)
simulateTextureUpload(u);
@@ -484,7 +497,7 @@ void QRhiNull::resourceUpdate(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *re
}
quint32 bytesPerLine = 0;
quint32 byteSize = 0;
- textureFormatInfo(result->format, result->pixelSize, &bytesPerLine, &byteSize);
+ textureFormatInfo(result->format, result->pixelSize, &bytesPerLine, &byteSize, nullptr);
if (texD && texD->format() == QRhiTexture::RGBA8) {
result->data.resize(int(byteSize));
const QImage &src(texD->image[u.rb.layer()][u.rb.level()]);
@@ -510,13 +523,21 @@ void QRhiNull::beginPass(QRhiCommandBuffer *cb,
QRhiRenderTarget *rt,
const QColor &colorClearValue,
const QRhiDepthStencilClearValue &depthStencilClearValue,
- QRhiResourceUpdateBatch *resourceUpdates)
+ QRhiResourceUpdateBatch *resourceUpdates,
+ QRhiCommandBuffer::BeginPassFlags flags)
{
- Q_UNUSED(rt);
Q_UNUSED(colorClearValue);
Q_UNUSED(depthStencilClearValue);
+ Q_UNUSED(flags);
+
if (resourceUpdates)
resourceUpdate(cb, resourceUpdates);
+
+ if (rt->resourceType() == QRhiRenderTarget::TextureRenderTarget) {
+ QNullTextureRenderTarget *rtTex = QRHI_RES(QNullTextureRenderTarget, rt);
+ if (!QRhiRenderTargetAttachmentTracker::isUpToDate<QNullTexture, QNullRenderBuffer>(rtTex->description(), rtTex->d.currentResIdList))
+ rtTex->create();
+ }
}
void QRhiNull::endPass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates)
@@ -525,8 +546,11 @@ void QRhiNull::endPass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceU
resourceUpdate(cb, resourceUpdates);
}
-void QRhiNull::beginComputePass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates)
+void QRhiNull::beginComputePass(QRhiCommandBuffer *cb,
+ QRhiResourceUpdateBatch *resourceUpdates,
+ QRhiCommandBuffer::BeginPassFlags flags)
{
+ Q_UNUSED(flags);
if (resourceUpdates)
resourceUpdate(cb, resourceUpdates);
}
@@ -537,7 +561,7 @@ void QRhiNull::endComputePass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *re
resourceUpdate(cb, resourceUpdates);
}
-QNullBuffer::QNullBuffer(QRhiImplementation *rhi, Type type, UsageFlags usage, int size)
+QNullBuffer::QNullBuffer(QRhiImplementation *rhi, Type type, UsageFlags usage, quint32 size)
: QRhiBuffer(rhi, type, usage, size)
{
}
@@ -549,21 +573,34 @@ QNullBuffer::~QNullBuffer()
void QNullBuffer::destroy()
{
- data.clear();
+ delete[] data;
+ data = nullptr;
- QRHI_PROF;
- QRHI_PROF_F(releaseBuffer(this));
+ QRHI_RES_RHI(QRhiNull);
+ if (rhiD)
+ rhiD->unregisterResource(this);
}
bool QNullBuffer::create()
{
- data.fill('\0', m_size);
+ if (data)
+ destroy();
+
+ data = new char[m_size];
+ memset(data, 0, m_size);
+
+ QRHI_RES_RHI(QRhiNull);
+ rhiD->registerResource(this);
- QRHI_PROF;
- QRHI_PROF_F(newBuffer(this, uint(m_size), 1, 0));
return true;
}
+char *QNullBuffer::beginFullDynamicBufferUpdateForCurrentFrame()
+{
+ Q_ASSERT(m_type == Dynamic);
+ return data;
+}
+
QNullRenderBuffer::QNullRenderBuffer(QRhiImplementation *rhi, Type type, const QSize &pixelSize,
int sampleCount, QRhiRenderBuffer::Flags flags,
QRhiTexture::Format backingFormatHint)
@@ -578,14 +615,24 @@ QNullRenderBuffer::~QNullRenderBuffer()
void QNullRenderBuffer::destroy()
{
- QRHI_PROF;
- QRHI_PROF_F(releaseRenderBuffer(this));
+ valid = false;
+
+ QRHI_RES_RHI(QRhiNull);
+ if (rhiD)
+ rhiD->unregisterResource(this);
}
bool QNullRenderBuffer::create()
{
- QRHI_PROF;
- QRHI_PROF_F(newRenderBuffer(this, false, false, 1));
+ if (valid)
+ destroy();
+
+ valid = true;
+ generation += 1;
+
+ QRHI_RES_RHI(QRhiNull);
+ rhiD->registerResource(this);
+
return true;
}
@@ -594,9 +641,9 @@ QRhiTexture::Format QNullRenderBuffer::backingFormat() const
return m_type == Color ? QRhiTexture::RGBA8 : QRhiTexture::UnknownFormat;
}
-QNullTexture::QNullTexture(QRhiImplementation *rhi, Format format, const QSize &pixelSize,
- int sampleCount, Flags flags)
- : QRhiTexture(rhi, format, pixelSize, sampleCount, flags)
+QNullTexture::QNullTexture(QRhiImplementation *rhi, Format format, const QSize &pixelSize, int depth,
+ int arraySize, int sampleCount, Flags flags)
+ : QRhiTexture(rhi, format, pixelSize, depth, arraySize, sampleCount, flags)
{
}
@@ -607,20 +654,36 @@ QNullTexture::~QNullTexture()
void QNullTexture::destroy()
{
- QRHI_PROF;
- QRHI_PROF_F(releaseTexture(this));
+ valid = false;
+
+ QRHI_RES_RHI(QRhiNull);
+ if (rhiD)
+ rhiD->unregisterResource(this);
}
bool QNullTexture::create()
{
+ if (valid)
+ destroy();
+
+ valid = true;
+
QRHI_RES_RHI(QRhiNull);
const bool isCube = m_flags.testFlag(CubeMap);
+ const bool is3D = m_flags.testFlag(ThreeDimensional);
+ const bool isArray = m_flags.testFlag(TextureArray);
const bool hasMipMaps = m_flags.testFlag(MipMapped);
- QSize size = m_pixelSize.isEmpty() ? QSize(1, 1) : m_pixelSize;
+ const bool is1D = m_flags.testFlags(OneDimensional);
+ QSize size = is1D ? QSize(qMax(1, m_pixelSize.width()), 1)
+ : (m_pixelSize.isEmpty() ? QSize(1, 1) : m_pixelSize);
const int mipLevelCount = hasMipMaps ? rhiD->q->mipLevelsForSize(size) : 1;
- const int layerCount = isCube ? 6 : 1;
+ const int layerCount = is3D ? qMax(1, m_depth)
+ : (isCube ? 6
+ : (isArray ? qMax(0, m_arraySize)
+ : 1));
if (m_format == RGBA8) {
+ image.resize(layerCount);
for (int layer = 0; layer < layerCount; ++layer) {
for (int level = 0; level < mipLevelCount; ++level) {
image[layer][level] = QImage(rhiD->q->sizeForMipLevel(level, size),
@@ -630,21 +693,26 @@ bool QNullTexture::create()
}
}
- QRHI_PROF;
- QRHI_PROF_F(newTexture(this, true, mipLevelCount, layerCount, 1));
+ generation += 1;
+
+ rhiD->registerResource(this);
+
return true;
}
bool QNullTexture::createFrom(QRhiTexture::NativeTexture src)
{
Q_UNUSED(src);
+ if (valid)
+ destroy();
+
+ valid = true;
+
+ generation += 1;
+
QRHI_RES_RHI(QRhiNull);
- const bool isCube = m_flags.testFlag(CubeMap);
- const bool hasMipMaps = m_flags.testFlag(MipMapped);
- QSize size = m_pixelSize.isEmpty() ? QSize(1, 1) : m_pixelSize;
- const int mipLevelCount = hasMipMaps ? rhiD->q->mipLevelsForSize(size) : 1;
- QRHI_PROF;
- QRHI_PROF_F(newTexture(this, false, mipLevelCount, isCube ? 6 : 1, 1));
+ rhiD->registerResource(this);
+
return true;
}
@@ -661,10 +729,15 @@ QNullSampler::~QNullSampler()
void QNullSampler::destroy()
{
+ QRHI_RES_RHI(QRhiNull);
+ if (rhiD)
+ rhiD->unregisterResource(this);
}
bool QNullSampler::create()
{
+ QRHI_RES_RHI(QRhiNull);
+ rhiD->registerResource(this);
return true;
}
@@ -680,6 +753,9 @@ QNullRenderPassDescriptor::~QNullRenderPassDescriptor()
void QNullRenderPassDescriptor::destroy()
{
+ QRHI_RES_RHI(QRhiNull);
+ if (rhiD)
+ rhiD->unregisterResource(this);
}
bool QNullRenderPassDescriptor::isCompatible(const QRhiRenderPassDescriptor *other) const
@@ -688,32 +764,45 @@ bool QNullRenderPassDescriptor::isCompatible(const QRhiRenderPassDescriptor *oth
return true;
}
-QNullReferenceRenderTarget::QNullReferenceRenderTarget(QRhiImplementation *rhi)
- : QRhiRenderTarget(rhi),
+QRhiRenderPassDescriptor *QNullRenderPassDescriptor::newCompatibleRenderPassDescriptor() const
+{
+ QNullRenderPassDescriptor *rpD = new QNullRenderPassDescriptor(m_rhi);
+ QRHI_RES_RHI(QRhiNull);
+ rhiD->registerResource(rpD, false);
+ return rpD;
+}
+
+QVector<quint32> QNullRenderPassDescriptor::serializedFormat() const
+{
+ return {};
+}
+
+QNullSwapChainRenderTarget::QNullSwapChainRenderTarget(QRhiImplementation *rhi, QRhiSwapChain *swapchain)
+ : QRhiSwapChainRenderTarget(rhi, swapchain),
d(rhi)
{
}
-QNullReferenceRenderTarget::~QNullReferenceRenderTarget()
+QNullSwapChainRenderTarget::~QNullSwapChainRenderTarget()
{
destroy();
}
-void QNullReferenceRenderTarget::destroy()
+void QNullSwapChainRenderTarget::destroy()
{
}
-QSize QNullReferenceRenderTarget::pixelSize() const
+QSize QNullSwapChainRenderTarget::pixelSize() const
{
return d.pixelSize;
}
-float QNullReferenceRenderTarget::devicePixelRatio() const
+float QNullSwapChainRenderTarget::devicePixelRatio() const
{
return d.dpr;
}
-int QNullReferenceRenderTarget::sampleCount() const
+int QNullSwapChainRenderTarget::sampleCount() const
{
return 1;
}
@@ -733,11 +822,17 @@ QNullTextureRenderTarget::~QNullTextureRenderTarget()
void QNullTextureRenderTarget::destroy()
{
+ QRHI_RES_RHI(QRhiNull);
+ if (rhiD)
+ rhiD->unregisterResource(this);
}
QRhiRenderPassDescriptor *QNullTextureRenderTarget::newCompatibleRenderPassDescriptor()
{
- return new QNullRenderPassDescriptor(m_rhi);
+ QNullRenderPassDescriptor *rpD = new QNullRenderPassDescriptor(m_rhi);
+ QRHI_RES_RHI(QRhiNull);
+ rhiD->registerResource(rpD, false);
+ return rpD;
}
bool QNullTextureRenderTarget::create()
@@ -754,11 +849,16 @@ bool QNullTextureRenderTarget::create()
} else if (m_desc.depthTexture()) {
d.pixelSize = m_desc.depthTexture()->pixelSize();
}
+ QRhiRenderTargetAttachmentTracker::updateResIdList<QNullTexture, QNullRenderBuffer>(m_desc, &d.currentResIdList);
+ rhiD->registerResource(this);
return true;
}
QSize QNullTextureRenderTarget::pixelSize() const
{
+ if (!QRhiRenderTargetAttachmentTracker::isUpToDate<QNullTexture, QNullRenderBuffer>(m_desc, d.currentResIdList))
+ const_cast<QNullTextureRenderTarget *>(this)->create();
+
return d.pixelSize;
}
@@ -784,13 +884,28 @@ QNullShaderResourceBindings::~QNullShaderResourceBindings()
void QNullShaderResourceBindings::destroy()
{
+ QRHI_RES_RHI(QRhiNull);
+ if (rhiD)
+ rhiD->unregisterResource(this);
}
bool QNullShaderResourceBindings::create()
{
+ QRHI_RES_RHI(QRhiNull);
+ if (!rhiD->sanityCheckShaderResourceBindings(this))
+ return false;
+
+ rhiD->updateLayoutDesc(this);
+
+ rhiD->registerResource(this, false);
return true;
}
+void QNullShaderResourceBindings::updateResources(UpdateFlags flags)
+{
+ Q_UNUSED(flags);
+}
+
QNullGraphicsPipeline::QNullGraphicsPipeline(QRhiImplementation *rhi)
: QRhiGraphicsPipeline(rhi)
{
@@ -803,6 +918,9 @@ QNullGraphicsPipeline::~QNullGraphicsPipeline()
void QNullGraphicsPipeline::destroy()
{
+ QRHI_RES_RHI(QRhiNull);
+ if (rhiD)
+ rhiD->unregisterResource(this);
}
bool QNullGraphicsPipeline::create()
@@ -811,6 +929,7 @@ bool QNullGraphicsPipeline::create()
if (!rhiD->sanityCheckGraphicsPipeline(this))
return false;
+ rhiD->registerResource(this);
return true;
}
@@ -826,10 +945,15 @@ QNullComputePipeline::~QNullComputePipeline()
void QNullComputePipeline::destroy()
{
+ QRHI_RES_RHI(QRhiNull);
+ if (rhiD)
+ rhiD->unregisterResource(this);
}
bool QNullComputePipeline::create()
{
+ QRHI_RES_RHI(QRhiNull);
+ rhiD->registerResource(this);
return true;
}
@@ -850,7 +974,7 @@ void QNullCommandBuffer::destroy()
QNullSwapChain::QNullSwapChain(QRhiImplementation *rhi)
: QRhiSwapChain(rhi),
- rt(rhi),
+ rt(rhi, this),
cb(rhi)
{
}
@@ -862,8 +986,9 @@ QNullSwapChain::~QNullSwapChain()
void QNullSwapChain::destroy()
{
- QRHI_PROF;
- QRHI_PROF_F(releaseSwapChain(this));
+ QRHI_RES_RHI(QRhiNull);
+ if (rhiD)
+ rhiD->unregisterResource(this);
}
QRhiCommandBuffer *QNullSwapChain::currentFrameCommandBuffer()
@@ -881,19 +1006,37 @@ QSize QNullSwapChain::surfacePixelSize()
return QSize(1280, 720);
}
+bool QNullSwapChain::isFormatSupported(Format f)
+{
+ return f == SDR;
+}
+
QRhiRenderPassDescriptor *QNullSwapChain::newCompatibleRenderPassDescriptor()
{
- return new QNullRenderPassDescriptor(m_rhi);
+ QNullRenderPassDescriptor *rpD = new QNullRenderPassDescriptor(m_rhi);
+ QRHI_RES_RHI(QRhiNull);
+ rhiD->registerResource(rpD, false);
+ return rpD;
}
bool QNullSwapChain::createOrResize()
{
+ const bool needsRegistration = !window || window != m_window;
+ if (window && window != m_window)
+ destroy();
+
+ window = m_window;
m_currentPixelSize = surfacePixelSize();
+ rt.setRenderPassDescriptor(m_renderPassDesc); // for the public getter in QRhiRenderTarget
rt.d.rp = QRHI_RES(QNullRenderPassDescriptor, m_renderPassDesc);
rt.d.pixelSize = m_currentPixelSize;
frameCount = 0;
- QRHI_PROF;
- QRHI_PROF_F(resizeSwapChain(this, 1, 0, 1));
+
+ if (needsRegistration) {
+ QRHI_RES_RHI(QRhiNull);
+ rhiD->registerResource(this);
+ }
+
return true;
}