DirectXShaderCompiler
DirectXShaderCompiler copied to clipboard
Odd compiliation error with ResourceDescriptorHeap and type deduction
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?
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