diff --git a/.cargo/config.toml b/.cargo/config.toml index 8434ec2cc6..4b01400617 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,10 +1,2 @@ [alias] -xtask = "run --manifest-path xtask/Cargo.toml" - -[build] -rustflags = [ -"--cfg=web_sys_unstable_apis" -] -rustdocflags = [ -"--cfg=web_sys_unstable_apis" -] +xtask = "run --manifest-path xtask/Cargo.toml --" diff --git a/.deny.toml b/.deny.toml index 5f1dd13487..a8b6db974e 100644 --- a/.deny.toml +++ b/.deny.toml @@ -4,6 +4,7 @@ skip-tree = [ { name = "windows-sys", version = "0.45" }, { name = "winit", version = "0.27.5" }, { name = "rustc_version", version = "0.2.3" }, + { name = "sourcemap", version = "7.1.1" }, ] skip = [ { name = "hlsl-snapshots", version = "0.1.0" }, diff --git a/.gitattributes b/.gitattributes index 149b5351f2..c239578a2c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,3 @@ *.mtl binary *.obj binary +wgpu/src/backend/webgpu/webgpu_sys/** linguist-generated=true diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 87a402ef89..8d5019fdcb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,10 +40,10 @@ env: # Once 1.76 coes out, we can use that instead of nightly. DOCS_RUST_VERSION: "nightly-2023-12-17" # This is the MSRV used by `wgpu` itself and all surrounding infrastructure. - REPO_MSRV: "1.71" + REPO_MSRV: "1.76" # This is the MSRV used by the `wgpu-core`, `wgpu-hal`, and `wgpu-types` crates, # to ensure that they can be used with firefox. - CORE_MSRV: "1.70" + CORE_MSRV: "1.74" # # Environment variables @@ -55,8 +55,8 @@ env: RUST_LOG: info RUST_BACKTRACE: full PKG_CONFIG_ALLOW_CROSS: 1 # allow android to work - RUSTFLAGS: --cfg=web_sys_unstable_apis -D warnings - RUSTDOCFLAGS: --cfg=web_sys_unstable_apis -D warnings + RUSTFLAGS: -D warnings + RUSTDOCFLAGS: -D warnings WASM_BINDGEN_TEST_TIMEOUT: 300 # 5 minutes CACHE_SUFFIX: c # cache busting @@ -344,7 +344,7 @@ jobs: wasm-test: # runtime is normally 2 minutes timeout-minutes: 10 - + name: Test WebAssembly runs-on: ubuntu-latest needs: [check] @@ -614,7 +614,7 @@ jobs: cargo fmt --manifest-path xtask/Cargo.toml -- --check - name: Check for typos - uses: crate-ci/typos@v1.18.0 + uses: crate-ci/typos@v1.19.0 check-cts-runner: # runtime is normally 2 minutes @@ -672,7 +672,7 @@ jobs: cargo-deny-check-rest: # runtime is normally 1 minute timeout-minutes: 5 - + name: "cargo-deny" runs-on: ubuntu-latest steps: diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index f45224779c..6dfed56f6a 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -12,7 +12,7 @@ env: CARGO_INCREMENTAL: false CARGO_TERM_COLOR: always RUST_BACKTRACE: full - RUSTFLAGS: --cfg=web_sys_unstable_apis + RUSTFLAGS: jobs: publish: diff --git a/.gitignore b/.gitignore index 089a7f2e19..4383c6f58c 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,9 @@ target/ # Output from capture example wgpu/red.png +# Output from render_to_texture example +**/please_don't_git_push_me.png + # Output from invalid comparison tests **/*-actual.png **/*-difference.png @@ -31,3 +34,6 @@ cts/ # Cached GPU config .gpuconfig + +# Temporary clone location for wasm-bindgen mirroring +wgpu/src/backend/webgpu/webgpu_sys/wasm_bindgen_clone_tmp \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index f3cae9dbb7..f45d479085 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,85 +39,122 @@ Bottom level categories: ## Unreleased +### Major Changes + ### Documentation -- Document Wayland specific behavior related to `SurfaceTexture::present`. By @i509VCB in [#5092](https://github.com/gfx-rs/wgpu/pull/5092). +- Add mention of primitive restart in the description of `PrimitiveState::strip_index_format`. By @cpsdqs in [#5350](https://github.com/gfx-rs/wgpu/pull/5350) +- Document precise behaviour of `SourceLocation`. By @stefnotch in [#5386](https://github.com/gfx-rs/wgpu/pull/5386) +- Give short example of WGSL `push_constant` syntax. By @waywardmonkeys in [#5393](https://github.com/gfx-rs/wgpu/pull/5393) ### New features #### General +- Implemented the `Unorm10_10_10_2` VertexFormat. - Many numeric built-ins have had a constant evaluation implementation added for them, which allows them to be used in a `const` context: - - [#4879](https://github.com/gfx-rs/wgpu/pull/4879) by @ErichDonGubler: - - `abs` - - `acos` - - `acosh` - - `asin` - - `asinh` - - `atan` - - `atanh` - - `cos` - - `cosh` - - `round` - - `saturate` - - `sin` - - `sinh` - - `sqrt` - - `step` - - `tan` - - `tanh` - - [#5098](https://github.com/gfx-rs/wgpu/pull/5098) by @ErichDonGubler: - - `ceil` - - `countLeadingZeros` - - `countOneBits` - - `countTrailingZeros` - - `degrees` - - `exp` - - `exp2` - - `floor` - - `fract` - - `fma` - - `inverseSqrt` - - `log` - - `log2` - - `max` - - `min` - - `radians` - - `reverseBits` - - `sign` - - `trunc` + - [#4879](https://github.com/gfx-rs/wgpu/pull/4879) by @ErichDonGubler: + - `abs` + - `acos` + - `acosh` + - `asin` + - `asinh` + - `atan` + - `atanh` + - `cos` + - `cosh` + - `round` + - `saturate` + - `sin` + - `sinh` + - `sqrt` + - `step` + - `tan` + - `tanh` + - [#5098](https://github.com/gfx-rs/wgpu/pull/5098) by @ErichDonGubler: + - `ceil` + - `countLeadingZeros` + - `countOneBits` + - `countTrailingZeros` + - `degrees` + - `exp` + - `exp2` + - `floor` + - `fract` + - `fma` + - `inverseSqrt` + - `log` + - `log2` + - `max` + - `min` + - `radians` + - `reverseBits` + - `sign` + - `trunc` - Eager release of GPU resources comes from device.trackers. By @bradwerth in [#5075](https://github.com/gfx-rs/wgpu/pull/5075) - `wgpu-types`'s `trace` and `replay` features have been replaced by the `serde` feature. By @KirmesBude in [#5149](https://github.com/gfx-rs/wgpu/pull/5149) - `wgpu-core`'s `serial-pass` feature has been removed. Use `serde` instead. By @KirmesBude in [#5149](https://github.com/gfx-rs/wgpu/pull/5149) -- Added `InstanceFlags::GPU_BASED_VALIDATION`, which enables GPU-based validation for shaders. This is currently only supported on the DX12 back end; other platforms ignore this flag, for now. - - This has been added to the set of flags set by `InstanceFlags::debugging` and `InstanceFlags::from_build_config`. If you notice your graphics workloads running more slowly, this may be the culprit. +- Added `InstanceFlags::GPU_BASED_VALIDATION`, which enables GPU-based validation for shaders. This is currently only supported on the DX12 and Vulkan backends; other platforms ignore this flag, for now. + - When set, this flag implies `InstanceFlags::VALIDATION`. + - This has been added to the set of flags set by `InstanceFlags::advanced_debugging`. Since the overhead is potentially very large, the flag is not enabled by default in debug builds when using `InstanceFlags::from_build_config`. - As with other instance flags, this flag can be changed in calls to `InstanceFlags::with_env` with the new `WGPU_GPU_BASED_VALIDATION` environment variable. - By @ErichDonGubler in [#5046](https://github.com/gfx-rs/wgpu/pull/5046). + By @ErichDonGubler in [#5146](https://github.com/gfx-rs/wgpu/pull/5146), [#5046](https://github.com/gfx-rs/wgpu/pull/5046). +- Signed and unsigned 64 bit integer support in shaders. By @rodolphito and @cwfitzgerald in [#5154](https://github.com/gfx-rs/wgpu/pull/5154) - `wgpu::Instance` can now report which `wgpu::Backends` are available based on the build configuration. By @wumpf [#5167](https://github.com/gfx-rs/wgpu/pull/5167) -```diff --wgpu::Instance::any_backend_feature_enabled() -+!wgpu::Instance::enabled_backend_features().is_empty() -``` -- `wgpu::Id` now implements `PartialOrd`/`Ord` allowing it to be put in `BTreeMap`s. By @cwfitzgerald and @9291Sam in [#5176](https://github.com/gfx-rs/wgpu/pull/5176) + + ```diff + -wgpu::Instance::any_backend_feature_enabled() + +!wgpu::Instance::enabled_backend_features().is_empty() + ``` + +- `wgpu::CommandEncoder::write_timestamp` requires now the new `wgpu::Features::TIMESTAMP_QUERY_INSIDE_ENCODERS` feature which is available on all native backends but not on WebGPU (due to a spec change `write_timestamp` is no longer supported on WebGPU). By @wumpf in [#5188](https://github.com/gfx-rs/wgpu/pull/5188) +- Breaking change: [`wgpu_core::pipeline::ProgrammableStageDescriptor`](https://docs.rs/wgpu-core/latest/wgpu_core/pipeline/struct.ProgrammableStageDescriptor.html#structfield.entry_point) is now optional. By @ErichDonGubler in [#5305](https://github.com/gfx-rs/wgpu/pull/5305). +- `Features::downlevel{_webgl2,}_features` was made const by @MultisampledNight in [#5343](https://github.com/gfx-rs/wgpu/pull/5343) + +- More as_hal methods and improvements by @JMS55 in [#5452](https://github.com/gfx-rs/wgpu/pull/5452) + - Added `wgpu::CommandEncoder::as_hal_mut` + - Added `wgpu::TextureView::as_hal` + - `wgpu::Texture::as_hal` now returns a user-defined type to match the other as_hal functions + +#### GLES + +- Log an error when GLES texture format heuristics fail. By @PolyMeilex in [#5266](https://github.com/gfx-rs/wgpu/issues/5266) +- Cache the sample count to keep `get_texture_format_features` cheap. By @Dinnerbone in [#5346](https://github.com/gfx-rs/wgpu/pull/5346) +- Mark `DEPTH32FLOAT_STENCIL8` as supported in GLES. By @Dinnerbone in [#5370](https://github.com/gfx-rs/wgpu/pull/5370) + +#### Naga + +- Allow user to select which MSL version to use via `--metal-version` with Naga CLI. By @pcleavelin in [#5392](https://github.com/gfx-rs/wgpu/pull/5392) +- Support `arrayLength` for runtime-sized arrays inside binding arrays (for WGSL input and SPIR-V output). By @kvark in [#5428](https://github.com/gfx-rs/wgpu/pull/5428) + +#### WebGPU + +- Implement the `device_set_device_lost_callback` method for `ContextWebGpu`. By @suti in [#5438](https://github.com/gfx-rs/wgpu/pull/5438) +- Add support for storage texture access modes `ReadOnly` and `ReadWrite`. By @JolifantoBambla in [#5434](https://github.com/gfx-rs/wgpu/pull/5434) ### Bug Fixes #### General -- Fix `panic!` when dropping `Instance` without `InstanceFlags::VALIDATION`. By @hakolao in [#5134](https://github.com/gfx-rs/wgpu/pull/5134) - Fix `serde` feature not compiling for `wgpu-types`. By @KirmesBude in [#5149](https://github.com/gfx-rs/wgpu/pull/5149) - Fix the validation of vertex and index ranges. By @nical in [#5144](https://github.com/gfx-rs/wgpu/pull/5144) and [#5156](https://github.com/gfx-rs/wgpu/pull/5156) -- Device lost callbacks are invoked when replaced and when global is dropped. By @bradwerth in [#5168](https://github.com/gfx-rs/wgpu/pull/5168) - Fix panic when creating a surface while no backend is available. By @wumpf [#5166](https://github.com/gfx-rs/wgpu/pull/5166) - Correctly compute minimum buffer size for array-typed `storage` and `uniform` vars. By @jimblandy [#5222](https://github.com/gfx-rs/wgpu/pull/5222) - Fix timeout when presenting a surface where no work has been done. By @waywardmonkeys in [#5200](https://github.com/gfx-rs/wgpu/pull/5200) - -#### WGL - -- In Surface::configure and Surface::present, fix the current GL context not being unset when releasing the lock that guards access to making the context current. This was causing other threads to panic when trying to make the context current. By @Imberflur in [#5087](https://github.com/gfx-rs/wgpu/pull/5087). +- Simplify and speed up the allocation of internal IDs. By @nical in [#5229](https://github.com/gfx-rs/wgpu/pull/5229) +- Fix behavior of `extractBits` and `insertBits` when `offset + count` overflows the bit width. By @cwfitzgerald in [#5305](https://github.com/gfx-rs/wgpu/pull/5305) +- Fix registry leaks with de-duplicated resources. By @nical in [#5244](https://github.com/gfx-rs/wgpu/pull/5244) +- Fix behavior of integer `clamp` when `min` argument > `max` argument. By @cwfitzgerald in [#5300](https://github.com/gfx-rs/wgpu/pull/5300). +- Fix linking when targeting android. By @ashdnazg in [#5326](https://github.com/gfx-rs/wgpu/pull/5326). +- fix resource leak for buffers/textures dropped while having pending writes. By @robtfm in [#5413](https://github.com/gfx-rs/wgpu/pull/5413) +- Failing to set the device lost closure will call the closure before returning. By @bradwerth in [#5358](https://github.com/gfx-rs/wgpu/pull/5358). +- Use memory pooling for UsageScopes to avoid frequent large allocations. by @robtfm in [#5414](https://github.com/gfx-rs/wgpu/pull/5414) +- Fix deadlocks caused by recursive read-write lock acquisitions [#5426](https://github.com/gfx-rs/wgpu/pull/5426). #### Naga -- Make use of `GL_EXT_texture_shadow_lod` to support sampling a cube depth texture with an explicit LOD. By @cmrschwarz in #[5171](https://github.com/gfx-rs/wgpu/pull/5171). +- In spv-in, remove unnecessary "gl_PerVertex" name check so unused builtins will always be skipped. By @Imberflur in [#5227](https://github.com/gfx-rs/wgpu/pull/5227). +- GLSL 410 does not support layout(binding = ...), enable only for GLSL 420. By @bes in [#5357](https://github.com/gfx-rs/wgpu/pull/5357) +- In spv-out, check for acceleration and ray-query types when enabling ray-query extension to prevent validation error. By @Vecvec in [#5463](https://github.com/gfx-rs/wgpu/pull/5463) #### Tests @@ -125,6 +162,120 @@ Bottom level categories: - Refactor tests to read feature flags by name instead of a hardcoded hexadecimal u64. By @rodolphito in [#5155](https://github.com/gfx-rs/wgpu/pull/5155). - Add test that verifies that we can drop the queue before using the device to create a command encoder. By @Davidster in [#5211](https://github.com/gfx-rs/wgpu/pull/5211) +#### GLES + +- Fixes for being able to use an OpenGL 4.1 core context provided by macOS with wgpu. By @bes in [#5331](https://github.com/gfx-rs/wgpu/pull/5331). +- Don't create a program for shader-clearing if that workaround isn't required. By @Dinnerbone in [#5348](https://github.com/gfx-rs/wgpu/pull/5348). +- Fix crash when holding multiple devices on wayland/surfaceless. By @ashdnazg in [#5351](https://github.com/gfx-rs/wgpu/pull/5351). +- Don't depend on bind group and bind group layout entry order in HAL. This caused incorrect severely incorrect command execution and, in some cases, crashes. By @ErichDonGubler in [#5421](https://github.com/gfx-rs/wgpu/pull/5421). + +#### Vulkan + +- Set object labels when the DEBUG flag is set, even if the VALIDATION flag is disabled. By @DJMcNab in [#5345](https://github.com/gfx-rs/wgpu/pull/5345). + +#### Metal + +- Don't depend on bind group and bind group layout entry order in HAL. This caused incorrect severely incorrect command execution and, in some cases, crashes. By @ErichDonGubler in [#5421](https://github.com/gfx-rs/wgpu/pull/5421). + +#### DX12 + +- Don't depend on bind group and bind group layout entry order in HAL. This caused incorrect severely incorrect command execution and, in some cases, crashes. By @ErichDonGubler in [#5421](https://github.com/gfx-rs/wgpu/pull/5421). + +## v0.19.3 (2024-03-01) + +This release includes `wgpu`, `wgpu-core`, and `wgpu-hal`. All other crates are unchanged. + +### Major Changes + +#### Vendored WebGPU Bindings from `web_sys` + +**`--cfg=web_sys_unstable_apis` is no longer needed in your `RUSTFLAGS` to compile for WebGPU!!!** + +While WebGPU's javascript api is stable in the browsers, the `web_sys` bindings for WebGPU are still improving. As such they are hidden behind the special cfg `--cfg=web_sys_unstable_apis` and are not available by default. Everyone who wanted to use our WebGPU backend needed to enable this cfg in their `RUSTFLAGS`. This was very inconvenient and made it hard to use WebGPU, especially when WebGPU is enabled by default. Additionally, the unstable APIs don't adhere to semver, so there were repeated breakages. + +To combat this problem we have decided to vendor the `web_sys` bindings for WebGPU within the crate. Notably we are not forking the bindings, merely vendoring, so any improvements we make to the bindings will be contributed directly to upstream `web_sys`. + +By @cwfitzgerald in [#5325](https://github.com/gfx-rs/wgpu/pull/5325). + +### Bug Fixes + +#### General + +- Fix an issue where command encoders weren't properly freed if an error occurred during command encoding. By @ErichDonGubler in [#5251](https://github.com/gfx-rs/wgpu/pull/5251). +- Fix incorrect validation causing all indexed draws on render bundles to fail. By @wumpf in [#5430](https://github.com/gfx-rs/wgpu/pull/5340). + +#### Android +- Fix linking error when targeting android without `winit`. By @ashdnazg in [#5326](https://github.com/gfx-rs/wgpu/pull/5326). + + +## v0.19.2 (2024-02-29) + +This release includes `wgpu`, `wgpu-core`, `wgpu-hal`, `wgpu-types`, and `naga`. All other crates are unchanged. + +### Added/New Features + +#### General +- `wgpu::Id` now implements `PartialOrd`/`Ord` allowing it to be put in `BTreeMap`s. By @cwfitzgerald and @9291Sam in [#5176](https://github.com/gfx-rs/wgpu/pull/5176) + +#### OpenGL +- Log an error when OpenGL texture format heuristics fail. By @PolyMeilex in [#5266](https://github.com/gfx-rs/wgpu/issues/5266) + +#### `wgsl-out` +- Learned to generate acceleration structure types. By @JMS55 in [#5261](https://github.com/gfx-rs/wgpu/pull/5261) + +### Documentation +- Fix link in `wgpu::Instance::create_surface` documentation. By @HexoKnight in [#5280](https://github.com/gfx-rs/wgpu/pull/5280). +- Fix typo in `wgpu::CommandEncoder::clear_buffer` documentation. By @PWhiddy in [#5281](https://github.com/gfx-rs/wgpu/pull/5281). +- `Surface` configuration incorrectly claimed that `wgpu::Instance::create_surface` was unsafe. By @hackaugusto in [#5265](https://github.com/gfx-rs/wgpu/pull/5265). + +### Bug Fixes + +#### General +- Device lost callbacks are invoked when replaced and when global is dropped. By @bradwerth in [#5168](https://github.com/gfx-rs/wgpu/pull/5168) +- Fix performance regression when allocating a large amount of resources of the same type. By @nical in [#5229](https://github.com/gfx-rs/wgpu/pull/5229) +- Fix docs.rs wasm32 builds. By @cwfitzgerald in [#5310](https://github.com/gfx-rs/wgpu/pull/5310) +- Improve error message when binding count limit hit. By @hackaugusto in [#5298](https://github.com/gfx-rs/wgpu/pull/5298) +- Remove an unnecessary `clone` during GLSL shader ingestion. By @a1phyr in [#5118](https://github.com/gfx-rs/wgpu/pull/5118). +- Fix missing validation for `Device::clear_buffer` where `offset + size > buffer.size` was not checked when `size` was omitted. By @ErichDonGubler in [#5282](https://github.com/gfx-rs/wgpu/pull/5282). + +#### DX12 +- Fix `panic!` when dropping `Instance` without `InstanceFlags::VALIDATION`. By @hakolao in [#5134](https://github.com/gfx-rs/wgpu/pull/5134) + +#### OpenGL +- Fix internal format for the `Etc2Rgba8Unorm` format. By @andristarr in [#5178](https://github.com/gfx-rs/wgpu/pull/5178) +- Try to load `libX11.so.6` in addition to `libX11.so` on linux. [#5307](https://github.com/gfx-rs/wgpu/pull/5307) +- Make use of `GL_EXT_texture_shadow_lod` to support sampling a cube depth texture with an explicit LOD. By @cmrschwarz in #[5171](https://github.com/gfx-rs/wgpu/pull/5171). + +#### `glsl-in` + +- Fix code generation from nested loops. By @cwfitzgerald and @teoxoy in [#5311](https://github.com/gfx-rs/wgpu/pull/5311) + + +## v0.19.1 (2024-01-22) + +This release includes `wgpu` and `wgpu-hal`. The rest of the crates are unchanged since 0.19.0. + +### Bug Fixes + +#### DX12 + +- Properly register all swapchain buffers to prevent error on surface present. By @dtzxporter in [#5091](https://github.com/gfx-rs/wgpu/pull/5091) +- Check for extra null states when creating resources. By @nical in [#5096](https://github.com/gfx-rs/wgpu/pull/5096) +- Fix depth-only and stencil-only views causing crashes. By @teoxoy in [#5100](https://github.com/gfx-rs/wgpu/pull/5100) + +#### OpenGL + +- In Surface::configure and Surface::present on Windows, fix the current GL context not being unset when releasing the lock that guards access to making the context current. This was causing other threads to panic when trying to make the context current. By @Imberflur in [#5087](https://github.com/gfx-rs/wgpu/pull/5087). + +#### WebGPU + +- Improve error message when compiling WebGPU backend on wasm without the `web_sys_unstable_apis` set. By @rukai in [#5104](https://github.com/gfx-rs/wgpu/pull/5104) + +### Documentation + +- Document Wayland specific behavior related to `SurfaceTexture::present`. By @i509VCB in [#5093](https://github.com/gfx-rs/wgpu/pull/5093). + + ## v0.19.0 (2024-01-17) This release includes: diff --git a/Cargo.lock b/Cargo.lock index 0d1769b4e0..69b4d58d9c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -35,9 +35,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "ahash" -version = "0.8.6" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ "cfg-if", "getrandom", @@ -63,9 +63,9 @@ checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" [[package]] name = "android-activity" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39b801912a977c3fd52d80511fe1c0c8480c6f957f21ae2ce1b92ffe970cf4b9" +checksum = "ee91c0c2905bae44f84bfa4e044536541df26b7703fd0888deeb9060fcc44289" dependencies = [ "android-properties", "bitflags 2.4.2", @@ -78,7 +78,7 @@ dependencies = [ "ndk 0.8.0", "ndk-context", "ndk-sys 0.5.0+25.2.9519653", - "num_enum 0.7.1", + "num_enum 0.7.2", "thiserror", ] @@ -105,9 +105,9 @@ checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" [[package]] name = "anstream" -version = "0.6.11" +version = "0.6.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e2e1ebcb11de5c03c67de28a7df593d32191b44939c482e97702baaaa6ab6a5" +checksum = "d96bd03f33fe50a863e394ee9718a706f988b9079b20c3784fb726e7678b62fb" dependencies = [ "anstyle", "anstyle-parse", @@ -119,9 +119,9 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.4" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" +checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" [[package]] name = "anstyle-parse" @@ -153,9 +153,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.79" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca" +checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247" [[package]] name = "arbitrary" @@ -185,7 +185,7 @@ dependencies = [ "argh_shared", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] @@ -241,7 +241,7 @@ checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] @@ -277,13 +277,22 @@ version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" +[[package]] +name = "base64-simd" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "781dd20c3aff0bd194fe7d2a977dd92f21c173891f3a03b677359e5fa457e5d5" +dependencies = [ + "simd-abstraction", +] + [[package]] name = "base64-simd" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "339abbe78e73178762e23bea9dfd08e697eb3f3301cd4be981c0f78ba5859195" dependencies = [ - "outref", + "outref 0.5.1", "vsimd", ] @@ -354,28 +363,28 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.14.0" +version = "3.15.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" +checksum = "7ff69b9dd49fd426c69a0db9fc04dd934cdb6645ff000864d98f7e2af8830eaa" [[package]] name = "bytemuck" -version = "1.14.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6" +checksum = "5d6d68c57235a3a081186990eca2867354726650f42f7516ca50c28d6281fd15" dependencies = [ "bytemuck_derive", ] [[package]] name = "bytemuck_derive" -version = "1.5.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "965ab7eb5f8f97d2a083c799f3a1b994fc397b2fe2da5d1da1626ce15a39f2b1" +checksum = "4da9a32f3fed317401fa3c862968128267c3106685286e15d5aaa3d7389c2f60" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] @@ -406,9 +415,9 @@ dependencies = [ [[package]] name = "calloop" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b50b5a44d59a98c55a9eeb518f39bf7499ba19fd98ee7d22618687f3f10adbf" +checksum = "fba7adb4dd5aa98e5553510223000e7148f621165ec5f9acd7113f6ca4995298" dependencies = [ "bitflags 2.4.2", "log", @@ -424,10 +433,10 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0f0ea9b9476c7fad82841a8dbb380e2eae480c21910feba80725b46931ed8f02" dependencies = [ - "calloop 0.12.3", + "calloop 0.12.4", "rustix", "wayland-backend", - "wayland-client 0.31.1", + "wayland-client 0.31.2", ] [[package]] @@ -438,9 +447,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.0.83" +version = "1.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" dependencies = [ "jobserver", "libc", @@ -475,9 +484,9 @@ dependencies = [ [[package]] name = "ciborium" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "effd91f6c78e5a4ace8a5d3c0b6bfaec9e2baaef55f3efc00e45fb2e477ee926" +checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e" dependencies = [ "ciborium-io", "ciborium-ll", @@ -492,9 +501,9 @@ checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757" [[package]] name = "ciborium-ll" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "defaa24ecc093c77630e6c15e17c51f5e187bf35ee514f4e2d67baaa96dae22b" +checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9" dependencies = [ "ciborium-io", "half", @@ -502,9 +511,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.18" +version = "4.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e578d6ec4194633722ccf9544794b71b1385c3c027efe0c55db226fc880865c" +checksum = "b230ab84b0ffdf890d5a10abdbc8b83ae1c4918275daea1ab8801f71536b2651" dependencies = [ "clap_builder", "clap_derive", @@ -512,33 +521,33 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.18" +version = "4.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4df4df40ec50c46000231c914968278b1eb05098cf8f1b3a518a95030e71d1c7" +checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" dependencies = [ "anstream", "anstyle", "clap_lex", - "strsim", + "strsim 0.11.0", ] [[package]] name = "clap_derive" -version = "4.4.7" +version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" +checksum = "307bc0538d5f0f83b8248db3087aa92fe504e4691294d0c96c0eabc33f47ba47" dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] name = "clap_lex" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" +checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" [[package]] name = "cmake" @@ -699,6 +708,12 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" +[[package]] +name = "cooked-waker" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147be55d677052dabc6b22252d5dd0fd4c29c8c27aa4f2fbef0f94aa003b406f" + [[package]] name = "core-foundation" version = "0.9.4" @@ -766,9 +781,9 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.3.2" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +checksum = "b3855a8a784b474f333699ef2bbca9db2c4a1f6d9088a90a2d25b1eb53111eaa" dependencies = [ "cfg-if", ] @@ -857,14 +872,20 @@ dependencies = [ "winapi", ] +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + [[package]] name = "ctor" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30d2b3721e861707777e3195b0158f950ae6dc4a27e4d02ff9f67e3eb3de199e" +checksum = "ad291aa74992b9b7a7e88c38acbbf6ad7e107f1d90ee8775b7bc1fc3394f485c" dependencies = [ "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] @@ -898,7 +919,7 @@ name = "d3d12" version = "0.19.0" dependencies = [ "bitflags 2.4.2", - "libloading 0.8.1", + "libloading 0.8.3", "winapi", ] @@ -922,7 +943,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim", + "strsim 0.10.0", "syn 1.0.109", ] @@ -955,26 +976,32 @@ dependencies = [ [[package]] name = "deno_console" -version = "0.125.0" +version = "0.143.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92543d4f4d82f2350123bd4b60e97a73aba1a9bbca8c931e827459096dedabba" +checksum = "1f770d8deb0eb0bfd596d242d9eaef5312ef57f0130964cb53c7f6a8107d13be" dependencies = [ "deno_core", ] [[package]] name = "deno_core" -version = "0.232.0" +version = "0.272.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "229ffd108e028b148a1a5a6122f771bc7c37094170226f44b8b93b3a9b79d114" +checksum = "07093891f2af763023614cfe2d1ce5f9ce5a7920c4fcf2f00911bd0d93083523" dependencies = [ "anyhow", + "bincode", + "bit-set", + "bit-vec", "bytes", + "cooked-waker", + "deno_core_icudata", "deno_ops", "deno_unsync", "futures", "libc", "log", + "memoffset 0.9.1", "parking_lot", "pin-project", "serde", @@ -982,23 +1009,30 @@ dependencies = [ "serde_v8", "smallvec", "sourcemap", + "static_assertions", "tokio", "url", "v8", ] +[[package]] +name = "deno_core_icudata" +version = "0.0.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a13951ea98c0a4c372f162d669193b4c9d991512de9f2381dd161027f34b26b1" + [[package]] name = "deno_ops" -version = "0.108.0" +version = "0.148.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7dde627916f8539f3f0d2e754dda40810c8ca4d655f2eaac1ef54785a12fd27" +checksum = "5bc73fc07ad26e71715d5a726d1dd228587c0d121a591b1931a0fcf958a2ec3b" dependencies = [ "proc-macro-rules", "proc-macro2", "quote", "strum", "strum_macros", - "syn 2.0.48", + "syn 2.0.52", "thiserror", ] @@ -1013,9 +1047,9 @@ dependencies = [ [[package]] name = "deno_url" -version = "0.125.0" +version = "0.143.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25ec92af225230fe4a429de0b5891f35b1ba5f143f8c1605bb7b9d1cb767ac73" +checksum = "39d9e6ffd6a7157bfd3cf1385c59232e49587c9bbb898e64010f7f082242a203" dependencies = [ "deno_core", "serde", @@ -1024,12 +1058,12 @@ dependencies = [ [[package]] name = "deno_web" -version = "0.156.0" +version = "0.174.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3aeef7522f46b3442e24a750ef914ca54aade2110d6540a66e4ea17b4eb68bb7" +checksum = "708666b5b346e6880c1372006615814db7fc5ef36bd1785f0b0e4f8617082999" dependencies = [ "async-trait", - "base64-simd", + "base64-simd 0.8.0", "bytes", "deno_core", "encoding_rs", @@ -1043,7 +1077,7 @@ dependencies = [ [[package]] name = "deno_webgpu" -version = "0.85.0" +version = "0.110.0" dependencies = [ "deno_core", "raw-window-handle 0.6.0", @@ -1056,9 +1090,9 @@ dependencies = [ [[package]] name = "deno_webidl" -version = "0.125.0" +version = "0.143.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74b1a86e9a1dec0dc5d4dc132faee72ac50297f41e30f7cab57dd52dda380eed" +checksum = "bddad93aa68e3c3c2d36976cd401af27a6ce750c23060e02401daf240f2acbe2" dependencies = [ "deno_core", ] @@ -1071,7 +1105,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] @@ -1105,7 +1139,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "330c60081dcc4c72131f8eb70510f1ac07223e5d4163db481a04a0befcffa412" dependencies = [ - "libloading 0.8.1", + "libloading 0.8.3", ] [[package]] @@ -1139,9 +1173,9 @@ dependencies = [ [[package]] name = "either" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" [[package]] name = "encase" @@ -1172,7 +1206,7 @@ checksum = "92959a9e8d13eaa13b8ae8c7b583c3bf1669ca7a8e7708a088d12587ba86effc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] @@ -1184,17 +1218,27 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "env_filter" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a009aa4810eb158359dda09d0c87378e4bbb89b5a801f016885a4707ba24f7ea" +dependencies = [ + "log", + "regex", +] + [[package]] name = "env_logger" -version = "0.10.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" +checksum = "38b35839ba51819680ba087cd351788c9a3c476841207e0b8cee0b04722343b9" dependencies = [ + "anstream", + "anstyle", + "env_filter", "humantime", - "is-terminal", "log", - "regex", - "termcolor", ] [[package]] @@ -1308,7 +1352,7 @@ checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] @@ -1356,9 +1400,9 @@ dependencies = [ [[package]] name = "fslock" -version = "0.1.8" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57eafdd0c16f57161105ae1b98a1238f97645f2f588438b2949c99a2af9616bf" +checksum = "04412b8935272e3a9bae6f48c7bfff74c2911f60525404edfdd28e49884c3bfb" dependencies = [ "libc", "winapi", @@ -1433,7 +1477,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] @@ -1650,11 +1694,24 @@ dependencies = [ "bitflags 2.4.2", ] +[[package]] +name = "gzip-header" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95cc527b92e6029a62960ad99aa8a6660faa4555fe5f731aab13aa6a921795a2" +dependencies = [ + "crc32fast", +] + [[package]] name = "half" -version = "1.8.2" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" +checksum = "b5eceaaeec696539ddaf7b333340f1af35a5aa87ae3e4f3ead0532f72affab2e" +dependencies = [ + "cfg-if", + "crunchy", +] [[package]] name = "hashbrown" @@ -1675,7 +1732,7 @@ dependencies = [ "bitflags 2.4.2", "com", "libc", - "libloading 0.8.1", + "libloading 0.8.3", "thiserror", "widestring", "winapi", @@ -1689,9 +1746,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.3.4" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d3d0e0f38255e7fa3cf31335b3a56f05febd18025f4db5ef7a0cfb4f8da651f" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" [[package]] name = "hexf-parse" @@ -1757,9 +1814,9 @@ checksum = "cb56e1aa765b4b4f3aadfab769793b7087bb03a4ea4920644a6d238e2df5b9ed" [[package]] name = "image" -version = "0.24.8" +version = "0.24.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "034bbe799d1909622a74d1193aa50147769440040ff36cb2baa947609b0a4e23" +checksum = "5690139d2f55868e080017335e4b94cb7414274c74f1669c84fb5feba2c9f69d" dependencies = [ "bytemuck", "byteorder", @@ -1770,9 +1827,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.1.0" +version = "2.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" +checksum = "7b0b929d511467233429c45a44ac1dcaa21ba0f5ba11e4879e6ed28ddb4f9df4" dependencies = [ "arbitrary", "equivalent", @@ -1794,12 +1851,12 @@ dependencies = [ [[package]] name = "is-terminal" -version = "0.4.10" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bad00257d07be169d870ab665980b06cdb366d792ad690bf2e76876dc503455" +checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" dependencies = [ "hermit-abi", - "rustix", + "libc", "windows-sys 0.52.0", ] @@ -1842,18 +1899,18 @@ checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" [[package]] name = "jobserver" -version = "0.1.27" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c37f63953c4c63420ed5fd3d6d398c719489b9f872b9fa683262f8edd363c7d" +checksum = "ab46a6e9526ddef3ae7f787c06f0f2600639ba80ea3eade3d8e670a2230f51d6" dependencies = [ "libc", ] [[package]] name = "js-sys" -version = "0.3.67" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a1d36f1235bc969acba30b7f5990b864423a6068a10f7c90ae8f0112e3a59d1" +checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" dependencies = [ "wasm-bindgen", ] @@ -1865,7 +1922,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6aae1df220ece3c0ada96b8153459b67eebe9ae9212258bb0134ae60416fdf76" dependencies = [ "libc", - "libloading 0.8.1", + "libloading 0.8.3", "pkg-config", ] @@ -1892,9 +1949,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.152" +version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "libfuzzer-sys" @@ -1919,12 +1976,12 @@ dependencies = [ [[package]] name = "libloading" -version = "0.8.1" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c571b676ddfc9a8c12f1f3d3085a7b163966a8fd8098a90640953ce5f6170161" +checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19" dependencies = [ "cfg-if", - "windows-sys 0.48.0", + "windows-targets 0.52.4", ] [[package]] @@ -1973,9 +2030,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.20" +version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "malloc_buf" @@ -2003,9 +2060,9 @@ dependencies = [ [[package]] name = "memmap2" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45fd3a57831bf88bc63f8cebc0cf956116276e97fef3966103e96416209f7c92" +checksum = "fe751422e4a8caa417e13c3ea66452215d7d63e19e604f4980461212f3ae1322" dependencies = [ "libc", ] @@ -2021,9 +2078,9 @@ dependencies = [ [[package]] name = "memoffset" -version = "0.7.1" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" +checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" dependencies = [ "autocfg", ] @@ -2045,9 +2102,9 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" dependencies = [ "adler", "simd-adler32", @@ -2055,9 +2112,9 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.10" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" +checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" dependencies = [ "libc", "log", @@ -2127,18 +2184,18 @@ dependencies = [ [[package]] name = "nanoserde" -version = "0.1.35" +version = "0.1.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a983d0b19ed0fcd803c4f04f9b20d5e6dd17e06d44d98742a0985ac45dab1bc" +checksum = "5de9cf844ab1e25a0353525bd74cb889843a6215fa4a0d156fd446f4857a1b99" dependencies = [ "nanoserde-derive", ] [[package]] name = "nanoserde-derive" -version = "0.1.21" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4dc96541767a4279572fdcf9f95af9cc1c9b2a2254e7a079203c81e206a9059" +checksum = "e943b2c21337b7e3ec6678500687cdc741b7639ad457f234693352075c082204" [[package]] name = "ndk" @@ -2164,7 +2221,7 @@ dependencies = [ "jni-sys", "log", "ndk-sys 0.5.0+25.2.9519653", - "num_enum 0.7.1", + "num_enum 0.7.2", "raw-window-handle 0.6.0", "thiserror", ] @@ -2247,18 +2304,6 @@ dependencies = [ "memoffset 0.6.5", ] -[[package]] -name = "nix" -version = "0.26.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" -dependencies = [ - "bitflags 1.3.2", - "cfg-if", - "libc", - "memoffset 0.7.1", -] - [[package]] name = "noise" version = "0.8.2" @@ -2283,19 +2328,18 @@ dependencies = [ [[package]] name = "num-integer" -version = "0.1.45" +version = "0.1.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" dependencies = [ - "autocfg", "num-traits", ] [[package]] name = "num-traits" -version = "0.2.17" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" dependencies = [ "autocfg", ] @@ -2321,11 +2365,11 @@ dependencies = [ [[package]] name = "num_enum" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "683751d591e6d81200c39fb0d1032608b77724f34114db54f571ff1317b337c0" +checksum = "02339744ee7253741199f897151b38e72257d13802d4ee837285cc2990a90845" dependencies = [ - "num_enum_derive 0.7.1", + "num_enum_derive 0.7.2", ] [[package]] @@ -2342,14 +2386,14 @@ dependencies = [ [[package]] name = "num_enum_derive" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c11e44798ad209ccdd91fc192f0526a369a01234f7373e1b141c96d7cee4f0e" +checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" dependencies = [ - "proc-macro-crate 2.0.1", + "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] @@ -2456,6 +2500,12 @@ dependencies = [ "shared_library", ] +[[package]] +name = "outref" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f222829ae9293e33a9f5e9f440c6760a3d450a64affe1846486b140db81c1f4" + [[package]] name = "outref" version = "0.5.1" @@ -2533,22 +2583,22 @@ checksum = "5be167a7af36ee22fe3115051bc51f6e6c7054c9348e28deb4f49bd6f705a315" [[package]] name = "pin-project" -version = "1.1.3" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fda4ed1c6c173e3fc7a83629421152e01d7b1f9b7f65fb301e490e8cfc656422" +checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.3" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" +checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] @@ -2565,9 +2615,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2900ede94e305130c13ddd391e0ab7cbaeb783945ae07a279c268cb05109c6cb" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" [[package]] name = "player" @@ -2580,7 +2630,7 @@ dependencies = [ "serde", "wgpu-core", "wgpu-types", - "winit 0.29.10", + "winit 0.29.15", ] [[package]] @@ -2613,9 +2663,9 @@ dependencies = [ [[package]] name = "png" -version = "0.17.11" +version = "0.17.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f6c3c3e617595665b8ea2ff95a86066be38fb121ff920a9c0eb282abcd1da5a" +checksum = "06e4b0d3d1312775e782c86c91a111aa1f910cbb65e1337f9975b5f9a554b5e1" dependencies = [ "bitflags 1.3.2", "crc32fast", @@ -2626,9 +2676,9 @@ dependencies = [ [[package]] name = "polling" -version = "3.3.2" +version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "545c980a3880efd47b2e262f6a4bb6daad6555cf3367aa9c4e52895f69537a41" +checksum = "24f040dee2588b4963afb4e420540439d126f73fdacf4a9c486a96d840bac3c9" dependencies = [ "cfg-if", "concurrent-queue", @@ -2671,12 +2721,11 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "2.0.1" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97dc5fea232fc28d2f597b37c4876b348a40e33f3b02cc975c8d006d78d94b1a" +checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" dependencies = [ - "toml_datetime", - "toml_edit 0.20.2", + "toml_edit 0.21.1", ] [[package]] @@ -2687,7 +2736,7 @@ checksum = "07c277e4e643ef00c1233393c673f655e3672cf7eb3ba08a00bdd0ea59139b5f" dependencies = [ "proc-macro-rules-macros", "proc-macro2", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] @@ -2699,29 +2748,29 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] name = "proc-macro2" -version = "1.0.78" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" dependencies = [ "unicode-ident", ] [[package]] name = "profiling" -version = "1.0.13" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d135ede8821cf6376eb7a64148901e1690b788c11ae94dc297ae917dbc91dc0e" +checksum = "43d84d1d7a6ac92673717f9f6d1518374ef257669c24ebc5ac25d5033828be58" [[package]] name = "quick-xml" -version = "0.30.0" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eff6510e86862b57b210fd8cbe8ed3f0d7d600b9c2863cd4549a2e033c66e956" +checksum = "1004a344b30a54e2ee58d66a71b32d2db2feb0a31f9a2d302bf0536f15de2a33" dependencies = [ "memchr", ] @@ -2788,9 +2837,9 @@ checksum = "42a9830a0e1b9fb145ebb365b8bc4ccd75f290f98c0247deafbbe2c75cefb544" [[package]] name = "rayon" -version = "1.8.1" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa7237101a77a10773db45d62004a272517633fbcc3df19d96455ede1122e051" +checksum = "e4963ed1bc86e4f3ee217022bd855b297cef07fb9eac5dfa1f788b220b49b3bd" dependencies = [ "either", "rayon-core", @@ -2838,9 +2887,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.4" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b7fa1134405e2ec9353fd416b17f8dacd46c473d7d3fd1cf202706a14eb792a" +checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" dependencies = [ "aho-corasick", "memchr", @@ -2855,9 +2904,9 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "renderdoc-sys" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "216080ab382b992234dda86873c18d4c48358f5cfcb70fd693d7f6f2131b628b" +checksum = "19b30a45b0cd0bcca8037f3d0dc3421eaf95327a17cad11964fb8179b4fc4832" [[package]] name = "ron" @@ -2907,14 +2956,14 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver 1.0.21", + "semver 1.0.22", ] [[package]] name = "rustix" -version = "0.38.30" +version = "0.38.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "322394588aaf33c24007e8bb3238ee3e4c5c09c084ab32bc73890b99ff326bca" +checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" dependencies = [ "bitflags 2.4.2", "errno", @@ -2931,9 +2980,9 @@ checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" [[package]] name = "ryu" -version = "1.0.16" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" +checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" [[package]] name = "safe_arch" @@ -2985,9 +3034,9 @@ checksum = "82b2eaf3a5b264a521b988b2e73042e742df700c4f962cde845d1541adb46550" dependencies = [ "ab_glyph", "log", - "memmap2 0.9.3", - "smithay-client-toolkit 0.18.0", - "tiny-skia 0.11.3", + "memmap2 0.9.4", + "smithay-client-toolkit 0.18.1", + "tiny-skia 0.11.4", ] [[package]] @@ -3001,9 +3050,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.21" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0" +checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" [[package]] name = "semver-parser" @@ -3013,29 +3062,29 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.195" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.195" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c" +checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] name = "serde_json" -version = "1.0.111" +version = "1.0.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4" +checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" dependencies = [ "indexmap", "itoa", @@ -3045,12 +3094,11 @@ dependencies = [ [[package]] name = "serde_v8" -version = "0.141.0" +version = "0.181.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc689cb316d67b200e9f7449ce76cceb7e483e0f828d1a9c3d057c4367b6c26e" +checksum = "fd25bb66a20a1a405fb3733aaaf8a8a77a14fd55c8f5fd9db2a2e95bbd7eeab9" dependencies = [ "bytes", - "derive_more", "num-bigint", "serde", "smallvec", @@ -3098,6 +3146,15 @@ dependencies = [ "libc", ] +[[package]] +name = "simd-abstraction" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cadb29c57caadc51ff8346233b5cec1d240b68ce55cf1afc764818791876987" +dependencies = [ + "outref 0.1.0", +] + [[package]] name = "simd-adler32" version = "0.3.7" @@ -3149,26 +3206,26 @@ dependencies = [ [[package]] name = "smithay-client-toolkit" -version = "0.18.0" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60e3d9941fa3bacf7c2bf4b065304faa14164151254cd16ce1b1bc8fc381600f" +checksum = "922fd3eeab3bd820d76537ce8f582b1cf951eceb5475c28500c7457d9d17f53a" dependencies = [ "bitflags 2.4.2", - "calloop 0.12.3", + "calloop 0.12.4", "calloop-wayland-source", "cursor-icon", "libc", "log", - "memmap2 0.9.3", + "memmap2 0.9.4", "rustix", "thiserror", "wayland-backend", - "wayland-client 0.31.1", + "wayland-client 0.31.2", "wayland-csd-frame", - "wayland-cursor 0.31.0", - "wayland-protocols 0.31.0", + "wayland-cursor 0.31.1", + "wayland-protocols 0.31.2", "wayland-protocols-wlr", - "wayland-scanner 0.31.0", + "wayland-scanner 0.31.1", "xkeysym", ] @@ -3183,27 +3240,28 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.5" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" +checksum = "05ffd9c0a93b7543e062e759284fcf5f5e3b098501104bfbdde4d404db792871" dependencies = [ "libc", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "sourcemap" -version = "7.0.1" +version = "7.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10da010a590ed2fa9ca8467b00ce7e9c5a8017742c0c09c45450efc172208c4b" +checksum = "e7768edd06c02535e0d50653968f46e1e0d3aa54742190d35dd9466f59de9c71" dependencies = [ + "base64-simd 0.7.0", "data-encoding", "debugid", "if_chain", "rustc_version 0.2.3", "serde", "serde_json", - "unicode-id", + "unicode-id-start", "url", ] @@ -3252,6 +3310,12 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[package]] +name = "strsim" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" + [[package]] name = "strum" version = "0.25.0" @@ -3271,7 +3335,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] @@ -3287,9 +3351,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.48" +version = "2.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" dependencies = [ "proc-macro2", "quote", @@ -3307,22 +3371,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.56" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" +checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.56" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" +checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] @@ -3361,16 +3425,16 @@ dependencies = [ [[package]] name = "tiny-skia" -version = "0.11.3" +version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6a067b809476893fce6a254cf285850ff69c847e6cfbade6a20b655b6c7e80d" +checksum = "83d13394d44dae3207b52a326c0c85a8bf87f1541f23b0d143811088497b09ab" dependencies = [ "arrayref", "arrayvec 0.7.4", "bytemuck", "cfg-if", "log", - "tiny-skia-path 0.11.3", + "tiny-skia-path 0.11.4", ] [[package]] @@ -3385,9 +3449,9 @@ dependencies = [ [[package]] name = "tiny-skia-path" -version = "0.11.3" +version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5de35e8a90052baaaf61f171680ac2f8e925a1e43ea9d2e3a00514772250e541" +checksum = "9c9e7fc0c2e86a30b117d0462aa261b72b7a99b7ebd7deb3a14ceda95c5bdc93" dependencies = [ "arrayref", "bytemuck", @@ -3421,9 +3485,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.35.1" +version = "1.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c89b4efa943be685f629b149f53829423f8f5531ea21249408e8e2f8671ec104" +checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931" dependencies = [ "backtrace", "bytes", @@ -3446,14 +3510,14 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] name = "toml_datetime" -version = "0.6.3" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" [[package]] name = "toml_edit" @@ -3468,9 +3532,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.20.2" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" +checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" dependencies = [ "indexmap", "toml_datetime", @@ -3547,10 +3611,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" [[package]] -name = "unicode-id" -version = "0.3.4" +name = "unicode-id-start" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1b6def86329695390197b82c1e244a54a131ceb66c996f2088a3876e2ae083f" +checksum = "b8f73150333cb58412db36f2aca8f2875b013049705cc77b94ded70a1ab1f5da" [[package]] name = "unicode-ident" @@ -3560,18 +3624,18 @@ checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-normalization" -version = "0.1.22" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" dependencies = [ "tinyvec", ] [[package]] name = "unicode-segmentation" -version = "1.10.1" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" +checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" [[package]] name = "unicode-width" @@ -3628,12 +3692,15 @@ dependencies = [ [[package]] name = "v8" -version = "0.81.0" +version = "0.89.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b75f5f378b9b54aff3b10da8170d26af4cfd217f644cf671badcd13af5db4beb" +checksum = "fe2197fbef82c98f7953d13568a961d4e1c663793b5caf3c74455a13918cdf33" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.4.2", "fslock", + "gzip-header", + "home", + "miniz_oxide", "once_cell", "which", ] @@ -3658,9 +3725,9 @@ checksum = "5c3082ca00d5a5ef149bb8b555a72ae84c9c59f7250f013ac822ac2e49b19c64" [[package]] name = "walkdir" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" dependencies = [ "same-file", "winapi-util", @@ -3674,9 +3741,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.90" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1223296a201415c7fad14792dbefaace9bd52b62d33453ade1c5b5f07555406" +checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -3684,24 +3751,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.90" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcdc935b63408d58a32f8cc9738a0bffd8f05cc7c002086c6ef20b7312ad9dcd" +checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.40" +version = "0.4.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bde2032aeb86bdfaecc8b261eef3cba735cc426c1f3a3416d1e0791be95fc461" +checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" dependencies = [ "cfg-if", "js-sys", @@ -3711,9 +3778,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.90" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e4c238561b2d428924c49815533a8b9121c664599558a5d9ec51f8a1740a999" +checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3721,28 +3788,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.90" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7" +checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.90" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b" +checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" [[package]] name = "wasm-bindgen-test" -version = "0.3.40" +version = "0.3.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "139bd73305d50e1c1c4333210c0db43d989395b64a237bd35c10ef3832a7f70c" +checksum = "d9bf62a58e0780af3e852044583deee40983e5886da43a271dd772379987667b" dependencies = [ "console_error_panic_hook", "js-sys", @@ -3754,24 +3821,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-test-macro" -version = "0.3.40" +version = "0.3.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70072aebfe5da66d2716002c729a14e4aec4da0e23cc2ea66323dac541c93928" +checksum = "b7f89739351a2e03cb94beb799d47fb2cac01759b40ec441f7de39b00cbf7ef0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] name = "wayland-backend" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19152ddd73f45f024ed4534d9ca2594e0ef252c1847695255dae47f34df9fbe4" +checksum = "9d50fa61ce90d76474c87f5fc002828d81b32677340112b4ef08079a9d459a40" dependencies = [ "cc", "downcast-rs", - "nix 0.26.4", + "rustix", "scoped-tls", "smallvec", "wayland-sys 0.31.1", @@ -3795,14 +3862,14 @@ dependencies = [ [[package]] name = "wayland-client" -version = "0.31.1" +version = "0.31.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ca7d52347346f5473bf2f56705f360e8440873052e575e55890c4fa57843ed3" +checksum = "82fb96ee935c2cea6668ccb470fb7771f6215d1691746c2d896b447a00ad3f1f" dependencies = [ "bitflags 2.4.2", - "nix 0.26.4", + "rustix", "wayland-backend", - "wayland-scanner 0.31.0", + "wayland-scanner 0.31.1", ] [[package]] @@ -3841,12 +3908,12 @@ dependencies = [ [[package]] name = "wayland-cursor" -version = "0.31.0" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44aa20ae986659d6c77d64d808a046996a932aa763913864dc40c359ef7ad5b" +checksum = "71ce5fa868dd13d11a0d04c5e2e65726d0897be8de247c0c5a65886e283231ba" dependencies = [ - "nix 0.26.4", - "wayland-client 0.31.1", + "rustix", + "wayland-client 0.31.2", "xcursor", ] @@ -3874,14 +3941,14 @@ dependencies = [ [[package]] name = "wayland-protocols" -version = "0.31.0" +version = "0.31.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e253d7107ba913923dc253967f35e8561a3c65f914543e46843c88ddd729e21c" +checksum = "8f81f365b8b4a97f422ac0e8737c438024b5951734506b0e1d775c73030561f4" dependencies = [ "bitflags 2.4.2", "wayland-backend", - "wayland-client 0.31.1", - "wayland-scanner 0.31.0", + "wayland-client 0.31.2", + "wayland-scanner 0.31.1", ] [[package]] @@ -3892,9 +3959,9 @@ checksum = "23803551115ff9ea9bce586860c5c5a971e360825a0309264102a9495a5ff479" dependencies = [ "bitflags 2.4.2", "wayland-backend", - "wayland-client 0.31.1", - "wayland-protocols 0.31.0", - "wayland-scanner 0.31.0", + "wayland-client 0.31.2", + "wayland-protocols 0.31.2", + "wayland-scanner 0.31.1", ] [[package]] @@ -3905,9 +3972,9 @@ checksum = "ad1f61b76b6c2d8742e10f9ba5c3737f6530b4c243132c2a2ccc8aa96fe25cd6" dependencies = [ "bitflags 2.4.2", "wayland-backend", - "wayland-client 0.31.1", - "wayland-protocols 0.31.0", - "wayland-scanner 0.31.0", + "wayland-client 0.31.2", + "wayland-protocols 0.31.2", + "wayland-scanner 0.31.1", ] [[package]] @@ -3923,9 +3990,9 @@ dependencies = [ [[package]] name = "wayland-scanner" -version = "0.31.0" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb8e28403665c9f9513202b7e1ed71ec56fde5c107816843fb14057910b2c09c" +checksum = "63b3a62929287001986fb58c789dce9b67604a397c15c611ad9f747300b6c283" dependencies = [ "proc-macro2", "quick-xml", @@ -3957,9 +4024,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.67" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58cd2333b6e0be7a39605f0e255892fd7418a682d8da8fe042fe25128794d2ed" +checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" dependencies = [ "js-sys", "wasm-bindgen", @@ -4058,7 +4125,7 @@ dependencies = [ "wgpu", "wgpu-hal", "wgpu-test", - "winit 0.29.10", + "winit 0.29.15", ] [[package]] @@ -4087,10 +4154,11 @@ dependencies = [ "js-sys", "khronos-egl", "libc", - "libloading 0.8.1", + "libloading 0.8.3", "log", "metal", "naga", + "ndk-sys 0.5.0+25.2.9519653", "objc", "once_cell", "parking_lot", @@ -4105,7 +4173,7 @@ dependencies = [ "web-sys", "wgpu-types", "winapi", - "winit 0.29.10", + "winit 0.29.15", ] [[package]] @@ -4128,7 +4196,7 @@ version = "0.19.0" dependencies = [ "heck", "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] @@ -4180,14 +4248,15 @@ dependencies = [ [[package]] name = "which" -version = "4.4.2" +version = "5.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +checksum = "9bf3ea8596f3a0dd5980b46430f2058dfe2c36a27ccfbb1845d6fbfcd9ba6e14" dependencies = [ "either", "home", "once_cell", "rustix", + "windows-sys 0.48.0", ] [[package]] @@ -4234,7 +4303,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e48a53791691ab099e5e2ad123536d0fff50652600abaf43bbf952894110d0be" dependencies = [ "windows-core", - "windows-targets 0.52.0", + "windows-targets 0.52.4", ] [[package]] @@ -4243,7 +4312,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.52.0", + "windows-targets 0.52.4", ] [[package]] @@ -4283,7 +4352,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.0", + "windows-targets 0.52.4", ] [[package]] @@ -4318,17 +4387,17 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" dependencies = [ - "windows_aarch64_gnullvm 0.52.0", - "windows_aarch64_msvc 0.52.0", - "windows_i686_gnu 0.52.0", - "windows_i686_msvc 0.52.0", - "windows_x86_64_gnu 0.52.0", - "windows_x86_64_gnullvm 0.52.0", - "windows_x86_64_msvc 0.52.0", + "windows_aarch64_gnullvm 0.52.4", + "windows_aarch64_msvc 0.52.4", + "windows_i686_gnu 0.52.4", + "windows_i686_msvc 0.52.4", + "windows_x86_64_gnu 0.52.4", + "windows_x86_64_gnullvm 0.52.4", + "windows_x86_64_msvc 0.52.4", ] [[package]] @@ -4345,9 +4414,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" +checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" [[package]] name = "windows_aarch64_msvc" @@ -4369,9 +4438,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" +checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" [[package]] name = "windows_i686_gnu" @@ -4393,9 +4462,9 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" +checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" [[package]] name = "windows_i686_msvc" @@ -4417,9 +4486,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" +checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" [[package]] name = "windows_x86_64_gnu" @@ -4441,9 +4510,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" +checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" [[package]] name = "windows_x86_64_gnullvm" @@ -4459,9 +4528,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" +checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" [[package]] name = "windows_x86_64_msvc" @@ -4483,9 +4552,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" +checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" [[package]] name = "winit" @@ -4522,16 +4591,16 @@ dependencies = [ [[package]] name = "winit" -version = "0.29.10" +version = "0.29.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c824f11941eeae66ec71111cc2674373c772f482b58939bb4066b642aa2ffcf" +checksum = "0d59ad965a635657faf09c8f062badd885748428933dad8e8bdd64064d92e5ca" dependencies = [ "ahash", "android-activity", "atomic-waker", "bitflags 2.4.2", "bytemuck", - "calloop 0.12.3", + "calloop 0.12.4", "cfg_aliases", "core-foundation", "core-graphics 0.23.1", @@ -4540,7 +4609,7 @@ dependencies = [ "js-sys", "libc", "log", - "memmap2 0.9.3", + "memmap2 0.9.4", "ndk 0.8.0", "ndk-sys 0.5.0+25.2.9519653", "objc2", @@ -4551,14 +4620,14 @@ dependencies = [ "redox_syscall 0.3.5", "rustix", "sctk-adwaita 0.8.1", - "smithay-client-toolkit 0.18.0", + "smithay-client-toolkit 0.18.1", "smol_str", "unicode-segmentation", "wasm-bindgen", "wasm-bindgen-futures", "wayland-backend", - "wayland-client 0.31.1", - "wayland-protocols 0.31.0", + "wayland-client 0.31.2", + "wayland-protocols 0.31.2", "wayland-protocols-plasma", "web-sys", "web-time", @@ -4570,9 +4639,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.5.34" +version = "0.5.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7cf47b659b318dccbd69cc4797a39ae128f533dce7902a1096044d1967b9c16" +checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" dependencies = [ "memchr", ] @@ -4606,7 +4675,7 @@ dependencies = [ "as-raw-xcb-connection", "gethostname", "libc", - "libloading 0.8.1", + "libloading 0.8.3", "once_cell", "rustix", "x11rb-protocol", @@ -4626,9 +4695,9 @@ checksum = "6a0ccd7b4a5345edfcd0c3535718a4e9ff7798ffc536bb5b5a0e26ff84732911" [[package]] name = "xkbcommon-dl" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6924668544c48c0133152e7eec86d644a056ca3d09275eb8d5cdb9855f9d8699" +checksum = "d039de8032a9a8856a6be89cea3e5d12fdd82306ab7c94d74e6deab2460651c5" dependencies = [ "bitflags 2.4.2", "dlib", @@ -4666,5 +4735,5 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", ] diff --git a/Cargo.toml b/Cargo.toml index 3dc6dfb6f3..52e8c5c176 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,7 +40,7 @@ default-members = [ [workspace.package] edition = "2021" -rust-version = "1.70" +rust-version = "1.74" keywords = ["graphics"] license = "MIT OR Apache-2.0" homepage = "https://wgpu.rs/" @@ -79,7 +79,7 @@ codespan-reporting = "0.11" ctor = "0.2" document-features = "0.2.8" encase = "0.7" -env_logger = "0.10" +env_logger = "0.11" fern = "0.6" flume = "0.11" futures-lite = "2" @@ -110,11 +110,11 @@ png = "0.17.11" pollster = "0.3" profiling = { version = "1", default-features = false } raw-window-handle = "0.6" -renderdoc-sys = "1.0.0" +renderdoc-sys = "1.1.0" ron = "0.8" rustc-hash = "1.1.0" serde = "1" -serde_json = "1.0.111" +serde_json = "1.0.113" smallvec = "1" static_assertions = "1.1.0" thiserror = "1" @@ -157,21 +157,21 @@ glutin = "0.29.1" # wasm32 dependencies console_error_panic_hook = "0.1.7" console_log = "1" -js-sys = "0.3.67" +js-sys = "0.3.69" wasm-bindgen = "0.2.87" -wasm-bindgen-futures = "0.4.40" +wasm-bindgen-futures = "0.4.42" wasm-bindgen-test = "0.3" -web-sys = "0.3.67" +web-sys = "0.3.69" web-time = "0.2.4" # deno dependencies -deno_console = "0.125.0" -deno_core = "0.232.0" -deno_url = "0.125.0" -deno_web = "0.156.0" -deno_webidl = "0.125.0" -deno_webgpu = { version = "0.85.0", path = "./deno_webgpu" } -tokio = "1.35.1" +deno_console = "0.143.0" +deno_core = "0.272.0" +deno_url = "0.143.0" +deno_web = "0.174.0" +deno_webidl = "0.143.0" +deno_webgpu = { version = "0.110.0", path = "./deno_webgpu" } +tokio = "1.36.0" termcolor = "1.4.1" [patch."https://github.com/gfx-rs/naga"] diff --git a/README.md b/README.md index 4dbcd243ef..bc0f01b302 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ We have a [wiki](https://github.com/gfx-rs/wgpu/wiki) that serves as a knowledge :ok: = Downlevel/Best Effort Support :triangular_ruler: = Requires the [ANGLE](#angle) translation layer (GL ES 3.0 only) :volcano: = Requires the [MoltenVK](https://vulkan.lunarg.com/sdk/home#mac) translation layer -:hammer_and_wrench: = Unsupported, though open to contributions +:hammer_and_wrench: = Unsupported, though open to contributions ### Shader Support @@ -119,8 +119,9 @@ On Linux, you can point to them using `LD_LIBRARY_PATH` environment. ### MSRV policy Due to complex dependants, we have two MSRV policies: - - `d3d12`, `naga`, `wgpu-core`, `wgpu-hal`, and `wgpu-types`'s MSRV is **1.70**. - - The rest of the workspace has an MSRV of **1.71**. + +- `d3d12`, `naga`, `wgpu-core`, `wgpu-hal`, and `wgpu-types`'s MSRV is **1.74**. +- The rest of the workspace has an MSRV of **1.76**. It is enforced on CI (in "/.github/workflows/ci.yml") with the `CORE_MSRV` and `REPO_MSRV` variables. This version can only be upgraded in breaking releases, though we release a breaking version every three months. diff --git a/cts_runner/src/bootstrap.js b/cts_runner/src/bootstrap.js index 640075e7ee..5d9c6f65da 100644 --- a/cts_runner/src/bootstrap.js +++ b/cts_runner/src/bootstrap.js @@ -5,8 +5,7 @@ // delete Object.prototype.__proto__; -const core = Deno.core; -const primordials = globalThis.__bootstrap.primordials; +import { core, primordials } from "ext:core/mod.js"; const { Error, ObjectDefineProperty, @@ -25,9 +24,11 @@ import * as base64 from "ext:deno_web/05_base64.js"; import * as encoding from "ext:deno_web/08_text_encoding.js"; import { Console } from "ext:deno_console/01_console.js"; import * as url from "ext:deno_url/00_url.js"; -import DOMException from "ext:deno_web/01_dom_exception.js"; +import { DOMException } from "ext:deno_web/01_dom_exception.js"; import * as performance from "ext:deno_web/15_performance.js"; -import * as webgpu from "ext:deno_webgpu/01_webgpu.js"; +import { loadWebGPU } from "ext:deno_webgpu/00_init.js"; +import * as imageData from "ext:deno_web/16_image_data.js"; +const webgpu = loadWebGPU(); // imports needed to pass module evaluation import "ext:deno_url/01_urlpattern.js"; @@ -39,11 +40,10 @@ import "ext:deno_web/10_filereader.js"; import "ext:deno_web/12_location.js"; import "ext:deno_web/13_message_port.js"; import "ext:deno_web/14_compression.js"; +import "ext:deno_webgpu/02_surface.js"; let globalThis_; -const { BadResource, Interrupted } = core; - class NotFound extends Error { constructor(msg) { super(msg); @@ -183,6 +183,7 @@ const windowOrWorkerGlobalScope = { clearInterval: util.writable(timers.clearInterval), clearTimeout: util.writable(timers.clearTimeout), performance: util.writable(performance.performance), + ImageData: core.propNonEnumerable(imageData.ImageData), GPU: util.nonEnumerable(webgpu.GPU), GPUAdapter: util.nonEnumerable(webgpu.GPUAdapter), @@ -248,10 +249,8 @@ core.registerErrorClass("NotFound", NotFound); core.registerErrorClass("AlreadyExists", AlreadyExists); core.registerErrorClass("InvalidData", InvalidData); core.registerErrorClass("TimedOut", TimedOut); -core.registerErrorClass("Interrupted", Interrupted); core.registerErrorClass("WriteZero", WriteZero); core.registerErrorClass("UnexpectedEof", UnexpectedEof); -core.registerErrorClass("BadResource", BadResource); core.registerErrorClass("NotSupported", NotSupported); core.registerErrorBuilder( "DOMExceptionOperationError", diff --git a/cts_runner/src/main.rs b/cts_runner/src/main.rs index 700fe3b3ef..fe8c1cf818 100644 --- a/cts_runner/src/main.rs +++ b/cts_runner/src/main.rs @@ -29,6 +29,9 @@ mod native { .ok_or_else(|| anyhow!("missing specifier in first command line argument"))?; let specifier = resolve_url_or_path(&url, &env::current_dir()?)?; + let mut feature_checker = deno_core::FeatureChecker::default(); + feature_checker.enable_feature(deno_webgpu::UNSTABLE_FEATURE_NAME); + let options = RuntimeOptions { module_loader: Some(Rc::new(deno_core::FsModuleLoader)), get_error_class_fn: Some(&get_error_class_name), @@ -40,18 +43,19 @@ mod native { Arc::new(BlobStore::default()), None, ), - deno_webgpu::deno_webgpu::init_ops_and_esm(true), + deno_webgpu::deno_webgpu::init_ops_and_esm(), cts_runner::init_ops_and_esm(), ], + feature_checker: Some(Arc::new(feature_checker)), ..Default::default() }; - let mut isolate = JsRuntime::new(options); + let mut js_runtime = JsRuntime::new(options); let args = args_iter.collect::>(); let cfg = json!({"args": args, "cwd": env::current_dir().unwrap().to_string_lossy() }); { - let context = isolate.main_context(); - let scope = &mut isolate.handle_scope(); + let context = js_runtime.main_context(); + let scope = &mut js_runtime.handle_scope(); let context_local = v8::Local::new(scope, context); let global_obj = context_local.global(scope); let bootstrap_str = v8::String::new(scope, "bootstrap").unwrap(); @@ -65,20 +69,12 @@ mod native { .unwrap(); } - isolate.op_state().borrow_mut().put(Permissions {}); - - let mod_id = isolate.load_main_module(&specifier, None).await?; - let mod_rx = isolate.mod_evaluate(mod_id); - - let rx = tokio::spawn(async move { - match mod_rx.await { - Ok(err @ Err(_)) => err, - _ => Ok(()), - } - }); + js_runtime.op_state().borrow_mut().put(Permissions {}); - isolate.run_event_loop(false).await?; - rx.await.unwrap()?; + let mod_id = js_runtime.load_main_es_module(&specifier).await?; + let result = js_runtime.mod_evaluate(mod_id); + js_runtime.run_event_loop(Default::default()).await?; + result.await?; Ok(()) } @@ -87,7 +83,7 @@ mod native { cts_runner, deps = [deno_webidl, deno_web], ops = [op_exit, op_read_file_sync, op_write_file_sync], - esm_entry_point = "ext:cts_runner/bootstrap.js", + esm_entry_point = "ext:cts_runner/src/bootstrap.js", esm = ["src/bootstrap.js"], ); @@ -118,13 +114,7 @@ mod native { deno_core::error::get_custom_error_class(e) .or_else(|| deno_webgpu::error::get_error_class_name(e)) .unwrap_or_else(|| { - panic!( - "Error '{}' contains boxed error of unsupported type:{}", - e, - e.chain() - .map(|e| format!("\n {:?}", e)) - .collect::() - ); + panic!("Error '{e}' contains boxed error of unsupported type: {e:#}"); }) } diff --git a/d3d12/Cargo.toml b/d3d12/Cargo.toml index 10c68eab77..44f5dc35e2 100644 --- a/d3d12/Cargo.toml +++ b/d3d12/Cargo.toml @@ -21,7 +21,7 @@ implicit-link = [] [target.'cfg(windows)'.dependencies] bitflags = "2" # libloading 0.8 switches from `winapi` to `windows-sys`; permit either -libloading = { version = ">=0.7,<0.9", optional = true } +libloading = { version = ">=0.7, <0.9", optional = true } [target.'cfg(windows)'.dependencies.winapi] version = "0.3" diff --git a/deno_webgpu/00_init.js b/deno_webgpu/00_init.js new file mode 100644 index 0000000000..0f10847cef --- /dev/null +++ b/deno_webgpu/00_init.js @@ -0,0 +1,7 @@ +// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. + +import { core } from "ext:core/mod.js"; + +const loadWebGPU = core.createLazyLoader("ext:deno_webgpu/01_webgpu.js"); + +export { loadWebGPU }; diff --git a/deno_webgpu/01_webgpu.js b/deno_webgpu/01_webgpu.js index d7a88ad445..f1916e81ee 100644 --- a/deno_webgpu/01_webgpu.js +++ b/deno_webgpu/01_webgpu.js @@ -1,4 +1,4 @@ -// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. +// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // @ts-check /// @@ -6,24 +6,101 @@ /// /// -const core = globalThis.Deno.core; -const ops = core.ops; -const primordials = globalThis.__bootstrap.primordials; -import * as webidl from "ext:deno_webidl/00_webidl.js"; -import { EventTarget } from "ext:deno_web/02_event.js"; -import DOMException from "ext:deno_web/01_dom_exception.js"; -import { createFilteredInspectProxy } from "ext:deno_console/01_console.js"; +import { core, primordials } from "ext:core/mod.js"; +const { + isDataView, + isTypedArray, +} = core; +import { + op_webgpu_buffer_get_map_async, + op_webgpu_buffer_get_mapped_range, + op_webgpu_buffer_unmap, + op_webgpu_command_encoder_begin_compute_pass, + op_webgpu_command_encoder_begin_render_pass, + op_webgpu_command_encoder_clear_buffer, + op_webgpu_command_encoder_copy_buffer_to_buffer, + op_webgpu_command_encoder_copy_buffer_to_texture, + op_webgpu_command_encoder_copy_texture_to_buffer, + op_webgpu_command_encoder_copy_texture_to_texture, + op_webgpu_command_encoder_finish, + op_webgpu_command_encoder_insert_debug_marker, + op_webgpu_command_encoder_pop_debug_group, + op_webgpu_command_encoder_push_debug_group, + op_webgpu_command_encoder_resolve_query_set, + op_webgpu_command_encoder_write_timestamp, + op_webgpu_compute_pass_dispatch_workgroups, + op_webgpu_compute_pass_dispatch_workgroups_indirect, + op_webgpu_compute_pass_end, + op_webgpu_compute_pass_insert_debug_marker, + op_webgpu_compute_pass_pop_debug_group, + op_webgpu_compute_pass_push_debug_group, + op_webgpu_compute_pass_set_bind_group, + op_webgpu_compute_pass_set_pipeline, + op_webgpu_compute_pipeline_get_bind_group_layout, + op_webgpu_create_bind_group, + op_webgpu_create_bind_group_layout, + op_webgpu_create_buffer, + op_webgpu_create_command_encoder, + op_webgpu_create_compute_pipeline, + op_webgpu_create_pipeline_layout, + op_webgpu_create_query_set, + op_webgpu_create_render_bundle_encoder, + op_webgpu_create_render_pipeline, + op_webgpu_create_sampler, + op_webgpu_create_shader_module, + op_webgpu_create_texture, + op_webgpu_create_texture_view, + op_webgpu_queue_submit, + op_webgpu_render_bundle_encoder_draw, + op_webgpu_render_bundle_encoder_draw_indexed, + op_webgpu_render_bundle_encoder_draw_indirect, + op_webgpu_render_bundle_encoder_finish, + op_webgpu_render_bundle_encoder_insert_debug_marker, + op_webgpu_render_bundle_encoder_pop_debug_group, + op_webgpu_render_bundle_encoder_push_debug_group, + op_webgpu_render_bundle_encoder_set_bind_group, + op_webgpu_render_bundle_encoder_set_index_buffer, + op_webgpu_render_bundle_encoder_set_pipeline, + op_webgpu_render_bundle_encoder_set_vertex_buffer, + op_webgpu_render_pass_begin_occlusion_query, + op_webgpu_render_pass_draw, + op_webgpu_render_pass_draw_indexed, + op_webgpu_render_pass_draw_indexed_indirect, + op_webgpu_render_pass_draw_indirect, + op_webgpu_render_pass_end, + op_webgpu_render_pass_end_occlusion_query, + op_webgpu_render_pass_execute_bundles, + op_webgpu_render_pass_insert_debug_marker, + op_webgpu_render_pass_pop_debug_group, + op_webgpu_render_pass_push_debug_group, + op_webgpu_render_pass_set_bind_group, + op_webgpu_render_pass_set_blend_constant, + op_webgpu_render_pass_set_index_buffer, + op_webgpu_render_pass_set_pipeline, + op_webgpu_render_pass_set_scissor_rect, + op_webgpu_render_pass_set_stencil_reference, + op_webgpu_render_pass_set_vertex_buffer, + op_webgpu_render_pass_set_viewport, + op_webgpu_render_pipeline_get_bind_group_layout, + op_webgpu_request_adapter, + op_webgpu_request_adapter_info, + op_webgpu_request_device, + op_webgpu_write_buffer, + op_webgpu_write_texture, +} from "ext:core/ops"; const { ArrayBuffer, - ArrayBufferIsView, + ArrayBufferPrototypeGetByteLength, ArrayIsArray, ArrayPrototypeFilter, ArrayPrototypeMap, ArrayPrototypePop, ArrayPrototypePush, + DataViewPrototypeGetBuffer, Error, MathMax, ObjectDefineProperty, + ObjectHasOwn, ObjectPrototypeIsPrototypeOf, Promise, PromisePrototypeCatch, @@ -32,17 +109,28 @@ const { PromiseResolve, SafeArrayIterator, SafePromiseAll, - Set, + SafeSet, + SafeWeakRef, SetPrototypeHas, Symbol, SymbolFor, SymbolIterator, TypeError, + TypedArrayPrototypeGetBuffer, + TypedArrayPrototypeGetSymbolToStringTag, Uint32Array, - Uint32ArrayPrototype, Uint8Array, } = primordials; +import * as webidl from "ext:deno_webidl/00_webidl.js"; +import { + Event, + EventTarget, + defineEventHandler, +} from "ext:deno_web/02_event.js"; +import { DOMException } from "ext:deno_web/01_dom_exception.js"; +import { createFilteredInspectProxy } from "ext:deno_console/01_console.js"; + const _rid = Symbol("[[rid]]"); const _size = Symbol("[[size]]"); const _usage = Symbol("[[usage]]"); @@ -229,6 +317,42 @@ class GPUOutOfMemoryError extends GPUError { } const GPUOutOfMemoryErrorPrototype = GPUOutOfMemoryError.prototype; +class GPUInternalError extends GPUError { + name = "GPUInternalError"; + constructor() { + super(illegalConstructorKey); + this[webidl.brand] = webidl.brand; + } +} +const GPUInternalErrorPrototype = GPUInternalError.prototype; + +class GPUUncapturedErrorEvent extends Event { + #error; + + constructor(type, gpuUncapturedErrorEventInitDict) { + super(type, gpuUncapturedErrorEventInitDict); + this[webidl.brand] = webidl.brand; + + const prefix = "Failed to construct 'GPUUncapturedErrorEvent'"; + webidl.requiredArguments(arguments.length, 2, prefix); + gpuUncapturedErrorEventInitDict = webidl.converters + .gpuUncapturedErrorEventInitDict( + gpuUncapturedErrorEventInitDict, + prefix, + "Argument 2", + ); + + this.#error = gpuUncapturedErrorEventInitDict.error; + } + + get error() { + webidl.assertBranded(this, GPUUncapturedErrorEventPrototype); + return this.#error; + } +} +const GPUUncapturedErrorEventPrototype = GPUUncapturedErrorEvent.prototype; +defineEventHandler(GPUUncapturedErrorEvent.prototype, "uncapturederror"); + class GPU { [webidl.brand] = webidl.brand; @@ -239,6 +363,7 @@ class GPU { /** * @param {GPURequestAdapterOptions} options */ + // deno-lint-ignore require-await async requestAdapter(options = {}) { webidl.assertBranded(this, GPUPrototype); options = webidl.converters.GPURequestAdapterOptions( @@ -247,8 +372,7 @@ class GPU { "Argument 1", ); - const { err, ...data } = await core.opAsync( - "op_webgpu_request_adapter", + const { err, ...data } = op_webgpu_request_adapter( options.powerPreference, options.forceFallbackAdapter, ); @@ -260,6 +384,16 @@ class GPU { } } + getPreferredCanvasFormat() { + // Same as Gecko. + // + // https://github.com/mozilla/gecko-dev/blob/b75080bb8b11844d18cb5f9ac6e68a866ef8e243/dom/webgpu/Instance.h#L42-L47 + if (core.build.os == "android") { + return "rgba8unorm"; + } + return "bgra8unorm"; + } + [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { return `${this.constructor.name} ${inspect({}, inspectOptions)}`; } @@ -305,7 +439,6 @@ class GPUAdapter { } /** @returns {boolean} */ get isFallbackAdapter() { - webidl.assertBranded(this, GPUAdapterPrototype); webidl.assertBranded(this, GPUAdapterPrototype); return this[_adapter].isFallbackAdapter; } @@ -318,6 +451,7 @@ class GPUAdapter { * @param {GPUDeviceDescriptor} descriptor * @returns {Promise} */ + // deno-lint-ignore require-await async requestDevice(descriptor = {}) { webidl.assertBranded(this, GPUAdapterPrototype); const prefix = "Failed to execute 'requestDevice' on 'GPUAdapter'"; @@ -338,8 +472,7 @@ class GPUAdapter { } } - const { rid, features, limits } = await core.opAsync( - "op_webgpu_request_device", + const { rid, queueRid, features, limits } = op_webgpu_request_device( this[_adapter].rid, descriptor.label, requiredFeatures, @@ -352,46 +485,34 @@ class GPUAdapter { features: createGPUSupportedFeatures(features), limits: createGPUSupportedLimits(limits), }); - return createGPUDevice( + const device = createGPUDevice( descriptor.label, inner, - createGPUQueue(descriptor.label, inner), + createGPUQueue(descriptor.label, inner, queueRid), ); + inner.device = device; + return device; } /** - * @param {string[]} unmaskHints * @returns {Promise} */ - async requestAdapterInfo(unmaskHints = []) { + requestAdapterInfo() { webidl.assertBranded(this, GPUAdapterPrototype); - const prefix = "Failed to execute 'requestAdapterInfo' on 'GPUAdapter'"; - unmaskHints = webidl.converters["sequence"]( - unmaskHints, - prefix, - "Argument 1", - ); const { vendor, architecture, device, description, - } = await core.opAsync( - "op_webgpu_request_adapter_info", - this[_adapter].rid, - ); + } = op_webgpu_request_adapter_info(this[_adapter].rid); const adapterInfo = webidl.createBranded(GPUAdapterInfo); - adapterInfo[_vendor] = unmaskHints.includes("vendor") ? vendor : ""; - adapterInfo[_architecture] = unmaskHints.includes("architecture") - ? architecture - : ""; - adapterInfo[_device] = unmaskHints.includes("device") ? device : ""; - adapterInfo[_description] = unmaskHints.includes("description") - ? description - : ""; - return adapterInfo; + adapterInfo[_vendor] = vendor; + adapterInfo[_architecture] = architecture; + adapterInfo[_device] = device; + adapterInfo[_description] = description; + return PromiseResolve(adapterInfo); } [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { @@ -594,6 +715,14 @@ class GPUSupportedLimits { webidl.assertBranded(this, GPUSupportedLimitsPrototype); return this[_limits].maxInterStageShaderComponents; } + get maxColorAttachments() { + webidl.assertBranded(this, GPUSupportedLimitsPrototype); + return this[_limits].maxColorAttachments; + } + get maxColorAttachmentBytesPerSample() { + webidl.assertBranded(this, GPUSupportedLimitsPrototype); + return this[_limits].maxColorAttachmentBytesPerSample; + } get maxComputeWorkgroupStorageSize() { webidl.assertBranded(this, GPUSupportedLimitsPrototype); return this[_limits].maxComputeWorkgroupStorageSize; @@ -623,7 +752,10 @@ class GPUSupportedLimits { return inspect( createFilteredInspectProxy({ object: this, - evaluate: ObjectPrototypeIsPrototypeOf(GPUSupportedLimitsPrototype, this), + evaluate: ObjectPrototypeIsPrototypeOf( + GPUSupportedLimitsPrototype, + this, + ), keys: [ "maxTextureDimension1D", "maxTextureDimension2D", @@ -647,6 +779,8 @@ class GPUSupportedLimits { "maxVertexAttributes", "maxVertexBufferArrayStride", "maxInterStageShaderComponents", + "maxColorAttachments", + "maxColorAttachmentBytesPerSample", "maxComputeWorkgroupStorageSize", "maxComputeInvocationsPerWorkgroup", "maxComputeWorkgroupSizeX", @@ -664,7 +798,7 @@ const GPUSupportedLimitsPrototype = GPUSupportedLimits.prototype; function createGPUSupportedFeatures(features) { /** @type {GPUSupportedFeatures} */ const supportedFeatures = webidl.createBranded(GPUSupportedFeatures); - supportedFeatures[webidl.setlikeInner] = new Set(features); + supportedFeatures[webidl.setlikeInner] = new SafeSet(features); webidl.setlike( supportedFeatures, GPUSupportedFeaturesPrototype, @@ -677,33 +811,33 @@ class GPUSupportedFeatures { constructor() { webidl.illegalConstructor(); } + [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { if (ObjectPrototypeIsPrototypeOf(GPUSupportedFeaturesPrototype, this)) { return `${this.constructor.name} ${ // deno-lint-ignore prefer-primordials - inspect([...this], inspectOptions) - }`; + inspect([...this], inspectOptions)}`; } else { return `${this.constructor.name} ${inspect({}, inspectOptions)}`; } } +} +const GPUSupportedFeaturesPrototype = GPUSupportedFeatures.prototype; - const GPUSupportedFeaturesPrototype = GPUSupportedFeatures.prototype; - - /** - * @param {string | undefined} reason - * @param {string} message - * @returns {GPUDeviceLostInfo} - */ - function createGPUDeviceLostInfo(reason, message) { - /** @type {GPUDeviceLostInfo} */ - const deviceLostInfo = webidl.createBranded(GPUDeviceLostInfo); - deviceLostInfo[_reason] = reason ?? "unknown"; - deviceLostInfo[_message] = message; - return deviceLostInfo; - } +/** + * @param {string | undefined} reason + * @param {string} message + * @returns {GPUDeviceLostInfo} + */ +function createGPUDeviceLostInfo(reason, message) { + /** @type {GPUDeviceLostInfo} */ + const deviceLostInfo = webidl.createBranded(GPUDeviceLostInfo); + deviceLostInfo[_reason] = reason ?? "unknown"; + deviceLostInfo[_message] = message; + return deviceLostInfo; +} - class GPUDeviceLostInfo { +class GPUDeviceLostInfo { /** @type {string} */ [_reason]; /** @type {string} */ @@ -726,7 +860,10 @@ class GPUSupportedFeatures { return inspect( createFilteredInspectProxy({ object: this, - evaluate: ObjectPrototypeIsPrototypeOf(GPUDeviceLostInfoPrototype, this), + evaluate: ObjectPrototypeIsPrototypeOf( + GPUDeviceLostInfoPrototype, + this, + ), keys: [ "reason", "message", @@ -780,6 +917,7 @@ function GPUObjectBaseMixin(name, type) { * @property {number | undefined} rid * @property {GPUSupportedFeatures} features * @property {GPUSupportedLimits} limits + * @property {GPUDevice} device */ class InnerGPUDevice { @@ -791,7 +929,7 @@ class InnerGPUDevice { features; /** @type {GPUSupportedLimits} */ limits; - /** @type {WeakRef[]} */ + /** @type {SafeWeakRef[]} */ resources; /** @type {boolean} */ isLost; @@ -801,6 +939,8 @@ class InnerGPUDevice { resolveLost; /** @type {ErrorScope[]} */ errorScopeStack; + /** @type {GPUDevice} */ + device; /** * @param {InnerGPUDeviceOptions} options @@ -821,7 +961,7 @@ class InnerGPUDevice { /** @param {any} resource */ trackResource(resource) { - ArrayPrototypePush(this.resources, new WeakRef(resource)); + ArrayPrototypePush(this.resources, new SafeWeakRef(resource)); } /** @param {{ type: string, value: string | null } | undefined} err */ @@ -846,6 +986,8 @@ class InnerGPUDevice { ); case "out-of-memory": return PromiseReject(new GPUOutOfMemoryError()); + case "internal": + return PromiseReject(new GPUInternalError()); } } }); @@ -870,8 +1012,12 @@ class InnerGPUDevice { validationFilteredPromise, ); } else { - PromisePrototypeCatch(validationFilteredPromise, () => { - // TODO(lucacasonato): emit an UncapturedErrorEvent + PromisePrototypeCatch(validationFilteredPromise, (err) => { + this.device.dispatchEvent( + new GPUUncapturedErrorEvent("uncapturederror", { + error: err, + }), + ); }); } // prevent uncaptured promise rejections @@ -891,12 +1037,41 @@ class InnerGPUDevice { if (oomScope) { ArrayPrototypePush(oomScope.operations, oomFilteredPromise); } else { - PromisePrototypeCatch(oomFilteredPromise, () => { - // TODO(lucacasonato): emit an UncapturedErrorEvent + PromisePrototypeCatch(oomFilteredPromise, (err) => { + this.device.dispatchEvent( + new GPUUncapturedErrorEvent("uncapturederror", { + error: err, + }), + ); }); } // prevent uncaptured promise rejections PromisePrototypeCatch(oomFilteredPromise, (_err) => {}); + + const internalStack = ArrayPrototypeFilter( + this.errorScopeStack, + ({ filter }) => filter == "internal", + ); + const internalScope = internalStack[internalStack.length - 1]; + const internalFilteredPromise = PromisePrototypeCatch(operation, (err) => { + if (ObjectPrototypeIsPrototypeOf(GPUInternalErrorPrototype, err)) { + return PromiseReject(err); + } + return PromiseResolve(); + }); + if (internalScope) { + ArrayPrototypePush(internalScope.operations, internalFilteredPromise); + } else { + PromisePrototypeCatch(internalFilteredPromise, (err) => { + this.device.dispatchEvent( + new GPUUncapturedErrorEvent("uncapturederror", { + error: err, + }), + ); + }); + } + // prevent uncaptured promise rejections + PromisePrototypeCatch(internalFilteredPromise, (_err) => {}); } } @@ -976,7 +1151,7 @@ class GPUDevice extends EventTarget { "Argument 1", ); const device = assertDevice(this, prefix, "this"); - const { rid, err } = ops.op_webgpu_create_buffer( + const { rid, err } = op_webgpu_create_buffer( device.rid, descriptor.label, descriptor.size, @@ -1027,7 +1202,7 @@ class GPUDevice extends EventTarget { "Argument 1", ); const device = assertDevice(this, prefix, "this"); - const { rid, err } = ops.op_webgpu_create_texture({ + const { rid, err } = op_webgpu_create_texture({ deviceRid: device.rid, ...descriptor, size: normalizeGPUExtent3D(descriptor.size), @@ -1056,7 +1231,7 @@ class GPUDevice extends EventTarget { "Argument 1", ); const device = assertDevice(this, prefix, "this"); - const { rid, err } = ops.op_webgpu_create_sampler({ + const { rid, err } = op_webgpu_create_sampler({ deviceRid: device.rid, ...descriptor, }); @@ -1089,6 +1264,7 @@ class GPUDevice extends EventTarget { const entry = descriptor.entries[i]; let j = 0; + // deno-lint-ignore prefer-primordials if (entry.buffer) j++; if (entry.sampler) j++; if (entry.texture) j++; @@ -1099,7 +1275,7 @@ class GPUDevice extends EventTarget { } } - const { rid, err } = ops.op_webgpu_create_bind_group_layout( + const { rid, err } = op_webgpu_create_bind_group_layout( device.rid, descriptor.label, descriptor.entries, @@ -1142,7 +1318,7 @@ class GPUDevice extends EventTarget { return rid; }, ); - const { rid, err } = ops.op_webgpu_create_pipeline_layout( + const { rid, err } = op_webgpu_create_pipeline_layout( device.rid, descriptor.label, bindGroupLayouts, @@ -1209,7 +1385,9 @@ class GPUDevice extends EventTarget { resource: rid, }; } else { + // deno-lint-ignore prefer-primordials const rid = assertResource(resource.buffer, prefix, context); + // deno-lint-ignore prefer-primordials assertDeviceMatch(device, resource.buffer, { prefix, resourceContext: context, @@ -1225,7 +1403,7 @@ class GPUDevice extends EventTarget { } }); - const { rid, err } = ops.op_webgpu_create_bind_group( + const { rid, err } = op_webgpu_create_bind_group( device.rid, descriptor.label, layout, @@ -1255,7 +1433,7 @@ class GPUDevice extends EventTarget { "Argument 1", ); const device = assertDevice(this, prefix, "this"); - const { rid, err } = ops.op_webgpu_create_shader_module( + const { rid, err } = op_webgpu_create_shader_module( device.rid, descriptor.label, descriptor.code, @@ -1306,7 +1484,7 @@ class GPUDevice extends EventTarget { selfContext: "this", }); - const { rid, err } = ops.op_webgpu_create_compute_pipeline( + const { rid, err } = op_webgpu_create_compute_pipeline( device.rid, descriptor.label, layout, @@ -1380,7 +1558,7 @@ class GPUDevice extends EventTarget { }; } - const { rid, err } = ops.op_webgpu_create_render_pipeline({ + const { rid, err } = op_webgpu_create_render_pipeline({ deviceRid: device.rid, label: descriptor.label, layout, @@ -1407,12 +1585,166 @@ class GPUDevice extends EventTarget { createComputePipelineAsync(descriptor) { // TODO(lucacasonato): this should be real async - return PromiseResolve(this.createComputePipeline(descriptor)); + + webidl.assertBranded(this, GPUDevicePrototype); + const prefix = + "Failed to execute 'createComputePipelineAsync' on 'GPUDevice'"; + webidl.requiredArguments(arguments.length, 1, prefix); + descriptor = webidl.converters.GPUComputePipelineDescriptor( + descriptor, + prefix, + "Argument 1", + ); + const device = assertDevice(this, prefix, "this"); + let layout = descriptor.layout; + if (typeof descriptor.layout !== "string") { + const context = "layout"; + layout = assertResource(descriptor.layout, prefix, context); + assertDeviceMatch(device, descriptor.layout, { + prefix, + resourceContext: context, + selfContext: "this", + }); + } + const module = assertResource( + descriptor.compute.module, + prefix, + "compute shader module", + ); + assertDeviceMatch(device, descriptor.compute.module, { + prefix, + resourceContext: "compute shader module", + selfContext: "this", + }); + + const { rid, err } = op_webgpu_create_compute_pipeline( + device.rid, + descriptor.label, + layout, + { + module, + entryPoint: descriptor.compute.entryPoint, + constants: descriptor.compute.constants, + }, + ); + device.pushError(err); + if (err) { + switch (err.type) { + case "validation": + return PromiseReject( + new GPUPipelineError(err.value ?? "validation error", { + reason: "validation", + }), + ); + case "internal": + return PromiseReject( + new GPUPipelineError("internal error", { + reason: "validation", + }), + ); + } + } + + const computePipeline = createGPUComputePipeline( + descriptor.label, + device, + rid, + ); + device.trackResource(computePipeline); + return PromiseResolve(computePipeline); } createRenderPipelineAsync(descriptor) { // TODO(lucacasonato): this should be real async - return PromiseResolve(this.createRenderPipeline(descriptor)); + + webidl.assertBranded(this, GPUDevicePrototype); + const prefix = + "Failed to execute 'createRenderPipelineAsync' on 'GPUDevice'"; + webidl.requiredArguments(arguments.length, 1, prefix); + descriptor = webidl.converters.GPURenderPipelineDescriptor( + descriptor, + prefix, + "Argument 1", + ); + const device = assertDevice(this, prefix, "this"); + let layout = descriptor.layout; + if (typeof descriptor.layout !== "string") { + const context = "layout"; + layout = assertResource(descriptor.layout, prefix, context); + assertDeviceMatch(device, descriptor.layout, { + prefix, + resourceContext: context, + selfContext: "this", + }); + } + const module = assertResource( + descriptor.vertex.module, + prefix, + "vertex shader module", + ); + assertDeviceMatch(device, descriptor.vertex.module, { + prefix, + resourceContext: "vertex shader module", + selfContext: "this", + }); + let fragment = undefined; + if (descriptor.fragment) { + const module = assertResource( + descriptor.fragment.module, + prefix, + "fragment shader module", + ); + assertDeviceMatch(device, descriptor.fragment.module, { + prefix, + resourceContext: "fragment shader module", + selfContext: "this", + }); + fragment = { + module, + entryPoint: descriptor.fragment.entryPoint, + targets: descriptor.fragment.targets, + }; + } + + const { rid, err } = op_webgpu_create_render_pipeline({ + deviceRid: device.rid, + label: descriptor.label, + layout, + vertex: { + module, + entryPoint: descriptor.vertex.entryPoint, + buffers: descriptor.vertex.buffers, + }, + primitive: descriptor.primitive, + depthStencil: descriptor.depthStencil, + multisample: descriptor.multisample, + fragment, + }); + device.pushError(err); + if (err) { + switch (err.type) { + case "validation": + return PromiseReject( + new GPUPipelineError(err.value ?? "validation error", { + reason: "validation", + }), + ); + case "internal": + return PromiseReject( + new GPUPipelineError("internal error", { + reason: "validation", + }), + ); + } + } + + const renderPipeline = createGPURenderPipeline( + descriptor.label, + device, + rid, + ); + device.trackResource(renderPipeline); + return renderPipeline; } /** @@ -1428,7 +1760,7 @@ class GPUDevice extends EventTarget { "Argument 1", ); const device = assertDevice(this, prefix, "this"); - const { rid, err } = ops.op_webgpu_create_command_encoder( + const { rid, err } = op_webgpu_create_command_encoder( device.rid, descriptor.label, ); @@ -1458,7 +1790,7 @@ class GPUDevice extends EventTarget { "Argument 1", ); const device = assertDevice(this, prefix, "this"); - const { rid, err } = ops.op_webgpu_create_render_bundle_encoder({ + const { rid, err } = op_webgpu_create_render_bundle_encoder({ deviceRid: device.rid, ...descriptor, }); @@ -1487,7 +1819,7 @@ class GPUDevice extends EventTarget { "Argument 1", ); const device = assertDevice(this, prefix, "this"); - const { rid, err } = ops.op_webgpu_create_query_set({ + const { rid, err } = op_webgpu_create_query_set({ deviceRid: device.rid, ...descriptor, }); @@ -1575,22 +1907,49 @@ class GPUDevice extends EventTarget { GPUObjectBaseMixin("GPUDevice", GPUDevice); const GPUDevicePrototype = GPUDevice.prototype; +class GPUPipelineError extends DOMException { + #reason; + + constructor(message = "", options = {}) { + const prefix = "Failed to construct 'GPUPipelineError'"; + message = webidl.converters.DOMString(message, prefix, "Argument 1"); + options = webidl.converters.GPUPipelineErrorInit( + options, + prefix, + "Argument 2", + ); + super(message, "GPUPipelineError"); + + this.#reason = options.reason; + } + + get reason() { + webidl.assertBranded(this, GPUPipelineErrorPrototype); + return this.#reason; + } +} +const GPUPipelineErrorPrototype = GPUPipelineError.prototype; + /** * @param {string | null} label * @param {InnerGPUDevice} device + * @param {number} rid * @returns {GPUQueue} */ -function createGPUQueue(label, device) { +function createGPUQueue(label, device, rid) { /** @type {GPUQueue} */ const queue = webidl.createBranded(GPUQueue); queue[_label] = label; queue[_device] = device; + queue[_rid] = rid; return queue; } class GPUQueue { /** @type {InnerGPUDevice} */ [_device]; + /** @type {number} */ + [_rid]; constructor() { webidl.illegalConstructor(); @@ -1624,7 +1983,7 @@ class GPUQueue { return rid; }, ); - const { err } = ops.op_webgpu_queue_submit(device.rid, commandBufferRids); + const { err } = op_webgpu_queue_submit(this[_rid], commandBufferRids); for (let i = 0; i < commandBuffers.length; ++i) { commandBuffers[i][_rid] = undefined; } @@ -1669,13 +2028,23 @@ class GPUQueue { selfContext: "this", resourceContext: "Argument 1", }); - const { err } = ops.op_webgpu_write_buffer( - device.rid, + /** @type {ArrayBufferLike} */ + let abLike = data; + if (isTypedArray(data)) { + abLike = TypedArrayPrototypeGetBuffer( + /** @type {Uint8Array} */ (data), + ); + } else if (isDataView(data)) { + abLike = DataViewPrototypeGetBuffer(/** @type {DataView} */ (data)); + } + + const { err } = op_webgpu_write_buffer( + this[_rid], bufferRid, bufferOffset, dataOffset, size, - new Uint8Array(ArrayBufferIsView(data) ? data.buffer : data), + new Uint8Array(abLike), ); device.pushError(err); } @@ -1709,8 +2078,19 @@ class GPUQueue { selfContext: "this", resourceContext: "texture", }); - const { err } = ops.op_webgpu_write_texture( - device.rid, + + /** @type {ArrayBufferLike} */ + let abLike = data; + if (isTypedArray(data)) { + abLike = TypedArrayPrototypeGetBuffer( + /** @type {Uint8Array} */ (data), + ); + } else if (isDataView(data)) { + abLike = DataViewPrototypeGetBuffer(/** @type {DataView} */ (data)); + } + + const { err } = op_webgpu_write_texture( + this[_rid], { texture: textureRid, mipLevel: destination.mipLevel, @@ -1721,7 +2101,7 @@ class GPUQueue { }, dataLayout, normalizeGPUExtent3D(size), - new Uint8Array(ArrayBufferIsView(data) ? data.buffer : data), + new Uint8Array(abLike), ); device.pushError(err); } @@ -1905,8 +2285,7 @@ class GPUBuffer { this[_mapMode] = mode; this[_state] = "pending"; const promise = PromisePrototypeThen( - core.opAsync( - "op_webgpu_buffer_get_map_async", + op_webgpu_buffer_get_map_async( bufferRid, device.rid, mode, @@ -1952,9 +2331,9 @@ class GPUBuffer { throw new DOMException(`${prefix}: invalid state.`, "OperationError"); } for (let i = 0; i < mappedRanges.length; ++i) { - const [buffer, _rid, start] = mappedRanges[i]; + const { 0: buffer, 1: _rid, 2: start } = mappedRanges[i]; // TODO(lucacasonato): is this logic correct? - const end = start + buffer.byteLength; + const end = start + ArrayBufferPrototypeGetByteLength(buffer); if ( (start >= offset && start < (offset + rangeSize)) || (end >= offset && end < (offset + rangeSize)) @@ -1967,7 +2346,7 @@ class GPUBuffer { } const buffer = new ArrayBuffer(rangeSize); - const { rid } = ops.op_webgpu_buffer_get_mapped_range( + const { rid } = op_webgpu_buffer_get_mapped_range( bufferRid, offset, size, @@ -2021,8 +2400,8 @@ class GPUBuffer { throw new DOMException(`${prefix}: invalid state.`, "OperationError"); } for (let i = 0; i < mappedRanges.length; ++i) { - const [buffer, mappedRid] = mappedRanges[i]; - const { err } = ops.op_webgpu_buffer_unmap( + const { 0: buffer, 1: mappedRid } = mappedRanges[i]; + const { err } = op_webgpu_buffer_unmap( bufferRid, mappedRid, ...new SafeArrayIterator(write ? [new Uint8Array(buffer)] : []), @@ -2140,7 +2519,7 @@ class GPUTexture { [_device]; /** @type {number | undefined} */ [_rid]; - /** @type {WeakRef[]} */ + /** @type {SafeWeakRef[]} */ [_views]; /** @type {number} */ @@ -2194,7 +2573,7 @@ class GPUTexture { ); const device = assertDevice(this, prefix, "this"); const textureRid = assertResource(this, prefix, "this"); - const { rid, err } = ops.op_webgpu_create_texture_view({ + const { rid, err } = op_webgpu_create_texture_view({ textureRid, ...descriptor, }); @@ -2205,7 +2584,7 @@ class GPUTexture { this, rid, ); - ArrayPrototypePush(this[_views], new WeakRef(textureView)); + ArrayPrototypePush(this[_views], new SafeWeakRef(textureView)); return textureView; } @@ -2428,7 +2807,10 @@ class GPUBindGroupLayout { return inspect( createFilteredInspectProxy({ object: this, - evaluate: ObjectPrototypeIsPrototypeOf(GPUBindGroupLayoutPrototype, this), + evaluate: ObjectPrototypeIsPrototypeOf( + GPUBindGroupLayoutPrototype, + this, + ), keys: [ "label", ], @@ -2476,7 +2858,10 @@ class GPUPipelineLayout { return inspect( createFilteredInspectProxy({ object: this, - evaluate: ObjectPrototypeIsPrototypeOf(GPUPipelineLayoutPrototype, this), + evaluate: ObjectPrototypeIsPrototypeOf( + GPUPipelineLayoutPrototype, + this, + ), keys: [ "label", ], @@ -2488,7 +2873,6 @@ class GPUPipelineLayout { GPUObjectBaseMixin("GPUPipelineLayout", GPUPipelineLayout); const GPUPipelineLayoutPrototype = GPUPipelineLayout.prototype; - /** * @param {string | null} label * @param {InnerGPUDevice} device @@ -2648,8 +3032,8 @@ class GPUComputePipeline { index = webidl.converters["unsigned long"](index, prefix, "Argument 1"); const device = assertDevice(this, prefix, "this"); const computePipelineRid = assertResource(this, prefix, "this"); - const { rid, label, err } = ops - .op_webgpu_compute_pipeline_get_bind_group_layout( + const { rid, label, err } = + op_webgpu_compute_pipeline_get_bind_group_layout( computePipelineRid, index, ); @@ -2668,7 +3052,10 @@ class GPUComputePipeline { return inspect( createFilteredInspectProxy({ object: this, - evaluate: ObjectPrototypeIsPrototypeOf(GPUComputePipelinePrototype, this), + evaluate: ObjectPrototypeIsPrototypeOf( + GPUComputePipelinePrototype, + this, + ), keys: [ "label", ], @@ -2724,11 +3111,10 @@ class GPURenderPipeline { index = webidl.converters["unsigned long"](index, prefix, "Argument 1"); const device = assertDevice(this, prefix, "this"); const renderPipelineRid = assertResource(this, prefix, "this"); - const { rid, label, err } = ops - .op_webgpu_render_pipeline_get_bind_group_layout( - renderPipelineRid, - index, - ); + const { rid, label, err } = op_webgpu_render_pipeline_get_bind_group_layout( + renderPipelineRid, + index, + ); device.pushError(err); const bindGroupLayout = createGPUBindGroupLayout( @@ -2744,7 +3130,10 @@ class GPURenderPipeline { return inspect( createFilteredInspectProxy({ object: this, - evaluate: ObjectPrototypeIsPrototypeOf(GPURenderPipelinePrototype, this), + evaluate: ObjectPrototypeIsPrototypeOf( + GPURenderPipelinePrototype, + this, + ), keys: [ "label", ], @@ -2798,7 +3187,7 @@ class GPUCommandEncoder { [_device]; /** @type {number | undefined} */ [_rid]; - /** @type {WeakRef[]} */ + /** @type {SafeWeakRef[]} */ [_encoders]; [_cleanup]() { @@ -2848,7 +3237,7 @@ class GPUCommandEncoder { if (descriptor.depthStencilAttachment) { if ( descriptor.depthStencilAttachment.depthLoadOp === "clear" && - !("depthClearValue" in descriptor.depthStencilAttachment) + !(ObjectHasOwn(descriptor.depthStencilAttachment, "depthClearValue")) ) { throw webidl.makeException( TypeError, @@ -2908,7 +3297,11 @@ class GPUCommandEncoder { prefix, `resolve target texture view for ${context}`, ); - assertResource(colorAttachment.resolveTarget[_texture], prefix, `texture backing resolve target texture view for ${context}`); + assertResource( + colorAttachment.resolveTarget[_texture], + prefix, + `texture backing resolve target texture view for ${context}`, + ); assertDeviceMatch( device, colorAttachment.resolveTarget[_texture], @@ -2941,16 +3334,21 @@ class GPUCommandEncoder { let timestampWrites = null; if (descriptor.timestampWrites) { - const querySet = assertResource(descriptor.timestampWrites.querySet, prefix, "querySet"); + const querySet = assertResource( + descriptor.timestampWrites.querySet, + prefix, + "querySet", + ); timestampWrites = { querySet, - beginningOfPassWriteIndex: descriptor.timestampWrites.beginningOfPassWriteIndex, + beginningOfPassWriteIndex: + descriptor.timestampWrites.beginningOfPassWriteIndex, endOfPassWriteIndex: descriptor.timestampWrites.endOfPassWriteIndex, }; } - const { rid } = ops.op_webgpu_command_encoder_begin_render_pass( + const { rid } = op_webgpu_command_encoder_begin_render_pass( commandEncoderRid, descriptor.label, colorAttachments, @@ -2964,7 +3362,7 @@ class GPUCommandEncoder { this, rid, ); - ArrayPrototypePush(this[_encoders], new WeakRef(renderPassEncoder)); + ArrayPrototypePush(this[_encoders], new SafeWeakRef(renderPassEncoder)); return renderPassEncoder; } @@ -2986,16 +3384,21 @@ class GPUCommandEncoder { let timestampWrites = null; if (descriptor.timestampWrites) { - const querySet = assertResource(descriptor.timestampWrites.querySet, prefix, "querySet"); + const querySet = assertResource( + descriptor.timestampWrites.querySet, + prefix, + "querySet", + ); timestampWrites = { querySet, - beginningOfPassWriteIndex: descriptor.timestampWrites.beginningOfPassWriteIndex, + beginningOfPassWriteIndex: + descriptor.timestampWrites.beginningOfPassWriteIndex, endOfPassWriteIndex: descriptor.timestampWrites.endOfPassWriteIndex, }; } - const { rid } = ops.op_webgpu_command_encoder_begin_compute_pass( + const { rid } = op_webgpu_command_encoder_begin_compute_pass( commandEncoderRid, descriptor.label, timestampWrites, @@ -3006,7 +3409,7 @@ class GPUCommandEncoder { this, rid, ); - ArrayPrototypePush(this[_encoders], new WeakRef(computePassEncoder)); + ArrayPrototypePush(this[_encoders], new SafeWeakRef(computePassEncoder)); return computePassEncoder; } @@ -3060,7 +3463,7 @@ class GPUCommandEncoder { selfContext: "this", }); - const { err } = ops.op_webgpu_command_encoder_copy_buffer_to_buffer( + const { err } = op_webgpu_command_encoder_copy_buffer_to_buffer( commandEncoderRid, sourceRid, sourceOffset, @@ -3091,10 +3494,12 @@ class GPUCommandEncoder { const device = assertDevice(this, prefix, "this"); const commandEncoderRid = assertResource(this, prefix, "this"); const sourceBufferRid = assertResource( + // deno-lint-ignore prefer-primordials source.buffer, prefix, "source in Argument 1", ); + // deno-lint-ignore prefer-primordials assertDeviceMatch(device, source.buffer, { prefix, resourceContext: "source in Argument 1", @@ -3111,7 +3516,7 @@ class GPUCommandEncoder { selfContext: "this", }); - const { err } = ops.op_webgpu_command_encoder_copy_buffer_to_texture( + const { err } = op_webgpu_command_encoder_copy_buffer_to_texture( commandEncoderRid, { ...source, @@ -3164,16 +3569,18 @@ class GPUCommandEncoder { selfContext: "this", }); const destinationBufferRid = assertResource( + // deno-lint-ignore prefer-primordials destination.buffer, prefix, "buffer in Argument 2", ); + // deno-lint-ignore prefer-primordials assertDeviceMatch(device, destination.buffer, { prefix, resourceContext: "buffer in Argument 2", selfContext: "this", }); - const { err } = ops.op_webgpu_command_encoder_copy_texture_to_buffer( + const { err } = op_webgpu_command_encoder_copy_texture_to_buffer( commandEncoderRid, { texture: sourceTextureRid, @@ -3233,7 +3640,7 @@ class GPUCommandEncoder { resourceContext: "texture in Argument 2", selfContext: "this", }); - const { err } = ops.op_webgpu_command_encoder_copy_texture_to_texture( + const { err } = op_webgpu_command_encoder_copy_texture_to_texture( commandEncoderRid, { texture: sourceTextureRid, @@ -3269,7 +3676,7 @@ class GPUCommandEncoder { const device = assertDevice(this, prefix, "this"); const commandEncoderRid = assertResource(this, prefix, "this"); const bufferRid = assertResource(buffer, prefix, "Argument 1"); - const { err } = ops.op_webgpu_command_encoder_clear_buffer( + const { err } = op_webgpu_command_encoder_clear_buffer( commandEncoderRid, bufferRid, offset, @@ -3288,7 +3695,7 @@ class GPUCommandEncoder { groupLabel = webidl.converters.USVString(groupLabel, prefix, "Argument 1"); const device = assertDevice(this, prefix, "this"); const commandEncoderRid = assertResource(this, prefix, "this"); - const { err } = ops.op_webgpu_command_encoder_push_debug_group( + const { err } = op_webgpu_command_encoder_push_debug_group( commandEncoderRid, groupLabel, ); @@ -3300,7 +3707,7 @@ class GPUCommandEncoder { const prefix = "Failed to execute 'popDebugGroup' on 'GPUCommandEncoder'"; const device = assertDevice(this, prefix, "this"); const commandEncoderRid = assertResource(this, prefix, "this"); - const { err } = ops.op_webgpu_command_encoder_pop_debug_group( + const { err } = op_webgpu_command_encoder_pop_debug_group( commandEncoderRid, ); device.pushError(err); @@ -3321,7 +3728,7 @@ class GPUCommandEncoder { ); const device = assertDevice(this, prefix, "this"); const commandEncoderRid = assertResource(this, prefix, "this"); - const { err } = ops.op_webgpu_command_encoder_insert_debug_marker( + const { err } = op_webgpu_command_encoder_insert_debug_marker( commandEncoderRid, markerLabel, ); @@ -3346,7 +3753,7 @@ class GPUCommandEncoder { resourceContext: "Argument 1", selfContext: "this", }); - const { err } = ops.op_webgpu_command_encoder_write_timestamp( + const { err } = op_webgpu_command_encoder_write_timestamp( commandEncoderRid, querySetRid, queryIndex, @@ -3398,7 +3805,7 @@ class GPUCommandEncoder { resourceContext: "Argument 3", selfContext: "this", }); - const { err } = ops.op_webgpu_command_encoder_resolve_query_set( + const { err } = op_webgpu_command_encoder_resolve_query_set( commandEncoderRid, querySetRid, firstQuery, @@ -3423,7 +3830,7 @@ class GPUCommandEncoder { ); const device = assertDevice(this, prefix, "this"); const commandEncoderRid = assertResource(this, prefix, "this"); - const { rid, err } = ops.op_webgpu_command_encoder_finish( + const { rid, err } = op_webgpu_command_encoder_finish( commandEncoderRid, descriptor.label, ); @@ -3444,7 +3851,10 @@ class GPUCommandEncoder { return inspect( createFilteredInspectProxy({ object: this, - evaluate: ObjectPrototypeIsPrototypeOf(GPUCommandEncoderPrototype, this), + evaluate: ObjectPrototypeIsPrototypeOf( + GPUCommandEncoderPrototype, + this, + ), keys: [ "label", ], @@ -3511,7 +3921,7 @@ class GPURenderPassEncoder { assertDevice(this[_encoder], prefix, "encoder referenced by this"); assertResource(this[_encoder], prefix, "encoder referenced by this"); const renderPassRid = assertResource(this, prefix, "this"); - ops.op_webgpu_render_pass_set_viewport({ + op_webgpu_render_pass_set_viewport({ renderPassRid, x, y, @@ -3544,7 +3954,7 @@ class GPURenderPassEncoder { assertDevice(this[_encoder], prefix, "encoder referenced by this"); assertResource(this[_encoder], prefix, "encoder referenced by this"); const renderPassRid = assertResource(this, prefix, "this"); - ops.op_webgpu_render_pass_set_scissor_rect( + op_webgpu_render_pass_set_scissor_rect( renderPassRid, x, y, @@ -3565,7 +3975,7 @@ class GPURenderPassEncoder { assertDevice(this[_encoder], prefix, "encoder referenced by this"); assertResource(this[_encoder], prefix, "encoder referenced by this"); const renderPassRid = assertResource(this, prefix, "this"); - ops.op_webgpu_render_pass_set_blend_constant( + op_webgpu_render_pass_set_blend_constant( renderPassRid, normalizeGPUColor(color), ); @@ -3587,7 +3997,7 @@ class GPURenderPassEncoder { assertDevice(this[_encoder], prefix, "encoder referenced by this"); assertResource(this[_encoder], prefix, "encoder referenced by this"); const renderPassRid = assertResource(this, prefix, "this"); - ops.op_webgpu_render_pass_set_stencil_reference( + op_webgpu_render_pass_set_stencil_reference( renderPassRid, reference, ); @@ -3605,7 +4015,7 @@ class GPURenderPassEncoder { assertDevice(this[_encoder], prefix, "encoder referenced by this"); assertResource(this[_encoder], prefix, "encoder referenced by this"); const renderPassRid = assertResource(this, prefix, "this"); - ops.op_webgpu_render_pass_begin_occlusion_query( + op_webgpu_render_pass_begin_occlusion_query( renderPassRid, queryIndex, ); @@ -3618,7 +4028,7 @@ class GPURenderPassEncoder { assertDevice(this[_encoder], prefix, "encoder referenced by this"); assertResource(this[_encoder], prefix, "encoder referenced by this"); const renderPassRid = assertResource(this, prefix, "this"); - ops.op_webgpu_render_pass_end_occlusion_query(renderPassRid); + op_webgpu_render_pass_end_occlusion_query(renderPassRid); } /** @@ -3651,7 +4061,7 @@ class GPURenderPassEncoder { }); return rid; }); - ops.op_webgpu_render_pass_execute_bundles(renderPassRid, bundleRids); + op_webgpu_render_pass_execute_bundles(renderPassRid, bundleRids); } end() { @@ -3668,7 +4078,7 @@ class GPURenderPassEncoder { "encoder referenced by this", ); const renderPassRid = assertResource(this, prefix, "this"); - const { err } = ops.op_webgpu_render_pass_end( + const { err } = op_webgpu_render_pass_end( commandEncoderRid, renderPassRid, ); @@ -3700,16 +4110,14 @@ class GPURenderPassEncoder { selfContext: "this", }); if ( - !(ObjectPrototypeIsPrototypeOf( - Uint32ArrayPrototype, - dynamicOffsetsData, - )) + TypedArrayPrototypeGetSymbolToStringTag(dynamicOffsetsData) !== + "Uint32Array" ) { dynamicOffsetsData = new Uint32Array(dynamicOffsetsData ?? []); dynamicOffsetsDataStart = 0; dynamicOffsetsDataLength = dynamicOffsetsData.length; } - ops.op_webgpu_render_pass_set_bind_group( + op_webgpu_render_pass_set_bind_group( renderPassRid, index, bindGroupRid, @@ -3731,7 +4139,7 @@ class GPURenderPassEncoder { assertDevice(this[_encoder], prefix, "encoder referenced by this"); assertResource(this[_encoder], prefix, "encoder referenced by this"); const renderPassRid = assertResource(this, prefix, "this"); - ops.op_webgpu_render_pass_push_debug_group(renderPassRid, groupLabel); + op_webgpu_render_pass_push_debug_group(renderPassRid, groupLabel); } popDebugGroup() { @@ -3741,7 +4149,7 @@ class GPURenderPassEncoder { assertDevice(this[_encoder], prefix, "encoder referenced by this"); assertResource(this[_encoder], prefix, "encoder referenced by this"); const renderPassRid = assertResource(this, prefix, "this"); - ops.op_webgpu_render_pass_pop_debug_group(renderPassRid); + op_webgpu_render_pass_pop_debug_group(renderPassRid); } /** @@ -3760,7 +4168,7 @@ class GPURenderPassEncoder { assertDevice(this[_encoder], prefix, "encoder referenced by this"); assertResource(this[_encoder], prefix, "encoder referenced by this"); const renderPassRid = assertResource(this, prefix, "this"); - ops.op_webgpu_render_pass_insert_debug_marker(renderPassRid, markerLabel); + op_webgpu_render_pass_insert_debug_marker(renderPassRid, markerLabel); } /** @@ -3788,7 +4196,7 @@ class GPURenderPassEncoder { resourceContext: "Argument 1", selfContext: "this", }); - ops.op_webgpu_render_pass_set_pipeline(renderPassRid, pipelineRid); + op_webgpu_render_pass_set_pipeline(renderPassRid, pipelineRid); } /** @@ -3825,7 +4233,7 @@ class GPURenderPassEncoder { resourceContext: "Argument 1", selfContext: "this", }); - ops.op_webgpu_render_pass_set_index_buffer( + op_webgpu_render_pass_set_index_buffer( renderPassRid, bufferRid, indexFormat, @@ -3864,7 +4272,7 @@ class GPURenderPassEncoder { resourceContext: "Argument 2", selfContext: "this", }); - ops.op_webgpu_render_pass_set_vertex_buffer( + op_webgpu_render_pass_set_vertex_buffer( renderPassRid, slot, bufferRid, @@ -3906,7 +4314,7 @@ class GPURenderPassEncoder { assertDevice(this[_encoder], prefix, "encoder referenced by this"); assertResource(this[_encoder], prefix, "encoder referenced by this"); const renderPassRid = assertResource(this, prefix, "this"); - ops.op_webgpu_render_pass_draw( + op_webgpu_render_pass_draw( renderPassRid, vertexCount, instanceCount, @@ -3952,7 +4360,7 @@ class GPURenderPassEncoder { assertDevice(this[_encoder], prefix, "encoder referenced by this"); assertResource(this[_encoder], prefix, "encoder referenced by this"); const renderPassRid = assertResource(this, prefix, "this"); - ops.op_webgpu_render_pass_draw_indexed( + op_webgpu_render_pass_draw_indexed( renderPassRid, indexCount, instanceCount, @@ -3997,7 +4405,7 @@ class GPURenderPassEncoder { resourceContext: "Argument 1", selfContext: "this", }); - ops.op_webgpu_render_pass_draw_indirect( + op_webgpu_render_pass_draw_indirect( renderPassRid, indirectBufferRid, indirectOffset, @@ -4040,7 +4448,7 @@ class GPURenderPassEncoder { resourceContext: "Argument 1", selfContext: "this", }); - ops.op_webgpu_render_pass_draw_indexed_indirect( + op_webgpu_render_pass_draw_indexed_indirect( renderPassRid, indirectBufferRid, indirectOffset, @@ -4051,7 +4459,10 @@ class GPURenderPassEncoder { return inspect( createFilteredInspectProxy({ object: this, - evaluate: ObjectPrototypeIsPrototypeOf(GPURenderPassEncoderPrototype, this), + evaluate: ObjectPrototypeIsPrototypeOf( + GPURenderPassEncoderPrototype, + this, + ), keys: [ "label", ], @@ -4123,7 +4534,7 @@ class GPUComputePassEncoder { resourceContext: "Argument 1", selfContext: "this", }); - ops.op_webgpu_compute_pass_set_pipeline(computePassRid, pipelineRid); + op_webgpu_compute_pass_set_pipeline(computePassRid, pipelineRid); } /** @@ -4158,7 +4569,7 @@ class GPUComputePassEncoder { assertDevice(this[_encoder], prefix, "encoder referenced by this"); assertResource(this[_encoder], prefix, "encoder referenced by this"); const computePassRid = assertResource(this, prefix, "this"); - ops.op_webgpu_compute_pass_dispatch_workgroups( + op_webgpu_compute_pass_dispatch_workgroups( computePassRid, workgroupCountX, workgroupCountY, @@ -4202,7 +4613,7 @@ class GPUComputePassEncoder { resourceContext: "Argument 1", selfContext: "this", }); - ops.op_webgpu_compute_pass_dispatch_workgroups_indirect( + op_webgpu_compute_pass_dispatch_workgroups_indirect( computePassRid, indirectBufferRid, indirectOffset, @@ -4223,7 +4634,7 @@ class GPUComputePassEncoder { "encoder referenced by this", ); const computePassRid = assertResource(this, prefix, "this"); - const { err } = ops.op_webgpu_compute_pass_end( + const { err } = op_webgpu_compute_pass_end( commandEncoderRid, computePassRid, ); @@ -4256,16 +4667,14 @@ class GPUComputePassEncoder { selfContext: "this", }); if ( - !(ObjectPrototypeIsPrototypeOf( - Uint32ArrayPrototype, - dynamicOffsetsData, - )) + TypedArrayPrototypeGetSymbolToStringTag(dynamicOffsetsData) !== + "Uint32Array" ) { dynamicOffsetsData = new Uint32Array(dynamicOffsetsData ?? []); dynamicOffsetsDataStart = 0; dynamicOffsetsDataLength = dynamicOffsetsData.length; } - ops.op_webgpu_compute_pass_set_bind_group( + op_webgpu_compute_pass_set_bind_group( computePassRid, index, bindGroupRid, @@ -4287,7 +4696,7 @@ class GPUComputePassEncoder { assertDevice(this[_encoder], prefix, "encoder referenced by this"); assertResource(this[_encoder], prefix, "encoder referenced by this"); const computePassRid = assertResource(this, prefix, "this"); - ops.op_webgpu_compute_pass_push_debug_group(computePassRid, groupLabel); + op_webgpu_compute_pass_push_debug_group(computePassRid, groupLabel); } popDebugGroup() { @@ -4297,7 +4706,7 @@ class GPUComputePassEncoder { assertDevice(this[_encoder], prefix, "encoder referenced by this"); assertResource(this[_encoder], prefix, "encoder referenced by this"); const computePassRid = assertResource(this, prefix, "this"); - ops.op_webgpu_compute_pass_pop_debug_group(computePassRid); + op_webgpu_compute_pass_pop_debug_group(computePassRid); } /** @@ -4316,7 +4725,7 @@ class GPUComputePassEncoder { assertDevice(this[_encoder], prefix, "encoder referenced by this"); assertResource(this[_encoder], prefix, "encoder referenced by this"); const computePassRid = assertResource(this, prefix, "this"); - ops.op_webgpu_compute_pass_insert_debug_marker( + op_webgpu_compute_pass_insert_debug_marker( computePassRid, markerLabel, ); @@ -4326,7 +4735,10 @@ class GPUComputePassEncoder { return inspect( createFilteredInspectProxy({ object: this, - evaluate: ObjectPrototypeIsPrototypeOf(GPUComputePassEncoderPrototype, this), + evaluate: ObjectPrototypeIsPrototypeOf( + GPUComputePassEncoderPrototype, + this, + ), keys: [ "label", ], @@ -4435,7 +4847,7 @@ class GPURenderBundleEncoder { ); const device = assertDevice(this, prefix, "this"); const renderBundleEncoderRid = assertResource(this, prefix, "this"); - const { rid, err } = ops.op_webgpu_render_bundle_encoder_finish( + const { rid, err } = op_webgpu_render_bundle_encoder_finish( renderBundleEncoderRid, descriptor.label, ); @@ -4471,16 +4883,14 @@ class GPURenderBundleEncoder { selfContext: "this", }); if ( - !(ObjectPrototypeIsPrototypeOf( - Uint32ArrayPrototype, - dynamicOffsetsData, - )) + TypedArrayPrototypeGetSymbolToStringTag(dynamicOffsetsData) !== + "Uint32Array" ) { dynamicOffsetsData = new Uint32Array(dynamicOffsetsData ?? []); dynamicOffsetsDataStart = 0; dynamicOffsetsDataLength = dynamicOffsetsData.length; } - ops.op_webgpu_render_bundle_encoder_set_bind_group( + op_webgpu_render_bundle_encoder_set_bind_group( renderBundleEncoderRid, index, bindGroupRid, @@ -4501,7 +4911,7 @@ class GPURenderBundleEncoder { groupLabel = webidl.converters.USVString(groupLabel, prefix, "Argument 1"); assertDevice(this, prefix, "this"); const renderBundleEncoderRid = assertResource(this, prefix, "this"); - ops.op_webgpu_render_bundle_encoder_push_debug_group( + op_webgpu_render_bundle_encoder_push_debug_group( renderBundleEncoderRid, groupLabel, ); @@ -4513,7 +4923,7 @@ class GPURenderBundleEncoder { "Failed to execute 'popDebugGroup' on 'GPURenderBundleEncoder'"; assertDevice(this, prefix, "this"); const renderBundleEncoderRid = assertResource(this, prefix, "this"); - ops.op_webgpu_render_bundle_encoder_pop_debug_group( + op_webgpu_render_bundle_encoder_pop_debug_group( renderBundleEncoderRid, ); } @@ -4533,7 +4943,7 @@ class GPURenderBundleEncoder { ); assertDevice(this, prefix, "this"); const renderBundleEncoderRid = assertResource(this, prefix, "this"); - ops.op_webgpu_render_bundle_encoder_insert_debug_marker( + op_webgpu_render_bundle_encoder_insert_debug_marker( renderBundleEncoderRid, markerLabel, ); @@ -4560,7 +4970,7 @@ class GPURenderBundleEncoder { resourceContext: "Argument 1", selfContext: "this", }); - ops.op_webgpu_render_bundle_encoder_set_pipeline( + op_webgpu_render_bundle_encoder_set_pipeline( renderBundleEncoderRid, pipelineRid, ); @@ -4593,7 +5003,7 @@ class GPURenderBundleEncoder { resourceContext: "Argument 1", selfContext: "this", }); - ops.op_webgpu_render_bundle_encoder_set_index_buffer( + op_webgpu_render_bundle_encoder_set_index_buffer( renderBundleEncoderRid, bufferRid, indexFormat, @@ -4627,7 +5037,7 @@ class GPURenderBundleEncoder { resourceContext: "Argument 2", selfContext: "this", }); - ops.op_webgpu_render_bundle_encoder_set_vertex_buffer( + op_webgpu_render_bundle_encoder_set_vertex_buffer( renderBundleEncoderRid, slot, bufferRid, @@ -4668,7 +5078,7 @@ class GPURenderBundleEncoder { ); assertDevice(this, prefix, "this"); const renderBundleEncoderRid = assertResource(this, prefix, "this"); - ops.op_webgpu_render_bundle_encoder_draw( + op_webgpu_render_bundle_encoder_draw( renderBundleEncoderRid, vertexCount, instanceCount, @@ -4714,7 +5124,7 @@ class GPURenderBundleEncoder { ); assertDevice(this, prefix, "this"); const renderBundleEncoderRid = assertResource(this, prefix, "this"); - ops.op_webgpu_render_bundle_encoder_draw_indexed( + op_webgpu_render_bundle_encoder_draw_indexed( renderBundleEncoderRid, indexCount, instanceCount, @@ -4755,7 +5165,7 @@ class GPURenderBundleEncoder { resourceContext: "Argument 1", selfContext: "this", }); - ops.op_webgpu_render_bundle_encoder_draw_indirect( + op_webgpu_render_bundle_encoder_draw_indirect( renderBundleEncoderRid, indirectBufferRid, indirectOffset, @@ -4766,7 +5176,10 @@ class GPURenderBundleEncoder { return inspect( createFilteredInspectProxy({ object: this, - evaluate: ObjectPrototypeIsPrototypeOf(GPURenderBundleEncoderPrototype, this), + evaluate: ObjectPrototypeIsPrototypeOf( + GPURenderBundleEncoderPrototype, + this, + ), keys: [ "label", ], @@ -4875,12 +5288,12 @@ class GPUQuerySet { get type() { webidl.assertBranded(this, GPUQuerySetPrototype); - this[_type](); + return this[_type](); } get count() { webidl.assertBranded(this, GPUQuerySetPrototype); - this[_count](); + return this[_count](); } [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { @@ -5019,6 +5432,27 @@ webidl.converters["GPUFeatureName"] = webidl.createEnumConverter( ], ); +// DICTIONARY: GPUPipelineErrorInit +webidl.converters["GPUPipelineErrorInit"] = webidl.createDictionaryConverter( + "GPUPipelineErrorInit", + [ + { + key: "reason", + converter: webidl.converters.GPUPipelineErrorReason, + required: true, + }, + ], +); + +// ENUM: GPUPipelineErrorReason +webidl.converters["GPUPipelineErrorReason"] = webidl.createEnumConverter( + "GPUPipelineErrorReason", + [ + "validation", + "internal", + ], +); + // TYPEDEF: GPUSize32 webidl.converters["GPUSize32"] = (V, opts) => webidl.converters["unsigned long"](V, { ...opts, enforceRange: true }); @@ -5198,6 +5632,7 @@ webidl.converters["GPUTextureFormat"] = webidl.createEnumConverter( "bgra8unorm", "bgra8unorm-srgb", "rgb9e5ufloat", + "rgb10a2uint", "rgb10a2unorm", "rg11b10ufloat", "rg32uint", @@ -5613,6 +6048,8 @@ webidl.converters["GPUStorageTextureAccess"] = webidl.createEnumConverter( "GPUStorageTextureAccess", [ "write-only", + "read-only", + "read-write", ], ); @@ -5872,7 +6309,6 @@ const dictMembersGPUProgrammableStage = [ { key: "entryPoint", converter: webidl.converters["USVString"], - required: true, }, { key: "constants", @@ -5955,6 +6391,7 @@ webidl.converters["GPUVertexFormat"] = webidl.createEnumConverter( "sint32x2", "sint32x3", "sint32x4", + "unorm10-10-10-2", ], ); @@ -6915,7 +7352,7 @@ webidl.converters["GPUErrorFilter"] = webidl.createEnumConverter( [ "out-of-memory", "validation", - "internal" + "internal", ], ); @@ -6962,6 +7399,78 @@ webidl.converters["GPUSignedOffset32"] = (V, opts) => // TYPEDEF: GPUFlagsConstant webidl.converters["GPUFlagsConstant"] = webidl.converters["unsigned long"]; +// ENUM: GPUCanvasAlphaMode +webidl.converters["GPUCanvasAlphaMode"] = webidl.createEnumConverter( + "GPUCanvasAlphaMode", + [ + "opaque", + "premultiplied", + ], +); + +// NON-SPEC: ENUM: GPUPresentMode +webidl.converters["GPUPresentMode"] = webidl.createEnumConverter( + "GPUPresentMode", + [ + "autoVsync", + "autoNoVsync", + "fifo", + "fifoRelaxed", + "immediate", + "mailbox", + ], +); + +// DICT: GPUCanvasConfiguration +const dictMembersGPUCanvasConfiguration = [ + { key: "device", converter: webidl.converters.GPUDevice, required: true }, + { + key: "format", + converter: webidl.converters.GPUTextureFormat, + required: true, + }, + { + key: "usage", + converter: webidl.converters["GPUTextureUsageFlags"], + defaultValue: GPUTextureUsage.RENDER_ATTACHMENT, + }, + { + key: "alphaMode", + converter: webidl.converters["GPUCanvasAlphaMode"], + defaultValue: "opaque", + }, + + // Extended from spec + { + key: "presentMode", + converter: webidl.converters["GPUPresentMode"], + }, + { + key: "width", + converter: webidl.converters["long"], + required: true, + }, + { + key: "height", + converter: webidl.converters["long"], + required: true, + }, + { + key: "viewFormats", + converter: webidl.createSequenceConverter( + webidl.converters["GPUTextureFormat"], + ), + get defaultValue() { + return []; + }, + }, +]; +webidl.converters["GPUCanvasConfiguration"] = webidl + .createDictionaryConverter( + "GPUCanvasConfiguration", + dictMembersGPUCanvasConfiguration, + ); + const gpu = webidl.createBranded(GPU); export { _device, @@ -6983,6 +7492,7 @@ export { GPUDevice, GPUDeviceLostInfo, GPUError, + GPUInternalError, GPUMapMode, GPUOutOfMemoryError, GPUPipelineLayout, @@ -7000,5 +7510,6 @@ export { GPUTexture, GPUTextureUsage, GPUTextureView, + GPUUncapturedErrorEvent, GPUValidationError, }; diff --git a/deno_webgpu/02_surface.js b/deno_webgpu/02_surface.js index d16f5c245d..f35f745af4 100644 --- a/deno_webgpu/02_surface.js +++ b/deno_webgpu/02_surface.js @@ -1,4 +1,4 @@ -// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. +// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // @ts-check /// @@ -6,27 +6,32 @@ /// /// -const core = globalThis.Deno.core; -const ops = core.ops; -import * as webidl from "ext:deno_webidl/00_webidl.js"; -const primordials = globalThis.__bootstrap.primordials; -const { Symbol } = primordials; +import { primordials } from "ext:core/mod.js"; import { - _device, - assertDevice, - createGPUTexture, - GPUTextureUsage, -} from "ext:deno_webgpu/01_webgpu.js"; + op_webgpu_surface_configure, + op_webgpu_surface_create, + op_webgpu_surface_get_current_texture, + op_webgpu_surface_present, +} from "ext:core/ops"; +const { + ObjectPrototypeIsPrototypeOf, + Symbol, + SymbolFor, + TypeError, +} = primordials; + +import * as webidl from "ext:deno_webidl/00_webidl.js"; +import { createFilteredInspectProxy } from "ext:deno_console/01_console.js"; +import { loadWebGPU } from "ext:deno_webgpu/00_init.js"; const _surfaceRid = Symbol("[[surfaceRid]]"); const _configuration = Symbol("[[configuration]]"); const _canvas = Symbol("[[canvas]]"); const _currentTexture = Symbol("[[currentTexture]]"); +const _present = Symbol("[[present]]"); class GPUCanvasContext { /** @type {number} */ [_surfaceRid]; - /** @type {InnerGPUDevice} */ - [_device]; [_configuration]; [_canvas]; /** @type {GPUTexture | undefined} */ @@ -50,11 +55,15 @@ class GPUCanvasContext { context: "Argument 1", }); + const { _device, assertDevice } = loadWebGPU(); this[_device] = configuration.device[_device]; this[_configuration] = configuration; - const device = assertDevice(this, { prefix, context: "configuration.device" }); + const device = assertDevice(this, { + prefix, + context: "configuration.device", + }); - const { err } = ops.op_webgpu_surface_configure({ + const { err } = op_webgpu_surface_configure({ surfaceRid: this[_surfaceRid], deviceRid: device.rid, format: configuration.format, @@ -69,6 +78,8 @@ class GPUCanvasContext { } unconfigure() { + const { _device } = loadWebGPU(); + webidl.assertBranded(this, GPUCanvasContextPrototype); this[_configuration] = null; @@ -77,11 +88,13 @@ class GPUCanvasContext { getCurrentTexture() { webidl.assertBranded(this, GPUCanvasContextPrototype); - const prefix = "Failed to execute 'getCurrentTexture' on 'GPUCanvasContext'"; + const prefix = + "Failed to execute 'getCurrentTexture' on 'GPUCanvasContext'"; if (this[_configuration] === null) { throw new DOMException("context is not configured.", "InvalidStateError"); } + const { createGPUTexture, assertDevice } = loadWebGPU(); const device = assertDevice(this, { prefix, context: "this" }); @@ -89,7 +102,10 @@ class GPUCanvasContext { return this[_currentTexture]; } - const { rid } = ops.op_webgpu_surface_get_current_texture(device.rid, this[_surfaceRid]); + const { rid } = op_webgpu_surface_get_current_texture( + device.rid, + this[_surfaceRid], + ); const texture = createGPUTexture( { @@ -112,102 +128,66 @@ class GPUCanvasContext { return texture; } - // Extended from spec. Required to present the texture; browser don't need this. - present() { + // Required to present the texture; browser don't need this. + [_present]() { + const { assertDevice } = loadWebGPU(); + webidl.assertBranded(this, GPUCanvasContextPrototype); const prefix = "Failed to execute 'present' on 'GPUCanvasContext'"; - const device = assertDevice(this[_currentTexture], { prefix, context: "this" }); - ops.op_webgpu_surface_present(device.rid, this[_surfaceRid]); + const device = assertDevice(this[_currentTexture], { + prefix, + context: "this", + }); + op_webgpu_surface_present(device.rid, this[_surfaceRid]); this[_currentTexture].destroy(); this[_currentTexture] = undefined; } + + [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { + return inspect( + createFilteredInspectProxy({ + object: this, + evaluate: ObjectPrototypeIsPrototypeOf(GPUCanvasContextPrototype, this), + keys: [ + "canvas", + ], + }), + inspectOptions, + ); + } } const GPUCanvasContextPrototype = GPUCanvasContext.prototype; function createCanvasContext(options) { + // lazy load webgpu if needed const canvasContext = webidl.createBranded(GPUCanvasContext); canvasContext[_surfaceRid] = options.surfaceRid; canvasContext[_canvas] = options.canvas; return canvasContext; } -// Converters - -// ENUM: GPUCanvasAlphaMode -webidl.converters["GPUCanvasAlphaMode"] = webidl.createEnumConverter( - "GPUCanvasAlphaMode", - [ - "opaque", - "premultiplied", - ], -); - -// NON-SPEC: ENUM: GPUPresentMode -webidl.converters["GPUPresentMode"] = webidl.createEnumConverter( - "GPUPresentMode", - [ - "autoVsync", - "autoNoVsync", - "fifo", - "fifoRelaxed", - "immediate", - "mailbox", - ], -); - -// DICT: GPUCanvasConfiguration -const dictMembersGPUCanvasConfiguration = [ - { key: "device", converter: webidl.converters.GPUDevice, required: true }, - { - key: "format", - converter: webidl.converters.GPUTextureFormat, - required: true, - }, - { - key: "usage", - converter: webidl.converters["GPUTextureUsageFlags"], - defaultValue: GPUTextureUsage.RENDER_ATTACHMENT, - }, - { - key: "alphaMode", - converter: webidl.converters["GPUCanvasAlphaMode"], - defaultValue: "opaque", - }, - - // Extended from spec - { - key: "presentMode", - converter: webidl.converters["GPUPresentMode"], - }, - { - key: "width", - converter: webidl.converters["long"], - required: true, - }, - { - key: "height", - converter: webidl.converters["long"], - required: true, - }, - { - key: "viewFormats", - converter: webidl.createSequenceConverter( - webidl.converters["GPUTextureFormat"], - ), - get defaultValue() { - return []; - }, - }, -]; -webidl.converters["GPUCanvasConfiguration"] = webidl - .createDictionaryConverter( - "GPUCanvasConfiguration", - dictMembersGPUCanvasConfiguration, - ); - - -window.__bootstrap.webgpu = { - ...window.__bootstrap.webgpu, - GPUCanvasContext, - createCanvasContext, -}; +// External webgpu surfaces + +// TODO(@littledivy): This will extend `OffscreenCanvas` when we add it. +class UnsafeWindowSurface { + #ctx; + #surfaceRid; + + constructor(system, win, display) { + this.#surfaceRid = op_webgpu_surface_create(system, win, display); + } + + getContext(context) { + if (context !== "webgpu") { + throw new TypeError("Only 'webgpu' context is supported."); + } + this.#ctx = createCanvasContext({ surfaceRid: this.#surfaceRid }); + return this.#ctx; + } + + present() { + this.#ctx[_present](); + } +} + +export { GPUCanvasContext, UnsafeWindowSurface }; diff --git a/deno_webgpu/Cargo.toml b/deno_webgpu/Cargo.toml index 9f6d96a95b..586eb90c85 100644 --- a/deno_webgpu/Cargo.toml +++ b/deno_webgpu/Cargo.toml @@ -1,8 +1,8 @@ -# Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. +# Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. [package] name = "deno_webgpu" -version = "0.85.0" +version = "0.110.0" authors = ["the Deno authors"] edition.workspace = true license = "MIT" @@ -13,9 +13,6 @@ description = "WebGPU implementation for Deno" [lib] path = "lib.rs" -[features] -surface = ["wgpu-core/raw-window-handle", "dep:raw-window-handle"] - # We make all dependencies conditional on not being wasm, # so the whole workspace can built as wasm. [target.'cfg(not(target_arch = "wasm32"))'.dependencies] @@ -23,11 +20,11 @@ deno_core.workspace = true serde = { workspace = true, features = ["derive"] } tokio = { workspace = true, features = ["full"] } wgpu-types = { workspace = true, features = ["serde"] } -raw-window-handle = { workspace = true, optional = true } +raw-window-handle = { workspace = true } [target.'cfg(not(target_arch = "wasm32"))'.dependencies.wgpu-core] workspace = true -features = ["trace", "replay", "serde", "strict_asserts", "wgsl", "gles"] +features = ["raw-window-handle", "trace", "replay", "serde", "strict_asserts", "wgsl", "gles"] # We want the wgpu-core Metal backend on macOS and iOS. [target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies.wgpu-core] diff --git a/deno_webgpu/LICENSE.md b/deno_webgpu/LICENSE.md index aec557f3a0..56753af367 100644 --- a/deno_webgpu/LICENSE.md +++ b/deno_webgpu/LICENSE.md @@ -1,6 +1,6 @@ MIT License -Copyright 2018-2023 the Deno authors +Copyright 2018-2024 the Deno authors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/deno_webgpu/README.md b/deno_webgpu/README.md index 1cf031cda2..c419bfc60e 100644 --- a/deno_webgpu/README.md +++ b/deno_webgpu/README.md @@ -2,8 +2,8 @@ This op crate implements the WebGPU API as defined in https://gpuweb.github.io/gpuweb/ in Deno. The implementation targets the spec -draft as of February 22, 2021. The spec is still very much in flux. This op -crate tries to stay up to date with the spec, but is constrained by the features +draft as of March 31, 2024. The spec is still very much in flux. This extension +tries to stay up to date with the spec, but is constrained by the features implemented in our GPU backend library [wgpu](https://github.com/gfx-rs/wgpu). The spec is still very bare bones, and is still missing many details. As the diff --git a/deno_webgpu/binding.rs b/deno_webgpu/binding.rs index c0b9b5836d..0efeb6716a 100644 --- a/deno_webgpu/binding.rs +++ b/deno_webgpu/binding.rs @@ -1,4 +1,4 @@ -// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. +// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. use deno_core::error::AnyError; use deno_core::op2; @@ -112,25 +112,11 @@ impl From for wgpu_types::TextureSampleType { #[derive(Deserialize)] #[serde(rename_all = "camelCase")] struct GpuStorageTextureBindingLayout { - access: GpuStorageTextureAccess, + access: wgpu_types::StorageTextureAccess, format: wgpu_types::TextureFormat, view_dimension: wgpu_types::TextureViewDimension, } -#[derive(Deserialize)] -#[serde(rename_all = "kebab-case")] -enum GpuStorageTextureAccess { - WriteOnly, -} - -impl From for wgpu_types::StorageTextureAccess { - fn from(access: GpuStorageTextureAccess) -> Self { - match access { - GpuStorageTextureAccess::WriteOnly => wgpu_types::StorageTextureAccess::WriteOnly, - } - } -} - #[derive(Deserialize)] #[serde(rename_all = "camelCase")] pub struct GpuBindGroupLayoutEntry { @@ -165,7 +151,7 @@ impl From for wgpu_types::BindingType { }, GpuBindingType::StorageTexture(storage_texture) => { wgpu_types::BindingType::StorageTexture { - access: storage_texture.access.into(), + access: storage_texture.access, format: storage_texture.format, view_dimension: storage_texture.view_dimension, } diff --git a/deno_webgpu/buffer.rs b/deno_webgpu/buffer.rs index 9a2ebb003b..5b7d208806 100644 --- a/deno_webgpu/buffer.rs +++ b/deno_webgpu/buffer.rs @@ -1,4 +1,4 @@ -// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. +// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. use deno_core::error::type_error; use deno_core::error::AnyError; @@ -163,6 +163,7 @@ pub fn op_webgpu_buffer_get_mapped_range( )) .map_err(|e| DomExceptionOperationError::new(&e.to_string()))?; + // SAFETY: guarantee to be safe from wgpu let slice = unsafe { std::slice::from_raw_parts_mut(slice_pointer, range_size as usize) }; buf.copy_from_slice(slice); @@ -189,6 +190,7 @@ pub fn op_webgpu_buffer_unmap( let buffer = buffer_resource.1; if let Some(buf) = buf { + // SAFETY: guarantee to be safe from wgpu let slice = unsafe { std::slice::from_raw_parts_mut(mapped_resource.0, mapped_resource.1) }; slice.copy_from_slice(buf); } diff --git a/deno_webgpu/bundle.rs b/deno_webgpu/bundle.rs index d503599313..dfe5ccf494 100644 --- a/deno_webgpu/bundle.rs +++ b/deno_webgpu/bundle.rs @@ -1,4 +1,4 @@ -// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. +// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. use deno_core::error::type_error; use deno_core::error::AnyError; diff --git a/deno_webgpu/byow.rs b/deno_webgpu/byow.rs new file mode 100644 index 0000000000..3042f46ee8 --- /dev/null +++ b/deno_webgpu/byow.rs @@ -0,0 +1,115 @@ +// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. + +use deno_core::error::type_error; +use deno_core::error::AnyError; +use deno_core::op2; +use deno_core::OpState; +use deno_core::ResourceId; +use std::ffi::c_void; +use std::ptr::NonNull; + +use crate::surface::WebGpuSurface; + +#[op2(fast)] +#[smi] +pub fn op_webgpu_surface_create( + state: &mut OpState, + #[string] system: &str, + p1: *const c_void, + p2: *const c_void, +) -> Result { + let instance = state.borrow::(); + // Security note: + // + // The `p1` and `p2` parameters are pointers to platform-specific window + // handles. + // + // The code below works under the assumption that: + // + // - handles can only be created by the FFI interface which + // enforces --allow-ffi. + // + // - `*const c_void` deserizalizes null and v8::External. + // + // - Only FFI can export v8::External to user code. + if p1.is_null() { + return Err(type_error("Invalid parameters")); + } + + let (win_handle, display_handle) = raw_window(system, p1, p2)?; + let surface = unsafe { instance.instance_create_surface(display_handle, win_handle, None)? }; + + let rid = state + .resource_table + .add(WebGpuSurface(instance.clone(), surface)); + Ok(rid) +} + +type RawHandles = ( + raw_window_handle::RawWindowHandle, + raw_window_handle::RawDisplayHandle, +); + +#[cfg(target_os = "macos")] +fn raw_window( + system: &str, + _ns_window: *const c_void, + ns_view: *const c_void, +) -> Result { + if system != "cocoa" { + return Err(type_error("Invalid system on macOS")); + } + + let win_handle = + raw_window_handle::RawWindowHandle::AppKit(raw_window_handle::AppKitWindowHandle::new( + NonNull::new(ns_view as *mut c_void).ok_or(type_error("ns_view is null"))?, + )); + + let display_handle = + raw_window_handle::RawDisplayHandle::AppKit(raw_window_handle::AppKitDisplayHandle::new()); + Ok((win_handle, display_handle)) +} + +#[cfg(target_os = "windows")] +fn raw_window( + system: &str, + window: *const c_void, + hinstance: *const c_void, +) -> Result { + use raw_window_handle::WindowsDisplayHandle; + if system != "win32" { + return Err(type_error("Invalid system on Windows")); + } + + let win_handle = { + let mut handle = raw_window_handle::Win32WindowHandle::new(); + handle.hwnd = window as *mut c_void; + handle.hinstance = hinstance as *mut c_void; + + raw_window_handle::RawWindowHandle::Win32(handle) + }; + + let display_handle = raw_window_handle::RawDisplayHandle::Windows(WindowsDisplayHandle::new()); + Ok((win_handle, display_handle)) +} + +#[cfg(target_os = "linux")] +fn raw_window( + system: &str, + window: *const c_void, + display: *const c_void, +) -> Result { + if system != "x11" { + return Err(type_error("Invalid system on Linux")); + } + + let win_handle = raw_window_handle::RawWindowHandle::Xlib( + raw_window_handle::XlibWindowHandle::new(window as *mut c_void as _), + ); + + let display_handle = raw_window_handle::RawDisplayHandle::Xlib( + raw_window_handle::XlibDisplayHandle::new(NonNull::new(display as *mut c_void), 0), + ); + + Ok((win_handle, display_handle)) +} diff --git a/deno_webgpu/command_encoder.rs b/deno_webgpu/command_encoder.rs index 679ac3cabf..20dfe0db09 100644 --- a/deno_webgpu/command_encoder.rs +++ b/deno_webgpu/command_encoder.rs @@ -1,4 +1,4 @@ -// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. +// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. use crate::WebGpuQuerySet; use deno_core::error::AnyError; diff --git a/deno_webgpu/compute_pass.rs b/deno_webgpu/compute_pass.rs index e1c9e29193..65ac93d632 100644 --- a/deno_webgpu/compute_pass.rs +++ b/deno_webgpu/compute_pass.rs @@ -1,4 +1,4 @@ -// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. +// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. use deno_core::error::AnyError; use deno_core::op2; diff --git a/deno_webgpu/error.rs b/deno_webgpu/error.rs index 6c509a80d3..bb82008992 100644 --- a/deno_webgpu/error.rs +++ b/deno_webgpu/error.rs @@ -1,4 +1,5 @@ -// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. +// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. + use deno_core::error::AnyError; use deno_core::ResourceId; use serde::Serialize; @@ -23,7 +24,6 @@ use wgpu_core::device::DeviceError; use wgpu_core::pipeline::CreateComputePipelineError; use wgpu_core::pipeline::CreateRenderPipelineError; use wgpu_core::pipeline::CreateShaderModuleError; -#[cfg(feature = "surface")] use wgpu_core::present::ConfigureSurfaceError; use wgpu_core::resource::BufferAccessError; use wgpu_core::resource::CreateBufferError; @@ -87,6 +87,7 @@ pub enum WebGpuError { Lost, OutOfMemory, Validation(String), + Internal, } impl From for WebGpuError { @@ -277,7 +278,6 @@ impl From for WebGpuError { } } -#[cfg(feature = "surface")] impl From for WebGpuError { fn from(err: ConfigureSurfaceError) -> Self { WebGpuError::Validation(fmt_err(&err)) diff --git a/deno_webgpu/lib.rs b/deno_webgpu/lib.rs index 40e76e0fa5..453d4ea7e3 100644 --- a/deno_webgpu/lib.rs +++ b/deno_webgpu/lib.rs @@ -1,4 +1,4 @@ -// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. +// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. #![cfg(not(target_arch = "wasm32"))] #![warn(unsafe_op_in_unsafe_fn)] @@ -19,6 +19,8 @@ pub use wgpu_types; use error::DomExceptionOperationError; use error::WebGpuResult; +pub const UNSTABLE_FEATURE_NAME: &str = "webgpu"; + #[macro_use] mod macros { macro_rules! gfx_select { @@ -71,6 +73,7 @@ mod macros { pub mod binding; pub mod buffer; pub mod bundle; +pub mod byow; pub mod command_encoder; pub mod compute_pass; pub mod error; @@ -79,23 +82,9 @@ pub mod queue; pub mod render_pass; pub mod sampler; pub mod shader; -#[cfg(feature = "surface")] pub mod surface; pub mod texture; -pub struct Unstable(pub bool); - -fn check_unstable(state: &OpState, api_name: &str) { - let unstable = state.borrow::(); - if !unstable.0 { - eprintln!( - "Unstable API '{}'. The --unstable flag must be provided.", - api_name - ); - std::process::exit(70); - } -} - pub type Instance = std::sync::Arc; struct WebGpuAdapter(Instance, wgpu_core::id::AdapterId); @@ -224,12 +213,15 @@ deno_core::extension!( queue::op_webgpu_write_texture, // shader shader::op_webgpu_create_shader_module, + // surface + surface::op_webgpu_surface_configure, + surface::op_webgpu_surface_get_current_texture, + surface::op_webgpu_surface_present, + // byow + byow::op_webgpu_surface_create, ], - esm = ["01_webgpu.js"], - options = { unstable: bool }, - state = |state, options| { - state.put(Unstable(options.unstable)); - }, + esm = ["00_init.js", "02_surface.js"], + lazy_loaded_esm = ["01_webgpu.js"], ); fn deserialize_features(features: &wgpu_types::Features) -> Vec<&'static str> { @@ -377,29 +369,45 @@ fn deserialize_features(features: &wgpu_types::Features) -> Vec<&'static str> { #[derive(Serialize)] #[serde(untagged)] -pub enum GpuAdapterDeviceOrErr { +pub enum GpuAdapterResOrErr { Error { err: String }, - Features(GpuAdapterDevice), + Features(GpuAdapterRes), } #[derive(Serialize)] #[serde(rename_all = "camelCase")] -pub struct GpuAdapterDevice { +pub struct GpuAdapterRes { rid: ResourceId, limits: wgpu_types::Limits, features: Vec<&'static str>, is_software: bool, } -#[op2(async)] +#[derive(Serialize)] +#[serde(rename_all = "camelCase")] +pub struct GpuDeviceRes { + rid: ResourceId, + queue_rid: ResourceId, + limits: wgpu_types::Limits, + features: Vec<&'static str>, + is_software: bool, +} + +#[op2] #[serde] -pub async fn op_webgpu_request_adapter( +pub fn op_webgpu_request_adapter( state: Rc>, #[serde] power_preference: Option, force_fallback_adapter: bool, -) -> Result { +) -> Result { let mut state = state.borrow_mut(); - check_unstable(&state, "navigator.gpu.requestAdapter"); + + // TODO(bartlomieju): replace with `state.feature_checker.check_or_exit` + // once we phase out `check_or_exit_with_legacy_fallback` + state + .feature_checker + .check_or_exit_with_legacy_fallback(UNSTABLE_FEATURE_NAME, "navigator.gpu.requestAdapter"); + let backends = std::env::var("DENO_WEBGPU_BACKEND").map_or_else( |_| wgpu_types::Backends::all(), |s| wgpu_core::instance::parse_backends_from_comma_list(&s), @@ -432,7 +440,7 @@ pub async fn op_webgpu_request_adapter( let adapter = match res { Ok(adapter) => adapter, Err(err) => { - return Ok(GpuAdapterDeviceOrErr::Error { + return Ok(GpuAdapterResOrErr::Error { err: err.to_string(), }) } @@ -445,7 +453,7 @@ pub async fn op_webgpu_request_adapter( let rid = state.resource_table.add(WebGpuAdapter(instance, adapter)); - Ok(GpuAdapterDeviceOrErr::Features(GpuAdapterDevice { + Ok(GpuAdapterResOrErr::Features(GpuAdapterRes { rid, features, limits: adapter_limits, @@ -649,15 +657,15 @@ impl From for wgpu_types::Features { } } -#[op2(async)] +#[op2] #[serde] -pub async fn op_webgpu_request_device( +pub fn op_webgpu_request_device( state: Rc>, #[smi] adapter_rid: ResourceId, #[string] label: String, #[serde] required_features: GpuRequiredFeatures, #[serde] required_limits: Option, -) -> Result { +) -> Result { let mut state = state.borrow_mut(); let adapter_resource = state.resource_table.get::(adapter_rid)?; let adapter = adapter_resource.1; @@ -669,7 +677,7 @@ pub async fn op_webgpu_request_device( required_limits: required_limits.unwrap_or_default(), }; - let (device, _queue, maybe_err) = gfx_select!(adapter => instance.adapter_request_device( + let (device, queue, maybe_err) = gfx_select!(adapter => instance.adapter_request_device( adapter, &descriptor, std::env::var("DENO_WEBGPU_TRACE").ok().as_ref().map(std::path::Path::new), @@ -685,10 +693,15 @@ pub async fn op_webgpu_request_device( let limits = gfx_select!(device => instance.device_limits(device))?; let instance = instance.clone(); + let instance2 = instance.clone(); let rid = state.resource_table.add(WebGpuDevice(instance, device)); + let queue_rid = state + .resource_table + .add(queue::WebGpuQueue(instance2, queue)); - Ok(GpuAdapterDevice { + Ok(GpuDeviceRes { rid, + queue_rid, features, limits, // TODO(lucacasonato): report correctly from wgpu @@ -705,9 +718,9 @@ pub struct GPUAdapterInfo { description: String, } -#[op2(async)] +#[op2] #[serde] -pub async fn op_webgpu_request_adapter_info( +pub fn op_webgpu_request_adapter_info( state: Rc>, #[smi] adapter_rid: ResourceId, ) -> Result { diff --git a/deno_webgpu/pipeline.rs b/deno_webgpu/pipeline.rs index 9175fe2075..ab7cf42e7b 100644 --- a/deno_webgpu/pipeline.rs +++ b/deno_webgpu/pipeline.rs @@ -1,4 +1,4 @@ -// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. +// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. use deno_core::error::AnyError; use deno_core::op2; @@ -74,7 +74,7 @@ pub enum GPUPipelineLayoutOrGPUAutoLayoutMode { #[serde(rename_all = "camelCase")] pub struct GpuProgrammableStage { module: ResourceId, - entry_point: String, + entry_point: Option, // constants: HashMap } @@ -110,7 +110,7 @@ pub fn op_webgpu_create_compute_pipeline( layout: pipeline_layout, stage: wgpu_core::pipeline::ProgrammableStageDescriptor { module: compute_shader_module_resource.1, - entry_point: Cow::from(compute.entry_point), + entry_point: compute.entry_point.map(Cow::from), // TODO(lucacasonato): support args.compute.constants }, }; @@ -355,7 +355,7 @@ pub fn op_webgpu_create_render_pipeline( Some(wgpu_core::pipeline::FragmentState { stage: wgpu_core::pipeline::ProgrammableStageDescriptor { module: fragment_shader_module_resource.1, - entry_point: Cow::from(fragment.entry_point), + entry_point: Some(Cow::from(fragment.entry_point)), }, targets: Cow::from(fragment.targets), }) @@ -377,7 +377,7 @@ pub fn op_webgpu_create_render_pipeline( vertex: wgpu_core::pipeline::VertexState { stage: wgpu_core::pipeline::ProgrammableStageDescriptor { module: vertex_shader_module_resource.1, - entry_point: Cow::Owned(args.vertex.entry_point), + entry_point: Some(Cow::Owned(args.vertex.entry_point)), }, buffers: Cow::Owned(vertex_buffers), }, diff --git a/deno_webgpu/queue.rs b/deno_webgpu/queue.rs index 61b56c7586..2640134455 100644 --- a/deno_webgpu/queue.rs +++ b/deno_webgpu/queue.rs @@ -1,16 +1,28 @@ -// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. +// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. use crate::command_encoder::WebGpuCommandBuffer; +use crate::Instance; use deno_core::error::AnyError; use deno_core::op2; use deno_core::OpState; use deno_core::Resource; use deno_core::ResourceId; use serde::Deserialize; +use std::borrow::Cow; +use std::rc::Rc; use super::error::WebGpuResult; -type WebGpuQueue = super::WebGpuDevice; +pub struct WebGpuQueue(pub Instance, pub wgpu_core::id::QueueId); +impl Resource for WebGpuQueue { + fn name(&self) -> Cow { + "webGPUQueue".into() + } + + fn close(self: Rc) { + gfx_select!(self.1 => self.0.queue_drop(self.1)); + } +} #[op2] #[serde] @@ -19,7 +31,7 @@ pub fn op_webgpu_queue_submit( #[smi] queue_rid: ResourceId, #[serde] command_buffers: Vec, ) -> Result { - let instance = state.borrow::(); + let instance = state.borrow::(); let queue_resource = state.resource_table.get::(queue_rid)?; let queue = queue_resource.1; @@ -32,7 +44,7 @@ pub fn op_webgpu_queue_submit( }) .collect::, AnyError>>()?; - let maybe_err = gfx_select!(queue => instance.queue_submit(queue.transmute(), &ids)).err(); + let maybe_err = gfx_select!(queue => instance.queue_submit(queue, &ids)).err(); for rid in command_buffers { let resource = state.resource_table.take::(rid)?; @@ -71,7 +83,7 @@ pub fn op_webgpu_write_buffer( #[number] size: Option, #[buffer] buf: &[u8], ) -> Result { - let instance = state.borrow::(); + let instance = state.borrow::(); let buffer_resource = state .resource_table .get::(buffer)?; @@ -84,7 +96,7 @@ pub fn op_webgpu_write_buffer( None => &buf[data_offset..], }; let maybe_err = gfx_select!(queue => instance.queue_write_buffer( - queue.transmute(), + queue, buffer, buffer_offset, data @@ -104,7 +116,7 @@ pub fn op_webgpu_write_texture( #[serde] size: wgpu_types::Extent3d, #[buffer] buf: &[u8], ) -> Result { - let instance = state.borrow::(); + let instance = state.borrow::(); let texture_resource = state .resource_table .get::(destination.texture)?; @@ -120,7 +132,7 @@ pub fn op_webgpu_write_texture( let data_layout = data_layout.into(); gfx_ok!(queue => instance.queue_write_texture( - queue.transmute(), + queue, &destination, buf, &data_layout, diff --git a/deno_webgpu/render_pass.rs b/deno_webgpu/render_pass.rs index 47b98c91fd..11b2f22865 100644 --- a/deno_webgpu/render_pass.rs +++ b/deno_webgpu/render_pass.rs @@ -1,4 +1,4 @@ -// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. +// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. use deno_core::error::type_error; use deno_core::error::AnyError; diff --git a/deno_webgpu/sampler.rs b/deno_webgpu/sampler.rs index 0d65d727a1..822c4bda14 100644 --- a/deno_webgpu/sampler.rs +++ b/deno_webgpu/sampler.rs @@ -1,4 +1,4 @@ -// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. +// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. use deno_core::error::AnyError; use deno_core::op2; diff --git a/deno_webgpu/shader.rs b/deno_webgpu/shader.rs index f4604a04a5..17cde43936 100644 --- a/deno_webgpu/shader.rs +++ b/deno_webgpu/shader.rs @@ -1,4 +1,4 @@ -// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. +// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. use deno_core::error::AnyError; use deno_core::op2; diff --git a/deno_webgpu/surface.rs b/deno_webgpu/surface.rs index 4d8412999c..a8b984eefe 100644 --- a/deno_webgpu/surface.rs +++ b/deno_webgpu/surface.rs @@ -1,4 +1,4 @@ -// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. +// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. use super::WebGpuResult; use deno_core::error::AnyError; @@ -11,21 +11,6 @@ use std::borrow::Cow; use std::rc::Rc; use wgpu_types::SurfaceStatus; -deno_core::extension!( - deno_webgpu_surface, - deps = [deno_webidl, deno_web, deno_webgpu], - ops = [ - op_webgpu_surface_configure, - op_webgpu_surface_get_current_texture, - op_webgpu_surface_present, - ], - esm = ["02_surface.js"], - options = { unstable: bool }, - state = |state, options| { - state.put(super::Unstable(options.unstable)); - }, -); - pub struct WebGpuSurface(pub crate::Instance, pub wgpu_core::id::SurfaceId); impl Resource for WebGpuSurface { fn name(&self) -> Cow { diff --git a/deno_webgpu/texture.rs b/deno_webgpu/texture.rs index a9be7b9914..2dc1a740a5 100644 --- a/deno_webgpu/texture.rs +++ b/deno_webgpu/texture.rs @@ -1,4 +1,4 @@ -// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. +// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. use deno_core::error::AnyError; use deno_core::op2; diff --git a/deno_webgpu/webgpu.idl b/deno_webgpu/webgpu.idl index 46d587874f..07d9d60ec7 100644 --- a/deno_webgpu/webgpu.idl +++ b/deno_webgpu/webgpu.idl @@ -6,7 +6,7 @@ dictionary GPUObjectDescriptorBase { USVString label = ""; }; -[Exposed=(Window, DedicatedWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUSupportedLimits { readonly attribute unsigned long maxTextureDimension1D; readonly attribute unsigned long maxTextureDimension2D; @@ -30,6 +30,8 @@ interface GPUSupportedLimits { readonly attribute unsigned long maxVertexAttributes; readonly attribute unsigned long maxVertexBufferArrayStride; readonly attribute unsigned long maxInterStageShaderComponents; + readonly attribute unsigned long maxColorAttachments; + readonly attribute unsigned long maxColorAttachmentBytesPerSample; readonly attribute unsigned long maxComputeWorkgroupStorageSize; readonly attribute unsigned long maxComputeInvocationsPerWorkgroup; readonly attribute unsigned long maxComputeWorkgroupSizeX; @@ -38,12 +40,12 @@ interface GPUSupportedLimits { readonly attribute unsigned long maxComputeWorkgroupsPerDimension; }; -[Exposed=(Window, DedicatedWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUSupportedFeatures { readonly setlike; }; -[Exposed=(Window, DedicatedWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUAdapterInfo { readonly attribute DOMString vendor; readonly attribute DOMString architecture; @@ -57,9 +59,10 @@ interface mixin NavigatorGPU { Navigator includes NavigatorGPU; WorkerNavigator includes NavigatorGPU; -[Exposed=(Window, DedicatedWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPU { Promise requestAdapter(optional GPURequestAdapterOptions options = {}); + GPUTextureFormat getPreferredCanvasFormat(); }; dictionary GPURequestAdapterOptions { @@ -72,14 +75,14 @@ enum GPUPowerPreference { "high-performance", }; -[Exposed=(Window, DedicatedWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUAdapter { [SameObject] readonly attribute GPUSupportedFeatures features; [SameObject] readonly attribute GPUSupportedLimits limits; readonly attribute boolean isFallbackAdapter; Promise requestDevice(optional GPUDeviceDescriptor descriptor = {}); - Promise requestAdapterInfo(optional sequence unmaskHints = []); + Promise requestAdapterInfo(); }; dictionary GPUDeviceDescriptor @@ -141,7 +144,7 @@ enum GPUFeatureName { "shader-early-depth-test", }; -[Exposed=(Window, DedicatedWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUDevice : EventTarget { [SameObject] readonly attribute GPUSupportedFeatures features; [SameObject] readonly attribute GPUSupportedLimits limits; @@ -171,7 +174,7 @@ interface GPUDevice : EventTarget { }; GPUDevice includes GPUObjectBase; -[Exposed=(Window, DedicatedWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUBuffer { readonly attribute GPUSize64Out size; readonly attribute GPUFlagsConstant usage; @@ -200,7 +203,7 @@ dictionary GPUBufferDescriptor }; typedef [EnforceRange] unsigned long GPUBufferUsageFlags; -[Exposed=(Window, DedicatedWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] namespace GPUBufferUsage { const GPUFlagsConstant MAP_READ = 0x0001; const GPUFlagsConstant MAP_WRITE = 0x0002; @@ -215,13 +218,13 @@ namespace GPUBufferUsage { }; typedef [EnforceRange] unsigned long GPUMapModeFlags; -[Exposed=(Window, DedicatedWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] namespace GPUMapMode { const GPUFlagsConstant READ = 0x0001; const GPUFlagsConstant WRITE = 0x0002; }; -[Exposed=(Window, DedicatedWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUTexture { GPUTextureView createView(optional GPUTextureViewDescriptor descriptor = {}); @@ -256,7 +259,7 @@ enum GPUTextureDimension { }; typedef [EnforceRange] unsigned long GPUTextureUsageFlags; -[Exposed=(Window, DedicatedWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] namespace GPUTextureUsage { const GPUFlagsConstant COPY_SRC = 0x01; const GPUFlagsConstant COPY_DST = 0x02; @@ -265,7 +268,7 @@ namespace GPUTextureUsage { const GPUFlagsConstant RENDER_ATTACHMENT = 0x10; }; -[Exposed=(Window, DedicatedWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUTextureView { }; GPUTextureView includes GPUObjectBase; @@ -328,6 +331,7 @@ enum GPUTextureFormat { "bgra8unorm-srgb", // Packed 32-bit formats "rgb9e5ufloat", + "rgb10a2uint", "rgb10a2unorm", "rg11b10ufloat", @@ -416,7 +420,7 @@ enum GPUTextureFormat { "astc-12x12-unorm-srgb", }; -[Exposed=(Window, DedicatedWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUSampler { }; GPUSampler includes GPUObjectBase; @@ -462,7 +466,7 @@ enum GPUCompareFunction { "always", }; -[Exposed=(Window, DedicatedWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUBindGroupLayout { }; GPUBindGroupLayout includes GPUObjectBase; @@ -483,7 +487,7 @@ dictionary GPUBindGroupLayoutEntry { }; typedef [EnforceRange] unsigned long GPUShaderStageFlags; -[Exposed=(Window, DedicatedWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] namespace GPUShaderStage { const GPUFlagsConstant VERTEX = 0x1; const GPUFlagsConstant FRAGMENT = 0x2; @@ -528,6 +532,8 @@ dictionary GPUTextureBindingLayout { enum GPUStorageTextureAccess { "write-only", + "read-only", + "read-write", }; dictionary GPUStorageTextureBindingLayout { @@ -536,7 +542,7 @@ dictionary GPUStorageTextureBindingLayout { GPUTextureViewDimension viewDimension = "2d"; }; -[Exposed=(Window, DedicatedWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUBindGroup { }; GPUBindGroup includes GPUObjectBase; @@ -560,7 +566,7 @@ dictionary GPUBufferBinding { GPUSize64 size; }; -[Exposed=(Window, DedicatedWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUPipelineLayout { }; GPUPipelineLayout includes GPUObjectBase; @@ -570,7 +576,7 @@ dictionary GPUPipelineLayoutDescriptor required sequence bindGroupLayouts; }; -[Exposed=(Window, DedicatedWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUShaderModule { }; GPUShaderModule includes GPUObjectBase; @@ -586,7 +592,7 @@ enum GPUCompilationMessageType { "info", }; -[Exposed=(Window, DedicatedWorker), Serializable, SecureContext] +[Exposed=(Window, Worker), Serializable, SecureContext] interface GPUCompilationMessage { readonly attribute DOMString message; readonly attribute GPUCompilationMessageType type; @@ -596,11 +602,26 @@ interface GPUCompilationMessage { readonly attribute unsigned long long length; }; -[Exposed=(Window, DedicatedWorker), Serializable, SecureContext] +[Exposed=(Window, Worker), Serializable, SecureContext] interface GPUCompilationInfo { readonly attribute FrozenArray messages; }; +[Exposed=(Window, Worker), SecureContext, Serializable] +interface GPUPipelineError : DOMException { + constructor(optional DOMString message = "", GPUPipelineErrorInit options); + readonly attribute GPUPipelineErrorReason reason; +}; + +dictionary GPUPipelineErrorInit { + required GPUPipelineErrorReason reason; +}; + +enum GPUPipelineErrorReason { + "validation", + "internal", +}; + enum GPUAutoLayoutMode { "auto", }; @@ -616,13 +637,13 @@ interface mixin GPUPipelineBase { dictionary GPUProgrammableStage { required GPUShaderModule module; - required USVString entryPoint; + USVString entryPoint; record constants; }; -typedef double GPUPipelineConstantValue; // May represent WGSL’s bool, f32, i32, u32, and f16 if enabled. +typedef double GPUPipelineConstantValue; // May represent WGSL's bool, f32, i32, u32, and f16 if enabled. -[Exposed=(Window, DedicatedWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUComputePipeline { }; GPUComputePipeline includes GPUObjectBase; @@ -633,7 +654,7 @@ dictionary GPUComputePipelineDescriptor required GPUProgrammableStage compute; }; -[Exposed=(Window, DedicatedWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPURenderPipeline { }; GPURenderPipeline includes GPUObjectBase; @@ -701,7 +722,7 @@ dictionary GPUBlendState { }; typedef [EnforceRange] unsigned long GPUColorWriteFlags; -[Exposed=(Window, DedicatedWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] namespace GPUColorWrite { const GPUFlagsConstant RED = 0x1; const GPUFlagsConstant GREEN = 0x2; @@ -811,6 +832,7 @@ enum GPUVertexFormat { "sint32x2", "sint32x3", "sint32x4", + "unorm10-10-10-2", }; enum GPUVertexStepMode { @@ -854,7 +876,7 @@ dictionary GPUImageCopyTexture { GPUTextureAspect aspect = "all"; }; -[Exposed=(Window, DedicatedWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUCommandBuffer { }; GPUCommandBuffer includes GPUObjectBase; @@ -866,7 +888,7 @@ dictionary GPUCommandBufferDescriptor interface mixin GPUCommandsMixin { }; -[Exposed=(Window, DedicatedWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUCommandEncoder { GPURenderPassEncoder beginRenderPass(GPURenderPassDescriptor descriptor); GPUComputePassEncoder beginComputePass(optional GPUComputePassDescriptor descriptor = {}); @@ -933,7 +955,7 @@ interface mixin GPUDebugCommandsMixin { undefined insertDebugMarker(USVString markerLabel); }; -[Exposed=(Window, DedicatedWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUComputePassEncoder { undefined setPipeline(GPUComputePipeline pipeline); undefined dispatchWorkgroups(GPUSize32 workgroupCountX, optional GPUSize32 workgroupCountY = 1, optional GPUSize32 workgroupCountZ = 1); @@ -957,7 +979,7 @@ dictionary GPUComputePassDescriptor GPUComputePassTimestampWrites timestampWrites; }; -[Exposed=(Window, DedicatedWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPURenderPassEncoder { undefined setViewport(float x, float y, float width, float height, @@ -1052,7 +1074,7 @@ interface mixin GPURenderCommandsMixin { undefined drawIndexedIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset); }; -[Exposed=(Window, DedicatedWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPURenderBundle { }; GPURenderBundle includes GPUObjectBase; @@ -1061,7 +1083,7 @@ dictionary GPURenderBundleDescriptor : GPUObjectDescriptorBase { }; -[Exposed=(Window, DedicatedWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPURenderBundleEncoder { GPURenderBundle finish(optional GPURenderBundleDescriptor descriptor = {}); }; @@ -1077,7 +1099,7 @@ dictionary GPURenderBundleEncoderDescriptor boolean stencilReadOnly = false; }; -[Exposed=(Window, DedicatedWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUQueue { undefined submit(sequence commandBuffers); @@ -1098,7 +1120,7 @@ interface GPUQueue { }; GPUQueue includes GPUObjectBase; -[Exposed=(Window, DedicatedWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUQuerySet { undefined destroy(); @@ -1118,7 +1140,7 @@ enum GPUQueryType { "timestamp", }; -[Exposed=(Window, DedicatedWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUCanvasContext { readonly attribute (HTMLCanvasElement or OffscreenCanvas) canvas; @@ -1146,7 +1168,7 @@ enum GPUDeviceLostReason { "destroyed", }; -[Exposed=(Window, DedicatedWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUDeviceLostInfo { readonly attribute GPUDeviceLostReason reason; readonly attribute DOMString message; @@ -1156,27 +1178,33 @@ partial interface GPUDevice { readonly attribute Promise lost; }; -[Exposed=(Window, DedicatedWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUError { readonly attribute DOMString message; }; -[Exposed=(Window, DedicatedWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUValidationError : GPUError { constructor(DOMString message); }; -[Exposed=(Window, DedicatedWorker), SecureContext] +[Exposed=(Window, Worker), SecureContext] interface GPUOutOfMemoryError : GPUError { constructor(DOMString message); }; +[Exposed=(Window, Worker), SecureContext] +interface GPUInternalError + : GPUError { + constructor(DOMString message); +}; + enum GPUErrorFilter { "validation", "out-of-memory", - "internal" + "internal", }; partial interface GPUDevice { @@ -1184,8 +1212,21 @@ partial interface GPUDevice { Promise popErrorScope(); }; +[Exposed=(Window, Worker), SecureContext] +interface GPUUncapturedErrorEvent : Event { + constructor( + DOMString type, + GPUUncapturedErrorEventInit gpuUncapturedErrorEventInitDict + ); + [SameObject] readonly attribute GPUError error; +}; + +dictionary GPUUncapturedErrorEventInit : EventInit { + required GPUError error; +}; + partial interface GPUDevice { - [Exposed=(Window, DedicatedWorker)] + [Exposed=(Window, Worker)] attribute EventHandler onuncapturederror; }; diff --git a/examples/README.md b/examples/README.md index 8232b863ad..134a71961a 100644 --- a/examples/README.md +++ b/examples/README.md @@ -3,8 +3,8 @@ For the simplest examples without using any helping code (see `framework.rs` here), check out: - `hello` for printing adapter information -- `hello-triangle` for graphics and presentation -- `hello-compute` for pure computing +- `hello_triangle` for graphics and presentation +- `hello_compute` for pure computing ### Summary of examples @@ -18,21 +18,21 @@ The rest of the examples are for demonstrating specific features that you can co #### Graphics -- `hello-triangle` - Provides an example of a bare-bones WGPU workflow using the Winit crate that simply renders a red triangle on a green background. -- `uniform-values` - Demonstrates the basics of enabling shaders and the GPU, in general, to access app state through uniform variables. `uniform-values` also serves as an example of rudimentary app building as the app stores state and takes window-captured keyboard events. The app displays the Mandelbrot Set in grayscale (similar to `storage-texture`) but allows the user to navigate and explore it using their arrow keys and scroll wheel. +- `hello_triangle` - Provides an example of a bare-bones WGPU workflow using the Winit crate that simply renders a red triangle on a green background. +- `uniform_values` - Demonstrates the basics of enabling shaders and the GPU, in general, to access app state through uniform variables. `uniform_values` also serves as an example of rudimentary app building as the app stores state and takes window-captured keyboard events. The app displays the Mandelbrot Set in grayscale (similar to `storage_texture`) but allows the user to navigate and explore it using their arrow keys and scroll wheel. - `cube` - Introduces the user to slightly more advanced models. The example creates a set of triangles to form a cube on the CPU and then uses a vertex and index buffer to send the generated model to the GPU for usage in rendering. It also uses a texture generated on the CPU to shade the sides of the cube and a uniform variable to apply a transformation matrix to the cube in the shader. - `bunnymark` - Demonstrates many things, but chief among them is performing numerous draw calls with different bind groups in one render pass. The example also uses textures for the icon and uniform buffers to transfer both global and per-particle states. -- `skybox` - Shows off too many concepts to list here. The name comes from game development where a "skybox" acts as a background for rendering, usually to add a sky texture for immersion, although they can also be used for backdrops to give the idea of a world beyond the game scene. This example does so much more than this, though, as it uses a car model loaded from a file and uses the user's mouse to rotate the car model in 3d. `skybox` also makes use of depth textures and similar app patterns to `uniform-values`. +- `skybox` - Shows off too many concepts to list here. The name comes from game development where a "skybox" acts as a background for rendering, usually to add a sky texture for immersion, although they can also be used for backdrops to give the idea of a world beyond the game scene. This example does so much more than this, though, as it uses a car model loaded from a file and uses the user's mouse to rotate the car model in 3d. `skybox` also makes use of depth textures and similar app patterns to `uniform_values`. - `shadow` - Likely by far the most complex example (certainly the largest in lines of code) of the official WGPU examples. `shadow` demonstrates basic scene rendering with the main attraction being lighting and shadows (as the name implies). It is recommended that any user looking into lighting be very familiar with the basic concepts of not only rendering with WGPU but also the primary mathematical ideas of computer graphics. -- `render-to-texture` - Renders to an image texture offscreen, demonstrating both off-screen rendering as well as how to add a sort of resolution-agnostic screenshot feature to an engine. This example either outputs an image file of your naming (pass command line arguments after specifying a `--` like `cargo run --bin render-to-texture -- "test.png"`) or adds an `img` element containing the image to the page in WASM. +- `render_to_texture` - Renders to an image texture offscreen, demonstrating both off-screen rendering as well as how to add a sort of resolution-agnostic screenshot feature to an engine. This example either outputs an image file of your naming (pass command line arguments after specifying a `--` like `cargo run --bin wgpu-examples -- render_to_texture "test.png"`) or adds an `img` element containing the image to the page in WASM. #### Compute -- `hello-compute` - Demonstrates the basic workflow for getting arrays of numbers to the GPU, executing a shader on them, and getting the results back. The operation it performs is finding the Collatz value (how many iterations of the [Collatz equation](https://en.wikipedia.org/wiki/Collatz_conjecture) it takes for the number to either reach 1 or overflow) of a set of numbers and prints the results. -- `repeated-compute` - Mostly for going into detail on subjects `hello-compute` did not. It, too, computes the Collatz conjecture, but this time, it automatically loads large arrays of randomly generated numbers, prints them, runs them, and prints the result. It does this cycle 10 times. -- `hello-workgroups` - Teaches the user about the basics of compute workgroups; what they are and what they can do. -- `hello-synchronization` - Teaches the user about synchronization in WGSL, the ability to force all invocations in a workgroup to synchronize with each other before continuing via a sort of barrier. -- `storage-texture` - Demonstrates the use of storage textures as outputs to compute shaders. The example on the outside seems very similar to `render-to-texture` in that it outputs an image either to the file system or the web page, except displaying a grayscale render of the Mandelbrot Set. However, inside, the example dispatches a grid of compute workgroups, one for each pixel, which calculates the pixel value and stores it to the corresponding pixel of the output storage texture. +- `hello_compute` - Demonstrates the basic workflow for getting arrays of numbers to the GPU, executing a shader on them, and getting the results back. The operation it performs is finding the Collatz value (how many iterations of the [Collatz equation](https://en.wikipedia.org/wiki/Collatz_conjecture) it takes for the number to either reach 1 or overflow) of a set of numbers and prints the results. +- `repeated_compute` - Mostly for going into detail on subjects `hello-compute` did not. It, too, computes the Collatz conjecture, but this time, it automatically loads large arrays of randomly generated numbers, prints them, runs them, and prints the result. It does this cycle 10 times. +- `hello_workgroups` - Teaches the user about the basics of compute workgroups; what they are and what they can do. +- `hello_synchronization` - Teaches the user about synchronization in WGSL, the ability to force all invocations in a workgroup to synchronize with each other before continuing via a sort of barrier. +- `storage_texture` - Demonstrates the use of storage textures as outputs to compute shaders. The example on the outside seems very similar to `render_to_texture` in that it outputs an image either to the file system or the web page, except displaying a grayscale render of the Mandelbrot Set. However, inside, the example dispatches a grid of compute workgroups, one for each pixel, which calculates the pixel value and stores it to the corresponding pixel of the output storage texture. This example either outputs an image file of your naming (pass command line arguments after specifying a `--` like `cargo run --bin wgpu-examples -- storage_texture "test.png"`) or adds an `img` element containing the image to the page in WASM. #### Combined @@ -40,7 +40,7 @@ The rest of the examples are for demonstrating specific features that you can co ## Feature matrix -| Feature | boids | bunnymark | conservative-raster | cube | hello-synchronization | hello-workgroups | mipmap | msaa-line | render-to-texture | repeated-compute | shadow | skybox | stencil-triangles | storage-texture | texture-arrays | uniform-values | water | +| Feature | boids | bunnymark | conservative_raster | cube | hello_synchronization | hello_workgroups | mipmap | msaa_line | render_to_texture | repeated_compute | shadow | skybox | stencil_triangles | storage_texture | texture_arrays | uniform_values | water | | ---------------------------- | ------ | --------- | ------------------- | ------ | --------------------- | ---------------- | ------ | --------- | ----------------- | ---------------- | ------ | ------ | ----------------- | --------------- | -------------- | -------------- | ------ | | vertex attributes | :star: | | | :star: | | | | :star: | | | :star: | :star: | | | :star: | | :star: | | instancing | :star: | | | | | | | | | | | | | | | | | @@ -83,7 +83,7 @@ The rest of the examples are for demonstrating specific features that you can co ## Additional notes -Note that the examples regarding computing build off of each other; repeated-compute extends hello-compute, hello-workgroups assumes you know the basic workflow of GPU computation, and hello-synchronization assumes you know what a workgroup is. Also, note that the computing examples cannot be downleveled to WebGL as WebGL does not allow storage textures. Running these in a browser will require that browser to support WebGPU. +Note that the examples regarding computing build off of each other; repeated_compute extends hello_compute, hello_workgroups assumes you know the basic workflow of GPU computation, and hello_synchronization assumes you know what a workgroup is. Also, note that the computing examples cannot be downleveled to WebGL as WebGL does not allow storage textures. Running these in a browser will require that browser to support WebGPU. All the examples use [WGSL](https://gpuweb.github.io/gpuweb/wgsl.html) shaders unless specified otherwise. diff --git a/examples/src/lib.rs b/examples/src/lib.rs index 1a55631097..d212fd404a 100644 --- a/examples/src/lib.rs +++ b/examples/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(clippy::arc_with_non_send_sync)] // False positive on wasm + pub mod framework; pub mod utils; diff --git a/examples/src/mipmap/mod.rs b/examples/src/mipmap/mod.rs index a4600753e9..7551021024 100644 --- a/examples/src/mipmap/mod.rs +++ b/examples/src/mipmap/mod.rs @@ -8,8 +8,8 @@ const MIP_PASS_COUNT: u32 = MIP_LEVEL_COUNT - 1; const QUERY_FEATURES: wgpu::Features = { wgpu::Features::TIMESTAMP_QUERY - .union(wgpu::Features::PIPELINE_STATISTICS_QUERY) .union(wgpu::Features::TIMESTAMP_QUERY_INSIDE_PASSES) + .union(wgpu::Features::PIPELINE_STATISTICS_QUERY) }; fn create_texels(size: usize, cx: f32, cy: f32) -> Vec { diff --git a/examples/src/render_to_texture/mod.rs b/examples/src/render_to_texture/mod.rs index 75d22dfe87..96be26b0f9 100644 --- a/examples/src/render_to_texture/mod.rs +++ b/examples/src/render_to_texture/mod.rs @@ -157,7 +157,7 @@ pub fn main() { .init(); let path = std::env::args() - .nth(1) + .nth(2) .unwrap_or_else(|| "please_don't_git_push_me.png".to_string()); pollster::block_on(run(Some(path))); } diff --git a/examples/src/storage_texture/mod.rs b/examples/src/storage_texture/mod.rs index d389ce139e..d4e207f3bc 100644 --- a/examples/src/storage_texture/mod.rs +++ b/examples/src/storage_texture/mod.rs @@ -169,7 +169,7 @@ pub fn main() { .init(); let path = std::env::args() - .nth(1) + .nth(2) .unwrap_or_else(|| "please_don't_git_push_me.png".to_string()); pollster::block_on(run(Some(path))); } diff --git a/examples/src/timestamp_queries/mod.rs b/examples/src/timestamp_queries/mod.rs index beccac73b2..4911af4136 100644 --- a/examples/src/timestamp_queries/mod.rs +++ b/examples/src/timestamp_queries/mod.rs @@ -2,11 +2,11 @@ //! //! Timestamp queries are typically used to profile how long certain operations take on the GPU. //! wgpu has several ways of performing gpu timestamp queries: -//! * `wgpu::Encoder::write_timestamp` writes a between any commands recorded on an encoder. -//! (enabled with wgpu::Features::TIMESTAMP_QUERY) //! * passing `wgpu::RenderPassTimestampWrites`/`wgpu::ComputePassTimestampWrites` during render/compute pass creation. //! This writes timestamps for the beginning and end of a given pass. //! (enabled with wgpu::Features::TIMESTAMP_QUERY) +//! * `wgpu::CommandEncoder::write_timestamp` writes a between any commands recorded on an encoder. +//! (enabled with wgpu::Features::TIMESTAMP_QUERY_INSIDE_ENCODERS) //! * `wgpu::RenderPass/ComputePass::write_timestamp` writes a timestamp within commands of a render pass. //! Note that some GPU architectures do not support this. //! (native only, enabled with wgpu::Features::TIMESTAMP_QUERY_INSIDE_PASSES) @@ -241,8 +241,13 @@ fn submit_render_and_compute_pass_with_queries( source: wgpu::ShaderSource::Wgsl(std::borrow::Cow::Borrowed(include_str!("shader.wgsl"))), }); - encoder.write_timestamp(&queries.set, queries.next_unused_query); - queries.next_unused_query += 1; + if device + .features() + .contains(wgpu::Features::TIMESTAMP_QUERY_INSIDE_ENCODERS) + { + encoder.write_timestamp(&queries.set, queries.next_unused_query); + queries.next_unused_query += 1; + } // Render two triangles and profile it. render_pass( @@ -262,8 +267,13 @@ fn submit_render_and_compute_pass_with_queries( &mut queries.next_unused_query, ); - encoder.write_timestamp(&queries.set, queries.next_unused_query); - queries.next_unused_query += 1; + if device + .features() + .contains(wgpu::Features::TIMESTAMP_QUERY_INSIDE_ENCODERS) + { + encoder.write_timestamp(&queries.set, queries.next_unused_query); + queries.next_unused_query += 1; + } queries.resolve(&mut encoder); queue.submit(Some(encoder.finish())); @@ -426,13 +436,25 @@ mod tests { use super::{submit_render_and_compute_pass_with_queries, QueryResults}; #[gpu_test] - static TIMESTAMPS_ENCODER: GpuTestConfiguration = GpuTestConfiguration::new() + static TIMESTAMPS_PASS_BOUNDARIES: GpuTestConfiguration = GpuTestConfiguration::new() .parameters( wgpu_test::TestParameters::default() .limits(wgpu::Limits::downlevel_defaults()) .features(wgpu::Features::TIMESTAMP_QUERY), ) - .run_sync(|ctx| test_timestamps(ctx, false)); + .run_sync(|ctx| test_timestamps(ctx, false, false)); + + #[gpu_test] + static TIMESTAMPS_ENCODER: GpuTestConfiguration = GpuTestConfiguration::new() + .parameters( + wgpu_test::TestParameters::default() + .limits(wgpu::Limits::downlevel_defaults()) + .features( + wgpu::Features::TIMESTAMP_QUERY + | wgpu::Features::TIMESTAMP_QUERY_INSIDE_ENCODERS, + ), + ) + .run_sync(|ctx| test_timestamps(ctx, true, false)); #[gpu_test] static TIMESTAMPS_PASSES: GpuTestConfiguration = GpuTestConfiguration::new() @@ -440,12 +462,18 @@ mod tests { wgpu_test::TestParameters::default() .limits(wgpu::Limits::downlevel_defaults()) .features( - wgpu::Features::TIMESTAMP_QUERY | wgpu::Features::TIMESTAMP_QUERY_INSIDE_PASSES, + wgpu::Features::TIMESTAMP_QUERY + | wgpu::Features::TIMESTAMP_QUERY_INSIDE_ENCODERS + | wgpu::Features::TIMESTAMP_QUERY_INSIDE_PASSES, ), ) - .run_sync(|ctx| test_timestamps(ctx, true)); + .run_sync(|ctx| test_timestamps(ctx, true, true)); - fn test_timestamps(ctx: wgpu_test::TestingContext, timestamps_inside_passes: bool) { + fn test_timestamps( + ctx: wgpu_test::TestingContext, + timestamps_on_encoder: bool, + timestamps_inside_passes: bool, + ) { let queries = submit_render_and_compute_pass_with_queries(&ctx.device, &ctx.queue); let raw_results = queries.wait_for_results(&ctx.device); let QueryResults { @@ -464,9 +492,10 @@ mod tests { compute_start_end_timestamps[1].wrapping_sub(compute_start_end_timestamps[0]); let encoder_delta = encoder_timestamps[1].wrapping_sub(encoder_timestamps[0]); - assert!(encoder_delta > 0); - assert!(encoder_delta >= render_delta + compute_delta); - + if timestamps_on_encoder { + assert!(encoder_delta > 0); + assert!(encoder_delta >= render_delta + compute_delta); + } if let Some(render_inside_timestamp) = render_inside_timestamp { assert!(render_inside_timestamp >= render_start_end_timestamps[0]); assert!(render_inside_timestamp <= render_start_end_timestamps[1]); diff --git a/examples/src/water/mod.rs b/examples/src/water/mod.rs index e1a80b1e4f..7371e96155 100644 --- a/examples/src/water/mod.rs +++ b/examples/src/water/mod.rs @@ -826,7 +826,25 @@ static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTest height: 768, optional_features: wgpu::Features::default(), base_test_parameters: wgpu_test::TestParameters::default() - .downlevel_flags(wgpu::DownlevelFlags::READ_ONLY_DEPTH_STENCIL), + .downlevel_flags(wgpu::DownlevelFlags::READ_ONLY_DEPTH_STENCIL) + // To be fixed in . + .expect_fail(wgpu_test::FailureCase { + backends: Some(wgpu::Backends::VULKAN), + reasons: vec![ + wgpu_test::FailureReason::validation_error().with_message(concat!( + "vkCmdEndRenderPass: ", + "Hazard WRITE_AFTER_READ in subpass 0 for attachment 1 depth aspect ", + "during store with storeOp VK_ATTACHMENT_STORE_OP_STORE. ", + "Access info (", + "usage: SYNC_LATE_FRAGMENT_TESTS_DEPTH_STENCIL_ATTACHMENT_WRITE, ", + "prior_usage: SYNC_FRAGMENT_SHADER_SHADER_SAMPLED_READ, ", + "read_barriers: VkPipelineStageFlags2(0), ", + "command: vkCmdDraw" + )), + ], + behavior: wgpu_test::FailureBehavior::AssertFailure, + ..Default::default() + }), comparisons: &[wgpu_test::ComparisonType::Mean(0.01)], _phantom: std::marker::PhantomData::, }; diff --git a/naga-cli/Cargo.toml b/naga-cli/Cargo.toml index 9fe22e3461..1f35499589 100644 --- a/naga-cli/Cargo.toml +++ b/naga-cli/Cargo.toml @@ -21,7 +21,7 @@ test = false bincode = "1" log = "0.4" codespan-reporting = "0.11" -env_logger = "0.10" +env_logger = "0.11" argh = "0.1.5" [dependencies.naga] diff --git a/naga-cli/src/bin/naga.rs b/naga-cli/src/bin/naga.rs index 7a3a0f260c..29e5a5044b 100644 --- a/naga-cli/src/bin/naga.rs +++ b/naga-cli/src/bin/naga.rs @@ -62,6 +62,10 @@ struct Args { #[argh(option)] shader_model: Option, + /// the metal version to use, for example, 1.0, 1.1, 1.2, etc. + #[argh(option)] + metal_version: Option, + /// if the selected frontends/backends support coordinate space conversions, /// disable them #[argh(switch)] @@ -174,6 +178,30 @@ impl FromStr for GlslProfileArg { } } +/// Newtype so we can implement [`FromStr`] for a Metal Language Version. +#[derive(Clone, Debug)] +struct MslVersionArg((u8, u8)); + +impl FromStr for MslVersionArg { + type Err = String; + + fn from_str(s: &str) -> Result { + let mut iter = s.split('.'); + + let check_value = |iter: &mut core::str::Split<_>| { + iter.next() + .ok_or_else(|| format!("Invalid value for --metal-version: {s}"))? + .parse::() + .map_err(|err| format!("Invalid value for --metal-version: '{s}': {err}")) + }; + + let major = check_value(&mut iter)?; + let minor = check_value(&mut iter)?; + + Ok(Self((major, minor))) + } +} + #[derive(Default)] struct Parameters<'a> { validation_flags: naga::valid::ValidationFlags, @@ -287,6 +315,9 @@ fn run() -> Result<(), Box> { if let Some(ref model) = args.shader_model { params.hlsl.shader_model = model.0; } + if let Some(ref version) = args.metal_version { + params.msl.lang_version = version.0; + } params.keep_coordinate_space = args.keep_coordinate_space; params.dot.cfg_only = args.dot_cfg_only; diff --git a/naga/Cargo.toml b/naga/Cargo.toml index 766d95f86f..a880b63126 100644 --- a/naga/Cargo.toml +++ b/naga/Cargo.toml @@ -9,7 +9,7 @@ keywords = ["shader", "SPIR-V", "GLSL", "MSL"] license = "MIT OR Apache-2.0" exclude = ["bin/**/*", "tests/**/*", "Cargo.lock", "target/**/*"] resolver = "2" -rust-version = "1.70" +rust-version = "1.74" autotests = false [[test]] @@ -54,8 +54,8 @@ indexmap = { version = "2", features = ["std"] } log = "0.4" num-traits = "0.2" spirv = { version = "0.3", optional = true } -thiserror = "1.0.56" -serde = { version = "1.0.195", features = ["derive"], optional = true } +thiserror = "1.0.57" +serde = { version = "1.0.196", features = ["derive"], optional = true } petgraph = { version = "0.6", optional = true } pp-rs = { version = "0.2.1", optional = true } hexf-parse = { version = "0.2.1", optional = true } @@ -68,7 +68,7 @@ criterion = { version = "0.5", features = [] } [dev-dependencies] bincode = "1" diff = "0.1" -env_logger = "0.10" +env_logger = "0.11" # This _cannot_ have a version specified. If it does, crates.io will look # for a version of the package on crates when we publish naga. Path dependencies # are allowed through though. diff --git a/naga/README.md b/naga/README.md index b7f352fc91..0e07d40496 100644 --- a/naga/README.md +++ b/naga/README.md @@ -4,7 +4,7 @@ [![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) [![Build Status](https://github.com/gfx-rs/naga/workflows/pipeline/badge.svg)](https://github.com/gfx-rs/naga/actions) -![MSRV](https://img.shields.io/badge/rustc-1.70+-blue.svg) +![MSRV](https://img.shields.io/badge/rustc-1.74+-blue.svg) [![codecov.io](https://codecov.io/gh/gfx-rs/naga/branch/master/graph/badge.svg?token=9VOKYO8BM2)](https://codecov.io/gh/gfx-rs/naga) The shader translation library for the needs of [wgpu](https://github.com/gfx-rs/wgpu). @@ -42,7 +42,7 @@ First, install `naga-cli` from crates.io or directly from GitHub. cargo install naga-cli # development version -cargo install naga-cli --git https://github.com/gfx-rs/naga.git +cargo install naga-cli --git https://github.com/gfx-rs/wgpu.git ``` Then, you can run `naga` command. diff --git a/naga/hlsl-snapshots/Cargo.toml b/naga/hlsl-snapshots/Cargo.toml index 09104adfbc..496bdbb3f8 100644 --- a/naga/hlsl-snapshots/Cargo.toml +++ b/naga/hlsl-snapshots/Cargo.toml @@ -12,4 +12,4 @@ test = false [dependencies] anyhow = "1" -nanoserde = "0.1.32" +nanoserde = "0.1.37" diff --git a/naga/src/back/glsl/mod.rs b/naga/src/back/glsl/mod.rs index 8f80bc1b73..9bda594610 100644 --- a/naga/src/back/glsl/mod.rs +++ b/naga/src/back/glsl/mod.rs @@ -178,7 +178,7 @@ impl Version { /// Note: `location=` for vertex inputs and fragment outputs is supported /// unconditionally for GLES 300. fn supports_explicit_locations(&self) -> bool { - *self >= Version::Desktop(410) || *self >= Version::new_gles(310) + *self >= Version::Desktop(420) || *self >= Version::new_gles(310) } fn supports_early_depth_test(&self) -> bool { @@ -1290,7 +1290,14 @@ impl<'a, W: Write> Writer<'a, W> { let inner = expr_info.ty.inner_with(&self.module.types); - if let Expression::Math { fun, arg, arg1, .. } = *expr { + if let Expression::Math { + fun, + arg, + arg1, + arg2, + .. + } = *expr + { match fun { crate::MathFunction::Dot => { // if the expression is a Dot product with integer arguments, @@ -1305,6 +1312,14 @@ impl<'a, W: Write> Writer<'a, W> { } } } + crate::MathFunction::ExtractBits => { + // Only argument 1 is re-used. + self.need_bake_expressions.insert(arg1.unwrap()); + } + crate::MathFunction::InsertBits => { + // Only argument 2 is re-used. + self.need_bake_expressions.insert(arg2.unwrap()); + } crate::MathFunction::CountLeadingZeros => { if let Some(crate::ScalarKind::Sint) = inner.scalar_kind() { self.need_bake_expressions.insert(arg); @@ -2441,6 +2456,9 @@ impl<'a, W: Write> Writer<'a, W> { crate::Literal::I64(_) => { return Err(Error::Custom("GLSL has no 64-bit integer type".into())); } + crate::Literal::U64(_) => { + return Err(Error::Custom("GLSL has no 64-bit integer type".into())); + } crate::Literal::AbstractInt(_) | crate::Literal::AbstractFloat(_) => { return Err(Error::Custom( "Abstract types should not appear in IR presented to backends".into(), @@ -3138,7 +3156,29 @@ impl<'a, W: Write> Writer<'a, W> { Mf::Abs => "abs", Mf::Min => "min", Mf::Max => "max", - Mf::Clamp => "clamp", + Mf::Clamp => { + let scalar_kind = ctx + .resolve_type(arg, &self.module.types) + .scalar_kind() + .unwrap(); + match scalar_kind { + crate::ScalarKind::Float => "clamp", + // Clamp is undefined if min > max. In practice this means it can use a median-of-three + // instruction to determine the value. This is fine according to the WGSL spec for float + // clamp, but integer clamp _must_ use min-max. As such we write out min/max. + _ => { + write!(self.out, "min(max(")?; + self.write_expr(arg, ctx)?; + write!(self.out, ", ")?; + self.write_expr(arg1.unwrap(), ctx)?; + write!(self.out, "), ")?; + self.write_expr(arg2.unwrap(), ctx)?; + write!(self.out, ")")?; + + return Ok(()); + } + } + } Mf::Saturate => { write!(self.out, "clamp(")?; @@ -3353,8 +3393,59 @@ impl<'a, W: Write> Writer<'a, W> { } Mf::CountOneBits => "bitCount", Mf::ReverseBits => "bitfieldReverse", - Mf::ExtractBits => "bitfieldExtract", - Mf::InsertBits => "bitfieldInsert", + Mf::ExtractBits => { + // The behavior of ExtractBits is undefined when offset + count > bit_width. We need + // to first sanitize the offset and count first. If we don't do this, AMD and Intel chips + // will return out-of-spec values if the extracted range is not within the bit width. + // + // This encodes the exact formula specified by the wgsl spec, without temporary values: + // https://gpuweb.github.io/gpuweb/wgsl/#extractBits-unsigned-builtin + // + // w = sizeof(x) * 8 + // o = min(offset, w) + // c = min(count, w - o) + // + // bitfieldExtract(x, o, c) + // + // extract_bits(e, min(offset, w), min(count, w - min(offset, w)))) + let scalar_bits = ctx + .resolve_type(arg, &self.module.types) + .scalar_width() + .unwrap(); + + write!(self.out, "bitfieldExtract(")?; + self.write_expr(arg, ctx)?; + write!(self.out, ", int(min(")?; + self.write_expr(arg1.unwrap(), ctx)?; + write!(self.out, ", {scalar_bits}u)), int(min(",)?; + self.write_expr(arg2.unwrap(), ctx)?; + write!(self.out, ", {scalar_bits}u - min(")?; + self.write_expr(arg1.unwrap(), ctx)?; + write!(self.out, ", {scalar_bits}u))))")?; + + return Ok(()); + } + Mf::InsertBits => { + // InsertBits has the same considerations as ExtractBits above + let scalar_bits = ctx + .resolve_type(arg, &self.module.types) + .scalar_width() + .unwrap(); + + write!(self.out, "bitfieldInsert(")?; + self.write_expr(arg, ctx)?; + write!(self.out, ", ")?; + self.write_expr(arg1.unwrap(), ctx)?; + write!(self.out, ", int(min(")?; + self.write_expr(arg2.unwrap(), ctx)?; + write!(self.out, ", {scalar_bits}u)), int(min(",)?; + self.write_expr(arg3.unwrap(), ctx)?; + write!(self.out, ", {scalar_bits}u - min(")?; + self.write_expr(arg2.unwrap(), ctx)?; + write!(self.out, ", {scalar_bits}u))))")?; + + return Ok(()); + } Mf::FindLsb => "findLSB", Mf::FindMsb => "findMSB", // data packing diff --git a/naga/src/back/hlsl/conv.rs b/naga/src/back/hlsl/conv.rs index b6918ddc42..2a6db35db8 100644 --- a/naga/src/back/hlsl/conv.rs +++ b/naga/src/back/hlsl/conv.rs @@ -21,8 +21,16 @@ impl crate::Scalar { /// pub(super) const fn to_hlsl_str(self) -> Result<&'static str, Error> { match self.kind { - crate::ScalarKind::Sint => Ok("int"), - crate::ScalarKind::Uint => Ok("uint"), + crate::ScalarKind::Sint => match self.width { + 4 => Ok("int"), + 8 => Ok("int64_t"), + _ => Err(Error::UnsupportedScalar(self)), + }, + crate::ScalarKind::Uint => match self.width { + 4 => Ok("uint"), + 8 => Ok("uint64_t"), + _ => Err(Error::UnsupportedScalar(self)), + }, crate::ScalarKind::Float => match self.width { 2 => Ok("half"), 4 => Ok("float"), diff --git a/naga/src/back/hlsl/help.rs b/naga/src/back/hlsl/help.rs index fa6062a1ad..4dd9ea5987 100644 --- a/naga/src/back/hlsl/help.rs +++ b/naga/src/back/hlsl/help.rs @@ -26,7 +26,11 @@ int dim_1d = NagaDimensions1D(image_1d); ``` */ -use super::{super::FunctionCtx, BackendResult}; +use super::{ + super::FunctionCtx, + writer::{EXTRACT_BITS_FUNCTION, INSERT_BITS_FUNCTION}, + BackendResult, +}; use crate::{arena::Handle, proc::NameKey}; use std::fmt::Write; @@ -59,6 +63,13 @@ pub(super) struct WrappedMatCx2 { pub(super) columns: crate::VectorSize, } +#[derive(Clone, Copy, Debug, Hash, Eq, Ord, PartialEq, PartialOrd)] +pub(super) struct WrappedMath { + pub(super) fun: crate::MathFunction, + pub(super) scalar: crate::Scalar, + pub(super) components: Option, +} + /// HLSL backend requires its own `ImageQuery` enum. /// /// It is used inside `WrappedImageQuery` and should be unique per ImageQuery function. @@ -851,12 +862,149 @@ impl<'a, W: Write> super::Writer<'a, W> { Ok(()) } + pub(super) fn write_wrapped_math_functions( + &mut self, + module: &crate::Module, + func_ctx: &FunctionCtx, + ) -> BackendResult { + for (_, expression) in func_ctx.expressions.iter() { + if let crate::Expression::Math { + fun, + arg, + arg1: _arg1, + arg2: _arg2, + arg3: _arg3, + } = *expression + { + match fun { + crate::MathFunction::ExtractBits => { + // The behavior of our extractBits polyfill is undefined if offset + count > bit_width. We need + // to first sanitize the offset and count first. If we don't do this, we will get out-of-spec + // values if the extracted range is not within the bit width. + // + // This encodes the exact formula specified by the wgsl spec: + // https://gpuweb.github.io/gpuweb/wgsl/#extractBits-unsigned-builtin + // + // w = sizeof(x) * 8 + // o = min(offset, w) + // c = min(count, w - o) + // + // bitfieldExtract(x, o, c) + let arg_ty = func_ctx.resolve_type(arg, &module.types); + let scalar = arg_ty.scalar().unwrap(); + let components = arg_ty.components(); + + let wrapped = WrappedMath { + fun, + scalar, + components, + }; + + if !self.wrapped.math.insert(wrapped) { + continue; + } + + // Write return type + self.write_value_type(module, arg_ty)?; + + let scalar_width: u8 = scalar.width * 8; + + // Write function name and parameters + writeln!(self.out, " {EXTRACT_BITS_FUNCTION}(")?; + write!(self.out, " ")?; + self.write_value_type(module, arg_ty)?; + writeln!(self.out, " e,")?; + writeln!(self.out, " uint offset,")?; + writeln!(self.out, " uint count")?; + writeln!(self.out, ") {{")?; + + // Write function body + writeln!(self.out, " uint w = {scalar_width};")?; + writeln!(self.out, " uint o = min(offset, w);")?; + writeln!(self.out, " uint c = min(count, w - o);")?; + writeln!( + self.out, + " return (c == 0 ? 0 : (e << (w - c - o)) >> (w - c));" + )?; + + // End of function body + writeln!(self.out, "}}")?; + } + crate::MathFunction::InsertBits => { + // The behavior of our insertBits polyfill has the same constraints as the extractBits polyfill. + + let arg_ty = func_ctx.resolve_type(arg, &module.types); + let scalar = arg_ty.scalar().unwrap(); + let components = arg_ty.components(); + + let wrapped = WrappedMath { + fun, + scalar, + components, + }; + + if !self.wrapped.math.insert(wrapped) { + continue; + } + + // Write return type + self.write_value_type(module, arg_ty)?; + + let scalar_width: u8 = scalar.width * 8; + let scalar_max: u64 = match scalar.width { + 1 => 0xFF, + 2 => 0xFFFF, + 4 => 0xFFFFFFFF, + 8 => 0xFFFFFFFFFFFFFFFF, + _ => unreachable!(), + }; + + // Write function name and parameters + writeln!(self.out, " {INSERT_BITS_FUNCTION}(")?; + write!(self.out, " ")?; + self.write_value_type(module, arg_ty)?; + writeln!(self.out, " e,")?; + write!(self.out, " ")?; + self.write_value_type(module, arg_ty)?; + writeln!(self.out, " newbits,")?; + writeln!(self.out, " uint offset,")?; + writeln!(self.out, " uint count")?; + writeln!(self.out, ") {{")?; + + // Write function body + writeln!(self.out, " uint w = {scalar_width}u;")?; + writeln!(self.out, " uint o = min(offset, w);")?; + writeln!(self.out, " uint c = min(count, w - o);")?; + + // The `u` suffix on the literals is _extremely_ important. Otherwise it will use + // i32 shifting instead of the intended u32 shifting. + writeln!( + self.out, + " uint mask = (({scalar_max}u >> ({scalar_width}u - c)) << o);" + )?; + writeln!( + self.out, + " return (c == 0 ? e : ((e & ~mask) | ((newbits << o) & mask)));" + )?; + + // End of function body + writeln!(self.out, "}}")?; + } + _ => {} + } + } + } + + Ok(()) + } + /// Helper function that writes various wrapped functions pub(super) fn write_wrapped_functions( &mut self, module: &crate::Module, func_ctx: &FunctionCtx, ) -> BackendResult { + self.write_wrapped_math_functions(module, func_ctx)?; self.write_wrapped_compose_functions(module, func_ctx.expressions)?; for (handle, _) in func_ctx.expressions.iter() { diff --git a/naga/src/back/hlsl/keywords.rs b/naga/src/back/hlsl/keywords.rs index 059e533ff7..2cb715c42c 100644 --- a/naga/src/back/hlsl/keywords.rs +++ b/naga/src/back/hlsl/keywords.rs @@ -817,6 +817,8 @@ pub const RESERVED: &[&str] = &[ // Naga utilities super::writer::MODF_FUNCTION, super::writer::FREXP_FUNCTION, + super::writer::EXTRACT_BITS_FUNCTION, + super::writer::INSERT_BITS_FUNCTION, ]; // DXC scalar types, from https://github.com/microsoft/DirectXShaderCompiler/blob/18c9e114f9c314f93e68fbc72ce207d4ed2e65ae/tools/clang/lib/AST/ASTContextHLSL.cpp#L48-L254 diff --git a/naga/src/back/hlsl/mod.rs b/naga/src/back/hlsl/mod.rs index 37ddbd3d67..f37a223f47 100644 --- a/naga/src/back/hlsl/mod.rs +++ b/naga/src/back/hlsl/mod.rs @@ -256,6 +256,7 @@ struct Wrapped { constructors: crate::FastHashSet, struct_matrix_access: crate::FastHashSet, mat_cx2s: crate::FastHashSet, + math: crate::FastHashSet, } impl Wrapped { @@ -265,6 +266,7 @@ impl Wrapped { self.constructors.clear(); self.struct_matrix_access.clear(); self.mat_cx2s.clear(); + self.math.clear(); } } diff --git a/naga/src/back/hlsl/storage.rs b/naga/src/back/hlsl/storage.rs index 1b8a6ec12d..4d3a6af56d 100644 --- a/naga/src/back/hlsl/storage.rs +++ b/naga/src/back/hlsl/storage.rs @@ -32,6 +32,16 @@ The [`temp_access_chain`] field is a member of [`Writer`] solely to allow re-use of the `Vec`'s dynamic allocation. Its value is no longer needed once HLSL for the access has been generated. +Note about DXC and Load/Store functions: + +DXC's HLSL has a generic [`Load` and `Store`] function for [`ByteAddressBuffer`] and +[`RWByteAddressBuffer`]. This is not available in FXC's HLSL, so we use +it only for types that are only available in DXC. Notably 64 and 16 bit types. + +FXC's HLSL has functions Load, Load2, Load3, and Load4 and Store, Store2, Store3, Store4. +This loads/stores a vector of length 1, 2, 3, or 4. We use that for 32bit types, bitcasting to the +correct type if necessary. + [`Storage`]: crate::AddressSpace::Storage [`ByteAddressBuffer`]: https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/sm5-object-byteaddressbuffer [`RWByteAddressBuffer`]: https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/sm5-object-rwbyteaddressbuffer @@ -42,6 +52,7 @@ needed once HLSL for the access has been generated. [`Writer::temp_access_chain`]: super::Writer::temp_access_chain [`temp_access_chain`]: super::Writer::temp_access_chain [`Writer`]: super::Writer +[`Load` and `Store`]: https://github.com/microsoft/DirectXShaderCompiler/wiki/ByteAddressBuffer-Load-Store-Additions */ use super::{super::FunctionCtx, BackendResult, Error}; @@ -161,20 +172,39 @@ impl super::Writer<'_, W> { // working around the borrow checker in `self.write_expr` let chain = mem::take(&mut self.temp_access_chain); let var_name = &self.names[&NameKey::GlobalVariable(var_handle)]; - let cast = scalar.kind.to_hlsl_cast(); - write!(self.out, "{cast}({var_name}.Load(")?; + // See note about DXC and Load/Store in the module's documentation. + if scalar.width == 4 { + let cast = scalar.kind.to_hlsl_cast(); + write!(self.out, "{cast}({var_name}.Load(")?; + } else { + let ty = scalar.to_hlsl_str()?; + write!(self.out, "{var_name}.Load<{ty}>(")?; + }; self.write_storage_address(module, &chain, func_ctx)?; - write!(self.out, "))")?; + write!(self.out, ")")?; + if scalar.width == 4 { + write!(self.out, ")")?; + } self.temp_access_chain = chain; } crate::TypeInner::Vector { size, scalar } => { // working around the borrow checker in `self.write_expr` let chain = mem::take(&mut self.temp_access_chain); let var_name = &self.names[&NameKey::GlobalVariable(var_handle)]; - let cast = scalar.kind.to_hlsl_cast(); - write!(self.out, "{}({}.Load{}(", cast, var_name, size as u8)?; + let size = size as u8; + // See note about DXC and Load/Store in the module's documentation. + if scalar.width == 4 { + let cast = scalar.kind.to_hlsl_cast(); + write!(self.out, "{cast}({var_name}.Load{size}(")?; + } else { + let ty = scalar.to_hlsl_str()?; + write!(self.out, "{var_name}.Load<{ty}{size}>(")?; + }; self.write_storage_address(module, &chain, func_ctx)?; - write!(self.out, "))")?; + write!(self.out, ")")?; + if scalar.width == 4 { + write!(self.out, ")")?; + } self.temp_access_chain = chain; } crate::TypeInner::Matrix { @@ -288,26 +318,44 @@ impl super::Writer<'_, W> { } }; match *ty_resolution.inner_with(&module.types) { - crate::TypeInner::Scalar(_) => { + crate::TypeInner::Scalar(scalar) => { // working around the borrow checker in `self.write_expr` let chain = mem::take(&mut self.temp_access_chain); let var_name = &self.names[&NameKey::GlobalVariable(var_handle)]; - write!(self.out, "{level}{var_name}.Store(")?; - self.write_storage_address(module, &chain, func_ctx)?; - write!(self.out, ", asuint(")?; - self.write_store_value(module, &value, func_ctx)?; - writeln!(self.out, "));")?; + // See note about DXC and Load/Store in the module's documentation. + if scalar.width == 4 { + write!(self.out, "{level}{var_name}.Store(")?; + self.write_storage_address(module, &chain, func_ctx)?; + write!(self.out, ", asuint(")?; + self.write_store_value(module, &value, func_ctx)?; + writeln!(self.out, "));")?; + } else { + write!(self.out, "{level}{var_name}.Store(")?; + self.write_storage_address(module, &chain, func_ctx)?; + write!(self.out, ", ")?; + self.write_store_value(module, &value, func_ctx)?; + writeln!(self.out, ");")?; + } self.temp_access_chain = chain; } - crate::TypeInner::Vector { size, .. } => { + crate::TypeInner::Vector { size, scalar } => { // working around the borrow checker in `self.write_expr` let chain = mem::take(&mut self.temp_access_chain); let var_name = &self.names[&NameKey::GlobalVariable(var_handle)]; - write!(self.out, "{}{}.Store{}(", level, var_name, size as u8)?; - self.write_storage_address(module, &chain, func_ctx)?; - write!(self.out, ", asuint(")?; - self.write_store_value(module, &value, func_ctx)?; - writeln!(self.out, "));")?; + // See note about DXC and Load/Store in the module's documentation. + if scalar.width == 4 { + write!(self.out, "{}{}.Store{}(", level, var_name, size as u8)?; + self.write_storage_address(module, &chain, func_ctx)?; + write!(self.out, ", asuint(")?; + self.write_store_value(module, &value, func_ctx)?; + writeln!(self.out, "));")?; + } else { + write!(self.out, "{}{}.Store(", level, var_name)?; + self.write_storage_address(module, &chain, func_ctx)?; + write!(self.out, ", ")?; + self.write_store_value(module, &value, func_ctx)?; + writeln!(self.out, ");")?; + } self.temp_access_chain = chain; } crate::TypeInner::Matrix { diff --git a/naga/src/back/hlsl/writer.rs b/naga/src/back/hlsl/writer.rs index 43f7212837..4ba856946b 100644 --- a/naga/src/back/hlsl/writer.rs +++ b/naga/src/back/hlsl/writer.rs @@ -19,6 +19,8 @@ const SPECIAL_OTHER: &str = "other"; pub(crate) const MODF_FUNCTION: &str = "naga_modf"; pub(crate) const FREXP_FUNCTION: &str = "naga_frexp"; +pub(crate) const EXTRACT_BITS_FUNCTION: &str = "naga_extractBits"; +pub(crate) const INSERT_BITS_FUNCTION: &str = "naga_insertBits"; struct EpStructMember { name: String, @@ -125,14 +127,7 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { self.need_bake_expressions.insert(fun_handle); } - if let Expression::Math { - fun, - arg, - arg1, - arg2, - arg3, - } = *expr - { + if let Expression::Math { fun, arg, .. } = *expr { match fun { crate::MathFunction::Asinh | crate::MathFunction::Acosh @@ -149,17 +144,6 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { | crate::MathFunction::Pack4x8unorm => { self.need_bake_expressions.insert(arg); } - crate::MathFunction::ExtractBits => { - self.need_bake_expressions.insert(arg); - self.need_bake_expressions.insert(arg1.unwrap()); - self.need_bake_expressions.insert(arg2.unwrap()); - } - crate::MathFunction::InsertBits => { - self.need_bake_expressions.insert(arg); - self.need_bake_expressions.insert(arg1.unwrap()); - self.need_bake_expressions.insert(arg2.unwrap()); - self.need_bake_expressions.insert(arg3.unwrap()); - } crate::MathFunction::CountLeadingZeros => { let inner = info[fun_handle].ty.inner_with(&module.types); if let Some(crate::ScalarKind::Sint) = inner.scalar_kind() { @@ -2038,6 +2022,7 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { crate::Literal::F32(value) => write!(self.out, "{value:?}")?, crate::Literal::U32(value) => write!(self.out, "{}u", value)?, crate::Literal::I32(value) => write!(self.out, "{}", value)?, + crate::Literal::U64(value) => write!(self.out, "{}uL", value)?, crate::Literal::I64(value) => write!(self.out, "{}L", value)?, crate::Literal::Bool(value) => write!(self.out, "{}", value)?, crate::Literal::AbstractInt(_) | crate::Literal::AbstractFloat(_) => { @@ -2567,7 +2552,7 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { convert, } => { let inner = func_ctx.resolve_type(expr, &module.types); - match convert { + let close_paren = match convert { Some(dst_width) => { let scalar = crate::Scalar { kind, @@ -2600,13 +2585,21 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { ))); } }; + true } None => { - write!(self.out, "{}(", kind.to_hlsl_cast(),)?; + if inner.scalar_width() == Some(64) { + false + } else { + write!(self.out, "{}(", kind.to_hlsl_cast(),)?; + true + } } - } + }; self.write_expr(module, expr, func_ctx)?; - write!(self.out, ")")?; + if close_paren { + write!(self.out, ")")?; + } } Expression::Math { fun, @@ -2620,8 +2613,6 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { enum Function { Asincosh { is_sin: bool }, Atanh, - ExtractBits, - InsertBits, Pack2x16float, Pack2x16snorm, Pack2x16unorm, @@ -2705,8 +2696,8 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { Mf::ReverseBits => Function::MissingIntOverload("reversebits"), Mf::FindLsb => Function::MissingIntReturnType("firstbitlow"), Mf::FindMsb => Function::MissingIntReturnType("firstbithigh"), - Mf::ExtractBits => Function::ExtractBits, - Mf::InsertBits => Function::InsertBits, + Mf::ExtractBits => Function::Regular(EXTRACT_BITS_FUNCTION), + Mf::InsertBits => Function::Regular(INSERT_BITS_FUNCTION), // Data Packing Mf::Pack2x16float => Function::Pack2x16float, Mf::Pack2x16snorm => Function::Pack2x16snorm, @@ -2742,70 +2733,6 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { self.write_expr(module, arg, func_ctx)?; write!(self.out, "))")?; } - Function::ExtractBits => { - // e: T, - // offset: u32, - // count: u32 - // T is u32 or i32 or vecN or vecN - if let (Some(offset), Some(count)) = (arg1, arg2) { - let scalar_width: u8 = 32; - // Works for signed and unsigned - // (count == 0 ? 0 : (e << (32 - count - offset)) >> (32 - count)) - write!(self.out, "(")?; - self.write_expr(module, count, func_ctx)?; - write!(self.out, " == 0 ? 0 : (")?; - self.write_expr(module, arg, func_ctx)?; - write!(self.out, " << ({scalar_width} - ")?; - self.write_expr(module, count, func_ctx)?; - write!(self.out, " - ")?; - self.write_expr(module, offset, func_ctx)?; - write!(self.out, ")) >> ({scalar_width} - ")?; - self.write_expr(module, count, func_ctx)?; - write!(self.out, "))")?; - } - } - Function::InsertBits => { - // e: T, - // newbits: T, - // offset: u32, - // count: u32 - // returns T - // T is i32, u32, vecN, or vecN - if let (Some(newbits), Some(offset), Some(count)) = (arg1, arg2, arg3) { - let scalar_width: u8 = 32; - let scalar_max: u32 = 0xFFFFFFFF; - // mask = ((0xFFFFFFFFu >> (32 - count)) << offset) - // (count == 0 ? e : ((e & ~mask) | ((newbits << offset) & mask))) - write!(self.out, "(")?; - self.write_expr(module, count, func_ctx)?; - write!(self.out, " == 0 ? ")?; - self.write_expr(module, arg, func_ctx)?; - write!(self.out, " : ")?; - write!(self.out, "(")?; - self.write_expr(module, arg, func_ctx)?; - write!(self.out, " & ~")?; - // mask - write!(self.out, "(({scalar_max}u >> ({scalar_width}u - ")?; - self.write_expr(module, count, func_ctx)?; - write!(self.out, ")) << ")?; - self.write_expr(module, offset, func_ctx)?; - write!(self.out, ")")?; - // end mask - write!(self.out, ") | ((")?; - self.write_expr(module, newbits, func_ctx)?; - write!(self.out, " << ")?; - self.write_expr(module, offset, func_ctx)?; - write!(self.out, ") & ")?; - // // mask - write!(self.out, "(({scalar_max}u >> ({scalar_width}u - ")?; - self.write_expr(module, count, func_ctx)?; - write!(self.out, ")) << ")?; - self.write_expr(module, offset, func_ctx)?; - write!(self.out, ")")?; - // // end mask - write!(self.out, "))")?; - } - } Function::Pack2x16float => { write!(self.out, "(f32tof16(")?; self.write_expr(module, arg, func_ctx)?; @@ -2944,9 +2871,15 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { } write!(self.out, ")")? } + // These overloads are only missing on FXC, so this is only needed for 32bit types, + // as non-32bit types are DXC only. Function::MissingIntOverload(fun_name) => { - let scalar_kind = func_ctx.resolve_type(arg, &module.types).scalar_kind(); - if let Some(ScalarKind::Sint) = scalar_kind { + let scalar_kind = func_ctx.resolve_type(arg, &module.types).scalar(); + if let Some(crate::Scalar { + kind: ScalarKind::Sint, + width: 4, + }) = scalar_kind + { write!(self.out, "asint({fun_name}(asuint(")?; self.write_expr(module, arg, func_ctx)?; write!(self.out, ")))")?; @@ -2956,9 +2889,15 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { write!(self.out, ")")?; } } + // These overloads are only missing on FXC, so this is only needed for 32bit types, + // as non-32bit types are DXC only. Function::MissingIntReturnType(fun_name) => { - let scalar_kind = func_ctx.resolve_type(arg, &module.types).scalar_kind(); - if let Some(ScalarKind::Sint) = scalar_kind { + let scalar_kind = func_ctx.resolve_type(arg, &module.types).scalar(); + if let Some(crate::Scalar { + kind: ScalarKind::Sint, + width: 4, + }) = scalar_kind + { write!(self.out, "asint({fun_name}(")?; self.write_expr(module, arg, func_ctx)?; write!(self.out, "))")?; @@ -2977,23 +2916,38 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { crate::VectorSize::Quad => ".xxxx", }; - if let ScalarKind::Uint = scalar.kind { - write!(self.out, "min((32u){s}, firstbitlow(")?; + let scalar_width_bits = scalar.width * 8; + + if scalar.kind == ScalarKind::Uint || scalar.width != 4 { + write!( + self.out, + "min(({scalar_width_bits}u){s}, firstbitlow(" + )?; self.write_expr(module, arg, func_ctx)?; write!(self.out, "))")?; } else { - write!(self.out, "asint(min((32u){s}, firstbitlow(")?; + // This is only needed for the FXC path, on 32bit signed integers. + write!( + self.out, + "asint(min(({scalar_width_bits}u){s}, firstbitlow(" + )?; self.write_expr(module, arg, func_ctx)?; write!(self.out, ")))")?; } } TypeInner::Scalar(scalar) => { - if let ScalarKind::Uint = scalar.kind { - write!(self.out, "min(32u, firstbitlow(")?; + let scalar_width_bits = scalar.width * 8; + + if scalar.kind == ScalarKind::Uint || scalar.width != 4 { + write!(self.out, "min({scalar_width_bits}u, firstbitlow(")?; self.write_expr(module, arg, func_ctx)?; write!(self.out, "))")?; } else { - write!(self.out, "asint(min(32u, firstbitlow(")?; + // This is only needed for the FXC path, on 32bit signed integers. + write!( + self.out, + "asint(min({scalar_width_bits}u, firstbitlow(" + )?; self.write_expr(module, arg, func_ctx)?; write!(self.out, ")))")?; } @@ -3012,30 +2966,47 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { crate::VectorSize::Quad => ".xxxx", }; - if let ScalarKind::Uint = scalar.kind { - write!(self.out, "((31u){s} - firstbithigh(")?; + // scalar width - 1 + let constant = scalar.width * 8 - 1; + + if scalar.kind == ScalarKind::Uint { + write!(self.out, "(({constant}u){s} - firstbithigh(")?; self.write_expr(module, arg, func_ctx)?; write!(self.out, "))")?; } else { + let conversion_func = match scalar.width { + 4 => "asint", + _ => "", + }; write!(self.out, "(")?; self.write_expr(module, arg, func_ctx)?; write!( self.out, - " < (0){s} ? (0){s} : (31){s} - asint(firstbithigh(" + " < (0){s} ? (0){s} : ({constant}){s} - {conversion_func}(firstbithigh(" )?; self.write_expr(module, arg, func_ctx)?; write!(self.out, ")))")?; } } TypeInner::Scalar(scalar) => { + // scalar width - 1 + let constant = scalar.width * 8 - 1; + if let ScalarKind::Uint = scalar.kind { - write!(self.out, "(31u - firstbithigh(")?; + write!(self.out, "({constant}u - firstbithigh(")?; self.write_expr(module, arg, func_ctx)?; write!(self.out, "))")?; } else { + let conversion_func = match scalar.width { + 4 => "asint", + _ => "", + }; write!(self.out, "(")?; self.write_expr(module, arg, func_ctx)?; - write!(self.out, " < 0 ? 0 : 31 - asint(firstbithigh(")?; + write!( + self.out, + " < 0 ? 0 : {constant} - {conversion_func}(firstbithigh(" + )?; self.write_expr(module, arg, func_ctx)?; write!(self.out, ")))")?; } diff --git a/naga/src/back/mod.rs b/naga/src/back/mod.rs index 8100b930e9..c8f091decb 100644 --- a/naga/src/back/mod.rs +++ b/naga/src/back/mod.rs @@ -16,14 +16,19 @@ pub mod spv; #[cfg(feature = "wgsl-out")] pub mod wgsl; -const COMPONENTS: &[char] = &['x', 'y', 'z', 'w']; -const INDENT: &str = " "; -const BAKE_PREFIX: &str = "_e"; +/// Names of vector components. +pub const COMPONENTS: &[char] = &['x', 'y', 'z', 'w']; +/// Indent for backends. +pub const INDENT: &str = " "; +/// Prefix used for baking. +pub const BAKE_PREFIX: &str = "_e"; -type NeedBakeExpressions = crate::FastHashSet>; +/// Expressions that need baking. +pub type NeedBakeExpressions = crate::FastHashSet>; +/// Indentation level. #[derive(Clone, Copy)] -struct Level(usize); +pub struct Level(pub usize); impl Level { const fn next(&self) -> Self { @@ -52,7 +57,7 @@ impl std::fmt::Display for Level { /// [`EntryPoint`]: crate::EntryPoint /// [`Module`]: crate::Module /// [`Module::entry_points`]: crate::Module::entry_points -enum FunctionType { +pub enum FunctionType { /// A regular function. Function(crate::Handle), /// An [`EntryPoint`], and its index in [`Module::entry_points`]. @@ -63,7 +68,8 @@ enum FunctionType { } impl FunctionType { - fn is_compute_entry_point(&self, module: &crate::Module) -> bool { + /// Returns true if the function is an entry point for a compute shader. + pub fn is_compute_entry_point(&self, module: &crate::Module) -> bool { match *self { FunctionType::EntryPoint(index) => { module.entry_points[index as usize].stage == crate::ShaderStage::Compute @@ -74,19 +80,20 @@ impl FunctionType { } /// Helper structure that stores data needed when writing the function -struct FunctionCtx<'a> { +pub struct FunctionCtx<'a> { /// The current function being written - ty: FunctionType, + pub ty: FunctionType, /// Analysis about the function - info: &'a crate::valid::FunctionInfo, + pub info: &'a crate::valid::FunctionInfo, /// The expression arena of the current function being written - expressions: &'a crate::Arena, + pub expressions: &'a crate::Arena, /// Map of expressions that have associated variable names - named_expressions: &'a crate::NamedExpressions, + pub named_expressions: &'a crate::NamedExpressions, } impl FunctionCtx<'_> { - fn resolve_type<'a>( + /// Helper method that resolves a type of a given expression. + pub fn resolve_type<'a>( &'a self, handle: crate::Handle, types: &'a crate::UniqueArena, @@ -95,7 +102,10 @@ impl FunctionCtx<'_> { } /// Helper method that generates a [`NameKey`](crate::proc::NameKey) for a local in the current function - const fn name_key(&self, local: crate::Handle) -> crate::proc::NameKey { + pub const fn name_key( + &self, + local: crate::Handle, + ) -> crate::proc::NameKey { match self.ty { FunctionType::Function(handle) => crate::proc::NameKey::FunctionLocal(handle, local), FunctionType::EntryPoint(idx) => crate::proc::NameKey::EntryPointLocal(idx, local), @@ -106,7 +116,7 @@ impl FunctionCtx<'_> { /// /// # Panics /// - If the function arguments are less or equal to `arg` - const fn argument_key(&self, arg: u32) -> crate::proc::NameKey { + pub const fn argument_key(&self, arg: u32) -> crate::proc::NameKey { match self.ty { FunctionType::Function(handle) => crate::proc::NameKey::FunctionArgument(handle, arg), FunctionType::EntryPoint(ep_index) => { @@ -115,8 +125,8 @@ impl FunctionCtx<'_> { } } - // Returns true if the given expression points to a fixed-function pipeline input. - fn is_fixed_function_input( + /// Returns true if the given expression points to a fixed-function pipeline input. + pub fn is_fixed_function_input( &self, mut expression: crate::Handle, module: &crate::Module, @@ -162,7 +172,7 @@ impl crate::Expression { /// See the [module-level documentation][emit] for details. /// /// [emit]: index.html#expression-evaluation-time - const fn bake_ref_count(&self) -> usize { + pub const fn bake_ref_count(&self) -> usize { match *self { // accesses are never cached, only loads are crate::Expression::Access { .. } | crate::Expression::AccessIndex { .. } => usize::MAX, @@ -181,9 +191,7 @@ impl crate::Expression { } /// Helper function that returns the string corresponding to the [`BinaryOperator`](crate::BinaryOperator) -/// # Notes -/// Used by `glsl-out`, `msl-out`, `wgsl-out`, `hlsl-out`. -const fn binary_operation_str(op: crate::BinaryOperator) -> &'static str { +pub const fn binary_operation_str(op: crate::BinaryOperator) -> &'static str { use crate::BinaryOperator as Bo; match op { Bo::Add => "+", @@ -208,8 +216,6 @@ const fn binary_operation_str(op: crate::BinaryOperator) -> &'static str { } /// Helper function that returns the string corresponding to the [`VectorSize`](crate::VectorSize) -/// # Notes -/// Used by `msl-out`, `wgsl-out`, `hlsl-out`. const fn vector_size_str(size: crate::VectorSize) -> &'static str { match size { crate::VectorSize::Bi => "2", @@ -219,7 +225,8 @@ const fn vector_size_str(size: crate::VectorSize) -> &'static str { } impl crate::TypeInner { - const fn is_handle(&self) -> bool { + /// Returns true if this is a handle to a type rather than the type directly. + pub const fn is_handle(&self) -> bool { match *self { crate::TypeInner::Image { .. } | crate::TypeInner::Sampler { .. } => true, _ => false, @@ -266,8 +273,9 @@ bitflags::bitflags! { } } +/// The intersection test to use for ray queries. #[repr(u32)] -enum RayIntersectionType { +pub enum RayIntersectionType { Triangle = 1, BoundingBox = 4, } diff --git a/naga/src/back/msl/keywords.rs b/naga/src/back/msl/keywords.rs index f0025bf239..73c457dd34 100644 --- a/naga/src/back/msl/keywords.rs +++ b/naga/src/back/msl/keywords.rs @@ -4,6 +4,8 @@ // C++ - Standard for Programming Language C++ (N4431) // https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4431.pdf pub const RESERVED: &[&str] = &[ + // Undocumented + "assert", // found in https://github.com/gfx-rs/wgpu/issues/5347 // Standard for Programming Language C++ (N4431): 2.5 Alternative tokens "and", "bitor", diff --git a/naga/src/back/msl/mod.rs b/naga/src/back/msl/mod.rs index 5ef18730c9..68e5b79906 100644 --- a/naga/src/back/msl/mod.rs +++ b/naga/src/back/msl/mod.rs @@ -121,8 +121,8 @@ pub enum Error { UnsupportedCall(String), #[error("feature '{0}' is not implemented yet")] FeatureNotImplemented(String), - #[error("module is not valid")] - Validation, + #[error("internal naga error: module should not have validated: {0}")] + GenericValidation(String), #[error("BuiltIn {0:?} is not supported")] UnsupportedBuiltIn(crate::BuiltIn), #[error("capability {0:?} is not supported")] @@ -306,13 +306,10 @@ impl Options { }, }) } - LocationMode::Uniform => { - log::error!( - "Unexpected Binding::Location({}) for the Uniform mode", - location - ); - Err(Error::Validation) - } + LocationMode::Uniform => Err(Error::GenericValidation(format!( + "Unexpected Binding::Location({}) for the Uniform mode", + location + ))), }, } } diff --git a/naga/src/back/msl/writer.rs b/naga/src/back/msl/writer.rs index 1e496b5f50..5227d8e7db 100644 --- a/naga/src/back/msl/writer.rs +++ b/naga/src/back/msl/writer.rs @@ -319,7 +319,7 @@ pub struct Writer { } impl crate::Scalar { - const fn to_msl_name(self) -> &'static str { + fn to_msl_name(self) -> &'static str { use crate::ScalarKind as Sk; match self { Self { @@ -328,12 +328,20 @@ impl crate::Scalar { } => "float", Self { kind: Sk::Sint, - width: _, + width: 4, } => "int", Self { kind: Sk::Uint, - width: _, + width: 4, } => "uint", + Self { + kind: Sk::Sint, + width: 8, + } => "long", + Self { + kind: Sk::Uint, + width: 8, + } => "ulong", Self { kind: Sk::Bool, width: _, @@ -341,7 +349,8 @@ impl crate::Scalar { Self { kind: Sk::AbstractInt | Sk::AbstractFloat, width: _, - } => unreachable!(), + } => unreachable!("Found Abstract scalar kind"), + _ => unreachable!("Unsupported scalar kind: {:?}", self), } } } @@ -735,7 +744,11 @@ impl Writer { crate::TypeInner::Vector { size, .. } => { put_numeric_type(&mut self.out, crate::Scalar::U32, &[size])? } - _ => return Err(Error::Validation), + _ => { + return Err(Error::GenericValidation( + "Invalid type for image coordinate".into(), + )) + } }; write!(self.out, "(")?; @@ -1068,13 +1081,17 @@ impl Writer { let (offset, array_ty) = match context.module.types[global.ty].inner { crate::TypeInner::Struct { ref members, .. } => match members.last() { Some(&crate::StructMember { offset, ty, .. }) => (offset, ty), - None => return Err(Error::Validation), + None => return Err(Error::GenericValidation("Struct has no members".into())), }, crate::TypeInner::Array { size: crate::ArraySize::Dynamic, .. } => (0, global.ty), - _ => return Err(Error::Validation), + ref ty => { + return Err(Error::GenericValidation(format!( + "Expected type with dynamic array, got {ty:?}" + ))) + } }; let (size, stride) = match context.module.types[array_ty].inner { @@ -1084,7 +1101,11 @@ impl Writer { .size(context.module.to_ctx()), stride, ), - _ => return Err(Error::Validation), + ref ty => { + return Err(Error::GenericValidation(format!( + "Expected array type, got {ty:?}" + ))) + } }; // When the stride length is larger than the size, the final element's stride of @@ -1273,6 +1294,9 @@ impl Writer { crate::Literal::I32(value) => { write!(self.out, "{value}")?; } + crate::Literal::U64(value) => { + write!(self.out, "{value}uL")?; + } crate::Literal::I64(value) => { write!(self.out, "{value}L")?; } @@ -1280,7 +1304,9 @@ impl Writer { write!(self.out, "{value}")?; } crate::Literal::AbstractInt(_) | crate::Literal::AbstractFloat(_) => { - return Err(Error::Validation); + return Err(Error::GenericValidation( + "Unsupported abstract literal".into(), + )); } }, crate::Expression::Constant(handle) => { @@ -1342,7 +1368,11 @@ impl Writer { crate::Expression::Splat { size, value } => { let scalar = match *get_expr_ty(ctx, value).inner_with(&module.types) { crate::TypeInner::Scalar(scalar) => scalar, - _ => return Err(Error::Validation), + ref ty => { + return Err(Error::GenericValidation(format!( + "Expected splat value type must be a scalar, got {ty:?}", + ))) + } }; put_numeric_type(&mut self.out, scalar, &[size])?; write!(self.out, "(")?; @@ -1672,7 +1702,11 @@ impl Writer { self.put_expression(condition, context, true)?; write!(self.out, ")")?; } - _ => return Err(Error::Validation), + ref ty => { + return Err(Error::GenericValidation(format!( + "Expected select condition to be a non-bool type, got {ty:?}", + ))) + } }, crate::Expression::Derivative { axis, expr, .. } => { use crate::DerivativeAxis as Axis; @@ -1794,8 +1828,8 @@ impl Writer { Mf::CountLeadingZeros => "clz", Mf::CountOneBits => "popcount", Mf::ReverseBits => "reverse_bits", - Mf::ExtractBits => "extract_bits", - Mf::InsertBits => "insert_bits", + Mf::ExtractBits => "", + Mf::InsertBits => "", Mf::FindLsb => "", Mf::FindMsb => "", // data packing @@ -1836,15 +1870,23 @@ impl Writer { self.put_expression(arg1.unwrap(), context, false)?; write!(self.out, ")")?; } else if fun == Mf::FindLsb { + let scalar = context.resolve_type(arg).scalar().unwrap(); + let constant = scalar.width * 8 + 1; + write!(self.out, "((({NAMESPACE}::ctz(")?; self.put_expression(arg, context, true)?; - write!(self.out, ") + 1) % 33) - 1)")?; + write!(self.out, ") + 1) % {constant}) - 1)")?; } else if fun == Mf::FindMsb { let inner = context.resolve_type(arg); + let scalar = inner.scalar().unwrap(); + let constant = scalar.width * 8 - 1; - write!(self.out, "{NAMESPACE}::select(31 - {NAMESPACE}::clz(")?; + write!( + self.out, + "{NAMESPACE}::select({constant} - {NAMESPACE}::clz(" + )?; - if let Some(crate::ScalarKind::Sint) = inner.scalar_kind() { + if scalar.kind == crate::ScalarKind::Sint { write!(self.out, "{NAMESPACE}::select(")?; self.put_expression(arg, context, true)?; write!(self.out, ", ~")?; @@ -1862,18 +1904,12 @@ impl Writer { match *inner { crate::TypeInner::Vector { size, scalar } => { let size = back::vector_size_str(size); - if let crate::ScalarKind::Sint = scalar.kind { - write!(self.out, "int{size}")?; - } else { - write!(self.out, "uint{size}")?; - } + let name = scalar.to_msl_name(); + write!(self.out, "{name}{size}")?; } crate::TypeInner::Scalar(scalar) => { - if let crate::ScalarKind::Sint = scalar.kind { - write!(self.out, "int")?; - } else { - write!(self.out, "uint")?; - } + let name = scalar.to_msl_name(); + write!(self.out, "{name}")?; } _ => (), } @@ -1891,6 +1927,52 @@ impl Writer { write!(self.out, "as_type(half2(")?; self.put_expression(arg, context, false)?; write!(self.out, "))")?; + } else if fun == Mf::ExtractBits { + // The behavior of ExtractBits is undefined when offset + count > bit_width. We need + // to first sanitize the offset and count first. If we don't do this, Apple chips + // will return out-of-spec values if the extracted range is not within the bit width. + // + // This encodes the exact formula specified by the wgsl spec, without temporary values: + // https://gpuweb.github.io/gpuweb/wgsl/#extractBits-unsigned-builtin + // + // w = sizeof(x) * 8 + // o = min(offset, w) + // tmp = w - o + // c = min(count, tmp) + // + // bitfieldExtract(x, o, c) + // + // extract_bits(e, min(offset, w), min(count, w - min(offset, w)))) + + let scalar_bits = context.resolve_type(arg).scalar_width().unwrap(); + + write!(self.out, "{NAMESPACE}::extract_bits(")?; + self.put_expression(arg, context, true)?; + write!(self.out, ", {NAMESPACE}::min(")?; + self.put_expression(arg1.unwrap(), context, true)?; + write!(self.out, ", {scalar_bits}u), {NAMESPACE}::min(")?; + self.put_expression(arg2.unwrap(), context, true)?; + write!(self.out, ", {scalar_bits}u - {NAMESPACE}::min(")?; + self.put_expression(arg1.unwrap(), context, true)?; + write!(self.out, ", {scalar_bits}u)))")?; + } else if fun == Mf::InsertBits { + // The behavior of InsertBits has the same issue as ExtractBits. + // + // insertBits(e, newBits, min(offset, w), min(count, w - min(offset, w)))) + + let scalar_bits = context.resolve_type(arg).scalar_width().unwrap(); + + write!(self.out, "{NAMESPACE}::insert_bits(")?; + self.put_expression(arg, context, true)?; + write!(self.out, ", ")?; + self.put_expression(arg1.unwrap(), context, true)?; + write!(self.out, ", {NAMESPACE}::min(")?; + self.put_expression(arg2.unwrap(), context, true)?; + write!(self.out, ", {scalar_bits}u), {NAMESPACE}::min(")?; + self.put_expression(arg3.unwrap(), context, true)?; + write!(self.out, ", {scalar_bits}u - {NAMESPACE}::min(")?; + self.put_expression(arg2.unwrap(), context, true)?; + write!(self.out, ", {scalar_bits}u)))")?; } else if fun == Mf::Radians { write!(self.out, "((")?; self.put_expression(arg, context, false)?; @@ -1920,14 +2002,8 @@ impl Writer { kind, width: convert.unwrap_or(src.width), }; - let is_bool_cast = - kind == crate::ScalarKind::Bool || src.kind == crate::ScalarKind::Bool; let op = match convert { - Some(w) if w == src.width || is_bool_cast => "static_cast", - Some(8) if kind == crate::ScalarKind::Float => { - return Err(Error::CapabilityNotSupported(valid::Capabilities::FLOAT64)) - } - Some(_) => return Err(Error::Validation), + Some(_) => "static_cast", None => "as_type", }; write!(self.out, "{op}<")?; @@ -1955,7 +2031,11 @@ impl Writer { self.put_expression(expr, context, true)?; write!(self.out, ")")?; } - _ => return Err(Error::Validation), + ref ty => { + return Err(Error::GenericValidation(format!( + "Unsupported type for As: {ty:?}" + ))) + } }, // has to be a named expression crate::Expression::CallResult(_) @@ -1970,11 +2050,19 @@ impl Writer { crate::Expression::AccessIndex { base, .. } => { match context.function.expressions[base] { crate::Expression::GlobalVariable(handle) => handle, - _ => return Err(Error::Validation), + ref ex => { + return Err(Error::GenericValidation(format!( + "Expected global variable in AccessIndex, got {ex:?}" + ))) + } } } crate::Expression::GlobalVariable(handle) => handle, - _ => return Err(Error::Validation), + ref ex => { + return Err(Error::GenericValidation(format!( + "Unexpected expression in ArrayLength, got {ex:?}" + ))) + } }; if !is_scoped { @@ -2140,10 +2228,12 @@ impl Writer { match length { index::IndexableLength::Known(value) => write!(self.out, "{value}")?, index::IndexableLength::Dynamic => { - let global = context - .function - .originating_global(base) - .ok_or(Error::Validation)?; + let global = + context.function.originating_global(base).ok_or_else(|| { + Error::GenericValidation( + "Could not find originating global".into(), + ) + })?; write!(self.out, "1 + ")?; self.put_dynamic_array_max_index(global, context)? } @@ -2300,10 +2390,9 @@ impl Writer { write!(self.out, "{}u", limit - 1)?; } index::IndexableLength::Dynamic => { - let global = context - .function - .originating_global(base) - .ok_or(Error::Validation)?; + let global = context.function.originating_global(base).ok_or_else(|| { + Error::GenericValidation("Could not find originating global".into()) + })?; self.put_dynamic_array_max_index(global, context)?; } } @@ -2489,7 +2578,14 @@ impl Writer { } } - if let Expression::Math { fun, arg, arg1, .. } = *expr { + if let Expression::Math { + fun, + arg, + arg1, + arg2, + .. + } = *expr + { match fun { crate::MathFunction::Dot => { // WGSL's `dot` function works on any `vecN` type, but Metal's only @@ -2514,6 +2610,14 @@ impl Writer { crate::MathFunction::FindMsb => { self.need_bake_expressions.insert(arg); } + crate::MathFunction::ExtractBits => { + // Only argument 1 is re-used. + self.need_bake_expressions.insert(arg1.unwrap()); + } + crate::MathFunction::InsertBits => { + // Only argument 2 is re-used. + self.need_bake_expressions.insert(arg2.unwrap()); + } crate::MathFunction::Sign => { // WGSL's `sign` function works also on signed ints, but Metal's only // works on floating points, so we emit inline code for integer `sign` @@ -3048,7 +3152,7 @@ impl Writer { for statement in statements { if let crate::Statement::Emit(ref range) = *statement { for handle in range.clone() { - self.named_expressions.remove(&handle); + self.named_expressions.shift_remove(&handle); } } } @@ -3897,7 +4001,9 @@ impl Writer { binding: None, first_time: true, }; - let binding = binding.ok_or(Error::Validation)?; + let binding = binding.ok_or_else(|| { + Error::GenericValidation("Expected binding, got None".into()) + })?; if let crate::Binding::BuiltIn(crate::BuiltIn::PointSize) = *binding { has_point_size = true; diff --git a/naga/src/back/spv/block.rs b/naga/src/back/spv/block.rs index 6c96fa09e3..81f2fc10e0 100644 --- a/naga/src/back/spv/block.rs +++ b/naga/src/back/spv/block.rs @@ -731,12 +731,41 @@ impl<'w> BlockContext<'w> { Some(crate::ScalarKind::Uint) => spirv::GLOp::UMax, other => unimplemented!("Unexpected max({:?})", other), }), - Mf::Clamp => MathOp::Ext(match arg_scalar_kind { - Some(crate::ScalarKind::Float) => spirv::GLOp::FClamp, - Some(crate::ScalarKind::Sint) => spirv::GLOp::SClamp, - Some(crate::ScalarKind::Uint) => spirv::GLOp::UClamp, + Mf::Clamp => match arg_scalar_kind { + // Clamp is undefined if min > max. In practice this means it can use a median-of-three + // instruction to determine the value. This is fine according to the WGSL spec for float + // clamp, but integer clamp _must_ use min-max. As such we write out min/max. + Some(crate::ScalarKind::Float) => MathOp::Ext(spirv::GLOp::FClamp), + Some(_) => { + let (min_op, max_op) = match arg_scalar_kind { + Some(crate::ScalarKind::Sint) => { + (spirv::GLOp::SMin, spirv::GLOp::SMax) + } + Some(crate::ScalarKind::Uint) => { + (spirv::GLOp::UMin, spirv::GLOp::UMax) + } + _ => unreachable!(), + }; + + let max_id = self.gen_id(); + block.body.push(Instruction::ext_inst( + self.writer.gl450_ext_inst_id, + max_op, + result_type_id, + max_id, + &[arg0_id, arg1_id], + )); + + MathOp::Custom(Instruction::ext_inst( + self.writer.gl450_ext_inst_id, + min_op, + result_type_id, + id, + &[max_id, arg2_id], + )) + } other => unimplemented!("Unexpected max({:?})", other), - }), + }, Mf::Saturate => { let (maybe_size, scalar) = match *arg_ty { crate::TypeInner::Vector { size, scalar } => (Some(size), scalar), @@ -915,8 +944,7 @@ impl<'w> BlockContext<'w> { )), Mf::CountTrailingZeros => { let uint_id = match *arg_ty { - crate::TypeInner::Vector { size, mut scalar } => { - scalar.kind = crate::ScalarKind::Uint; + crate::TypeInner::Vector { size, scalar } => { let ty = LocalType::Value { vector_size: Some(size), scalar, @@ -927,15 +955,15 @@ impl<'w> BlockContext<'w> { self.temp_list.clear(); self.temp_list.resize( size as _, - self.writer.get_constant_scalar_with(32, scalar)?, + self.writer + .get_constant_scalar_with(scalar.width * 8, scalar)?, ); self.writer.get_constant_composite(ty, &self.temp_list) } - crate::TypeInner::Scalar(mut scalar) => { - scalar.kind = crate::ScalarKind::Uint; - self.writer.get_constant_scalar_with(32, scalar)? - } + crate::TypeInner::Scalar(scalar) => self + .writer + .get_constant_scalar_with(scalar.width * 8, scalar)?, _ => unreachable!(), }; @@ -957,9 +985,8 @@ impl<'w> BlockContext<'w> { )) } Mf::CountLeadingZeros => { - let (int_type_id, int_id) = match *arg_ty { - crate::TypeInner::Vector { size, mut scalar } => { - scalar.kind = crate::ScalarKind::Sint; + let (int_type_id, int_id, width) = match *arg_ty { + crate::TypeInner::Vector { size, scalar } => { let ty = LocalType::Value { vector_size: Some(size), scalar, @@ -970,32 +997,41 @@ impl<'w> BlockContext<'w> { self.temp_list.clear(); self.temp_list.resize( size as _, - self.writer.get_constant_scalar_with(31, scalar)?, + self.writer + .get_constant_scalar_with(scalar.width * 8 - 1, scalar)?, ); ( self.get_type_id(ty), self.writer.get_constant_composite(ty, &self.temp_list), + scalar.width, ) } - crate::TypeInner::Scalar(mut scalar) => { - scalar.kind = crate::ScalarKind::Sint; - ( - self.get_type_id(LookupType::Local(LocalType::Value { - vector_size: None, - scalar, - pointer_space: None, - })), - self.writer.get_constant_scalar_with(31, scalar)?, - ) - } + crate::TypeInner::Scalar(scalar) => ( + self.get_type_id(LookupType::Local(LocalType::Value { + vector_size: None, + scalar, + pointer_space: None, + })), + self.writer + .get_constant_scalar_with(scalar.width * 8 - 1, scalar)?, + scalar.width, + ), _ => unreachable!(), }; + if width != 4 { + unreachable!("This is validated out until a polyfill is implemented. https://github.com/gfx-rs/wgpu/issues/5276"); + }; + let msb_id = self.gen_id(); block.body.push(Instruction::ext_inst( self.writer.gl450_ext_inst_id, - spirv::GLOp::FindUMsb, + if width != 4 { + spirv::GLOp::FindILsb + } else { + spirv::GLOp::FindUMsb + }, int_type_id, msb_id, &[arg0_id], @@ -1021,30 +1057,144 @@ impl<'w> BlockContext<'w> { Some(crate::ScalarKind::Sint) => spirv::Op::BitFieldSExtract, other => unimplemented!("Unexpected sign({:?})", other), }; + + // The behavior of ExtractBits is undefined when offset + count > bit_width. We need + // to first sanitize the offset and count first. If we don't do this, AMD and Intel + // will return out-of-spec values if the extracted range is not within the bit width. + // + // This encodes the exact formula specified by the wgsl spec: + // https://gpuweb.github.io/gpuweb/wgsl/#extractBits-unsigned-builtin + // + // w = sizeof(x) * 8 + // o = min(offset, w) + // tmp = w - o + // c = min(count, tmp) + // + // bitfieldExtract(x, o, c) + + let bit_width = arg_ty.scalar_width().unwrap(); + let width_constant = self + .writer + .get_constant_scalar(crate::Literal::U32(bit_width as u32)); + + let u32_type = self.get_type_id(LookupType::Local(LocalType::Value { + vector_size: None, + scalar: crate::Scalar { + kind: crate::ScalarKind::Uint, + width: 4, + }, + pointer_space: None, + })); + + // o = min(offset, w) + let offset_id = self.gen_id(); + block.body.push(Instruction::ext_inst( + self.writer.gl450_ext_inst_id, + spirv::GLOp::UMin, + u32_type, + offset_id, + &[arg1_id, width_constant], + )); + + // tmp = w - o + let max_count_id = self.gen_id(); + block.body.push(Instruction::binary( + spirv::Op::ISub, + u32_type, + max_count_id, + width_constant, + offset_id, + )); + + // c = min(count, tmp) + let count_id = self.gen_id(); + block.body.push(Instruction::ext_inst( + self.writer.gl450_ext_inst_id, + spirv::GLOp::UMin, + u32_type, + count_id, + &[arg2_id, max_count_id], + )); + MathOp::Custom(Instruction::ternary( op, result_type_id, id, arg0_id, + offset_id, + count_id, + )) + } + Mf::InsertBits => { + // The behavior of InsertBits has the same undefined behavior as ExtractBits. + + let bit_width = arg_ty.scalar_width().unwrap(); + let width_constant = self + .writer + .get_constant_scalar(crate::Literal::U32(bit_width as u32)); + + let u32_type = self.get_type_id(LookupType::Local(LocalType::Value { + vector_size: None, + scalar: crate::Scalar { + kind: crate::ScalarKind::Uint, + width: 4, + }, + pointer_space: None, + })); + + // o = min(offset, w) + let offset_id = self.gen_id(); + block.body.push(Instruction::ext_inst( + self.writer.gl450_ext_inst_id, + spirv::GLOp::UMin, + u32_type, + offset_id, + &[arg2_id, width_constant], + )); + + // tmp = w - o + let max_count_id = self.gen_id(); + block.body.push(Instruction::binary( + spirv::Op::ISub, + u32_type, + max_count_id, + width_constant, + offset_id, + )); + + // c = min(count, tmp) + let count_id = self.gen_id(); + block.body.push(Instruction::ext_inst( + self.writer.gl450_ext_inst_id, + spirv::GLOp::UMin, + u32_type, + count_id, + &[arg3_id, max_count_id], + )); + + MathOp::Custom(Instruction::quaternary( + spirv::Op::BitFieldInsert, + result_type_id, + id, + arg0_id, arg1_id, - arg2_id, + offset_id, + count_id, )) } - Mf::InsertBits => MathOp::Custom(Instruction::quaternary( - spirv::Op::BitFieldInsert, - result_type_id, - id, - arg0_id, - arg1_id, - arg2_id, - arg3_id, - )), Mf::FindLsb => MathOp::Ext(spirv::GLOp::FindILsb), - Mf::FindMsb => MathOp::Ext(match arg_scalar_kind { - Some(crate::ScalarKind::Uint) => spirv::GLOp::FindUMsb, - Some(crate::ScalarKind::Sint) => spirv::GLOp::FindSMsb, - other => unimplemented!("Unexpected findMSB({:?})", other), - }), + Mf::FindMsb => { + if arg_ty.scalar_width() == Some(32) { + let thing = match arg_scalar_kind { + Some(crate::ScalarKind::Uint) => spirv::GLOp::FindUMsb, + Some(crate::ScalarKind::Sint) => spirv::GLOp::FindSMsb, + other => unimplemented!("Unexpected findMSB({:?})", other), + }; + MathOp::Ext(thing) + } else { + unreachable!("This is validated out until a polyfill is implemented. https://github.com/gfx-rs/wgpu/issues/5276"); + } + } Mf::Pack4x8unorm => MathOp::Ext(spirv::GLOp::PackUnorm4x8), Mf::Pack4x8snorm => MathOp::Ext(spirv::GLOp::PackSnorm4x8), Mf::Pack2x16float => MathOp::Ext(spirv::GLOp::PackHalf2x16), @@ -1250,6 +1400,12 @@ impl<'w> BlockContext<'w> { (Sk::Uint, Sk::Uint, Some(dst_width)) if src_scalar.width != dst_width => { Cast::Unary(spirv::Op::UConvert) } + (Sk::Uint, Sk::Sint, Some(dst_width)) if src_scalar.width != dst_width => { + Cast::Unary(spirv::Op::SConvert) + } + (Sk::Sint, Sk::Uint, Some(dst_width)) if src_scalar.width != dst_width => { + Cast::Unary(spirv::Op::UConvert) + } // We assume it's either an identity cast, or int-uint. _ => Cast::Unary(spirv::Op::Bitcast), } diff --git a/naga/src/back/spv/index.rs b/naga/src/back/spv/index.rs index 92e0f88d9a..0effb568be 100644 --- a/naga/src/back/spv/index.rs +++ b/naga/src/back/spv/index.rs @@ -3,8 +3,9 @@ Bounds-checking for SPIR-V output. */ use super::{ - helpers::global_needs_wrapper, selection::Selection, Block, BlockContext, Error, IdGenerator, - Instruction, Word, + helpers::{global_needs_wrapper, map_storage_class}, + selection::Selection, + Block, BlockContext, Error, IdGenerator, Instruction, Word, }; use crate::{arena::Handle, proc::BoundsCheckPolicy}; @@ -42,32 +43,113 @@ impl<'w> BlockContext<'w> { array: Handle, block: &mut Block, ) -> Result { - // Naga IR permits runtime-sized arrays as global variables or as the - // final member of a struct that is a global variable. SPIR-V permits - // only the latter, so this back end wraps bare runtime-sized arrays - // in a made-up struct; see `helpers::global_needs_wrapper` and its uses. - // This code must handle both cases. - let (structure_id, last_member_index) = match self.ir_function.expressions[array] { + // Naga IR permits runtime-sized arrays as global variables, or as the + // final member of a struct that is a global variable, or one of these + // inside a buffer that is itself an element in a buffer bindings array. + // SPIR-V requires that runtime-sized arrays are wrapped in structs. + // See `helpers::global_needs_wrapper` and its uses. + let (opt_array_index_id, global_handle, opt_last_member_index) = match self + .ir_function + .expressions[array] + { crate::Expression::AccessIndex { base, index } => { match self.ir_function.expressions[base] { - crate::Expression::GlobalVariable(handle) => ( - self.writer.global_variables[handle.index()].access_id, - index, - ), - _ => return Err(Error::Validation("array length expression")), + // The global variable is an array of buffer bindings of structs, + // we are accessing one of them with a static index, + // and the last member of it. + crate::Expression::AccessIndex { + base: base_outer, + index: index_outer, + } => match self.ir_function.expressions[base_outer] { + crate::Expression::GlobalVariable(handle) => { + let index_id = self.get_index_constant(index_outer); + (Some(index_id), handle, Some(index)) + } + _ => return Err(Error::Validation("array length expression case-1a")), + }, + // The global variable is an array of buffer bindings of structs, + // we are accessing one of them with a dynamic index, + // and the last member of it. + crate::Expression::Access { + base: base_outer, + index: index_outer, + } => match self.ir_function.expressions[base_outer] { + crate::Expression::GlobalVariable(handle) => { + let index_id = self.cached[index_outer]; + (Some(index_id), handle, Some(index)) + } + _ => return Err(Error::Validation("array length expression case-1b")), + }, + // The global variable is a buffer, and we are accessing the last member. + crate::Expression::GlobalVariable(handle) => { + let global = &self.ir_module.global_variables[handle]; + match self.ir_module.types[global.ty].inner { + // The global variable is an array of buffer bindings of run-time arrays. + crate::TypeInner::BindingArray { .. } => (Some(index), handle, None), + // The global variable is a struct, and we are accessing the last member + _ => (None, handle, Some(index)), + } + } + _ => return Err(Error::Validation("array length expression case-1c")), } } + // The global variable is an array of buffer bindings of arrays. + crate::Expression::Access { base, index } => match self.ir_function.expressions[base] { + crate::Expression::GlobalVariable(handle) => { + let index_id = self.cached[index]; + let global = &self.ir_module.global_variables[handle]; + match self.ir_module.types[global.ty].inner { + crate::TypeInner::BindingArray { .. } => (Some(index_id), handle, None), + _ => return Err(Error::Validation("array length expression case-2a")), + } + } + _ => return Err(Error::Validation("array length expression case-2b")), + }, + // The global variable is a run-time array. crate::Expression::GlobalVariable(handle) => { let global = &self.ir_module.global_variables[handle]; if !global_needs_wrapper(self.ir_module, global) { - return Err(Error::Validation("array length expression")); + return Err(Error::Validation("array length expression case-3")); } - - (self.writer.global_variables[handle.index()].var_id, 0) + (None, handle, None) } - _ => return Err(Error::Validation("array length expression")), + _ => return Err(Error::Validation("array length expression case-4")), }; + let gvar = self.writer.global_variables[global_handle.index()].clone(); + let global = &self.ir_module.global_variables[global_handle]; + let (last_member_index, gvar_id) = match opt_last_member_index { + Some(index) => (index, gvar.access_id), + None => { + if !global_needs_wrapper(self.ir_module, global) { + return Err(Error::Validation( + "pointer to a global that is not a wrapped array", + )); + } + (0, gvar.var_id) + } + }; + let structure_id = match opt_array_index_id { + // We are indexing inside a binding array, generate the access op. + Some(index_id) => { + let element_type_id = match self.ir_module.types[global.ty].inner { + crate::TypeInner::BindingArray { base, size: _ } => { + let class = map_storage_class(global.space); + self.get_pointer_id(base, class)? + } + _ => return Err(Error::Validation("array length expression case-5")), + }; + let structure_id = self.gen_id(); + block.body.push(Instruction::access_chain( + element_type_id, + structure_id, + gvar_id, + &[index_id], + )); + structure_id + } + None => gvar_id, + }; let length_id = self.gen_id(); block.body.push(Instruction::array_length( self.writer.get_uint_type_id(), diff --git a/naga/src/back/spv/mod.rs b/naga/src/back/spv/mod.rs index b7d57be0d4..eb29e3cd8b 100644 --- a/naga/src/back/spv/mod.rs +++ b/naga/src/back/spv/mod.rs @@ -576,6 +576,15 @@ impl BlockContext<'_> { self.writer .get_constant_scalar(crate::Literal::I32(scope as _)) } + + fn get_pointer_id( + &mut self, + handle: Handle, + class: spirv::StorageClass, + ) -> Result { + self.writer + .get_pointer_id(&self.ir_module.types, handle, class) + } } #[derive(Clone, Copy, Default)] diff --git a/naga/src/back/spv/writer.rs b/naga/src/back/spv/writer.rs index 4db86c93a7..a5065e0623 100644 --- a/naga/src/back/spv/writer.rs +++ b/naga/src/back/spv/writer.rs @@ -565,36 +565,38 @@ impl Writer { // Handle globals are pre-emitted and should be loaded automatically. // // Any that are binding arrays we skip as we cannot load the array, we must load the result after indexing. - let is_binding_array = match ir_module.types[var.ty].inner { - crate::TypeInner::BindingArray { .. } => true, - _ => false, - }; - - if var.space == crate::AddressSpace::Handle && !is_binding_array { - let var_type_id = self.get_type_id(LookupType::Handle(var.ty)); - let id = self.id_gen.next(); - prelude - .body - .push(Instruction::load(var_type_id, id, gv.var_id, None)); - gv.access_id = gv.var_id; - gv.handle_id = id; - } else if global_needs_wrapper(ir_module, var) { - let class = map_storage_class(var.space); - let pointer_type_id = self.get_pointer_id(&ir_module.types, var.ty, class)?; - let index_id = self.get_index_constant(0); - - let id = self.id_gen.next(); - prelude.body.push(Instruction::access_chain( - pointer_type_id, - id, - gv.var_id, - &[index_id], - )); - gv.access_id = id; - } else { - // by default, the variable ID is accessed as is - gv.access_id = gv.var_id; - }; + match ir_module.types[var.ty].inner { + crate::TypeInner::BindingArray { .. } => { + gv.access_id = gv.var_id; + } + _ => { + if var.space == crate::AddressSpace::Handle { + let var_type_id = self.get_type_id(LookupType::Handle(var.ty)); + let id = self.id_gen.next(); + prelude + .body + .push(Instruction::load(var_type_id, id, gv.var_id, None)); + gv.access_id = gv.var_id; + gv.handle_id = id; + } else if global_needs_wrapper(ir_module, var) { + let class = map_storage_class(var.space); + let pointer_type_id = + self.get_pointer_id(&ir_module.types, var.ty, class)?; + let index_id = self.get_index_constant(0); + let id = self.id_gen.next(); + prelude.body.push(Instruction::access_chain( + pointer_type_id, + id, + gv.var_id, + &[index_id], + )); + gv.access_id = id; + } else { + // by default, the variable ID is accessed as is + gv.access_id = gv.var_id; + }; + } + } // work around borrow checking in the presence of `self.xxx()` calls self.global_variables[handle.index()] = gv; @@ -1182,6 +1184,9 @@ impl Writer { crate::Literal::F32(value) => Instruction::constant_32bit(type_id, id, value.to_bits()), crate::Literal::U32(value) => Instruction::constant_32bit(type_id, id, value), crate::Literal::I32(value) => Instruction::constant_32bit(type_id, id, value as u32), + crate::Literal::U64(value) => { + Instruction::constant_64bit(type_id, id, value as u32, (value >> 32) as u32) + } crate::Literal::I64(value) => { Instruction::constant_64bit(type_id, id, value as u32, (value >> 32) as u32) } @@ -1855,9 +1860,15 @@ impl Writer { .iter() .flat_map(|entry| entry.function.arguments.iter()) .any(|arg| has_view_index_check(ir_module, arg.binding.as_ref(), arg.ty)); - let has_ray_query = ir_module.special_types.ray_desc.is_some() + let mut has_ray_query = ir_module.special_types.ray_desc.is_some() | ir_module.special_types.ray_intersection.is_some(); + for (_, &crate::Type { ref inner, .. }) in ir_module.types.iter() { + if let &crate::TypeInner::AccelerationStructure | &crate::TypeInner::RayQuery = inner { + has_ray_query = true + } + } + if self.physical_layout.version < 0x10300 && has_storage_buffers { // enable the storage buffer class on < SPV-1.3 Instruction::extension("SPV_KHR_storage_buffer_storage_class") diff --git a/naga/src/back/wgsl/writer.rs b/naga/src/back/wgsl/writer.rs index c737934f5e..3039cbbbe4 100644 --- a/naga/src/back/wgsl/writer.rs +++ b/naga/src/back/wgsl/writer.rs @@ -109,7 +109,7 @@ impl Writer { self.reset(module); // Save all ep result types - for (_, ep) in module.entry_points.iter().enumerate() { + for ep in &module.entry_points { if let Some(ref result) = ep.function.result { self.ep_results.push((ep.stage, result.ty)); } @@ -593,6 +593,7 @@ impl Writer { } write!(self.out, ">")?; } + TypeInner::AccelerationStructure => write!(self.out, "acceleration_structure")?, _ => { return Err(Error::Unimplemented(format!("write_value_type {inner:?}"))); } @@ -1095,16 +1096,24 @@ impl Writer { // value can only be expressed in WGSL using AbstractInt and // a unary negation operator. if value == i32::MIN { - write!(self.out, "i32(-2147483648)")?; + write!(self.out, "i32({})", value)?; } else { write!(self.out, "{}i", value)?; } } crate::Literal::Bool(value) => write!(self.out, "{}", value)?, crate::Literal::F64(value) => write!(self.out, "{:?}lf", value)?, - crate::Literal::I64(_) => { - return Err(Error::Custom("unsupported i64 literal".to_string())); + crate::Literal::I64(value) => { + // `-9223372036854775808li` is not valid WGSL. The most negative `i64` + // value can only be expressed in WGSL using AbstractInt and + // a unary negation operator. + if value == i64::MIN { + write!(self.out, "i64({})", value)?; + } else { + write!(self.out, "{}li", value)?; + } } + crate::Literal::U64(value) => write!(self.out, "{:?}lu", value)?, crate::Literal::AbstractInt(_) | crate::Literal::AbstractFloat(_) => { return Err(Error::Custom( "Abstract types should not appear in IR presented to backends".into(), @@ -1827,6 +1836,14 @@ const fn scalar_kind_str(scalar: crate::Scalar) -> &'static str { kind: Sk::Uint, width: 4, } => "u32", + Scalar { + kind: Sk::Sint, + width: 8, + } => "i64", + Scalar { + kind: Sk::Uint, + width: 8, + } => "u64", Scalar { kind: Sk::Bool, width: 1, diff --git a/naga/src/front/glsl/functions.rs b/naga/src/front/glsl/functions.rs index df8cc8a30e..01846eb814 100644 --- a/naga/src/front/glsl/functions.rs +++ b/naga/src/front/glsl/functions.rs @@ -160,7 +160,7 @@ impl Frontend { } => self.matrix_one_arg(ctx, ty, columns, rows, scalar, (value, expr_meta), meta)?, TypeInner::Struct { ref members, .. } => { let scalar_components = members - .get(0) + .first() .and_then(|member| scalar_components(&ctx.module.types[member.ty].inner)); if let Some(scalar) = scalar_components { ctx.implicit_conversion(&mut value, expr_meta, scalar)?; diff --git a/naga/src/front/glsl/parser/functions.rs b/naga/src/front/glsl/parser/functions.rs index 38184eedf7..d428d74761 100644 --- a/naga/src/front/glsl/parser/functions.rs +++ b/naga/src/front/glsl/parser/functions.rs @@ -435,7 +435,7 @@ impl<'source> ParsingContext<'source> { if self.bump_if(frontend, TokenValue::Semicolon).is_none() { if self.peek_type_name(frontend) || self.peek_type_qualifier(frontend) { - self.parse_declaration(frontend, ctx, false, false)?; + self.parse_declaration(frontend, ctx, false, is_inside_loop)?; } else { let mut stmt = ctx.stmt_ctx(); let expr = self.parse_expression(frontend, ctx, &mut stmt)?; diff --git a/naga/src/front/glsl/variables.rs b/naga/src/front/glsl/variables.rs index 5af2b228f0..9d2e7a0e7b 100644 --- a/naga/src/front/glsl/variables.rs +++ b/naga/src/front/glsl/variables.rs @@ -65,7 +65,7 @@ impl Frontend { let idx = self.entry_args.len(); self.entry_args.push(EntryArg { - name: None, + name: Some(name.into()), binding: Binding::BuiltIn(data.builtin), handle, storage: data.storage, diff --git a/naga/src/front/spv/function.rs b/naga/src/front/spv/function.rs index 198d9c52dd..e81ecf5c9b 100644 --- a/naga/src/front/spv/function.rs +++ b/naga/src/front/spv/function.rs @@ -292,278 +292,286 @@ impl> super::Frontend { ); if let Some(ep) = self.lookup_entry_point.remove(&fun_id) { - // create a wrapping function - let mut function = crate::Function { - name: Some(format!("{}_wrap", ep.name)), - arguments: Vec::new(), - result: None, - local_variables: Arena::new(), - expressions: Arena::new(), - named_expressions: crate::NamedExpressions::default(), - body: crate::Block::new(), - }; + self.deferred_entry_points.push((ep, fun_id)); + } - // 1. copy the inputs from arguments to privates - for &v_id in ep.variable_ids.iter() { - let lvar = self.lookup_variable.lookup(v_id)?; - if let super::Variable::Input(ref arg) = lvar.inner { - let span = module.global_variables.get_span(lvar.handle); - let arg_expr = function.expressions.append( - crate::Expression::FunctionArgument(function.arguments.len() as u32), - span, - ); - let load_expr = if arg.ty == module.global_variables[lvar.handle].ty { - arg_expr - } else { - // The only case where the type is different is if we need to treat - // unsigned integer as signed. - let mut emitter = Emitter::default(); - emitter.start(&function.expressions); - let handle = function.expressions.append( - crate::Expression::As { - expr: arg_expr, - kind: crate::ScalarKind::Sint, - convert: Some(4), - }, - span, - ); - function.body.extend(emitter.finish(&function.expressions)); - handle - }; - function.body.push( - crate::Statement::Store { - pointer: function - .expressions - .append(crate::Expression::GlobalVariable(lvar.handle), span), - value: load_expr, + Ok(()) + } + + pub(super) fn process_entry_point( + &mut self, + module: &mut crate::Module, + ep: super::EntryPoint, + fun_id: u32, + ) -> Result<(), Error> { + // create a wrapping function + let mut function = crate::Function { + name: Some(format!("{}_wrap", ep.name)), + arguments: Vec::new(), + result: None, + local_variables: Arena::new(), + expressions: Arena::new(), + named_expressions: crate::NamedExpressions::default(), + body: crate::Block::new(), + }; + + // 1. copy the inputs from arguments to privates + for &v_id in ep.variable_ids.iter() { + let lvar = self.lookup_variable.lookup(v_id)?; + if let super::Variable::Input(ref arg) = lvar.inner { + let span = module.global_variables.get_span(lvar.handle); + let arg_expr = function.expressions.append( + crate::Expression::FunctionArgument(function.arguments.len() as u32), + span, + ); + let load_expr = if arg.ty == module.global_variables[lvar.handle].ty { + arg_expr + } else { + // The only case where the type is different is if we need to treat + // unsigned integer as signed. + let mut emitter = Emitter::default(); + emitter.start(&function.expressions); + let handle = function.expressions.append( + crate::Expression::As { + expr: arg_expr, + kind: crate::ScalarKind::Sint, + convert: Some(4), }, span, ); + function.body.extend(emitter.finish(&function.expressions)); + handle + }; + function.body.push( + crate::Statement::Store { + pointer: function + .expressions + .append(crate::Expression::GlobalVariable(lvar.handle), span), + value: load_expr, + }, + span, + ); - let mut arg = arg.clone(); - if ep.stage == crate::ShaderStage::Fragment { - if let Some(ref mut binding) = arg.binding { - binding.apply_default_interpolation(&module.types[arg.ty].inner); - } + let mut arg = arg.clone(); + if ep.stage == crate::ShaderStage::Fragment { + if let Some(ref mut binding) = arg.binding { + binding.apply_default_interpolation(&module.types[arg.ty].inner); } - function.arguments.push(arg); } + function.arguments.push(arg); } - // 2. call the wrapped function - let fake_id = !(module.entry_points.len() as u32); // doesn't matter, as long as it's not a collision - let dummy_handle = self.add_call(fake_id, fun_id); - function.body.push( - crate::Statement::Call { - function: dummy_handle, - arguments: Vec::new(), - result: None, - }, - crate::Span::default(), - ); - - // 3. copy the outputs from privates to the result - let mut members = Vec::new(); - let mut components = Vec::new(); - for &v_id in ep.variable_ids.iter() { - let lvar = self.lookup_variable.lookup(v_id)?; - if let super::Variable::Output(ref result) = lvar.inner { - let span = module.global_variables.get_span(lvar.handle); - let expr_handle = function - .expressions - .append(crate::Expression::GlobalVariable(lvar.handle), span); + } + // 2. call the wrapped function + let fake_id = !(module.entry_points.len() as u32); // doesn't matter, as long as it's not a collision + let dummy_handle = self.add_call(fake_id, fun_id); + function.body.push( + crate::Statement::Call { + function: dummy_handle, + arguments: Vec::new(), + result: None, + }, + crate::Span::default(), + ); - // Cull problematic builtins of gl_PerVertex. - // See the docs for `Frontend::gl_per_vertex_builtin_access`. + // 3. copy the outputs from privates to the result + let mut members = Vec::new(); + let mut components = Vec::new(); + for &v_id in ep.variable_ids.iter() { + let lvar = self.lookup_variable.lookup(v_id)?; + if let super::Variable::Output(ref result) = lvar.inner { + let span = module.global_variables.get_span(lvar.handle); + let expr_handle = function + .expressions + .append(crate::Expression::GlobalVariable(lvar.handle), span); + + // Cull problematic builtins of gl_PerVertex. + // See the docs for `Frontend::gl_per_vertex_builtin_access`. + { + let ty = &module.types[result.ty]; + if let crate::TypeInner::Struct { + members: ref original_members, + span, + } = ty.inner { - let ty = &module.types[result.ty]; - match ty.inner { - crate::TypeInner::Struct { - members: ref original_members, - span, - } if ty.name.as_deref() == Some("gl_PerVertex") => { - let mut new_members = original_members.clone(); - for member in &mut new_members { - if let Some(crate::Binding::BuiltIn(built_in)) = member.binding - { - if !self.gl_per_vertex_builtin_access.contains(&built_in) { - member.binding = None - } - } - } - if &new_members != original_members { - module.types.replace( - result.ty, - crate::Type { - name: ty.name.clone(), - inner: crate::TypeInner::Struct { - members: new_members, - span, - }, - }, - ); + let mut new_members = None; + for (idx, member) in original_members.iter().enumerate() { + if let Some(crate::Binding::BuiltIn(built_in)) = member.binding { + if !self.gl_per_vertex_builtin_access.contains(&built_in) { + new_members.get_or_insert_with(|| original_members.clone()) + [idx] + .binding = None; } } - _ => {} + } + if let Some(new_members) = new_members { + module.types.replace( + result.ty, + crate::Type { + name: ty.name.clone(), + inner: crate::TypeInner::Struct { + members: new_members, + span, + }, + }, + ); } } + } - match module.types[result.ty].inner { - crate::TypeInner::Struct { - members: ref sub_members, - .. - } => { - for (index, sm) in sub_members.iter().enumerate() { - if sm.binding.is_none() { - continue; - } - let mut sm = sm.clone(); - - if let Some(ref mut binding) = sm.binding { - if ep.stage == crate::ShaderStage::Vertex { - binding.apply_default_interpolation( - &module.types[sm.ty].inner, - ); - } - } - - members.push(sm); - - components.push(function.expressions.append( - crate::Expression::AccessIndex { - base: expr_handle, - index: index as u32, - }, - span, - )); + match module.types[result.ty].inner { + crate::TypeInner::Struct { + members: ref sub_members, + .. + } => { + for (index, sm) in sub_members.iter().enumerate() { + if sm.binding.is_none() { + continue; } - } - ref inner => { - let mut binding = result.binding.clone(); - if let Some(ref mut binding) = binding { + let mut sm = sm.clone(); + + if let Some(ref mut binding) = sm.binding { if ep.stage == crate::ShaderStage::Vertex { - binding.apply_default_interpolation(inner); + binding.apply_default_interpolation(&module.types[sm.ty].inner); } } - members.push(crate::StructMember { - name: None, - ty: result.ty, - binding, - offset: 0, - }); - // populate just the globals first, then do `Load` in a - // separate step, so that we can get a range. - components.push(expr_handle); + members.push(sm); + + components.push(function.expressions.append( + crate::Expression::AccessIndex { + base: expr_handle, + index: index as u32, + }, + span, + )); } } - } - } + ref inner => { + let mut binding = result.binding.clone(); + if let Some(ref mut binding) = binding { + if ep.stage == crate::ShaderStage::Vertex { + binding.apply_default_interpolation(inner); + } + } - for (member_index, member) in members.iter().enumerate() { - match member.binding { - Some(crate::Binding::BuiltIn(crate::BuiltIn::Position { .. })) - if self.options.adjust_coordinate_space => - { - let mut emitter = Emitter::default(); - emitter.start(&function.expressions); - let global_expr = components[member_index]; - let span = function.expressions.get_span(global_expr); - let access_expr = function.expressions.append( - crate::Expression::AccessIndex { - base: global_expr, - index: 1, - }, - span, - ); - let load_expr = function.expressions.append( - crate::Expression::Load { - pointer: access_expr, - }, - span, - ); - let neg_expr = function.expressions.append( - crate::Expression::Unary { - op: crate::UnaryOperator::Negate, - expr: load_expr, - }, - span, - ); - function.body.extend(emitter.finish(&function.expressions)); - function.body.push( - crate::Statement::Store { - pointer: access_expr, - value: neg_expr, - }, - span, - ); + members.push(crate::StructMember { + name: None, + ty: result.ty, + binding, + offset: 0, + }); + // populate just the globals first, then do `Load` in a + // separate step, so that we can get a range. + components.push(expr_handle); } - _ => {} } } + } - let mut emitter = Emitter::default(); - emitter.start(&function.expressions); - for component in components.iter_mut() { - let load_expr = crate::Expression::Load { - pointer: *component, - }; - let span = function.expressions.get_span(*component); - *component = function.expressions.append(load_expr, span); - } - - match members[..] { - [] => {} - [ref member] => { - function.body.extend(emitter.finish(&function.expressions)); - let span = function.expressions.get_span(components[0]); - function.body.push( - crate::Statement::Return { - value: components.first().cloned(), + for (member_index, member) in members.iter().enumerate() { + match member.binding { + Some(crate::Binding::BuiltIn(crate::BuiltIn::Position { .. })) + if self.options.adjust_coordinate_space => + { + let mut emitter = Emitter::default(); + emitter.start(&function.expressions); + let global_expr = components[member_index]; + let span = function.expressions.get_span(global_expr); + let access_expr = function.expressions.append( + crate::Expression::AccessIndex { + base: global_expr, + index: 1, }, span, ); - function.result = Some(crate::FunctionResult { - ty: member.ty, - binding: member.binding.clone(), - }); - } - _ => { - let span = crate::Span::total_span( - components.iter().map(|h| function.expressions.get_span(*h)), + let load_expr = function.expressions.append( + crate::Expression::Load { + pointer: access_expr, + }, + span, ); - let ty = module.types.insert( - crate::Type { - name: None, - inner: crate::TypeInner::Struct { - members, - span: 0xFFFF, // shouldn't matter - }, + let neg_expr = function.expressions.append( + crate::Expression::Unary { + op: crate::UnaryOperator::Negate, + expr: load_expr, }, span, ); - let result_expr = function - .expressions - .append(crate::Expression::Compose { ty, components }, span); function.body.extend(emitter.finish(&function.expressions)); function.body.push( - crate::Statement::Return { - value: Some(result_expr), + crate::Statement::Store { + pointer: access_expr, + value: neg_expr, }, span, ); - function.result = Some(crate::FunctionResult { ty, binding: None }); } + _ => {} } + } - module.entry_points.push(crate::EntryPoint { - name: ep.name, - stage: ep.stage, - early_depth_test: ep.early_depth_test, - workgroup_size: ep.workgroup_size, - function, - }); + let mut emitter = Emitter::default(); + emitter.start(&function.expressions); + for component in components.iter_mut() { + let load_expr = crate::Expression::Load { + pointer: *component, + }; + let span = function.expressions.get_span(*component); + *component = function.expressions.append(load_expr, span); } + match members[..] { + [] => {} + [ref member] => { + function.body.extend(emitter.finish(&function.expressions)); + let span = function.expressions.get_span(components[0]); + function.body.push( + crate::Statement::Return { + value: components.first().cloned(), + }, + span, + ); + function.result = Some(crate::FunctionResult { + ty: member.ty, + binding: member.binding.clone(), + }); + } + _ => { + let span = crate::Span::total_span( + components.iter().map(|h| function.expressions.get_span(*h)), + ); + let ty = module.types.insert( + crate::Type { + name: None, + inner: crate::TypeInner::Struct { + members, + span: 0xFFFF, // shouldn't matter + }, + }, + span, + ); + let result_expr = function + .expressions + .append(crate::Expression::Compose { ty, components }, span); + function.body.extend(emitter.finish(&function.expressions)); + function.body.push( + crate::Statement::Return { + value: Some(result_expr), + }, + span, + ); + function.result = Some(crate::FunctionResult { ty, binding: None }); + } + } + + module.entry_points.push(crate::EntryPoint { + name: ep.name, + stage: ep.stage, + early_depth_test: ep.early_depth_test, + workgroup_size: ep.workgroup_size, + function, + }); + Ok(()) } } diff --git a/naga/src/front/spv/mod.rs b/naga/src/front/spv/mod.rs index 8b1c854358..b793448597 100644 --- a/naga/src/front/spv/mod.rs +++ b/naga/src/front/spv/mod.rs @@ -577,6 +577,9 @@ pub struct Frontend { lookup_function_type: FastHashMap, lookup_function: FastHashMap, lookup_entry_point: FastHashMap, + // When parsing functions, each entry point function gets an entry here so that additional + // processing for them can be performed after all function parsing. + deferred_entry_points: Vec<(EntryPoint, spirv::Word)>, //Note: each `OpFunctionCall` gets a single entry here, indexed by the // dummy `Handle` of the call site. deferred_function_calls: Vec, @@ -628,6 +631,7 @@ impl> Frontend { lookup_function_type: FastHashMap::default(), lookup_function: FastHashMap::default(), lookup_entry_point: FastHashMap::default(), + deferred_entry_points: Vec::default(), deferred_function_calls: Vec::default(), dummy_functions: Arena::new(), function_call_graph: GraphMap::new(), @@ -1561,12 +1565,10 @@ impl> Frontend { span, ); - if ty.name.as_deref() == Some("gl_PerVertex") { - if let Some(crate::Binding::BuiltIn(built_in)) = - members[index as usize].binding - { - self.gl_per_vertex_builtin_access.insert(built_in); - } + if let Some(crate::Binding::BuiltIn(built_in)) = + members[index as usize].binding + { + self.gl_per_vertex_builtin_access.insert(built_in); } AccessExpression { @@ -3956,6 +3958,12 @@ impl> Frontend { }?; } + // Do entry point specific processing after all functions are parsed so that we can + // cull unused problematic builtins of gl_PerVertex. + for (ep, fun_id) in core::mem::take(&mut self.deferred_entry_points) { + self.process_entry_point(&mut module, ep, fun_id)?; + } + log::info!("Patching..."); { let mut nodes = petgraph::algo::toposort(&self.function_call_graph, None) @@ -4868,6 +4876,11 @@ impl> Frontend { let low = self.next()?; match width { 4 => crate::Literal::U32(low), + 8 => { + inst.expect(5)?; + let high = self.next()?; + crate::Literal::U64(u64::from(high) << 32 | u64::from(low)) + } _ => return Err(Error::InvalidTypeWidth(width as u32)), } } @@ -5081,7 +5094,7 @@ impl> Frontend { None }; let span = self.span_from_with_op(start); - let mut dec = self.future_decor.remove(&id).unwrap_or_default(); + let dec = self.future_decor.remove(&id).unwrap_or_default(); let original_ty = self.lookup_type.lookup(type_id)?.handle; let mut ty = original_ty; @@ -5127,17 +5140,6 @@ impl> Frontend { None => map_storage_class(storage_class)?, }; - // Fix empty name for gl_PerVertex struct generated by glslang - if let crate::TypeInner::Pointer { .. } = module.types[original_ty].inner { - if ext_class == ExtendedClass::Input || ext_class == ExtendedClass::Output { - if let Some(ref dec_name) = dec.name { - if dec_name.is_empty() { - dec.name = Some("perVertexStruct".to_string()) - } - } - } - } - let (inner, var) = match ext_class { ExtendedClass::Global(mut space) => { if let crate::AddressSpace::Storage { ref mut access } = space { @@ -5323,6 +5325,21 @@ pub fn parse_u8_slice(data: &[u8], options: &Options) -> Result bool { + loop { + if child == parent { + // The child is in the scope parent + break true; + } else if child == 0 { + // Searched finished at the root the child isn't in the parent's body + break false; + } + + child = block_ctx.bodies[child].parent; + } +} + #[cfg(test)] mod test { #[test] @@ -5339,18 +5356,3 @@ mod test { let _ = super::parse_u8_slice(&bin, &Default::default()).unwrap(); } } - -/// Helper function to check if `child` is in the scope of `parent` -fn is_parent(mut child: usize, parent: usize, block_ctx: &BlockContext) -> bool { - loop { - if child == parent { - // The child is in the scope parent - break true; - } else if child == 0 { - // Searched finished at the root the child isn't in the parent's body - break false; - } - - child = block_ctx.bodies[child].parent; - } -} diff --git a/naga/src/front/wgsl/error.rs b/naga/src/front/wgsl/error.rs index 07e68f8dd9..54aa8296b1 100644 --- a/naga/src/front/wgsl/error.rs +++ b/naga/src/front/wgsl/error.rs @@ -87,7 +87,7 @@ impl ParseError { /// Returns a [`SourceLocation`] for the first label in the error message. pub fn location(&self, source: &str) -> Option { - self.labels.get(0).map(|label| label.0.location(source)) + self.labels.first().map(|label| label.0.location(source)) } } diff --git a/naga/src/front/wgsl/lower/mod.rs b/naga/src/front/wgsl/lower/mod.rs index ba9b49e135..2ca6c182b7 100644 --- a/naga/src/front/wgsl/lower/mod.rs +++ b/naga/src/front/wgsl/lower/mod.rs @@ -1530,6 +1530,8 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { ast::Literal::Number(Number::F32(f)) => crate::Literal::F32(f), ast::Literal::Number(Number::I32(i)) => crate::Literal::I32(i), ast::Literal::Number(Number::U32(u)) => crate::Literal::U32(u), + ast::Literal::Number(Number::I64(i)) => crate::Literal::I64(i), + ast::Literal::Number(Number::U64(u)) => crate::Literal::U64(u), ast::Literal::Number(Number::F64(f)) => crate::Literal::F64(f), ast::Literal::Number(Number::AbstractInt(i)) => crate::Literal::AbstractInt(i), ast::Literal::Number(Number::AbstractFloat(f)) => { diff --git a/naga/src/front/wgsl/parse/conv.rs b/naga/src/front/wgsl/parse/conv.rs index 08f1e39285..1a4911a3bd 100644 --- a/naga/src/front/wgsl/parse/conv.rs +++ b/naga/src/front/wgsl/parse/conv.rs @@ -124,6 +124,14 @@ pub fn get_scalar_type(word: &str) -> Option { kind: Sk::Uint, width: 4, }), + "i64" => Some(Scalar { + kind: Sk::Sint, + width: 8, + }), + "u64" => Some(Scalar { + kind: Sk::Uint, + width: 8, + }), "bool" => Some(Scalar { kind: Sk::Bool, width: crate::BOOL_WIDTH, diff --git a/naga/src/front/wgsl/parse/number.rs b/naga/src/front/wgsl/parse/number.rs index 7b09ac59bb..ceb2cb336c 100644 --- a/naga/src/front/wgsl/parse/number.rs +++ b/naga/src/front/wgsl/parse/number.rs @@ -12,6 +12,10 @@ pub enum Number { I32(i32), /// Concrete u32 U32(u32), + /// Concrete i64 + I64(i64), + /// Concrete u64 + U64(u64), /// Concrete f32 F32(f32), /// Concrete f64 @@ -31,6 +35,8 @@ enum Kind { enum IntKind { I32, U32, + I64, + U64, } #[derive(Debug)] @@ -270,6 +276,8 @@ fn parse(input: &str) -> (Result, &str) { let kind = consume_map!(bytes, [ b'i' => Kind::Int(IntKind::I32), b'u' => Kind::Int(IntKind::U32), + b'l', b'i' => Kind::Int(IntKind::I64), + b'l', b'u' => Kind::Int(IntKind::U64), b'h' => Kind::Float(FloatKind::F16), b'f' => Kind::Float(FloatKind::F32), b'l', b'f' => Kind::Float(FloatKind::F64), @@ -416,5 +424,13 @@ fn parse_int(input: &str, kind: Option, radix: u32) -> Result Ok(Number::U32(num)), Err(e) => Err(map_err(e)), }, + Some(IntKind::I64) => match i64::from_str_radix(input, radix) { + Ok(num) => Ok(Number::I64(num)), + Err(e) => Err(map_err(e)), + }, + Some(IntKind::U64) => match u64::from_str_radix(input, radix) { + Ok(num) => Ok(Number::U64(num)), + Err(e) => Err(map_err(e)), + }, } } diff --git a/naga/src/front/wgsl/tests.rs b/naga/src/front/wgsl/tests.rs index eb2f8a2eb3..cc3d858317 100644 --- a/naga/src/front/wgsl/tests.rs +++ b/naga/src/front/wgsl/tests.rs @@ -17,6 +17,7 @@ fn parse_comment() { #[test] fn parse_types() { parse_str("const a : i32 = 2;").unwrap(); + parse_str("const a : u64 = 2lu;").unwrap(); assert!(parse_str("const a : x32 = 2;").is_err()); parse_str("var t: texture_2d;").unwrap(); parse_str("var t: texture_cube_array;").unwrap(); diff --git a/naga/src/keywords/wgsl.rs b/naga/src/keywords/wgsl.rs index 7b47a13128..683840dc1f 100644 --- a/naga/src/keywords/wgsl.rs +++ b/naga/src/keywords/wgsl.rs @@ -14,6 +14,7 @@ pub const RESERVED: &[&str] = &[ "f32", "f16", "i32", + "i64", "mat2x2", "mat2x3", "mat2x4", @@ -43,6 +44,7 @@ pub const RESERVED: &[&str] = &[ "texture_depth_cube_array", "texture_depth_multisampled_2d", "u32", + "u64", "vec2", "vec3", "vec4", diff --git a/naga/src/lib.rs b/naga/src/lib.rs index d6b9c6a7f4..4b45174300 100644 --- a/naga/src/lib.rs +++ b/naga/src/lib.rs @@ -252,7 +252,8 @@ An override expression can be evaluated at pipeline creation time. clippy::collapsible_if, clippy::derive_partial_eq_without_eq, clippy::needless_borrowed_reference, - clippy::single_match + clippy::single_match, + clippy::enum_variant_names )] #![warn( trivial_casts, @@ -490,7 +491,7 @@ pub enum ScalarKind { } /// Characteristics of a scalar type. -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize))] #[cfg_attr(feature = "deserialize", derive(Deserialize))] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] @@ -884,6 +885,7 @@ pub enum Literal { F32(f32), U32(u32), I32(i32), + U64(u64), I64(i64), Bool(bool), AbstractInt(i64), @@ -1255,15 +1257,18 @@ pub enum SampleLevel { #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] pub enum ImageQuery { /// Get the size at the specified level. + /// + /// The return value is a `u32` for 1D images, and a `vecN` + /// for an image with dimensions N > 2. Size { /// If `None`, the base level is considered. level: Option>, }, - /// Get the number of mipmap levels. + /// Get the number of mipmap levels, a `u32`. NumLevels, - /// Get the number of array layers. + /// Get the number of array layers, a `u32`. NumLayers, - /// Get the number of samples. + /// Get the number of samples, a `u32`. NumSamples, } @@ -1683,6 +1688,10 @@ pub enum Statement { /// A block containing more statements, to be executed sequentially. Block(Block), /// Conditionally executes one of two blocks, based on the value of the condition. + /// + /// Naga IR does not have "phi" instructions. If you need to use + /// values computed in an `accept` or `reject` block after the `If`, + /// store them in a [`LocalVariable`]. If { condition: Handle, //bool accept: Block, @@ -1702,6 +1711,10 @@ pub enum Statement { /// represented in the IR as a series of fallthrough cases with empty /// bodies, except for the last. /// + /// Naga IR does not have "phi" instructions. If you need to use + /// values computed in a [`SwitchCase::body`] block after the `Switch`, + /// store them in a [`LocalVariable`]. + /// /// [`value`]: SwitchCase::value /// [`body`]: SwitchCase::body /// [`Default`]: SwitchValue::Default @@ -1736,6 +1749,10 @@ pub enum Statement { /// if" statement in WGSL, or a loop whose back edge is an /// `OpBranchConditional` instruction in SPIR-V. /// + /// Naga IR does not have "phi" instructions. If you need to use + /// values computed in a `body` or `continuing` block after the + /// `Loop`, store them in a [`LocalVariable`]. + /// /// [`Break`]: Statement::Break /// [`Continue`]: Statement::Continue /// [`Kill`]: Statement::Kill diff --git a/naga/src/proc/constant_evaluator.rs b/naga/src/proc/constant_evaluator.rs index b3884b04b1..983af3718c 100644 --- a/naga/src/proc/constant_evaluator.rs +++ b/naga/src/proc/constant_evaluator.rs @@ -31,7 +31,7 @@ macro_rules! gen_component_wise_extractor { $( #[doc = concat!( "Maps to [`Literal::", - stringify!($mapping), + stringify!($literal), "`]", )] $mapping([$ty; N]), @@ -200,6 +200,8 @@ gen_component_wise_extractor! { AbstractInt => AbstractInt: i64, U32 => U32: u32, I32 => I32: i32, + U64 => U64: u64, + I64 => I64: i64, ], scalar_kinds: [ Float, @@ -847,6 +849,8 @@ impl<'a> ConstantEvaluator<'a> { Scalar::AbstractInt([e]) => Ok(Scalar::AbstractInt([e.abs()])), Scalar::I32([e]) => Ok(Scalar::I32([e.wrapping_abs()])), Scalar::U32([e]) => Ok(Scalar::U32([e])), // TODO: just re-use the expression, ezpz + Scalar::I64([e]) => Ok(Scalar::I64([e.wrapping_abs()])), + Scalar::U64([e]) => Ok(Scalar::U64([e])), }) } crate::MathFunction::Min => { @@ -1280,7 +1284,7 @@ impl<'a> ConstantEvaluator<'a> { Literal::U32(v) => v as i32, Literal::F32(v) => v as i32, Literal::Bool(v) => v as i32, - Literal::F64(_) | Literal::I64(_) => { + Literal::F64(_) | Literal::I64(_) | Literal::U64(_) => { return make_error(); } Literal::AbstractInt(v) => i32::try_from_abstract(v)?, @@ -1291,18 +1295,40 @@ impl<'a> ConstantEvaluator<'a> { Literal::U32(v) => v, Literal::F32(v) => v as u32, Literal::Bool(v) => v as u32, - Literal::F64(_) | Literal::I64(_) => { + Literal::F64(_) | Literal::I64(_) | Literal::U64(_) => { return make_error(); } Literal::AbstractInt(v) => u32::try_from_abstract(v)?, Literal::AbstractFloat(v) => u32::try_from_abstract(v)?, }), + Sc::I64 => Literal::I64(match literal { + Literal::I32(v) => v as i64, + Literal::U32(v) => v as i64, + Literal::F32(v) => v as i64, + Literal::Bool(v) => v as i64, + Literal::F64(v) => v as i64, + Literal::I64(v) => v, + Literal::U64(v) => v as i64, + Literal::AbstractInt(v) => i64::try_from_abstract(v)?, + Literal::AbstractFloat(v) => i64::try_from_abstract(v)?, + }), + Sc::U64 => Literal::U64(match literal { + Literal::I32(v) => v as u64, + Literal::U32(v) => v as u64, + Literal::F32(v) => v as u64, + Literal::Bool(v) => v as u64, + Literal::F64(v) => v as u64, + Literal::I64(v) => v as u64, + Literal::U64(v) => v, + Literal::AbstractInt(v) => u64::try_from_abstract(v)?, + Literal::AbstractFloat(v) => u64::try_from_abstract(v)?, + }), Sc::F32 => Literal::F32(match literal { Literal::I32(v) => v as f32, Literal::U32(v) => v as f32, Literal::F32(v) => v, Literal::Bool(v) => v as u32 as f32, - Literal::F64(_) | Literal::I64(_) => { + Literal::F64(_) | Literal::I64(_) | Literal::U64(_) => { return make_error(); } Literal::AbstractInt(v) => f32::try_from_abstract(v)?, @@ -1314,7 +1340,7 @@ impl<'a> ConstantEvaluator<'a> { Literal::F32(v) => v as f64, Literal::F64(v) => v, Literal::Bool(v) => v as u32 as f64, - Literal::I64(_) => return make_error(), + Literal::I64(_) | Literal::U64(_) => return make_error(), Literal::AbstractInt(v) => f64::try_from_abstract(v)?, Literal::AbstractFloat(v) => f64::try_from_abstract(v)?, }), @@ -1325,6 +1351,7 @@ impl<'a> ConstantEvaluator<'a> { Literal::Bool(v) => v, Literal::F64(_) | Literal::I64(_) + | Literal::U64(_) | Literal::AbstractInt(_) | Literal::AbstractFloat(_) => { return make_error(); @@ -1877,6 +1904,122 @@ impl<'a> ConstantEvaluator<'a> { } } +/// Trait for conversions of abstract values to concrete types. +trait TryFromAbstract: Sized { + /// Convert an abstract literal `value` to `Self`. + /// + /// Since Naga's `AbstractInt` and `AbstractFloat` exist to support + /// WGSL, we follow WGSL's conversion rules here: + /// + /// - WGSL §6.1.2. Conversion Rank says that automatic conversions + /// to integers are either lossless or an error. + /// + /// - WGSL §14.6.4 Floating Point Conversion says that conversions + /// to floating point in constant expressions and override + /// expressions are errors if the value is out of range for the + /// destination type, but rounding is okay. + /// + /// [`AbstractInt`]: crate::Literal::AbstractInt + /// [`Float`]: crate::Literal::Float + fn try_from_abstract(value: T) -> Result; +} + +impl TryFromAbstract for i32 { + fn try_from_abstract(value: i64) -> Result { + i32::try_from(value).map_err(|_| ConstantEvaluatorError::AutomaticConversionLossy { + value: format!("{value:?}"), + to_type: "i32", + }) + } +} + +impl TryFromAbstract for u32 { + fn try_from_abstract(value: i64) -> Result { + u32::try_from(value).map_err(|_| ConstantEvaluatorError::AutomaticConversionLossy { + value: format!("{value:?}"), + to_type: "u32", + }) + } +} + +impl TryFromAbstract for u64 { + fn try_from_abstract(value: i64) -> Result { + u64::try_from(value).map_err(|_| ConstantEvaluatorError::AutomaticConversionLossy { + value: format!("{value:?}"), + to_type: "u64", + }) + } +} + +impl TryFromAbstract for i64 { + fn try_from_abstract(value: i64) -> Result { + Ok(value) + } +} + +impl TryFromAbstract for f32 { + fn try_from_abstract(value: i64) -> Result { + let f = value as f32; + // The range of `i64` is roughly ±18 × 10¹⁸, whereas the range of + // `f32` is roughly ±3.4 × 10³⁸, so there's no opportunity for + // overflow here. + Ok(f) + } +} + +impl TryFromAbstract for f32 { + fn try_from_abstract(value: f64) -> Result { + let f = value as f32; + if f.is_infinite() { + return Err(ConstantEvaluatorError::AutomaticConversionLossy { + value: format!("{value:?}"), + to_type: "f32", + }); + } + Ok(f) + } +} + +impl TryFromAbstract for f64 { + fn try_from_abstract(value: i64) -> Result { + let f = value as f64; + // The range of `i64` is roughly ±18 × 10¹⁸, whereas the range of + // `f64` is roughly ±1.8 × 10³⁰⁸, so there's no opportunity for + // overflow here. + Ok(f) + } +} + +impl TryFromAbstract for f64 { + fn try_from_abstract(value: f64) -> Result { + Ok(value) + } +} + +impl TryFromAbstract for i32 { + fn try_from_abstract(_: f64) -> Result { + Err(ConstantEvaluatorError::AutomaticConversionFloatToInt { to_type: "i32" }) + } +} + +impl TryFromAbstract for u32 { + fn try_from_abstract(_: f64) -> Result { + Err(ConstantEvaluatorError::AutomaticConversionFloatToInt { to_type: "u32" }) + } +} + +impl TryFromAbstract for i64 { + fn try_from_abstract(_: f64) -> Result { + Err(ConstantEvaluatorError::AutomaticConversionFloatToInt { to_type: "i64" }) + } +} + +impl TryFromAbstract for u64 { + fn try_from_abstract(_: f64) -> Result { + Err(ConstantEvaluatorError::AutomaticConversionFloatToInt { to_type: "u64" }) + } +} + #[cfg(test)] mod tests { use std::vec; @@ -2384,92 +2527,3 @@ mod tests { } } } - -/// Trait for conversions of abstract values to concrete types. -trait TryFromAbstract: Sized { - /// Convert an abstract literal `value` to `Self`. - /// - /// Since Naga's `AbstractInt` and `AbstractFloat` exist to support - /// WGSL, we follow WGSL's conversion rules here: - /// - /// - WGSL §6.1.2. Conversion Rank says that automatic conversions - /// to integers are either lossless or an error. - /// - /// - WGSL §14.6.4 Floating Point Conversion says that conversions - /// to floating point in constant expressions and override - /// expressions are errors if the value is out of range for the - /// destination type, but rounding is okay. - /// - /// [`AbstractInt`]: crate::Literal::AbstractInt - /// [`Float`]: crate::Literal::Float - fn try_from_abstract(value: T) -> Result; -} - -impl TryFromAbstract for i32 { - fn try_from_abstract(value: i64) -> Result { - i32::try_from(value).map_err(|_| ConstantEvaluatorError::AutomaticConversionLossy { - value: format!("{value:?}"), - to_type: "i32", - }) - } -} - -impl TryFromAbstract for u32 { - fn try_from_abstract(value: i64) -> Result { - u32::try_from(value).map_err(|_| ConstantEvaluatorError::AutomaticConversionLossy { - value: format!("{value:?}"), - to_type: "u32", - }) - } -} - -impl TryFromAbstract for f32 { - fn try_from_abstract(value: i64) -> Result { - let f = value as f32; - // The range of `i64` is roughly ±18 × 10¹⁸, whereas the range of - // `f32` is roughly ±3.4 × 10³⁸, so there's no opportunity for - // overflow here. - Ok(f) - } -} - -impl TryFromAbstract for f32 { - fn try_from_abstract(value: f64) -> Result { - let f = value as f32; - if f.is_infinite() { - return Err(ConstantEvaluatorError::AutomaticConversionLossy { - value: format!("{value:?}"), - to_type: "f32", - }); - } - Ok(f) - } -} - -impl TryFromAbstract for f64 { - fn try_from_abstract(value: i64) -> Result { - let f = value as f64; - // The range of `i64` is roughly ±18 × 10¹⁸, whereas the range of - // `f64` is roughly ±1.8 × 10³⁰⁸, so there's no opportunity for - // overflow here. - Ok(f) - } -} - -impl TryFromAbstract for f64 { - fn try_from_abstract(value: f64) -> Result { - Ok(value) - } -} - -impl TryFromAbstract for i32 { - fn try_from_abstract(_: f64) -> Result { - Err(ConstantEvaluatorError::AutomaticConversionFloatToInt { to_type: "i32" }) - } -} - -impl TryFromAbstract for u32 { - fn try_from_abstract(_: f64) -> Result { - Err(ConstantEvaluatorError::AutomaticConversionFloatToInt { to_type: "u32" }) - } -} diff --git a/naga/src/proc/mod.rs b/naga/src/proc/mod.rs index b9ce80b5ea..46cbb6c3b3 100644 --- a/naga/src/proc/mod.rs +++ b/naga/src/proc/mod.rs @@ -102,6 +102,10 @@ impl super::Scalar { kind: crate::ScalarKind::Sint, width: 8, }; + pub const U64: Self = Self { + kind: crate::ScalarKind::Uint, + width: 8, + }; pub const BOOL: Self = Self { kind: crate::ScalarKind::Bool, width: crate::BOOL_WIDTH, @@ -156,6 +160,7 @@ impl PartialEq for crate::Literal { (Self::F32(a), Self::F32(b)) => a.to_bits() == b.to_bits(), (Self::U32(a), Self::U32(b)) => a == b, (Self::I32(a), Self::I32(b)) => a == b, + (Self::U64(a), Self::U64(b)) => a == b, (Self::I64(a), Self::I64(b)) => a == b, (Self::Bool(a), Self::Bool(b)) => a == b, _ => false, @@ -186,10 +191,18 @@ impl std::hash::Hash for crate::Literal { hasher.write_u8(4); v.hash(hasher); } - Self::I64(v) | Self::AbstractInt(v) => { + Self::I64(v) => { hasher.write_u8(5); v.hash(hasher); } + Self::U64(v) => { + hasher.write_u8(6); + v.hash(hasher); + } + Self::AbstractInt(v) => { + hasher.write_u8(7); + v.hash(hasher); + } } } } @@ -201,6 +214,7 @@ impl crate::Literal { (value, crate::ScalarKind::Float, 4) => Some(Self::F32(value as _)), (value, crate::ScalarKind::Uint, 4) => Some(Self::U32(value as _)), (value, crate::ScalarKind::Sint, 4) => Some(Self::I32(value as _)), + (value, crate::ScalarKind::Uint, 8) => Some(Self::U64(value as _)), (value, crate::ScalarKind::Sint, 8) => Some(Self::I64(value as _)), (1, crate::ScalarKind::Bool, 4) => Some(Self::Bool(true)), (0, crate::ScalarKind::Bool, 4) => Some(Self::Bool(false)), @@ -218,7 +232,7 @@ impl crate::Literal { pub const fn width(&self) -> crate::Bytes { match *self { - Self::F64(_) | Self::I64(_) => 8, + Self::F64(_) | Self::I64(_) | Self::U64(_) => 8, Self::F32(_) | Self::U32(_) | Self::I32(_) => 4, Self::Bool(_) => crate::BOOL_WIDTH, Self::AbstractInt(_) | Self::AbstractFloat(_) => crate::ABSTRACT_WIDTH, @@ -230,6 +244,7 @@ impl crate::Literal { Self::F32(_) => crate::Scalar::F32, Self::U32(_) => crate::Scalar::U32, Self::I32(_) => crate::Scalar::I32, + Self::U64(_) => crate::Scalar::U64, Self::I64(_) => crate::Scalar::I64, Self::Bool(_) => crate::Scalar::BOOL, Self::AbstractInt(_) => crate::Scalar::ABSTRACT_INT, diff --git a/naga/src/span.rs b/naga/src/span.rs index 53246b25d6..10744647e9 100644 --- a/naga/src/span.rs +++ b/naga/src/span.rs @@ -104,16 +104,17 @@ impl std::ops::Index for str { /// A human-readable representation for a span, tailored for text source. /// -/// Corresponds to the positional members of [`GPUCompilationMessage`][gcm] from -/// the WebGPU specification, except that `offset` and `length` are in bytes -/// (UTF-8 code units), instead of UTF-16 code units. +/// Roughly corresponds to the positional members of [`GPUCompilationMessage`][gcm] from +/// the WebGPU specification, except +/// - `offset` and `length` are in bytes (UTF-8 code units), instead of UTF-16 code units. +/// - `line_position` counts entire Unicode code points, instead of UTF-16 code units. /// /// [gcm]: https://www.w3.org/TR/webgpu/#gpucompilationmessage #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub struct SourceLocation { /// 1-based line number. pub line_number: u32, - /// 1-based column of the start of this span + /// 1-based column of the start of this span, counted in Unicode code points. pub line_position: u32, /// 0-based Offset in code units (in bytes) of the start of the span. pub offset: u32, diff --git a/naga/src/valid/analyzer.rs b/naga/src/valid/analyzer.rs index df6fc5e9b0..03fbc4089b 100644 --- a/naga/src/valid/analyzer.rs +++ b/naga/src/valid/analyzer.rs @@ -145,10 +145,35 @@ pub struct SamplingKey { #[derive(Clone, Debug)] #[cfg_attr(feature = "serialize", derive(serde::Serialize))] #[cfg_attr(feature = "deserialize", derive(serde::Deserialize))] +/// Information about an expression in a function body. pub struct ExpressionInfo { + /// Whether this expression is uniform, and why. + /// + /// If this expression's value is not uniform, this is the handle + /// of the expression from which this one's non-uniformity + /// originates. Otherwise, this is `None`. pub uniformity: Uniformity, + + /// The number of statements and other expressions using this + /// expression's value. pub ref_count: usize, + + /// The global variable into which this expression produces a pointer. + /// + /// This is `None` unless this expression is either a + /// [`GlobalVariable`], or an [`Access`] or [`AccessIndex`] that + /// ultimately refers to some part of a global. + /// + /// [`Load`] expressions applied to pointer-typed arguments could + /// refer to globals, but we leave this as `None` for them. + /// + /// [`GlobalVariable`]: crate::Expression::GlobalVariable + /// [`Access`]: crate::Expression::Access + /// [`AccessIndex`]: crate::Expression::AccessIndex + /// [`Load`]: crate::Expression::Load assignable_global: Option>, + + /// The type of this expression. pub ty: TypeResolution, } @@ -311,14 +336,20 @@ pub enum UniformityDisruptor { } impl FunctionInfo { - /// Adds a value-type reference to an expression. + /// Record a use of `expr` of the sort given by `global_use`. + /// + /// Bump `expr`'s reference count, and return its uniformity. + /// + /// If `expr` is a pointer to a global variable, or some part of + /// a global variable, add `global_use` to that global's set of + /// uses. #[must_use] fn add_ref_impl( &mut self, - handle: Handle, + expr: Handle, global_use: GlobalUse, ) -> NonUniformResult { - let info = &mut self.expressions[handle.index()]; + let info = &mut self.expressions[expr.index()]; info.ref_count += 1; // mark the used global as read if let Some(global) = info.assignable_global { @@ -327,22 +358,38 @@ impl FunctionInfo { info.uniformity.non_uniform_result } - /// Adds a value-type reference to an expression. + /// Record a use of `expr` for its value. + /// + /// This is used for almost all expression references. Anything + /// that writes to the value `expr` points to, or otherwise wants + /// contribute flags other than `GlobalUse::READ`, should use + /// `add_ref_impl` directly. #[must_use] - fn add_ref(&mut self, handle: Handle) -> NonUniformResult { - self.add_ref_impl(handle, GlobalUse::READ) + fn add_ref(&mut self, expr: Handle) -> NonUniformResult { + self.add_ref_impl(expr, GlobalUse::READ) } - /// Adds a potentially assignable reference to an expression. - /// These are destinations for `Store` and `ImageStore` statements, - /// which can transit through `Access` and `AccessIndex`. + /// Record a use of `expr`, and indicate which global variable it + /// refers to, if any. + /// + /// Bump `expr`'s reference count, and return its uniformity. + /// + /// If `expr` is a pointer to a global variable, or some part + /// thereof, store that global in `*assignable_global`. Leave the + /// global's uses unchanged. + /// + /// This is used to determine the [`assignable_global`] for + /// [`Access`] and [`AccessIndex`] expressions that ultimately + /// refer to a global variable. Those expressions don't contribute + /// any usage to the global themselves; that depends on how other + /// expressions use them. #[must_use] fn add_assignable_ref( &mut self, - handle: Handle, + expr: Handle, assignable_global: &mut Option>, ) -> NonUniformResult { - let info = &mut self.expressions[handle.index()]; + let info = &mut self.expressions[expr.index()]; info.ref_count += 1; // propagate the assignable global up the chain, till it either hits // a value-type expression, or the assignment statement. diff --git a/naga/src/valid/expression.rs b/naga/src/valid/expression.rs index c82d60f062..838ecc4e27 100644 --- a/naga/src/valid/expression.rs +++ b/naga/src/valid/expression.rs @@ -124,6 +124,8 @@ pub enum ExpressionError { MissingCapabilities(super::Capabilities), #[error(transparent)] Literal(#[from] LiteralError), + #[error("{0:?} is not supported for Width {2} {1:?} arguments yet, see https://github.com/gfx-rs/wgpu/issues/5276")] + UnsupportedWidth(crate::MathFunction, crate::ScalarKind, crate::Bytes), } #[derive(Clone, Debug, thiserror::Error)] @@ -1332,28 +1334,29 @@ impl super::Validator { _ => return Err(ExpressionError::InvalidArgumentType(fun, 0, arg)), } } - Mf::CountTrailingZeros - | Mf::CountLeadingZeros + // Remove once fixed https://github.com/gfx-rs/wgpu/issues/5276 + Mf::CountLeadingZeros + | Mf::CountTrailingZeros | Mf::CountOneBits | Mf::ReverseBits - | Mf::FindLsb - | Mf::FindMsb => { + | Mf::FindMsb + | Mf::FindLsb => { if arg1_ty.is_some() || arg2_ty.is_some() || arg3_ty.is_some() { return Err(ExpressionError::WrongArgumentCount(fun)); } match *arg_ty { - Ti::Scalar(Sc { - kind: Sk::Sint | Sk::Uint, - .. - }) - | Ti::Vector { - scalar: - Sc { - kind: Sk::Sint | Sk::Uint, - .. - }, - .. - } => {} + Ti::Scalar(scalar) | Ti::Vector { scalar, .. } => match scalar.kind { + Sk::Sint | Sk::Uint => { + if scalar.width != 4 { + return Err(ExpressionError::UnsupportedWidth( + fun, + scalar.kind, + scalar.width, + )); + } + } + _ => return Err(ExpressionError::InvalidArgumentType(fun, 0, arg)), + }, _ => return Err(ExpressionError::InvalidArgumentType(fun, 0, arg)), } } @@ -1404,6 +1407,21 @@ impl super::Validator { )) } } + // Remove once fixed https://github.com/gfx-rs/wgpu/issues/5276 + for &arg in [arg_ty, arg1_ty, arg2_ty, arg3_ty].iter() { + match *arg { + Ti::Scalar(scalar) | Ti::Vector { scalar, .. } => { + if scalar.width != 4 { + return Err(ExpressionError::UnsupportedWidth( + fun, + scalar.kind, + scalar.width, + )); + } + } + _ => {} + } + } } Mf::ExtractBits => { let (arg1_ty, arg2_ty) = match (arg1_ty, arg2_ty, arg3_ty) { @@ -1445,6 +1463,21 @@ impl super::Validator { )) } } + // Remove once fixed https://github.com/gfx-rs/wgpu/issues/5276 + for &arg in [arg_ty, arg1_ty, arg2_ty].iter() { + match *arg { + Ti::Scalar(scalar) | Ti::Vector { scalar, .. } => { + if scalar.width != 4 { + return Err(ExpressionError::UnsupportedWidth( + fun, + scalar.kind, + scalar.width, + )); + } + } + _ => {} + } + } } Mf::Pack2x16unorm | Mf::Pack2x16snorm | Mf::Pack2x16float => { if arg1_ty.is_some() || arg2_ty.is_some() || arg3_ty.is_some() { diff --git a/naga/src/valid/mod.rs b/naga/src/valid/mod.rs index 388495a3ac..5459434f33 100644 --- a/naga/src/valid/mod.rs +++ b/naga/src/valid/mod.rs @@ -28,7 +28,7 @@ pub use expression::{check_literal_value, LiteralError}; pub use expression::{ConstExpressionError, ExpressionError}; pub use function::{CallError, FunctionError, LocalVariableError}; pub use interface::{EntryPointError, GlobalVariableError, VaryingError}; -pub use r#type::{Disalignment, TypeError, TypeFlags}; +pub use r#type::{Disalignment, TypeError, TypeFlags, WidthError}; use self::handles::InvalidHandleError; @@ -108,6 +108,8 @@ bitflags::bitflags! { const DUAL_SOURCE_BLENDING = 0x2000; /// Support for arrayed cube textures. const CUBE_ARRAY_TEXTURES = 0x4000; + /// Support for 64-bit signed and unsigned integers. + const SHADER_INT64 = 0x8000; } } diff --git a/naga/src/valid/type.rs b/naga/src/valid/type.rs index 3cc3b2f7cc..b8eb618ed4 100644 --- a/naga/src/valid/type.rs +++ b/naga/src/valid/type.rs @@ -147,9 +147,6 @@ pub enum WidthError { flag: &'static str, }, - #[error("64-bit integers are not yet supported")] - Unsupported64Bit, - #[error("Abstract types may only appear in constant expressions")] Abstract, } @@ -251,11 +248,31 @@ impl super::Validator { scalar.width == 4 } } - crate::ScalarKind::Sint | crate::ScalarKind::Uint => { + crate::ScalarKind::Sint => { if scalar.width == 8 { - return Err(WidthError::Unsupported64Bit); + if !self.capabilities.contains(Capabilities::SHADER_INT64) { + return Err(WidthError::MissingCapability { + name: "i64", + flag: "SHADER_INT64", + }); + } + true + } else { + scalar.width == 4 + } + } + crate::ScalarKind::Uint => { + if scalar.width == 8 { + if !self.capabilities.contains(Capabilities::SHADER_INT64) { + return Err(WidthError::MissingCapability { + name: "u64", + flag: "SHADER_INT64", + }); + } + true + } else { + scalar.width == 4 } - scalar.width == 4 } crate::ScalarKind::AbstractInt | crate::ScalarKind::AbstractFloat => { return Err(WidthError::Abstract); @@ -493,7 +510,6 @@ impl super::Validator { ti.uniform_layout = Ok(Alignment::MIN_UNIFORM); let mut min_offset = 0; - let mut prev_struct_data: Option<(u32, u32)> = None; for (i, member) in members.iter().enumerate() { @@ -645,6 +661,7 @@ impl super::Validator { // Currently Naga only supports binding arrays of structs for non-handle types. match gctx.types[base].inner { crate::TypeInner::Struct { .. } => {} + crate::TypeInner::Array { .. } => {} _ => return Err(TypeError::BindingArrayBaseTypeNotStruct(base)), }; } diff --git a/naga/tests/in/binding-buffer-arrays.wgsl b/naga/tests/in/binding-buffer-arrays.wgsl index a76d52c200..fb25623962 100644 --- a/naga/tests/in/binding-buffer-arrays.wgsl +++ b/naga/tests/in/binding-buffer-arrays.wgsl @@ -2,7 +2,7 @@ struct UniformIndex { index: u32 } -struct Foo { x: u32 } +struct Foo { x: u32, far: array } @group(0) @binding(0) var storage_array: binding_array; @group(0) @binding(10) @@ -23,5 +23,9 @@ fn main(fragment_in: FragmentIn) -> @location(0) u32 { u1 += storage_array[uniform_index].x; u1 += storage_array[non_uniform_index].x; + u1 += arrayLength(&storage_array[0].far); + u1 += arrayLength(&storage_array[uniform_index].far); + u1 += arrayLength(&storage_array[non_uniform_index].far); + return u1; } diff --git a/naga/tests/in/glsl/5246-dual-iteration.frag b/naga/tests/in/glsl/5246-dual-iteration.frag new file mode 100644 index 0000000000..8967339ddf --- /dev/null +++ b/naga/tests/in/glsl/5246-dual-iteration.frag @@ -0,0 +1,12 @@ +// AUTHOR: cwfitzgerald +// ISSUE: #5246 + +void main() { + for (int x = 0; x < 10; x++) { + for (int y = 0; y < 10; y++) { + for (int z = 0; z < 10; z++) { + ; + } + } + } +} \ No newline at end of file diff --git a/naga/tests/in/int64.param.ron b/naga/tests/in/int64.param.ron new file mode 100644 index 0000000000..15348b9052 --- /dev/null +++ b/naga/tests/in/int64.param.ron @@ -0,0 +1,22 @@ +( + god_mode: true, + spv: ( + version: (1, 0), + ), + hlsl: ( + shader_model: V6_0, + binding_map: {}, + fake_missing_bindings: true, + special_constants_binding: Some((space: 1, register: 0)), + push_constants_target: Some((space: 0, register: 0)), + zero_initialize_workgroup_memory: true, + ), + msl: ( + lang_version: (2, 3), + per_entry_point_map: {}, + inline_samplers: [], + spirv_cross_compatibility: false, + fake_missing_bindings: true, + zero_initialize_workgroup_memory: true, + ), +) diff --git a/naga/tests/in/int64.wgsl b/naga/tests/in/int64.wgsl new file mode 100644 index 0000000000..3da5fefc1c --- /dev/null +++ b/naga/tests/in/int64.wgsl @@ -0,0 +1,141 @@ +var private_variable: i64 = 1li; +const constant_variable: u64 = 20lu; + +struct UniformCompatible { + // Other types + val_u32: u32, + val_i32: i32, + val_f32: f32, + + // u64 + val_u64: u64, + val_u64_2: vec2, + val_u64_3: vec3, + val_u64_4: vec4, + + // i64 + val_i64: i64, + val_i64_2: vec2, + val_i64_3: vec3, + val_i64_4: vec4, + + final_value: u64, +} + +struct StorageCompatible { + val_u64_array_2: array, + val_i64_array_2: array, +} + +@group(0) @binding(0) +var input_uniform: UniformCompatible; +@group(0) @binding(1) +var input_storage: UniformCompatible; +@group(0) @binding(2) +var input_arrays: StorageCompatible; +@group(0) @binding(3) +var output: UniformCompatible; +@group(0) @binding(4) +var output_arrays: StorageCompatible; + +fn int64_function(x: i64) -> i64 { + var val: i64 = i64(constant_variable); + // A number too big for i32 + val += 31li - 1002003004005006li; + // Constructing an i64 from an AbstractInt + val += val + i64(5); + // Constructing a i64 from other types and other types from u64. + val += i64(input_uniform.val_u32 + u32(val)); + val += i64(input_uniform.val_i32 + i32(val)); + val += i64(input_uniform.val_f32 + f32(val)); + // Constructing a vec3 from a i64 + val += vec3(input_uniform.val_i64).z; + // Bitcasting from u64 to i64 + val += bitcast(input_uniform.val_u64); + val += bitcast>(input_uniform.val_u64_2).y; + val += bitcast>(input_uniform.val_u64_3).z; + val += bitcast>(input_uniform.val_u64_4).w; + + // Reading/writing to a uniform/storage buffer + output.val_i64 = input_uniform.val_i64 + input_storage.val_i64; + output.val_i64_2 = input_uniform.val_i64_2 + input_storage.val_i64_2; + output.val_i64_3 = input_uniform.val_i64_3 + input_storage.val_i64_3; + output.val_i64_4 = input_uniform.val_i64_4 + input_storage.val_i64_4; + + output_arrays.val_i64_array_2 = input_arrays.val_i64_array_2; + + // We make sure not to use 32 in these arguments, so it's clear in the results which are builtin + // constants based on the size of the type, and which are arguments. + + // Numeric functions + val += abs(val); + val += clamp(val, val, val); + //val += countLeadingZeros(val); + //val += countOneBits(val); + //val += countTrailingZeros(val); + val += dot(vec2(val), vec2(val)); + //val += extractBits(val, 15u, 28u); + //val += firstLeadingBit(val); + //val += firstTrailingBit(val); + //val += insertBits(val, 12li, 15u, 28u); + val += max(val, val); + val += min(val, val); + //val += reverseBits(val); + val += sign(val); // only for i64 + + // Make sure all the variables are used. + return val; +} + +fn uint64_function(x: u64) -> u64 { + var val: u64 = u64(constant_variable); + // A number too big for u32 + val += 31lu + 1002003004005006lu; + // Constructing a u64 from an AbstractInt + val += val + u64(5); + // Constructing a u64 from other types and other types from u64. + val += u64(input_uniform.val_u32 + u32(val)); + val += u64(input_uniform.val_i32 + i32(val)); + val += u64(input_uniform.val_f32 + f32(val)); + // Constructing a vec3 from a u64 + val += vec3(input_uniform.val_u64).z; + // Bitcasting from i64 to u64 + val += bitcast(input_uniform.val_i64); + val += bitcast>(input_uniform.val_i64_2).y; + val += bitcast>(input_uniform.val_i64_3).z; + val += bitcast>(input_uniform.val_i64_4).w; + + // Reading/writing to a uniform/storage buffer + output.val_u64 = input_uniform.val_u64 + input_storage.val_u64; + output.val_u64_2 = input_uniform.val_u64_2 + input_storage.val_u64_2; + output.val_u64_3 = input_uniform.val_u64_3 + input_storage.val_u64_3; + output.val_u64_4 = input_uniform.val_u64_4 + input_storage.val_u64_4; + + output_arrays.val_u64_array_2 = input_arrays.val_u64_array_2; + + // We make sure not to use 32 in these arguments, so it's clear in the results which are builtin + // constants based on the size of the type, and which are arguments. + + // Numeric functions + val += abs(val); + val += clamp(val, val, val); + //val += countLeadingZeros(val); + //val += countOneBits(val); + //val += countTrailingZeros(val); + val += dot(vec2(val), vec2(val)); + //val += extractBits(val, 15u, 28u); + //val += firstLeadingBit(val); + //val += firstTrailingBit(val); + //val += insertBits(val, 12lu, 15u, 28u); + val += max(val, val); + val += min(val, val); + //val += reverseBits(val); + + // Make sure all the variables are used. + return val; +} + +@compute @workgroup_size(1) +fn main() { + output.final_value = uint64_function(67lu) + bitcast(int64_function(60li)); +} diff --git a/naga/tests/in/spv/builtin-accessed-outside-entrypoint.spv b/naga/tests/in/spv/builtin-accessed-outside-entrypoint.spv new file mode 100644 index 0000000000..1498107419 Binary files /dev/null and b/naga/tests/in/spv/builtin-accessed-outside-entrypoint.spv differ diff --git a/naga/tests/in/spv/builtin-accessed-outside-entrypoint.spvasm b/naga/tests/in/spv/builtin-accessed-outside-entrypoint.spvasm new file mode 100644 index 0000000000..2c31f90233 --- /dev/null +++ b/naga/tests/in/spv/builtin-accessed-outside-entrypoint.spvasm @@ -0,0 +1,90 @@ +;; Ensure builtin binding isn't removed by unused gl_PerVertex builtin culling when +;; the builtin is used in a function defined after (in the SPIRV) the entry point. +;; +;; Generated from the following glsl via `glslc` (without `-O` flag): +;; +;; ```glsl +;; #version 450 +;; +;; void builtin_usage() { +;; gl_Position = vec4( +;; (gl_VertexIndex == 0) ? -4.0 : 1.0, +;; (gl_VertexIndex == 2) ? 4.0 : -1.0, +;; 0.0, +;; 1.0 +;; ); +;; } +;; +;; void main() +;; { +;; builtin_usage(); +;; } +;; ``` +;; +; SPIR-V +; Version: 1.0 +; Generator: Google Shaderc over Glslang; 11 +; Bound: 37 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %main "main" %_ %gl_VertexIndex + OpSource GLSL 450 + OpSourceExtension "GL_GOOGLE_cpp_style_line_directive" + OpSourceExtension "GL_GOOGLE_include_directive" + OpName %main "main" + OpName %builtin_usage_ "builtin_usage(" + OpName %gl_PerVertex "gl_PerVertex" + OpMemberName %gl_PerVertex 0 "gl_Position" + OpMemberName %gl_PerVertex 1 "gl_PointSize" + OpMemberName %gl_PerVertex 2 "gl_ClipDistance" + OpMemberName %gl_PerVertex 3 "gl_CullDistance" + OpName %_ "" + OpName %gl_VertexIndex "gl_VertexIndex" + OpMemberDecorate %gl_PerVertex 0 BuiltIn Position + OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize + OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance + OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance + OpDecorate %gl_PerVertex Block + OpDecorate %gl_VertexIndex BuiltIn VertexIndex + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %uint = OpTypeInt 32 0 + %uint_1 = OpConstant %uint 1 +%_arr_float_uint_1 = OpTypeArray %float %uint_1 +%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1 +%_ptr_Output_gl_PerVertex = OpTypePointer Output %gl_PerVertex + %_ = OpVariable %_ptr_Output_gl_PerVertex Output + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 +%_ptr_Input_int = OpTypePointer Input %int +%gl_VertexIndex = OpVariable %_ptr_Input_int Input + %bool = OpTypeBool + %float_n4 = OpConstant %float -4 + %float_1 = OpConstant %float 1 + %int_2 = OpConstant %int 2 + %float_4 = OpConstant %float 4 + %float_n1 = OpConstant %float -1 + %float_0 = OpConstant %float 0 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %main = OpFunction %void None %3 + %5 = OpLabel + %36 = OpFunctionCall %void %builtin_usage_ + OpReturn + OpFunctionEnd +%builtin_usage_ = OpFunction %void None %3 + %7 = OpLabel + %20 = OpLoad %int %gl_VertexIndex + %22 = OpIEqual %bool %20 %int_0 + %25 = OpSelect %float %22 %float_n4 %float_1 + %26 = OpLoad %int %gl_VertexIndex + %28 = OpIEqual %bool %26 %int_2 + %31 = OpSelect %float %28 %float_4 %float_n1 + %33 = OpCompositeConstruct %v4float %25 %31 %float_0 %float_1 + %35 = OpAccessChain %_ptr_Output_v4float %_ %int_0 + OpStore %35 %33 + OpReturn + OpFunctionEnd diff --git a/naga/tests/in/spv/unnamed-gl-per-vertex.spv b/naga/tests/in/spv/unnamed-gl-per-vertex.spv new file mode 100644 index 0000000000..1ecbd434ff Binary files /dev/null and b/naga/tests/in/spv/unnamed-gl-per-vertex.spv differ diff --git a/naga/tests/in/spv/unnamed-gl-per-vertex.spvasm b/naga/tests/in/spv/unnamed-gl-per-vertex.spvasm new file mode 100644 index 0000000000..693878872d --- /dev/null +++ b/naga/tests/in/spv/unnamed-gl-per-vertex.spvasm @@ -0,0 +1,73 @@ +;; Make sure that we don't have a validation error due to lacking capabilities +;; for bulltins such as ClipDistance when those builtin are not actually used. +;; +;; This specifically doesn't name the gl_PerVertex struct to make sure we don't +;; rely on checks for this name. +;; +;; See https://github.com/gfx-rs/wgpu/issues/4915 +;; +;; Generated via `glslc -O` on this glsl code (taken from https://github.com/gfx-rs/wgpu/issues/4915): +;; +;; ```glsl +;; #version 450 +;; +;; void main() +;; { +;; gl_Position = vec4( +;; (gl_VertexIndex == 0) ? -4.0 : 1.0, +;; (gl_VertexIndex == 2) ? 4.0 : -1.0, +;; 0.0, +;; 1.0 +;; ); +;; } +;; ``` +;; +; SPIR-V +; Version: 1.0 +; Generator: Google Shaderc over Glslang; 11 +; Bound: 34 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %4 "main" %13 %gl_VertexIndex + OpMemberDecorate %_struct_11 0 BuiltIn Position + OpMemberDecorate %_struct_11 1 BuiltIn PointSize + OpMemberDecorate %_struct_11 2 BuiltIn ClipDistance + OpMemberDecorate %_struct_11 3 BuiltIn CullDistance + OpDecorate %_struct_11 Block + OpDecorate %gl_VertexIndex BuiltIn VertexIndex + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %uint = OpTypeInt 32 0 + %uint_1 = OpConstant %uint 1 +%_arr_float_uint_1 = OpTypeArray %float %uint_1 + %_struct_11 = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1 +%_ptr_Output__struct_11 = OpTypePointer Output %_struct_11 + %13 = OpVariable %_ptr_Output__struct_11 Output + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 +%_ptr_Input_int = OpTypePointer Input %int +%gl_VertexIndex = OpVariable %_ptr_Input_int Input + %bool = OpTypeBool + %float_n4 = OpConstant %float -4 + %float_1 = OpConstant %float 1 + %int_2 = OpConstant %int 2 + %float_4 = OpConstant %float 4 + %float_n1 = OpConstant %float -1 + %float_0 = OpConstant %float 0 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %4 = OpFunction %void None %3 + %5 = OpLabel + %18 = OpLoad %int %gl_VertexIndex + %20 = OpIEqual %bool %18 %int_0 + %23 = OpSelect %float %20 %float_n4 %float_1 + %26 = OpIEqual %bool %18 %int_2 + %29 = OpSelect %float %26 %float_4 %float_n1 + %31 = OpCompositeConstruct %v4float %23 %29 %float_0 %float_1 + %33 = OpAccessChain %_ptr_Output_v4float %13 %int_0 + OpStore %33 %31 + OpReturn + OpFunctionEnd diff --git a/naga/tests/out/glsl/bits.main.Compute.glsl b/naga/tests/out/glsl/bits.main.Compute.glsl index f991f532ac..a5cc0f7c6f 100644 --- a/naga/tests/out/glsl/bits.main.Compute.glsl +++ b/naga/tests/out/glsl/bits.main.Compute.glsl @@ -39,44 +39,44 @@ void main() { f2_ = unpackHalf2x16(_e46); int _e48 = i; int _e49 = i; - i = bitfieldInsert(_e48, _e49, int(5u), int(10u)); + i = bitfieldInsert(_e48, _e49, int(min(5u, 32u)), int(min(10u, 32u - min(5u, 32u)))); ivec2 _e53 = i2_; ivec2 _e54 = i2_; - i2_ = bitfieldInsert(_e53, _e54, int(5u), int(10u)); + i2_ = bitfieldInsert(_e53, _e54, int(min(5u, 32u)), int(min(10u, 32u - min(5u, 32u)))); ivec3 _e58 = i3_; ivec3 _e59 = i3_; - i3_ = bitfieldInsert(_e58, _e59, int(5u), int(10u)); + i3_ = bitfieldInsert(_e58, _e59, int(min(5u, 32u)), int(min(10u, 32u - min(5u, 32u)))); ivec4 _e63 = i4_; ivec4 _e64 = i4_; - i4_ = bitfieldInsert(_e63, _e64, int(5u), int(10u)); + i4_ = bitfieldInsert(_e63, _e64, int(min(5u, 32u)), int(min(10u, 32u - min(5u, 32u)))); uint _e68 = u; uint _e69 = u; - u = bitfieldInsert(_e68, _e69, int(5u), int(10u)); + u = bitfieldInsert(_e68, _e69, int(min(5u, 32u)), int(min(10u, 32u - min(5u, 32u)))); uvec2 _e73 = u2_; uvec2 _e74 = u2_; - u2_ = bitfieldInsert(_e73, _e74, int(5u), int(10u)); + u2_ = bitfieldInsert(_e73, _e74, int(min(5u, 32u)), int(min(10u, 32u - min(5u, 32u)))); uvec3 _e78 = u3_; uvec3 _e79 = u3_; - u3_ = bitfieldInsert(_e78, _e79, int(5u), int(10u)); + u3_ = bitfieldInsert(_e78, _e79, int(min(5u, 32u)), int(min(10u, 32u - min(5u, 32u)))); uvec4 _e83 = u4_; uvec4 _e84 = u4_; - u4_ = bitfieldInsert(_e83, _e84, int(5u), int(10u)); + u4_ = bitfieldInsert(_e83, _e84, int(min(5u, 32u)), int(min(10u, 32u - min(5u, 32u)))); int _e88 = i; - i = bitfieldExtract(_e88, int(5u), int(10u)); + i = bitfieldExtract(_e88, int(min(5u, 32u)), int(min(10u, 32u - min(5u, 32u)))); ivec2 _e92 = i2_; - i2_ = bitfieldExtract(_e92, int(5u), int(10u)); + i2_ = bitfieldExtract(_e92, int(min(5u, 32u)), int(min(10u, 32u - min(5u, 32u)))); ivec3 _e96 = i3_; - i3_ = bitfieldExtract(_e96, int(5u), int(10u)); + i3_ = bitfieldExtract(_e96, int(min(5u, 32u)), int(min(10u, 32u - min(5u, 32u)))); ivec4 _e100 = i4_; - i4_ = bitfieldExtract(_e100, int(5u), int(10u)); + i4_ = bitfieldExtract(_e100, int(min(5u, 32u)), int(min(10u, 32u - min(5u, 32u)))); uint _e104 = u; - u = bitfieldExtract(_e104, int(5u), int(10u)); + u = bitfieldExtract(_e104, int(min(5u, 32u)), int(min(10u, 32u - min(5u, 32u)))); uvec2 _e108 = u2_; - u2_ = bitfieldExtract(_e108, int(5u), int(10u)); + u2_ = bitfieldExtract(_e108, int(min(5u, 32u)), int(min(10u, 32u - min(5u, 32u)))); uvec3 _e112 = u3_; - u3_ = bitfieldExtract(_e112, int(5u), int(10u)); + u3_ = bitfieldExtract(_e112, int(min(5u, 32u)), int(min(10u, 32u - min(5u, 32u)))); uvec4 _e116 = u4_; - u4_ = bitfieldExtract(_e116, int(5u), int(10u)); + u4_ = bitfieldExtract(_e116, int(min(5u, 32u)), int(min(10u, 32u - min(5u, 32u)))); int _e120 = i; i = findLSB(_e120); uvec2 _e122 = u2_; diff --git a/naga/tests/out/glsl/quad-vert.main.Vertex.glsl b/naga/tests/out/glsl/quad-vert.main.Vertex.glsl index db5089c2df..4a48679668 100644 --- a/naga/tests/out/glsl/quad-vert.main.Vertex.glsl +++ b/naga/tests/out/glsl/quad-vert.main.Vertex.glsl @@ -17,7 +17,7 @@ vec2 v_uv = vec2(0.0); vec2 a_uv_1 = vec2(0.0); -gen_gl_PerVertex perVertexStruct = gen_gl_PerVertex(vec4(0.0, 0.0, 0.0, 1.0), 1.0, float[1](0.0), float[1](0.0)); +gen_gl_PerVertex unnamed = gen_gl_PerVertex(vec4(0.0, 0.0, 0.0, 1.0), 1.0, float[1](0.0), float[1](0.0)); vec2 a_pos_1 = vec2(0.0); @@ -29,7 +29,7 @@ void main_1() { vec2 _e6 = a_uv_1; v_uv = _e6; vec2 _e7 = a_pos_1; - perVertexStruct.gen_gl_Position = vec4(_e7.x, _e7.y, 0.0, 1.0); + unnamed.gen_gl_Position = vec4(_e7.x, _e7.y, 0.0, 1.0); return; } @@ -40,7 +40,7 @@ void main() { a_pos_1 = a_pos; main_1(); vec2 _e7 = v_uv; - vec4 _e8 = perVertexStruct.gen_gl_Position; + vec4 _e8 = unnamed.gen_gl_Position; type_4 _tmp_return = type_4(_e7, _e8); _vs2fs_location0 = _tmp_return.member; gl_Position = _tmp_return.gen_gl_Position; diff --git a/naga/tests/out/glsl/unnamed-gl-per-vertex.main.Vertex.glsl b/naga/tests/out/glsl/unnamed-gl-per-vertex.main.Vertex.glsl new file mode 100644 index 0000000000..e44bef49aa --- /dev/null +++ b/naga/tests/out/glsl/unnamed-gl-per-vertex.main.Vertex.glsl @@ -0,0 +1,34 @@ +#version 310 es + +precision highp float; +precision highp int; + +struct type_4 { + vec4 member; + float member_1; + float member_2[1]; + float member_3[1]; +}; +type_4 global = type_4(vec4(0.0, 0.0, 0.0, 1.0), 1.0, float[1](0.0), float[1](0.0)); + +int global_1 = 0; + + +void function() { + int _e9 = global_1; + global.member = vec4(((_e9 == 0) ? -4.0 : 1.0), ((_e9 == 2) ? 4.0 : -1.0), 0.0, 1.0); + return; +} + +void main() { + uint param = uint(gl_VertexID); + global_1 = int(param); + function(); + float _e6 = global.member.y; + global.member.y = -(_e6); + vec4 _e8 = global.member; + gl_Position = _e8; + gl_Position.yz = vec2(-gl_Position.y, gl_Position.z * 2.0 - gl_Position.w); + return; +} + diff --git a/naga/tests/out/hlsl/bits.hlsl b/naga/tests/out/hlsl/bits.hlsl index 8ae2f7e1fc..7cfaeddea8 100644 --- a/naga/tests/out/hlsl/bits.hlsl +++ b/naga/tests/out/hlsl/bits.hlsl @@ -1,3 +1,179 @@ +int naga_insertBits( + int e, + int newbits, + uint offset, + uint count +) { + uint w = 32u; + uint o = min(offset, w); + uint c = min(count, w - o); + uint mask = ((4294967295u >> (32u - c)) << o); + return (c == 0 ? e : ((e & ~mask) | ((newbits << o) & mask))); +} +int2 naga_insertBits( + int2 e, + int2 newbits, + uint offset, + uint count +) { + uint w = 32u; + uint o = min(offset, w); + uint c = min(count, w - o); + uint mask = ((4294967295u >> (32u - c)) << o); + return (c == 0 ? e : ((e & ~mask) | ((newbits << o) & mask))); +} +int3 naga_insertBits( + int3 e, + int3 newbits, + uint offset, + uint count +) { + uint w = 32u; + uint o = min(offset, w); + uint c = min(count, w - o); + uint mask = ((4294967295u >> (32u - c)) << o); + return (c == 0 ? e : ((e & ~mask) | ((newbits << o) & mask))); +} +int4 naga_insertBits( + int4 e, + int4 newbits, + uint offset, + uint count +) { + uint w = 32u; + uint o = min(offset, w); + uint c = min(count, w - o); + uint mask = ((4294967295u >> (32u - c)) << o); + return (c == 0 ? e : ((e & ~mask) | ((newbits << o) & mask))); +} +uint naga_insertBits( + uint e, + uint newbits, + uint offset, + uint count +) { + uint w = 32u; + uint o = min(offset, w); + uint c = min(count, w - o); + uint mask = ((4294967295u >> (32u - c)) << o); + return (c == 0 ? e : ((e & ~mask) | ((newbits << o) & mask))); +} +uint2 naga_insertBits( + uint2 e, + uint2 newbits, + uint offset, + uint count +) { + uint w = 32u; + uint o = min(offset, w); + uint c = min(count, w - o); + uint mask = ((4294967295u >> (32u - c)) << o); + return (c == 0 ? e : ((e & ~mask) | ((newbits << o) & mask))); +} +uint3 naga_insertBits( + uint3 e, + uint3 newbits, + uint offset, + uint count +) { + uint w = 32u; + uint o = min(offset, w); + uint c = min(count, w - o); + uint mask = ((4294967295u >> (32u - c)) << o); + return (c == 0 ? e : ((e & ~mask) | ((newbits << o) & mask))); +} +uint4 naga_insertBits( + uint4 e, + uint4 newbits, + uint offset, + uint count +) { + uint w = 32u; + uint o = min(offset, w); + uint c = min(count, w - o); + uint mask = ((4294967295u >> (32u - c)) << o); + return (c == 0 ? e : ((e & ~mask) | ((newbits << o) & mask))); +} +int naga_extractBits( + int e, + uint offset, + uint count +) { + uint w = 32; + uint o = min(offset, w); + uint c = min(count, w - o); + return (c == 0 ? 0 : (e << (w - c - o)) >> (w - c)); +} +int2 naga_extractBits( + int2 e, + uint offset, + uint count +) { + uint w = 32; + uint o = min(offset, w); + uint c = min(count, w - o); + return (c == 0 ? 0 : (e << (w - c - o)) >> (w - c)); +} +int3 naga_extractBits( + int3 e, + uint offset, + uint count +) { + uint w = 32; + uint o = min(offset, w); + uint c = min(count, w - o); + return (c == 0 ? 0 : (e << (w - c - o)) >> (w - c)); +} +int4 naga_extractBits( + int4 e, + uint offset, + uint count +) { + uint w = 32; + uint o = min(offset, w); + uint c = min(count, w - o); + return (c == 0 ? 0 : (e << (w - c - o)) >> (w - c)); +} +uint naga_extractBits( + uint e, + uint offset, + uint count +) { + uint w = 32; + uint o = min(offset, w); + uint c = min(count, w - o); + return (c == 0 ? 0 : (e << (w - c - o)) >> (w - c)); +} +uint2 naga_extractBits( + uint2 e, + uint offset, + uint count +) { + uint w = 32; + uint o = min(offset, w); + uint c = min(count, w - o); + return (c == 0 ? 0 : (e << (w - c - o)) >> (w - c)); +} +uint3 naga_extractBits( + uint3 e, + uint offset, + uint count +) { + uint w = 32; + uint o = min(offset, w); + uint c = min(count, w - o); + return (c == 0 ? 0 : (e << (w - c - o)) >> (w - c)); +} +uint4 naga_extractBits( + uint4 e, + uint offset, + uint count +) { + uint w = 32; + uint o = min(offset, w); + uint c = min(count, w - o); + return (c == 0 ? 0 : (e << (w - c - o)) >> (w - c)); +} [numthreads(1, 1, 1)] void main() { @@ -34,44 +210,44 @@ void main() f2_ = float2(f16tof32(_expr46), f16tof32((_expr46) >> 16)); int _expr48 = i; int _expr49 = i; - i = (10u == 0 ? _expr48 : (_expr48 & ~((4294967295u >> (32u - 10u)) << 5u)) | ((_expr49 << 5u) & ((4294967295u >> (32u - 10u)) << 5u))); + i = naga_insertBits(_expr48, _expr49, 5u, 10u); int2 _expr53 = i2_; int2 _expr54 = i2_; - i2_ = (10u == 0 ? _expr53 : (_expr53 & ~((4294967295u >> (32u - 10u)) << 5u)) | ((_expr54 << 5u) & ((4294967295u >> (32u - 10u)) << 5u))); + i2_ = naga_insertBits(_expr53, _expr54, 5u, 10u); int3 _expr58 = i3_; int3 _expr59 = i3_; - i3_ = (10u == 0 ? _expr58 : (_expr58 & ~((4294967295u >> (32u - 10u)) << 5u)) | ((_expr59 << 5u) & ((4294967295u >> (32u - 10u)) << 5u))); + i3_ = naga_insertBits(_expr58, _expr59, 5u, 10u); int4 _expr63 = i4_; int4 _expr64 = i4_; - i4_ = (10u == 0 ? _expr63 : (_expr63 & ~((4294967295u >> (32u - 10u)) << 5u)) | ((_expr64 << 5u) & ((4294967295u >> (32u - 10u)) << 5u))); + i4_ = naga_insertBits(_expr63, _expr64, 5u, 10u); uint _expr68 = u; uint _expr69 = u; - u = (10u == 0 ? _expr68 : (_expr68 & ~((4294967295u >> (32u - 10u)) << 5u)) | ((_expr69 << 5u) & ((4294967295u >> (32u - 10u)) << 5u))); + u = naga_insertBits(_expr68, _expr69, 5u, 10u); uint2 _expr73 = u2_; uint2 _expr74 = u2_; - u2_ = (10u == 0 ? _expr73 : (_expr73 & ~((4294967295u >> (32u - 10u)) << 5u)) | ((_expr74 << 5u) & ((4294967295u >> (32u - 10u)) << 5u))); + u2_ = naga_insertBits(_expr73, _expr74, 5u, 10u); uint3 _expr78 = u3_; uint3 _expr79 = u3_; - u3_ = (10u == 0 ? _expr78 : (_expr78 & ~((4294967295u >> (32u - 10u)) << 5u)) | ((_expr79 << 5u) & ((4294967295u >> (32u - 10u)) << 5u))); + u3_ = naga_insertBits(_expr78, _expr79, 5u, 10u); uint4 _expr83 = u4_; uint4 _expr84 = u4_; - u4_ = (10u == 0 ? _expr83 : (_expr83 & ~((4294967295u >> (32u - 10u)) << 5u)) | ((_expr84 << 5u) & ((4294967295u >> (32u - 10u)) << 5u))); + u4_ = naga_insertBits(_expr83, _expr84, 5u, 10u); int _expr88 = i; - i = (10u == 0 ? 0 : (_expr88 << (32 - 10u - 5u)) >> (32 - 10u)); + i = naga_extractBits(_expr88, 5u, 10u); int2 _expr92 = i2_; - i2_ = (10u == 0 ? 0 : (_expr92 << (32 - 10u - 5u)) >> (32 - 10u)); + i2_ = naga_extractBits(_expr92, 5u, 10u); int3 _expr96 = i3_; - i3_ = (10u == 0 ? 0 : (_expr96 << (32 - 10u - 5u)) >> (32 - 10u)); + i3_ = naga_extractBits(_expr96, 5u, 10u); int4 _expr100 = i4_; - i4_ = (10u == 0 ? 0 : (_expr100 << (32 - 10u - 5u)) >> (32 - 10u)); + i4_ = naga_extractBits(_expr100, 5u, 10u); uint _expr104 = u; - u = (10u == 0 ? 0 : (_expr104 << (32 - 10u - 5u)) >> (32 - 10u)); + u = naga_extractBits(_expr104, 5u, 10u); uint2 _expr108 = u2_; - u2_ = (10u == 0 ? 0 : (_expr108 << (32 - 10u - 5u)) >> (32 - 10u)); + u2_ = naga_extractBits(_expr108, 5u, 10u); uint3 _expr112 = u3_; - u3_ = (10u == 0 ? 0 : (_expr112 << (32 - 10u - 5u)) >> (32 - 10u)); + u3_ = naga_extractBits(_expr112, 5u, 10u); uint4 _expr116 = u4_; - u4_ = (10u == 0 ? 0 : (_expr116 << (32 - 10u - 5u)) >> (32 - 10u)); + u4_ = naga_extractBits(_expr116, 5u, 10u); int _expr120 = i; i = asint(firstbitlow(_expr120)); uint2 _expr122 = u2_; diff --git a/naga/tests/out/hlsl/int64.hlsl b/naga/tests/out/hlsl/int64.hlsl new file mode 100644 index 0000000000..af53b303f6 --- /dev/null +++ b/naga/tests/out/hlsl/int64.hlsl @@ -0,0 +1,234 @@ +struct NagaConstants { + int first_vertex; + int first_instance; + uint other; +}; +ConstantBuffer _NagaConstants: register(b0, space1); + +struct UniformCompatible { + uint val_u32_; + int val_i32_; + float val_f32_; + int _pad3_0; + uint64_t val_u64_; + int _pad4_0; + int _pad4_1; + uint64_t2 val_u64_2_; + int _pad5_0; + int _pad5_1; + int _pad5_2; + int _pad5_3; + uint64_t3 val_u64_3_; + int _pad6_0; + int _pad6_1; + uint64_t4 val_u64_4_; + int64_t val_i64_; + int _pad8_0; + int _pad8_1; + int64_t2 val_i64_2_; + int64_t3 val_i64_3_; + int _pad10_0; + int _pad10_1; + int64_t4 val_i64_4_; + uint64_t final_value; + int _end_pad_0; + int _end_pad_1; + int _end_pad_2; + int _end_pad_3; + int _end_pad_4; + int _end_pad_5; +}; + +struct StorageCompatible { + uint64_t val_u64_array_2_[2]; + int64_t val_i64_array_2_[2]; +}; + +static const uint64_t constant_variable = 20uL; + +static int64_t private_variable = 1L; +cbuffer input_uniform : register(b0) { UniformCompatible input_uniform; } +ByteAddressBuffer input_storage : register(t1); +ByteAddressBuffer input_arrays : register(t2); +RWByteAddressBuffer output : register(u3); +RWByteAddressBuffer output_arrays : register(u4); + +typedef int64_t ret_Constructarray2_int64_t_[2]; +ret_Constructarray2_int64_t_ Constructarray2_int64_t_(int64_t arg0, int64_t arg1) { + int64_t ret[2] = { arg0, arg1 }; + return ret; +} + +int64_t int64_function(int64_t x) +{ + int64_t val = 20L; + + int64_t _expr6 = val; + val = (_expr6 + (31L - 1002003004005006L)); + int64_t _expr8 = val; + int64_t _expr11 = val; + val = (_expr11 + (_expr8 + 5L)); + uint _expr15 = input_uniform.val_u32_; + int64_t _expr16 = val; + int64_t _expr20 = val; + val = (_expr20 + int64_t((_expr15 + uint(_expr16)))); + int _expr24 = input_uniform.val_i32_; + int64_t _expr25 = val; + int64_t _expr29 = val; + val = (_expr29 + int64_t((_expr24 + int(_expr25)))); + float _expr33 = input_uniform.val_f32_; + int64_t _expr34 = val; + int64_t _expr38 = val; + val = (_expr38 + int64_t((_expr33 + float(_expr34)))); + int64_t _expr42 = input_uniform.val_i64_; + int64_t _expr45 = val; + val = (_expr45 + (_expr42).xxx.z); + uint64_t _expr49 = input_uniform.val_u64_; + int64_t _expr51 = val; + val = (_expr51 + _expr49); + uint64_t2 _expr55 = input_uniform.val_u64_2_; + int64_t _expr58 = val; + val = (_expr58 + _expr55.y); + uint64_t3 _expr62 = input_uniform.val_u64_3_; + int64_t _expr65 = val; + val = (_expr65 + _expr62.z); + uint64_t4 _expr69 = input_uniform.val_u64_4_; + int64_t _expr72 = val; + val = (_expr72 + _expr69.w); + int64_t _expr78 = input_uniform.val_i64_; + int64_t _expr81 = input_storage.Load(128); + output.Store(128, (_expr78 + _expr81)); + int64_t2 _expr87 = input_uniform.val_i64_2_; + int64_t2 _expr90 = input_storage.Load(144); + output.Store(144, (_expr87 + _expr90)); + int64_t3 _expr96 = input_uniform.val_i64_3_; + int64_t3 _expr99 = input_storage.Load(160); + output.Store(160, (_expr96 + _expr99)); + int64_t4 _expr105 = input_uniform.val_i64_4_; + int64_t4 _expr108 = input_storage.Load(192); + output.Store(192, (_expr105 + _expr108)); + int64_t _expr114[2] = Constructarray2_int64_t_(input_arrays.Load(16+0), input_arrays.Load(16+8)); + { + int64_t _value2[2] = _expr114; + output_arrays.Store(16+0, _value2[0]); + output_arrays.Store(16+8, _value2[1]); + } + int64_t _expr115 = val; + int64_t _expr117 = val; + val = (_expr117 + abs(_expr115)); + int64_t _expr119 = val; + int64_t _expr120 = val; + int64_t _expr121 = val; + int64_t _expr123 = val; + val = (_expr123 + clamp(_expr119, _expr120, _expr121)); + int64_t _expr125 = val; + int64_t _expr127 = val; + int64_t _expr130 = val; + val = (_expr130 + dot((_expr125).xx, (_expr127).xx)); + int64_t _expr132 = val; + int64_t _expr133 = val; + int64_t _expr135 = val; + val = (_expr135 + max(_expr132, _expr133)); + int64_t _expr137 = val; + int64_t _expr138 = val; + int64_t _expr140 = val; + val = (_expr140 + min(_expr137, _expr138)); + int64_t _expr142 = val; + int64_t _expr144 = val; + val = (_expr144 + sign(_expr142)); + int64_t _expr146 = val; + return _expr146; +} + +typedef uint64_t ret_Constructarray2_uint64_t_[2]; +ret_Constructarray2_uint64_t_ Constructarray2_uint64_t_(uint64_t arg0, uint64_t arg1) { + uint64_t ret[2] = { arg0, arg1 }; + return ret; +} + +uint64_t uint64_function(uint64_t x_1) +{ + uint64_t val_1 = 20uL; + + uint64_t _expr6 = val_1; + val_1 = (_expr6 + (31uL + 1002003004005006uL)); + uint64_t _expr8 = val_1; + uint64_t _expr11 = val_1; + val_1 = (_expr11 + (_expr8 + 5uL)); + uint _expr15 = input_uniform.val_u32_; + uint64_t _expr16 = val_1; + uint64_t _expr20 = val_1; + val_1 = (_expr20 + uint64_t((_expr15 + uint(_expr16)))); + int _expr24 = input_uniform.val_i32_; + uint64_t _expr25 = val_1; + uint64_t _expr29 = val_1; + val_1 = (_expr29 + uint64_t((_expr24 + int(_expr25)))); + float _expr33 = input_uniform.val_f32_; + uint64_t _expr34 = val_1; + uint64_t _expr38 = val_1; + val_1 = (_expr38 + uint64_t((_expr33 + float(_expr34)))); + uint64_t _expr42 = input_uniform.val_u64_; + uint64_t _expr45 = val_1; + val_1 = (_expr45 + (_expr42).xxx.z); + int64_t _expr49 = input_uniform.val_i64_; + uint64_t _expr51 = val_1; + val_1 = (_expr51 + _expr49); + int64_t2 _expr55 = input_uniform.val_i64_2_; + uint64_t _expr58 = val_1; + val_1 = (_expr58 + _expr55.y); + int64_t3 _expr62 = input_uniform.val_i64_3_; + uint64_t _expr65 = val_1; + val_1 = (_expr65 + _expr62.z); + int64_t4 _expr69 = input_uniform.val_i64_4_; + uint64_t _expr72 = val_1; + val_1 = (_expr72 + _expr69.w); + uint64_t _expr78 = input_uniform.val_u64_; + uint64_t _expr81 = input_storage.Load(16); + output.Store(16, (_expr78 + _expr81)); + uint64_t2 _expr87 = input_uniform.val_u64_2_; + uint64_t2 _expr90 = input_storage.Load(32); + output.Store(32, (_expr87 + _expr90)); + uint64_t3 _expr96 = input_uniform.val_u64_3_; + uint64_t3 _expr99 = input_storage.Load(64); + output.Store(64, (_expr96 + _expr99)); + uint64_t4 _expr105 = input_uniform.val_u64_4_; + uint64_t4 _expr108 = input_storage.Load(96); + output.Store(96, (_expr105 + _expr108)); + uint64_t _expr114[2] = Constructarray2_uint64_t_(input_arrays.Load(0+0), input_arrays.Load(0+8)); + { + uint64_t _value2[2] = _expr114; + output_arrays.Store(0+0, _value2[0]); + output_arrays.Store(0+8, _value2[1]); + } + uint64_t _expr115 = val_1; + uint64_t _expr117 = val_1; + val_1 = (_expr117 + abs(_expr115)); + uint64_t _expr119 = val_1; + uint64_t _expr120 = val_1; + uint64_t _expr121 = val_1; + uint64_t _expr123 = val_1; + val_1 = (_expr123 + clamp(_expr119, _expr120, _expr121)); + uint64_t _expr125 = val_1; + uint64_t _expr127 = val_1; + uint64_t _expr130 = val_1; + val_1 = (_expr130 + dot((_expr125).xx, (_expr127).xx)); + uint64_t _expr132 = val_1; + uint64_t _expr133 = val_1; + uint64_t _expr135 = val_1; + val_1 = (_expr135 + max(_expr132, _expr133)); + uint64_t _expr137 = val_1; + uint64_t _expr138 = val_1; + uint64_t _expr140 = val_1; + val_1 = (_expr140 + min(_expr137, _expr138)); + uint64_t _expr142 = val_1; + return _expr142; +} + +[numthreads(1, 1, 1)] +void main() +{ + const uint64_t _e3 = uint64_function(67uL); + const int64_t _e5 = int64_function(60L); + output.Store(224, (_e3 + _e5)); + return; +} diff --git a/naga/tests/out/hlsl/int64.ron b/naga/tests/out/hlsl/int64.ron new file mode 100644 index 0000000000..b973fe3da1 --- /dev/null +++ b/naga/tests/out/hlsl/int64.ron @@ -0,0 +1,12 @@ +( + vertex:[ + ], + fragment:[ + ], + compute:[ + ( + entry_point:"main", + target_profile:"cs_6_0", + ), + ], +) diff --git a/naga/tests/out/hlsl/quad-vert.hlsl b/naga/tests/out/hlsl/quad-vert.hlsl index da2ff49dab..4505858a4f 100644 --- a/naga/tests/out/hlsl/quad-vert.hlsl +++ b/naga/tests/out/hlsl/quad-vert.hlsl @@ -22,7 +22,7 @@ gl_PerVertex Constructgl_PerVertex(float4 arg0, float arg1, float arg2[1], float static float2 v_uv = (float2)0; static float2 a_uv_1 = (float2)0; -static gl_PerVertex perVertexStruct = Constructgl_PerVertex(float4(0.0, 0.0, 0.0, 1.0), 1.0, (float[1])0, (float[1])0); +static gl_PerVertex unnamed = Constructgl_PerVertex(float4(0.0, 0.0, 0.0, 1.0), 1.0, (float[1])0, (float[1])0); static float2 a_pos_1 = (float2)0; struct VertexOutput_main { @@ -35,7 +35,7 @@ void main_1() float2 _expr6 = a_uv_1; v_uv = _expr6; float2 _expr7 = a_pos_1; - perVertexStruct.gl_Position = float4(_expr7.x, _expr7.y, 0.0, 1.0); + unnamed.gl_Position = float4(_expr7.x, _expr7.y, 0.0, 1.0); return; } @@ -52,7 +52,7 @@ VertexOutput_main main(float2 a_uv : LOC1, float2 a_pos : LOC0) a_pos_1 = a_pos; main_1(); float2 _expr7 = v_uv; - float4 _expr8 = perVertexStruct.gl_Position; + float4 _expr8 = unnamed.gl_Position; const type_4 type_4_ = Constructtype_4(_expr7, _expr8); const VertexOutput_main type_4_1 = { type_4_.member, type_4_.gl_Position }; return type_4_1; diff --git a/naga/tests/out/hlsl/unnamed-gl-per-vertex.hlsl b/naga/tests/out/hlsl/unnamed-gl-per-vertex.hlsl new file mode 100644 index 0000000000..8270ad4e5d --- /dev/null +++ b/naga/tests/out/hlsl/unnamed-gl-per-vertex.hlsl @@ -0,0 +1,36 @@ +struct type_4 { + float4 member : SV_Position; + float member_1; + float member_2[1]; + float member_3[1]; + int _end_pad_0; +}; + +type_4 Constructtype_4(float4 arg0, float arg1, float arg2[1], float arg3[1]) { + type_4 ret = (type_4)0; + ret.member = arg0; + ret.member_1 = arg1; + ret.member_2 = arg2; + ret.member_3 = arg3; + return ret; +} + +static type_4 global = Constructtype_4(float4(0.0, 0.0, 0.0, 1.0), 1.0, (float[1])0, (float[1])0); +static int global_1 = (int)0; + +void function() +{ + int _expr9 = global_1; + global.member = float4(((_expr9 == 0) ? -4.0 : 1.0), ((_expr9 == 2) ? 4.0 : -1.0), 0.0, 1.0); + return; +} + +float4 main(uint param : SV_VertexID) : SV_Position +{ + global_1 = int(param); + function(); + float _expr6 = global.member.y; + global.member.y = -(_expr6); + float4 _expr8 = global.member; + return _expr8; +} diff --git a/naga/tests/out/hlsl/unnamed-gl-per-vertex.ron b/naga/tests/out/hlsl/unnamed-gl-per-vertex.ron new file mode 100644 index 0000000000..8240856a5c --- /dev/null +++ b/naga/tests/out/hlsl/unnamed-gl-per-vertex.ron @@ -0,0 +1,12 @@ +( + vertex:[ + ( + entry_point:"main", + target_profile:"vs_5_1", + ), + ], + fragment:[ + ], + compute:[ + ], +) diff --git a/naga/tests/out/msl/bits.msl b/naga/tests/out/msl/bits.msl index 7d73568b7f..20f0f8de94 100644 --- a/naga/tests/out/msl/bits.msl +++ b/naga/tests/out/msl/bits.msl @@ -39,44 +39,44 @@ kernel void main_( f2_ = float2(as_type(_e46)); int _e48 = i; int _e49 = i; - i = metal::insert_bits(_e48, _e49, 5u, 10u); + i = metal::insert_bits(_e48, _e49, metal::min(5u, 32u), metal::min(10u, 32u - metal::min(5u, 32u))); metal::int2 _e53 = i2_; metal::int2 _e54 = i2_; - i2_ = metal::insert_bits(_e53, _e54, 5u, 10u); + i2_ = metal::insert_bits(_e53, _e54, metal::min(5u, 32u), metal::min(10u, 32u - metal::min(5u, 32u))); metal::int3 _e58 = i3_; metal::int3 _e59 = i3_; - i3_ = metal::insert_bits(_e58, _e59, 5u, 10u); + i3_ = metal::insert_bits(_e58, _e59, metal::min(5u, 32u), metal::min(10u, 32u - metal::min(5u, 32u))); metal::int4 _e63 = i4_; metal::int4 _e64 = i4_; - i4_ = metal::insert_bits(_e63, _e64, 5u, 10u); + i4_ = metal::insert_bits(_e63, _e64, metal::min(5u, 32u), metal::min(10u, 32u - metal::min(5u, 32u))); uint _e68 = u; uint _e69 = u; - u = metal::insert_bits(_e68, _e69, 5u, 10u); + u = metal::insert_bits(_e68, _e69, metal::min(5u, 32u), metal::min(10u, 32u - metal::min(5u, 32u))); metal::uint2 _e73 = u2_; metal::uint2 _e74 = u2_; - u2_ = metal::insert_bits(_e73, _e74, 5u, 10u); + u2_ = metal::insert_bits(_e73, _e74, metal::min(5u, 32u), metal::min(10u, 32u - metal::min(5u, 32u))); metal::uint3 _e78 = u3_; metal::uint3 _e79 = u3_; - u3_ = metal::insert_bits(_e78, _e79, 5u, 10u); + u3_ = metal::insert_bits(_e78, _e79, metal::min(5u, 32u), metal::min(10u, 32u - metal::min(5u, 32u))); metal::uint4 _e83 = u4_; metal::uint4 _e84 = u4_; - u4_ = metal::insert_bits(_e83, _e84, 5u, 10u); + u4_ = metal::insert_bits(_e83, _e84, metal::min(5u, 32u), metal::min(10u, 32u - metal::min(5u, 32u))); int _e88 = i; - i = metal::extract_bits(_e88, 5u, 10u); + i = metal::extract_bits(_e88, metal::min(5u, 32u), metal::min(10u, 32u - metal::min(5u, 32u))); metal::int2 _e92 = i2_; - i2_ = metal::extract_bits(_e92, 5u, 10u); + i2_ = metal::extract_bits(_e92, metal::min(5u, 32u), metal::min(10u, 32u - metal::min(5u, 32u))); metal::int3 _e96 = i3_; - i3_ = metal::extract_bits(_e96, 5u, 10u); + i3_ = metal::extract_bits(_e96, metal::min(5u, 32u), metal::min(10u, 32u - metal::min(5u, 32u))); metal::int4 _e100 = i4_; - i4_ = metal::extract_bits(_e100, 5u, 10u); + i4_ = metal::extract_bits(_e100, metal::min(5u, 32u), metal::min(10u, 32u - metal::min(5u, 32u))); uint _e104 = u; - u = metal::extract_bits(_e104, 5u, 10u); + u = metal::extract_bits(_e104, metal::min(5u, 32u), metal::min(10u, 32u - metal::min(5u, 32u))); metal::uint2 _e108 = u2_; - u2_ = metal::extract_bits(_e108, 5u, 10u); + u2_ = metal::extract_bits(_e108, metal::min(5u, 32u), metal::min(10u, 32u - metal::min(5u, 32u))); metal::uint3 _e112 = u3_; - u3_ = metal::extract_bits(_e112, 5u, 10u); + u3_ = metal::extract_bits(_e112, metal::min(5u, 32u), metal::min(10u, 32u - metal::min(5u, 32u))); metal::uint4 _e116 = u4_; - u4_ = metal::extract_bits(_e116, 5u, 10u); + u4_ = metal::extract_bits(_e116, metal::min(5u, 32u), metal::min(10u, 32u - metal::min(5u, 32u))); int _e120 = i; i = (((metal::ctz(_e120) + 1) % 33) - 1); metal::uint2 _e122 = u2_; diff --git a/naga/tests/out/msl/int64.msl b/naga/tests/out/msl/int64.msl new file mode 100644 index 0000000000..2ef03d9aeb --- /dev/null +++ b/naga/tests/out/msl/int64.msl @@ -0,0 +1,213 @@ +// language: metal2.3 +#include +#include + +using metal::uint; + +struct UniformCompatible { + uint val_u32_; + int val_i32_; + float val_f32_; + char _pad3[4]; + ulong val_u64_; + char _pad4[8]; + metal::ulong2 val_u64_2_; + char _pad5[16]; + metal::ulong3 val_u64_3_; + metal::ulong4 val_u64_4_; + long val_i64_; + char _pad8[8]; + metal::long2 val_i64_2_; + metal::long3 val_i64_3_; + metal::long4 val_i64_4_; + ulong final_value; +}; +struct type_11 { + ulong inner[2]; +}; +struct type_12 { + long inner[2]; +}; +struct StorageCompatible { + type_11 val_u64_array_2_; + type_12 val_i64_array_2_; +}; +constant ulong constant_variable = 20uL; + +long int64_function( + long x, + constant UniformCompatible& input_uniform, + device UniformCompatible const& input_storage, + device StorageCompatible const& input_arrays, + device UniformCompatible& output, + device StorageCompatible& output_arrays +) { + long val = 20L; + long _e6 = val; + val = _e6 + (31L - 1002003004005006L); + long _e8 = val; + long _e11 = val; + val = _e11 + (_e8 + 5L); + uint _e15 = input_uniform.val_u32_; + long _e16 = val; + long _e20 = val; + val = _e20 + static_cast(_e15 + static_cast(_e16)); + int _e24 = input_uniform.val_i32_; + long _e25 = val; + long _e29 = val; + val = _e29 + static_cast(_e24 + static_cast(_e25)); + float _e33 = input_uniform.val_f32_; + long _e34 = val; + long _e38 = val; + val = _e38 + static_cast(_e33 + static_cast(_e34)); + long _e42 = input_uniform.val_i64_; + long _e45 = val; + val = _e45 + metal::long3(_e42).z; + ulong _e49 = input_uniform.val_u64_; + long _e51 = val; + val = _e51 + as_type(_e49); + metal::ulong2 _e55 = input_uniform.val_u64_2_; + long _e58 = val; + val = _e58 + as_type(_e55).y; + metal::ulong3 _e62 = input_uniform.val_u64_3_; + long _e65 = val; + val = _e65 + as_type(_e62).z; + metal::ulong4 _e69 = input_uniform.val_u64_4_; + long _e72 = val; + val = _e72 + as_type(_e69).w; + long _e78 = input_uniform.val_i64_; + long _e81 = input_storage.val_i64_; + output.val_i64_ = _e78 + _e81; + metal::long2 _e87 = input_uniform.val_i64_2_; + metal::long2 _e90 = input_storage.val_i64_2_; + output.val_i64_2_ = _e87 + _e90; + metal::long3 _e96 = input_uniform.val_i64_3_; + metal::long3 _e99 = input_storage.val_i64_3_; + output.val_i64_3_ = _e96 + _e99; + metal::long4 _e105 = input_uniform.val_i64_4_; + metal::long4 _e108 = input_storage.val_i64_4_; + output.val_i64_4_ = _e105 + _e108; + type_12 _e114 = input_arrays.val_i64_array_2_; + output_arrays.val_i64_array_2_ = _e114; + long _e115 = val; + long _e117 = val; + val = _e117 + metal::abs(_e115); + long _e119 = val; + long _e120 = val; + long _e121 = val; + long _e123 = val; + val = _e123 + metal::clamp(_e119, _e120, _e121); + long _e125 = val; + metal::long2 _e126 = metal::long2(_e125); + long _e127 = val; + metal::long2 _e128 = metal::long2(_e127); + long _e130 = val; + val = _e130 + ( + _e126.x * _e128.x + _e126.y * _e128.y); + long _e132 = val; + long _e133 = val; + long _e135 = val; + val = _e135 + metal::max(_e132, _e133); + long _e137 = val; + long _e138 = val; + long _e140 = val; + val = _e140 + metal::min(_e137, _e138); + long _e142 = val; + long _e144 = val; + val = _e144 + metal::select(metal::select(-1, 1, (_e142 > 0)), 0, (_e142 == 0)); + long _e146 = val; + return _e146; +} + +ulong uint64_function( + ulong x_1, + constant UniformCompatible& input_uniform, + device UniformCompatible const& input_storage, + device StorageCompatible const& input_arrays, + device UniformCompatible& output, + device StorageCompatible& output_arrays +) { + ulong val_1 = 20uL; + ulong _e6 = val_1; + val_1 = _e6 + (31uL + 1002003004005006uL); + ulong _e8 = val_1; + ulong _e11 = val_1; + val_1 = _e11 + (_e8 + 5uL); + uint _e15 = input_uniform.val_u32_; + ulong _e16 = val_1; + ulong _e20 = val_1; + val_1 = _e20 + static_cast(_e15 + static_cast(_e16)); + int _e24 = input_uniform.val_i32_; + ulong _e25 = val_1; + ulong _e29 = val_1; + val_1 = _e29 + static_cast(_e24 + static_cast(_e25)); + float _e33 = input_uniform.val_f32_; + ulong _e34 = val_1; + ulong _e38 = val_1; + val_1 = _e38 + static_cast(_e33 + static_cast(_e34)); + ulong _e42 = input_uniform.val_u64_; + ulong _e45 = val_1; + val_1 = _e45 + metal::ulong3(_e42).z; + long _e49 = input_uniform.val_i64_; + ulong _e51 = val_1; + val_1 = _e51 + as_type(_e49); + metal::long2 _e55 = input_uniform.val_i64_2_; + ulong _e58 = val_1; + val_1 = _e58 + as_type(_e55).y; + metal::long3 _e62 = input_uniform.val_i64_3_; + ulong _e65 = val_1; + val_1 = _e65 + as_type(_e62).z; + metal::long4 _e69 = input_uniform.val_i64_4_; + ulong _e72 = val_1; + val_1 = _e72 + as_type(_e69).w; + ulong _e78 = input_uniform.val_u64_; + ulong _e81 = input_storage.val_u64_; + output.val_u64_ = _e78 + _e81; + metal::ulong2 _e87 = input_uniform.val_u64_2_; + metal::ulong2 _e90 = input_storage.val_u64_2_; + output.val_u64_2_ = _e87 + _e90; + metal::ulong3 _e96 = input_uniform.val_u64_3_; + metal::ulong3 _e99 = input_storage.val_u64_3_; + output.val_u64_3_ = _e96 + _e99; + metal::ulong4 _e105 = input_uniform.val_u64_4_; + metal::ulong4 _e108 = input_storage.val_u64_4_; + output.val_u64_4_ = _e105 + _e108; + type_11 _e114 = input_arrays.val_u64_array_2_; + output_arrays.val_u64_array_2_ = _e114; + ulong _e115 = val_1; + ulong _e117 = val_1; + val_1 = _e117 + metal::abs(_e115); + ulong _e119 = val_1; + ulong _e120 = val_1; + ulong _e121 = val_1; + ulong _e123 = val_1; + val_1 = _e123 + metal::clamp(_e119, _e120, _e121); + ulong _e125 = val_1; + metal::ulong2 _e126 = metal::ulong2(_e125); + ulong _e127 = val_1; + metal::ulong2 _e128 = metal::ulong2(_e127); + ulong _e130 = val_1; + val_1 = _e130 + ( + _e126.x * _e128.x + _e126.y * _e128.y); + ulong _e132 = val_1; + ulong _e133 = val_1; + ulong _e135 = val_1; + val_1 = _e135 + metal::max(_e132, _e133); + ulong _e137 = val_1; + ulong _e138 = val_1; + ulong _e140 = val_1; + val_1 = _e140 + metal::min(_e137, _e138); + ulong _e142 = val_1; + return _e142; +} + +kernel void main_( + constant UniformCompatible& input_uniform [[user(fake0)]] +, device UniformCompatible const& input_storage [[user(fake0)]] +, device StorageCompatible const& input_arrays [[user(fake0)]] +, device UniformCompatible& output [[user(fake0)]] +, device StorageCompatible& output_arrays [[user(fake0)]] +) { + ulong _e3 = uint64_function(67uL, input_uniform, input_storage, input_arrays, output, output_arrays); + long _e5 = int64_function(60L, input_uniform, input_storage, input_arrays, output, output_arrays); + output.final_value = _e3 + as_type(_e5); + return; +} diff --git a/naga/tests/out/msl/quad-vert.msl b/naga/tests/out/msl/quad-vert.msl index 24b6cdd095..e70df2260d 100644 --- a/naga/tests/out/msl/quad-vert.msl +++ b/naga/tests/out/msl/quad-vert.msl @@ -21,13 +21,13 @@ struct type_4 { void main_1( thread metal::float2& v_uv, thread metal::float2& a_uv_1, - thread gl_PerVertex& perVertexStruct, + thread gl_PerVertex& unnamed, thread metal::float2& a_pos_1 ) { metal::float2 _e6 = a_uv_1; v_uv = _e6; metal::float2 _e7 = a_pos_1; - perVertexStruct.gl_Position = metal::float4(_e7.x, _e7.y, 0.0, 1.0); + unnamed.gl_Position = metal::float4(_e7.x, _e7.y, 0.0, 1.0); return; } @@ -44,15 +44,15 @@ vertex main_Output main_( ) { metal::float2 v_uv = {}; metal::float2 a_uv_1 = {}; - gl_PerVertex perVertexStruct = gl_PerVertex {metal::float4(0.0, 0.0, 0.0, 1.0), 1.0, type_3 {}, type_3 {}}; + gl_PerVertex unnamed = gl_PerVertex {metal::float4(0.0, 0.0, 0.0, 1.0), 1.0, type_3 {}, type_3 {}}; metal::float2 a_pos_1 = {}; const auto a_uv = varyings.a_uv; const auto a_pos = varyings.a_pos; a_uv_1 = a_uv; a_pos_1 = a_pos; - main_1(v_uv, a_uv_1, perVertexStruct, a_pos_1); + main_1(v_uv, a_uv_1, unnamed, a_pos_1); metal::float2 _e7 = v_uv; - metal::float4 _e8 = perVertexStruct.gl_Position; + metal::float4 _e8 = unnamed.gl_Position; const auto _tmp = type_4 {_e7, _e8}; return main_Output { _tmp.member, _tmp.gl_Position }; } diff --git a/naga/tests/out/msl/unnamed-gl-per-vertex.msl b/naga/tests/out/msl/unnamed-gl-per-vertex.msl new file mode 100644 index 0000000000..83aea653df --- /dev/null +++ b/naga/tests/out/msl/unnamed-gl-per-vertex.msl @@ -0,0 +1,42 @@ +// language: metal1.0 +#include +#include + +using metal::uint; + +struct type_3 { + float inner[1]; +}; +struct type_4 { + metal::float4 member; + float member_1; + type_3 member_2; + type_3 member_3; +}; + +void function( + thread type_4& global, + thread int& global_1 +) { + int _e9 = global_1; + global.member = metal::float4((_e9 == 0) ? -4.0 : 1.0, (_e9 == 2) ? 4.0 : -1.0, 0.0, 1.0); + return; +} + +struct main_Input { +}; +struct main_Output { + metal::float4 member [[position]]; +}; +vertex main_Output main_( + uint param [[vertex_id]] +) { + type_4 global = type_4 {metal::float4(0.0, 0.0, 0.0, 1.0), 1.0, type_3 {}, type_3 {}}; + int global_1 = {}; + global_1 = static_cast(param); + function(global, global_1); + float _e6 = global.member.y; + global.member.y = -(_e6); + metal::float4 _e8 = global.member; + return main_Output { _e8 }; +} diff --git a/naga/tests/out/spv/binding-buffer-arrays.spvasm b/naga/tests/out/spv/binding-buffer-arrays.spvasm index 050372036d..8595962cef 100644 --- a/naga/tests/out/spv/binding-buffer-arrays.spvasm +++ b/naga/tests/out/spv/binding-buffer-arrays.spvasm @@ -1,99 +1,120 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 61 +; Bound: 76 OpCapability Shader OpCapability ShaderNonUniform OpExtension "SPV_KHR_storage_buffer_storage_class" OpExtension "SPV_EXT_descriptor_indexing" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint Fragment %23 "main" %18 %21 -OpExecutionMode %23 OriginUpperLeft +OpEntryPoint Fragment %25 "main" %20 %23 +OpExecutionMode %25 OriginUpperLeft OpMemberDecorate %4 0 Offset 0 -OpMemberDecorate %5 0 Offset 0 -OpMemberDecorate %8 0 Offset 0 -OpDecorate %9 NonWritable -OpDecorate %9 DescriptorSet 0 -OpDecorate %9 Binding 0 -OpDecorate %5 Block -OpDecorate %13 DescriptorSet 0 -OpDecorate %13 Binding 10 -OpDecorate %14 Block -OpMemberDecorate %14 0 Offset 0 -OpDecorate %18 Location 0 -OpDecorate %18 Flat -OpDecorate %21 Location 0 -OpDecorate %53 NonUniform +OpDecorate %6 ArrayStride 4 +OpMemberDecorate %7 0 Offset 0 +OpMemberDecorate %7 1 Offset 4 +OpDecorate %7 Block +OpMemberDecorate %10 0 Offset 0 +OpDecorate %11 NonWritable +OpDecorate %11 DescriptorSet 0 +OpDecorate %11 Binding 0 +OpDecorate %7 Block +OpDecorate %15 DescriptorSet 0 +OpDecorate %15 Binding 10 +OpDecorate %16 Block +OpMemberDecorate %16 0 Offset 0 +OpDecorate %20 Location 0 +OpDecorate %20 Flat +OpDecorate %23 Location 0 +OpDecorate %55 NonUniform %2 = OpTypeVoid %3 = OpTypeInt 32 0 %4 = OpTypeStruct %3 -%5 = OpTypeStruct %3 -%7 = OpConstant %3 1 -%6 = OpTypeArray %5 %7 -%8 = OpTypeStruct %3 -%12 = OpConstant %3 10 -%11 = OpTypeArray %5 %12 -%10 = OpTypePointer StorageBuffer %11 -%9 = OpVariable %10 StorageBuffer -%14 = OpTypeStruct %4 -%15 = OpTypePointer Uniform %14 -%13 = OpVariable %15 Uniform -%19 = OpTypePointer Input %3 -%18 = OpVariable %19 Input -%22 = OpTypePointer Output %3 -%21 = OpVariable %22 Output -%24 = OpTypeFunction %2 -%25 = OpTypePointer Uniform %4 -%26 = OpConstant %3 0 -%28 = OpTypePointer StorageBuffer %6 -%30 = OpTypePointer Function %3 -%32 = OpTypePointer Uniform %3 -%36 = OpTypePointer StorageBuffer %5 -%37 = OpTypePointer StorageBuffer %3 -%43 = OpTypeBool -%45 = OpConstantNull %3 -%23 = OpFunction %2 None %24 -%16 = OpLabel -%29 = OpVariable %30 Function %26 -%20 = OpLoad %3 %18 -%17 = OpCompositeConstruct %8 %20 -%27 = OpAccessChain %25 %13 %26 -OpBranch %31 -%31 = OpLabel -%33 = OpAccessChain %32 %27 %26 -%34 = OpLoad %3 %33 -%35 = OpCompositeExtract %3 %17 0 -%38 = OpAccessChain %37 %9 %26 %26 -%39 = OpLoad %3 %38 -%40 = OpLoad %3 %29 -%41 = OpIAdd %3 %40 %39 -OpStore %29 %41 -%42 = OpULessThan %43 %34 %7 -OpSelectionMerge %46 None -OpBranchConditional %42 %47 %46 -%47 = OpLabel -%44 = OpAccessChain %37 %9 %34 %26 -%48 = OpLoad %3 %44 -OpBranch %46 -%46 = OpLabel -%49 = OpPhi %3 %45 %31 %48 %47 -%50 = OpLoad %3 %29 -%51 = OpIAdd %3 %50 %49 -OpStore %29 %51 -%52 = OpULessThan %43 %35 %7 -OpSelectionMerge %54 None -OpBranchConditional %52 %55 %54 -%55 = OpLabel -%53 = OpAccessChain %37 %9 %35 %26 -%56 = OpLoad %3 %53 -OpBranch %54 -%54 = OpLabel -%57 = OpPhi %3 %45 %46 %56 %55 -%58 = OpLoad %3 %29 -%59 = OpIAdd %3 %58 %57 -OpStore %29 %59 -%60 = OpLoad %3 %29 -OpStore %21 %60 +%5 = OpTypeInt 32 1 +%6 = OpTypeRuntimeArray %5 +%7 = OpTypeStruct %3 %6 +%9 = OpConstant %3 1 +%8 = OpTypeArray %7 %9 +%10 = OpTypeStruct %3 +%14 = OpConstant %3 10 +%13 = OpTypeArray %7 %14 +%12 = OpTypePointer StorageBuffer %13 +%11 = OpVariable %12 StorageBuffer +%16 = OpTypeStruct %4 +%17 = OpTypePointer Uniform %16 +%15 = OpVariable %17 Uniform +%21 = OpTypePointer Input %3 +%20 = OpVariable %21 Input +%24 = OpTypePointer Output %3 +%23 = OpVariable %24 Output +%26 = OpTypeFunction %2 +%27 = OpTypePointer Uniform %4 +%28 = OpConstant %3 0 +%30 = OpTypePointer StorageBuffer %8 +%32 = OpTypePointer Function %3 +%34 = OpTypePointer Uniform %3 +%38 = OpTypePointer StorageBuffer %7 +%39 = OpTypePointer StorageBuffer %3 +%45 = OpTypeBool +%47 = OpConstantNull %3 +%62 = OpTypePointer StorageBuffer %6 +%25 = OpFunction %2 None %26 +%18 = OpLabel +%31 = OpVariable %32 Function %28 +%22 = OpLoad %3 %20 +%19 = OpCompositeConstruct %10 %22 +%29 = OpAccessChain %27 %15 %28 +OpBranch %33 +%33 = OpLabel +%35 = OpAccessChain %34 %29 %28 +%36 = OpLoad %3 %35 +%37 = OpCompositeExtract %3 %19 0 +%40 = OpAccessChain %39 %11 %28 %28 +%41 = OpLoad %3 %40 +%42 = OpLoad %3 %31 +%43 = OpIAdd %3 %42 %41 +OpStore %31 %43 +%44 = OpULessThan %45 %36 %9 +OpSelectionMerge %48 None +OpBranchConditional %44 %49 %48 +%49 = OpLabel +%46 = OpAccessChain %39 %11 %36 %28 +%50 = OpLoad %3 %46 +OpBranch %48 +%48 = OpLabel +%51 = OpPhi %3 %47 %33 %50 %49 +%52 = OpLoad %3 %31 +%53 = OpIAdd %3 %52 %51 +OpStore %31 %53 +%54 = OpULessThan %45 %37 %9 +OpSelectionMerge %56 None +OpBranchConditional %54 %57 %56 +%57 = OpLabel +%55 = OpAccessChain %39 %11 %37 %28 +%58 = OpLoad %3 %55 +OpBranch %56 +%56 = OpLabel +%59 = OpPhi %3 %47 %48 %58 %57 +%60 = OpLoad %3 %31 +%61 = OpIAdd %3 %60 %59 +OpStore %31 %61 +%63 = OpAccessChain %38 %11 %28 +%64 = OpArrayLength %3 %63 1 +%65 = OpLoad %3 %31 +%66 = OpIAdd %3 %65 %64 +OpStore %31 %66 +%67 = OpAccessChain %38 %11 %36 +%68 = OpArrayLength %3 %67 1 +%69 = OpLoad %3 %31 +%70 = OpIAdd %3 %69 %68 +OpStore %31 %70 +%71 = OpAccessChain %38 %11 %37 +%72 = OpArrayLength %3 %71 1 +%73 = OpLoad %3 %31 +%74 = OpIAdd %3 %73 %72 +OpStore %31 %74 +%75 = OpLoad %3 %31 +OpStore %23 %75 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/naga/tests/out/spv/bits.spvasm b/naga/tests/out/spv/bits.spvasm index a77c4470a6..33e2bb9e53 100644 --- a/naga/tests/out/spv/bits.spvasm +++ b/naga/tests/out/spv/bits.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 155 +; Bound: 204 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -43,6 +43,7 @@ OpExecutionMode %15 LocalSize 1 1 1 %45 = OpTypePointer Function %10 %47 = OpTypePointer Function %11 %49 = OpTypePointer Function %13 +%74 = OpConstant %7 32 %15 = OpFunction %2 None %16 %14 = OpLabel %48 = OpVariable %49 Function %27 @@ -89,125 +90,173 @@ OpStore %46 %68 OpStore %46 %70 %71 = OpLoad %3 %30 %72 = OpLoad %3 %30 -%73 = OpBitFieldInsert %3 %71 %72 %28 %29 +%75 = OpExtInst %7 %1 UMin %28 %74 +%76 = OpISub %7 %74 %75 +%77 = OpExtInst %7 %1 UMin %29 %76 +%73 = OpBitFieldInsert %3 %71 %72 %75 %77 OpStore %30 %73 -%74 = OpLoad %4 %32 -%75 = OpLoad %4 %32 -%76 = OpBitFieldInsert %4 %74 %75 %28 %29 -OpStore %32 %76 -%77 = OpLoad %5 %34 -%78 = OpLoad %5 %34 -%79 = OpBitFieldInsert %5 %77 %78 %28 %29 -OpStore %34 %79 -%80 = OpLoad %6 %36 -%81 = OpLoad %6 %36 -%82 = OpBitFieldInsert %6 %80 %81 %28 %29 -OpStore %36 %82 -%83 = OpLoad %7 %38 -%84 = OpLoad %7 %38 -%85 = OpBitFieldInsert %7 %83 %84 %28 %29 -OpStore %38 %85 -%86 = OpLoad %8 %40 -%87 = OpLoad %8 %40 -%88 = OpBitFieldInsert %8 %86 %87 %28 %29 -OpStore %40 %88 -%89 = OpLoad %9 %42 -%90 = OpLoad %9 %42 -%91 = OpBitFieldInsert %9 %89 %90 %28 %29 -OpStore %42 %91 -%92 = OpLoad %10 %44 -%93 = OpLoad %10 %44 -%94 = OpBitFieldInsert %10 %92 %93 %28 %29 -OpStore %44 %94 -%95 = OpLoad %3 %30 -%96 = OpBitFieldSExtract %3 %95 %28 %29 -OpStore %30 %96 -%97 = OpLoad %4 %32 -%98 = OpBitFieldSExtract %4 %97 %28 %29 -OpStore %32 %98 -%99 = OpLoad %5 %34 -%100 = OpBitFieldSExtract %5 %99 %28 %29 -OpStore %34 %100 -%101 = OpLoad %6 %36 -%102 = OpBitFieldSExtract %6 %101 %28 %29 -OpStore %36 %102 -%103 = OpLoad %7 %38 -%104 = OpBitFieldUExtract %7 %103 %28 %29 -OpStore %38 %104 -%105 = OpLoad %8 %40 -%106 = OpBitFieldUExtract %8 %105 %28 %29 -OpStore %40 %106 -%107 = OpLoad %9 %42 -%108 = OpBitFieldUExtract %9 %107 %28 %29 -OpStore %42 %108 -%109 = OpLoad %10 %44 -%110 = OpBitFieldUExtract %10 %109 %28 %29 -OpStore %44 %110 -%111 = OpLoad %3 %30 -%112 = OpExtInst %3 %1 FindILsb %111 -OpStore %30 %112 -%113 = OpLoad %8 %40 -%114 = OpExtInst %8 %1 FindILsb %113 -OpStore %40 %114 -%115 = OpLoad %5 %34 -%116 = OpExtInst %5 %1 FindSMsb %115 -OpStore %34 %116 -%117 = OpLoad %9 %42 -%118 = OpExtInst %9 %1 FindUMsb %117 -OpStore %42 %118 -%119 = OpLoad %3 %30 -%120 = OpExtInst %3 %1 FindSMsb %119 -OpStore %30 %120 -%121 = OpLoad %7 %38 -%122 = OpExtInst %7 %1 FindUMsb %121 -OpStore %38 %122 -%123 = OpLoad %3 %30 -%124 = OpBitCount %3 %123 -OpStore %30 %124 +%78 = OpLoad %4 %32 +%79 = OpLoad %4 %32 +%81 = OpExtInst %7 %1 UMin %28 %74 +%82 = OpISub %7 %74 %81 +%83 = OpExtInst %7 %1 UMin %29 %82 +%80 = OpBitFieldInsert %4 %78 %79 %81 %83 +OpStore %32 %80 +%84 = OpLoad %5 %34 +%85 = OpLoad %5 %34 +%87 = OpExtInst %7 %1 UMin %28 %74 +%88 = OpISub %7 %74 %87 +%89 = OpExtInst %7 %1 UMin %29 %88 +%86 = OpBitFieldInsert %5 %84 %85 %87 %89 +OpStore %34 %86 +%90 = OpLoad %6 %36 +%91 = OpLoad %6 %36 +%93 = OpExtInst %7 %1 UMin %28 %74 +%94 = OpISub %7 %74 %93 +%95 = OpExtInst %7 %1 UMin %29 %94 +%92 = OpBitFieldInsert %6 %90 %91 %93 %95 +OpStore %36 %92 +%96 = OpLoad %7 %38 +%97 = OpLoad %7 %38 +%99 = OpExtInst %7 %1 UMin %28 %74 +%100 = OpISub %7 %74 %99 +%101 = OpExtInst %7 %1 UMin %29 %100 +%98 = OpBitFieldInsert %7 %96 %97 %99 %101 +OpStore %38 %98 +%102 = OpLoad %8 %40 +%103 = OpLoad %8 %40 +%105 = OpExtInst %7 %1 UMin %28 %74 +%106 = OpISub %7 %74 %105 +%107 = OpExtInst %7 %1 UMin %29 %106 +%104 = OpBitFieldInsert %8 %102 %103 %105 %107 +OpStore %40 %104 +%108 = OpLoad %9 %42 +%109 = OpLoad %9 %42 +%111 = OpExtInst %7 %1 UMin %28 %74 +%112 = OpISub %7 %74 %111 +%113 = OpExtInst %7 %1 UMin %29 %112 +%110 = OpBitFieldInsert %9 %108 %109 %111 %113 +OpStore %42 %110 +%114 = OpLoad %10 %44 +%115 = OpLoad %10 %44 +%117 = OpExtInst %7 %1 UMin %28 %74 +%118 = OpISub %7 %74 %117 +%119 = OpExtInst %7 %1 UMin %29 %118 +%116 = OpBitFieldInsert %10 %114 %115 %117 %119 +OpStore %44 %116 +%120 = OpLoad %3 %30 +%122 = OpExtInst %7 %1 UMin %28 %74 +%123 = OpISub %7 %74 %122 +%124 = OpExtInst %7 %1 UMin %29 %123 +%121 = OpBitFieldSExtract %3 %120 %122 %124 +OpStore %30 %121 %125 = OpLoad %4 %32 -%126 = OpBitCount %4 %125 +%127 = OpExtInst %7 %1 UMin %28 %74 +%128 = OpISub %7 %74 %127 +%129 = OpExtInst %7 %1 UMin %29 %128 +%126 = OpBitFieldSExtract %4 %125 %127 %129 OpStore %32 %126 -%127 = OpLoad %5 %34 -%128 = OpBitCount %5 %127 -OpStore %34 %128 -%129 = OpLoad %6 %36 -%130 = OpBitCount %6 %129 -OpStore %36 %130 -%131 = OpLoad %7 %38 -%132 = OpBitCount %7 %131 -OpStore %38 %132 -%133 = OpLoad %8 %40 -%134 = OpBitCount %8 %133 -OpStore %40 %134 -%135 = OpLoad %9 %42 -%136 = OpBitCount %9 %135 -OpStore %42 %136 -%137 = OpLoad %10 %44 -%138 = OpBitCount %10 %137 -OpStore %44 %138 -%139 = OpLoad %3 %30 -%140 = OpBitReverse %3 %139 -OpStore %30 %140 -%141 = OpLoad %4 %32 -%142 = OpBitReverse %4 %141 -OpStore %32 %142 -%143 = OpLoad %5 %34 -%144 = OpBitReverse %5 %143 -OpStore %34 %144 -%145 = OpLoad %6 %36 -%146 = OpBitReverse %6 %145 -OpStore %36 %146 -%147 = OpLoad %7 %38 -%148 = OpBitReverse %7 %147 -OpStore %38 %148 -%149 = OpLoad %8 %40 -%150 = OpBitReverse %8 %149 -OpStore %40 %150 -%151 = OpLoad %9 %42 -%152 = OpBitReverse %9 %151 -OpStore %42 %152 -%153 = OpLoad %10 %44 -%154 = OpBitReverse %10 %153 -OpStore %44 %154 +%130 = OpLoad %5 %34 +%132 = OpExtInst %7 %1 UMin %28 %74 +%133 = OpISub %7 %74 %132 +%134 = OpExtInst %7 %1 UMin %29 %133 +%131 = OpBitFieldSExtract %5 %130 %132 %134 +OpStore %34 %131 +%135 = OpLoad %6 %36 +%137 = OpExtInst %7 %1 UMin %28 %74 +%138 = OpISub %7 %74 %137 +%139 = OpExtInst %7 %1 UMin %29 %138 +%136 = OpBitFieldSExtract %6 %135 %137 %139 +OpStore %36 %136 +%140 = OpLoad %7 %38 +%142 = OpExtInst %7 %1 UMin %28 %74 +%143 = OpISub %7 %74 %142 +%144 = OpExtInst %7 %1 UMin %29 %143 +%141 = OpBitFieldUExtract %7 %140 %142 %144 +OpStore %38 %141 +%145 = OpLoad %8 %40 +%147 = OpExtInst %7 %1 UMin %28 %74 +%148 = OpISub %7 %74 %147 +%149 = OpExtInst %7 %1 UMin %29 %148 +%146 = OpBitFieldUExtract %8 %145 %147 %149 +OpStore %40 %146 +%150 = OpLoad %9 %42 +%152 = OpExtInst %7 %1 UMin %28 %74 +%153 = OpISub %7 %74 %152 +%154 = OpExtInst %7 %1 UMin %29 %153 +%151 = OpBitFieldUExtract %9 %150 %152 %154 +OpStore %42 %151 +%155 = OpLoad %10 %44 +%157 = OpExtInst %7 %1 UMin %28 %74 +%158 = OpISub %7 %74 %157 +%159 = OpExtInst %7 %1 UMin %29 %158 +%156 = OpBitFieldUExtract %10 %155 %157 %159 +OpStore %44 %156 +%160 = OpLoad %3 %30 +%161 = OpExtInst %3 %1 FindILsb %160 +OpStore %30 %161 +%162 = OpLoad %8 %40 +%163 = OpExtInst %8 %1 FindILsb %162 +OpStore %40 %163 +%164 = OpLoad %5 %34 +%165 = OpExtInst %5 %1 FindSMsb %164 +OpStore %34 %165 +%166 = OpLoad %9 %42 +%167 = OpExtInst %9 %1 FindUMsb %166 +OpStore %42 %167 +%168 = OpLoad %3 %30 +%169 = OpExtInst %3 %1 FindSMsb %168 +OpStore %30 %169 +%170 = OpLoad %7 %38 +%171 = OpExtInst %7 %1 FindUMsb %170 +OpStore %38 %171 +%172 = OpLoad %3 %30 +%173 = OpBitCount %3 %172 +OpStore %30 %173 +%174 = OpLoad %4 %32 +%175 = OpBitCount %4 %174 +OpStore %32 %175 +%176 = OpLoad %5 %34 +%177 = OpBitCount %5 %176 +OpStore %34 %177 +%178 = OpLoad %6 %36 +%179 = OpBitCount %6 %178 +OpStore %36 %179 +%180 = OpLoad %7 %38 +%181 = OpBitCount %7 %180 +OpStore %38 %181 +%182 = OpLoad %8 %40 +%183 = OpBitCount %8 %182 +OpStore %40 %183 +%184 = OpLoad %9 %42 +%185 = OpBitCount %9 %184 +OpStore %42 %185 +%186 = OpLoad %10 %44 +%187 = OpBitCount %10 %186 +OpStore %44 %187 +%188 = OpLoad %3 %30 +%189 = OpBitReverse %3 %188 +OpStore %30 %189 +%190 = OpLoad %4 %32 +%191 = OpBitReverse %4 %190 +OpStore %32 %191 +%192 = OpLoad %5 %34 +%193 = OpBitReverse %5 %192 +OpStore %34 %193 +%194 = OpLoad %6 %36 +%195 = OpBitReverse %6 %194 +OpStore %36 %195 +%196 = OpLoad %7 %38 +%197 = OpBitReverse %7 %196 +OpStore %38 %197 +%198 = OpLoad %8 %40 +%199 = OpBitReverse %8 %198 +OpStore %40 %199 +%200 = OpLoad %9 %42 +%201 = OpBitReverse %9 %200 +OpStore %42 %201 +%202 = OpLoad %10 %44 +%203 = OpBitReverse %10 %202 +OpStore %44 %203 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/naga/tests/out/spv/int64.spvasm b/naga/tests/out/spv/int64.spvasm new file mode 100644 index 0000000000..a60a14d75f --- /dev/null +++ b/naga/tests/out/spv/int64.spvasm @@ -0,0 +1,470 @@ +; SPIR-V +; Version: 1.0 +; Generator: rspirv +; Bound: 372 +OpCapability Shader +OpCapability Int64 +OpExtension "SPV_KHR_storage_buffer_storage_class" +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %356 "main" +OpExecutionMode %356 LocalSize 1 1 1 +OpMemberDecorate %14 0 Offset 0 +OpMemberDecorate %14 1 Offset 4 +OpMemberDecorate %14 2 Offset 8 +OpMemberDecorate %14 3 Offset 16 +OpMemberDecorate %14 4 Offset 32 +OpMemberDecorate %14 5 Offset 64 +OpMemberDecorate %14 6 Offset 96 +OpMemberDecorate %14 7 Offset 128 +OpMemberDecorate %14 8 Offset 144 +OpMemberDecorate %14 9 Offset 160 +OpMemberDecorate %14 10 Offset 192 +OpMemberDecorate %14 11 Offset 224 +OpDecorate %15 ArrayStride 8 +OpDecorate %17 ArrayStride 8 +OpMemberDecorate %18 0 Offset 0 +OpMemberDecorate %18 1 Offset 16 +OpDecorate %23 DescriptorSet 0 +OpDecorate %23 Binding 0 +OpDecorate %24 Block +OpMemberDecorate %24 0 Offset 0 +OpDecorate %26 NonWritable +OpDecorate %26 DescriptorSet 0 +OpDecorate %26 Binding 1 +OpDecorate %27 Block +OpMemberDecorate %27 0 Offset 0 +OpDecorate %29 NonWritable +OpDecorate %29 DescriptorSet 0 +OpDecorate %29 Binding 2 +OpDecorate %30 Block +OpMemberDecorate %30 0 Offset 0 +OpDecorate %32 DescriptorSet 0 +OpDecorate %32 Binding 3 +OpDecorate %33 Block +OpMemberDecorate %33 0 Offset 0 +OpDecorate %35 DescriptorSet 0 +OpDecorate %35 Binding 4 +OpDecorate %36 Block +OpMemberDecorate %36 0 Offset 0 +%2 = OpTypeVoid +%3 = OpTypeInt 64 1 +%4 = OpTypeInt 64 0 +%5 = OpTypeInt 32 0 +%6 = OpTypeInt 32 1 +%7 = OpTypeFloat 32 +%8 = OpTypeVector %4 2 +%9 = OpTypeVector %4 3 +%10 = OpTypeVector %4 4 +%11 = OpTypeVector %3 2 +%12 = OpTypeVector %3 3 +%13 = OpTypeVector %3 4 +%14 = OpTypeStruct %5 %6 %7 %4 %8 %9 %10 %3 %11 %12 %13 %4 +%16 = OpConstant %5 2 +%15 = OpTypeArray %4 %16 +%17 = OpTypeArray %3 %16 +%18 = OpTypeStruct %15 %17 +%19 = OpConstant %3 1 +%20 = OpConstant %4 20 +%22 = OpTypePointer Private %3 +%21 = OpVariable %22 Private %19 +%24 = OpTypeStruct %14 +%25 = OpTypePointer Uniform %24 +%23 = OpVariable %25 Uniform +%27 = OpTypeStruct %14 +%28 = OpTypePointer StorageBuffer %27 +%26 = OpVariable %28 StorageBuffer +%30 = OpTypeStruct %18 +%31 = OpTypePointer StorageBuffer %30 +%29 = OpVariable %31 StorageBuffer +%33 = OpTypeStruct %14 +%34 = OpTypePointer StorageBuffer %33 +%32 = OpVariable %34 StorageBuffer +%36 = OpTypeStruct %18 +%37 = OpTypePointer StorageBuffer %36 +%35 = OpVariable %37 StorageBuffer +%41 = OpTypeFunction %3 %3 +%42 = OpTypePointer Uniform %14 +%43 = OpConstant %5 0 +%45 = OpTypePointer StorageBuffer %14 +%47 = OpTypePointer StorageBuffer %18 +%51 = OpConstant %3 20 +%52 = OpConstant %3 31 +%53 = OpConstant %3 1002003004005006 +%54 = OpConstant %3 5 +%56 = OpTypePointer Function %3 +%65 = OpTypePointer Uniform %5 +%74 = OpTypePointer Uniform %6 +%75 = OpConstant %5 1 +%84 = OpTypePointer Uniform %7 +%93 = OpTypePointer Uniform %3 +%94 = OpConstant %5 7 +%101 = OpTypePointer Uniform %4 +%102 = OpConstant %5 3 +%108 = OpTypePointer Uniform %8 +%109 = OpConstant %5 4 +%116 = OpTypePointer Uniform %9 +%117 = OpConstant %5 5 +%124 = OpTypePointer Uniform %10 +%125 = OpConstant %5 6 +%132 = OpTypePointer StorageBuffer %3 +%139 = OpTypePointer StorageBuffer %11 +%140 = OpTypePointer Uniform %11 +%141 = OpConstant %5 8 +%148 = OpTypePointer StorageBuffer %12 +%149 = OpTypePointer Uniform %12 +%150 = OpConstant %5 9 +%157 = OpTypePointer StorageBuffer %13 +%158 = OpTypePointer Uniform %13 +%159 = OpConstant %5 10 +%166 = OpTypePointer StorageBuffer %17 +%186 = OpConstantNull %3 +%214 = OpTypeFunction %4 %4 +%220 = OpConstant %4 31 +%221 = OpConstant %4 1002003004005006 +%222 = OpConstant %4 5 +%224 = OpTypePointer Function %4 +%286 = OpTypePointer StorageBuffer %4 +%293 = OpTypePointer StorageBuffer %8 +%300 = OpTypePointer StorageBuffer %9 +%307 = OpTypePointer StorageBuffer %10 +%314 = OpTypePointer StorageBuffer %15 +%334 = OpConstantNull %4 +%357 = OpTypeFunction %2 +%363 = OpConstant %4 67 +%364 = OpConstant %3 60 +%370 = OpConstant %5 11 +%40 = OpFunction %3 None %41 +%39 = OpFunctionParameter %3 +%38 = OpLabel +%55 = OpVariable %56 Function %51 +%44 = OpAccessChain %42 %23 %43 +%46 = OpAccessChain %45 %26 %43 +%48 = OpAccessChain %47 %29 %43 +%49 = OpAccessChain %45 %32 %43 +%50 = OpAccessChain %47 %35 %43 +OpBranch %57 +%57 = OpLabel +%58 = OpISub %3 %52 %53 +%59 = OpLoad %3 %55 +%60 = OpIAdd %3 %59 %58 +OpStore %55 %60 +%61 = OpLoad %3 %55 +%62 = OpIAdd %3 %61 %54 +%63 = OpLoad %3 %55 +%64 = OpIAdd %3 %63 %62 +OpStore %55 %64 +%66 = OpAccessChain %65 %44 %43 +%67 = OpLoad %5 %66 +%68 = OpLoad %3 %55 +%69 = OpUConvert %5 %68 +%70 = OpIAdd %5 %67 %69 +%71 = OpSConvert %3 %70 +%72 = OpLoad %3 %55 +%73 = OpIAdd %3 %72 %71 +OpStore %55 %73 +%76 = OpAccessChain %74 %44 %75 +%77 = OpLoad %6 %76 +%78 = OpLoad %3 %55 +%79 = OpSConvert %6 %78 +%80 = OpIAdd %6 %77 %79 +%81 = OpSConvert %3 %80 +%82 = OpLoad %3 %55 +%83 = OpIAdd %3 %82 %81 +OpStore %55 %83 +%85 = OpAccessChain %84 %44 %16 +%86 = OpLoad %7 %85 +%87 = OpLoad %3 %55 +%88 = OpConvertSToF %7 %87 +%89 = OpFAdd %7 %86 %88 +%90 = OpConvertFToS %3 %89 +%91 = OpLoad %3 %55 +%92 = OpIAdd %3 %91 %90 +OpStore %55 %92 +%95 = OpAccessChain %93 %44 %94 +%96 = OpLoad %3 %95 +%97 = OpCompositeConstruct %12 %96 %96 %96 +%98 = OpCompositeExtract %3 %97 2 +%99 = OpLoad %3 %55 +%100 = OpIAdd %3 %99 %98 +OpStore %55 %100 +%103 = OpAccessChain %101 %44 %102 +%104 = OpLoad %4 %103 +%105 = OpBitcast %3 %104 +%106 = OpLoad %3 %55 +%107 = OpIAdd %3 %106 %105 +OpStore %55 %107 +%110 = OpAccessChain %108 %44 %109 +%111 = OpLoad %8 %110 +%112 = OpBitcast %11 %111 +%113 = OpCompositeExtract %3 %112 1 +%114 = OpLoad %3 %55 +%115 = OpIAdd %3 %114 %113 +OpStore %55 %115 +%118 = OpAccessChain %116 %44 %117 +%119 = OpLoad %9 %118 +%120 = OpBitcast %12 %119 +%121 = OpCompositeExtract %3 %120 2 +%122 = OpLoad %3 %55 +%123 = OpIAdd %3 %122 %121 +OpStore %55 %123 +%126 = OpAccessChain %124 %44 %125 +%127 = OpLoad %10 %126 +%128 = OpBitcast %13 %127 +%129 = OpCompositeExtract %3 %128 3 +%130 = OpLoad %3 %55 +%131 = OpIAdd %3 %130 %129 +OpStore %55 %131 +%133 = OpAccessChain %93 %44 %94 +%134 = OpLoad %3 %133 +%135 = OpAccessChain %132 %46 %94 +%136 = OpLoad %3 %135 +%137 = OpIAdd %3 %134 %136 +%138 = OpAccessChain %132 %49 %94 +OpStore %138 %137 +%142 = OpAccessChain %140 %44 %141 +%143 = OpLoad %11 %142 +%144 = OpAccessChain %139 %46 %141 +%145 = OpLoad %11 %144 +%146 = OpIAdd %11 %143 %145 +%147 = OpAccessChain %139 %49 %141 +OpStore %147 %146 +%151 = OpAccessChain %149 %44 %150 +%152 = OpLoad %12 %151 +%153 = OpAccessChain %148 %46 %150 +%154 = OpLoad %12 %153 +%155 = OpIAdd %12 %152 %154 +%156 = OpAccessChain %148 %49 %150 +OpStore %156 %155 +%160 = OpAccessChain %158 %44 %159 +%161 = OpLoad %13 %160 +%162 = OpAccessChain %157 %46 %159 +%163 = OpLoad %13 %162 +%164 = OpIAdd %13 %161 %163 +%165 = OpAccessChain %157 %49 %159 +OpStore %165 %164 +%167 = OpAccessChain %166 %48 %75 +%168 = OpLoad %17 %167 +%169 = OpAccessChain %166 %50 %75 +OpStore %169 %168 +%170 = OpLoad %3 %55 +%171 = OpExtInst %3 %1 SAbs %170 +%172 = OpLoad %3 %55 +%173 = OpIAdd %3 %172 %171 +OpStore %55 %173 +%174 = OpLoad %3 %55 +%175 = OpLoad %3 %55 +%176 = OpLoad %3 %55 +%178 = OpExtInst %3 %1 SMax %174 %175 +%177 = OpExtInst %3 %1 SMin %178 %176 +%179 = OpLoad %3 %55 +%180 = OpIAdd %3 %179 %177 +OpStore %55 %180 +%181 = OpLoad %3 %55 +%182 = OpCompositeConstruct %11 %181 %181 +%183 = OpLoad %3 %55 +%184 = OpCompositeConstruct %11 %183 %183 +%187 = OpCompositeExtract %3 %182 0 +%188 = OpCompositeExtract %3 %184 0 +%189 = OpIMul %3 %187 %188 +%190 = OpIAdd %3 %186 %189 +%191 = OpCompositeExtract %3 %182 1 +%192 = OpCompositeExtract %3 %184 1 +%193 = OpIMul %3 %191 %192 +%185 = OpIAdd %3 %190 %193 +%194 = OpLoad %3 %55 +%195 = OpIAdd %3 %194 %185 +OpStore %55 %195 +%196 = OpLoad %3 %55 +%197 = OpLoad %3 %55 +%198 = OpExtInst %3 %1 SMax %196 %197 +%199 = OpLoad %3 %55 +%200 = OpIAdd %3 %199 %198 +OpStore %55 %200 +%201 = OpLoad %3 %55 +%202 = OpLoad %3 %55 +%203 = OpExtInst %3 %1 SMin %201 %202 +%204 = OpLoad %3 %55 +%205 = OpIAdd %3 %204 %203 +OpStore %55 %205 +%206 = OpLoad %3 %55 +%207 = OpExtInst %3 %1 SSign %206 +%208 = OpLoad %3 %55 +%209 = OpIAdd %3 %208 %207 +OpStore %55 %209 +%210 = OpLoad %3 %55 +OpReturnValue %210 +OpFunctionEnd +%213 = OpFunction %4 None %214 +%212 = OpFunctionParameter %4 +%211 = OpLabel +%223 = OpVariable %224 Function %20 +%215 = OpAccessChain %42 %23 %43 +%216 = OpAccessChain %45 %26 %43 +%217 = OpAccessChain %47 %29 %43 +%218 = OpAccessChain %45 %32 %43 +%219 = OpAccessChain %47 %35 %43 +OpBranch %225 +%225 = OpLabel +%226 = OpIAdd %4 %220 %221 +%227 = OpLoad %4 %223 +%228 = OpIAdd %4 %227 %226 +OpStore %223 %228 +%229 = OpLoad %4 %223 +%230 = OpIAdd %4 %229 %222 +%231 = OpLoad %4 %223 +%232 = OpIAdd %4 %231 %230 +OpStore %223 %232 +%233 = OpAccessChain %65 %215 %43 +%234 = OpLoad %5 %233 +%235 = OpLoad %4 %223 +%236 = OpUConvert %5 %235 +%237 = OpIAdd %5 %234 %236 +%238 = OpUConvert %4 %237 +%239 = OpLoad %4 %223 +%240 = OpIAdd %4 %239 %238 +OpStore %223 %240 +%241 = OpAccessChain %74 %215 %75 +%242 = OpLoad %6 %241 +%243 = OpLoad %4 %223 +%244 = OpSConvert %6 %243 +%245 = OpIAdd %6 %242 %244 +%246 = OpUConvert %4 %245 +%247 = OpLoad %4 %223 +%248 = OpIAdd %4 %247 %246 +OpStore %223 %248 +%249 = OpAccessChain %84 %215 %16 +%250 = OpLoad %7 %249 +%251 = OpLoad %4 %223 +%252 = OpConvertUToF %7 %251 +%253 = OpFAdd %7 %250 %252 +%254 = OpConvertFToU %4 %253 +%255 = OpLoad %4 %223 +%256 = OpIAdd %4 %255 %254 +OpStore %223 %256 +%257 = OpAccessChain %101 %215 %102 +%258 = OpLoad %4 %257 +%259 = OpCompositeConstruct %9 %258 %258 %258 +%260 = OpCompositeExtract %4 %259 2 +%261 = OpLoad %4 %223 +%262 = OpIAdd %4 %261 %260 +OpStore %223 %262 +%263 = OpAccessChain %93 %215 %94 +%264 = OpLoad %3 %263 +%265 = OpBitcast %4 %264 +%266 = OpLoad %4 %223 +%267 = OpIAdd %4 %266 %265 +OpStore %223 %267 +%268 = OpAccessChain %140 %215 %141 +%269 = OpLoad %11 %268 +%270 = OpBitcast %8 %269 +%271 = OpCompositeExtract %4 %270 1 +%272 = OpLoad %4 %223 +%273 = OpIAdd %4 %272 %271 +OpStore %223 %273 +%274 = OpAccessChain %149 %215 %150 +%275 = OpLoad %12 %274 +%276 = OpBitcast %9 %275 +%277 = OpCompositeExtract %4 %276 2 +%278 = OpLoad %4 %223 +%279 = OpIAdd %4 %278 %277 +OpStore %223 %279 +%280 = OpAccessChain %158 %215 %159 +%281 = OpLoad %13 %280 +%282 = OpBitcast %10 %281 +%283 = OpCompositeExtract %4 %282 3 +%284 = OpLoad %4 %223 +%285 = OpIAdd %4 %284 %283 +OpStore %223 %285 +%287 = OpAccessChain %101 %215 %102 +%288 = OpLoad %4 %287 +%289 = OpAccessChain %286 %216 %102 +%290 = OpLoad %4 %289 +%291 = OpIAdd %4 %288 %290 +%292 = OpAccessChain %286 %218 %102 +OpStore %292 %291 +%294 = OpAccessChain %108 %215 %109 +%295 = OpLoad %8 %294 +%296 = OpAccessChain %293 %216 %109 +%297 = OpLoad %8 %296 +%298 = OpIAdd %8 %295 %297 +%299 = OpAccessChain %293 %218 %109 +OpStore %299 %298 +%301 = OpAccessChain %116 %215 %117 +%302 = OpLoad %9 %301 +%303 = OpAccessChain %300 %216 %117 +%304 = OpLoad %9 %303 +%305 = OpIAdd %9 %302 %304 +%306 = OpAccessChain %300 %218 %117 +OpStore %306 %305 +%308 = OpAccessChain %124 %215 %125 +%309 = OpLoad %10 %308 +%310 = OpAccessChain %307 %216 %125 +%311 = OpLoad %10 %310 +%312 = OpIAdd %10 %309 %311 +%313 = OpAccessChain %307 %218 %125 +OpStore %313 %312 +%315 = OpAccessChain %314 %217 %43 +%316 = OpLoad %15 %315 +%317 = OpAccessChain %314 %219 %43 +OpStore %317 %316 +%318 = OpLoad %4 %223 +%319 = OpCopyObject %4 %318 +%320 = OpLoad %4 %223 +%321 = OpIAdd %4 %320 %319 +OpStore %223 %321 +%322 = OpLoad %4 %223 +%323 = OpLoad %4 %223 +%324 = OpLoad %4 %223 +%326 = OpExtInst %4 %1 UMax %322 %323 +%325 = OpExtInst %4 %1 UMin %326 %324 +%327 = OpLoad %4 %223 +%328 = OpIAdd %4 %327 %325 +OpStore %223 %328 +%329 = OpLoad %4 %223 +%330 = OpCompositeConstruct %8 %329 %329 +%331 = OpLoad %4 %223 +%332 = OpCompositeConstruct %8 %331 %331 +%335 = OpCompositeExtract %4 %330 0 +%336 = OpCompositeExtract %4 %332 0 +%337 = OpIMul %4 %335 %336 +%338 = OpIAdd %4 %334 %337 +%339 = OpCompositeExtract %4 %330 1 +%340 = OpCompositeExtract %4 %332 1 +%341 = OpIMul %4 %339 %340 +%333 = OpIAdd %4 %338 %341 +%342 = OpLoad %4 %223 +%343 = OpIAdd %4 %342 %333 +OpStore %223 %343 +%344 = OpLoad %4 %223 +%345 = OpLoad %4 %223 +%346 = OpExtInst %4 %1 UMax %344 %345 +%347 = OpLoad %4 %223 +%348 = OpIAdd %4 %347 %346 +OpStore %223 %348 +%349 = OpLoad %4 %223 +%350 = OpLoad %4 %223 +%351 = OpExtInst %4 %1 UMin %349 %350 +%352 = OpLoad %4 %223 +%353 = OpIAdd %4 %352 %351 +OpStore %223 %353 +%354 = OpLoad %4 %223 +OpReturnValue %354 +OpFunctionEnd +%356 = OpFunction %2 None %357 +%355 = OpLabel +%358 = OpAccessChain %42 %23 %43 +%359 = OpAccessChain %45 %26 %43 +%360 = OpAccessChain %47 %29 %43 +%361 = OpAccessChain %45 %32 %43 +%362 = OpAccessChain %47 %35 %43 +OpBranch %365 +%365 = OpLabel +%366 = OpFunctionCall %4 %213 %363 +%367 = OpFunctionCall %3 %40 %364 +%368 = OpBitcast %4 %367 +%369 = OpIAdd %4 %366 %368 +%371 = OpAccessChain %286 %361 %370 +OpStore %371 %369 +OpReturn +OpFunctionEnd \ No newline at end of file diff --git a/naga/tests/out/wgsl/210-bevy-2d-shader.vert.wgsl b/naga/tests/out/wgsl/210-bevy-2d-shader.vert.wgsl index 5a8e54159a..52355cd404 100644 --- a/naga/tests/out/wgsl/210-bevy-2d-shader.vert.wgsl +++ b/naga/tests/out/wgsl/210-bevy-2d-shader.vert.wgsl @@ -12,7 +12,7 @@ struct Sprite_size { struct VertexOutput { @location(0) v_Uv: vec2, - @builtin(position) member: vec4, + @builtin(position) gl_Position: vec4, } var Vertex_Position_1: vec3; diff --git a/naga/tests/out/wgsl/210-bevy-shader.vert.wgsl b/naga/tests/out/wgsl/210-bevy-shader.vert.wgsl index f929543ebf..223538e4e0 100644 --- a/naga/tests/out/wgsl/210-bevy-shader.vert.wgsl +++ b/naga/tests/out/wgsl/210-bevy-shader.vert.wgsl @@ -10,7 +10,7 @@ struct VertexOutput { @location(0) v_Position: vec3, @location(1) v_Normal: vec3, @location(2) v_Uv: vec2, - @builtin(position) member: vec4, + @builtin(position) gl_Position: vec4, } var Vertex_Position_1: vec3; diff --git a/naga/tests/out/wgsl/246-collatz.comp.wgsl b/naga/tests/out/wgsl/246-collatz.comp.wgsl index cd89fd831a..916bb4ae4d 100644 --- a/naga/tests/out/wgsl/246-collatz.comp.wgsl +++ b/naga/tests/out/wgsl/246-collatz.comp.wgsl @@ -4,7 +4,7 @@ struct PrimeIndices { @group(0) @binding(0) var global: PrimeIndices; -var gl_GlobalInvocationID: vec3; +var gl_GlobalInvocationID_1: vec3; fn collatz_iterations(n: u32) -> u32 { var n_1: u32; @@ -41,7 +41,7 @@ fn collatz_iterations(n: u32) -> u32 { fn main_1() { var index: u32; - let _e3 = gl_GlobalInvocationID; + let _e3 = gl_GlobalInvocationID_1; index = _e3.x; let _e6 = index; let _e8 = index; @@ -53,8 +53,8 @@ fn main_1() { } @compute @workgroup_size(1, 1, 1) -fn main(@builtin(global_invocation_id) param: vec3) { - gl_GlobalInvocationID = param; +fn main(@builtin(global_invocation_id) gl_GlobalInvocationID: vec3) { + gl_GlobalInvocationID_1 = gl_GlobalInvocationID; main_1(); return; } diff --git a/naga/tests/out/wgsl/5246-dual-iteration.frag.wgsl b/naga/tests/out/wgsl/5246-dual-iteration.frag.wgsl new file mode 100644 index 0000000000..e2672a9951 --- /dev/null +++ b/naga/tests/out/wgsl/5246-dual-iteration.frag.wgsl @@ -0,0 +1,51 @@ +fn main_1() { + var x: i32 = 0i; + var y: i32; + var z: i32; + + loop { + let _e2 = x; + if !((_e2 < 10i)) { + break; + } + { + y = 0i; + loop { + let _e11 = y; + if !((_e11 < 10i)) { + break; + } + { + z = 0i; + loop { + let _e20 = z; + if !((_e20 < 10i)) { + break; + } + { + } + continuing { + let _e24 = z; + z = (_e24 + 1i); + } + } + } + continuing { + let _e15 = y; + y = (_e15 + 1i); + } + } + } + continuing { + let _e6 = x; + x = (_e6 + 1i); + } + } + return; +} + +@fragment +fn main() { + main_1(); + return; +} diff --git a/naga/tests/out/wgsl/800-out-of-bounds-panic.vert.wgsl b/naga/tests/out/wgsl/800-out-of-bounds-panic.vert.wgsl index 820ab6194c..8d6bc50af0 100644 --- a/naga/tests/out/wgsl/800-out-of-bounds-panic.vert.wgsl +++ b/naga/tests/out/wgsl/800-out-of-bounds-panic.vert.wgsl @@ -8,7 +8,7 @@ struct VertexPushConstants { struct VertexOutput { @location(0) frag_color: vec4, - @builtin(position) member: vec4, + @builtin(position) gl_Position: vec4, } @group(0) @binding(0) diff --git a/naga/tests/out/wgsl/bevy-pbr.frag.wgsl b/naga/tests/out/wgsl/bevy-pbr.frag.wgsl index 81d69d0736..012077791e 100644 --- a/naga/tests/out/wgsl/bevy-pbr.frag.wgsl +++ b/naga/tests/out/wgsl/bevy-pbr.frag.wgsl @@ -93,7 +93,7 @@ var global_7: StandardMaterial_emissive; var StandardMaterial_emissive_texture: texture_2d; @group(3) @binding(14) var StandardMaterial_emissive_texture_sampler: sampler; -var gl_FrontFacing: bool; +var gl_FrontFacing_1: bool; fn pow5_(x: f32) -> f32 { var x_1: f32; @@ -746,7 +746,7 @@ fn main_1() { let _e78 = T; let _e80 = v_WorldTangent_1; B = (cross(_e77, _e78) * _e80.w); - let _e85 = gl_FrontFacing; + let _e85 = gl_FrontFacing_1; if _e85 { let _e86 = N_2; local = _e86; @@ -756,7 +756,7 @@ fn main_1() { } let _e90 = local; N_2 = _e90; - let _e91 = gl_FrontFacing; + let _e91 = gl_FrontFacing_1; if _e91 { let _e92 = T; local_1 = _e92; @@ -766,7 +766,7 @@ fn main_1() { } let _e96 = local_1; T = _e96; - let _e97 = gl_FrontFacing; + let _e97 = gl_FrontFacing_1; if _e97 { let _e98 = B; local_2 = _e98; @@ -921,12 +921,12 @@ fn main_1() { } @fragment -fn main(@location(0) v_WorldPosition: vec3, @location(1) v_WorldNormal: vec3, @location(2) v_Uv: vec2, @location(3) v_WorldTangent: vec4, @builtin(front_facing) param: bool) -> FragmentOutput { +fn main(@location(0) v_WorldPosition: vec3, @location(1) v_WorldNormal: vec3, @location(2) v_Uv: vec2, @location(3) v_WorldTangent: vec4, @builtin(front_facing) gl_FrontFacing: bool) -> FragmentOutput { v_WorldPosition_1 = v_WorldPosition; v_WorldNormal_1 = v_WorldNormal; v_Uv_1 = v_Uv; v_WorldTangent_1 = v_WorldTangent; - gl_FrontFacing = param; + gl_FrontFacing_1 = gl_FrontFacing; main_1(); let _e69 = o_Target; return FragmentOutput(_e69); diff --git a/naga/tests/out/wgsl/bevy-pbr.vert.wgsl b/naga/tests/out/wgsl/bevy-pbr.vert.wgsl index 71cf8d2fe6..1524b9e469 100644 --- a/naga/tests/out/wgsl/bevy-pbr.vert.wgsl +++ b/naga/tests/out/wgsl/bevy-pbr.vert.wgsl @@ -11,7 +11,7 @@ struct VertexOutput { @location(1) v_WorldNormal: vec3, @location(2) v_Uv: vec2, @location(3) v_WorldTangent: vec4, - @builtin(position) member: vec4, + @builtin(position) gl_Position: vec4, } var Vertex_Position_1: vec3; diff --git a/naga/tests/out/wgsl/binding-buffer-arrays.wgsl b/naga/tests/out/wgsl/binding-buffer-arrays.wgsl index 317a386239..a11ef3d0fe 100644 --- a/naga/tests/out/wgsl/binding-buffer-arrays.wgsl +++ b/naga/tests/out/wgsl/binding-buffer-arrays.wgsl @@ -4,6 +4,7 @@ struct UniformIndex { struct Foo { x: u32, + far: array, } struct FragmentIn { @@ -30,6 +31,12 @@ fn main(fragment_in: FragmentIn) -> @location(0) @interpolate(flat) u32 { let _e22 = storage_array[non_uniform_index].x; let _e23 = u1_; u1_ = (_e23 + _e22); - let _e25 = u1_; - return _e25; + let _e29 = u1_; + u1_ = (_e29 + arrayLength((&storage_array[0].far))); + let _e35 = u1_; + u1_ = (_e35 + arrayLength((&storage_array[uniform_index].far))); + let _e41 = u1_; + u1_ = (_e41 + arrayLength((&storage_array[non_uniform_index].far))); + let _e43 = u1_; + return _e43; } diff --git a/naga/tests/out/wgsl/builtin-accessed-outside-entrypoint.wgsl b/naga/tests/out/wgsl/builtin-accessed-outside-entrypoint.wgsl new file mode 100644 index 0000000000..8e1b885bf7 --- /dev/null +++ b/naga/tests/out/wgsl/builtin-accessed-outside-entrypoint.wgsl @@ -0,0 +1,31 @@ +struct gl_PerVertex { + @builtin(position) gl_Position: vec4, + gl_PointSize: f32, + gl_ClipDistance: array, + gl_CullDistance: array, +} + +var unnamed: gl_PerVertex = gl_PerVertex(vec4(0f, 0f, 0f, 1f), 1f, array(), array()); +var gl_VertexIndex_1: i32; + +fn builtin_usage() { + let _e9 = gl_VertexIndex_1; + let _e12 = gl_VertexIndex_1; + unnamed.gl_Position = vec4(select(1f, -4f, (_e9 == 0i)), select(-1f, 4f, (_e12 == 2i)), 0f, 1f); + return; +} + +fn main_1() { + builtin_usage(); + return; +} + +@vertex +fn main(@builtin(vertex_index) gl_VertexIndex: u32) -> @builtin(position) vec4 { + gl_VertexIndex_1 = i32(gl_VertexIndex); + main_1(); + let _e6 = unnamed.gl_Position.y; + unnamed.gl_Position.y = -(_e6); + let _e8 = unnamed.gl_Position; + return _e8; +} diff --git a/naga/tests/out/wgsl/clamp-splat.vert.wgsl b/naga/tests/out/wgsl/clamp-splat.vert.wgsl index 5dcc28e979..3425e57588 100644 --- a/naga/tests/out/wgsl/clamp-splat.vert.wgsl +++ b/naga/tests/out/wgsl/clamp-splat.vert.wgsl @@ -1,5 +1,5 @@ struct VertexOutput { - @builtin(position) member: vec4, + @builtin(position) gl_Position: vec4, } var a_pos_1: vec2; diff --git a/naga/tests/out/wgsl/int64.wgsl b/naga/tests/out/wgsl/int64.wgsl new file mode 100644 index 0000000000..f378bef20b --- /dev/null +++ b/naga/tests/out/wgsl/int64.wgsl @@ -0,0 +1,190 @@ +struct UniformCompatible { + val_u32_: u32, + val_i32_: i32, + val_f32_: f32, + val_u64_: u64, + val_u64_2_: vec2, + val_u64_3_: vec3, + val_u64_4_: vec4, + val_i64_: i64, + val_i64_2_: vec2, + val_i64_3_: vec3, + val_i64_4_: vec4, + final_value: u64, +} + +struct StorageCompatible { + val_u64_array_2_: array, + val_i64_array_2_: array, +} + +const constant_variable: u64 = 20lu; + +var private_variable: i64 = 1li; +@group(0) @binding(0) +var input_uniform: UniformCompatible; +@group(0) @binding(1) +var input_storage: UniformCompatible; +@group(0) @binding(2) +var input_arrays: StorageCompatible; +@group(0) @binding(3) +var output: UniformCompatible; +@group(0) @binding(4) +var output_arrays: StorageCompatible; + +fn int64_function(x: i64) -> i64 { + var val: i64 = 20li; + + let _e6 = val; + val = (_e6 + (31li - 1002003004005006li)); + let _e8 = val; + let _e11 = val; + val = (_e11 + (_e8 + 5li)); + let _e15 = input_uniform.val_u32_; + let _e16 = val; + let _e20 = val; + val = (_e20 + i64((_e15 + u32(_e16)))); + let _e24 = input_uniform.val_i32_; + let _e25 = val; + let _e29 = val; + val = (_e29 + i64((_e24 + i32(_e25)))); + let _e33 = input_uniform.val_f32_; + let _e34 = val; + let _e38 = val; + val = (_e38 + i64((_e33 + f32(_e34)))); + let _e42 = input_uniform.val_i64_; + let _e45 = val; + val = (_e45 + vec3(_e42).z); + let _e49 = input_uniform.val_u64_; + let _e51 = val; + val = (_e51 + bitcast(_e49)); + let _e55 = input_uniform.val_u64_2_; + let _e58 = val; + val = (_e58 + bitcast>(_e55).y); + let _e62 = input_uniform.val_u64_3_; + let _e65 = val; + val = (_e65 + bitcast>(_e62).z); + let _e69 = input_uniform.val_u64_4_; + let _e72 = val; + val = (_e72 + bitcast>(_e69).w); + let _e78 = input_uniform.val_i64_; + let _e81 = input_storage.val_i64_; + output.val_i64_ = (_e78 + _e81); + let _e87 = input_uniform.val_i64_2_; + let _e90 = input_storage.val_i64_2_; + output.val_i64_2_ = (_e87 + _e90); + let _e96 = input_uniform.val_i64_3_; + let _e99 = input_storage.val_i64_3_; + output.val_i64_3_ = (_e96 + _e99); + let _e105 = input_uniform.val_i64_4_; + let _e108 = input_storage.val_i64_4_; + output.val_i64_4_ = (_e105 + _e108); + let _e114 = input_arrays.val_i64_array_2_; + output_arrays.val_i64_array_2_ = _e114; + let _e115 = val; + let _e117 = val; + val = (_e117 + abs(_e115)); + let _e119 = val; + let _e120 = val; + let _e121 = val; + let _e123 = val; + val = (_e123 + clamp(_e119, _e120, _e121)); + let _e125 = val; + let _e127 = val; + let _e130 = val; + val = (_e130 + dot(vec2(_e125), vec2(_e127))); + let _e132 = val; + let _e133 = val; + let _e135 = val; + val = (_e135 + max(_e132, _e133)); + let _e137 = val; + let _e138 = val; + let _e140 = val; + val = (_e140 + min(_e137, _e138)); + let _e142 = val; + let _e144 = val; + val = (_e144 + sign(_e142)); + let _e146 = val; + return _e146; +} + +fn uint64_function(x_1: u64) -> u64 { + var val_1: u64 = 20lu; + + let _e6 = val_1; + val_1 = (_e6 + (31lu + 1002003004005006lu)); + let _e8 = val_1; + let _e11 = val_1; + val_1 = (_e11 + (_e8 + 5lu)); + let _e15 = input_uniform.val_u32_; + let _e16 = val_1; + let _e20 = val_1; + val_1 = (_e20 + u64((_e15 + u32(_e16)))); + let _e24 = input_uniform.val_i32_; + let _e25 = val_1; + let _e29 = val_1; + val_1 = (_e29 + u64((_e24 + i32(_e25)))); + let _e33 = input_uniform.val_f32_; + let _e34 = val_1; + let _e38 = val_1; + val_1 = (_e38 + u64((_e33 + f32(_e34)))); + let _e42 = input_uniform.val_u64_; + let _e45 = val_1; + val_1 = (_e45 + vec3(_e42).z); + let _e49 = input_uniform.val_i64_; + let _e51 = val_1; + val_1 = (_e51 + bitcast(_e49)); + let _e55 = input_uniform.val_i64_2_; + let _e58 = val_1; + val_1 = (_e58 + bitcast>(_e55).y); + let _e62 = input_uniform.val_i64_3_; + let _e65 = val_1; + val_1 = (_e65 + bitcast>(_e62).z); + let _e69 = input_uniform.val_i64_4_; + let _e72 = val_1; + val_1 = (_e72 + bitcast>(_e69).w); + let _e78 = input_uniform.val_u64_; + let _e81 = input_storage.val_u64_; + output.val_u64_ = (_e78 + _e81); + let _e87 = input_uniform.val_u64_2_; + let _e90 = input_storage.val_u64_2_; + output.val_u64_2_ = (_e87 + _e90); + let _e96 = input_uniform.val_u64_3_; + let _e99 = input_storage.val_u64_3_; + output.val_u64_3_ = (_e96 + _e99); + let _e105 = input_uniform.val_u64_4_; + let _e108 = input_storage.val_u64_4_; + output.val_u64_4_ = (_e105 + _e108); + let _e114 = input_arrays.val_u64_array_2_; + output_arrays.val_u64_array_2_ = _e114; + let _e115 = val_1; + let _e117 = val_1; + val_1 = (_e117 + abs(_e115)); + let _e119 = val_1; + let _e120 = val_1; + let _e121 = val_1; + let _e123 = val_1; + val_1 = (_e123 + clamp(_e119, _e120, _e121)); + let _e125 = val_1; + let _e127 = val_1; + let _e130 = val_1; + val_1 = (_e130 + dot(vec2(_e125), vec2(_e127))); + let _e132 = val_1; + let _e133 = val_1; + let _e135 = val_1; + val_1 = (_e135 + max(_e132, _e133)); + let _e137 = val_1; + let _e138 = val_1; + let _e140 = val_1; + val_1 = (_e140 + min(_e137, _e138)); + let _e142 = val_1; + return _e142; +} + +@compute @workgroup_size(1, 1, 1) +fn main() { + let _e3 = uint64_function(67lu); + let _e5 = int64_function(60li); + output.final_value = (_e3 + bitcast(_e5)); + return; +} diff --git a/naga/tests/out/wgsl/quad-vert.wgsl b/naga/tests/out/wgsl/quad-vert.wgsl index 28a2317e91..2de0528cca 100644 --- a/naga/tests/out/wgsl/quad-vert.wgsl +++ b/naga/tests/out/wgsl/quad-vert.wgsl @@ -12,14 +12,14 @@ struct VertexOutput { var v_uv: vec2; var a_uv_1: vec2; -var perVertexStruct: gl_PerVertex = gl_PerVertex(vec4(0f, 0f, 0f, 1f), 1f, array(), array()); +var unnamed: gl_PerVertex = gl_PerVertex(vec4(0f, 0f, 0f, 1f), 1f, array(), array()); var a_pos_1: vec2; fn main_1() { let _e6 = a_uv_1; v_uv = _e6; let _e7 = a_pos_1; - perVertexStruct.gl_Position = vec4(_e7.x, _e7.y, 0f, 1f); + unnamed.gl_Position = vec4(_e7.x, _e7.y, 0f, 1f); return; } @@ -29,6 +29,6 @@ fn main(@location(1) a_uv: vec2, @location(0) a_pos: vec2) -> VertexOu a_pos_1 = a_pos; main_1(); let _e7 = v_uv; - let _e8 = perVertexStruct.gl_Position; + let _e8 = unnamed.gl_Position; return VertexOutput(_e7, _e8); } diff --git a/naga/tests/out/wgsl/quad_glsl.vert.wgsl b/naga/tests/out/wgsl/quad_glsl.vert.wgsl index 5c5ee71041..8942e4c72f 100644 --- a/naga/tests/out/wgsl/quad_glsl.vert.wgsl +++ b/naga/tests/out/wgsl/quad_glsl.vert.wgsl @@ -1,6 +1,6 @@ struct VertexOutput { @location(0) v_uv: vec2, - @builtin(position) member: vec4, + @builtin(position) gl_Position: vec4, } const c_scale: f32 = 1.2f; diff --git a/naga/tests/out/wgsl/unnamed-gl-per-vertex.wgsl b/naga/tests/out/wgsl/unnamed-gl-per-vertex.wgsl new file mode 100644 index 0000000000..9f1b9ee607 --- /dev/null +++ b/naga/tests/out/wgsl/unnamed-gl-per-vertex.wgsl @@ -0,0 +1,25 @@ +struct type_4 { + @builtin(position) member: vec4, + member_1: f32, + member_2: array, + member_3: array, +} + +var global: type_4 = type_4(vec4(0f, 0f, 0f, 1f), 1f, array(), array()); +var global_1: i32; + +fn function() { + let _e9 = global_1; + global.member = vec4(select(1f, -4f, (_e9 == 0i)), select(-1f, 4f, (_e9 == 2i)), 0f, 1f); + return; +} + +@vertex +fn main(@builtin(vertex_index) param: u32) -> @builtin(position) vec4 { + global_1 = i32(param); + function(); + let _e6 = global.member.y; + global.member.y = -(_e6); + let _e8 = global.member; + return _e8; +} diff --git a/naga/tests/snapshots.rs b/naga/tests/snapshots.rs index 02dda1f45e..198a4aa2db 100644 --- a/naga/tests/snapshots.rs +++ b/naga/tests/snapshots.rs @@ -807,6 +807,10 @@ fn convert_wgsl() { "abstract-types-operators", Targets::SPIRV | Targets::METAL | Targets::GLSL | Targets::WGSL, ), + ( + "int64", + Targets::SPIRV | Targets::HLSL | Targets::WGSL | Targets::METAL, + ), ]; for &(name, targets) in inputs.iter() { @@ -886,6 +890,12 @@ fn convert_spv_all() { true, Targets::METAL | Targets::GLSL | Targets::HLSL | Targets::WGSL, ); + convert_spv( + "unnamed-gl-per-vertex", + true, + Targets::METAL | Targets::GLSL | Targets::HLSL | Targets::WGSL, + ); + convert_spv("builtin-accessed-outside-entrypoint", true, Targets::WGSL); } #[cfg(feature = "glsl-in")] diff --git a/naga/tests/spirv_capabilities.rs b/naga/tests/spirv_capabilities.rs index 35f24b7d69..82d7ef74bb 100644 --- a/naga/tests/spirv_capabilities.rs +++ b/naga/tests/spirv_capabilities.rs @@ -176,3 +176,35 @@ fn storage_image_formats() { "#, ); } + +#[test] +fn float64() { + require( + &[Ca::Float64], + r#" + fn f(x: f64) -> f64 { + return x; + } + "#, + ); +} + +#[test] +fn int64() { + require( + &[Ca::Int64], + r#" + fn f(x: i64) -> i64 { + return x; + } + "#, + ); + require( + &[Ca::Int64], + r#" + fn f(x: u64) -> u64 { + return x; + } + "#, + ); +} diff --git a/naga/tests/wgsl_errors.rs b/naga/tests/wgsl_errors.rs index 5624b3098e..46270b6650 100644 --- a/naga/tests/wgsl_errors.rs +++ b/naga/tests/wgsl_errors.rs @@ -870,7 +870,28 @@ fn matrix_constructor_inferred() { macro_rules! check_one_validation { ( $source:expr, $pattern:pat $( if $guard:expr )? ) => { let source = $source; - let error = validation_error($source); + let error = validation_error($source, naga::valid::Capabilities::default()); + #[allow(clippy::redundant_pattern_matching)] + if ! matches!(&error, $pattern $( if $guard )? ) { + eprintln!("validation error does not match pattern:\n\ + source code: {}\n\ + \n\ + actual result:\n\ + {:#?}\n\ + \n\ + expected match for pattern:\n\ + {}", + &source, + error, + stringify!($pattern)); + $( eprintln!("if {}", stringify!($guard)); )? + panic!("validation error does not match pattern"); + } + }; + ( $source:expr, $pattern:pat $( if $guard:expr )?, $capabilities:expr ) => { + let source = $source; + let error = validation_error($source, $capabilities); + #[allow(clippy::redundant_pattern_matching)] if ! matches!(&error, $pattern $( if $guard )? ) { eprintln!("validation error does not match pattern:\n\ source code: {}\n\ @@ -900,14 +921,27 @@ macro_rules! check_validation { check_one_validation!($source, $pattern); )* }; + ( $( $source:literal ),* : $pattern:pat, $capabilities:expr ) => { + $( + check_one_validation!($source, $pattern, $capabilities); + )* + }; ( $( $source:literal ),* : $pattern:pat if $guard:expr ) => { $( check_one_validation!($source, $pattern if $guard); )* + }; + ( $( $source:literal ),* : $pattern:pat if $guard:expr, $capabilities:expr ) => { + $( + check_one_validation!($source, $pattern if $guard, $capabilities); + )* } } -fn validation_error(source: &str) -> Result { +fn validation_error( + source: &str, + caps: naga::valid::Capabilities, +) -> Result { let module = match naga::front::wgsl::parse_str(source) { Ok(module) => module, Err(err) => { @@ -915,12 +949,21 @@ fn validation_error(source: &str) -> Result input: array;", + "var input: array, 2>;": + Err(naga::valid::ValidationError::GlobalVariable { + source: naga::valid::GlobalVariableError::Alignment(naga::AddressSpace::Uniform,_,_), + .. + }), + naga::valid::Capabilities::SHADER_INT64 + } + check_validation! { r#" fn main() -> f32 { diff --git a/naga/xtask/Cargo.lock b/naga/xtask/Cargo.lock index a1727a8970..122b2ded90 100644 --- a/naga/xtask/Cargo.lock +++ b/naga/xtask/Cargo.lock @@ -122,18 +122,18 @@ dependencies = [ [[package]] name = "nanoserde" -version = "0.1.32" +version = "0.1.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "755e7965536bc54d7c9fba2df5ada5bf835b0443fd613f0a53fa199a301839d3" +checksum = "5de9cf844ab1e25a0353525bd74cb889843a6215fa4a0d156fd446f4857a1b99" dependencies = [ "nanoserde-derive", ] [[package]] name = "nanoserde-derive" -version = "0.1.19" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed7a94da6c6181c35d043fc61c43ac96d3a5d739e7b8027f77650ba41504d6ab" +checksum = "e943b2c21337b7e3ec6678500687cdc741b7639ad457f234693352075c082204" [[package]] name = "num_cpus" diff --git a/player/tests/data/bind-group.ron b/player/tests/data/bind-group.ron index eacc36eb66..471f921fe9 100644 --- a/player/tests/data/bind-group.ron +++ b/player/tests/data/bind-group.ron @@ -56,7 +56,7 @@ layout: Some(Id(0, 1, Empty)), stage: ( module: Id(0, 1, Empty), - entry_point: "main", + entry_point: None, ), ), ), @@ -78,4 +78,4 @@ ), ]), ], -) \ No newline at end of file +) diff --git a/player/tests/data/pipeline-statistics-query.ron b/player/tests/data/pipeline-statistics-query.ron index 2565ee7376..8274e341f2 100644 --- a/player/tests/data/pipeline-statistics-query.ron +++ b/player/tests/data/pipeline-statistics-query.ron @@ -29,7 +29,7 @@ layout: Some(Id(0, 1, Empty)), stage: ( module: Id(0, 1, Empty), - entry_point: "main", + entry_point: None, ), ), ), diff --git a/player/tests/data/quad.ron b/player/tests/data/quad.ron index 68bf8ee97e..b7db1f8c24 100644 --- a/player/tests/data/quad.ron +++ b/player/tests/data/quad.ron @@ -57,14 +57,14 @@ vertex: ( stage: ( module: Id(0, 1, Empty), - entry_point: "vs_main", + entry_point: None, ), buffers: [], ), fragment: Some(( stage: ( module: Id(0, 1, Empty), - entry_point: "fs_main", + entry_point: None, ), targets: [ Some(( diff --git a/player/tests/data/zero-init-buffer.ron b/player/tests/data/zero-init-buffer.ron index 73692d10ee..be9a20d898 100644 --- a/player/tests/data/zero-init-buffer.ron +++ b/player/tests/data/zero-init-buffer.ron @@ -133,7 +133,7 @@ layout: Some(Id(0, 1, Empty)), stage: ( module: Id(0, 1, Empty), - entry_point: "main", + entry_point: None, ), ), ), diff --git a/player/tests/data/zero-init-texture-binding.ron b/player/tests/data/zero-init-texture-binding.ron index 7dcfa4e2e6..41a513f60f 100644 --- a/player/tests/data/zero-init-texture-binding.ron +++ b/player/tests/data/zero-init-texture-binding.ron @@ -134,7 +134,7 @@ layout: Some(Id(0, 1, Empty)), stage: ( module: Id(0, 1, Empty), - entry_point: "main", + entry_point: None, ), ), ), diff --git a/rust-toolchain.toml b/rust-toolchain.toml index dde5f402a2..642513ae4e 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -5,6 +5,6 @@ # to the user in the error, instead of "error: invalid channel name '[toolchain]'". [toolchain] -channel = "1.71" # Needed for deno & cts_runner. Firefox's MSRV is 1.70 +channel = "1.76" # Needed for deno & cts_runner. Firefox's MSRV is 1.74 components = ["rustfmt", "clippy"] targets = ["wasm32-unknown-unknown"] diff --git a/tests/src/lib.rs b/tests/src/lib.rs index 08f464e5aa..9df1edfd76 100644 --- a/tests/src/lib.rs +++ b/tests/src/lib.rs @@ -1,5 +1,7 @@ //! Test utilities for the wgpu repository. +#![allow(clippy::arc_with_non_send_sync)] // False positive on wasm + mod config; mod expectations; pub mod image; diff --git a/tests/tests/bind_group_layout_dedup.rs b/tests/tests/bind_group_layout_dedup.rs index 8da284b41b..7ac30fb8fe 100644 --- a/tests/tests/bind_group_layout_dedup.rs +++ b/tests/tests/bind_group_layout_dedup.rs @@ -1,9 +1,6 @@ use std::num::NonZeroU64; -use wgpu_test::{ - fail, gpu_test, FailureCase, GpuTestConfiguration, TestParameters, TestingContext, -}; -use wgt::Backends; +use wgpu_test::{fail, gpu_test, GpuTestConfiguration, TestParameters, TestingContext}; const SHADER_SRC: &str = " @group(0) @binding(0) @@ -131,8 +128,12 @@ async fn bgl_dedupe(ctx: TestingContext) { .panic_on_timeout(); if ctx.adapter_info.backend != wgt::Backend::BrowserWebGpu { + // Indices are made reusable as soon as the handle is dropped so we keep them around + // for the duration of the loop. + let mut bgls = Vec::new(); + let mut indices = Vec::new(); // Now all of the BGL ids should be dead, so we should get the same ids again. - for i in 0..=2 { + for _ in 0..=2 { let test_bgl = ctx .device .create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor { @@ -141,15 +142,14 @@ async fn bgl_dedupe(ctx: TestingContext) { }); let test_bgl_idx = test_bgl.global_id().inner() & 0xFFFF_FFFF; - - // https://github.com/gfx-rs/wgpu/issues/4912 - // - // ID 2 is the deduplicated ID, which is never properly recycled. - if i == 2 { - assert_eq!(test_bgl_idx, 3); - } else { - assert_eq!(test_bgl_idx, i); - } + bgls.push(test_bgl); + indices.push(test_bgl_idx); + } + // We don't guarantee that the IDs will appear in the same order. Sort them + // and check that they all appear exactly once. + indices.sort(); + for (i, index) in indices.iter().enumerate() { + assert_eq!(*index, i as u64); } } } @@ -307,18 +307,10 @@ fn bgl_dedupe_derived(ctx: TestingContext) { ctx.queue.submit(Some(encoder.finish())); } -const DX12_VALIDATION_ERROR: &str = "The command allocator cannot be reset because a command list is currently being recorded with the allocator."; - #[gpu_test] static SEPARATE_PROGRAMS_HAVE_INCOMPATIBLE_DERIVED_BGLS: GpuTestConfiguration = GpuTestConfiguration::new() - .parameters( - TestParameters::default() - .test_features_limits() - .expect_fail( - FailureCase::backend(Backends::DX12).validation_error(DX12_VALIDATION_ERROR), - ), - ) + .parameters(TestParameters::default().test_features_limits()) .run_sync(separate_programs_have_incompatible_derived_bgls); fn separate_programs_have_incompatible_derived_bgls(ctx: TestingContext) { @@ -376,13 +368,7 @@ fn separate_programs_have_incompatible_derived_bgls(ctx: TestingContext) { #[gpu_test] static DERIVED_BGLS_INCOMPATIBLE_WITH_REGULAR_BGLS: GpuTestConfiguration = GpuTestConfiguration::new() - .parameters( - TestParameters::default() - .test_features_limits() - .expect_fail( - FailureCase::backend(Backends::DX12).validation_error(DX12_VALIDATION_ERROR), - ), - ) + .parameters(TestParameters::default().test_features_limits()) .run_sync(derived_bgls_incompatible_with_regular_bgls); fn derived_bgls_incompatible_with_regular_bgls(ctx: TestingContext) { diff --git a/tests/tests/buffer.rs b/tests/tests/buffer.rs index 23f244c249..a5fcf3e595 100644 --- a/tests/tests/buffer.rs +++ b/tests/tests/buffer.rs @@ -326,3 +326,62 @@ static MINIMUM_BUFFER_BINDING_SIZE_DISPATCH: GpuTestConfiguration = GpuTestConfi let _ = encoder.finish(); }); }); + +#[gpu_test] +static CLEAR_OFFSET_OUTSIDE_RESOURCE_BOUNDS: GpuTestConfiguration = GpuTestConfiguration::new() + .parameters(TestParameters::default()) + .run_sync(|ctx| { + let size = 16; + + let buffer = ctx.device.create_buffer(&wgpu::BufferDescriptor { + label: None, + size, + usage: wgpu::BufferUsages::COPY_DST, + mapped_at_creation: false, + }); + + let out_of_bounds = size.checked_add(wgpu::COPY_BUFFER_ALIGNMENT).unwrap(); + + ctx.device.push_error_scope(wgpu::ErrorFilter::Validation); + ctx.device + .create_command_encoder(&Default::default()) + .clear_buffer(&buffer, out_of_bounds, None); + let err_msg = pollster::block_on(ctx.device.pop_error_scope()) + .unwrap() + .to_string(); + assert!(err_msg.contains( + "Clear of 20..20 would end up overrunning the bounds of the buffer of size 16" + )); + }); + +#[gpu_test] +static CLEAR_OFFSET_PLUS_SIZE_OUTSIDE_U64_BOUNDS: GpuTestConfiguration = + GpuTestConfiguration::new() + .parameters(TestParameters::default()) + .run_sync(|ctx| { + let buffer = ctx.device.create_buffer(&wgpu::BufferDescriptor { + label: None, + size: 16, // unimportant for this test + usage: wgpu::BufferUsages::COPY_DST, + mapped_at_creation: false, + }); + + let max_valid_offset = u64::MAX - (u64::MAX % wgpu::COPY_BUFFER_ALIGNMENT); + let smallest_aligned_invalid_size = wgpu::COPY_BUFFER_ALIGNMENT; + + ctx.device.push_error_scope(wgpu::ErrorFilter::Validation); + ctx.device + .create_command_encoder(&Default::default()) + .clear_buffer( + &buffer, + max_valid_offset, + Some(smallest_aligned_invalid_size), + ); + let err_msg = pollster::block_on(ctx.device.pop_error_scope()) + .unwrap() + .to_string(); + assert!(err_msg.contains(concat!( + "Clear starts at offset 18446744073709551612 with size of 4, ", + "but these added together exceed `u64::MAX`" + ))); + }); diff --git a/tests/tests/clear_texture.rs b/tests/tests/clear_texture.rs index 3e7484ab56..175c642b93 100644 --- a/tests/tests/clear_texture.rs +++ b/tests/tests/clear_texture.rs @@ -375,6 +375,7 @@ static CLEAR_TEXTURE_DEPTH32_STENCIL8: GpuTestConfiguration = GpuTestConfigurati .parameters( TestParameters::default() .features(wgpu::Features::CLEAR_TEXTURE | wgpu::Features::DEPTH32FLOAT_STENCIL8) + .downlevel_flags(wgpu::DownlevelFlags::DEPTH_TEXTURE_AND_BUFFER_COPIES) // https://github.com/gfx-rs/wgpu/issues/5016 .skip(FailureCase::adapter("Apple Paravirtual device")), ) diff --git a/tests/tests/device.rs b/tests/tests/device.rs index 5d3a102234..ff596d0918 100644 --- a/tests/tests/device.rs +++ b/tests/tests/device.rs @@ -1,3 +1,5 @@ +use std::sync::atomic::AtomicBool; + use wgpu_test::{fail, gpu_test, FailureCase, GpuTestConfiguration, TestParameters}; #[gpu_test] @@ -29,39 +31,69 @@ static CROSS_DEVICE_BIND_GROUP_USAGE: GpuTestConfiguration = GpuTestConfiguratio }); #[cfg(not(all(target_arch = "wasm32", not(target_os = "emscripten"))))] -#[test] -fn device_lifetime_check() { - use pollster::FutureExt as _; - - env_logger::init(); - let instance = wgpu::Instance::new(wgpu::InstanceDescriptor { - backends: wgpu::util::backend_bits_from_env().unwrap_or(wgpu::Backends::all()), - dx12_shader_compiler: wgpu::util::dx12_shader_compiler_from_env().unwrap_or_default(), - gles_minor_version: wgpu::util::gles_minor_version_from_env().unwrap_or_default(), - flags: wgpu::InstanceFlags::debugging().with_env(), - }); +#[gpu_test] +static DEVICE_LIFETIME_CHECK: GpuTestConfiguration = GpuTestConfiguration::new() + .parameters(TestParameters::default()) + .run_sync(|_| { + use pollster::FutureExt as _; + + let instance = wgpu::Instance::new(wgpu::InstanceDescriptor { + backends: wgpu::util::backend_bits_from_env().unwrap_or(wgpu::Backends::all()), + dx12_shader_compiler: wgpu::util::dx12_shader_compiler_from_env().unwrap_or_default(), + gles_minor_version: wgpu::util::gles_minor_version_from_env().unwrap_or_default(), + flags: wgpu::InstanceFlags::advanced_debugging().with_env(), + }); - let adapter = wgpu::util::initialize_adapter_from_env_or_default(&instance, None) - .block_on() - .expect("failed to create adapter"); + let adapter = wgpu::util::initialize_adapter_from_env_or_default(&instance, None) + .block_on() + .expect("failed to create adapter"); - let (device, queue) = adapter - .request_device(&wgpu::DeviceDescriptor::default(), None) - .block_on() - .expect("failed to create device"); + let (device, queue) = adapter + .request_device(&wgpu::DeviceDescriptor::default(), None) + .block_on() + .expect("failed to create device"); - instance.poll_all(false); + instance.poll_all(false); - let pre_report = instance.generate_report().unwrap().unwrap(); + let pre_report = instance.generate_report().unwrap(); - drop(queue); - drop(device); - let post_report = instance.generate_report().unwrap().unwrap(); - assert_ne!( - pre_report, post_report, - "Queue and Device has not been dropped as expected" - ); -} + drop(queue); + drop(device); + let post_report = instance.generate_report().unwrap(); + assert_ne!( + pre_report, post_report, + "Queue and Device has not been dropped as expected" + ); + }); + +#[cfg(not(all(target_arch = "wasm32", not(target_os = "emscripten"))))] +#[gpu_test] +static MULTIPLE_DEVICES: GpuTestConfiguration = GpuTestConfiguration::new() + .parameters(TestParameters::default()) + .run_sync(|_| { + use pollster::FutureExt as _; + + fn create_device_and_queue() -> (wgpu::Device, wgpu::Queue) { + let instance = wgpu::Instance::new(wgpu::InstanceDescriptor { + backends: wgpu::util::backend_bits_from_env().unwrap_or(wgpu::Backends::all()), + dx12_shader_compiler: wgpu::util::dx12_shader_compiler_from_env() + .unwrap_or_default(), + gles_minor_version: wgpu::util::gles_minor_version_from_env().unwrap_or_default(), + flags: wgpu::InstanceFlags::advanced_debugging().with_env(), + }); + + let adapter = wgpu::util::initialize_adapter_from_env_or_default(&instance, None) + .block_on() + .expect("failed to create adapter"); + + adapter + .request_device(&wgpu::DeviceDescriptor::default(), None) + .block_on() + .expect("failed to create device") + } + + let _ = vec![create_device_and_queue(), create_device_and_queue()]; + }); #[cfg(not(all(target_arch = "wasm32", not(target_os = "emscripten"))))] #[gpu_test] @@ -488,12 +520,11 @@ static DEVICE_DESTROY_THEN_LOST: GpuTestConfiguration = GpuTestConfiguration::ne .run_async(|ctx| async move { // This test checks that when device.destroy is called, the provided // DeviceLostClosure is called with reason DeviceLostReason::Destroyed. - let was_called = std::sync::Arc::::new(false.into()); + static WAS_CALLED: AtomicBool = AtomicBool::new(false); // Set a LoseDeviceCallback on the device. - let was_called_clone = was_called.clone(); - let callback = Box::new(move |reason, _m| { - was_called_clone.store(true, std::sync::atomic::Ordering::SeqCst); + let callback = Box::new(|reason, _m| { + WAS_CALLED.store(true, std::sync::atomic::Ordering::SeqCst); assert!( matches!(reason, wgt::DeviceLostReason::Destroyed), "Device lost info reason should match DeviceLostReason::Destroyed." @@ -512,7 +543,7 @@ static DEVICE_DESTROY_THEN_LOST: GpuTestConfiguration = GpuTestConfiguration::ne .is_queue_empty()); assert!( - was_called.load(std::sync::atomic::Ordering::SeqCst), + WAS_CALLED.load(std::sync::atomic::Ordering::SeqCst), "Device lost callback should have been called." ); }); @@ -524,20 +555,13 @@ static DEVICE_DROP_THEN_LOST: GpuTestConfiguration = GpuTestConfiguration::new() // This test checks that when the device is dropped (such as in a GC), // the provided DeviceLostClosure is called with reason DeviceLostReason::Unknown. // Fails on webgl because webgl doesn't implement drop. - let was_called = std::sync::Arc::::new(false.into()); + static WAS_CALLED: std::sync::atomic::AtomicBool = AtomicBool::new(false); // Set a LoseDeviceCallback on the device. - let was_called_clone = was_called.clone(); - let callback = Box::new(move |reason, message| { - was_called_clone.store(true, std::sync::atomic::Ordering::SeqCst); - assert!( - matches!(reason, wgt::DeviceLostReason::Dropped), - "Device lost info reason should match DeviceLostReason::Dropped." - ); - assert!( - message == "Device dropped.", - "Device lost info message should be \"Device dropped.\"." - ); + let callback = Box::new(|reason, message| { + WAS_CALLED.store(true, std::sync::atomic::Ordering::SeqCst); + assert_eq!(reason, wgt::DeviceLostReason::Dropped); + assert_eq!(message, "Device dropped."); }); ctx.device.set_device_lost_callback(callback); @@ -545,7 +569,34 @@ static DEVICE_DROP_THEN_LOST: GpuTestConfiguration = GpuTestConfiguration::new() drop(ctx.device); assert!( - was_called.load(std::sync::atomic::Ordering::SeqCst), + WAS_CALLED.load(std::sync::atomic::Ordering::SeqCst), + "Device lost callback should have been called." + ); + }); + +#[gpu_test] +static DEVICE_INVALID_THEN_SET_LOST_CALLBACK: GpuTestConfiguration = GpuTestConfiguration::new() + .parameters(TestParameters::default().expect_fail(FailureCase::webgl2())) + .run_sync(|ctx| { + // This test checks that when the device is invalid, a subsequent call + // to set the device lost callback will immediately call the callback. + // Invalidating the device is done via a testing-only method. Fails on + // webgl because webgl doesn't implement make_invalid. + + // Make the device invalid. + ctx.device.make_invalid(); + + static WAS_CALLED: AtomicBool = AtomicBool::new(false); + + // Set a LoseDeviceCallback on the device. + let callback = Box::new(|reason, _m| { + WAS_CALLED.store(true, std::sync::atomic::Ordering::SeqCst); + assert_eq!(reason, wgt::DeviceLostReason::DeviceInvalid); + }); + ctx.device.set_device_lost_callback(callback); + + assert!( + WAS_CALLED.load(std::sync::atomic::Ordering::SeqCst), "Device lost callback should have been called." ); }); @@ -556,16 +607,12 @@ static DEVICE_LOST_REPLACED_CALLBACK: GpuTestConfiguration = GpuTestConfiguratio .run_sync(|ctx| { // This test checks that a device_lost_callback is called when it is // replaced by another callback. - let was_called = std::sync::Arc::::new(false.into()); + static WAS_CALLED: AtomicBool = AtomicBool::new(false); // Set a LoseDeviceCallback on the device. - let was_called_clone = was_called.clone(); - let callback = Box::new(move |reason, _m| { - was_called_clone.store(true, std::sync::atomic::Ordering::SeqCst); - assert!( - matches!(reason, wgt::DeviceLostReason::ReplacedCallback), - "Device lost info reason should match DeviceLostReason::ReplacedCallback." - ); + let callback = Box::new(|reason, _m| { + WAS_CALLED.store(true, std::sync::atomic::Ordering::SeqCst); + assert_eq!(reason, wgt::DeviceLostReason::ReplacedCallback); }); ctx.device.set_device_lost_callback(callback); @@ -574,7 +621,7 @@ static DEVICE_LOST_REPLACED_CALLBACK: GpuTestConfiguration = GpuTestConfiguratio ctx.device.set_device_lost_callback(replacement_callback); assert!( - was_called.load(std::sync::atomic::Ordering::SeqCst), + WAS_CALLED.load(std::sync::atomic::Ordering::SeqCst), "Device lost callback should have been called." ); }); @@ -589,21 +636,13 @@ static DROPPED_GLOBAL_THEN_DEVICE_LOST: GpuTestConfiguration = GpuTestConfigurat // wgpu without providing a more orderly shutdown. In such a case, the // device lost callback should be invoked with the message "Device is // dying." - let was_called = std::sync::Arc::::new(false.into()); + static WAS_CALLED: AtomicBool = AtomicBool::new(false); // Set a LoseDeviceCallback on the device. - let was_called_clone = was_called.clone(); - let callback = Box::new(move |reason, message| { - was_called_clone.store(true, std::sync::atomic::Ordering::SeqCst); - assert!( - matches!(reason, wgt::DeviceLostReason::Dropped), - "Device lost info reason should match DeviceLostReason::Dropped." - ); - assert!( - message == "Device is dying.", - "Device lost info message is \"{}\" and it should be \"Device is dying.\".", - message - ); + let callback = Box::new(|reason, message| { + WAS_CALLED.store(true, std::sync::atomic::Ordering::SeqCst); + assert_eq!(reason, wgt::DeviceLostReason::Dropped); + assert_eq!(message, "Device is dying."); }); ctx.device.set_device_lost_callback(callback); @@ -611,7 +650,168 @@ static DROPPED_GLOBAL_THEN_DEVICE_LOST: GpuTestConfiguration = GpuTestConfigurat // Confirm that the callback was invoked. assert!( - was_called.load(std::sync::atomic::Ordering::SeqCst), + WAS_CALLED.load(std::sync::atomic::Ordering::SeqCst), "Device lost callback should have been called." ); }); + +#[gpu_test] +static DIFFERENT_BGL_ORDER_BW_SHADER_AND_API: GpuTestConfiguration = GpuTestConfiguration::new() + .parameters(TestParameters::default()) + .run_sync(|ctx| { + // This test addresses a bug found in multiple backends where `wgpu_core` and `wgpu_hal` + // backends made different assumptions about the element order of vectors of bind group + // layout entries and bind group resource bindings. + // + // Said bug was exposed originally by: + // + // 1. Shader-declared bindings having a different order than resource bindings provided to + // `Device::create_bind_group`. + // 2. Having more of one type of resource in the bind group than another. + // + // …such that internals would accidentally attempt to use an out-of-bounds index (of one + // resource type) in the wrong list of a different resource type. Let's reproduce that + // here. + + let trivial_shaders_with_some_reversed_bindings = "\ +@group(0) @binding(3) var myTexture2: texture_2d; +@group(0) @binding(2) var myTexture1: texture_2d; +@group(0) @binding(1) var mySampler: sampler; + +@fragment +fn fs_main(@builtin(position) pos: vec4) -> @location(0) vec4f { + return textureSample(myTexture1, mySampler, pos.xy) + textureSample(myTexture2, mySampler, pos.xy); +} + +@vertex +fn vs_main() -> @builtin(position) vec4 { + return vec4(0.0, 0.0, 0.0, 1.0); +} +"; + + let trivial_shaders_with_some_reversed_bindings = + ctx.device + .create_shader_module(wgpu::ShaderModuleDescriptor { + label: None, + source: wgpu::ShaderSource::Wgsl( + trivial_shaders_with_some_reversed_bindings.into(), + ), + }); + + let my_texture = ctx.device.create_texture(&wgt::TextureDescriptor { + label: None, + size: wgt::Extent3d { + width: 1024, + height: 512, + depth_or_array_layers: 1, + }, + mip_level_count: 1, + sample_count: 1, + dimension: wgt::TextureDimension::D2, + format: wgt::TextureFormat::Rgba8Unorm, + usage: wgt::TextureUsages::RENDER_ATTACHMENT | wgt::TextureUsages::TEXTURE_BINDING, + view_formats: &[], + }); + + let my_texture_view = my_texture.create_view(&wgpu::TextureViewDescriptor { + label: None, + format: None, + dimension: None, + aspect: wgt::TextureAspect::All, + base_mip_level: 0, + mip_level_count: None, + base_array_layer: 0, + array_layer_count: None, + }); + + let my_sampler = ctx + .device + .create_sampler(&wgpu::SamplerDescriptor::default()); + + let render_pipeline = ctx + .device + .create_render_pipeline(&wgpu::RenderPipelineDescriptor { + fragment: Some(wgpu::FragmentState { + module: &trivial_shaders_with_some_reversed_bindings, + entry_point: "fs_main", + targets: &[Some(wgt::ColorTargetState { + format: wgt::TextureFormat::Bgra8Unorm, + blend: None, + write_mask: wgt::ColorWrites::ALL, + })], + }), + layout: None, + + // Other fields below aren't interesting for this text. + label: None, + vertex: wgpu::VertexState { + module: &trivial_shaders_with_some_reversed_bindings, + entry_point: "vs_main", + buffers: &[], + }, + primitive: wgt::PrimitiveState::default(), + depth_stencil: None, + multisample: wgt::MultisampleState::default(), + multiview: None, + }); + + // fail(&ctx.device, || { + // }, ""); + ctx.device.create_bind_group(&wgpu::BindGroupDescriptor { + label: None, + layout: &render_pipeline.get_bind_group_layout(0), + entries: &[ + wgpu::BindGroupEntry { + binding: 1, + resource: wgpu::BindingResource::Sampler(&my_sampler), + }, + wgpu::BindGroupEntry { + binding: 2, + resource: wgpu::BindingResource::TextureView(&my_texture_view), + }, + wgpu::BindGroupEntry { + binding: 3, + resource: wgpu::BindingResource::TextureView(&my_texture_view), + }, + ], + }); + }); + +#[gpu_test] +static DEVICE_DESTROY_THEN_BUFFER_CLEANUP: GpuTestConfiguration = GpuTestConfiguration::new() + .parameters(TestParameters::default()) + .run_sync(|ctx| { + // When a device is destroyed, its resources should be released, + // without causing a deadlock. + + // Create a buffer to be left around until the device is destroyed. + let _buffer = ctx.device.create_buffer(&wgpu::BufferDescriptor { + label: None, + size: 256, + usage: wgpu::BufferUsages::MAP_READ, + mapped_at_creation: false, + }); + + // Create a texture to be left around until the device is destroyed. + let texture_extent = wgpu::Extent3d { + width: 512, + height: 512, + depth_or_array_layers: 1, + }; + let _texture = ctx.device.create_texture(&wgpu::TextureDescriptor { + label: None, + size: texture_extent, + mip_level_count: 2, + sample_count: 1, + dimension: wgpu::TextureDimension::D2, + format: wgpu::TextureFormat::Rg8Uint, + usage: wgpu::TextureUsages::RENDER_ATTACHMENT, + view_formats: &[], + }); + + // Destroy the device. + ctx.device.destroy(); + + // Poll the device, which should try to clean up its resources. + ctx.instance.poll_all(true); + }); diff --git a/tests/tests/encoder.rs b/tests/tests/encoder.rs index 4e0c61a896..3858e3d070 100644 --- a/tests/tests/encoder.rs +++ b/tests/tests/encoder.rs @@ -21,16 +21,9 @@ static DROP_QUEUE_BEFORE_CREATING_COMMAND_ENCODER: GpuTestConfiguration = device.create_command_encoder(&wgpu::CommandEncoderDescriptor::default()); }); -// This test crashes on DX12 with the exception: -// -// ID3D12CommandAllocator::Reset: The command allocator cannot be reset because a -// command list is currently being recorded with the allocator. [ EXECUTION ERROR -// #543: COMMAND_ALLOCATOR_CANNOT_RESET] -// -// For now, we mark the test as failing on DX12. #[gpu_test] static DROP_ENCODER_AFTER_ERROR: GpuTestConfiguration = GpuTestConfiguration::new() - .parameters(TestParameters::default().expect_fail(FailureCase::backend(wgpu::Backends::DX12))) + .parameters(TestParameters::default()) .run_sync(|ctx| { let mut encoder = ctx .device diff --git a/tests/tests/mem_leaks.rs b/tests/tests/mem_leaks.rs index 91a329d20c..83fa2bbc11 100644 --- a/tests/tests/mem_leaks.rs +++ b/tests/tests/mem_leaks.rs @@ -127,7 +127,7 @@ async fn draw_test_with_reports( let global_report = ctx.instance.generate_report().unwrap(); let report = global_report.hub_report(ctx.adapter_info.backend); - assert_eq!(report.shader_modules.num_allocated, 1); + assert_eq!(report.shader_modules.num_allocated, 0); assert_eq!(report.shader_modules.num_kept_from_user, 0); assert_eq!(report.textures.num_allocated, 0); assert_eq!(report.texture_views.num_allocated, 0); @@ -166,7 +166,7 @@ async fn draw_test_with_reports( assert_eq!(report.buffers.num_allocated, 1); assert_eq!(report.texture_views.num_allocated, 1); assert_eq!(report.texture_views.num_kept_from_user, 1); - assert_eq!(report.textures.num_allocated, 1); + assert_eq!(report.textures.num_allocated, 0); assert_eq!(report.textures.num_kept_from_user, 0); let mut encoder = ctx @@ -204,7 +204,7 @@ async fn draw_test_with_reports( assert_eq!(report.command_buffers.num_allocated, 1); assert_eq!(report.render_bundles.num_allocated, 0); assert_eq!(report.texture_views.num_allocated, 1); - assert_eq!(report.textures.num_allocated, 1); + assert_eq!(report.textures.num_allocated, 0); function(&mut rpass); @@ -227,19 +227,20 @@ async fn draw_test_with_reports( assert_eq!(report.texture_views.num_kept_from_user, 0); assert_eq!(report.textures.num_kept_from_user, 0); assert_eq!(report.command_buffers.num_allocated, 1); - assert_eq!(report.render_pipelines.num_allocated, 1); - assert_eq!(report.pipeline_layouts.num_allocated, 1); - assert_eq!(report.bind_group_layouts.num_allocated, 1); - assert_eq!(report.bind_groups.num_allocated, 1); - assert_eq!(report.buffers.num_allocated, 1); - assert_eq!(report.texture_views.num_allocated, 1); - assert_eq!(report.textures.num_allocated, 1); + assert_eq!(report.render_pipelines.num_allocated, 0); + assert_eq!(report.pipeline_layouts.num_allocated, 0); + assert_eq!(report.bind_group_layouts.num_allocated, 0); + assert_eq!(report.bind_groups.num_allocated, 0); + assert_eq!(report.buffers.num_allocated, 0); + assert_eq!(report.texture_views.num_allocated, 0); + assert_eq!(report.textures.num_allocated, 0); let submit_index = ctx.queue.submit(Some(encoder.finish())); - let global_report = ctx.instance.generate_report().unwrap(); - let report = global_report.hub_report(ctx.adapter_info.backend); - assert_eq!(report.command_buffers.num_allocated, 0); + // TODO: fix in https://github.com/gfx-rs/wgpu/pull/5141 + // let global_report = ctx.instance.generate_report().unwrap(); + // let report = global_report.hub_report(ctx.adapter_info.backend); + // assert_eq!(report.command_buffers.num_allocated, 0); ctx.async_poll(wgpu::Maintain::wait_for(submit_index)) .await diff --git a/tests/tests/shader/numeric_builtins.rs b/tests/tests/shader/numeric_builtins.rs index 26c2a89d92..999d9dfb0c 100644 --- a/tests/tests/shader/numeric_builtins.rs +++ b/tests/tests/shader/numeric_builtins.rs @@ -21,7 +21,7 @@ fn create_numeric_builtin_test() -> Vec { for &(input, low, high, output) in clamp_values { let mut test = ShaderTest::new( - format!("clamp({input}, 0.0, 10.0) == {output:?})"), + format!("clamp({input}, {low}, {high}) == {output:?}"), String::from("value: f32, low: f32, high: f32"), String::from("output[0] = bitcast(clamp(input.value, input.low, input.high));"), &[input, low, high], @@ -51,3 +51,112 @@ static NUMERIC_BUILTINS: GpuTestConfiguration = GpuTestConfiguration::new() create_numeric_builtin_test(), ) }); + +// See https://github.com/gfx-rs/wgpu/issues/5276 +/* +fn create_int64_polyfill_test() -> Vec { + let mut tests = Vec::new(); + + let u64_clz_values: &[(u64, u32)] = &[ + (u64::MAX, 0), + (1, 63), + (2, 62), + (3, 62), + (1 << 63, 0), + (1 << 62, 1), + (0, 64), + ]; + + for &(input, output) in u64_clz_values { + let test = ShaderTest::new( + format!("countLeadingZeros({input}lu) == {output:?}"), + String::from("value: u64"), + String::from("output[0] = u32(countLeadingZeros(input.value));"), + &[input], + &[output], + ); + + tests.push(test); + } + + let i64_clz_values: &[(i64, u32)] = &[ + (i64::MAX, 1), + (i64::MIN, 0), + (1, 63), + (1 << 62, 1), + (-1 << 62, 0), + (0, 64), + (-1, 0), + ]; + + for &(input, output) in i64_clz_values { + let test = ShaderTest::new( + format!("countLeadingZeros({input}li) == {output:?}"), + String::from("value: i64"), + String::from("output[0] = u32(countLeadingZeros(input.value));"), + &[input], + &[output], + ); + + tests.push(test); + } + + let u64_flb_values: &[(u64, u32)] = &[ + (u64::MAX, 63), + (1, 0), + (2, 1), + (3, 1), + (1 << 63, 63), + (1 << 62, 62), + (0, u32::MAX), + ]; + + for &(input, output) in u64_flb_values { + let test = ShaderTest::new( + format!("firstLeadingBit({input}lu) == {output:?}"), + String::from("value: u64"), + String::from("output[0] = u32(firstLeadingBit(input.value));"), + &[input], + &[output], + ); + + tests.push(test); + } + + let i64_flb_values: &[(i64, u32)] = &[ + (i64::MAX, 62), + (i64::MIN, 62), + (1, 0), + (1 << 62, 62), + (-1 << 62, 61), + (0, u32::MAX), + (-1, u32::MAX), + ]; + + for &(input, output) in i64_flb_values { + let test = ShaderTest::new( + format!("firstLeadingBit({input}li) == {output:?}"), + String::from("value: i64"), + String::from("output[0] = u32(firstLeadingBit(input.value));"), + &[input], + &[output], + ); + + tests.push(test); + } + + tests +} + +#[gpu_test] +static INT64_POLYFILL: GpuTestConfiguration = GpuTestConfiguration::new() + .parameters( + TestParameters::default() + .features(Features::SHADER_INT64) + .downlevel_flags(DownlevelFlags::COMPUTE_SHADERS) + .limits(Limits::downlevel_defaults()), + ) + .run_async(|ctx| { + shader_input_output_test(ctx, InputStorageType::Storage, create_int64_polyfill_test()) + }); +*/ diff --git a/tests/tests/shader/struct_layout.rs b/tests/tests/shader/struct_layout.rs index f5acde971c..38a040fcad 100644 --- a/tests/tests/shader/struct_layout.rs +++ b/tests/tests/shader/struct_layout.rs @@ -155,6 +155,40 @@ fn create_struct_layout_tests(storage_type: InputStorageType) -> Vec )); } + // Test for https://github.com/gfx-rs/wgpu/issues/5262. + // + // The struct is supposed to have a size of 32 and alignment of 16, but on metal, it has size 24. + for ty in ["f32", "u32", "i32"] { + let header = format!("struct Inner {{ vec: vec3<{ty}>, scalar1: u32, scalar2: u32 }}"); + let members = String::from("arr: array"); + let direct = String::from( + "\ + output[0] = bitcast(input.arr[0].vec.x); + output[1] = bitcast(input.arr[0].vec.y); + output[2] = bitcast(input.arr[0].vec.z); + output[3] = bitcast(input.arr[0].scalar1); + output[4] = bitcast(input.arr[0].scalar2); + output[5] = bitcast(input.arr[1].vec.x); + output[6] = bitcast(input.arr[1].vec.y); + output[7] = bitcast(input.arr[1].vec.z); + output[8] = bitcast(input.arr[1].scalar1); + output[9] = bitcast(input.arr[1].scalar2); + ", + ); + + tests.push( + ShaderTest::new( + format!("Alignment of 24 byte struct with a vec3<{ty}>"), + members, + direct, + &input_values, + &[0, 1, 2, 3, 4, 8, 9, 10, 11, 12], + ) + .header(header) + .failures(Backends::METAL), + ); + } + // Mat3 alignment tests for ty in ["f32", "u32", "i32"] { for columns in [2, 3, 4] { @@ -219,6 +253,108 @@ fn create_struct_layout_tests(storage_type: InputStorageType) -> Vec tests } +fn create_64bit_struct_layout_tests() -> Vec { + let input_values: Vec<_> = (0..(MAX_BUFFER_SIZE as u32 / 4)).collect(); + + let mut tests = Vec::new(); + + // 64 bit alignment tests + for ty in ["u64", "i64"] { + let members = format!("scalar: {ty},"); + let direct = String::from( + "\ + output[0] = u32(bitcast(input.scalar) & 0xFFFFFFFF); + output[1] = u32((bitcast(input.scalar) >> 32) & 0xFFFFFFFF); + ", + ); + + tests.push(ShaderTest::new( + format!("{ty} alignment"), + members, + direct, + &input_values, + &[0, 1], + )); + } + + // Nested struct and array test. + // + // This tries to exploit all the weird edge cases of the struct layout algorithm. + // We dont go as all-out as the other nested struct test because + // all our primitives are twice as wide and we have only so much buffer to spare. + { + let header = String::from( + "struct Inner { scalar: u64, scalar32: u32, member: array, 2> }", + ); + let members = String::from("inner: Inner"); + let direct = String::from( + "\ + output[0] = u32(bitcast(input.inner.scalar) & 0xFFFFFFFF); + output[1] = u32((bitcast(input.inner.scalar) >> 32) & 0xFFFFFFFF); + output[2] = bitcast(input.inner.scalar32); + for (var index = 0u; index < 2u; index += 1u) { + for (var component = 0u; component < 3u; component += 1u) { + output[3 + index * 6 + component * 2] = u32(bitcast(input.inner.member[index][component]) & 0xFFFFFFFF); + output[4 + index * 6 + component * 2] = u32((bitcast(input.inner.member[index][component]) >> 32) & 0xFFFFFFFF); + } + } + ", + ); + + tests.push( + ShaderTest::new( + String::from("nested struct and array"), + members, + direct, + &input_values, + &[ + 0, 1, // inner.scalar + 2, // inner.scalar32 + 8, 9, 10, 11, 12, 13, // inner.member[0] + 16, 17, 18, 19, 20, 21, // inner.member[1] + ], + ) + .header(header), + ); + } + { + let header = String::from("struct Inner { scalar32: u32, scalar: u64, scalar32_2: u32 }"); + let members = String::from("inner: Inner, vector: vec3"); + let direct = String::from( + "\ + output[0] = bitcast(input.inner.scalar32); + output[1] = u32(bitcast(input.inner.scalar) & 0xFFFFFFFF); + output[2] = u32((bitcast(input.inner.scalar) >> 32) & 0xFFFFFFFF); + output[3] = bitcast(input.inner.scalar32_2); + output[4] = u32(bitcast(input.vector.x) & 0xFFFFFFFF); + output[5] = u32((bitcast(input.vector.x) >> 32) & 0xFFFFFFFF); + output[6] = u32(bitcast(input.vector.y) & 0xFFFFFFFF); + output[7] = u32((bitcast(input.vector.y) >> 32) & 0xFFFFFFFF); + output[8] = u32(bitcast(input.vector.z) & 0xFFFFFFFF); + output[9] = u32((bitcast(input.vector.z) >> 32) & 0xFFFFFFFF); + ", + ); + + tests.push( + ShaderTest::new( + String::from("nested struct and array"), + members, + direct, + &input_values, + &[ + 0, // inner.scalar32 + 2, 3, // inner.scalar + 4, // inner.scalar32_2 + 8, 9, 10, 11, 12, 13, // vector + ], + ) + .header(header), + ); + } + + tests +} + #[gpu_test] static UNIFORM_INPUT: GpuTestConfiguration = GpuTestConfiguration::new() .parameters( @@ -272,3 +408,54 @@ static PUSH_CONSTANT_INPUT: GpuTestConfiguration = GpuTestConfiguration::new() create_struct_layout_tests(InputStorageType::PushConstant), ) }); + +#[gpu_test] +static UNIFORM_INPUT_INT64: GpuTestConfiguration = GpuTestConfiguration::new() + .parameters( + TestParameters::default() + .features(Features::SHADER_INT64) + .downlevel_flags(DownlevelFlags::COMPUTE_SHADERS) + .limits(Limits::downlevel_defaults()), + ) + .run_async(|ctx| { + shader_input_output_test( + ctx, + InputStorageType::Storage, + create_64bit_struct_layout_tests(), + ) + }); + +#[gpu_test] +static STORAGE_INPUT_INT64: GpuTestConfiguration = GpuTestConfiguration::new() + .parameters( + TestParameters::default() + .features(Features::SHADER_INT64) + .downlevel_flags(DownlevelFlags::COMPUTE_SHADERS) + .limits(Limits::downlevel_defaults()), + ) + .run_async(|ctx| { + shader_input_output_test( + ctx, + InputStorageType::Storage, + create_64bit_struct_layout_tests(), + ) + }); + +#[gpu_test] +static PUSH_CONSTANT_INPUT_INT64: GpuTestConfiguration = GpuTestConfiguration::new() + .parameters( + TestParameters::default() + .features(Features::SHADER_INT64 | Features::PUSH_CONSTANTS) + .downlevel_flags(DownlevelFlags::COMPUTE_SHADERS) + .limits(Limits { + max_push_constant_size: MAX_BUFFER_SIZE as u32, + ..Limits::downlevel_defaults() + }), + ) + .run_async(|ctx| { + shader_input_output_test( + ctx, + InputStorageType::PushConstant, + create_64bit_struct_layout_tests(), + ) + }); diff --git a/tests/tests/vertex_indices/mod.rs b/tests/tests/vertex_indices/mod.rs index 745eeff8c3..e0a2cbae06 100644 --- a/tests/tests/vertex_indices/mod.rs +++ b/tests/tests/vertex_indices/mod.rs @@ -5,9 +5,10 @@ use std::{num::NonZeroU64, ops::Range}; -use wgpu::util::{BufferInitDescriptor, DeviceExt}; +use wgpu::util::{BufferInitDescriptor, DeviceExt, RenderEncoder}; use wgpu_test::{gpu_test, GpuTestConfiguration, TestParameters, TestingContext}; +use wgt::RenderBundleDescriptor; /// Generic struct representing a draw call struct Draw { @@ -19,7 +20,7 @@ struct Draw { impl Draw { /// Directly execute the draw call - fn execute(&self, rpass: &mut wgpu::RenderPass<'_>) { + fn execute(&self, rpass: &mut dyn RenderEncoder<'_>) { if let Some(base_vertex) = self.base_vertex { rpass.draw_indexed(self.vertex.clone(), base_vertex, self.instance.clone()); } else { @@ -64,7 +65,7 @@ impl Draw { /// Execute the draw call from the given indirect buffer fn execute_indirect<'rpass>( &self, - rpass: &mut wgpu::RenderPass<'rpass>, + rpass: &mut dyn RenderEncoder<'rpass>, indirect: &'rpass wgpu::Buffer, offset: &mut u64, ) { @@ -169,10 +170,21 @@ impl DrawCallKind { const ARRAY: [Self; 2] = [Self::Direct, Self::Indirect]; } +#[derive(Debug, Copy, Clone)] +enum EncoderKind { + RenderPass, + RenderBundle, +} + +impl EncoderKind { + const ARRAY: [Self; 2] = [Self::RenderPass, Self::RenderBundle]; +} + struct Test { case: TestCase, id_source: IdSource, draw_call_kind: DrawCallKind, + encoder_kind: EncoderKind, } impl Test { @@ -325,11 +337,14 @@ async fn vertex_index_common(ctx: TestingContext) { for case in TestCase::ARRAY { for id_source in IdSource::ARRAY { for draw_call_kind in DrawCallKind::ARRAY { - tests.push(Test { - case, - id_source, - draw_call_kind, - }) + for encoder_kind in EncoderKind::ARRAY { + tests.push(Test { + case, + id_source, + draw_call_kind, + encoder_kind, + }) + } } } } @@ -373,6 +388,7 @@ async fn vertex_index_common(ctx: TestingContext) { .device .create_command_encoder(&wgpu::CommandEncoderDescriptor::default()); + let render_bundle; let indirect_buffer; let mut rpass = encoder1.begin_render_pass(&wgpu::RenderPassDescriptor { label: None, @@ -386,34 +402,64 @@ async fn vertex_index_common(ctx: TestingContext) { occlusion_query_set: None, }); - rpass.set_vertex_buffer(0, identity_buffer.slice(..)); - rpass.set_vertex_buffer(1, identity_buffer.slice(..)); - rpass.set_index_buffer(identity_buffer.slice(..), wgpu::IndexFormat::Uint32); - rpass.set_pipeline(pipeline); - rpass.set_bind_group(0, &bg, &[]); - - let draws = test.case.draws(); - - match test.draw_call_kind { - DrawCallKind::Direct => { - for draw in draws { - draw.execute(&mut rpass); + { + // Need to scope render_bundle_encoder since it's not Send and would otherwise + // infect the function if not going out of scope before an await call. + // (it is dropped via `take` + `finish` earlier, but compiler does not take this into account) + let mut render_bundle_encoder = match test.encoder_kind { + EncoderKind::RenderPass => None, + EncoderKind::RenderBundle => Some(ctx.device.create_render_bundle_encoder( + &wgpu::RenderBundleEncoderDescriptor { + label: Some("test renderbundle encoder"), + color_formats: &[Some(wgpu::TextureFormat::Rgba8Unorm)], + depth_stencil: None, + sample_count: 1, + multiview: None, + }, + )), + }; + + let render_encoder: &mut dyn RenderEncoder = render_bundle_encoder + .as_mut() + .map(|r| r as &mut dyn RenderEncoder) + .unwrap_or(&mut rpass); + + render_encoder.set_vertex_buffer(0, identity_buffer.slice(..)); + render_encoder.set_vertex_buffer(1, identity_buffer.slice(..)); + render_encoder.set_index_buffer(identity_buffer.slice(..), wgpu::IndexFormat::Uint32); + render_encoder.set_pipeline(pipeline); + render_encoder.set_bind_group(0, &bg, &[]); + + let draws = test.case.draws(); + + match test.draw_call_kind { + DrawCallKind::Direct => { + for draw in draws { + draw.execute(render_encoder); + } } - } - DrawCallKind::Indirect => { - let mut indirect_bytes = Vec::new(); - for draw in draws { - draw.add_to_buffer(&mut indirect_bytes, features); + DrawCallKind::Indirect => { + let mut indirect_bytes = Vec::new(); + for draw in draws { + draw.add_to_buffer(&mut indirect_bytes, features); + } + indirect_buffer = ctx.device.create_buffer_init(&BufferInitDescriptor { + label: Some("indirect"), + contents: &indirect_bytes, + usage: wgpu::BufferUsages::INDIRECT, + }); + let mut offset = 0; + for draw in draws { + draw.execute_indirect(render_encoder, &indirect_buffer, &mut offset); + } } - indirect_buffer = ctx.device.create_buffer_init(&BufferInitDescriptor { - label: Some("indirect"), - contents: &indirect_bytes, - usage: wgpu::BufferUsages::INDIRECT, + } + + if let Some(render_bundle_encoder) = render_bundle_encoder.take() { + render_bundle = render_bundle_encoder.finish(&RenderBundleDescriptor { + label: Some("test renderbundle"), }); - let mut offset = 0; - for draw in draws { - draw.execute_indirect(&mut rpass, &indirect_buffer, &mut offset); - } + rpass.execute_bundles([&render_bundle]); } } @@ -439,21 +485,18 @@ async fn vertex_index_common(ctx: TestingContext) { .panic_on_timeout(); let data: Vec = bytemuck::cast_slice(&slice.get_mapped_range()).to_vec(); + let case_name = format!( + "Case {:?} getting indices from {:?} using {:?} draw calls, encoded with a {:?}", + test.case, test.id_source, test.draw_call_kind, test.encoder_kind + ); if data != expected { eprintln!( - "Failed: Got: {:?} Expected: {:?} - Case {:?} getting indices from {:?} using {:?} draw calls", - data, - expected, - test.case, - test.id_source, - test.draw_call_kind + "Failed: Got: {:?} Expected: {:?} - {case_name}", + data, expected, ); failed = true; } else { - eprintln!( - "Passed: Case {:?} getting indices from {:?} using {:?} draw calls", - test.case, test.id_source, test.draw_call_kind - ); + eprintln!("Passed: {case_name}"); } } diff --git a/wgpu-core/Cargo.toml b/wgpu-core/Cargo.toml index 890120ac08..a0d3a5b612 100644 --- a/wgpu-core/Cargo.toml +++ b/wgpu-core/Cargo.toml @@ -13,7 +13,7 @@ license = "MIT OR Apache-2.0" # copy the crates it actually uses out of the workspace, so it's meaningful for # them to have less restrictive MSRVs individually than the workspace as a # whole, if their code permits. See `../README.md` for details. -rust-version = "1.70" +rust-version = "1.74" [package.metadata.docs.rs] all-features = true @@ -132,7 +132,7 @@ version = "0.19.0" default_features = false [target.'cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))'.dependencies] -web-sys = { version = "0.3.67", features = [ +web-sys = { version = "0.3.69", features = [ "HtmlCanvasElement", "OffscreenCanvas", ] } diff --git a/wgpu-core/src/binding_model.rs b/wgpu-core/src/binding_model.rs index d7b54ad5a5..8689af2ac1 100644 --- a/wgpu-core/src/binding_model.rs +++ b/wgpu-core/src/binding_model.rs @@ -38,6 +38,8 @@ pub enum BindGroupLayoutEntryError { ArrayUnsupported, #[error("Multisampled binding with sample type `TextureSampleType::Float` must have filterable set to false.")] SampleTypeFloatFilterableBindingMultisampled, + #[error("Multisampled texture binding view dimension must be 2d, got {0:?}")] + Non2DMultisampled(wgt::TextureViewDimension), #[error(transparent)] MissingFeatures(#[from] MissingFeatures), #[error(transparent)] @@ -219,7 +221,7 @@ pub enum BindingZone { } #[derive(Clone, Debug, Error)] -#[error("Too many bindings of type {kind:?} in {zone}, limit is {limit}, count was {count}")] +#[error("Too many bindings of type {kind:?} in {zone}, limit is {limit}, count was {count}. Check the limit `{}` passed to `Adapter::request_device`", .kind.to_config_str())] pub struct BindingTypeMaxCountError { pub kind: BindingTypeMaxCountErrorKind, pub zone: BindingZone, @@ -238,6 +240,28 @@ pub enum BindingTypeMaxCountErrorKind { UniformBuffers, } +impl BindingTypeMaxCountErrorKind { + fn to_config_str(&self) -> &'static str { + match self { + BindingTypeMaxCountErrorKind::DynamicUniformBuffers => { + "max_dynamic_uniform_buffers_per_pipeline_layout" + } + BindingTypeMaxCountErrorKind::DynamicStorageBuffers => { + "max_dynamic_storage_buffers_per_pipeline_layout" + } + BindingTypeMaxCountErrorKind::SampledTextures => { + "max_sampled_textures_per_shader_stage" + } + BindingTypeMaxCountErrorKind::Samplers => "max_samplers_per_shader_stage", + BindingTypeMaxCountErrorKind::StorageBuffers => "max_storage_buffers_per_shader_stage", + BindingTypeMaxCountErrorKind::StorageTextures => { + "max_storage_textures_per_shader_stage" + } + BindingTypeMaxCountErrorKind::UniformBuffers => "max_uniform_buffers_per_shader_stage", + } + } +} + #[derive(Debug, Default)] pub(crate) struct PerStageBindingTypeCounter { vertex: u32, diff --git a/wgpu-core/src/command/bundle.rs b/wgpu-core/src/command/bundle.rs index 930af68322..47beda8ec6 100644 --- a/wgpu-core/src/command/bundle.rs +++ b/wgpu-core/src/command/bundle.rs @@ -97,8 +97,9 @@ use crate::{ id, init_tracker::{BufferInitTrackerAction, MemoryInitKind, TextureInitTrackerAction}, pipeline::{PipelineFlags, RenderPipeline, VertexStep}, - resource::{Resource, ResourceInfo, ResourceType}, + resource::{Buffer, Resource, ResourceInfo, ResourceType}, resource_log, + snatch::SnatchGuard, track::RenderBundleScope, validation::check_buffer_usage, Label, LabelHelpers, @@ -110,9 +111,11 @@ use thiserror::Error; use hal::CommandEncoder as _; +use super::ArcRenderCommand; + /// https://gpuweb.github.io/gpuweb/#dom-gpurendercommandsmixin-draw -fn validate_draw( - vertex: &[Option], +fn validate_draw( + vertex: &[Option>], step: &[VertexStep], first_vertex: u32, vertex_count: u32, @@ -152,10 +155,10 @@ fn validate_draw( } // See https://gpuweb.github.io/gpuweb/#dom-gpurendercommandsmixin-drawindexed -fn validate_indexed_draw( - vertex: &[Option], +fn validate_indexed_draw( + vertex: &[Option>], step: &[VertexStep], - index_state: &IndexState, + index_state: &IndexState, first_index: u32, index_count: u32, first_instance: u32, @@ -163,7 +166,7 @@ fn validate_indexed_draw( ) -> Result<(), DrawError> { let last_index = first_index as u64 + index_count as u64; let index_limit = index_state.limit(); - if last_index <= index_limit { + if last_index > index_limit { return Err(DrawError::IndexBeyondLimit { last_index, index_limit, @@ -348,24 +351,44 @@ impl RenderBundleEncoder { ) -> Result, RenderBundleError> { let bind_group_guard = hub.bind_groups.read(); let pipeline_guard = hub.render_pipelines.read(); - let query_set_guard = hub.query_sets.read(); let buffer_guard = hub.buffers.read(); - let texture_guard = hub.textures.read(); let mut state = State { - trackers: RenderBundleScope::new( - &*buffer_guard, - &*texture_guard, - &*bind_group_guard, - &*pipeline_guard, - &*query_set_guard, - ), + trackers: RenderBundleScope::new(), pipeline: None, bind: (0..hal::MAX_BIND_GROUPS).map(|_| None).collect(), vertex: (0..hal::MAX_VERTEX_BUFFERS).map(|_| None).collect(), index: None, flat_dynamic_offsets: Vec::new(), }; + + let indices = &device.tracker_indices; + state + .trackers + .buffers + .write() + .set_size(indices.buffers.size()); + state + .trackers + .textures + .write() + .set_size(indices.textures.size()); + state + .trackers + .bind_groups + .write() + .set_size(indices.bind_groups.size()); + state + .trackers + .render_pipelines + .write() + .set_size(indices.render_pipelines.size()); + state + .trackers + .query_sets + .write() + .set_size(indices.query_sets.size()); + let mut commands = Vec::new(); let mut buffer_memory_init_actions = Vec::new(); let mut texture_memory_init_actions = Vec::new(); @@ -402,7 +425,6 @@ impl RenderBundleEncoder { } // Identify the next `num_dynamic_offsets` entries from `base.dynamic_offsets`. - let num_dynamic_offsets = num_dynamic_offsets; let offsets_range = next_dynamic_offset..next_dynamic_offset + num_dynamic_offsets; next_dynamic_offset = offsets_range.end; @@ -474,7 +496,7 @@ impl RenderBundleEncoder { let pipeline_state = PipelineState::new(pipeline); - commands.push(command); + commands.push(ArcRenderCommand::SetPipeline(pipeline.clone())); // If this pipeline uses push constants, zero out their values. if let Some(iter) = pipeline_state.zero_push_constants() { @@ -499,7 +521,7 @@ impl RenderBundleEncoder { .map_pass_err(scope)?; self.check_valid_to_use(buffer.device.info.id()) .map_pass_err(scope)?; - check_buffer_usage(buffer.usage, wgt::BufferUsages::INDEX) + check_buffer_usage(buffer_id, buffer.usage, wgt::BufferUsages::INDEX) .map_pass_err(scope)?; let end = match size { @@ -511,7 +533,7 @@ impl RenderBundleEncoder { offset..end, MemoryInitKind::NeedsInitializedMemory, )); - state.set_index_buffer(buffer_id, index_format, offset..end); + state.set_index_buffer(buffer.clone(), index_format, offset..end); } RenderCommand::SetVertexBuffer { slot, @@ -538,7 +560,7 @@ impl RenderBundleEncoder { .map_pass_err(scope)?; self.check_valid_to_use(buffer.device.info.id()) .map_pass_err(scope)?; - check_buffer_usage(buffer.usage, wgt::BufferUsages::VERTEX) + check_buffer_usage(buffer_id, buffer.usage, wgt::BufferUsages::VERTEX) .map_pass_err(scope)?; let end = match size { @@ -550,13 +572,13 @@ impl RenderBundleEncoder { offset..end, MemoryInitKind::NeedsInitializedMemory, )); - state.vertex[slot as usize] = Some(VertexState::new(buffer_id, offset..end)); + state.vertex[slot as usize] = Some(VertexState::new(buffer.clone(), offset..end)); } RenderCommand::SetPushConstant { stages, offset, size_bytes, - values_offset: _, + values_offset, } => { let scope = PassErrorScope::SetPushConstant; let end_offset = offset + size_bytes; @@ -567,7 +589,7 @@ impl RenderBundleEncoder { .validate_push_constant_ranges(stages, offset, end_offset) .map_pass_err(scope)?; - commands.push(command); + commands.push(ArcRenderCommand::SetPushConstant { stages, offset, size_bytes, values_offset }); } RenderCommand::Draw { vertex_count, @@ -595,14 +617,19 @@ impl RenderBundleEncoder { if instance_count > 0 && vertex_count > 0 { commands.extend(state.flush_vertices()); commands.extend(state.flush_binds(used_bind_groups, base.dynamic_offsets)); - commands.push(command); + commands.push(ArcRenderCommand::Draw { + vertex_count, + instance_count, + first_vertex, + first_instance, + }); } } RenderCommand::DrawIndexed { index_count, instance_count, first_index, - base_vertex: _, + base_vertex, first_instance, } => { let scope = PassErrorScope::Draw { @@ -631,7 +658,7 @@ impl RenderBundleEncoder { commands.extend(state.flush_index()); commands.extend(state.flush_vertices()); commands.extend(state.flush_binds(used_bind_groups, base.dynamic_offsets)); - commands.push(command); + commands.push(ArcRenderCommand::DrawIndexed { index_count, instance_count, first_index, base_vertex, first_instance }); } } RenderCommand::MultiDrawIndirect { @@ -660,7 +687,7 @@ impl RenderBundleEncoder { .map_pass_err(scope)?; self.check_valid_to_use(buffer.device.info.id()) .map_pass_err(scope)?; - check_buffer_usage(buffer.usage, wgt::BufferUsages::INDIRECT) + check_buffer_usage(buffer_id, buffer.usage, wgt::BufferUsages::INDIRECT) .map_pass_err(scope)?; buffer_memory_init_actions.extend(buffer.initialization_status.read().create_action( @@ -671,7 +698,7 @@ impl RenderBundleEncoder { commands.extend(state.flush_vertices()); commands.extend(state.flush_binds(used_bind_groups, base.dynamic_offsets)); - commands.push(command); + commands.push(ArcRenderCommand::MultiDrawIndirect { buffer: buffer.clone(), offset, count: None, indexed: false }); } RenderCommand::MultiDrawIndirect { buffer_id, @@ -699,7 +726,7 @@ impl RenderBundleEncoder { .map_pass_err(scope)?; self.check_valid_to_use(buffer.device.info.id()) .map_pass_err(scope)?; - check_buffer_usage(buffer.usage, wgt::BufferUsages::INDIRECT) + check_buffer_usage(buffer_id, buffer.usage, wgt::BufferUsages::INDIRECT) .map_pass_err(scope)?; buffer_memory_init_actions.extend(buffer.initialization_status.read().create_action( @@ -716,7 +743,7 @@ impl RenderBundleEncoder { commands.extend(index.flush()); commands.extend(state.flush_vertices()); commands.extend(state.flush_binds(used_bind_groups, base.dynamic_offsets)); - commands.push(command); + commands.push(ArcRenderCommand::MultiDrawIndirect { buffer: buffer.clone(), offset, count: None, indexed: true }); } RenderCommand::MultiDrawIndirect { .. } | RenderCommand::MultiDrawIndirectCount { .. } => unimplemented!(), @@ -751,7 +778,10 @@ impl RenderBundleEncoder { buffer_memory_init_actions, texture_memory_init_actions, context: self.context, - info: ResourceInfo::new(desc.label.borrow_or_default()), + info: ResourceInfo::new( + desc.label.borrow_or_default(), + Some(device.tracker_indices.bundles.clone()), + ), discard_hal_labels: device .instance_flags .contains(wgt::InstanceFlags::DISCARD_HAL_LABELS), @@ -827,7 +857,7 @@ pub type RenderBundleDescriptor<'a> = wgt::RenderBundleDescriptor>; pub struct RenderBundle { // Normalized command stream. It can be executed verbatim, // without re-binding anything on the pipeline change. - base: BasePass, + base: BasePass>, pub(super) is_depth_read_only: bool, pub(super) is_stencil_read_only: bool, pub(crate) device: Arc>, @@ -865,8 +895,11 @@ impl RenderBundle { /// Note that the function isn't expected to fail, generally. /// All the validation has already been done by this point. /// The only failure condition is if some of the used buffers are destroyed. - pub(super) unsafe fn execute(&self, raw: &mut A::CommandEncoder) -> Result<(), ExecutionError> { - let trackers = &self.used; + pub(super) unsafe fn execute( + &self, + raw: &mut A::CommandEncoder, + snatch_guard: &SnatchGuard, + ) -> Result<(), ExecutionError> { let mut offsets = self.base.dynamic_offsets.as_slice(); let mut pipeline_layout = None::>>; if !self.discard_hal_labels { @@ -875,76 +908,65 @@ impl RenderBundle { } } - let snatch_guard = self.device.snatchable_lock.read(); - + use ArcRenderCommand as Cmd; for command in self.base.commands.iter() { - match *command { - RenderCommand::SetBindGroup { + match command { + Cmd::SetBindGroup { index, num_dynamic_offsets, - bind_group_id, + bind_group, } => { - let bind_groups = trackers.bind_groups.read(); - let bind_group = bind_groups.get(bind_group_id).unwrap(); let raw_bg = bind_group - .raw(&snatch_guard) - .ok_or(ExecutionError::InvalidBindGroup(bind_group_id))?; + .raw(snatch_guard) + .ok_or(ExecutionError::InvalidBindGroup(bind_group.info.id()))?; unsafe { raw.set_bind_group( pipeline_layout.as_ref().unwrap().raw(), - index, + *index, raw_bg, - &offsets[..num_dynamic_offsets], + &offsets[..*num_dynamic_offsets], ) }; - offsets = &offsets[num_dynamic_offsets..]; + offsets = &offsets[*num_dynamic_offsets..]; } - RenderCommand::SetPipeline(pipeline_id) => { - let render_pipelines = trackers.render_pipelines.read(); - let pipeline = render_pipelines.get(pipeline_id).unwrap(); + Cmd::SetPipeline(pipeline) => { unsafe { raw.set_render_pipeline(pipeline.raw()) }; pipeline_layout = Some(pipeline.layout.clone()); } - RenderCommand::SetIndexBuffer { - buffer_id, + Cmd::SetIndexBuffer { + buffer, index_format, offset, size, } => { - let buffers = trackers.buffers.read(); - let buffer: &A::Buffer = buffers - .get(buffer_id) - .ok_or(ExecutionError::DestroyedBuffer(buffer_id))? - .raw(&snatch_guard) - .ok_or(ExecutionError::DestroyedBuffer(buffer_id))?; + let buffer: &A::Buffer = buffer + .raw(snatch_guard) + .ok_or(ExecutionError::DestroyedBuffer(buffer.info.id()))?; let bb = hal::BufferBinding { buffer, - offset, - size, + offset: *offset, + size: *size, }; - unsafe { raw.set_index_buffer(bb, index_format) }; + unsafe { raw.set_index_buffer(bb, *index_format) }; } - RenderCommand::SetVertexBuffer { + Cmd::SetVertexBuffer { slot, - buffer_id, + buffer, offset, size, } => { - let buffers = trackers.buffers.read(); - let buffer = buffers - .get(buffer_id) - .ok_or(ExecutionError::DestroyedBuffer(buffer_id))? - .raw(&snatch_guard) - .ok_or(ExecutionError::DestroyedBuffer(buffer_id))?; + let buffer = buffer + .raw(snatch_guard) + .ok_or(ExecutionError::DestroyedBuffer(buffer.info.id()))?; let bb = hal::BufferBinding { buffer, - offset, - size, + offset: *offset, + size: *size, }; - unsafe { raw.set_vertex_buffer(slot, bb) }; + unsafe { raw.set_vertex_buffer(*slot, bb) }; } - RenderCommand::SetPushConstant { + Cmd::SetPushConstant { stages, offset, size_bytes, @@ -952,7 +974,7 @@ impl RenderBundle { } => { let pipeline_layout = pipeline_layout.as_ref().unwrap(); - if let Some(values_offset) = values_offset { + if let Some(values_offset) = *values_offset { let values_end_offset = (values_offset + size_bytes / wgt::PUSH_CONSTANT_ALIGNMENT) as usize; let data_slice = &self.base.push_constant_data @@ -961,20 +983,20 @@ impl RenderBundle { unsafe { raw.set_push_constants( pipeline_layout.raw(), - stages, - offset, + *stages, + *offset, data_slice, ) } } else { super::push_constant_clear( - offset, - size_bytes, + *offset, + *size_bytes, |clear_offset, clear_data| { unsafe { raw.set_push_constants( pipeline_layout.raw(), - stages, + *stages, clear_offset, clear_data, ) @@ -983,15 +1005,22 @@ impl RenderBundle { ); } } - RenderCommand::Draw { + Cmd::Draw { vertex_count, instance_count, first_vertex, first_instance, } => { - unsafe { raw.draw(first_vertex, vertex_count, first_instance, instance_count) }; + unsafe { + raw.draw( + *first_vertex, + *vertex_count, + *first_instance, + *instance_count, + ) + }; } - RenderCommand::DrawIndexed { + Cmd::DrawIndexed { index_count, instance_count, first_index, @@ -1000,63 +1029,54 @@ impl RenderBundle { } => { unsafe { raw.draw_indexed( - first_index, - index_count, - base_vertex, - first_instance, - instance_count, + *first_index, + *index_count, + *base_vertex, + *first_instance, + *instance_count, ) }; } - RenderCommand::MultiDrawIndirect { - buffer_id, + Cmd::MultiDrawIndirect { + buffer, offset, count: None, indexed: false, } => { - let buffers = trackers.buffers.read(); - let buffer = buffers - .get(buffer_id) - .ok_or(ExecutionError::DestroyedBuffer(buffer_id))? - .raw(&snatch_guard) - .ok_or(ExecutionError::DestroyedBuffer(buffer_id))?; - unsafe { raw.draw_indirect(buffer, offset, 1) }; + let buffer = buffer + .raw(snatch_guard) + .ok_or(ExecutionError::DestroyedBuffer(buffer.info.id()))?; + unsafe { raw.draw_indirect(buffer, *offset, 1) }; } - RenderCommand::MultiDrawIndirect { - buffer_id, + Cmd::MultiDrawIndirect { + buffer, offset, count: None, indexed: true, } => { - let buffers = trackers.buffers.read(); - let buffer = buffers - .get(buffer_id) - .ok_or(ExecutionError::DestroyedBuffer(buffer_id))? - .raw(&snatch_guard) - .ok_or(ExecutionError::DestroyedBuffer(buffer_id))?; - unsafe { raw.draw_indexed_indirect(buffer, offset, 1) }; + let buffer = buffer + .raw(snatch_guard) + .ok_or(ExecutionError::DestroyedBuffer(buffer.info.id()))?; + unsafe { raw.draw_indexed_indirect(buffer, *offset, 1) }; } - RenderCommand::MultiDrawIndirect { .. } - | RenderCommand::MultiDrawIndirectCount { .. } => { + Cmd::MultiDrawIndirect { .. } | Cmd::MultiDrawIndirectCount { .. } => { return Err(ExecutionError::Unimplemented("multi-draw-indirect")) } - RenderCommand::PushDebugGroup { .. } - | RenderCommand::InsertDebugMarker { .. } - | RenderCommand::PopDebugGroup => { + Cmd::PushDebugGroup { .. } | Cmd::InsertDebugMarker { .. } | Cmd::PopDebugGroup => { return Err(ExecutionError::Unimplemented("debug-markers")) } - RenderCommand::WriteTimestamp { .. } - | RenderCommand::BeginOcclusionQuery { .. } - | RenderCommand::EndOcclusionQuery - | RenderCommand::BeginPipelineStatisticsQuery { .. } - | RenderCommand::EndPipelineStatisticsQuery => { + Cmd::WriteTimestamp { .. } + | Cmd::BeginOcclusionQuery { .. } + | Cmd::EndOcclusionQuery + | Cmd::BeginPipelineStatisticsQuery { .. } + | Cmd::EndPipelineStatisticsQuery => { return Err(ExecutionError::Unimplemented("queries")) } - RenderCommand::ExecuteBundle(_) - | RenderCommand::SetBlendConstant(_) - | RenderCommand::SetStencilReference(_) - | RenderCommand::SetViewport { .. } - | RenderCommand::SetScissor(_) => unreachable!(), + Cmd::ExecuteBundle(_) + | Cmd::SetBlendConstant(_) + | Cmd::SetStencilReference(_) + | Cmd::SetViewport { .. } + | Cmd::SetScissor(_) => unreachable!(), } } @@ -1090,14 +1110,14 @@ impl Resource for RenderBundle { /// and calls [`State::flush_index`] before any indexed draw command to produce /// a `SetIndexBuffer` command if one is necessary. #[derive(Debug)] -struct IndexState { - buffer: id::BufferId, +struct IndexState { + buffer: Arc>, format: wgt::IndexFormat, range: Range, is_dirty: bool, } -impl IndexState { +impl IndexState { /// Return the number of entries in the current index buffer. /// /// Panic if no index buffer has been set. @@ -1112,11 +1132,11 @@ impl IndexState { /// Generate a `SetIndexBuffer` command to prepare for an indexed draw /// command, if needed. - fn flush(&mut self) -> Option { + fn flush(&mut self) -> Option> { if self.is_dirty { self.is_dirty = false; - Some(RenderCommand::SetIndexBuffer { - buffer_id: self.buffer, + Some(ArcRenderCommand::SetIndexBuffer { + buffer: self.buffer.clone(), index_format: self.format, offset: self.range.start, size: wgt::BufferSize::new(self.range.end - self.range.start), @@ -1137,14 +1157,14 @@ impl IndexState { /// /// [`flush`]: IndexState::flush #[derive(Debug)] -struct VertexState { - buffer: id::BufferId, +struct VertexState { + buffer: Arc>, range: Range, is_dirty: bool, } -impl VertexState { - fn new(buffer: id::BufferId, range: Range) -> Self { +impl VertexState { + fn new(buffer: Arc>, range: Range) -> Self { Self { buffer, range, @@ -1155,12 +1175,12 @@ impl VertexState { /// Generate a `SetVertexBuffer` command for this slot, if necessary. /// /// `slot` is the index of the vertex buffer slot that `self` tracks. - fn flush(&mut self, slot: u32) -> Option { + fn flush(&mut self, slot: u32) -> Option> { if self.is_dirty { self.is_dirty = false; - Some(RenderCommand::SetVertexBuffer { + Some(ArcRenderCommand::SetVertexBuffer { slot, - buffer_id: self.buffer, + buffer: self.buffer.clone(), offset: self.range.start, size: wgt::BufferSize::new(self.range.end - self.range.start), }) @@ -1222,7 +1242,7 @@ impl PipelineState { /// Return a sequence of commands to zero the push constant ranges this /// pipeline uses. If no initialization is necessary, return `None`. - fn zero_push_constants(&self) -> Option> { + fn zero_push_constants(&self) -> Option>> { if !self.push_constant_ranges.is_empty() { let nonoverlapping_ranges = super::bind::compute_nonoverlapping_ranges(&self.push_constant_ranges); @@ -1230,7 +1250,7 @@ impl PipelineState { Some( nonoverlapping_ranges .into_iter() - .map(|range| RenderCommand::SetPushConstant { + .map(|range| ArcRenderCommand::SetPushConstant { stages: range.stages, offset: range.range.start, size_bytes: range.range.end - range.range.start, @@ -1264,11 +1284,11 @@ struct State { bind: ArrayVec>, { hal::MAX_BIND_GROUPS }>, /// The state of each vertex buffer slot. - vertex: ArrayVec, { hal::MAX_VERTEX_BUFFERS }>, + vertex: ArrayVec>, { hal::MAX_VERTEX_BUFFERS }>, /// The current index buffer, if one has been set. We flush this state /// before indexed draw commands. - index: Option, + index: Option>, /// Dynamic offset values used by the cleaned-up command sequence. /// @@ -1378,13 +1398,13 @@ impl State { /// Set the bundle's current index buffer and its associated parameters. fn set_index_buffer( &mut self, - buffer: id::BufferId, + buffer: Arc>, format: wgt::IndexFormat, range: Range, ) { match self.index { Some(ref current) - if current.buffer == buffer + if Arc::ptr_eq(¤t.buffer, &buffer) && current.format == format && current.range == range => { @@ -1403,11 +1423,11 @@ impl State { /// Generate a `SetIndexBuffer` command to prepare for an indexed draw /// command, if needed. - fn flush_index(&mut self) -> Option { + fn flush_index(&mut self) -> Option> { self.index.as_mut().and_then(|index| index.flush()) } - fn flush_vertices(&mut self) -> impl Iterator + '_ { + fn flush_vertices(&mut self) -> impl Iterator> + '_ { self.vertex .iter_mut() .enumerate() @@ -1419,7 +1439,7 @@ impl State { &mut self, used_bind_groups: usize, dynamic_offsets: &[wgt::DynamicOffset], - ) -> impl Iterator + '_ { + ) -> impl Iterator> + '_ { // Append each dirty bind group's dynamic offsets to `flat_dynamic_offsets`. for contents in self.bind[..used_bind_groups].iter().flatten() { if contents.is_dirty { @@ -1438,9 +1458,9 @@ impl State { if contents.is_dirty { contents.is_dirty = false; let offsets = &contents.dynamic_offsets; - return Some(RenderCommand::SetBindGroup { + return Some(ArcRenderCommand::SetBindGroup { index: i.try_into().unwrap(), - bind_group_id: contents.bind_group.as_info().id(), + bind_group: contents.bind_group.clone(), num_dynamic_offsets: offsets.end - offsets.start, }); } diff --git a/wgpu-core/src/command/clear.rs b/wgpu-core/src/command/clear.rs index 2569fea1a4..72c923f82e 100644 --- a/wgpu-core/src/command/clear.rs +++ b/wgpu-core/src/command/clear.rs @@ -12,6 +12,7 @@ use crate::{ id::{BufferId, CommandEncoderId, DeviceId, TextureId}, init_tracker::{MemoryInitKind, TextureInitRange}, resource::{Resource, Texture, TextureClearMode}, + snatch::SnatchGuard, track::{TextureSelector, TextureTracker}, }; @@ -39,6 +40,11 @@ pub enum ClearError { UnalignedFillSize(BufferAddress), #[error("Buffer offset {0:?} is not a multiple of `COPY_BUFFER_ALIGNMENT`")] UnalignedBufferOffset(BufferAddress), + #[error("Clear starts at offset {start_offset} with size of {requested_size}, but these added together exceed `u64::MAX`")] + OffsetPlusSizeExceeds64BitBounds { + start_offset: BufferAddress, + requested_size: BufferAddress, + }, #[error("Clear of {start_offset}..{end_offset} would end up overrunning the bounds of the buffer of size {buffer_size}")] BufferOverrun { start_offset: BufferAddress, @@ -117,25 +123,27 @@ impl Global { if offset % wgt::COPY_BUFFER_ALIGNMENT != 0 { return Err(ClearError::UnalignedBufferOffset(offset)); } - if let Some(size) = size { - if size % wgt::COPY_BUFFER_ALIGNMENT != 0 { - return Err(ClearError::UnalignedFillSize(size)); - } - let destination_end_offset = offset + size; - if destination_end_offset > dst_buffer.size { - return Err(ClearError::BufferOverrun { + + let size = size.unwrap_or(dst_buffer.size.saturating_sub(offset)); + if size % wgt::COPY_BUFFER_ALIGNMENT != 0 { + return Err(ClearError::UnalignedFillSize(size)); + } + let end_offset = + offset + .checked_add(size) + .ok_or(ClearError::OffsetPlusSizeExceeds64BitBounds { start_offset: offset, - end_offset: destination_end_offset, - buffer_size: dst_buffer.size, - }); - } + requested_size: size, + })?; + if end_offset > dst_buffer.size { + return Err(ClearError::BufferOverrun { + start_offset: offset, + end_offset, + buffer_size: dst_buffer.size, + }); } - let end = match size { - Some(size) => offset + size, - None => dst_buffer.size, - }; - if offset == end { + if offset == end_offset { log::trace!("Ignoring fill_buffer of size 0"); return Ok(()); } @@ -144,7 +152,7 @@ impl Global { cmd_buf_data.buffer_memory_init_actions.extend( dst_buffer.initialization_status.read().create_action( &dst_buffer, - offset..end, + offset..end_offset, MemoryInitKind::ImplicitlyInitialized, ), ); @@ -154,7 +162,7 @@ impl Global { let cmd_buf_raw = cmd_buf_data.encoder.open()?; unsafe { cmd_buf_raw.transition_buffers(dst_barrier.into_iter()); - cmd_buf_raw.clear_buffer(dst_raw, offset..end); + cmd_buf_raw.clear_buffer(dst_raw, offset..end_offset); } Ok(()) } @@ -232,6 +240,7 @@ impl Global { } let (encoder, tracker) = cmd_buf_data.open_encoder_and_tracker()?; + let snatch_guard = device.snatchable_lock.read(); clear_texture( &dst_texture, TextureInitRange { @@ -242,6 +251,7 @@ impl Global { &mut tracker.textures, &device.alignments, device.zero_buffer.as_ref().unwrap(), + &snatch_guard, ) } } @@ -253,10 +263,10 @@ pub(crate) fn clear_texture( texture_tracker: &mut TextureTracker, alignments: &hal::Alignments, zero_buffer: &A::Buffer, + snatch_guard: &SnatchGuard<'_>, ) -> Result<(), ClearError> { - let snatch_guard = dst_texture.device.snatchable_lock.read(); let dst_raw = dst_texture - .raw(&snatch_guard) + .raw(snatch_guard) .ok_or_else(|| ClearError::InvalidTexture(dst_texture.as_info().id()))?; // Issue the right barrier. @@ -366,7 +376,7 @@ fn clear_texture_via_buffer_copies( assert!( max_rows_per_copy > 0, "Zero buffer size is too small to fill a single row \ - of a texture with format {:?} and desc {:?}", + of a texture with format {:?} and desc {:?}", texture_desc.format, texture_desc.size ); diff --git a/wgpu-core/src/command/compute.rs b/wgpu-core/src/command/compute.rs index 804186a01e..b38324984c 100644 --- a/wgpu-core/src/command/compute.rs +++ b/wgpu-core/src/command/compute.rs @@ -1,6 +1,7 @@ use crate::device::DeviceError; use crate::resource::Resource; use crate::snatch::SnatchGuard; +use crate::track::TrackerIndex; use crate::{ binding_model::{ BindError, BindGroup, LateMinBufferBindingSizeMismatch, PushConstantUploadError, @@ -271,14 +272,14 @@ where } } -struct State { +struct State<'a, A: HalApi> { binder: Binder, pipeline: Option, - scope: UsageScope, + scope: UsageScope<'a, A>, debug_scope_depth: u32, } -impl State { +impl<'a, A: HalApi> State<'a, A> { fn is_ready(&self) -> Result<(), DispatchError> { let bind_mask = self.binder.invalid_mask(); if bind_mask != 0 { @@ -305,7 +306,7 @@ impl State { raw_encoder: &mut A::CommandEncoder, base_trackers: &mut Tracker, bind_group_guard: &Storage>, - indirect_buffer: Option, + indirect_buffer: Option, snatch_guard: &SnatchGuard, ) -> Result<(), UsageConflict> { for id in self.binder.list_active() { @@ -402,12 +403,11 @@ impl Global { let pipeline_guard = hub.compute_pipelines.read(); let query_set_guard = hub.query_sets.read(); let buffer_guard = hub.buffers.read(); - let texture_guard = hub.textures.read(); let mut state = State { binder: Binder::new(), pipeline: None, - scope: UsageScope::new(&*buffer_guard, &*texture_guard), + scope: device.new_usage_scope(), debug_scope_depth: 0, }; let mut temp_offsets = Vec::new(); @@ -452,17 +452,14 @@ impl Global { let snatch_guard = device.snatchable_lock.read(); - tracker.set_size( - Some(&*buffer_guard), - Some(&*texture_guard), - None, - None, - Some(&*bind_group_guard), - Some(&*pipeline_guard), - None, - None, - Some(&*query_set_guard), - ); + let indices = &device.tracker_indices; + tracker.buffers.set_size(indices.buffers.size()); + tracker.textures.set_size(indices.textures.size()); + tracker.bind_groups.set_size(indices.bind_groups.size()); + tracker + .compute_pipelines + .set_size(indices.compute_pipelines.size()); + tracker.query_sets.set_size(indices.query_sets.size()); let discard_hal_labels = self .instance @@ -719,8 +716,12 @@ impl Global { .buffers .merge_single(&*buffer_guard, buffer_id, hal::BufferUses::INDIRECT) .map_pass_err(scope)?; - check_buffer_usage(indirect_buffer.usage, wgt::BufferUsages::INDIRECT) - .map_pass_err(scope)?; + check_buffer_usage( + buffer_id, + indirect_buffer.usage, + wgt::BufferUsages::INDIRECT, + ) + .map_pass_err(scope)?; let end_offset = offset + mem::size_of::() as u64; if end_offset > indirect_buffer.size { @@ -753,7 +754,7 @@ impl Global { raw, &mut intermediate_trackers, &*bind_group_guard, - Some(buffer_id), + Some(indirect_buffer.as_info().tracker_index()), &snatch_guard, ) .map_pass_err(scope)?; @@ -867,6 +868,7 @@ impl Global { transit, &mut tracker.textures, device, + &snatch_guard, ); CommandBuffer::insert_barriers_from_tracker( transit, diff --git a/wgpu-core/src/command/draw.rs b/wgpu-core/src/command/draw.rs index e03a78ee93..98aa689b78 100644 --- a/wgpu-core/src/command/draw.rs +++ b/wgpu-core/src/command/draw.rs @@ -2,17 +2,22 @@ !*/ use crate::{ - binding_model::{LateMinBufferBindingSizeMismatch, PushConstantUploadError}, + binding_model::{BindGroup, LateMinBufferBindingSizeMismatch, PushConstantUploadError}, error::ErrorFormatter, + hal_api::HalApi, id, + pipeline::RenderPipeline, + resource::{Buffer, QuerySet}, track::UsageConflict, validation::{MissingBufferUsageError, MissingTextureUsageError}, }; use wgt::{BufferAddress, BufferSize, Color, VertexStepMode}; -use std::num::NonZeroU32; +use std::{num::NonZeroU32, sync::Arc}; use thiserror::Error; +use super::RenderBundle; + /// Error validating a draw call. #[derive(Clone, Debug, Error, Eq, PartialEq)] #[non_exhaustive] @@ -245,3 +250,114 @@ pub enum RenderCommand { EndPipelineStatisticsQuery, ExecuteBundle(id::RenderBundleId), } + +/// Equivalent to `RenderCommand` with the Ids resolved into resource Arcs. +#[doc(hidden)] +#[derive(Clone, Debug)] +pub enum ArcRenderCommand { + SetBindGroup { + index: u32, + num_dynamic_offsets: usize, + bind_group: Arc>, + }, + SetPipeline(Arc>), + SetIndexBuffer { + buffer: Arc>, + index_format: wgt::IndexFormat, + offset: BufferAddress, + size: Option, + }, + SetVertexBuffer { + slot: u32, + buffer: Arc>, + offset: BufferAddress, + size: Option, + }, + SetBlendConstant(Color), + SetStencilReference(u32), + SetViewport { + rect: Rect, + depth_min: f32, + depth_max: f32, + }, + SetScissor(Rect), + + /// Set a range of push constants to values stored in [`BasePass::push_constant_data`]. + /// + /// See [`wgpu::RenderPass::set_push_constants`] for a detailed explanation + /// of the restrictions these commands must satisfy. + SetPushConstant { + /// Which stages we are setting push constant values for. + stages: wgt::ShaderStages, + + /// The byte offset within the push constant storage to write to. This + /// must be a multiple of four. + offset: u32, + + /// The number of bytes to write. This must be a multiple of four. + size_bytes: u32, + + /// Index in [`BasePass::push_constant_data`] of the start of the data + /// to be written. + /// + /// Note: this is not a byte offset like `offset`. Rather, it is the + /// index of the first `u32` element in `push_constant_data` to read. + /// + /// `None` means zeros should be written to the destination range, and + /// there is no corresponding data in `push_constant_data`. This is used + /// by render bundles, which explicitly clear out any state that + /// post-bundle code might see. + values_offset: Option, + }, + Draw { + vertex_count: u32, + instance_count: u32, + first_vertex: u32, + first_instance: u32, + }, + DrawIndexed { + index_count: u32, + instance_count: u32, + first_index: u32, + base_vertex: i32, + first_instance: u32, + }, + MultiDrawIndirect { + buffer: Arc>, + offset: BufferAddress, + /// Count of `None` represents a non-multi call. + count: Option, + indexed: bool, + }, + MultiDrawIndirectCount { + buffer: Arc>, + offset: BufferAddress, + count_buffer: Arc>, + count_buffer_offset: BufferAddress, + max_count: u32, + indexed: bool, + }, + PushDebugGroup { + color: u32, + len: usize, + }, + PopDebugGroup, + InsertDebugMarker { + color: u32, + len: usize, + }, + WriteTimestamp { + query_set: Arc>, + query_index: u32, + }, + BeginOcclusionQuery { + query_index: u32, + }, + EndOcclusionQuery, + BeginPipelineStatisticsQuery { + query_set: Arc>, + query_index: u32, + }, + EndPipelineStatisticsQuery, + ExecuteBundle(Arc>), +} diff --git a/wgpu-core/src/command/memory_init.rs b/wgpu-core/src/command/memory_init.rs index 3bfc71f4f7..54bdedb792 100644 --- a/wgpu-core/src/command/memory_init.rs +++ b/wgpu-core/src/command/memory_init.rs @@ -7,6 +7,7 @@ use crate::{ hal_api::HalApi, init_tracker::*, resource::{Resource, Texture}, + snatch::SnatchGuard, track::{TextureTracker, Tracker}, FastHashMap, }; @@ -144,6 +145,7 @@ pub(crate) fn fixup_discarded_surfaces< encoder: &mut A::CommandEncoder, texture_tracker: &mut TextureTracker, device: &Device, + snatch_guard: &SnatchGuard<'_>, ) { for init in inits { clear_texture( @@ -156,6 +158,7 @@ pub(crate) fn fixup_discarded_surfaces< texture_tracker, &device.alignments, device.zero_buffer.as_ref().unwrap(), + snatch_guard, ) .unwrap(); } @@ -167,6 +170,7 @@ impl BakedCommands { pub(crate) fn initialize_buffer_memory( &mut self, device_tracker: &mut Tracker, + snatch_guard: &SnatchGuard<'_>, ) -> Result<(), DestroyedBufferError> { // Gather init ranges for each buffer so we can collapse them. // It is not possible to do this at an earlier point since previously @@ -225,16 +229,15 @@ impl BakedCommands { .unwrap() .1; - let snatch_guard = buffer.device.snatchable_lock.read(); let raw_buf = buffer .raw - .get(&snatch_guard) + .get(snatch_guard) .ok_or(DestroyedBufferError(buffer_id))?; unsafe { self.encoder.transition_buffers( transition - .map(|pending| pending.into_hal(&buffer, &snatch_guard)) + .map(|pending| pending.into_hal(&buffer, snatch_guard)) .into_iter(), ); } @@ -271,6 +274,7 @@ impl BakedCommands { &mut self, device_tracker: &mut Tracker, device: &Device, + snatch_guard: &SnatchGuard<'_>, ) -> Result<(), DestroyedTextureError> { let mut ranges: Vec = Vec::new(); for texture_use in self.texture_memory_actions.drain_init_actions() { @@ -310,6 +314,7 @@ impl BakedCommands { &mut device_tracker.textures, &device.alignments, device.zero_buffer.as_ref().unwrap(), + snatch_guard, ); // A Texture can be destroyed between the command recording diff --git a/wgpu-core/src/command/mod.rs b/wgpu-core/src/command/mod.rs index 2d5fca200a..ab413db737 100644 --- a/wgpu-core/src/command/mod.rs +++ b/wgpu-core/src/command/mod.rs @@ -75,14 +75,14 @@ impl CommandEncoder { Ok(()) } - fn discard(&mut self) { + pub(crate) fn discard(&mut self) { if self.is_open { self.is_open = false; unsafe { self.raw.discard_encoding() }; } } - fn open(&mut self) -> Result<&mut A::CommandEncoder, DeviceError> { + pub(crate) fn open(&mut self) -> Result<&mut A::CommandEncoder, DeviceError> { if !self.is_open { self.is_open = true; let label = self.label.as_deref(); @@ -112,7 +112,7 @@ pub(crate) struct DestroyedBufferError(pub id::BufferId); pub(crate) struct DestroyedTextureError(pub id::TextureId); pub struct CommandBufferMutable { - encoder: CommandEncoder, + pub(crate) encoder: CommandEncoder, status: CommandEncoderStatus, pub(crate) trackers: Tracker, buffer_memory_init_actions: Vec>, @@ -174,6 +174,7 @@ impl CommandBuffer { .as_ref() .unwrap_or(&String::from("")) .as_str(), + None, ), data: Mutex::new(Some(CommandBufferMutable { encoder: CommandEncoder { diff --git a/wgpu-core/src/command/query.rs b/wgpu-core/src/command/query.rs index 39d7a9cc93..89cba6fbf3 100644 --- a/wgpu-core/src/command/query.rs +++ b/wgpu-core/src/command/query.rs @@ -4,7 +4,7 @@ use hal::CommandEncoder as _; use crate::device::trace::Command as TraceCommand; use crate::{ command::{CommandBuffer, CommandEncoderError}, - device::DeviceError, + device::{DeviceError, MissingFeatures}, global::Global, hal_api::HalApi, id::{self, Id}, @@ -108,6 +108,8 @@ pub enum QueryError { Device(#[from] DeviceError), #[error(transparent)] Encoder(#[from] CommandEncoderError), + #[error(transparent)] + MissingFeature(#[from] MissingFeatures), #[error("Error encountered while trying to use queries")] Use(#[from] QueryUseError), #[error("Error encountered while trying to resolve a query")] @@ -355,6 +357,11 @@ impl Global { let hub = A::hub(self); let cmd_buf = CommandBuffer::get_encoder(hub, command_encoder_id)?; + + cmd_buf + .device + .require_features(wgt::Features::TIMESTAMP_QUERY_INSIDE_ENCODERS)?; + let mut cmd_buf_data = cmd_buf.data.lock(); let cmd_buf_data = cmd_buf_data.as_mut().unwrap(); diff --git a/wgpu-core/src/command/render.rs b/wgpu-core/src/command/render.rs index 8acde08196..7e859e3cc8 100644 --- a/wgpu-core/src/command/render.rs +++ b/wgpu-core/src/command/render.rs @@ -22,7 +22,7 @@ use crate::{ hal_label, id, init_tracker::{MemoryInitKind, TextureInitRange, TextureInitTrackerAction}, pipeline::{self, PipelineFlags}, - resource::{Buffer, QuerySet, Texture, TextureView, TextureViewNotRenderableReason}, + resource::{QuerySet, Texture, TextureView, TextureViewNotRenderableReason}, storage::Storage, track::{TextureSelector, Tracker, UsageConflict, UsageScope}, validation::{ @@ -739,9 +739,9 @@ impl TextureView { const MAX_TOTAL_ATTACHMENTS: usize = hal::MAX_COLOR_ATTACHMENTS + hal::MAX_COLOR_ATTACHMENTS + 1; type AttachmentDataVec = ArrayVec; -struct RenderPassInfo<'a, A: HalApi> { +struct RenderPassInfo<'a, 'd, A: HalApi> { context: RenderPassContext, - usage_scope: UsageScope, + usage_scope: UsageScope<'d, A>, /// All render attachments, including depth/stencil render_attachments: AttachmentDataVec>, is_depth_read_only: bool, @@ -754,7 +754,7 @@ struct RenderPassInfo<'a, A: HalApi> { multiview: Option, } -impl<'a, A: HalApi> RenderPassInfo<'a, A> { +impl<'a, 'd, A: HalApi> RenderPassInfo<'a, 'd, A> { fn add_pass_texture_init_actions( channel: &PassChannel, texture_memory_actions: &mut CommandBufferTextureMemoryActions, @@ -790,7 +790,7 @@ impl<'a, A: HalApi> RenderPassInfo<'a, A> { } fn start( - device: &Device, + device: &'d Device, label: Option<&str>, color_attachments: &[Option], depth_stencil_attachment: Option<&RenderPassDepthStencilAttachment>, @@ -801,8 +801,6 @@ impl<'a, A: HalApi> RenderPassInfo<'a, A> { texture_memory_actions: &mut CommandBufferTextureMemoryActions, pending_query_resets: &mut QueryResetMap, view_guard: &'a Storage>, - buffer_guard: &'a Storage>, - texture_guard: &'a Storage>, query_set_guard: &'a Storage>, snatch_guard: &SnatchGuard<'a>, ) -> Result { @@ -1216,7 +1214,7 @@ impl<'a, A: HalApi> RenderPassInfo<'a, A> { Ok(Self { context, - usage_scope: UsageScope::new(buffer_guard, texture_guard), + usage_scope: device.new_usage_scope(), render_attachments, is_depth_read_only, is_stencil_read_only, @@ -1232,7 +1230,7 @@ impl<'a, A: HalApi> RenderPassInfo<'a, A> { mut self, raw: &mut A::CommandEncoder, snatch_guard: &SnatchGuard, - ) -> Result<(UsageScope, SurfacesInDiscardState), RenderPassErrorInner> { + ) -> Result<(UsageScope<'d, A>, SurfacesInDiscardState), RenderPassErrorInner> { profiling::scope!("RenderPassInfo::finish"); unsafe { raw.end_render_pass(); @@ -1388,7 +1386,6 @@ impl Global { let render_pipeline_guard = hub.render_pipelines.read(); let query_set_guard = hub.query_sets.read(); let buffer_guard = hub.buffers.read(); - let texture_guard = hub.textures.read(); let view_guard = hub.texture_views.read(); log::trace!( @@ -1408,24 +1405,21 @@ impl Global { texture_memory_actions, pending_query_resets, &*view_guard, - &*buffer_guard, - &*texture_guard, &*query_set_guard, &snatch_guard, ) .map_pass_err(pass_scope)?; - tracker.set_size( - Some(&*buffer_guard), - Some(&*texture_guard), - Some(&*view_guard), - None, - Some(&*bind_group_guard), - None, - Some(&*render_pipeline_guard), - Some(&*bundle_guard), - Some(&*query_set_guard), - ); + let indices = &device.tracker_indices; + tracker.buffers.set_size(indices.buffers.size()); + tracker.textures.set_size(indices.textures.size()); + tracker.views.set_size(indices.texture_views.size()); + tracker.bind_groups.set_size(indices.bind_groups.size()); + tracker + .render_pipelines + .set_size(indices.render_pipelines.size()); + tracker.bundles.set_size(indices.bundles.size()); + tracker.query_sets.set_size(indices.query_sets.size()); let raw = &mut encoder.raw; @@ -1677,7 +1671,7 @@ impl Global { return Err(DeviceError::WrongDevice).map_pass_err(scope); } - check_buffer_usage(buffer.usage, BufferUsages::INDEX) + check_buffer_usage(buffer_id, buffer.usage, BufferUsages::INDEX) .map_pass_err(scope)?; let buf_raw = buffer .raw @@ -1739,7 +1733,7 @@ impl Global { .map_pass_err(scope); } - check_buffer_usage(buffer.usage, BufferUsages::VERTEX) + check_buffer_usage(buffer_id, buffer.usage, BufferUsages::VERTEX) .map_pass_err(scope)?; let buf_raw = buffer .raw @@ -2036,8 +2030,12 @@ impl Global { .buffers .merge_single(&*buffer_guard, buffer_id, hal::BufferUses::INDIRECT) .map_pass_err(scope)?; - check_buffer_usage(indirect_buffer.usage, BufferUsages::INDIRECT) - .map_pass_err(scope)?; + check_buffer_usage( + buffer_id, + indirect_buffer.usage, + BufferUsages::INDIRECT, + ) + .map_pass_err(scope)?; let indirect_raw = indirect_buffer .raw .get(&snatch_guard) @@ -2108,8 +2106,12 @@ impl Global { .buffers .merge_single(&*buffer_guard, buffer_id, hal::BufferUses::INDIRECT) .map_pass_err(scope)?; - check_buffer_usage(indirect_buffer.usage, BufferUsages::INDIRECT) - .map_pass_err(scope)?; + check_buffer_usage( + buffer_id, + indirect_buffer.usage, + BufferUsages::INDIRECT, + ) + .map_pass_err(scope)?; let indirect_raw = indirect_buffer .raw .get(&snatch_guard) @@ -2125,7 +2127,7 @@ impl Global { hal::BufferUses::INDIRECT, ) .map_pass_err(scope)?; - check_buffer_usage(count_buffer.usage, BufferUsages::INDIRECT) + check_buffer_usage(buffer_id, count_buffer.usage, BufferUsages::INDIRECT) .map_pass_err(scope)?; let count_raw = count_buffer .raw @@ -2372,7 +2374,7 @@ impl Global { .extend(texture_memory_actions.register_init_action(action)); } - unsafe { bundle.execute(raw) } + unsafe { bundle.execute(raw, &snatch_guard) } .map_err(|e| match e { ExecutionError::DestroyedBuffer(id) => { RenderCommandError::DestroyedBuffer(id) @@ -2425,6 +2427,7 @@ impl Global { transit, &mut tracker.textures, &cmd_buf.device, + &snatch_guard, ); cmd_buf_data diff --git a/wgpu-core/src/command/transfer.rs b/wgpu-core/src/command/transfer.rs index 0a952dfc84..8e98a4c9b9 100644 --- a/wgpu-core/src/command/transfer.rs +++ b/wgpu-core/src/command/transfer.rs @@ -14,6 +14,7 @@ use crate::{ TextureInitTrackerAction, }, resource::{Resource, Texture, TextureErrorDimension}, + snatch::SnatchGuard, track::{TextureSelector, Tracker}, }; @@ -452,6 +453,7 @@ fn handle_texture_init( copy_texture: &ImageCopyTexture, copy_size: &Extent3d, texture: &Arc>, + snatch_guard: &SnatchGuard<'_>, ) -> Result<(), ClearError> { let init_action = TextureInitTrackerAction { texture: texture.clone(), @@ -480,6 +482,7 @@ fn handle_texture_init( &mut trackers.textures, &device.alignments, device.zero_buffer.as_ref().unwrap(), + snatch_guard, )?; } } @@ -499,6 +502,7 @@ fn handle_src_texture_init( source: &ImageCopyTexture, copy_size: &Extent3d, texture: &Arc>, + snatch_guard: &SnatchGuard<'_>, ) -> Result<(), TransferError> { handle_texture_init( MemoryInitKind::NeedsInitializedMemory, @@ -509,6 +513,7 @@ fn handle_src_texture_init( source, copy_size, texture, + snatch_guard, )?; Ok(()) } @@ -525,6 +530,7 @@ fn handle_dst_texture_init( destination: &ImageCopyTexture, copy_size: &Extent3d, texture: &Arc>, + snatch_guard: &SnatchGuard<'_>, ) -> Result<(), TransferError> { // Attention: If we don't write full texture subresources, we need to a full // clear first since we don't track subrects. This means that in rare cases @@ -549,6 +555,7 @@ fn handle_dst_texture_init( destination, copy_size, texture, + snatch_guard, )?; Ok(()) } @@ -779,6 +786,8 @@ impl Global { let (dst_range, dst_base) = extract_texture_selector(destination, copy_size, &dst_texture)?; + let snatch_guard = device.snatchable_lock.read(); + // Handle texture init *before* dealing with barrier transitions so we // have an easier time inserting "immediate-inits" that may be required // by prior discards in rare cases. @@ -790,10 +799,9 @@ impl Global { destination, copy_size, &dst_texture, + &snatch_guard, )?; - let snatch_guard = device.snatchable_lock.read(); - let (src_buffer, src_pending) = { let buffer_guard = hub.buffers.read(); let src_buffer = buffer_guard @@ -935,6 +943,8 @@ impl Global { let (src_range, src_base) = extract_texture_selector(source, copy_size, &src_texture)?; + let snatch_guard = device.snatchable_lock.read(); + // Handle texture init *before* dealing with barrier transitions so we // have an easier time inserting "immediate-inits" that may be required // by prior discards in rare cases. @@ -946,10 +956,9 @@ impl Global { source, copy_size, &src_texture, + &snatch_guard, )?; - let snatch_guard = device.snatchable_lock.read(); - let src_pending = tracker .textures .set_single(&src_texture, src_range, hal::TextureUses::COPY_SRC) @@ -1152,6 +1161,7 @@ impl Global { source, copy_size, &src_texture, + &snatch_guard, )?; handle_dst_texture_init( encoder, @@ -1161,6 +1171,7 @@ impl Global { destination, copy_size, &dst_texture, + &snatch_guard, )?; let src_pending = cmd_buf_data diff --git a/wgpu-core/src/device/global.rs b/wgpu-core/src/device/global.rs index e5c4e733b5..0c97e1b504 100644 --- a/wgpu-core/src/device/global.rs +++ b/wgpu-core/src/device/global.rs @@ -192,7 +192,15 @@ impl Global { let ptr = if map_size == 0 { std::ptr::NonNull::dangling() } else { - match map_buffer(device.raw(), &buffer, 0, map_size, HostMap::Write) { + let snatch_guard = device.snatchable_lock.read(); + match map_buffer( + device.raw(), + &buffer, + 0, + map_size, + HostMap::Write, + &snatch_guard, + ) { Ok(ptr) => ptr, Err(e) => { to_destroy.push(buffer); @@ -217,7 +225,7 @@ impl Global { mapped_at_creation: false, }; let stage = match device.create_buffer(&stage_desc, true) { - Ok(stage) => stage, + Ok(stage) => Arc::new(stage), Err(e) => { to_destroy.push(buffer); break e; @@ -230,14 +238,10 @@ impl Global { Ok(mapping) => mapping, Err(e) => { to_destroy.push(buffer); - to_destroy.push(stage); break CreateBufferError::Device(e.into()); } }; - let stage_fid = hub.buffers.request(); - let stage = stage_fid.init(stage); - assert_eq!(buffer.size % wgt::COPY_BUFFER_ALIGNMENT, 0); // Zero initialize memory and then mark both staging and buffer as initialized // (it's guaranteed that this is the case by the time the buffer is usable) @@ -260,7 +264,7 @@ impl Global { .trackers .lock() .buffers - .insert_single(id, resource, buffer_use); + .insert_single(resource, buffer_use); return (id, None); }; @@ -381,7 +385,7 @@ impl Global { .buffers .get(buffer_id) .map_err(|_| BufferAccessError::Invalid)?; - check_buffer_usage(buffer.usage, wgt::BufferUsages::MAP_WRITE)?; + check_buffer_usage(buffer_id, buffer.usage, wgt::BufferUsages::MAP_WRITE)?; //assert!(buffer isn't used by the GPU); #[cfg(feature = "trace")] @@ -444,7 +448,7 @@ impl Global { .buffers .get(buffer_id) .map_err(|_| BufferAccessError::Invalid)?; - check_buffer_usage(buffer.usage, wgt::BufferUsages::MAP_READ)?; + check_buffer_usage(buffer_id, buffer.usage, wgt::BufferUsages::MAP_READ)?; //assert!(buffer isn't used by the GPU); let raw_buf = buffer @@ -527,7 +531,7 @@ impl Global { .lock_life() .suspected_resources .buffers - .insert(buffer_id, buffer); + .insert(buffer.info.tracker_index(), buffer); } if wait { @@ -571,11 +575,11 @@ impl Global { let (id, resource) = fid.assign(texture); api_log!("Device::create_texture({desc:?}) -> {id:?}"); - device.trackers.lock().textures.insert_single( - id, - resource, - hal::TextureUses::UNINITIALIZED, - ); + device + .trackers + .lock() + .textures + .insert_single(resource, hal::TextureUses::UNINITIALIZED); return (id, None); }; @@ -645,11 +649,11 @@ impl Global { let (id, resource) = fid.assign(texture); api_log!("Device::create_texture({desc:?}) -> {id:?}"); - device.trackers.lock().textures.insert_single( - id, - resource, - hal::TextureUses::UNINITIALIZED, - ); + device + .trackers + .lock() + .textures + .insert_single(resource, hal::TextureUses::UNINITIALIZED); return (id, None); }; @@ -702,7 +706,7 @@ impl Global { .trackers .lock() .buffers - .insert_single(id, buffer, hal::BufferUses::empty()); + .insert_single(buffer, hal::BufferUses::empty()); return (id, None); }; @@ -762,7 +766,7 @@ impl Global { .lock_life() .suspected_resources .textures - .insert(texture_id, texture.clone()); + .insert(texture.info.tracker_index(), texture.clone()); } } @@ -822,7 +826,7 @@ impl Global { } api_log!("Texture::create_view({texture_id:?}) -> {id:?}"); - device.trackers.lock().views.insert_single(id, resource); + device.trackers.lock().views.insert_single(resource); return (id, None); }; @@ -852,7 +856,7 @@ impl Global { .lock_life() .suspected_resources .texture_views - .insert(texture_view_id, view.clone()); + .insert(view.info.tracker_index(), view.clone()); if wait { match view.device.wait_for_submit(last_submit_index) { @@ -898,7 +902,7 @@ impl Global { let (id, resource) = fid.assign(sampler); api_log!("Device::create_sampler -> {id:?}"); - device.trackers.lock().samplers.insert_single(id, resource); + device.trackers.lock().samplers.insert_single(resource); return (id, None); }; @@ -923,7 +927,7 @@ impl Global { .lock_life() .suspected_resources .samplers - .insert(sampler_id, sampler.clone()); + .insert(sampler.info.tracker_index(), sampler.clone()); } } @@ -1022,7 +1026,7 @@ impl Global { .lock_life() .suspected_resources .bind_group_layouts - .insert(bind_group_layout_id, layout.clone()); + .insert(layout.info.tracker_index(), layout.clone()); } } @@ -1083,7 +1087,7 @@ impl Global { .lock_life() .suspected_resources .pipeline_layouts - .insert(pipeline_layout_id, layout.clone()); + .insert(layout.info.tracker_index(), layout.clone()); } } @@ -1138,11 +1142,7 @@ impl Global { api_log!("Device::create_bind_group -> {id:?}"); - device - .trackers - .lock() - .bind_groups - .insert_single(id, resource); + device.trackers.lock().bind_groups.insert_single(resource); return (id, None); }; @@ -1166,7 +1166,7 @@ impl Global { .lock_life() .suspected_resources .bind_groups - .insert(bind_group_id, bind_group.clone()); + .insert(bind_group.info.tracker_index(), bind_group.clone()); } } @@ -1330,9 +1330,8 @@ impl Global { if !device.is_valid() { break DeviceError::Lost; } - let queue = match hub.queues.get(device.queue_id.read().unwrap()) { - Ok(queue) => queue, - Err(_) => break DeviceError::InvalidQueueId, + let Some(queue) = device.get_queue() else { + break DeviceError::InvalidQueueId; }; let encoder = match device .command_allocator @@ -1377,6 +1376,7 @@ impl Global { .command_buffers .unregister(command_encoder_id.transmute()) { + cmd_buf.data.lock().as_mut().unwrap().encoder.discard(); cmd_buf .device .untrack(&cmd_buf.data.lock().as_ref().unwrap().trackers); @@ -1448,7 +1448,7 @@ impl Global { let (id, resource) = fid.assign(render_bundle); api_log!("RenderBundleEncoder::finish -> {id:?}"); - device.trackers.lock().bundles.insert_single(id, resource); + device.trackers.lock().bundles.insert_single(resource); return (id, None); }; @@ -1472,7 +1472,7 @@ impl Global { .lock_life() .suspected_resources .render_bundles - .insert(render_bundle_id, bundle.clone()); + .insert(bundle.info.tracker_index(), bundle.clone()); } } @@ -1511,11 +1511,7 @@ impl Global { let (id, resource) = fid.assign(query_set); api_log!("Device::create_query_set -> {id:?}"); - device - .trackers - .lock() - .query_sets - .insert_single(id, resource); + device.trackers.lock().query_sets.insert_single(resource); return (id, None); }; @@ -1542,7 +1538,7 @@ impl Global { .lock_life() .suspected_resources .query_sets - .insert(query_set_id, query_set.clone()); + .insert(query_set.info.tracker_index(), query_set.clone()); } } @@ -1598,7 +1594,7 @@ impl Global { .trackers .lock() .render_pipelines - .insert_single(id, resource); + .insert_single(resource); return (id, None); }; @@ -1670,18 +1666,17 @@ impl Global { let hub = A::hub(self); if let Some(pipeline) = hub.render_pipelines.unregister(render_pipeline_id) { - let layout_id = pipeline.layout.as_info().id(); let device = &pipeline.device; let mut life_lock = device.lock_life(); life_lock .suspected_resources .render_pipelines - .insert(render_pipeline_id, pipeline.clone()); + .insert(pipeline.info.tracker_index(), pipeline.clone()); - life_lock - .suspected_resources - .pipeline_layouts - .insert(layout_id, pipeline.layout.clone()); + life_lock.suspected_resources.pipeline_layouts.insert( + pipeline.layout.info.tracker_index(), + pipeline.layout.clone(), + ); } } @@ -1732,7 +1727,7 @@ impl Global { .trackers .lock() .compute_pipelines - .insert_single(id, resource); + .insert_single(resource); return (id, None); }; @@ -1802,17 +1797,16 @@ impl Global { let hub = A::hub(self); if let Some(pipeline) = hub.compute_pipelines.unregister(compute_pipeline_id) { - let layout_id = pipeline.layout.as_info().id(); let device = &pipeline.device; let mut life_lock = device.lock_life(); life_lock .suspected_resources .compute_pipelines - .insert(compute_pipeline_id, pipeline.clone()); - life_lock - .suspected_resources - .pipeline_layouts - .insert(layout_id, pipeline.layout.clone()); + .insert(pipeline.info.tracker_index(), pipeline.clone()); + life_lock.suspected_resources.pipeline_layouts.insert( + pipeline.layout.info.tracker_index(), + pipeline.layout.clone(), + ); } } @@ -2022,9 +2016,10 @@ impl Global { } // Wait for all work to finish before configuring the surface. + let snatch_guard = device.snatchable_lock.read(); let fence = device.fence.read(); let fence = fence.as_ref().unwrap(); - match device.maintain(fence, wgt::Maintain::Wait) { + match device.maintain(fence, wgt::Maintain::Wait, snatch_guard) { Ok((closures, _)) => { user_callbacks = closures; } @@ -2111,28 +2106,42 @@ impl Global { .get(device_id) .map_err(|_| DeviceError::Invalid)?; - let (closures, queue_empty) = { - if let wgt::Maintain::WaitForSubmissionIndex(submission_index) = maintain { - if submission_index.queue_id != device_id.transmute() { - return Err(WaitIdleError::WrongSubmissionIndex( - submission_index.queue_id, - device_id, - )); - } + if let wgt::Maintain::WaitForSubmissionIndex(submission_index) = maintain { + if submission_index.queue_id != device_id.transmute() { + return Err(WaitIdleError::WrongSubmissionIndex( + submission_index.queue_id, + device_id, + )); } + } - let fence = device.fence.read(); - let fence = fence.as_ref().unwrap(); - device.maintain(fence, maintain)? - }; + let DevicePoll { + closures, + queue_empty, + } = Self::poll_single_device(&device, maintain)?; + + closures.fire(); + + Ok(queue_empty) + } + + fn poll_single_device( + device: &crate::device::Device, + maintain: wgt::Maintain, + ) -> Result { + let snatch_guard = device.snatchable_lock.read(); + let fence = device.fence.read(); + let fence = fence.as_ref().unwrap(); + let (closures, queue_empty) = device.maintain(fence, maintain, snatch_guard)?; // Some deferred destroys are scheduled in maintain so run this right after // to avoid holding on to them until the next device poll. device.deferred_resource_destruction(); - closures.fire(); - - Ok(queue_empty) + Ok(DevicePoll { + closures, + queue_empty, + }) } /// Poll all devices belonging to the backend `A`. @@ -2141,7 +2150,7 @@ impl Global { /// /// Return `all_queue_empty` indicating whether there are more queue /// submissions still in flight. - fn poll_device( + fn poll_all_devices_of_api( &self, force_wait: bool, closures: &mut UserClosures, @@ -2159,10 +2168,13 @@ impl Global { } else { wgt::Maintain::Poll }; - let fence = device.fence.read(); - let fence = fence.as_ref().unwrap(); - let (cbs, queue_empty) = device.maintain(fence, maintain)?; - all_queue_empty = all_queue_empty && queue_empty; + + let DevicePoll { + closures: cbs, + queue_empty, + } = Self::poll_single_device(device, maintain)?; + + all_queue_empty &= queue_empty; closures.extend(cbs); } @@ -2184,23 +2196,23 @@ impl Global { #[cfg(vulkan)] { - all_queue_empty = - self.poll_device::(force_wait, &mut closures)? && all_queue_empty; + all_queue_empty &= + self.poll_all_devices_of_api::(force_wait, &mut closures)?; } #[cfg(metal)] { - all_queue_empty = - self.poll_device::(force_wait, &mut closures)? && all_queue_empty; + all_queue_empty &= + self.poll_all_devices_of_api::(force_wait, &mut closures)?; } #[cfg(dx12)] { - all_queue_empty = - self.poll_device::(force_wait, &mut closures)? && all_queue_empty; + all_queue_empty &= + self.poll_all_devices_of_api::(force_wait, &mut closures)?; } #[cfg(gles)] { - all_queue_empty = - self.poll_device::(force_wait, &mut closures)? && all_queue_empty; + all_queue_empty &= + self.poll_all_devices_of_api::(force_wait, &mut closures)?; } closures.fire(); @@ -2238,6 +2250,15 @@ impl Global { } } + // This is a test-only function to force the device into an + // invalid state by inserting an error value in its place in + // the registry. + pub fn device_make_invalid(&self, device_id: DeviceId) { + let hub = A::hub(self); + hub.devices + .force_replace_with_error(device_id, "Made invalid."); + } + pub fn device_drop(&self, device_id: DeviceId) { profiling::scope!("Device::drop"); api_log!("Device::drop {device_id:?}"); @@ -2273,7 +2294,7 @@ impl Global { ) { let hub = A::hub(self); - if let Ok(device) = hub.devices.get(device_id) { + if let Ok(Some(device)) = hub.devices.try_get(device_id) { let mut life_tracker = device.lock_life(); if let Some(existing_closure) = life_tracker.device_lost_closure.take() { // It's important to not hold the lock while calling the closure. @@ -2282,6 +2303,12 @@ impl Global { life_tracker = device.lock_life(); } life_tracker.device_lost_closure = Some(device_lost_closure); + } else { + // No device? Okay. Just like we have to call any existing closure + // before we drop it, we need to call this closure before we exit + // this function, because there's no device that is ever going to + // call it. + device_lost_closure.call(DeviceLostReason::DeviceInvalid, "".to_string()); } } @@ -2417,7 +2444,7 @@ impl Global { return Err((op, DeviceError::Lost.into())); } - if let Err(e) = check_buffer_usage(buffer.usage, pub_usage) { + if let Err(e) = check_buffer_usage(buffer.info.id(), buffer.usage, pub_usage) { return Err((op, e.into())); } @@ -2577,3 +2604,8 @@ impl Global { buffer.unmap() } } + +struct DevicePoll { + closures: UserClosures, + queue_empty: bool, +} diff --git a/wgpu-core/src/device/life.rs b/wgpu-core/src/device/life.rs index 86c5d027c7..af345015df 100644 --- a/wgpu-core/src/device/life.rs +++ b/wgpu-core/src/device/life.rs @@ -6,17 +6,14 @@ use crate::{ DeviceError, DeviceLostClosure, }, hal_api::HalApi, - id::{ - self, BindGroupId, BindGroupLayoutId, BufferId, ComputePipelineId, Id, PipelineLayoutId, - QuerySetId, RenderBundleId, RenderPipelineId, SamplerId, StagingBufferId, TextureId, - TextureViewId, - }, + id, pipeline::{ComputePipeline, RenderPipeline}, resource::{ self, Buffer, DestroyedBuffer, DestroyedTexture, QuerySet, Resource, Sampler, StagingBuffer, Texture, TextureView, }, - track::{ResourceTracker, Tracker}, + snatch::SnatchGuard, + track::{ResourceTracker, Tracker, TrackerIndex}, FastHashMap, SubmissionIndex, }; use smallvec::SmallVec; @@ -28,20 +25,20 @@ use thiserror::Error; /// A struct that keeps lists of resources that are no longer needed by the user. #[derive(Default)] pub(crate) struct ResourceMaps { - pub buffers: FastHashMap>>, - pub staging_buffers: FastHashMap>>, - pub textures: FastHashMap>>, - pub texture_views: FastHashMap>>, - pub samplers: FastHashMap>>, - pub bind_groups: FastHashMap>>, - pub bind_group_layouts: FastHashMap>>, - pub render_pipelines: FastHashMap>>, - pub compute_pipelines: FastHashMap>>, - pub pipeline_layouts: FastHashMap>>, - pub render_bundles: FastHashMap>>, - pub query_sets: FastHashMap>>, - pub destroyed_buffers: FastHashMap>>, - pub destroyed_textures: FastHashMap>>, + pub buffers: FastHashMap>>, + pub staging_buffers: FastHashMap>>, + pub textures: FastHashMap>>, + pub texture_views: FastHashMap>>, + pub samplers: FastHashMap>>, + pub bind_groups: FastHashMap>>, + pub bind_group_layouts: FastHashMap>>, + pub render_pipelines: FastHashMap>>, + pub compute_pipelines: FastHashMap>>, + pub pipeline_layouts: FastHashMap>>, + pub render_bundles: FastHashMap>>, + pub query_sets: FastHashMap>>, + pub destroyed_buffers: FastHashMap>>, + pub destroyed_textures: FastHashMap>>, } impl ResourceMaps { @@ -276,25 +273,29 @@ impl LifetimeTracker { for res in temp_resources { match res { TempResource::Buffer(raw) => { - last_resources.buffers.insert(raw.as_info().id(), raw); + last_resources + .buffers + .insert(raw.as_info().tracker_index(), raw); } TempResource::StagingBuffer(raw) => { last_resources .staging_buffers - .insert(raw.as_info().id(), raw); + .insert(raw.as_info().tracker_index(), raw); } TempResource::DestroyedBuffer(destroyed) => { last_resources .destroyed_buffers - .insert(destroyed.id, destroyed); + .insert(destroyed.tracker_index, destroyed); } TempResource::Texture(raw) => { - last_resources.textures.insert(raw.as_info().id(), raw); + last_resources + .textures + .insert(raw.as_info().tracker_index(), raw); } TempResource::DestroyedTexture(destroyed) => { last_resources .destroyed_textures - .insert(destroyed.id, destroyed); + .insert(destroyed.tracker_index, destroyed); } } } @@ -309,13 +310,15 @@ impl LifetimeTracker { } pub fn post_submit(&mut self) { - for v in self.future_suspected_buffers.drain(..).take(1) { - self.suspected_resources.buffers.insert(v.as_info().id(), v); + for v in self.future_suspected_buffers.drain(..) { + self.suspected_resources + .buffers + .insert(v.as_info().tracker_index(), v); } - for v in self.future_suspected_textures.drain(..).take(1) { + for v in self.future_suspected_textures.drain(..) { self.suspected_resources .textures - .insert(v.as_info().id(), v); + .insert(v.as_info().tracker_index(), v); } } @@ -386,19 +389,27 @@ impl LifetimeTracker { if let Some(resources) = resources { match temp_resource { TempResource::Buffer(raw) => { - resources.buffers.insert(raw.as_info().id(), raw); + resources.buffers.insert(raw.as_info().tracker_index(), raw); } TempResource::StagingBuffer(raw) => { - resources.staging_buffers.insert(raw.as_info().id(), raw); + resources + .staging_buffers + .insert(raw.as_info().tracker_index(), raw); } TempResource::DestroyedBuffer(destroyed) => { - resources.destroyed_buffers.insert(destroyed.id, destroyed); + resources + .destroyed_buffers + .insert(destroyed.tracker_index, destroyed); } TempResource::Texture(raw) => { - resources.textures.insert(raw.as_info().id(), raw); + resources + .textures + .insert(raw.as_info().tracker_index(), raw); } TempResource::DestroyedTexture(destroyed) => { - resources.destroyed_textures.insert(destroyed.id, destroyed); + resources + .destroyed_textures + .insert(destroyed.tracker_index, destroyed); } } } @@ -420,27 +431,27 @@ impl LifetimeTracker { impl LifetimeTracker { fn triage_resources( - resources_map: &mut FastHashMap, Arc>, + resources_map: &mut FastHashMap>, active: &mut [ActiveSubmission], - trackers: &mut impl ResourceTracker, - get_resource_map: impl Fn(&mut ResourceMaps) -> &mut FastHashMap, Arc>, + trackers: &mut impl ResourceTracker, + get_resource_map: impl Fn(&mut ResourceMaps) -> &mut FastHashMap>, ) -> Vec> where R: Resource, { let mut removed_resources = Vec::new(); - resources_map.retain(|&id, resource| { + resources_map.retain(|&index, resource| { let submit_index = resource.as_info().submission_index(); let non_referenced_resources = active .iter_mut() .find(|a| a.index == submit_index) .map(|a| &mut a.last_resources); - let is_removed = trackers.remove_abandoned(id); + let is_removed = trackers.remove_abandoned(index); if is_removed { removed_resources.push(resource.clone()); if let Some(resources) = non_referenced_resources { - get_resource_map(resources).insert(id, resource.clone()); + get_resource_map(resources).insert(index, resource.clone()); } } !is_removed @@ -459,27 +470,29 @@ impl LifetimeTracker { ); removed_resources.drain(..).for_each(|bundle| { for v in bundle.used.buffers.write().drain_resources() { - self.suspected_resources.buffers.insert(v.as_info().id(), v); + self.suspected_resources + .buffers + .insert(v.as_info().tracker_index(), v); } for v in bundle.used.textures.write().drain_resources() { self.suspected_resources .textures - .insert(v.as_info().id(), v); + .insert(v.as_info().tracker_index(), v); } for v in bundle.used.bind_groups.write().drain_resources() { self.suspected_resources .bind_groups - .insert(v.as_info().id(), v); + .insert(v.as_info().tracker_index(), v); } for v in bundle.used.render_pipelines.write().drain_resources() { self.suspected_resources .render_pipelines - .insert(v.as_info().id(), v); + .insert(v.as_info().tracker_index(), v); } for v in bundle.used.query_sets.write().drain_resources() { self.suspected_resources .query_sets - .insert(v.as_info().id(), v); + .insert(v.as_info().tracker_index(), v); } }); self @@ -496,27 +509,30 @@ impl LifetimeTracker { ); removed_resource.drain(..).for_each(|bind_group| { for v in bind_group.used.buffers.drain_resources() { - self.suspected_resources.buffers.insert(v.as_info().id(), v); + self.suspected_resources + .buffers + .insert(v.as_info().tracker_index(), v); } for v in bind_group.used.textures.drain_resources() { self.suspected_resources .textures - .insert(v.as_info().id(), v); + .insert(v.as_info().tracker_index(), v); } for v in bind_group.used.views.drain_resources() { self.suspected_resources .texture_views - .insert(v.as_info().id(), v); + .insert(v.as_info().tracker_index(), v); } for v in bind_group.used.samplers.drain_resources() { self.suspected_resources .samplers - .insert(v.as_info().id(), v); + .insert(v.as_info().tracker_index(), v); } - self.suspected_resources - .bind_group_layouts - .insert(bind_group.layout.as_info().id(), bind_group.layout.clone()); + self.suspected_resources.bind_group_layouts.insert( + bind_group.layout.as_info().tracker_index(), + bind_group.layout.clone(), + ); }); self } @@ -605,7 +621,7 @@ impl LifetimeTracker { ); removed_resources.drain(..).for_each(|compute_pipeline| { self.suspected_resources.pipeline_layouts.insert( - compute_pipeline.layout.as_info().id(), + compute_pipeline.layout.as_info().tracker_index(), compute_pipeline.layout.clone(), ); }); @@ -623,7 +639,7 @@ impl LifetimeTracker { ); removed_resources.drain(..).for_each(|render_pipeline| { self.suspected_resources.pipeline_layouts.insert( - render_pipeline.layout.as_info().id(), + render_pipeline.layout.as_info().tracker_index(), render_pipeline.layout.clone(), ); }); @@ -642,7 +658,7 @@ impl LifetimeTracker { for bgl in &pipeline_layout.bind_group_layouts { self.suspected_resources .bind_group_layouts - .insert(bgl.as_info().id(), bgl.clone()); + .insert(bgl.as_info().tracker_index(), bgl.clone()); } }); self @@ -765,6 +781,7 @@ impl LifetimeTracker { &mut self, raw: &A::Device, trackers: &Mutex>, + snatch_guard: &SnatchGuard, ) -> Vec { if self.ready_to_map.is_empty() { return Vec::new(); @@ -773,14 +790,14 @@ impl LifetimeTracker { Vec::with_capacity(self.ready_to_map.len()); for buffer in self.ready_to_map.drain(..) { - let buffer_id = buffer.info.id(); + let tracker_index = buffer.info.tracker_index(); let is_removed = { let mut trackers = trackers.lock(); - trackers.buffers.remove_abandoned(buffer_id) + trackers.buffers.remove_abandoned(tracker_index) }; if is_removed { *buffer.map_state.lock() = resource::BufferMapState::Idle; - log::trace!("Buffer ready to map {:?} is not tracked anymore", buffer_id); + log::trace!("Buffer ready to map {tracker_index:?} is not tracked anymore"); } else { let mapping = match std::mem::replace( &mut *buffer.map_state.lock(), @@ -798,10 +815,17 @@ impl LifetimeTracker { _ => panic!("No pending mapping."), }; let status = if mapping.range.start != mapping.range.end { - log::debug!("Buffer {:?} map state -> Active", buffer_id); + log::debug!("Buffer {tracker_index:?} map state -> Active"); let host = mapping.op.host; let size = mapping.range.end - mapping.range.start; - match super::map_buffer(raw, &buffer, mapping.range.start, size, host) { + match super::map_buffer( + raw, + &buffer, + mapping.range.start, + size, + host, + snatch_guard, + ) { Ok(ptr) => { *buffer.map_state.lock() = resource::BufferMapState::Active { ptr, diff --git a/wgpu-core/src/device/mod.rs b/wgpu-core/src/device/mod.rs index 7ecda830a3..e2ab6c2690 100644 --- a/wgpu-core/src/device/mod.rs +++ b/wgpu-core/src/device/mod.rs @@ -3,9 +3,10 @@ use crate::{ hal_api::HalApi, hub::Hub, id::{BindGroupLayoutId, PipelineLayoutId}, - resource::{Buffer, BufferAccessResult}, - resource::{BufferAccessError, BufferMapOperation}, - resource_log, Label, DOWNLEVEL_ERROR_MESSAGE, + resource::{Buffer, BufferAccessError, BufferAccessResult, BufferMapOperation}, + resource_log, + snatch::SnatchGuard, + Label, DOWNLEVEL_ERROR_MESSAGE, }; use arrayvec::ArrayVec; @@ -317,10 +318,10 @@ fn map_buffer( offset: BufferAddress, size: BufferAddress, kind: HostMap, + snatch_guard: &SnatchGuard, ) -> Result, BufferAccessError> { - let snatch_guard = buffer.device.snatchable_lock.read(); let raw_buffer = buffer - .raw(&snatch_guard) + .raw(snatch_guard) .ok_or(BufferAccessError::Destroyed)?; let mapping = unsafe { raw.map_buffer(raw_buffer, offset..offset + size) diff --git a/wgpu-core/src/device/queue.rs b/wgpu-core/src/device/queue.rs index a280abd9b3..3cb5f695a7 100644 --- a/wgpu-core/src/device/queue.rs +++ b/wgpu-core/src/device/queue.rs @@ -12,7 +12,7 @@ use crate::{ global::Global, hal_api::HalApi, hal_label, - id::{self, QueueId}, + id::{self, DeviceId, QueueId}, init_tracker::{has_copy_partial_init_tracker_coverage, TextureInitRange}, resource::{ Buffer, BufferAccessError, BufferMapState, DestroyedBuffer, DestroyedTexture, Resource, @@ -310,7 +310,10 @@ fn prepare_staging_buffer( raw: Mutex::new(Some(buffer)), device: device.clone(), size, - info: ResourceInfo::new(""), + info: ResourceInfo::new( + "", + Some(device.tracker_indices.staging_buffers.clone()), + ), is_coherent: mapping.is_coherent, }; @@ -339,6 +342,15 @@ pub struct InvalidQueue; #[derive(Clone, Debug, Error)] #[non_exhaustive] pub enum QueueWriteError { + #[error( + "Device of queue ({:?}) does not match device of write recipient ({:?})", + queue_device_id, + target_device_id + )] + DeviceMismatch { + queue_device_id: DeviceId, + target_device_id: DeviceId, + }, #[error(transparent)] Queue(#[from] DeviceError), #[error(transparent)] @@ -383,6 +395,14 @@ impl Global { let hub = A::hub(self); + let buffer_device_id = hub + .buffers + .get(buffer_id) + .map_err(|_| TransferError::InvalidBuffer(buffer_id))? + .device + .as_info() + .id(); + let queue = hub .queues .get(queue_id) @@ -390,6 +410,16 @@ impl Global { let device = queue.device.as_ref().unwrap(); + { + let queue_device_id = device.as_info().id(); + if buffer_device_id != queue_device_id { + return Err(QueueWriteError::DeviceMismatch { + queue_device_id, + target_device_id: buffer_device_id, + }); + } + } + let data_size = data.len() as wgt::BufferAddress; #[cfg(feature = "trace")] @@ -785,6 +815,7 @@ impl Global { &mut trackers.textures, &device.alignments, device.zero_buffer.as_ref().unwrap(), + &device.snatchable_lock.read(), ) .map_err(QueueWriteError::from)?; } @@ -1054,6 +1085,7 @@ impl Global { &mut trackers.textures, &device.alignments, device.zero_buffer.as_ref().unwrap(), + &device.snatchable_lock.read(), ) .map_err(QueueWriteError::from)?; } @@ -1117,6 +1149,9 @@ impl Global { let device = queue.device.as_ref().unwrap(); + let snatch_guard = device.snatchable_lock.read(); + + // Fence lock must be acquired after the snatch lock everywhere to avoid deadlocks. let mut fence = device.fence.write(); let fence = fence.as_mut().unwrap(); let submit_index = device @@ -1125,9 +1160,7 @@ impl Global { + 1; let mut active_executions = Vec::new(); - let mut used_surface_textures = track::TextureUsageScope::new(); - - let snatch_guard = device.snatchable_lock.read(); + let mut used_surface_textures = track::TextureUsageScope::default(); let mut submit_surface_textures_owned = SmallVec::<[_; 2]>::new(); @@ -1150,7 +1183,7 @@ impl Global { for &cmb_id in command_buffer_ids { // we reset the used surface textures every time we use // it, so make sure to set_size on it. - used_surface_textures.set_size(hub.textures.read().len()); + used_surface_textures.set_size(device.tracker_indices.textures.size()); #[allow(unused_mut)] let mut cmdbuf = match command_buffer_guard.replace_with_error(cmb_id) { @@ -1195,11 +1228,13 @@ impl Global { // update submission IDs for buffer in cmd_buf_trackers.buffers.used_resources() { - let id = buffer.info.id(); + let tracker_index = buffer.info.tracker_index(); let raw_buf = match buffer.raw.get(&snatch_guard) { Some(raw) => raw, None => { - return Err(QueueSubmitError::DestroyedBuffer(id)); + return Err(QueueSubmitError::DestroyedBuffer( + buffer.info.id(), + )); } }; buffer.info.use_at(submit_index); @@ -1214,19 +1249,25 @@ impl Global { .as_mut() .unwrap() .buffers - .insert(id, buffer.clone()); + .insert(tracker_index, buffer.clone()); } else { match *buffer.map_state.lock() { BufferMapState::Idle => (), - _ => return Err(QueueSubmitError::BufferStillMapped(id)), + _ => { + return Err(QueueSubmitError::BufferStillMapped( + buffer.info.id(), + )) + } } } } for texture in cmd_buf_trackers.textures.used_resources() { - let id = texture.info.id(); + let tracker_index = texture.info.tracker_index(); let should_extend = match texture.inner.get(&snatch_guard) { None => { - return Err(QueueSubmitError::DestroyedTexture(id)); + return Err(QueueSubmitError::DestroyedTexture( + texture.info.id(), + )); } Some(TextureInner::Native { .. }) => false, Some(TextureInner::Surface { ref raw, .. }) => { @@ -1243,7 +1284,7 @@ impl Global { .as_mut() .unwrap() .textures - .insert(id, texture.clone()); + .insert(tracker_index, texture.clone()); } if should_extend { unsafe { @@ -1256,11 +1297,10 @@ impl Global { for texture_view in cmd_buf_trackers.views.used_resources() { texture_view.info.use_at(submit_index); if texture_view.is_unique() { - temp_suspected - .as_mut() - .unwrap() - .texture_views - .insert(texture_view.as_info().id(), texture_view.clone()); + temp_suspected.as_mut().unwrap().texture_views.insert( + texture_view.as_info().tracker_index(), + texture_view.clone(), + ); } } { @@ -1280,7 +1320,7 @@ impl Global { .as_mut() .unwrap() .bind_groups - .insert(bg.as_info().id(), bg.clone()); + .insert(bg.as_info().tracker_index(), bg.clone()); } } } @@ -1291,7 +1331,7 @@ impl Global { compute_pipeline.info.use_at(submit_index); if compute_pipeline.is_unique() { temp_suspected.as_mut().unwrap().compute_pipelines.insert( - compute_pipeline.as_info().id(), + compute_pipeline.as_info().tracker_index(), compute_pipeline.clone(), ); } @@ -1302,7 +1342,7 @@ impl Global { render_pipeline.info.use_at(submit_index); if render_pipeline.is_unique() { temp_suspected.as_mut().unwrap().render_pipelines.insert( - render_pipeline.as_info().id(), + render_pipeline.as_info().tracker_index(), render_pipeline.clone(), ); } @@ -1310,11 +1350,10 @@ impl Global { for query_set in cmd_buf_trackers.query_sets.used_resources() { query_set.info.use_at(submit_index); if query_set.is_unique() { - temp_suspected - .as_mut() - .unwrap() - .query_sets - .insert(query_set.as_info().id(), query_set.clone()); + temp_suspected.as_mut().unwrap().query_sets.insert( + query_set.as_info().tracker_index(), + query_set.clone(), + ); } } for bundle in cmd_buf_trackers.bundles.used_resources() { @@ -1335,7 +1374,7 @@ impl Global { .as_mut() .unwrap() .render_bundles - .insert(bundle.as_info().id(), bundle.clone()); + .insert(bundle.as_info().tracker_index(), bundle.clone()); } } } @@ -1355,10 +1394,10 @@ impl Global { //Note: locking the trackers has to be done after the storages let mut trackers = device.trackers.lock(); baked - .initialize_buffer_memory(&mut *trackers) + .initialize_buffer_memory(&mut *trackers, &snatch_guard) .map_err(|err| QueueSubmitError::DestroyedBuffer(err.0))?; baked - .initialize_texture_memory(&mut *trackers, device) + .initialize_texture_memory(&mut *trackers, device, &snatch_guard) .map_err(|err| QueueSubmitError::DestroyedTexture(err.0))?; //Note: stateless trackers are not merged: // device already knows these resources exist. @@ -1399,7 +1438,7 @@ impl Global { baked.encoder.end_encoding().unwrap() }; baked.list.push(present); - used_surface_textures = track::TextureUsageScope::new(); + used_surface_textures = track::TextureUsageScope::default(); } // done @@ -1506,7 +1545,7 @@ impl Global { // This will schedule destruction of all resources that are no longer needed // by the user but used in the command stream, among other things. - let (closures, _) = match device.maintain(fence, wgt::Maintain::Poll) { + let (closures, _) = match device.maintain(fence, wgt::Maintain::Poll, snatch_guard) { Ok(closures) => closures, Err(WaitIdleError::Device(err)) => return Err(QueueSubmitError::Queue(err)), Err(WaitIdleError::StuckGpu) => return Err(QueueSubmitError::StuckGpu), diff --git a/wgpu-core/src/device/resource.rs b/wgpu-core/src/device/resource.rs index 6cb5223493..4892aecb75 100644 --- a/wgpu-core/src/device/resource.rs +++ b/wgpu-core/src/device/resource.rs @@ -13,7 +13,6 @@ use crate::{ hal_api::HalApi, hal_label, hub::Hub, - id::QueueId, init_tracker::{ BufferInitTracker, BufferInitTrackerAction, MemoryInitKind, TextureInitRange, TextureInitTracker, TextureInitTrackerAction, @@ -29,7 +28,10 @@ use crate::{ resource_log, snatch::{SnatchGuard, SnatchLock, Snatchable}, storage::Storage, - track::{BindGroupStates, TextureSelector, Tracker}, + track::{ + BindGroupStates, TextureSelector, Tracker, TrackerIndexAllocators, UsageScope, + UsageScopePool, + }, validation::{ self, check_buffer_usage, check_texture_usage, validate_color_attachment_bytes_per_sample, }, @@ -38,6 +40,7 @@ use crate::{ use arrayvec::ArrayVec; use hal::{CommandEncoder as _, Device as _}; +use once_cell::sync::OnceCell; use parking_lot::{Mutex, MutexGuard, RwLock}; use smallvec::SmallVec; @@ -56,7 +59,7 @@ use std::{ use super::{ life::{self, ResourceMaps}, - queue::{self}, + queue::{self, Queue}, DeviceDescriptor, DeviceError, ImplicitPipelineContext, UserClosures, ENTRYPOINT_FAILURE_ERROR, IMPLICIT_BIND_GROUP_LAYOUT_ERROR_LABEL, ZERO_BUFFER_SIZE, }; @@ -89,14 +92,16 @@ use super::{ pub struct Device { raw: Option, pub(crate) adapter: Arc>, - pub(crate) queue_id: RwLock>, - queue_to_drop: RwLock>, + pub(crate) queue: OnceCell>>, + queue_to_drop: OnceCell, pub(crate) zero_buffer: Option, pub(crate) info: ResourceInfo>, pub(crate) command_allocator: Mutex>>, //Note: The submission index here corresponds to the last submission that is done. pub(crate) active_submission_index: AtomicU64, //SubmissionIndex, + // NOTE: if both are needed, the `snatchable_lock` must be consistently acquired before the + // `fence` lock to avoid deadlocks. pub(crate) fence: RwLock>, pub(crate) snatchable_lock: SnatchLock, @@ -118,6 +123,7 @@ pub struct Device { /// Has to be locked temporarily only (locked last) /// and never before pending_writes pub(crate) trackers: Mutex>, + pub(crate) tracker_indices: TrackerIndexAllocators, // Life tracker should be locked right after the device and before anything else. life_tracker: Mutex>, /// Temporary storage for resource management functions. Cleared at the end @@ -134,6 +140,7 @@ pub struct Device { pub(crate) deferred_destroy: Mutex>>, #[cfg(feature = "trace")] pub(crate) trace: Mutex>, + pub(crate) usage_scopes: UsageScopePool, } pub(crate) enum DeferredDestroy { @@ -162,7 +169,7 @@ impl Drop for Device { unsafe { raw.destroy_buffer(self.zero_buffer.take().unwrap()); raw.destroy_fence(self.fence.write().take().unwrap()); - let queue = self.queue_to_drop.write().take().unwrap(); + let queue = self.queue_to_drop.take().unwrap(); raw.exit(queue); } } @@ -260,16 +267,17 @@ impl Device { Ok(Self { raw: Some(raw_device), adapter: adapter.clone(), - queue_id: RwLock::new(None), - queue_to_drop: RwLock::new(None), + queue: OnceCell::new(), + queue_to_drop: OnceCell::new(), zero_buffer: Some(zero_buffer), - info: ResourceInfo::new(""), + info: ResourceInfo::new("", None), command_allocator: Mutex::new(Some(com_alloc)), active_submission_index: AtomicU64::new(0), fence: RwLock::new(Some(fence)), snatchable_lock: unsafe { SnatchLock::new() }, valid: AtomicBool::new(true), trackers: Mutex::new(Tracker::new()), + tracker_indices: TrackerIndexAllocators::new(), life_tracker: Mutex::new(life::LifetimeTracker::new()), temp_suspected: Mutex::new(Some(life::ResourceMaps::new())), bgl_pool: ResourcePool::new(), @@ -294,6 +302,7 @@ impl Device { instance_flags, pending_writes: Mutex::new(Some(pending_writes)), deferred_destroy: Mutex::new(Vec::new()), + usage_scopes: Default::default(), }) } @@ -302,7 +311,7 @@ impl Device { } pub(crate) fn release_queue(&self, queue: A::Queue) { - self.queue_to_drop.write().replace(queue); + assert!(self.queue_to_drop.set(queue).is_ok()); } pub(crate) fn lock_life<'a>(&'a self) -> MutexGuard<'a, LifetimeTracker> { @@ -341,7 +350,8 @@ impl Device { let Some(bind_group) = bind_group.upgrade() else { continue; }; - let Some(raw_bind_group) = bind_group.raw.snatch(self.snatchable_lock.write()) else { + let Some(raw_bind_group) = bind_group.raw.snatch(self.snatchable_lock.write()) + else { continue; }; @@ -359,6 +369,14 @@ impl Device { } } + pub fn get_queue(&self) -> Option>> { + self.queue.get().as_ref()?.upgrade() + } + + pub fn set_queue(&self, queue: Arc>) { + assert!(self.queue.set(Arc::downgrade(&queue)).is_ok()); + } + /// Check this device for completed commands. /// /// The `maintain` argument tells how the maintence function should behave, either @@ -376,6 +394,7 @@ impl Device { &'this self, fence: &A::Fence, maintain: wgt::Maintain, + snatch_guard: SnatchGuard, ) -> Result<(UserClosures, bool), WaitIdleError> { profiling::scope!("Device::maintain"); let last_done_index = if maintain.is_wait() { @@ -429,7 +448,8 @@ impl Device { life_tracker.triage_mapped(); } - let mapping_closures = life_tracker.handle_mapping(self.raw(), &self.trackers); + let mapping_closures = + life_tracker.handle_mapping(self.raw(), &self.trackers, &snatch_guard); let queue_empty = life_tracker.queue_empty(); @@ -456,8 +476,9 @@ impl Device { } } - // Don't hold the lock while calling release_gpu_resources. + // Don't hold the locks while calling release_gpu_resources. drop(life_tracker); + drop(snatch_guard); if should_release_gpu_resource { self.release_gpu_resources(); @@ -485,56 +506,56 @@ impl Device { if resource.is_unique() { temp_suspected .buffers - .insert(resource.as_info().id(), resource.clone()); + .insert(resource.as_info().tracker_index(), resource.clone()); } } for resource in trackers.textures.used_resources() { if resource.is_unique() { temp_suspected .textures - .insert(resource.as_info().id(), resource.clone()); + .insert(resource.as_info().tracker_index(), resource.clone()); } } for resource in trackers.views.used_resources() { if resource.is_unique() { temp_suspected .texture_views - .insert(resource.as_info().id(), resource.clone()); + .insert(resource.as_info().tracker_index(), resource.clone()); } } for resource in trackers.bind_groups.used_resources() { if resource.is_unique() { temp_suspected .bind_groups - .insert(resource.as_info().id(), resource.clone()); + .insert(resource.as_info().tracker_index(), resource.clone()); } } for resource in trackers.samplers.used_resources() { if resource.is_unique() { temp_suspected .samplers - .insert(resource.as_info().id(), resource.clone()); + .insert(resource.as_info().tracker_index(), resource.clone()); } } for resource in trackers.compute_pipelines.used_resources() { if resource.is_unique() { temp_suspected .compute_pipelines - .insert(resource.as_info().id(), resource.clone()); + .insert(resource.as_info().tracker_index(), resource.clone()); } } for resource in trackers.render_pipelines.used_resources() { if resource.is_unique() { temp_suspected .render_pipelines - .insert(resource.as_info().id(), resource.clone()); + .insert(resource.as_info().tracker_index(), resource.clone()); } } for resource in trackers.query_sets.used_resources() { if resource.is_unique() { temp_suspected .query_sets - .insert(resource.as_info().id(), resource.clone()); + .insert(resource.as_info().tracker_index(), resource.clone()); } } } @@ -635,7 +656,10 @@ impl Device { initialization_status: RwLock::new(BufferInitTracker::new(aligned_size)), sync_mapped_writes: Mutex::new(None), map_state: Mutex::new(resource::BufferMapState::Idle), - info: ResourceInfo::new(desc.label.borrow_or_default()), + info: ResourceInfo::new( + desc.label.borrow_or_default(), + Some(self.tracker_indices.buffers.clone()), + ), bind_groups: Mutex::new(Vec::new()), }) } @@ -664,7 +688,10 @@ impl Device { mips: 0..desc.mip_level_count, layers: 0..desc.array_layer_count(), }, - info: ResourceInfo::new(desc.label.borrow_or_default()), + info: ResourceInfo::new( + desc.label.borrow_or_default(), + Some(self.tracker_indices.textures.clone()), + ), clear_mode: RwLock::new(clear_mode), views: Mutex::new(Vec::new()), bind_groups: Mutex::new(Vec::new()), @@ -686,7 +713,10 @@ impl Device { initialization_status: RwLock::new(BufferInitTracker::new(0)), sync_mapped_writes: Mutex::new(None), map_state: Mutex::new(resource::BufferMapState::Idle), - info: ResourceInfo::new(desc.label.borrow_or_default()), + info: ResourceInfo::new( + desc.label.borrow_or_default(), + Some(self.tracker_indices.buffers.clone()), + ), bind_groups: Mutex::new(Vec::new()), } } @@ -1264,7 +1294,10 @@ impl Device { render_extent, samples: texture.desc.sample_count, selector, - info: ResourceInfo::new(desc.label.borrow_or_default()), + info: ResourceInfo::new( + desc.label.borrow_or_default(), + Some(self.tracker_indices.texture_views.clone()), + ), }) } @@ -1368,7 +1401,10 @@ impl Device { Ok(Sampler { raw: Some(raw), device: self.clone(), - info: ResourceInfo::new(desc.label.borrow_or_default()), + info: ResourceInfo::new( + desc.label.borrow_or_default(), + Some(self.tracker_indices.samplers.clone()), + ), comparison: desc.compare.is_some(), filtering: desc.min_filter == wgt::FilterMode::Linear || desc.mag_filter == wgt::FilterMode::Linear, @@ -1485,6 +1521,10 @@ impl Device { self.features .contains(wgt::Features::SHADER_EARLY_DEPTH_TEST), ); + caps.set( + Caps::SHADER_INT64, + self.features.contains(wgt::Features::SHADER_INT64), + ); caps.set( Caps::MULTISAMPLED_SHADING, self.downlevel @@ -1561,7 +1601,7 @@ impl Device { raw: Some(raw), device: self.clone(), interface: Some(interface), - info: ResourceInfo::new(desc.label.borrow_or_default()), + info: ResourceInfo::new(desc.label.borrow_or_default(), None), label: desc.label.borrow_or_default().to_string(), }) } @@ -1602,7 +1642,7 @@ impl Device { raw: Some(raw), device: self.clone(), interface: None, - info: ResourceInfo::new(desc.label.borrow_or_default()), + info: ResourceInfo::new(desc.label.borrow_or_default(), None), label: desc.label.borrow_or_default().to_string(), }) } @@ -1706,10 +1746,23 @@ impl Device { BindGroupLayoutEntryError::SampleTypeFloatFilterableBindingMultisampled, }); } - Bt::Texture { .. } => ( - Some(wgt::Features::TEXTURE_BINDING_ARRAY), - WritableStorage::No, - ), + Bt::Texture { + multisampled, + view_dimension, + .. + } => { + if multisampled && view_dimension != TextureViewDimension::D2 { + return Err(binding_model::CreateBindGroupLayoutError::Entry { + binding: entry.binding, + error: BindGroupLayoutEntryError::Non2DMultisampled(view_dimension), + }); + } + + ( + Some(wgt::Features::TEXTURE_BINDING_ARRAY), + WritableStorage::No, + ) + } Bt::StorageTexture { access, view_dimension, @@ -1842,7 +1895,10 @@ impl Device { entries: entry_map, origin, binding_count_validator: count_validator, - info: ResourceInfo::new(label.unwrap_or("")), + info: ResourceInfo::new( + label.unwrap_or(""), + Some(self.tracker_indices.bind_group_layouts.clone()), + ), label: label.unwrap_or_default().to_string(), }) } @@ -1907,7 +1963,7 @@ impl Device { .add_single(storage, bb.buffer_id, internal_use) .ok_or(Error::InvalidBuffer(bb.buffer_id))?; - check_buffer_usage(buffer.usage, pub_usage)?; + check_buffer_usage(bb.buffer_id, buffer.usage, pub_usage)?; let raw_buffer = buffer .raw .get(snatch_guard) @@ -2275,7 +2331,10 @@ impl Device { raw: Snatchable::new(raw), device: self.clone(), layout: layout.clone(), - info: ResourceInfo::new(desc.label.borrow_or_default()), + info: ResourceInfo::new( + desc.label.borrow_or_default(), + Some(self.tracker_indices.bind_groups.clone()), + ), used, used_buffer_ranges, used_texture_ranges, @@ -2557,7 +2616,10 @@ impl Device { Ok(binding_model::PipelineLayout { raw: Some(raw), device: self.clone(), - info: ResourceInfo::new(desc.label.borrow_or_default()), + info: ResourceInfo::new( + desc.label.borrow_or_default(), + Some(self.tracker_indices.pipeline_layouts.clone()), + ), bind_group_layouts, push_constant_ranges: desc.push_constant_ranges.iter().cloned().collect(), }) @@ -2658,14 +2720,21 @@ impl Device { let mut shader_binding_sizes = FastHashMap::default(); let io = validation::StageIo::default(); + let final_entry_point_name; + { let stage = wgt::ShaderStages::COMPUTE; + final_entry_point_name = shader_module.finalize_entry_point_name( + stage, + desc.stage.entry_point.as_ref().map(|ep| ep.as_ref()), + )?; + if let Some(ref interface) = shader_module.interface { let _ = interface.check_stage( &mut binding_layout_source, &mut shader_binding_sizes, - &desc.stage.entry_point, + &final_entry_point_name, stage, io, None, @@ -2693,7 +2762,7 @@ impl Device { label: desc.label.to_hal(self.instance_flags), layout: pipeline_layout.raw(), stage: hal::ProgrammableStage { - entry_point: desc.stage.entry_point.as_ref(), + entry_point: final_entry_point_name.as_ref(), module: shader_module.raw(), }, }; @@ -2722,7 +2791,10 @@ impl Device { device: self.clone(), _shader_module: shader_module, late_sized_buffer_groups, - info: ResourceInfo::new(desc.label.borrow_or_default()), + info: ResourceInfo::new( + desc.label.borrow_or_default(), + Some(self.tracker_indices.compute_pipelines.clone()), + ), }; Ok(pipeline) } @@ -3065,6 +3137,7 @@ impl Device { }; let vertex_shader_module; + let vertex_entry_point_name; let vertex_stage = { let stage_desc = &desc.vertex.stage; let stage = wgt::ShaderStages::VERTEX; @@ -3079,27 +3152,37 @@ impl Device { return Err(DeviceError::WrongDevice.into()); } + let stage_err = |error| pipeline::CreateRenderPipelineError::Stage { stage, error }; + + vertex_entry_point_name = vertex_shader_module + .finalize_entry_point_name( + stage, + stage_desc.entry_point.as_ref().map(|ep| ep.as_ref()), + ) + .map_err(stage_err)?; + if let Some(ref interface) = vertex_shader_module.interface { io = interface .check_stage( &mut binding_layout_source, &mut shader_binding_sizes, - &stage_desc.entry_point, + &vertex_entry_point_name, stage, io, desc.depth_stencil.as_ref().map(|d| d.depth_compare), ) - .map_err(|error| pipeline::CreateRenderPipelineError::Stage { stage, error })?; + .map_err(stage_err)?; validated_stages |= stage; } hal::ProgrammableStage { module: vertex_shader_module.raw(), - entry_point: stage_desc.entry_point.as_ref(), + entry_point: &vertex_entry_point_name, } }; let mut fragment_shader_module = None; + let fragment_entry_point_name; let fragment_stage = match desc.fragment { Some(ref fragment_state) => { let stage = wgt::ShaderStages::FRAGMENT; @@ -3113,28 +3196,38 @@ impl Device { })?, ); + let stage_err = |error| pipeline::CreateRenderPipelineError::Stage { stage, error }; + + fragment_entry_point_name = shader_module + .finalize_entry_point_name( + stage, + fragment_state + .stage + .entry_point + .as_ref() + .map(|ep| ep.as_ref()), + ) + .map_err(stage_err)?; + if validated_stages == wgt::ShaderStages::VERTEX { if let Some(ref interface) = shader_module.interface { io = interface .check_stage( &mut binding_layout_source, &mut shader_binding_sizes, - &fragment_state.stage.entry_point, + &fragment_entry_point_name, stage, io, desc.depth_stencil.as_ref().map(|d| d.depth_compare), ) - .map_err(|error| pipeline::CreateRenderPipelineError::Stage { - stage, - error, - })?; + .map_err(stage_err)?; validated_stages |= stage; } } if let Some(ref interface) = shader_module.interface { shader_expects_dual_source_blending = interface - .fragment_uses_dual_source_blending(&fragment_state.stage.entry_point) + .fragment_uses_dual_source_blending(&fragment_entry_point_name) .map_err(|error| pipeline::CreateRenderPipelineError::Stage { stage, error, @@ -3143,7 +3236,7 @@ impl Device { Some(hal::ProgrammableStage { module: shader_module.raw(), - entry_point: fragment_state.stage.entry_point.as_ref(), + entry_point: &fragment_entry_point_name, }) } None => None, @@ -3316,7 +3409,10 @@ impl Device { strip_index_format: desc.primitive.strip_index_format, vertex_steps, late_sized_buffer_groups, - info: ResourceInfo::new(desc.label.borrow_or_default()), + info: ResourceInfo::new( + desc.label.borrow_or_default(), + Some(self.tracker_indices.render_pipelines.clone()), + ), }; Ok(pipeline) } @@ -3429,7 +3525,7 @@ impl Device { Ok(QuerySet { raw: Some(unsafe { self.raw().create_query_set(&hal_desc).unwrap() }), device: self.clone(), - info: ResourceInfo::new(""), + info: ResourceInfo::new("", Some(self.tracker_indices.query_sets.clone())), desc: desc.map_label(|_| ()), }) } @@ -3482,6 +3578,10 @@ impl Device { let _ = texture.destroy(); } } + + pub(crate) fn new_usage_scope(&self) -> UsageScope<'_, A> { + UsageScope::new_pooled(&self.usage_scopes, &self.tracker_indices) + } } impl Device { diff --git a/wgpu-core/src/id.rs b/wgpu-core/src/id.rs index 1dbb491e60..72b74218d0 100644 --- a/wgpu-core/src/id.rs +++ b/wgpu-core/src/id.rs @@ -275,7 +275,7 @@ where { #[inline] fn partial_cmp(&self, other: &Self) -> Option { - self.0.partial_cmp(&other.0) + Some(self.cmp(other)) } } diff --git a/wgpu-core/src/identity.rs b/wgpu-core/src/identity.rs index 0e34055c74..d76d29341a 100644 --- a/wgpu-core/src/identity.rs +++ b/wgpu-core/src/identity.rs @@ -3,10 +3,17 @@ use wgt::Backend; use crate::{ id::{Id, Marker}, - Epoch, FastHashMap, Index, + Epoch, Index, }; use std::{fmt::Debug, marker::PhantomData}; +#[derive(Copy, Clone, Debug, PartialEq)] +enum IdSource { + External, + Allocated, + None, +} + /// A simple structure to allocate [`Id`] identifiers. /// /// Calling [`alloc`] returns a fresh, never-before-seen id. Calling [`free`] @@ -34,12 +41,15 @@ use std::{fmt::Debug, marker::PhantomData}; /// [`Backend`]: wgt::Backend; /// [`alloc`]: IdentityManager::alloc /// [`free`]: IdentityManager::free -#[derive(Debug, Default)] +#[derive(Debug)] pub(super) struct IdentityValues { free: Vec<(Index, Epoch)>, - //sorted by Index - used: FastHashMap>, + next_index: Index, count: usize, + // Sanity check: The allocation logic works under the assumption that we don't + // do a mix of allocating ids from here and providing ids manually for the same + // storage container. + id_source: IdSource, } impl IdentityValues { @@ -48,35 +58,41 @@ impl IdentityValues { /// The backend is incorporated into the id, so that ids allocated with /// different `backend` values are always distinct. pub fn alloc(&mut self, backend: Backend) -> Id { + assert!( + self.id_source != IdSource::External, + "Mix of internally allocated and externally provided IDs" + ); + self.id_source = IdSource::Allocated; + self.count += 1; match self.free.pop() { Some((index, epoch)) => Id::zip(index, epoch + 1, backend), None => { + let index = self.next_index; + self.next_index += 1; let epoch = 1; - let used = self.used.entry(epoch).or_insert_with(Default::default); - let index = if let Some(i) = used.iter().max_by_key(|v| *v) { - i + 1 - } else { - 0 - }; - used.push(index); Id::zip(index, epoch, backend) } } } pub fn mark_as_used(&mut self, id: Id) -> Id { + assert!( + self.id_source != IdSource::Allocated, + "Mix of internally allocated and externally provided IDs" + ); + self.id_source = IdSource::External; + self.count += 1; - let (index, epoch, _backend) = id.unzip(); - let used = self.used.entry(epoch).or_insert_with(Default::default); - used.push(index); id } /// Free `id`. It will never be returned from `alloc` again. pub fn release(&mut self, id: Id) { - let (index, epoch, _backend) = id.unzip(); - self.free.push((index, epoch)); + if let IdSource::Allocated = self.id_source { + let (index, epoch, _backend) = id.unzip(); + self.free.push((index, epoch)); + } self.count -= 1; } @@ -106,7 +122,12 @@ impl IdentityManager { impl IdentityManager { pub fn new() -> Self { Self { - values: Mutex::new(IdentityValues::default()), + values: Mutex::new(IdentityValues { + free: Vec::new(), + next_index: 0, + count: 0, + id_source: IdSource::None, + }), _phantom: PhantomData, } } @@ -115,15 +136,11 @@ impl IdentityManager { #[test] fn test_epoch_end_of_life() { use crate::id; - let man = IdentityManager::::new(); - let forced_id = man.mark_as_used(id::BufferId::zip(0, 1, Backend::Empty)); - assert_eq!(forced_id.unzip().0, 0); let id1 = man.process(Backend::Empty); - assert_eq!(id1.unzip().0, 1); + assert_eq!(id1.unzip(), (0, 1, Backend::Empty)); man.free(id1); let id2 = man.process(Backend::Empty); // confirm that the epoch 1 is no longer re-used - assert_eq!(id2.unzip().0, 1); - assert_eq!(id2.unzip().1, 2); + assert_eq!(id2.unzip(), (0, 2, Backend::Empty)); } diff --git a/wgpu-core/src/instance.rs b/wgpu-core/src/instance.rs index 582571c2b8..b909245fac 100644 --- a/wgpu-core/src/instance.rs +++ b/wgpu-core/src/instance.rs @@ -198,7 +198,7 @@ impl Adapter { Self { raw, - info: ResourceInfo::new(""), + info: ResourceInfo::new("", None), } } @@ -303,7 +303,7 @@ impl Adapter { let queue = Queue { device: None, raw: Some(hal_device.queue), - info: ResourceInfo::new(""), + info: ResourceInfo::new("", None), }; return Ok((device, queue)); } @@ -521,7 +521,7 @@ impl Global { let surface = Surface { presentation: Mutex::new(None), - info: ResourceInfo::new(""), + info: ResourceInfo::new("", None), raw: hal_surface, }; @@ -542,7 +542,7 @@ impl Global { let surface = Surface { presentation: Mutex::new(None), - info: ResourceInfo::new(""), + info: ResourceInfo::new("", None), raw: { let hal_surface = self .instance @@ -575,7 +575,7 @@ impl Global { let surface = Surface { presentation: Mutex::new(None), - info: ResourceInfo::new(""), + info: ResourceInfo::new("", None), raw: { let hal_surface = self .instance @@ -604,7 +604,7 @@ impl Global { let surface = Surface { presentation: Mutex::new(None), - info: ResourceInfo::new(""), + info: ResourceInfo::new("", None), raw: { let hal_surface = self .instance @@ -633,7 +633,7 @@ impl Global { let surface = Surface { presentation: Mutex::new(None), - info: ResourceInfo::new(""), + info: ResourceInfo::new("", None), raw: { let hal_surface = self .instance @@ -1072,10 +1072,10 @@ impl Global { let device = hub.devices.get(device_id).unwrap(); queue.device = Some(device.clone()); - let (queue_id, _) = queue_fid.assign(queue); + let (queue_id, queue) = queue_fid.assign(queue); resource_log!("Created Queue {:?}", queue_id); - device.queue_id.write().replace(queue_id); + device.set_queue(queue); return (device_id, queue_id, None); }; @@ -1124,10 +1124,10 @@ impl Global { let device = hub.devices.get(device_id).unwrap(); queue.device = Some(device.clone()); - let (queue_id, _) = queues_fid.assign(queue); + let (queue_id, queue) = queues_fid.assign(queue); resource_log!("Created Queue {:?}", queue_id); - device.queue_id.write().replace(queue_id); + device.set_queue(queue); return (device_id, queue_id, None); }; diff --git a/wgpu-core/src/pipeline.rs b/wgpu-core/src/pipeline.rs index acc1b24b0c..4a7651b327 100644 --- a/wgpu-core/src/pipeline.rs +++ b/wgpu-core/src/pipeline.rs @@ -92,6 +92,19 @@ impl ShaderModule { pub(crate) fn raw(&self) -> &A::ShaderModule { self.raw.as_ref().unwrap() } + + pub(crate) fn finalize_entry_point_name( + &self, + stage_bit: wgt::ShaderStages, + entry_point: Option<&str>, + ) -> Result { + match &self.interface { + Some(interface) => interface.finalize_entry_point_name(stage_bit, entry_point), + None => entry_point + .map(|ep| ep.to_string()) + .ok_or(validation::StageError::NoEntryPointFound), + } + } } #[derive(Clone, Debug)] @@ -213,9 +226,13 @@ impl CreateShaderModuleError { pub struct ProgrammableStageDescriptor<'a> { /// The compiled shader module for this stage. pub module: ShaderModuleId, - /// The name of the entry point in the compiled shader. There must be a function with this name - /// in the shader. - pub entry_point: Cow<'a, str>, + /// The name of the entry point in the compiled shader. The name is selected using the + /// following logic: + /// + /// * If `Some(name)` is specified, there must be a function with this name in the shader. + /// * If a single entry point associated with this stage must be in the shader, then proceed as + /// if `Some(…)` was specified with that entry point's name. + pub entry_point: Option>, } /// Number of implicit bind groups derived at pipeline creation. diff --git a/wgpu-core/src/present.rs b/wgpu-core/src/present.rs index ed1810a653..cb4e17798f 100644 --- a/wgpu-core/src/present.rs +++ b/wgpu-core/src/present.rs @@ -70,7 +70,7 @@ pub enum ConfigureSurfaceError { PreviousOutputExists, #[error("Both `Surface` width and height must be non-zero. Wait to recreate the `Surface` until the window has non-zero area.")] ZeroArea, - #[error("`Surface` width and height must be within the maximum supported texture size. Requested was ({width}, {height}), maximum extent is {max_texture_dimension_2d}.")] + #[error("`Surface` width and height must be within the maximum supported texture size. Requested was ({width}, {height}), maximum extent for either dimension is {max_texture_dimension_2d}.")] TooLarge { width: u32, height: u32, @@ -220,7 +220,10 @@ impl Global { layers: 0..1, mips: 0..1, }, - info: ResourceInfo::new(""), + info: ResourceInfo::new( + "", + Some(device.tracker_indices.textures.clone()), + ), clear_mode: RwLock::new(resource::TextureClearMode::Surface { clear_view: Some(clear_view), }), @@ -236,7 +239,7 @@ impl Global { let mut trackers = device.trackers.lock(); trackers .textures - .insert_single(id, resource, hal::TextureUses::UNINITIALIZED); + .insert_single(resource, hal::TextureUses::UNINITIALIZED); } if present.acquired_texture.is_some() { @@ -294,8 +297,7 @@ impl Global { if !device.is_valid() { return Err(DeviceError::Lost.into()); } - let queue_id = device.queue_id.read().unwrap(); - let queue = hub.queues.get(queue_id).unwrap(); + let queue = device.get_queue().unwrap(); #[cfg(feature = "trace")] if let Some(ref mut trace) = *device.trace.lock() { @@ -314,10 +316,13 @@ impl Global { "Removing swapchain texture {:?} from the device tracker", texture_id ); - device.trackers.lock().textures.remove(texture_id); - let texture = hub.textures.unregister(texture_id); if let Some(texture) = texture { + device + .trackers + .lock() + .textures + .remove(texture.info.tracker_index()); let mut exclusive_snatch_guard = device.snatchable_lock.write(); let suf = A::get_surface(&surface); let mut inner = texture.inner_mut(&mut exclusive_snatch_guard); @@ -404,10 +409,15 @@ impl Global { "Removing swapchain texture {:?} from the device tracker", texture_id ); - device.trackers.lock().textures.remove(texture_id); let texture = hub.textures.unregister(texture_id); + if let Some(texture) = texture { + device + .trackers + .lock() + .textures + .remove(texture.info.tracker_index()); let suf = A::get_surface(&surface); let exclusive_snatch_guard = device.snatchable_lock.write(); match texture.inner.snatch(exclusive_snatch_guard).unwrap() { diff --git a/wgpu-core/src/registry.rs b/wgpu-core/src/registry.rs index f55809770b..80394351af 100644 --- a/wgpu-core/src/registry.rs +++ b/wgpu-core/src/registry.rs @@ -60,7 +60,6 @@ impl Registry { #[must_use] pub(crate) struct FutureId<'a, T: Resource> { id: Id, - identity: Arc>, data: &'a RwLock>, } @@ -75,7 +74,7 @@ impl FutureId<'_, T> { } pub fn init(&self, mut value: T) -> Arc { - value.as_info_mut().set_id(self.id, &self.identity); + value.as_info_mut().set_id(self.id); Arc::new(value) } @@ -117,7 +116,6 @@ impl Registry { } None => self.identity.process(self.backend), }, - identity: self.identity.clone(), data: &self.storage, } } @@ -125,7 +123,6 @@ impl Registry { pub(crate) fn request(&self) -> FutureId { FutureId { id: self.identity.process(self.backend), - identity: self.identity.clone(), data: &self.storage, } } @@ -142,11 +139,12 @@ impl Registry { self.storage.write() } pub fn unregister_locked(&self, id: Id, storage: &mut Storage) -> Option> { + self.identity.free(id); storage.remove(id) } pub fn force_replace(&self, id: Id, mut value: T) { let mut storage = self.storage.write(); - value.as_info_mut().set_id(id, &self.identity); + value.as_info_mut().set_id(id); storage.force_replace(id, value) } pub fn force_replace_with_error(&self, id: Id, label: &str) { @@ -155,6 +153,7 @@ impl Registry { storage.insert_error(id, label); } pub(crate) fn unregister(&self, id: Id) -> Option> { + self.identity.free(id); let value = self.storage.write().remove(id); //Returning None is legal if it's an error ID value diff --git a/wgpu-core/src/resource.rs b/wgpu-core/src/resource.rs index 5108328f2b..8256b95539 100644 --- a/wgpu-core/src/resource.rs +++ b/wgpu-core/src/resource.rs @@ -8,12 +8,14 @@ use crate::{ }, global::Global, hal_api::HalApi, - id::{AdapterId, BufferId, DeviceId, Id, Marker, SurfaceId, TextureId}, - identity::IdentityManager, + id::{ + AdapterId, BufferId, CommandEncoderId, DeviceId, Id, Marker, SurfaceId, TextureId, + TextureViewId, + }, init_tracker::{BufferInitTracker, TextureInitTracker}, resource, resource_log, snatch::{ExclusiveSnatchGuard, SnatchGuard, Snatchable}, - track::TextureSelector, + track::{SharedTrackerIndexAllocator, TextureSelector, TrackerIndex}, validation::MissingBufferUsageError, Label, SubmissionIndex, }; @@ -58,7 +60,8 @@ use std::{ #[derive(Debug)] pub struct ResourceInfo { id: Option>, - identity: Option>>, + tracker_index: TrackerIndex, + tracker_indices: Option>, /// The index of the last queue submission in which the resource /// was used. /// @@ -74,19 +77,26 @@ pub struct ResourceInfo { impl Drop for ResourceInfo { fn drop(&mut self) { - if let Some(identity) = self.identity.as_ref() { - let id = self.id.as_ref().unwrap(); - identity.free(*id); + if let Some(indices) = &self.tracker_indices { + indices.free(self.tracker_index); } } } impl ResourceInfo { #[allow(unused_variables)] - pub(crate) fn new(label: &str) -> Self { + pub(crate) fn new( + label: &str, + tracker_indices: Option>, + ) -> Self { + let tracker_index = tracker_indices + .as_ref() + .map(|indices| indices.alloc()) + .unwrap_or(TrackerIndex::INVALID); Self { id: None, - identity: None, + tracker_index, + tracker_indices, submission_index: AtomicUsize::new(0), label: label.to_string(), } @@ -111,9 +121,13 @@ impl ResourceInfo { self.id.unwrap() } - pub(crate) fn set_id(&mut self, id: Id, identity: &Arc>) { + pub(crate) fn tracker_index(&self) -> TrackerIndex { + debug_assert!(self.tracker_index != TrackerIndex::INVALID); + self.tracker_index + } + + pub(crate) fn set_id(&mut self, id: Id) { self.id = Some(id); - self.identity = Some(identity.clone()); } /// Record that this resource will be used by the queue submission with the @@ -551,6 +565,7 @@ impl Buffer { device: Arc::clone(&self.device), submission_index: self.info.submission_index(), id: self.info.id.unwrap(), + tracker_index: self.info.tracker_index(), label: self.info.label.clone(), bind_groups, })) @@ -611,6 +626,7 @@ pub struct DestroyedBuffer { device: Arc>, label: String, pub(crate) id: BufferId, + pub(crate) tracker_index: TrackerIndex, pub(crate) submission_index: u64, bind_groups: Vec>>, } @@ -885,6 +901,7 @@ impl Texture { views, bind_groups, device: Arc::clone(&self.device), + tracker_index: self.info.tracker_index(), submission_index: self.info.submission_index(), id: self.info.id.unwrap(), label: self.info.label.clone(), @@ -910,11 +927,11 @@ impl Global { /// # Safety /// /// - The raw texture handle must not be manually destroyed - pub unsafe fn texture_as_hal)>( + pub unsafe fn texture_as_hal) -> R, R>( &self, id: TextureId, hal_texture_callback: F, - ) { + ) -> R { profiling::scope!("Texture::as_hal"); let hub = A::hub(self); @@ -923,7 +940,26 @@ impl Global { let snatch_guard = texture.device.snatchable_lock.read(); let hal_texture = texture.raw(&snatch_guard); - hal_texture_callback(hal_texture); + hal_texture_callback(hal_texture) + } + + /// # Safety + /// + /// - The raw texture view handle must not be manually destroyed + pub unsafe fn texture_view_as_hal) -> R, R>( + &self, + id: TextureViewId, + hal_texture_view_callback: F, + ) -> R { + profiling::scope!("TextureView::as_hal"); + + let hub = A::hub(self); + let texture_view_opt = { hub.texture_views.try_get(id).ok().flatten() }; + let texture_view = texture_view_opt.as_ref().unwrap(); + let snatch_guard = texture_view.device.snatchable_lock.read(); + let hal_texture_view = texture_view.raw(&snatch_guard); + + hal_texture_view_callback(hal_texture_view) } /// # Safety @@ -991,6 +1027,29 @@ impl Global { hal_surface_callback(hal_surface) } + + /// # Safety + /// + /// - The raw command encoder handle must not be manually destroyed + pub unsafe fn command_encoder_as_hal_mut< + A: HalApi, + F: FnOnce(Option<&mut A::CommandEncoder>) -> R, + R, + >( + &self, + id: CommandEncoderId, + hal_command_encoder_callback: F, + ) -> R { + profiling::scope!("CommandEncoder::as_hal"); + + let hub = A::hub(self); + let cmd_buf = hub.command_buffers.get(id.transmute()).unwrap(); + let mut cmd_buf_data = cmd_buf.data.lock(); + let cmd_buf_data = cmd_buf_data.as_mut().unwrap(); + let cmd_buf_raw = cmd_buf_data.encoder.open().ok(); + + hal_command_encoder_callback(cmd_buf_raw) + } } /// A texture that has been marked as destroyed and is staged for actual deletion soon. @@ -1002,6 +1061,7 @@ pub struct DestroyedTexture { device: Arc>, label: String, pub(crate) id: TextureId, + pub(crate) tracker_index: TrackerIndex, pub(crate) submission_index: u64, } diff --git a/wgpu-core/src/snatch.rs b/wgpu-core/src/snatch.rs index 2324d33574..d5cd1a3d37 100644 --- a/wgpu-core/src/snatch.rs +++ b/wgpu-core/src/snatch.rs @@ -1,7 +1,12 @@ #![allow(unused)] use parking_lot::{RwLock, RwLockReadGuard, RwLockWriteGuard}; -use std::cell::UnsafeCell; +use std::{ + backtrace::Backtrace, + cell::{Cell, RefCell, UnsafeCell}, + panic::{self, Location}, + thread, +}; /// A guard that provides read access to snatchable data. pub struct SnatchGuard<'a>(RwLockReadGuard<'a, ()>); @@ -59,6 +64,10 @@ impl std::fmt::Debug for Snatchable { unsafe impl Sync for Snatchable {} +thread_local! { + static READ_LOCK_LOCATION: Cell, Backtrace)>> = const { Cell::new(None) }; +} + /// A Device-global lock for all snatchable data. pub struct SnatchLock { lock: RwLock<()>, @@ -76,7 +85,24 @@ impl SnatchLock { } /// Request read access to snatchable resources. + #[track_caller] pub fn read(&self) -> SnatchGuard { + if cfg!(debug_assertions) { + let caller = Location::caller(); + let backtrace = Backtrace::capture(); + if let Some((prev, bt)) = READ_LOCK_LOCATION.take() { + let current = thread::current(); + let name = current.name().unwrap_or(""); + panic!( + "thread '{name}' attempted to acquire a snatch read lock recursively.\n + - {prev}\n{bt}\n + - {caller}\n{backtrace}" + ); + } else { + READ_LOCK_LOCATION.set(Some((caller, backtrace))); + } + } + SnatchGuard(self.lock.read()) } @@ -89,3 +115,10 @@ impl SnatchLock { ExclusiveSnatchGuard(self.lock.write()) } } + +impl Drop for SnatchGuard<'_> { + fn drop(&mut self) { + #[cfg(debug_assertions)] + READ_LOCK_LOCATION.take(); + } +} diff --git a/wgpu-core/src/track/buffer.rs b/wgpu-core/src/track/buffer.rs index 323d2dab9d..6cf1fdda6f 100644 --- a/wgpu-core/src/track/buffer.rs +++ b/wgpu-core/src/track/buffer.rs @@ -7,7 +7,7 @@ use std::{borrow::Cow, marker::PhantomData, sync::Arc}; -use super::{PendingTransition, ResourceTracker}; +use super::{PendingTransition, ResourceTracker, TrackerIndex}; use crate::{ hal_api::HalApi, id::BufferId, @@ -64,16 +64,16 @@ impl BufferBindGroupState { #[allow(clippy::pattern_type_mismatch)] pub(crate) fn optimize(&self) { let mut buffers = self.buffers.lock(); - buffers.sort_unstable_by_key(|(b, _)| b.as_info().id().unzip().0); + buffers.sort_unstable_by_key(|(b, _)| b.as_info().tracker_index()); } /// Returns a list of all buffers tracked. May contain duplicates. #[allow(clippy::pattern_type_mismatch)] - pub fn used_ids(&self) -> impl Iterator + '_ { + pub fn used_tracker_indices(&self) -> impl Iterator + '_ { let buffers = self.buffers.lock(); buffers .iter() - .map(|(ref b, _)| b.as_info().id()) + .map(|(ref b, _)| b.as_info().tracker_index()) .collect::>() .into_iter() } @@ -108,23 +108,27 @@ impl BufferBindGroupState { #[derive(Debug)] pub(crate) struct BufferUsageScope { state: Vec, - metadata: ResourceMetadata>, } -impl BufferUsageScope { - pub fn new() -> Self { +impl Default for BufferUsageScope { + fn default() -> Self { Self { state: Vec::new(), - metadata: ResourceMetadata::new(), } } +} +impl BufferUsageScope { fn tracker_assert_in_bounds(&self, index: usize) { strict_assert!(index < self.state.len()); self.metadata.tracker_assert_in_bounds(index); } + pub fn clear(&mut self) { + self.state.clear(); + self.metadata.clear(); + } /// Sets the size of all the vectors inside the tracker. /// @@ -149,20 +153,6 @@ impl BufferUsageScope { resources.into_iter() } - pub fn get(&self, id: BufferId) -> Option<&Arc>> { - let index = id.unzip().0 as usize; - if index > self.metadata.size() { - return None; - } - self.tracker_assert_in_bounds(index); - unsafe { - if self.metadata.contains_unchecked(index) { - return Some(self.metadata.get_resource_unchecked(index)); - } - } - None - } - /// Merge the list of buffer states in the given bind group into this usage scope. /// /// If any of the resulting states is invalid, stops the merge and returns a usage @@ -181,7 +171,7 @@ impl BufferUsageScope { ) -> Result<(), UsageConflict> { let buffers = bind_group.buffers.lock(); for &(ref resource, state) in &*buffers { - let index = resource.as_info().id().unzip().0 as usize; + let index = resource.as_info().tracker_index().as_usize(); unsafe { insert_or_merge( @@ -255,7 +245,7 @@ impl BufferUsageScope { .get(id) .map_err(|_| UsageConflict::BufferInvalid { id })?; - let index = id.unzip().0 as usize; + let index = buffer.info.tracker_index().as_usize(); self.allow_index(index); @@ -292,7 +282,7 @@ pub(crate) struct BufferTracker { temp: Vec>, } -impl ResourceTracker> for BufferTracker { +impl ResourceTracker for BufferTracker { /// Try to remove the buffer `id` from this tracker if it is otherwise unused. /// /// A buffer is 'otherwise unused' when the only references to it are: @@ -313,8 +303,8 @@ impl ResourceTracker> for BufferTracker { /// [`Device::trackers`]: crate::device::Device /// [`self.metadata`]: BufferTracker::metadata /// [`Hub::buffers`]: crate::hub::Hub::buffers - fn remove_abandoned(&mut self, id: BufferId) -> bool { - let index = id.unzip().0 as usize; + fn remove_abandoned(&mut self, index: TrackerIndex) -> bool { + let index = index.as_usize(); if index > self.metadata.size() { return false; @@ -329,16 +319,10 @@ impl ResourceTracker> for BufferTracker { //so it's already been released from user and so it's not inside Registry\Storage if existing_ref_count <= 2 { self.metadata.remove(index); - log::trace!("Buffer {:?} is not tracked anymore", id,); return true; - } else { - log::trace!( - "Buffer {:?} is still referenced from {}", - id, - existing_ref_count - ); - return false; } + + return false; } } true @@ -404,8 +388,8 @@ impl BufferTracker { /// /// If the ID is higher than the length of internal vectors, /// the vectors will be extended. A call to set_size is not needed. - pub fn insert_single(&mut self, id: BufferId, resource: Arc>, state: BufferUses) { - let index = id.unzip().0 as usize; + pub fn insert_single(&mut self, resource: Arc>, state: BufferUses) { + let index = resource.info.tracker_index().as_usize(); self.allow_index(index); @@ -440,7 +424,7 @@ impl BufferTracker { /// If the ID is higher than the length of internal vectors, /// the vectors will be extended. A call to set_size is not needed. pub fn set_single(&mut self, buffer: &Arc>, state: BufferUses) -> SetSingleResult { - let index: usize = buffer.as_info().id().unzip().0 as usize; + let index: usize = buffer.as_info().tracker_index().as_usize(); self.allow_index(index); @@ -561,16 +545,15 @@ impl BufferTracker { pub unsafe fn set_and_remove_from_usage_scope_sparse( &mut self, scope: &mut BufferUsageScope, - id_source: impl IntoIterator, + index_source: impl IntoIterator, ) { let incoming_size = scope.state.len(); if incoming_size > self.start.len() { self.set_size(incoming_size); } - for id in id_source { - let (index32, _, _) = id.unzip(); - let index = index32 as usize; + for index in index_source { + let index = index.as_usize(); scope.tracker_assert_in_bounds(index); @@ -599,8 +582,8 @@ impl BufferTracker { } #[allow(dead_code)] - pub fn get(&self, id: BufferId) -> Option<&Arc>> { - let index = id.unzip().0 as usize; + pub fn get(&self, index: TrackerIndex) -> Option<&Arc>> { + let index = index.as_usize(); if index > self.metadata.size() { return None; } @@ -785,11 +768,7 @@ unsafe fn merge( if invalid_resource_state(merged_state) { return Err(UsageConflict::from_buffer( - BufferId::zip( - index32, - unsafe { metadata_provider.get_epoch(index) }, - A::VARIANT, - ), + unsafe { metadata_provider.get_own(index).info.id() }, *current_state, new_state, )); diff --git a/wgpu-core/src/track/metadata.rs b/wgpu-core/src/track/metadata.rs index e5f4d5e969..3e71e0e084 100644 --- a/wgpu-core/src/track/metadata.rs +++ b/wgpu-core/src/track/metadata.rs @@ -1,6 +1,6 @@ //! The `ResourceMetadata` type. -use crate::{resource::Resource, Epoch}; +use crate::resource::Resource; use bit_vec::BitVec; use std::{borrow::Cow, mem, sync::Arc}; use wgt::strict_assert; @@ -39,6 +39,11 @@ impl ResourceMetadata { resize_bitvec(&mut self.owned, size); } + pub(super) fn clear(&mut self) { + self.resources.clear(); + self.owned.clear(); + } + /// Ensures a given index is in bounds for all arrays and does /// sanity checks of the presence of a refcount. /// @@ -194,15 +199,6 @@ impl ResourceMetadataProvider<'_, T> { } } } - /// Get the epoch from this. - /// - /// # Safety - /// - /// - The index must be in bounds of the metadata tracker if this uses an indirect source. - #[inline(always)] - pub(super) unsafe fn get_epoch(self, index: usize) -> Epoch { - unsafe { self.get_own(index).as_info().id().unzip().1 } - } } /// Resizes the given bitvec to the given size. I'm not sure why this is hard to do but it is. diff --git a/wgpu-core/src/track/mod.rs b/wgpu-core/src/track/mod.rs index a36280d03b..374dfe7493 100644 --- a/wgpu-core/src/track/mod.rs +++ b/wgpu-core/src/track/mod.rs @@ -102,16 +102,11 @@ mod stateless; mod texture; use crate::{ - binding_model, command, conv, - hal_api::HalApi, - id::{self, Id}, - pipeline, resource, - snatch::SnatchGuard, - storage::Storage, + binding_model, command, conv, hal_api::HalApi, id, pipeline, resource, snatch::SnatchGuard, }; -use parking_lot::RwLock; -use std::{fmt, ops}; +use parking_lot::{Mutex, RwLock}; +use std::{fmt, ops, sync::Arc}; use thiserror::Error; pub(crate) use buffer::{BufferBindGroupState, BufferTracker, BufferUsageScope}; @@ -122,6 +117,130 @@ pub(crate) use texture::{ }; use wgt::strict_assert_ne; +#[repr(transparent)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +pub(crate) struct TrackerIndex(u32); + +impl TrackerIndex { + /// A dummy value to place in ResourceInfo for resources that are never tracked. + pub const INVALID: Self = TrackerIndex(u32::MAX); + + pub fn as_usize(self) -> usize { + debug_assert!(self != Self::INVALID); + self.0 as usize + } +} + +/// wgpu-core internally use some array-like storage for tracking resources. +/// To that end, there needs to be a uniquely assigned index for each live resource +/// of a certain type. This index is separate from the resource ID for various reasons: +/// - There can be multiple resource IDs pointing the the same resource. +/// - IDs of dead handles can be recycled while resources are internally held alive (and tracked). +/// - The plan is to remove IDs in the long run (https://github.com/gfx-rs/wgpu/issues/5121). +/// In order to produce these tracker indices, there is a shared TrackerIndexAllocator +/// per resource type. Indices have the same lifetime as the internal resource they +/// are associated to (alloc happens when creating the resource and free is called when +/// the resource is dropped). +struct TrackerIndexAllocator { + unused: Vec, + next_index: TrackerIndex, +} + +impl TrackerIndexAllocator { + pub fn new() -> Self { + TrackerIndexAllocator { + unused: Vec::new(), + next_index: TrackerIndex(0), + } + } + + pub fn alloc(&mut self) -> TrackerIndex { + if let Some(index) = self.unused.pop() { + return index; + } + + let index = self.next_index; + self.next_index.0 += 1; + + index + } + + pub fn free(&mut self, index: TrackerIndex) { + self.unused.push(index); + } + + // This is used to pre-allocate the tracker storage. + pub fn size(&self) -> usize { + self.next_index.0 as usize + } +} + +impl std::fmt::Debug for TrackerIndexAllocator { + fn fmt(&self, _: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { + Ok(()) + } +} + +/// See TrackerIndexAllocator. +#[derive(Debug)] +pub(crate) struct SharedTrackerIndexAllocator { + inner: Mutex, +} + +impl SharedTrackerIndexAllocator { + pub fn new() -> Self { + SharedTrackerIndexAllocator { + inner: Mutex::new(TrackerIndexAllocator::new()), + } + } + + pub fn alloc(&self) -> TrackerIndex { + self.inner.lock().alloc() + } + + pub fn free(&self, index: TrackerIndex) { + self.inner.lock().free(index); + } + + pub fn size(&self) -> usize { + self.inner.lock().size() + } +} + +pub(crate) struct TrackerIndexAllocators { + pub buffers: Arc, + pub staging_buffers: Arc, + pub textures: Arc, + pub texture_views: Arc, + pub samplers: Arc, + pub bind_groups: Arc, + pub bind_group_layouts: Arc, + pub compute_pipelines: Arc, + pub render_pipelines: Arc, + pub pipeline_layouts: Arc, + pub bundles: Arc, + pub query_sets: Arc, +} + +impl TrackerIndexAllocators { + pub fn new() -> Self { + TrackerIndexAllocators { + buffers: Arc::new(SharedTrackerIndexAllocator::new()), + staging_buffers: Arc::new(SharedTrackerIndexAllocator::new()), + textures: Arc::new(SharedTrackerIndexAllocator::new()), + texture_views: Arc::new(SharedTrackerIndexAllocator::new()), + samplers: Arc::new(SharedTrackerIndexAllocator::new()), + bind_groups: Arc::new(SharedTrackerIndexAllocator::new()), + bind_group_layouts: Arc::new(SharedTrackerIndexAllocator::new()), + compute_pipelines: Arc::new(SharedTrackerIndexAllocator::new()), + render_pipelines: Arc::new(SharedTrackerIndexAllocator::new()), + pipeline_layouts: Arc::new(SharedTrackerIndexAllocator::new()), + bundles: Arc::new(SharedTrackerIndexAllocator::new()), + query_sets: Arc::new(SharedTrackerIndexAllocator::new()), + } + } +} + /// A structure containing all the information about a particular resource /// transition. User code should be able to generate a pipeline barrier /// based on the contents. @@ -359,31 +478,14 @@ pub(crate) struct RenderBundleScope { impl RenderBundleScope { /// Create the render bundle scope and pull the maximum IDs from the hubs. - pub fn new( - buffers: &Storage>, - textures: &Storage>, - bind_groups: &Storage>, - render_pipelines: &Storage>, - query_sets: &Storage>, - ) -> Self { - let value = Self { - buffers: RwLock::new(BufferUsageScope::new()), - textures: RwLock::new(TextureUsageScope::new()), + pub fn new() -> Self { + Self { + buffers: RwLock::new(BufferUsageScope::default()), + textures: RwLock::new(TextureUsageScope::default()), bind_groups: RwLock::new(StatelessTracker::new()), render_pipelines: RwLock::new(StatelessTracker::new()), query_sets: RwLock::new(StatelessTracker::new()), - }; - - value.buffers.write().set_size(buffers.len()); - value.textures.write().set_size(textures.len()); - value.bind_groups.write().set_size(bind_groups.len()); - value - .render_pipelines - .write() - .set_size(render_pipelines.len()); - value.query_sets.write().set_size(query_sets.len()); - - value + } } /// Merge the inner contents of a bind group into the render bundle tracker. @@ -410,31 +512,52 @@ impl RenderBundleScope { } } +/// A pool for storing the memory used by [`UsageScope`]s. We take and store this memory when the +/// scope is dropped to avoid reallocating. The memory required only grows and allocation cost is +/// significant when a large number of resources have been used. +pub(crate) type UsageScopePool = Mutex, TextureUsageScope)>>; + /// A usage scope tracker. Only needs to store stateful resources as stateless /// resources cannot possibly have a usage conflict. #[derive(Debug)] -pub(crate) struct UsageScope { +pub(crate) struct UsageScope<'a, A: HalApi> { + pub pool: &'a UsageScopePool, pub buffers: BufferUsageScope, pub textures: TextureUsageScope, } -impl UsageScope { - /// Create the render bundle scope and pull the maximum IDs from the hubs. - pub fn new( - buffers: &Storage>, - textures: &Storage>, - ) -> Self { - let mut value = Self { - buffers: BufferUsageScope::new(), - textures: TextureUsageScope::new(), - }; +impl<'a, A: HalApi> Drop for UsageScope<'a, A> { + fn drop(&mut self) { + // clear vecs and push into pool + self.buffers.clear(); + self.textures.clear(); + self.pool.lock().push(( + std::mem::take(&mut self.buffers), + std::mem::take(&mut self.textures), + )); + } +} - value.buffers.set_size(buffers.len()); - value.textures.set_size(textures.len()); +impl UsageScope<'static, A> { + pub fn new_pooled<'d>( + pool: &'d UsageScopePool, + tracker_indices: &TrackerIndexAllocators, + ) -> UsageScope<'d, A> { + let pooled = pool.lock().pop().unwrap_or_default(); + + let mut scope = UsageScope::<'d, A> { + pool, + buffers: pooled.0, + textures: pooled.1, + }; - value + scope.buffers.set_size(tracker_indices.buffers.size()); + scope.textures.set_size(tracker_indices.textures.size()); + scope } +} +impl<'a, A: HalApi> UsageScope<'a, A> { /// Merge the inner contents of a bind group into the usage scope. /// /// Only stateful things are merged in here, all other resources are owned @@ -478,11 +601,8 @@ impl UsageScope { } } -pub(crate) trait ResourceTracker -where - R: resource::Resource, -{ - fn remove_abandoned(&mut self, id: Id) -> bool; +pub(crate) trait ResourceTracker { + fn remove_abandoned(&mut self, index: TrackerIndex) -> bool; } /// A full double sided tracker used by CommandBuffers and the Device. @@ -513,48 +633,6 @@ impl Tracker { } } - /// Pull the maximum IDs from the hubs. - pub fn set_size( - &mut self, - buffers: Option<&Storage>>, - textures: Option<&Storage>>, - views: Option<&Storage>>, - samplers: Option<&Storage>>, - bind_groups: Option<&Storage>>, - compute_pipelines: Option<&Storage>>, - render_pipelines: Option<&Storage>>, - bundles: Option<&Storage>>, - query_sets: Option<&Storage>>, - ) { - if let Some(buffers) = buffers { - self.buffers.set_size(buffers.len()); - }; - if let Some(textures) = textures { - self.textures.set_size(textures.len()); - }; - if let Some(views) = views { - self.views.set_size(views.len()); - }; - if let Some(samplers) = samplers { - self.samplers.set_size(samplers.len()); - }; - if let Some(bind_groups) = bind_groups { - self.bind_groups.set_size(bind_groups.len()); - }; - if let Some(compute_pipelines) = compute_pipelines { - self.compute_pipelines.set_size(compute_pipelines.len()); - } - if let Some(render_pipelines) = render_pipelines { - self.render_pipelines.set_size(render_pipelines.len()); - }; - if let Some(bundles) = bundles { - self.bundles.set_size(bundles.len()); - }; - if let Some(query_sets) = query_sets { - self.query_sets.set_size(query_sets.len()); - }; - } - /// Iterates through all resources in the given bind group and adopts /// the state given for those resources in the UsageScope. It also /// removes all touched resources from the usage scope. @@ -585,7 +663,7 @@ impl Tracker { unsafe { self.buffers.set_and_remove_from_usage_scope_sparse( &mut scope.buffers, - bind_group.buffers.used_ids(), + bind_group.buffers.used_tracker_indices(), ) }; unsafe { diff --git a/wgpu-core/src/track/stateless.rs b/wgpu-core/src/track/stateless.rs index 4111a90f79..00225f2305 100644 --- a/wgpu-core/src/track/stateless.rs +++ b/wgpu-core/src/track/stateless.rs @@ -10,7 +10,7 @@ use parking_lot::Mutex; use crate::{id::Id, resource::Resource, resource_log, storage::Storage, track::ResourceMetadata}; -use super::ResourceTracker; +use super::{ResourceTracker, TrackerIndex}; /// Satisfy clippy. type Pair = (Id<::Marker>, Arc); @@ -74,7 +74,7 @@ pub(crate) struct StatelessTracker { metadata: ResourceMetadata, } -impl ResourceTracker for StatelessTracker { +impl ResourceTracker for StatelessTracker { /// Try to remove the given resource from the tracker iff we have the last reference to the /// resource and the epoch matches. /// @@ -82,14 +82,14 @@ impl ResourceTracker for StatelessTracker { /// /// If the ID is higher than the length of internal vectors, /// false will be returned. - fn remove_abandoned(&mut self, id: Id) -> bool { - let index = id.unzip().0 as usize; + fn remove_abandoned(&mut self, index: TrackerIndex) -> bool { + let index = index.as_usize(); if index >= self.metadata.size() { return false; } - resource_log!("StatelessTracker::remove_abandoned {id:?}"); + resource_log!("StatelessTracker::remove_abandoned {index:?}"); self.tracker_assert_in_bounds(index); @@ -100,17 +100,10 @@ impl ResourceTracker for StatelessTracker { //so it's already been released from user and so it's not inside Registry\Storage if existing_ref_count <= 2 { self.metadata.remove(index); - log::trace!("{} {:?} is not tracked anymore", T::TYPE, id,); return true; - } else { - log::trace!( - "{} {:?} is still referenced from {}", - T::TYPE, - id, - existing_ref_count - ); - return false; } + + return false; } } true @@ -160,9 +153,8 @@ impl StatelessTracker { /// /// If the ID is higher than the length of internal vectors, /// the vectors will be extended. A call to set_size is not needed. - pub fn insert_single(&mut self, id: Id, resource: Arc) { - let (index32, _epoch, _) = id.unzip(); - let index = index32 as usize; + pub fn insert_single(&mut self, resource: Arc) { + let index = resource.as_info().tracker_index().as_usize(); self.allow_index(index); @@ -184,8 +176,7 @@ impl StatelessTracker { ) -> Option<&'a Arc> { let resource = storage.get(id).ok()?; - let (index32, _epoch, _) = id.unzip(); - let index = index32 as usize; + let index = resource.as_info().tracker_index().as_usize(); self.allow_index(index); @@ -221,18 +212,4 @@ impl StatelessTracker { } } } - - pub fn get(&self, id: Id) -> Option<&Arc> { - let index = id.unzip().0 as usize; - if index > self.metadata.size() { - return None; - } - self.tracker_assert_in_bounds(index); - unsafe { - if self.metadata.contains_unchecked(index) { - return Some(self.metadata.get_resource_unchecked(index)); - } - } - None - } } diff --git a/wgpu-core/src/track/texture.rs b/wgpu-core/src/track/texture.rs index 601df11e1b..3cf95ff38a 100644 --- a/wgpu-core/src/track/texture.rs +++ b/wgpu-core/src/track/texture.rs @@ -19,10 +19,11 @@ * will treat the contents as junk. !*/ -use super::{range::RangedStates, PendingTransition, PendingTransitionList, ResourceTracker}; +use super::{ + range::RangedStates, PendingTransition, PendingTransitionList, ResourceTracker, TrackerIndex, +}; use crate::{ hal_api::HalApi, - id::TextureId, resource::{Resource, Texture, TextureInner}, snatch::SnatchGuard, track::{ @@ -173,7 +174,7 @@ impl TextureBindGroupState { /// accesses will be in a constant ascending order. pub(crate) fn optimize(&self) { let mut textures = self.textures.lock(); - textures.sort_unstable_by_key(|v| v.texture.as_info().id().unzip().0); + textures.sort_unstable_by_key(|v| v.texture.as_info().tracker_index()); } /// Returns a list of all textures tracked. May contain duplicates. @@ -209,6 +210,7 @@ pub(crate) struct TextureStateSet { simple: Vec, complex: FastHashMap, } + impl TextureStateSet { fn new() -> Self { Self { @@ -234,15 +236,16 @@ pub(crate) struct TextureUsageScope { metadata: ResourceMetadata>, } -impl TextureUsageScope { - pub fn new() -> Self { +impl Default for TextureUsageScope { + fn default() -> Self { Self { set: TextureStateSet::new(), - metadata: ResourceMetadata::new(), } } +} +impl TextureUsageScope { fn tracker_assert_in_bounds(&self, index: usize) { self.metadata.tracker_assert_in_bounds(index); @@ -257,6 +260,11 @@ impl TextureUsageScope { }); } + pub fn clear(&mut self) { + self.set.clear(); + self.metadata.clear(); + } + /// Sets the size of all the vectors inside the tracker. /// /// Must be called with the highest possible Texture ID before @@ -359,7 +367,7 @@ impl TextureUsageScope { selector: Option, new_state: TextureUses, ) -> Result<(), UsageConflict> { - let index = texture.as_info().id().unzip().0 as usize; + let index = texture.as_info().tracker_index().as_usize(); self.tracker_assert_in_bounds(index); @@ -393,7 +401,7 @@ pub(crate) struct TextureTracker { _phantom: PhantomData, } -impl ResourceTracker> for TextureTracker { +impl ResourceTracker for TextureTracker { /// Try to remove the given resource from the tracker iff we have the last reference to the /// resource and the epoch matches. /// @@ -401,10 +409,10 @@ impl ResourceTracker> for TextureTracker { /// /// If the ID is higher than the length of internal vectors, /// false will be returned. - fn remove_abandoned(&mut self, id: TextureId) -> bool { - let index = id.unzip().0 as usize; + fn remove_abandoned(&mut self, index: TrackerIndex) -> bool { + let index = index.as_usize(); - if index > self.metadata.size() { + if index >= self.metadata.size() { return false; } @@ -419,16 +427,10 @@ impl ResourceTracker> for TextureTracker { self.start_set.complex.remove(&index); self.end_set.complex.remove(&index); self.metadata.remove(index); - log::trace!("Texture {:?} is not tracked anymore", id,); return true; - } else { - log::trace!( - "Texture {:?} is still referenced from {}", - id, - existing_ref_count - ); - return false; } + + return false; } } true @@ -518,8 +520,8 @@ impl TextureTracker { /// /// If the ID is higher than the length of internal vectors, /// the vectors will be extended. A call to set_size is not needed. - pub fn insert_single(&mut self, id: TextureId, resource: Arc>, usage: TextureUses) { - let index = id.unzip().0 as usize; + pub fn insert_single(&mut self, resource: Arc>, usage: TextureUses) { + let index = resource.info.tracker_index().as_usize(); self.allow_index(index); @@ -560,7 +562,7 @@ impl TextureTracker { selector: TextureSelector, new_state: TextureUses, ) -> Option>> { - let index = texture.as_info().id().unzip().0 as usize; + let index = texture.as_info().tracker_index().as_usize(); self.allow_index(index); @@ -694,7 +696,7 @@ impl TextureTracker { let textures = bind_group_state.textures.lock(); for t in textures.iter() { - let index = t.texture.as_info().id().unzip().0 as usize; + let index = t.texture.as_info().tracker_index().as_usize(); scope.tracker_assert_in_bounds(index); if unsafe { !scope.metadata.contains_unchecked(index) } { @@ -727,10 +729,10 @@ impl TextureTracker { /// /// If the ID is higher than the length of internal vectors, /// false will be returned. - pub fn remove(&mut self, id: TextureId) -> bool { - let index = id.unzip().0 as usize; + pub fn remove(&mut self, index: TrackerIndex) -> bool { + let index = index.as_usize(); - if index > self.metadata.size() { + if index >= self.metadata.size() { return false; } @@ -1080,11 +1082,7 @@ unsafe fn merge( if invalid_resource_state(merged_state) { return Err(UsageConflict::from_texture( - TextureId::zip( - index as _, - unsafe { metadata_provider.get_epoch(index) }, - A::VARIANT, - ), + unsafe { metadata_provider.get_own(index).info.id() }, texture_selector.clone(), *current_simple, new_simple, @@ -1111,11 +1109,7 @@ unsafe fn merge( if invalid_resource_state(merged_state) { return Err(UsageConflict::from_texture( - TextureId::zip( - index as _, - unsafe { metadata_provider.get_epoch(index) }, - A::VARIANT, - ), + unsafe { metadata_provider.get_own(index).info.id() }, selector, *current_simple, new_state, @@ -1156,11 +1150,7 @@ unsafe fn merge( if invalid_resource_state(merged_state) { return Err(UsageConflict::from_texture( - TextureId::zip( - index as _, - unsafe { metadata_provider.get_epoch(index) }, - A::VARIANT, - ), + unsafe { metadata_provider.get_own(index).info.id() }, TextureSelector { mips: mip_id..mip_id + 1, layers: layers.clone(), @@ -1201,11 +1191,7 @@ unsafe fn merge( if invalid_resource_state(merged_state) { return Err(UsageConflict::from_texture( - TextureId::zip( - index as _, - unsafe { metadata_provider.get_epoch(index) }, - A::VARIANT, - ), + unsafe { metadata_provider.get_own(index).info.id() }, TextureSelector { mips: mip_id..mip_id + 1, layers: layers.clone(), diff --git a/wgpu-core/src/validation.rs b/wgpu-core/src/validation.rs index 00307a71b6..d360ee9621 100644 --- a/wgpu-core/src/validation.rs +++ b/wgpu-core/src/validation.rs @@ -1,4 +1,8 @@ -use crate::{device::bgl, FastHashMap, FastHashSet}; +use crate::{ + device::bgl, + id::{markers::Buffer, Id}, + FastHashMap, FastHashSet, +}; use arrayvec::ArrayVec; use std::{collections::hash_map::Entry, fmt}; use thiserror::Error; @@ -134,8 +138,11 @@ pub struct Interface { } #[derive(Clone, Debug, Error)] -#[error("Buffer usage is {actual:?} which does not contain required usage {expected:?}")] +#[error( + "Usage flags {actual:?} for buffer {id:?} do not contain required usage flags {expected:?}" +)] pub struct MissingBufferUsageError { + pub(crate) id: Id, pub(crate) actual: wgt::BufferUsages, pub(crate) expected: wgt::BufferUsages, } @@ -143,11 +150,16 @@ pub struct MissingBufferUsageError { /// Checks that the given buffer usage contains the required buffer usage, /// returns an error otherwise. pub fn check_buffer_usage( + id: Id, actual: wgt::BufferUsages, expected: wgt::BufferUsages, ) -> Result<(), MissingBufferUsageError> { if !actual.contains(expected) { - Err(MissingBufferUsageError { actual, expected }) + Err(MissingBufferUsageError { + id, + actual, + expected, + }) } else { Ok(()) } @@ -271,6 +283,16 @@ pub enum StageError { }, #[error("Location[{location}] is provided by the previous stage output but is not consumed as input by this stage.")] InputNotConsumed { location: wgt::ShaderLocation }, + #[error( + "Unable to select an entry point: no entry point was found in the provided shader module" + )] + NoEntryPointFound, + #[error( + "Unable to select an entry point: \ + multiple entry points were found in the provided shader module, \ + but no entry point was specified" + )] + MultipleEntryPointsFound, } fn map_storage_format_to_naga(format: wgt::TextureFormat) -> Option { @@ -633,7 +655,8 @@ impl NumericType { | Vf::Unorm16x4 | Vf::Snorm16x4 | Vf::Float16x4 - | Vf::Float32x4 => (NumericDimension::Vector(Vs::Quad), Scalar::F32), + | Vf::Float32x4 + | Vf::Unorm10_10_10_2 => (NumericDimension::Vector(Vs::Quad), Scalar::F32), Vf::Float64 => (NumericDimension::Scalar, Scalar::F64), Vf::Float64x2 => (NumericDimension::Vector(Vs::Bi), Scalar::F64), Vf::Float64x3 => (NumericDimension::Vector(Vs::Tri), Scalar::F64), @@ -959,6 +982,37 @@ impl Interface { } } + pub fn finalize_entry_point_name( + &self, + stage_bit: wgt::ShaderStages, + entry_point_name: Option<&str>, + ) -> Result { + let stage = Self::shader_stage_from_stage_bit(stage_bit); + entry_point_name + .map(|ep| ep.to_string()) + .map(Ok) + .unwrap_or_else(|| { + let mut entry_points = self + .entry_points + .keys() + .filter_map(|(ep_stage, name)| (ep_stage == &stage).then_some(name)); + let first = entry_points.next().ok_or(StageError::NoEntryPointFound)?; + if entry_points.next().is_some() { + return Err(StageError::MultipleEntryPointsFound); + } + Ok(first.clone()) + }) + } + + pub(crate) fn shader_stage_from_stage_bit(stage_bit: wgt::ShaderStages) -> naga::ShaderStage { + match stage_bit { + wgt::ShaderStages::VERTEX => naga::ShaderStage::Vertex, + wgt::ShaderStages::FRAGMENT => naga::ShaderStage::Fragment, + wgt::ShaderStages::COMPUTE => naga::ShaderStage::Compute, + _ => unreachable!(), + } + } + pub fn check_stage( &self, layouts: &mut BindingLayoutSource<'_>, @@ -970,17 +1024,13 @@ impl Interface { ) -> Result { // Since a shader module can have multiple entry points with the same name, // we need to look for one with the right execution model. - let shader_stage = match stage_bit { - wgt::ShaderStages::VERTEX => naga::ShaderStage::Vertex, - wgt::ShaderStages::FRAGMENT => naga::ShaderStage::Fragment, - wgt::ShaderStages::COMPUTE => naga::ShaderStage::Compute, - _ => unreachable!(), - }; + let shader_stage = Self::shader_stage_from_stage_bit(stage_bit); let pair = (shader_stage, entry_point_name.to_string()); - let entry_point = self - .entry_points - .get(&pair) - .ok_or(StageError::MissingEntryPoint(pair.1))?; + let entry_point = match self.entry_points.get(&pair) { + Some(some) => some, + None => return Err(StageError::MissingEntryPoint(pair.1)), + }; + let (_stage, entry_point_name) = pair; // check resources visibility for &handle in entry_point.resources.iter() { @@ -1260,7 +1310,9 @@ pub fn validate_color_attachment_bytes_per_sample( ) -> Result<(), u32> { let mut total_bytes_per_sample = 0; for format in attachment_formats { - let Some(format) = format else { continue; }; + let Some(format) = format else { + continue; + }; let byte_cost = format.target_pixel_byte_cost().unwrap(); let alignment = format.target_component_alignment().unwrap(); diff --git a/wgpu-hal/Cargo.toml b/wgpu-hal/Cargo.toml index 9dd24ee2b1..ad1d0a974a 100644 --- a/wgpu-hal/Cargo.toml +++ b/wgpu-hal/Cargo.toml @@ -13,7 +13,7 @@ license = "MIT OR Apache-2.0" # copy the crates it actually uses out of the workspace, so it's meaningful for # them to have less restrictive MSRVs individually than the workspace as a # whole, if their code permits. See `../README.md` for details. -rust-version = "1.70" +rust-version = "1.74" [package.metadata.docs.rs] # Ideally we would enable all the features. @@ -42,8 +42,16 @@ vulkan = [ "gpu-descriptor", "libloading", "smallvec", + "android_system_properties", +] +gles = [ + "naga/glsl-out", + "glow", + "glutin_wgl_sys", + "khronos-egl", + "libloading", + "ndk-sys", ] -gles = ["naga/glsl-out", "glow", "glutin_wgl_sys", "khronos-egl", "libloading"] dx12 = [ "naga/hlsl-out", "d3d12", @@ -63,6 +71,18 @@ dxc_shader_compiler = ["hassle-rs"] renderdoc = ["libloading", "renderdoc-sys"] fragile-send-sync-non-atomic-wasm = ["wgt/fragile-send-sync-non-atomic-wasm"] link = ["metal/link"] +# Panic when running into an out-of-memory error (for debugging purposes). +# +# Only affects the d3d12 and vulkan backends. +oom_panic = [] +# Panic when running into a device lost error (for debugging purposes). +# Only affects the d3d12 and vulkan backends. +device_lost_panic = [] +# Panic when running into an internal error other than out-of-memory and device lost +# (for debugging purposes). +# +# Only affects the d3d12 and vulkan backends. +internal_error_panic = [] [[example]] name = "halmark" @@ -101,7 +121,7 @@ smallvec = { version = "1", optional = true, features = ["union"] } khronos-egl = { version = "6", features = ["dynamic"], optional = true } libloading = { version = ">=0.7, <0.9", optional = true } -renderdoc-sys = { version = "1.0.0", optional = true } +renderdoc-sys = { version = "1.1.0", optional = true } [target.'cfg(target_os = "emscripten")'.dependencies] khronos-egl = { version = "6", features = ["static", "no-pkg-config"] } @@ -141,19 +161,20 @@ core-graphics-types = "0.1" [target.'cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))'.dependencies] wasm-bindgen = "0.2.87" -web-sys = { version = "0.3.67", features = [ +web-sys = { version = "0.3.69", features = [ "Window", "HtmlCanvasElement", "WebGl2RenderingContext", "OffscreenCanvas", ] } -js-sys = "0.3.67" +js-sys = "0.3.69" [target.'cfg(unix)'.dependencies] libc = "0.2" [target.'cfg(target_os = "android")'.dependencies] -android_system_properties = "0.1.1" +android_system_properties = { version = "0.1.1", optional = true } +ndk-sys = { version = "0.5.0", optional = true } [dependencies.naga] path = "../naga" @@ -171,9 +192,9 @@ features = ["wgsl-in"] [dev-dependencies] cfg-if = "1" -env_logger = "0.10" +env_logger = "0.11" glam = "0.25.0" # for ray-traced-triangle example -winit = { version = "0.29.10", features = [ +winit = { version = "0.29.14", features = [ "android-native-activity", ] } # for "halmark" example diff --git a/wgpu-hal/src/auxil/dxgi/conv.rs b/wgpu-hal/src/auxil/dxgi/conv.rs index 6af4b77bb3..e5162362f7 100644 --- a/wgpu-hal/src/auxil/dxgi/conv.rs +++ b/wgpu-hal/src/auxil/dxgi/conv.rs @@ -261,6 +261,7 @@ pub fn map_vertex_format(format: wgt::VertexFormat) -> dxgiformat::DXGI_FORMAT { Vf::Uint32x4 => DXGI_FORMAT_R32G32B32A32_UINT, Vf::Sint32x4 => DXGI_FORMAT_R32G32B32A32_SINT, Vf::Float32x4 => DXGI_FORMAT_R32G32B32A32_FLOAT, + Vf::Unorm10_10_10_2 => DXGI_FORMAT_R10G10B10A2_UNORM, Vf::Float64 | Vf::Float64x2 | Vf::Float64x3 | Vf::Float64x4 => unimplemented!(), } } diff --git a/wgpu-hal/src/auxil/dxgi/result.rs b/wgpu-hal/src/auxil/dxgi/result.rs index db013d2dec..2ac4464568 100644 --- a/wgpu-hal/src/auxil/dxgi/result.rs +++ b/wgpu-hal/src/auxil/dxgi/result.rs @@ -21,8 +21,26 @@ impl HResult<()> for i32 { Err(Cow::Borrowed(description)) } fn into_device_result(self, description: &str) -> Result<(), crate::DeviceError> { + #![allow(unreachable_code)] + self.into_result().map_err(|err| { log::error!("{} failed: {}", description, err); + + match self { + winerror::E_OUTOFMEMORY => { + #[cfg(feature = "oom_panic")] + panic!("{description} failed: Out of memory"); + } + winerror::DXGI_ERROR_DEVICE_RESET | winerror::DXGI_ERROR_DEVICE_REMOVED => { + #[cfg(feature = "device_lost_panic")] + panic!("{description} failed: Device lost ({err})"); + } + _ => { + #[cfg(feature = "internal_error_panic")] + panic!("{description} failed: {err}"); + } + } + if self == winerror::E_OUTOFMEMORY { crate::DeviceError::OutOfMemory } else { diff --git a/wgpu-hal/src/dx12/adapter.rs b/wgpu-hal/src/dx12/adapter.rs index 712c2254b3..b417a88a6f 100644 --- a/wgpu-hal/src/dx12/adapter.rs +++ b/wgpu-hal/src/dx12/adapter.rs @@ -242,6 +242,7 @@ impl super::Adapter { | wgt::Features::POLYGON_MODE_LINE | wgt::Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES | wgt::Features::TIMESTAMP_QUERY + | wgt::Features::TIMESTAMP_QUERY_INSIDE_ENCODERS | wgt::Features::TIMESTAMP_QUERY_INSIDE_PASSES | wgt::Features::TEXTURE_COMPRESSION_BC | wgt::Features::CLEAR_TEXTURE @@ -294,6 +295,22 @@ impl super::Adapter { bgra8unorm_storage_supported, ); + // we must be using DXC because uint64_t was added with Shader Model 6 + // and FXC only supports up to 5.1 + let int64_shader_ops_supported = dxc_container.is_some() && { + let mut features1: d3d12_ty::D3D12_FEATURE_DATA_D3D12_OPTIONS1 = + unsafe { mem::zeroed() }; + let hr = unsafe { + device.CheckFeatureSupport( + d3d12_ty::D3D12_FEATURE_D3D12_OPTIONS1, + &mut features1 as *mut _ as *mut _, + mem::size_of::() as _, + ) + }; + hr == 0 && features1.Int64ShaderOps != 0 + }; + features.set(wgt::Features::SHADER_INT64, int64_shader_ops_supported); + // float32-filterable should always be available on d3d12 features.set(wgt::Features::FLOAT32_FILTERABLE, true); @@ -415,7 +432,9 @@ impl super::Adapter { } } -impl crate::Adapter for super::Adapter { +impl crate::Adapter for super::Adapter { + type A = super::Api; + unsafe fn open( &self, _features: wgt::Features, diff --git a/wgpu-hal/src/dx12/command.rs b/wgpu-hal/src/dx12/command.rs index f527898d90..3c535b2234 100644 --- a/wgpu-hal/src/dx12/command.rs +++ b/wgpu-hal/src/dx12/command.rs @@ -56,6 +56,13 @@ impl super::Temp { } } +impl Drop for super::CommandEncoder { + fn drop(&mut self) { + use crate::CommandEncoder; + unsafe { self.discard_encoding() } + } +} + impl super::CommandEncoder { unsafe fn begin_pass(&mut self, kind: super::PassKind, label: crate::Label) { let list = self.list.as_ref().unwrap(); @@ -242,7 +249,9 @@ impl super::CommandEncoder { } } -impl crate::CommandEncoder for super::CommandEncoder { +impl crate::CommandEncoder for super::CommandEncoder { + type A = super::Api; + unsafe fn begin_encoding(&mut self, label: crate::Label) -> Result<(), crate::DeviceError> { let list = loop { if let Some(list) = self.free_lists.pop() { diff --git a/wgpu-hal/src/dx12/device.rs b/wgpu-hal/src/dx12/device.rs index 2507c125f8..23bd409dc4 100644 --- a/wgpu-hal/src/dx12/device.rs +++ b/wgpu-hal/src/dx12/device.rs @@ -323,7 +323,9 @@ impl super::Device { } } -impl crate::Device for super::Device { +impl crate::Device for super::Device { + type A = super::Api; + unsafe fn exit(mut self, _queue: super::Queue) { self.rtv_pool.lock().free_handle(self.null_rtv_handle); self.mem_allocator = None; @@ -663,11 +665,7 @@ impl crate::Device for super::Device { end_of_pass_timer_query: None, }) } - unsafe fn destroy_command_encoder(&self, encoder: super::CommandEncoder) { - if let Some(list) = encoder.list { - list.close(); - } - } + unsafe fn destroy_command_encoder(&self, _encoder: super::CommandEncoder) {} unsafe fn create_bind_group_layout( &self, @@ -1102,7 +1100,16 @@ impl crate::Device for super::Device { } let mut dynamic_buffers = Vec::new(); - for (layout, entry) in desc.layout.entries.iter().zip(desc.entries.iter()) { + let layout_and_entry_iter = desc.entries.iter().map(|entry| { + let layout = desc + .layout + .entries + .iter() + .find(|layout_entry| layout_entry.binding == entry.binding) + .expect("internal error: no layout entry found with binding slot"); + (layout, entry) + }); + for (layout, entry) in layout_and_entry_iter { match layout.ty { wgt::BindingType::Buffer { has_dynamic_offset: true, diff --git a/wgpu-hal/src/dx12/instance.rs b/wgpu-hal/src/dx12/instance.rs index 020809328e..1dba7101df 100644 --- a/wgpu-hal/src/dx12/instance.rs +++ b/wgpu-hal/src/dx12/instance.rs @@ -13,7 +13,9 @@ impl Drop for super::Instance { } } -impl crate::Instance for super::Instance { +impl crate::Instance for super::Instance { + type A = super::Api; + unsafe fn init(desc: &crate::InstanceDescriptor) -> Result { profiling::scope!("Init DX12 Backend"); let lib_main = d3d12::D3D12Lib::new().map_err(|e| { diff --git a/wgpu-hal/src/dx12/mod.rs b/wgpu-hal/src/dx12/mod.rs index 053b880689..4f958943ca 100644 --- a/wgpu-hal/src/dx12/mod.rs +++ b/wgpu-hal/src/dx12/mod.rs @@ -238,6 +238,9 @@ struct DeviceShared { heap_samplers: descriptor::GeneralHeap, } +unsafe impl Send for DeviceShared {} +unsafe impl Sync for DeviceShared {} + pub struct Device { raw: d3d12::Device, present_queue: d3d12::CommandQueue, @@ -636,7 +639,9 @@ impl SwapChain { } } -impl crate::Surface for Surface { +impl crate::Surface for Surface { + type A = Api; + unsafe fn configure( &self, device: &Device, @@ -881,7 +886,9 @@ impl crate::Surface for Surface { } } -impl crate::Queue for Queue { +impl crate::Queue for Queue { + type A = Api; + unsafe fn submit( &self, command_buffers: &[&CommandBuffer], diff --git a/wgpu-hal/src/dx12/shader_compilation.rs b/wgpu-hal/src/dx12/shader_compilation.rs index df040dba15..288fc24745 100644 --- a/wgpu-hal/src/dx12/shader_compilation.rs +++ b/wgpu-hal/src/dx12/shader_compilation.rs @@ -13,7 +13,7 @@ use crate::auxil::dxgi::result::HResult; pub(super) fn compile_fxc( device: &super::Device, - source: &String, + source: &str, source_name: &str, raw_ep: &std::ffi::CString, stage_bit: wgt::ShaderStages, @@ -211,7 +211,7 @@ mod dxc { Err(crate::PipelineError::Linkage( stage_bit, format!( - "DXC compile error: {:?}", + "DXC compile error: {}", get_error_string_from_dxc_result(&dxc_container.library, &e.0) .unwrap_or_default() ), diff --git a/wgpu-hal/src/empty.rs b/wgpu-hal/src/empty.rs index d58e779b96..ad00da1b7f 100644 --- a/wgpu-hal/src/empty.rs +++ b/wgpu-hal/src/empty.rs @@ -39,7 +39,9 @@ impl crate::Api for Api { type ComputePipeline = Resource; } -impl crate::Instance for Context { +impl crate::Instance for Context { + type A = Api; + unsafe fn init(desc: &crate::InstanceDescriptor) -> Result { Ok(Context) } @@ -56,7 +58,9 @@ impl crate::Instance for Context { } } -impl crate::Surface for Context { +impl crate::Surface for Context { + type A = Api; + unsafe fn configure( &self, device: &Context, @@ -76,7 +80,9 @@ impl crate::Surface for Context { unsafe fn discard_texture(&self, texture: Resource) {} } -impl crate::Adapter for Context { +impl crate::Adapter for Context { + type A = Api; + unsafe fn open( &self, features: wgt::Features, @@ -100,7 +106,9 @@ impl crate::Adapter for Context { } } -impl crate::Queue for Context { +impl crate::Queue for Context { + type A = Api; + unsafe fn submit( &self, command_buffers: &[&Resource], @@ -122,7 +130,9 @@ impl crate::Queue for Context { } } -impl crate::Device for Context { +impl crate::Device for Context { + type A = Api; + unsafe fn exit(self, queue: Context) {} unsafe fn create_buffer(&self, desc: &crate::BufferDescriptor) -> DeviceResult { Ok(Resource) @@ -259,7 +269,9 @@ impl crate::Device for Context { unsafe fn destroy_acceleration_structure(&self, _acceleration_structure: Resource) {} } -impl crate::CommandEncoder for Encoder { +impl crate::CommandEncoder for Encoder { + type A = Api; + unsafe fn begin_encoding(&mut self, label: crate::Label) -> DeviceResult<()> { Ok(()) } diff --git a/wgpu-hal/src/gles/adapter.rs b/wgpu-hal/src/gles/adapter.rs index fd8ad7e695..b9d044337c 100644 --- a/wgpu-hal/src/gles/adapter.rs +++ b/wgpu-hal/src/gles/adapter.rs @@ -4,6 +4,7 @@ use std::sync::{atomic::AtomicU8, Arc}; use wgt::AstcChannel; use crate::auxil::db; +use crate::gles::ShaderClearProgram; // https://webgl2fundamentals.org/webgl/lessons/webgl-data-textures.html @@ -435,7 +436,8 @@ impl super::Adapter { let mut features = wgt::Features::empty() | wgt::Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES | wgt::Features::CLEAR_TEXTURE - | wgt::Features::PUSH_CONSTANTS; + | wgt::Features::PUSH_CONSTANTS + | wgt::Features::DEPTH32FLOAT_STENCIL8; features.set( wgt::Features::ADDRESS_MODE_CLAMP_TO_BORDER | wgt::Features::ADDRESS_MODE_CLAMP_TO_ZERO, extensions.contains("GL_EXT_texture_border_clamp") @@ -472,6 +474,7 @@ impl super::Adapter { features.set(wgt::Features::SHADER_UNUSED_VERTEX_OUTPUT, true); if extensions.contains("GL_ARB_timer_query") { features.set(wgt::Features::TIMESTAMP_QUERY, true); + features.set(wgt::Features::TIMESTAMP_QUERY_INSIDE_ENCODERS, true); features.set(wgt::Features::TIMESTAMP_QUERY_INSIDE_PASSES, true); } let gl_bcn_exts = [ @@ -728,9 +731,19 @@ impl super::Adapter { max_push_constant_size: super::MAX_PUSH_CONSTANTS as u32 * 4, min_uniform_buffer_offset_alignment, min_storage_buffer_offset_alignment, - max_inter_stage_shader_components: unsafe { - gl.get_parameter_i32(glow::MAX_VARYING_COMPONENTS) - } as u32, + max_inter_stage_shader_components: { + // MAX_VARYING_COMPONENTS may return 0, because it is deprecated since OpenGL 3.2 core, + // and an OpenGL Context with the core profile and with forward-compatibility=true, + // will make deprecated constants unavailable. + let max_varying_components = + unsafe { gl.get_parameter_i32(glow::MAX_VARYING_COMPONENTS) } as u32; + if max_varying_components == 0 { + // default value for max_inter_stage_shader_components + 60 + } else { + max_varying_components + } + }, max_color_attachments, max_color_attachment_bytes_per_sample, max_compute_workgroup_storage_size: if supports_work_group_params { @@ -790,6 +803,7 @@ impl super::Adapter { } let downlevel_defaults = wgt::DownlevelLimits {}; + let max_samples = unsafe { gl.get_parameter_i32(glow::MAX_SAMPLES) }; // Drop the GL guard so we can move the context into AdapterShared // ( on Wasm the gl handle is just a ref so we tell clippy to allow @@ -808,6 +822,7 @@ impl super::Adapter { next_shader_id: Default::default(), program_cache: Default::default(), es: es_ver.is_some(), + max_msaa_samples: max_samples, }), }, info: Self::make_info(vendor, renderer), @@ -836,7 +851,14 @@ impl super::Adapter { let source = if es { format!("#version 300 es\nprecision lowp float;\n{source}") } else { - format!("#version 130\n{source}") + let version = gl.version(); + if version.major == 3 && version.minor == 0 { + // OpenGL 3.0 only supports this format + format!("#version 130\n{source}") + } else { + // OpenGL 3.1+ support this format + format!("#version 140\n{source}") + } }; let shader = unsafe { gl.create_shader(shader_type) }.expect("Could not create shader"); unsafe { gl.shader_source(shader, &source) }; @@ -857,7 +879,7 @@ impl super::Adapter { unsafe fn create_shader_clear_program( gl: &glow::Context, es: bool, - ) -> Option<(glow::Program, glow::UniformLocation)> { + ) -> Option { let program = unsafe { gl.create_program() }.expect("Could not create shader program"); let vertex = unsafe { Self::compile_shader( @@ -893,11 +915,16 @@ impl super::Adapter { unsafe { gl.delete_shader(vertex) }; unsafe { gl.delete_shader(fragment) }; - Some((program, color_uniform_location)) + Some(ShaderClearProgram { + program, + color_uniform_location, + }) } } -impl crate::Adapter for super::Adapter { +impl crate::Adapter for super::Adapter { + type A = super::Api; + unsafe fn open( &self, features: wgt::Features, @@ -919,9 +946,18 @@ impl crate::Adapter for super::Adapter { // Compile the shader program we use for doing manual clears to work around Mesa fastclear // bug. - let (shader_clear_program, shader_clear_program_color_uniform_location) = unsafe { - Self::create_shader_clear_program(gl, self.shared.es) - .ok_or(crate::DeviceError::ResourceCreationFailed)? + let shader_clear_program = if self + .shared + .workarounds + .contains(super::Workarounds::MESA_I915_SRGB_SHADER_CLEAR) + { + Some(unsafe { + Self::create_shader_clear_program(gl, self.shared.es) + .ok_or(crate::DeviceError::ResourceCreationFailed)? + }) + } else { + // If we don't need the workaround, don't waste time and resources compiling the clear program + None }; Ok(crate::OpenDevice { @@ -939,7 +975,6 @@ impl crate::Adapter for super::Adapter { copy_fbo: unsafe { gl.create_framebuffer() } .map_err(|_| crate::DeviceError::OutOfMemory)?, shader_clear_program, - shader_clear_program_color_uniform_location, zero_buffer, temp_query_results: Mutex::new(Vec::new()), draw_buffer_count: AtomicU8::new(1), @@ -956,12 +991,7 @@ impl crate::Adapter for super::Adapter { use wgt::TextureFormat as Tf; let sample_count = { - let max_samples = unsafe { - self.shared - .context - .lock() - .get_parameter_i32(glow::MAX_SAMPLES) - }; + let max_samples = self.shared.max_msaa_samples; if max_samples >= 16 { Tfc::MULTISAMPLE_X2 | Tfc::MULTISAMPLE_X4 diff --git a/wgpu-hal/src/gles/command.rs b/wgpu-hal/src/gles/command.rs index 926122e4ad..258dee76e5 100644 --- a/wgpu-hal/src/gles/command.rs +++ b/wgpu-hal/src/gles/command.rs @@ -93,6 +93,13 @@ impl super::CommandBuffer { } } +impl Drop for super::CommandEncoder { + fn drop(&mut self) { + use crate::CommandEncoder; + unsafe { self.discard_encoding() } + } +} + impl super::CommandEncoder { fn rebind_stencil_func(&mut self) { fn make(s: &super::StencilSide, face: u32) -> C { @@ -243,7 +250,9 @@ impl super::CommandEncoder { } } -impl crate::CommandEncoder for super::CommandEncoder { +impl crate::CommandEncoder for super::CommandEncoder { + type A = super::Api; + unsafe fn begin_encoding(&mut self, label: crate::Label) -> Result<(), crate::DeviceError> { self.state = State::default(); self.cmd_buffer.label = label.map(str::to_string); diff --git a/wgpu-hal/src/gles/conv.rs b/wgpu-hal/src/gles/conv.rs index bde69b8629..a6c924f162 100644 --- a/wgpu-hal/src/gles/conv.rs +++ b/wgpu-hal/src/gles/conv.rs @@ -212,6 +212,7 @@ pub(super) fn describe_vertex_format(vertex_format: wgt::VertexFormat) -> super: Vf::Uint32x4 => (4, glow::UNSIGNED_INT, Vak::Integer), Vf::Sint32x4 => (4, glow::INT, Vak::Integer), Vf::Float32x4 => (4, glow::FLOAT, Vak::Float), + Vf::Unorm10_10_10_2 => (4, glow::UNSIGNED_INT_10_10_10_2, Vak::Float), Vf::Float64 | Vf::Float64x2 | Vf::Float64x3 | Vf::Float64x4 => unimplemented!(), }; diff --git a/wgpu-hal/src/gles/device.rs b/wgpu-hal/src/gles/device.rs index d0abe2c169..50c07f3ff0 100644 --- a/wgpu-hal/src/gles/device.rs +++ b/wgpu-hal/src/gles/device.rs @@ -483,7 +483,9 @@ impl super::Device { } } -impl crate::Device for super::Device { +impl crate::Device for super::Device { + type A = super::Api; + unsafe fn exit(self, queue: super::Queue) { let gl = &self.shared.context.lock(); unsafe { gl.delete_vertex_array(self.main_vao) }; @@ -1123,8 +1125,10 @@ impl crate::Device for super::Device { !0; bg_layout .entries - .last() - .map_or(0, |b| b.binding as usize + 1) + .iter() + .map(|b| b.binding) + .max() + .map_or(0, |idx| idx as usize + 1) ] .into_boxed_slice(); @@ -1177,7 +1181,16 @@ impl crate::Device for super::Device { ) -> Result { let mut contents = Vec::new(); - for (entry, layout) in desc.entries.iter().zip(desc.layout.entries.iter()) { + let layout_and_entry_iter = desc.entries.iter().map(|entry| { + let layout = desc + .layout + .entries + .iter() + .find(|layout_entry| layout_entry.binding == entry.binding) + .expect("internal error: no layout entry found with binding slot"); + (entry, layout) + }); + for (entry, layout) in layout_and_entry_iter { let binding = match layout.ty { wgt::BindingType::Buffer { .. } => { let bb = &desc.buffers[entry.resource_index as usize]; @@ -1194,13 +1207,16 @@ impl crate::Device for super::Device { let sampler = desc.samplers[entry.resource_index as usize]; super::RawBinding::Sampler(sampler.raw) } - wgt::BindingType::Texture { .. } => { + wgt::BindingType::Texture { view_dimension, .. } => { let view = desc.textures[entry.resource_index as usize].view; if view.array_layers.start != 0 { log::error!("Unable to create a sampled texture binding for non-zero array layer.\n{}", "This is an implementation problem of wgpu-hal/gles backend.") } let (raw, target) = view.inner.as_native(); + + super::Texture::log_failing_target_heuristics(view_dimension, target); + super::RawBinding::Texture { raw, target, diff --git a/wgpu-hal/src/gles/egl.rs b/wgpu-hal/src/gles/egl.rs index aa985d8121..b166f4f102 100644 --- a/wgpu-hal/src/gles/egl.rs +++ b/wgpu-hal/src/gles/egl.rs @@ -1,7 +1,8 @@ use glow::HasContext; +use once_cell::sync::Lazy; use parking_lot::{Mutex, MutexGuard, RwLock}; -use std::{ffi, os::raw, ptr, rc::Rc, sync::Arc, time::Duration}; +use std::{collections::HashMap, ffi, os::raw, ptr, rc::Rc, sync::Arc, time::Duration}; /// The amount of time to wait while trying to obtain a lock to the adapter context const CONTEXT_LOCK_TIMEOUT_SECS: u64 = 1; @@ -50,16 +51,6 @@ type WlEglWindowResizeFun = unsafe extern "system" fn( type WlEglWindowDestroyFun = unsafe extern "system" fn(window: *const raw::c_void); -#[cfg(target_os = "android")] -extern "C" { - pub fn ANativeWindow_setBuffersGeometry( - window: *mut raw::c_void, - width: i32, - height: i32, - format: i32, - ) -> i32; -} - type EglLabel = *const raw::c_void; #[allow(clippy::upper_case_acronyms)] @@ -161,7 +152,7 @@ impl Drop for DisplayOwner { fn open_x_display() -> Option { log::debug!("Loading X11 library to get the current display"); unsafe { - let library = libloading::Library::new("libX11.so").ok()?; + let library = find_library(&["libX11.so.6", "libX11.so"])?; let func: libloading::Symbol = library.get(b"XOpenDisplay").unwrap(); let result = func(ptr::null()); ptr::NonNull::new(result).map(|ptr| DisplayOwner { @@ -442,6 +433,45 @@ struct Inner { srgb_kind: SrgbFrameBufferKind, } +// Different calls to `eglGetPlatformDisplay` may return the same `Display`, making it a global +// state of all our `EglContext`s. This forces us to track the number of such context to prevent +// terminating the display if it's currently used by another `EglContext`. +static DISPLAYS_REFERENCE_COUNT: Lazy>> = Lazy::new(Default::default); + +fn initialize_display( + egl: &EglInstance, + display: khronos_egl::Display, +) -> Result<(i32, i32), khronos_egl::Error> { + let mut guard = DISPLAYS_REFERENCE_COUNT.lock(); + *guard.entry(display.as_ptr() as usize).or_default() += 1; + + // We don't need to check the reference count here since according to the `eglInitialize` + // documentation, initializing an already initialized EGL display connection has no effect + // besides returning the version numbers. + egl.initialize(display) +} + +fn terminate_display( + egl: &EglInstance, + display: khronos_egl::Display, +) -> Result<(), khronos_egl::Error> { + let key = &(display.as_ptr() as usize); + let mut guard = DISPLAYS_REFERENCE_COUNT.lock(); + let count_ref = guard + .get_mut(key) + .expect("Attempted to decref a display before incref was called"); + + if *count_ref > 1 { + *count_ref -= 1; + + Ok(()) + } else { + guard.remove(key); + + egl.terminate(display) + } +} + impl Inner { fn create( flags: wgt::InstanceFlags, @@ -449,7 +479,7 @@ impl Inner { display: khronos_egl::Display, force_gles_minor_version: wgt::Gles3MinorVersion, ) -> Result { - let version = egl.initialize(display).map_err(|e| { + let version = initialize_display(&egl, display).map_err(|e| { crate::InstanceError::with_source( String::from("failed to initialize EGL display connection"), e, @@ -618,7 +648,8 @@ impl Drop for Inner { { log::warn!("Error in destroy_context: {:?}", e); } - if let Err(e) = self.egl.instance.terminate(self.egl.display) { + + if let Err(e) = terminate_display(&self.egl.instance, self.egl.display) { log::warn!("Error in terminate: {:?}", e); } } @@ -672,7 +703,9 @@ impl Instance { unsafe impl Send for Instance {} unsafe impl Sync for Instance {} -impl crate::Instance for Instance { +impl crate::Instance for Instance { + type A = super::Api; + unsafe fn init(desc: &crate::InstanceDescriptor) -> Result { profiling::scope!("Init OpenGL (EGL) Backend"); #[cfg(Emscripten)] @@ -783,11 +816,12 @@ impl crate::Instance for Instance { (display, Some(Rc::new(display_owner)), WindowKind::AngleX11) } else if client_ext_str.contains("EGL_MESA_platform_surfaceless") { log::warn!("No windowing system present. Using surfaceless platform"); + #[allow(clippy::unnecessary_literal_unwrap)] // This is only a literal on Emscripten let egl = egl1_5.expect("Failed to get EGL 1.5 for surfaceless"); let display = unsafe { egl.get_platform_display( EGL_PLATFORM_SURFACELESS_MESA, - std::ptr::null_mut(), + khronos_egl::DEFAULT_DISPLAY, &[khronos_egl::ATTRIB_NONE], ) } @@ -863,7 +897,12 @@ impl crate::Instance for Instance { .unwrap(); let ret = unsafe { - ANativeWindow_setBuffersGeometry(handle.a_native_window.as_ptr(), 0, 0, format) + ndk_sys::ANativeWindow_setBuffersGeometry( + handle.a_native_window.as_ptr() as *mut ndk_sys::ANativeWindow, + 0, + 0, + format, + ) }; if ret != 0 { @@ -1128,7 +1167,9 @@ impl Surface { } } -impl crate::Surface for Surface { +impl crate::Surface for Surface { + type A = super::Api; + unsafe fn configure( &self, device: &super::Device, diff --git a/wgpu-hal/src/gles/mod.rs b/wgpu-hal/src/gles/mod.rs index 646419c7fe..6f41f7c000 100644 --- a/wgpu-hal/src/gles/mod.rs +++ b/wgpu-hal/src/gles/mod.rs @@ -251,6 +251,11 @@ struct AdapterShared { next_shader_id: AtomicU32, program_cache: Mutex, es: bool, + + /// Result of `gl.get_parameter_i32(glow::MAX_SAMPLES)`. + /// Cached here so it doesn't need to be queried every time texture format capabilities are requested. + /// (this has been shown to be a significant enough overhead) + max_msaa_samples: i32, } pub struct Adapter { @@ -264,6 +269,11 @@ pub struct Device { render_doc: crate::auxil::renderdoc::RenderDoc, } +pub struct ShaderClearProgram { + pub program: glow::Program, + pub color_uniform_location: glow::UniformLocation, +} + pub struct Queue { shared: Arc, features: wgt::Features, @@ -271,9 +281,7 @@ pub struct Queue { copy_fbo: glow::Framebuffer, /// Shader program used to clear the screen for [`Workarounds::MESA_I915_SRGB_SHADER_CLEAR`] /// devices. - shader_clear_program: glow::Program, - /// The uniform location of the color uniform in the shader clear program - shader_clear_program_color_uniform_location: glow::UniformLocation, + shader_clear_program: Option, /// Keep a reasonably large buffer filled with zeroes, so that we can implement `ClearBuffer` of /// zeroes by copying from it. zero_buffer: glow::Buffer, @@ -366,6 +374,8 @@ impl Texture { /// Returns the `target`, whether the image is 3d and whether the image is a cubemap. fn get_info_from_desc(desc: &TextureDescriptor) -> u32 { match desc.dimension { + // WebGL (1 and 2) as well as some GLES versions do not have 1D textures, so we are + // doing `TEXTURE_2D` instead wgt::TextureDimension::D1 => glow::TEXTURE_2D, wgt::TextureDimension::D2 => { // HACK: detect a cube map; forces cube compatible textures to be cube textures @@ -379,6 +389,43 @@ impl Texture { wgt::TextureDimension::D3 => glow::TEXTURE_3D, } } + + /// More information can be found in issues #1614 and #1574 + fn log_failing_target_heuristics(view_dimension: wgt::TextureViewDimension, target: u32) { + let expected_target = match view_dimension { + wgt::TextureViewDimension::D1 => glow::TEXTURE_2D, + wgt::TextureViewDimension::D2 => glow::TEXTURE_2D, + wgt::TextureViewDimension::D2Array => glow::TEXTURE_2D_ARRAY, + wgt::TextureViewDimension::Cube => glow::TEXTURE_CUBE_MAP, + wgt::TextureViewDimension::CubeArray => glow::TEXTURE_CUBE_MAP_ARRAY, + wgt::TextureViewDimension::D3 => glow::TEXTURE_3D, + }; + + if expected_target == target { + return; + } + + let buffer; + let got = match target { + glow::TEXTURE_2D => "D2", + glow::TEXTURE_2D_ARRAY => "D2Array", + glow::TEXTURE_CUBE_MAP => "Cube", + glow::TEXTURE_CUBE_MAP_ARRAY => "CubeArray", + glow::TEXTURE_3D => "D3", + target => { + buffer = target.to_string(); + &buffer + } + }; + + log::error!( + "wgpu-hal heuristics assumed that the view dimension will be equal to `{got}` rather than `{view_dimension:?}`.\n{}\n{}\n{}\n{}", + "`D2` textures with `depth_or_array_layers == 1` are assumed to have view dimension `D2`", + "`D2` textures with `depth_or_array_layers > 1` are assumed to have view dimension `D2Array`", + "`D2` textures with `depth_or_array_layers == 6` are assumed to have view dimension `Cube`", + "`D2` textures with `depth_or_array_layers > 6 && depth_or_array_layers % 6 == 0` are assumed to have view dimension `CubeArray`", + ); + } } #[derive(Clone, Debug)] diff --git a/wgpu-hal/src/gles/queue.rs b/wgpu-hal/src/gles/queue.rs index 6ec553bd29..29dfb79d04 100644 --- a/wgpu-hal/src/gles/queue.rs +++ b/wgpu-hal/src/gles/queue.rs @@ -40,10 +40,14 @@ fn get_z_offset(target: u32, base: &crate::TextureCopyBase) -> u32 { impl super::Queue { /// Performs a manual shader clear, used as a workaround for a clearing bug on mesa unsafe fn perform_shader_clear(&self, gl: &glow::Context, draw_buffer: u32, color: [f32; 4]) { - unsafe { gl.use_program(Some(self.shader_clear_program)) }; + let shader_clear = self + .shader_clear_program + .as_ref() + .expect("shader_clear_program should always be set if the workaround is enabled"); + unsafe { gl.use_program(Some(shader_clear.program)) }; unsafe { gl.uniform_4_f32( - Some(&self.shader_clear_program_color_uniform_location), + Some(&shader_clear.color_uniform_location), color[0], color[1], color[2], @@ -1744,7 +1748,9 @@ impl super::Queue { } } -impl crate::Queue for super::Queue { +impl crate::Queue for super::Queue { + type A = super::Api; + unsafe fn submit( &self, command_buffers: &[&super::CommandBuffer], diff --git a/wgpu-hal/src/gles/web.rs b/wgpu-hal/src/gles/web.rs index 797d6f91d7..ab2ccef8b6 100644 --- a/wgpu-hal/src/gles/web.rs +++ b/wgpu-hal/src/gles/web.rs @@ -116,7 +116,9 @@ unsafe impl Sync for Instance {} #[cfg(send_sync)] unsafe impl Send for Instance {} -impl crate::Instance for Instance { +impl crate::Instance for Instance { + type A = super::Api; + unsafe fn init(_desc: &crate::InstanceDescriptor) -> Result { profiling::scope!("Init OpenGL (WebGL) Backend"); Ok(Instance { @@ -309,7 +311,9 @@ impl Surface { } } -impl crate::Surface for Surface { +impl crate::Surface for Surface { + type A = super::Api; + unsafe fn configure( &self, device: &super::Device, diff --git a/wgpu-hal/src/gles/wgl.rs b/wgpu-hal/src/gles/wgl.rs index 6243430dc2..2564892969 100644 --- a/wgpu-hal/src/gles/wgl.rs +++ b/wgpu-hal/src/gles/wgl.rs @@ -160,6 +160,9 @@ struct Inner { context: WglContext, } +unsafe impl Send for Inner {} +unsafe impl Sync for Inner {} + pub struct Instance { srgb_capable: bool, inner: Arc>, @@ -419,7 +422,9 @@ fn create_instance_device() -> Result { Ok(InstanceDevice { dc, _tx: drop_tx }) } -impl crate::Instance for Instance { +impl crate::Instance for Instance { + type A = super::Api; + unsafe fn init(desc: &crate::InstanceDescriptor) -> Result { profiling::scope!("Init OpenGL (WGL) Backend"); let opengl_module = unsafe { LoadLibraryA("opengl32.dll\0".as_ptr() as *const _) }; @@ -673,7 +678,9 @@ impl Surface { } } -impl crate::Surface for Surface { +impl crate::Surface for Surface { + type A = super::Api; + unsafe fn configure( &self, device: &super::Device, diff --git a/wgpu-hal/src/lib.rs b/wgpu-hal/src/lib.rs index 75e8a827b5..79bd54e66e 100644 --- a/wgpu-hal/src/lib.rs +++ b/wgpu-hal/src/lib.rs @@ -16,6 +16,8 @@ #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] #![allow( + // this happens on the GL backend, where it is both thread safe and non-thread safe in the same code. + clippy::arc_with_non_send_sync, // for `if_then_panic` until it reaches stable unknown_lints, // We use loops for getting early-out of scope without closures. @@ -189,13 +191,13 @@ impl InstanceError { } pub trait Api: Clone + fmt::Debug + Sized { - type Instance: Instance; - type Surface: Surface; - type Adapter: Adapter; - type Device: Device; + type Instance: Instance; + type Surface: Surface; + type Adapter: Adapter; + type Device: Device; - type Queue: Queue; - type CommandEncoder: CommandEncoder; + type Queue: Queue; + type CommandEncoder: CommandEncoder; type CommandBuffer: WasmNotSendSync + fmt::Debug; type Buffer: fmt::Debug + WasmNotSendSync + 'static; @@ -216,18 +218,22 @@ pub trait Api: Clone + fmt::Debug + Sized { type AccelerationStructure: fmt::Debug + WasmNotSendSync + 'static; } -pub trait Instance: Sized + WasmNotSendSync { +pub trait Instance: Sized + WasmNotSendSync { + type A: Api; + unsafe fn init(desc: &InstanceDescriptor) -> Result; unsafe fn create_surface( &self, display_handle: raw_window_handle::RawDisplayHandle, window_handle: raw_window_handle::RawWindowHandle, - ) -> Result; - unsafe fn destroy_surface(&self, surface: A::Surface); - unsafe fn enumerate_adapters(&self) -> Vec>; + ) -> Result<::Surface, InstanceError>; + unsafe fn destroy_surface(&self, surface: ::Surface); + unsafe fn enumerate_adapters(&self) -> Vec>; } -pub trait Surface: WasmNotSendSync { +pub trait Surface: WasmNotSendSync { + type A: Api; + /// Configures the surface to use the given device. /// /// # Safety @@ -238,7 +244,7 @@ pub trait Surface: WasmNotSendSync { /// - All surfaces created using other devices must have been unconfigured before this call. unsafe fn configure( &self, - device: &A::Device, + device: &::Device, config: &SurfaceConfiguration, ) -> Result<(), SurfaceError>; @@ -250,7 +256,7 @@ pub trait Surface: WasmNotSendSync { /// - All [`AcquiredSurfaceTexture`]s must have been destroyed. /// - All [`Api::TextureView`]s derived from the [`AcquiredSurfaceTexture`]s must have been destroyed. /// - The surface must have been configured on the given device. - unsafe fn unconfigure(&self, device: &A::Device); + unsafe fn unconfigure(&self, device: &::Device); /// Returns the next texture to be presented by the swapchain for drawing /// @@ -265,16 +271,18 @@ pub trait Surface: WasmNotSendSync { unsafe fn acquire_texture( &self, timeout: Option, - ) -> Result>, SurfaceError>; - unsafe fn discard_texture(&self, texture: A::SurfaceTexture); + ) -> Result>, SurfaceError>; + unsafe fn discard_texture(&self, texture: ::SurfaceTexture); } -pub trait Adapter: WasmNotSendSync { +pub trait Adapter: WasmNotSendSync { + type A: Api; + unsafe fn open( &self, features: wgt::Features, limits: &wgt::Limits, - ) -> Result, DeviceError>; + ) -> Result, DeviceError>; /// Return the set of supported capabilities for a texture format. unsafe fn texture_format_capabilities( @@ -285,7 +293,10 @@ pub trait Adapter: WasmNotSendSync { /// Returns the capabilities of working with a specified surface. /// /// `None` means presentation is not supported for it. - unsafe fn surface_capabilities(&self, surface: &A::Surface) -> Option; + unsafe fn surface_capabilities( + &self, + surface: &::Surface, + ) -> Option; /// Creates a [`PresentationTimestamp`] using the adapter's WSI. /// @@ -293,97 +304,111 @@ pub trait Adapter: WasmNotSendSync { unsafe fn get_presentation_timestamp(&self) -> wgt::PresentationTimestamp; } -pub trait Device: WasmNotSendSync { +pub trait Device: WasmNotSendSync { + type A: Api; + /// Exit connection to this logical device. - unsafe fn exit(self, queue: A::Queue); + unsafe fn exit(self, queue: ::Queue); /// Creates a new buffer. /// /// The initial usage is `BufferUses::empty()`. - unsafe fn create_buffer(&self, desc: &BufferDescriptor) -> Result; - unsafe fn destroy_buffer(&self, buffer: A::Buffer); + unsafe fn create_buffer( + &self, + desc: &BufferDescriptor, + ) -> Result<::Buffer, DeviceError>; + unsafe fn destroy_buffer(&self, buffer: ::Buffer); //TODO: clarify if zero-sized mapping is allowed unsafe fn map_buffer( &self, - buffer: &A::Buffer, + buffer: &::Buffer, range: MemoryRange, ) -> Result; - unsafe fn unmap_buffer(&self, buffer: &A::Buffer) -> Result<(), DeviceError>; - unsafe fn flush_mapped_ranges(&self, buffer: &A::Buffer, ranges: I) + unsafe fn unmap_buffer(&self, buffer: &::Buffer) -> Result<(), DeviceError>; + unsafe fn flush_mapped_ranges(&self, buffer: &::Buffer, ranges: I) where I: Iterator; - unsafe fn invalidate_mapped_ranges(&self, buffer: &A::Buffer, ranges: I) + unsafe fn invalidate_mapped_ranges(&self, buffer: &::Buffer, ranges: I) where I: Iterator; /// Creates a new texture. /// /// The initial usage for all subresources is `TextureUses::UNINITIALIZED`. - unsafe fn create_texture(&self, desc: &TextureDescriptor) -> Result; - unsafe fn destroy_texture(&self, texture: A::Texture); + unsafe fn create_texture( + &self, + desc: &TextureDescriptor, + ) -> Result<::Texture, DeviceError>; + unsafe fn destroy_texture(&self, texture: ::Texture); unsafe fn create_texture_view( &self, - texture: &A::Texture, + texture: &::Texture, desc: &TextureViewDescriptor, - ) -> Result; - unsafe fn destroy_texture_view(&self, view: A::TextureView); - unsafe fn create_sampler(&self, desc: &SamplerDescriptor) -> Result; - unsafe fn destroy_sampler(&self, sampler: A::Sampler); + ) -> Result<::TextureView, DeviceError>; + unsafe fn destroy_texture_view(&self, view: ::TextureView); + unsafe fn create_sampler( + &self, + desc: &SamplerDescriptor, + ) -> Result<::Sampler, DeviceError>; + unsafe fn destroy_sampler(&self, sampler: ::Sampler); /// Create a fresh [`CommandEncoder`]. /// /// The new `CommandEncoder` is in the "closed" state. unsafe fn create_command_encoder( &self, - desc: &CommandEncoderDescriptor, - ) -> Result; - unsafe fn destroy_command_encoder(&self, pool: A::CommandEncoder); + desc: &CommandEncoderDescriptor, + ) -> Result<::CommandEncoder, DeviceError>; + unsafe fn destroy_command_encoder(&self, pool: ::CommandEncoder); /// Creates a bind group layout. unsafe fn create_bind_group_layout( &self, desc: &BindGroupLayoutDescriptor, - ) -> Result; - unsafe fn destroy_bind_group_layout(&self, bg_layout: A::BindGroupLayout); + ) -> Result<::BindGroupLayout, DeviceError>; + unsafe fn destroy_bind_group_layout(&self, bg_layout: ::BindGroupLayout); unsafe fn create_pipeline_layout( &self, - desc: &PipelineLayoutDescriptor, - ) -> Result; - unsafe fn destroy_pipeline_layout(&self, pipeline_layout: A::PipelineLayout); + desc: &PipelineLayoutDescriptor, + ) -> Result<::PipelineLayout, DeviceError>; + unsafe fn destroy_pipeline_layout(&self, pipeline_layout: ::PipelineLayout); unsafe fn create_bind_group( &self, - desc: &BindGroupDescriptor, - ) -> Result; - unsafe fn destroy_bind_group(&self, group: A::BindGroup); + desc: &BindGroupDescriptor, + ) -> Result<::BindGroup, DeviceError>; + unsafe fn destroy_bind_group(&self, group: ::BindGroup); unsafe fn create_shader_module( &self, desc: &ShaderModuleDescriptor, shader: ShaderInput, - ) -> Result; - unsafe fn destroy_shader_module(&self, module: A::ShaderModule); + ) -> Result<::ShaderModule, ShaderError>; + unsafe fn destroy_shader_module(&self, module: ::ShaderModule); unsafe fn create_render_pipeline( &self, - desc: &RenderPipelineDescriptor, - ) -> Result; - unsafe fn destroy_render_pipeline(&self, pipeline: A::RenderPipeline); + desc: &RenderPipelineDescriptor, + ) -> Result<::RenderPipeline, PipelineError>; + unsafe fn destroy_render_pipeline(&self, pipeline: ::RenderPipeline); unsafe fn create_compute_pipeline( &self, - desc: &ComputePipelineDescriptor, - ) -> Result; - unsafe fn destroy_compute_pipeline(&self, pipeline: A::ComputePipeline); + desc: &ComputePipelineDescriptor, + ) -> Result<::ComputePipeline, PipelineError>; + unsafe fn destroy_compute_pipeline(&self, pipeline: ::ComputePipeline); unsafe fn create_query_set( &self, desc: &wgt::QuerySetDescriptor, + desc: &GetAccelerationStructureBuildSizesDescriptor, ) -> AccelerationStructureBuildSizes; unsafe fn get_acceleration_structure_device_address( &self, - acceleration_structure: &A::AccelerationStructure, + acceleration_structure: &::AccelerationStructure, ) -> wgt::BufferAddress; unsafe fn destroy_acceleration_structure( &self, - acceleration_structure: A::AccelerationStructure, + acceleration_structure: ::AccelerationStructure, ); } -pub trait Queue: WasmNotSendSync { +pub trait Queue: WasmNotSendSync { + type A: Api; + /// Submits the command buffers for execution on GPU. /// /// Valid usage: @@ -420,14 +447,14 @@ pub trait Queue: WasmNotSendSync { /// passed to the surface_textures argument. unsafe fn submit( &self, - command_buffers: &[&A::CommandBuffer], - surface_textures: &[&A::SurfaceTexture], - signal_fence: Option<(&mut A::Fence, FenceValue)>, + command_buffers: &[&::CommandBuffer], + surface_textures: &[&::SurfaceTexture], + signal_fence: Option<(&mut ::Fence, FenceValue)>, ) -> Result<(), DeviceError>; unsafe fn present( &self, - surface: &A::Surface, - texture: A::SurfaceTexture, + surface: &::Surface, + texture: ::SurfaceTexture, ) -> Result<(), SurfaceError>; unsafe fn get_timestamp_period(&self) -> f32; } @@ -470,7 +497,9 @@ pub trait Queue: WasmNotSendSync { /// built it. /// /// - A `CommandEncoder` must not outlive its `Device`. -pub trait CommandEncoder: WasmNotSendSync + fmt::Debug { +pub trait CommandEncoder: WasmNotSendSync + fmt::Debug { + type A: Api; + /// Begin encoding a new command buffer. /// /// This puts this `CommandEncoder` in the "recording" state. @@ -508,7 +537,7 @@ pub trait CommandEncoder: WasmNotSendSync + fmt::Debug { /// /// [`CommandBuffer`]: Api::CommandBuffer /// [`begin_encoding`]: CommandEncoder::begin_encoding - unsafe fn end_encoding(&mut self) -> Result; + unsafe fn end_encoding(&mut self) -> Result<::CommandBuffer, DeviceError>; /// Reclaim all resources belonging to this `CommandEncoder`. /// @@ -523,22 +552,26 @@ pub trait CommandEncoder: WasmNotSendSync + fmt::Debug { /// [`CommandBuffer`]: Api::CommandBuffer unsafe fn reset_all(&mut self, command_buffers: I) where - I: Iterator; + I: Iterator::CommandBuffer>; unsafe fn transition_buffers<'a, T>(&mut self, barriers: T) where - T: Iterator>; + T: Iterator>; unsafe fn transition_textures<'a, T>(&mut self, barriers: T) where - T: Iterator>; + T: Iterator>; // copy operations - unsafe fn clear_buffer(&mut self, buffer: &A::Buffer, range: MemoryRange); + unsafe fn clear_buffer(&mut self, buffer: &::Buffer, range: MemoryRange); - unsafe fn copy_buffer_to_buffer(&mut self, src: &A::Buffer, dst: &A::Buffer, regions: T) - where + unsafe fn copy_buffer_to_buffer( + &mut self, + src: &::Buffer, + dst: &::Buffer, + regions: T, + ) where T: Iterator; /// Copy from an external image to an internal texture. @@ -549,7 +582,7 @@ pub trait CommandEncoder: WasmNotSendSync + fmt::Debug { unsafe fn copy_external_image_to_texture( &mut self, src: &wgt::ImageCopyExternalImage, - dst: &A::Texture, + dst: &::Texture, dst_premultiplication: bool, regions: T, ) where @@ -561,9 +594,9 @@ pub trait CommandEncoder: WasmNotSendSync + fmt::Debug { /// Note: the copy extent is in physical size (rounded to the block size) unsafe fn copy_texture_to_texture( &mut self, - src: &A::Texture, + src: &::Texture, src_usage: TextureUses, - dst: &A::Texture, + dst: &::Texture, regions: T, ) where T: Iterator; @@ -572,8 +605,12 @@ pub trait CommandEncoder: WasmNotSendSync + fmt::Debug { /// Works with a single array layer. /// Note: `dst` current usage has to be `TextureUses::COPY_DST`. /// Note: the copy extent is in physical size (rounded to the block size) - unsafe fn copy_buffer_to_texture(&mut self, src: &A::Buffer, dst: &A::Texture, regions: T) - where + unsafe fn copy_buffer_to_texture( + &mut self, + src: &::Buffer, + dst: &::Texture, + regions: T, + ) where T: Iterator; /// Copy from texture to buffer. @@ -581,9 +618,9 @@ pub trait CommandEncoder: WasmNotSendSync + fmt::Debug { /// Note: the copy extent is in physical size (rounded to the block size) unsafe fn copy_texture_to_buffer( &mut self, - src: &A::Texture, + src: &::Texture, src_usage: TextureUses, - dst: &A::Buffer, + dst: &::Buffer, regions: T, ) where T: Iterator; @@ -594,9 +631,9 @@ pub trait CommandEncoder: WasmNotSendSync + fmt::Debug { /// of all the preceding groups to be taken from `layout`. unsafe fn set_bind_group( &mut self, - layout: &A::PipelineLayout, + layout: &::PipelineLayout, index: u32, - group: &A::BindGroup, + group: &::BindGroup, dynamic_offsets: &[wgt::DynamicOffset], ); @@ -610,7 +647,7 @@ pub trait CommandEncoder: WasmNotSendSync + fmt::Debug { /// - The range of push constants written must be valid for the pipeline layout at draw time. unsafe fn set_push_constants( &mut self, - layout: &A::PipelineLayout, + layout: &::PipelineLayout, stages: wgt::ShaderStages, offset_bytes: u32, data: &[u32], @@ -625,18 +662,18 @@ pub trait CommandEncoder: WasmNotSendSync + fmt::Debug { /// # Safety: /// /// - If `set` is an occlusion query set, it must be the same one as used in the [`RenderPassDescriptor::occlusion_query_set`] parameter. - unsafe fn begin_query(&mut self, set: &A::QuerySet, index: u32); + unsafe fn begin_query(&mut self, set: &::QuerySet, index: u32); /// # Safety: /// /// - If `set` is an occlusion query set, it must be the same one as used in the [`RenderPassDescriptor::occlusion_query_set`] parameter. - unsafe fn end_query(&mut self, set: &A::QuerySet, index: u32); - unsafe fn write_timestamp(&mut self, set: &A::QuerySet, index: u32); - unsafe fn reset_queries(&mut self, set: &A::QuerySet, range: Range); + unsafe fn end_query(&mut self, set: &::QuerySet, index: u32); + unsafe fn write_timestamp(&mut self, set: &::QuerySet, index: u32); + unsafe fn reset_queries(&mut self, set: &::QuerySet, range: Range); unsafe fn copy_query_results( &mut self, - set: &A::QuerySet, + set: &::QuerySet, range: Range, - buffer: &A::Buffer, + buffer: &::Buffer, offset: wgt::BufferAddress, stride: wgt::BufferSize, ); @@ -644,17 +681,17 @@ pub trait CommandEncoder: WasmNotSendSync + fmt::Debug { // render passes // Begins a render pass, clears all active bindings. - unsafe fn begin_render_pass(&mut self, desc: &RenderPassDescriptor); + unsafe fn begin_render_pass(&mut self, desc: &RenderPassDescriptor); unsafe fn end_render_pass(&mut self); - unsafe fn set_render_pipeline(&mut self, pipeline: &A::RenderPipeline); + unsafe fn set_render_pipeline(&mut self, pipeline: &::RenderPipeline); unsafe fn set_index_buffer<'a>( &mut self, - binding: BufferBinding<'a, A>, + binding: BufferBinding<'a, Self::A>, format: wgt::IndexFormat, ); - unsafe fn set_vertex_buffer<'a>(&mut self, index: u32, binding: BufferBinding<'a, A>); + unsafe fn set_vertex_buffer<'a>(&mut self, index: u32, binding: BufferBinding<'a, Self::A>); unsafe fn set_viewport(&mut self, rect: &Rect, depth_range: Range); unsafe fn set_scissor_rect(&mut self, rect: &Rect); unsafe fn set_stencil_reference(&mut self, value: u32); @@ -677,29 +714,29 @@ pub trait CommandEncoder: WasmNotSendSync + fmt::Debug { ); unsafe fn draw_indirect( &mut self, - buffer: &A::Buffer, + buffer: &::Buffer, offset: wgt::BufferAddress, draw_count: u32, ); unsafe fn draw_indexed_indirect( &mut self, - buffer: &A::Buffer, + buffer: &::Buffer, offset: wgt::BufferAddress, draw_count: u32, ); unsafe fn draw_indirect_count( &mut self, - buffer: &A::Buffer, + buffer: &::Buffer, offset: wgt::BufferAddress, - count_buffer: &A::Buffer, + count_buffer: &::Buffer, count_offset: wgt::BufferAddress, max_count: u32, ); unsafe fn draw_indexed_indirect_count( &mut self, - buffer: &A::Buffer, + buffer: &::Buffer, offset: wgt::BufferAddress, - count_buffer: &A::Buffer, + count_buffer: &::Buffer, count_offset: wgt::BufferAddress, max_count: u32, ); @@ -707,13 +744,17 @@ pub trait CommandEncoder: WasmNotSendSync + fmt::Debug { // compute passes // Begins a compute pass, clears all active bindings. - unsafe fn begin_compute_pass(&mut self, desc: &ComputePassDescriptor); + unsafe fn begin_compute_pass(&mut self, desc: &ComputePassDescriptor); unsafe fn end_compute_pass(&mut self); - unsafe fn set_compute_pipeline(&mut self, pipeline: &A::ComputePipeline); + unsafe fn set_compute_pipeline(&mut self, pipeline: &::ComputePipeline); unsafe fn dispatch(&mut self, count: [u32; 3]); - unsafe fn dispatch_indirect(&mut self, buffer: &A::Buffer, offset: wgt::BufferAddress); + unsafe fn dispatch_indirect( + &mut self, + buffer: &::Buffer, + offset: wgt::BufferAddress, + ); /// To get the required sizes for the buffer allocations use `get_acceleration_structure_build_sizes` per descriptor /// All buffers must be synchronized externally @@ -727,8 +768,8 @@ pub trait CommandEncoder: WasmNotSendSync + fmt::Debug { descriptor_count: u32, descriptors: T, ) where - A: 'a, - T: IntoIterator>; + Self::A: 'a, + T: IntoIterator>; unsafe fn place_acceleration_structure_barrier( &mut self, diff --git a/wgpu-hal/src/metal/adapter.rs b/wgpu-hal/src/metal/adapter.rs index f3b27de716..6211896838 100644 --- a/wgpu-hal/src/metal/adapter.rs +++ b/wgpu-hal/src/metal/adapter.rs @@ -18,7 +18,9 @@ impl super::Adapter { } } -impl crate::Adapter for super::Adapter { +impl crate::Adapter for super::Adapter { + type A = super::Api; + unsafe fn open( &self, features: wgt::Features, @@ -839,7 +841,7 @@ impl super::PrivateCapabilities { self.indirect_draw_dispatch, ); features.set( - F::TIMESTAMP_QUERY, + F::TIMESTAMP_QUERY | F::TIMESTAMP_QUERY_INSIDE_ENCODERS, self.timestamp_query_support .contains(TimestampQuerySupport::STAGE_BOUNDARIES), ); @@ -878,6 +880,10 @@ impl super::PrivateCapabilities { { features.insert(F::STORAGE_RESOURCE_BINDING_ARRAY); } + features.set( + F::SHADER_INT64, + self.msl_version >= MTLLanguageVersion::V2_3, + ); features.set( F::ADDRESS_MODE_CLAMP_TO_BORDER, diff --git a/wgpu-hal/src/metal/command.rs b/wgpu-hal/src/metal/command.rs index 6f1a0d9c2f..341712c323 100644 --- a/wgpu-hal/src/metal/command.rs +++ b/wgpu-hal/src/metal/command.rs @@ -168,7 +168,9 @@ impl super::CommandState { } } -impl crate::CommandEncoder for super::CommandEncoder { +impl crate::CommandEncoder for super::CommandEncoder { + type A = super::Api; + unsafe fn begin_encoding(&mut self, label: crate::Label) -> Result<(), crate::DeviceError> { let queue = &self.raw_queue.lock(); let retain_references = self.shared.settings.retain_command_buffer_references; diff --git a/wgpu-hal/src/metal/conv.rs b/wgpu-hal/src/metal/conv.rs index 8f6439b50b..6ebabee1a6 100644 --- a/wgpu-hal/src/metal/conv.rs +++ b/wgpu-hal/src/metal/conv.rs @@ -222,6 +222,7 @@ pub fn map_vertex_format(format: wgt::VertexFormat) -> metal::MTLVertexFormat { Vf::Uint32x4 => UInt4, Vf::Sint32x4 => Int4, Vf::Float32x4 => Float4, + Vf::Unorm10_10_10_2 => UInt1010102Normalized, Vf::Float64 | Vf::Float64x2 | Vf::Float64x3 | Vf::Float64x4 => unimplemented!(), } } diff --git a/wgpu-hal/src/metal/device.rs b/wgpu-hal/src/metal/device.rs index d7fd06c8f3..179429f5d7 100644 --- a/wgpu-hal/src/metal/device.rs +++ b/wgpu-hal/src/metal/device.rs @@ -273,7 +273,9 @@ impl super::Device { } } -impl crate::Device for super::Device { +impl crate::Device for super::Device { + type A = super::Api; + unsafe fn exit(self, _queue: super::Queue) {} unsafe fn create_buffer(&self, desc: &crate::BufferDescriptor) -> DeviceResult { @@ -706,7 +708,16 @@ impl crate::Device for super::Device { for (&stage, counter) in super::NAGA_STAGES.iter().zip(bg.counters.iter_mut()) { let stage_bit = map_naga_stage(stage); let mut dynamic_offsets_count = 0u32; - for (entry, layout) in desc.entries.iter().zip(desc.layout.entries.iter()) { + let layout_and_entry_iter = desc.entries.iter().map(|entry| { + let layout = desc + .layout + .entries + .iter() + .find(|layout_entry| layout_entry.binding == entry.binding) + .expect("internal error: no layout entry found with binding slot"); + (entry, layout) + }); + for (entry, layout) in layout_and_entry_iter { let size = layout.count.map_or(1, |c| c.get()); if let wgt::BindingType::Buffer { has_dynamic_offset: true, diff --git a/wgpu-hal/src/metal/mod.rs b/wgpu-hal/src/metal/mod.rs index 62fbf3d49d..6aeafb0f86 100644 --- a/wgpu-hal/src/metal/mod.rs +++ b/wgpu-hal/src/metal/mod.rs @@ -80,7 +80,9 @@ impl Instance { } } -impl crate::Instance for Instance { +impl crate::Instance for Instance { + type A = Api; + unsafe fn init(_desc: &crate::InstanceDescriptor) -> Result { profiling::scope!("Init Metal Backend"); // We do not enable metal validation based on the validation flags as it affects the entire @@ -365,7 +367,9 @@ impl std::borrow::Borrow for SurfaceTexture { unsafe impl Send for SurfaceTexture {} unsafe impl Sync for SurfaceTexture {} -impl crate::Queue for Queue { +impl crate::Queue for Queue { + type A = Api; + unsafe fn submit( &self, command_buffers: &[&CommandBuffer], diff --git a/wgpu-hal/src/metal/surface.rs b/wgpu-hal/src/metal/surface.rs index a97eff0aae..889e319493 100644 --- a/wgpu-hal/src/metal/surface.rs +++ b/wgpu-hal/src/metal/surface.rs @@ -169,7 +169,9 @@ impl super::Surface { } } -impl crate::Surface for super::Surface { +impl crate::Surface for super::Surface { + type A = super::Api; + unsafe fn configure( &self, device: &super::Device, diff --git a/wgpu-hal/src/vulkan/adapter.rs b/wgpu-hal/src/vulkan/adapter.rs index 2693e74020..2665463792 100644 --- a/wgpu-hal/src/vulkan/adapter.rs +++ b/wgpu-hal/src/vulkan/adapter.rs @@ -20,25 +20,85 @@ fn indexing_features() -> wgt::Features { | wgt::Features::PARTIALLY_BOUND_BINDING_ARRAY } -/// Aggregate of the `vk::PhysicalDevice*Features` structs used by `gfx`. +/// Features supported by a [`vk::PhysicalDevice`] and its extensions. +/// +/// This is used in two phases: +/// +/// - When enumerating adapters, this represents the features offered by the +/// adapter. [`Instance::expose_adapter`] calls `vkGetPhysicalDeviceFeatures2` +/// (or `vkGetPhysicalDeviceFeatures` if that is not available) to collect +/// this information about the `VkPhysicalDevice` represented by the +/// `wgpu_hal::ExposedAdapter`. +/// +/// - When opening a device, this represents the features we would like to +/// enable. At `wgpu_hal::Device` construction time, +/// [`PhysicalDeviceFeatures::from_extensions_and_requested_features`] +/// constructs an value of this type indicating which Vulkan features to +/// enable, based on the `wgpu_types::Features` requested. #[derive(Debug, Default)] pub struct PhysicalDeviceFeatures { + /// Basic Vulkan 1.0 features. core: vk::PhysicalDeviceFeatures, + + /// Features provided by `VK_EXT_descriptor_indexing`, promoted to Vulkan 1.2. pub(super) descriptor_indexing: Option, + + /// Features provided by `VK_KHR_imageless_framebuffer`, promoted to Vulkan 1.2. imageless_framebuffer: Option, + + /// Features provided by `VK_KHR_timeline_semaphore`, promoted to Vulkan 1.2 timeline_semaphore: Option, + + /// Features provided by `VK_EXT_image_robustness`, promoted to Vulkan 1.3 image_robustness: Option, + + /// Features provided by `VK_EXT_robustness2`. robustness2: Option, + + /// Features provided by `VK_KHR_multiview`, promoted to Vulkan 1.1. multiview: Option, + + /// Features provided by `VK_KHR_sampler_ycbcr_conversion`, promoted to Vulkan 1.1. sampler_ycbcr_conversion: Option, + + /// Features provided by `VK_EXT_texture_compression_astc_hdr`, promoted to Vulkan 1.3. astc_hdr: Option, + + /// Features provided by `VK_KHR_shader_float16_int8` (promoted to Vulkan + /// 1.2) and `VK_KHR_16bit_storage` (promoted to Vulkan 1.1). We use these + /// features together, or not at all. shader_float16: Option<( vk::PhysicalDeviceShaderFloat16Int8Features, vk::PhysicalDevice16BitStorageFeatures, )>, + + /// Features provided by `VK_KHR_acceleration_structure`. acceleration_structure: Option, + + /// Features provided by `VK_KHR_buffer_device_address`, promoted to Vulkan 1.2. + /// + /// We only use this feature for + /// [`Features::RAY_TRACING_ACCELERATION_STRUCTURE`], which requires + /// `VK_KHR_acceleration_structure`, which depends on + /// `VK_KHR_buffer_device_address`, so [`Instance::expose_adapter`] only + /// bothers to check if `VK_KHR_acceleration_structure` is available, + /// leaving this `None`. + /// + /// However, we do populate this when creating a device if + /// [`Features::RAY_TRACING_ACCELERATION_STRUCTURE`] is requested. buffer_device_address: Option, + + /// Features provided by `VK_KHR_ray_query`, + /// + /// Vulkan requires that the feature be present if the `VK_KHR_ray_query` + /// extension is present, so [`Instance::expose_adapter`] doesn't bother retrieving + /// this from `vkGetPhysicalDeviceFeatures2`. + /// + /// However, we do populate this when creating a device if ray tracing is requested. ray_query: Option, + + /// Features provided by `VK_KHR_zero_initialize_workgroup_memory`, promoted + /// to Vulkan 1.3. zero_initialize_workgroup_memory: Option, } @@ -91,9 +151,32 @@ impl PhysicalDeviceFeatures { info } - /// Create a `PhysicalDeviceFeatures` that will be used to create a logical device. + /// Create a `PhysicalDeviceFeatures` that can be used to create a logical + /// device. + /// + /// Return a `PhysicalDeviceFeatures` value capturing all the Vulkan + /// features needed for the given [`Features`], [`DownlevelFlags`], and + /// [`PrivateCapabilities`]. You can use the returned value's + /// [`add_to_device_create_builder`] method to configure a + /// [`DeviceCreateInfoBuilder`] to build a logical device providing those + /// features. /// - /// `requested_features` should be the same as what was used to generate `enabled_extensions`. + /// To ensure that the returned value is able to select all the Vulkan + /// features needed to express `requested_features`, `downlevel_flags`, and + /// `private_caps`: + /// + /// - The given `enabled_extensions` set must include all the extensions + /// selected by [`Adapter::required_device_extensions`] when passed + /// `features`. + /// + /// - The given `device_api_version` must be the Vulkan API version of the + /// physical device we will use to create the logical device. + /// + /// [`Features`]: wgt::Features + /// [`DownlevelFlags`]: wgt::DownlevelFlags + /// [`PrivateCapabilities`]: super::PrivateCapabilities + /// [`DeviceCreateInfoBuilder`]: vk::DeviceCreateInfoBuilder + /// [`Adapter::required_device_extensions`]: super::Adapter::required_device_extensions fn from_extensions_and_requested_features( device_api_version: u32, enabled_extensions: &[&'static CStr], @@ -189,7 +272,7 @@ impl PhysicalDeviceFeatures { //.shader_clip_distance(requested_features.contains(wgt::Features::SHADER_CLIP_DISTANCE)) //.shader_cull_distance(requested_features.contains(wgt::Features::SHADER_CULL_DISTANCE)) .shader_float64(requested_features.contains(wgt::Features::SHADER_F64)) - //.shader_int64(requested_features.contains(wgt::Features::SHADER_INT64)) + .shader_int64(requested_features.contains(wgt::Features::SHADER_INT64)) .shader_int16(requested_features.contains(wgt::Features::SHADER_I16)) //.shader_resource_residency(requested_features.contains(wgt::Features::SHADER_RESOURCE_RESIDENCY)) .geometry_shader(requested_features.contains(wgt::Features::SHADER_PRIMITIVE_INDEX)) @@ -354,11 +437,16 @@ impl PhysicalDeviceFeatures { } } + /// Compute the wgpu [`Features`] and [`DownlevelFlags`] supported by a physical device. + /// + /// Given `self`, together with the instance and physical device it was + /// built from, and a `caps` also built from those, determine which wgpu + /// features and downlevel flags the device can support. fn to_wgpu( &self, instance: &ash::Instance, phd: vk::PhysicalDevice, - caps: &PhysicalDeviceCapabilities, + caps: &PhysicalDeviceProperties, ) -> (wgt::Features, wgt::DownlevelFlags) { use crate::auxil::db; use wgt::{DownlevelFlags as Df, Features as F}; @@ -369,6 +457,7 @@ impl PhysicalDeviceFeatures { | F::ADDRESS_MODE_CLAMP_TO_BORDER | F::ADDRESS_MODE_CLAMP_TO_ZERO | F::TIMESTAMP_QUERY + | F::TIMESTAMP_QUERY_INSIDE_ENCODERS | F::TIMESTAMP_QUERY_INSIDE_PASSES | F::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES | F::CLEAR_TEXTURE; @@ -468,7 +557,7 @@ impl PhysicalDeviceFeatures { //if self.core.shader_clip_distance != 0 { //if self.core.shader_cull_distance != 0 { features.set(F::SHADER_F64, self.core.shader_float64 != 0); - //if self.core.shader_int64 != 0 { + features.set(F::SHADER_INT64, self.core.shader_int64 != 0); features.set(F::SHADER_I16, self.core.shader_int16 != 0); //if caps.supports_extension(vk::KhrSamplerMirrorClampToEdgeFn::name()) { @@ -638,15 +727,52 @@ impl PhysicalDeviceFeatures { } } -/// Information gathered about a physical device capabilities. +/// Vulkan "properties" structures gathered about a physical device. +/// +/// This structure holds the properties of a [`vk::PhysicalDevice`]: +/// - the standard Vulkan device properties +/// - the `VkExtensionProperties` structs for all available extensions, and +/// - the per-extension properties structures for the available extensions that +/// `wgpu` cares about. +/// +/// Generally, if you get it from any of these functions, it's stored +/// here: +/// - `vkEnumerateDeviceExtensionProperties` +/// - `vkGetPhysicalDeviceProperties` +/// - `vkGetPhysicalDeviceProperties2` +/// +/// This also includes a copy of the device API version, since we can +/// use that as a shortcut for searching for an extension, if the +/// extension has been promoted to core in the current version. +/// +/// This does not include device features; for those, see +/// [`PhysicalDeviceFeatures`]. #[derive(Default, Debug)] -pub struct PhysicalDeviceCapabilities { +pub struct PhysicalDeviceProperties { + /// Extensions supported by the `vk::PhysicalDevice`, + /// as returned by `vkEnumerateDeviceExtensionProperties`. supported_extensions: Vec, + + /// Properties of the `vk::PhysicalDevice`, as returned by + /// `vkGetPhysicalDeviceProperties`. properties: vk::PhysicalDeviceProperties, + + /// Additional `vk::PhysicalDevice` properties from the + /// `VK_KHR_maintenance3` extension, promoted to Vulkan 1.1. maintenance_3: Option, + + /// Additional `vk::PhysicalDevice` properties from the + /// `VK_EXT_descriptor_indexing` extension, promoted to Vulkan 1.2. descriptor_indexing: Option, + + /// Additional `vk::PhysicalDevice` properties from the + /// `VK_KHR_acceleration_structure` extension. acceleration_structure: Option, + + /// Additional `vk::PhysicalDevice` properties from the + /// `VK_KHR_driver_properties` extension, promoted to Vulkan 1.2. driver: Option, + /// The device API version. /// /// Which is the version of Vulkan supported for device-level functionality. @@ -656,10 +782,10 @@ pub struct PhysicalDeviceCapabilities { } // This is safe because the structs have `p_next: *mut c_void`, which we null out/never read. -unsafe impl Send for PhysicalDeviceCapabilities {} -unsafe impl Sync for PhysicalDeviceCapabilities {} +unsafe impl Send for PhysicalDeviceProperties {} +unsafe impl Sync for PhysicalDeviceProperties {} -impl PhysicalDeviceCapabilities { +impl PhysicalDeviceProperties { pub fn properties(&self) -> vk::PhysicalDeviceProperties { self.properties } @@ -898,9 +1024,9 @@ impl super::InstanceShared { fn inspect( &self, phd: vk::PhysicalDevice, - ) -> (PhysicalDeviceCapabilities, PhysicalDeviceFeatures) { + ) -> (PhysicalDeviceProperties, PhysicalDeviceFeatures) { let capabilities = { - let mut capabilities = PhysicalDeviceCapabilities::default(); + let mut capabilities = PhysicalDeviceProperties::default(); capabilities.supported_extensions = unsafe { self.raw.enumerate_device_extension_properties(phd).unwrap() }; capabilities.properties = unsafe { self.raw.get_physical_device_properties(phd) }; @@ -922,9 +1048,10 @@ impl super::InstanceShared { let mut builder = vk::PhysicalDeviceProperties2KHR::builder(); if supports_maintenance3 { - capabilities.maintenance_3 = - Some(vk::PhysicalDeviceMaintenance3Properties::default()); - builder = builder.push_next(capabilities.maintenance_3.as_mut().unwrap()); + let next = capabilities + .maintenance_3 + .insert(vk::PhysicalDeviceMaintenance3Properties::default()); + builder = builder.push_next(next); } if supports_descriptor_indexing { @@ -1000,7 +1127,8 @@ impl super::InstanceShared { builder = builder.push_next(next); } - // `VK_KHR_imageless_framebuffer` is promoted to 1.2, but has no changes, so we can keep using the extension unconditionally. + // `VK_KHR_imageless_framebuffer` is promoted to 1.2, but has no + // changes, so we can keep using the extension unconditionally. if capabilities.supports_extension(vk::KhrImagelessFramebufferFn::name()) { let next = features .imageless_framebuffer @@ -1008,7 +1136,8 @@ impl super::InstanceShared { builder = builder.push_next(next); } - // `VK_KHR_timeline_semaphore` is promoted to 1.2, but has no changes, so we can keep using the extension unconditionally. + // `VK_KHR_timeline_semaphore` is promoted to 1.2, but has no + // changes, so we can keep using the extension unconditionally. if capabilities.supports_extension(vk::KhrTimelineSemaphoreFn::name()) { let next = features .timeline_semaphore @@ -1294,7 +1423,7 @@ impl super::Adapter { self.raw } - pub fn physical_device_capabilities(&self) -> &PhysicalDeviceCapabilities { + pub fn physical_device_capabilities(&self) -> &PhysicalDeviceProperties { &self.phd_capabilities } @@ -1319,7 +1448,20 @@ impl super::Adapter { supported_extensions } - /// `features` must be the same features used to create `enabled_extensions`. + /// Create a `PhysicalDeviceFeatures` for opening a logical device with + /// `features` from this adapter. + /// + /// The given `enabled_extensions` set must include all the extensions + /// selected by [`required_device_extensions`] when passed `features`. + /// Otherwise, the `PhysicalDeviceFeatures` value may not be able to select + /// all the Vulkan features needed to represent `features` and this + /// adapter's characteristics. + /// + /// Typically, you'd simply call `required_device_extensions`, and then pass + /// its return value and the feature set you gave it directly to this + /// function. But it's fine to add more extensions to the list. + /// + /// [`required_device_extensions`]: Self::required_device_extensions pub fn physical_device_features( &self, enabled_extensions: &[&'static CStr], @@ -1453,6 +1595,10 @@ impl super::Adapter { capabilities.push(spv::Capability::RayQueryKHR); } + if features.contains(wgt::Features::SHADER_INT64) { + capabilities.push(spv::Capability::Int64); + } + let mut flags = spv::WriterFlags::empty(); flags.set( spv::WriterFlags::DEBUG, @@ -1602,7 +1748,9 @@ impl super::Adapter { } } -impl crate::Adapter for super::Adapter { +impl crate::Adapter for super::Adapter { + type A = super::Api; + unsafe fn open( &self, features: wgt::Features, diff --git a/wgpu-hal/src/vulkan/command.rs b/wgpu-hal/src/vulkan/command.rs index 42ea907738..43a2471954 100644 --- a/wgpu-hal/src/vulkan/command.rs +++ b/wgpu-hal/src/vulkan/command.rs @@ -60,7 +60,9 @@ impl super::CommandEncoder { } } -impl crate::CommandEncoder for super::CommandEncoder { +impl crate::CommandEncoder for super::CommandEncoder { + type A = super::Api; + unsafe fn begin_encoding(&mut self, label: crate::Label) -> Result<(), crate::DeviceError> { if self.free.is_empty() { let vk_info = vk::CommandBufferAllocateInfo::builder() diff --git a/wgpu-hal/src/vulkan/conv.rs b/wgpu-hal/src/vulkan/conv.rs index 8202c93aa3..fe284f32a9 100644 --- a/wgpu-hal/src/vulkan/conv.rs +++ b/wgpu-hal/src/vulkan/conv.rs @@ -399,6 +399,7 @@ pub fn map_vertex_format(vertex_format: wgt::VertexFormat) -> vk::Format { Vf::Float64x2 => vk::Format::R64G64_SFLOAT, Vf::Float64x3 => vk::Format::R64G64B64_SFLOAT, Vf::Float64x4 => vk::Format::R64G64B64A64_SFLOAT, + Vf::Unorm10_10_10_2 => vk::Format::A2B10G10R10_UNORM_PACK32, } } diff --git a/wgpu-hal/src/vulkan/device.rs b/wgpu-hal/src/vulkan/device.rs index c00c3d1d43..70028cc700 100644 --- a/wgpu-hal/src/vulkan/device.rs +++ b/wgpu-hal/src/vulkan/device.rs @@ -830,7 +830,9 @@ impl super::Device { } } -impl crate::Device for super::Device { +impl crate::Device for super::Device { + type A = super::Api; + unsafe fn exit(self, queue: super::Queue) { unsafe { self.mem_allocator.into_inner().cleanup(&*self.shared) }; unsafe { self.desc_allocator.into_inner().cleanup(&*self.shared) }; diff --git a/wgpu-hal/src/vulkan/instance.rs b/wgpu-hal/src/vulkan/instance.rs index c4ef573461..a0d29a13a3 100644 --- a/wgpu-hal/src/vulkan/instance.rs +++ b/wgpu-hal/src/vulkan/instance.rs @@ -6,6 +6,7 @@ use std::{ thread, }; +use arrayvec::ArrayVec; use ash::{ extensions::{ext, khr}, vk, @@ -34,11 +35,13 @@ unsafe extern "system" fn debug_utils_messenger_callback( // the debug range start and end appear in different command buffers. let khronos_validation_layer = std::ffi::CStr::from_bytes_with_nul(b"Khronos Validation Layer\0").unwrap(); - if user_data.validation_layer_description.as_ref() == khronos_validation_layer - && user_data.validation_layer_spec_version >= vk::make_api_version(0, 1, 3, 240) - && user_data.validation_layer_spec_version <= vk::make_api_version(0, 1, 3, 250) - { - return vk::FALSE; + if let Some(layer_properties) = user_data.validation_layer_properties.as_ref() { + if layer_properties.layer_description.as_ref() == khronos_validation_layer + && layer_properties.layer_spec_version >= vk::make_api_version(0, 1, 3, 240) + && layer_properties.layer_spec_version <= vk::make_api_version(0, 1, 3, 250) + { + return vk::FALSE; + } } } @@ -211,6 +214,22 @@ impl super::Instance { &self.shared } + fn enumerate_instance_extension_properties( + entry: &ash::Entry, + layer_name: Option<&CStr>, + ) -> Result, crate::InstanceError> { + let instance_extensions = { + profiling::scope!("vkEnumerateInstanceExtensionProperties"); + entry.enumerate_instance_extension_properties(layer_name) + }; + instance_extensions.map_err(|e| { + crate::InstanceError::with_source( + String::from("enumerate_instance_extension_properties() failed"), + e, + ) + }) + } + /// Return the instance extension names wgpu would like to enable. /// /// Return a vector of the names of instance extensions actually available @@ -229,16 +248,7 @@ impl super::Instance { _instance_api_version: u32, flags: wgt::InstanceFlags, ) -> Result, crate::InstanceError> { - let instance_extensions = { - profiling::scope!("vkEnumerateInstanceExtensionProperties"); - entry.enumerate_instance_extension_properties(None) - }; - let instance_extensions = instance_extensions.map_err(|e| { - crate::InstanceError::with_source( - String::from("enumerate_instance_extension_properties() failed"), - e, - ) - })?; + let instance_extensions = Self::enumerate_instance_extension_properties(entry, None)?; // Check our extensions against the available extensions let mut extensions: Vec<&'static CStr> = Vec::new(); @@ -569,7 +579,9 @@ impl Drop for super::InstanceShared { } } -impl crate::Instance for super::Instance { +impl crate::Instance for super::Instance { + type A = super::Api; + unsafe fn init(desc: &crate::InstanceDescriptor) -> Result { profiling::scope!("Init Vulkan Backend"); use crate::auxil::cstr_from_bytes_until_nul; @@ -643,6 +655,31 @@ impl crate::Instance for super::Instance { .find(|inst_layer| cstr_from_bytes_until_nul(&inst_layer.layer_name) == Some(name)) } + let validation_layer_name = + CStr::from_bytes_with_nul(b"VK_LAYER_KHRONOS_validation\0").unwrap(); + let validation_layer_properties = find_layer(&instance_layers, validation_layer_name); + + // Determine if VK_EXT_validation_features is available, so we can enable + // GPU assisted validation and synchronization validation. + let validation_features_are_enabled = if validation_layer_properties.is_some() { + // Get the all the instance extension properties. + let exts = + Self::enumerate_instance_extension_properties(&entry, Some(validation_layer_name))?; + // Convert all the names of the extensions into an iterator of CStrs. + let mut ext_names = exts + .iter() + .filter_map(|ext| cstr_from_bytes_until_nul(&ext.extension_name)); + // Find the validation features extension. + ext_names.any(|ext_name| ext_name == vk::ExtValidationFeaturesFn::name()) + } else { + false + }; + + let should_enable_gpu_based_validation = desc + .flags + .intersects(wgt::InstanceFlags::GPU_BASED_VALIDATION) + && validation_features_are_enabled; + let nv_optimus_layer = CStr::from_bytes_with_nul(b"VK_LAYER_NV_optimus\0").unwrap(); let has_nv_optimus = find_layer(&instance_layers, nv_optimus_layer).is_some(); @@ -651,52 +688,33 @@ impl crate::Instance for super::Instance { let mut layers: Vec<&'static CStr> = Vec::new(); + let has_debug_extension = extensions.contains(&ext::DebugUtils::name()); + let mut debug_user_data = has_debug_extension.then(|| { + // Put the callback data on the heap, to ensure it will never be + // moved. + Box::new(super::DebugUtilsMessengerUserData { + validation_layer_properties: None, + has_obs_layer, + }) + }); + // Request validation layer if asked. - let mut debug_utils = None; - if desc.flags.intersects(wgt::InstanceFlags::VALIDATION) { - let validation_layer_name = - CStr::from_bytes_with_nul(b"VK_LAYER_KHRONOS_validation\0").unwrap(); - if let Some(layer_properties) = find_layer(&instance_layers, validation_layer_name) { + if desc.flags.intersects(wgt::InstanceFlags::VALIDATION) + || should_enable_gpu_based_validation + { + if let Some(layer_properties) = validation_layer_properties { layers.push(validation_layer_name); - if extensions.contains(&ext::DebugUtils::name()) { - // Put the callback data on the heap, to ensure it will never be - // moved. - let callback_data = Box::new(super::DebugUtilsMessengerUserData { - validation_layer_description: cstr_from_bytes_until_nul( - &layer_properties.description, - ) - .unwrap() - .to_owned(), - validation_layer_spec_version: layer_properties.spec_version, - has_obs_layer, - }); - - // having ERROR unconditionally because Vk doesn't like empty flags - let mut severity = vk::DebugUtilsMessageSeverityFlagsEXT::ERROR; - if log::max_level() >= log::LevelFilter::Debug { - severity |= vk::DebugUtilsMessageSeverityFlagsEXT::VERBOSE; - } - if log::max_level() >= log::LevelFilter::Info { - severity |= vk::DebugUtilsMessageSeverityFlagsEXT::INFO; - } - if log::max_level() >= log::LevelFilter::Warn { - severity |= vk::DebugUtilsMessageSeverityFlagsEXT::WARNING; - } - - let message_type = vk::DebugUtilsMessageTypeFlagsEXT::GENERAL - | vk::DebugUtilsMessageTypeFlagsEXT::VALIDATION - | vk::DebugUtilsMessageTypeFlagsEXT::PERFORMANCE; - - let create_info = super::DebugUtilsCreateInfo { - severity, - message_type, - callback_data, - }; - - let vk_create_info = create_info.to_vk_create_info().build(); - - debug_utils = Some((create_info, vk_create_info)); + if let Some(debug_user_data) = debug_user_data.as_mut() { + debug_user_data.validation_layer_properties = + Some(super::ValidationLayerProperties { + layer_description: cstr_from_bytes_until_nul( + &layer_properties.description, + ) + .unwrap() + .to_owned(), + layer_spec_version: layer_properties.spec_version, + }); } } else { log::warn!( @@ -705,6 +723,35 @@ impl crate::Instance for super::Instance { ); } } + let mut debug_utils = if let Some(callback_data) = debug_user_data { + // having ERROR unconditionally because Vk doesn't like empty flags + let mut severity = vk::DebugUtilsMessageSeverityFlagsEXT::ERROR; + if log::max_level() >= log::LevelFilter::Debug { + severity |= vk::DebugUtilsMessageSeverityFlagsEXT::VERBOSE; + } + if log::max_level() >= log::LevelFilter::Info { + severity |= vk::DebugUtilsMessageSeverityFlagsEXT::INFO; + } + if log::max_level() >= log::LevelFilter::Warn { + severity |= vk::DebugUtilsMessageSeverityFlagsEXT::WARNING; + } + + let message_type = vk::DebugUtilsMessageTypeFlagsEXT::GENERAL + | vk::DebugUtilsMessageTypeFlagsEXT::VALIDATION + | vk::DebugUtilsMessageTypeFlagsEXT::PERFORMANCE; + + let create_info = super::DebugUtilsCreateInfo { + severity, + message_type, + callback_data, + }; + + let vk_create_info = create_info.to_vk_create_info().build(); + + Some((create_info, vk_create_info)) + } else { + None + }; #[cfg(target_os = "android")] let android_sdk_version = { @@ -756,6 +803,28 @@ impl crate::Instance for super::Instance { create_info = create_info.push_next(vk_create_info); } + // Enable explicit validation features if available + let mut validation_features; + let mut validation_feature_list: ArrayVec<_, 3>; + if validation_features_are_enabled { + validation_feature_list = ArrayVec::new(); + + // Always enable synchronization validation + validation_feature_list + .push(vk::ValidationFeatureEnableEXT::SYNCHRONIZATION_VALIDATION); + + // Only enable GPU assisted validation if requested. + if should_enable_gpu_based_validation { + validation_feature_list.push(vk::ValidationFeatureEnableEXT::GPU_ASSISTED); + validation_feature_list + .push(vk::ValidationFeatureEnableEXT::GPU_ASSISTED_RESERVE_BINDING_SLOT); + } + + validation_features = vk::ValidationFeaturesEXT::builder() + .enabled_validation_features(&validation_feature_list); + create_info = create_info.push_next(&mut validation_features); + } + unsafe { profiling::scope!("vkCreateInstance"); entry.create_instance(&create_info, None) @@ -889,7 +958,9 @@ impl crate::Instance for super::Instance { } } -impl crate::Surface for super::Surface { +impl crate::Surface for super::Surface { + type A = super::Api; + unsafe fn configure( &self, device: &super::Device, diff --git a/wgpu-hal/src/vulkan/mod.rs b/wgpu-hal/src/vulkan/mod.rs index 787ebd7267..d969c887d5 100644 --- a/wgpu-hal/src/vulkan/mod.rs +++ b/wgpu-hal/src/vulkan/mod.rs @@ -101,17 +101,25 @@ pub struct DebugUtilsCreateInfo { callback_data: Box, } +#[derive(Debug)] +/// The properties related to the validation layer needed for the +/// DebugUtilsMessenger for their workarounds +struct ValidationLayerProperties { + /// Validation layer description, from `vk::LayerProperties`. + layer_description: std::ffi::CString, + + /// Validation layer specification version, from `vk::LayerProperties`. + layer_spec_version: u32, +} + /// User data needed by `instance::debug_utils_messenger_callback`. /// /// When we create the [`vk::DebugUtilsMessengerEXT`], the `pUserData` /// pointer refers to one of these values. #[derive(Debug)] pub struct DebugUtilsMessengerUserData { - /// Validation layer description, from `vk::LayerProperties`. - validation_layer_description: std::ffi::CString, - - /// Validation layer specification version, from `vk::LayerProperties`. - validation_layer_spec_version: u32, + /// The properties related to the validation layer, if present + validation_layer_properties: Option, /// If the OBS layer is present. OBS never increments the version of their layer, /// so there's no reason to have the version. @@ -181,7 +189,7 @@ pub struct Adapter { instance: Arc, //queue_families: Vec, known_memory_flags: vk::MemoryPropertyFlags, - phd_capabilities: adapter::PhysicalDeviceCapabilities, + phd_capabilities: adapter::PhysicalDeviceProperties, //phd_features: adapter::PhysicalDeviceFeatures, downlevel_flags: wgt::DownlevelFlags, private_caps: PrivateCapabilities, @@ -405,6 +413,15 @@ pub struct TextureView { attachment: FramebufferAttachment, } +impl TextureView { + /// # Safety + /// + /// - The image view handle must not be manually destroyed + pub unsafe fn raw_handle(&self) -> vk::ImageView { + self.raw + } +} + #[derive(Debug)] pub struct Sampler { raw: vk::Sampler, @@ -473,6 +490,15 @@ pub struct CommandEncoder { end_of_pass_timer_query: Option<(vk::QueryPool, u32)>, } +impl CommandEncoder { + /// # Safety + /// + /// - The command buffer handle must not be manually destroyed + pub unsafe fn raw_handle(&self) -> vk::CommandBuffer { + self.active + } +} + impl fmt::Debug for CommandEncoder { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("CommandEncoder") @@ -586,7 +612,9 @@ impl Fence { } } -impl crate::Queue for Queue { +impl crate::Queue for Queue { + type A = Api; + unsafe fn submit( &self, command_buffers: &[&CommandBuffer], @@ -724,13 +752,25 @@ impl crate::Queue for Queue { impl From for crate::DeviceError { fn from(result: vk::Result) -> Self { + #![allow(unreachable_code)] match result { vk::Result::ERROR_OUT_OF_HOST_MEMORY | vk::Result::ERROR_OUT_OF_DEVICE_MEMORY => { + #[cfg(feature = "oom_panic")] + panic!("Out of memory ({result:?})"); + Self::OutOfMemory } - vk::Result::ERROR_DEVICE_LOST => Self::Lost, + vk::Result::ERROR_DEVICE_LOST => { + #[cfg(feature = "device_lost_panic")] + panic!("Device lost"); + + Self::Lost + } _ => { - log::warn!("Unrecognized device error {:?}", result); + #[cfg(feature = "internal_error_panic")] + panic!("Internal error: {result:?}"); + + log::warn!("Unrecognized device error {result:?}"); Self::Lost } } diff --git a/wgpu-types/Cargo.toml b/wgpu-types/Cargo.toml index ff3649f24b..b54e5ce48d 100644 --- a/wgpu-types/Cargo.toml +++ b/wgpu-types/Cargo.toml @@ -13,7 +13,7 @@ license = "MIT OR Apache-2.0" # copy the crates it actually uses out of the workspace, so it's meaningful for # them to have less restrictive MSRVs individually than the workspace as a # whole, if their code permits. See `../README.md` for details. -rust-version = "1.70" +rust-version = "1.74" [package.metadata.docs.rs] all-features = true @@ -36,8 +36,8 @@ bitflags = "2" serde = { version = "1", features = ["serde_derive"], optional = true } [target.'cfg(target_arch = "wasm32")'.dependencies] -js-sys = "0.3.67" -web-sys = { version = "0.3.67", features = [ +js-sys = "0.3.69" +web-sys = { version = "0.3.69", features = [ "ImageBitmap", "HtmlVideoElement", "HtmlCanvasElement", @@ -46,4 +46,4 @@ web-sys = { version = "0.3.67", features = [ [dev-dependencies] serde = { version = "1", features = ["serde_derive"] } -serde_json = "1.0.111" +serde_json = "1.0.113" diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index 003cbb8473..fafa7d8cd7 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -267,17 +267,77 @@ bitflags::bitflags! { /// /// This is a web and native feature. const DEPTH_CLIP_CONTROL = 1 << 0; + + /// Allows for explicit creation of textures of format [`TextureFormat::Depth32FloatStencil8`] + /// + /// Supported platforms: + /// - Vulkan (mostly) + /// - DX12 + /// - Metal + /// - OpenGL + /// + /// This is a web and native feature. + const DEPTH32FLOAT_STENCIL8 = 1 << 1; + + /// Enables BCn family of compressed textures. All BCn textures use 4x4 pixel blocks + /// with 8 or 16 bytes per block. + /// + /// Compressed textures sacrifice some quality in exchange for significantly reduced + /// bandwidth usage. + /// + /// Support for this feature guarantees availability of [`TextureUsages::COPY_SRC | TextureUsages::COPY_DST | TextureUsages::TEXTURE_BINDING`] for BCn formats. + /// [`Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES`] may enable additional usages. + /// + /// Supported Platforms: + /// - desktops + /// + /// This is a web and native feature. + const TEXTURE_COMPRESSION_BC = 1 << 2; + + /// Enables ETC family of compressed textures. All ETC textures use 4x4 pixel blocks. + /// ETC2 RGB and RGBA1 are 8 bytes per block. RTC2 RGBA8 and EAC are 16 bytes per block. + /// + /// Compressed textures sacrifice some quality in exchange for significantly reduced + /// bandwidth usage. + /// + /// Support for this feature guarantees availability of [`TextureUsages::COPY_SRC | TextureUsages::COPY_DST | TextureUsages::TEXTURE_BINDING`] for ETC2 formats. + /// [`Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES`] may enable additional usages. + /// + /// Supported Platforms: + /// - Vulkan on Intel + /// - Mobile (some) + /// + /// This is a web and native feature. + const TEXTURE_COMPRESSION_ETC2 = 1 << 3; + + /// Enables ASTC family of compressed textures. ASTC textures use pixel blocks varying from 4x4 to 12x12. + /// Blocks are always 16 bytes. + /// + /// Compressed textures sacrifice some quality in exchange for significantly reduced + /// bandwidth usage. + /// + /// Support for this feature guarantees availability of [`TextureUsages::COPY_SRC | TextureUsages::COPY_DST | TextureUsages::TEXTURE_BINDING`] for ASTC formats with Unorm/UnormSrgb channel type. + /// [`Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES`] may enable additional usages. + /// + /// Supported Platforms: + /// - Vulkan on Intel + /// - Mobile (some) + /// + /// This is a web and native feature. + const TEXTURE_COMPRESSION_ASTC = 1 << 4; + /// Enables use of Timestamp Queries. These queries tell the current gpu timestamp when /// all work before the query is finished. /// /// This feature allows the use of - /// - [`CommandEncoder::write_timestamp`] /// - [`RenderPassDescriptor::timestamp_writes`] /// - [`ComputePassDescriptor::timestamp_writes`] /// to write out timestamps. - /// For timestamps within passes refer to [`Features::TIMESTAMP_QUERY_INSIDE_PASSES`] /// - /// They must be resolved using [`CommandEncoder::resolve_query_sets`] into a buffer, + /// For arbitrary timestamp write commands on encoders refer to [`Features::TIMESTAMP_QUERY_INSIDE_ENCODERS`]. + /// For arbitrary timestamp write commands on passes refer to [`Features::TIMESTAMP_QUERY_INSIDE_PASSES`]. + /// + /// They must be resolved using [`CommandEncoder::resolve_query_set`] into a buffer, /// then the result must be multiplied by the timestamp period [`Queue::get_timestamp_period`] /// to get the timestamp in nanoseconds. Multiple timestamps can then be diffed to get the /// time for operations between them to finish. @@ -288,7 +348,8 @@ bitflags::bitflags! { /// - Metal /// /// This is a web and native feature. - const TIMESTAMP_QUERY = 1 << 1; + const TIMESTAMP_QUERY = 1 << 5; + /// Allows non-zero value for the `first_instance` member in indirect draw calls. /// /// If this feature is not enabled, and the `first_instance` member is non-zero, the behavior may be: @@ -306,33 +367,29 @@ bitflags::bitflags! { /// - OpenGL ES / WebGL /// /// This is a web and native feature. - const INDIRECT_FIRST_INSTANCE = 1 << 2; - - // 3..8 available - - // Shader: + const INDIRECT_FIRST_INSTANCE = 1 << 6; /// Allows shaders to acquire the FP16 ability /// - /// Note: this is not supported in `naga` yet,only through `spirv-passthrough` right now. + /// Note: this is not supported in `naga` yet, only through `spirv-passthrough` right now. /// /// Supported Platforms: /// - Vulkan /// - Metal /// /// This is a web and native feature. - const SHADER_F16 = 1 << 8; + const SHADER_F16 = 1 << 7; - // 9..14 available - // Texture Formats: - - // The features starting with a ? are features that might become part of the spec or - // at the very least we can implement as native features; since they should cover all - // possible formats and capabilities across backends. - // - // ? const FORMATS_TIER_1 = 1 << 14; (https://github.com/gpuweb/gpuweb/issues/3837) - // ? const RW_STORAGE_TEXTURE_TIER_1 = 1 << 15; (https://github.com/gpuweb/gpuweb/issues/3838) + /// Allows for usage of textures of format [`TextureFormat::Rg11b10Float`] as a render target + /// + /// Supported platforms: + /// - Vulkan + /// - DX12 + /// - Metal + /// + /// This is a web and native feature. + const RG11B10UFLOAT_RENDERABLE = 1 << 8; /// Allows the [`wgpu::TextureUsages::STORAGE_BINDING`] usage on textures with format [`TextureFormat::Bgra8unorm`] /// @@ -342,10 +399,8 @@ bitflags::bitflags! { /// - Metal /// /// This is a web and native feature. - const BGRA8UNORM_STORAGE = 1 << 16; + const BGRA8UNORM_STORAGE = 1 << 9; - // ? const NORM16_FILTERABLE = 1 << 17; (https://github.com/gpuweb/gpuweb/issues/3839) - // ? const NORM16_RESOLVE = 1 << 18; (https://github.com/gpuweb/gpuweb/issues/3839) /// Allows textures with formats "r32float", "rg32float", and "rgba32float" to be filterable. /// @@ -356,81 +411,11 @@ bitflags::bitflags! { /// - GL with one of `GL_ARB_color_buffer_float`/`GL_EXT_color_buffer_float`/`OES_texture_float_linear` /// /// This is a web and native feature. - const FLOAT32_FILTERABLE = 1 << 19; + const FLOAT32_FILTERABLE = 1 << 10; - // ? const FLOAT32_BLENDABLE = 1 << 20; (https://github.com/gpuweb/gpuweb/issues/3556) - // ? const 32BIT_FORMAT_MULTISAMPLE = 1 << 21; (https://github.com/gpuweb/gpuweb/issues/3844) - // ? const 32BIT_FORMAT_RESOLVE = 1 << 22; (https://github.com/gpuweb/gpuweb/issues/3844) - - /// Allows for usage of textures of format [`TextureFormat::Rg11b10Float`] as a render target - /// - /// Supported platforms: - /// - Vulkan - /// - DX12 - /// - Metal - /// - /// This is a web and native feature. - const RG11B10UFLOAT_RENDERABLE = 1 << 23; - - /// Allows for explicit creation of textures of format [`TextureFormat::Depth32FloatStencil8`] - /// - /// Supported platforms: - /// - Vulkan (mostly) - /// - DX12 - /// - Metal - /// - /// This is a web and native feature. - const DEPTH32FLOAT_STENCIL8 = 1 << 24; - /// Enables BCn family of compressed textures. All BCn textures use 4x4 pixel blocks - /// with 8 or 16 bytes per block. - /// - /// Compressed textures sacrifice some quality in exchange for significantly reduced - /// bandwidth usage. - /// - /// Support for this feature guarantees availability of [`TextureUsages::COPY_SRC | TextureUsages::COPY_DST | TextureUsages::TEXTURE_BINDING`] for BCn formats. - /// [`Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES`] may enable additional usages. - /// - /// Supported Platforms: - /// - desktops - /// - /// This is a web and native feature. - const TEXTURE_COMPRESSION_BC = 1 << 25; - /// Enables ETC family of compressed textures. All ETC textures use 4x4 pixel blocks. - /// ETC2 RGB and RGBA1 are 8 bytes per block. RTC2 RGBA8 and EAC are 16 bytes per block. - /// - /// Compressed textures sacrifice some quality in exchange for significantly reduced - /// bandwidth usage. - /// - /// Support for this feature guarantees availability of [`TextureUsages::COPY_SRC | TextureUsages::COPY_DST | TextureUsages::TEXTURE_BINDING`] for ETC2 formats. - /// [`Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES`] may enable additional usages. - /// - /// Supported Platforms: - /// - Vulkan on Intel - /// - Mobile (some) - /// - /// This is a web and native feature. - const TEXTURE_COMPRESSION_ETC2 = 1 << 26; - /// Enables ASTC family of compressed textures. ASTC textures use pixel blocks varying from 4x4 to 12x12. - /// Blocks are always 16 bytes. - /// - /// Compressed textures sacrifice some quality in exchange for significantly reduced - /// bandwidth usage. - /// - /// Support for this feature guarantees availability of [`TextureUsages::COPY_SRC | TextureUsages::COPY_DST | TextureUsages::TEXTURE_BINDING`] for ASTC formats with Unorm/UnormSrgb channel type. - /// [`Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES`] may enable additional usages. - /// - /// Supported Platforms: - /// - Vulkan on Intel - /// - Mobile (some) - /// - /// This is a web and native feature. - const TEXTURE_COMPRESSION_ASTC = 1 << 27; - - // ? const TEXTURE_COMPRESSION_ASTC_HDR = 1 << 28; (https://github.com/gpuweb/gpuweb/issues/3856) - - // 29..32 should be available but are for now occupied by native only texture related features - // TEXTURE_FORMAT_16BIT_NORM & TEXTURE_COMPRESSION_ASTC_HDR will most likely become web features as well - // TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES might not be necessary if we have all the texture features implemented + // Bits 11-19 available for webgpu features. Should you chose to use some of them for + // for native features, don't forget to update `all_webgpu_mask` and `all_native_mask` + // accordingly. // // ---- Restart Numbering for Native Features --- @@ -438,6 +423,21 @@ bitflags::bitflags! { // Native Features: // + // The features starting with a ? are features that might become part of the spec or + // at the very least we can implement as native features; since they should cover all + // possible formats and capabilities across backends. + // + // ? const FORMATS_TIER_1 = 1 << ??; (https://github.com/gpuweb/gpuweb/issues/3837) + // ? const RW_STORAGE_TEXTURE_TIER_1 = 1 << ??; (https://github.com/gpuweb/gpuweb/issues/3838) + // ? const NORM16_FILTERABLE = 1 << ??; (https://github.com/gpuweb/gpuweb/issues/3839) + // ? const NORM16_RESOLVE = 1 << ??; (https://github.com/gpuweb/gpuweb/issues/3839) + // ? const FLOAT32_BLENDABLE = 1 << ??; (https://github.com/gpuweb/gpuweb/issues/3556) + // ? const 32BIT_FORMAT_MULTISAMPLE = 1 << ??; (https://github.com/gpuweb/gpuweb/issues/3844) + // ? const 32BIT_FORMAT_RESOLVE = 1 << ??; (https://github.com/gpuweb/gpuweb/issues/3844) + // ? const TEXTURE_COMPRESSION_ASTC_HDR = 1 << ??; (https://github.com/gpuweb/gpuweb/issues/3856) + // TEXTURE_FORMAT_16BIT_NORM & TEXTURE_COMPRESSION_ASTC_HDR will most likely become web features as well + // TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES might not be necessary if we have all the texture features implemented + // Texture Formats: /// Enables normalized `16-bit` texture formats. @@ -448,7 +448,7 @@ bitflags::bitflags! { /// - Metal /// /// This is a native only feature. - const TEXTURE_FORMAT_16BIT_NORM = 1 << 29; + const TEXTURE_FORMAT_16BIT_NORM = 1 << 20; /// Enables ASTC HDR family of compressed textures. /// /// Compressed textures sacrifice some quality in exchange for significantly reduced @@ -463,7 +463,7 @@ bitflags::bitflags! { /// - OpenGL /// /// This is a native only feature. - const TEXTURE_COMPRESSION_ASTC_HDR = 1 << 30; + const TEXTURE_COMPRESSION_ASTC_HDR = 1 << 21; /// Enables device specific texture format features. /// /// See `TextureFormatFeatures` for a listing of the features in question. @@ -475,15 +475,15 @@ bitflags::bitflags! { /// This extension does not enable additional formats. /// /// This is a native only feature. - const TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES = 1 << 31; + const TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES = 1 << 22; // API: /// Enables use of Pipeline Statistics Queries. These queries tell the count of various operations - /// performed between the start and stop call. Call [`RenderPassEncoder::begin_pipeline_statistics_query`] to start - /// a query, then call [`RenderPassEncoder::end_pipeline_statistics_query`] to stop one. + /// performed between the start and stop call. Call [`RenderPass::begin_pipeline_statistics_query`] to start + /// a query, then call [`RenderPass::end_pipeline_statistics_query`] to stop one. /// - /// They must be resolved using [`CommandEncoder::resolve_query_sets`] into a buffer. + /// They must be resolved using [`CommandEncoder::resolve_query_set`] into a buffer. /// The rules on how these resolve into buffers are detailed in the documentation for [`PipelineStatisticsTypes`]. /// /// Supported Platforms: @@ -491,14 +491,28 @@ bitflags::bitflags! { /// - DX12 /// /// This is a native only feature with a [proposal](https://github.com/gpuweb/gpuweb/blob/0008bd30da2366af88180b511a5d0d0c1dffbc36/proposals/pipeline-statistics-query.md) for the web. - const PIPELINE_STATISTICS_QUERY = 1 << 32; - /// Allows for timestamp queries inside render passes. + const PIPELINE_STATISTICS_QUERY = 1 << 23; + /// Allows for timestamp queries directly on command encoders. /// /// Implies [`Features::TIMESTAMP_QUERY`] is supported. /// + /// Additionally allows for timestamp writes on command encoders + /// using [`CommandEncoder::write_timestamp`]. + /// + /// Supported platforms: + /// - Vulkan + /// - DX12 + /// - Metal + /// + /// This is a native only feature. + const TIMESTAMP_QUERY_INSIDE_ENCODERS = 1 << 24; + /// Allows for timestamp queries directly on command encoders. + /// + /// Implies [`Features::TIMESTAMP_QUERY`] & [`Features::TIMESTAMP_QUERY_INSIDE_ENCODERS`] is supported. + /// /// Additionally allows for timestamp queries to be used inside render & compute passes using: - /// - [`RenderPassEncoder::write_timestamp`] - /// - [`ComputePassEncoder::write_timestamp`] + /// - [`RenderPass::write_timestamp`] + /// - [`ComputePass::write_timestamp`] /// /// Supported platforms: /// - Vulkan @@ -508,7 +522,7 @@ bitflags::bitflags! { /// This is generally not available on tile-based rasterization GPUs. /// /// This is a native only feature with a [proposal](https://github.com/gpuweb/gpuweb/blob/0008bd30da2366af88180b511a5d0d0c1dffbc36/proposals/timestamp-query-inside-passes.md) for the web. - const TIMESTAMP_QUERY_INSIDE_PASSES = 1 << 33; + const TIMESTAMP_QUERY_INSIDE_PASSES = 1 << 25; /// Webgpu only allows the MAP_READ and MAP_WRITE buffer usage to be matched with /// COPY_DST and COPY_SRC respectively. This removes this requirement. /// @@ -522,7 +536,7 @@ bitflags::bitflags! { /// - Metal /// /// This is a native only feature. - const MAPPABLE_PRIMARY_BUFFERS = 1 << 34; + const MAPPABLE_PRIMARY_BUFFERS = 1 << 26; /// Allows the user to create uniform arrays of textures in shaders: /// /// ex. @@ -545,7 +559,7 @@ bitflags::bitflags! { /// - Vulkan /// /// This is a native only feature. - const TEXTURE_BINDING_ARRAY = 1 << 35; + const TEXTURE_BINDING_ARRAY = 1 << 27; /// Allows the user to create arrays of buffers in shaders: /// /// ex. @@ -567,7 +581,7 @@ bitflags::bitflags! { /// - Vulkan /// /// This is a native only feature. - const BUFFER_BINDING_ARRAY = 1 << 36; + const BUFFER_BINDING_ARRAY = 1 << 28; /// Allows the user to create uniform arrays of storage buffers or textures in shaders, /// if resp. [`Features::BUFFER_BINDING_ARRAY`] or [`Features::TEXTURE_BINDING_ARRAY`] /// is supported. @@ -580,7 +594,7 @@ bitflags::bitflags! { /// - Vulkan /// /// This is a native only feature. - const STORAGE_RESOURCE_BINDING_ARRAY = 1 << 37; + const STORAGE_RESOURCE_BINDING_ARRAY = 1 << 29; /// Allows shaders to index sampled texture and storage buffer resource arrays with dynamically non-uniform values: /// /// ex. `texture_array[vertex_data]` @@ -605,7 +619,7 @@ bitflags::bitflags! { /// - Vulkan 1.2+ (or VK_EXT_descriptor_indexing)'s shaderSampledImageArrayNonUniformIndexing & shaderStorageBufferArrayNonUniformIndexing feature) /// /// This is a native only feature. - const SAMPLED_TEXTURE_AND_STORAGE_BUFFER_ARRAY_NON_UNIFORM_INDEXING = 1 << 38; + const SAMPLED_TEXTURE_AND_STORAGE_BUFFER_ARRAY_NON_UNIFORM_INDEXING = 1 << 30; /// Allows shaders to index uniform buffer and storage texture resource arrays with dynamically non-uniform values: /// /// ex. `texture_array[vertex_data]` @@ -630,11 +644,11 @@ bitflags::bitflags! { /// - Vulkan 1.2+ (or VK_EXT_descriptor_indexing)'s shaderUniformBufferArrayNonUniformIndexing & shaderStorageTextureArrayNonUniformIndexing feature) /// /// This is a native only feature. - const UNIFORM_BUFFER_AND_STORAGE_TEXTURE_ARRAY_NON_UNIFORM_INDEXING = 1 << 39; + const UNIFORM_BUFFER_AND_STORAGE_TEXTURE_ARRAY_NON_UNIFORM_INDEXING = 1 << 31; /// Allows the user to create bind groups containing arrays with less bindings than the BindGroupLayout. /// /// This is a native only feature. - const PARTIALLY_BOUND_BINDING_ARRAY = 1 << 40; + const PARTIALLY_BOUND_BINDING_ARRAY = 1 << 32; /// Allows the user to call [`RenderPass::multi_draw_indirect`] and [`RenderPass::multi_draw_indexed_indirect`]. /// /// Allows multiple indirect calls to be dispatched from a single buffer. @@ -648,7 +662,7 @@ bitflags::bitflags! { /// /// [`RenderPass::multi_draw_indirect`]: ../wgpu/struct.RenderPass.html#method.multi_draw_indirect /// [`RenderPass::multi_draw_indexed_indirect`]: ../wgpu/struct.RenderPass.html#method.multi_draw_indexed_indirect - const MULTI_DRAW_INDIRECT = 1 << 41; + const MULTI_DRAW_INDIRECT = 1 << 33; /// Allows the user to call [`RenderPass::multi_draw_indirect_count`] and [`RenderPass::multi_draw_indexed_indirect_count`]. /// /// This allows the use of a buffer containing the actual number of draw calls. @@ -661,14 +675,21 @@ bitflags::bitflags! { /// /// [`RenderPass::multi_draw_indirect_count`]: ../wgpu/struct.RenderPass.html#method.multi_draw_indirect_count /// [`RenderPass::multi_draw_indexed_indirect_count`]: ../wgpu/struct.RenderPass.html#method.multi_draw_indexed_indirect_count - const MULTI_DRAW_INDIRECT_COUNT = 1 << 42; + const MULTI_DRAW_INDIRECT_COUNT = 1 << 34; /// Allows the use of push constants: small, fast bits of memory that can be updated /// inside a [`RenderPass`]. /// /// Allows the user to call [`RenderPass::set_push_constants`], provide a non-empty array /// to [`PipelineLayoutDescriptor`], and provide a non-zero limit to [`Limits::max_push_constant_size`]. /// - /// A block of push constants can be declared with `layout(push_constant) uniform Name {..}` in shaders. + /// A block of push constants can be declared in WGSL with `var`: + /// + /// ```rust,ignore + /// struct PushConstants { example: f32, } + /// var c: PushConstants; + /// ``` + /// + /// In GLSL, this corresponds to `layout(push_constant) uniform Name {..}`. /// /// Supported platforms: /// - DX12 @@ -681,7 +702,7 @@ bitflags::bitflags! { /// [`RenderPass`]: ../wgpu/struct.RenderPass.html /// [`PipelineLayoutDescriptor`]: ../wgpu/struct.PipelineLayoutDescriptor.html /// [`RenderPass::set_push_constants`]: ../wgpu/struct.RenderPass.html#method.set_push_constants - const PUSH_CONSTANTS = 1 << 43; + const PUSH_CONSTANTS = 1 << 35; /// Allows the use of [`AddressMode::ClampToBorder`] with a border color /// of [`SamplerBorderColor::Zero`]. /// @@ -692,7 +713,7 @@ bitflags::bitflags! { /// - OpenGL /// /// This is a native only feature. - const ADDRESS_MODE_CLAMP_TO_ZERO = 1 << 44; + const ADDRESS_MODE_CLAMP_TO_ZERO = 1 << 36; /// Allows the use of [`AddressMode::ClampToBorder`] with a border color /// other than [`SamplerBorderColor::Zero`]. /// @@ -703,7 +724,7 @@ bitflags::bitflags! { /// - OpenGL /// /// This is a native only feature. - const ADDRESS_MODE_CLAMP_TO_BORDER = 1 << 45; + const ADDRESS_MODE_CLAMP_TO_BORDER = 1 << 37; /// Allows the user to set [`PolygonMode::Line`] in [`PrimitiveState::polygon_mode`] /// /// This allows drawing polygons/triangles as lines (wireframe) instead of filled @@ -714,7 +735,7 @@ bitflags::bitflags! { /// - Metal /// /// This is a native only feature. - const POLYGON_MODE_LINE = 1 << 46; + const POLYGON_MODE_LINE = 1 << 38; /// Allows the user to set [`PolygonMode::Point`] in [`PrimitiveState::polygon_mode`] /// /// This allows only drawing the vertices of polygons/triangles instead of filled @@ -723,7 +744,7 @@ bitflags::bitflags! { /// - Vulkan /// /// This is a native only feature. - const POLYGON_MODE_POINT = 1 << 47; + const POLYGON_MODE_POINT = 1 << 39; /// Allows the user to set a overestimation-conservative-rasterization in [`PrimitiveState::conservative`] /// /// Processing of degenerate triangles/lines is hardware specific. @@ -733,7 +754,7 @@ bitflags::bitflags! { /// - Vulkan /// /// This is a native only feature. - const CONSERVATIVE_RASTERIZATION = 1 << 48; + const CONSERVATIVE_RASTERIZATION = 1 << 40; /// Enables bindings of writable storage buffers and textures visible to vertex shaders. /// /// Note: some (tiled-based) platforms do not support vertex shaders with any side-effects. @@ -742,14 +763,14 @@ bitflags::bitflags! { /// - All /// /// This is a native only feature. - const VERTEX_WRITABLE_STORAGE = 1 << 49; + const VERTEX_WRITABLE_STORAGE = 1 << 41; /// Enables clear to zero for textures. /// /// Supported platforms: /// - All /// /// This is a native only feature. - const CLEAR_TEXTURE = 1 << 50; + const CLEAR_TEXTURE = 1 << 42; /// Enables creating shader modules from SPIR-V binary data (unsafe). /// /// SPIR-V data is not parsed or interpreted in any way; you can use @@ -761,7 +782,7 @@ bitflags::bitflags! { /// Vulkan implementation. /// /// This is a native only feature. - const SPIRV_SHADER_PASSTHROUGH = 1 << 51; + const SPIRV_SHADER_PASSTHROUGH = 1 << 43; /// Enables multiview render passes and `builtin(view_index)` in vertex shaders. /// /// Supported platforms: @@ -769,7 +790,7 @@ bitflags::bitflags! { /// - OpenGL (web only) /// /// This is a native only feature. - const MULTIVIEW = 1 << 52; + const MULTIVIEW = 1 << 44; /// Enables using 64-bit types for vertex attributes. /// /// Requires SHADER_FLOAT64. @@ -777,7 +798,7 @@ bitflags::bitflags! { /// Supported Platforms: N/A /// /// This is a native only feature. - const VERTEX_ATTRIBUTE_64BIT = 1 << 53; + const VERTEX_ATTRIBUTE_64BIT = 1 << 45; /// Allows vertex shaders to have outputs which are not consumed /// by the fragment shader. /// @@ -785,7 +806,7 @@ bitflags::bitflags! { /// - Vulkan /// - Metal /// - OpenGL - const SHADER_UNUSED_VERTEX_OUTPUT = 1 << 54; + const SHADER_UNUSED_VERTEX_OUTPUT = 1 << 46; /// Allows for creation of textures of format [`TextureFormat::NV12`] /// /// Supported platforms: @@ -793,16 +814,14 @@ bitflags::bitflags! { /// - Vulkan /// /// This is a native only feature. - const TEXTURE_FORMAT_NV12 = 1 << 55; + const TEXTURE_FORMAT_NV12 = 1 << 47; /// Allows for the creation of ray-tracing acceleration structures. /// /// Supported platforms: /// - Vulkan /// /// This is a native-only feature. - const RAY_TRACING_ACCELERATION_STRUCTURE = 1 << 56; - - // 57 available + const RAY_TRACING_ACCELERATION_STRUCTURE = 1 << 48; // Shader: @@ -812,7 +831,7 @@ bitflags::bitflags! { /// - Vulkan /// /// This is a native-only feature. - const RAY_QUERY = 1 << 58; + const RAY_QUERY = 1 << 49; /// Enables 64-bit floating point types in SPIR-V shaders. /// /// Note: even when supported by GPU hardware, 64-bit floating point operations are @@ -822,14 +841,14 @@ bitflags::bitflags! { /// - Vulkan /// /// This is a native only feature. - const SHADER_F64 = 1 << 59; + const SHADER_F64 = 1 << 50; /// Allows shaders to use i16. Not currently supported in `naga`, only available through `spirv-passthrough`. /// /// Supported platforms: /// - Vulkan /// /// This is a native only feature. - const SHADER_I16 = 1 << 60; + const SHADER_I16 = 1 << 51; /// Enables `builtin(primitive_index)` in fragment shaders. /// /// Note: enables geometry processing for pipelines using the builtin. @@ -843,14 +862,14 @@ bitflags::bitflags! { /// - OpenGL (some) /// /// This is a native only feature. - const SHADER_PRIMITIVE_INDEX = 1 << 61; + const SHADER_PRIMITIVE_INDEX = 1 << 52; /// Allows shaders to use the `early_depth_test` attribute. /// /// Supported platforms: /// - GLES 3.1+ /// /// This is a native only feature. - const SHADER_EARLY_DEPTH_TEST = 1 << 62; + const SHADER_EARLY_DEPTH_TEST = 1 << 53; /// Allows two outputs from a shader to be used for blending. /// Note that dual-source blending doesn't support multiple render targets. /// @@ -861,7 +880,16 @@ bitflags::bitflags! { /// - Metal (with MSL 1.2+) /// - Vulkan (with dualSrcBlend) /// - DX12 - const DUAL_SOURCE_BLENDING = 1 << 63; + const DUAL_SOURCE_BLENDING = 1 << 54; + /// Allows shaders to use i64 and u64. + /// + /// Supported platforms: + /// - Vulkan + /// - DX12 (DXC only) + /// - Metal (with MSL 2.3+) + /// + /// This is a native only feature. + const SHADER_INT64 = 1 << 55; } } @@ -870,12 +898,12 @@ impl_bitflags!(Features); impl Features { /// Mask of all features which are part of the upstream WebGPU standard. pub const fn all_webgpu_mask() -> Self { - Self::from_bits_truncate(0x0000_0000_0000_FFFF) + Self::from_bits_truncate(0xFFFFF) } /// Mask of all features that are only available when targeting native (not web). pub const fn all_native_mask() -> Self { - Self::from_bits_truncate(0xFFFF_FFFF_FFFF_0000) + Self::from_bits_truncate(!Self::all_webgpu_mask().bits()) } } @@ -904,13 +932,15 @@ bitflags::bitflags! { /// This mainly applies to a Vulkan driver's compliance version. If the major compliance version /// is `0`, then the driver is ignored. This flag allows that driver to be enabled for testing. const ALLOW_UNDERLYING_NONCOMPLIANT_ADAPTER = 1 << 3; - /// Enable GPU-based validation. Currently, this only changes behavior on the DX12 - /// backend. + /// Enable GPU-based validation. Implies [`Self::VALIDATION`]. Currently, this only changes + /// behavior on the DX12 and Vulkan backends. /// /// Supported platforms: /// /// - D3D12; called ["GPU-based validation", or /// "GBV"](https://web.archive.org/web/20230206120404/https://learn.microsoft.com/en-us/windows/win32/direct3d12/using-d3d12-debug-layer-gpu-based-validation) + /// - Vulkan, via the `VK_LAYER_KHRONOS_validation` layer; called ["GPU-Assisted + /// Validation"](https://github.com/KhronosGroup/Vulkan-ValidationLayers/blob/e45aeb85079e0835694cb8f03e6681fd18ae72c9/docs/gpu_validation.md#gpu-assisted-validation) const GPU_BASED_VALIDATION = 1 << 4; } } @@ -924,7 +954,12 @@ impl Default for InstanceFlags { impl InstanceFlags { /// Enable recommended debugging and validation flags. pub fn debugging() -> Self { - InstanceFlags::DEBUG | InstanceFlags::VALIDATION | InstanceFlags::GPU_BASED_VALIDATION + InstanceFlags::DEBUG | InstanceFlags::VALIDATION + } + + /// Enable advanced debugging and validation flags (potentially very slow). + pub fn advanced_debugging() -> Self { + Self::debugging() | InstanceFlags::GPU_BASED_VALIDATION } /// Infer good defaults from the build type @@ -1199,7 +1234,7 @@ impl Limits { /// max_non_sampler_bindings: 1_000_000, /// }); /// ``` - pub fn downlevel_defaults() -> Self { + pub const fn downlevel_defaults() -> Self { Self { max_texture_dimension_1d: 2048, max_texture_dimension_2d: 2048, @@ -1277,7 +1312,7 @@ impl Limits { /// max_non_sampler_bindings: 1_000_000, /// }); /// ``` - pub fn downlevel_webgl2_defaults() -> Self { + pub const fn downlevel_webgl2_defaults() -> Self { Self { max_uniform_buffers_per_shader_stage: 11, max_storage_buffers_per_shader_stage: 0, @@ -1305,7 +1340,7 @@ impl Limits { /// This is useful because the swapchain might need to be larger than any other image in the application. /// /// If your application only needs 512x512, you might be running on a 4k display and need extremely high resolution limits. - pub fn using_resolution(self, other: Self) -> Self { + pub const fn using_resolution(self, other: Self) -> Self { Self { max_texture_dimension_1d: other.max_texture_dimension_1d, max_texture_dimension_2d: other.max_texture_dimension_2d, @@ -1317,7 +1352,7 @@ impl Limits { /// Modify the current limits to use the buffer alignment limits of the adapter. /// /// This is useful for when you'd like to dynamically use the "best" supported buffer alignments. - pub fn using_alignment(self, other: Self) -> Self { + pub const fn using_alignment(self, other: Self) -> Self { Self { min_uniform_buffer_offset_alignment: other.min_uniform_buffer_offset_alignment, min_storage_buffer_offset_alignment: other.min_storage_buffer_offset_alignment, @@ -2111,6 +2146,9 @@ pub struct PrimitiveState { pub topology: PrimitiveTopology, /// When drawing strip topologies with indices, this is the required format for the index buffer. /// This has no effect on non-indexed or non-strip draws. + /// + /// Specifying this value enables primitive restart, allowing individual strips to be separated + /// with the index value `0xFFFF` when using `Uint16`, or `0xFFFFFFFF` when using `Uint32`. #[cfg_attr(feature = "serde", serde(default))] pub strip_index_format: Option, /// The face to consider the front for the purpose of culling and stencil operations. @@ -4904,6 +4942,9 @@ pub enum VertexFormat { Float64x3 = 32, /// Four double-precision floats (f64). `vec4` in shaders. Requires [`Features::VERTEX_ATTRIBUTE_64BIT`]. Float64x4 = 33, + /// Three unsigned 10-bit integers and one 2-bit integer, packed into a 32-bit integer (u32). [0, 1024] converted to float [0, 1] `vec4` in shaders. + #[cfg_attr(feature = "serde", serde(rename = "unorm10-10-10-2"))] + Unorm10_10_10_2 = 34, } impl VertexFormat { @@ -4922,7 +4963,8 @@ impl VertexFormat { | Self::Float16x2 | Self::Float32 | Self::Uint32 - | Self::Sint32 => 4, + | Self::Sint32 + | Self::Unorm10_10_10_2 => 4, Self::Uint16x4 | Self::Sint16x4 | Self::Unorm16x4 @@ -7152,7 +7194,7 @@ mod send_sync { /// /// Corresponds to [WebGPU `GPUDeviceLostReason`](https://gpuweb.github.io/gpuweb/#enumdef-gpudevicelostreason). #[repr(u8)] -#[derive(Debug, Copy, Clone)] +#[derive(Debug, Copy, Clone, Eq, PartialEq)] pub enum DeviceLostReason { /// Triggered by driver Unknown = 0, @@ -7172,4 +7214,10 @@ pub enum DeviceLostReason { /// exactly once before it is dropped, which helps with managing the /// memory owned by the callback. ReplacedCallback = 3, + /// When setting the callback, but the device is already invalid + /// + /// As above, when the callback is provided, wgpu guarantees that it + /// will eventually be called. If the device is already invalid, wgpu + /// will call the callback immediately, with this reason. + DeviceInvalid = 4, } diff --git a/wgpu/Cargo.toml b/wgpu/Cargo.toml index e4d4795cb1..43605f1f41 100644 --- a/wgpu/Cargo.toml +++ b/wgpu/Cargo.toml @@ -194,124 +194,6 @@ web-sys = { workspace = true, features = [ "Navigator", "Node", "NodeList", - "Gpu", - "GpuAdapter", - "GpuAddressMode", - "GpuAutoLayoutMode", - "GpuBindGroup", - "GpuBindGroupDescriptor", - "GpuBindGroupEntry", - "GpuBindGroupLayout", - "GpuBindGroupLayoutDescriptor", - "GpuBindGroupLayoutEntry", - "GpuBlendComponent", - "GpuBlendFactor", - "GpuBlendOperation", - "GpuBlendState", - "GpuBuffer", - "GpuBufferBinding", - "GpuBufferBindingLayout", - "GpuBufferBindingType", - "GpuBufferDescriptor", - "GpuCanvasAlphaMode", - "GpuCanvasContext", - "GpuCanvasConfiguration", - "GpuColorDict", - "GpuColorTargetState", - "GpuCommandBuffer", - "GpuCommandBufferDescriptor", - "GpuCommandEncoder", - "GpuCommandEncoderDescriptor", - "GpuCompareFunction", - "GpuCompilationInfo", - "GpuCompilationMessage", - "GpuCompilationMessageType", - "GpuComputePassDescriptor", - "GpuComputePassEncoder", - "GpuComputePassTimestampWrites", - "GpuComputePipeline", - "GpuComputePipelineDescriptor", - "GpuCullMode", - "GpuDepthStencilState", - "GpuDevice", - "GpuDeviceDescriptor", - "GpuDeviceLostInfo", - "GpuDeviceLostReason", - "GpuError", - "GpuErrorFilter", - # "GpuExtent2dDict", Not yet implemented in web_sys - "GpuExtent3dDict", - "GpuFeatureName", - "GpuFilterMode", - "GpuFragmentState", - "GpuFrontFace", - "GpuImageCopyBuffer", - "GpuImageCopyExternalImage", - "GpuImageCopyTexture", - "GpuImageCopyTextureTagged", - "GpuImageDataLayout", - "GpuIndexFormat", - "GpuLoadOp", - "gpu_map_mode", - "GpuMipmapFilterMode", - "GpuMultisampleState", - "GpuObjectDescriptorBase", - "GpuOrigin2dDict", - "GpuOrigin3dDict", - "GpuOutOfMemoryError", - "GpuPipelineDescriptorBase", - "GpuPipelineLayout", - "GpuPipelineLayoutDescriptor", - "GpuPowerPreference", - "GpuPrimitiveState", - "GpuPrimitiveTopology", - "GpuProgrammableStage", - "GpuQuerySet", - "GpuQuerySetDescriptor", - "GpuQueryType", - "GpuQueue", - "GpuRenderBundle", - "GpuRenderBundleDescriptor", - "GpuRenderBundleEncoder", - "GpuRenderBundleEncoderDescriptor", - "GpuRenderPassColorAttachment", - "GpuRenderPassDepthStencilAttachment", - "GpuRenderPassDescriptor", - "GpuRenderPassEncoder", - "GpuRenderPipeline", - "GpuRenderPipelineDescriptor", - "GpuRequestAdapterOptions", - "GpuSampler", - "GpuSamplerBindingLayout", - "GpuSamplerBindingType", - "GpuSamplerDescriptor", - "GpuShaderModule", - "GpuShaderModuleDescriptor", - "GpuStencilFaceState", - "GpuStencilOperation", - "GpuStorageTextureAccess", - "GpuStorageTextureBindingLayout", - "GpuStoreOp", - "GpuSupportedFeatures", - "GpuSupportedLimits", - "GpuTexture", - "GpuTextureAspect", - "GpuTextureBindingLayout", - "GpuTextureDescriptor", - "GpuTextureDimension", - "GpuTextureFormat", - "GpuTextureSampleType", - "GpuTextureView", - "GpuTextureViewDescriptor", - "GpuTextureViewDimension", - "GpuUncapturedErrorEvent", - "GpuUncapturedErrorEventInit", - "GpuValidationError", - "GpuVertexAttribute", - "GpuVertexBufferLayout", - "GpuVertexFormat", - "GpuVertexState", - "GpuVertexStepMode", "HtmlCanvasElement", "OffscreenCanvas", "ImageBitmap", @@ -319,6 +201,9 @@ web-sys = { workspace = true, features = [ "Window", "WorkerGlobalScope", "WorkerNavigator", + # Needed by webgpu_sys + "Event", + "EventTarget", ] } wasm-bindgen.workspace = true js-sys.workspace = true diff --git a/wgpu/src/backend/mod.rs b/wgpu/src/backend/mod.rs index 9a0b7ef28a..7364eb3fd6 100644 --- a/wgpu/src/backend/mod.rs +++ b/wgpu/src/backend/mod.rs @@ -1,21 +1,8 @@ -#[cfg(all(webgpu, web_sys_unstable_apis))] +#[cfg(webgpu)] mod webgpu; -#[cfg(all(webgpu, web_sys_unstable_apis))] +#[cfg(webgpu)] pub(crate) use webgpu::{get_browser_gpu_property, ContextWebGpu}; -#[cfg(all(webgpu, not(web_sys_unstable_apis)))] -compile_error!( - "webgpu feature used without web_sys_unstable_apis config: -Here are some ways to resolve this: -* If you wish to use webgpu backend, create a .cargo/config.toml in the root of the repo containing: - [build] - rustflags = [ \"--cfg=web_sys_unstable_apis\" ] - rustdocflags = [ \"--cfg=web_sys_unstable_apis\" ] -* If you wish to disable webgpu backend and instead use webgl backend, change your wgpu Cargo.toml entry to: - wgpu = { version = \"\", default-features = false, features = [\"webgl\"] } -" -); - #[cfg(wgpu_core)] mod wgpu_core; diff --git a/wgpu/src/backend/webgpu.rs b/wgpu/src/backend/webgpu.rs index a855f6e479..7ecceaa956 100644 --- a/wgpu/src/backend/webgpu.rs +++ b/wgpu/src/backend/webgpu.rs @@ -1,5 +1,8 @@ #![allow(clippy::type_complexity)] +mod ext_bindings; +mod webgpu_sys; + use js_sys::Promise; use std::{ any::Any, @@ -69,7 +72,7 @@ unsafe impl Send for Identified {} #[cfg(send_sync)] unsafe impl Sync for Identified {} -pub(crate) struct ContextWebGpu(web_sys::Gpu); +pub(crate) struct ContextWebGpu(webgpu_sys::Gpu); #[cfg(send_sync)] unsafe impl Send for ContextWebGpu {} #[cfg(send_sync)] @@ -90,12 +93,12 @@ impl fmt::Debug for ContextWebGpu { impl crate::Error { fn from_js(js_error: js_sys::Object) -> Self { let source = Box::::from(""); - if let Some(js_error) = js_error.dyn_ref::() { + if let Some(js_error) = js_error.dyn_ref::() { crate::Error::Validation { source, description: js_error.message(), } - } else if js_error.has_type::() { + } else if js_error.has_type::() { crate::Error::OutOfMemory { source } } else { panic!("Unexpected error"); @@ -138,8 +141,8 @@ impl MakeSendFuture { #[cfg(send_sync)] unsafe impl Send for MakeSendFuture {} -fn map_texture_format(texture_format: wgt::TextureFormat) -> web_sys::GpuTextureFormat { - use web_sys::GpuTextureFormat as tf; +fn map_texture_format(texture_format: wgt::TextureFormat) -> webgpu_sys::GpuTextureFormat { + use webgpu_sys::GpuTextureFormat as tf; use wgt::TextureFormat; match texture_format { // 8-bit formats @@ -263,8 +266,8 @@ fn map_texture_format(texture_format: wgt::TextureFormat) -> web_sys::GpuTexture fn map_texture_component_type( sample_type: wgt::TextureSampleType, -) -> web_sys::GpuTextureSampleType { - use web_sys::GpuTextureSampleType as ts; +) -> webgpu_sys::GpuTextureSampleType { + use webgpu_sys::GpuTextureSampleType as ts; use wgt::TextureSampleType; match sample_type { TextureSampleType::Float { filterable: true } => ts::Float, @@ -275,8 +278,8 @@ fn map_texture_component_type( } } -fn map_cull_mode(cull_mode: Option) -> web_sys::GpuCullMode { - use web_sys::GpuCullMode as cm; +fn map_cull_mode(cull_mode: Option) -> webgpu_sys::GpuCullMode { + use webgpu_sys::GpuCullMode as cm; use wgt::Face; match cull_mode { None => cm::None, @@ -285,8 +288,8 @@ fn map_cull_mode(cull_mode: Option) -> web_sys::GpuCullMode { } } -fn map_front_face(front_face: wgt::FrontFace) -> web_sys::GpuFrontFace { - use web_sys::GpuFrontFace as ff; +fn map_front_face(front_face: wgt::FrontFace) -> webgpu_sys::GpuFrontFace { + use webgpu_sys::GpuFrontFace as ff; use wgt::FrontFace; match front_face { FrontFace::Ccw => ff::Ccw, @@ -294,11 +297,11 @@ fn map_front_face(front_face: wgt::FrontFace) -> web_sys::GpuFrontFace { } } -fn map_primitive_state(primitive: &wgt::PrimitiveState) -> web_sys::GpuPrimitiveState { - use web_sys::GpuPrimitiveTopology as pt; +fn map_primitive_state(primitive: &wgt::PrimitiveState) -> webgpu_sys::GpuPrimitiveState { + use webgpu_sys::GpuPrimitiveTopology as pt; use wgt::PrimitiveTopology; - let mut mapped = web_sys::GpuPrimitiveState::new(); + let mut mapped = webgpu_sys::GpuPrimitiveState::new(); mapped.cull_mode(map_cull_mode(primitive.cull_mode)); mapped.front_face(map_front_face(primitive.front_face)); @@ -332,8 +335,8 @@ fn map_primitive_state(primitive: &wgt::PrimitiveState) -> web_sys::GpuPrimitive mapped } -fn map_compare_function(compare_fn: wgt::CompareFunction) -> web_sys::GpuCompareFunction { - use web_sys::GpuCompareFunction as cf; +fn map_compare_function(compare_fn: wgt::CompareFunction) -> webgpu_sys::GpuCompareFunction { + use webgpu_sys::GpuCompareFunction as cf; use wgt::CompareFunction; match compare_fn { CompareFunction::Never => cf::Never, @@ -347,8 +350,8 @@ fn map_compare_function(compare_fn: wgt::CompareFunction) -> web_sys::GpuCompare } } -fn map_stencil_operation(op: wgt::StencilOperation) -> web_sys::GpuStencilOperation { - use web_sys::GpuStencilOperation as so; +fn map_stencil_operation(op: wgt::StencilOperation) -> webgpu_sys::GpuStencilOperation { + use webgpu_sys::GpuStencilOperation as so; use wgt::StencilOperation; match op { StencilOperation::Keep => so::Keep, @@ -362,8 +365,8 @@ fn map_stencil_operation(op: wgt::StencilOperation) -> web_sys::GpuStencilOperat } } -fn map_stencil_state_face(desc: &wgt::StencilFaceState) -> web_sys::GpuStencilFaceState { - let mut mapped = web_sys::GpuStencilFaceState::new(); +fn map_stencil_state_face(desc: &wgt::StencilFaceState) -> webgpu_sys::GpuStencilFaceState { + let mut mapped = webgpu_sys::GpuStencilFaceState::new(); mapped.compare(map_compare_function(desc.compare)); mapped.depth_fail_op(map_stencil_operation(desc.depth_fail_op)); mapped.fail_op(map_stencil_operation(desc.fail_op)); @@ -371,12 +374,10 @@ fn map_stencil_state_face(desc: &wgt::StencilFaceState) -> web_sys::GpuStencilFa mapped } -fn map_depth_stencil_state(desc: &wgt::DepthStencilState) -> web_sys::GpuDepthStencilState { - let mut mapped = web_sys::GpuDepthStencilState::new( - map_compare_function(desc.depth_compare), - desc.depth_write_enabled, - map_texture_format(desc.format), - ); +fn map_depth_stencil_state(desc: &wgt::DepthStencilState) -> webgpu_sys::GpuDepthStencilState { + let mut mapped = webgpu_sys::GpuDepthStencilState::new(map_texture_format(desc.format)); + mapped.depth_compare(map_compare_function(desc.depth_compare)); + mapped.depth_write_enabled(desc.depth_write_enabled); mapped.depth_bias(desc.bias.constant); mapped.depth_bias_clamp(desc.bias.clamp); mapped.depth_bias_slope_scale(desc.bias.slope_scale); @@ -387,16 +388,16 @@ fn map_depth_stencil_state(desc: &wgt::DepthStencilState) -> web_sys::GpuDepthSt mapped } -fn map_blend_component(desc: &wgt::BlendComponent) -> web_sys::GpuBlendComponent { - let mut mapped = web_sys::GpuBlendComponent::new(); +fn map_blend_component(desc: &wgt::BlendComponent) -> webgpu_sys::GpuBlendComponent { + let mut mapped = webgpu_sys::GpuBlendComponent::new(); mapped.dst_factor(map_blend_factor(desc.dst_factor)); mapped.operation(map_blend_operation(desc.operation)); mapped.src_factor(map_blend_factor(desc.src_factor)); mapped } -fn map_blend_factor(factor: wgt::BlendFactor) -> web_sys::GpuBlendFactor { - use web_sys::GpuBlendFactor as bf; +fn map_blend_factor(factor: wgt::BlendFactor) -> webgpu_sys::GpuBlendFactor { + use webgpu_sys::GpuBlendFactor as bf; use wgt::BlendFactor; match factor { BlendFactor::Zero => bf::Zero, @@ -424,8 +425,8 @@ fn map_blend_factor(factor: wgt::BlendFactor) -> web_sys::GpuBlendFactor { } } -fn map_blend_operation(op: wgt::BlendOperation) -> web_sys::GpuBlendOperation { - use web_sys::GpuBlendOperation as bo; +fn map_blend_operation(op: wgt::BlendOperation) -> webgpu_sys::GpuBlendOperation { + use webgpu_sys::GpuBlendOperation as bo; use wgt::BlendOperation; match op { BlendOperation::Add => bo::Add, @@ -436,8 +437,8 @@ fn map_blend_operation(op: wgt::BlendOperation) -> web_sys::GpuBlendOperation { } } -fn map_index_format(format: wgt::IndexFormat) -> web_sys::GpuIndexFormat { - use web_sys::GpuIndexFormat as f; +fn map_index_format(format: wgt::IndexFormat) -> webgpu_sys::GpuIndexFormat { + use webgpu_sys::GpuIndexFormat as f; use wgt::IndexFormat; match format { IndexFormat::Uint16 => f::Uint16, @@ -445,8 +446,8 @@ fn map_index_format(format: wgt::IndexFormat) -> web_sys::GpuIndexFormat { } } -fn map_vertex_format(format: wgt::VertexFormat) -> web_sys::GpuVertexFormat { - use web_sys::GpuVertexFormat as vf; +fn map_vertex_format(format: wgt::VertexFormat) -> webgpu_sys::GpuVertexFormat { + use webgpu_sys::GpuVertexFormat as vf; use wgt::VertexFormat; match format { VertexFormat::Uint8x2 => vf::Uint8x2, @@ -479,6 +480,7 @@ fn map_vertex_format(format: wgt::VertexFormat) -> web_sys::GpuVertexFormat { VertexFormat::Sint32x2 => vf::Sint32x2, VertexFormat::Sint32x3 => vf::Sint32x3, VertexFormat::Sint32x4 => vf::Sint32x4, + VertexFormat::Unorm10_10_10_2 => vf::Unorm1010102, VertexFormat::Float64 | VertexFormat::Float64x2 | VertexFormat::Float64x3 @@ -488,8 +490,8 @@ fn map_vertex_format(format: wgt::VertexFormat) -> web_sys::GpuVertexFormat { } } -fn map_vertex_step_mode(mode: wgt::VertexStepMode) -> web_sys::GpuVertexStepMode { - use web_sys::GpuVertexStepMode as sm; +fn map_vertex_step_mode(mode: wgt::VertexStepMode) -> webgpu_sys::GpuVertexStepMode { + use webgpu_sys::GpuVertexStepMode as sm; use wgt::VertexStepMode; match mode { VertexStepMode::Vertex => sm::Vertex, @@ -497,40 +499,42 @@ fn map_vertex_step_mode(mode: wgt::VertexStepMode) -> web_sys::GpuVertexStepMode } } -fn map_extent_3d(extent: wgt::Extent3d) -> web_sys::GpuExtent3dDict { - let mut mapped = web_sys::GpuExtent3dDict::new(extent.width); +fn map_extent_3d(extent: wgt::Extent3d) -> webgpu_sys::GpuExtent3dDict { + let mut mapped = webgpu_sys::GpuExtent3dDict::new(extent.width); mapped.height(extent.height); mapped.depth_or_array_layers(extent.depth_or_array_layers); mapped } -fn map_origin_2d(extent: wgt::Origin2d) -> web_sys::GpuOrigin2dDict { - let mut mapped = web_sys::GpuOrigin2dDict::new(); +fn map_origin_2d(extent: wgt::Origin2d) -> webgpu_sys::GpuOrigin2dDict { + let mut mapped = webgpu_sys::GpuOrigin2dDict::new(); mapped.x(extent.x); mapped.y(extent.y); mapped } -fn map_origin_3d(origin: wgt::Origin3d) -> web_sys::GpuOrigin3dDict { - let mut mapped = web_sys::GpuOrigin3dDict::new(); +fn map_origin_3d(origin: wgt::Origin3d) -> webgpu_sys::GpuOrigin3dDict { + let mut mapped = webgpu_sys::GpuOrigin3dDict::new(); mapped.x(origin.x); mapped.y(origin.y); mapped.z(origin.z); mapped } -fn map_texture_dimension(texture_dimension: wgt::TextureDimension) -> web_sys::GpuTextureDimension { +fn map_texture_dimension( + texture_dimension: wgt::TextureDimension, +) -> webgpu_sys::GpuTextureDimension { match texture_dimension { - wgt::TextureDimension::D1 => web_sys::GpuTextureDimension::N1d, - wgt::TextureDimension::D2 => web_sys::GpuTextureDimension::N2d, - wgt::TextureDimension::D3 => web_sys::GpuTextureDimension::N3d, + wgt::TextureDimension::D1 => webgpu_sys::GpuTextureDimension::N1d, + wgt::TextureDimension::D2 => webgpu_sys::GpuTextureDimension::N2d, + wgt::TextureDimension::D3 => webgpu_sys::GpuTextureDimension::N3d, } } fn map_texture_view_dimension( texture_view_dimension: wgt::TextureViewDimension, -) -> web_sys::GpuTextureViewDimension { - use web_sys::GpuTextureViewDimension as tvd; +) -> webgpu_sys::GpuTextureViewDimension { + use webgpu_sys::GpuTextureViewDimension as tvd; match texture_view_dimension { wgt::TextureViewDimension::D1 => tvd::N1d, wgt::TextureViewDimension::D2 => tvd::N2d, @@ -541,10 +545,10 @@ fn map_texture_view_dimension( } } -fn map_buffer_copy_view(view: crate::ImageCopyBuffer<'_>) -> web_sys::GpuImageCopyBuffer { +fn map_buffer_copy_view(view: crate::ImageCopyBuffer<'_>) -> webgpu_sys::GpuImageCopyBuffer { let buffer: &::BufferData = downcast_ref(view.buffer.data.as_ref()); - let mut mapped = web_sys::GpuImageCopyBuffer::new(&buffer.0.buffer); + let mut mapped = webgpu_sys::GpuImageCopyBuffer::new(&buffer.0.buffer); if let Some(bytes_per_row) = view.layout.bytes_per_row { mapped.bytes_per_row(bytes_per_row); } @@ -555,10 +559,10 @@ fn map_buffer_copy_view(view: crate::ImageCopyBuffer<'_>) -> web_sys::GpuImageCo mapped } -fn map_texture_copy_view(view: crate::ImageCopyTexture<'_>) -> web_sys::GpuImageCopyTexture { +fn map_texture_copy_view(view: crate::ImageCopyTexture<'_>) -> webgpu_sys::GpuImageCopyTexture { let texture: &::TextureData = downcast_ref(view.texture.data.as_ref()); - let mut mapped = web_sys::GpuImageCopyTexture::new(&texture.0); + let mut mapped = webgpu_sys::GpuImageCopyTexture::new(&texture.0); mapped.mip_level(view.mip_level); mapped.origin(&map_origin_3d(view.origin)); mapped @@ -566,10 +570,10 @@ fn map_texture_copy_view(view: crate::ImageCopyTexture<'_>) -> web_sys::GpuImage fn map_tagged_texture_copy_view( view: crate::ImageCopyTextureTagged<'_>, -) -> web_sys::GpuImageCopyTextureTagged { +) -> webgpu_sys::GpuImageCopyTextureTagged { let texture: &::TextureData = downcast_ref(view.texture.data.as_ref()); - let mut mapped = web_sys::GpuImageCopyTextureTagged::new(&texture.0); + let mut mapped = webgpu_sys::GpuImageCopyTextureTagged::new(&texture.0); mapped.mip_level(view.mip_level); mapped.origin(&map_origin_3d(view.origin)); mapped.aspect(map_texture_aspect(view.aspect)); @@ -580,114 +584,114 @@ fn map_tagged_texture_copy_view( fn map_external_texture_copy_view( view: &crate::ImageCopyExternalImage, -) -> web_sys::GpuImageCopyExternalImage { - let mut mapped = web_sys::GpuImageCopyExternalImage::new(&view.source); +) -> webgpu_sys::GpuImageCopyExternalImage { + let mut mapped = webgpu_sys::GpuImageCopyExternalImage::new(&view.source); mapped.origin(&map_origin_2d(view.origin)); mapped.flip_y(view.flip_y); mapped } -fn map_texture_aspect(aspect: wgt::TextureAspect) -> web_sys::GpuTextureAspect { +fn map_texture_aspect(aspect: wgt::TextureAspect) -> webgpu_sys::GpuTextureAspect { match aspect { - wgt::TextureAspect::All => web_sys::GpuTextureAspect::All, - wgt::TextureAspect::StencilOnly => web_sys::GpuTextureAspect::StencilOnly, - wgt::TextureAspect::DepthOnly => web_sys::GpuTextureAspect::DepthOnly, + wgt::TextureAspect::All => webgpu_sys::GpuTextureAspect::All, + wgt::TextureAspect::StencilOnly => webgpu_sys::GpuTextureAspect::StencilOnly, + wgt::TextureAspect::DepthOnly => webgpu_sys::GpuTextureAspect::DepthOnly, wgt::TextureAspect::Plane0 | wgt::TextureAspect::Plane1 | wgt::TextureAspect::Plane2 => { panic!("multi-plane textures are not supported") } } } -fn map_filter_mode(mode: wgt::FilterMode) -> web_sys::GpuFilterMode { +fn map_filter_mode(mode: wgt::FilterMode) -> webgpu_sys::GpuFilterMode { match mode { - wgt::FilterMode::Nearest => web_sys::GpuFilterMode::Nearest, - wgt::FilterMode::Linear => web_sys::GpuFilterMode::Linear, + wgt::FilterMode::Nearest => webgpu_sys::GpuFilterMode::Nearest, + wgt::FilterMode::Linear => webgpu_sys::GpuFilterMode::Linear, } } -fn map_mipmap_filter_mode(mode: wgt::FilterMode) -> web_sys::GpuMipmapFilterMode { +fn map_mipmap_filter_mode(mode: wgt::FilterMode) -> webgpu_sys::GpuMipmapFilterMode { match mode { - wgt::FilterMode::Nearest => web_sys::GpuMipmapFilterMode::Nearest, - wgt::FilterMode::Linear => web_sys::GpuMipmapFilterMode::Linear, + wgt::FilterMode::Nearest => webgpu_sys::GpuMipmapFilterMode::Nearest, + wgt::FilterMode::Linear => webgpu_sys::GpuMipmapFilterMode::Linear, } } -fn map_address_mode(mode: wgt::AddressMode) -> web_sys::GpuAddressMode { +fn map_address_mode(mode: wgt::AddressMode) -> webgpu_sys::GpuAddressMode { match mode { - wgt::AddressMode::ClampToEdge => web_sys::GpuAddressMode::ClampToEdge, - wgt::AddressMode::Repeat => web_sys::GpuAddressMode::Repeat, - wgt::AddressMode::MirrorRepeat => web_sys::GpuAddressMode::MirrorRepeat, + wgt::AddressMode::ClampToEdge => webgpu_sys::GpuAddressMode::ClampToEdge, + wgt::AddressMode::Repeat => webgpu_sys::GpuAddressMode::Repeat, + wgt::AddressMode::MirrorRepeat => webgpu_sys::GpuAddressMode::MirrorRepeat, wgt::AddressMode::ClampToBorder => panic!("Clamp to border is not supported"), } } -fn map_color(color: wgt::Color) -> web_sys::GpuColorDict { - web_sys::GpuColorDict::new(color.a, color.b, color.g, color.r) +fn map_color(color: wgt::Color) -> webgpu_sys::GpuColorDict { + webgpu_sys::GpuColorDict::new(color.a, color.b, color.g, color.r) } -fn map_store_op(store: crate::StoreOp) -> web_sys::GpuStoreOp { +fn map_store_op(store: crate::StoreOp) -> webgpu_sys::GpuStoreOp { match store { - crate::StoreOp::Store => web_sys::GpuStoreOp::Store, - crate::StoreOp::Discard => web_sys::GpuStoreOp::Discard, + crate::StoreOp::Store => webgpu_sys::GpuStoreOp::Store, + crate::StoreOp::Discard => webgpu_sys::GpuStoreOp::Discard, } } fn map_map_mode(mode: crate::MapMode) -> u32 { match mode { - crate::MapMode::Read => web_sys::gpu_map_mode::READ, - crate::MapMode::Write => web_sys::gpu_map_mode::WRITE, + crate::MapMode::Read => webgpu_sys::gpu_map_mode::READ, + crate::MapMode::Write => webgpu_sys::gpu_map_mode::WRITE, } } -const FEATURES_MAPPING: [(wgt::Features, web_sys::GpuFeatureName); 11] = [ +const FEATURES_MAPPING: [(wgt::Features, webgpu_sys::GpuFeatureName); 11] = [ //TODO: update the name ( wgt::Features::DEPTH_CLIP_CONTROL, - web_sys::GpuFeatureName::DepthClipControl, + webgpu_sys::GpuFeatureName::DepthClipControl, ), ( wgt::Features::DEPTH32FLOAT_STENCIL8, - web_sys::GpuFeatureName::Depth32floatStencil8, + webgpu_sys::GpuFeatureName::Depth32floatStencil8, ), ( wgt::Features::TEXTURE_COMPRESSION_BC, - web_sys::GpuFeatureName::TextureCompressionBc, + webgpu_sys::GpuFeatureName::TextureCompressionBc, ), ( wgt::Features::TEXTURE_COMPRESSION_ETC2, - web_sys::GpuFeatureName::TextureCompressionEtc2, + webgpu_sys::GpuFeatureName::TextureCompressionEtc2, ), ( wgt::Features::TEXTURE_COMPRESSION_ASTC, - web_sys::GpuFeatureName::TextureCompressionAstc, + webgpu_sys::GpuFeatureName::TextureCompressionAstc, ), ( wgt::Features::TIMESTAMP_QUERY, - web_sys::GpuFeatureName::TimestampQuery, + webgpu_sys::GpuFeatureName::TimestampQuery, ), ( wgt::Features::INDIRECT_FIRST_INSTANCE, - web_sys::GpuFeatureName::IndirectFirstInstance, + webgpu_sys::GpuFeatureName::IndirectFirstInstance, ), ( wgt::Features::SHADER_F16, - web_sys::GpuFeatureName::ShaderF16, + webgpu_sys::GpuFeatureName::ShaderF16, ), ( wgt::Features::RG11B10UFLOAT_RENDERABLE, - web_sys::GpuFeatureName::Rg11b10ufloatRenderable, + webgpu_sys::GpuFeatureName::Rg11b10ufloatRenderable, ), ( wgt::Features::BGRA8UNORM_STORAGE, - web_sys::GpuFeatureName::Bgra8unormStorage, + webgpu_sys::GpuFeatureName::Bgra8unormStorage, ), ( wgt::Features::FLOAT32_FILTERABLE, - web_sys::GpuFeatureName::Float32Filterable, + webgpu_sys::GpuFeatureName::Float32Filterable, ), ]; -fn map_wgt_features(supported_features: web_sys::GpuSupportedFeatures) -> wgt::Features { +fn map_wgt_features(supported_features: webgpu_sys::GpuSupportedFeatures) -> wgt::Features { let mut features = wgt::Features::empty(); for (wgpu_feat, web_feat) in FEATURES_MAPPING { match wasm_bindgen::JsValue::from(web_feat).as_string() { @@ -698,7 +702,7 @@ fn map_wgt_features(supported_features: web_sys::GpuSupportedFeatures) -> wgt::F features } -fn map_wgt_limits(limits: web_sys::GpuSupportedLimits) -> wgt::Limits { +fn map_wgt_limits(limits: webgpu_sys::GpuSupportedLimits) -> wgt::Limits { wgt::Limits { max_texture_dimension_1d: limits.max_texture_dimension_1d(), max_texture_dimension_2d: limits.max_texture_dimension_2d(), @@ -798,8 +802,8 @@ type JsFutureResult = Result; fn future_request_adapter( result: JsFutureResult, ) -> Option<( - Identified, - Sendable, + Identified, + Sendable, )> { match result.and_then(wasm_bindgen::JsCast::dyn_into) { Ok(adapter) => Some(create_identified(adapter)), @@ -811,16 +815,16 @@ fn future_request_device( result: JsFutureResult, ) -> Result< ( - Identified, - Sendable, - Identified, - Sendable, + Identified, + Sendable, + Identified, + Sendable, ), crate::RequestDeviceError, > { result .map(|js_value| { - let (device_id, device_data) = create_identified(web_sys::GpuDevice::from(js_value)); + let (device_id, device_data) = create_identified(webgpu_sys::GpuDevice::from(js_value)); let (queue_id, queue_data) = create_identified(device_data.0.queue()); (device_id, device_data, queue_id, queue_data) @@ -928,7 +932,7 @@ impl ContextWebGpu { // Not returning this error because it is a type error that shouldn't happen unless // the browser, JS builtin objects, or wasm bindings are misbehaving somehow. - let context: web_sys::GpuCanvasContext = context + let context: webgpu_sys::GpuCanvasContext = context .dyn_into() .expect("canvas context is not a GPUCanvasContext"); @@ -946,7 +950,7 @@ impl ContextWebGpu { } // Represents the global object in the JavaScript context. -// It can be cast to from `web_sys::global` and exposes two getters `window` and `worker` of which only one is defined depending on the caller's context. +// It can be cast to from `webgpu_sys::global` and exposes two getters `window` and `worker` of which only one is defined depending on the caller's context. // When called from the UI thread only `window` is defined whereas `worker` is only defined within a web worker context. // See: https://github.com/rustwasm/gloo/blob/2c9e776701ecb90c53e62dec1abd19c2b70e47c7/crates/timers/src/callback.rs#L8-L40 #[wasm_bindgen] @@ -973,66 +977,65 @@ pub enum Canvas { /// See: /// * /// * -pub fn get_browser_gpu_property() -> Option { +pub fn get_browser_gpu_property() -> Option { let global: Global = js_sys::global().unchecked_into(); if !global.window().is_undefined() { - Some(global.unchecked_into::().navigator().gpu()) + let navigator = global.unchecked_into::().navigator(); + Some(ext_bindings::NavigatorGpu::gpu(&navigator)) } else if !global.worker().is_undefined() { - Some( - global - .unchecked_into::() - .navigator() - .gpu(), - ) + let navigator = global + .unchecked_into::() + .navigator(); + Some(ext_bindings::NavigatorGpu::gpu(&navigator)) } else { None } } impl crate::context::Context for ContextWebGpu { - type AdapterId = Identified; - type AdapterData = Sendable; - type DeviceId = Identified; - type DeviceData = Sendable; - type QueueId = Identified; - type QueueData = Sendable; - type ShaderModuleId = Identified; - type ShaderModuleData = Sendable; - type BindGroupLayoutId = Identified; - type BindGroupLayoutData = Sendable; - type BindGroupId = Identified; - type BindGroupData = Sendable; - type TextureViewId = Identified; - type TextureViewData = Sendable; - type SamplerId = Identified; - type SamplerData = Sendable; + type AdapterId = Identified; + type AdapterData = Sendable; + type DeviceId = Identified; + type DeviceData = Sendable; + type QueueId = Identified; + type QueueData = Sendable; + type ShaderModuleId = Identified; + type ShaderModuleData = Sendable; + type BindGroupLayoutId = Identified; + type BindGroupLayoutData = Sendable; + type BindGroupId = Identified; + type BindGroupData = Sendable; + type TextureViewId = Identified; + type TextureViewData = Sendable; + type SamplerId = Identified; + type SamplerData = Sendable; type BufferId = Identified; type BufferData = Sendable; - type TextureId = Identified; - type TextureData = Sendable; - type QuerySetId = Identified; - type QuerySetData = Sendable; - type PipelineLayoutId = Identified; - type PipelineLayoutData = Sendable; - type RenderPipelineId = Identified; - type RenderPipelineData = Sendable; - type ComputePipelineId = Identified; - type ComputePipelineData = Sendable; - type CommandEncoderId = Identified; - type CommandEncoderData = Sendable; - type ComputePassId = Identified; - type ComputePassData = Sendable; - type RenderPassId = Identified; - type RenderPassData = Sendable; - type CommandBufferId = Identified; - type CommandBufferData = Sendable; - type RenderBundleEncoderId = Identified; - type RenderBundleEncoderData = Sendable; - type RenderBundleId = Identified; - type RenderBundleData = Sendable; - type SurfaceId = Identified<(Canvas, web_sys::GpuCanvasContext)>; - type SurfaceData = Sendable<(Canvas, web_sys::GpuCanvasContext)>; + type TextureId = Identified; + type TextureData = Sendable; + type QuerySetId = Identified; + type QuerySetData = Sendable; + type PipelineLayoutId = Identified; + type PipelineLayoutData = Sendable; + type RenderPipelineId = Identified; + type RenderPipelineData = Sendable; + type ComputePipelineId = Identified; + type ComputePipelineData = Sendable; + type CommandEncoderId = Identified; + type CommandEncoderData = Sendable; + type ComputePassId = Identified; + type ComputePassData = Sendable; + type RenderPassId = Identified; + type RenderPassData = Sendable; + type CommandBufferId = Identified; + type CommandBufferData = Sendable; + type RenderBundleEncoderId = Identified; + type RenderBundleEncoderData = Sendable; + type RenderBundleId = Identified; + type RenderBundleData = Sendable; + type SurfaceId = Identified<(Canvas, webgpu_sys::GpuCanvasContext)>; + type SurfaceData = Sendable<(Canvas, webgpu_sys::GpuCanvasContext)>; type SurfaceOutputDetail = SurfaceOutputDetail; type SubmissionIndex = Unused; @@ -1124,12 +1127,12 @@ impl crate::context::Context for ContextWebGpu { // It's not trivial, since we need the Future logic to have this check, // and currently the Future here has no room for extra parameter `backends`. //assert!(backends.contains(wgt::Backends::BROWSER_WEBGPU)); - let mut mapped_options = web_sys::GpuRequestAdapterOptions::new(); + let mut mapped_options = webgpu_sys::GpuRequestAdapterOptions::new(); let mapped_power_preference = match options.power_preference { wgt::PowerPreference::None => None, - wgt::PowerPreference::LowPower => Some(web_sys::GpuPowerPreference::LowPower), + wgt::PowerPreference::LowPower => Some(webgpu_sys::GpuPowerPreference::LowPower), wgt::PowerPreference::HighPerformance => { - Some(web_sys::GpuPowerPreference::HighPerformance) + Some(webgpu_sys::GpuPowerPreference::HighPerformance) } }; if let Some(mapped_pref) = mapped_power_preference { @@ -1154,7 +1157,7 @@ impl crate::context::Context for ContextWebGpu { //Error: Tracing isn't supported on the Web target } - let mut mapped_desc = web_sys::GpuDeviceDescriptor::new(); + let mut mapped_desc = webgpu_sys::GpuDeviceDescriptor::new(); // TODO: Migrate to a web_sys api. // See https://github.com/rustwasm/wasm-bindgen/issues/3587 @@ -1325,11 +1328,13 @@ impl crate::context::Context for ContextWebGpu { panic!("Only Opaque/Auto or PreMultiplied alpha mode are supported on web"); } let alpha_mode = match config.alpha_mode { - wgt::CompositeAlphaMode::PreMultiplied => web_sys::GpuCanvasAlphaMode::Premultiplied, - _ => web_sys::GpuCanvasAlphaMode::Opaque, + wgt::CompositeAlphaMode::PreMultiplied => webgpu_sys::GpuCanvasAlphaMode::Premultiplied, + _ => webgpu_sys::GpuCanvasAlphaMode::Opaque, }; - let mut mapped = - web_sys::GpuCanvasConfiguration::new(&device_data.0, map_texture_format(config.format)); + let mut mapped = webgpu_sys::GpuCanvasConfiguration::new( + &device_data.0, + map_texture_format(config.format), + ); mapped.usage(config.usage.bits()); mapped.alpha_mode(alpha_mode); let mapped_view_formats = config @@ -1413,7 +1418,7 @@ impl crate::context::Context for ContextWebGpu { desc: crate::ShaderModuleDescriptor<'_>, _shader_bound_checks: wgt::ShaderBoundChecks, ) -> (Self::ShaderModuleId, Self::ShaderModuleData) { - let mut descriptor: web_sys::GpuShaderModuleDescriptor = match desc.source { + let mut descriptor: webgpu_sys::GpuShaderModuleDescriptor = match desc.source { #[cfg(feature = "spirv")] crate::ShaderSource::SpirV(ref spv) => { use naga::{back, front, valid}; @@ -1435,7 +1440,7 @@ impl crate::context::Context for ContextWebGpu { let writer_flags = naga::back::wgsl::WriterFlags::empty(); let wgsl_text = back::wgsl::write_string(&spv_module, &spv_module_info, writer_flags).unwrap(); - web_sys::GpuShaderModuleDescriptor::new(wgsl_text.as_str()) + webgpu_sys::GpuShaderModuleDescriptor::new(wgsl_text.as_str()) } #[cfg(feature = "glsl")] crate::ShaderSource::Glsl { @@ -1463,10 +1468,10 @@ impl crate::context::Context for ContextWebGpu { let wgsl_text = back::wgsl::write_string(&glsl_module, &glsl_module_info, writer_flags) .unwrap(); - web_sys::GpuShaderModuleDescriptor::new(wgsl_text.as_str()) + webgpu_sys::GpuShaderModuleDescriptor::new(wgsl_text.as_str()) } #[cfg(feature = "wgsl")] - crate::ShaderSource::Wgsl(ref code) => web_sys::GpuShaderModuleDescriptor::new(code), + crate::ShaderSource::Wgsl(ref code) => webgpu_sys::GpuShaderModuleDescriptor::new(code), #[cfg(feature = "naga-ir")] crate::ShaderSource::Naga(module) => { use naga::{back, valid}; @@ -1480,7 +1485,7 @@ impl crate::context::Context for ContextWebGpu { let writer_flags = naga::back::wgsl::WriterFlags::empty(); let wgsl_text = back::wgsl::write_string(&module, &module_info, writer_flags).unwrap(); - web_sys::GpuShaderModuleDescriptor::new(wgsl_text.as_str()) + webgpu_sys::GpuShaderModuleDescriptor::new(wgsl_text.as_str()) } crate::ShaderSource::Dummy(_) => { panic!("found `ShaderSource::Dummy`") @@ -1512,7 +1517,7 @@ impl crate::context::Context for ContextWebGpu { .iter() .map(|bind| { let mut mapped_entry = - web_sys::GpuBindGroupLayoutEntry::new(bind.binding, bind.visibility.bits()); + webgpu_sys::GpuBindGroupLayoutEntry::new(bind.binding, bind.visibility.bits()); match bind.ty { wgt::BindingType::Buffer { @@ -1520,35 +1525,35 @@ impl crate::context::Context for ContextWebGpu { has_dynamic_offset, min_binding_size, } => { - let mut buffer = web_sys::GpuBufferBindingLayout::new(); + let mut buffer = webgpu_sys::GpuBufferBindingLayout::new(); buffer.has_dynamic_offset(has_dynamic_offset); if let Some(size) = min_binding_size { buffer.min_binding_size(size.get() as f64); } buffer.type_(match ty { wgt::BufferBindingType::Uniform => { - web_sys::GpuBufferBindingType::Uniform + webgpu_sys::GpuBufferBindingType::Uniform } wgt::BufferBindingType::Storage { read_only: false } => { - web_sys::GpuBufferBindingType::Storage + webgpu_sys::GpuBufferBindingType::Storage } wgt::BufferBindingType::Storage { read_only: true } => { - web_sys::GpuBufferBindingType::ReadOnlyStorage + webgpu_sys::GpuBufferBindingType::ReadOnlyStorage } }); mapped_entry.buffer(&buffer); } wgt::BindingType::Sampler(ty) => { - let mut sampler = web_sys::GpuSamplerBindingLayout::new(); + let mut sampler = webgpu_sys::GpuSamplerBindingLayout::new(); sampler.type_(match ty { wgt::SamplerBindingType::NonFiltering => { - web_sys::GpuSamplerBindingType::NonFiltering + webgpu_sys::GpuSamplerBindingType::NonFiltering } wgt::SamplerBindingType::Filtering => { - web_sys::GpuSamplerBindingType::Filtering + webgpu_sys::GpuSamplerBindingType::Filtering } wgt::SamplerBindingType::Comparison => { - web_sys::GpuSamplerBindingType::Comparison + webgpu_sys::GpuSamplerBindingType::Comparison } }); mapped_entry.sampler(&sampler); @@ -1558,7 +1563,7 @@ impl crate::context::Context for ContextWebGpu { sample_type, view_dimension, } => { - let mut texture = web_sys::GpuTextureBindingLayout::new(); + let mut texture = webgpu_sys::GpuTextureBindingLayout::new(); texture.multisampled(multisampled); texture.sample_type(map_texture_component_type(sample_type)); texture.view_dimension(map_texture_view_dimension(view_dimension)); @@ -1571,16 +1576,16 @@ impl crate::context::Context for ContextWebGpu { } => { let mapped_access = match access { wgt::StorageTextureAccess::WriteOnly => { - web_sys::GpuStorageTextureAccess::WriteOnly + webgpu_sys::GpuStorageTextureAccess::WriteOnly } wgt::StorageTextureAccess::ReadOnly => { - panic!("ReadOnly is not available") + webgpu_sys::GpuStorageTextureAccess::ReadOnly } wgt::StorageTextureAccess::ReadWrite => { - panic!("ReadWrite is not available") + webgpu_sys::GpuStorageTextureAccess::ReadWrite } }; - let mut storage_texture = web_sys::GpuStorageTextureBindingLayout::new( + let mut storage_texture = webgpu_sys::GpuStorageTextureBindingLayout::new( map_texture_format(format), ); storage_texture.access(mapped_access); @@ -1594,7 +1599,7 @@ impl crate::context::Context for ContextWebGpu { }) .collect::(); - let mut mapped_desc = web_sys::GpuBindGroupLayoutDescriptor::new(&mapped_bindings); + let mut mapped_desc = webgpu_sys::GpuBindGroupLayoutDescriptor::new(&mapped_bindings); if let Some(label) = desc.label { mapped_desc.label(label); } @@ -1620,7 +1625,7 @@ impl crate::context::Context for ContextWebGpu { let buffer: &::BufferData = downcast_ref(buffer.data.as_ref()); let mut mapped_buffer_binding = - web_sys::GpuBufferBinding::new(&buffer.0.buffer); + webgpu_sys::GpuBufferBinding::new(&buffer.0.buffer); mapped_buffer_binding.offset(offset as f64); if let Some(s) = size { mapped_buffer_binding.size(s.get() as f64); @@ -1648,13 +1653,13 @@ impl crate::context::Context for ContextWebGpu { } }; - web_sys::GpuBindGroupEntry::new(binding.binding, &mapped_resource) + webgpu_sys::GpuBindGroupEntry::new(binding.binding, &mapped_resource) }) .collect::(); let bgl: &::BindGroupLayoutData = downcast_ref(desc.layout.data.as_ref()); - let mut mapped_desc = web_sys::GpuBindGroupDescriptor::new(&mapped_entries, &bgl.0); + let mut mapped_desc = webgpu_sys::GpuBindGroupDescriptor::new(&mapped_entries, &bgl.0); if let Some(label) = desc.label { mapped_desc.label(label); } @@ -1676,7 +1681,7 @@ impl crate::context::Context for ContextWebGpu { &bgl.0 }) .collect::(); - let mut mapped_desc = web_sys::GpuPipelineLayoutDescriptor::new(&temp_layouts); + let mut mapped_desc = webgpu_sys::GpuPipelineLayoutDescriptor::new(&temp_layouts); if let Some(label) = desc.label { mapped_desc.label(label); } @@ -1691,8 +1696,8 @@ impl crate::context::Context for ContextWebGpu { ) -> (Self::RenderPipelineId, Self::RenderPipelineData) { let module: &::ShaderModuleData = downcast_ref(desc.vertex.module.data.as_ref()); - let mut mapped_vertex_state = - web_sys::GpuVertexState::new(desc.vertex.entry_point, &module.0); + let mut mapped_vertex_state = webgpu_sys::GpuVertexState::new(&module.0); + mapped_vertex_state.entry_point(desc.vertex.entry_point); let buffers = desc .vertex @@ -1703,7 +1708,7 @@ impl crate::context::Context for ContextWebGpu { .attributes .iter() .map(|attr| { - web_sys::GpuVertexAttribute::new( + webgpu_sys::GpuVertexAttribute::new( map_vertex_format(attr.format), attr.offset as f64, attr.shader_location, @@ -1711,7 +1716,7 @@ impl crate::context::Context for ContextWebGpu { }) .collect::(); - let mut mapped_vbuf = web_sys::GpuVertexBufferLayout::new( + let mut mapped_vbuf = webgpu_sys::GpuVertexBufferLayout::new( vbuf.array_stride as f64, &mapped_attributes, ); @@ -1722,8 +1727,8 @@ impl crate::context::Context for ContextWebGpu { mapped_vertex_state.buffers(&buffers); - let auto_layout = wasm_bindgen::JsValue::from(web_sys::GpuAutoLayoutMode::Auto); - let mut mapped_desc = web_sys::GpuRenderPipelineDescriptor::new( + let auto_layout = wasm_bindgen::JsValue::from(webgpu_sys::GpuAutoLayoutMode::Auto); + let mut mapped_desc = webgpu_sys::GpuRenderPipelineDescriptor::new( &match desc.layout { Some(layout) => { let layout: &::PipelineLayoutData = @@ -1751,11 +1756,11 @@ impl crate::context::Context for ContextWebGpu { Some(target) => { let mapped_format = map_texture_format(target.format); let mut mapped_color_state = - web_sys::GpuColorTargetState::new(mapped_format); + webgpu_sys::GpuColorTargetState::new(mapped_format); if let Some(ref bs) = target.blend { let alpha = map_blend_component(&bs.alpha); let color = map_blend_component(&bs.color); - let mapped_blend_state = web_sys::GpuBlendState::new(&alpha, &color); + let mapped_blend_state = webgpu_sys::GpuBlendState::new(&alpha, &color); mapped_color_state.blend(&mapped_blend_state); } mapped_color_state.write_mask(target.write_mask.bits()); @@ -1766,12 +1771,12 @@ impl crate::context::Context for ContextWebGpu { .collect::(); let module: &::ShaderModuleData = downcast_ref(frag.module.data.as_ref()); - let mapped_fragment_desc = - web_sys::GpuFragmentState::new(frag.entry_point, &module.0, &targets); + let mut mapped_fragment_desc = webgpu_sys::GpuFragmentState::new(&module.0, &targets); + mapped_fragment_desc.entry_point(frag.entry_point); mapped_desc.fragment(&mapped_fragment_desc); } - let mut mapped_multisample = web_sys::GpuMultisampleState::new(); + let mut mapped_multisample = webgpu_sys::GpuMultisampleState::new(); mapped_multisample.count(desc.multisample.count); mapped_multisample.mask(desc.multisample.mask as u32); mapped_multisample.alpha_to_coverage_enabled(desc.multisample.alpha_to_coverage_enabled); @@ -1791,10 +1796,10 @@ impl crate::context::Context for ContextWebGpu { ) -> (Self::ComputePipelineId, Self::ComputePipelineData) { let shader_module: &::ShaderModuleData = downcast_ref(desc.module.data.as_ref()); - let mapped_compute_stage = - web_sys::GpuProgrammableStage::new(desc.entry_point, &shader_module.0); - let auto_layout = wasm_bindgen::JsValue::from(web_sys::GpuAutoLayoutMode::Auto); - let mut mapped_desc = web_sys::GpuComputePipelineDescriptor::new( + let mut mapped_compute_stage = webgpu_sys::GpuProgrammableStage::new(&shader_module.0); + mapped_compute_stage.entry_point(desc.entry_point); + let auto_layout = wasm_bindgen::JsValue::from(webgpu_sys::GpuAutoLayoutMode::Auto); + let mut mapped_desc = webgpu_sys::GpuComputePipelineDescriptor::new( &match desc.layout { Some(layout) => { let layout: &::PipelineLayoutData = @@ -1818,7 +1823,7 @@ impl crate::context::Context for ContextWebGpu { desc: &crate::BufferDescriptor<'_>, ) -> (Self::BufferId, Self::BufferData) { let mut mapped_desc = - web_sys::GpuBufferDescriptor::new(desc.size as f64, desc.usage.bits()); + webgpu_sys::GpuBufferDescriptor::new(desc.size as f64, desc.usage.bits()); mapped_desc.mapped_at_creation(desc.mapped_at_creation); if let Some(label) = desc.label { mapped_desc.label(label); @@ -1835,7 +1840,7 @@ impl crate::context::Context for ContextWebGpu { device_data: &Self::DeviceData, desc: &crate::TextureDescriptor<'_>, ) -> (Self::TextureId, Self::TextureData) { - let mut mapped_desc = web_sys::GpuTextureDescriptor::new( + let mut mapped_desc = webgpu_sys::GpuTextureDescriptor::new( map_texture_format(desc.format), &map_extent_3d(desc.size), desc.usage.bits(), @@ -1861,7 +1866,7 @@ impl crate::context::Context for ContextWebGpu { device_data: &Self::DeviceData, desc: &crate::SamplerDescriptor<'_>, ) -> (Self::SamplerId, Self::SamplerData) { - let mut mapped_desc = web_sys::GpuSamplerDescriptor::new(); + let mut mapped_desc = webgpu_sys::GpuSamplerDescriptor::new(); mapped_desc.address_mode_u(map_address_mode(desc.address_mode_u)); mapped_desc.address_mode_v(map_address_mode(desc.address_mode_v)); mapped_desc.address_mode_w(map_address_mode(desc.address_mode_w)); @@ -1888,11 +1893,11 @@ impl crate::context::Context for ContextWebGpu { desc: &wgt::QuerySetDescriptor>, ) -> (Self::QuerySetId, Self::QuerySetData) { let ty = match desc.ty { - wgt::QueryType::Occlusion => web_sys::GpuQueryType::Occlusion, - wgt::QueryType::Timestamp => web_sys::GpuQueryType::Timestamp, + wgt::QueryType::Occlusion => webgpu_sys::GpuQueryType::Occlusion, + wgt::QueryType::Timestamp => webgpu_sys::GpuQueryType::Timestamp, wgt::QueryType::PipelineStatistics(_) => unreachable!(), }; - let mut mapped_desc = web_sys::GpuQuerySetDescriptor::new(desc.count, ty); + let mut mapped_desc = webgpu_sys::GpuQuerySetDescriptor::new(desc.count, ty); if let Some(label) = desc.label { mapped_desc.label(label); } @@ -1905,7 +1910,7 @@ impl crate::context::Context for ContextWebGpu { device_data: &Self::DeviceData, desc: &crate::CommandEncoderDescriptor<'_>, ) -> (Self::CommandEncoderId, Self::CommandEncoderData) { - let mut mapped_desc = web_sys::GpuCommandEncoderDescriptor::new(); + let mut mapped_desc = webgpu_sys::GpuCommandEncoderDescriptor::new(); if let Some(label) = desc.label { mapped_desc.label(label); } @@ -1930,7 +1935,8 @@ impl crate::context::Context for ContextWebGpu { None => wasm_bindgen::JsValue::null(), }) .collect::(); - let mut mapped_desc = web_sys::GpuRenderBundleEncoderDescriptor::new(&mapped_color_formats); + let mut mapped_desc = + webgpu_sys::GpuRenderBundleEncoderDescriptor::new(&mapped_color_formats); if let Some(label) = desc.label { mapped_desc.label(label); } @@ -1943,6 +1949,11 @@ impl crate::context::Context for ContextWebGpu { create_identified(device_data.0.create_render_bundle_encoder(&mapped_desc)) } + #[doc(hidden)] + fn device_make_invalid(&self, _device: &Self::DeviceId, _device_data: &Self::DeviceData) { + // Unimplemented + } + fn device_drop(&self, _device: &Self::DeviceId, _device_data: &Self::DeviceData) { // Device is dropped automatically } @@ -1969,10 +1980,23 @@ impl crate::context::Context for ContextWebGpu { fn device_set_device_lost_callback( &self, _device: &Self::DeviceId, - _device_data: &Self::DeviceData, - _device_lost_callback: crate::context::DeviceLostCallback, - ) { - unimplemented!(); + device_data: &Self::DeviceData, + device_lost_callback: crate::context::DeviceLostCallback, + ) { + use webgpu_sys::{GpuDeviceLostInfo, GpuDeviceLostReason}; + + let closure = Closure::once(move |info: JsValue| { + let info = info.dyn_into::().unwrap(); + device_lost_callback( + match info.reason() { + GpuDeviceLostReason::Destroyed => crate::DeviceLostReason::Destroyed, + GpuDeviceLostReason::Unknown => crate::DeviceLostReason::Unknown, + _ => crate::DeviceLostReason::Unknown, + }, + info.message(), + ); + }); + let _ = device_data.0.lost().then(&closure); } fn device_poll( @@ -1991,7 +2015,7 @@ impl crate::context::Context for ContextWebGpu { device_data: &Self::DeviceData, handler: Box, ) { - let f = Closure::wrap(Box::new(move |event: web_sys::GpuUncapturedErrorEvent| { + let f = Closure::wrap(Box::new(move |event: webgpu_sys::GpuUncapturedErrorEvent| { let error = crate::Error::from_js(event.error().value_of()); handler(error); }) as Box); @@ -2009,9 +2033,9 @@ impl crate::context::Context for ContextWebGpu { filter: crate::ErrorFilter, ) { device_data.0.push_error_scope(match filter { - crate::ErrorFilter::OutOfMemory => web_sys::GpuErrorFilter::OutOfMemory, - crate::ErrorFilter::Validation => web_sys::GpuErrorFilter::Validation, - crate::ErrorFilter::Internal => web_sys::GpuErrorFilter::Internal, + crate::ErrorFilter::OutOfMemory => webgpu_sys::GpuErrorFilter::OutOfMemory, + crate::ErrorFilter::Validation => webgpu_sys::GpuErrorFilter::Validation, + crate::ErrorFilter::Internal => webgpu_sys::GpuErrorFilter::Internal, }); } @@ -2071,7 +2095,7 @@ impl crate::context::Context for ContextWebGpu { texture_data: &Self::TextureData, desc: &crate::TextureViewDescriptor<'_>, ) -> (Self::TextureViewId, Self::TextureViewData) { - let mut mapped = web_sys::GpuTextureViewDescriptor::new(); + let mut mapped = webgpu_sys::GpuTextureViewDescriptor::new(); if let Some(dim) = desc.dimension { mapped.dimension(map_texture_view_dimension(dim)); } @@ -2303,7 +2327,7 @@ impl crate::context::Context for ContextWebGpu { encoder_data: &Self::CommandEncoderData, desc: &crate::ComputePassDescriptor<'_>, ) -> (Self::ComputePassId, Self::ComputePassData) { - let mut mapped_desc = web_sys::GpuComputePassDescriptor::new(); + let mut mapped_desc = webgpu_sys::GpuComputePassDescriptor::new(); if let Some(label) = desc.label { mapped_desc.label(label); } @@ -2339,15 +2363,15 @@ impl crate::context::Context for ContextWebGpu { let load_value = match ca.ops.load { crate::LoadOp::Clear(color) => { clear_value = Some(wasm_bindgen::JsValue::from(map_color(color))); - web_sys::GpuLoadOp::Clear + webgpu_sys::GpuLoadOp::Clear } - crate::LoadOp::Load => web_sys::GpuLoadOp::Load, + crate::LoadOp::Load => webgpu_sys::GpuLoadOp::Load, }; let view: &::TextureViewData = downcast_ref(ca.view.data.as_ref()); - let mut mapped_color_attachment = web_sys::GpuRenderPassColorAttachment::new( + let mut mapped_color_attachment = webgpu_sys::GpuRenderPassColorAttachment::new( load_value, map_store_op(ca.ops.store), &view.0, @@ -2368,7 +2392,7 @@ impl crate::context::Context for ContextWebGpu { }) .collect::(); - let mut mapped_desc = web_sys::GpuRenderPassDescriptor::new(&mapped_color_attachments); + let mut mapped_desc = webgpu_sys::GpuRenderPassDescriptor::new(&mapped_color_attachments); if let Some(label) = desc.label { mapped_desc.label(label); @@ -2378,14 +2402,14 @@ impl crate::context::Context for ContextWebGpu { let depth_stencil_attachment: &::TextureViewData = downcast_ref(dsa.view.data.as_ref()); let mut mapped_depth_stencil_attachment = - web_sys::GpuRenderPassDepthStencilAttachment::new(&depth_stencil_attachment.0); + webgpu_sys::GpuRenderPassDepthStencilAttachment::new(&depth_stencil_attachment.0); if let Some(ref ops) = dsa.depth_ops { let load_op = match ops.load { crate::LoadOp::Clear(v) => { mapped_depth_stencil_attachment.depth_clear_value(v); - web_sys::GpuLoadOp::Clear + webgpu_sys::GpuLoadOp::Clear } - crate::LoadOp::Load => web_sys::GpuLoadOp::Load, + crate::LoadOp::Load => webgpu_sys::GpuLoadOp::Load, }; mapped_depth_stencil_attachment.depth_load_op(load_op); mapped_depth_stencil_attachment.depth_store_op(map_store_op(ops.store)); @@ -2395,9 +2419,9 @@ impl crate::context::Context for ContextWebGpu { let load_op = match ops.load { crate::LoadOp::Clear(v) => { mapped_depth_stencil_attachment.stencil_clear_value(v); - web_sys::GpuLoadOp::Clear + webgpu_sys::GpuLoadOp::Clear } - crate::LoadOp::Load => web_sys::GpuLoadOp::Load, + crate::LoadOp::Load => webgpu_sys::GpuLoadOp::Load, }; mapped_depth_stencil_attachment.stencil_load_op(load_op); mapped_depth_stencil_attachment.stencil_store_op(map_store_op(ops.store)); @@ -2428,7 +2452,7 @@ impl crate::context::Context for ContextWebGpu { create_identified(if label.is_empty() { encoder_data.0.finish() } else { - let mut mapped_desc = web_sys::GpuCommandBufferDescriptor::new(); + let mut mapped_desc = webgpu_sys::GpuCommandBufferDescriptor::new(); mapped_desc.label(&label); encoder_data.0.finish_with_descriptor(&mapped_desc) }) @@ -2498,14 +2522,14 @@ impl crate::context::Context for ContextWebGpu { fn command_encoder_write_timestamp( &self, _encoder: &Self::CommandEncoderId, - encoder_data: &Self::CommandEncoderData, + _encoder_data: &Self::CommandEncoderData, _query_set: &Self::QuerySetId, - query_set_data: &Self::QuerySetData, - query_index: u32, + _query_set_data: &Self::QuerySetData, + _query_index: u32, ) { - encoder_data - .0 - .write_timestamp(&query_set_data.0, query_index); + // Not available on WebGPU. + // This was part of the spec originally but got removed, see https://github.com/gpuweb/gpuweb/pull/4370 + panic!("TIMESTAMP_QUERY_INSIDE_ENCODERS feature must be enabled to call write_timestamp on a command encoder.") } fn command_encoder_resolve_query_set( @@ -2537,7 +2561,7 @@ impl crate::context::Context for ContextWebGpu { ) -> (Self::RenderBundleId, Self::RenderBundleData) { create_identified(match desc.label { Some(label) => { - let mut mapped_desc = web_sys::GpuRenderBundleDescriptor::new(); + let mut mapped_desc = webgpu_sys::GpuRenderBundleDescriptor::new(); mapped_desc.label(label); encoder_data.0.finish_with_descriptor(&mapped_desc) } @@ -2655,7 +2679,7 @@ impl crate::context::Context for ContextWebGpu { data_layout: wgt::ImageDataLayout, size: wgt::Extent3d, ) { - let mut mapped_data_layout = web_sys::GpuImageDataLayout::new(); + let mut mapped_data_layout = webgpu_sys::GpuImageDataLayout::new(); if let Some(bytes_per_row) = data_layout.bytes_per_row { mapped_data_layout.bytes_per_row(bytes_per_row); } @@ -2816,7 +2840,7 @@ impl crate::context::Context for ContextWebGpu { _query_set_data: &Self::QuerySetData, _query_index: u32, ) { - panic!("TIMESTAMP_QUERY_INSIDE_PASSES feature must be enabled to call write_timestamp in a compute pass") + panic!("TIMESTAMP_QUERY_INSIDE_PASSES feature must be enabled to call write_timestamp in a compute pass.") } fn compute_pass_begin_pipeline_statistics_query( @@ -3394,7 +3418,7 @@ impl crate::context::Context for ContextWebGpu { _query_set_data: &Self::QuerySetData, _query_index: u32, ) { - panic!("TIMESTAMP_QUERY_INSIDE_PASSES feature must be enabled to call write_timestamp in a compute pass") + panic!("TIMESTAMP_QUERY_INSIDE_PASSES feature must be enabled to call write_timestamp in a render pass.") } fn render_pass_begin_occlusion_query( @@ -3467,20 +3491,20 @@ impl QueueWriteBuffer for WebQueueWriteBuffer { } /// Stores the state of a GPU buffer and a reference to its mapped `ArrayBuffer` (if any). -/// The WebGPU specification forbids calling `getMappedRange` on a `web_sys::GpuBuffer` more than +/// The WebGPU specification forbids calling `getMappedRange` on a `webgpu_sys::GpuBuffer` more than /// once, so this struct stores the initial mapped range and re-uses it, allowing for multiple `get_mapped_range` /// calls on the Rust-side. #[derive(Debug)] pub struct WebBuffer { /// The associated GPU buffer. - buffer: web_sys::GpuBuffer, + buffer: webgpu_sys::GpuBuffer, /// The mapped array buffer and mapped range. mapping: RefCell, } impl WebBuffer { /// Creates a new web buffer for the given Javascript object and description. - fn new(buffer: web_sys::GpuBuffer, desc: &crate::BufferDescriptor<'_>) -> Self { + fn new(buffer: webgpu_sys::GpuBuffer, desc: &crate::BufferDescriptor<'_>) -> Self { Self { buffer, mapping: RefCell::new(WebBufferMapState { diff --git a/wgpu/src/backend/webgpu/ext_bindings.rs b/wgpu/src/backend/webgpu/ext_bindings.rs new file mode 100644 index 0000000000..218caf75cd --- /dev/null +++ b/wgpu/src/backend/webgpu/ext_bindings.rs @@ -0,0 +1,45 @@ +//! Extension bindings for WebGPU. +//! +//! These contain ideomatic Rust extension traits for various parts of the WebGPU +//! bindings that are missing, need to be improved, or otherwise need to be different +//! from the generated web_sys bindings. + +use crate::backend::webgpu::webgpu_sys; +use wasm_bindgen::prelude::*; + +/// Extension trait for [`web_sys::Navigator`] and [`web_sys::WorkerNavigator`] to +/// access the `gpu` property. +pub trait NavigatorGpu { + /// Get the `gpu` property. + /// + /// This is intentionally a free function, to prevent overload conflicts with + /// the method if it is enabled in web-sys itself. + fn gpu(navigator: &Self) -> webgpu_sys::Gpu; +} + +// --- Bindings for `Navigator` --- +#[wasm_bindgen] +extern "C" { + /// Create a fake class which we tell wasm-bindgen has access to the `gpu` property. + #[wasm_bindgen] + type NavigatorWithGpu; + + #[wasm_bindgen(method, getter)] + fn gpu(ext: &NavigatorWithGpu) -> webgpu_sys::Gpu; +} + +impl NavigatorGpu for web_sys::Navigator { + fn gpu(navigator: &Self) -> webgpu_sys::Gpu { + // Must be an unchecked ref as this class does not exist at runtime. + let extension: &NavigatorWithGpu = navigator.unchecked_ref(); + extension.gpu() + } +} + +impl NavigatorGpu for web_sys::WorkerNavigator { + fn gpu(navigator: &Self) -> webgpu_sys::Gpu { + // Must be an unchecked ref as this class does not exist at runtime. + let extension: &NavigatorWithGpu = navigator.unchecked_ref(); + extension.gpu() + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_Gpu.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_Gpu.rs new file mode 100644 index 0000000000..7c94bd4f46 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_Gpu.rs @@ -0,0 +1,73 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPU , typescript_type = "GPU")] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `Gpu` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPU)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `Gpu`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type Gpu; + + # [wasm_bindgen (structural , method , getter , js_class = "GPU" , js_name = wgslLanguageFeatures)] + #[doc = "Getter for the `wgslLanguageFeatures` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPU/wgslLanguageFeatures)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `Gpu`, `WgslLanguageFeatures`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn wgsl_language_features(this: &Gpu) -> WgslLanguageFeatures; + + # [wasm_bindgen (method , structural , js_class = "GPU" , js_name = getPreferredCanvasFormat)] + #[doc = "The `getPreferredCanvasFormat()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPU/getPreferredCanvasFormat)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `Gpu`, `GpuTextureFormat`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn get_preferred_canvas_format(this: &Gpu) -> GpuTextureFormat; + + # [wasm_bindgen (method , structural , js_class = "GPU" , js_name = requestAdapter)] + #[doc = "The `requestAdapter()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPU/requestAdapter)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `Gpu`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn request_adapter(this: &Gpu) -> ::js_sys::Promise; + + # [wasm_bindgen (method , structural , js_class = "GPU" , js_name = requestAdapter)] + #[doc = "The `requestAdapter()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPU/requestAdapter)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `Gpu`, `GpuRequestAdapterOptions`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn request_adapter_with_options( + this: &Gpu, + options: &GpuRequestAdapterOptions, + ) -> ::js_sys::Promise; +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuAdapter.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuAdapter.rs new file mode 100644 index 0000000000..72b375d88c --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuAdapter.rs @@ -0,0 +1,95 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUAdapter , typescript_type = "GPUAdapter")] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuAdapter` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUAdapter)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuAdapter`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuAdapter; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUAdapter" , js_name = features)] + #[doc = "Getter for the `features` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUAdapter/features)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuAdapter`, `GpuSupportedFeatures`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn features(this: &GpuAdapter) -> GpuSupportedFeatures; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUAdapter" , js_name = limits)] + #[doc = "Getter for the `limits` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUAdapter/limits)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuAdapter`, `GpuSupportedLimits`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn limits(this: &GpuAdapter) -> GpuSupportedLimits; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUAdapter" , js_name = isFallbackAdapter)] + #[doc = "Getter for the `isFallbackAdapter` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUAdapter/isFallbackAdapter)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuAdapter`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn is_fallback_adapter(this: &GpuAdapter) -> bool; + + # [wasm_bindgen (method , structural , js_class = "GPUAdapter" , js_name = requestAdapterInfo)] + #[doc = "The `requestAdapterInfo()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUAdapter/requestAdapterInfo)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuAdapter`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn request_adapter_info(this: &GpuAdapter) -> ::js_sys::Promise; + + # [wasm_bindgen (method , structural , js_class = "GPUAdapter" , js_name = requestDevice)] + #[doc = "The `requestDevice()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUAdapter/requestDevice)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuAdapter`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn request_device(this: &GpuAdapter) -> ::js_sys::Promise; + + # [wasm_bindgen (method , structural , js_class = "GPUAdapter" , js_name = requestDevice)] + #[doc = "The `requestDevice()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUAdapter/requestDevice)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuAdapter`, `GpuDeviceDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn request_device_with_descriptor( + this: &GpuAdapter, + descriptor: &GpuDeviceDescriptor, + ) -> ::js_sys::Promise; +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuAddressMode.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuAddressMode.rs new file mode 100644 index 0000000000..2a4094c1ca --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuAddressMode.rs @@ -0,0 +1,24 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +#[doc = "The `GpuAddressMode` enum."] +#[doc = ""] +#[doc = "*This API requires the following crate features to be activated: `GpuAddressMode`*"] +#[doc = ""] +#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] +#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum GpuAddressMode { + ClampToEdge = "clamp-to-edge", + Repeat = "repeat", + MirrorRepeat = "mirror-repeat", +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuAutoLayoutMode.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuAutoLayoutMode.rs new file mode 100644 index 0000000000..7034a1cb1b --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuAutoLayoutMode.rs @@ -0,0 +1,22 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +#[doc = "The `GpuAutoLayoutMode` enum."] +#[doc = ""] +#[doc = "*This API requires the following crate features to be activated: `GpuAutoLayoutMode`*"] +#[doc = ""] +#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] +#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum GpuAutoLayoutMode { + Auto = "auto", +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBindGroup.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBindGroup.rs new file mode 100644 index 0000000000..80af440da3 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBindGroup.rs @@ -0,0 +1,48 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUBindGroup , typescript_type = "GPUBindGroup")] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuBindGroup` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUBindGroup)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroup`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuBindGroup; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUBindGroup" , js_name = label)] + #[doc = "Getter for the `label` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUBindGroup/label)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroup`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn label(this: &GpuBindGroup) -> String; + + # [wasm_bindgen (structural , method , setter , js_class = "GPUBindGroup" , js_name = label)] + #[doc = "Setter for the `label` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUBindGroup/label)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroup`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_label(this: &GpuBindGroup, value: &str); +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBindGroupDescriptor.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBindGroupDescriptor.rs new file mode 100644 index 0000000000..453d04da8a --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBindGroupDescriptor.rs @@ -0,0 +1,96 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUBindGroupDescriptor)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuBindGroupDescriptor` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuBindGroupDescriptor; +} + +impl GpuBindGroupDescriptor { + #[doc = "Construct a new `GpuBindGroupDescriptor`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupDescriptor`, `GpuBindGroupLayout`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new(entries: &::wasm_bindgen::JsValue, layout: &GpuBindGroupLayout) -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret.entries(entries); + ret.layout(layout); + ret + } + + #[doc = "Change the `label` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn label(&mut self, val: &str) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("label"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `entries` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn entries(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("entries"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `layout` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupDescriptor`, `GpuBindGroupLayout`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn layout(&mut self, val: &GpuBindGroupLayout) -> &mut Self { + use wasm_bindgen::JsValue; + let r = + ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("layout"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBindGroupEntry.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBindGroupEntry.rs new file mode 100644 index 0000000000..4ae0f1a6c4 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBindGroupEntry.rs @@ -0,0 +1,82 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUBindGroupEntry)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuBindGroupEntry` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupEntry`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuBindGroupEntry; +} + +impl GpuBindGroupEntry { + #[doc = "Construct a new `GpuBindGroupEntry`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupEntry`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new(binding: u32, resource: &::wasm_bindgen::JsValue) -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret.binding(binding); + ret.resource(resource); + ret + } + + #[doc = "Change the `binding` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupEntry`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn binding(&mut self, val: u32) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("binding"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `resource` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupEntry`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn resource(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("resource"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBindGroupLayout.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBindGroupLayout.rs new file mode 100644 index 0000000000..36c620611b --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBindGroupLayout.rs @@ -0,0 +1,48 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUBindGroupLayout , typescript_type = "GPUBindGroupLayout")] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuBindGroupLayout` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUBindGroupLayout)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayout`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuBindGroupLayout; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUBindGroupLayout" , js_name = label)] + #[doc = "Getter for the `label` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUBindGroupLayout/label)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayout`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn label(this: &GpuBindGroupLayout) -> String; + + # [wasm_bindgen (structural , method , setter , js_class = "GPUBindGroupLayout" , js_name = label)] + #[doc = "Setter for the `label` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUBindGroupLayout/label)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayout`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_label(this: &GpuBindGroupLayout, value: &str); +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBindGroupLayoutDescriptor.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBindGroupLayoutDescriptor.rs new file mode 100644 index 0000000000..9e7f3cb54f --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBindGroupLayoutDescriptor.rs @@ -0,0 +1,77 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUBindGroupLayoutDescriptor)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuBindGroupLayoutDescriptor` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuBindGroupLayoutDescriptor; +} + +impl GpuBindGroupLayoutDescriptor { + #[doc = "Construct a new `GpuBindGroupLayoutDescriptor`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new(entries: &::wasm_bindgen::JsValue) -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret.entries(entries); + ret + } + + #[doc = "Change the `label` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn label(&mut self, val: &str) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("label"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `entries` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn entries(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("entries"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBindGroupLayoutEntry.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBindGroupLayoutEntry.rs new file mode 100644 index 0000000000..0fada9059d --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBindGroupLayoutEntry.rs @@ -0,0 +1,184 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUBindGroupLayoutEntry)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuBindGroupLayoutEntry` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutEntry`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuBindGroupLayoutEntry; +} + +impl GpuBindGroupLayoutEntry { + #[doc = "Construct a new `GpuBindGroupLayoutEntry`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutEntry`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new(binding: u32, visibility: u32) -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret.binding(binding); + ret.visibility(visibility); + ret + } + + #[doc = "Change the `binding` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutEntry`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn binding(&mut self, val: u32) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("binding"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `buffer` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutEntry`, `GpuBufferBindingLayout`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn buffer(&mut self, val: &GpuBufferBindingLayout) -> &mut Self { + use wasm_bindgen::JsValue; + let r = + ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("buffer"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `externalTexture` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutEntry`, `GpuExternalTextureBindingLayout`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn external_texture(&mut self, val: &GpuExternalTextureBindingLayout) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("externalTexture"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `sampler` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutEntry`, `GpuSamplerBindingLayout`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn sampler(&mut self, val: &GpuSamplerBindingLayout) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("sampler"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `storageTexture` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutEntry`, `GpuStorageTextureBindingLayout`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn storage_texture(&mut self, val: &GpuStorageTextureBindingLayout) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("storageTexture"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `texture` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutEntry`, `GpuTextureBindingLayout`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn texture(&mut self, val: &GpuTextureBindingLayout) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("texture"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `visibility` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutEntry`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn visibility(&mut self, val: u32) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("visibility"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBlendComponent.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBlendComponent.rs new file mode 100644 index 0000000000..4bb04574dc --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBlendComponent.rs @@ -0,0 +1,107 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUBlendComponent)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuBlendComponent` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBlendComponent`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuBlendComponent; +} + +impl GpuBlendComponent { + #[doc = "Construct a new `GpuBlendComponent`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBlendComponent`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new() -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret + } + + #[doc = "Change the `dstFactor` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBlendComponent`, `GpuBlendFactor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn dst_factor(&mut self, val: GpuBlendFactor) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("dstFactor"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `operation` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBlendComponent`, `GpuBlendOperation`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn operation(&mut self, val: GpuBlendOperation) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("operation"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `srcFactor` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBlendComponent`, `GpuBlendFactor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn src_factor(&mut self, val: GpuBlendFactor) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("srcFactor"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} + +impl Default for GpuBlendComponent { + fn default() -> Self { + Self::new() + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBlendFactor.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBlendFactor.rs new file mode 100644 index 0000000000..47253d7cdb --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBlendFactor.rs @@ -0,0 +1,34 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +#[doc = "The `GpuBlendFactor` enum."] +#[doc = ""] +#[doc = "*This API requires the following crate features to be activated: `GpuBlendFactor`*"] +#[doc = ""] +#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] +#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum GpuBlendFactor { + Zero = "zero", + One = "one", + Src = "src", + OneMinusSrc = "one-minus-src", + SrcAlpha = "src-alpha", + OneMinusSrcAlpha = "one-minus-src-alpha", + Dst = "dst", + OneMinusDst = "one-minus-dst", + DstAlpha = "dst-alpha", + OneMinusDstAlpha = "one-minus-dst-alpha", + SrcAlphaSaturated = "src-alpha-saturated", + Constant = "constant", + OneMinusConstant = "one-minus-constant", +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBlendOperation.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBlendOperation.rs new file mode 100644 index 0000000000..b65ede6a70 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBlendOperation.rs @@ -0,0 +1,26 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +#[doc = "The `GpuBlendOperation` enum."] +#[doc = ""] +#[doc = "*This API requires the following crate features to be activated: `GpuBlendOperation`*"] +#[doc = ""] +#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] +#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum GpuBlendOperation { + Add = "add", + Subtract = "subtract", + ReverseSubtract = "reverse-subtract", + Min = "min", + Max = "max", +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBlendState.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBlendState.rs new file mode 100644 index 0000000000..4e3426c709 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBlendState.rs @@ -0,0 +1,74 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUBlendState)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuBlendState` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBlendState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuBlendState; +} + +impl GpuBlendState { + #[doc = "Construct a new `GpuBlendState`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBlendComponent`, `GpuBlendState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new(alpha: &GpuBlendComponent, color: &GpuBlendComponent) -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret.alpha(alpha); + ret.color(color); + ret + } + + #[doc = "Change the `alpha` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBlendComponent`, `GpuBlendState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn alpha(&mut self, val: &GpuBlendComponent) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("alpha"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `color` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBlendComponent`, `GpuBlendState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn color(&mut self, val: &GpuBlendComponent) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("color"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBuffer.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBuffer.rs new file mode 100644 index 0000000000..6d6c5dca93 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBuffer.rs @@ -0,0 +1,293 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUBuffer , typescript_type = "GPUBuffer")] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuBuffer` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuBuffer; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUBuffer" , js_name = size)] + #[doc = "Getter for the `size` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUBuffer/size)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn size(this: &GpuBuffer) -> f64; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUBuffer" , js_name = usage)] + #[doc = "Getter for the `usage` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUBuffer/usage)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn usage(this: &GpuBuffer) -> u32; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUBuffer" , js_name = mapState)] + #[doc = "Getter for the `mapState` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUBuffer/mapState)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuBufferMapState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn map_state(this: &GpuBuffer) -> GpuBufferMapState; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUBuffer" , js_name = label)] + #[doc = "Getter for the `label` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUBuffer/label)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn label(this: &GpuBuffer) -> String; + + # [wasm_bindgen (structural , method , setter , js_class = "GPUBuffer" , js_name = label)] + #[doc = "Setter for the `label` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUBuffer/label)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_label(this: &GpuBuffer, value: &str); + + # [wasm_bindgen (method , structural , js_class = "GPUBuffer" , js_name = destroy)] + #[doc = "The `destroy()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUBuffer/destroy)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn destroy(this: &GpuBuffer); + + # [wasm_bindgen (method , structural , js_class = "GPUBuffer" , js_name = getMappedRange)] + #[doc = "The `getMappedRange()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUBuffer/getMappedRange)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn get_mapped_range(this: &GpuBuffer) -> ::js_sys::ArrayBuffer; + + # [wasm_bindgen (method , structural , js_class = "GPUBuffer" , js_name = getMappedRange)] + #[doc = "The `getMappedRange()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUBuffer/getMappedRange)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn get_mapped_range_with_u32(this: &GpuBuffer, offset: u32) -> ::js_sys::ArrayBuffer; + + # [wasm_bindgen (method , structural , js_class = "GPUBuffer" , js_name = getMappedRange)] + #[doc = "The `getMappedRange()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUBuffer/getMappedRange)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn get_mapped_range_with_f64(this: &GpuBuffer, offset: f64) -> ::js_sys::ArrayBuffer; + + # [wasm_bindgen (method , structural , js_class = "GPUBuffer" , js_name = getMappedRange)] + #[doc = "The `getMappedRange()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUBuffer/getMappedRange)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn get_mapped_range_with_u32_and_u32( + this: &GpuBuffer, + offset: u32, + size: u32, + ) -> ::js_sys::ArrayBuffer; + + # [wasm_bindgen (method , structural , js_class = "GPUBuffer" , js_name = getMappedRange)] + #[doc = "The `getMappedRange()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUBuffer/getMappedRange)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn get_mapped_range_with_f64_and_u32( + this: &GpuBuffer, + offset: f64, + size: u32, + ) -> ::js_sys::ArrayBuffer; + + # [wasm_bindgen (method , structural , js_class = "GPUBuffer" , js_name = getMappedRange)] + #[doc = "The `getMappedRange()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUBuffer/getMappedRange)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn get_mapped_range_with_u32_and_f64( + this: &GpuBuffer, + offset: u32, + size: f64, + ) -> ::js_sys::ArrayBuffer; + + # [wasm_bindgen (method , structural , js_class = "GPUBuffer" , js_name = getMappedRange)] + #[doc = "The `getMappedRange()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUBuffer/getMappedRange)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn get_mapped_range_with_f64_and_f64( + this: &GpuBuffer, + offset: f64, + size: f64, + ) -> ::js_sys::ArrayBuffer; + + # [wasm_bindgen (method , structural , js_class = "GPUBuffer" , js_name = mapAsync)] + #[doc = "The `mapAsync()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUBuffer/mapAsync)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn map_async(this: &GpuBuffer, mode: u32) -> ::js_sys::Promise; + + # [wasm_bindgen (method , structural , js_class = "GPUBuffer" , js_name = mapAsync)] + #[doc = "The `mapAsync()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUBuffer/mapAsync)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn map_async_with_u32(this: &GpuBuffer, mode: u32, offset: u32) -> ::js_sys::Promise; + + # [wasm_bindgen (method , structural , js_class = "GPUBuffer" , js_name = mapAsync)] + #[doc = "The `mapAsync()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUBuffer/mapAsync)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn map_async_with_f64(this: &GpuBuffer, mode: u32, offset: f64) -> ::js_sys::Promise; + + # [wasm_bindgen (method , structural , js_class = "GPUBuffer" , js_name = mapAsync)] + #[doc = "The `mapAsync()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUBuffer/mapAsync)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn map_async_with_u32_and_u32( + this: &GpuBuffer, + mode: u32, + offset: u32, + size: u32, + ) -> ::js_sys::Promise; + + # [wasm_bindgen (method , structural , js_class = "GPUBuffer" , js_name = mapAsync)] + #[doc = "The `mapAsync()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUBuffer/mapAsync)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn map_async_with_f64_and_u32( + this: &GpuBuffer, + mode: u32, + offset: f64, + size: u32, + ) -> ::js_sys::Promise; + + # [wasm_bindgen (method , structural , js_class = "GPUBuffer" , js_name = mapAsync)] + #[doc = "The `mapAsync()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUBuffer/mapAsync)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn map_async_with_u32_and_f64( + this: &GpuBuffer, + mode: u32, + offset: u32, + size: f64, + ) -> ::js_sys::Promise; + + # [wasm_bindgen (method , structural , js_class = "GPUBuffer" , js_name = mapAsync)] + #[doc = "The `mapAsync()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUBuffer/mapAsync)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn map_async_with_f64_and_f64( + this: &GpuBuffer, + mode: u32, + offset: f64, + size: f64, + ) -> ::js_sys::Promise; + + # [wasm_bindgen (method , structural , js_class = "GPUBuffer" , js_name = unmap)] + #[doc = "The `unmap()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUBuffer/unmap)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn unmap(this: &GpuBuffer); +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBufferBinding.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBufferBinding.rs new file mode 100644 index 0000000000..c583c69850 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBufferBinding.rs @@ -0,0 +1,92 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUBufferBinding)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuBufferBinding` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBufferBinding`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuBufferBinding; +} + +impl GpuBufferBinding { + #[doc = "Construct a new `GpuBufferBinding`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuBufferBinding`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new(buffer: &GpuBuffer) -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret.buffer(buffer); + ret + } + + #[doc = "Change the `buffer` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuBufferBinding`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn buffer(&mut self, val: &GpuBuffer) -> &mut Self { + use wasm_bindgen::JsValue; + let r = + ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("buffer"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `offset` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBufferBinding`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn offset(&mut self, val: f64) -> &mut Self { + use wasm_bindgen::JsValue; + let r = + ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("offset"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `size` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBufferBinding`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn size(&mut self, val: f64) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("size"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBufferBindingLayout.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBufferBindingLayout.rs new file mode 100644 index 0000000000..0fd2488f0e --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBufferBindingLayout.rs @@ -0,0 +1,103 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUBufferBindingLayout)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuBufferBindingLayout` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBufferBindingLayout`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuBufferBindingLayout; +} + +impl GpuBufferBindingLayout { + #[doc = "Construct a new `GpuBufferBindingLayout`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBufferBindingLayout`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new() -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret + } + + #[doc = "Change the `hasDynamicOffset` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBufferBindingLayout`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn has_dynamic_offset(&mut self, val: bool) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("hasDynamicOffset"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `minBindingSize` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBufferBindingLayout`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn min_binding_size(&mut self, val: f64) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("minBindingSize"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `type` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBufferBindingLayout`, `GpuBufferBindingType`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn type_(&mut self, val: GpuBufferBindingType) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("type"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} + +impl Default for GpuBufferBindingLayout { + fn default() -> Self { + Self::new() + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBufferBindingType.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBufferBindingType.rs new file mode 100644 index 0000000000..f3361cccda --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBufferBindingType.rs @@ -0,0 +1,24 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +#[doc = "The `GpuBufferBindingType` enum."] +#[doc = ""] +#[doc = "*This API requires the following crate features to be activated: `GpuBufferBindingType`*"] +#[doc = ""] +#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] +#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum GpuBufferBindingType { + Uniform = "uniform", + Storage = "storage", + ReadOnlyStorage = "read-only-storage", +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBufferDescriptor.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBufferDescriptor.rs new file mode 100644 index 0000000000..377e829f3f --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBufferDescriptor.rs @@ -0,0 +1,112 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUBufferDescriptor)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuBufferDescriptor` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBufferDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuBufferDescriptor; +} + +impl GpuBufferDescriptor { + #[doc = "Construct a new `GpuBufferDescriptor`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBufferDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new(size: f64, usage: u32) -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret.size(size); + ret.usage(usage); + ret + } + + #[doc = "Change the `label` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBufferDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn label(&mut self, val: &str) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("label"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `mappedAtCreation` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBufferDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn mapped_at_creation(&mut self, val: bool) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("mappedAtCreation"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `size` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBufferDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn size(&mut self, val: f64) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("size"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `usage` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBufferDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn usage(&mut self, val: u32) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("usage"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBufferMapState.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBufferMapState.rs new file mode 100644 index 0000000000..2e0b271e2a --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBufferMapState.rs @@ -0,0 +1,24 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +#[doc = "The `GpuBufferMapState` enum."] +#[doc = ""] +#[doc = "*This API requires the following crate features to be activated: `GpuBufferMapState`*"] +#[doc = ""] +#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] +#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum GpuBufferMapState { + Unmapped = "unmapped", + Pending = "pending", + Mapped = "mapped", +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCanvasAlphaMode.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCanvasAlphaMode.rs new file mode 100644 index 0000000000..687939ceb6 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCanvasAlphaMode.rs @@ -0,0 +1,23 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +#[doc = "The `GpuCanvasAlphaMode` enum."] +#[doc = ""] +#[doc = "*This API requires the following crate features to be activated: `GpuCanvasAlphaMode`*"] +#[doc = ""] +#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] +#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum GpuCanvasAlphaMode { + Opaque = "opaque", + Premultiplied = "premultiplied", +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCanvasConfiguration.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCanvasConfiguration.rs new file mode 100644 index 0000000000..5db5747c20 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCanvasConfiguration.rs @@ -0,0 +1,135 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUCanvasConfiguration)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuCanvasConfiguration` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCanvasConfiguration`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuCanvasConfiguration; +} + +impl GpuCanvasConfiguration { + #[doc = "Construct a new `GpuCanvasConfiguration`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCanvasConfiguration`, `GpuDevice`, `GpuTextureFormat`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new(device: &GpuDevice, format: GpuTextureFormat) -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret.device(device); + ret.format(format); + ret + } + + #[doc = "Change the `alphaMode` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCanvasAlphaMode`, `GpuCanvasConfiguration`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn alpha_mode(&mut self, val: GpuCanvasAlphaMode) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("alphaMode"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `device` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCanvasConfiguration`, `GpuDevice`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn device(&mut self, val: &GpuDevice) -> &mut Self { + use wasm_bindgen::JsValue; + let r = + ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("device"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `format` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCanvasConfiguration`, `GpuTextureFormat`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn format(&mut self, val: GpuTextureFormat) -> &mut Self { + use wasm_bindgen::JsValue; + let r = + ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("format"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `usage` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCanvasConfiguration`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn usage(&mut self, val: u32) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("usage"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `viewFormats` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCanvasConfiguration`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn view_formats(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("viewFormats"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCanvasContext.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCanvasContext.rs new file mode 100644 index 0000000000..b7734084aa --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCanvasContext.rs @@ -0,0 +1,70 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUCanvasContext , typescript_type = "GPUCanvasContext")] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuCanvasContext` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCanvasContext)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCanvasContext`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuCanvasContext; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUCanvasContext" , js_name = canvas)] + #[doc = "Getter for the `canvas` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCanvasContext/canvas)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCanvasContext`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn canvas(this: &GpuCanvasContext) -> ::js_sys::Object; + + # [wasm_bindgen (method , structural , js_class = "GPUCanvasContext" , js_name = configure)] + #[doc = "The `configure()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCanvasContext/configure)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCanvasConfiguration`, `GpuCanvasContext`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn configure(this: &GpuCanvasContext, configuration: &GpuCanvasConfiguration); + + # [wasm_bindgen (method , structural , js_class = "GPUCanvasContext" , js_name = getCurrentTexture)] + #[doc = "The `getCurrentTexture()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCanvasContext/getCurrentTexture)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCanvasContext`, `GpuTexture`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn get_current_texture(this: &GpuCanvasContext) -> GpuTexture; + + # [wasm_bindgen (method , structural , js_class = "GPUCanvasContext" , js_name = unconfigure)] + #[doc = "The `unconfigure()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCanvasContext/unconfigure)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCanvasContext`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn unconfigure(this: &GpuCanvasContext); +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuColorDict.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuColorDict.rs new file mode 100644 index 0000000000..73ab12a727 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuColorDict.rs @@ -0,0 +1,110 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUColorDict)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuColorDict` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuColorDict`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuColorDict; +} + +impl GpuColorDict { + #[doc = "Construct a new `GpuColorDict`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuColorDict`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new(a: f64, b: f64, g: f64, r: f64) -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret.a(a); + ret.b(b); + ret.g(g); + ret.r(r); + ret + } + + #[doc = "Change the `a` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuColorDict`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn a(&mut self, val: f64) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("a"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `b` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuColorDict`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn b(&mut self, val: f64) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("b"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `g` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuColorDict`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn g(&mut self, val: f64) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("g"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `r` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuColorDict`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn r(&mut self, val: f64) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("r"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuColorTargetState.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuColorTargetState.rs new file mode 100644 index 0000000000..6a4701f73e --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuColorTargetState.rs @@ -0,0 +1,95 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUColorTargetState)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuColorTargetState` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuColorTargetState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuColorTargetState; +} + +impl GpuColorTargetState { + #[doc = "Construct a new `GpuColorTargetState`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuColorTargetState`, `GpuTextureFormat`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new(format: GpuTextureFormat) -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret.format(format); + ret + } + + #[doc = "Change the `blend` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBlendState`, `GpuColorTargetState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn blend(&mut self, val: &GpuBlendState) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("blend"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `format` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuColorTargetState`, `GpuTextureFormat`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn format(&mut self, val: GpuTextureFormat) -> &mut Self { + use wasm_bindgen::JsValue; + let r = + ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("format"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `writeMask` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuColorTargetState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn write_mask(&mut self, val: u32) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("writeMask"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCommandBuffer.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCommandBuffer.rs new file mode 100644 index 0000000000..20aef1d1b3 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCommandBuffer.rs @@ -0,0 +1,48 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUCommandBuffer , typescript_type = "GPUCommandBuffer")] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuCommandBuffer` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCommandBuffer`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuCommandBuffer; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUCommandBuffer" , js_name = label)] + #[doc = "Getter for the `label` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandBuffer/label)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCommandBuffer`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn label(this: &GpuCommandBuffer) -> String; + + # [wasm_bindgen (structural , method , setter , js_class = "GPUCommandBuffer" , js_name = label)] + #[doc = "Setter for the `label` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandBuffer/label)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCommandBuffer`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_label(this: &GpuCommandBuffer, value: &str); +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCommandBufferDescriptor.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCommandBufferDescriptor.rs new file mode 100644 index 0000000000..bedfcb6320 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCommandBufferDescriptor.rs @@ -0,0 +1,61 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUCommandBufferDescriptor)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuCommandBufferDescriptor` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCommandBufferDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuCommandBufferDescriptor; +} + +impl GpuCommandBufferDescriptor { + #[doc = "Construct a new `GpuCommandBufferDescriptor`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCommandBufferDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new() -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret + } + + #[doc = "Change the `label` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCommandBufferDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn label(&mut self, val: &str) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("label"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} + +impl Default for GpuCommandBufferDescriptor { + fn default() -> Self { + Self::new() + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCommandEncoder.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCommandEncoder.rs new file mode 100644 index 0000000000..b6e705fed9 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCommandEncoder.rs @@ -0,0 +1,518 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUCommandEncoder , typescript_type = "GPUCommandEncoder")] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuCommandEncoder` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCommandEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuCommandEncoder; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUCommandEncoder" , js_name = label)] + #[doc = "Getter for the `label` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/label)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCommandEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn label(this: &GpuCommandEncoder) -> String; + + # [wasm_bindgen (structural , method , setter , js_class = "GPUCommandEncoder" , js_name = label)] + #[doc = "Setter for the `label` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/label)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCommandEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_label(this: &GpuCommandEncoder, value: &str); + + # [wasm_bindgen (method , structural , js_class = "GPUCommandEncoder" , js_name = beginComputePass)] + #[doc = "The `beginComputePass()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/beginComputePass)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCommandEncoder`, `GpuComputePassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn begin_compute_pass(this: &GpuCommandEncoder) -> GpuComputePassEncoder; + + # [wasm_bindgen (method , structural , js_class = "GPUCommandEncoder" , js_name = beginComputePass)] + #[doc = "The `beginComputePass()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/beginComputePass)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCommandEncoder`, `GpuComputePassDescriptor`, `GpuComputePassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn begin_compute_pass_with_descriptor( + this: &GpuCommandEncoder, + descriptor: &GpuComputePassDescriptor, + ) -> GpuComputePassEncoder; + + # [wasm_bindgen (method , structural , js_class = "GPUCommandEncoder" , js_name = beginRenderPass)] + #[doc = "The `beginRenderPass()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/beginRenderPass)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCommandEncoder`, `GpuRenderPassDescriptor`, `GpuRenderPassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn begin_render_pass( + this: &GpuCommandEncoder, + descriptor: &GpuRenderPassDescriptor, + ) -> GpuRenderPassEncoder; + + # [wasm_bindgen (method , structural , js_class = "GPUCommandEncoder" , js_name = clearBuffer)] + #[doc = "The `clearBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/clearBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuCommandEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn clear_buffer(this: &GpuCommandEncoder, buffer: &GpuBuffer); + + # [wasm_bindgen (method , structural , js_class = "GPUCommandEncoder" , js_name = clearBuffer)] + #[doc = "The `clearBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/clearBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuCommandEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn clear_buffer_with_u32(this: &GpuCommandEncoder, buffer: &GpuBuffer, offset: u32); + + # [wasm_bindgen (method , structural , js_class = "GPUCommandEncoder" , js_name = clearBuffer)] + #[doc = "The `clearBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/clearBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuCommandEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn clear_buffer_with_f64(this: &GpuCommandEncoder, buffer: &GpuBuffer, offset: f64); + + # [wasm_bindgen (method , structural , js_class = "GPUCommandEncoder" , js_name = clearBuffer)] + #[doc = "The `clearBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/clearBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuCommandEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn clear_buffer_with_u32_and_u32( + this: &GpuCommandEncoder, + buffer: &GpuBuffer, + offset: u32, + size: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUCommandEncoder" , js_name = clearBuffer)] + #[doc = "The `clearBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/clearBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuCommandEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn clear_buffer_with_f64_and_u32( + this: &GpuCommandEncoder, + buffer: &GpuBuffer, + offset: f64, + size: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUCommandEncoder" , js_name = clearBuffer)] + #[doc = "The `clearBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/clearBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuCommandEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn clear_buffer_with_u32_and_f64( + this: &GpuCommandEncoder, + buffer: &GpuBuffer, + offset: u32, + size: f64, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUCommandEncoder" , js_name = clearBuffer)] + #[doc = "The `clearBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/clearBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuCommandEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn clear_buffer_with_f64_and_f64( + this: &GpuCommandEncoder, + buffer: &GpuBuffer, + offset: f64, + size: f64, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUCommandEncoder" , js_name = copyBufferToBuffer)] + #[doc = "The `copyBufferToBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/copyBufferToBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuCommandEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn copy_buffer_to_buffer_with_u32_and_u32_and_u32( + this: &GpuCommandEncoder, + source: &GpuBuffer, + source_offset: u32, + destination: &GpuBuffer, + destination_offset: u32, + size: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUCommandEncoder" , js_name = copyBufferToBuffer)] + #[doc = "The `copyBufferToBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/copyBufferToBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuCommandEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn copy_buffer_to_buffer_with_f64_and_u32_and_u32( + this: &GpuCommandEncoder, + source: &GpuBuffer, + source_offset: f64, + destination: &GpuBuffer, + destination_offset: u32, + size: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUCommandEncoder" , js_name = copyBufferToBuffer)] + #[doc = "The `copyBufferToBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/copyBufferToBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuCommandEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn copy_buffer_to_buffer_with_u32_and_f64_and_u32( + this: &GpuCommandEncoder, + source: &GpuBuffer, + source_offset: u32, + destination: &GpuBuffer, + destination_offset: f64, + size: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUCommandEncoder" , js_name = copyBufferToBuffer)] + #[doc = "The `copyBufferToBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/copyBufferToBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuCommandEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn copy_buffer_to_buffer_with_f64_and_f64_and_u32( + this: &GpuCommandEncoder, + source: &GpuBuffer, + source_offset: f64, + destination: &GpuBuffer, + destination_offset: f64, + size: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUCommandEncoder" , js_name = copyBufferToBuffer)] + #[doc = "The `copyBufferToBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/copyBufferToBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuCommandEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn copy_buffer_to_buffer_with_u32_and_u32_and_f64( + this: &GpuCommandEncoder, + source: &GpuBuffer, + source_offset: u32, + destination: &GpuBuffer, + destination_offset: u32, + size: f64, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUCommandEncoder" , js_name = copyBufferToBuffer)] + #[doc = "The `copyBufferToBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/copyBufferToBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuCommandEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn copy_buffer_to_buffer_with_f64_and_u32_and_f64( + this: &GpuCommandEncoder, + source: &GpuBuffer, + source_offset: f64, + destination: &GpuBuffer, + destination_offset: u32, + size: f64, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUCommandEncoder" , js_name = copyBufferToBuffer)] + #[doc = "The `copyBufferToBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/copyBufferToBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuCommandEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn copy_buffer_to_buffer_with_u32_and_f64_and_f64( + this: &GpuCommandEncoder, + source: &GpuBuffer, + source_offset: u32, + destination: &GpuBuffer, + destination_offset: f64, + size: f64, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUCommandEncoder" , js_name = copyBufferToBuffer)] + #[doc = "The `copyBufferToBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/copyBufferToBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuCommandEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn copy_buffer_to_buffer_with_f64_and_f64_and_f64( + this: &GpuCommandEncoder, + source: &GpuBuffer, + source_offset: f64, + destination: &GpuBuffer, + destination_offset: f64, + size: f64, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUCommandEncoder" , js_name = copyBufferToTexture)] + #[doc = "The `copyBufferToTexture()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/copyBufferToTexture)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCommandEncoder`, `GpuImageCopyBuffer`, `GpuImageCopyTexture`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn copy_buffer_to_texture_with_u32_sequence( + this: &GpuCommandEncoder, + source: &GpuImageCopyBuffer, + destination: &GpuImageCopyTexture, + copy_size: &::wasm_bindgen::JsValue, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUCommandEncoder" , js_name = copyBufferToTexture)] + #[doc = "The `copyBufferToTexture()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/copyBufferToTexture)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCommandEncoder`, `GpuExtent3dDict`, `GpuImageCopyBuffer`, `GpuImageCopyTexture`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn copy_buffer_to_texture_with_gpu_extent_3d_dict( + this: &GpuCommandEncoder, + source: &GpuImageCopyBuffer, + destination: &GpuImageCopyTexture, + copy_size: &GpuExtent3dDict, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUCommandEncoder" , js_name = copyTextureToBuffer)] + #[doc = "The `copyTextureToBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/copyTextureToBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCommandEncoder`, `GpuImageCopyBuffer`, `GpuImageCopyTexture`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn copy_texture_to_buffer_with_u32_sequence( + this: &GpuCommandEncoder, + source: &GpuImageCopyTexture, + destination: &GpuImageCopyBuffer, + copy_size: &::wasm_bindgen::JsValue, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUCommandEncoder" , js_name = copyTextureToBuffer)] + #[doc = "The `copyTextureToBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/copyTextureToBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCommandEncoder`, `GpuExtent3dDict`, `GpuImageCopyBuffer`, `GpuImageCopyTexture`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn copy_texture_to_buffer_with_gpu_extent_3d_dict( + this: &GpuCommandEncoder, + source: &GpuImageCopyTexture, + destination: &GpuImageCopyBuffer, + copy_size: &GpuExtent3dDict, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUCommandEncoder" , js_name = copyTextureToTexture)] + #[doc = "The `copyTextureToTexture()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/copyTextureToTexture)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCommandEncoder`, `GpuImageCopyTexture`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn copy_texture_to_texture_with_u32_sequence( + this: &GpuCommandEncoder, + source: &GpuImageCopyTexture, + destination: &GpuImageCopyTexture, + copy_size: &::wasm_bindgen::JsValue, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUCommandEncoder" , js_name = copyTextureToTexture)] + #[doc = "The `copyTextureToTexture()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/copyTextureToTexture)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCommandEncoder`, `GpuExtent3dDict`, `GpuImageCopyTexture`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn copy_texture_to_texture_with_gpu_extent_3d_dict( + this: &GpuCommandEncoder, + source: &GpuImageCopyTexture, + destination: &GpuImageCopyTexture, + copy_size: &GpuExtent3dDict, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUCommandEncoder" , js_name = finish)] + #[doc = "The `finish()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/finish)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCommandBuffer`, `GpuCommandEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn finish(this: &GpuCommandEncoder) -> GpuCommandBuffer; + + # [wasm_bindgen (method , structural , js_class = "GPUCommandEncoder" , js_name = finish)] + #[doc = "The `finish()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/finish)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCommandBuffer`, `GpuCommandBufferDescriptor`, `GpuCommandEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn finish_with_descriptor( + this: &GpuCommandEncoder, + descriptor: &GpuCommandBufferDescriptor, + ) -> GpuCommandBuffer; + + # [wasm_bindgen (method , structural , js_class = "GPUCommandEncoder" , js_name = resolveQuerySet)] + #[doc = "The `resolveQuerySet()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/resolveQuerySet)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuCommandEncoder`, `GpuQuerySet`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn resolve_query_set_with_u32( + this: &GpuCommandEncoder, + query_set: &GpuQuerySet, + first_query: u32, + query_count: u32, + destination: &GpuBuffer, + destination_offset: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUCommandEncoder" , js_name = resolveQuerySet)] + #[doc = "The `resolveQuerySet()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/resolveQuerySet)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuCommandEncoder`, `GpuQuerySet`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn resolve_query_set_with_f64( + this: &GpuCommandEncoder, + query_set: &GpuQuerySet, + first_query: u32, + query_count: u32, + destination: &GpuBuffer, + destination_offset: f64, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUCommandEncoder" , js_name = insertDebugMarker)] + #[doc = "The `insertDebugMarker()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/insertDebugMarker)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCommandEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn insert_debug_marker(this: &GpuCommandEncoder, marker_label: &str); + + # [wasm_bindgen (method , structural , js_class = "GPUCommandEncoder" , js_name = popDebugGroup)] + #[doc = "The `popDebugGroup()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/popDebugGroup)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCommandEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn pop_debug_group(this: &GpuCommandEncoder); + + # [wasm_bindgen (method , structural , js_class = "GPUCommandEncoder" , js_name = pushDebugGroup)] + #[doc = "The `pushDebugGroup()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/pushDebugGroup)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCommandEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn push_debug_group(this: &GpuCommandEncoder, group_label: &str); +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCommandEncoderDescriptor.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCommandEncoderDescriptor.rs new file mode 100644 index 0000000000..2659ef75ce --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCommandEncoderDescriptor.rs @@ -0,0 +1,61 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUCommandEncoderDescriptor)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuCommandEncoderDescriptor` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCommandEncoderDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuCommandEncoderDescriptor; +} + +impl GpuCommandEncoderDescriptor { + #[doc = "Construct a new `GpuCommandEncoderDescriptor`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCommandEncoderDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new() -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret + } + + #[doc = "Change the `label` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCommandEncoderDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn label(&mut self, val: &str) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("label"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} + +impl Default for GpuCommandEncoderDescriptor { + fn default() -> Self { + Self::new() + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCompareFunction.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCompareFunction.rs new file mode 100644 index 0000000000..52bb4b8ebd --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCompareFunction.rs @@ -0,0 +1,29 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +#[doc = "The `GpuCompareFunction` enum."] +#[doc = ""] +#[doc = "*This API requires the following crate features to be activated: `GpuCompareFunction`*"] +#[doc = ""] +#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] +#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum GpuCompareFunction { + Never = "never", + Less = "less", + Equal = "equal", + LessEqual = "less-equal", + Greater = "greater", + NotEqual = "not-equal", + GreaterEqual = "greater-equal", + Always = "always", +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCompilationInfo.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCompilationInfo.rs new file mode 100644 index 0000000000..b345013dab --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCompilationInfo.rs @@ -0,0 +1,37 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUCompilationInfo , typescript_type = "GPUCompilationInfo")] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuCompilationInfo` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCompilationInfo)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCompilationInfo`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuCompilationInfo; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUCompilationInfo" , js_name = messages)] + #[doc = "Getter for the `messages` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCompilationInfo/messages)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCompilationInfo`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn messages(this: &GpuCompilationInfo) -> ::js_sys::Array; +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCompilationMessage.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCompilationMessage.rs new file mode 100644 index 0000000000..b93bf6562c --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCompilationMessage.rs @@ -0,0 +1,92 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUCompilationMessage , typescript_type = "GPUCompilationMessage")] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuCompilationMessage` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCompilationMessage)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCompilationMessage`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuCompilationMessage; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUCompilationMessage" , js_name = message)] + #[doc = "Getter for the `message` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCompilationMessage/message)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCompilationMessage`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn message(this: &GpuCompilationMessage) -> String; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUCompilationMessage" , js_name = type)] + #[doc = "Getter for the `type` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCompilationMessage/type)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCompilationMessage`, `GpuCompilationMessageType`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn type_(this: &GpuCompilationMessage) -> GpuCompilationMessageType; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUCompilationMessage" , js_name = lineNum)] + #[doc = "Getter for the `lineNum` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCompilationMessage/lineNum)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCompilationMessage`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn line_num(this: &GpuCompilationMessage) -> f64; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUCompilationMessage" , js_name = linePos)] + #[doc = "Getter for the `linePos` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCompilationMessage/linePos)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCompilationMessage`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn line_pos(this: &GpuCompilationMessage) -> f64; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUCompilationMessage" , js_name = offset)] + #[doc = "Getter for the `offset` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCompilationMessage/offset)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCompilationMessage`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn offset(this: &GpuCompilationMessage) -> f64; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUCompilationMessage" , js_name = length)] + #[doc = "Getter for the `length` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCompilationMessage/length)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCompilationMessage`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn length(this: &GpuCompilationMessage) -> f64; +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCompilationMessageType.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCompilationMessageType.rs new file mode 100644 index 0000000000..e98f438d68 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCompilationMessageType.rs @@ -0,0 +1,24 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +#[doc = "The `GpuCompilationMessageType` enum."] +#[doc = ""] +#[doc = "*This API requires the following crate features to be activated: `GpuCompilationMessageType`*"] +#[doc = ""] +#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] +#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum GpuCompilationMessageType { + Error = "error", + Warning = "warning", + Info = "info", +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuComputePassDescriptor.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuComputePassDescriptor.rs new file mode 100644 index 0000000000..d1eb125f99 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuComputePassDescriptor.rs @@ -0,0 +1,82 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUComputePassDescriptor)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuComputePassDescriptor` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuComputePassDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuComputePassDescriptor; +} + +impl GpuComputePassDescriptor { + #[doc = "Construct a new `GpuComputePassDescriptor`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuComputePassDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new() -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret + } + + #[doc = "Change the `label` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuComputePassDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn label(&mut self, val: &str) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("label"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `timestampWrites` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuComputePassDescriptor`, `GpuComputePassTimestampWrites`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn timestamp_writes(&mut self, val: &GpuComputePassTimestampWrites) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("timestampWrites"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} + +impl Default for GpuComputePassDescriptor { + fn default() -> Self { + Self::new() + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuComputePassEncoder.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuComputePassEncoder.rs new file mode 100644 index 0000000000..1643039349 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuComputePassEncoder.rs @@ -0,0 +1,242 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUComputePassEncoder , typescript_type = "GPUComputePassEncoder")] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuComputePassEncoder` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUComputePassEncoder)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuComputePassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuComputePassEncoder; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUComputePassEncoder" , js_name = label)] + #[doc = "Getter for the `label` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUComputePassEncoder/label)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuComputePassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn label(this: &GpuComputePassEncoder) -> String; + + # [wasm_bindgen (structural , method , setter , js_class = "GPUComputePassEncoder" , js_name = label)] + #[doc = "Setter for the `label` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUComputePassEncoder/label)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuComputePassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_label(this: &GpuComputePassEncoder, value: &str); + + # [wasm_bindgen (method , structural , js_class = "GPUComputePassEncoder" , js_name = dispatchWorkgroups)] + #[doc = "The `dispatchWorkgroups()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUComputePassEncoder/dispatchWorkgroups)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuComputePassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn dispatch_workgroups(this: &GpuComputePassEncoder, workgroup_count_x: u32); + + # [wasm_bindgen (method , structural , js_class = "GPUComputePassEncoder" , js_name = dispatchWorkgroups)] + #[doc = "The `dispatchWorkgroups()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUComputePassEncoder/dispatchWorkgroups)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuComputePassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn dispatch_workgroups_with_workgroup_count_y( + this: &GpuComputePassEncoder, + workgroup_count_x: u32, + workgroup_count_y: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUComputePassEncoder" , js_name = dispatchWorkgroups)] + #[doc = "The `dispatchWorkgroups()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUComputePassEncoder/dispatchWorkgroups)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuComputePassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn dispatch_workgroups_with_workgroup_count_y_and_workgroup_count_z( + this: &GpuComputePassEncoder, + workgroup_count_x: u32, + workgroup_count_y: u32, + workgroup_count_z: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUComputePassEncoder" , js_name = dispatchWorkgroupsIndirect)] + #[doc = "The `dispatchWorkgroupsIndirect()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUComputePassEncoder/dispatchWorkgroupsIndirect)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuComputePassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn dispatch_workgroups_indirect_with_u32( + this: &GpuComputePassEncoder, + indirect_buffer: &GpuBuffer, + indirect_offset: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUComputePassEncoder" , js_name = dispatchWorkgroupsIndirect)] + #[doc = "The `dispatchWorkgroupsIndirect()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUComputePassEncoder/dispatchWorkgroupsIndirect)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuComputePassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn dispatch_workgroups_indirect_with_f64( + this: &GpuComputePassEncoder, + indirect_buffer: &GpuBuffer, + indirect_offset: f64, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUComputePassEncoder" , js_name = end)] + #[doc = "The `end()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUComputePassEncoder/end)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuComputePassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn end(this: &GpuComputePassEncoder); + + # [wasm_bindgen (method , structural , js_class = "GPUComputePassEncoder" , js_name = setPipeline)] + #[doc = "The `setPipeline()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUComputePassEncoder/setPipeline)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuComputePassEncoder`, `GpuComputePipeline`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_pipeline(this: &GpuComputePassEncoder, pipeline: &GpuComputePipeline); + + # [wasm_bindgen (method , structural , js_class = "GPUComputePassEncoder" , js_name = setBindGroup)] + #[doc = "The `setBindGroup()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUComputePassEncoder/setBindGroup)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroup`, `GpuComputePassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_bind_group( + this: &GpuComputePassEncoder, + index: u32, + bind_group: Option<&GpuBindGroup>, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUComputePassEncoder" , js_name = setBindGroup)] + #[doc = "The `setBindGroup()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUComputePassEncoder/setBindGroup)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroup`, `GpuComputePassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_bind_group_with_u32_sequence( + this: &GpuComputePassEncoder, + index: u32, + bind_group: Option<&GpuBindGroup>, + dynamic_offsets: &::wasm_bindgen::JsValue, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUComputePassEncoder" , js_name = setBindGroup)] + #[doc = "The `setBindGroup()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUComputePassEncoder/setBindGroup)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroup`, `GpuComputePassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_bind_group_with_u32_array_and_u32_and_dynamic_offsets_data_length( + this: &GpuComputePassEncoder, + index: u32, + bind_group: Option<&GpuBindGroup>, + dynamic_offsets_data: &[u32], + dynamic_offsets_data_start: u32, + dynamic_offsets_data_length: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUComputePassEncoder" , js_name = setBindGroup)] + #[doc = "The `setBindGroup()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUComputePassEncoder/setBindGroup)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroup`, `GpuComputePassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_bind_group_with_u32_array_and_f64_and_dynamic_offsets_data_length( + this: &GpuComputePassEncoder, + index: u32, + bind_group: Option<&GpuBindGroup>, + dynamic_offsets_data: &[u32], + dynamic_offsets_data_start: f64, + dynamic_offsets_data_length: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUComputePassEncoder" , js_name = insertDebugMarker)] + #[doc = "The `insertDebugMarker()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUComputePassEncoder/insertDebugMarker)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuComputePassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn insert_debug_marker(this: &GpuComputePassEncoder, marker_label: &str); + + # [wasm_bindgen (method , structural , js_class = "GPUComputePassEncoder" , js_name = popDebugGroup)] + #[doc = "The `popDebugGroup()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUComputePassEncoder/popDebugGroup)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuComputePassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn pop_debug_group(this: &GpuComputePassEncoder); + + # [wasm_bindgen (method , structural , js_class = "GPUComputePassEncoder" , js_name = pushDebugGroup)] + #[doc = "The `pushDebugGroup()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUComputePassEncoder/pushDebugGroup)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuComputePassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn push_debug_group(this: &GpuComputePassEncoder, group_label: &str); +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuComputePassTimestampWrites.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuComputePassTimestampWrites.rs new file mode 100644 index 0000000000..f88a40c0a6 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuComputePassTimestampWrites.rs @@ -0,0 +1,102 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUComputePassTimestampWrites)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuComputePassTimestampWrites` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuComputePassTimestampWrites`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuComputePassTimestampWrites; +} + +impl GpuComputePassTimestampWrites { + #[doc = "Construct a new `GpuComputePassTimestampWrites`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuComputePassTimestampWrites`, `GpuQuerySet`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new(query_set: &GpuQuerySet) -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret.query_set(query_set); + ret + } + + #[doc = "Change the `beginningOfPassWriteIndex` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuComputePassTimestampWrites`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn beginning_of_pass_write_index(&mut self, val: u32) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("beginningOfPassWriteIndex"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `endOfPassWriteIndex` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuComputePassTimestampWrites`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn end_of_pass_write_index(&mut self, val: u32) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("endOfPassWriteIndex"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `querySet` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuComputePassTimestampWrites`, `GpuQuerySet`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn query_set(&mut self, val: &GpuQuerySet) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("querySet"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuComputePipeline.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuComputePipeline.rs new file mode 100644 index 0000000000..c2e8db370a --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuComputePipeline.rs @@ -0,0 +1,59 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUComputePipeline , typescript_type = "GPUComputePipeline")] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuComputePipeline` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUComputePipeline)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuComputePipeline`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuComputePipeline; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUComputePipeline" , js_name = label)] + #[doc = "Getter for the `label` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUComputePipeline/label)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuComputePipeline`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn label(this: &GpuComputePipeline) -> String; + + # [wasm_bindgen (structural , method , setter , js_class = "GPUComputePipeline" , js_name = label)] + #[doc = "Setter for the `label` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUComputePipeline/label)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuComputePipeline`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_label(this: &GpuComputePipeline, value: &str); + + # [wasm_bindgen (method , structural , js_class = "GPUComputePipeline" , js_name = getBindGroupLayout)] + #[doc = "The `getBindGroupLayout()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUComputePipeline/getBindGroupLayout)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayout`, `GpuComputePipeline`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn get_bind_group_layout(this: &GpuComputePipeline, index: u32) -> GpuBindGroupLayout; +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuComputePipelineDescriptor.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuComputePipelineDescriptor.rs new file mode 100644 index 0000000000..110b4f34ba --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuComputePipelineDescriptor.rs @@ -0,0 +1,96 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUComputePipelineDescriptor)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuComputePipelineDescriptor` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuComputePipelineDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuComputePipelineDescriptor; +} + +impl GpuComputePipelineDescriptor { + #[doc = "Construct a new `GpuComputePipelineDescriptor`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuComputePipelineDescriptor`, `GpuProgrammableStage`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new(layout: &::wasm_bindgen::JsValue, compute: &GpuProgrammableStage) -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret.layout(layout); + ret.compute(compute); + ret + } + + #[doc = "Change the `label` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuComputePipelineDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn label(&mut self, val: &str) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("label"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `layout` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuComputePipelineDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn layout(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self { + use wasm_bindgen::JsValue; + let r = + ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("layout"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `compute` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuComputePipelineDescriptor`, `GpuProgrammableStage`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn compute(&mut self, val: &GpuProgrammableStage) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("compute"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCullMode.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCullMode.rs new file mode 100644 index 0000000000..8242ff4305 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCullMode.rs @@ -0,0 +1,24 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +#[doc = "The `GpuCullMode` enum."] +#[doc = ""] +#[doc = "*This API requires the following crate features to be activated: `GpuCullMode`*"] +#[doc = ""] +#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] +#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum GpuCullMode { + None = "none", + Front = "front", + Back = "back", +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuDepthStencilState.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuDepthStencilState.rs new file mode 100644 index 0000000000..f48c27411b --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuDepthStencilState.rs @@ -0,0 +1,246 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUDepthStencilState)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuDepthStencilState` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuDepthStencilState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuDepthStencilState; +} + +impl GpuDepthStencilState { + #[doc = "Construct a new `GpuDepthStencilState`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuDepthStencilState`, `GpuTextureFormat`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new(format: GpuTextureFormat) -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret.format(format); + ret + } + + #[doc = "Change the `depthBias` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuDepthStencilState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn depth_bias(&mut self, val: i32) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("depthBias"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `depthBiasClamp` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuDepthStencilState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn depth_bias_clamp(&mut self, val: f32) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("depthBiasClamp"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `depthBiasSlopeScale` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuDepthStencilState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn depth_bias_slope_scale(&mut self, val: f32) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("depthBiasSlopeScale"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `depthCompare` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCompareFunction`, `GpuDepthStencilState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn depth_compare(&mut self, val: GpuCompareFunction) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("depthCompare"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `depthWriteEnabled` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuDepthStencilState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn depth_write_enabled(&mut self, val: bool) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("depthWriteEnabled"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `format` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuDepthStencilState`, `GpuTextureFormat`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn format(&mut self, val: GpuTextureFormat) -> &mut Self { + use wasm_bindgen::JsValue; + let r = + ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("format"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `stencilBack` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuDepthStencilState`, `GpuStencilFaceState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn stencil_back(&mut self, val: &GpuStencilFaceState) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("stencilBack"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `stencilFront` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuDepthStencilState`, `GpuStencilFaceState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn stencil_front(&mut self, val: &GpuStencilFaceState) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("stencilFront"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `stencilReadMask` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuDepthStencilState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn stencil_read_mask(&mut self, val: u32) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("stencilReadMask"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `stencilWriteMask` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuDepthStencilState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn stencil_write_mask(&mut self, val: u32) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("stencilWriteMask"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuDevice.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuDevice.rs new file mode 100644 index 0000000000..3a3f424736 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuDevice.rs @@ -0,0 +1,368 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = EventTarget , extends = :: js_sys :: Object , js_name = GPUDevice , typescript_type = "GPUDevice")] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuDevice` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUDevice)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuDevice`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuDevice; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUDevice" , js_name = features)] + #[doc = "Getter for the `features` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUDevice/features)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuDevice`, `GpuSupportedFeatures`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn features(this: &GpuDevice) -> GpuSupportedFeatures; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUDevice" , js_name = limits)] + #[doc = "Getter for the `limits` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUDevice/limits)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuDevice`, `GpuSupportedLimits`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn limits(this: &GpuDevice) -> GpuSupportedLimits; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUDevice" , js_name = queue)] + #[doc = "Getter for the `queue` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUDevice/queue)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuDevice`, `GpuQueue`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn queue(this: &GpuDevice) -> GpuQueue; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUDevice" , js_name = lost)] + #[doc = "Getter for the `lost` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUDevice/lost)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuDevice`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn lost(this: &GpuDevice) -> ::js_sys::Promise; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUDevice" , js_name = onuncapturederror)] + #[doc = "Getter for the `onuncapturederror` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUDevice/onuncapturederror)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuDevice`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn onuncapturederror(this: &GpuDevice) -> Option<::js_sys::Function>; + + # [wasm_bindgen (structural , method , setter , js_class = "GPUDevice" , js_name = onuncapturederror)] + #[doc = "Setter for the `onuncapturederror` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUDevice/onuncapturederror)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuDevice`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_onuncapturederror(this: &GpuDevice, value: Option<&::js_sys::Function>); + + # [wasm_bindgen (structural , method , getter , js_class = "GPUDevice" , js_name = label)] + #[doc = "Getter for the `label` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUDevice/label)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuDevice`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn label(this: &GpuDevice) -> String; + + # [wasm_bindgen (structural , method , setter , js_class = "GPUDevice" , js_name = label)] + #[doc = "Setter for the `label` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUDevice/label)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuDevice`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_label(this: &GpuDevice, value: &str); + + # [wasm_bindgen (method , structural , js_class = "GPUDevice" , js_name = createBindGroup)] + #[doc = "The `createBindGroup()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUDevice/createBindGroup)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroup`, `GpuBindGroupDescriptor`, `GpuDevice`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn create_bind_group(this: &GpuDevice, descriptor: &GpuBindGroupDescriptor) + -> GpuBindGroup; + + # [wasm_bindgen (method , structural , js_class = "GPUDevice" , js_name = createBindGroupLayout)] + #[doc = "The `createBindGroupLayout()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUDevice/createBindGroupLayout)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayout`, `GpuBindGroupLayoutDescriptor`, `GpuDevice`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn create_bind_group_layout( + this: &GpuDevice, + descriptor: &GpuBindGroupLayoutDescriptor, + ) -> GpuBindGroupLayout; + + # [wasm_bindgen (method , structural , js_class = "GPUDevice" , js_name = createBuffer)] + #[doc = "The `createBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUDevice/createBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuBufferDescriptor`, `GpuDevice`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn create_buffer(this: &GpuDevice, descriptor: &GpuBufferDescriptor) -> GpuBuffer; + + # [wasm_bindgen (method , structural , js_class = "GPUDevice" , js_name = createCommandEncoder)] + #[doc = "The `createCommandEncoder()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUDevice/createCommandEncoder)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCommandEncoder`, `GpuDevice`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn create_command_encoder(this: &GpuDevice) -> GpuCommandEncoder; + + # [wasm_bindgen (method , structural , js_class = "GPUDevice" , js_name = createCommandEncoder)] + #[doc = "The `createCommandEncoder()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUDevice/createCommandEncoder)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCommandEncoder`, `GpuCommandEncoderDescriptor`, `GpuDevice`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn create_command_encoder_with_descriptor( + this: &GpuDevice, + descriptor: &GpuCommandEncoderDescriptor, + ) -> GpuCommandEncoder; + + # [wasm_bindgen (method , structural , js_class = "GPUDevice" , js_name = createComputePipeline)] + #[doc = "The `createComputePipeline()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUDevice/createComputePipeline)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuComputePipeline`, `GpuComputePipelineDescriptor`, `GpuDevice`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn create_compute_pipeline( + this: &GpuDevice, + descriptor: &GpuComputePipelineDescriptor, + ) -> GpuComputePipeline; + + # [wasm_bindgen (method , structural , js_class = "GPUDevice" , js_name = createComputePipelineAsync)] + #[doc = "The `createComputePipelineAsync()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUDevice/createComputePipelineAsync)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuComputePipelineDescriptor`, `GpuDevice`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn create_compute_pipeline_async( + this: &GpuDevice, + descriptor: &GpuComputePipelineDescriptor, + ) -> ::js_sys::Promise; + + # [wasm_bindgen (method , structural , js_class = "GPUDevice" , js_name = createPipelineLayout)] + #[doc = "The `createPipelineLayout()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUDevice/createPipelineLayout)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuDevice`, `GpuPipelineLayout`, `GpuPipelineLayoutDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn create_pipeline_layout( + this: &GpuDevice, + descriptor: &GpuPipelineLayoutDescriptor, + ) -> GpuPipelineLayout; + + # [wasm_bindgen (method , structural , js_class = "GPUDevice" , js_name = createQuerySet)] + #[doc = "The `createQuerySet()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUDevice/createQuerySet)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuDevice`, `GpuQuerySet`, `GpuQuerySetDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn create_query_set(this: &GpuDevice, descriptor: &GpuQuerySetDescriptor) -> GpuQuerySet; + + # [wasm_bindgen (method , structural , js_class = "GPUDevice" , js_name = createRenderBundleEncoder)] + #[doc = "The `createRenderBundleEncoder()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUDevice/createRenderBundleEncoder)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuDevice`, `GpuRenderBundleEncoder`, `GpuRenderBundleEncoderDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn create_render_bundle_encoder( + this: &GpuDevice, + descriptor: &GpuRenderBundleEncoderDescriptor, + ) -> GpuRenderBundleEncoder; + + # [wasm_bindgen (method , structural , js_class = "GPUDevice" , js_name = createRenderPipeline)] + #[doc = "The `createRenderPipeline()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUDevice/createRenderPipeline)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuDevice`, `GpuRenderPipeline`, `GpuRenderPipelineDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn create_render_pipeline( + this: &GpuDevice, + descriptor: &GpuRenderPipelineDescriptor, + ) -> GpuRenderPipeline; + + # [wasm_bindgen (method , structural , js_class = "GPUDevice" , js_name = createRenderPipelineAsync)] + #[doc = "The `createRenderPipelineAsync()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUDevice/createRenderPipelineAsync)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuDevice`, `GpuRenderPipelineDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn create_render_pipeline_async( + this: &GpuDevice, + descriptor: &GpuRenderPipelineDescriptor, + ) -> ::js_sys::Promise; + + # [wasm_bindgen (method , structural , js_class = "GPUDevice" , js_name = createSampler)] + #[doc = "The `createSampler()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUDevice/createSampler)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuDevice`, `GpuSampler`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn create_sampler(this: &GpuDevice) -> GpuSampler; + + # [wasm_bindgen (method , structural , js_class = "GPUDevice" , js_name = createSampler)] + #[doc = "The `createSampler()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUDevice/createSampler)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuDevice`, `GpuSampler`, `GpuSamplerDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn create_sampler_with_descriptor( + this: &GpuDevice, + descriptor: &GpuSamplerDescriptor, + ) -> GpuSampler; + + # [wasm_bindgen (method , structural , js_class = "GPUDevice" , js_name = createShaderModule)] + #[doc = "The `createShaderModule()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUDevice/createShaderModule)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuDevice`, `GpuShaderModule`, `GpuShaderModuleDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn create_shader_module( + this: &GpuDevice, + descriptor: &GpuShaderModuleDescriptor, + ) -> GpuShaderModule; + + # [wasm_bindgen (method , structural , js_class = "GPUDevice" , js_name = createTexture)] + #[doc = "The `createTexture()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUDevice/createTexture)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuDevice`, `GpuTexture`, `GpuTextureDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn create_texture(this: &GpuDevice, descriptor: &GpuTextureDescriptor) -> GpuTexture; + + # [wasm_bindgen (method , structural , js_class = "GPUDevice" , js_name = destroy)] + #[doc = "The `destroy()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUDevice/destroy)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuDevice`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn destroy(this: &GpuDevice); + + # [wasm_bindgen (method , structural , js_class = "GPUDevice" , js_name = importExternalTexture)] + #[doc = "The `importExternalTexture()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUDevice/importExternalTexture)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuDevice`, `GpuExternalTexture`, `GpuExternalTextureDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn import_external_texture( + this: &GpuDevice, + descriptor: &GpuExternalTextureDescriptor, + ) -> GpuExternalTexture; + + # [wasm_bindgen (method , structural , js_class = "GPUDevice" , js_name = popErrorScope)] + #[doc = "The `popErrorScope()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUDevice/popErrorScope)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuDevice`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn pop_error_scope(this: &GpuDevice) -> ::js_sys::Promise; + + # [wasm_bindgen (method , structural , js_class = "GPUDevice" , js_name = pushErrorScope)] + #[doc = "The `pushErrorScope()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUDevice/pushErrorScope)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuDevice`, `GpuErrorFilter`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn push_error_scope(this: &GpuDevice, filter: GpuErrorFilter); +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuDeviceDescriptor.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuDeviceDescriptor.rs new file mode 100644 index 0000000000..98ceb1a2d6 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuDeviceDescriptor.rs @@ -0,0 +1,103 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUDeviceDescriptor)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuDeviceDescriptor` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuDeviceDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuDeviceDescriptor; +} + +impl GpuDeviceDescriptor { + #[doc = "Construct a new `GpuDeviceDescriptor`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuDeviceDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new() -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret + } + + #[doc = "Change the `label` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuDeviceDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn label(&mut self, val: &str) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("label"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `defaultQueue` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuDeviceDescriptor`, `GpuQueueDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn default_queue(&mut self, val: &GpuQueueDescriptor) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("defaultQueue"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `requiredFeatures` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuDeviceDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn required_features(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("requiredFeatures"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} + +impl Default for GpuDeviceDescriptor { + fn default() -> Self { + Self::new() + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuDeviceLostInfo.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuDeviceLostInfo.rs new file mode 100644 index 0000000000..d2ac3682fe --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuDeviceLostInfo.rs @@ -0,0 +1,48 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUDeviceLostInfo , typescript_type = "GPUDeviceLostInfo")] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuDeviceLostInfo` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUDeviceLostInfo)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuDeviceLostInfo`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuDeviceLostInfo; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUDeviceLostInfo" , js_name = reason)] + #[doc = "Getter for the `reason` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUDeviceLostInfo/reason)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuDeviceLostInfo`, `GpuDeviceLostReason`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn reason(this: &GpuDeviceLostInfo) -> GpuDeviceLostReason; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUDeviceLostInfo" , js_name = message)] + #[doc = "Getter for the `message` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUDeviceLostInfo/message)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuDeviceLostInfo`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn message(this: &GpuDeviceLostInfo) -> String; +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuDeviceLostReason.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuDeviceLostReason.rs new file mode 100644 index 0000000000..d40e4dcce0 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuDeviceLostReason.rs @@ -0,0 +1,23 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +#[doc = "The `GpuDeviceLostReason` enum."] +#[doc = ""] +#[doc = "*This API requires the following crate features to be activated: `GpuDeviceLostReason`*"] +#[doc = ""] +#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] +#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum GpuDeviceLostReason { + Unknown = "unknown", + Destroyed = "destroyed", +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuError.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuError.rs new file mode 100644 index 0000000000..b79e34e855 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuError.rs @@ -0,0 +1,37 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUError , typescript_type = "GPUError")] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuError` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUError)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuError`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuError; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUError" , js_name = message)] + #[doc = "Getter for the `message` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUError/message)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuError`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn message(this: &GpuError) -> String; +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuErrorFilter.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuErrorFilter.rs new file mode 100644 index 0000000000..07b9d9efdd --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuErrorFilter.rs @@ -0,0 +1,24 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +#[doc = "The `GpuErrorFilter` enum."] +#[doc = ""] +#[doc = "*This API requires the following crate features to be activated: `GpuErrorFilter`*"] +#[doc = ""] +#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] +#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum GpuErrorFilter { + Validation = "validation", + OutOfMemory = "out-of-memory", + Internal = "internal", +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuExtent3dDict.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuExtent3dDict.rs new file mode 100644 index 0000000000..6367c27aef --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuExtent3dDict.rs @@ -0,0 +1,95 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUExtent3DDict)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuExtent3dDict` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuExtent3dDict`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuExtent3dDict; +} + +impl GpuExtent3dDict { + #[doc = "Construct a new `GpuExtent3dDict`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuExtent3dDict`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new(width: u32) -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret.width(width); + ret + } + + #[doc = "Change the `depthOrArrayLayers` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuExtent3dDict`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn depth_or_array_layers(&mut self, val: u32) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("depthOrArrayLayers"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `height` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuExtent3dDict`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn height(&mut self, val: u32) -> &mut Self { + use wasm_bindgen::JsValue; + let r = + ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("height"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `width` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuExtent3dDict`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn width(&mut self, val: u32) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("width"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuExternalTexture.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuExternalTexture.rs new file mode 100644 index 0000000000..3ba889d2b3 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuExternalTexture.rs @@ -0,0 +1,48 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUExternalTexture , typescript_type = "GPUExternalTexture")] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuExternalTexture` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUExternalTexture)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuExternalTexture`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuExternalTexture; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUExternalTexture" , js_name = label)] + #[doc = "Getter for the `label` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUExternalTexture/label)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuExternalTexture`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn label(this: &GpuExternalTexture) -> String; + + # [wasm_bindgen (structural , method , setter , js_class = "GPUExternalTexture" , js_name = label)] + #[doc = "Setter for the `label` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUExternalTexture/label)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuExternalTexture`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_label(this: &GpuExternalTexture, value: &str); +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuExternalTextureBindingLayout.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuExternalTextureBindingLayout.rs new file mode 100644 index 0000000000..993e1e8362 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuExternalTextureBindingLayout.rs @@ -0,0 +1,44 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUExternalTextureBindingLayout)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuExternalTextureBindingLayout` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuExternalTextureBindingLayout`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuExternalTextureBindingLayout; +} + +impl GpuExternalTextureBindingLayout { + #[doc = "Construct a new `GpuExternalTextureBindingLayout`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuExternalTextureBindingLayout`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new() -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret + } +} + +impl Default for GpuExternalTextureBindingLayout { + fn default() -> Self { + Self::new() + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuExternalTextureDescriptor.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuExternalTextureDescriptor.rs new file mode 100644 index 0000000000..67a15483ad --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuExternalTextureDescriptor.rs @@ -0,0 +1,74 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUExternalTextureDescriptor)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuExternalTextureDescriptor` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuExternalTextureDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuExternalTextureDescriptor; +} + +impl GpuExternalTextureDescriptor { + #[doc = "Construct a new `GpuExternalTextureDescriptor`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuExternalTextureDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new(source: &::js_sys::Object) -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret.source(source); + ret + } + + #[doc = "Change the `label` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuExternalTextureDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn label(&mut self, val: &str) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("label"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `source` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuExternalTextureDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn source(&mut self, val: &::js_sys::Object) -> &mut Self { + use wasm_bindgen::JsValue; + let r = + ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("source"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuFeatureName.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuFeatureName.rs new file mode 100644 index 0000000000..ed39a14c51 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuFeatureName.rs @@ -0,0 +1,32 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +#[doc = "The `GpuFeatureName` enum."] +#[doc = ""] +#[doc = "*This API requires the following crate features to be activated: `GpuFeatureName`*"] +#[doc = ""] +#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] +#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum GpuFeatureName { + DepthClipControl = "depth-clip-control", + Depth32floatStencil8 = "depth32float-stencil8", + TextureCompressionBc = "texture-compression-bc", + TextureCompressionEtc2 = "texture-compression-etc2", + TextureCompressionAstc = "texture-compression-astc", + TimestampQuery = "timestamp-query", + IndirectFirstInstance = "indirect-first-instance", + ShaderF16 = "shader-f16", + Rg11b10ufloatRenderable = "rg11b10ufloat-renderable", + Bgra8unormStorage = "bgra8unorm-storage", + Float32Filterable = "float32-filterable", +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuFilterMode.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuFilterMode.rs new file mode 100644 index 0000000000..6113531e9d --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuFilterMode.rs @@ -0,0 +1,23 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +#[doc = "The `GpuFilterMode` enum."] +#[doc = ""] +#[doc = "*This API requires the following crate features to be activated: `GpuFilterMode`*"] +#[doc = ""] +#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] +#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum GpuFilterMode { + Nearest = "nearest", + Linear = "linear", +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuFragmentState.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuFragmentState.rs new file mode 100644 index 0000000000..cd5c794219 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuFragmentState.rs @@ -0,0 +1,100 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUFragmentState)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuFragmentState` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuFragmentState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuFragmentState; +} + +impl GpuFragmentState { + #[doc = "Construct a new `GpuFragmentState`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuFragmentState`, `GpuShaderModule`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new(module: &GpuShaderModule, targets: &::wasm_bindgen::JsValue) -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret.module(module); + ret.targets(targets); + ret + } + + #[doc = "Change the `entryPoint` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuFragmentState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn entry_point(&mut self, val: &str) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("entryPoint"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `module` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuFragmentState`, `GpuShaderModule`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn module(&mut self, val: &GpuShaderModule) -> &mut Self { + use wasm_bindgen::JsValue; + let r = + ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("module"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `targets` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuFragmentState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn targets(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("targets"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuFrontFace.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuFrontFace.rs new file mode 100644 index 0000000000..5ecadfaaef --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuFrontFace.rs @@ -0,0 +1,23 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +#[doc = "The `GpuFrontFace` enum."] +#[doc = ""] +#[doc = "*This API requires the following crate features to be activated: `GpuFrontFace`*"] +#[doc = ""] +#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] +#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum GpuFrontFace { + Ccw = "ccw", + Cw = "cw", +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuImageCopyBuffer.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuImageCopyBuffer.rs new file mode 100644 index 0000000000..bb3655b635 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuImageCopyBuffer.rs @@ -0,0 +1,117 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUImageCopyBuffer)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuImageCopyBuffer` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuImageCopyBuffer`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuImageCopyBuffer; +} + +impl GpuImageCopyBuffer { + #[doc = "Construct a new `GpuImageCopyBuffer`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuImageCopyBuffer`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new(buffer: &GpuBuffer) -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret.buffer(buffer); + ret + } + + #[doc = "Change the `bytesPerRow` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuImageCopyBuffer`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn bytes_per_row(&mut self, val: u32) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("bytesPerRow"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `offset` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuImageCopyBuffer`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn offset(&mut self, val: f64) -> &mut Self { + use wasm_bindgen::JsValue; + let r = + ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("offset"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `rowsPerImage` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuImageCopyBuffer`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn rows_per_image(&mut self, val: u32) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("rowsPerImage"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `buffer` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuImageCopyBuffer`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn buffer(&mut self, val: &GpuBuffer) -> &mut Self { + use wasm_bindgen::JsValue; + let r = + ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("buffer"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuImageCopyExternalImage.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuImageCopyExternalImage.rs new file mode 100644 index 0000000000..8e37000dc2 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuImageCopyExternalImage.rs @@ -0,0 +1,92 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUImageCopyExternalImage)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuImageCopyExternalImage` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuImageCopyExternalImage`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuImageCopyExternalImage; +} + +impl GpuImageCopyExternalImage { + #[doc = "Construct a new `GpuImageCopyExternalImage`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuImageCopyExternalImage`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new(source: &::js_sys::Object) -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret.source(source); + ret + } + + #[doc = "Change the `flipY` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuImageCopyExternalImage`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn flip_y(&mut self, val: bool) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("flipY"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `origin` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuImageCopyExternalImage`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn origin(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self { + use wasm_bindgen::JsValue; + let r = + ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("origin"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `source` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuImageCopyExternalImage`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn source(&mut self, val: &::js_sys::Object) -> &mut Self { + use wasm_bindgen::JsValue; + let r = + ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("source"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuImageCopyTexture.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuImageCopyTexture.rs new file mode 100644 index 0000000000..40e33db1cf --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuImageCopyTexture.rs @@ -0,0 +1,117 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUImageCopyTexture)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuImageCopyTexture` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuImageCopyTexture`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuImageCopyTexture; +} + +impl GpuImageCopyTexture { + #[doc = "Construct a new `GpuImageCopyTexture`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuImageCopyTexture`, `GpuTexture`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new(texture: &GpuTexture) -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret.texture(texture); + ret + } + + #[doc = "Change the `aspect` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuImageCopyTexture`, `GpuTextureAspect`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn aspect(&mut self, val: GpuTextureAspect) -> &mut Self { + use wasm_bindgen::JsValue; + let r = + ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("aspect"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `mipLevel` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuImageCopyTexture`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn mip_level(&mut self, val: u32) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("mipLevel"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `origin` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuImageCopyTexture`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn origin(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self { + use wasm_bindgen::JsValue; + let r = + ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("origin"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `texture` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuImageCopyTexture`, `GpuTexture`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn texture(&mut self, val: &GpuTexture) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("texture"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuImageCopyTextureTagged.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuImageCopyTextureTagged.rs new file mode 100644 index 0000000000..0382477852 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuImageCopyTextureTagged.rs @@ -0,0 +1,138 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUImageCopyTextureTagged)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuImageCopyTextureTagged` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuImageCopyTextureTagged`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuImageCopyTextureTagged; +} + +impl GpuImageCopyTextureTagged { + #[doc = "Construct a new `GpuImageCopyTextureTagged`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuImageCopyTextureTagged`, `GpuTexture`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new(texture: &GpuTexture) -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret.texture(texture); + ret + } + + #[doc = "Change the `aspect` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuImageCopyTextureTagged`, `GpuTextureAspect`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn aspect(&mut self, val: GpuTextureAspect) -> &mut Self { + use wasm_bindgen::JsValue; + let r = + ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("aspect"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `mipLevel` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuImageCopyTextureTagged`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn mip_level(&mut self, val: u32) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("mipLevel"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `origin` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuImageCopyTextureTagged`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn origin(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self { + use wasm_bindgen::JsValue; + let r = + ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("origin"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `texture` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuImageCopyTextureTagged`, `GpuTexture`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn texture(&mut self, val: &GpuTexture) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("texture"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `premultipliedAlpha` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuImageCopyTextureTagged`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn premultiplied_alpha(&mut self, val: bool) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("premultipliedAlpha"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuImageDataLayout.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuImageDataLayout.rs new file mode 100644 index 0000000000..aa373814b1 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuImageDataLayout.rs @@ -0,0 +1,104 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUImageDataLayout)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuImageDataLayout` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuImageDataLayout`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuImageDataLayout; +} + +impl GpuImageDataLayout { + #[doc = "Construct a new `GpuImageDataLayout`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuImageDataLayout`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new() -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret + } + + #[doc = "Change the `bytesPerRow` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuImageDataLayout`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn bytes_per_row(&mut self, val: u32) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("bytesPerRow"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `offset` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuImageDataLayout`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn offset(&mut self, val: f64) -> &mut Self { + use wasm_bindgen::JsValue; + let r = + ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("offset"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `rowsPerImage` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuImageDataLayout`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn rows_per_image(&mut self, val: u32) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("rowsPerImage"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} + +impl Default for GpuImageDataLayout { + fn default() -> Self { + Self::new() + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuIndexFormat.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuIndexFormat.rs new file mode 100644 index 0000000000..e49411bdb0 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuIndexFormat.rs @@ -0,0 +1,23 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +#[doc = "The `GpuIndexFormat` enum."] +#[doc = ""] +#[doc = "*This API requires the following crate features to be activated: `GpuIndexFormat`*"] +#[doc = ""] +#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] +#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum GpuIndexFormat { + Uint16 = "uint16", + Uint32 = "uint32", +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuLoadOp.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuLoadOp.rs new file mode 100644 index 0000000000..2b341815a2 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuLoadOp.rs @@ -0,0 +1,23 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +#[doc = "The `GpuLoadOp` enum."] +#[doc = ""] +#[doc = "*This API requires the following crate features to be activated: `GpuLoadOp`*"] +#[doc = ""] +#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] +#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum GpuLoadOp { + Load = "load", + Clear = "clear", +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuMipmapFilterMode.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuMipmapFilterMode.rs new file mode 100644 index 0000000000..9a795f5a32 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuMipmapFilterMode.rs @@ -0,0 +1,23 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +#[doc = "The `GpuMipmapFilterMode` enum."] +#[doc = ""] +#[doc = "*This API requires the following crate features to be activated: `GpuMipmapFilterMode`*"] +#[doc = ""] +#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] +#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum GpuMipmapFilterMode { + Nearest = "nearest", + Linear = "linear", +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuMultisampleState.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuMultisampleState.rs new file mode 100644 index 0000000000..b6cdc5a849 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuMultisampleState.rs @@ -0,0 +1,99 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUMultisampleState)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuMultisampleState` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuMultisampleState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuMultisampleState; +} + +impl GpuMultisampleState { + #[doc = "Construct a new `GpuMultisampleState`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuMultisampleState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new() -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret + } + + #[doc = "Change the `alphaToCoverageEnabled` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuMultisampleState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn alpha_to_coverage_enabled(&mut self, val: bool) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("alphaToCoverageEnabled"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `count` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuMultisampleState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn count(&mut self, val: u32) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("count"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `mask` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuMultisampleState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn mask(&mut self, val: u32) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("mask"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} + +impl Default for GpuMultisampleState { + fn default() -> Self { + Self::new() + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuObjectDescriptorBase.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuObjectDescriptorBase.rs new file mode 100644 index 0000000000..072a83a096 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuObjectDescriptorBase.rs @@ -0,0 +1,61 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUObjectDescriptorBase)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuObjectDescriptorBase` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuObjectDescriptorBase`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuObjectDescriptorBase; +} + +impl GpuObjectDescriptorBase { + #[doc = "Construct a new `GpuObjectDescriptorBase`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuObjectDescriptorBase`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new() -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret + } + + #[doc = "Change the `label` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuObjectDescriptorBase`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn label(&mut self, val: &str) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("label"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} + +impl Default for GpuObjectDescriptorBase { + fn default() -> Self { + Self::new() + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuOrigin2dDict.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuOrigin2dDict.rs new file mode 100644 index 0000000000..d301235afd --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuOrigin2dDict.rs @@ -0,0 +1,78 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUOrigin2DDict)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuOrigin2dDict` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuOrigin2dDict`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuOrigin2dDict; +} + +impl GpuOrigin2dDict { + #[doc = "Construct a new `GpuOrigin2dDict`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuOrigin2dDict`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new() -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret + } + + #[doc = "Change the `x` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuOrigin2dDict`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn x(&mut self, val: u32) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("x"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `y` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuOrigin2dDict`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn y(&mut self, val: u32) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("y"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} + +impl Default for GpuOrigin2dDict { + fn default() -> Self { + Self::new() + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuOrigin3dDict.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuOrigin3dDict.rs new file mode 100644 index 0000000000..f93fbe4d82 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuOrigin3dDict.rs @@ -0,0 +1,95 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUOrigin3DDict)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuOrigin3dDict` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuOrigin3dDict`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuOrigin3dDict; +} + +impl GpuOrigin3dDict { + #[doc = "Construct a new `GpuOrigin3dDict`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuOrigin3dDict`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new() -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret + } + + #[doc = "Change the `x` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuOrigin3dDict`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn x(&mut self, val: u32) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("x"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `y` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuOrigin3dDict`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn y(&mut self, val: u32) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("y"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `z` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuOrigin3dDict`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn z(&mut self, val: u32) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("z"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} + +impl Default for GpuOrigin3dDict { + fn default() -> Self { + Self::new() + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuOutOfMemoryError.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuOutOfMemoryError.rs new file mode 100644 index 0000000000..b56ac35cdf --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuOutOfMemoryError.rs @@ -0,0 +1,37 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = GpuError , extends = :: js_sys :: Object , js_name = GPUOutOfMemoryError , typescript_type = "GPUOutOfMemoryError")] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuOutOfMemoryError` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUOutOfMemoryError)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuOutOfMemoryError`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuOutOfMemoryError; + + #[wasm_bindgen(catch, constructor, js_class = "GPUOutOfMemoryError")] + #[doc = "The `new GpuOutOfMemoryError(..)` constructor, creating a new instance of `GpuOutOfMemoryError`."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUOutOfMemoryError/GPUOutOfMemoryError)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuOutOfMemoryError`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new(message: &str) -> Result; +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuPipelineDescriptorBase.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuPipelineDescriptorBase.rs new file mode 100644 index 0000000000..4afd5f7fbb --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuPipelineDescriptorBase.rs @@ -0,0 +1,74 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUPipelineDescriptorBase)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuPipelineDescriptorBase` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuPipelineDescriptorBase`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuPipelineDescriptorBase; +} + +impl GpuPipelineDescriptorBase { + #[doc = "Construct a new `GpuPipelineDescriptorBase`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuPipelineDescriptorBase`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new(layout: &::wasm_bindgen::JsValue) -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret.layout(layout); + ret + } + + #[doc = "Change the `label` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuPipelineDescriptorBase`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn label(&mut self, val: &str) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("label"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `layout` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuPipelineDescriptorBase`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn layout(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self { + use wasm_bindgen::JsValue; + let r = + ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("layout"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuPipelineLayout.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuPipelineLayout.rs new file mode 100644 index 0000000000..6e3e1aedbf --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuPipelineLayout.rs @@ -0,0 +1,48 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUPipelineLayout , typescript_type = "GPUPipelineLayout")] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuPipelineLayout` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUPipelineLayout)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuPipelineLayout`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuPipelineLayout; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUPipelineLayout" , js_name = label)] + #[doc = "Getter for the `label` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUPipelineLayout/label)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuPipelineLayout`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn label(this: &GpuPipelineLayout) -> String; + + # [wasm_bindgen (structural , method , setter , js_class = "GPUPipelineLayout" , js_name = label)] + #[doc = "Setter for the `label` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUPipelineLayout/label)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuPipelineLayout`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_label(this: &GpuPipelineLayout, value: &str); +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuPipelineLayoutDescriptor.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuPipelineLayoutDescriptor.rs new file mode 100644 index 0000000000..6b574cbcf4 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuPipelineLayoutDescriptor.rs @@ -0,0 +1,77 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUPipelineLayoutDescriptor)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuPipelineLayoutDescriptor` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuPipelineLayoutDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuPipelineLayoutDescriptor; +} + +impl GpuPipelineLayoutDescriptor { + #[doc = "Construct a new `GpuPipelineLayoutDescriptor`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuPipelineLayoutDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new(bind_group_layouts: &::wasm_bindgen::JsValue) -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret.bind_group_layouts(bind_group_layouts); + ret + } + + #[doc = "Change the `label` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuPipelineLayoutDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn label(&mut self, val: &str) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("label"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `bindGroupLayouts` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuPipelineLayoutDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn bind_group_layouts(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("bindGroupLayouts"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuPowerPreference.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuPowerPreference.rs new file mode 100644 index 0000000000..996db271c4 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuPowerPreference.rs @@ -0,0 +1,23 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +#[doc = "The `GpuPowerPreference` enum."] +#[doc = ""] +#[doc = "*This API requires the following crate features to be activated: `GpuPowerPreference`*"] +#[doc = ""] +#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] +#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum GpuPowerPreference { + LowPower = "low-power", + HighPerformance = "high-performance", +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuPrimitiveState.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuPrimitiveState.rs new file mode 100644 index 0000000000..f347e493b3 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuPrimitiveState.rs @@ -0,0 +1,149 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUPrimitiveState)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuPrimitiveState` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuPrimitiveState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuPrimitiveState; +} + +impl GpuPrimitiveState { + #[doc = "Construct a new `GpuPrimitiveState`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuPrimitiveState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new() -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret + } + + #[doc = "Change the `cullMode` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCullMode`, `GpuPrimitiveState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn cull_mode(&mut self, val: GpuCullMode) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("cullMode"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `frontFace` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuFrontFace`, `GpuPrimitiveState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn front_face(&mut self, val: GpuFrontFace) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("frontFace"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `stripIndexFormat` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuIndexFormat`, `GpuPrimitiveState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn strip_index_format(&mut self, val: GpuIndexFormat) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("stripIndexFormat"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `topology` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuPrimitiveState`, `GpuPrimitiveTopology`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn topology(&mut self, val: GpuPrimitiveTopology) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("topology"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `unclippedDepth` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuPrimitiveState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn unclipped_depth(&mut self, val: bool) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("unclippedDepth"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} + +impl Default for GpuPrimitiveState { + fn default() -> Self { + Self::new() + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuPrimitiveTopology.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuPrimitiveTopology.rs new file mode 100644 index 0000000000..6d7972c331 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuPrimitiveTopology.rs @@ -0,0 +1,26 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +#[doc = "The `GpuPrimitiveTopology` enum."] +#[doc = ""] +#[doc = "*This API requires the following crate features to be activated: `GpuPrimitiveTopology`*"] +#[doc = ""] +#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] +#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum GpuPrimitiveTopology { + PointList = "point-list", + LineList = "line-list", + LineStrip = "line-strip", + TriangleList = "triangle-list", + TriangleStrip = "triangle-strip", +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuProgrammableStage.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuProgrammableStage.rs new file mode 100644 index 0000000000..761bf6bfbf --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuProgrammableStage.rs @@ -0,0 +1,78 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUProgrammableStage)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuProgrammableStage` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuProgrammableStage`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuProgrammableStage; +} + +impl GpuProgrammableStage { + #[doc = "Construct a new `GpuProgrammableStage`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuProgrammableStage`, `GpuShaderModule`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new(module: &GpuShaderModule) -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret.module(module); + ret + } + + #[doc = "Change the `entryPoint` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuProgrammableStage`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn entry_point(&mut self, val: &str) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("entryPoint"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `module` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuProgrammableStage`, `GpuShaderModule`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn module(&mut self, val: &GpuShaderModule) -> &mut Self { + use wasm_bindgen::JsValue; + let r = + ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("module"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuQuerySet.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuQuerySet.rs new file mode 100644 index 0000000000..590ede3451 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuQuerySet.rs @@ -0,0 +1,81 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUQuerySet , typescript_type = "GPUQuerySet")] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuQuerySet` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQuerySet)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuQuerySet`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuQuerySet; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUQuerySet" , js_name = type)] + #[doc = "Getter for the `type` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQuerySet/type)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuQuerySet`, `GpuQueryType`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn type_(this: &GpuQuerySet) -> GpuQueryType; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUQuerySet" , js_name = count)] + #[doc = "Getter for the `count` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQuerySet/count)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuQuerySet`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn count(this: &GpuQuerySet) -> u32; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUQuerySet" , js_name = label)] + #[doc = "Getter for the `label` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQuerySet/label)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuQuerySet`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn label(this: &GpuQuerySet) -> String; + + # [wasm_bindgen (structural , method , setter , js_class = "GPUQuerySet" , js_name = label)] + #[doc = "Setter for the `label` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQuerySet/label)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuQuerySet`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_label(this: &GpuQuerySet, value: &str); + + # [wasm_bindgen (method , structural , js_class = "GPUQuerySet" , js_name = destroy)] + #[doc = "The `destroy()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQuerySet/destroy)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuQuerySet`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn destroy(this: &GpuQuerySet); +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuQuerySetDescriptor.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuQuerySetDescriptor.rs new file mode 100644 index 0000000000..174e9dd2a8 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuQuerySetDescriptor.rs @@ -0,0 +1,91 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUQuerySetDescriptor)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuQuerySetDescriptor` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuQuerySetDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuQuerySetDescriptor; +} + +impl GpuQuerySetDescriptor { + #[doc = "Construct a new `GpuQuerySetDescriptor`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuQuerySetDescriptor`, `GpuQueryType`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new(count: u32, type_: GpuQueryType) -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret.count(count); + ret.type_(type_); + ret + } + + #[doc = "Change the `label` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuQuerySetDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn label(&mut self, val: &str) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("label"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `count` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuQuerySetDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn count(&mut self, val: u32) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("count"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `type` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuQuerySetDescriptor`, `GpuQueryType`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn type_(&mut self, val: GpuQueryType) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("type"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuQueryType.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuQueryType.rs new file mode 100644 index 0000000000..2f7969e352 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuQueryType.rs @@ -0,0 +1,23 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +#[doc = "The `GpuQueryType` enum."] +#[doc = ""] +#[doc = "*This API requires the following crate features to be activated: `GpuQueryType`*"] +#[doc = ""] +#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] +#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum GpuQueryType { + Occlusion = "occlusion", + Timestamp = "timestamp", +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuQueue.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuQueue.rs new file mode 100644 index 0000000000..ed5647b749 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuQueue.rs @@ -0,0 +1,658 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUQueue , typescript_type = "GPUQueue")] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuQueue` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuQueue`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuQueue; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUQueue" , js_name = label)] + #[doc = "Getter for the `label` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/label)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuQueue`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn label(this: &GpuQueue) -> String; + + # [wasm_bindgen (structural , method , setter , js_class = "GPUQueue" , js_name = label)] + #[doc = "Setter for the `label` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/label)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuQueue`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_label(this: &GpuQueue, value: &str); + + # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = copyExternalImageToTexture)] + #[doc = "The `copyExternalImageToTexture()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/copyExternalImageToTexture)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuImageCopyExternalImage`, `GpuImageCopyTextureTagged`, `GpuQueue`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn copy_external_image_to_texture_with_u32_sequence( + this: &GpuQueue, + source: &GpuImageCopyExternalImage, + destination: &GpuImageCopyTextureTagged, + copy_size: &::wasm_bindgen::JsValue, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = copyExternalImageToTexture)] + #[doc = "The `copyExternalImageToTexture()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/copyExternalImageToTexture)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuExtent3dDict`, `GpuImageCopyExternalImage`, `GpuImageCopyTextureTagged`, `GpuQueue`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn copy_external_image_to_texture_with_gpu_extent_3d_dict( + this: &GpuQueue, + source: &GpuImageCopyExternalImage, + destination: &GpuImageCopyTextureTagged, + copy_size: &GpuExtent3dDict, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = onSubmittedWorkDone)] + #[doc = "The `onSubmittedWorkDone()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/onSubmittedWorkDone)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuQueue`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn on_submitted_work_done(this: &GpuQueue) -> ::js_sys::Promise; + + # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = submit)] + #[doc = "The `submit()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/submit)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuQueue`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn submit(this: &GpuQueue, command_buffers: &::wasm_bindgen::JsValue); + + # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + #[doc = "The `writeBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuQueue`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn write_buffer_with_u32_and_buffer_source( + this: &GpuQueue, + buffer: &GpuBuffer, + buffer_offset: u32, + data: &::js_sys::Object, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + #[doc = "The `writeBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuQueue`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn write_buffer_with_f64_and_buffer_source( + this: &GpuQueue, + buffer: &GpuBuffer, + buffer_offset: f64, + data: &::js_sys::Object, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + #[doc = "The `writeBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuQueue`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn write_buffer_with_u32_and_u8_array( + this: &GpuQueue, + buffer: &GpuBuffer, + buffer_offset: u32, + data: &[u8], + ); + + # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + #[doc = "The `writeBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuQueue`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn write_buffer_with_f64_and_u8_array( + this: &GpuQueue, + buffer: &GpuBuffer, + buffer_offset: f64, + data: &[u8], + ); + + # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + #[doc = "The `writeBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuQueue`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn write_buffer_with_u32_and_buffer_source_and_u32( + this: &GpuQueue, + buffer: &GpuBuffer, + buffer_offset: u32, + data: &::js_sys::Object, + data_offset: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + #[doc = "The `writeBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuQueue`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn write_buffer_with_f64_and_buffer_source_and_u32( + this: &GpuQueue, + buffer: &GpuBuffer, + buffer_offset: f64, + data: &::js_sys::Object, + data_offset: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + #[doc = "The `writeBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuQueue`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn write_buffer_with_u32_and_u8_array_and_u32( + this: &GpuQueue, + buffer: &GpuBuffer, + buffer_offset: u32, + data: &[u8], + data_offset: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + #[doc = "The `writeBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuQueue`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn write_buffer_with_f64_and_u8_array_and_u32( + this: &GpuQueue, + buffer: &GpuBuffer, + buffer_offset: f64, + data: &[u8], + data_offset: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + #[doc = "The `writeBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuQueue`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn write_buffer_with_u32_and_buffer_source_and_f64( + this: &GpuQueue, + buffer: &GpuBuffer, + buffer_offset: u32, + data: &::js_sys::Object, + data_offset: f64, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + #[doc = "The `writeBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuQueue`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn write_buffer_with_f64_and_buffer_source_and_f64( + this: &GpuQueue, + buffer: &GpuBuffer, + buffer_offset: f64, + data: &::js_sys::Object, + data_offset: f64, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + #[doc = "The `writeBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuQueue`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn write_buffer_with_u32_and_u8_array_and_f64( + this: &GpuQueue, + buffer: &GpuBuffer, + buffer_offset: u32, + data: &[u8], + data_offset: f64, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + #[doc = "The `writeBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuQueue`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn write_buffer_with_f64_and_u8_array_and_f64( + this: &GpuQueue, + buffer: &GpuBuffer, + buffer_offset: f64, + data: &[u8], + data_offset: f64, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + #[doc = "The `writeBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuQueue`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn write_buffer_with_u32_and_buffer_source_and_u32_and_u32( + this: &GpuQueue, + buffer: &GpuBuffer, + buffer_offset: u32, + data: &::js_sys::Object, + data_offset: u32, + size: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + #[doc = "The `writeBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuQueue`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn write_buffer_with_f64_and_buffer_source_and_u32_and_u32( + this: &GpuQueue, + buffer: &GpuBuffer, + buffer_offset: f64, + data: &::js_sys::Object, + data_offset: u32, + size: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + #[doc = "The `writeBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuQueue`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn write_buffer_with_u32_and_u8_array_and_u32_and_u32( + this: &GpuQueue, + buffer: &GpuBuffer, + buffer_offset: u32, + data: &[u8], + data_offset: u32, + size: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + #[doc = "The `writeBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuQueue`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn write_buffer_with_f64_and_u8_array_and_u32_and_u32( + this: &GpuQueue, + buffer: &GpuBuffer, + buffer_offset: f64, + data: &[u8], + data_offset: u32, + size: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + #[doc = "The `writeBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuQueue`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn write_buffer_with_u32_and_buffer_source_and_f64_and_u32( + this: &GpuQueue, + buffer: &GpuBuffer, + buffer_offset: u32, + data: &::js_sys::Object, + data_offset: f64, + size: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + #[doc = "The `writeBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuQueue`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn write_buffer_with_f64_and_buffer_source_and_f64_and_u32( + this: &GpuQueue, + buffer: &GpuBuffer, + buffer_offset: f64, + data: &::js_sys::Object, + data_offset: f64, + size: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + #[doc = "The `writeBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuQueue`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn write_buffer_with_u32_and_u8_array_and_f64_and_u32( + this: &GpuQueue, + buffer: &GpuBuffer, + buffer_offset: u32, + data: &[u8], + data_offset: f64, + size: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + #[doc = "The `writeBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuQueue`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn write_buffer_with_f64_and_u8_array_and_f64_and_u32( + this: &GpuQueue, + buffer: &GpuBuffer, + buffer_offset: f64, + data: &[u8], + data_offset: f64, + size: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + #[doc = "The `writeBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuQueue`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn write_buffer_with_u32_and_buffer_source_and_u32_and_f64( + this: &GpuQueue, + buffer: &GpuBuffer, + buffer_offset: u32, + data: &::js_sys::Object, + data_offset: u32, + size: f64, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + #[doc = "The `writeBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuQueue`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn write_buffer_with_f64_and_buffer_source_and_u32_and_f64( + this: &GpuQueue, + buffer: &GpuBuffer, + buffer_offset: f64, + data: &::js_sys::Object, + data_offset: u32, + size: f64, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + #[doc = "The `writeBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuQueue`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn write_buffer_with_u32_and_u8_array_and_u32_and_f64( + this: &GpuQueue, + buffer: &GpuBuffer, + buffer_offset: u32, + data: &[u8], + data_offset: u32, + size: f64, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + #[doc = "The `writeBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuQueue`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn write_buffer_with_f64_and_u8_array_and_u32_and_f64( + this: &GpuQueue, + buffer: &GpuBuffer, + buffer_offset: f64, + data: &[u8], + data_offset: u32, + size: f64, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + #[doc = "The `writeBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuQueue`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn write_buffer_with_u32_and_buffer_source_and_f64_and_f64( + this: &GpuQueue, + buffer: &GpuBuffer, + buffer_offset: u32, + data: &::js_sys::Object, + data_offset: f64, + size: f64, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + #[doc = "The `writeBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuQueue`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn write_buffer_with_f64_and_buffer_source_and_f64_and_f64( + this: &GpuQueue, + buffer: &GpuBuffer, + buffer_offset: f64, + data: &::js_sys::Object, + data_offset: f64, + size: f64, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + #[doc = "The `writeBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuQueue`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn write_buffer_with_u32_and_u8_array_and_f64_and_f64( + this: &GpuQueue, + buffer: &GpuBuffer, + buffer_offset: u32, + data: &[u8], + data_offset: f64, + size: f64, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeBuffer)] + #[doc = "The `writeBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuQueue`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn write_buffer_with_f64_and_u8_array_and_f64_and_f64( + this: &GpuQueue, + buffer: &GpuBuffer, + buffer_offset: f64, + data: &[u8], + data_offset: f64, + size: f64, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeTexture)] + #[doc = "The `writeTexture()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeTexture)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuImageCopyTexture`, `GpuImageDataLayout`, `GpuQueue`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn write_texture_with_buffer_source_and_u32_sequence( + this: &GpuQueue, + destination: &GpuImageCopyTexture, + data: &::js_sys::Object, + data_layout: &GpuImageDataLayout, + size: &::wasm_bindgen::JsValue, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeTexture)] + #[doc = "The `writeTexture()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeTexture)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuImageCopyTexture`, `GpuImageDataLayout`, `GpuQueue`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn write_texture_with_u8_array_and_u32_sequence( + this: &GpuQueue, + destination: &GpuImageCopyTexture, + data: &[u8], + data_layout: &GpuImageDataLayout, + size: &::wasm_bindgen::JsValue, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeTexture)] + #[doc = "The `writeTexture()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeTexture)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuExtent3dDict`, `GpuImageCopyTexture`, `GpuImageDataLayout`, `GpuQueue`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn write_texture_with_buffer_source_and_gpu_extent_3d_dict( + this: &GpuQueue, + destination: &GpuImageCopyTexture, + data: &::js_sys::Object, + data_layout: &GpuImageDataLayout, + size: &GpuExtent3dDict, + ); + + # [wasm_bindgen (method , structural , js_class = "GPUQueue" , js_name = writeTexture)] + #[doc = "The `writeTexture()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue/writeTexture)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuExtent3dDict`, `GpuImageCopyTexture`, `GpuImageDataLayout`, `GpuQueue`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn write_texture_with_u8_array_and_gpu_extent_3d_dict( + this: &GpuQueue, + destination: &GpuImageCopyTexture, + data: &[u8], + data_layout: &GpuImageDataLayout, + size: &GpuExtent3dDict, + ); +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuQueueDescriptor.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuQueueDescriptor.rs new file mode 100644 index 0000000000..527ea14638 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuQueueDescriptor.rs @@ -0,0 +1,61 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUQueueDescriptor)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuQueueDescriptor` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuQueueDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuQueueDescriptor; +} + +impl GpuQueueDescriptor { + #[doc = "Construct a new `GpuQueueDescriptor`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuQueueDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new() -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret + } + + #[doc = "Change the `label` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuQueueDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn label(&mut self, val: &str) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("label"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} + +impl Default for GpuQueueDescriptor { + fn default() -> Self { + Self::new() + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderBundle.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderBundle.rs new file mode 100644 index 0000000000..d2eaefa99d --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderBundle.rs @@ -0,0 +1,48 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPURenderBundle , typescript_type = "GPURenderBundle")] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuRenderBundle` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderBundle)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderBundle`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuRenderBundle; + + # [wasm_bindgen (structural , method , getter , js_class = "GPURenderBundle" , js_name = label)] + #[doc = "Getter for the `label` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderBundle/label)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderBundle`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn label(this: &GpuRenderBundle) -> String; + + # [wasm_bindgen (structural , method , setter , js_class = "GPURenderBundle" , js_name = label)] + #[doc = "Setter for the `label` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderBundle/label)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderBundle`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_label(this: &GpuRenderBundle, value: &str); +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderBundleDescriptor.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderBundleDescriptor.rs new file mode 100644 index 0000000000..9cf2df9145 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderBundleDescriptor.rs @@ -0,0 +1,61 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPURenderBundleDescriptor)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuRenderBundleDescriptor` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderBundleDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuRenderBundleDescriptor; +} + +impl GpuRenderBundleDescriptor { + #[doc = "Construct a new `GpuRenderBundleDescriptor`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderBundleDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new() -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret + } + + #[doc = "Change the `label` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderBundleDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn label(&mut self, val: &str) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("label"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} + +impl Default for GpuRenderBundleDescriptor { + fn default() -> Self { + Self::new() + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderBundleEncoder.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderBundleEncoder.rs new file mode 100644 index 0000000000..d73c71330d --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderBundleEncoder.rs @@ -0,0 +1,606 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPURenderBundleEncoder , typescript_type = "GPURenderBundleEncoder")] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuRenderBundleEncoder` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderBundleEncoder)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderBundleEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuRenderBundleEncoder; + + # [wasm_bindgen (structural , method , getter , js_class = "GPURenderBundleEncoder" , js_name = label)] + #[doc = "Getter for the `label` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderBundleEncoder/label)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderBundleEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn label(this: &GpuRenderBundleEncoder) -> String; + + # [wasm_bindgen (structural , method , setter , js_class = "GPURenderBundleEncoder" , js_name = label)] + #[doc = "Setter for the `label` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderBundleEncoder/label)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderBundleEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_label(this: &GpuRenderBundleEncoder, value: &str); + + # [wasm_bindgen (method , structural , js_class = "GPURenderBundleEncoder" , js_name = finish)] + #[doc = "The `finish()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderBundleEncoder/finish)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderBundle`, `GpuRenderBundleEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn finish(this: &GpuRenderBundleEncoder) -> GpuRenderBundle; + + # [wasm_bindgen (method , structural , js_class = "GPURenderBundleEncoder" , js_name = finish)] + #[doc = "The `finish()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderBundleEncoder/finish)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderBundle`, `GpuRenderBundleDescriptor`, `GpuRenderBundleEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn finish_with_descriptor( + this: &GpuRenderBundleEncoder, + descriptor: &GpuRenderBundleDescriptor, + ) -> GpuRenderBundle; + + # [wasm_bindgen (method , structural , js_class = "GPURenderBundleEncoder" , js_name = setBindGroup)] + #[doc = "The `setBindGroup()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderBundleEncoder/setBindGroup)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroup`, `GpuRenderBundleEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_bind_group( + this: &GpuRenderBundleEncoder, + index: u32, + bind_group: Option<&GpuBindGroup>, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderBundleEncoder" , js_name = setBindGroup)] + #[doc = "The `setBindGroup()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderBundleEncoder/setBindGroup)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroup`, `GpuRenderBundleEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_bind_group_with_u32_sequence( + this: &GpuRenderBundleEncoder, + index: u32, + bind_group: Option<&GpuBindGroup>, + dynamic_offsets: &::wasm_bindgen::JsValue, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderBundleEncoder" , js_name = setBindGroup)] + #[doc = "The `setBindGroup()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderBundleEncoder/setBindGroup)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroup`, `GpuRenderBundleEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_bind_group_with_u32_array_and_u32_and_dynamic_offsets_data_length( + this: &GpuRenderBundleEncoder, + index: u32, + bind_group: Option<&GpuBindGroup>, + dynamic_offsets_data: &[u32], + dynamic_offsets_data_start: u32, + dynamic_offsets_data_length: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderBundleEncoder" , js_name = setBindGroup)] + #[doc = "The `setBindGroup()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderBundleEncoder/setBindGroup)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroup`, `GpuRenderBundleEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_bind_group_with_u32_array_and_f64_and_dynamic_offsets_data_length( + this: &GpuRenderBundleEncoder, + index: u32, + bind_group: Option<&GpuBindGroup>, + dynamic_offsets_data: &[u32], + dynamic_offsets_data_start: f64, + dynamic_offsets_data_length: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderBundleEncoder" , js_name = insertDebugMarker)] + #[doc = "The `insertDebugMarker()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderBundleEncoder/insertDebugMarker)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderBundleEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn insert_debug_marker(this: &GpuRenderBundleEncoder, marker_label: &str); + + # [wasm_bindgen (method , structural , js_class = "GPURenderBundleEncoder" , js_name = popDebugGroup)] + #[doc = "The `popDebugGroup()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderBundleEncoder/popDebugGroup)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderBundleEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn pop_debug_group(this: &GpuRenderBundleEncoder); + + # [wasm_bindgen (method , structural , js_class = "GPURenderBundleEncoder" , js_name = pushDebugGroup)] + #[doc = "The `pushDebugGroup()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderBundleEncoder/pushDebugGroup)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderBundleEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn push_debug_group(this: &GpuRenderBundleEncoder, group_label: &str); + + # [wasm_bindgen (method , structural , js_class = "GPURenderBundleEncoder" , js_name = draw)] + #[doc = "The `draw()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderBundleEncoder/draw)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderBundleEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn draw(this: &GpuRenderBundleEncoder, vertex_count: u32); + + # [wasm_bindgen (method , structural , js_class = "GPURenderBundleEncoder" , js_name = draw)] + #[doc = "The `draw()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderBundleEncoder/draw)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderBundleEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn draw_with_instance_count( + this: &GpuRenderBundleEncoder, + vertex_count: u32, + instance_count: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderBundleEncoder" , js_name = draw)] + #[doc = "The `draw()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderBundleEncoder/draw)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderBundleEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn draw_with_instance_count_and_first_vertex( + this: &GpuRenderBundleEncoder, + vertex_count: u32, + instance_count: u32, + first_vertex: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderBundleEncoder" , js_name = draw)] + #[doc = "The `draw()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderBundleEncoder/draw)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderBundleEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn draw_with_instance_count_and_first_vertex_and_first_instance( + this: &GpuRenderBundleEncoder, + vertex_count: u32, + instance_count: u32, + first_vertex: u32, + first_instance: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderBundleEncoder" , js_name = drawIndexed)] + #[doc = "The `drawIndexed()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderBundleEncoder/drawIndexed)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderBundleEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn draw_indexed(this: &GpuRenderBundleEncoder, index_count: u32); + + # [wasm_bindgen (method , structural , js_class = "GPURenderBundleEncoder" , js_name = drawIndexed)] + #[doc = "The `drawIndexed()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderBundleEncoder/drawIndexed)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderBundleEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn draw_indexed_with_instance_count( + this: &GpuRenderBundleEncoder, + index_count: u32, + instance_count: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderBundleEncoder" , js_name = drawIndexed)] + #[doc = "The `drawIndexed()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderBundleEncoder/drawIndexed)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderBundleEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn draw_indexed_with_instance_count_and_first_index( + this: &GpuRenderBundleEncoder, + index_count: u32, + instance_count: u32, + first_index: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderBundleEncoder" , js_name = drawIndexed)] + #[doc = "The `drawIndexed()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderBundleEncoder/drawIndexed)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderBundleEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn draw_indexed_with_instance_count_and_first_index_and_base_vertex( + this: &GpuRenderBundleEncoder, + index_count: u32, + instance_count: u32, + first_index: u32, + base_vertex: i32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderBundleEncoder" , js_name = drawIndexed)] + #[doc = "The `drawIndexed()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderBundleEncoder/drawIndexed)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderBundleEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn draw_indexed_with_instance_count_and_first_index_and_base_vertex_and_first_instance( + this: &GpuRenderBundleEncoder, + index_count: u32, + instance_count: u32, + first_index: u32, + base_vertex: i32, + first_instance: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderBundleEncoder" , js_name = drawIndexedIndirect)] + #[doc = "The `drawIndexedIndirect()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderBundleEncoder/drawIndexedIndirect)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuRenderBundleEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn draw_indexed_indirect_with_u32( + this: &GpuRenderBundleEncoder, + indirect_buffer: &GpuBuffer, + indirect_offset: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderBundleEncoder" , js_name = drawIndexedIndirect)] + #[doc = "The `drawIndexedIndirect()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderBundleEncoder/drawIndexedIndirect)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuRenderBundleEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn draw_indexed_indirect_with_f64( + this: &GpuRenderBundleEncoder, + indirect_buffer: &GpuBuffer, + indirect_offset: f64, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderBundleEncoder" , js_name = drawIndirect)] + #[doc = "The `drawIndirect()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderBundleEncoder/drawIndirect)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuRenderBundleEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn draw_indirect_with_u32( + this: &GpuRenderBundleEncoder, + indirect_buffer: &GpuBuffer, + indirect_offset: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderBundleEncoder" , js_name = drawIndirect)] + #[doc = "The `drawIndirect()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderBundleEncoder/drawIndirect)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuRenderBundleEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn draw_indirect_with_f64( + this: &GpuRenderBundleEncoder, + indirect_buffer: &GpuBuffer, + indirect_offset: f64, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderBundleEncoder" , js_name = setIndexBuffer)] + #[doc = "The `setIndexBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderBundleEncoder/setIndexBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuIndexFormat`, `GpuRenderBundleEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_index_buffer( + this: &GpuRenderBundleEncoder, + buffer: &GpuBuffer, + index_format: GpuIndexFormat, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderBundleEncoder" , js_name = setIndexBuffer)] + #[doc = "The `setIndexBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderBundleEncoder/setIndexBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuIndexFormat`, `GpuRenderBundleEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_index_buffer_with_u32( + this: &GpuRenderBundleEncoder, + buffer: &GpuBuffer, + index_format: GpuIndexFormat, + offset: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderBundleEncoder" , js_name = setIndexBuffer)] + #[doc = "The `setIndexBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderBundleEncoder/setIndexBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuIndexFormat`, `GpuRenderBundleEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_index_buffer_with_f64( + this: &GpuRenderBundleEncoder, + buffer: &GpuBuffer, + index_format: GpuIndexFormat, + offset: f64, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderBundleEncoder" , js_name = setIndexBuffer)] + #[doc = "The `setIndexBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderBundleEncoder/setIndexBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuIndexFormat`, `GpuRenderBundleEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_index_buffer_with_u32_and_u32( + this: &GpuRenderBundleEncoder, + buffer: &GpuBuffer, + index_format: GpuIndexFormat, + offset: u32, + size: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderBundleEncoder" , js_name = setIndexBuffer)] + #[doc = "The `setIndexBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderBundleEncoder/setIndexBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuIndexFormat`, `GpuRenderBundleEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_index_buffer_with_f64_and_u32( + this: &GpuRenderBundleEncoder, + buffer: &GpuBuffer, + index_format: GpuIndexFormat, + offset: f64, + size: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderBundleEncoder" , js_name = setIndexBuffer)] + #[doc = "The `setIndexBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderBundleEncoder/setIndexBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuIndexFormat`, `GpuRenderBundleEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_index_buffer_with_u32_and_f64( + this: &GpuRenderBundleEncoder, + buffer: &GpuBuffer, + index_format: GpuIndexFormat, + offset: u32, + size: f64, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderBundleEncoder" , js_name = setIndexBuffer)] + #[doc = "The `setIndexBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderBundleEncoder/setIndexBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuIndexFormat`, `GpuRenderBundleEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_index_buffer_with_f64_and_f64( + this: &GpuRenderBundleEncoder, + buffer: &GpuBuffer, + index_format: GpuIndexFormat, + offset: f64, + size: f64, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderBundleEncoder" , js_name = setPipeline)] + #[doc = "The `setPipeline()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderBundleEncoder/setPipeline)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderBundleEncoder`, `GpuRenderPipeline`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_pipeline(this: &GpuRenderBundleEncoder, pipeline: &GpuRenderPipeline); + + # [wasm_bindgen (method , structural , js_class = "GPURenderBundleEncoder" , js_name = setVertexBuffer)] + #[doc = "The `setVertexBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderBundleEncoder/setVertexBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuRenderBundleEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_vertex_buffer(this: &GpuRenderBundleEncoder, slot: u32, buffer: Option<&GpuBuffer>); + + # [wasm_bindgen (method , structural , js_class = "GPURenderBundleEncoder" , js_name = setVertexBuffer)] + #[doc = "The `setVertexBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderBundleEncoder/setVertexBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuRenderBundleEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_vertex_buffer_with_u32( + this: &GpuRenderBundleEncoder, + slot: u32, + buffer: Option<&GpuBuffer>, + offset: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderBundleEncoder" , js_name = setVertexBuffer)] + #[doc = "The `setVertexBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderBundleEncoder/setVertexBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuRenderBundleEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_vertex_buffer_with_f64( + this: &GpuRenderBundleEncoder, + slot: u32, + buffer: Option<&GpuBuffer>, + offset: f64, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderBundleEncoder" , js_name = setVertexBuffer)] + #[doc = "The `setVertexBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderBundleEncoder/setVertexBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuRenderBundleEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_vertex_buffer_with_u32_and_u32( + this: &GpuRenderBundleEncoder, + slot: u32, + buffer: Option<&GpuBuffer>, + offset: u32, + size: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderBundleEncoder" , js_name = setVertexBuffer)] + #[doc = "The `setVertexBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderBundleEncoder/setVertexBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuRenderBundleEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_vertex_buffer_with_f64_and_u32( + this: &GpuRenderBundleEncoder, + slot: u32, + buffer: Option<&GpuBuffer>, + offset: f64, + size: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderBundleEncoder" , js_name = setVertexBuffer)] + #[doc = "The `setVertexBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderBundleEncoder/setVertexBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuRenderBundleEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_vertex_buffer_with_u32_and_f64( + this: &GpuRenderBundleEncoder, + slot: u32, + buffer: Option<&GpuBuffer>, + offset: u32, + size: f64, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderBundleEncoder" , js_name = setVertexBuffer)] + #[doc = "The `setVertexBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderBundleEncoder/setVertexBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuRenderBundleEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_vertex_buffer_with_f64_and_f64( + this: &GpuRenderBundleEncoder, + slot: u32, + buffer: Option<&GpuBuffer>, + offset: f64, + size: f64, + ); +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderBundleEncoderDescriptor.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderBundleEncoderDescriptor.rs new file mode 100644 index 0000000000..e2bef72547 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderBundleEncoderDescriptor.rs @@ -0,0 +1,161 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPURenderBundleEncoderDescriptor)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuRenderBundleEncoderDescriptor` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderBundleEncoderDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuRenderBundleEncoderDescriptor; +} + +impl GpuRenderBundleEncoderDescriptor { + #[doc = "Construct a new `GpuRenderBundleEncoderDescriptor`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderBundleEncoderDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new(color_formats: &::wasm_bindgen::JsValue) -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret.color_formats(color_formats); + ret + } + + #[doc = "Change the `label` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderBundleEncoderDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn label(&mut self, val: &str) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("label"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `colorFormats` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderBundleEncoderDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn color_formats(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("colorFormats"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `depthStencilFormat` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderBundleEncoderDescriptor`, `GpuTextureFormat`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn depth_stencil_format(&mut self, val: GpuTextureFormat) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("depthStencilFormat"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `sampleCount` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderBundleEncoderDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn sample_count(&mut self, val: u32) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("sampleCount"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `depthReadOnly` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderBundleEncoderDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn depth_read_only(&mut self, val: bool) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("depthReadOnly"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `stencilReadOnly` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderBundleEncoderDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn stencil_read_only(&mut self, val: bool) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("stencilReadOnly"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderPassColorAttachment.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderPassColorAttachment.rs new file mode 100644 index 0000000000..dedf8dc8e2 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderPassColorAttachment.rs @@ -0,0 +1,160 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPURenderPassColorAttachment)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuRenderPassColorAttachment` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPassColorAttachment`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuRenderPassColorAttachment; +} + +impl GpuRenderPassColorAttachment { + #[doc = "Construct a new `GpuRenderPassColorAttachment`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuLoadOp`, `GpuRenderPassColorAttachment`, `GpuStoreOp`, `GpuTextureView`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new(load_op: GpuLoadOp, store_op: GpuStoreOp, view: &GpuTextureView) -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret.load_op(load_op); + ret.store_op(store_op); + ret.view(view); + ret + } + + #[doc = "Change the `clearValue` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPassColorAttachment`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn clear_value(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("clearValue"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `depthSlice` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPassColorAttachment`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn depth_slice(&mut self, val: u32) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("depthSlice"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `loadOp` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuLoadOp`, `GpuRenderPassColorAttachment`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn load_op(&mut self, val: GpuLoadOp) -> &mut Self { + use wasm_bindgen::JsValue; + let r = + ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("loadOp"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `resolveTarget` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPassColorAttachment`, `GpuTextureView`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn resolve_target(&mut self, val: &GpuTextureView) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("resolveTarget"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `storeOp` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPassColorAttachment`, `GpuStoreOp`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn store_op(&mut self, val: GpuStoreOp) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("storeOp"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `view` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPassColorAttachment`, `GpuTextureView`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn view(&mut self, val: &GpuTextureView) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("view"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderPassDepthStencilAttachment.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderPassDepthStencilAttachment.rs new file mode 100644 index 0000000000..cc0f290f4b --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderPassDepthStencilAttachment.rs @@ -0,0 +1,224 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPURenderPassDepthStencilAttachment)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuRenderPassDepthStencilAttachment` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPassDepthStencilAttachment`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuRenderPassDepthStencilAttachment; +} + +impl GpuRenderPassDepthStencilAttachment { + #[doc = "Construct a new `GpuRenderPassDepthStencilAttachment`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPassDepthStencilAttachment`, `GpuTextureView`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new(view: &GpuTextureView) -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret.view(view); + ret + } + + #[doc = "Change the `depthClearValue` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPassDepthStencilAttachment`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn depth_clear_value(&mut self, val: f32) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("depthClearValue"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `depthLoadOp` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuLoadOp`, `GpuRenderPassDepthStencilAttachment`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn depth_load_op(&mut self, val: GpuLoadOp) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("depthLoadOp"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `depthReadOnly` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPassDepthStencilAttachment`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn depth_read_only(&mut self, val: bool) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("depthReadOnly"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `depthStoreOp` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPassDepthStencilAttachment`, `GpuStoreOp`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn depth_store_op(&mut self, val: GpuStoreOp) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("depthStoreOp"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `stencilClearValue` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPassDepthStencilAttachment`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn stencil_clear_value(&mut self, val: u32) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("stencilClearValue"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `stencilLoadOp` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuLoadOp`, `GpuRenderPassDepthStencilAttachment`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn stencil_load_op(&mut self, val: GpuLoadOp) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("stencilLoadOp"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `stencilReadOnly` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPassDepthStencilAttachment`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn stencil_read_only(&mut self, val: bool) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("stencilReadOnly"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `stencilStoreOp` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPassDepthStencilAttachment`, `GpuStoreOp`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn stencil_store_op(&mut self, val: GpuStoreOp) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("stencilStoreOp"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `view` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPassDepthStencilAttachment`, `GpuTextureView`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn view(&mut self, val: &GpuTextureView) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("view"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderPassDescriptor.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderPassDescriptor.rs new file mode 100644 index 0000000000..0f74b953a5 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderPassDescriptor.rs @@ -0,0 +1,164 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPURenderPassDescriptor)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuRenderPassDescriptor` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPassDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuRenderPassDescriptor; +} + +impl GpuRenderPassDescriptor { + #[doc = "Construct a new `GpuRenderPassDescriptor`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPassDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new(color_attachments: &::wasm_bindgen::JsValue) -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret.color_attachments(color_attachments); + ret + } + + #[doc = "Change the `label` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPassDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn label(&mut self, val: &str) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("label"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `colorAttachments` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPassDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn color_attachments(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("colorAttachments"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `depthStencilAttachment` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPassDepthStencilAttachment`, `GpuRenderPassDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn depth_stencil_attachment( + &mut self, + val: &GpuRenderPassDepthStencilAttachment, + ) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("depthStencilAttachment"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `maxDrawCount` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPassDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn max_draw_count(&mut self, val: f64) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("maxDrawCount"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `occlusionQuerySet` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuQuerySet`, `GpuRenderPassDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn occlusion_query_set(&mut self, val: &GpuQuerySet) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("occlusionQuerySet"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `timestampWrites` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPassDescriptor`, `GpuRenderPassTimestampWrites`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn timestamp_writes(&mut self, val: &GpuRenderPassTimestampWrites) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("timestampWrites"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderPassEncoder.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderPassEncoder.rs new file mode 100644 index 0000000000..87e735251a --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderPassEncoder.rs @@ -0,0 +1,694 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPURenderPassEncoder , typescript_type = "GPURenderPassEncoder")] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuRenderPassEncoder` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuRenderPassEncoder; + + # [wasm_bindgen (structural , method , getter , js_class = "GPURenderPassEncoder" , js_name = label)] + #[doc = "Getter for the `label` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder/label)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn label(this: &GpuRenderPassEncoder) -> String; + + # [wasm_bindgen (structural , method , setter , js_class = "GPURenderPassEncoder" , js_name = label)] + #[doc = "Setter for the `label` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder/label)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_label(this: &GpuRenderPassEncoder, value: &str); + + # [wasm_bindgen (method , structural , js_class = "GPURenderPassEncoder" , js_name = beginOcclusionQuery)] + #[doc = "The `beginOcclusionQuery()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder/beginOcclusionQuery)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn begin_occlusion_query(this: &GpuRenderPassEncoder, query_index: u32); + + # [wasm_bindgen (method , structural , js_class = "GPURenderPassEncoder" , js_name = end)] + #[doc = "The `end()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder/end)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn end(this: &GpuRenderPassEncoder); + + # [wasm_bindgen (method , structural , js_class = "GPURenderPassEncoder" , js_name = endOcclusionQuery)] + #[doc = "The `endOcclusionQuery()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder/endOcclusionQuery)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn end_occlusion_query(this: &GpuRenderPassEncoder); + + # [wasm_bindgen (method , structural , js_class = "GPURenderPassEncoder" , js_name = executeBundles)] + #[doc = "The `executeBundles()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder/executeBundles)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn execute_bundles(this: &GpuRenderPassEncoder, bundles: &::wasm_bindgen::JsValue); + + # [wasm_bindgen (method , structural , js_class = "GPURenderPassEncoder" , js_name = setBlendConstant)] + #[doc = "The `setBlendConstant()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder/setBlendConstant)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_blend_constant_with_f64_sequence( + this: &GpuRenderPassEncoder, + color: &::wasm_bindgen::JsValue, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderPassEncoder" , js_name = setBlendConstant)] + #[doc = "The `setBlendConstant()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder/setBlendConstant)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuColorDict`, `GpuRenderPassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_blend_constant_with_gpu_color_dict( + this: &GpuRenderPassEncoder, + color: &GpuColorDict, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderPassEncoder" , js_name = setScissorRect)] + #[doc = "The `setScissorRect()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder/setScissorRect)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_scissor_rect(this: &GpuRenderPassEncoder, x: u32, y: u32, width: u32, height: u32); + + # [wasm_bindgen (method , structural , js_class = "GPURenderPassEncoder" , js_name = setStencilReference)] + #[doc = "The `setStencilReference()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder/setStencilReference)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_stencil_reference(this: &GpuRenderPassEncoder, reference: u32); + + # [wasm_bindgen (method , structural , js_class = "GPURenderPassEncoder" , js_name = setViewport)] + #[doc = "The `setViewport()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder/setViewport)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_viewport( + this: &GpuRenderPassEncoder, + x: f32, + y: f32, + width: f32, + height: f32, + min_depth: f32, + max_depth: f32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderPassEncoder" , js_name = setBindGroup)] + #[doc = "The `setBindGroup()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder/setBindGroup)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroup`, `GpuRenderPassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_bind_group( + this: &GpuRenderPassEncoder, + index: u32, + bind_group: Option<&GpuBindGroup>, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderPassEncoder" , js_name = setBindGroup)] + #[doc = "The `setBindGroup()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder/setBindGroup)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroup`, `GpuRenderPassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_bind_group_with_u32_sequence( + this: &GpuRenderPassEncoder, + index: u32, + bind_group: Option<&GpuBindGroup>, + dynamic_offsets: &::wasm_bindgen::JsValue, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderPassEncoder" , js_name = setBindGroup)] + #[doc = "The `setBindGroup()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder/setBindGroup)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroup`, `GpuRenderPassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_bind_group_with_u32_array_and_u32_and_dynamic_offsets_data_length( + this: &GpuRenderPassEncoder, + index: u32, + bind_group: Option<&GpuBindGroup>, + dynamic_offsets_data: &[u32], + dynamic_offsets_data_start: u32, + dynamic_offsets_data_length: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderPassEncoder" , js_name = setBindGroup)] + #[doc = "The `setBindGroup()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder/setBindGroup)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroup`, `GpuRenderPassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_bind_group_with_u32_array_and_f64_and_dynamic_offsets_data_length( + this: &GpuRenderPassEncoder, + index: u32, + bind_group: Option<&GpuBindGroup>, + dynamic_offsets_data: &[u32], + dynamic_offsets_data_start: f64, + dynamic_offsets_data_length: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderPassEncoder" , js_name = insertDebugMarker)] + #[doc = "The `insertDebugMarker()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder/insertDebugMarker)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn insert_debug_marker(this: &GpuRenderPassEncoder, marker_label: &str); + + # [wasm_bindgen (method , structural , js_class = "GPURenderPassEncoder" , js_name = popDebugGroup)] + #[doc = "The `popDebugGroup()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder/popDebugGroup)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn pop_debug_group(this: &GpuRenderPassEncoder); + + # [wasm_bindgen (method , structural , js_class = "GPURenderPassEncoder" , js_name = pushDebugGroup)] + #[doc = "The `pushDebugGroup()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder/pushDebugGroup)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn push_debug_group(this: &GpuRenderPassEncoder, group_label: &str); + + # [wasm_bindgen (method , structural , js_class = "GPURenderPassEncoder" , js_name = draw)] + #[doc = "The `draw()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder/draw)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn draw(this: &GpuRenderPassEncoder, vertex_count: u32); + + # [wasm_bindgen (method , structural , js_class = "GPURenderPassEncoder" , js_name = draw)] + #[doc = "The `draw()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder/draw)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn draw_with_instance_count( + this: &GpuRenderPassEncoder, + vertex_count: u32, + instance_count: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderPassEncoder" , js_name = draw)] + #[doc = "The `draw()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder/draw)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn draw_with_instance_count_and_first_vertex( + this: &GpuRenderPassEncoder, + vertex_count: u32, + instance_count: u32, + first_vertex: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderPassEncoder" , js_name = draw)] + #[doc = "The `draw()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder/draw)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn draw_with_instance_count_and_first_vertex_and_first_instance( + this: &GpuRenderPassEncoder, + vertex_count: u32, + instance_count: u32, + first_vertex: u32, + first_instance: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderPassEncoder" , js_name = drawIndexed)] + #[doc = "The `drawIndexed()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder/drawIndexed)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn draw_indexed(this: &GpuRenderPassEncoder, index_count: u32); + + # [wasm_bindgen (method , structural , js_class = "GPURenderPassEncoder" , js_name = drawIndexed)] + #[doc = "The `drawIndexed()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder/drawIndexed)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn draw_indexed_with_instance_count( + this: &GpuRenderPassEncoder, + index_count: u32, + instance_count: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderPassEncoder" , js_name = drawIndexed)] + #[doc = "The `drawIndexed()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder/drawIndexed)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn draw_indexed_with_instance_count_and_first_index( + this: &GpuRenderPassEncoder, + index_count: u32, + instance_count: u32, + first_index: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderPassEncoder" , js_name = drawIndexed)] + #[doc = "The `drawIndexed()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder/drawIndexed)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn draw_indexed_with_instance_count_and_first_index_and_base_vertex( + this: &GpuRenderPassEncoder, + index_count: u32, + instance_count: u32, + first_index: u32, + base_vertex: i32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderPassEncoder" , js_name = drawIndexed)] + #[doc = "The `drawIndexed()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder/drawIndexed)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn draw_indexed_with_instance_count_and_first_index_and_base_vertex_and_first_instance( + this: &GpuRenderPassEncoder, + index_count: u32, + instance_count: u32, + first_index: u32, + base_vertex: i32, + first_instance: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderPassEncoder" , js_name = drawIndexedIndirect)] + #[doc = "The `drawIndexedIndirect()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder/drawIndexedIndirect)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuRenderPassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn draw_indexed_indirect_with_u32( + this: &GpuRenderPassEncoder, + indirect_buffer: &GpuBuffer, + indirect_offset: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderPassEncoder" , js_name = drawIndexedIndirect)] + #[doc = "The `drawIndexedIndirect()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder/drawIndexedIndirect)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuRenderPassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn draw_indexed_indirect_with_f64( + this: &GpuRenderPassEncoder, + indirect_buffer: &GpuBuffer, + indirect_offset: f64, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderPassEncoder" , js_name = drawIndirect)] + #[doc = "The `drawIndirect()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder/drawIndirect)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuRenderPassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn draw_indirect_with_u32( + this: &GpuRenderPassEncoder, + indirect_buffer: &GpuBuffer, + indirect_offset: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderPassEncoder" , js_name = drawIndirect)] + #[doc = "The `drawIndirect()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder/drawIndirect)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuRenderPassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn draw_indirect_with_f64( + this: &GpuRenderPassEncoder, + indirect_buffer: &GpuBuffer, + indirect_offset: f64, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderPassEncoder" , js_name = setIndexBuffer)] + #[doc = "The `setIndexBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder/setIndexBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuIndexFormat`, `GpuRenderPassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_index_buffer( + this: &GpuRenderPassEncoder, + buffer: &GpuBuffer, + index_format: GpuIndexFormat, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderPassEncoder" , js_name = setIndexBuffer)] + #[doc = "The `setIndexBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder/setIndexBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuIndexFormat`, `GpuRenderPassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_index_buffer_with_u32( + this: &GpuRenderPassEncoder, + buffer: &GpuBuffer, + index_format: GpuIndexFormat, + offset: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderPassEncoder" , js_name = setIndexBuffer)] + #[doc = "The `setIndexBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder/setIndexBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuIndexFormat`, `GpuRenderPassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_index_buffer_with_f64( + this: &GpuRenderPassEncoder, + buffer: &GpuBuffer, + index_format: GpuIndexFormat, + offset: f64, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderPassEncoder" , js_name = setIndexBuffer)] + #[doc = "The `setIndexBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder/setIndexBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuIndexFormat`, `GpuRenderPassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_index_buffer_with_u32_and_u32( + this: &GpuRenderPassEncoder, + buffer: &GpuBuffer, + index_format: GpuIndexFormat, + offset: u32, + size: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderPassEncoder" , js_name = setIndexBuffer)] + #[doc = "The `setIndexBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder/setIndexBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuIndexFormat`, `GpuRenderPassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_index_buffer_with_f64_and_u32( + this: &GpuRenderPassEncoder, + buffer: &GpuBuffer, + index_format: GpuIndexFormat, + offset: f64, + size: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderPassEncoder" , js_name = setIndexBuffer)] + #[doc = "The `setIndexBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder/setIndexBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuIndexFormat`, `GpuRenderPassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_index_buffer_with_u32_and_f64( + this: &GpuRenderPassEncoder, + buffer: &GpuBuffer, + index_format: GpuIndexFormat, + offset: u32, + size: f64, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderPassEncoder" , js_name = setIndexBuffer)] + #[doc = "The `setIndexBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder/setIndexBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuIndexFormat`, `GpuRenderPassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_index_buffer_with_f64_and_f64( + this: &GpuRenderPassEncoder, + buffer: &GpuBuffer, + index_format: GpuIndexFormat, + offset: f64, + size: f64, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderPassEncoder" , js_name = setPipeline)] + #[doc = "The `setPipeline()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder/setPipeline)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPassEncoder`, `GpuRenderPipeline`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_pipeline(this: &GpuRenderPassEncoder, pipeline: &GpuRenderPipeline); + + # [wasm_bindgen (method , structural , js_class = "GPURenderPassEncoder" , js_name = setVertexBuffer)] + #[doc = "The `setVertexBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder/setVertexBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuRenderPassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_vertex_buffer(this: &GpuRenderPassEncoder, slot: u32, buffer: Option<&GpuBuffer>); + + # [wasm_bindgen (method , structural , js_class = "GPURenderPassEncoder" , js_name = setVertexBuffer)] + #[doc = "The `setVertexBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder/setVertexBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuRenderPassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_vertex_buffer_with_u32( + this: &GpuRenderPassEncoder, + slot: u32, + buffer: Option<&GpuBuffer>, + offset: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderPassEncoder" , js_name = setVertexBuffer)] + #[doc = "The `setVertexBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder/setVertexBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuRenderPassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_vertex_buffer_with_f64( + this: &GpuRenderPassEncoder, + slot: u32, + buffer: Option<&GpuBuffer>, + offset: f64, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderPassEncoder" , js_name = setVertexBuffer)] + #[doc = "The `setVertexBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder/setVertexBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuRenderPassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_vertex_buffer_with_u32_and_u32( + this: &GpuRenderPassEncoder, + slot: u32, + buffer: Option<&GpuBuffer>, + offset: u32, + size: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderPassEncoder" , js_name = setVertexBuffer)] + #[doc = "The `setVertexBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder/setVertexBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuRenderPassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_vertex_buffer_with_f64_and_u32( + this: &GpuRenderPassEncoder, + slot: u32, + buffer: Option<&GpuBuffer>, + offset: f64, + size: u32, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderPassEncoder" , js_name = setVertexBuffer)] + #[doc = "The `setVertexBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder/setVertexBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuRenderPassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_vertex_buffer_with_u32_and_f64( + this: &GpuRenderPassEncoder, + slot: u32, + buffer: Option<&GpuBuffer>, + offset: u32, + size: f64, + ); + + # [wasm_bindgen (method , structural , js_class = "GPURenderPassEncoder" , js_name = setVertexBuffer)] + #[doc = "The `setVertexBuffer()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPassEncoder/setVertexBuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuRenderPassEncoder`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_vertex_buffer_with_f64_and_f64( + this: &GpuRenderPassEncoder, + slot: u32, + buffer: Option<&GpuBuffer>, + offset: f64, + size: f64, + ); +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderPassTimestampWrites.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderPassTimestampWrites.rs new file mode 100644 index 0000000000..ef2c09e4bf --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderPassTimestampWrites.rs @@ -0,0 +1,102 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPURenderPassTimestampWrites)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuRenderPassTimestampWrites` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPassTimestampWrites`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuRenderPassTimestampWrites; +} + +impl GpuRenderPassTimestampWrites { + #[doc = "Construct a new `GpuRenderPassTimestampWrites`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuQuerySet`, `GpuRenderPassTimestampWrites`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new(query_set: &GpuQuerySet) -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret.query_set(query_set); + ret + } + + #[doc = "Change the `beginningOfPassWriteIndex` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPassTimestampWrites`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn beginning_of_pass_write_index(&mut self, val: u32) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("beginningOfPassWriteIndex"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `endOfPassWriteIndex` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPassTimestampWrites`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn end_of_pass_write_index(&mut self, val: u32) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("endOfPassWriteIndex"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `querySet` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuQuerySet`, `GpuRenderPassTimestampWrites`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn query_set(&mut self, val: &GpuQuerySet) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("querySet"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderPipeline.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderPipeline.rs new file mode 100644 index 0000000000..59a1634421 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderPipeline.rs @@ -0,0 +1,59 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPURenderPipeline , typescript_type = "GPURenderPipeline")] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuRenderPipeline` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPipeline)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPipeline`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuRenderPipeline; + + # [wasm_bindgen (structural , method , getter , js_class = "GPURenderPipeline" , js_name = label)] + #[doc = "Getter for the `label` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPipeline/label)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPipeline`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn label(this: &GpuRenderPipeline) -> String; + + # [wasm_bindgen (structural , method , setter , js_class = "GPURenderPipeline" , js_name = label)] + #[doc = "Setter for the `label` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPipeline/label)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPipeline`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_label(this: &GpuRenderPipeline, value: &str); + + # [wasm_bindgen (method , structural , js_class = "GPURenderPipeline" , js_name = getBindGroupLayout)] + #[doc = "The `getBindGroupLayout()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPURenderPipeline/getBindGroupLayout)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayout`, `GpuRenderPipeline`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn get_bind_group_layout(this: &GpuRenderPipeline, index: u32) -> GpuBindGroupLayout; +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderPipelineDescriptor.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderPipelineDescriptor.rs new file mode 100644 index 0000000000..06a47432d8 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderPipelineDescriptor.rs @@ -0,0 +1,177 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPURenderPipelineDescriptor)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuRenderPipelineDescriptor` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPipelineDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuRenderPipelineDescriptor; +} + +impl GpuRenderPipelineDescriptor { + #[doc = "Construct a new `GpuRenderPipelineDescriptor`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPipelineDescriptor`, `GpuVertexState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new(layout: &::wasm_bindgen::JsValue, vertex: &GpuVertexState) -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret.layout(layout); + ret.vertex(vertex); + ret + } + + #[doc = "Change the `label` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPipelineDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn label(&mut self, val: &str) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("label"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `layout` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPipelineDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn layout(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self { + use wasm_bindgen::JsValue; + let r = + ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("layout"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `depthStencil` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuDepthStencilState`, `GpuRenderPipelineDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn depth_stencil(&mut self, val: &GpuDepthStencilState) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("depthStencil"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `fragment` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuFragmentState`, `GpuRenderPipelineDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn fragment(&mut self, val: &GpuFragmentState) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("fragment"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `multisample` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuMultisampleState`, `GpuRenderPipelineDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn multisample(&mut self, val: &GpuMultisampleState) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("multisample"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `primitive` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuPrimitiveState`, `GpuRenderPipelineDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn primitive(&mut self, val: &GpuPrimitiveState) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("primitive"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `vertex` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRenderPipelineDescriptor`, `GpuVertexState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn vertex(&mut self, val: &GpuVertexState) -> &mut Self { + use wasm_bindgen::JsValue; + let r = + ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("vertex"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRequestAdapterOptions.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRequestAdapterOptions.rs new file mode 100644 index 0000000000..947db22a75 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRequestAdapterOptions.rs @@ -0,0 +1,86 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPURequestAdapterOptions)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuRequestAdapterOptions` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRequestAdapterOptions`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuRequestAdapterOptions; +} + +impl GpuRequestAdapterOptions { + #[doc = "Construct a new `GpuRequestAdapterOptions`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRequestAdapterOptions`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new() -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret + } + + #[doc = "Change the `forceFallbackAdapter` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuRequestAdapterOptions`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn force_fallback_adapter(&mut self, val: bool) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("forceFallbackAdapter"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `powerPreference` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuPowerPreference`, `GpuRequestAdapterOptions`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn power_preference(&mut self, val: GpuPowerPreference) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("powerPreference"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} + +impl Default for GpuRequestAdapterOptions { + fn default() -> Self { + Self::new() + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuSampler.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuSampler.rs new file mode 100644 index 0000000000..c42656202c --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuSampler.rs @@ -0,0 +1,48 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUSampler , typescript_type = "GPUSampler")] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuSampler` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUSampler)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSampler`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuSampler; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUSampler" , js_name = label)] + #[doc = "Getter for the `label` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUSampler/label)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSampler`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn label(this: &GpuSampler) -> String; + + # [wasm_bindgen (structural , method , setter , js_class = "GPUSampler" , js_name = label)] + #[doc = "Setter for the `label` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUSampler/label)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSampler`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_label(this: &GpuSampler, value: &str); +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuSamplerBindingLayout.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuSamplerBindingLayout.rs new file mode 100644 index 0000000000..a1973b9e38 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuSamplerBindingLayout.rs @@ -0,0 +1,61 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUSamplerBindingLayout)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuSamplerBindingLayout` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSamplerBindingLayout`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuSamplerBindingLayout; +} + +impl GpuSamplerBindingLayout { + #[doc = "Construct a new `GpuSamplerBindingLayout`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSamplerBindingLayout`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new() -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret + } + + #[doc = "Change the `type` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSamplerBindingLayout`, `GpuSamplerBindingType`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn type_(&mut self, val: GpuSamplerBindingType) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("type"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} + +impl Default for GpuSamplerBindingLayout { + fn default() -> Self { + Self::new() + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuSamplerBindingType.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuSamplerBindingType.rs new file mode 100644 index 0000000000..4d49ec529e --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuSamplerBindingType.rs @@ -0,0 +1,24 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +#[doc = "The `GpuSamplerBindingType` enum."] +#[doc = ""] +#[doc = "*This API requires the following crate features to be activated: `GpuSamplerBindingType`*"] +#[doc = ""] +#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] +#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum GpuSamplerBindingType { + Filtering = "filtering", + NonFiltering = "non-filtering", + Comparison = "comparison", +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuSamplerDescriptor.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuSamplerDescriptor.rs new file mode 100644 index 0000000000..3ecc89e195 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuSamplerDescriptor.rs @@ -0,0 +1,271 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUSamplerDescriptor)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuSamplerDescriptor` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSamplerDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuSamplerDescriptor; +} + +impl GpuSamplerDescriptor { + #[doc = "Construct a new `GpuSamplerDescriptor`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSamplerDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new() -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret + } + + #[doc = "Change the `label` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSamplerDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn label(&mut self, val: &str) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("label"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `addressModeU` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuAddressMode`, `GpuSamplerDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn address_mode_u(&mut self, val: GpuAddressMode) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("addressModeU"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `addressModeV` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuAddressMode`, `GpuSamplerDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn address_mode_v(&mut self, val: GpuAddressMode) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("addressModeV"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `addressModeW` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuAddressMode`, `GpuSamplerDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn address_mode_w(&mut self, val: GpuAddressMode) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("addressModeW"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `compare` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCompareFunction`, `GpuSamplerDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn compare(&mut self, val: GpuCompareFunction) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("compare"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `lodMaxClamp` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSamplerDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn lod_max_clamp(&mut self, val: f32) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("lodMaxClamp"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `lodMinClamp` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSamplerDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn lod_min_clamp(&mut self, val: f32) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("lodMinClamp"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `magFilter` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuFilterMode`, `GpuSamplerDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn mag_filter(&mut self, val: GpuFilterMode) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("magFilter"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `maxAnisotropy` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSamplerDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn max_anisotropy(&mut self, val: u16) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("maxAnisotropy"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `minFilter` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuFilterMode`, `GpuSamplerDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn min_filter(&mut self, val: GpuFilterMode) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("minFilter"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `mipmapFilter` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuMipmapFilterMode`, `GpuSamplerDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn mipmap_filter(&mut self, val: GpuMipmapFilterMode) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("mipmapFilter"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} + +impl Default for GpuSamplerDescriptor { + fn default() -> Self { + Self::new() + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuShaderModule.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuShaderModule.rs new file mode 100644 index 0000000000..1de5900a0b --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuShaderModule.rs @@ -0,0 +1,59 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUShaderModule , typescript_type = "GPUShaderModule")] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuShaderModule` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUShaderModule)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuShaderModule`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuShaderModule; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUShaderModule" , js_name = label)] + #[doc = "Getter for the `label` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUShaderModule/label)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuShaderModule`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn label(this: &GpuShaderModule) -> String; + + # [wasm_bindgen (structural , method , setter , js_class = "GPUShaderModule" , js_name = label)] + #[doc = "Setter for the `label` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUShaderModule/label)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuShaderModule`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_label(this: &GpuShaderModule, value: &str); + + # [wasm_bindgen (method , structural , js_class = "GPUShaderModule" , js_name = getCompilationInfo)] + #[doc = "The `getCompilationInfo()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUShaderModule/getCompilationInfo)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuShaderModule`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn get_compilation_info(this: &GpuShaderModule) -> ::js_sys::Promise; +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuShaderModuleDescriptor.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuShaderModuleDescriptor.rs new file mode 100644 index 0000000000..87cb3c0444 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuShaderModuleDescriptor.rs @@ -0,0 +1,115 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUShaderModuleDescriptor)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuShaderModuleDescriptor` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuShaderModuleDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuShaderModuleDescriptor; +} + +impl GpuShaderModuleDescriptor { + #[doc = "Construct a new `GpuShaderModuleDescriptor`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuShaderModuleDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new(code: &str) -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret.code(code); + ret + } + + #[doc = "Change the `label` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuShaderModuleDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn label(&mut self, val: &str) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("label"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `code` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuShaderModuleDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn code(&mut self, val: &str) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("code"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `compilationHints` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuShaderModuleDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn compilation_hints(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("compilationHints"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `sourceMap` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuShaderModuleDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn source_map(&mut self, val: &::js_sys::Object) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("sourceMap"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuStencilFaceState.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuStencilFaceState.rs new file mode 100644 index 0000000000..1e0f5509cc --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuStencilFaceState.rs @@ -0,0 +1,122 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUStencilFaceState)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuStencilFaceState` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuStencilFaceState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuStencilFaceState; +} + +impl GpuStencilFaceState { + #[doc = "Construct a new `GpuStencilFaceState`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuStencilFaceState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new() -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret + } + + #[doc = "Change the `compare` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuCompareFunction`, `GpuStencilFaceState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn compare(&mut self, val: GpuCompareFunction) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("compare"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `depthFailOp` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuStencilFaceState`, `GpuStencilOperation`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn depth_fail_op(&mut self, val: GpuStencilOperation) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("depthFailOp"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `failOp` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuStencilFaceState`, `GpuStencilOperation`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn fail_op(&mut self, val: GpuStencilOperation) -> &mut Self { + use wasm_bindgen::JsValue; + let r = + ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("failOp"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `passOp` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuStencilFaceState`, `GpuStencilOperation`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn pass_op(&mut self, val: GpuStencilOperation) -> &mut Self { + use wasm_bindgen::JsValue; + let r = + ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("passOp"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} + +impl Default for GpuStencilFaceState { + fn default() -> Self { + Self::new() + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuStencilOperation.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuStencilOperation.rs new file mode 100644 index 0000000000..6c6b7fa1c4 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuStencilOperation.rs @@ -0,0 +1,29 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +#[doc = "The `GpuStencilOperation` enum."] +#[doc = ""] +#[doc = "*This API requires the following crate features to be activated: `GpuStencilOperation`*"] +#[doc = ""] +#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] +#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum GpuStencilOperation { + Keep = "keep", + Zero = "zero", + Replace = "replace", + Invert = "invert", + IncrementClamp = "increment-clamp", + DecrementClamp = "decrement-clamp", + IncrementWrap = "increment-wrap", + DecrementWrap = "decrement-wrap", +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuStorageTextureAccess.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuStorageTextureAccess.rs new file mode 100644 index 0000000000..299fde647e --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuStorageTextureAccess.rs @@ -0,0 +1,24 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +#[doc = "The `GpuStorageTextureAccess` enum."] +#[doc = ""] +#[doc = "*This API requires the following crate features to be activated: `GpuStorageTextureAccess`*"] +#[doc = ""] +#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] +#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum GpuStorageTextureAccess { + WriteOnly = "write-only", + ReadOnly = "read-only", + ReadWrite = "read-write", +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuStorageTextureBindingLayout.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuStorageTextureBindingLayout.rs new file mode 100644 index 0000000000..2e3bc28023 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuStorageTextureBindingLayout.rs @@ -0,0 +1,96 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUStorageTextureBindingLayout)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuStorageTextureBindingLayout` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuStorageTextureBindingLayout`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuStorageTextureBindingLayout; +} + +impl GpuStorageTextureBindingLayout { + #[doc = "Construct a new `GpuStorageTextureBindingLayout`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuStorageTextureBindingLayout`, `GpuTextureFormat`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new(format: GpuTextureFormat) -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret.format(format); + ret + } + + #[doc = "Change the `access` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuStorageTextureAccess`, `GpuStorageTextureBindingLayout`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn access(&mut self, val: GpuStorageTextureAccess) -> &mut Self { + use wasm_bindgen::JsValue; + let r = + ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("access"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `format` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuStorageTextureBindingLayout`, `GpuTextureFormat`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn format(&mut self, val: GpuTextureFormat) -> &mut Self { + use wasm_bindgen::JsValue; + let r = + ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("format"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `viewDimension` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuStorageTextureBindingLayout`, `GpuTextureViewDimension`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn view_dimension(&mut self, val: GpuTextureViewDimension) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("viewDimension"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuStoreOp.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuStoreOp.rs new file mode 100644 index 0000000000..bdca8cab7c --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuStoreOp.rs @@ -0,0 +1,23 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +#[doc = "The `GpuStoreOp` enum."] +#[doc = ""] +#[doc = "*This API requires the following crate features to be activated: `GpuStoreOp`*"] +#[doc = ""] +#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] +#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum GpuStoreOp { + Store = "store", + Discard = "discard", +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuSupportedFeatures.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuSupportedFeatures.rs new file mode 100644 index 0000000000..8a22856be2 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuSupportedFeatures.rs @@ -0,0 +1,95 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUSupportedFeatures , typescript_type = "GPUSupportedFeatures")] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuSupportedFeatures` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUSupportedFeatures)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSupportedFeatures`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuSupportedFeatures; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUSupportedFeatures" , js_name = size)] + #[doc = "Getter for the `size` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUSupportedFeatures/size)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSupportedFeatures`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn size(this: &GpuSupportedFeatures) -> u32; + + # [wasm_bindgen (method , structural , js_class = "GPUSupportedFeatures" , js_name = entries)] + #[doc = "The `entries()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUSupportedFeatures/entries)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSupportedFeatures`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn entries(this: &GpuSupportedFeatures) -> ::js_sys::Iterator; + + # [wasm_bindgen (catch , method , structural , js_class = "GPUSupportedFeatures" , js_name = forEach)] + #[doc = "The `forEach()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUSupportedFeatures/forEach)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSupportedFeatures`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn for_each( + this: &GpuSupportedFeatures, + callback: &::js_sys::Function, + ) -> Result<(), JsValue>; + + # [wasm_bindgen (method , structural , js_class = "GPUSupportedFeatures" , js_name = has)] + #[doc = "The `has()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUSupportedFeatures/has)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSupportedFeatures`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn has(this: &GpuSupportedFeatures, value: &str) -> bool; + + # [wasm_bindgen (method , structural , js_class = "GPUSupportedFeatures" , js_name = keys)] + #[doc = "The `keys()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUSupportedFeatures/keys)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSupportedFeatures`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn keys(this: &GpuSupportedFeatures) -> ::js_sys::Iterator; + + # [wasm_bindgen (method , structural , js_class = "GPUSupportedFeatures" , js_name = values)] + #[doc = "The `values()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUSupportedFeatures/values)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSupportedFeatures`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn values(this: &GpuSupportedFeatures) -> ::js_sys::Iterator; +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuSupportedLimits.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuSupportedLimits.rs new file mode 100644 index 0000000000..3816dcf035 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuSupportedLimits.rs @@ -0,0 +1,378 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUSupportedLimits , typescript_type = "GPUSupportedLimits")] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuSupportedLimits` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUSupportedLimits)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSupportedLimits`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuSupportedLimits; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUSupportedLimits" , js_name = maxTextureDimension1D)] + #[doc = "Getter for the `maxTextureDimension1D` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUSupportedLimits/maxTextureDimension1D)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSupportedLimits`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn max_texture_dimension_1d(this: &GpuSupportedLimits) -> u32; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUSupportedLimits" , js_name = maxTextureDimension2D)] + #[doc = "Getter for the `maxTextureDimension2D` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUSupportedLimits/maxTextureDimension2D)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSupportedLimits`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn max_texture_dimension_2d(this: &GpuSupportedLimits) -> u32; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUSupportedLimits" , js_name = maxTextureDimension3D)] + #[doc = "Getter for the `maxTextureDimension3D` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUSupportedLimits/maxTextureDimension3D)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSupportedLimits`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn max_texture_dimension_3d(this: &GpuSupportedLimits) -> u32; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUSupportedLimits" , js_name = maxTextureArrayLayers)] + #[doc = "Getter for the `maxTextureArrayLayers` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUSupportedLimits/maxTextureArrayLayers)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSupportedLimits`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn max_texture_array_layers(this: &GpuSupportedLimits) -> u32; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUSupportedLimits" , js_name = maxBindGroups)] + #[doc = "Getter for the `maxBindGroups` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUSupportedLimits/maxBindGroups)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSupportedLimits`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn max_bind_groups(this: &GpuSupportedLimits) -> u32; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUSupportedLimits" , js_name = maxBindGroupsPlusVertexBuffers)] + #[doc = "Getter for the `maxBindGroupsPlusVertexBuffers` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUSupportedLimits/maxBindGroupsPlusVertexBuffers)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSupportedLimits`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn max_bind_groups_plus_vertex_buffers(this: &GpuSupportedLimits) -> u32; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUSupportedLimits" , js_name = maxBindingsPerBindGroup)] + #[doc = "Getter for the `maxBindingsPerBindGroup` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUSupportedLimits/maxBindingsPerBindGroup)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSupportedLimits`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn max_bindings_per_bind_group(this: &GpuSupportedLimits) -> u32; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUSupportedLimits" , js_name = maxDynamicUniformBuffersPerPipelineLayout)] + #[doc = "Getter for the `maxDynamicUniformBuffersPerPipelineLayout` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUSupportedLimits/maxDynamicUniformBuffersPerPipelineLayout)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSupportedLimits`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn max_dynamic_uniform_buffers_per_pipeline_layout(this: &GpuSupportedLimits) -> u32; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUSupportedLimits" , js_name = maxDynamicStorageBuffersPerPipelineLayout)] + #[doc = "Getter for the `maxDynamicStorageBuffersPerPipelineLayout` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUSupportedLimits/maxDynamicStorageBuffersPerPipelineLayout)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSupportedLimits`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn max_dynamic_storage_buffers_per_pipeline_layout(this: &GpuSupportedLimits) -> u32; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUSupportedLimits" , js_name = maxSampledTexturesPerShaderStage)] + #[doc = "Getter for the `maxSampledTexturesPerShaderStage` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUSupportedLimits/maxSampledTexturesPerShaderStage)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSupportedLimits`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn max_sampled_textures_per_shader_stage(this: &GpuSupportedLimits) -> u32; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUSupportedLimits" , js_name = maxSamplersPerShaderStage)] + #[doc = "Getter for the `maxSamplersPerShaderStage` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUSupportedLimits/maxSamplersPerShaderStage)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSupportedLimits`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn max_samplers_per_shader_stage(this: &GpuSupportedLimits) -> u32; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUSupportedLimits" , js_name = maxStorageBuffersPerShaderStage)] + #[doc = "Getter for the `maxStorageBuffersPerShaderStage` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUSupportedLimits/maxStorageBuffersPerShaderStage)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSupportedLimits`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn max_storage_buffers_per_shader_stage(this: &GpuSupportedLimits) -> u32; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUSupportedLimits" , js_name = maxStorageTexturesPerShaderStage)] + #[doc = "Getter for the `maxStorageTexturesPerShaderStage` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUSupportedLimits/maxStorageTexturesPerShaderStage)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSupportedLimits`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn max_storage_textures_per_shader_stage(this: &GpuSupportedLimits) -> u32; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUSupportedLimits" , js_name = maxUniformBuffersPerShaderStage)] + #[doc = "Getter for the `maxUniformBuffersPerShaderStage` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUSupportedLimits/maxUniformBuffersPerShaderStage)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSupportedLimits`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn max_uniform_buffers_per_shader_stage(this: &GpuSupportedLimits) -> u32; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUSupportedLimits" , js_name = maxUniformBufferBindingSize)] + #[doc = "Getter for the `maxUniformBufferBindingSize` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUSupportedLimits/maxUniformBufferBindingSize)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSupportedLimits`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn max_uniform_buffer_binding_size(this: &GpuSupportedLimits) -> f64; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUSupportedLimits" , js_name = maxStorageBufferBindingSize)] + #[doc = "Getter for the `maxStorageBufferBindingSize` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUSupportedLimits/maxStorageBufferBindingSize)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSupportedLimits`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn max_storage_buffer_binding_size(this: &GpuSupportedLimits) -> f64; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUSupportedLimits" , js_name = minUniformBufferOffsetAlignment)] + #[doc = "Getter for the `minUniformBufferOffsetAlignment` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUSupportedLimits/minUniformBufferOffsetAlignment)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSupportedLimits`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn min_uniform_buffer_offset_alignment(this: &GpuSupportedLimits) -> u32; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUSupportedLimits" , js_name = minStorageBufferOffsetAlignment)] + #[doc = "Getter for the `minStorageBufferOffsetAlignment` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUSupportedLimits/minStorageBufferOffsetAlignment)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSupportedLimits`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn min_storage_buffer_offset_alignment(this: &GpuSupportedLimits) -> u32; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUSupportedLimits" , js_name = maxVertexBuffers)] + #[doc = "Getter for the `maxVertexBuffers` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUSupportedLimits/maxVertexBuffers)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSupportedLimits`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn max_vertex_buffers(this: &GpuSupportedLimits) -> u32; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUSupportedLimits" , js_name = maxBufferSize)] + #[doc = "Getter for the `maxBufferSize` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUSupportedLimits/maxBufferSize)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSupportedLimits`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn max_buffer_size(this: &GpuSupportedLimits) -> f64; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUSupportedLimits" , js_name = maxVertexAttributes)] + #[doc = "Getter for the `maxVertexAttributes` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUSupportedLimits/maxVertexAttributes)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSupportedLimits`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn max_vertex_attributes(this: &GpuSupportedLimits) -> u32; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUSupportedLimits" , js_name = maxVertexBufferArrayStride)] + #[doc = "Getter for the `maxVertexBufferArrayStride` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUSupportedLimits/maxVertexBufferArrayStride)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSupportedLimits`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn max_vertex_buffer_array_stride(this: &GpuSupportedLimits) -> u32; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUSupportedLimits" , js_name = maxInterStageShaderComponents)] + #[doc = "Getter for the `maxInterStageShaderComponents` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUSupportedLimits/maxInterStageShaderComponents)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSupportedLimits`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn max_inter_stage_shader_components(this: &GpuSupportedLimits) -> u32; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUSupportedLimits" , js_name = maxInterStageShaderVariables)] + #[doc = "Getter for the `maxInterStageShaderVariables` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUSupportedLimits/maxInterStageShaderVariables)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSupportedLimits`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn max_inter_stage_shader_variables(this: &GpuSupportedLimits) -> u32; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUSupportedLimits" , js_name = maxColorAttachments)] + #[doc = "Getter for the `maxColorAttachments` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUSupportedLimits/maxColorAttachments)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSupportedLimits`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn max_color_attachments(this: &GpuSupportedLimits) -> u32; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUSupportedLimits" , js_name = maxColorAttachmentBytesPerSample)] + #[doc = "Getter for the `maxColorAttachmentBytesPerSample` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUSupportedLimits/maxColorAttachmentBytesPerSample)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSupportedLimits`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn max_color_attachment_bytes_per_sample(this: &GpuSupportedLimits) -> u32; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUSupportedLimits" , js_name = maxComputeWorkgroupStorageSize)] + #[doc = "Getter for the `maxComputeWorkgroupStorageSize` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUSupportedLimits/maxComputeWorkgroupStorageSize)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSupportedLimits`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn max_compute_workgroup_storage_size(this: &GpuSupportedLimits) -> u32; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUSupportedLimits" , js_name = maxComputeInvocationsPerWorkgroup)] + #[doc = "Getter for the `maxComputeInvocationsPerWorkgroup` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUSupportedLimits/maxComputeInvocationsPerWorkgroup)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSupportedLimits`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn max_compute_invocations_per_workgroup(this: &GpuSupportedLimits) -> u32; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUSupportedLimits" , js_name = maxComputeWorkgroupSizeX)] + #[doc = "Getter for the `maxComputeWorkgroupSizeX` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUSupportedLimits/maxComputeWorkgroupSizeX)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSupportedLimits`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn max_compute_workgroup_size_x(this: &GpuSupportedLimits) -> u32; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUSupportedLimits" , js_name = maxComputeWorkgroupSizeY)] + #[doc = "Getter for the `maxComputeWorkgroupSizeY` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUSupportedLimits/maxComputeWorkgroupSizeY)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSupportedLimits`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn max_compute_workgroup_size_y(this: &GpuSupportedLimits) -> u32; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUSupportedLimits" , js_name = maxComputeWorkgroupSizeZ)] + #[doc = "Getter for the `maxComputeWorkgroupSizeZ` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUSupportedLimits/maxComputeWorkgroupSizeZ)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSupportedLimits`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn max_compute_workgroup_size_z(this: &GpuSupportedLimits) -> u32; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUSupportedLimits" , js_name = maxComputeWorkgroupsPerDimension)] + #[doc = "Getter for the `maxComputeWorkgroupsPerDimension` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUSupportedLimits/maxComputeWorkgroupsPerDimension)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSupportedLimits`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn max_compute_workgroups_per_dimension(this: &GpuSupportedLimits) -> u32; +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTexture.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTexture.rs new file mode 100644 index 0000000000..78d7a3714a --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTexture.rs @@ -0,0 +1,172 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUTexture , typescript_type = "GPUTexture")] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuTexture` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUTexture)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuTexture`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuTexture; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUTexture" , js_name = width)] + #[doc = "Getter for the `width` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUTexture/width)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuTexture`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn width(this: &GpuTexture) -> u32; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUTexture" , js_name = height)] + #[doc = "Getter for the `height` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUTexture/height)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuTexture`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn height(this: &GpuTexture) -> u32; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUTexture" , js_name = depthOrArrayLayers)] + #[doc = "Getter for the `depthOrArrayLayers` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUTexture/depthOrArrayLayers)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuTexture`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn depth_or_array_layers(this: &GpuTexture) -> u32; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUTexture" , js_name = mipLevelCount)] + #[doc = "Getter for the `mipLevelCount` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUTexture/mipLevelCount)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuTexture`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn mip_level_count(this: &GpuTexture) -> u32; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUTexture" , js_name = sampleCount)] + #[doc = "Getter for the `sampleCount` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUTexture/sampleCount)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuTexture`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn sample_count(this: &GpuTexture) -> u32; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUTexture" , js_name = dimension)] + #[doc = "Getter for the `dimension` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUTexture/dimension)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuTexture`, `GpuTextureDimension`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn dimension(this: &GpuTexture) -> GpuTextureDimension; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUTexture" , js_name = format)] + #[doc = "Getter for the `format` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUTexture/format)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuTexture`, `GpuTextureFormat`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn format(this: &GpuTexture) -> GpuTextureFormat; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUTexture" , js_name = usage)] + #[doc = "Getter for the `usage` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUTexture/usage)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuTexture`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn usage(this: &GpuTexture) -> u32; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUTexture" , js_name = label)] + #[doc = "Getter for the `label` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUTexture/label)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuTexture`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn label(this: &GpuTexture) -> String; + + # [wasm_bindgen (structural , method , setter , js_class = "GPUTexture" , js_name = label)] + #[doc = "Setter for the `label` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUTexture/label)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuTexture`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_label(this: &GpuTexture, value: &str); + + # [wasm_bindgen (method , structural , js_class = "GPUTexture" , js_name = createView)] + #[doc = "The `createView()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUTexture/createView)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuTexture`, `GpuTextureView`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn create_view(this: &GpuTexture) -> GpuTextureView; + + # [wasm_bindgen (method , structural , js_class = "GPUTexture" , js_name = createView)] + #[doc = "The `createView()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUTexture/createView)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuTexture`, `GpuTextureView`, `GpuTextureViewDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn create_view_with_descriptor( + this: &GpuTexture, + descriptor: &GpuTextureViewDescriptor, + ) -> GpuTextureView; + + # [wasm_bindgen (method , structural , js_class = "GPUTexture" , js_name = destroy)] + #[doc = "The `destroy()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUTexture/destroy)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuTexture`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn destroy(this: &GpuTexture); +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureAspect.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureAspect.rs new file mode 100644 index 0000000000..955890a5ca --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureAspect.rs @@ -0,0 +1,24 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +#[doc = "The `GpuTextureAspect` enum."] +#[doc = ""] +#[doc = "*This API requires the following crate features to be activated: `GpuTextureAspect`*"] +#[doc = ""] +#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] +#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum GpuTextureAspect { + All = "all", + StencilOnly = "stencil-only", + DepthOnly = "depth-only", +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureBindingLayout.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureBindingLayout.rs new file mode 100644 index 0000000000..fc1917a2eb --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureBindingLayout.rs @@ -0,0 +1,107 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUTextureBindingLayout)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuTextureBindingLayout` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuTextureBindingLayout`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuTextureBindingLayout; +} + +impl GpuTextureBindingLayout { + #[doc = "Construct a new `GpuTextureBindingLayout`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuTextureBindingLayout`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new() -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret + } + + #[doc = "Change the `multisampled` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuTextureBindingLayout`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn multisampled(&mut self, val: bool) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("multisampled"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `sampleType` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuTextureBindingLayout`, `GpuTextureSampleType`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn sample_type(&mut self, val: GpuTextureSampleType) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("sampleType"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `viewDimension` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuTextureBindingLayout`, `GpuTextureViewDimension`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn view_dimension(&mut self, val: GpuTextureViewDimension) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("viewDimension"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} + +impl Default for GpuTextureBindingLayout { + fn default() -> Self { + Self::new() + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureDescriptor.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureDescriptor.rs new file mode 100644 index 0000000000..4b4ee0bcd5 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureDescriptor.rs @@ -0,0 +1,194 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUTextureDescriptor)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuTextureDescriptor` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuTextureDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuTextureDescriptor; +} + +impl GpuTextureDescriptor { + #[doc = "Construct a new `GpuTextureDescriptor`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuTextureDescriptor`, `GpuTextureFormat`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new(format: GpuTextureFormat, size: &::wasm_bindgen::JsValue, usage: u32) -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret.format(format); + ret.size(size); + ret.usage(usage); + ret + } + + #[doc = "Change the `label` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuTextureDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn label(&mut self, val: &str) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("label"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `dimension` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuTextureDescriptor`, `GpuTextureDimension`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn dimension(&mut self, val: GpuTextureDimension) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("dimension"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `format` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuTextureDescriptor`, `GpuTextureFormat`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn format(&mut self, val: GpuTextureFormat) -> &mut Self { + use wasm_bindgen::JsValue; + let r = + ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("format"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `mipLevelCount` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuTextureDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn mip_level_count(&mut self, val: u32) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("mipLevelCount"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `sampleCount` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuTextureDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn sample_count(&mut self, val: u32) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("sampleCount"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `size` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuTextureDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn size(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("size"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `usage` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuTextureDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn usage(&mut self, val: u32) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("usage"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `viewFormats` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuTextureDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn view_formats(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("viewFormats"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureDimension.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureDimension.rs new file mode 100644 index 0000000000..548fd820bd --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureDimension.rs @@ -0,0 +1,24 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +#[doc = "The `GpuTextureDimension` enum."] +#[doc = ""] +#[doc = "*This API requires the following crate features to be activated: `GpuTextureDimension`*"] +#[doc = ""] +#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] +#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum GpuTextureDimension { + N1d = "1d", + N2d = "2d", + N3d = "3d", +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureFormat.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureFormat.rs new file mode 100644 index 0000000000..cf07abd384 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureFormat.rs @@ -0,0 +1,116 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +#[doc = "The `GpuTextureFormat` enum."] +#[doc = ""] +#[doc = "*This API requires the following crate features to be activated: `GpuTextureFormat`*"] +#[doc = ""] +#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] +#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum GpuTextureFormat { + R8unorm = "r8unorm", + R8snorm = "r8snorm", + R8uint = "r8uint", + R8sint = "r8sint", + R16uint = "r16uint", + R16sint = "r16sint", + R16float = "r16float", + Rg8unorm = "rg8unorm", + Rg8snorm = "rg8snorm", + Rg8uint = "rg8uint", + Rg8sint = "rg8sint", + R32uint = "r32uint", + R32sint = "r32sint", + R32float = "r32float", + Rg16uint = "rg16uint", + Rg16sint = "rg16sint", + Rg16float = "rg16float", + Rgba8unorm = "rgba8unorm", + Rgba8unormSrgb = "rgba8unorm-srgb", + Rgba8snorm = "rgba8snorm", + Rgba8uint = "rgba8uint", + Rgba8sint = "rgba8sint", + Bgra8unorm = "bgra8unorm", + Bgra8unormSrgb = "bgra8unorm-srgb", + Rgb9e5ufloat = "rgb9e5ufloat", + Rgb10a2uint = "rgb10a2uint", + Rgb10a2unorm = "rgb10a2unorm", + Rg11b10ufloat = "rg11b10ufloat", + Rg32uint = "rg32uint", + Rg32sint = "rg32sint", + Rg32float = "rg32float", + Rgba16uint = "rgba16uint", + Rgba16sint = "rgba16sint", + Rgba16float = "rgba16float", + Rgba32uint = "rgba32uint", + Rgba32sint = "rgba32sint", + Rgba32float = "rgba32float", + Stencil8 = "stencil8", + Depth16unorm = "depth16unorm", + Depth24plus = "depth24plus", + Depth24plusStencil8 = "depth24plus-stencil8", + Depth32float = "depth32float", + Depth32floatStencil8 = "depth32float-stencil8", + Bc1RgbaUnorm = "bc1-rgba-unorm", + Bc1RgbaUnormSrgb = "bc1-rgba-unorm-srgb", + Bc2RgbaUnorm = "bc2-rgba-unorm", + Bc2RgbaUnormSrgb = "bc2-rgba-unorm-srgb", + Bc3RgbaUnorm = "bc3-rgba-unorm", + Bc3RgbaUnormSrgb = "bc3-rgba-unorm-srgb", + Bc4RUnorm = "bc4-r-unorm", + Bc4RSnorm = "bc4-r-snorm", + Bc5RgUnorm = "bc5-rg-unorm", + Bc5RgSnorm = "bc5-rg-snorm", + Bc6hRgbUfloat = "bc6h-rgb-ufloat", + Bc6hRgbFloat = "bc6h-rgb-float", + Bc7RgbaUnorm = "bc7-rgba-unorm", + Bc7RgbaUnormSrgb = "bc7-rgba-unorm-srgb", + Etc2Rgb8unorm = "etc2-rgb8unorm", + Etc2Rgb8unormSrgb = "etc2-rgb8unorm-srgb", + Etc2Rgb8a1unorm = "etc2-rgb8a1unorm", + Etc2Rgb8a1unormSrgb = "etc2-rgb8a1unorm-srgb", + Etc2Rgba8unorm = "etc2-rgba8unorm", + Etc2Rgba8unormSrgb = "etc2-rgba8unorm-srgb", + EacR11unorm = "eac-r11unorm", + EacR11snorm = "eac-r11snorm", + EacRg11unorm = "eac-rg11unorm", + EacRg11snorm = "eac-rg11snorm", + Astc4x4Unorm = "astc-4x4-unorm", + Astc4x4UnormSrgb = "astc-4x4-unorm-srgb", + Astc5x4Unorm = "astc-5x4-unorm", + Astc5x4UnormSrgb = "astc-5x4-unorm-srgb", + Astc5x5Unorm = "astc-5x5-unorm", + Astc5x5UnormSrgb = "astc-5x5-unorm-srgb", + Astc6x5Unorm = "astc-6x5-unorm", + Astc6x5UnormSrgb = "astc-6x5-unorm-srgb", + Astc6x6Unorm = "astc-6x6-unorm", + Astc6x6UnormSrgb = "astc-6x6-unorm-srgb", + Astc8x5Unorm = "astc-8x5-unorm", + Astc8x5UnormSrgb = "astc-8x5-unorm-srgb", + Astc8x6Unorm = "astc-8x6-unorm", + Astc8x6UnormSrgb = "astc-8x6-unorm-srgb", + Astc8x8Unorm = "astc-8x8-unorm", + Astc8x8UnormSrgb = "astc-8x8-unorm-srgb", + Astc10x5Unorm = "astc-10x5-unorm", + Astc10x5UnormSrgb = "astc-10x5-unorm-srgb", + Astc10x6Unorm = "astc-10x6-unorm", + Astc10x6UnormSrgb = "astc-10x6-unorm-srgb", + Astc10x8Unorm = "astc-10x8-unorm", + Astc10x8UnormSrgb = "astc-10x8-unorm-srgb", + Astc10x10Unorm = "astc-10x10-unorm", + Astc10x10UnormSrgb = "astc-10x10-unorm-srgb", + Astc12x10Unorm = "astc-12x10-unorm", + Astc12x10UnormSrgb = "astc-12x10-unorm-srgb", + Astc12x12Unorm = "astc-12x12-unorm", + Astc12x12UnormSrgb = "astc-12x12-unorm-srgb", +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureSampleType.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureSampleType.rs new file mode 100644 index 0000000000..61bc98b468 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureSampleType.rs @@ -0,0 +1,26 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +#[doc = "The `GpuTextureSampleType` enum."] +#[doc = ""] +#[doc = "*This API requires the following crate features to be activated: `GpuTextureSampleType`*"] +#[doc = ""] +#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] +#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum GpuTextureSampleType { + Float = "float", + UnfilterableFloat = "unfilterable-float", + Depth = "depth", + Sint = "sint", + Uint = "uint", +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureView.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureView.rs new file mode 100644 index 0000000000..063382d4ee --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureView.rs @@ -0,0 +1,48 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUTextureView , typescript_type = "GPUTextureView")] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuTextureView` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUTextureView)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuTextureView`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuTextureView; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUTextureView" , js_name = label)] + #[doc = "Getter for the `label` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUTextureView/label)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuTextureView`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn label(this: &GpuTextureView) -> String; + + # [wasm_bindgen (structural , method , setter , js_class = "GPUTextureView" , js_name = label)] + #[doc = "Setter for the `label` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUTextureView/label)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuTextureView`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_label(this: &GpuTextureView, value: &str); +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureViewDescriptor.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureViewDescriptor.rs new file mode 100644 index 0000000000..dcc4d48a8e --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureViewDescriptor.rs @@ -0,0 +1,202 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUTextureViewDescriptor)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuTextureViewDescriptor` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuTextureViewDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuTextureViewDescriptor; +} + +impl GpuTextureViewDescriptor { + #[doc = "Construct a new `GpuTextureViewDescriptor`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuTextureViewDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new() -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret + } + + #[doc = "Change the `label` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuTextureViewDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn label(&mut self, val: &str) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("label"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `arrayLayerCount` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuTextureViewDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn array_layer_count(&mut self, val: u32) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("arrayLayerCount"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `aspect` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuTextureAspect`, `GpuTextureViewDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn aspect(&mut self, val: GpuTextureAspect) -> &mut Self { + use wasm_bindgen::JsValue; + let r = + ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("aspect"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `baseArrayLayer` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuTextureViewDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn base_array_layer(&mut self, val: u32) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("baseArrayLayer"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `baseMipLevel` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuTextureViewDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn base_mip_level(&mut self, val: u32) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("baseMipLevel"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `dimension` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuTextureViewDescriptor`, `GpuTextureViewDimension`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn dimension(&mut self, val: GpuTextureViewDimension) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("dimension"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `format` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuTextureFormat`, `GpuTextureViewDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn format(&mut self, val: GpuTextureFormat) -> &mut Self { + use wasm_bindgen::JsValue; + let r = + ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("format"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `mipLevelCount` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuTextureViewDescriptor`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn mip_level_count(&mut self, val: u32) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("mipLevelCount"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} + +impl Default for GpuTextureViewDescriptor { + fn default() -> Self { + Self::new() + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureViewDimension.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureViewDimension.rs new file mode 100644 index 0000000000..c3c62a745e --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureViewDimension.rs @@ -0,0 +1,27 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +#[doc = "The `GpuTextureViewDimension` enum."] +#[doc = ""] +#[doc = "*This API requires the following crate features to be activated: `GpuTextureViewDimension`*"] +#[doc = ""] +#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] +#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum GpuTextureViewDimension { + N1d = "1d", + N2d = "2d", + N2dArray = "2d-array", + Cube = "cube", + CubeArray = "cube-array", + N3d = "3d", +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuUncapturedErrorEvent.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuUncapturedErrorEvent.rs new file mode 100644 index 0000000000..e665b8de73 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuUncapturedErrorEvent.rs @@ -0,0 +1,51 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = Event , extends = :: js_sys :: Object , js_name = GPUUncapturedErrorEvent , typescript_type = "GPUUncapturedErrorEvent")] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuUncapturedErrorEvent` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUUncapturedErrorEvent)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuUncapturedErrorEvent`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuUncapturedErrorEvent; + + # [wasm_bindgen (structural , method , getter , js_class = "GPUUncapturedErrorEvent" , js_name = error)] + #[doc = "Getter for the `error` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUUncapturedErrorEvent/error)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuError`, `GpuUncapturedErrorEvent`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn error(this: &GpuUncapturedErrorEvent) -> GpuError; + + #[wasm_bindgen(catch, constructor, js_class = "GPUUncapturedErrorEvent")] + #[doc = "The `new GpuUncapturedErrorEvent(..)` constructor, creating a new instance of `GpuUncapturedErrorEvent`."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUUncapturedErrorEvent/GPUUncapturedErrorEvent)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuUncapturedErrorEvent`, `GpuUncapturedErrorEventInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new( + type_: &str, + gpu_uncaptured_error_event_init_dict: &GpuUncapturedErrorEventInit, + ) -> Result; +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuUncapturedErrorEventInit.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuUncapturedErrorEventInit.rs new file mode 100644 index 0000000000..012c910d7a --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuUncapturedErrorEventInit.rs @@ -0,0 +1,119 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUUncapturedErrorEventInit)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuUncapturedErrorEventInit` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuUncapturedErrorEventInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuUncapturedErrorEventInit; +} + +impl GpuUncapturedErrorEventInit { + #[doc = "Construct a new `GpuUncapturedErrorEventInit`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuError`, `GpuUncapturedErrorEventInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new(error: &GpuError) -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret.error(error); + ret + } + + #[doc = "Change the `bubbles` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuUncapturedErrorEventInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn bubbles(&mut self, val: bool) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("bubbles"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `cancelable` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuUncapturedErrorEventInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn cancelable(&mut self, val: bool) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("cancelable"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `composed` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuUncapturedErrorEventInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn composed(&mut self, val: bool) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("composed"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `error` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuError`, `GpuUncapturedErrorEventInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn error(&mut self, val: &GpuError) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("error"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuValidationError.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuValidationError.rs new file mode 100644 index 0000000000..e59e697496 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuValidationError.rs @@ -0,0 +1,37 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = GpuError , extends = :: js_sys :: Object , js_name = GPUValidationError , typescript_type = "GPUValidationError")] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuValidationError` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUValidationError)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuValidationError`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuValidationError; + + #[wasm_bindgen(catch, constructor, js_class = "GPUValidationError")] + #[doc = "The `new GpuValidationError(..)` constructor, creating a new instance of `GpuValidationError`."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUValidationError/GPUValidationError)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuValidationError`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new(message: &str) -> Result; +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuVertexAttribute.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuVertexAttribute.rs new file mode 100644 index 0000000000..41588b1bc5 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuVertexAttribute.rs @@ -0,0 +1,98 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUVertexAttribute)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuVertexAttribute` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuVertexAttribute`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuVertexAttribute; +} + +impl GpuVertexAttribute { + #[doc = "Construct a new `GpuVertexAttribute`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuVertexAttribute`, `GpuVertexFormat`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new(format: GpuVertexFormat, offset: f64, shader_location: u32) -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret.format(format); + ret.offset(offset); + ret.shader_location(shader_location); + ret + } + + #[doc = "Change the `format` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuVertexAttribute`, `GpuVertexFormat`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn format(&mut self, val: GpuVertexFormat) -> &mut Self { + use wasm_bindgen::JsValue; + let r = + ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("format"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `offset` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuVertexAttribute`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn offset(&mut self, val: f64) -> &mut Self { + use wasm_bindgen::JsValue; + let r = + ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("offset"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `shaderLocation` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuVertexAttribute`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn shader_location(&mut self, val: u32) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("shaderLocation"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuVertexBufferLayout.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuVertexBufferLayout.rs new file mode 100644 index 0000000000..f6d92ef630 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuVertexBufferLayout.rs @@ -0,0 +1,103 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUVertexBufferLayout)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuVertexBufferLayout` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuVertexBufferLayout`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuVertexBufferLayout; +} + +impl GpuVertexBufferLayout { + #[doc = "Construct a new `GpuVertexBufferLayout`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuVertexBufferLayout`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new(array_stride: f64, attributes: &::wasm_bindgen::JsValue) -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret.array_stride(array_stride); + ret.attributes(attributes); + ret + } + + #[doc = "Change the `arrayStride` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuVertexBufferLayout`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn array_stride(&mut self, val: f64) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("arrayStride"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `attributes` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuVertexBufferLayout`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn attributes(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("attributes"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `stepMode` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuVertexBufferLayout`, `GpuVertexStepMode`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn step_mode(&mut self, val: GpuVertexStepMode) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("stepMode"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuVertexFormat.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuVertexFormat.rs new file mode 100644 index 0000000000..10f294c37e --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuVertexFormat.rs @@ -0,0 +1,52 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +#[doc = "The `GpuVertexFormat` enum."] +#[doc = ""] +#[doc = "*This API requires the following crate features to be activated: `GpuVertexFormat`*"] +#[doc = ""] +#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] +#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum GpuVertexFormat { + Uint8x2 = "uint8x2", + Uint8x4 = "uint8x4", + Sint8x2 = "sint8x2", + Sint8x4 = "sint8x4", + Unorm8x2 = "unorm8x2", + Unorm8x4 = "unorm8x4", + Snorm8x2 = "snorm8x2", + Snorm8x4 = "snorm8x4", + Uint16x2 = "uint16x2", + Uint16x4 = "uint16x4", + Sint16x2 = "sint16x2", + Sint16x4 = "sint16x4", + Unorm16x2 = "unorm16x2", + Unorm16x4 = "unorm16x4", + Snorm16x2 = "snorm16x2", + Snorm16x4 = "snorm16x4", + Float16x2 = "float16x2", + Float16x4 = "float16x4", + Float32 = "float32", + Float32x2 = "float32x2", + Float32x3 = "float32x3", + Float32x4 = "float32x4", + Uint32 = "uint32", + Uint32x2 = "uint32x2", + Uint32x3 = "uint32x3", + Uint32x4 = "uint32x4", + Sint32 = "sint32", + Sint32x2 = "sint32x2", + Sint32x3 = "sint32x3", + Sint32x4 = "sint32x4", + Unorm1010102 = "unorm10-10-10-2", +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuVertexState.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuVertexState.rs new file mode 100644 index 0000000000..5869d00978 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuVertexState.rs @@ -0,0 +1,99 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GPUVertexState)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuVertexState` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuVertexState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuVertexState; +} + +impl GpuVertexState { + #[doc = "Construct a new `GpuVertexState`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuShaderModule`, `GpuVertexState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new(module: &GpuShaderModule) -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret.module(module); + ret + } + + #[doc = "Change the `entryPoint` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuVertexState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn entry_point(&mut self, val: &str) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("entryPoint"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `module` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuShaderModule`, `GpuVertexState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn module(&mut self, val: &GpuShaderModule) -> &mut Self { + use wasm_bindgen::JsValue; + let r = + ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("module"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + + #[doc = "Change the `buffers` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuVertexState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn buffers(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("buffers"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuVertexStepMode.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuVertexStepMode.rs new file mode 100644 index 0000000000..f64c86605c --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuVertexStepMode.rs @@ -0,0 +1,23 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +#[doc = "The `GpuVertexStepMode` enum."] +#[doc = ""] +#[doc = "*This API requires the following crate features to be activated: `GpuVertexStepMode`*"] +#[doc = ""] +#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] +#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum GpuVertexStepMode { + Vertex = "vertex", + Instance = "instance", +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_WgslLanguageFeatures.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_WgslLanguageFeatures.rs new file mode 100644 index 0000000000..429c166bb2 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_WgslLanguageFeatures.rs @@ -0,0 +1,95 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = WGSLLanguageFeatures , typescript_type = "WGSLLanguageFeatures")] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `WgslLanguageFeatures` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WGSLLanguageFeatures)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `WgslLanguageFeatures`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type WgslLanguageFeatures; + + # [wasm_bindgen (structural , method , getter , js_class = "WGSLLanguageFeatures" , js_name = size)] + #[doc = "Getter for the `size` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WGSLLanguageFeatures/size)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `WgslLanguageFeatures`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn size(this: &WgslLanguageFeatures) -> u32; + + # [wasm_bindgen (method , structural , js_class = "WGSLLanguageFeatures" , js_name = entries)] + #[doc = "The `entries()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WGSLLanguageFeatures/entries)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `WgslLanguageFeatures`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn entries(this: &WgslLanguageFeatures) -> ::js_sys::Iterator; + + # [wasm_bindgen (catch , method , structural , js_class = "WGSLLanguageFeatures" , js_name = forEach)] + #[doc = "The `forEach()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WGSLLanguageFeatures/forEach)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `WgslLanguageFeatures`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn for_each( + this: &WgslLanguageFeatures, + callback: &::js_sys::Function, + ) -> Result<(), JsValue>; + + # [wasm_bindgen (method , structural , js_class = "WGSLLanguageFeatures" , js_name = has)] + #[doc = "The `has()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WGSLLanguageFeatures/has)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `WgslLanguageFeatures`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn has(this: &WgslLanguageFeatures, value: &str) -> bool; + + # [wasm_bindgen (method , structural , js_class = "WGSLLanguageFeatures" , js_name = keys)] + #[doc = "The `keys()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WGSLLanguageFeatures/keys)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `WgslLanguageFeatures`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn keys(this: &WgslLanguageFeatures) -> ::js_sys::Iterator; + + # [wasm_bindgen (method , structural , js_class = "WGSLLanguageFeatures" , js_name = values)] + #[doc = "The `values()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WGSLLanguageFeatures/values)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `WgslLanguageFeatures`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn values(this: &WgslLanguageFeatures) -> ::js_sys::Iterator; +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_gpu_map_mode.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_gpu_map_mode.rs new file mode 100644 index 0000000000..b3e20113b5 --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_gpu_map_mode.rs @@ -0,0 +1,33 @@ +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. + +#[doc = ""] +#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] +#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] +pub mod gpu_map_mode { + #![allow(unused_imports)] + #![allow(clippy::all)] + use super::super::*; + use wasm_bindgen::prelude::*; + + #[doc = "The `GPUMapMode.READ` const."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `gpu_map_mode`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub const READ: u32 = 1u64 as u32; + + #[doc = "The `GPUMapMode.WRITE` const."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `gpu_map_mode`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub const WRITE: u32 = 2u64 as u32; +} diff --git a/wgpu/src/backend/webgpu/webgpu_sys/mod.rs b/wgpu/src/backend/webgpu/webgpu_sys/mod.rs new file mode 100644 index 0000000000..f2b050dd5f --- /dev/null +++ b/wgpu/src/backend/webgpu/webgpu_sys/mod.rs @@ -0,0 +1,261 @@ +//! Bindings to the WebGPU API. +//! +//! Internally vendored from the `web-sys` crate until the WebGPU binding are stabilized. +// DO NOT EDIT THIS FILE! +// +// This module part of a subset of web-sys that is used by wgpu's webgpu backend. +// +// If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. +// +// This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. + +#![allow(unused_imports, non_snake_case)] +use web_sys::{Event, EventTarget}; +mod gen_Gpu; +pub use gen_Gpu::*; +mod gen_GpuAdapter; +pub use gen_GpuAdapter::*; +mod gen_GpuAddressMode; +pub use gen_GpuAddressMode::*; +mod gen_GpuAutoLayoutMode; +pub use gen_GpuAutoLayoutMode::*; +mod gen_GpuBindGroup; +pub use gen_GpuBindGroup::*; +mod gen_GpuBindGroupDescriptor; +pub use gen_GpuBindGroupDescriptor::*; +mod gen_GpuBindGroupEntry; +pub use gen_GpuBindGroupEntry::*; +mod gen_GpuBindGroupLayout; +pub use gen_GpuBindGroupLayout::*; +mod gen_GpuBindGroupLayoutDescriptor; +pub use gen_GpuBindGroupLayoutDescriptor::*; +mod gen_GpuBindGroupLayoutEntry; +pub use gen_GpuBindGroupLayoutEntry::*; +mod gen_GpuBlendComponent; +pub use gen_GpuBlendComponent::*; +mod gen_GpuBlendFactor; +pub use gen_GpuBlendFactor::*; +mod gen_GpuBlendOperation; +pub use gen_GpuBlendOperation::*; +mod gen_GpuBlendState; +pub use gen_GpuBlendState::*; +mod gen_GpuBuffer; +pub use gen_GpuBuffer::*; +mod gen_GpuBufferBinding; +pub use gen_GpuBufferBinding::*; +mod gen_GpuBufferBindingLayout; +pub use gen_GpuBufferBindingLayout::*; +mod gen_GpuBufferBindingType; +pub use gen_GpuBufferBindingType::*; +mod gen_GpuBufferDescriptor; +pub use gen_GpuBufferDescriptor::*; +mod gen_GpuBufferMapState; +pub use gen_GpuBufferMapState::*; +mod gen_GpuCanvasAlphaMode; +pub use gen_GpuCanvasAlphaMode::*; +mod gen_GpuCanvasContext; +pub use gen_GpuCanvasContext::*; +mod gen_GpuCanvasConfiguration; +pub use gen_GpuCanvasConfiguration::*; +mod gen_GpuColorDict; +pub use gen_GpuColorDict::*; +mod gen_GpuColorTargetState; +pub use gen_GpuColorTargetState::*; +mod gen_GpuCommandBuffer; +pub use gen_GpuCommandBuffer::*; +mod gen_GpuCommandBufferDescriptor; +pub use gen_GpuCommandBufferDescriptor::*; +mod gen_GpuCommandEncoder; +pub use gen_GpuCommandEncoder::*; +mod gen_GpuCommandEncoderDescriptor; +pub use gen_GpuCommandEncoderDescriptor::*; +mod gen_GpuCompareFunction; +pub use gen_GpuCompareFunction::*; +mod gen_GpuCompilationInfo; +pub use gen_GpuCompilationInfo::*; +mod gen_GpuCompilationMessage; +pub use gen_GpuCompilationMessage::*; +mod gen_GpuCompilationMessageType; +pub use gen_GpuCompilationMessageType::*; +mod gen_GpuComputePassDescriptor; +pub use gen_GpuComputePassDescriptor::*; +mod gen_GpuComputePassEncoder; +pub use gen_GpuComputePassEncoder::*; +mod gen_GpuComputePassTimestampWrites; +pub use gen_GpuComputePassTimestampWrites::*; +mod gen_GpuComputePipeline; +pub use gen_GpuComputePipeline::*; +mod gen_GpuComputePipelineDescriptor; +pub use gen_GpuComputePipelineDescriptor::*; +mod gen_GpuCullMode; +pub use gen_GpuCullMode::*; +mod gen_GpuDepthStencilState; +pub use gen_GpuDepthStencilState::*; +mod gen_GpuDevice; +pub use gen_GpuDevice::*; +mod gen_GpuDeviceDescriptor; +pub use gen_GpuDeviceDescriptor::*; +mod gen_GpuDeviceLostInfo; +pub use gen_GpuDeviceLostInfo::*; +mod gen_GpuDeviceLostReason; +pub use gen_GpuDeviceLostReason::*; +mod gen_GpuError; +pub use gen_GpuError::*; +mod gen_GpuErrorFilter; +pub use gen_GpuErrorFilter::*; +mod gen_GpuExternalTexture; +pub use gen_GpuExternalTexture::*; +mod gen_GpuExternalTextureBindingLayout; +pub use gen_GpuExternalTextureBindingLayout::*; +mod gen_GpuExternalTextureDescriptor; +pub use gen_GpuExternalTextureDescriptor::*; +mod gen_GpuExtent3dDict; +pub use gen_GpuExtent3dDict::*; +mod gen_GpuFeatureName; +pub use gen_GpuFeatureName::*; +mod gen_GpuFilterMode; +pub use gen_GpuFilterMode::*; +mod gen_GpuFragmentState; +pub use gen_GpuFragmentState::*; +mod gen_GpuFrontFace; +pub use gen_GpuFrontFace::*; +mod gen_GpuImageCopyBuffer; +pub use gen_GpuImageCopyBuffer::*; +mod gen_GpuImageCopyExternalImage; +pub use gen_GpuImageCopyExternalImage::*; +mod gen_GpuImageCopyTexture; +pub use gen_GpuImageCopyTexture::*; +mod gen_GpuImageCopyTextureTagged; +pub use gen_GpuImageCopyTextureTagged::*; +mod gen_GpuImageDataLayout; +pub use gen_GpuImageDataLayout::*; +mod gen_GpuIndexFormat; +pub use gen_GpuIndexFormat::*; +mod gen_GpuLoadOp; +pub use gen_GpuLoadOp::*; +mod gen_gpu_map_mode; +pub use gen_gpu_map_mode::*; +mod gen_GpuMipmapFilterMode; +pub use gen_GpuMipmapFilterMode::*; +mod gen_GpuMultisampleState; +pub use gen_GpuMultisampleState::*; +mod gen_GpuObjectDescriptorBase; +pub use gen_GpuObjectDescriptorBase::*; +mod gen_GpuOrigin2dDict; +pub use gen_GpuOrigin2dDict::*; +mod gen_GpuOrigin3dDict; +pub use gen_GpuOrigin3dDict::*; +mod gen_GpuOutOfMemoryError; +pub use gen_GpuOutOfMemoryError::*; +mod gen_GpuPipelineDescriptorBase; +pub use gen_GpuPipelineDescriptorBase::*; +mod gen_GpuPipelineLayout; +pub use gen_GpuPipelineLayout::*; +mod gen_GpuPipelineLayoutDescriptor; +pub use gen_GpuPipelineLayoutDescriptor::*; +mod gen_GpuPowerPreference; +pub use gen_GpuPowerPreference::*; +mod gen_GpuPrimitiveState; +pub use gen_GpuPrimitiveState::*; +mod gen_GpuPrimitiveTopology; +pub use gen_GpuPrimitiveTopology::*; +mod gen_GpuProgrammableStage; +pub use gen_GpuProgrammableStage::*; +mod gen_GpuQuerySet; +pub use gen_GpuQuerySet::*; +mod gen_GpuQuerySetDescriptor; +pub use gen_GpuQuerySetDescriptor::*; +mod gen_GpuQueryType; +pub use gen_GpuQueryType::*; +mod gen_GpuQueue; +pub use gen_GpuQueue::*; +mod gen_GpuQueueDescriptor; +pub use gen_GpuQueueDescriptor::*; +mod gen_GpuRenderBundle; +pub use gen_GpuRenderBundle::*; +mod gen_GpuRenderBundleDescriptor; +pub use gen_GpuRenderBundleDescriptor::*; +mod gen_GpuRenderBundleEncoder; +pub use gen_GpuRenderBundleEncoder::*; +mod gen_GpuRenderBundleEncoderDescriptor; +pub use gen_GpuRenderBundleEncoderDescriptor::*; +mod gen_GpuRenderPassColorAttachment; +pub use gen_GpuRenderPassColorAttachment::*; +mod gen_GpuRenderPassDepthStencilAttachment; +pub use gen_GpuRenderPassDepthStencilAttachment::*; +mod gen_GpuRenderPassDescriptor; +pub use gen_GpuRenderPassDescriptor::*; +mod gen_GpuRenderPassEncoder; +pub use gen_GpuRenderPassEncoder::*; +mod gen_GpuRenderPassTimestampWrites; +pub use gen_GpuRenderPassTimestampWrites::*; +mod gen_GpuRenderPipeline; +pub use gen_GpuRenderPipeline::*; +mod gen_GpuRenderPipelineDescriptor; +pub use gen_GpuRenderPipelineDescriptor::*; +mod gen_GpuRequestAdapterOptions; +pub use gen_GpuRequestAdapterOptions::*; +mod gen_GpuSampler; +pub use gen_GpuSampler::*; +mod gen_GpuSamplerBindingLayout; +pub use gen_GpuSamplerBindingLayout::*; +mod gen_GpuSamplerBindingType; +pub use gen_GpuSamplerBindingType::*; +mod gen_GpuSamplerDescriptor; +pub use gen_GpuSamplerDescriptor::*; +mod gen_GpuShaderModule; +pub use gen_GpuShaderModule::*; +mod gen_GpuShaderModuleDescriptor; +pub use gen_GpuShaderModuleDescriptor::*; +mod gen_GpuStencilFaceState; +pub use gen_GpuStencilFaceState::*; +mod gen_GpuStencilOperation; +pub use gen_GpuStencilOperation::*; +mod gen_GpuStorageTextureAccess; +pub use gen_GpuStorageTextureAccess::*; +mod gen_GpuStorageTextureBindingLayout; +pub use gen_GpuStorageTextureBindingLayout::*; +mod gen_GpuStoreOp; +pub use gen_GpuStoreOp::*; +mod gen_GpuSupportedFeatures; +pub use gen_GpuSupportedFeatures::*; +mod gen_GpuSupportedLimits; +pub use gen_GpuSupportedLimits::*; +mod gen_GpuTexture; +pub use gen_GpuTexture::*; +mod gen_GpuTextureAspect; +pub use gen_GpuTextureAspect::*; +mod gen_GpuTextureBindingLayout; +pub use gen_GpuTextureBindingLayout::*; +mod gen_GpuTextureDescriptor; +pub use gen_GpuTextureDescriptor::*; +mod gen_GpuTextureDimension; +pub use gen_GpuTextureDimension::*; +mod gen_GpuTextureFormat; +pub use gen_GpuTextureFormat::*; +mod gen_GpuTextureSampleType; +pub use gen_GpuTextureSampleType::*; +mod gen_GpuTextureView; +pub use gen_GpuTextureView::*; +mod gen_GpuTextureViewDescriptor; +pub use gen_GpuTextureViewDescriptor::*; +mod gen_GpuTextureViewDimension; +pub use gen_GpuTextureViewDimension::*; +mod gen_GpuUncapturedErrorEvent; +pub use gen_GpuUncapturedErrorEvent::*; +mod gen_GpuUncapturedErrorEventInit; +pub use gen_GpuUncapturedErrorEventInit::*; +mod gen_GpuValidationError; +pub use gen_GpuValidationError::*; +mod gen_GpuVertexAttribute; +pub use gen_GpuVertexAttribute::*; +mod gen_GpuVertexBufferLayout; +pub use gen_GpuVertexBufferLayout::*; +mod gen_GpuVertexFormat; +pub use gen_GpuVertexFormat::*; +mod gen_GpuVertexState; +pub use gen_GpuVertexState::*; +mod gen_GpuVertexStepMode; +pub use gen_GpuVertexStepMode::*; +mod gen_WgslLanguageFeatures; +pub use gen_WgslLanguageFeatures::*; diff --git a/wgpu/src/backend/wgpu_core.rs b/wgpu/src/backend/wgpu_core.rs index b43291e797..98f1ca1de6 100644 --- a/wgpu/src/backend/wgpu_core.rs +++ b/wgpu/src/backend/wgpu_core.rs @@ -22,8 +22,11 @@ use std::{ slice, sync::Arc, }; -use wgc::command::{bundle_ffi::*, compute_ffi::*, render_ffi::*}; -use wgc::device::DeviceLostClosure; +use wgc::{ + command::{bundle_ffi::*, compute_ffi::*, render_ffi::*}, + device::DeviceLostClosure, + id::{CommandEncoderId, TextureViewId}, +}; use wgt::WasmNotSendSync; const LABEL: &str = "label"; @@ -207,14 +210,51 @@ impl ContextWgpuCore { } } - pub unsafe fn texture_as_hal)>( + pub unsafe fn texture_as_hal< + A: wgc::hal_api::HalApi, + F: FnOnce(Option<&A::Texture>) -> R, + R, + >( &self, texture: &Texture, hal_texture_callback: F, - ) { + ) -> R { + unsafe { + self.0 + .texture_as_hal::(texture.id, hal_texture_callback) + } + } + + pub unsafe fn texture_view_as_hal< + A: wgc::hal_api::HalApi, + F: FnOnce(Option<&A::TextureView>) -> R, + R, + >( + &self, + texture_view_id: TextureViewId, + hal_texture_view_callback: F, + ) -> R { unsafe { self.0 - .texture_as_hal::(texture.id, hal_texture_callback) + .texture_view_as_hal::(texture_view_id, hal_texture_view_callback) + } + } + + /// This method will start the wgpu_core level command recording. + pub unsafe fn command_encoder_as_hal_mut< + A: wgc::hal_api::HalApi, + F: FnOnce(Option<&mut A::CommandEncoder>) -> R, + R, + >( + &self, + command_encoder_id: CommandEncoderId, + hal_command_encoder_callback: F, + ) -> R { + unsafe { + self.0.command_encoder_as_hal_mut::( + command_encoder_id, + hal_command_encoder_callback, + ) } } @@ -1102,7 +1142,7 @@ impl crate::Context for ContextWgpuCore { vertex: pipe::VertexState { stage: pipe::ProgrammableStageDescriptor { module: desc.vertex.module.id.into(), - entry_point: Borrowed(desc.vertex.entry_point), + entry_point: Some(Borrowed(desc.vertex.entry_point)), }, buffers: Borrowed(&vertex_buffers), }, @@ -1112,7 +1152,7 @@ impl crate::Context for ContextWgpuCore { fragment: desc.fragment.as_ref().map(|frag| pipe::FragmentState { stage: pipe::ProgrammableStageDescriptor { module: frag.module.id.into(), - entry_point: Borrowed(frag.entry_point), + entry_point: Some(Borrowed(frag.entry_point)), }, targets: Borrowed(frag.targets), }), @@ -1160,7 +1200,7 @@ impl crate::Context for ContextWgpuCore { layout: desc.layout.map(|l| l.id.into()), stage: pipe::ProgrammableStageDescriptor { module: desc.module.id.into(), - entry_point: Borrowed(desc.entry_point), + entry_point: Some(Borrowed(desc.entry_point)), }, }; @@ -1346,14 +1386,17 @@ impl crate::Context for ContextWgpuCore { Err(e) => panic!("Error in Device::create_render_bundle_encoder: {e}"), } } + #[doc(hidden)] + fn device_make_invalid(&self, device: &Self::DeviceId, _device_data: &Self::DeviceData) { + wgc::gfx_select!(device => self.0.device_make_invalid(*device)); + } #[cfg_attr(not(any(native, Emscripten)), allow(unused))] fn device_drop(&self, device: &Self::DeviceId, _device_data: &Self::DeviceData) { #[cfg(any(native, Emscripten))] { - match wgc::gfx_select!(device => self.0.device_poll(*device, wgt::Maintain::wait())) { - Ok(_) => {} - Err(err) => self.handle_error_fatal(err, "Device::drop"), - } + // Call device_poll, but don't check for errors. We have to use its + // return value, but we just drop it. + let _ = wgc::gfx_select!(device => self.0.device_poll(*device, wgt::Maintain::wait())); wgc::gfx_select!(device => self.0.device_drop(*device)); } } diff --git a/wgpu/src/context.rs b/wgpu/src/context.rs index ba1e52ef71..75de4361c0 100644 --- a/wgpu/src/context.rs +++ b/wgpu/src/context.rs @@ -267,6 +267,8 @@ pub trait Context: Debug + WasmNotSendSync + Sized { device_data: &Self::DeviceData, desc: &RenderBundleEncoderDescriptor<'_>, ) -> (Self::RenderBundleEncoderId, Self::RenderBundleEncoderData); + #[doc(hidden)] + fn device_make_invalid(&self, device: &Self::DeviceId, device_data: &Self::DeviceData); fn device_drop(&self, device: &Self::DeviceId, device_data: &Self::DeviceData); fn device_set_device_lost_callback( &self, @@ -1293,6 +1295,8 @@ pub(crate) trait DynContext: Debug + WasmNotSendSync { device_data: &crate::Data, desc: &RenderBundleEncoderDescriptor<'_>, ) -> (ObjectId, Box); + #[doc(hidden)] + fn device_make_invalid(&self, device: &ObjectId, device_data: &crate::Data); fn device_drop(&self, device: &ObjectId, device_data: &crate::Data); fn device_set_device_lost_callback( &self, @@ -2350,6 +2354,13 @@ where (render_bundle_encoder.into(), Box::new(data) as _) } + #[doc(hidden)] + fn device_make_invalid(&self, device: &ObjectId, device_data: &crate::Data) { + let device = ::from(*device); + let device_data = downcast_ref(device_data); + Context::device_make_invalid(self, &device, device_data) + } + fn device_drop(&self, device: &ObjectId, device_data: &crate::Data) { let device = ::from(*device); let device_data = downcast_ref(device_data); diff --git a/wgpu/src/lib.rs b/wgpu/src/lib.rs index 983c7d5a2b..ecf5f88d88 100644 --- a/wgpu/src/lib.rs +++ b/wgpu/src/lib.rs @@ -358,7 +358,7 @@ static_assertions::assert_impl_all!(SurfaceConfiguration: Send, Sync); /// Handle to a presentable surface. /// /// A `Surface` represents a platform-specific surface (e.g. a window) onto which rendered images may -/// be presented. A `Surface` may be created with the unsafe function [`Instance::create_surface`]. +/// be presented. A `Surface` may be created with the function [`Instance::create_surface`]. /// /// This type is unique to the Rust API of `wgpu`. In the WebGPU specification, /// [`GPUCanvasContext`](https://gpuweb.github.io/gpuweb/#canvas-context) @@ -1788,7 +1788,7 @@ impl Instance { ); } - #[cfg(all(webgpu, web_sys_unstable_apis))] + #[cfg(webgpu)] { let is_only_available_backend = !cfg!(wgpu_core); let requested_webgpu = _instance_desc.backends.contains(Backends::BROWSER_WEBGPU); @@ -1943,7 +1943,7 @@ impl Instance { /// Creates a new surface targeting a given window/canvas/surface/etc.. /// /// See [`SurfaceTarget`] for what targets are supported. - /// See [`Instance::create_surface`] for surface creation with unsafe target variants. + /// See [`Instance::create_surface_unsafe`] for surface creation with unsafe target variants. /// /// Most commonly used are window handles (or provider of windows handles) /// which can be passed directly as they're automatically converted to [`SurfaceTarget`]. @@ -2703,6 +2703,12 @@ impl Device { Box::new(callback), ) } + + /// Test-only function to make this device invalid. + #[doc(hidden)] + pub fn make_invalid(&self) { + DynContext::device_make_invalid(&*self.context, &self.id, self.data.as_ref()) + } } impl Drop for Device { @@ -3062,7 +3068,7 @@ impl<'a> BufferSlice<'a> { /// this function directly hands you the ArrayBuffer that we mapped the data into in js. /// /// This is only available on WebGPU, on any other backends this will return `None`. - #[cfg(all(webgpu, web_sys_unstable_apis))] + #[cfg(webgpu)] pub fn get_mapped_range_as_array_buffer(&self) -> Option { self.buffer .context @@ -3109,10 +3115,10 @@ impl Texture { /// /// - The raw handle obtained from the hal Texture must not be manually destroyed #[cfg(wgpu_core)] - pub unsafe fn as_hal)>( + pub unsafe fn as_hal) -> R, R>( &self, hal_texture_callback: F, - ) { + ) -> R { let texture = self.data.as_ref().downcast_ref().unwrap(); if let Some(ctx) = self @@ -3120,7 +3126,7 @@ impl Texture { .as_any() .downcast_ref::() { - unsafe { ctx.texture_as_hal::(texture, hal_texture_callback) } + unsafe { ctx.texture_as_hal::(texture, hal_texture_callback) } } else { hal_texture_callback(None) } @@ -3400,7 +3406,7 @@ impl CommandEncoder { /// # Panics /// /// - Buffer does not have `COPY_DST` usage. - /// - Range it out of bounds + /// - Range is out of bounds pub fn clear_buffer( &mut self, buffer: &Buffer, @@ -3464,9 +3470,39 @@ impl CommandEncoder { destination_offset, ) } + + /// Returns the inner hal CommandEncoder using a callback. The hal command encoder will be `None` if the + /// backend type argument does not match with this wgpu CommandEncoder + /// + /// This method will start the wgpu_core level command recording. + /// + /// # Safety + /// + /// - The raw handle obtained from the hal CommandEncoder must not be manually destroyed + #[cfg(wgpu_core)] + pub unsafe fn as_hal_mut< + A: wgc::hal_api::HalApi, + F: FnOnce(Option<&mut A::CommandEncoder>) -> R, + R, + >( + &mut self, + hal_command_encoder_callback: F, + ) -> Option { + use core::id::CommandEncoderId; + + self.context + .as_any() + .downcast_ref::() + .map(|ctx| unsafe { + ctx.command_encoder_as_hal_mut::( + CommandEncoderId::from(self.id.unwrap()), + hal_command_encoder_callback, + ) + }) + } } -/// [`Features::TIMESTAMP_QUERY`] must be enabled on the device in order to call these functions. +/// [`Features::TIMESTAMP_QUERY_INSIDE_ENCODERS`] must be enabled on the device in order to call these functions. impl CommandEncoder { /// Issue a timestamp command at this point in the queue. /// The timestamp will be written to the specified query set, at the specified index. @@ -3475,6 +3511,11 @@ impl CommandEncoder { /// the value in nanoseconds. Absolute values have no meaning, /// but timestamps can be subtracted to get the time it takes /// for a string of operations to complete. + /// + /// Attention: Since commands within a command recorder may be reordered, + /// there is no strict guarantee that timestamps are taken after all commands + /// recorded so far and all before all commands recorded after. + /// This may depend both on the backend and the driver. pub fn write_timestamp(&mut self, query_set: &QuerySet, query_index: u32) { DynContext::command_encoder_write_timestamp( &*self.context, @@ -4232,7 +4273,7 @@ impl<'a> ComputePass<'a> { /// [`Features::PIPELINE_STATISTICS_QUERY`] must be enabled on the device in order to call these functions. impl<'a> ComputePass<'a> { - /// Start a pipeline statistics query on this render pass. It can be ended with + /// Start a pipeline statistics query on this compute pass. It can be ended with /// `end_pipeline_statistics_query`. Pipeline statistics queries may not be nested. pub fn begin_pipeline_statistics_query(&mut self, query_set: &QuerySet, query_index: u32) { DynContext::compute_pass_begin_pipeline_statistics_query( @@ -4245,7 +4286,7 @@ impl<'a> ComputePass<'a> { ); } - /// End the pipeline statistics query on this render pass. It can be started with + /// End the pipeline statistics query on this compute pass. It can be started with /// `begin_pipeline_statistics_query`. Pipeline statistics queries may not be nested. pub fn end_pipeline_statistics_query(&mut self) { DynContext::compute_pass_end_pipeline_statistics_query( @@ -4772,11 +4813,11 @@ impl Surface<'_> { let caps = self.get_capabilities(adapter); Some(SurfaceConfiguration { usage: wgt::TextureUsages::RENDER_ATTACHMENT, - format: *caps.formats.get(0)?, + format: *caps.formats.first()?, width, height, desired_maximum_frame_latency: 2, - present_mode: *caps.present_modes.get(0)?, + present_mode: *caps.present_modes.first()?, alpha_mode: wgt::CompositeAlphaMode::Auto, view_formats: vec![], }) @@ -4926,7 +4967,7 @@ impl Eq for Id {} impl PartialOrd for Id { fn partial_cmp(&self, other: &Id) -> Option { - self.0.partial_cmp(&other.0) + Some(self.cmp(other)) } } @@ -5010,6 +5051,34 @@ impl TextureView { pub fn global_id(&self) -> Id { Id(self.id.global_id(), PhantomData) } + + /// Returns the inner hal TextureView using a callback. The hal texture will be `None` if the + /// backend type argument does not match with this wgpu Texture + /// + /// # Safety + /// + /// - The raw handle obtained from the hal TextureView must not be manually destroyed + #[cfg(wgpu_core)] + pub unsafe fn as_hal) -> R, R>( + &self, + hal_texture_view_callback: F, + ) -> R { + use core::id::TextureViewId; + + let texture_view_id = TextureViewId::from(self.id); + + if let Some(ctx) = self + .context + .as_any() + .downcast_ref::() + { + unsafe { + ctx.texture_view_as_hal::(texture_view_id, hal_texture_view_callback) + } + } else { + hal_texture_view_callback(None) + } + } } impl Sampler { diff --git a/wgpu/src/macros.rs b/wgpu/src/macros.rs index fc3560e01c..f1a15e764e 100644 --- a/wgpu/src/macros.rs +++ b/wgpu/src/macros.rs @@ -78,7 +78,16 @@ macro_rules! include_spirv_raw { }; } -/// Macro to load a WGSL module statically. +/// Load WGSL source code from a file at compile time. +/// +/// The loaded path is relative to the path of the file containing the macro call, in the same way +/// as [`include_str!`] operates. +/// +/// ```ignore +/// fn main() { +/// let module: ShaderModuleDescriptor = include_wgsl!("shader.wgsl"); +/// } +/// ``` #[macro_export] macro_rules! include_wgsl { ($($token:tt)*) => { diff --git a/wgpu/src/util/belt.rs b/wgpu/src/util/belt.rs index d6ef7a0c46..9d8c3c4e21 100644 --- a/wgpu/src/util/belt.rs +++ b/wgpu/src/util/belt.rs @@ -117,6 +117,7 @@ impl StagingBelt { } else { let size = self.chunk_size.max(size.get()); Chunk { + #[allow(clippy::arc_with_non_send_sync)] // False positive on emscripten buffer: Arc::new(device.create_buffer(&BufferDescriptor { label: Some("(wgpu internal) StagingBelt staging buffer"), size, diff --git a/wgpu/src/util/mod.rs b/wgpu/src/util/mod.rs index 081346faf7..3ab6639cf8 100644 --- a/wgpu/src/util/mod.rs +++ b/wgpu/src/util/mod.rs @@ -100,6 +100,7 @@ impl DownloadBuffer { None => buffer.buffer.map_context.lock().total_size - buffer.offset, }; + #[allow(clippy::arc_with_non_send_sync)] // False positive on emscripten let download = Arc::new(device.create_buffer(&super::BufferDescriptor { size, usage: super::BufferUsages::COPY_DST | super::BufferUsages::MAP_READ, diff --git a/xtask/Cargo.lock b/xtask/Cargo.lock index 50b572cd03..da50a58f99 100644 --- a/xtask/Cargo.lock +++ b/xtask/Cargo.lock @@ -29,6 +29,12 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5be167a7af36ee22fe3115051bc51f6e6c7054c9348e28deb4f49bd6f705a315" +[[package]] +name = "regex-lite" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30b661b2f27137bdbc16f00eda72866a92bb28af1753ffbd56744fb6e2e9cd8e" + [[package]] name = "xshell" version = "0.2.5" @@ -52,5 +58,6 @@ dependencies = [ "env_logger", "log", "pico-args", + "regex-lite", "xshell", ] diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml index 3bbc64c46f..b608e4f80f 100644 --- a/xtask/Cargo.toml +++ b/xtask/Cargo.toml @@ -8,6 +8,7 @@ publish = false # The dependencies in this config have no transitive dependencies. anyhow = "1.0.71" env_logger = { version = "0.10.0", default-features = false } +regex-lite = "0.1.5" log = "0.4.18" pico-args = { version = "0.5.0", features = [ "eq-separator", diff --git a/xtask/src/cli.rs b/xtask/src/cli.rs deleted file mode 100644 index 78547268a9..0000000000 --- a/xtask/src/cli.rs +++ /dev/null @@ -1,67 +0,0 @@ -use std::process::exit; - -use anyhow::{anyhow, bail, Context}; -use pico_args::Arguments; - -const HELP: &str = "\ -Usage: xtask - -Commands: - run-wasm - --release Build in release mode - --no-serve Just build the generated files, don't serve them - test - --llvm-cov Run tests with LLVM code coverage using the llvm-cov tool - -Options: - -h, --help Print help -"; - -pub struct Args { - pub subcommand: Subcommand, - pub command_args: Arguments, -} - -impl Args { - pub fn parse() -> Self { - let mut args = Arguments::from_env(); - if args.contains("--help") { - eprint!("{HELP}"); - // Emulate Cargo exit status: - // - let cargo_like_exit_code = 101; - exit(cargo_like_exit_code); - } - match Subcommand::parse(&mut args) { - Ok(subcommand) => Self { - subcommand, - command_args: args, - }, - Err(e) => { - eprintln!("{:?}", anyhow!(e)); - exit(1) - } - } - } -} - -pub enum Subcommand { - RunWasm, - Test, -} - -impl Subcommand { - fn parse(args: &mut Arguments) -> anyhow::Result { - let subcmd = args - .subcommand() - .context("failed to parse subcommand")? - .context("no subcommand specified; see `--help` for more details")?; - match &*subcmd { - "run-wasm" => Ok(Self::RunWasm), - "test" => Ok(Self::Test), - other => { - bail!("unrecognized subcommand {other:?}; see `--help` for more details") - } - } - } -} diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 1ff0aa8efd..3f6eb622bf 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -1,27 +1,76 @@ -use cli::Args; +use std::process::ExitCode; + +use anyhow::Context; +use pico_args::Arguments; -mod cli; mod run_wasm; mod test; mod util; +mod vendor_web_sys; + +const HELP: &str = "\ +Usage: xtask + +Commands: + run-wasm + --release Build in release mode + --no-serve Just build the generated files, don't serve them + test + --llvm-cov Run tests with LLVM code coverage using the llvm-cov tool + vendor-web-sys + --no-cleanup Don't clean up temporary checkout of wasm-bindgen + One of: + --path-to-checkout Path to a local checkout of wasm-bindgen to generate bindings from. + This is useful for testing changes to wasm-bindgen + --version String that can be passed to `git checkout` to checkout the wasm-bindgen repository. + +Options: + -h, --help Print help +"; + +/// Helper macro for printing the help message, then bailing with an error message. +#[macro_export] +macro_rules! bad_arguments { + ($($arg:tt)*) => {{ + eprintln!("{}", crate::HELP); + anyhow::bail!($($arg)*) + }}; +} -fn main() -> anyhow::Result<()> { +fn main() -> anyhow::Result { env_logger::builder() .filter_level(log::LevelFilter::Info) .parse_default_env() .format_indent(Some(0)) .init(); - let args = Args::parse(); + let mut args = Arguments::from_env(); - run(args) -} + if args.contains("--help") { + eprint!("{HELP}"); + return Ok(ExitCode::FAILURE); + } + + let subcommand = args + .subcommand() + .context("Expected subcommand to be UTF-8")?; -#[allow(unused_mut, unreachable_patterns)] -fn run(mut args: Args) -> anyhow::Result<()> { - match args.subcommand { - cli::Subcommand::RunWasm => run_wasm::run_wasm(args.command_args), - cli::Subcommand::Test => test::run_tests(args.command_args), - _ => unreachable!(), + // -- Shell Creation -- + + let shell = xshell::Shell::new().context("Couldn't create xshell shell")?; + shell.change_dir(String::from(env!("CARGO_MANIFEST_DIR")) + "/.."); + + match subcommand.as_deref() { + Some("run-wasm") => run_wasm::run_wasm(shell, args)?, + Some("test") => test::run_tests(shell, args)?, + Some("vendor-web-sys") => vendor_web_sys::run_vendor_web_sys(shell, args)?, + Some(subcommand) => { + bad_arguments!("Unknown subcommand: {}", subcommand) + } + None => { + bad_arguments!("Expected subcommand") + } } + + Ok(ExitCode::SUCCESS) } diff --git a/xtask/src/run_wasm.rs b/xtask/src/run_wasm.rs index 280ef82775..33351e670c 100644 --- a/xtask/src/run_wasm.rs +++ b/xtask/src/run_wasm.rs @@ -1,10 +1,11 @@ use anyhow::Context; use pico_args::Arguments; +use xshell::Shell; use crate::util::{check_all_programs, Program}; -pub(crate) fn run_wasm(mut args: Arguments) -> Result<(), anyhow::Error> { +pub(crate) fn run_wasm(shell: Shell, mut args: Arguments) -> Result<(), anyhow::Error> { let no_serve = args.contains("--no-serve"); let release = args.contains("--release"); @@ -31,9 +32,6 @@ pub(crate) fn run_wasm(mut args: Arguments) -> Result<(), anyhow::Error> { let release_flag: &[_] = if release { &["--release"] } else { &[] }; let output_dir = if release { "release" } else { "debug" }; - let shell = xshell::Shell::new().context("Couldn't create xshell shell")?; - shell.change_dir(String::from(env!("CARGO_MANIFEST_DIR")) + "/.."); - log::info!("building webgpu examples"); let cargo_args = args.finish(); diff --git a/xtask/src/test.rs b/xtask/src/test.rs index 71e084f044..70278df47b 100644 --- a/xtask/src/test.rs +++ b/xtask/src/test.rs @@ -1,7 +1,8 @@ use anyhow::Context; use pico_args::Arguments; +use xshell::Shell; -pub fn run_tests(mut args: Arguments) -> anyhow::Result<()> { +pub fn run_tests(shell: Shell, mut args: Arguments) -> anyhow::Result<()> { let llvm_cov = args.contains("--llvm-cov"); // These needs to match the command in "run wgpu-info" in `.github/workflows/ci.yml` let llvm_cov_flags: &[_] = if llvm_cov { @@ -15,10 +16,6 @@ pub fn run_tests(mut args: Arguments) -> anyhow::Result<()> { &["nextest", "run"] }; - let shell = xshell::Shell::new().context("Couldn't create xshell shell")?; - - shell.change_dir(String::from(env!("CARGO_MANIFEST_DIR")) + "/.."); - log::info!("Generating .gpuconfig file based on gpus on the system"); xshell::cmd!( diff --git a/xtask/src/vendor_web_sys.rs b/xtask/src/vendor_web_sys.rs new file mode 100644 index 0000000000..afa590fa6a --- /dev/null +++ b/xtask/src/vendor_web_sys.rs @@ -0,0 +1,302 @@ +use anyhow::Context; +use pico_args::Arguments; +use xshell::Shell; + +use crate::bad_arguments; + +/// Path to the webgpu_sys folder relative to the root of the repository +const WEBGPU_SYS_PATH: &str = "wgpu/src/backend/webgpu/webgpu_sys"; +/// Path to the temporary clone of the wasm-bindgen repository. +/// +/// This should be synchronized with the path in .gitignore. +const WASM_BINDGEN_TEMP_CLONE_PATH: &str = + "wgpu/src/backend/webgpu/webgpu_sys/wasm_bindgen_clone_tmp"; +/// Prefix of the file names in the wasm-bindgen repository that we need to copy. +/// +/// This prefix will be added to all of the feature names to get the full file name. +/// Relative to the root of the wasm-bindgen repository. +const WEB_SYS_FILE_PREFIX: &str = "crates/web-sys/src/features/gen_"; +const WEB_SYS_FEATURES_NEEDED: &[&str] = &[ + "Gpu", + "GpuAdapter", + "GpuAddressMode", + "GpuAutoLayoutMode", + "GpuBindGroup", + "GpuBindGroupDescriptor", + "GpuBindGroupEntry", + "GpuBindGroupLayout", + "GpuBindGroupLayoutDescriptor", + "GpuBindGroupLayoutEntry", + "GpuBlendComponent", + "GpuBlendFactor", + "GpuBlendOperation", + "GpuBlendState", + "GpuBuffer", + "GpuBufferBinding", + "GpuBufferBindingLayout", + "GpuBufferBindingType", + "GpuBufferDescriptor", + "GpuBufferMapState", + "GpuCanvasAlphaMode", + "GpuCanvasContext", + "GpuCanvasConfiguration", + "GpuColorDict", + "GpuColorTargetState", + "GpuCommandBuffer", + "GpuCommandBufferDescriptor", + "GpuCommandEncoder", + "GpuCommandEncoderDescriptor", + "GpuCompareFunction", + "GpuCompilationInfo", + "GpuCompilationMessage", + "GpuCompilationMessageType", + "GpuComputePassDescriptor", + "GpuComputePassEncoder", + "GpuComputePassTimestampWrites", + "GpuComputePipeline", + "GpuComputePipelineDescriptor", + "GpuCullMode", + "GpuDepthStencilState", + "GpuDevice", + "GpuDeviceDescriptor", + "GpuDeviceLostInfo", + "GpuDeviceLostReason", + "GpuError", + "GpuErrorFilter", + "GpuExternalTexture", + "GpuExternalTextureBindingLayout", + "GpuExternalTextureDescriptor", + // "GpuExtent2dDict", Not yet implemented in web_sys + "GpuExtent3dDict", + "GpuFeatureName", + "GpuFilterMode", + "GpuFragmentState", + "GpuFrontFace", + "GpuImageCopyBuffer", + "GpuImageCopyExternalImage", + "GpuImageCopyTexture", + "GpuImageCopyTextureTagged", + "GpuImageDataLayout", + "GpuIndexFormat", + "GpuLoadOp", + "gpu_map_mode", + "GpuMipmapFilterMode", + "GpuMultisampleState", + "GpuObjectDescriptorBase", + "GpuOrigin2dDict", + "GpuOrigin3dDict", + "GpuOutOfMemoryError", + "GpuPipelineDescriptorBase", + "GpuPipelineLayout", + "GpuPipelineLayoutDescriptor", + "GpuPowerPreference", + "GpuPrimitiveState", + "GpuPrimitiveTopology", + "GpuProgrammableStage", + "GpuQuerySet", + "GpuQuerySetDescriptor", + "GpuQueryType", + "GpuQueue", + "GpuQueueDescriptor", + "GpuRenderBundle", + "GpuRenderBundleDescriptor", + "GpuRenderBundleEncoder", + "GpuRenderBundleEncoderDescriptor", + "GpuRenderPassColorAttachment", + "GpuRenderPassDepthStencilAttachment", + "GpuRenderPassDescriptor", + "GpuRenderPassEncoder", + "GpuRenderPassTimestampWrites", + "GpuRenderPipeline", + "GpuRenderPipelineDescriptor", + "GpuRequestAdapterOptions", + "GpuSampler", + "GpuSamplerBindingLayout", + "GpuSamplerBindingType", + "GpuSamplerDescriptor", + "GpuShaderModule", + "GpuShaderModuleDescriptor", + "GpuStencilFaceState", + "GpuStencilOperation", + "GpuStorageTextureAccess", + "GpuStorageTextureBindingLayout", + "GpuStoreOp", + "GpuSupportedFeatures", + "GpuSupportedLimits", + "GpuTexture", + "GpuTextureAspect", + "GpuTextureBindingLayout", + "GpuTextureDescriptor", + "GpuTextureDimension", + "GpuTextureFormat", + "GpuTextureSampleType", + "GpuTextureView", + "GpuTextureViewDescriptor", + "GpuTextureViewDimension", + "GpuUncapturedErrorEvent", + "GpuUncapturedErrorEventInit", + "GpuValidationError", + "GpuVertexAttribute", + "GpuVertexBufferLayout", + "GpuVertexFormat", + "GpuVertexState", + "GpuVertexStepMode", + "WgslLanguageFeatures", +]; + +pub(crate) fn run_vendor_web_sys(shell: Shell, mut args: Arguments) -> anyhow::Result<()> { + // -- Argument Parsing -- + + let no_cleanup = args.contains("--no-cleanup"); + + // We only allow one of these arguments to be passed at a time. + let version: Option = args.opt_value_from_str("--version")?; + let path_to_checkout_arg: Option = args.opt_value_from_str("--path-to-checkout")?; + + // Plain text of the command that was run. + let argument_description; + // Path to the checkout we're using + let path_to_wasm_bindgen_checkout; + match (path_to_checkout_arg.as_deref(), version.as_deref()) { + (Some(path), None) => { + argument_description = format!("--path-to-checkout {path}"); + path_to_wasm_bindgen_checkout = path + } + (None, Some(version)) => { + argument_description = format!("--version {version}"); + path_to_wasm_bindgen_checkout = WASM_BINDGEN_TEMP_CLONE_PATH + } + (Some(_), Some(_)) => { + bad_arguments!("Cannot use both --path-to-checkout and --version at the same time") + } + (None, None) => { + bad_arguments!("Expected either --path-to-checkout or --version") + } + }; + + let unknown_args = args.finish(); + if !unknown_args.is_empty() { + bad_arguments!( + "Unknown arguments to vendor-web-sys subcommand: {:?}", + unknown_args + ); + } + + // -- Main Logic -- + + eprintln!("# Removing {WEBGPU_SYS_PATH}"); + shell + .remove_path(WEBGPU_SYS_PATH) + .context("could not remove webgpu_sys")?; + + if let Some(ref version) = version { + eprintln!("# Cloning wasm-bindgen repository with version {version}"); + shell + .cmd("git") + .args([ + "clone", + "-b", + version, + "--depth", + "1", + "https://github.com/rustwasm/wasm-bindgen.git", + WASM_BINDGEN_TEMP_CLONE_PATH, + ]) + .ignore_stderr() + .run() + .context("Could not clone wasm-bindgen repository")?; + } + + if let Some(ref path) = path_to_checkout_arg { + eprintln!("# Using local checkout of wasm-bindgen at {path}"); + } + + shell + .create_dir(WEBGPU_SYS_PATH) + .context("Could not create webgpu_sys folder")?; + + // The indentation here does not matter, as rustfmt will normalize it. + let file_prefix = format!("\ + // DO NOT EDIT THIS FILE! + // + // This module part of a subset of web-sys that is used by wgpu's webgpu backend. + // + // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. + // + // This file was generated by the `cargo xtask vendor-web-sys {argument_description}` command.\n" + ); + + eprintln!( + "# Copying {} files and removing `#[cfg(...)]` attributes", + WEB_SYS_FEATURES_NEEDED.len() + ); + + // Matches all `#[cfg(...)]` attributes, including multi-line ones. + // + // The ? is very important, otherwise the regex will match the entire file. + let regex = regex_lite::RegexBuilder::new(r#"#\[cfg\(.*?\)\]"#) + .dot_matches_new_line(true) + .build() + .unwrap(); + + for &feature in WEB_SYS_FEATURES_NEEDED { + let feature_file = + format!("{path_to_wasm_bindgen_checkout}/{WEB_SYS_FILE_PREFIX}{feature}.rs"); + let destination = format!("{WEBGPU_SYS_PATH}/gen_{feature}.rs"); + + let file_contents = shell + .read_file(&feature_file) + .context("Could not read file")?; + + let mut file_contents = regex.replace_all(&file_contents, "").to_string(); + file_contents.insert_str(0, &file_prefix); + + shell + .write_file(destination, file_contents.as_bytes()) + .context("could not write file")?; + } + + eprintln!("# Writing mod.rs file"); + + let mut module_file_contents = format!( + "\ + //! Bindings to the WebGPU API. + //! + //! Internally vendored from the `web-sys` crate until the WebGPU binding are stabilized. + {file_prefix} + #![allow(unused_imports, non_snake_case)]\n" + ); + + module_file_contents.push_str("use web_sys::{Event, EventTarget};\n"); + + for &feature in WEB_SYS_FEATURES_NEEDED { + module_file_contents.push_str(&format!("mod gen_{};\n", feature)); + module_file_contents.push_str(&format!("pub use gen_{}::*;\n", feature)); + } + + shell.write_file(format!("{}/mod.rs", WEBGPU_SYS_PATH), module_file_contents)?; + + eprintln!("# Formatting files"); + + shell + .cmd("rustfmt") + .arg(format!("{WEBGPU_SYS_PATH}/mod.rs")) + .run() + .context("could not format")?; + + if !no_cleanup { + // We only need to remove this if we cloned it in the first place. + if version.is_some() { + eprintln!("# Removing wasm-bindgen clone"); + shell + .remove_path(WASM_BINDGEN_TEMP_CLONE_PATH) + .context("could not remove wasm-bindgen clone")?; + } + } else { + eprintln!("# Skipping cleanup"); + } + + eprintln!("# Finished!"); + + Ok(()) +}