summaryrefslogtreecommitdiffstats
path: root/src/gui/rhi/qrhimetal.mm
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2021-12-17 17:04:38 +0100
committerLaszlo Agocs <laszlo.agocs@qt.io>2022-01-04 13:00:40 +0100
commit23f8d6c57f8d599b8b9542586801964d10cf8fba (patch)
tree3c0fe3e7b3cb808afcd828687e3613c57b3b9a41 /src/gui/rhi/qrhimetal.mm
parentdcc2704d17bda08e6dc7783559ccbfd864dd4339 (diff)
rhi: Drop the profiler for now
The system we inherited from the original Qt 5.14 introduction of QRhi is a text stream based solution where resource creation and frame timings are sent in a comma-separated format to a QIODevice. This, while useful to get insights about the number of resources at a given time, is not actively helpful. The frameworks built on top (Qt Quick, Qt Quick 3D) are expected to provide solutions for logging timings in a different way (e.g. via the QML Profiler). Similarly, tracking active resources and generating statistics from that is better handled on a higher level. The unique bits, such as the Vulkan memory allocator statistics and the GPU frame timestamps, are converted into APIs in QRhi. This way a user of QRhi can query it at any time and do whatever it sees fit with the data. When it comes to the GPU timestamps, that has a somewhat limited value due to the heavy asynchronousness, hence the callback based API. Nonetheless, this is still useful since it is the only means of reporting some frame timing data (an approx. elapsed milliseconds for a frame) from the GPU side. Change-Id: I67cd58b81aaa7e343c11731f9aa5b4804c2a1823 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/gui/rhi/qrhimetal.mm')
-rw-r--r--src/gui/rhi/qrhimetal.mm45
1 files changed, 2 insertions, 43 deletions
diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm
index 58e9efc07f..4e7f092c54 100644
--- a/src/gui/rhi/qrhimetal.mm
+++ b/src/gui/rhi/qrhimetal.mm
@@ -670,9 +670,9 @@ QRhiDriverInfo QRhiMetal::driverInfo() const
return driverInfoStruct;
}
-void QRhiMetal::sendVMemStatsToProfiler()
+QRhiMemAllocStats QRhiMetal::graphicsMemoryAllocationStatistics()
{
- // nothing to do here
+ return {};
}
bool QRhiMetal::makeThreadLocalNativeContextCurrent()
@@ -1470,9 +1470,6 @@ QRhi::FrameOpResult QRhiMetal::beginFrame(QRhiSwapChain *swapChain, QRhi::BeginF
swapChainD->rtWrapper.d->fb.hasStencil = swapChainD->ds ? true : false;
swapChainD->rtWrapper.d->fb.depthNeedsStore = false;
- QRhiProfilerPrivate *rhiP = profilerPrivateOrNull();
- QRHI_PROF_F(beginSwapChainFrame(swapChain));
-
executeDeferredReleases();
swapChainD->cbWrapper.resetState();
finishActiveReadbacks();
@@ -1504,9 +1501,6 @@ QRhi::FrameOpResult QRhiMetal::endFrame(QRhiSwapChain *swapChain, QRhi::EndFrame
[swapChainD->cbWrapper.d->cb commit];
- QRhiProfilerPrivate *rhiP = profilerPrivateOrNull();
- QRHI_PROF_F(endSwapChainFrame(swapChain, swapChainD->frameCount + 1));
-
[d->captureScope endScope];
if (needsPresent)
@@ -1776,7 +1770,6 @@ void QRhiMetal::enqueueResourceUpdates(QRhiCommandBuffer *cb, QRhiResourceUpdate
{
QMetalCommandBuffer *cbD = QRHI_RES(QMetalCommandBuffer, cb);
QRhiResourceUpdateBatchPrivate *ud = QRhiResourceUpdateBatchPrivate::get(resourceUpdates);
- QRhiProfilerPrivate *rhiP = profilerPrivateOrNull();
for (int opIdx = 0; opIdx < ud->activeBufferOpCount; ++opIdx) {
const QRhiResourceUpdateBatchPrivate::BufferOp &u(ud->bufferOps[opIdx]);
@@ -1835,7 +1828,6 @@ void QRhiMetal::enqueueResourceUpdates(QRhiCommandBuffer *cb, QRhiResourceUpdate
Q_ASSERT(!utexD->d->stagingBuf[currentFrameSlot]);
utexD->d->stagingBuf[currentFrameSlot] = [d->dev newBufferWithLength: NSUInteger(stagingSize)
options: MTLResourceStorageModeShared];
- QRHI_PROF_F(newTextureStagingArea(utexD, currentFrameSlot, quint32(stagingSize)));
void *mp = [utexD->d->stagingBuf[currentFrameSlot] contents];
qsizetype curOfs = 0;
@@ -1854,7 +1846,6 @@ void QRhiMetal::enqueueResourceUpdates(QRhiCommandBuffer *cb, QRhiResourceUpdate
e.stagingBuffer.buffer = utexD->d->stagingBuf[currentFrameSlot];
utexD->d->stagingBuf[currentFrameSlot] = nil;
d->releaseQueue.append(e);
- QRHI_PROF_F(releaseTextureStagingArea(utexD, currentFrameSlot));
} else if (u.type == QRhiResourceUpdateBatchPrivate::TextureOp::Copy) {
Q_ASSERT(u.src && u.dst);
QMetalTexture *srcD = QRHI_RES(QMetalTexture, u.src);
@@ -1916,10 +1907,6 @@ void QRhiMetal::enqueueResourceUpdates(QRhiCommandBuffer *cb, QRhiResourceUpdate
textureFormatInfo(readback.format, readback.pixelSize, &bpl, &readback.bufSize, nullptr);
readback.buf = [d->dev newBufferWithLength: readback.bufSize options: MTLResourceStorageModeShared];
- QRHI_PROF_F(newReadbackBuffer(qint64(qintptr(readback.buf)),
- texD ? static_cast<QRhiResource *>(texD) : static_cast<QRhiResource *>(swapChainD),
- readback.bufSize));
-
ensureBlit();
[blitEnc copyFromTexture: src
sourceSlice: NSUInteger(is3D ? 0 : u.rb.layer())
@@ -2218,7 +2205,6 @@ void QRhiMetal::executeDeferredReleases(bool forced)
void QRhiMetal::finishActiveReadbacks(bool forced)
{
QVarLengthArray<std::function<void()>, 4> completedCallbacks;
- QRhiProfilerPrivate *rhiP = profilerPrivateOrNull();
for (int i = d->activeTextureReadbacks.count() - 1; i >= 0; --i) {
const QRhiMetalData::TextureReadback &readback(d->activeTextureReadbacks[i]);
@@ -2230,8 +2216,6 @@ void QRhiMetal::finishActiveReadbacks(bool forced)
memcpy(readback.result->data.data(), p, readback.bufSize);
[readback.buf release];
- QRHI_PROF_F(releaseReadbackBuffer(qint64(qintptr(readback.buf))));
-
if (readback.result->completed)
completedCallbacks.append(readback.result->completed);
@@ -2275,8 +2259,6 @@ void QMetalBuffer::destroy()
QRHI_RES_RHI(QRhiMetal);
if (rhiD) {
rhiD->d->releaseQueue.append(e);
- QRHI_PROF;
- QRHI_PROF_F(releaseBuffer(this));
rhiD->unregisterResource(this);
}
}
@@ -2324,9 +2306,6 @@ bool QMetalBuffer::create()
}
}
- QRHI_PROF;
- QRHI_PROF_F(newBuffer(this, roundedSize, d->slotted ? QMTL_FRAMES_IN_FLIGHT : 1, 0));
-
lastActiveFrameSlot = -1;
generation += 1;
rhiD->registerResource(this);
@@ -2556,8 +2535,6 @@ void QMetalRenderBuffer::destroy()
QRHI_RES_RHI(QRhiMetal);
if (rhiD) {
rhiD->d->releaseQueue.append(e);
- QRHI_PROF;
- QRHI_PROF_F(releaseRenderBuffer(this));
rhiD->unregisterResource(this);
}
}
@@ -2582,7 +2559,6 @@ bool QMetalRenderBuffer::create()
desc.resourceOptions = MTLResourceStorageModePrivate;
desc.usage = MTLTextureUsageRenderTarget;
- bool transientBacking = false;
switch (m_type) {
case DepthStencil:
#ifdef Q_OS_MACOS
@@ -2591,7 +2567,6 @@ bool QMetalRenderBuffer::create()
? MTLPixelFormatDepth24Unorm_Stencil8 : MTLPixelFormatDepth32Float_Stencil8;
#else
desc.storageMode = MTLStorageModeMemoryless;
- transientBacking = true;
d->format = MTLPixelFormatDepth32Float_Stencil8;
#endif
desc.pixelFormat = d->format;
@@ -2615,9 +2590,6 @@ bool QMetalRenderBuffer::create()
if (!m_objectName.isEmpty())
d->tex.label = [NSString stringWithUTF8String: m_objectName.constData()];
- QRHI_PROF;
- QRHI_PROF_F(newRenderBuffer(this, transientBacking, false, samples));
-
lastActiveFrameSlot = -1;
generation += 1;
rhiD->registerResource(this);
@@ -2675,8 +2647,6 @@ void QMetalTexture::destroy()
QRHI_RES_RHI(QRhiMetal);
if (rhiD) {
rhiD->d->releaseQueue.append(e);
- QRHI_PROF;
- QRHI_PROF_F(releaseTexture(this));
rhiD->unregisterResource(this);
}
}
@@ -2793,9 +2763,6 @@ bool QMetalTexture::create()
d->owns = true;
- QRHI_PROF;
- QRHI_PROF_F(newTexture(this, true, mipLevelCount, isCube ? 6 : (isArray ? m_arraySize : 1), samples));
-
lastActiveFrameSlot = -1;
generation += 1;
rhiD->registerResource(this);
@@ -2815,9 +2782,6 @@ bool QMetalTexture::createFrom(QRhiTexture::NativeTexture src)
d->owns = false;
- QRHI_PROF;
- QRHI_PROF_F(newTexture(this, false, mipLevelCount, m_flags.testFlag(CubeMap) ? 6 : 1, samples));
-
lastActiveFrameSlot = -1;
generation += 1;
QRHI_RES_RHI(QRhiMetal);
@@ -3966,8 +3930,6 @@ void QMetalSwapChain::destroy()
QRHI_RES_RHI(QRhiMetal);
if (rhiD) {
rhiD->swapchains.remove(this);
- QRHI_PROF;
- QRHI_PROF_F(releaseSwapChain(this));
rhiD->unregisterResource(this);
}
}
@@ -4159,9 +4121,6 @@ bool QMetalSwapChain::createOrResize()
[desc release];
}
- QRHI_PROF;
- QRHI_PROF_F(resizeSwapChain(this, QMTL_FRAMES_IN_FLIGHT, samples > 1 ? QMTL_FRAMES_IN_FLIGHT : 0, samples));
-
if (needsRegistration)
rhiD->registerResource(this);