microsoft / microsoft/DirectXShaderCompiler

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

Open
#8,342 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug needs-triage spirv
Dominant language
C++
Stars
3.7k
Forks
900
Avg merge
2d 11h
Merged PRs (30d)
44

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Run the supplied dxc command with the reproducer in fail.hlsl to confirm the type-generation failure. Trace the SPIR-V generator path handling the namespaced R::PU member. Done means the reproducer compiles successfully without using namespace R and emits fail.spv.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.