Commit 5969d1b8 authored by Laszlo Agocs's avatar Laszlo Agocs

Make it possible to do uploads/copies after a pass as well

parent f0383810
......@@ -524,9 +524,9 @@ void QRhiCommandBuffer::beginPass(QRhiRenderTarget *rt,
rhi->beginPass(rt, this, colorClearValue, depthStencilClearValue, resourceUpdates);
}
void QRhiCommandBuffer::endPass()
void QRhiCommandBuffer::endPass(QRhiResourceUpdateBatch *resourceUpdates)
{
rhi->endPass(this);
rhi->endPass(this, resourceUpdates);
}
void QRhiCommandBuffer::setGraphicsPipeline(QRhiGraphicsPipeline *ps,
......
......@@ -899,7 +899,7 @@ public:
const QRhiColorClearValue &colorClearValue, // ignored when rt has PreserveColorContents
const QRhiDepthStencilClearValue &depthStencilClearValue, // ignored when no ds attachment
QRhiResourceUpdateBatch *resourceUpdates = nullptr);
void endPass();
void endPass(QRhiResourceUpdateBatch *resourceUpdates = nullptr);
// 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
......@@ -938,10 +938,10 @@ public:
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:
When used in a begin-endFrame (not offscreen), the data may only be
available in a future frame. Hence the completed callback:
beginFrame(sc);
beginPass
...
QRhiReadbackResult *rbResult = new QRhiReadbackResult;
rbResult->completed = [rbResult] {
......@@ -954,8 +954,10 @@ public:
}
delete rbResult;
};
u = nextResourceUpdateBatch();
QRhiReadbackDescription rb; // no texture -> backbuffer
cb->readback(rb, rbResult);
u->readback(rb, rbResult);
endPass(u);
endFrame(sc);
*/
bool readback(const QRhiReadbackDescription &rb, QRhiReadbackResult *result);
......@@ -1117,8 +1119,11 @@ public:
QRhiReadbackResult rbResult;
QRhiCommandBuffer *cb; // not owned
beginOffscreenFrame(&cb);
// ... the usual, set up a QRhiTextureRenderTarget, beginPass-endPass, etc.
cb->readback(rb, &rbResult);
beginPass
...
u = nextResourceUpdateBatch();
u->readback(rb, &rbResult);
endPass(u);
endOffscreenFrame();
// image data available in rbResult
*/
......
......@@ -94,7 +94,7 @@ public:
const QRhiColorClearValue &colorClearValue,
const QRhiDepthStencilClearValue &depthStencilClearValue,
QRhiResourceUpdateBatch *resourceUpdates) = 0;
virtual void endPass(QRhiCommandBuffer *cb) = 0;
virtual void endPass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) = 0;
virtual void setGraphicsPipeline(QRhiCommandBuffer *cb,
QRhiGraphicsPipeline *ps,
......
......@@ -889,13 +889,16 @@ void QRhiD3D11::beginPass(QRhiRenderTarget *rt,
inPass = true;
}
void QRhiD3D11::endPass(QRhiCommandBuffer *cb)
void QRhiD3D11::endPass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates)
{
Q_ASSERT(inPass);
inPass = false;
QD3D11CommandBuffer *cbD = QRHI_RES(QD3D11CommandBuffer, cb);
cbD->currentTarget = nullptr;
if (resourceUpdates)
commitResourceUpdates(resourceUpdates);
}
void QRhiD3D11::updateShaderResourceBindings(QD3D11ShaderResourceBindings *srbD)
......
......@@ -409,7 +409,7 @@ public:
const QRhiColorClearValue &colorClearValue,
const QRhiDepthStencilClearValue &depthStencilClearValue,
QRhiResourceUpdateBatch *resourceUpdates) override;
void endPass(QRhiCommandBuffer *cb) override;
void endPass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override;
void setGraphicsPipeline(QRhiCommandBuffer *cb,
QRhiGraphicsPipeline *ps,
......
......@@ -1292,13 +1292,16 @@ void QRhiGles2::beginPass(QRhiRenderTarget *rt,
inPass = true;
}
void QRhiGles2::endPass(QRhiCommandBuffer *cb)
void QRhiGles2::endPass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates)
{
Q_ASSERT(inPass);
inPass = false;
QGles2CommandBuffer *cbD = QRHI_RES(QGles2CommandBuffer, cb);
cbD->currentTarget = nullptr;
if (resourceUpdates)
commitResourceUpdates(resourceUpdates);
}
QGles2Buffer::QGles2Buffer(QRhiImplementation *rhi, Type type, UsageFlags usage, int size)
......
......@@ -373,7 +373,7 @@ public:
const QRhiColorClearValue &colorClearValue,
const QRhiDepthStencilClearValue &depthStencilClearValue,
QRhiResourceUpdateBatch *resourceUpdates) override;
void endPass(QRhiCommandBuffer *cb) override;
void endPass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override;
void setGraphicsPipeline(QRhiCommandBuffer *cb,
QRhiGraphicsPipeline *ps,
......
......@@ -776,7 +776,7 @@ void QRhiMetal::beginPass(QRhiRenderTarget *rt,
inPass = true;
}
void QRhiMetal::endPass(QRhiCommandBuffer *cb)
void QRhiMetal::endPass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates)
{
Q_ASSERT(inPass);
inPass = false;
......@@ -785,6 +785,9 @@ void QRhiMetal::endPass(QRhiCommandBuffer *cb)
[cbD->d->currentPassEncoder endEncoding];
cbD->currentTarget = nullptr;
if (resourceUpdates)
commitResourceUpdates(cb, resourceUpdates);
}
void QRhiMetal::executeDeferredReleases(bool forced)
......
......@@ -275,7 +275,7 @@ public:
const QRhiColorClearValue &colorClearValue,
const QRhiDepthStencilClearValue &depthStencilClearValue,
QRhiResourceUpdateBatch *resourceUpdates) override;
void endPass(QRhiCommandBuffer *cb) override;
void endPass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override;
void setGraphicsPipeline(QRhiCommandBuffer *cb,
QRhiGraphicsPipeline *ps,
......
......@@ -1698,7 +1698,7 @@ void QRhiVulkan::beginPass(QRhiRenderTarget *rt,
inPass = true;
}
void QRhiVulkan::endPass(QRhiCommandBuffer *cb)
void QRhiVulkan::endPass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates)
{
Q_ASSERT(inPass);
QVkCommandBuffer *cbD = QRHI_RES(QVkCommandBuffer, cb);
......@@ -1709,6 +1709,9 @@ void QRhiVulkan::endPass(QRhiCommandBuffer *cb)
deactivateTextureRenderTarget(cb, static_cast<QRhiTextureRenderTarget *>(cbD->currentTarget));
cbD->currentTarget = nullptr;
if (resourceUpdates)
commitResourceUpdates(cb, resourceUpdates);
}
VkShaderModule QRhiVulkan::createShader(const QByteArray &spirv)
......
......@@ -338,7 +338,7 @@ public:
const QRhiColorClearValue &colorClearValue,
const QRhiDepthStencilClearValue &depthStencilClearValue,
QRhiResourceUpdateBatch *resourceUpdates) override;
void endPass(QRhiCommandBuffer *cb) override;
void endPass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override;
void setGraphicsPipeline(QRhiCommandBuffer *cb,
QRhiGraphicsPipeline *ps,
......
......@@ -12,8 +12,9 @@ test cubemap
test cubemap face as target
face cubemap readback? (test vk/d3d, impl for gl/mtl)
d3d: resolveimage (color only)
mtl, gl, vk: msaa tex+rt
mtl, gl, vk: resolveimage
mtl, gl, vk: resolveimage (color only)
gl: tex size stuff (npot etc.)
gl: tex formats (texture, readback)
......@@ -59,13 +60,14 @@ multi mip/layer copy? (fewer barriers...)
multi-buffer (region) readback?
depth readback
copy image depth
depth resolve
shadertools:
dxc for d3d as an alternative to fxc?
hlsl -> dxc -> spirv -> spirv-cross hmmm...
+++ done
d3d: resolveimage (color and ds, only to resolve samples)
resourceUpdates in endPass
d3d: msaa tex+rt
multisample texture (and tex rt) (no readback)
gl: compressed textures
......
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