{"id":19941069,"url":"https://github.com/rust-gpu/rust-gpu","last_synced_at":"2025-05-14T10:11:02.414Z","repository":{"id":252839646,"uuid":"827357591","full_name":"Rust-GPU/rust-gpu","owner":"Rust-GPU","description":"🐉 Making Rust a first-class language and ecosystem for GPU shaders 🚧","archived":false,"fork":false,"pushed_at":"2025-04-12T01:05:39.000Z","size":303850,"stargazers_count":1609,"open_issues_count":125,"forks_count":47,"subscribers_count":26,"default_branch":"main","last_synced_at":"2025-04-12T22:16:54.447Z","etag":null,"topics":["compiler","gpu-programming","graphics-programing","rust","shaders","spirv","vulkan"],"latest_commit_sha":null,"homepage":"https://rust-gpu.github.io","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Rust-GPU.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE-APACHE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-11T13:50:56.000Z","updated_at":"2025-04-12T19:02:31.000Z","dependencies_parsed_at":"2024-12-06T13:02:52.738Z","dependency_job_id":"4eda2b6a-f45b-4c0e-a78b-3bbde432e2d2","html_url":"https://github.com/Rust-GPU/rust-gpu","commit_stats":null,"previous_names":["rust-gpu/rust-gpu"],"tags_count":87,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rust-GPU%2Frust-gpu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rust-GPU%2Frust-gpu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rust-GPU%2Frust-gpu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rust-GPU%2Frust-gpu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Rust-GPU","download_url":"https://codeload.github.com/Rust-GPU/rust-gpu/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248637786,"owners_count":21137538,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compiler","gpu-programming","graphics-programing","rust","shaders","spirv","vulkan"],"created_at":"2024-11-13T00:08:00.452Z","updated_at":"2025-04-12T22:17:00.158Z","avatar_url":"https://github.com/Rust-GPU.png","language":"Rust","readme":"\u003c!-- Allow this file to not have a first line heading --\u003e\n\u003c!-- markdownlint-disable-file MD041 --\u003e\n\u003c!-- Disable warning om emphasis after first heading --\u003e\n\u003c!-- markdownlint-disable-file MD036 --\u003e\n\n\u003c!-- inline html --\u003e\n\u003c!-- markdownlint-disable-file MD033 --\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n# `🐉 rust-gpu`\n\n**Rust as a first-class language and ecosystem for GPU graphics \u0026 compute shaders**\n\n[![Build status](https://github.com/rust-gpu/rust-gpu/actions/workflows/ci.yaml/badge.svg)](https://github.com/rust-gpu/rust-gpu/actions/workflows/ci.yaml)\n[![Documentation](https://img.shields.io/badge/docs-API-blue)](https://rust-gpu.github.io/rust-gpu/api/rustc_codegen_spirv)\n\n\u003c/div\u003e\n\n## Current Status 🚧\n\nNote: This project is still heavily in development and is at an early stage.\n\nCompiling and running simple shaders works, and a significant portion of [the core library](https://doc.rust-lang.org/core/index.html) also compiles.\n\nHowever, many things aren't implemented yet. That means that while being technically\nusable, this project is not yet production-ready.\n\n## Example\n\n![Sky shader](docs/assets/sky.jpg)\n\n```rust,no_run\nuse glam::{Vec3, Vec4, vec2, vec3};\n\n#[spirv(fragment)]\npub fn main(\n    #[spirv(frag_coord)] in_frag_coord: \u0026Vec4,\n    #[spirv(push_constant)] constants: \u0026ShaderConstants,\n    output: \u0026mut Vec4,\n) {\n    let frag_coord = vec2(in_frag_coord.x, in_frag_coord.y);\n    let mut uv = (frag_coord - 0.5 * vec2(constants.width as f32, constants.height as f32))\n        / constants.height as f32;\n    uv.y = -uv.y;\n\n    let eye_pos = vec3(0.0, 0.0997, 0.2);\n    let sun_pos = vec3(0.0, 75.0, -1000.0);\n    let dir = get_ray_dir(uv, eye_pos, sun_pos);\n\n    // evaluate Preetham sky model\n    let color = sky(dir, sun_pos);\n\n    *output = tonemap(color).extend(1.0)\n}\n```\n\nSee [source](examples/shaders/sky-shader/src/lib.rs) for full details.\n\n## Getting started\n\nCheck out [The `rust-gpu` Dev Guide][gpu-guide] for information on how to get started with using it in your projects.\n\nExperiment with rust-gpu shaders in-browser at [SHADERed][shadered].\n\n[gpu-guide]: https://rust-gpu.github.io/rust-gpu/book/\n[shadered]: https://shadered.org/shaders?language=rust\u0026sort=hot\n\n## Getting help\n\nFor questions and comments, we use [GitHub discussions](https://github.com/Rust-GPU/rust-gpu/discussions) to keep conversations organized and searchable. This also makes it easy to escalate relevant topics to GitHub issues if needed. We do not have an official chat room.\n\n## Background\n\nHistorically in games GPU programming has been done through writing either HLSL, or to a lesser extent GLSL and WGSL. These are simple programming languages that have evolved along with rendering APIs over the years. However, these languages have failed to provide mechanisms for dealing with large codebases, and have generally stayed behind the curve compared to other programming languages.\n\nIn part this is because it's a niche language for a niche market, and in part this has been because the industry as a whole has sunk quite a lot of time and effort into the status quo. While over-all better alternatives to both languages exist, none of them are in a place to replace HLSL or GLSL. Either because they are vendor locked, or because they don't support the traditional graphics pipeline. Examples of this include CUDA and OpenCL. And while attempts have been made to create language in this space, none of them have gained any notable traction.\n\nOur hope with this project is that we push the industry forward by bringing an existing, low-level, safe, and high performance language to the GPU; namely [Rust](https://rust-lang.org). And with it come some additional benefits that can't be overlooked: a package/module system that's one of the industry's best, built in safety against race-conditions or out of bounds memory access, a wide range of tools and utilities to improve programmer workflows, and many others!\n\n### Embark\n\nThis project was originally created and supported by the folks at\n[Embark](https://www.embark-studios.com/). We thank them for their foresight and\ncontributions.\n\nEmbark wanted to streamline their internal development with a single great language,\nbuild an open source graphics ecosystem and community, facilitate code-sharing between\nGPU and CPU, and most importantly: to enable their (future) users, and fellow\ndevelopers, to more rapidly build great looking and engaging experiences.\n\n## Project scope\n\nThe scope of this overall project is quite broad, but is in multiple stages\n\n- `rustc` compiler backend to generate [SPIR-V], plugging in via `-Z codegen-backend`.\n  - This is the same mechanism that [rustc_codegen_cranelift](https://github.com/bjorn3/rustc_codegen_cranelift) and [rustc_codegen_gcc](https://github.com/antoyo/rustc_codegen_gcc) use.\n  - Currently only [SPIR-V] support is planned, [Vulkan](\u003chttps://en.wikipedia.org/wiki/Vulkan_(API)\u003e)'s open compiler target\n  - Possible a future version could support [DXIL](https://github.com/microsoft/DirectXShaderCompiler/blob/master/docs/DXIL.rst) (the target for DirectX) or [WGSL](https://github.com/gpuweb/gpuweb/tree/main/wgsl) (the WebGPU shading language that's bijective with SPIR-V)\n- [Cargo](https://github.com/rust-lang/cargo/) and [crates.io](https://crates.io) support to develop and publish SPIR-V crates\n\n## Process\n\nWe use this repo as a monorepo for everything related to the project: crates, tools, shaders, examples, tests, and design documents. This way, we can use issues and PRs covering everything in the same place, cross-reference stuff within the repo, as well as with other GitHub repos such as [rspirv](https://github.com/gfx-rs/rspirv) and [Rust](https://github.com/rust-lang/rust) itself.\n\n## Backwards compatibility, breaking changes and deprecation\n\nRight now because the project is in an early state of development, we might introduce temporary changes as stop-gap measures, or implement features or APIs that might not work exactly in a way we end up liking. Therefore it is expected that some (if not most) of the user facing code will change and evolve over time. At the moment this means that we make no guarantees about backwards compatibility and have no formal deprecation model in place. Effectively meaning that currently we only support building from source with the latest `main` branch in our repository. We appreciate our early adopters and would ask them to evolve their code along with ours.\n\n## Structure\n\nThere are a few different components to this repo:\n\n- [rfcs](docs/src/rfcs) for in-depth discussion and specs.\n- [rustc_codegen_spirv](crates/rustc_codegen_spirv) for the compiler itself.\n- [spirv-std](crates/spirv-std) for GPU intrinsics, types, and other library items used by GPU crates.\n- [spirv-builder](crates/spirv-builder) for a convenient way of building a GPU crate in a CPU build.rs file.\n\n## Related Projects\n\nHistorical and other related projects for compiling Rust code to GPUs.\n\n- [SPIR-V LLVM backend](https://llvm.org/docs/SPIRVUsage.html) Compiles to OpenCL SPIR-V, which differs from Vulkan SPIR-V used by Rust GPU.\n- 2016: [glassful](https://github.com/kmcallister/glassful) Compiles a subset of Rust to GLSL.\n- 2017: [inspirv-rust](https://github.com/msiglreith/inspirv-rust) Experimental Rust to SPIR-V compiler.\n- 2018: [nvptx](https://github.com/japaric-archived/nvptx) Rust to PTX compiler.\n- 2020: [accel](https://github.com/termoshtt/accel) GPGPU library for Rust.\n- 2020: [rlsl](https://github.com/MaikKlein/rlsl) Predeccesor to rust_gpu, Rust to SPIR-V compiler.\n- 2021: [Rust CUDA](https://github.com/Rust-GPU/Rust-CUDA) Rust to PTX compiler, similar mechanism to rustc_codegen_spirv.\n- 2024 Embark transitions maintenance of `rust-gpu` to the open source community.\n\n## Contributing\n\n[![Contributor Covenant](https://img.shields.io/badge/contributor%20covenant-v2.0-ff69b4.svg)](CODE_OF_CONDUCT.md)\n\nWe welcome community contributions to this project.\n\nPlease read our [Contributor Guide](CONTRIBUTING.md) for more information on how to get started.\n\n## License\n\nLicensed under either of\n\n- Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or \u003chttp://www.apache.org/licenses/LICENSE-2.0\u003e)\n- MIT license ([LICENSE-MIT](LICENSE-MIT) or \u003chttp://opensource.org/licenses/MIT\u003e)\n\nat your option.\n\n### Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.\n\n[SPIR-V]: https://en.wikipedia.org/wiki/Standard_Portable_Intermediate_Representation\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frust-gpu%2Frust-gpu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frust-gpu%2Frust-gpu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frust-gpu%2Frust-gpu/lists"}