Fixed shader ref counting.
This commit is contained in:
parent
6225876692
commit
54c8d69590
20
src/bgfx.cpp
20
src/bgfx.cpp
@ -1513,13 +1513,19 @@ namespace bgfx
|
||||
|
||||
if (BX_ENABLED(BGFX_CONFIG_DEBUG) )
|
||||
{
|
||||
#define CHECK_HANDLE_LEAK(_handleAlloc) \
|
||||
BX_MACRO_BLOCK_BEGIN \
|
||||
BX_WARN(0 == _handleAlloc.getNumHandles() \
|
||||
, "LEAK: " #_handleAlloc " %d (max: %d)" \
|
||||
, _handleAlloc.getNumHandles() \
|
||||
, _handleAlloc.getMaxHandles() \
|
||||
); \
|
||||
#define CHECK_HANDLE_LEAK(_handleAlloc) \
|
||||
BX_MACRO_BLOCK_BEGIN \
|
||||
if (0 != _handleAlloc.getNumHandles() ) \
|
||||
{ \
|
||||
BX_TRACE("LEAK: " #_handleAlloc " %d (max: %d)" \
|
||||
, _handleAlloc.getNumHandles() \
|
||||
, _handleAlloc.getMaxHandles() \
|
||||
); \
|
||||
for (uint16_t ii = 0, num = _handleAlloc.getNumHandles(); ii < num; ++ii) \
|
||||
{ \
|
||||
BX_TRACE("\t%3d: %d", ii, _handleAlloc.getHandleAt(ii) ); \
|
||||
} \
|
||||
} \
|
||||
BX_MACRO_BLOCK_END
|
||||
|
||||
CHECK_HANDLE_LEAK(m_dynamicIndexBufferHandle);
|
||||
|
12
src/bgfx_p.h
12
src/bgfx_p.h
@ -3062,6 +3062,7 @@ namespace bgfx
|
||||
{
|
||||
ShaderHandle handle = { idx };
|
||||
shaderIncRef(handle);
|
||||
release(_mem);
|
||||
return handle;
|
||||
}
|
||||
|
||||
@ -3083,7 +3084,6 @@ namespace bgfx
|
||||
sr.m_refCount = 1;
|
||||
sr.m_hash = iohash;
|
||||
sr.m_num = 0;
|
||||
sr.m_owned = false;
|
||||
sr.m_uniforms = NULL;
|
||||
|
||||
UniformHandle* uniforms = (UniformHandle*)alloca(count*sizeof(UniformHandle) );
|
||||
@ -3169,12 +3169,7 @@ namespace bgfx
|
||||
|
||||
void shaderTakeOwnership(ShaderHandle _handle)
|
||||
{
|
||||
ShaderRef& sr = m_shaderRef[_handle.idx];
|
||||
if (!sr.m_owned)
|
||||
{
|
||||
sr.m_owned = true;
|
||||
shaderDecRef(_handle);
|
||||
}
|
||||
shaderDecRef(_handle);
|
||||
}
|
||||
|
||||
void shaderIncRef(ShaderHandle _handle)
|
||||
@ -3227,6 +3222,8 @@ namespace bgfx
|
||||
ProgramHandle handle = { idx };
|
||||
ProgramRef& pr = m_programRef[handle.idx];
|
||||
++pr.m_refCount;
|
||||
shaderIncRef(pr.m_vsh);
|
||||
shaderIncRef(pr.m_fsh);
|
||||
return handle;
|
||||
}
|
||||
|
||||
@ -4342,7 +4339,6 @@ namespace bgfx
|
||||
uint32_t m_hash;
|
||||
int16_t m_refCount;
|
||||
uint16_t m_num;
|
||||
bool m_owned;
|
||||
};
|
||||
|
||||
struct ProgramRef
|
||||
|
Loading…
Reference in New Issue
Block a user