Commit fe83848a authored by Laszlo Agocs's avatar Laszlo Agocs
Browse files

Convert cb api to QRhiCommandBuffer members

...in order to make the api nicer. Does not affect the internals.
parent eb7a7ce1
......@@ -283,12 +283,12 @@ void Window::customRender()
QRhiCommandBuffer *cb = m_sc->currentFrameCommandBuffer();
const QSize outputSizeInPixels = m_sc->effectivePixelSize();
m_r->beginPass(m_sc->currentFrameRenderTarget(), cb, { 0.4f, 0.7f, 0.0f, 1.0f }, { 1.0f, 0 }, u);
cb->beginPass(m_sc->currentFrameRenderTarget(), { 0.4f, 0.7f, 0.0f, 1.0f }, { 1.0f, 0 }, u);
m_r->setGraphicsPipeline(cb, d.ps);
m_r->setViewport(cb, { 0, 0, float(outputSizeInPixels.width()), float(outputSizeInPixels.height()) });
m_r->setVertexInput(cb, 0, { { d.vbuf, 0 }, { d.vbuf, 36 * 3 * sizeof(float) } });
m_r->draw(cb, 36);
cb->setGraphicsPipeline(d.ps);
cb->setViewport({ 0, 0, float(outputSizeInPixels.width()), float(outputSizeInPixels.height()) });
cb->setVertexInput(0, { { d.vbuf, 0 }, { d.vbuf, 36 * 3 * sizeof(float) } });
cb->draw(36);
m_r->endPass(cb);
cb->endPass();
}
......@@ -480,14 +480,14 @@ void Window::render()
const QSize outputSizeInPixels = m_sc->effectivePixelSize();
// Apply buffer updates, clear, start the renderpass (where applicable).
m_r->beginPass(m_sc->currentFrameRenderTarget(), cb, { 0.4f, 0.7f, 0.0f, 1.0f }, { 1.0f, 0 }, u);
cb->beginPass(m_sc->currentFrameRenderTarget(), { 0.4f, 0.7f, 0.0f, 1.0f }, { 1.0f, 0 }, u);
m_r->setGraphicsPipeline(cb, m_ps);
m_r->setViewport(cb, { 0, 0, float(outputSizeInPixels.width()), float(outputSizeInPixels.height()) });
m_r->setVertexInput(cb, 0, { { m_vbuf, 0 } });
m_r->draw(cb, 3);
cb->setGraphicsPipeline(m_ps);
cb->setViewport({ 0, 0, float(outputSizeInPixels.width()), float(outputSizeInPixels.height()) });
cb->setVertexInput(0, { { m_vbuf, 0 } });
cb->draw(3);
m_r->endPass(cb);
cb->endPass();
// Submit.
m_r->endFrame(m_sc);
......
......@@ -162,17 +162,17 @@ int main(int argc, char **argv)
opacity = qBound(0.0f, opacity, 1.0f);
}
r->beginPass(rt, cb, { 0, 1, 0, 1 }, { 1, 0 }, u);
r->setGraphicsPipeline(cb, ps);
r->setViewport(cb, { 0, 0, 1280, 720 });
r->setVertexInput(cb, 0, { { vbuf, 0 } });
r->draw(cb, 3);
r->endPass(cb);
cb->beginPass(rt, { 0, 1, 0, 1 }, { 1, 0 }, u);
cb->setGraphicsPipeline(ps);
cb->setViewport({ 0, 0, 1280, 720 });
cb->setVertexInput(0, { { vbuf, 0 } });
cb->draw(3);
cb->endPass();
QRhiReadbackDescription rb(tex);
QRhiReadbackResult rbResult;
rbResult.completed = [frame] { qDebug(" - readback %d completed", frame); };
r->readback(cb, rb, &rbResult);
cb->readback(rb, &rbResult);
qDebug("Submit and wait");
r->endOffscreenFrame();
......
......@@ -175,17 +175,17 @@ int main(int argc, char **argv)
opacity = qBound(0.0f, opacity, 1.0f);
}
r->beginPass(rt, cb, { 0, 1, 0, 1 }, { 1, 0 }, u);
r->setGraphicsPipeline(cb, ps);
r->setViewport(cb, { 0, 0, 1280, 720 });
r->setVertexInput(cb, 0, { { vbuf, 0 } });
r->draw(cb, 3);
r->endPass(cb);
cb->beginPass(rt, { 0, 1, 0, 1 }, { 1, 0 }, u);
cb->setGraphicsPipeline(ps);
cb->setViewport({ 0, 0, 1280, 720 });
cb->setVertexInput(0, { { vbuf, 0 } });
cb->draw(3);
cb->endPass();
QRhiReadbackDescription rb(tex);
QRhiReadbackResult rbResult;
rbResult.completed = [frame] { qDebug(" - readback %d completed", frame); };
r->readback(cb, rb, &rbResult);
cb->readback(rb, &rbResult);
qDebug("Submit and wait");
r->endOffscreenFrame();
......
......@@ -185,17 +185,17 @@ int main(int argc, char **argv)
opacity = qBound(0.0f, opacity, 1.0f);
}
r->beginPass(rt, cb, { 0, 1, 0, 1 }, { 1, 0 }, u);
r->setGraphicsPipeline(cb, ps);
r->setViewport(cb, { 0, 0, 1280, 720 });
r->setVertexInput(cb, 0, { { vbuf, 0 } });
r->draw(cb, 3);
r->endPass(cb);
cb->beginPass(rt, { 0, 1, 0, 1 }, { 1, 0 }, u);
cb->setGraphicsPipeline(ps);
cb->setViewport({ 0, 0, 1280, 720 });
cb->setVertexInput(0, { { vbuf, 0 } });
cb->draw(3);
cb->endPass();
QRhiReadbackDescription rb(tex);
QRhiReadbackResult rbResult;
rbResult.completed = [frame] { qDebug(" - readback %d completed", frame); };
r->readback(cb, rb, &rbResult);
cb->readback(rb, &rbResult);
qDebug("Submit and wait");
r->endOffscreenFrame();
......
......@@ -246,7 +246,7 @@ void ExampleWindow::render()
if (!m_onScreenOnly)
m_liveTexCubeRenderer.queueResourceUpdates(u);
m_r->beginPass(m_sc->currentFrameRenderTarget(), cb, { 0.4f, 0.7f, 0.0f, 1.0f }, { 1.0f, 0 }, u);
cb->beginPass(m_sc->currentFrameRenderTarget(), { 0.4f, 0.7f, 0.0f, 1.0f }, { 1.0f, 0 }, u);
m_triRenderer.queueDraw(cb, outputSize);
if (!m_triangleOnly) {
m_quadRenderer.queueDraw(cb, outputSize);
......@@ -254,7 +254,7 @@ void ExampleWindow::render()
}
if (!m_onScreenOnly)
m_liveTexCubeRenderer.queueDraw(cb, outputSize);
m_r->endPass(cb);
cb->endPass();
#ifdef READBACK_SWAPCHAIN
QRhiReadbackDescription rb; // no texture given -> backbuffer
......
......@@ -147,8 +147,8 @@ void QuadRenderer::queueResourceUpdates(QRhiResourceUpdateBatch *resourceUpdates
void QuadRenderer::queueDraw(QRhiCommandBuffer *cb, const QSize &/*outputSizeInPixels*/)
{
m_r->setGraphicsPipeline(cb, m_ps, m_srb);
//m_r->setViewport(cb, QRhiViewport(0, 0, outputSizeInPixels.width(), outputSizeInPixels.height()));
m_r->setVertexInput(cb, 0, { { m_vbuf, 0 } }, m_ibuf, 0, QRhi::IndexUInt16);
m_r->drawIndexed(cb, 6);
cb->setGraphicsPipeline(m_ps, m_srb);
//cb->setViewport(QRhiViewport(0, 0, outputSizeInPixels.width(), outputSizeInPixels.height()));
cb->setVertexInput(0, { { m_vbuf, 0 } }, m_ibuf, 0, QRhiCommandBuffer::IndexUInt16);
cb->drawIndexed(6);
}
......@@ -211,8 +211,8 @@ void TexturedCubeRenderer::queueResourceUpdates(QRhiResourceUpdateBatch *resourc
void TexturedCubeRenderer::queueDraw(QRhiCommandBuffer *cb, const QSize &outputSizeInPixels)
{
m_r->setGraphicsPipeline(cb, m_ps);
m_r->setViewport(cb, QRhiViewport(0, 0, outputSizeInPixels.width(), outputSizeInPixels.height()));
m_r->setVertexInput(cb, 0, { { m_vbuf, 0 }, { m_vbuf, 36 * 3 * sizeof(float) } });
m_r->draw(cb, 36);
cb->setGraphicsPipeline(m_ps);
cb->setViewport(QRhiViewport(0, 0, outputSizeInPixels.width(), outputSizeInPixels.height()));
cb->setVertexInput(0, { { m_vbuf, 0 }, { m_vbuf, 36 * 3 * sizeof(float) } });
cb->draw(36);
}
......@@ -272,15 +272,15 @@ void TriangleOnCubeRenderer::queueOffscreenPass(QRhiCommandBuffer *cb)
m_image = QImage();
}
m_r->beginPass(m_rt, cb, { 0.0f, 0.4f, 0.7f, 1.0f }, { 1.0f, 0 }, u);
cb->beginPass(m_rt, { 0.0f, 0.4f, 0.7f, 1.0f }, { 1.0f, 0 }, u);
m_offscreenTriangle.queueDraw(cb, OFFSCREEN_SIZE);
m_r->endPass(cb);
cb->endPass();
}
void TriangleOnCubeRenderer::queueDraw(QRhiCommandBuffer *cb, const QSize &outputSizeInPixels)
{
m_r->setGraphicsPipeline(cb, m_ps);
m_r->setViewport(cb, QRhiViewport(0, 0, outputSizeInPixels.width(), outputSizeInPixels.height()));
m_r->setVertexInput(cb, 0, { { m_vbuf, 0 }, { m_vbuf, 36 * 3 * sizeof(float) } });
m_r->draw(cb, 36);
cb->setGraphicsPipeline(m_ps);
cb->setViewport(QRhiViewport(0, 0, outputSizeInPixels.width(), outputSizeInPixels.height()));
cb->setVertexInput(0, { { m_vbuf, 0 }, { m_vbuf, 36 * 3 * sizeof(float) } });
cb->draw(36);
}
......@@ -199,8 +199,8 @@ void TriangleRenderer::queueResourceUpdates(QRhiResourceUpdateBatch *resourceUpd
void TriangleRenderer::queueDraw(QRhiCommandBuffer *cb, const QSize &outputSizeInPixels)
{
m_r->setGraphicsPipeline(cb, m_ps);
m_r->setViewport(cb, QRhiViewport(0, 0, outputSizeInPixels.width(), outputSizeInPixels.height()));
m_r->setVertexInput(cb, 0, { { m_vbuf, 0 } });
m_r->draw(cb, 3);
cb->setGraphicsPipeline(m_ps);
cb->setViewport(QRhiViewport(0, 0, outputSizeInPixels.width(), outputSizeInPixels.height()));
cb->setVertexInput(0, { { m_vbuf, 0 } });
cb->draw(3);
}
......@@ -256,14 +256,14 @@ void Window::customRender()
QRhiCommandBuffer *cb = m_sc->currentFrameCommandBuffer();
const QSize outputSizeInPixels = m_sc->effectivePixelSize();
m_r->beginPass(m_sc->currentFrameRenderTarget(), cb, { 0.4f, 0.7f, 0.0f, 1.0f }, { 1.0f, 0 }, u);
cb->beginPass(m_sc->currentFrameRenderTarget(), { 0.4f, 0.7f, 0.0f, 1.0f }, { 1.0f, 0 }, u);
m_r->setGraphicsPipeline(cb, d.ps);
m_r->setViewport(cb, { 0, 0, float(outputSizeInPixels.width()), float(outputSizeInPixels.height()) });
m_r->setVertexInput(cb, 0, { { d.vbuf, 0 }, { d.vbuf, 36 * 3 * sizeof(float) } });
m_r->draw(cb, 36);
cb->setGraphicsPipeline(d.ps);
cb->setViewport({ 0, 0, float(outputSizeInPixels.width()), float(outputSizeInPixels.height()) });
cb->setVertexInput(0, { { d.vbuf, 0 }, { d.vbuf, 36 * 3 * sizeof(float) } });
cb->draw(36);
m_r->endPass(cb);
cb->endPass();
d.frameCount += 1;
}
......@@ -117,9 +117,9 @@ void Renderer::startNextFrame()
QRhiResourceUpdateBatch *u = m_r->nextResourceUpdateBatch();
m_triRenderer.queueResourceUpdates(u);
m_r->beginPass(m_sc->currentFrameRenderTarget(), cb, { 0.4f, 0.7f, 0.0f, 1.0f }, { 1.0f, 0 }, u);
cb->beginPass(m_sc->currentFrameRenderTarget(), { 0.4f, 0.7f, 0.0f, 1.0f }, { 1.0f, 0 }, u);
m_triRenderer.queueDraw(cb, m_sc->effectivePixelSize());
m_r->endPass(cb);
cb->endPass();
m_r->endFrame(m_sc);
......
......@@ -512,6 +512,70 @@ void QRhiResourceUpdateBatchPrivate::merge(QRhiResourceUpdateBatchPrivate *other
texturePrepares += other->texturePrepares;
}
void QRhiCommandBuffer::beginPass(QRhiRenderTarget *rt,
const QRhiColorClearValue &colorClearValue,
const QRhiDepthStencilClearValue &depthStencilClearValue,
QRhiResourceUpdateBatch *resourceUpdates)
{
rhi->beginPass(rt, this, colorClearValue, depthStencilClearValue, resourceUpdates);
}
void QRhiCommandBuffer::endPass()
{
rhi->endPass(this);
}
void QRhiCommandBuffer::setGraphicsPipeline(QRhiGraphicsPipeline *ps,
QRhiShaderResourceBindings *srb)
{
rhi->setGraphicsPipeline(this, ps, srb);
}
void QRhiCommandBuffer::setVertexInput(int startBinding, const QVector<VertexInput> &bindings,
QRhiBuffer *indexBuf, quint32 indexOffset,
IndexFormat indexFormat)
{
rhi->setVertexInput(this, startBinding, bindings, indexBuf, indexOffset, indexFormat);
}
void QRhiCommandBuffer::setViewport(const QRhiViewport &viewport)
{
rhi->setViewport(this, viewport);
}
void QRhiCommandBuffer::setScissor(const QRhiScissor &scissor)
{
rhi->setScissor(this, scissor);
}
void QRhiCommandBuffer::setBlendConstants(const QVector4D &c)
{
rhi->setBlendConstants(this, c);
}
void QRhiCommandBuffer::setStencilRef(quint32 refValue)
{
rhi->setStencilRef(this, refValue);
}
void QRhiCommandBuffer::draw(quint32 vertexCount,
quint32 instanceCount, quint32 firstVertex, quint32 firstInstance)
{
rhi->draw(this, vertexCount, instanceCount, firstVertex, firstInstance);
}
void QRhiCommandBuffer::drawIndexed(quint32 indexCount,
quint32 instanceCount, quint32 firstIndex,
qint32 vertexOffset, quint32 firstInstance)
{
rhi->drawIndexed(this, indexCount, instanceCount, firstIndex, vertexOffset, firstInstance);
}
bool QRhiCommandBuffer::readback(const QRhiReadbackDescription &rb, QRhiReadbackResult *result)
{
return rhi->readback(this, rb, result);
}
int QRhi::ubufAligned(int v) const
{
const int byteAlign = ubufAlignment();
......@@ -615,78 +679,11 @@ QRhi::FrameOpResult QRhi::endOffscreenFrame()
return d->endOffscreenFrame();
}
bool QRhi::readback(QRhiCommandBuffer *cb, const QRhiReadbackDescription &rb, QRhiReadbackResult *result)
{
return d->readback(cb, rb, result);
}
QRhi::FrameOpResult QRhi::finish()
{
return d->finish();
}
void QRhi::beginPass(QRhiRenderTarget *rt,
QRhiCommandBuffer *cb,
const QRhiColorClearValue &colorClearValue,
const QRhiDepthStencilClearValue &depthStencilClearValue,
QRhiResourceUpdateBatch *resourceUpdates)
{
d->beginPass(rt, cb, colorClearValue, depthStencilClearValue, resourceUpdates);
}
void QRhi::endPass(QRhiCommandBuffer *cb)
{
d->endPass(cb);
}
void QRhi::setGraphicsPipeline(QRhiCommandBuffer *cb,
QRhiGraphicsPipeline *ps,
QRhiShaderResourceBindings *srb)
{
d->setGraphicsPipeline(cb, ps, srb);
}
void QRhi::setVertexInput(QRhiCommandBuffer *cb,
int startBinding, const QVector<VertexInput> &bindings,
QRhiBuffer *indexBuf, quint32 indexOffset,
IndexFormat indexFormat)
{
d->setVertexInput(cb, startBinding, bindings, indexBuf, indexOffset, indexFormat);
}
void QRhi::setViewport(QRhiCommandBuffer *cb, const QRhiViewport &viewport)
{
d->setViewport(cb, viewport);
}
void QRhi::setScissor(QRhiCommandBuffer *cb, const QRhiScissor &scissor)
{
d->setScissor(cb, scissor);
}
void QRhi::setBlendConstants(QRhiCommandBuffer *cb, const QVector4D &c)
{
d->setBlendConstants(cb, c);
}
void QRhi::setStencilRef(QRhiCommandBuffer *cb, quint32 refValue)
{
d->setStencilRef(cb, refValue);
}
void QRhi::draw(QRhiCommandBuffer *cb, quint32 vertexCount,
quint32 instanceCount, quint32 firstVertex, quint32 firstInstance)
{
d->draw(cb, vertexCount, instanceCount, firstVertex, firstInstance);
}
void QRhi::drawIndexed(QRhiCommandBuffer *cb, quint32 indexCount,
quint32 instanceCount, quint32 firstIndex,
qint32 vertexOffset, quint32 firstInstance)
{
d->drawIndexed(cb, indexCount, instanceCount, firstIndex, vertexOffset, firstInstance);
}
QVector<int> QRhi::supportedSampleCounts() const
{
return d->supportedSampleCounts();
......
......@@ -55,6 +55,8 @@ class QRhiBuffer;
class QRhiRenderBuffer;
class QRhiTexture;
class QRhiSampler;
class QRhiCommandBuffer;
class QRhiResourceUpdateBatch;
struct QRhiResourceUpdateBatchPrivate;
// C++ object ownership rules:
......@@ -784,13 +786,6 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiGraphicsPipeline::Flags)
Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiGraphicsPipeline::ColorMask)
Q_DECLARE_TYPEINFO(QRhiGraphicsPipeline::TargetBlend, Q_MOVABLE_TYPE);
class Q_RHI_EXPORT QRhiCommandBuffer : public QRhiResource
{
protected:
QRhiCommandBuffer(QRhiImplementation *rhi);
void *m_reserved;
};
class Q_RHI_EXPORT QRhiSwapChain : public QRhiResource
{
public:
......@@ -863,6 +858,92 @@ protected:
Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiSwapChain::SurfaceImportFlags)
struct Q_RHI_EXPORT QRhiReadbackResult
{
std::function<void()> completed = nullptr;
QRhiTexture::Format format;
QSize pixelSize;
QByteArray data;
}; // non-movable due to the std::function
class Q_RHI_EXPORT QRhiCommandBuffer : public QRhiResource
{
public:
enum IndexFormat {
IndexUInt16,
IndexUInt32
};
void beginPass(QRhiRenderTarget *rt,
const QRhiColorClearValue &colorClearValue, // ignored when rt has PreserveColorContents
const QRhiDepthStencilClearValue &depthStencilClearValue, // ignored when no ds attachment
QRhiResourceUpdateBatch *resourceUpdates = nullptr);
void endPass();
// When specified, srb can be different from ps' srb but the layouts must
// match. Basic tracking is included: no command is added to the cb when
// the pipeline or desc.set are the same as in the last call in the same
// frame; srb is updated automatically at this point whenever a referenced
// buffer, texture, etc. is out of date internally (due to rebuilding since
// the creation of the srb) - hence no need to manually recreate the srb in
// case a QRhiBuffer is "resized" etc.
void setGraphicsPipeline(QRhiGraphicsPipeline *ps,
QRhiShaderResourceBindings *srb = nullptr);
// The set* and draw* functions expect to have the pipeline set before on
// the command buffer. Otherwise, unspecified issues may arise depending on
// the backend.
using VertexInput = QPair<QRhiBuffer *, quint32>; // buffer, offset
void setVertexInput(int startBinding, const QVector<VertexInput> &bindings,
QRhiBuffer *indexBuf = nullptr, quint32 indexOffset = 0,
IndexFormat indexFormat = IndexUInt16);
void setViewport(const QRhiViewport &viewport);
void setScissor(const QRhiScissor &scissor);
void setBlendConstants(const QVector4D &c);
void setStencilRef(quint32 refValue);
void draw(quint32 vertexCount,
quint32 instanceCount = 1,
quint32 firstVertex = 0,
quint32 firstInstance = 0);
// final offset (indexOffset + firstIndex * n) must be 4 byte aligned with some backends
void drawIndexed(quint32 indexCount,
quint32 instanceCount = 1,
quint32 firstIndex = 0,
qint32 vertexOffset = 0,
quint32 firstInstance = 0);
/*
Readbacks cannot be inside a pass. When used in a begin-endFrame (not
offscreen), the data may only be available in a future frame. Hence the
completed callback:
beginFrame(sc);
...
QRhiReadbackResult *rbResult = new QRhiReadbackResult;
rbResult->completed = [rbResult] {
{
QImage::Format fmt = rbResult->format == QRhiTexture::BGRA8 ? QImage::Format_ARGB32_Premultiplied
: QImage::Format_RGBA8888_Premultiplied;
const uchar *p = reinterpret_cast<const uchar *>(rbResult->data.constData());
QImage image(p, rbResult->pixelSize.width(), rbResult->pixelSize.height(), fmt);
...
}
delete rbResult;
};
QRhiReadbackDescription rb; // no texture -> backbuffer
cb->readback(rb, rbResult);
endFrame(sc);
*/
bool readback(const QRhiReadbackDescription &rb, QRhiReadbackResult *result);
protected:
QRhiCommandBuffer(QRhiImplementation *rhi);
void *m_reserved;
};
class Q_RHI_EXPORT QRhiResourceUpdateBatch // sort of a command buffer for copy type of operations
{
public:
......@@ -905,14 +986,6 @@ private:
Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiResourceUpdateBatch::TexturePrepareFlags)
struct Q_RHI_EXPORT QRhiReadbackResult
{
std::function<void()> completed = nullptr;
QRhiTexture::Format format;
QSize pixelSize;
QByteArray data;
}; // non-movable due to the std::function
struct Q_RHI_EXPORT QRhiInitParams
{
};
......@@ -934,11 +1007,6 @@ public:
FrameOpDeviceLost
};
enum IndexFormat {
IndexUInt16,
IndexUInt32
};
~QRhi();
static QRhi *create(Implementation impl, QRhiInitParams *params);
......@@ -1007,9 +1075,10 @@ public:
beginFrame(sc);
updates = nextResourceUpdateBatch();
updates->...
beginPass(sc->currentFrameRenderTarget(), sc->currentFrameCommandBuffer(), clearValues, updates);
QRhiCommandBuffer *cb = sc->currentFrameCommandBuffer();
cb->beginPass(sc->currentFrameRenderTarget(), clearValues, updates);
...
endPass(sc->currentFrameCommandBuffer());
cb->endPass();
endFrame(sc); // this queues the Present, begin/endFrame manages double buffering internally
*/
QRhiSwapChain *newSwapChain();
......@@ -1027,36 +1096,13 @@ public:
QRhiCommandBuffer *cb; // not owned
beginOffscreenFrame(&cb);
// ... the usual, set up a QRhiTextureRenderTarget, beginPass-endPass, etc.
readback(cb, rb, &rbResult);
cb->readback(rb, &rbResult);
endOffscreenFrame();
// image data available in rbResult
*/
FrameOpResult beginOffscreenFrame(QRhiCommandBuffer **cb);
FrameOpResult endOffscreenFrame();
/*
Readbacks cannot be inside a pass. When used in a begin-endFrame (not
offscreen), the data may only be available in a future frame. Hence the
completed callback:
m_r->beginFrame(sc);
...
QRhiReadbackResult *rbResult = new QRhiReadbackResult;
rbResult->completed = [rbResult] {
{
QImage::Format fmt = rbResult->format == QRhiTexture::BGRA8 ? QImage::Format_ARGB32_Premultiplied
: QImage::Format_RGBA8888_Premultiplied;
const uchar *p = reinterpret_cast<const uchar *>(rbResult->data.constData());
QImage image(p, rbResult->pixelSize.width(), rbResult->pixelSize.height(), fmt);
...
}
delete rbResult;
};
QRhiReadbackDescription rb; // no texture -> backbuffer
m_r->readback(cb, rb, rbResult);
m_r->endFrame(sc);
*/
bool readback(QRhiCommandBuffer *cb, const QRhiReadbackDescription &rb, QRhiReadbackResult *result);
// Waits for any work on the graphics queue (where applicable) to complete,
// then forcibly executes all deferred operations, like completing
// readbacks and resource releases. This should _not_ be used in practice,
......@@ -1075,46 +1121,6 @@ public:
// a batch instance just collects data on its own.
QRhiResourceUpdateBatch *nextResourceUpdateBatch();
void beginPass(QRhiRenderTarget *rt,
QRhiCommandBuffer *cb,
const QRhiColorClearValue &colorClearValue, // ignored when rt has PreserveColorContents
const QRhiDepthStencilClearValue &depthStencilClearValue, // ignored when no ds attachment
QRhiResourceUpdateBatch *resourceUpdates = nullptr);
void endPass(QRhiCommandBuffer *cb);
// When specified, srb can be different from ps' srb but the layouts must
// match. Basic tracking is included: no command is added to the cb when
// the pipeline or desc.set are the same as in the last call in the same
// frame; srb is updated automatically at this point whenever a referenced