KhronosGroup / KhronosGroup/SPIRV-Cross
MSL: spvArrayCopyFrom*To*N() functions don't work with multidimensional templates
- Dominant language
- GLSL
- Stars
- 2.5k
- Forks
- 713
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 16
Description
For the template functions `spvArrayCopyFrom*To*N()`, when one or both of the arguments is a multidimensional template array (as opposed to a C-style multidimensional array), the template copy function can't be matched, because all template functions are expecting to pass a C-style array (eg. `T[A]`) to the next dimension recursion level, whereas multidimensional template array contain an array of template arrays (eg. `spvUnsafeArray`).
For instance:
spvUnsafeArray, 8> _24;
spvArrayCopyFromStackToDevice2(_4._m0, _24.elements);
results in:
program_source:532:5: error: no matching function for call to 'spvArrayCopyFromStackToDevice2'
spvArrayCopyFromStackToDevice2(_4._m0, _24.elements);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
program_source:228:13: note: candidate template ignored: could not match 'type-parameter-0-0 [B]' against 'spvUnsafeArray'
inline void spvArrayCopyFromStackToDevice2(device T (&dst)[A][B], thread const T (&src)[A][B])
I've played with different ways of declaring the template arrays and copy functions, but haven't hit on any combination that will work to copy arbitrary combinations of C-style arrays of a type and template arrays of that type.
With the current set of template and copy function declarations, we'd need to insert something like a `.elements` into each dimension recursion when the array is templated. But this would effectively quadruple the already combinatorial set of copy functions.
I'm also wondering if we should scrap the templated copy functions altogether and just dump the appropriate bespoke inline looping code, or equivalent unrolled non-looping code, each time such a function is currently used.
Looking for help and discussion to pull together a solution.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the spvArrayCopyFrom*To*N() template declarations and reproduce the shown spvUnsafeArray multidimensional call. Determine how the recursive copy functions handle C-style arrays versus template arrays, then verify that the affected combinations compile without the reported matching error.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100