From e22fac6794cf8b4417fb33ca475c89764b5e89dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Wed, 4 Feb 2026 18:01:52 -0800 Subject: [PATCH] shaderc: Fix getUniformTypeName. (#3580) --- scripts/shader.mk | 2 +- tools/shaderc/shaderc.cpp | 29 +++++++++++++++-------------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/scripts/shader.mk b/scripts/shader.mk index bf18cacc3..8798f118c 100644 --- a/scripts/shader.mk +++ b/scripts/shader.mk @@ -133,7 +133,7 @@ CS_BIN = $(addprefix $(BUILD_INTERMEDIATE_DIR)/, $(addsuffix .bin, $(basename $( BIN = $(VS_BIN) $(FS_BIN) $(CS_BIN) ASM = $(VS_ASM) $(FS_ASM) -ifeq ($(TARGET), $(filter $(TARGET),1 3 4 5 6 7)) +ifeq ($(TARGET), $(filter $(TARGET),1 3 4 5 6 7 8)) BIN += $(CS_BIN) ASM += $(CS_ASM) endif diff --git a/tools/shaderc/shaderc.cpp b/tools/shaderc/shaderc.cpp index 7182b9147..85e233ed5 100644 --- a/tools/shaderc/shaderc.cpp +++ b/tools/shaderc/shaderc.cpp @@ -319,16 +319,6 @@ namespace bgfx NULL }; - const char* s_uniformTypeName[] = - { - "int", "int", - NULL, NULL, - "vec4", "float4", - "mat3", "float3x3", - "mat4", "float4x4", - }; - static_assert(BX_COUNTOF(s_uniformTypeName) == UniformType::Count*2); - static const char* s_allowedVertexShaderInputs[] = { "a_position", @@ -471,7 +461,8 @@ namespace bgfx { return "linear"; } - else if (0 == bx::strCmp(_glsl, "flat") ) + + if (0 == bx::strCmp(_glsl, "flat") ) { return "nointerpolation"; } @@ -479,12 +470,22 @@ namespace bgfx return _glsl; // centroid, noperspective } + const char* s_uniformTypeName[] = + { + "int", "int", + NULL, NULL, + "vec4", "float4", + "mat3", "float3x3", + "mat4", "float4x4", + }; + static_assert(BX_COUNTOF(s_uniformTypeName) == UniformType::Count*2); + const char* getUniformTypeName(UniformType::Enum _enum) { - uint32_t idx = _enum & ~(kUniformFragmentBit|kUniformSamplerBit); + const uint32_t idx = _enum & ~(kUniformFragmentBit|kUniformSamplerBit); if (idx < UniformType::Count) { - return s_uniformTypeName[idx]; + return s_uniformTypeName[idx*2+0]; } return "Unknown uniform type?!"; @@ -495,7 +496,7 @@ namespace bgfx for (uint32_t ii = 0; ii < UniformType::Count*2; ++ii) { if (NULL != s_uniformTypeName[ii] - && 0 == bx::strCmp(_name, s_uniformTypeName[ii]) ) + && 0 == bx::strCmp(_name, s_uniformTypeName[ii]) ) { return UniformType::Enum(ii/2); }