import { GLsizei3 } from './tuples'; export interface KernelJSON { kernel: any; size: { width: number; height: number; depth: number; }; } /** * Kernel class is based on the idea of glkernel {@link https://github.com/cginternals/glkernel} and is the basis for * various auxiliary kernels that are mainly intended for but not limited to GPU use. A kernel stores samples in a * three-dimensional structure. Each sample can have up to four components (vec4) and is strongly typed, e.g., * {@link KernelF32}. The samples can be accessed and modified in various ways and easily passed to the GPU. */ export declare abstract class AbstractKernel { protected _samples: T; /** @see {@link width} */ protected _width: GLsizei; /** @see {@link height} */ protected _height: GLsizei; /** @see {@link depth} */ protected _depth: GLsizei; /** @see {@link components} */ protected _components: 1 | 2 | 3 | 4; constructor(components: 1 | 2 | 3 | 4, width: GLsizei, height?: GLsizei, depth?: GLsizei); /** * Should resize the samples array w.r.t. to the typed array buffer. * The resulting array buffer may be empty. */ protected abstract resize(): void; /** * Returns the n-tuple/n-component element at index within the cached kernel. * @param xPosOrIndex - If x is greater than width, this is interpreted as overall kernel index (requires y and z * positions to be undefined). Position is clamped to the range [0, width - 1]. * @param yPos - Position along the y-axis to access the kernel element at (clamped to range [0, height - 1]). * @param zPos - Position along the z-axis to access the kernel element at (clamped to range [0, depth - 1]). * @returns - Tuple of all components of the element at the requested index/position. */ get(xPosOrIndex: GLsizei, yPos?: GLsizei, zPos?: GLsizei): number[]; /** * Sets the n-tuple/n-component sample at index within the cached kernel. * @param sample - Values to be set at specified index or position. * @param xPosOrIndex - If x is greater than width, this is interpreted as overall kernel index (requires y and z * positions to be undefined). Position is clamped to the range [0, width - 1]. * @param yPos - Position along the y-axis to access the kernel element at (clamped to range [0, height - 1]). * @param zPos - Position along the z-axis to access the kernel element at (clamped to range [0, depth - 1]). */ set(sample: number[], xPosOrIndex: GLsizei, yPos?: GLsizei, zPos?: GLsizei): void; /** * Inheritor is expected to implement this in order to copy and type-convert a flat array. * @param samples - Array of all sample components in a flat sequence. */ abstract fromArray(samples: Array): void; /** * Fully reconfigures, i.e., resizes and copies samples, the kernel. * @param json - JSON object either from file, or set manually. These kernels can be generated using, e.g., * glkernel {@link https://github.com/cginternals/glkernel}. */ fromJSON(json: KernelJSON): void; /** * Returns the index of an element at a specific position. * @param xPos - Position along the x-axis (clamped to range [0, width - 1]). * @param yPos - Position along the y-axis (clamped to range [0, height - 1]). * @param zPos - Position along the z-axis (clamped to range [0, depth - 1]). * @returns - The index of the element at the requested position. */ index(xPos: GLsizei, yPos?: GLsizei, zPos?: GLsizei): GLsizei; /** * Returns the position of an element at a specific index. * @param index - Index of the requested position (clamped to range [0, size]). * @returns - The position of the element at the requested index as 3-tuple [x, y, z]. */ position(index: GLsizei): GLsizei3; /** * Sorts all samples based on the given sorting approach, e.g., by length of a sample. In order to sort an array * of samples comprising a number of components an sort-auxiliary array is created, sorted, and, finally, mapped to * the sample array. * @param approach - Sorting approach that is to be used. */ sort(approach: AbstractKernel.SortApproach): void; /** * All elements/samples of the kernel as array buffer. */ get samples(): T; /** * Returns the number of samples, i.e., the number of elements times the number of components per element. */ get length(): GLsizei; /** * Returns the number of samples. */ get elements(): GLsizei; /** * Number of components per sample, e.g., 2 for 2-tuple samples, 3 for 3-tuple samples, etc. */ get components(): GLsizei; /** * The width of the kernel (x-axis) */ get width(): GLsizei; /** * The height of the kernel (y-axis) */ get height(): GLsizei; /** * The depth of the kernel (z-axis) */ get depth(): GLsizei; /** * Distance between the indices of two adjacent elements along the x-axis in bytes. */ get xStride(): GLsizei; /** * Distance between the indices of two adjacent elements along the y-axis in bytes. */ get yStride(): GLsizei; /** * Distance between the indices of two adjacent elements along the z-axis in bytes. */ get zStride(): GLsizei; /** * Length of all samples in bytes. */ get bytesLength(): GLsizei; /** * Size of a sample's component in bytes. */ abstract get bytesPerComponent(): GLsizei; } export declare namespace AbstractKernel { enum SortApproach { BySquaredLength = 0 } } export declare class KernelF32 extends AbstractKernel { protected resize(): void; /** * Copies and converts samples to this kernels typed samples. * @param samples - Flat array of all sample values. */ fromArray(samples: Array): void; get bytesPerComponent(): GLsizei; } export declare class KernelUI32 extends AbstractKernel { protected resize(): void; /** * Copies and converts samples to this kernels typed samples. * @param samples - Flat array of all sample values. */ fromArray(samples: Array): void; get bytesPerComponent(): GLsizei; } export declare class KernelI32 extends AbstractKernel { protected resize(): void; /** * Copies and converts samples to this kernels typed samples. * @param samples - Flat array of all sample values. */ fromArray(samples: Array): void; get bytesPerComponent(): GLsizei; } export declare class KernelUI8 extends AbstractKernel { protected resize(): void; /** * Copies and converts samples to this kernels typed samples. * @param samples - Flat array of all sample values. */ fromArray(samples: Array): void; get bytesPerComponent(): GLsizei; } export declare class KernelI8 extends AbstractKernel { protected resize(): void; /** * Copies and converts samples to this kernels typed samples. * @param samples - Flat array of all sample values. */ fromArray(samples: Array): void; get bytesPerComponent(): GLsizei; }