microsoft / microsoft/DirectXShaderCompiler

[Work Graphs] Invalid Shader function attributes

Open
#7,783 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug diagnostic incorrect-code
Dominant language
C++
Stars
3.7k
Forks
900
Avg merge
2d 11h
Merged PRs (30d)
44

Description

Description
DXC allows the following input/output attributes on shader functions:

  • NodeArraySize - no warning or error
  • MaxRecords - no warning or error
  • AllowSparseNodes - warning, no error
  • UnboundedSparseNodes - warning, no error

I expected all of these to be errors. Some developers have expressed confusion since they are allowed.

Steps to Reproduce
https://godbolt.org/z/9jvhqcPhs

struct NodeRecord
{
    float4 spam;
    uint gridSize : SV_DispatchGrid;
};

[Shader("node")] 
[NodeLaunch("broadcasting")] 
[NodeIsProgramEntry] 
[NodeMaxDispatchGrid(64, 64, 1)] 
[NumThreads(32, 1, 1)] 
void Foo(
    DispatchNodeInputRecord<NodeRecord> inputRecord,
    [NodeArraySize(128)] [MaxRecords(1)] NodeOutputArray<NodeRecord> bar, 
    in uint ThreadIndex : SV_GroupIndex
    )
{
}

[Shader("node")] 
[NodeLaunch("coalescing")] 
[NumThreads(8, 4, 1)] 
[NodeArraySize(1)] // no warning or error
[MaxRecords(1)] /// no warning or error
[AllowSparseNodes] // warning, no error
[UnboundedSparseNodes] // warning, no error
void Bar(
    [MaxRecords(4)] GroupNodeInputRecords<NodeRecord> inputRecords
    )
{
}

Actual Behavior
The DXC compile succeeds. Warning messages are easily missed and ignored.

<source>:27:2: warning: 'UnboundedSparseNodes' attribute only applies to parameters [-Wignored-attributes]
[UnboundedSparseNodes] // warning, no error
 ^
<source>:26:2: warning: 'AllowSparseNodes' attribute only applies to parameters [-Wignored-attributes]
[AllowSparseNodes] // warning, no error
 ^

Compiler returned: 0

Environment

  • DXC 1.8.2506, 1.8.2306-preview
  • Win11 24H2

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

Start with the Godbolt reproduction and the listed DXC warning output to confirm the four attribute cases. Trace the compiler's HLSL shader-attribute validation for NodeArraySize, MaxRecords, AllowSparseNodes, and UnboundedSparseNodes, then add or update coverage so each invalid placement produces an error and run the relevant DXC tests.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.