Fixed constant buffer allocation logic.

This commit is contained in:
Branimir Karadžić 2014-10-08 19:36:59 -07:00
parent 14a71bd477
commit 51d8daf762
3 changed files with 28 additions and 9 deletions

View file

@ -2218,8 +2218,6 @@ RENDERDOC_IMPORT
if (0 < count) if (0 < count)
{ {
m_constantBuffer = ConstantBuffer::create(1024);
for (uint32_t ii = 0; ii < count; ++ii) for (uint32_t ii = 0; ii < count; ++ii)
{ {
uint8_t nameSize; uint8_t nameSize;
@ -2258,6 +2256,11 @@ RENDERDOC_IMPORT
if (NULL != info) if (NULL != info)
{ {
if (NULL == m_constantBuffer)
{
m_constantBuffer = ConstantBuffer::create(1024);
}
kind = "user"; kind = "user";
m_constantBuffer->writeUniformHandle( (UniformType::Enum)(type|fragmentBit), regIndex, info->m_handle, regCount); m_constantBuffer->writeUniformHandle( (UniformType::Enum)(type|fragmentBit), regIndex, info->m_handle, regCount);
} }
@ -2274,7 +2277,10 @@ RENDERDOC_IMPORT
BX_UNUSED(kind); BX_UNUSED(kind);
} }
m_constantBuffer->finish(); if (NULL != m_constantBuffer)
{
m_constantBuffer->finish();
}
} }
uint16_t shaderSize; uint16_t shaderSize;

View file

@ -1916,8 +1916,6 @@ namespace bgfx
if (0 < count) if (0 < count)
{ {
m_constantBuffer = ConstantBuffer::create(1024);
for (uint32_t ii = 0; ii < count; ++ii) for (uint32_t ii = 0; ii < count; ++ii)
{ {
uint8_t nameSize; uint8_t nameSize;
@ -1956,6 +1954,11 @@ namespace bgfx
BX_CHECK(NULL != info, "User defined uniform '%s' is not found, it won't be set.", name); BX_CHECK(NULL != info, "User defined uniform '%s' is not found, it won't be set.", name);
if (NULL != info) if (NULL != info)
{ {
if (NULL == m_constantBuffer)
{
m_constantBuffer = ConstantBuffer::create(1024);
}
kind = "user"; kind = "user";
m_constantBuffer->writeUniformHandle( (UniformType::Enum)(type|fragmentBit), regIndex, info->m_handle, regCount); m_constantBuffer->writeUniformHandle( (UniformType::Enum)(type|fragmentBit), regIndex, info->m_handle, regCount);
} }
@ -1972,7 +1975,10 @@ namespace bgfx
BX_UNUSED(kind); BX_UNUSED(kind);
} }
m_constantBuffer->finish(); if (NULL != m_constantBuffer)
{
m_constantBuffer->finish();
}
} }
uint16_t shaderSize; uint16_t shaderSize;

View file

@ -2555,7 +2555,6 @@ namespace bgfx
} }
m_numPredefined = 0; m_numPredefined = 0;
m_constantBuffer = ConstantBuffer::create(1024);
m_numSamplers = 0; m_numSamplers = 0;
struct VariableInfo struct VariableInfo
@ -2653,6 +2652,11 @@ namespace bgfx
const UniformInfo* info = s_renderGL->m_uniformReg.find(name); const UniformInfo* info = s_renderGL->m_uniformReg.find(name);
if (NULL != info) if (NULL != info)
{ {
if (NULL == m_constantBuffer)
{
m_constantBuffer = ConstantBuffer::create(1024);
}
UniformType::Enum type = convertGlType(gltype); UniformType::Enum type = convertGlType(gltype);
m_constantBuffer->writeUniformHandle(type, 0, info->m_handle, num); m_constantBuffer->writeUniformHandle(type, 0, info->m_handle, num);
m_constantBuffer->write(loc); m_constantBuffer->write(loc);
@ -2671,6 +2675,11 @@ namespace bgfx
BX_UNUSED(offset); BX_UNUSED(offset);
} }
if (NULL != m_constantBuffer)
{
m_constantBuffer->finish();
}
if (s_extension[Extension::ARB_program_interface_query].m_supported if (s_extension[Extension::ARB_program_interface_query].m_supported
|| BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES >= 31) ) || BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES >= 31) )
{ {
@ -2710,8 +2719,6 @@ namespace bgfx
} }
} }
m_constantBuffer->finish();
memset(m_attributes, 0xff, sizeof(m_attributes) ); memset(m_attributes, 0xff, sizeof(m_attributes) );
uint32_t used = 0; uint32_t used = 0;
for (uint32_t ii = 0; ii < Attrib::Count; ++ii) for (uint32_t ii = 0; ii < Attrib::Count; ++ii)