diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2021-09-15 13:28:44 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2021-09-16 22:58:17 +0200 |
commit | 43a42fa19693d8ee1a52a5723aa026ee1ccd5de2 (patch) | |
tree | d936b77ba8c110cfb8dd8261c1997203aa2df612 /src/gui/rhi/qrhi.cpp | |
parent | c5a3cabce0f9fd615a77772002d6e1b5ca121919 (diff) |
rhi: Allow testing renderpass compatibility without the objects
Follow what has been done for QRhiShaderResourceBindings. Have a way
to retrieve an opaque blob (that just happens to be a list of integers)
so that a simple == comparison can be used to determine compatibility
even when the objects from which the blob was retrieved are no longer
alive.
The contract is the following:
bool a = rp1->isCompatible(rp2);
bool b = rp1->serializedFormat() == rp2->serializedFormat();
assert(a == b);
Pick-to: 6.2
Change-Id: I45e7d05eeb6dfa2b2de474da0a0644912aaf174a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
Diffstat (limited to 'src/gui/rhi/qrhi.cpp')
-rw-r--r-- | src/gui/rhi/qrhi.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/gui/rhi/qrhi.cpp b/src/gui/rhi/qrhi.cpp index e924841375..072d100c59 100644 --- a/src/gui/rhi/qrhi.cpp +++ b/src/gui/rhi/qrhi.cpp @@ -2740,7 +2740,17 @@ QRhiResource::Type QRhiRenderPassDescriptor::resourceType() const \l{QRhiTextureRenderTarget::newCompatibleRenderPassDescriptor()}{created} from the same QRhiTextureRenderTarget are always compatible. - \sa newCompatibleRenderPassDescriptor() + Similarly to QRhiShaderResourceBindings, compatibility can also be tested + without having two existing objects available. Extracting the opaque blob by + calling serializedFormat() allows testing for compatibility by comparing the + returned vector to another QRhiRenderPassDescriptor's + serializedFormat(). This has benefits in certain situations, because it + allows testing the compatibility of a QRhiRenderPassDescriptor with a + QRhiGraphicsPipeline even when the QRhiRenderPassDescriptor the pipeline was + originally built was is no longer available (but the data returned from its + serializedFormat() still is). + + \sa newCompatibleRenderPassDescriptor(), serializedFormat() */ /*! @@ -2765,6 +2775,18 @@ QRhiResource::Type QRhiRenderPassDescriptor::resourceType() const */ /*! + \fn QVector<quint32> QRhiRenderPassDescriptor::serializedFormat() const + + \return a vector of integers containing an opaque blob describing the data + relevant for \l{isCompatible()}{compatibility}. Given two + QRhiRenderPassDescriptor objects \c rp1 and \c rp2, if the data returned + from this function is identical, then \c{rp1->isCompatible(rp2)}, and vice + versa hold true as well. + + \sa isCompatible() + */ + +/*! \return a pointer to a backend-specific QRhiNativeHandles subclass, such as QRhiVulkanRenderPassNativeHandles. The returned value is \nullptr when exposing the underlying native resources is not supported by the backend. |