microsoft / microsoft/DirectXShaderCompiler
SamplerDescriptorHeap[sampIdx] cannot be used inside of texture.Sample(...)
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 3.7k
- Forks
- 900
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 44
Description
The following is a sample from this document: https://microsoft.github.io/DirectX-Specs/d3d/HLSL_SM_6_6_DynamicResources.html
Texture2D<float4> myTexture = ResourceDescriptorHeap[texIdx];
float4 result = myTexture.Sample(SamplerDescriptorHeap[sampIdx], coord);
But in practice (with the December 2021 release), doing this results in compilation errors:
MyShader.hlsl: error: no matching member function for call to 'Sample'
float4 result = myTexture.Sample(SamplerDescriptorHeap[sampIdx], coord);
~~~~~~~~~~~~~^~~~~~
note: candidate function template not viable: requires 3 arguments, but 2 were provided
note: candidate function template not viable: requires 4 arguments, but 2 were provided
note: candidate function template not viable: requires 5 arguments, but 2 were provided
Creating a separate SamplerState variable to store it and then using that works, casting within the Sample function like this also works:
myTexture.Sample(((SamplerState)SamplerDescriptorHeap[sampIdx]), coord);
Presumably some confusion between SamplerState and SamplerComparisonState, but since these use Sample() and SampleCmp() respectively, we might still expect it to just work.
Thank you for your time!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the MyShader.hlsl reproducer from the DirectX HLSL dynamic-resources document and compile it using the December 2021 release. Investigate why SamplerDescriptorHeap[sampIdx] is rejected as the first argument to Sample while a separate SamplerState or explicit cast works; done means the documented two-argument form compiles successfully.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers, computer-graphics
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100