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