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(components: 1 | 2 | 3 | 4, width: GLsizei, height?: GLsizei, depth?: GLsizei): AbstractKernel
  • Parameters

    • components: 1 | 2 | 3 | 4
    • width: GLsizei
    • Default value height: GLsizei = 1
    • Default value depth: GLsizei = 1

    Returns AbstractKernel

Properties

Protected _components

_components: 1 | 2 | 3 | 4

Protected _depth

_depth: GLsizei
see

depth

Protected _height

_height: GLsizei
see

height

Protected _samples

_samples: T

Protected _width

_width: GLsizei
see

width

Accessors

bytesLength

  • get bytesLength(): GLsizei
  • Length of all samples in bytes.

    Returns GLsizei

bytesPerComponent

  • get bytesPerComponent(): GLsizei
  • Size of a sample's component in bytes.

    Returns GLsizei

components

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

    Returns GLsizei

depth

  • get depth(): GLsizei
  • The depth of the kernel (z-axis)

    Returns GLsizei

elements

  • get elements(): GLsizei
  • Returns the number of samples.

    Returns GLsizei

height

  • get height(): GLsizei
  • The height of the kernel (y-axis)

    Returns GLsizei

length

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

    Returns GLsizei

samples

  • get samples(): T
  • All elements/samples of the kernel as array buffer.

    Returns T

width

  • get width(): GLsizei
  • The width of the kernel (x-axis)

    Returns GLsizei

xStride

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

    Returns GLsizei

yStride

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

    Returns GLsizei

zStride

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

    Returns GLsizei

Methods

Abstract fromArray

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

    Parameters

    • samples: Array<number>

      Array of all sample components in a flat sequence.

    Returns void

fromJSON

get

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

    Parameters

    • xPosOrIndex: GLsizei

      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: GLsizei

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

    • Optional zPos: GLsizei

      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: GLsizei, yPos?: GLsizei, zPos?: GLsizei): GLsizei
  • Returns the index of an element at a specific position.

    Parameters

    • xPos: GLsizei

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

    • Default value yPos: GLsizei = 0

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

    • Default value zPos: GLsizei = 0

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

    Returns GLsizei

    • The index of the element at the requested position.

position

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

    Parameters

    • index: GLsizei

      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: GLsizei, yPos?: GLsizei, zPos?: GLsizei): 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: GLsizei

      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: GLsizei

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

    • Optional zPos: GLsizei

      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

    • approach: SortApproach

      Sorting approach that is to be used.

    Returns void