Browse Source

Fixed shader ref counting.

Branimir Karadžić 8 years ago
parent
commit
1d5c3386fe
1 changed files with 7 additions and 9 deletions
  1. 7 9
      src/bgfx_p.h

+ 7 - 9
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);
 			}
 		}