///
import { HasReactive } from "@reactively/decorate";
import { Cache, ComposableShader, ValueOrFn, Vec2 } from "thimbleberry";
import { HistogramModule } from "../binop/HistogramModule.js";
import { ComponentName, LoadComponent } from "../util/GenerateLoadTexel.js";
export interface TextureToHistogramsParams {
device: GPUDevice;
/**
* Source data to be bucketed in a histogram
*
* A function returning the source buffer will be executed lazily,
* and reexecuted if the function's `@reactively` source values change.
*/
source: ValueOrFn;
/**
* range of values
*
* A function returning the source buffer will be executed lazily,
* and reexecuted if the function's `@reactively` source values change.
*/
minMaxBuffer: ValueOrFn;
/** {@inheritDoc TextureToHistograms#histogramOps} */
histogramOps: HistogramModule;
/** {@inheritDoc TextureToHistograms#blockSize} */
blockSize?: Vec2;
/** {@inheritDoc TextureToHistograms#forceWorkgroupSize} */
forceWorkgroupSize?: Vec2;
/** {@inheritDoc TextureToHistograms#sourceComponent} */
sourceComponent?: ComponentName | LoadComponent;
/** cache for GPUComputePipeline */
pipelineCache?: () => Cache;
/** {@inheritDoc TextureToHistograms#bucketSums} */
bucketSums?: boolean;
/** {@inheritDoc TextureToHistograms#saturateMax} */
saturateMax?: boolean;
/** {@inheritDoc TextureToHistograms#label} */
label?: string;
}
/** calc histograms from gpu texture
* Each workgroup thread reads a blockSize group of elements to one histogram,
* and each dispatch reduces the workgroup histograms to one histogram.
* The result is a buffer of histograms, one per dispatched workgroup.
* (The resulting histogram buffer should be reduced to one histogram via ReduceBuffer)
*/
export declare class TextureToHistograms extends HasReactive implements ComposableShader {
/** Source texture to be counted in a histogram */
source: GPUTexture;
/** range of values to consider in histogram */
minMaxBuffer: GPUBuffer;
/** macros to customize wgsl shader for size of data and size of histogram */
histogramOps: HistogramModule;
/** select or synthesize a component (e.g. r,g,b,a) from the source texture */
sourceComponent: ComponentName | LoadComponent;
/** calculate sums for each bucket */
bucketSums: boolean;
/** include values > max range in last bucket */
saturateMax: boolean;
/** Debug label attached to gpu objects for error reporting */
label?: string;
/** number of elements to reduce in each invocation (4) */
blockSize: Vec2;
/** Override to set compute workgroup size e.g. for testing. */
forceWorkgroupSize: Vec2;
private device;
private pipelineCache?;
private usageContext;
constructor(params: TextureToHistogramsParams);
commands(commandEncoder: GPUCommandEncoder): void;
destroy(): void;
/** histogram bucket counts */
get histogramsResult(): GPUBuffer;
/** histogram bucket sums */
get sumsResult(): GPUBuffer;
/** number of elements in the result buffer */
get resultElems(): number;
get debugBuffer(): GPUBuffer;
private get registry();
private pipeline;
private get uniformBuffer();
private get dispatchSize();
private get workgroupSize();
private bindGroup;
}