shaderc: Added in/out hash. Fixed shader binary backward compatibility.

This commit is contained in:
Branimir Karadžić
2018-10-12 16:41:26 -07:00
parent 1ba107d156
commit 623fd3cf0b
10 changed files with 220 additions and 115 deletions

View File

@@ -4338,22 +4338,21 @@ namespace bgfx { namespace d3d12
uint32_t magic;
bx::read(&reader, magic);
switch (magic)
const bool fragment = isShaderType(magic, 'F');
uint32_t hashIn;
bx::read(&reader, hashIn);
uint32_t hashOut;
if (isShaderVerLess(magic, 6) )
{
case BGFX_CHUNK_MAGIC_CSH:
case BGFX_CHUNK_MAGIC_FSH:
case BGFX_CHUNK_MAGIC_VSH:
break;
default:
BGFX_FATAL(false, Fatal::InvalidShader, "Unknown shader format %x.", magic);
break;
hashOut = hashIn;
}
else
{
bx::read(&reader, hashOut);
}
bool fragment = BGFX_CHUNK_MAGIC_FSH == magic;
uint32_t iohash;
bx::read(&reader, iohash);
uint16_t count;
bx::read(&reader, count);
@@ -4362,7 +4361,7 @@ namespace bgfx { namespace d3d12
m_numUniforms = count;
BX_TRACE("%s Shader consts %d"
, BGFX_CHUNK_MAGIC_FSH == magic ? "Fragment" : BGFX_CHUNK_MAGIC_VSH == magic ? "Vertex" : "Compute"
, getShaderTypeName(magic)
, count
);
@@ -4468,7 +4467,8 @@ namespace bgfx { namespace d3d12
bx::HashMurmur2A murmur;
murmur.begin();
murmur.add(iohash);
murmur.add(hashIn);
murmur.add(hashOut);
murmur.add(code, shaderSize);
murmur.add(numAttrs);
murmur.add(m_attrMask, numAttrs);