{"id":47820971,"url":"https://github.com/schell/wgsl-rs","last_synced_at":"2026-04-03T19:09:00.449Z","repository":{"id":330494316,"uuid":"1110170449","full_name":"schell/wgsl-rs","owner":"schell","description":"WGSL embedded in Rust","archived":false,"fork":false,"pushed_at":"2026-03-28T20:30:59.000Z","size":610,"stargazers_count":37,"open_issues_count":16,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-03-28T22:27:07.285Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/schell.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2025-12-04T20:11:24.000Z","updated_at":"2026-03-28T20:32:02.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/schell/wgsl-rs","commit_stats":null,"previous_names":["schell/wgsl-rs"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/schell/wgsl-rs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schell%2Fwgsl-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schell%2Fwgsl-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schell%2Fwgsl-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schell%2Fwgsl-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/schell","download_url":"https://codeload.github.com/schell/wgsl-rs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schell%2Fwgsl-rs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31372176,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-03T17:53:18.093Z","status":"ssl_error","status_checked_at":"2026-04-03T17:53:17.617Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2026-04-03T19:08:58.263Z","updated_at":"2026-04-03T19:09:00.444Z","avatar_url":"https://github.com/schell.png","language":"Rust","readme":"# wgsl-rs\n\nWith **wgsl-rs** you write a subset of Rust code and it automatically generates WGSL shaders and `wgpu` runtime linkage. \nRust code written this way is fully operational (it can be run on the CPU) while the transpiled WGSL is isomorphic and \nshould generate the same results on the GPU. \n\nIn short, with `wgsl-rs`, you can unit test and run your code on the CPU in Rust, and use the generated WGSL on the GPU,\nwhile sharing the same type definitions between the two.\n\nProcedural macros are provided by the [`wgsl-rs-macros`](./crates/wgsl-rs-macros) crate.\n\n---\n\nThis project is funded through [NGI Zero Commons](https://nlnet.nl/commonsfund/), a fund established by [NLnet](https://nlnet.nl) \nwith financial support from the European Commission's [Next Generation Internet](https://ngi.eu) program. \nLearn more at the [2025 NLnet project page](https://nlnet.nl/project/Renderling-Ecosystem/).\n\n[\u003cimg src=\"https://nlnet.nl/logo/banner.png\" alt=\"NLnet foundation logo\" width=\"20%\" /\u003e](https://nlnet.nl)\n\n[\u003cimg src=\"https://nlnet.nl/image/logos/NGI0_tag.svg\" alt=\"NGI Zero Logo\" width=\"20%\" /\u003e](https://nlnet.nl/core)\n\n## 🫶 Sponsor this!\n\nThis work will always be free and open source. \nIf you use it (outright or for inspiration), please consider donating.\n\n[💰 Sponsor 💝](https://github.com/sponsors/schell)\n\n---\n\n## Roadmap to Beta\n\nThere is a project plan for getting to beta [here](https://github.com/users/schell/projects/3/views/1)\n\n### Can it Hello World?\n\nYes! See the [example](crates/example/src/main.rs), which transpiles the shader from\n[Tour of WGSL](https://google.github.io/tour-of-wgsl/).\n\n---\n\n## Validation\n\n`wgsl-rs` validates your WGSL at compile-time using [naga](https://github.com/gfx-rs/wgpu/tree/trunk/naga).\nValidation errors are mapped back to Rust source spans, so they show up in your IDE via rust-analyzer.\n\n### Validation Strategy\n\n| Module Type | Validation |\n|-------------|------------|\n| Standalone (no imports) | Compile-time via naga |\n| With imports from other `#[wgsl]` modules | Test-time via auto-generated `#[test]` function |\n| `#[wgsl(skip_validation)]` | No validation |\n\n**Why test-time for modules with imports?**\n\nModules that import from other `#[wgsl]` modules cannot be validated at compile-time because\nthe imported symbols aren't available during macro expansion. Instead, `wgsl-rs` generates a\n`#[test] fn __validate_wgsl()` that validates the concatenated WGSL source at test-time.\n\n### Example\n\n```rust\n// Standalone module - validated at compile-time\n#[wgsl]\npub mod constants {\n    pub const PI: f32 = 3.14159;\n}\n\n// Module with imports - validated at test-time\n#[wgsl]\npub mod shader {\n    use super::constants::*;\n    \n    pub fn circle_area(r: f32) -\u003e f32 {\n        PI * r * r\n    }\n}\n\n// Skip all validation\n#[wgsl(skip_validation)]\npub mod experimental {\n    // ...\n}\n```\n\n### Runtime Validation\n\nYou can also validate modules at runtime using `Module::validate()`:\n\n```rust\nuse wgsl_rs::wgsl;\n\n#[wgsl]\npub mod my_shader {\n    // ...\n}\n\nfn main() {\n    // Validate manually (requires \"validation\" feature)\n    my_shader::WGSL_MODULE.validate().expect(\"WGSL validation failed\");\n}\n```\n\n### Disabling Validation\n\nTo disable validation entirely, disable the `validation` feature:\n\n```toml\n[dependencies]\nwgsl-rs = { version = \"...\", default-features = false }\n```\n\n---\n\n## Should I use Rust-GPU instead?\n\n**Maybe — it depends on your needs.**\n\n### Pros of wgsl-rs\n\n- **Lower barrier to entry:** No custom Rust compiler backend required.\n- **Works with stable Rust:** No need for nightly or custom toolchains.\n- **Editor support:** The `#[wgsl]` macro makes supported syntax explicit, so\n  your editor (via rust-analyzer) can help you write valid code.\n- **Immediate WGSL output:** Use, inspect, and debug the generated WGSL anywhere\n  WGSL is supported, including browsers and non-Rust projects.\n- **Human readable WGSL output:** The WGSL that `wgsl-rs` produces is very close\n  in structure to the Rust code you write, including binding names and types.\n- **Easy interop:** Generated WGSL can be used in any WebGPU environment.\n\n### Cons of wgsl-rs\n\n- **WGSL only:** Only works on platforms that support WGSL.\n- **Limited to WebGPU features:** No support for features not present in WGSL (e.g., bindless resources).\n- **Subset of Rust:** Only a strict subset of Rust is supported.\n  - No traits\n  - No borrowing\n  - Very restricted module support\n\n\u003e **Note:** wgsl-rs and Rust-GPU are not mutually exclusive!\n  You can start with wgsl-rs and switch to Rust-GPU when you need more advanced features.\n  I'm working on making them co-habitable.\n\n---\n\n## Getting Involved\n\nThe project is split into a few parts:\n\n- **`wgsl-rs-macros`**\n  Provides the `wgsl` procedural macro for writing WGSL modules in Rust. Handles\n  parsing and code generation for the supported Rust subset.\n- **`wgsl-rs`**\n  Provides the `Module` type, `wgsl::std`, and exports the `wgsl` macro.\n\nThere's also a [devlog](DEVLOG.md) that explains some of the decisions and tradeoffs made during the making\nof this library.\n\n---\n\nContributions, feedback, and questions are welcome!\n","funding_links":["https://github.com/sponsors/schell"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschell%2Fwgsl-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fschell%2Fwgsl-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschell%2Fwgsl-rs/lists"}