Skip to content

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

Open

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.

Activity

  1. added
    bug
    needs-triage
    on Jul 17, 2024
  2. added
    incorrect-code
    on Jul 18, 2024
  3. moved this from Triaged to No status in HLSL Triageon Jul 18, 2024
  4. added
    hlsl-next
    on Jul 18, 2024
  5. removed
    hlsl-next
    on Jul 18, 2024
  6. damyanp commented on Jul 18, 2024

    @damyanp
    Member

    Nathan Gauër (@Keenuts):
    We don't think that float1 should implicitly extend to float3. Going forward, we expect that clang will reject this case.

    In fact, we also have questions about whether or not the scalar case should be allowed. We haven't bottomed out yet on whether or not this case will be accepted in clang.

    Moving to the HLSL 202x milestone - this is something we should tighten up in DXC to ensure that it is more closely aligned to the behavior in clang.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugincorrect-code

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions