diff --git a/src/bgfx.cpp b/src/bgfx.cpp index 639458af2..a159b3f78 100644 --- a/src/bgfx.cpp +++ b/src/bgfx.cpp @@ -1328,6 +1328,11 @@ namespace bgfx { BX_CHECK(0 == m_instBufferCount, "Instance buffer allocated, but not used. This is incorrect, and causes memory leak."); + if (BX_ENABLED(BGFX_CONFIG_DEBUG_OCCLUSION) ) + { + m_occlusionQuerySet.clear(); + } + // wait for render thread to finish renderSemWait(); frameNoRenderWait(); diff --git a/src/bgfx_p.h b/src/bgfx_p.h index 5c5b2867b..b6f806f29 100644 --- a/src/bgfx_p.h +++ b/src/bgfx_p.h @@ -3605,6 +3605,17 @@ namespace bgfx { m_uniformSet.clear(); } + + if (BX_ENABLED(BGFX_CONFIG_DEBUG_OCCLUSION) + && isValid(_occlusionQuery) ) + { + BX_CHECK(m_occlusionQuerySet.end() == m_occlusionQuerySet.find(_occlusionQuery.idx) + , "OcclusionQuery %d was already used for this frame." + , _occlusionQuery.idx + ); + m_occlusionQuerySet.insert(_occlusionQuery.idx); + } + return m_submit->submit(_id, _program, _occlusionQuery, _depth); } @@ -3873,10 +3884,12 @@ namespace bgfx bool m_window; }; + typedef stl::unordered_set HandleSet; + HandleSet m_uniformSet; + HandleSet m_occlusionQuerySet; + typedef stl::unordered_map UniformHashMap; UniformHashMap m_uniformHashMap; - typedef stl::unordered_set UniformSet; - UniformSet m_uniformSet; UniformRef m_uniformRef[BGFX_CONFIG_MAX_UNIFORMS]; ShaderRef m_shaderRef[BGFX_CONFIG_MAX_SHADERS]; diff --git a/src/config.h b/src/config.h index 1237b93ee..28cc418fe 100644 --- a/src/config.h +++ b/src/config.h @@ -164,11 +164,16 @@ # define BGFX_CONFIG_DEBUG_MTL BGFX_CONFIG_DEBUG #endif // BGFX_CONFIG_DEBUG_MTL -/// +/// Enable uniform debug checks. #ifndef BGFX_CONFIG_DEBUG_UNIFORM # define BGFX_CONFIG_DEBUG_UNIFORM BGFX_CONFIG_DEBUG #endif // BGFX_CONFIG_DEBUG_UNIFORM +/// Enable occlusion debug checks. +#ifndef BGFX_CONFIG_DEBUG_OCCLUSION +# define BGFX_CONFIG_DEBUG_OCCLUSION BGFX_CONFIG_DEBUG +#endif // BGFX_CONFIG_DEBUG_OCCLUSION + #ifndef BGFX_CONFIG_MULTITHREADED # define BGFX_CONFIG_MULTITHREADED ( (!BGFX_CONFIG_RENDERER_NULL)&&(0 \ || BX_PLATFORM_ANDROID \