Rust (MIR) → SPIR-V (Shader) compiler

Overview

inspirv-rust

UPDATE 2: Next design iteration would probably be based on HIR instead of MIR. See more details here. In the meantime, you might want to checkout rlsl!

UPDATE: Development currently slowed down as other projects (i.e gfx-rs) have priority over this one. Will keep on working on it in the future (see above)!

An experimental compiler from Rust to SPIR-V, using the rustc compiler and MIR. The code is based upon [rustc_trans::mir], legacy (actually working) version was based on miri and mir2wasm.

rustc 1.17.0-nightly (0e7727795 2017-02-19)

Build

In order to build the standard and core library directly, you can run:

cargo run -- libcore\lib.rs --target=etc/spirv.json
cargo run -- libstd\lib.rs --extern core=libcore.rlib -L . --target=etc/spirv.json

To build the quad example shader:

cargo run -- rust-examples\quad.rs --extern std=libstd.rlib --extern core=libcore.lib -L . --target=etc/spirv.json

Resources

License

Licensed under either of

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be dual licensed as above, without any additional terms or conditions.

You might also like...
Rust language bindings for TensorFlow
Rust language bindings for TensorFlow

TensorFlow Rust provides idiomatic Rust language bindings for TensorFlow. Notice: This project is still under active development and not guaranteed to

Machine learning crate for Rust

rustlearn A machine learning package for Rust. For full usage details, see the API documentation. Introduction This crate contains reasonably effectiv

Rust bindings for the C++ api of PyTorch.

tch-rs Rust bindings for the C++ api of PyTorch. The goal of the tch crate is to provide some thin wrappers around the C++ PyTorch api (a.k.a. libtorc

个人的 rust 学习资料

🔝 通知: 项目文档迁移到: https://github.com/higker/learn-rust learning-rust-zh 个人的 rust 学习资料 学习目录 目录 源代码地址 相关解析 第一个rust程序 https://github.com/higker/learning-ru

Distributed compute platform implemented in Rust, and powered by Apache Arrow.
Distributed compute platform implemented in Rust, and powered by Apache Arrow.

Ballista: Distributed Compute Platform Overview Ballista is a distributed compute platform primarily implemented in Rust, powered by Apache Arrow. It

Tensors and differentiable operations (like TensorFlow) in Rust

autograd Differentiable operations and tensors backed by ndarray. Motivation Machine learning is one of the field where Rust lagging behind other lang

Rust numeric library with R, MATLAB & Python syntax

Peroxide Rust numeric library contains linear algebra, numerical analysis, statistics and machine learning tools with R, MATLAB, Python like macros. W

A fast, safe and easy to use reinforcement learning framework in Rust.
A fast, safe and easy to use reinforcement learning framework in Rust.

RSRL (api) Reinforcement learning should be fast, safe and easy to use. Overview rsrl provides generic constructs for reinforcement learning (RL) expe

Neural networks in Rust

deeplearn-rs Deep learning in Rust! This is my first shot at this. It's mostly just a proof of concept right now. The API will change. Status We have

Comments
  • Higher level APIs

    Higher level APIs

    Motivation: A large advantage of rust shaders in comparison to most extisting shaders are the support of modules and crates allowing to write reuseable code, which can be distributed fairly simple.

    Providing libraries on-top of the std/core library would be a desirable target after the release of the compiler and the main library settles slowly. These libraries might contain code for example BRDF implementations (Lambertian, Phong, Oren-Nayar, ...) or common algorithms for noise creation.

    help wanted diff: hard pri: low Interesting project 
    opened by msiglreith 0
  • Software rasterizer

    Software rasterizer

    Software rendering could be used as validation tool for testing the emitted SPIR-V code and also in later production stage to check for shader errors and regression. As the inspirv shaders are valid rust code this should be pretty straightfoward, but requiring some Rust backend only functions e.g. creation of interface structs.

    Depends on #7

    diff: medium pri: low Interesting project 
    opened by msiglreith 0
  • Provide Rust support for core/std

    Provide Rust support for core/std

    The movitation is to be able to compile a shader program also using the standard Rust compiler, allowing easy support for software renderer. This requires to implement all intrinsic functions with a Rust backend.

    help wanted diff: hard pri: low 
    opened by msiglreith 0
  • Improve enum type support

    Improve enum type support

    Currently only support C-like enums or consisting of unit types. SPIR-V (shader) doesn't support union types (afaik), so we probably will use a simple struct layout for emulating it:

    enum Foo {
        A(u32),
        B(f32),
        C,
    }
    

    would be translated to

    struct FooA(u32);
    struct FooB(u32);
    enum FooTy { A, B, C };
    
    struct Foo {
       ty: FooTy,
       a: FooA,
       b: FooB,
    }
    

    This will need alot more memory than an corresponding enum, so complex enum types should be avoided.

    Alternative

    Keep the current state and disallow complex enum types, but add special handling for Option<T>.

    diff: medium pri: high 
    opened by msiglreith 1
Owner
Markus Siglreithmaier
Physics-based Animations, Embedded and Computer Graphics
Markus Siglreithmaier
Compile your WebAssembly programs into SPIR-V shaders

wasm2spirv - Compile your WebAssembly programs into SPIR-V shaders Warning wasm2spirv is still in early development, and not production ready. This re

Alex Andreba 18 Jul 25, 2023
Open deep learning compiler stack for cpu, gpu and specialized accelerators

Open Deep Learning Compiler Stack Documentation | Contributors | Community | Release Notes Apache TVM is a compiler stack for deep learning systems. I

The Apache Software Foundation 8.9k Jan 4, 2023
WASM runtime for Deku and Michelson-to-WASM compiler

Tuna This repository has two different projects, a plugable VM for running WASM contracts on Deku and a Michelson to WASM compiler which also has some

Marigold 6 Nov 17, 2022
Msgpack serialization/deserialization library for Python, written in Rust using PyO3, and rust-msgpack. Reboot of orjson. msgpack.org[Python]

ormsgpack ormsgpack is a fast msgpack library for Python. It is a fork/reboot of orjson It serializes faster than msgpack-python and deserializes a bi

Aviram Hassan 139 Dec 30, 2022
Practice repo for learning Rust. Currently going through "Rust for JavaScript Developers" course.

rust-practice ?? Practice repo for learning Rust. Directories /rust-for-js-dev Files directed towards "Rust for JavaScript Developers" course. Thank y

Sammy Samkough 0 Dec 25, 2021
A Rust library with homemade machine learning models to classify the MNIST dataset. Built in an attempt to get familiar with advanced Rust concepts.

mnist-classifier Ideas UPDATED: Finish CLI Flags Parallelize conputationally intensive functions Class-based naive bayes README Image parsing Confusio

Neil Kaushikkar 0 Sep 2, 2021
🦀Rust Turkiye - Rust Dersleri

Rust Turkiye - Rust Dersleri CURIOSITY - Featuring Richard Feynman Bu repo Rust Turkiye tarafindan duzenlenen Rust Dersleri egitiminin alistirma ve ko

Theo M. Bulut 12 Jan 14, 2023
A Rust machine learning framework.

Linfa linfa (Italian) / sap (English): The vital circulating fluid of a plant. linfa aims to provide a comprehensive toolkit to build Machine Learning

Rust-ML 2.2k Jan 2, 2023
Machine Learning library for Rust

rusty-machine This library is no longer actively maintained. The crate is currently on version 0.5.4. Read the API Documentation to learn more. And he

James Lucas 1.2k Dec 31, 2022
Rust library for Self Organising Maps (SOM).

RusticSOM Rust library for Self Organising Maps (SOM). Using this Crate Add rusticsom as a dependency in Cargo.toml [dependencies] rusticsom = "1.1.0"

Avinash Shenoy 26 Oct 17, 2022