Skip to content

[SPIR-V] fail to generate type when using namespaced struct. #8342

@BenoitAmbry

Description

@BenoitAmbry

Description
The spirv generator fails to generate code when using a struct with a namespaced member.

Steps to Reproduce
Command line:

dxc /nologo /Od /Zi -spirv -fspv-flatten-resource-arrays -Efail -Tvs_6_0 -Fo fail.spv fail.hlsl

Code:

struct L { float2 p0, p1; };

namespace R {
struct PU {
    float4x4 p;
};
}

struct VU {
    float4 c;
};

struct U {
    R::PU b;
    VU v;
};

static inline L failme(U u) {
    L o;

    o.p0 = float2(0, 0);
    o.p1 = float2(0, 1);

    return o;
}

[[ vk::binding(0, 0) ]] ConstantBuffer<U> us : register(b0, space0);

struct O {
    float4 p : SV_POSITION;
};

O fail() {

    // crash
    L pl = failme(us);

    O o;
    o.p = float4(0,0,0,1);

    return o;
}

Actual Behavior
fails to compile with error
Trying to generate a type that we cannot generate
Removing the namespace by adding using namespace R; is a possible workaround.

Environment

  • DXC version (libdxcompiler.dylib: 1.10(5304-0131a626)(1.9.0.15304))
  • Host Operating System osx 26.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugBug, regression, crashneeds-triageAwaiting triagespirvWork related to SPIR-V

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions