From eb871bb618beaf45cab2e6c68b666bd6b6e9e567 Mon Sep 17 00:00:00 2001 From: James Fulop <40307536+jamesfAnet@users.noreply.github.com> Date: Tue, 19 Dec 2023 12:19:33 -0800 Subject: [PATCH] add error log detecting uint8_t overflow in hlsl shader compilation --- tools/shaderc/shaderc_hlsl.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tools/shaderc/shaderc_hlsl.cpp b/tools/shaderc/shaderc_hlsl.cpp index 82a9244907..75755f40e5 100644 --- a/tools/shaderc/shaderc_hlsl.cpp +++ b/tools/shaderc/shaderc_hlsl.cpp @@ -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;