@@ -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 ;
0 commit comments