Options
All
  • Public
  • Public/Protected
  • All
Menu

Class AbstractKernel<T>

Kernel class is based on the idea of glkernel 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., KernelF32. The samples can be accessed and modified in various ways and easily passed to the GPU.

Type parameters

  • T: Float32Array | Uint32Array | Int32Array | Uint8Array | Int8Array

Hierarchy

Index

Constructors

constructor

  • new AbstractKernel<T>(components: 2 | 3 | 1 | 4, width: number, height?: number, depth?: number): AbstractKernel<T>
  • Type parameters

    • T: Float32Array | Uint8Array | Uint32Array | Int32Array | Int8Array

    Parameters

    • components: 2 | 3 | 1 | 4
    • width: number
    • height: number = 1
    • depth: number = 1

    Returns AbstractKernel<T>

Properties

Protected _components

_components: 2 | 3 | 1 | 4

Protected _depth

_depth: number
see

depth

Protected _height

_height: number
see

height

Protected _samples

_samples: T

Protected _width

_width: number
see

width

Accessors

bytesLength

  • get bytesLength(): number

Abstract bytesPerComponent

  • get bytesPerComponent(): number

components

  • get components(): number
  • Number of components per sample, e.g., 2 for 2-tuple samples, 3 for 3-tuple samples, etc.

    Returns number

depth

  • get depth(): number

elements

  • get elements(): number

height

  • get height(): number

length

  • get length(): number
  • Returns the number of samples, i.e., the number of elements times the number of components per element.

    Returns number

samples

  • get samples(): T

width

  • get width(): number

xStride

  • get xStride(): number
  • Distance between the indices of two adjacent elements along the x-axis in bytes.

    Returns number

yStride

  • get yStride(): number
  • Distance between the indices of two adjacent elements along the y-axis in bytes.

    Returns number

zStride

  • get zStride(): number
  • Distance between the indices of two adjacent elements along the z-axis in bytes.

    Returns number

Methods

Abstract fromArray

  • fromArray(samples: number[]): void
  • Inheritor is expected to implement this in order to copy and type-convert a flat array.

    Parameters

    • samples: number[]

      Array of all sample components in a flat sequence.

    Returns void

fromJSON

  • fromJSON(json: KernelJSON): void

get

  • get(xPosOrIndex: number, yPos?: number, zPos?: number): number[]
  • Returns the n-tuple/n-component element at index within the cached kernel.

    Parameters

    • xPosOrIndex: number

      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].

    • Optional yPos: number

      Position along the y-axis to access the kernel element at (clamped to range [0, height - 1]).

    • Optional zPos: number

      Position along the z-axis to access the kernel element at (clamped to range [0, depth - 1]).

    Returns number[]

    • Tuple of all components of the element at the requested index/position.

index

  • index(xPos: number, yPos?: number, zPos?: number): number
  • Returns the index of an element at a specific position.

    Parameters

    • xPos: number

      Position along the x-axis (clamped to range [0, width - 1]).

    • yPos: number = 0

      Position along the y-axis (clamped to range [0, height - 1]).

    • zPos: number = 0

      Position along the z-axis (clamped to range [0, depth - 1]).

    Returns number

    • The index of the element at the requested position.

position

  • Returns the position of an element at a specific index.

    Parameters

    • index: number

      Index of the requested position (clamped to range [0, size]).

    Returns GLsizei3

    • The position of the element at the requested index as 3-tuple [x, y, z].

Protected Abstract resize

  • resize(): void
  • Should resize the samples array w.r.t. to the typed array buffer. The resulting array buffer may be empty.

    Returns void

set

  • set(sample: number[], xPosOrIndex: number, yPos?: number, zPos?: number): void
  • Sets the n-tuple/n-component sample at index within the cached kernel.

    Parameters

    • sample: number[]

      Values to be set at specified index or position.

    • xPosOrIndex: number

      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].

    • Optional yPos: number

      Position along the y-axis to access the kernel element at (clamped to range [0, height - 1]).

    • Optional zPos: number

      Position along the z-axis to access the kernel element at (clamped to range [0, depth - 1]).

    Returns void

sort

  • 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.

    Parameters

    Returns void