Pointer type cast in wgsl #7066
Labels
area: api
Issues related to API surface
feature: bindless
Issues with the Bindless Native Feature
type: enhancement
New feature or request
Related problem
Currently, the buffer binding array feature requires that every buffer has the same type. Is it possible to work around this limitation?
The possible solution
For some reason, if I want to bind different types of buffer into one buffer binding array, If we support some sort of pointer type cast in wgsl, can this be worked around like this?
use a u32 array as some untyped buffer.
var<storage> buffer_array: array<array<u32>, BIND_ARRAY_SIZE>
, then cast any sub-item pointerptr<storage, array<u32>, read>
toptr<storage, array<MyType>, read>
.Considered alternatives
The alternative is just to mimic the entire shader type system based on
var<storage> buffer_array: array<array<u32>, BIND_ARRAY_SIZE>
, but it's pretty hard to implement as a general solution and error-prone to implement for specific cases.Additional context
I guess the pointer cast is possible based on the spriv spec. but maybe I don't know what I'm talking about.
https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#OpConvertPtrToU
https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#OpConvertUToPtr
The text was updated successfully, but these errors were encountered: