{"id":13477657,"url":"https://github.com/gfx-rs/wgpu","last_synced_at":"2025-05-12T16:12:57.713Z","repository":{"id":37493452,"uuid":"148686316","full_name":"gfx-rs/wgpu","owner":"gfx-rs","description":"A cross-platform, safe, pure-Rust graphics API.","archived":false,"fork":false,"pushed_at":"2025-04-30T11:07:21.000Z","size":67694,"stargazers_count":14071,"open_issues_count":910,"forks_count":1045,"subscribers_count":109,"default_branch":"trunk","last_synced_at":"2025-04-30T12:42:32.600Z","etag":null,"topics":["d3d12","gpu","hacktoberfest","metal","opengl","rust","vulkan","webgpu"],"latest_commit_sha":null,"homepage":"https://wgpu.rs","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/gfx-rs.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":"GOVERNANCE.md","roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-09-13T19:18:50.000Z","updated_at":"2025-04-30T12:11:55.000Z","dependencies_parsed_at":"2023-12-12T13:28:07.854Z","dependency_job_id":"68ce7c68-ba51-4b2e-ae84-6c9214911473","html_url":"https://github.com/gfx-rs/wgpu","commit_stats":{"total_commits":7401,"total_committers":484,"mean_commits":"15.291322314049587","dds":0.7469260910687745,"last_synced_commit":"0dab31ab2a06d8f6c94d4b94c9c11d92afd3249d"},"previous_names":[],"tags_count":306,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gfx-rs%2Fwgpu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gfx-rs%2Fwgpu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gfx-rs%2Fwgpu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gfx-rs%2Fwgpu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gfx-rs","download_url":"https://codeload.github.com/gfx-rs/wgpu/tar.gz/refs/heads/trunk","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251703010,"owners_count":21630142,"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":["d3d12","gpu","hacktoberfest","metal","opengl","rust","vulkan","webgpu"],"created_at":"2024-07-31T16:01:45.791Z","updated_at":"2025-05-05T08:39:15.401Z","avatar_url":"https://github.com/gfx-rs.png","language":"Rust","readme":"# wgpu\n\u003cimg align=\"right\" width=\"20%\" src=\"logo.png\"\u003e\n\n[![Matrix Space](https://img.shields.io/static/v1?label=Space\u0026message=%23Wgpu\u0026color=blue\u0026logo=matrix)](https://matrix.to/#/#Wgpu:matrix.org)\n[![Dev Matrix  ](https://img.shields.io/static/v1?label=devs\u0026message=%23wgpu\u0026color=blueviolet\u0026logo=matrix)](https://matrix.to/#/#wgpu:matrix.org)\n[![User Matrix ](https://img.shields.io/static/v1?label=users\u0026message=%23wgpu-users\u0026color=blueviolet\u0026logo=matrix)](https://matrix.to/#/#wgpu-users:matrix.org)\n[![Build Status](https://github.com/gfx-rs/wgpu/workflows/CI/badge.svg)](https://github.com/gfx-rs/wgpu/actions)\n[![codecov.io](https://codecov.io/gh/gfx-rs/wgpu/branch/trunk/graph/badge.svg?token=84qJTesmeS)](https://codecov.io/gh/gfx-rs/wgpu)\n\n`wgpu` is a cross-platform, safe, pure-rust graphics API. It runs natively on Vulkan, Metal, D3D12, and OpenGL; and on top of WebGL2 and WebGPU on wasm.\n\nThe API is based on the [WebGPU standard][webgpu]. It serves as the core of the WebGPU integration in Firefox, Servo, and Deno.\n\n[webgpu]: https://gpuweb.github.io/gpuweb/\n\n## Quick Links\n\n| Docs                  | Examples                  | Changelog               |\n|:---------------------:|:-------------------------:|:-----------------------:|\n| [v25][rel-docs]       | [v25][rel-examples]       | [v25][rel-change]       |\n| [`trunk`][trunk-docs] | [`trunk`][trunk-examples] | [`trunk`][trunk-change] |\n\nContributors are welcome! See [CONTRIBUTING.md][contrib] for more information.\n\n[rel-docs]: https://docs.rs/wgpu/\n[rel-examples]: https://github.com/gfx-rs/wgpu/tree/v25/examples#readme\n[rel-change]: https://github.com/gfx-rs/wgpu/releases\n[trunk-docs]: https://wgpu.rs/doc/wgpu/\n[trunk-examples]: https://github.com/gfx-rs/wgpu/tree/trunk/examples#readme\n[trunk-change]: https://github.com/gfx-rs/wgpu/blob/trunk/CHANGELOG.md#unreleased\n[contrib]: CONTRIBUTING.md\n\n## Repo Overview\n\nThe repository hosts the following libraries:\n\n- [![Crates.io](https://img.shields.io/crates/v/wgpu.svg?label=wgpu)](https://crates.io/crates/wgpu) [![docs.rs](https://docs.rs/wgpu/badge.svg)](https://docs.rs/wgpu/) - User facing Rust API.\n- [![Crates.io](https://img.shields.io/crates/v/wgpu-core.svg?label=wgpu-core)](https://crates.io/crates/wgpu-core) [![docs.rs](https://docs.rs/wgpu-core/badge.svg)](https://docs.rs/wgpu-core/) - Internal safe implementation.\n- [![Crates.io](https://img.shields.io/crates/v/wgpu-hal.svg?label=wgpu-hal)](https://crates.io/crates/wgpu-hal) [![docs.rs](https://docs.rs/wgpu-hal/badge.svg)](https://docs.rs/wgpu-hal/) - Internal unsafe GPU API abstraction layer.\n- [![Crates.io](https://img.shields.io/crates/v/wgpu-types.svg?label=wgpu-types)](https://crates.io/crates/wgpu-types) [![docs.rs](https://docs.rs/wgpu-types/badge.svg)](https://docs.rs/wgpu-types/) - Rust types shared between all crates.\n- [![Crates.io](https://img.shields.io/crates/v/naga.svg?label=naga)](https://crates.io/crates/naga) [![docs.rs](https://docs.rs/naga/badge.svg)](https://docs.rs/naga/) - Stand-alone shader translation library.\n- [![Crates.io](https://img.shields.io/crates/v/deno_webgpu.svg?label=deno_webgpu)](https://crates.io/crates/deno_webgpu) - WebGPU implementation for the Deno JavaScript/TypeScript runtime\n\nThe following binaries:\n\n- [![Crates.io](https://img.shields.io/crates/v/naga-cli.svg?label=naga-cli)](https://crates.io/crates/naga-cli) - Tool for translating shaders between different languages using `naga`.\n- [![Crates.io](https://img.shields.io/crates/v/wgpu-info.svg?label=wgpu-info)](https://crates.io/crates/wgpu-info) - Tool for getting information on GPUs in the system.\n- `cts_runner` - WebGPU Conformance Test Suite runner using `deno_webgpu`.\n- `player` - standalone application for replaying the API traces.\n\nFor an overview of all the components in the gfx-rs ecosystem, see [the big picture](./docs/big-picture.png).\n\n## Getting Started\n\n### Play with our Examples\n\nGo to \u003chttps://wgpu.rs/examples/\u003e to play with our examples in your browser. Requires a browser supporting WebGPU for the WebGPU examples.\n\n### Rust\n\nRust examples can be found at [examples](examples). You can run the examples natively with `cargo run --bin wgpu-examples \u003cexample\u003e`.\n\nIf you are new to wgpu and graphics programming, we recommend starting with https://sotrh.github.io/learn-wgpu/.\n\nTo run the examples in a browser, run `cargo xtask run-wasm`.\nThen open `http://localhost:8000` in your browser, and you can choose an example to run.\nNaturally, in order to display any of the WebGPU based examples, you need to make sure your browser supports it.\n\n### C/C++\n\nTo use wgpu in C/C++, you need [wgpu-native](https://github.com/gfx-rs/wgpu-native).\n\nIf you are looking for a wgpu C++ tutorial, look at the following:\n\n- https://eliemichel.github.io/LearnWebGPU/\n\n### Others\n\nIf you want to use wgpu in other languages, there are many bindings to wgpu-native from languages such as Python, D, Julia, Kotlin, and more. See [the list](https://github.com/gfx-rs/wgpu-native#bindings).\n\n## Community\n\nWe have the Matrix space [![Matrix Space](https://img.shields.io/static/v1?label=Space\u0026message=%23Wgpu\u0026color=blue\u0026logo=matrix)](https://matrix.to/#/#Wgpu:matrix.org) with a few different rooms that form the wgpu community:\n\n- [![Wgpu Matrix](https://img.shields.io/static/v1?label=wgpu-devs\u0026message=%23wgpu\u0026color=blueviolet\u0026logo=matrix)](https://matrix.to/#/#wgpu:matrix.org) - discussion of the wgpu's development.\n- [![Naga Matrix](https://img.shields.io/static/v1?label=naga-devs\u0026message=%23naga\u0026color=blueviolet\u0026logo=matrix)](https://matrix.to/#/#naga:matrix.org) - discussion of the naga's development.\n- [![User Matrix](https://img.shields.io/static/v1?label=wgpu-users\u0026message=%23wgpu-users\u0026color=blueviolet\u0026logo=matrix)](https://matrix.to/#/#wgpu-users:matrix.org) - discussion of using the library and the surrounding ecosystem.\n- [![Random Matrix](https://img.shields.io/static/v1?label=random\u0026message=%23wgpu-random\u0026color=blueviolet\u0026logo=matrix)](https://matrix.to/#/#wgpu-random:matrix.org) - discussion of everything else.\n\n## Wiki\n\nWe have a [wiki](https://github.com/gfx-rs/wgpu/wiki) that serves as a knowledge base.\n\n## Extension Specifications\n\nWhile the core of wgpu is based on the WebGPU standard, we also support extensions that allow for features that the standard does not have yet.\nFor high-level documentation on how to use these extensions, see the individual specifications:\n\n🧪EXPERIMENTAL🧪 APIs are subject to change and may allow undefined behavior if used incorrectly.\n\n- 🧪EXPERIMENTAL🧪 [Ray Tracing](./docs/api-specs/ray_tracing.md).\n\n## Supported Platforms\n\n| API    | Windows            | Linux/Android      | macOS/iOS          | Web (wasm)         |\n| ------ | ------------------ | ------------------ | ------------------ | ------------------ |\n| Vulkan |         ✅         |         ✅         |         🌋         |                    |\n| Metal  |                    |                    |         ✅         |                    |\n| DX12   |         ✅         |                    |                    |                    |\n| OpenGL |    🆗 (GL 3.3+)    |  🆗 (GL ES 3.0+)   |         📐         |    🆗 (WebGL2)     |\n| WebGPU |                    |                    |                    |         ✅         |\n\n✅ = First Class Support  \n🆗 = Downlevel/Best Effort Support  \n📐 = Requires the [ANGLE](#angle) translation layer (GL ES 3.0 only)  \n🌋 = Requires the [MoltenVK](https://vulkan.lunarg.com/sdk/home#mac) translation layer  \n🛠️ = Unsupported, though open to contributions\n\n### Shader Support\n\nwgpu supports shaders in [WGSL](https://gpuweb.github.io/gpuweb/wgsl/), SPIR-V, and GLSL.\nBoth [HLSL](https://github.com/Microsoft/DirectXShaderCompiler) and [GLSL](https://github.com/KhronosGroup/glslang)\nhave compilers to target SPIR-V. All of these shader languages can be used with any backend as we handle all of the conversions. Additionally, support for these shader inputs is not going away.\n\nWhile WebGPU does not support any shading language other than WGSL, we will automatically convert your\nnon-WGSL shaders if you're running on WebGPU.\n\nWGSL is always supported by default, but GLSL and SPIR-V need features enabled to compile in support.\n\nNote that the WGSL specification is still under development,\nso the [draft specification][wgsl spec] does not exactly describe what `wgpu` supports.\nSee [below](#tracking-the-webgpu-and-wgsl-draft-specifications) for details.\n\nTo enable SPIR-V shaders, enable the `spirv` feature of wgpu.\nTo enable GLSL shaders, enable the `glsl` feature of wgpu.\n\n### Angle\n\n[Angle](http://angleproject.org) is a translation layer from GLES to other backends developed by Google.\nWe support running our GLES3 backend over it in order to reach platforms DX11 support, which aren't accessible otherwise.\nIn order to run with Angle, the \"angle\" feature has to be enabled, and Angle libraries placed in a location visible to the application.\nThese binaries can be downloaded from [gfbuild-angle](https://github.com/DileSoft/gfbuild-angle) artifacts, [manual compilation](https://github.com/google/angle/blob/main/doc/DevSetup.md) may be required on Macs with Apple silicon.\n\nOn Windows, you generally need to copy them into the working directory, in the same directory as the executable, or somewhere in your path.\nOn Linux, you can point to them using `LD_LIBRARY_PATH` environment.\n\n### MSRV policy\n\nDue to complex dependants, we have two MSRV policies:\n\n- `naga`, `wgpu-core`, `wgpu-hal`, and `wgpu-types`'s MSRV is **1.76**.\n- The rest of the workspace has an MSRV of **1.84**.\n\nIt is enforced on CI (in \"/.github/workflows/ci.yml\") with the `CORE_MSRV` and `REPO_MSRV` variables.\nThis version can only be upgraded in breaking releases, though we release a breaking version every three months.\n\nThe `naga`, `wgpu-core`, `wgpu-hal`, and `wgpu-types` crates should never\nrequire an MSRV ahead of Firefox's MSRV for nightly builds, as\ndetermined by the value of `MINIMUM_RUST_VERSION` in\n[`python/mozboot/mozboot/util.py`][util].\n\n[util]: https://searchfox.org/mozilla-central/source/python/mozboot/mozboot/util.py\n\n## Environment Variables\n\nAll testing and example infrastructure share the same set of environment variables that determine which Backend/GPU it will run on.\n\n- `WGPU_ADAPTER_NAME` with a substring of the name of the adapter you want to use (ex. `1080` will match `NVIDIA GeForce 1080ti`).\n- `WGPU_BACKEND` with a comma-separated list of the backends you want to use (`vulkan`, `metal`, `dx12`, or `gl`).\n- `WGPU_POWER_PREF` with the power preference to choose when a specific adapter name isn't specified (`high`, `low` or `none`)\n- `WGPU_DX12_COMPILER` with the DX12 shader compiler you wish to use (`dxc`, `static-dxc`, or `fxc`). Note that `dxc` requires `dxcompiler.dll` (min v1.8.2502) to be in the working directory, and `static-dxc` requires the `static-dxc` crate feature to be enabled. Otherwise, it will fall back to `fxc`.\n- `WGPU_GLES_MINOR_VERSION` with the minor OpenGL ES 3 version number to request (`0`, `1`, `2` or `automatic`).\n- `WGPU_ALLOW_UNDERLYING_NONCOMPLIANT_ADAPTER` with a boolean whether non-compliant drivers are enumerated (`0` for false, `1` for true).\n\nWhen running the CTS, use the variables `DENO_WEBGPU_ADAPTER_NAME`, `DENO_WEBGPU_BACKEND`, `DENO_WEBGPU_POWER_PREFERENCE`.\n\n## Testing\n\nWe have multiple methods of testing, each of which tests different qualities about wgpu. We automatically run our tests on CI. The current state of CI testing:\n\n| Platform/Backend | Tests              | Notes                 |\n| ---------------- | ------------------ | --------------------- |\n| Windows/DX12     | :heavy_check_mark: | using WARP            |\n| Windows/OpenGL   | :heavy_check_mark: | using llvmpipe        |\n| MacOS/Metal      | :heavy_check_mark: | using hardware runner |\n| Linux/Vulkan     | :heavy_check_mark: | using lavapipe        |\n| Linux/OpenGL ES  | :heavy_check_mark: | using llvmpipe        |\n| Chrome/WebGL     | :heavy_check_mark: | using swiftshader     |\n| Chrome/WebGPU    | :x:                | not set up            |\n\n### Core Test Infrastructure\n\nWe use a tool called [`cargo nextest`](https://github.com/nextest-rs/nextest) to run our tests.\nTo install it, run `cargo install cargo-nextest`.\n\nTo run the test suite:\n\n```\ncargo xtask test\n```\n\nTo run the test suite on WebGL (currently incomplete):\n\n```\ncd wgpu\nwasm-pack test --headless --chrome --no-default-features --features webgl --workspace\n```\n\nThis will automatically run the tests using a packaged browser. Remove `--headless` to run the tests with whatever browser you wish at `http://localhost:8000`.\n\nIf you are a user and want a way to help contribute to wgpu, we always need more help writing test cases.\n\n### WebGPU Conformance Test Suite\n\nWebGPU includes a Conformance Test Suite to validate that implementations are working correctly. We can run this CTS against wgpu.\n\nTo run the CTS, first, you need to check it out:\n\n```\ngit clone https://github.com/gpuweb/cts.git\ncd cts\n# works in bash and powershell\ngit checkout $(cat ../cts_runner/revision.txt)\n```\n\nTo run a given set of tests:\n\n```\n# Must be inside the `cts` folder we just checked out, else this will fail\ncargo run --manifest-path ../Cargo.toml -p cts_runner --bin cts_runner -- ./tools/run_deno --verbose \"\u003ctest string\u003e\"\n```\n\nTo find the full list of tests, go to the [online cts viewer](https://gpuweb.github.io/cts/standalone/?runnow=0\u0026worker=0\u0026debug=0\u0026q=webgpu:*).\n\nThe list of currently enabled CTS tests can be found [here](./cts_runner/test.lst).\n\n## Tracking the WebGPU and WGSL draft specifications\n\nThe `wgpu` crate is meant to be an idiomatic Rust translation of the [WebGPU API][webgpu spec].\nThat specification, along with its shading language, [WGSL][wgsl spec],\nare both still in the \"Working Draft\" phase,\nand while the general outlines are stable,\ndetails change frequently.\nUntil the specification is stabilized, the `wgpu` crate and the version of WGSL it implements\nwill likely differ from what is specified,\nas the implementation catches up.\n\nExactly which WGSL features `wgpu` supports depends on how you are using it:\n\n- When running as native code, `wgpu` uses the [Naga][naga] crate\n  to translate WGSL code into the shading language of your platform's native GPU API.\n  Naga has [a milestone][naga wgsl milestone]\n  for catching up to the WGSL specification,\n  but in general, there is no up-to-date summary\n  of the differences between Naga and the WGSL spec.\n\n- When running in a web browser (by compilation to WebAssembly)\n  without the `\"webgl\"` feature enabled,\n  `wgpu` relies on the browser's own WebGPU implementation.\n  WGSL shaders are simply passed through to the browser,\n  so that determines which WGSL features you can use.\n\n- When running in a web browser with `wgpu`'s `\"webgl\"` feature enabled,\n  `wgpu` uses Naga to translate WGSL programs into GLSL.\n  This uses the same version of Naga as if you were running `wgpu` as native code.\n\n[webgpu spec]: https://www.w3.org/TR/webgpu/\n[wgsl spec]: https://gpuweb.github.io/gpuweb/wgsl/\n[naga]: https://github.com/gfx-rs/naga/\n[naga wgsl milestone]: https://github.com/gfx-rs/naga/milestone/4\n\n## Coordinate Systems\n\nwgpu uses the coordinate systems of D3D and Metal:\n\n| Render                                              | Texture                                               |\n| --------------------------------------------------- | ----------------------------------------------------- |\n| ![render_coordinates](./docs/render_coordinates.png) | ![texture_coordinates](./docs/texture_coordinates.png) |\n","funding_links":[],"categories":["Rust","Libraries","库 Libraries","Rust 程序设计","开源库","Frameworks","GPU Programming","vulkan","Graphics"],"sub_categories":["Graphics","图形 Graphics","网络服务_其他","Safari"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgfx-rs%2Fwgpu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgfx-rs%2Fwgpu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgfx-rs%2Fwgpu/lists"}