Skip to content

AnyHit Shader hits llvm_unreachable("Unexpected matrix subscript use.")  #3954

Open

Description

We hit an internal compiler error with one of our Ray Tracing shaders:

Internal Compiler error: Unexpected matrix subscript use.
UNREACHABLE executed at DirectXShaderCompiler\lib\HLSL\HLMatrixSubscriptUseReplacer.cpp:91!

I reproduced the issue with the small sample shader below and tested it on the latest revision of the master branch:

struct Parameters {
    float3x3 Matrix;
};

struct Attributes {
    float3 Color;
};

struct Payload {
    float3 AccumulatedColor;
};

float3 TransformColor(inout Parameters Param, float3 Color) {
    float3 NewColor = Color * Param.Matrix[2].r.xxx; // INTERNAL ERROR
    return NewColor;
}

cbuffer Config {
    float3x3 GlobalMatrix;
}

[shader("anyhit")]
void MaterialAHS(inout Payload Data, in Attributes Attrib) {
    Parameters Param;
    Param.Matrix = GlobalMatrix;
    Data.AccumulatedColor += TransformColor(Param, Attrib.Color);
}

Using the expression Param.Matrix[2].xxx instead of Param.Matrix[2].r.xxx fixes the issue. Our HLSL generator produces a lot of redundant subscripts. We are trying to avoid this issue by improving the generated code, but it's probably worth mentioning. Also because this seems to only happen with Ray Tracing shaders.

Activity

  1. added
    bug
    crash
    and removed
    needs-triage
    on Apr 18, 2024
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

    bugcrash

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions