这是indexloc提供的服务,不要输入任何密码
Skip to content

[buffer-view] Extent of reinterpretation permitted #5409

@alan-baker

Description

@alan-baker

Proposal currently limits reinterpretation to always from the base variable and only once.

Would more extensive reinterpretation be better? This seems it would imply taking any pointer type and reinterpreting it. That would mean implementations would have to track through more expressions. For example:

var<storage, read_write> buf : buffer;

struct T {
  u : vec4,
  v : vec2i,
}

struct S {
  a : array<T, 4>,
  b : f32
}

fn foo() {
  let p1 : ptr<storage, S, read_write> = bufferView<S>(&buf, offset1);
  let p2 : ptr<storage, f32, read_write> = &(p1.a[2].u[1]);
  let p3 : ptr<storage, vec4u, read_write> = bufferView<vec4u>(p2, offset2); // real potential for unaligned memory access
}

The current restrictions avoid some footguns like unaligned memory access.

Metadata

Metadata

Assignees

No one assigned

    Labels

    wgslWebGPU Shading Language Issues

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions