Commit 75bda640 authored by Laszlo Agocs's avatar Laszlo Agocs

Add readback api skeleton

not yet implemented
parent 525be680
...@@ -94,9 +94,12 @@ int main(int argc, char **argv) ...@@ -94,9 +94,12 @@ int main(int argc, char **argv)
rt->setRenderPassDescriptor(rp); rt->setRenderPassDescriptor(rp);
rt->build(); rt->build();
QRhiCommandBuffer *cb; for (int frame = 0; frame < 20; ++frame) {
if (r->beginOffscreenFrame(&cb) == QRhi::FrameOpSuccess) { QRhiCommandBuffer *cb;
qDebug("Generating offscreen frame"); if (r->beginOffscreenFrame(&cb) != QRhi::FrameOpSuccess)
break;
qDebug("Generating offscreen frame %d", frame);
r->beginPass(rt, cb, { 0, 1, 0, 1 }, { 1, 0 }, nullptr); r->beginPass(rt, cb, { 0, 1, 0, 1 }, { 1, 0 }, nullptr);
r->endPass(cb); r->endPass(cb);
......
...@@ -487,6 +487,11 @@ void QRhi::drawIndexed(QRhiCommandBuffer *cb, quint32 indexCount, ...@@ -487,6 +487,11 @@ void QRhi::drawIndexed(QRhiCommandBuffer *cb, quint32 indexCount,
d->drawIndexed(cb, indexCount, instanceCount, firstIndex, vertexOffset, firstInstance); d->drawIndexed(cb, indexCount, instanceCount, firstIndex, vertexOffset, firstInstance);
} }
void QRhi::readback(QRhiCommandBuffer *cb, QRhiReadback *rb)
{
d->readback(cb, rb);
}
QVector<int> QRhi::supportedSampleCounts() const QVector<int> QRhi::supportedSampleCounts() const
{ {
return d->supportedSampleCounts(); return d->supportedSampleCounts();
......
...@@ -280,6 +280,13 @@ Q_DECLARE_TYPEINFO(QRhiTextureUploadDescription::Layer::MipLevel, Q_MOVABLE_TYPE ...@@ -280,6 +280,13 @@ Q_DECLARE_TYPEINFO(QRhiTextureUploadDescription::Layer::MipLevel, Q_MOVABLE_TYPE
Q_DECLARE_TYPEINFO(QRhiTextureUploadDescription::Layer, Q_MOVABLE_TYPE); Q_DECLARE_TYPEINFO(QRhiTextureUploadDescription::Layer, Q_MOVABLE_TYPE);
Q_DECLARE_TYPEINFO(QRhiTextureUploadDescription, Q_MOVABLE_TYPE); Q_DECLARE_TYPEINFO(QRhiTextureUploadDescription, Q_MOVABLE_TYPE);
struct Q_RHI_EXPORT QRhiReadback
{
// ###
};
Q_DECLARE_TYPEINFO(QRhiReadback, Q_MOVABLE_TYPE);
class Q_RHI_EXPORT QRhiResource class Q_RHI_EXPORT QRhiResource
{ {
public: public:
...@@ -976,9 +983,9 @@ public: ...@@ -976,9 +983,9 @@ public:
QRhiCommandBuffer *cb; // not owned QRhiCommandBuffer *cb; // not owned
beginOffscreenFrame(&cb); beginOffscreenFrame(&cb);
// ... the usual, set up a QRhiTextureRenderTarget, beginPass-endPass, etc. // ... the usual, set up a QRhiTextureRenderTarget, beginPass-endPass, etc.
readback(cb, someTexture, rb);
endAndWaitOffscreenFrame(); endAndWaitOffscreenFrame();
// unlike a normal begin-end, the commands, including any readbacks // the results are available in rb
// have completed at this point
*/ */
FrameOpResult beginOffscreenFrame(QRhiCommandBuffer **cb); FrameOpResult beginOffscreenFrame(QRhiCommandBuffer **cb);
FrameOpResult endAndWaitOffscreenFrame(); FrameOpResult endAndWaitOffscreenFrame();
...@@ -1030,6 +1037,9 @@ public: ...@@ -1030,6 +1037,9 @@ public:
quint32 instanceCount = 1, quint32 firstIndex = 0, quint32 instanceCount = 1, quint32 firstIndex = 0,
qint32 vertexOffset = 0, quint32 firstInstance = 0); qint32 vertexOffset = 0, quint32 firstInstance = 0);
// Must only be called outside a begin-endPass section.
void readback(QRhiCommandBuffer *cb, QRhiReadback *rb);
QVector<int> supportedSampleCounts() const; QVector<int> supportedSampleCounts() const;
int ubufAlignment() const; int ubufAlignment() const;
......
...@@ -113,6 +113,8 @@ public: ...@@ -113,6 +113,8 @@ public:
quint32 instanceCount, quint32 firstIndex, quint32 instanceCount, quint32 firstIndex,
qint32 vertexOffset, quint32 firstInstance) = 0; qint32 vertexOffset, quint32 firstInstance) = 0;
virtual void readback(QRhiCommandBuffer *cb, QRhiReadback *rb) = 0;
virtual QVector<int> supportedSampleCounts() const = 0; virtual QVector<int> supportedSampleCounts() const = 0;
virtual int ubufAlignment() const = 0; virtual int ubufAlignment() const = 0;
virtual bool isYUpInFramebuffer() const = 0; virtual bool isYUpInFramebuffer() const = 0;
......
...@@ -453,6 +453,12 @@ void QRhiD3D11::drawIndexed(QRhiCommandBuffer *cb, quint32 indexCount, ...@@ -453,6 +453,12 @@ void QRhiD3D11::drawIndexed(QRhiCommandBuffer *cb, quint32 indexCount,
cbD->commands.append(cmd); cbD->commands.append(cmd);
} }
void QRhiD3D11::readback(QRhiCommandBuffer *cb, QRhiReadback *rb)
{
Q_UNUSED(cb);
Q_UNUSED(rb);
}
QRhi::FrameOpResult QRhiD3D11::beginFrame(QRhiSwapChain *swapChain) QRhi::FrameOpResult QRhiD3D11::beginFrame(QRhiSwapChain *swapChain)
{ {
Q_ASSERT(!inFrame); Q_ASSERT(!inFrame);
......
...@@ -405,6 +405,8 @@ public: ...@@ -405,6 +405,8 @@ public:
quint32 instanceCount, quint32 firstIndex, quint32 instanceCount, quint32 firstIndex,
qint32 vertexOffset, quint32 firstInstance) override; qint32 vertexOffset, quint32 firstInstance) override;
void readback(QRhiCommandBuffer *cb, QRhiReadback *rb) override;
QVector<int> supportedSampleCounts() const override; QVector<int> supportedSampleCounts() const override;
int ubufAlignment() const override; int ubufAlignment() const override;
bool isYUpInFramebuffer() const override; bool isYUpInFramebuffer() const override;
......
...@@ -366,6 +366,12 @@ void QRhiGles2::drawIndexed(QRhiCommandBuffer *cb, quint32 indexCount, ...@@ -366,6 +366,12 @@ void QRhiGles2::drawIndexed(QRhiCommandBuffer *cb, quint32 indexCount,
cbD->commands.append(cmd); cbD->commands.append(cmd);
} }
void QRhiGles2::readback(QRhiCommandBuffer *cb, QRhiReadback *rb)
{
Q_UNUSED(cb);
Q_UNUSED(rb);
}
QRhi::FrameOpResult QRhiGles2::beginFrame(QRhiSwapChain *swapChain) QRhi::FrameOpResult QRhiGles2::beginFrame(QRhiSwapChain *swapChain)
{ {
Q_ASSERT(!inFrame); Q_ASSERT(!inFrame);
......
...@@ -363,6 +363,8 @@ public: ...@@ -363,6 +363,8 @@ public:
quint32 instanceCount, quint32 firstIndex, quint32 instanceCount, quint32 firstIndex,
qint32 vertexOffset, quint32 firstInstance) override; qint32 vertexOffset, quint32 firstInstance) override;
void readback(QRhiCommandBuffer *cb, QRhiReadback *rb) override;
QVector<int> supportedSampleCounts() const override; QVector<int> supportedSampleCounts() const override;
int ubufAlignment() const override; int ubufAlignment() const override;
bool isYUpInFramebuffer() const override; bool isYUpInFramebuffer() const override;
......
...@@ -496,6 +496,12 @@ void QRhiMetal::drawIndexed(QRhiCommandBuffer *cb, quint32 indexCount, ...@@ -496,6 +496,12 @@ void QRhiMetal::drawIndexed(QRhiCommandBuffer *cb, quint32 indexCount,
baseInstance: firstInstance]; baseInstance: firstInstance];
} }
void QRhiMetal::readback(QRhiCommandBuffer *cb, QRhiReadback *rb)
{
Q_UNUSED(cb);
Q_UNUSED(rb);
}
QRhi::FrameOpResult QRhiMetal::beginFrame(QRhiSwapChain *swapChain) QRhi::FrameOpResult QRhiMetal::beginFrame(QRhiSwapChain *swapChain)
{ {
Q_ASSERT(!inFrame); Q_ASSERT(!inFrame);
......
...@@ -294,6 +294,8 @@ public: ...@@ -294,6 +294,8 @@ public:
quint32 instanceCount, quint32 firstIndex, quint32 instanceCount, quint32 firstIndex,
qint32 vertexOffset, quint32 firstInstance) override; qint32 vertexOffset, quint32 firstInstance) override;
void readback(QRhiCommandBuffer *cb, QRhiReadback *rb) override;
QVector<int> supportedSampleCounts() const override; QVector<int> supportedSampleCounts() const override;
int ubufAlignment() const override; int ubufAlignment() const override;
bool isYUpInFramebuffer() const override; bool isYUpInFramebuffer() const override;
......
...@@ -2315,6 +2315,12 @@ void QRhiVulkan::drawIndexed(QRhiCommandBuffer *cb, quint32 indexCount, ...@@ -2315,6 +2315,12 @@ void QRhiVulkan::drawIndexed(QRhiCommandBuffer *cb, quint32 indexCount,
df->vkCmdDrawIndexed(QRHI_RES(QVkCommandBuffer, cb)->cb, indexCount, instanceCount, firstIndex, vertexOffset, firstInstance); df->vkCmdDrawIndexed(QRHI_RES(QVkCommandBuffer, cb)->cb, indexCount, instanceCount, firstIndex, vertexOffset, firstInstance);
} }
void QRhiVulkan::readback(QRhiCommandBuffer *cb, QRhiReadback *rb)
{
Q_UNUSED(cb);
Q_UNUSED(rb);
}
static inline VkBufferUsageFlagBits toVkBufferUsage(QRhiBuffer::UsageFlags usage) static inline VkBufferUsageFlagBits toVkBufferUsage(QRhiBuffer::UsageFlags usage)
{ {
int u = 0; int u = 0;
......
...@@ -356,6 +356,8 @@ public: ...@@ -356,6 +356,8 @@ public:
quint32 instanceCount, quint32 firstIndex, quint32 instanceCount, quint32 firstIndex,
qint32 vertexOffset, quint32 firstInstance) override; qint32 vertexOffset, quint32 firstInstance) override;
void readback(QRhiCommandBuffer *cb, QRhiReadback *rb) override;
QVector<int> supportedSampleCounts() const override; QVector<int> supportedSampleCounts() const override;
int ubufAlignment() const override; int ubufAlignment() const override;
bool isYUpInFramebuffer() const override; bool isYUpInFramebuffer() const override;
......
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