Skip to content

"External declaration [decl name] is unused" after resource assignment #5573

@jeremyong

Description

@jeremyong

Description
Given a global extern resource with an auto-assigned or user assigned resource register, reassigning the variable to a different resource (e.g. from ResourceDescriptorHeap) results in the "external declaration is unused" validation error, even if the resource is used prior to assignment.

Steps to Reproduce

CE link

RWByteAddressBuffer buffer : register(u0);

[numthreads(8, 8, 1)]
void CSMain(uint3 id : SV_DispatchThreadID)
{
        buffer.Store(id.x, 0);
        buffer = ResourceDescriptorHeap[0];
        buffer.Store(id.x, 0);
}

Actual Behavior

error: validation errors
<source>:1: error: External declaration '\01?buffer@@3URWByteAddressBuffer@@A' is unused.
Validation failed.

Note that this may be intended behavior (understandably), however, I think in this case the error message is misleading and should directly indicate that this sort of reassignment is forbidden if so.

Environment

  • DXC version 1.7.2207
  • Host Operating System Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugBug, regression, crashcorrectnessBugs that impact shader correctnessdxil

    Type

    No type

    Projects

    Status

    Triaged

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions