Skip to main content

Class: ReduceTexture

A sequence of shader dispatches that reduces a source texture to a single value according to a specified binary operation (e.g. min, max, or sum).

Two underlying shaders are used: . one to reduce the source texture to a small buffer . one to reduce a small buffer to smaller buffer

When executed, FrameReduceSequence will dispatch a sufficient number of times to end with a single value. The final result is stored in a single element reducedResult buffer.

Hierarchy

  • HasReactive

    ReduceTexture

Implements

Constructors

constructor

new ReduceTexture(params): ReduceTexture

Parameters

NameType
paramsReduceTextureParams

Returns

ReduceTexture

Overrides

HasReactive.constructor

Defined in

packages/stoneberry/src/reduce-texture/ReduceTexture.ts:96

Properties

binOps

binOps: BinOpModule

wgsl macros for a binary operation to reduce two elements to one

Defined in

packages/stoneberry/src/reduce-texture/ReduceTexture.ts:84


blockSize

blockSize: Vec2

length of block to read when reducing from texture to buffer

Defined in

packages/stoneberry/src/reduce-texture/ReduceTexture.ts:75


bufferBlockLength

bufferBlockLength: undefined | number

length of block to read when reducing from buffer to buffer

Defined in

packages/stoneberry/src/reduce-texture/ReduceTexture.ts:78


device

device: GPUDevice

Defined in

packages/stoneberry/src/reduce-texture/ReduceTexture.ts:92


forceWorkgroupSize

forceWorkgroupSize: undefined | Vec2

number and arrangement of threads in each dispatched workgroup

Defined in

packages/stoneberry/src/reduce-texture/ReduceTexture.ts:81


label

Optional label: string

Debug label attached to gpu objects for error reporting

Defined in

packages/stoneberry/src/reduce-texture/ReduceTexture.ts:90


source

source: GPUTexture

Defined in

packages/stoneberry/src/reduce-texture/ReduceTexture.ts:72


sourceComponent

sourceComponent: LoadComponent | ComponentName

select or synthesize a component from the source texture

Defined in

packages/stoneberry/src/reduce-texture/ReduceTexture.ts:87

Accessors

result

get result(): GPUBuffer

result of the final reduction pass, one element in size

Returns

GPUBuffer

Defined in

packages/stoneberry/src/reduce-texture/ReduceTexture.ts:119

Methods

commands

commands(commandEncoder): void

Add compute or render passes for this shader to the provided GPUCommandEncoder

Parameters

NameType
commandEncoderGPUCommandEncoder

Returns

void

Implementation of

ComposableShader.commands

Defined in

packages/stoneberry/src/reduce-texture/ReduceTexture.ts:101


destroy

destroy(): void

Returns

void

Implementation of

ComposableShader.destroy

Defined in

packages/stoneberry/src/reduce-texture/ReduceTexture.ts:105


reduce

reduce(): Promise<number[]>

Execute the reduce immediately and copy the results back to the CPU. (results are copied from the ReduceTexture.result GPUBuffer)

Returns

Promise<number[]>

a single reduced result value in an array

Defined in

packages/stoneberry/src/reduce-texture/ReduceTexture.ts:113