From 1d5c3386fe4097cb0178103d46c5875c2c8ca80f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Mon, 7 Aug 2017 17:41:08 -0700 Subject: [PATCH] Fixed shader ref counting. --- src/bgfx_p.h | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/bgfx_p.h b/src/bgfx_p.h index 949fdc605..c646a36f8 100644 --- a/src/bgfx_p.h +++ b/src/bgfx_p.h @@ -3322,6 +3322,13 @@ namespace bgfx BGFX_CHECK_HANDLE("destroyProgram", m_programHandle, _handle); ProgramRef& pr = m_programRef[_handle.idx]; + shaderDecRef(pr.m_vsh); + + if (isValid(pr.m_fsh) ) + { + shaderDecRef(pr.m_fsh); + } + int32_t refs = --pr.m_refCount; if (0 == refs) { @@ -3331,15 +3338,6 @@ namespace bgfx CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::DestroyProgram); cmdbuf.write(_handle); - shaderDecRef(pr.m_vsh); - uint32_t hash = pr.m_vsh.idx; - - if (isValid(pr.m_fsh) ) - { - shaderDecRef(pr.m_fsh); - hash |= pr.m_fsh.idx << 16; - } - m_programHashMap.removeByHandle(_handle.idx); } }