Skip to content

Naga's typechecker ignores scalar kind when casting matrices #6441

@cogumbreiro

Description

@cogumbreiro

Description

I think that there's a bug in the naga/src/proc/typifier.rs. Notably, when casting with As the new scalar kind, variable kind, is not propagated to the output scalar, only the width.

                Ti::Matrix {
                    columns,
                    rows,
                    mut scalar,
                } => {
                    if let Some(width) = convert {
                        scalar.width = width;
                    }
                    TypeResolution::Value(Ti::Matrix {
                        columns,
                        rows,
                        scalar,
                    })
                }

Note a correct behavior on vectors where the kind is propagated to the generated vector:

                Ti::Vector {
                    size,
                    scalar: crate::Scalar { kind: _, width },
                } => TypeResolution::Value(Ti::Vector {
                    size,
                    scalar: crate::Scalar {
                        kind,
                        width: convert.unwrap_or(width),
                    },
                }), 

Source:

TypeResolution::Value(Ti::Matrix {
columns,
rows,
scalar,

Metadata

Metadata

Assignees

No one assigned

    Labels

    nagaShader Translator

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions