[web] correct float count in runtime effect (flutter/engine#38288)

This commit is contained in:
Jonah Williams
2022-12-14 10:11:50 -08:00
committed by GitHub
parent 9896c5f66d
commit d7a2d4a253
2 changed files with 4 additions and 3 deletions

View File

@@ -423,11 +423,12 @@ class CkFragmentProgram implements ui.FragmentProgram {
if (type == UniformType.SampledImage) {
textureCount += 1;
} else {
final Object? rows = rawUniformData['rows'];
final Object? bitWidth = rawUniformData['bit_width'];
if (bitWidth is! int) {
if (bitWidth is! int || rows is! int) {
throw const FormatException('Invalid Shader Data');
}
floatCount += bitWidth ~/ 32;
floatCount += (bitWidth ~/ 32) * rows;
}
uniforms[location] = UniformData(
name: name,

View File

@@ -192,7 +192,7 @@ void testMain() {
final CkFragmentProgram program = await CkFragmentProgram.fromBytes('test', data);
expect(program.effect, isNotNull);
expect(program.floatCount, 17);
expect(program.floatCount, 32);
expect(program.textureCount, 0);
expect(program.uniforms, hasLength(17));
expect(program.name, 'test');