// automatically generated by the FlatBuffers compiler, do not modify
// ignore_for_file: unused_import, unused_field, unused_element, unused_local_variable

library impeller.fb.shaderbundle;

import 'dart:typed_data' show Uint8List;
import 'package:flat_buffers/flat_buffers.dart' as fb;

class ShaderBundleFormatVersion {
  final int value;
  const ShaderBundleFormatVersion._(this.value);

  factory ShaderBundleFormatVersion.fromValue(int value) {
    final result = values[value];
    if (result == null) {
      throw StateError(
        'Invalid value $value for bit flag enum ShaderBundleFormatVersion',
      );
    }
    return result;
  }

  static ShaderBundleFormatVersion? _createOrNull(int? value) =>
      value == null ? null : ShaderBundleFormatVersion.fromValue(value);

  static const int minValue = 2;
  static const int maxValue = 2;
  static bool containsValue(int value) => values.containsKey(value);

  static const ShaderBundleFormatVersion kVersion = ShaderBundleFormatVersion._(
    2,
  );
  static const Map<int, ShaderBundleFormatVersion> values = {2: kVersion};

  static const fb.Reader<ShaderBundleFormatVersion> reader =
      _ShaderBundleFormatVersionReader();

  @override
  String toString() {
    return 'ShaderBundleFormatVersion{value: $value}';
  }
}

class _ShaderBundleFormatVersionReader
    extends fb.Reader<ShaderBundleFormatVersion> {
  const _ShaderBundleFormatVersionReader();

  @override
  int get size => 4;

  @override
  ShaderBundleFormatVersion read(fb.BufferContext bc, int offset) =>
      ShaderBundleFormatVersion.fromValue(
        const fb.Uint32Reader().read(bc, offset),
      );
}

class ShaderStage {
  final int value;
  const ShaderStage._(this.value);

  factory ShaderStage.fromValue(int value) {
    final result = values[value];
    if (result == null) {
      throw StateError('Invalid value $value for bit flag enum ShaderStage');
    }
    return result;
  }

  static ShaderStage? _createOrNull(int? value) =>
      value == null ? null : ShaderStage.fromValue(value);

  static const int minValue = 0;
  static const int maxValue = 2;
  static bool containsValue(int value) => values.containsKey(value);

  static const ShaderStage kVertex = ShaderStage._(0);
  static const ShaderStage kFragment = ShaderStage._(1);
  static const ShaderStage kCompute = ShaderStage._(2);
  static const Map<int, ShaderStage> values = {
    0: kVertex,
    1: kFragment,
    2: kCompute,
  };

  static const fb.Reader<ShaderStage> reader = _ShaderStageReader();

  @override
  String toString() {
    return 'ShaderStage{value: $value}';
  }
}

class _ShaderStageReader extends fb.Reader<ShaderStage> {
  const _ShaderStageReader();

  @override
  int get size => 1;

  @override
  ShaderStage read(fb.BufferContext bc, int offset) =>
      ShaderStage.fromValue(const fb.Int8Reader().read(bc, offset));
}

class InputDataType {
  final int value;
  const InputDataType._(this.value);

  factory InputDataType.fromValue(int value) {
    final result = values[value];
    if (result == null) {
      throw StateError('Invalid value $value for bit flag enum InputDataType');
    }
    return result;
  }

  static InputDataType? _createOrNull(int? value) =>
      value == null ? null : InputDataType.fromValue(value);

  static const int minValue = 0;
  static const int maxValue = 10;
  static bool containsValue(int value) => values.containsKey(value);

  static const InputDataType kBoolean = InputDataType._(0);
  static const InputDataType kSignedByte = InputDataType._(1);
  static const InputDataType kUnsignedByte = InputDataType._(2);
  static const InputDataType kSignedShort = InputDataType._(3);
  static const InputDataType kUnsignedShort = InputDataType._(4);
  static const InputDataType kSignedInt = InputDataType._(5);
  static const InputDataType kUnsignedInt = InputDataType._(6);
  static const InputDataType kSignedInt64 = InputDataType._(7);
  static const InputDataType kUnsignedInt64 = InputDataType._(8);
  static const InputDataType kFloat = InputDataType._(9);
  static const InputDataType kDouble = InputDataType._(10);
  static const Map<int, InputDataType> values = {
    0: kBoolean,
    1: kSignedByte,
    2: kUnsignedByte,
    3: kSignedShort,
    4: kUnsignedShort,
    5: kSignedInt,
    6: kUnsignedInt,
    7: kSignedInt64,
    8: kUnsignedInt64,
    9: kFloat,
    10: kDouble,
  };

  static const fb.Reader<InputDataType> reader = _InputDataTypeReader();

  @override
  String toString() {
    return 'InputDataType{value: $value}';
  }
}

class _InputDataTypeReader extends fb.Reader<InputDataType> {
  const _InputDataTypeReader();

  @override
  int get size => 4;

  @override
  InputDataType read(fb.BufferContext bc, int offset) =>
      InputDataType.fromValue(const fb.Uint32Reader().read(bc, offset));
}

class UniformDataType {
  final int value;
  const UniformDataType._(this.value);

  factory UniformDataType.fromValue(int value) {
    final result = values[value];
    if (result == null) {
      throw StateError(
        'Invalid value $value for bit flag enum UniformDataType',
      );
    }
    return result;
  }

  static UniformDataType? _createOrNull(int? value) =>
      value == null ? null : UniformDataType.fromValue(value);

  static const int minValue = 0;
  static const int maxValue = 12;
  static bool containsValue(int value) => values.containsKey(value);

  static const UniformDataType kBoolean = UniformDataType._(0);
  static const UniformDataType kSignedByte = UniformDataType._(1);
  static const UniformDataType kUnsignedByte = UniformDataType._(2);
  static const UniformDataType kSignedShort = UniformDataType._(3);
  static const UniformDataType kUnsignedShort = UniformDataType._(4);
  static const UniformDataType kSignedInt = UniformDataType._(5);
  static const UniformDataType kUnsignedInt = UniformDataType._(6);
  static const UniformDataType kSignedInt64 = UniformDataType._(7);
  static const UniformDataType kUnsignedInt64 = UniformDataType._(8);
  static const UniformDataType kHalfFloat = UniformDataType._(9);
  static const UniformDataType kFloat = UniformDataType._(10);
  static const UniformDataType kDouble = UniformDataType._(11);
  static const UniformDataType kSampledImage = UniformDataType._(12);
  static const Map<int, UniformDataType> values = {
    0: kBoolean,
    1: kSignedByte,
    2: kUnsignedByte,
    3: kSignedShort,
    4: kUnsignedShort,
    5: kSignedInt,
    6: kUnsignedInt,
    7: kSignedInt64,
    8: kUnsignedInt64,
    9: kHalfFloat,
    10: kFloat,
    11: kDouble,
    12: kSampledImage,
  };

  static const fb.Reader<UniformDataType> reader = _UniformDataTypeReader();

  @override
  String toString() {
    return 'UniformDataType{value: $value}';
  }
}

class _UniformDataTypeReader extends fb.Reader<UniformDataType> {
  const _UniformDataTypeReader();

  @override
  int get size => 4;

  @override
  UniformDataType read(fb.BufferContext bc, int offset) =>
      UniformDataType.fromValue(const fb.Uint32Reader().read(bc, offset));
}

class ShaderInput {
  ShaderInput._(this._bc, this._bcOffset);
  factory ShaderInput(List<int> bytes) {
    final rootRef = fb.BufferContext.fromBytes(bytes);
    return reader.read(rootRef, 0);
  }

  static const fb.Reader<ShaderInput> reader = _ShaderInputReader();

  final fb.BufferContext _bc;
  final int _bcOffset;

  String? get name =>
      const fb.StringReader().vTableGetNullable(_bc, _bcOffset, 4);
  int get location => const fb.Uint64Reader().vTableGet(_bc, _bcOffset, 6, 0);
  int get $set => const fb.Uint64Reader().vTableGet(_bc, _bcOffset, 8, 0);
  int get binding => const fb.Uint64Reader().vTableGet(_bc, _bcOffset, 10, 0);
  InputDataType get type => InputDataType.fromValue(
    const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 12, 0),
  );
  int get bitWidth => const fb.Uint64Reader().vTableGet(_bc, _bcOffset, 14, 0);
  int get vecSize => const fb.Uint64Reader().vTableGet(_bc, _bcOffset, 16, 0);
  int get columns => const fb.Uint64Reader().vTableGet(_bc, _bcOffset, 18, 0);
  int get offset => const fb.Uint64Reader().vTableGet(_bc, _bcOffset, 20, 0);

  @override
  String toString() {
    return 'ShaderInput{name: ${name}, location: ${location}, \$set: ${$set}, binding: ${binding}, type: ${type}, bitWidth: ${bitWidth}, vecSize: ${vecSize}, columns: ${columns}, offset: ${offset}}';
  }
}

class _ShaderInputReader extends fb.TableReader<ShaderInput> {
  const _ShaderInputReader();

  @override
  ShaderInput createObject(fb.BufferContext bc, int offset) =>
      ShaderInput._(bc, offset);
}

class ShaderInputBuilder {
  ShaderInputBuilder(this.fbBuilder);

  final fb.Builder fbBuilder;

  void begin() {
    fbBuilder.startTable(9);
  }

  int addNameOffset(int? offset) {
    fbBuilder.addOffset(0, offset);
    return fbBuilder.offset;
  }

  int addLocation(int? location) {
    fbBuilder.addUint64(1, location);
    return fbBuilder.offset;
  }

  int addSet(int? $set) {
    fbBuilder.addUint64(2, $set);
    return fbBuilder.offset;
  }

  int addBinding(int? binding) {
    fbBuilder.addUint64(3, binding);
    return fbBuilder.offset;
  }

  int addType(InputDataType? type) {
    fbBuilder.addUint32(4, type?.value);
    return fbBuilder.offset;
  }

  int addBitWidth(int? bitWidth) {
    fbBuilder.addUint64(5, bitWidth);
    return fbBuilder.offset;
  }

  int addVecSize(int? vecSize) {
    fbBuilder.addUint64(6, vecSize);
    return fbBuilder.offset;
  }

  int addColumns(int? columns) {
    fbBuilder.addUint64(7, columns);
    return fbBuilder.offset;
  }

  int addOffset(int? offset) {
    fbBuilder.addUint64(8, offset);
    return fbBuilder.offset;
  }

  int finish() {
    return fbBuilder.endTable();
  }
}

class ShaderInputObjectBuilder extends fb.ObjectBuilder {
  final String? _name;
  final int? _location;
  final int? _$set;
  final int? _binding;
  final InputDataType? _type;
  final int? _bitWidth;
  final int? _vecSize;
  final int? _columns;
  final int? _offset;

  ShaderInputObjectBuilder({
    String? name,
    int? location,
    int? $set,
    int? binding,
    InputDataType? type,
    int? bitWidth,
    int? vecSize,
    int? columns,
    int? offset,
  }) : _name = name,
       _location = location,
       _$set = $set,
       _binding = binding,
       _type = type,
       _bitWidth = bitWidth,
       _vecSize = vecSize,
       _columns = columns,
       _offset = offset;

  /// Finish building, and store into the [fbBuilder].
  @override
  int finish(fb.Builder fbBuilder) {
    final int? nameOffset = _name == null
        ? null
        : fbBuilder.writeString(_name!);
    fbBuilder.startTable(9);
    fbBuilder.addOffset(0, nameOffset);
    fbBuilder.addUint64(1, _location);
    fbBuilder.addUint64(2, _$set);
    fbBuilder.addUint64(3, _binding);
    fbBuilder.addUint32(4, _type?.value);
    fbBuilder.addUint64(5, _bitWidth);
    fbBuilder.addUint64(6, _vecSize);
    fbBuilder.addUint64(7, _columns);
    fbBuilder.addUint64(8, _offset);
    return fbBuilder.endTable();
  }

  /// Convenience method to serialize to byte list.
  @override
  Uint8List toBytes([String? fileIdentifier]) {
    final fbBuilder = fb.Builder(deduplicateTables: false);
    fbBuilder.finish(finish(fbBuilder), fileIdentifier);
    return fbBuilder.buffer;
  }
}

class ShaderUniformStructField {
  ShaderUniformStructField._(this._bc, this._bcOffset);
  factory ShaderUniformStructField(List<int> bytes) {
    final rootRef = fb.BufferContext.fromBytes(bytes);
    return reader.read(rootRef, 0);
  }

  static const fb.Reader<ShaderUniformStructField> reader =
      _ShaderUniformStructFieldReader();

  final fb.BufferContext _bc;
  final int _bcOffset;

  String? get name =>
      const fb.StringReader().vTableGetNullable(_bc, _bcOffset, 4);
  UniformDataType get type => UniformDataType.fromValue(
    const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 6, 0),
  );
  int get offsetInBytes =>
      const fb.Uint64Reader().vTableGet(_bc, _bcOffset, 8, 0);
  int get elementSizeInBytes =>
      const fb.Uint64Reader().vTableGet(_bc, _bcOffset, 10, 0);
  int get totalSizeInBytes =>
      const fb.Uint64Reader().vTableGet(_bc, _bcOffset, 12, 0);
  int get arrayElements =>
      const fb.Uint64Reader().vTableGet(_bc, _bcOffset, 14, 0);
  int get vecSize => const fb.Uint64Reader().vTableGet(_bc, _bcOffset, 16, 0);
  int get columns => const fb.Uint64Reader().vTableGet(_bc, _bcOffset, 18, 0);

  @override
  String toString() {
    return 'ShaderUniformStructField{name: ${name}, type: ${type}, offsetInBytes: ${offsetInBytes}, elementSizeInBytes: ${elementSizeInBytes}, totalSizeInBytes: ${totalSizeInBytes}, arrayElements: ${arrayElements}, vecSize: ${vecSize}, columns: ${columns}}';
  }
}

class _ShaderUniformStructFieldReader
    extends fb.TableReader<ShaderUniformStructField> {
  const _ShaderUniformStructFieldReader();

  @override
  ShaderUniformStructField createObject(fb.BufferContext bc, int offset) =>
      ShaderUniformStructField._(bc, offset);
}

class ShaderUniformStructFieldBuilder {
  ShaderUniformStructFieldBuilder(this.fbBuilder);

  final fb.Builder fbBuilder;

  void begin() {
    fbBuilder.startTable(8);
  }

  int addNameOffset(int? offset) {
    fbBuilder.addOffset(0, offset);
    return fbBuilder.offset;
  }

  int addType(UniformDataType? type) {
    fbBuilder.addUint32(1, type?.value);
    return fbBuilder.offset;
  }

  int addOffsetInBytes(int? offsetInBytes) {
    fbBuilder.addUint64(2, offsetInBytes);
    return fbBuilder.offset;
  }

  int addElementSizeInBytes(int? elementSizeInBytes) {
    fbBuilder.addUint64(3, elementSizeInBytes);
    return fbBuilder.offset;
  }

  int addTotalSizeInBytes(int? totalSizeInBytes) {
    fbBuilder.addUint64(4, totalSizeInBytes);
    return fbBuilder.offset;
  }

  int addArrayElements(int? arrayElements) {
    fbBuilder.addUint64(5, arrayElements);
    return fbBuilder.offset;
  }

  int addVecSize(int? vecSize) {
    fbBuilder.addUint64(6, vecSize);
    return fbBuilder.offset;
  }

  int addColumns(int? columns) {
    fbBuilder.addUint64(7, columns);
    return fbBuilder.offset;
  }

  int finish() {
    return fbBuilder.endTable();
  }
}

class ShaderUniformStructFieldObjectBuilder extends fb.ObjectBuilder {
  final String? _name;
  final UniformDataType? _type;
  final int? _offsetInBytes;
  final int? _elementSizeInBytes;
  final int? _totalSizeInBytes;
  final int? _arrayElements;
  final int? _vecSize;
  final int? _columns;

  ShaderUniformStructFieldObjectBuilder({
    String? name,
    UniformDataType? type,
    int? offsetInBytes,
    int? elementSizeInBytes,
    int? totalSizeInBytes,
    int? arrayElements,
    int? vecSize,
    int? columns,
  }) : _name = name,
       _type = type,
       _offsetInBytes = offsetInBytes,
       _elementSizeInBytes = elementSizeInBytes,
       _totalSizeInBytes = totalSizeInBytes,
       _arrayElements = arrayElements,
       _vecSize = vecSize,
       _columns = columns;

  /// Finish building, and store into the [fbBuilder].
  @override
  int finish(fb.Builder fbBuilder) {
    final int? nameOffset = _name == null
        ? null
        : fbBuilder.writeString(_name!);
    fbBuilder.startTable(8);
    fbBuilder.addOffset(0, nameOffset);
    fbBuilder.addUint32(1, _type?.value);
    fbBuilder.addUint64(2, _offsetInBytes);
    fbBuilder.addUint64(3, _elementSizeInBytes);
    fbBuilder.addUint64(4, _totalSizeInBytes);
    fbBuilder.addUint64(5, _arrayElements);
    fbBuilder.addUint64(6, _vecSize);
    fbBuilder.addUint64(7, _columns);
    return fbBuilder.endTable();
  }

  /// Convenience method to serialize to byte list.
  @override
  Uint8List toBytes([String? fileIdentifier]) {
    final fbBuilder = fb.Builder(deduplicateTables: false);
    fbBuilder.finish(finish(fbBuilder), fileIdentifier);
    return fbBuilder.buffer;
  }
}

class ShaderUniformStruct {
  ShaderUniformStruct._(this._bc, this._bcOffset);
  factory ShaderUniformStruct(List<int> bytes) {
    final rootRef = fb.BufferContext.fromBytes(bytes);
    return reader.read(rootRef, 0);
  }

  static const fb.Reader<ShaderUniformStruct> reader =
      _ShaderUniformStructReader();

  final fb.BufferContext _bc;
  final int _bcOffset;

  String? get name =>
      const fb.StringReader().vTableGetNullable(_bc, _bcOffset, 4);
  int get extRes0 => const fb.Uint64Reader().vTableGet(_bc, _bcOffset, 6, 0);
  int get $set => const fb.Uint64Reader().vTableGet(_bc, _bcOffset, 8, 0);
  int get binding => const fb.Uint64Reader().vTableGet(_bc, _bcOffset, 10, 0);
  int get sizeInBytes =>
      const fb.Uint64Reader().vTableGet(_bc, _bcOffset, 12, 0);
  List<ShaderUniformStructField>? get fields =>
      const fb.ListReader<ShaderUniformStructField>(
        ShaderUniformStructField.reader,
      ).vTableGetNullable(_bc, _bcOffset, 14);

  @override
  String toString() {
    return 'ShaderUniformStruct{name: ${name}, extRes0: ${extRes0}, \$set: ${$set}, binding: ${binding}, sizeInBytes: ${sizeInBytes}, fields: ${fields}}';
  }
}

class _ShaderUniformStructReader extends fb.TableReader<ShaderUniformStruct> {
  const _ShaderUniformStructReader();

  @override
  ShaderUniformStruct createObject(fb.BufferContext bc, int offset) =>
      ShaderUniformStruct._(bc, offset);
}

class ShaderUniformStructBuilder {
  ShaderUniformStructBuilder(this.fbBuilder);

  final fb.Builder fbBuilder;

  void begin() {
    fbBuilder.startTable(6);
  }

  int addNameOffset(int? offset) {
    fbBuilder.addOffset(0, offset);
    return fbBuilder.offset;
  }

  int addExtRes0(int? extRes0) {
    fbBuilder.addUint64(1, extRes0);
    return fbBuilder.offset;
  }

  int addSet(int? $set) {
    fbBuilder.addUint64(2, $set);
    return fbBuilder.offset;
  }

  int addBinding(int? binding) {
    fbBuilder.addUint64(3, binding);
    return fbBuilder.offset;
  }

  int addSizeInBytes(int? sizeInBytes) {
    fbBuilder.addUint64(4, sizeInBytes);
    return fbBuilder.offset;
  }

  int addFieldsOffset(int? offset) {
    fbBuilder.addOffset(5, offset);
    return fbBuilder.offset;
  }

  int finish() {
    return fbBuilder.endTable();
  }
}

class ShaderUniformStructObjectBuilder extends fb.ObjectBuilder {
  final String? _name;
  final int? _extRes0;
  final int? _$set;
  final int? _binding;
  final int? _sizeInBytes;
  final List<ShaderUniformStructFieldObjectBuilder>? _fields;

  ShaderUniformStructObjectBuilder({
    String? name,
    int? extRes0,
    int? $set,
    int? binding,
    int? sizeInBytes,
    List<ShaderUniformStructFieldObjectBuilder>? fields,
  }) : _name = name,
       _extRes0 = extRes0,
       _$set = $set,
       _binding = binding,
       _sizeInBytes = sizeInBytes,
       _fields = fields;

  /// Finish building, and store into the [fbBuilder].
  @override
  int finish(fb.Builder fbBuilder) {
    final int? nameOffset = _name == null
        ? null
        : fbBuilder.writeString(_name!);
    final int? fieldsOffset = _fields == null
        ? null
        : fbBuilder.writeList(
            _fields!.map((b) => b.getOrCreateOffset(fbBuilder)).toList(),
          );
    fbBuilder.startTable(6);
    fbBuilder.addOffset(0, nameOffset);
    fbBuilder.addUint64(1, _extRes0);
    fbBuilder.addUint64(2, _$set);
    fbBuilder.addUint64(3, _binding);
    fbBuilder.addUint64(4, _sizeInBytes);
    fbBuilder.addOffset(5, fieldsOffset);
    return fbBuilder.endTable();
  }

  /// Convenience method to serialize to byte list.
  @override
  Uint8List toBytes([String? fileIdentifier]) {
    final fbBuilder = fb.Builder(deduplicateTables: false);
    fbBuilder.finish(finish(fbBuilder), fileIdentifier);
    return fbBuilder.buffer;
  }
}

class ShaderUniformTexture {
  ShaderUniformTexture._(this._bc, this._bcOffset);
  factory ShaderUniformTexture(List<int> bytes) {
    final rootRef = fb.BufferContext.fromBytes(bytes);
    return reader.read(rootRef, 0);
  }

  static const fb.Reader<ShaderUniformTexture> reader =
      _ShaderUniformTextureReader();

  final fb.BufferContext _bc;
  final int _bcOffset;

  String? get name =>
      const fb.StringReader().vTableGetNullable(_bc, _bcOffset, 4);
  int get extRes0 => const fb.Uint64Reader().vTableGet(_bc, _bcOffset, 6, 0);
  int get $set => const fb.Uint64Reader().vTableGet(_bc, _bcOffset, 8, 0);
  int get binding => const fb.Uint64Reader().vTableGet(_bc, _bcOffset, 10, 0);

  @override
  String toString() {
    return 'ShaderUniformTexture{name: ${name}, extRes0: ${extRes0}, \$set: ${$set}, binding: ${binding}}';
  }
}

class _ShaderUniformTextureReader extends fb.TableReader<ShaderUniformTexture> {
  const _ShaderUniformTextureReader();

  @override
  ShaderUniformTexture createObject(fb.BufferContext bc, int offset) =>
      ShaderUniformTexture._(bc, offset);
}

class ShaderUniformTextureBuilder {
  ShaderUniformTextureBuilder(this.fbBuilder);

  final fb.Builder fbBuilder;

  void begin() {
    fbBuilder.startTable(4);
  }

  int addNameOffset(int? offset) {
    fbBuilder.addOffset(0, offset);
    return fbBuilder.offset;
  }

  int addExtRes0(int? extRes0) {
    fbBuilder.addUint64(1, extRes0);
    return fbBuilder.offset;
  }

  int addSet(int? $set) {
    fbBuilder.addUint64(2, $set);
    return fbBuilder.offset;
  }

  int addBinding(int? binding) {
    fbBuilder.addUint64(3, binding);
    return fbBuilder.offset;
  }

  int finish() {
    return fbBuilder.endTable();
  }
}

class ShaderUniformTextureObjectBuilder extends fb.ObjectBuilder {
  final String? _name;
  final int? _extRes0;
  final int? _$set;
  final int? _binding;

  ShaderUniformTextureObjectBuilder({
    String? name,
    int? extRes0,
    int? $set,
    int? binding,
  }) : _name = name,
       _extRes0 = extRes0,
       _$set = $set,
       _binding = binding;

  /// Finish building, and store into the [fbBuilder].
  @override
  int finish(fb.Builder fbBuilder) {
    final int? nameOffset = _name == null
        ? null
        : fbBuilder.writeString(_name!);
    fbBuilder.startTable(4);
    fbBuilder.addOffset(0, nameOffset);
    fbBuilder.addUint64(1, _extRes0);
    fbBuilder.addUint64(2, _$set);
    fbBuilder.addUint64(3, _binding);
    return fbBuilder.endTable();
  }

  /// Convenience method to serialize to byte list.
  @override
  Uint8List toBytes([String? fileIdentifier]) {
    final fbBuilder = fb.Builder(deduplicateTables: false);
    fbBuilder.finish(finish(fbBuilder), fileIdentifier);
    return fbBuilder.buffer;
  }
}

class BackendShader {
  BackendShader._(this._bc, this._bcOffset);
  factory BackendShader(List<int> bytes) {
    final rootRef = fb.BufferContext.fromBytes(bytes);
    return reader.read(rootRef, 0);
  }

  static const fb.Reader<BackendShader> reader = _BackendShaderReader();

  final fb.BufferContext _bc;
  final int _bcOffset;

  ShaderStage get stage => ShaderStage.fromValue(
    const fb.Int8Reader().vTableGet(_bc, _bcOffset, 4, 0),
  );
  String? get entrypoint =>
      const fb.StringReader().vTableGetNullable(_bc, _bcOffset, 6);
  List<ShaderInput>? get inputs => const fb.ListReader<ShaderInput>(
    ShaderInput.reader,
  ).vTableGetNullable(_bc, _bcOffset, 8);
  List<ShaderUniformStruct>? get uniformStructs =>
      const fb.ListReader<ShaderUniformStruct>(
        ShaderUniformStruct.reader,
      ).vTableGetNullable(_bc, _bcOffset, 10);
  List<ShaderUniformTexture>? get uniformTextures =>
      const fb.ListReader<ShaderUniformTexture>(
        ShaderUniformTexture.reader,
      ).vTableGetNullable(_bc, _bcOffset, 12);
  List<int>? get shader =>
      const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 14);

  @override
  String toString() {
    return 'BackendShader{stage: ${stage}, entrypoint: ${entrypoint}, inputs: ${inputs}, uniformStructs: ${uniformStructs}, uniformTextures: ${uniformTextures}, shader: ${shader}}';
  }
}

class _BackendShaderReader extends fb.TableReader<BackendShader> {
  const _BackendShaderReader();

  @override
  BackendShader createObject(fb.BufferContext bc, int offset) =>
      BackendShader._(bc, offset);
}

class BackendShaderBuilder {
  BackendShaderBuilder(this.fbBuilder);

  final fb.Builder fbBuilder;

  void begin() {
    fbBuilder.startTable(6);
  }

  int addStage(ShaderStage? stage) {
    fbBuilder.addInt8(0, stage?.value);
    return fbBuilder.offset;
  }

  int addEntrypointOffset(int? offset) {
    fbBuilder.addOffset(1, offset);
    return fbBuilder.offset;
  }

  int addInputsOffset(int? offset) {
    fbBuilder.addOffset(2, offset);
    return fbBuilder.offset;
  }

  int addUniformStructsOffset(int? offset) {
    fbBuilder.addOffset(3, offset);
    return fbBuilder.offset;
  }

  int addUniformTexturesOffset(int? offset) {
    fbBuilder.addOffset(4, offset);
    return fbBuilder.offset;
  }

  int addShaderOffset(int? offset) {
    fbBuilder.addOffset(5, offset);
    return fbBuilder.offset;
  }

  int finish() {
    return fbBuilder.endTable();
  }
}

class BackendShaderObjectBuilder extends fb.ObjectBuilder {
  final ShaderStage? _stage;
  final String? _entrypoint;
  final List<ShaderInputObjectBuilder>? _inputs;
  final List<ShaderUniformStructObjectBuilder>? _uniformStructs;
  final List<ShaderUniformTextureObjectBuilder>? _uniformTextures;
  final List<int>? _shader;

  BackendShaderObjectBuilder({
    ShaderStage? stage,
    String? entrypoint,
    List<ShaderInputObjectBuilder>? inputs,
    List<ShaderUniformStructObjectBuilder>? uniformStructs,
    List<ShaderUniformTextureObjectBuilder>? uniformTextures,
    List<int>? shader,
  }) : _stage = stage,
       _entrypoint = entrypoint,
       _inputs = inputs,
       _uniformStructs = uniformStructs,
       _uniformTextures = uniformTextures,
       _shader = shader;

  /// Finish building, and store into the [fbBuilder].
  @override
  int finish(fb.Builder fbBuilder) {
    final int? entrypointOffset = _entrypoint == null
        ? null
        : fbBuilder.writeString(_entrypoint!);
    final int? inputsOffset = _inputs == null
        ? null
        : fbBuilder.writeList(
            _inputs!.map((b) => b.getOrCreateOffset(fbBuilder)).toList(),
          );
    final int? uniformStructsOffset = _uniformStructs == null
        ? null
        : fbBuilder.writeList(
            _uniformStructs!
                .map((b) => b.getOrCreateOffset(fbBuilder))
                .toList(),
          );
    final int? uniformTexturesOffset = _uniformTextures == null
        ? null
        : fbBuilder.writeList(
            _uniformTextures!
                .map((b) => b.getOrCreateOffset(fbBuilder))
                .toList(),
          );
    final int? shaderOffset = _shader == null
        ? null
        : fbBuilder.writeListUint8(_shader!);
    fbBuilder.startTable(6);
    fbBuilder.addInt8(0, _stage?.value);
    fbBuilder.addOffset(1, entrypointOffset);
    fbBuilder.addOffset(2, inputsOffset);
    fbBuilder.addOffset(3, uniformStructsOffset);
    fbBuilder.addOffset(4, uniformTexturesOffset);
    fbBuilder.addOffset(5, shaderOffset);
    return fbBuilder.endTable();
  }

  /// Convenience method to serialize to byte list.
  @override
  Uint8List toBytes([String? fileIdentifier]) {
    final fbBuilder = fb.Builder(deduplicateTables: false);
    fbBuilder.finish(finish(fbBuilder), fileIdentifier);
    return fbBuilder.buffer;
  }
}

class Shader {
  Shader._(this._bc, this._bcOffset);
  factory Shader(List<int> bytes) {
    final rootRef = fb.BufferContext.fromBytes(bytes);
    return reader.read(rootRef, 0);
  }

  static const fb.Reader<Shader> reader = _ShaderReader();

  final fb.BufferContext _bc;
  final int _bcOffset;

  String? get name =>
      const fb.StringReader().vTableGetNullable(_bc, _bcOffset, 4);
  BackendShader? get metalIos =>
      BackendShader.reader.vTableGetNullable(_bc, _bcOffset, 6);
  BackendShader? get metalDesktop =>
      BackendShader.reader.vTableGetNullable(_bc, _bcOffset, 8);
  BackendShader? get openglEs =>
      BackendShader.reader.vTableGetNullable(_bc, _bcOffset, 10);
  BackendShader? get openglDesktop =>
      BackendShader.reader.vTableGetNullable(_bc, _bcOffset, 12);
  BackendShader? get vulkan =>
      BackendShader.reader.vTableGetNullable(_bc, _bcOffset, 14);

  @override
  String toString() {
    return 'Shader{name: ${name}, metalIos: ${metalIos}, metalDesktop: ${metalDesktop}, openglEs: ${openglEs}, openglDesktop: ${openglDesktop}, vulkan: ${vulkan}}';
  }
}

class _ShaderReader extends fb.TableReader<Shader> {
  const _ShaderReader();

  @override
  Shader createObject(fb.BufferContext bc, int offset) => Shader._(bc, offset);
}

class ShaderBuilder {
  ShaderBuilder(this.fbBuilder);

  final fb.Builder fbBuilder;

  void begin() {
    fbBuilder.startTable(6);
  }

  int addNameOffset(int? offset) {
    fbBuilder.addOffset(0, offset);
    return fbBuilder.offset;
  }

  int addMetalIosOffset(int? offset) {
    fbBuilder.addOffset(1, offset);
    return fbBuilder.offset;
  }

  int addMetalDesktopOffset(int? offset) {
    fbBuilder.addOffset(2, offset);
    return fbBuilder.offset;
  }

  int addOpenglEsOffset(int? offset) {
    fbBuilder.addOffset(3, offset);
    return fbBuilder.offset;
  }

  int addOpenglDesktopOffset(int? offset) {
    fbBuilder.addOffset(4, offset);
    return fbBuilder.offset;
  }

  int addVulkanOffset(int? offset) {
    fbBuilder.addOffset(5, offset);
    return fbBuilder.offset;
  }

  int finish() {
    return fbBuilder.endTable();
  }
}

class ShaderObjectBuilder extends fb.ObjectBuilder {
  final String? _name;
  final BackendShaderObjectBuilder? _metalIos;
  final BackendShaderObjectBuilder? _metalDesktop;
  final BackendShaderObjectBuilder? _openglEs;
  final BackendShaderObjectBuilder? _openglDesktop;
  final BackendShaderObjectBuilder? _vulkan;

  ShaderObjectBuilder({
    String? name,
    BackendShaderObjectBuilder? metalIos,
    BackendShaderObjectBuilder? metalDesktop,
    BackendShaderObjectBuilder? openglEs,
    BackendShaderObjectBuilder? openglDesktop,
    BackendShaderObjectBuilder? vulkan,
  }) : _name = name,
       _metalIos = metalIos,
       _metalDesktop = metalDesktop,
       _openglEs = openglEs,
       _openglDesktop = openglDesktop,
       _vulkan = vulkan;

  /// Finish building, and store into the [fbBuilder].
  @override
  int finish(fb.Builder fbBuilder) {
    final int? nameOffset = _name == null
        ? null
        : fbBuilder.writeString(_name!);
    final int? metalIosOffset = _metalIos?.getOrCreateOffset(fbBuilder);
    final int? metalDesktopOffset = _metalDesktop?.getOrCreateOffset(fbBuilder);
    final int? openglEsOffset = _openglEs?.getOrCreateOffset(fbBuilder);
    final int? openglDesktopOffset = _openglDesktop?.getOrCreateOffset(
      fbBuilder,
    );
    final int? vulkanOffset = _vulkan?.getOrCreateOffset(fbBuilder);
    fbBuilder.startTable(6);
    fbBuilder.addOffset(0, nameOffset);
    fbBuilder.addOffset(1, metalIosOffset);
    fbBuilder.addOffset(2, metalDesktopOffset);
    fbBuilder.addOffset(3, openglEsOffset);
    fbBuilder.addOffset(4, openglDesktopOffset);
    fbBuilder.addOffset(5, vulkanOffset);
    return fbBuilder.endTable();
  }

  /// Convenience method to serialize to byte list.
  @override
  Uint8List toBytes([String? fileIdentifier]) {
    final fbBuilder = fb.Builder(deduplicateTables: false);
    fbBuilder.finish(finish(fbBuilder), fileIdentifier);
    return fbBuilder.buffer;
  }
}

class ShaderBundle {
  ShaderBundle._(this._bc, this._bcOffset);
  factory ShaderBundle(List<int> bytes) {
    final rootRef = fb.BufferContext.fromBytes(bytes);
    return reader.read(rootRef, 0);
  }

  static const fb.Reader<ShaderBundle> reader = _ShaderBundleReader();

  final fb.BufferContext _bc;
  final int _bcOffset;

  List<Shader>? get shaders => const fb.ListReader<Shader>(
    Shader.reader,
  ).vTableGetNullable(_bc, _bcOffset, 4);
  int get formatVersion =>
      const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 6, 0);

  @override
  String toString() {
    return 'ShaderBundle{shaders: ${shaders}, formatVersion: ${formatVersion}}';
  }
}

class _ShaderBundleReader extends fb.TableReader<ShaderBundle> {
  const _ShaderBundleReader();

  @override
  ShaderBundle createObject(fb.BufferContext bc, int offset) =>
      ShaderBundle._(bc, offset);
}

class ShaderBundleBuilder {
  ShaderBundleBuilder(this.fbBuilder);

  final fb.Builder fbBuilder;

  void begin() {
    fbBuilder.startTable(2);
  }

  int addShadersOffset(int? offset) {
    fbBuilder.addOffset(0, offset);
    return fbBuilder.offset;
  }

  int addFormatVersion(int? formatVersion) {
    fbBuilder.addUint32(1, formatVersion);
    return fbBuilder.offset;
  }

  int finish() {
    return fbBuilder.endTable();
  }
}

class ShaderBundleObjectBuilder extends fb.ObjectBuilder {
  final List<ShaderObjectBuilder>? _shaders;
  final int? _formatVersion;

  ShaderBundleObjectBuilder({
    List<ShaderObjectBuilder>? shaders,
    int? formatVersion,
  }) : _shaders = shaders,
       _formatVersion = formatVersion;

  /// Finish building, and store into the [fbBuilder].
  @override
  int finish(fb.Builder fbBuilder) {
    final int? shadersOffset = _shaders == null
        ? null
        : fbBuilder.writeList(
            _shaders!.map((b) => b.getOrCreateOffset(fbBuilder)).toList(),
          );
    fbBuilder.startTable(2);
    fbBuilder.addOffset(0, shadersOffset);
    fbBuilder.addUint32(1, _formatVersion);
    return fbBuilder.endTable();
  }

  /// Convenience method to serialize to byte list.
  @override
  Uint8List toBytes([String? fileIdentifier]) {
    final fbBuilder = fb.Builder(deduplicateTables: false);
    fbBuilder.finish(finish(fbBuilder), fileIdentifier);
    return fbBuilder.buffer;
  }
}
