summaryrefslogtreecommitdiffstats
path: root/src/gui/rhi/qrhi_p.h
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2020-09-30 14:08:53 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2020-10-02 13:14:08 +0200
commitd92b0e18c1b987e60304c2e366ff374405adaab1 (patch)
tree07734992c8ce08cedf3214c1893dc033c21c2996 /src/gui/rhi/qrhi_p.h
parent3080194ae41128e91da59301a7e221303a2f04a5 (diff)
rhi: Make per-frame flags per-pass where appropriate
ExternalContentsInPass becomes a per-pass flag now. Why is this beneficial? Because while Qt Quick has no choice for its render pass, not being able to guess if the application wants to do some native rendering in there, Quick 3D's render passes, all the ones that are under Quick3D's control, do not have native rendering from the application in them, and so using secondary command buffers with Vulkan is not necessary. Introduce something similar for compute and OpenGL. By knowing that none of the resources used in a pass are used with a compute pass (e.g. because we know that there are no compute passes at all) a small amount of time can be saved by skipping tracking buffers and textures because the only purpose of said tracking is to generate barriers that are relevant only to compute. Change-Id: I0eceb4774d87803c73a39db527f5707a9f4d75c1 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.h32
1 files changed, 20 insertions, 12 deletions
diff --git a/src/gui/rhi/qrhi_p.h b/src/gui/rhi/qrhi_p.h
index d3e32f2723..adbb1b61ff 100644
--- a/src/gui/rhi/qrhi_p.h
+++ b/src/gui/rhi/qrhi_p.h
@@ -1331,6 +1331,12 @@ public:
IndexUInt32
};
+ enum BeginPassFlag {
+ ExternalContent = 0x01,
+ DoNotTrackResourcesForCompute = 0x02
+ };
+ Q_DECLARE_FLAGS(BeginPassFlags, BeginPassFlag)
+
QRhiResource::Type resourceType() const override;
void resourceUpdate(QRhiResourceUpdateBatch *resourceUpdates);
@@ -1338,7 +1344,8 @@ public:
void beginPass(QRhiRenderTarget *rt,
const QColor &colorClearValue,
const QRhiDepthStencilClearValue &depthStencilClearValue,
- QRhiResourceUpdateBatch *resourceUpdates = nullptr);
+ QRhiResourceUpdateBatch *resourceUpdates = nullptr,
+ BeginPassFlags flags = {});
void endPass(QRhiResourceUpdateBatch *resourceUpdates = nullptr);
void setGraphicsPipeline(QRhiGraphicsPipeline *ps);
@@ -1371,7 +1378,7 @@ public:
void debugMarkEnd();
void debugMarkMsg(const QByteArray &msg);
- void beginComputePass(QRhiResourceUpdateBatch *resourceUpdates = nullptr);
+ void beginComputePass(QRhiResourceUpdateBatch *resourceUpdates = nullptr, BeginPassFlags flags = {});
void endComputePass(QRhiResourceUpdateBatch *resourceUpdates = nullptr);
void setComputePipeline(QRhiComputePipeline *ps);
void dispatch(int x, int y, int z);
@@ -1384,6 +1391,8 @@ protected:
QRhiCommandBuffer(QRhiImplementation *rhi);
};
+Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiCommandBuffer::BeginPassFlags)
+
struct Q_GUI_EXPORT QRhiReadbackResult
{
std::function<void()> completed = nullptr;
@@ -1484,7 +1493,6 @@ public:
};
enum BeginFrameFlag {
- ExternalContentsInPass = 0x01
};
Q_DECLARE_FLAGS(BeginFrameFlags, BeginFrameFlag)
@@ -1510,7 +1518,7 @@ public:
static QRhi *create(Implementation impl,
QRhiInitParams *params,
- Flags flags = Flags(),
+ Flags flags = {},
QRhiNativeHandles *importDevice = nullptr);
Implementation backend() const;
@@ -1531,13 +1539,13 @@ public:
QRhiRenderBuffer *newRenderBuffer(QRhiRenderBuffer::Type type,
const QSize &pixelSize,
int sampleCount = 1,
- QRhiRenderBuffer::Flags flags = QRhiRenderBuffer::Flags(),
+ QRhiRenderBuffer::Flags flags = {},
QRhiTexture::Format backingFormatHint = QRhiTexture::UnknownFormat);
QRhiTexture *newTexture(QRhiTexture::Format format,
const QSize &pixelSize,
int sampleCount = 1,
- QRhiTexture::Flags flags = QRhiTexture::Flags());
+ QRhiTexture::Flags flags = {});
QRhiSampler *newSampler(QRhiSampler::Filter magFilter,
QRhiSampler::Filter minFilter,
@@ -1547,16 +1555,16 @@ public:
QRhiSampler::AddressMode addressW = QRhiSampler::Repeat);
QRhiTextureRenderTarget *newTextureRenderTarget(const QRhiTextureRenderTargetDescription &desc,
- QRhiTextureRenderTarget::Flags flags = QRhiTextureRenderTarget::Flags());
+ QRhiTextureRenderTarget::Flags flags = {});
QRhiSwapChain *newSwapChain();
- FrameOpResult beginFrame(QRhiSwapChain *swapChain, BeginFrameFlags flags = BeginFrameFlags());
- FrameOpResult endFrame(QRhiSwapChain *swapChain, EndFrameFlags flags = EndFrameFlags());
+ FrameOpResult beginFrame(QRhiSwapChain *swapChain, BeginFrameFlags flags = {});
+ FrameOpResult endFrame(QRhiSwapChain *swapChain, EndFrameFlags flags = {});
bool isRecordingFrame() const;
int currentFrameSlot() const;
- FrameOpResult beginOffscreenFrame(QRhiCommandBuffer **cb, BeginFrameFlags flags = BeginFrameFlags());
- FrameOpResult endOffscreenFrame(EndFrameFlags flags = EndFrameFlags());
+ FrameOpResult beginOffscreenFrame(QRhiCommandBuffer **cb, BeginFrameFlags flags = {});
+ FrameOpResult endOffscreenFrame(EndFrameFlags flags = {});
QRhi::FrameOpResult finish();
@@ -1576,7 +1584,7 @@ public:
QMatrix4x4 clipSpaceCorrMatrix() const;
- bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags = QRhiTexture::Flags()) const;
+ bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags = {}) const;
bool isFeatureSupported(QRhi::Feature feature) const;
int resourceLimit(ResourceLimit limit) const;