llvm / llvm/llvm-project

[SPIRV] Should Clang targeting Vulkan support multidimensional resource arrays?

Open
#164,908 0 comments 0 reactions 0 assignees View on GitHub
clang:HLSL:SPIRV HLSL
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

DXC on Vulkan does not support multi-dimensional resource arrays. This task is to track whether they should be supported in Clang when the targeting Vulkan/SPIR-V or not.

https://godbolt.org/z/4e14GjMhM
```
RWStructuredBuffer In[4][2] : register(u0);
RWStructuredBuffer Out : register(u0, space1);

[numthreads(4,1,1)]
void main(uint GI : SV_GroupIndex) {
for (int i = 0; i < 4; i++)
Out[i] = In[i][0][0] + In[i][1][0];
}
```
`error: Multi-dimensional arrays of RW/append/consume structured buffers are unsupported in Vulkan`

If the `RWStructuredBuffer` type is changed to `RWBuffer` the DXC compiler generates invalid SPIR-V:
```
fatal error: generated SPIR-V is invalid: [VUID-StandaloneSpirv-UniformConstant-04655] UniformConstant OpVariable '4[%In]' has illegal type.
Variables identified with the UniformConstant storage class are used only as handles to refer to opaque resources. Such variables must be typed as OpTypeImage, OpTypeSampler, OpTypeSampledImage, OpTypeAccelerationStructureKHR, or an array of one of these types.
%In = OpVariable %_ptr_UniformConstant__arr__arr_type_buffer_image_uint_2_uint_4 UniformConstant
```

Contributor guide

Open the contributing guide

Research direction

Start by examining the linked Godbolt example and the Vulkan/SPIR-V diagnostics in the issue. The open question is whether Clang should support multidimensional resource arrays; determine the expected behavior for both RWStructuredBuffer and RWBuffer and how valid SPIR-V should be produced. Done means the project has an agreed behavior and implementation with tests demonstrating it.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, cpp
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.