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 <andy.nichols@qt.io>
This commit is contained in:
Laszlo Agocs 2019-08-01 14:50:23 +02:00
parent eab533ae0d
commit d468978d50

View File

@ -3592,6 +3592,42 @@ QRhiResource::Type QRhiCommandBuffer::resourceType() const
return CommandBuffer; 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() QRhiImplementation::~QRhiImplementation()
{ {
qDeleteAll(resUpdPool); qDeleteAll(resUpdPool);
@ -3601,10 +3637,10 @@ QRhiImplementation::~QRhiImplementation()
// and freak out for unfreed graphics objects in the derived dtor already. // and freak out for unfreed graphics objects in the derived dtor already.
#ifndef QT_NO_DEBUG #ifndef QT_NO_DEBUG
if (!resources.isEmpty()) { 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()); q, resources.count());
for (QRhiResource *res : qAsConst(resources)) { 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; res->m_rhi = nullptr;
} }
} }