Commit 4c13d723 authored by Laszlo Agocs's avatar Laszlo Agocs
Browse files

Add begin/endOffscreen in the api

only implemented for Vulkan for now
parent 31c51fa0
...@@ -415,6 +415,16 @@ QRhi::FrameOpResult QRhi::endFrame(QRhiSwapChain *swapChain) ...@@ -415,6 +415,16 @@ QRhi::FrameOpResult QRhi::endFrame(QRhiSwapChain *swapChain)
return d->endFrame(swapChain); return d->endFrame(swapChain);
} }
QRhi::FrameOpResult QRhi::beginOffscreenFrame(QRhiCommandBuffer **cb)
{
return d->beginOffscreenFrame(cb);
}
QRhi::FrameOpResult QRhi::endAndWaitOffscreenFrame()
{
return d->endAndWaitOffscreenFrame();
}
void QRhi::beginPass(QRhiRenderTarget *rt, void QRhi::beginPass(QRhiRenderTarget *rt,
QRhiCommandBuffer *cb, QRhiCommandBuffer *cb,
const QRhiColorClearValue &colorClearValue, const QRhiColorClearValue &colorClearValue,
......
...@@ -967,6 +967,22 @@ public: ...@@ -967,6 +967,22 @@ public:
FrameOpResult beginFrame(QRhiSwapChain *swapChain); FrameOpResult beginFrame(QRhiSwapChain *swapChain);
FrameOpResult endFrame(QRhiSwapChain *swapChain); FrameOpResult endFrame(QRhiSwapChain *swapChain);
/*
Rendering without a swapchain is possible as well. This is synchronous in
the sense that end will wait for completion of the submitted commands.
The typical use case is to use it in completely offscreen applications,
e.g. to generate image sequences by rendering and reading back without
ever showing a window.
QRhiCommandBuffer *cb; // not owned
beginOffscreenFrame(&cb);
// ... the usual, set up a QRhiTextureRenderTarget, beginPass-endPass, etc.
endAndWaitOffscreenFrame();
// unlike a normal begin-end, the commands, including any readbacks
// have completed at this point
*/
FrameOpResult beginOffscreenFrame(QRhiCommandBuffer **cb);
FrameOpResult endAndWaitOffscreenFrame();
// Returns an instance to which updates can be queued. Batch instances are // Returns an instance to which updates can be queued. Batch instances are
// pooled and never owned by the application. An instance is returned to // pooled and never owned by the application. An instance is returned to
// the pool after a beginPass() processes it or when it is "canceled" by // the pool after a beginPass() processes it or when it is "canceled" by
......
...@@ -83,6 +83,8 @@ public: ...@@ -83,6 +83,8 @@ public:
virtual QRhiSwapChain *createSwapChain() = 0; virtual QRhiSwapChain *createSwapChain() = 0;
virtual QRhi::FrameOpResult beginFrame(QRhiSwapChain *swapChain) = 0; virtual QRhi::FrameOpResult beginFrame(QRhiSwapChain *swapChain) = 0;
virtual QRhi::FrameOpResult endFrame(QRhiSwapChain *swapChain) = 0; virtual QRhi::FrameOpResult endFrame(QRhiSwapChain *swapChain) = 0;
virtual QRhi::FrameOpResult beginOffscreenFrame(QRhiCommandBuffer **cb) = 0;
virtual QRhi::FrameOpResult endAndWaitOffscreenFrame() = 0;
virtual void beginPass(QRhiRenderTarget *rt, virtual void beginPass(QRhiRenderTarget *rt,
QRhiCommandBuffer *cb, QRhiCommandBuffer *cb,
......
...@@ -497,6 +497,17 @@ QRhi::FrameOpResult QRhiD3D11::endFrame(QRhiSwapChain *swapChain) ...@@ -497,6 +497,17 @@ QRhi::FrameOpResult QRhiD3D11::endFrame(QRhiSwapChain *swapChain)
return QRhi::FrameOpSuccess; return QRhi::FrameOpSuccess;
} }
QRhi::FrameOpResult QRhiD3D11::beginOffscreenFrame(QRhiCommandBuffer **cb)
{
Q_UNUSED(cb);
return QRhi::FrameOpError;
}
QRhi::FrameOpResult QRhiD3D11::endAndWaitOffscreenFrame()
{
return QRhi::FrameOpError;
}
static inline bool isCompressedFormat(QRhiTexture::Format format) static inline bool isCompressedFormat(QRhiTexture::Format format)
{ {
return format >= QRhiTexture::BC1 && format <= QRhiTexture::BC7; return format >= QRhiTexture::BC1 && format <= QRhiTexture::BC7;
......
...@@ -374,6 +374,8 @@ public: ...@@ -374,6 +374,8 @@ public:
QRhiSwapChain *createSwapChain() override; QRhiSwapChain *createSwapChain() override;
QRhi::FrameOpResult beginFrame(QRhiSwapChain *swapChain) override; QRhi::FrameOpResult beginFrame(QRhiSwapChain *swapChain) override;
QRhi::FrameOpResult endFrame(QRhiSwapChain *swapChain) override; QRhi::FrameOpResult endFrame(QRhiSwapChain *swapChain) override;
QRhi::FrameOpResult beginOffscreenFrame(QRhiCommandBuffer **cb) override;
QRhi::FrameOpResult endAndWaitOffscreenFrame() override;
void beginPass(QRhiRenderTarget *rt, void beginPass(QRhiRenderTarget *rt,
QRhiCommandBuffer *cb, QRhiCommandBuffer *cb,
......
...@@ -399,6 +399,17 @@ QRhi::FrameOpResult QRhiGles2::endFrame(QRhiSwapChain *swapChain) ...@@ -399,6 +399,17 @@ QRhi::FrameOpResult QRhiGles2::endFrame(QRhiSwapChain *swapChain)
return QRhi::FrameOpSuccess; return QRhi::FrameOpSuccess;
} }
QRhi::FrameOpResult QRhiGles2::beginOffscreenFrame(QRhiCommandBuffer **cb)
{
Q_UNUSED(cb);
return QRhi::FrameOpError;
}
QRhi::FrameOpResult QRhiGles2::endAndWaitOffscreenFrame()
{
return QRhi::FrameOpError;
}
void QRhiGles2::commitResourceUpdates(QRhiResourceUpdateBatch *resourceUpdates) void QRhiGles2::commitResourceUpdates(QRhiResourceUpdateBatch *resourceUpdates)
{ {
QRhiResourceUpdateBatchPrivate *ud = QRhiResourceUpdateBatchPrivate::get(resourceUpdates); QRhiResourceUpdateBatchPrivate *ud = QRhiResourceUpdateBatchPrivate::get(resourceUpdates);
......
...@@ -332,6 +332,8 @@ public: ...@@ -332,6 +332,8 @@ public:
QRhiSwapChain *createSwapChain() override; QRhiSwapChain *createSwapChain() override;
QRhi::FrameOpResult beginFrame(QRhiSwapChain *swapChain) override; QRhi::FrameOpResult beginFrame(QRhiSwapChain *swapChain) override;
QRhi::FrameOpResult endFrame(QRhiSwapChain *swapChain) override; QRhi::FrameOpResult endFrame(QRhiSwapChain *swapChain) override;
QRhi::FrameOpResult beginOffscreenFrame(QRhiCommandBuffer **cb) override;
QRhi::FrameOpResult endAndWaitOffscreenFrame() override;
void beginPass(QRhiRenderTarget *rt, void beginPass(QRhiRenderTarget *rt,
QRhiCommandBuffer *cb, QRhiCommandBuffer *cb,
......
...@@ -557,6 +557,17 @@ QRhi::FrameOpResult QRhiMetal::endFrame(QRhiSwapChain *swapChain) ...@@ -557,6 +557,17 @@ QRhi::FrameOpResult QRhiMetal::endFrame(QRhiSwapChain *swapChain)
return QRhi::FrameOpSuccess; return QRhi::FrameOpSuccess;
} }
QRhi::FrameOpResult QRhiMetal::beginOffscreenFrame(QRhiCommandBuffer **cb)
{
Q_UNUSED(cb);
return QRhi::FrameOpError;
}
QRhi::FrameOpResult QRhiMetal::endAndWaitOffscreenFrame()
{
return QRhi::FrameOpError;
}
MTLRenderPassDescriptor *QRhiMetalData::createDefaultRenderPass(bool hasDepthStencil, MTLRenderPassDescriptor *QRhiMetalData::createDefaultRenderPass(bool hasDepthStencil,
const QRhiColorClearValue &colorClearValue, const QRhiColorClearValue &colorClearValue,
const QRhiDepthStencilClearValue &depthStencilClearValue) const QRhiDepthStencilClearValue &depthStencilClearValue)
......
...@@ -263,6 +263,8 @@ public: ...@@ -263,6 +263,8 @@ public:
QRhiSwapChain *createSwapChain() override; QRhiSwapChain *createSwapChain() override;
QRhi::FrameOpResult beginFrame(QRhiSwapChain *swapChain) override; QRhi::FrameOpResult beginFrame(QRhiSwapChain *swapChain) override;
QRhi::FrameOpResult endFrame(QRhiSwapChain *swapChain) override; QRhi::FrameOpResult endFrame(QRhiSwapChain *swapChain) override;
QRhi::FrameOpResult beginOffscreenFrame(QRhiCommandBuffer **cb) override;
QRhi::FrameOpResult endAndWaitOffscreenFrame() override;
void beginPass(QRhiRenderTarget *rt, void beginPass(QRhiRenderTarget *rt,
QRhiCommandBuffer *cb, QRhiCommandBuffer *cb,
......
...@@ -325,6 +325,8 @@ public: ...@@ -325,6 +325,8 @@ public:
QRhiSwapChain *createSwapChain() override; QRhiSwapChain *createSwapChain() override;
QRhi::FrameOpResult beginFrame(QRhiSwapChain *swapChain) override; QRhi::FrameOpResult beginFrame(QRhiSwapChain *swapChain) override;
QRhi::FrameOpResult endFrame(QRhiSwapChain *swapChain) override; QRhi::FrameOpResult endFrame(QRhiSwapChain *swapChain) override;
QRhi::FrameOpResult beginOffscreenFrame(QRhiCommandBuffer **cb) override;
QRhi::FrameOpResult endAndWaitOffscreenFrame() override;
void beginPass(QRhiRenderTarget *rt, void beginPass(QRhiRenderTarget *rt,
QRhiCommandBuffer *cb, QRhiCommandBuffer *cb,
...@@ -392,8 +394,6 @@ public: ...@@ -392,8 +394,6 @@ public:
QRhi::FrameOpResult endWrapperFrame(QRhiSwapChain *swapChain); QRhi::FrameOpResult endWrapperFrame(QRhiSwapChain *swapChain);
QRhi::FrameOpResult beginNonWrapperFrame(QRhiSwapChain *swapChain); QRhi::FrameOpResult beginNonWrapperFrame(QRhiSwapChain *swapChain);
QRhi::FrameOpResult endNonWrapperFrame(QRhiSwapChain *swapChain); QRhi::FrameOpResult endNonWrapperFrame(QRhiSwapChain *swapChain);
QRhi::FrameOpResult beginOffscreenFrame(QRhiCommandBuffer **cb);
QRhi::FrameOpResult endAndWaitOffscreenFrame();
void prepareNewFrame(QRhiCommandBuffer *cb); void prepareNewFrame(QRhiCommandBuffer *cb);
void finishFrame(); void finishFrame();
void commitResourceUpdates(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates); void commitResourceUpdates(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment