microsoft / microsoft/DirectXShaderCompiler
Implicit cast from float1 to inout float3 hits an assert for DXIL
Open
Nobody has claimed this yet.
bug
incorrect-code
- Dominant language
- C++
- Stars
- 3.7k
- Forks
- 900
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 44
Description
Hello!
void bar(inout float3 param) {
}
[numthreads(1, 1, 1)]
void main() {
float1 a = 0;
bar(a);
}
$ dxc -T cs_6_6 -E main repro.hlsl
EmitNumericConversion can only cast between scalars or vectors of matching sizesdxc: DirectXShaderCompiler/tools/clang/lib/CodeGen/CGHLSLMS.cpp:4328: llvm::Value* ConvertScalarOrVector(clang::CodeGen::CGBuilderTy&, clang::CodeGen::CodeGenTypes&, llvm::Value*, clang::QualType, clang::QualType): Assertion `false && "EmitNumericConversion can only cast between scalars or vectors of " "matching sizes"' failed.
Aborted (core dumped)
This however is allowed and just warns for the implicit truncation.
void bar(inout float3 param) {
}
[numthreads(1, 1, 1)]
void main() {
float a = 0;
bar(a);
}
On the SPIR-V side, we accept this.
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
Reproduce the crash with the dxc command and repro.hlsl shown in the issue, then inspect tools/clang/lib/CodeGen/CGHLSLMS.cpp around line 4328 and the ConvertScalarOrVector assertion. Done means the float1-to-inout-float3 example no longer aborts during DXIL compilation and preserves the accepted implicit-conversion behavior described in the issue.
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
- Clearly specified
- Newbie friendliness
- 42/100