add error log detecting uint8_t overflow in hlsl shader compilation

This commit is contained in:
James Fulop 2023-12-19 12:19:33 -08:00 committed by GitHub
parent a0057adaaa
commit eb871bb618
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 0 deletions

View File

@ -481,6 +481,17 @@ namespace bgfx { namespace hlsl
if (UniformType::Count != uniformType
&& 0 != (varDesc.uFlags & D3D_SVF_USED) )
{
if (constDesc.Elements > UINT8_MAX)
{
bx::write(_messageWriter
, &messageErr
, "Error: Uniform %s has %u elements. 255 is the limit for shaderc uniform serialization.\n"
, varDesc.Name
, constDesc.Elements
);
return false;
}
Uniform un;
un.name = varDesc.Name;
un.type = uniformType;