Commit 0c9d9458 authored by Laszlo Agocs's avatar Laszlo Agocs
Browse files

vk, d3d: Report readback temp buffer to prof

parent ae388989
......@@ -753,6 +753,7 @@ void QRhiD3D11::enqueueResourceUpdates(QRhiCommandBuffer *cb, QRhiResourceUpdate
{
QD3D11CommandBuffer *cbD = QRHI_RES(QD3D11CommandBuffer, cb);
QRhiResourceUpdateBatchPrivate *ud = QRhiResourceUpdateBatchPrivate::get(resourceUpdates);
QRhiProfilerPrivate *rhiP = profilerPrivateOrNull();
for (const QRhiResourceUpdateBatchPrivate::DynamicBufferUpdate &u : ud->dynamicBufferUpdates) {
QD3D11Buffer *bufD = QRHI_RES(QD3D11Buffer, u.buf);
......@@ -959,6 +960,9 @@ void QRhiD3D11::enqueueResourceUpdates(QRhiCommandBuffer *cb, QRhiResourceUpdate
qWarning("Failed to create readback staging texture: %s", qPrintable(comErrorMessage(hr)));
return;
}
QRHI_PROF_F(newReadbackBuffer(quint64(quintptr(stagingTex)),
texD ? static_cast<QRhiResource *>(texD) : static_cast<QRhiResource *>(swapChainD),
bufSize));
QD3D11CommandBuffer::Command cmd;
cmd.cmd = QD3D11CommandBuffer::Command::CopySubRes;
......@@ -993,6 +997,7 @@ void QRhiD3D11::enqueueResourceUpdates(QRhiCommandBuffer *cb, QRhiResourceUpdate
void QRhiD3D11::finishActiveReadbacks()
{
QVarLengthArray<std::function<void()>, 4> completedCallbacks;
QRhiProfilerPrivate *rhiP = profilerPrivateOrNull();
for (int i = activeReadbacks.count() - 1; i >= 0; --i) {
const QRhiD3D11::ActiveReadback &aRb(activeReadbacks[i]);
......@@ -1011,6 +1016,7 @@ void QRhiD3D11::finishActiveReadbacks()
context->Unmap(aRb.stagingTex, 0);
aRb.stagingTex->Release();
QRHI_PROF_F(releaseReadbackBuffer(quint64(quintptr(aRb.stagingTex))));
if (aRb.result->completed)
completedCallbacks.append(aRb.result->completed);
......
......@@ -343,6 +343,32 @@ void QRhiProfilerPrivate::endSwapChainFrame(QRhiSwapChain *sc, int frameCount)
}
}
void QRhiProfilerPrivate::newReadbackBuffer(quint64 id, QRhiResource *src, quint32 size)
{
if (!ensureStream())
return;
writer->startMap();
WRITE_OP(NewReadbackBuffer);
WRITE_TIMESTAMP;
WRITE_PAIR(QLatin1String("id"), id);
WRITE_PAIR(QLatin1String("source"), quint64(quintptr(src)));
WRITE_PAIR(QLatin1String("size"), size);
writer->endMap();
}
void QRhiProfilerPrivate::releaseReadbackBuffer(quint64 id)
{
if (!ensureStream())
return;
writer->startMap();
WRITE_OP(ReleaseReadbackBuffer);
WRITE_TIMESTAMP;
WRITE_PAIR(QLatin1String("id"), id);
writer->endMap();
}
void QRhiProfilerPrivate::vmemStat(int realAllocCount, int subAllocCount, quint32 totalSize, quint32 unusedSize)
{
if (!ensureStream())
......
......@@ -60,6 +60,8 @@ public:
ReleaseTextureStagingArea,
ResizeSwapChain,
ReleaseSwapChain,
NewReadbackBuffer,
ReleaseReadbackBuffer,
VMemAllocStats,
FrameTime
};
......
......@@ -75,6 +75,9 @@ public:
void endSwapChainFrame(QRhiSwapChain *sc, int frameCount);
void newReadbackBuffer(quint64 id, QRhiResource *src, quint32 size);
void releaseReadbackBuffer(quint64 id);
void vmemStat(int realAllocCount, int subAllocCount, quint32 totalSize, quint32 unusedSize);
bool ensureStream();
......
......@@ -2299,6 +2299,9 @@ void QRhiVulkan::enqueueResourceUpdates(QRhiCommandBuffer *cb, QRhiResourceUpdat
VkResult err = vmaCreateBuffer(toVmaAllocator(allocator), &bufferInfo, &allocInfo, &aRb.buf, &allocation, nullptr);
if (err == VK_SUCCESS) {
aRb.bufAlloc = allocation;
QRHI_PROF_F(newReadbackBuffer(reinterpret_cast<quint64>(aRb.buf),
texD ? static_cast<QRhiResource *>(texD) : static_cast<QRhiResource *>(swapChainD),
aRb.bufSize));
} else {
qWarning("Failed to create readback buffer of size %u: %d", aRb.bufSize, err);
continue;
......@@ -2514,6 +2517,7 @@ void QRhiVulkan::executeDeferredReleases(bool forced)
void QRhiVulkan::finishActiveReadbacks(bool forced)
{
QVarLengthArray<std::function<void()>, 4> completedCallbacks;
QRhiProfilerPrivate *rhiP = profilerPrivateOrNull();
for (int i = activeReadbacks.count() - 1; i >= 0; --i) {
const QRhiVulkan::ActiveReadback &aRb(activeReadbacks[i]);
......@@ -2532,6 +2536,7 @@ void QRhiVulkan::finishActiveReadbacks(bool forced)
vmaUnmapMemory(toVmaAllocator(allocator), a);
vmaDestroyBuffer(toVmaAllocator(allocator), aRb.buf, a);
QRHI_PROF_F(releaseReadbackBuffer(reinterpret_cast<quint64>(aRb.buf)));
if (aRb.result->completed)
completedCallbacks.append(aRb.result->completed);
......
d3d, vk: timestamp query
prof report api (fed by a cbor stream)
prof: report readback temp buf
mtl: report readback temp buf
multiwindow_threaded should demo pulling out the device and importing to another rhi
mtl: reduce set*
advanced blend modes
......@@ -52,6 +52,7 @@ dxc for d3d as an alternative to fxc?
hlsl -> dxc -> spirv -> spirv-cross hmmm...
+++ done
prof: report readback temp buf
merge offscreen examples into one
mtl: max texture size
vk: obj name and debug markers
......
Supports Markdown
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