bindBlock method

bool bindBlock(
  1. ShaderHandle stage,
  2. UniformBlock block
)

Binds block to stage — bindUniformBlock with the block's name and members.

Only the members stage has, where its layout is known. One block name can be wider in one stage than another: bloom's upsample declares a tint its threshold does not, and a generated class carries the union. Handing the narrower stage the wider map would be refused by name, so the members its layout does not list are left out here.

Implementation

bool bindBlock(ShaderHandle stage, UniformBlock block) {
  final layout = stage.layouts?[block.name];
  final members = block.members;
  if (layout == null || layout.length >= members.length) {
    return bindUniformBlock(stage, block.name, members);
  }
  return bindUniformBlock(stage, block.name, <String, Float32List>{
    for (final MapEntry(:key, :value) in members.entries)
      if (layout.containsKey(key)) key: value,
  });
}