summaryrefslogtreecommitdiffstats
path: root/src/gui/rhi/qrhi_p.h
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2022-04-01 15:01:45 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2022-04-05 19:40:17 +0200
commita5db072dc2e85be1c8c6411b67844a53fafcb522 (patch)
tree5506ec12a8d2b6a121f5ed002d54b8105137c1a4 /src/gui/rhi/qrhi_p.h
parentd72f2ca9ea5e8bc7357f457370b2eb039bb48a2f (diff)
rhi: Add explicit subclass for RTs from swapchains
We want to enable gaining access to the underlying resource(s) by inspecting a QRhiRenderTarget. This is not currently possible for swapchains since there is nothing that references the actual QRhiSwapChain. To clean this up, make an explicit, new QRhiSwapChainRenderTarget subclass. Thus the logic already used in a couple of places to examine the resources attached to a QRhiTextureRenderTarget can now work with swapchain render targets too, by branching based on the resourceType(). This eliminates the somewhat odd setup where a "RenderTarget" resource is QRhiRenderTarget corresponding (but not exposing!) a swapchain, whereas a "TextureRenderTarget" is a QRhiTextureRenderTarget which is a subclass of QRhiRenderTarget. Now we correctly have an (abstract) base and two subclasses, one for each type of render targets. Besides, it allows us to clean up the oddly named Q...ReferenceRenderTarget classes in the backends, which initially tried to indicate that this "render target" merely references (or, in practice, is) a swapchain. We can now have a nice and symmetrical Q...SwapChainRenderTarget and Q...TextureRenderTarget naming scheme. Change-Id: Ib07e9be99a316eec67b94de0860e08f5f4638959 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/gui/rhi/qrhi_p.h')
-rw-r--r--src/gui/rhi/qrhi_p.h16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/gui/rhi/qrhi_p.h b/src/gui/rhi/qrhi_p.h
index 07f3ad69be..bbc404f09b 100644
--- a/src/gui/rhi/qrhi_p.h
+++ b/src/gui/rhi/qrhi_p.h
@@ -74,6 +74,7 @@ class QRhiSampler;
class QRhiCommandBuffer;
class QRhiResourceUpdateBatch;
class QRhiResourceUpdateBatchPrivate;
+class QRhiSwapChain;
class Q_GUI_EXPORT QRhiDepthStencilClearValue
{
@@ -697,7 +698,7 @@ public:
Sampler,
RenderBuffer,
RenderPassDescriptor,
- RenderTarget,
+ SwapChainRenderTarget,
TextureRenderTarget,
ShaderResourceBindings,
GraphicsPipeline,
@@ -1031,8 +1032,6 @@ protected:
class Q_GUI_EXPORT QRhiRenderTarget : public QRhiResource
{
public:
- QRhiResource::Type resourceType() const override;
-
virtual QSize pixelSize() const = 0;
virtual float devicePixelRatio() const = 0;
virtual int sampleCount() const = 0;
@@ -1045,6 +1044,17 @@ protected:
QRhiRenderPassDescriptor *m_renderPassDesc = nullptr;
};
+class Q_GUI_EXPORT QRhiSwapChainRenderTarget : public QRhiRenderTarget
+{
+public:
+ QRhiResource::Type resourceType() const override;
+ QRhiSwapChain *swapChain() const { return m_swapchain; }
+
+protected:
+ QRhiSwapChainRenderTarget(QRhiImplementation *rhi, QRhiSwapChain *swapchain_);
+ QRhiSwapChain *m_swapchain;
+};
+
class Q_GUI_EXPORT QRhiTextureRenderTarget : public QRhiRenderTarget
{
public: