microsoft / microsoft/DirectXShaderCompiler

Implicit cast from float1 to inout float3 hits an assert for DXIL

Open
#6,796 1 comment 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.