gpuweb
gpuweb copied to clipboard
[buffer-view] Extent of reinterpretation permitted
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.
Additionally, the proposal currently limits the return type as host-shareable. This is a restriction on workgroup variables since it may be desirable to reinterpret them as an override-sized array. Related to #5486.