microsoft / microsoft/DirectXShaderCompiler

Odd compiliation error with ResourceDescriptorHeap and type deduction

Open
#4,036 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

struct PSInput
{
	float4 color : COLOR;
};

float4 PSMain(PSInput input) : SV_TARGET
{
	return ((StructuredBuffer<float>)ResourceDescriptorHeap[int(input.color.x)]).Load(0);
}

https://shader-playground.timjones.io/27ac5c864a447a7014ae267711a86d4a

Error:

D:\local\Temp\178b99bf-6e48-4e9f-88b4-102b65301c33.hlsl:8:79: error: no member named 'Load' in 'StructuredBuffer<float>'
        return ((StructuredBuffer<float>)ResourceDescriptorHeap[int(input.color.x)]).Load(0);
               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^

Somehow the right type is deduced, but we can't call it's functions?

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 HLSL repro in the issue and the linked Shader Playground result, focusing on ResourceDescriptorHeap indexing, the StructuredBuffer cast, and member lookup for Load. Trace the compiler path that handles this expression and add or run a regression test; done means the repro compiles with the expected Load behavior or produces a correct diagnostic.

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
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.