Skip to content
This repository was archived by the owner on Oct 31, 2025. It is now read-only.
This repository was archived by the owner on Oct 31, 2025. It is now read-only.

Add support for using glam crate in shaders #134

@repi

Description

@repi

Goal

At Embark we use glam as our primary math library in our native and WASM code and are quite happy with it.

We want to bring up the crate in Rust GPU so it can be built and used with our new spirv-unknown-unknown target in the Rust GPU compiler backend, and once that works likely change the example shaders here to use it, or have separate ones that uses and tests it.

In our own Rust engine we plan to convert our shaders to Rust GPU from GLSL and want to use the same math crate on all sides, or at least be able to.

Bring up

I've talked briefly with @bitshifter (the glam maintainer) and he was open to the idea of support, but we'll have to see what is needed for it.

May be multiple issues to resolve in Rust GPU first in its early stage to get this to work, which is why we are tracking this on our side first here. Once have a first compiling shader we can open a draft PR on glam with it and use it as a git dependency from there. May also take time until it can be merged in and tested as part of glam mainline if non trivial changes are required (or to get it it compiling in glam CI).

@bitshifter do you have any additional thoughts or concerns about how we may approach this? We don't want to take up too much of our time and do think we have a bunch of stuff we need to try and fix first.

Alternatives

Also note that this work does not mean that glam should be the only or the de facto math library for shaders in Rust.

We hope that most Rust math crates could eventually have support and we'll likely also be interested in exploring specific adaptions to make it adapted and ergonomic for GPU and shader programming (like vector swizzles) or even Rust language changes. But it would be great to have a standard well-designed crate, that we already use, to focus on and bring up first to have as a base.

Metadata

Metadata

Assignees

No one assigned

    Labels

    c: spirv-stdIssues specific to the spirv-std crate

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions