Skip to content

[DXIL] Crash when a function output parameter of a matrix type requires a cast to another matrix type of equal dimensions (e.g., float3x3 -> half3x3) #8809

Description

Description
The following code will cause a crash when compiling for DXIL output:

void crash_test(out float3x3 output)
{
    output = (float3x3)0;
}

float4 main() : SV_Position
{
    half3x3 output;
    crash_test(output); // <- the output parameter is not able to cast between halfNxM and floatNxM
    return (float4)0;
}

The cause is the function crash_test() having an output parameter of type float3x3, but passing in a variable of type half3x3 when calling it from main(). After a bit of digging in a debug build, it seem a DXASSERT is being hit in ConvertScalarOrVector() because the source and destination values are neither scalars nor vectors. It is getting to that code because there is no specific behavior defined in CGMSHLSLRuntime::EmitHLSLOutParamConversionCopyBack() for handling matrix type casting.

Steps to Reproduce

Actual Behavior
The following DXASSERT in ConvertScalarOrVector() is being hit when attempting to compile the above code for DXIL:

  DXASSERT(
      (SrcTy->isIntOrIntVectorTy() || SrcTy->isFPOrFPVectorTy()) &&
          (DstTy->isIntOrIntVectorTy() || DstTy->isFPOrFPVectorTy()),
      "EmitNumericConversion can only be used with int/float scalars/vectors.");

Environment

  • DXC version: dxcompiler.dll: 1.10(5434-75cab590)(1.9.0.15434) - 1.9.0.15434 (main, 75cab590f)
  • Host Operating System: Windows 11

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugBug, regression, crashneeds-triageAwaiting triage

    Type

    No type

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions