microsoft / microsoft/DirectXShaderCompiler

Dynamic resources validation errors: All metadata must be used by dxil.!55 = !{i32 1}

Open
#4,888 5 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Compiling this code with -T ps_6_6 -E PSMain outputs: error: All metadata must be used by dxil.!55 = !{i32 1}

Is this code invalid or is it a compiler bug in DXC?

https://godbolt.org/z/4fMjoW4Gv

struct PSInput
{
    float4 position : SV_Position;
    float4 color    : COLOR0;
};

cbuffer Ids {
    int id1;
    int id2;
};

static const Texture2D<float4> textures[2] = {
    Texture2D<float4>(ResourceDescriptorHeap[id1]),
    Texture2D<float4>(ResourceDescriptorHeap[id2])
};

SamplerState ss: register(s0);

float4 PSMain(PSInput input) : SV_Target0
{
    float4 sample = textures[NonUniformResourceIndex(int(input.color.x))].Sample(ss, float2(0, 1));
    return sample;
}

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

Reproduce the report using the linked Godbolt example and the -T ps_6_6 -E PSMain command. Inspect the handling of dynamic resources and the emitted dxil.!55 metadata around the “All metadata must be used” diagnostic. Done means determining whether the HLSL is valid and, if so, correcting the validation failure with coverage for this case.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.