Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qssgassert_p.h File Reference

(8656351cb5a6a037d4f435797e50554b6dea1f73)

#include <QtCore/qglobal.h>
#include <QtQuick3DUtils/qtquick3dutilsexports.h>
+ Include dependency graph for qssgassert_p.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define QSSG_DEBUG_COND(cond)   (true || (cond))
 
#define QSSG_ASSERT_STRINGIFY_HELPER(x)   #x
 
#define QSSG_ASSERT_STRINGIFY(x)   QSSG_ASSERT_STRINGIFY_HELPER(x)
 
#define QSSG_ASSERT_STRING_X(msg)   QT_PREPEND_NAMESPACE(qssgWriteAssertLocation)(msg)
 
#define QSSG_ASSERT_STRING(cond)
 
#define QSSG_ASSERT(cond, action)   if (Q_LIKELY(cond)) {} else { QSSG_ASSERT_STRING(#cond); action; } do {} while (0)
 
#define QSSG_ASSERT_X(cond, msg, action)   if (Q_LIKELY(cond)) {} else { QSSG_ASSERT_STRING_X(msg); action; } do {} while (0)
 
#define QSSG_CHECK(cond)   if (Q_LIKELY(cond)) {} else { QSSG_ASSERT_STRING(#cond); } do {} while (0)
 
#define QSSG_CHECK_X(cond, msg)   if (Q_LIKELY(cond)) {} else { QSSG_ASSERT_STRING_X(msg); } do {} while (0)
 
#define QSSG_GUARD(cond)   ((Q_LIKELY(cond)) ? true : (QSSG_ASSERT_STRING(#cond), false))
 
#define QSSG_GUARD_X(cond, msg)   ((Q_LIKELY(cond)) ? true : (QSSG_ASSERT_STRING_X(msg), false))
 

Functions

QT_BEGIN_NAMESPACE Q_QUICK3DUTILS_EXPORT void qssgWriteAssertLocation (const char *msg)
 Collection of assert checks that causes a soft or hard assert depending on the build.
 

Macro Definition Documentation

◆ QSSG_ASSERT

#define QSSG_ASSERT ( cond,
action )   if (Q_LIKELY(cond)) {} else { QSSG_ASSERT_STRING(#cond); action; } do {} while (0)

Definition at line 42 of file qssgassert_p.h.

Referenced by QSSGRhiBuffer::QSSGRhiBuffer(), QSSGFrameData::activeCamera(), bfs(), checkParticleSupport(), QSSGLayerRenderData::createRenderables(), QQuick3DExtensionListHelper::extensionAppend(), QQuick3DExtensionListHelper::extensionAt(), QQuick3DExtensionListHelper::extensionClear(), QQuick3DExtensionListHelper::extensionCount(), QQuick3DExtensionListHelper::extensionRemoveLast(), QQuick3DExtensionListHelper::extensionReplace(), QSSGLayerRenderData::frustumCulling(), QSSGRenderGraphObjectUtils::getCameraId(), QSSGRenderGraphObjectUtils::getExtensionId(), QSSGRenderGraphObjectUtils::getNodeId(), QSSGLayerRenderData::getOrCreateExtensionContext(), QSSGFrameData::getPipelineState(), QSSGRenderGraphObjectUtils::getResourceId(), QSSGRendererPrivate::getShaderPipelineForDefaultMaterial(), QSSGCameraHelpers::getViewProjectionMatrix(), OpaquePass::prep(), TransparentPass::prep(), QSSGLayerRenderData::prepareForRender(), QSSGLayerRenderData::prepareModelsForRender(), QSSGLayerRenderData::prepareParticlesForRender(), QSSGLayerRenderData::prepareRenderables(), QSSGRhiEffectSystem::process(), OpaquePass::render(), TransparentPass::render(), ShadowMapPass::renderPass(), ReflectionMapPass::renderPass(), ZPrePassPass::renderPass(), SSAOMapPass::renderPass(), DepthMapPass::renderPass(), SkyboxPass::renderPass(), SkyboxCubeMapPass::renderPass(), ScreenMapPass::renderPass(), ScreenReflectionPass::renderPass(), OpaquePass::renderPass(), TransparentPass::renderPass(), Item2DPass::renderPass(), InfiniteGridPass::renderPass(), DebugDrawPass::renderPass(), UserPass::renderPass(), ShadowMapPass::renderPrep(), ReflectionMapPass::renderPrep(), ZPrePassPass::renderPrep(), SSAOMapPass::renderPrep(), DepthMapPass::renderPrep(), SkyboxPass::renderPrep(), SkyboxCubeMapPass::renderPrep(), ScreenMapPass::renderPrep(), ScreenReflectionPass::renderPrep(), OpaquePass::renderPrep(), TransparentPass::renderPrep(), Item2DPass::renderPrep(), InfiniteGridPass::renderPrep(), DebugDrawPass::renderPrep(), QSSGLayerRenderData::renderRenderables(), QSSGRenderer::rhiPrepare(), rhiPrepareResourcesForShadowMap(), QSSGRenderer::rhiRender(), RenderHelpers::rhiRenderShadowMap(), QSSGLayerRenderData::setModelMaterials(), QSSGLayerRenderData::setModelMaterials(), QSSGRhiShaderPipeline::setUniformArray(), QQuick3DSceneRenderer::synchronize(), and QSSGQmlUtilities::writeQmlComponent().

◆ QSSG_ASSERT_STRING

#define QSSG_ASSERT_STRING ( cond)
Value:
"\"" cond"\" in file " __FILE__ ", line " QSSG_ASSERT_STRINGIFY(__LINE__))
#define QSSG_ASSERT_STRING_X(msg)
#define QSSG_ASSERT_STRINGIFY(x)

Definition at line 36 of file qssgassert_p.h.

◆ QSSG_ASSERT_STRING_X

#define QSSG_ASSERT_STRING_X ( msg)    QT_PREPEND_NAMESPACE(qssgWriteAssertLocation)(msg)

Definition at line 35 of file qssgassert_p.h.

◆ QSSG_ASSERT_STRINGIFY

#define QSSG_ASSERT_STRINGIFY ( x)    QSSG_ASSERT_STRINGIFY_HELPER(x)

Definition at line 34 of file qssgassert_p.h.

◆ QSSG_ASSERT_STRINGIFY_HELPER

#define QSSG_ASSERT_STRINGIFY_HELPER ( x)    #x

Definition at line 33 of file qssgassert_p.h.

◆ QSSG_ASSERT_X

#define QSSG_ASSERT_X ( cond,
msg,
action )   if (Q_LIKELY(cond)) {} else { QSSG_ASSERT_STRING_X(msg); action; } do {} while (0)

Definition at line 43 of file qssgassert_p.h.

Referenced by QSSGRenderHelpers::commit(), QSSGRenderHelpers::createRenderables(), QSSGLayerRenderData::createRenderables(), QQuick3DExtensionHelpers::getCameraId(), QQuick3DExtensionHelpers::getExtensionId(), QSSGModelHelpers::getGlobalOpacity(), QSSGModelHelpers::getGlobalOpacity(), QSSGLayerRenderData::getGlobalOpacity(), QSSGModelHelpers::getGlobalTransform(), QSSGLayerRenderData::getGlobalTransform(), QSSGModelHelpers::getLocalOpacity(), QSSGModelHelpers::getLocalTransform(), QQuick3DExtensionHelpers::getNodeId(), QSSGLayerRenderData::getOrCreateExtensionContext(), QQuick3DExtensionHelpers::getResourceId(), QSSGLayerRenderData::prepareForRender(), QSSGRenderHelpers::prepareForRender(), QSSGLayerRenderData::prepareModelsForRender(), QSSGLayerRenderData::prepareModelsForRender(), QSSGRenderHelpers::prepareRenderables(), QSSGLayerRenderData::prepareRenderables(), SSAOMapPass::renderPrep(), ScreenReflectionPass::renderPrep(), QSSGRenderHelpers::renderRenderables(), QSSGLayerRenderData::renderRenderables(), QSSGModelHelpers::setGlobalOpacity(), QSSGLayerRenderData::setGlobalOpacity(), QSSGModelHelpers::setGlobalTransform(), QSSGLayerRenderData::setGlobalTransform(), QSSGModelHelpers::setModelMaterials(), QSSGModelHelpers::setModelMaterials(), QSSGLayerRenderData::setModelMaterials(), QSSGLayerRenderData::setModelMaterials(), QSSGRhiShaderPipeline::setUniform(), QSSGRhiShaderPipeline::setUniformArray(), and QSSGRhiHelpers::toTopology().

◆ QSSG_CHECK

◆ QSSG_CHECK_X

◆ QSSG_DEBUG_COND

#define QSSG_DEBUG_COND ( cond)    (true || (cond))

◆ QSSG_GUARD

◆ QSSG_GUARD_X

#define QSSG_GUARD_X ( cond,
msg )   ((Q_LIKELY(cond)) ? true : (QSSG_ASSERT_STRING_X(msg), false))

Definition at line 47 of file qssgassert_p.h.

Referenced by QQuick3DWindowAttachment::QQuick3DWindowAttachment().

Function Documentation

◆ qssgWriteAssertLocation()

QT_BEGIN_NAMESPACE Q_QUICK3DUTILS_EXPORT void qssgWriteAssertLocation ( const char * msg)

Collection of assert checks that causes a soft or hard assert depending on the build.

Unlike Q_ASSERT(), which is a no-op for non-debug build, QSSG_ASSERT() etc., will print a warning in non-developer builds (soft assert) or terminate on developer-build (hard assert).

\macro QSSG_ASSERT(condition, action)

The assert will be fatal in developer builds if condition is not met. In non-developer builds the assert is "soft" and will instead print a warning with the reason and location of the assert before execution action. The action can be for example be: return, break or continue.

For example, writing:

\badcode QSSG_ASSERT(ptr != nullptr, return);

other actions are of course possible, e.g., in a loop it might be better to do:

\badcode QSSG_ASSERT(ptr != nullptr, continue);

is the equivalent to:

\badcode Q_ASSERT(ptr != nullptr); if (ptr != nullptr) { qWarning() << "Something unexpected here, proceeding will be fatal!"; return; }

See also
QSSG_ASSERT_X

\macro QSSG_ASSERT_X(condition, message, action)

Same as \l QSSG_ASSERT() but with a custom message that will be print if condition is not met.

\macro QSSG_CHECK(condition)

Similar to \l QSSG_ASSERT but without an action. Convenient when the condition is expected to be valid, but it's not immediately fatal if the current code path continues.

\badcode QSSG_CHECK(ptr != nullptr);

is the equivalent to:

\badcode Q_ASSERT(ptr != nullptr); if (ptr != nullptr) qWarning() << "Something unexpected here, will probably not work as expected!";

See also
QSSG_CHECK_X

\macro QSSG_CHECK_X(condition, message)

Same as \l QSSG_CHECK() but with a custom message that will be print if condition is not met.

\macro QSSG_GUARD(condition)

Check that returns the result of condition. As with the other assert functions, a call to QSSG_GUARD, when condition is not met, is fatal for developer builds.

\badcode

if (QSSG_GUARD(ptr != nullptr)) { ... // OK } else { ... // We shouldn't be here! }

is the equivalent to:

\badcode if (ptr != nullptr) { ... // OK } else { Q_ASSERT(ptr != nullptr); qWarning() << "Something unexpected here!"; }

See also
QSSG_GUARD_X

\macro QSSG_GUARD_X(condition, message)

Same as \l QSSG_GUARD() but with a custom message that will be print if condition is not met.

\macro QSSG_DEBUG_COND(condition)

Macro for condition that should only be run in debug builds. In releases build the macro produces an "almost-no-op" condition (always true) and the condition is never run. Can e.g., be combined with the assert checks to add potentially expensive sanity checks that should only be run in debug builds.

\badcode QSSG_CEHCK(QSSG_DEBUG_COND(!list.contains(...)));

In a release build the QSSG_DEBUG_COND will never return false and the condition will never be evaluated.

Note
DO NOT make surrounding code depend on the condition being evaluated or called!.
Unlike the assert checks, this macro does not change behavior in relation to developer-builds.

Definition at line 140 of file qssgassert.cpp.

References qFatal, and qWarning.