From d468978d505d785b566bec88817a9c1a4a4a5be9 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 1 Aug 2019 14:50:23 +0200 Subject: [PATCH] rhi: Print the type of the resources in the leak check Also clarify what this check includes (backends are expected to register only QRhiResource instances that actually own native graphics objects - the ones that don't are not included in the leak checking) Change-Id: If0f43b302b148f043391fa7fd7bb77cfc8d93b79 Reviewed-by: Andy Nichols --- src/gui/rhi/qrhi.cpp | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/src/gui/rhi/qrhi.cpp b/src/gui/rhi/qrhi.cpp index 7443c0a04f..0da3e05f13 100644 --- a/src/gui/rhi/qrhi.cpp +++ b/src/gui/rhi/qrhi.cpp @@ -3592,6 +3592,42 @@ QRhiResource::Type QRhiCommandBuffer::resourceType() const return CommandBuffer; } +#ifndef QT_NO_DEBUG +static const char *resourceTypeStr(QRhiResource *res) +{ + switch (res->resourceType()) { + case QRhiResource::Buffer: + return "Buffer"; + case QRhiResource::Texture: + return "Texture"; + case QRhiResource::Sampler: + return "Sampler"; + case QRhiResource::RenderBuffer: + return "RenderBuffer"; + case QRhiResource::RenderPassDescriptor: + return "RenderPassDescriptor"; + case QRhiResource::RenderTarget: + return "RenderTarget"; + case QRhiResource::TextureRenderTarget: + return "TextureRenderTarget"; + case QRhiResource::ShaderResourceBindings: + return "ShaderResourceBindings"; + case QRhiResource::GraphicsPipeline: + return "GraphicsPipeline"; + case QRhiResource::SwapChain: + return "SwapChain"; + case QRhiResource::ComputePipeline: + return "ComputePipeline"; + case QRhiResource::CommandBuffer: + return "CommandBuffer"; + default: + Q_UNREACHABLE(); + break; + } + return ""; +} +#endif + QRhiImplementation::~QRhiImplementation() { qDeleteAll(resUpdPool); @@ -3601,10 +3637,10 @@ QRhiImplementation::~QRhiImplementation() // and freak out for unfreed graphics objects in the derived dtor already. #ifndef QT_NO_DEBUG if (!resources.isEmpty()) { - qWarning("QRhi %p going down with %d unreleased resources. This is not nice.", + qWarning("QRhi %p going down with %d unreleased resources that own native graphics objects. This is not nice.", q, resources.count()); for (QRhiResource *res : qAsConst(resources)) { - qWarning(" Resource %p (%s)", res, res->m_objectName.constData()); + qWarning(" %s resource %p (%s)", resourceTypeStr(res), res, res->m_objectName.constData()); res->m_rhi = nullptr; } }