Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 27 additions & 6 deletions lib/web_ui/lib/src/engine/shader_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@ class ShaderData {
if (rawShaderData is! Map<String, Object?>) {
throw const FormatException('Invalid Shader Data');
}
final Object? source = rawShaderData['sksl'];
final Object? rawUniforms = rawShaderData['uniforms'];
final Object? root = rawShaderData['sksl'];
if (root is! Map<String, Object?>) {
throw const FormatException('Invalid Shader Data');
}

final Object? source = root['shader'];
final Object? rawUniforms = root['uniforms'];
if (source is! String || rawUniforms is! List<Object?>) {
throw const FormatException('Invalid Shader Data');
}
Expand All @@ -47,14 +52,30 @@ class ShaderData {
if (type == UniformType.SampledImage) {
textureCount += 1;
} else {
final Object? rows = rawUniformData['rows'];
final Object? bitWidth = rawUniformData['bit_width'];
if (bitWidth is! int || rows is! int) {

final Object? arrayElements = rawUniformData['array_elements'];
final Object? rows = rawUniformData['rows'];
final Object? columns = rawUniformData['columns'];

if (bitWidth is! int ||
rows is! int ||
arrayElements is! int ||
columns is! int) {
throw const FormatException('Invalid Shader Data');
}
floatCount += (bitWidth ~/ 32) * rows;

final int units = rows * columns;

int value = (bitWidth ~/ 32) * units;

if (arrayElements > 1) {
value *= arrayElements;
}

floatCount += value;
}
uniforms[location] = UniformData(
uniforms[i] = UniformData(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To reviewer: Attention to this change, in the current impl we get an out of bounds error as the location value also considers the array size.

name: name,
location: location,
type: type,
Expand Down
Loading