Skip to content

[docs] textures: Writing arrays of images to a 3D texture crashes #2662

Description

@dakumisu

Docs

This may be me who hasn't understood yet how it works but it seems that the "Writing arrays of images" docs example doesn't work :

const texture3d = root.createTexture({
  size: [256, 256, 3],
  format: 'rgba8unorm',
  dimension: '3d',
}).$usage('sampled');

texture3d.write([imageBitmap1, imageBitmap2, imageBitmap3]); // ↓
Image

WebGPU's copyExternalImageToTexture (used internally by .write()) only accepts 2D textures as destination — dimension: '3d' is invalid by spec, regardless of usage flags.

Workaround

Drop dimension: '3d'. The default creates a 2D-array texture, which works:

const texture3d = root.createTexture({
  size: [256, 256, 3],
  format: 'rgba8unorm',
}).$usage('sampled', 'render');

texture3d.write([imageBitmap1, imageBitmap2, imageBitmap3]); // ✅

The docs example should be updated to use a 2D-array, or include a note that dimension: '3d' cannot be written from image sources.

Environment

  • TypeGPU 0.11.2
  • Arc / macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions