microsoft / microsoft/DirectXShaderCompiler
Cannot do swizzle operations with floating type when it's a typename
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 3.7k
- Forks
- 900
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 44
Description
Description
cannot use float.xx when float is a templated typename
Steps to Reproduce
Reproduced in this godbolt snippet: https://godbolt.org/z/KeYcTozYh
-T ps_6_0 -E PSMain
struct PSInput
{
float4 position : SV_Position;
float4 color : COLOR0;
};
template<typename float_t>
struct StyleClipper
{
using float_t2 = vector<float_t, 2>;
static float_t2 func(float_t t)
{
return t.xx;
}
};
float4 PSMain(PSInput input) : SV_TARGET
{
return input.color + StyleClipper<float>::func(input.color.x).x;
}
Actual Behavior
Changing static float_t2 func(float_t t) to static float_t2 func(float t) will compile successfuly when the input param not a template typename float_t
Environment
- Godbolt DXC Trunk
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 by compiling the provided Godbolt HLSL reproducer with DXC using the shown shader model and entry point. Trace how templated typename parameters are handled for floating-point swizzle expressions; done means the reproducer compiles with the templated parameter as it does when the parameter is declared as float.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100