Skip to content

Commit 40557cd

Browse files
authored
Fix breaking change from bgfx update that broke morph targets (#1152)
1 parent f1d92a1 commit 40557cd

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

Plugins/NativeEngine/Source/ShaderCompilerCommon.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ namespace Babylon::ShaderCompilerCommon
3737
AppendBytes(bytes, static_cast<uint8_t>(uniform.Name.size()));
3838
AppendBytes(bytes, uniform.Name);
3939
AppendBytes(bytes, static_cast<uint8_t>(bgfxType | fragmentBit));
40-
AppendBytes(bytes, static_cast<uint8_t>(0)); // Value "num" not used by D3D11 pipeline.
40+
AppendBytes(bytes, static_cast<uint8_t>(uniform.ElementLength));
4141
AppendBytes(bytes, static_cast<uint16_t>(uniform.Offset));
4242
AppendBytes(bytes, static_cast<uint16_t>(uniform.RegisterSize));
4343
}
@@ -103,9 +103,14 @@ namespace Babylon::ShaderCompilerCommon
103103
throw std::runtime_error{"Unrecognized uniform type."};
104104
}
105105

106-
for (const auto size : spirType.array)
106+
if (spirType.array.size() == 1)
107107
{
108-
uniform.RegisterSize *= static_cast<uint16_t>(size);
108+
uniform.ElementLength = static_cast<uint8_t>(spirType.array[0]);
109+
uniform.RegisterSize *= uniform.ElementLength;
110+
}
111+
else if (spirType.array.size() > 1)
112+
{
113+
throw std::runtime_error{"Unsupported multidimensional array."};
109114
}
110115
}
111116
}
@@ -137,9 +142,14 @@ namespace Babylon::ShaderCompilerCommon
137142
throw std::runtime_error{"Unrecognized uniform type."};
138143
}
139144

140-
for (const auto size : type.array)
145+
if (type.array.size() == 1)
146+
{
147+
uniform.ElementLength = static_cast<uint8_t>(type.array[0]);
148+
uniform.RegisterSize *= uniform.ElementLength;
149+
}
150+
else if (type.array.size() > 1)
141151
{
142-
uniform.RegisterSize *= static_cast<uint16_t>(size);
152+
throw std::runtime_error{"Unsupported multidimensional array."};
143153
}
144154

145155
info.ByteSize += 4 * uniform.RegisterSize;

Plugins/NativeEngine/Source/ShaderCompilerCommon.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ namespace Babylon::ShaderCompilerCommon
4545
};
4646

4747
std::string Name{};
48+
uint8_t ElementLength{};
4849
uint32_t Offset{};
4950
uint16_t RegisterSize{};
5051
TypeEnum Type{};

0 commit comments

Comments
 (0)