Fixed compute program destruction.

This commit is contained in:
Branimir Karadžić 2014-12-16 20:12:09 -08:00
Родитель 0dcde526dd
Коммит efcb10aef6
3 изменённых файлов: 28 добавлений и 12 удалений

Просмотреть файл

@ -790,6 +790,15 @@ namespace bgfx
///
ProgramHandle createProgram(ShaderHandle _vsh, ShaderHandle _fsh, bool _destroyShaders = false);
/// Create program with compute shader.
///
/// @param _csh Compute shader.
/// @param _destroyShader If true, shader will be destroyed when
/// program is destroyed.
/// @returns Program handle.
///
ProgramHandle createProgram(ShaderHandle _csh, bool _destroyShader = false);
/// Destroy program.
void destroyProgram(ProgramHandle _handle);

Просмотреть файл

@ -2235,14 +2235,14 @@ again:
return handle;
}
ProgramHandle createProgram(ShaderHandle _vsh, bool _destroyShaders)
ProgramHandle createProgram(ShaderHandle _csh, bool _destroyShader)
{
BGFX_CHECK_MAIN_THREAD();
ProgramHandle handle = s_ctx->createProgram(_vsh);
ProgramHandle handle = s_ctx->createProgram(_csh);
if (_destroyShaders)
if (_destroyShader)
{
destroyShader(_vsh);
destroyShader(_csh);
}
return handle;

Просмотреть файл

@ -2467,8 +2467,9 @@ namespace bgfx
{
shaderIncRef(_vsh);
shaderIncRef(_fsh);
m_programRef[handle.idx].m_vsh = _vsh;
m_programRef[handle.idx].m_fsh = _fsh;
ProgramRef& pr = m_programRef[handle.idx];
pr.m_vsh = _vsh;
pr.m_fsh = _fsh;
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateProgram);
cmdbuf.write(handle);
@ -2495,14 +2496,15 @@ namespace bgfx
if (isValid(handle) )
{
shaderIncRef(_vsh);
m_programRef[handle.idx].m_vsh = _vsh;
ProgramRef& pr = m_programRef[handle.idx];
pr.m_vsh = _vsh;
ShaderHandle fsh = BGFX_INVALID_HANDLE;
pr.m_fsh = fsh;
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateProgram);
cmdbuf.write(handle);
cmdbuf.write(_vsh);
ShaderHandle invalid = BGFX_INVALID_HANDLE;
cmdbuf.write(invalid);
cmdbuf.write(fsh);
}
return handle;
@ -2514,8 +2516,13 @@ namespace bgfx
cmdbuf.write(_handle);
m_submit->free(_handle);
shaderDecRef(m_programRef[_handle.idx].m_vsh);
shaderDecRef(m_programRef[_handle.idx].m_fsh);
const ProgramRef& pr = m_programRef[_handle.idx];
shaderDecRef(pr.m_vsh);
if (isValid(pr.m_fsh) )
{
shaderDecRef(pr.m_fsh);
}
}
BGFX_API_FUNC(TextureHandle createTexture(const Memory* _mem, uint32_t _flags, uint8_t _skip, TextureInfo* _info) )