diff --git a/src/gui/rhi/qrhi.cpp b/src/gui/rhi/qrhi.cpp index 922c1f97e85..82cef0affef 100644 --- a/src/gui/rhi/qrhi.cpp +++ b/src/gui/rhi/qrhi.cpp @@ -4,6 +4,7 @@ #include "qrhi_p.h" #include #include +#include "private/qloggingregistry_p.h" #include "qrhinull_p.h" #ifndef QT_NO_OPENGL @@ -24,8 +25,12 @@ QT_BEGIN_NAMESPACE -Q_LOGGING_CATEGORY(QRHI_LOG_INFO, "qt.rhi.general") -Q_STATIC_LOGGING_CATEGORY(QRHI_LOG_RUB, "qt.rhi.rub") +// Play nice with QSG_INFO since that is still the most commonly used +// way to get graphics info printed from Qt Quick apps, and the Quick +// scenegraph is our primary user. +Q_LOGGING_CATEGORY_WITH_ENV_OVERRIDE(QRHI_LOG_INFO, "QSG_INFO", "qt.rhi.general") + +Q_LOGGING_CATEGORY(QRHI_LOG_RUB, "qt.rhi.rub") /*! \class QRhi @@ -8873,22 +8878,12 @@ QRhiImplementation *QRhiImplementation::newInstance(QRhi::Implementation impl, Q return d; } -bool QRhiImplementation::rubLogEnabled = false; - void QRhiImplementation::prepareForCreate(QRhi *rhi, QRhi::Implementation impl, QRhi::Flags flags, QRhiAdapter *adapter) { q = rhi; - // Play nice with QSG_INFO since that is still the most commonly used - // way to get graphics info printed from Qt Quick apps, and the Quick - // scenegraph is our primary user. - if (qEnvironmentVariableIsSet("QSG_INFO")) - const_cast(QRHI_LOG_INFO()).setEnabled(QtDebugMsg, true); - debugMarkers = flags.testFlag(QRhi::EnableDebugMarkers); - rubLogEnabled = QRHI_LOG_RUB().isDebugEnabled(); - implType = impl; implThread = QThread::currentThread(); @@ -9931,7 +9926,7 @@ void QRhiResourceUpdateBatchPrivate::free() bufferLargeAllocTotal += op.data.largeAlloc(); // alloc when > 1 KB } - if (rhi->rubLogEnabled) { + if (QRHI_LOG_RUB().isDebugEnabled()) { qDebug() << "[rub] release to pool upd.batch #" << poolIndex << "/ bufferOps active" << activeBufferOpCount << "of" << bufferOps.count() @@ -11449,8 +11444,7 @@ QRhi::FrameOpResult QRhi::beginFrame(QRhiSwapChain *swapChain, BeginFrameFlags f if (d->inFrame) qWarning("Attempted to call beginFrame() within a still active frame; ignored"); - if (d->rubLogEnabled) - qDebug("[rub] new frame"); + qCDebug(QRHI_LOG_RUB) << "[rub] new frame"; QRhi::FrameOpResult r = !d->inFrame ? d->beginFrame(swapChain, flags) : FrameOpSuccess; if (r == FrameOpSuccess) @@ -11600,8 +11594,7 @@ QRhi::FrameOpResult QRhi::beginOffscreenFrame(QRhiCommandBuffer **cb, BeginFrame if (d->inFrame) qWarning("Attempted to call beginOffscreenFrame() within a still active frame; ignored"); - if (d->rubLogEnabled) - qDebug("[rub] new offscreen frame"); + qCDebug(QRHI_LOG_RUB) << "[rub] new offscreen frame"; QRhi::FrameOpResult r = !d->inFrame ? d->beginOffscreenFrame(cb, flags) : FrameOpSuccess; if (r == FrameOpSuccess) diff --git a/src/gui/rhi/qrhi_p.h b/src/gui/rhi/qrhi_p.h index 065e7178f56..c62d5b6448f 100644 --- a/src/gui/rhi/qrhi_p.h +++ b/src/gui/rhi/qrhi_p.h @@ -29,6 +29,7 @@ QT_BEGIN_NAMESPACE #define QRHI_RES_RHI(t) t *rhiD = static_cast(m_rhi) Q_DECLARE_LOGGING_CATEGORY(QRHI_LOG_INFO) +Q_DECLARE_LOGGING_CATEGORY(QRHI_LOG_RUB) class QRhiImplementation { @@ -263,7 +264,6 @@ private: QHash keyedCleanupCallbacks; QElapsedTimer pipelineCreationTimer; qint64 accumulatedPipelineCreationTime = 0; - static bool rubLogEnabled; friend class QRhi; friend class QRhiResourceUpdateBatchPrivate; @@ -376,7 +376,7 @@ public: if (!d) { d = new QRhiBufferDataPrivate; } else if (d->ref != 1) { - if (QRhiImplementation::rubLogEnabled) + if (QRHI_LOG_RUB().isDebugEnabled()) qDebug("[rub] QRhiBufferData %p/%p new backing due to no-copy detach, ref was %d", this, d, d->ref); d->ref -= 1; d = new QRhiBufferDataPrivate; @@ -385,7 +385,7 @@ public: if (size <= QRhiBufferDataPrivate::SMALL_DATA_SIZE) { memcpy(d->smallData, s, size); } else { - if (QRhiImplementation::rubLogEnabled && largeAlloc() < size) + if (QRHI_LOG_RUB().isDebugEnabled() && largeAlloc() < size) qDebug("[rub] QRhiBufferData %p/%p new large data allocation %u -> %u", this, d, largeAlloc(), size); d->largeData.assign(QByteArrayView(s, size)); // keeps capacity } @@ -395,7 +395,7 @@ public: if (!d) { d = new QRhiBufferDataPrivate; } else if (d->ref != 1) { - if (QRhiImplementation::rubLogEnabled) + if (QRHI_LOG_RUB().isDebugEnabled()) qDebug("[rub] QRhiBufferData %p/%p new backing due to no-copy detach, ref was %d", this, d, d->ref); d->ref -= 1; d = new QRhiBufferDataPrivate;