DirectXShaderCompiler icon indicating copy to clipboard operation
DirectXShaderCompiler copied to clipboard

Odd compiliation error with ResourceDescriptorHeap and type deduction

Open Jasper-Bekkers opened this issue 3 years ago • 1 comments

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?

Jasper-Bekkers avatar Oct 25 '21 08:10 Jasper-Bekkers

Hi @Jasper-Bekkers

Thanks for the report. The expected usage of this is to assign to a local variable. However, we agree that this usage should be supported. Given that there's a workaround and the compiler can be expected to optimize any extra copies away, it won't be a priority

pow2clk avatar Nov 08 '21 21:11 pow2clk