Skip to content

TSL: Storage buffers are automatically converted to a scalar uniform if they only have a single element #33145

@gkjohnson

Description

@gkjohnson

Description

When using a "storage" node to attach a storage buffer attribute the buffer is automatically converted to a scalar value if the buffer is only a single element long. This breaks shaders that rely on accessing the storage buffer as an array. The resulting shader should respect the user's graph definition rather than transforming it in ways that may break user code.

This has been causing headaches during the path tracer development when a single geometry or material is rendered, for example, so the transform and material buffers are set to a length of 1.

Reproduction steps

  1. Create a compute kernel with a storage buffer of length 1
  2. Add a wgslFn node that access the storage buffer
  3. Run it, see that it breaks because the scalar version of the input is not an array.
  4. Replace the buffer with one that is longer than length 1
  5. See that it still does not work because the shader has already been compiled with a scalar.

Code

See fiddle

Live example

https://jsfiddle.net/9dqzj42L/

Screenshots

Image

Version

r183

Device

No response

Browser

No response

OS

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    TSLThree.js Shading Language

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions