Skip to content

[SPIR-V] Arrays of arrays of resources are unsupported #7922

Closed
KhronosGroup/SPIRV-Tools
#6535

Description

Description
Using RWTexture2D<float4>[16][32] for example produces invalid SPIRV. Annotating this resource with [[vk::image_format("unknown")]] produces a validation error. It seems like this feature is unsupported, while with DXIL this works okay (though it flattens it to a 1D array).

Steps to Reproduce

//dxc -spirv -E mainCompute -T cs_6_5
RWTexture2D<float4> _test[16][32];

[numthreads(8, 8, 1)]
void mainCompute(uint2 id : SV_DispatchThreadID) {
    _test[0][0][id] = float4(id, 0, 1);
}
fatal error: generated SPIR-V is invalid: [VUID-StandaloneSpirv-UniformConstant-04655] UniformConstant OpVariable <id> '4[%_test]' 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.
  %_test = OpVariable %_ptr_UniformConstantarrarr_type_2d_image_uint_32_uint_16 UniformConstant

note: please file a bug report on https://github.com/Microsoft/DirectXShaderCompiler/issues with source code if possible

And

[[vk::image_format("unknown")]] RWTexture2D<float4> _test[16][32];

[numthreads(8, 8, 1)]
void mainCompute(uint2 id : SV_DispatchThreadID) {
    _test[0][0][id] = float4(id, 0, 1);
}
C:\local\Temp\ea8c1737-a2f4-421d-a3b7-88e1c5278ee6.hlsl:2:3: error: 'image_format' attribute only applies to RWTextures, Buffers and RWBuffers
[[vk::image_format("unknown")]] RWTexture2D<float4> _test[16][32];
  ^

Actual Behavior
Spirv to support this with arrays of arrays (if possible by spec), otherwise flattening the array or throwing an error that's clearer about lack of multi dimensional descriptor array support.

Environment

  • DXC version: latest
  • Host Operating System: N/A

Activity

  1. added
    bug
    spirv
    needs-triage
    on Nov 17, 2025
  2. s-perron commented on Nov 28, 2025

    @s-perron
    Collaborator

    I gave this a little thought. We currently do a straight translation of the two dimensional array. This seems reasonable for DXC. Modifying the type while translating the AST will create many special case I don't want to deal with. I think the more reasonable solution is to write a spir-v pass to legalize this. It will look for resources that are multidimensional arrays in the appropriate storage class, and turns them into a single dimensional array.

    The validation rules we are interested in avoiding are:

  3. added 2 commits that reference this issue on Feb 18, 2026
    844f2ef
    6de7fe1
  4. added a commit that references this issue on Feb 20, 2026
    214e182
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugspirv

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions