diff options
Diffstat (limited to 'src/gui/rhi/qrhinull.cpp')
-rw-r--r-- | src/gui/rhi/qrhinull.cpp | 69 |
1 files changed, 58 insertions, 11 deletions
diff --git a/src/gui/rhi/qrhinull.cpp b/src/gui/rhi/qrhinull.cpp index ec1b5aa64a..566b922c1b 100644 --- a/src/gui/rhi/qrhinull.cpp +++ b/src/gui/rhi/qrhinull.cpp @@ -1,7 +1,7 @@ -// Copyright (C) 2019 The Qt Company Ltd. +// 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_p.h" +#include "qrhinull_p.h" #include <qmath.h> #include <QPainter> @@ -9,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 @@ -28,9 +31,12 @@ QT_BEGIN_NAMESPACE /*! \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) @@ -344,6 +350,12 @@ 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); @@ -456,7 +468,7 @@ void QRhiNull::resourceUpdate(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *re QNullBuffer *bufD = QRHI_RES(QNullBuffer, u.buf); 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 + u.offset, size_t(u.readSize)); @@ -664,10 +676,11 @@ bool QNullTexture::create() 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); - m_depth = qMax(1, m_depth); const int mipLevelCount = hasMipMaps ? rhiD->q->mipLevelsForSize(size) : 1; - m_arraySize = qMax(0, m_arraySize); - const int layerCount = is3D ? m_depth : (isCube ? 6 : (isArray ? m_arraySize : 1)); + const int layerCount = is3D ? qMax(1, m_depth) + : (isCube ? 6 + : (isArray ? qMax(0, m_arraySize) + : 1)); if (m_format == RGBA8) { image.resize(layerCount); @@ -716,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; } @@ -735,6 +753,9 @@ QNullRenderPassDescriptor::~QNullRenderPassDescriptor() void QNullRenderPassDescriptor::destroy() { + QRHI_RES_RHI(QRhiNull); + if (rhiD) + rhiD->unregisterResource(this); } bool QNullRenderPassDescriptor::isCompatible(const QRhiRenderPassDescriptor *other) const @@ -745,7 +766,10 @@ bool QNullRenderPassDescriptor::isCompatible(const QRhiRenderPassDescriptor *oth QRhiRenderPassDescriptor *QNullRenderPassDescriptor::newCompatibleRenderPassDescriptor() const { - return new QNullRenderPassDescriptor(m_rhi); + QNullRenderPassDescriptor *rpD = new QNullRenderPassDescriptor(m_rhi); + QRHI_RES_RHI(QRhiNull); + rhiD->registerResource(rpD, false); + return rpD; } QVector<quint32> QNullRenderPassDescriptor::serializedFormat() const @@ -798,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() @@ -820,6 +850,7 @@ bool QNullTextureRenderTarget::create() d.pixelSize = m_desc.depthTexture()->pixelSize(); } QRhiRenderTargetAttachmentTracker::updateResIdList<QNullTexture, QNullRenderBuffer>(m_desc, &d.currentResIdList); + rhiD->registerResource(this); return true; } @@ -853,6 +884,9 @@ QNullShaderResourceBindings::~QNullShaderResourceBindings() void QNullShaderResourceBindings::destroy() { + QRHI_RES_RHI(QRhiNull); + if (rhiD) + rhiD->unregisterResource(this); } bool QNullShaderResourceBindings::create() @@ -863,6 +897,7 @@ bool QNullShaderResourceBindings::create() rhiD->updateLayoutDesc(this); + rhiD->registerResource(this, false); return true; } @@ -883,6 +918,9 @@ QNullGraphicsPipeline::~QNullGraphicsPipeline() void QNullGraphicsPipeline::destroy() { + QRHI_RES_RHI(QRhiNull); + if (rhiD) + rhiD->unregisterResource(this); } bool QNullGraphicsPipeline::create() @@ -891,6 +929,7 @@ bool QNullGraphicsPipeline::create() if (!rhiD->sanityCheckGraphicsPipeline(this)) return false; + rhiD->registerResource(this); return true; } @@ -906,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; } @@ -969,7 +1013,10 @@ bool QNullSwapChain::isFormatSupported(Format f) 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() |