Skip to content

scanRakedWGSL

Overview

Raked workgroup scan. Assumes the existence of things in the scratch array.

WILL NEED workgroupBarrier() before/after (before if needed for scratch, after for scratch)

@author Jonathan Olson <jonathan.olson@colorado.edu>

Type scanRakedWGSLOptions

import type { scanRakedWGSLOptions } from 'scenerystack/alpenglow';
  • scratch: WGSLVariableName
    varname of var<workgroup> array<${binaryOp.type.valueType}, ${workgroupSize * grainSize}>
  • direction?: "left" | "right"
    The direction of the scan. For instance, a left inclusive scan of [ 1, 2, 3, 4 ] is [ 1, 3, 6, 10 ], but a right incluive scan is [ 10, 9, 7, 4 ] (just scans in the other direction)
  • binaryOp: BinaryOp<T>
  • storeReduction?: ( ( index: WGSLExpressionU32, expr: WGSLExpression ) => WGSLStatements ) | null
    null | ( index expr, expr: T ) => statements - Stores out the "fully reduced" value
  • stripeReducedOutput?: boolean
    Whether we should stripe the reduced output (so that each workgroup has a reduced value)
  • exclusive?: boolean
    boolean (whether the scan should be exclusive - otherwise it is inclusive). e.g. an inclusive left scan of [ 1, 2, 3, 4 ] is [ 1, 3, 6, 10 ], whereas an exclusive left scan is [ 0, 1, 3, 6 ]
  • getAddedValue?: ( ( varName: WGSLVariableName ) => WGSLStatements ) | null
    null | ( varName ) => statements - should write a value to be added to everything into the specific variable name This is designed to be used for multi-level scans, where you essentially want to add an "offset" value to everything in the workgroup.
  • addedValueNeedsWorkgroupBarrier?: boolean
    We can opt out of the extra workgroupBarrier if getAddedValue executes one itself (say, for atomics).
  • & RakedSizable & WorkgroupIndexable & LocalIndexable

Source Code

See the source for scanRakedWGSL.ts in the alpenglow repository.