gpuweb icon indicating copy to clipboard operation
gpuweb copied to clipboard

why can't *any* fixed-size array use an element count that is an override expression

Open dneto0 opened this issue 3 years ago • 1 comments

Fixed-size arrays are declared with an element count. That element count is almost always a const-expression. In one case it can be an override-expression that is not a const-expression, and that's when that array type is the store type for a variable in workgroup storage.

SPIR-V doesn't have that peculiar restriction. You can declare an array in Function storage class with an element count that is a spec constant.

Metal support for flexibly-sized data in threadgroup address space is via a pointer-to-threadgroup parameter to the shader entry point. If W is a WGSL variable in workgroup address space where its store type has an override-sized element count, then W is modeled as a pointer-to-threadgroup parameter to the entry points of the shaders that use it. Then the implementation has to set the size of that parameter at command recording time.

The original discussion is in #2304, with the spec change in #2347

dneto0 avatar Sep 23 '22 20:09 dneto0

Note that in any case we would still want an array to be constructible only if its element count is a const-expression.

dneto0 avatar Sep 23 '22 20:09 dneto0