Raw data into a buffer

  • writeBuffer()
  • MAP_WRITE buffer + mapAsync() + copyBufferToBuffer()

Raw data from the network into a buffer

  • fetch() + .arrayBuffer() + "Raw data into a buffer"

Raw (uncompressed or block-compressed) data into a texture

  • writeTexture()
  • "Raw data into a buffer" + copyBufferToTexture()

Raw (uncompressed or block-compressed) data from the network into a texture

  • fetch() + .arrayBuffer() + "Raw data into a texture"

Image file into a texture

  • TODO: paths through HTMLImageElement directly
  • fetch() + .blob() + createImageBitmap() + copyExternalImageToTexture()
  • HTMLImageElement + createImageBitmap() + copyExternalImageToTexture()
  • HTMLImageElement + .decode() + createImageBitmap() + copyExternalImageToTexture()
  • .drawImage() + copyExternalImageToTexture()
  • fetch() + ImageDecoder to VideoFrame + copyExternalImageToTexture()

Note that all of these paths use an intermediate image object to represent the decoded image. This may incur extra copies, so the recommended path may change if a new API becomes available.

Video frame into a texture

  • HTMLVideoElement + copyExternalImageToTexture()
  • HTMLVideoElement + importExternalTexture()
  • VideoFrame + copyExternalImageToTexture()
  • VideoFrame + importExternalTexture()

Canvas (e.g. 2d canvas) into a texture

  • copyExternalImageToTexture()

ImageData into a texture

  • .data + writeTexture(), if the exact encoding (format, color space, premultiplication) matches
  • manual conversion + writeTexture()
  • createImageBitmap() + copyExternalImageToTexture()
  • .putImageData() + copyExternalImageToTexture()
Select a repo