mirror of https://github.com/bkaradzic/bgfx
shaderc: Added SPIR-V uniform buffer size.
This commit is contained in:
parent
d8160075e8
commit
fc87e05199
|
@ -3569,20 +3569,6 @@ VK_DESTROY
|
|||
m_attrMask[Attrib::Color0] = UINT16_MAX;
|
||||
iohash = 0;
|
||||
|
||||
if (BGFX_CHUNK_MAGIC_VSH == magic)
|
||||
{
|
||||
m_predefined[0].m_loc = 0;
|
||||
m_predefined[0].m_count = 4;
|
||||
m_predefined[0].m_type = uint8_t(PredefinedUniform::ModelViewProj);
|
||||
m_numPredefined = 1;
|
||||
m_size = 64;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_size = 0;
|
||||
m_numPredefined = 0;
|
||||
}
|
||||
|
||||
uint8_t numAttrs = 0;
|
||||
// bx::read(&reader, numAttrs);
|
||||
//
|
||||
|
@ -3606,6 +3592,8 @@ VK_DESTROY
|
|||
murmur.add(numAttrs);
|
||||
murmur.add(m_attrMask, numAttrs);
|
||||
m_hash = murmur.end();
|
||||
|
||||
bx::read(&reader, m_size);
|
||||
}
|
||||
|
||||
void ShaderVK::destroy()
|
||||
|
|
|
@ -570,7 +570,6 @@ namespace bgfx { namespace spirv
|
|||
);
|
||||
bool linked = false;
|
||||
bool validated = true;
|
||||
bool optimized = true;
|
||||
|
||||
if (!compiled)
|
||||
{
|
||||
|
@ -625,6 +624,8 @@ namespace bgfx { namespace spirv
|
|||
}
|
||||
else
|
||||
{
|
||||
uint16_t size = 0;
|
||||
|
||||
program->buildReflection();
|
||||
{
|
||||
uint16_t count = (uint16_t)program->getNumLiveUniformVariables();
|
||||
|
@ -635,6 +636,11 @@ namespace bgfx { namespace spirv
|
|||
{
|
||||
Uniform un;
|
||||
un.name = program->getUniformName(ii);
|
||||
|
||||
un.num = uint8_t(program->getUniformArraySize(ii) );
|
||||
un.regIndex = 0;
|
||||
un.regCount = un.num;
|
||||
|
||||
switch (program->getUniformType(ii))
|
||||
{
|
||||
case 0x1404: // GL_INT:
|
||||
|
@ -645,17 +651,18 @@ namespace bgfx { namespace spirv
|
|||
break;
|
||||
case 0x8B5B: // GL_FLOAT_MAT3:
|
||||
un.type = UniformType::Mat3;
|
||||
un.regCount *= 3;
|
||||
break;
|
||||
case 0x8B5C: // GL_FLOAT_MAT4:
|
||||
un.type = UniformType::Mat4;
|
||||
un.regCount *= 4;
|
||||
break;
|
||||
default:
|
||||
un.type = UniformType::End;
|
||||
break;
|
||||
}
|
||||
un.num = uint8_t(program->getUniformArraySize(ii) );
|
||||
un.regIndex = 0;
|
||||
un.regCount = un.num;
|
||||
|
||||
size += un.regCount*16;
|
||||
|
||||
uint8_t nameSize = (uint8_t)un.name.size();
|
||||
bx::write(_writer, nameSize);
|
||||
|
@ -694,14 +701,13 @@ namespace bgfx { namespace spirv
|
|||
bx::MemoryReader reader(spirv.data(), uint32_t(spirv.size()*4) );
|
||||
disassemble(writer, &reader, &err);
|
||||
|
||||
if (optimized)
|
||||
{
|
||||
uint32_t shaderSize = (uint32_t)spirv.size()*sizeof(uint32_t);
|
||||
bx::write(_writer, shaderSize);
|
||||
bx::write(_writer, spirv.data(), shaderSize);
|
||||
uint8_t nul = 0;
|
||||
bx::write(_writer, nul);
|
||||
}
|
||||
uint32_t shaderSize = (uint32_t)spirv.size()*sizeof(uint32_t);
|
||||
bx::write(_writer, shaderSize);
|
||||
bx::write(_writer, spirv.data(), shaderSize);
|
||||
uint8_t nul = 0;
|
||||
bx::write(_writer, nul);
|
||||
|
||||
bx::write(_writer, size);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -710,7 +716,7 @@ namespace bgfx { namespace spirv
|
|||
|
||||
glslang::FinalizeProcess();
|
||||
|
||||
return compiled && linked && validated && optimized;
|
||||
return compiled && linked && validated;
|
||||
}
|
||||
|
||||
} // namespace spirv
|
||||
|
|
Loading…
Reference in New Issue