uploadOrder method

void uploadOrder(
  1. Uint32List indices
)

Uploads the sorted splat order as little-endian RGBA8 texels.

Implementation

void uploadOrder(Uint32List indices) {
  if (indices.isEmpty) return;

  final neededRows =
      (indices.length + GsConst.splatsPerRow - 1) ~/ GsConst.splatsPerRow;
  if (orderTexture == null || _orderAllocHeight < neededRows) {
    _orderAllocHeight = (neededRows * 5) ~/ 4 + 1;
    orderTexture = gpu.gpuContext.createTexture(
      gpu.StorageMode.hostVisible,
      GsConst.splatsPerRow,
      _orderAllocHeight,
      enableRenderTargetUsage: false,
    );
  }

  final totalTexels = _orderAllocHeight * GsConst.splatsPerRow;
  final neededBytes = totalTexels * 4;
  final scratch = _ensureOrderScratch(neededBytes);
  Uint32List.view(scratch.buffer)
    ..fillRange(0, totalTexels, 0)
    ..setRange(0, indices.length, indices);
  orderTexture!.overwrite(scratch.buffer.asByteData(0, neededBytes));
}