From 52f1227374cff72ce456db8efa2c1798f0728468 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 30 Mar 2025 23:01:42 -0400 Subject: [PATCH 001/806] chore(deps): bump crate-ci/typos from 1.30.2 to 1.31.0 (#7452) Bumps [crate-ci/typos](https://github.com/crate-ci/typos) from 1.30.2 to 1.31.0. - [Release notes](https://github.com/crate-ci/typos/releases) - [Changelog](https://github.com/crate-ci/typos/blob/master/CHANGELOG.md) - [Commits](https://github.com/crate-ci/typos/compare/v1.30.2...v1.31.0) --- updated-dependencies: - dependency-name: crate-ci/typos dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cc5dce5cd..92aed4c06 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -758,7 +758,7 @@ jobs: run: taplo format --check --diff - name: Check for typos - uses: crate-ci/typos@v1.30.2 + uses: crate-ci/typos@v1.31.0 check-cts-runner: # runtime is normally 2 minutes From 24b72fc99454a1f8bb7dcf029c14af73d4937377 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 31 Mar 2025 09:55:42 -0400 Subject: [PATCH 002/806] chore(deps): bump the patch-updates group with 6 updates (#7453) Bumps the patch-updates group with 6 updates: | Package | From | To | | --- | --- | --- | | [glam](https://github.com/bitshifter/glam-rs) | `0.29.2` | `0.29.3` | | [once_cell](https://github.com/matklad/once_cell) | `1.21.1` | `1.21.3` | | [bytemuck_derive](https://github.com/Lokathor/bytemuck) | `1.9.2` | `1.9.3` | | [clap](https://github.com/clap-rs/clap) | `4.5.33` | `4.5.34` | | [clap_builder](https://github.com/clap-rs/clap) | `4.5.33` | `4.5.34` | | [socket2](https://github.com/rust-lang/socket2) | `0.5.8` | `0.5.9` | Updates `glam` from 0.29.2 to 0.29.3 - [Changelog](https://github.com/bitshifter/glam-rs/blob/0.29.3/CHANGELOG.md) - [Commits](https://github.com/bitshifter/glam-rs/compare/0.29.2...0.29.3) Updates `once_cell` from 1.21.1 to 1.21.3 - [Changelog](https://github.com/matklad/once_cell/blob/master/CHANGELOG.md) - [Commits](https://github.com/matklad/once_cell/compare/v1.21.1...v1.21.3) Updates `bytemuck_derive` from 1.9.2 to 1.9.3 - [Changelog](https://github.com/Lokathor/bytemuck/blob/main/changelog.md) - [Commits](https://github.com/Lokathor/bytemuck/commits) Updates `clap` from 4.5.33 to 4.5.34 - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.5.33...clap_complete-v4.5.34) Updates `clap_builder` from 4.5.33 to 4.5.34 - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.5.33...v4.5.34) Updates `socket2` from 0.5.8 to 0.5.9 - [Release notes](https://github.com/rust-lang/socket2/releases) - [Changelog](https://github.com/rust-lang/socket2/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-lang/socket2/commits) --- updated-dependencies: - dependency-name: glam dependency-type: direct:production update-type: version-update:semver-patch dependency-group: patch-updates - dependency-name: once_cell dependency-type: direct:production update-type: version-update:semver-patch dependency-group: patch-updates - dependency-name: bytemuck_derive dependency-type: indirect update-type: version-update:semver-patch dependency-group: patch-updates - dependency-name: clap dependency-type: indirect update-type: version-update:semver-patch dependency-group: patch-updates - dependency-name: clap_builder dependency-type: indirect update-type: version-update:semver-patch dependency-group: patch-updates - dependency-name: socket2 dependency-type: indirect update-type: version-update:semver-patch dependency-group: patch-updates ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 30 +++++++++++++++--------------- Cargo.toml | 2 +- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4ccb5da9e..0a2e220a4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -473,9 +473,9 @@ dependencies = [ [[package]] name = "bytemuck_derive" -version = "1.9.2" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ff22c2722516255d1823ce3cc4bc0b154dbc9364be5c905d6baa6eccbbc8774" +checksum = "7ecc273b49b3205b83d648f0690daa588925572cc5063745bfe547fe7ec8e1a1" dependencies = [ "proc-macro2", "quote", @@ -706,9 +706,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.33" +version = "4.5.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2c80cae4c3350dd8f1272c73e83baff9a6ba550b8bfbe651b3c45b78cd1751e" +checksum = "e958897981290da2a852763fe9cdb89cd36977a5d729023127095fa94d95e2ff" dependencies = [ "clap_builder", "clap_derive", @@ -716,9 +716,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.33" +version = "4.5.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0123e386f691c90aa228219b5b1ee72d465e8e231c79e9c82324f016a62a741c" +checksum = "83b0f35019843db2160b5bb19ae09b4e6411ac33fc6a712003c33e03090e2489" dependencies = [ "anstream", "anstyle", @@ -1338,7 +1338,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -1632,9 +1632,9 @@ dependencies = [ [[package]] name = "glam" -version = "0.29.2" +version = "0.29.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc46dd3ec48fdd8e693a98d2b8bafae273a2d54c1de02a2a7e3d57d501f39677" +checksum = "8babf46d4c1c9d92deac9f7be466f76dfc4482b6452fc5024b5e8daf6ffeb3ee" dependencies = [ "bytemuck", ] @@ -2041,7 +2041,7 @@ checksum = "e04d7f318608d35d4b61ddd75cbdaee86b023ebe2bd5a66ee0915f0bf93095a9" dependencies = [ "hermit-abi 0.5.0", "libc", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -2873,9 +2873,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.21.1" +version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d75b0bedcc4fe52caa0e03d9f1151a323e4aa5e2d78ba3580400cd3c9e2bc4bc" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" [[package]] name = "oorandom" @@ -3435,7 +3435,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -3701,9 +3701,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.8" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c970269d99b64e60ec3bd6ad27270092a5394c4e309314b18ae3fe575695fbe8" +checksum = "4f5fd57c80058a56cf5c777ab8a126398ece8e442983605d280a44ce79d0edef" dependencies = [ "libc", "windows-sys 0.52.0", diff --git a/Cargo.toml b/Cargo.toml index 7924888be..559e281c0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -126,7 +126,7 @@ noise = "0.9" nv-flip = "0.1" obj = "0.10" # NOTE: once_cell/std is *required* for some commonly-used features, selecting this per crate -once_cell = { version = "1.21.1", default-features = false } +once_cell = { version = "1.21.3", default-features = false } # Firefox has 3.4.0 vendored, so we allow that version in our dependencies ordered-float = { version = ">=3,<=4.6", default-features = false } parking_lot = "0.12.1" From d1b00c5d25c75af34e960132a1e9b96e7409d46e Mon Sep 17 00:00:00 2001 From: Andy Leiserson Date: Mon, 31 Mar 2025 13:07:52 -0700 Subject: [PATCH 003/806] [examples] Fixes for examples on web (#7454) Fixes #7364 --- examples/features/src/boids/mod.rs | 4 +-- .../src/multiple_render_targets/mod.rs | 11 ++++--- examples/features/src/utils.rs | 32 +++++++++++-------- examples/features/web-static/index.html | 21 +++++++++--- 4 files changed, 42 insertions(+), 26 deletions(-) diff --git a/examples/features/src/boids/mod.rs b/examples/features/src/boids/mod.rs index bef725661..a5364548d 100644 --- a/examples/features/src/boids/mod.rs +++ b/examples/features/src/boids/mod.rs @@ -265,9 +265,7 @@ impl crate::framework::Example for Example { view, resolve_target: None, ops: wgpu::Operations { - // Not clearing here in order to test wgpu's zero texture initialization on a surface texture. - // Users should avoid loading uninitialized memory since this can cause additional overhead. - load: wgpu::LoadOp::Load, + load: wgpu::LoadOp::Clear(wgpu::Color::BLACK), store: wgpu::StoreOp::Store, }, })]; diff --git a/examples/features/src/multiple_render_targets/mod.rs b/examples/features/src/multiple_render_targets/mod.rs index 37991354b..68eb3d2a5 100644 --- a/examples/features/src/multiple_render_targets/mod.rs +++ b/examples/features/src/multiple_render_targets/mod.rs @@ -454,12 +454,12 @@ impl crate::framework::Example for Example { // output textures: &[ Some(wgpu::ColorTargetState { - format: config.format, + format: config.view_formats[0], blend: None, write_mask: Default::default(), }), Some(wgpu::ColorTargetState { - format: config.format, + format: config.view_formats[0], blend: None, write_mask: Default::default(), }), @@ -468,10 +468,11 @@ impl crate::framework::Example for Example { // create our target textures that will receive the simultaneous rendering: let texture_targets = - TextureTargets::new(device, config.format, config.width, config.height); + TextureTargets::new(device, config.view_formats[0], config.width, config.height); // helper renderer that displays the results in 2 separate viewports: - let drawer = TargetRenderer::init(device, &shader, config.format, &texture_targets); + let drawer = + TargetRenderer::init(device, &shader, config.view_formats[0], &texture_targets); Self { texture_targets, @@ -491,7 +492,7 @@ impl crate::framework::Example for Example { self.screen_width = config.width; self.screen_height = config.height; self.texture_targets = - TextureTargets::new(device, config.format, config.width, config.height); + TextureTargets::new(device, config.view_formats[0], config.width, config.height); self.drawer.rebuild_resources(device, &self.texture_targets); } diff --git a/examples/features/src/utils.rs b/examples/features/src/utils.rs index bbc727582..0ec28b71c 100644 --- a/examples/features/src/utils.rs +++ b/examples/features/src/utils.rs @@ -3,14 +3,20 @@ use std::io::Write; #[cfg(target_arch = "wasm32")] use wasm_bindgen::prelude::*; +#[cfg(target_arch = "wasm32")] +fn get_content_div() -> web_sys::Element { + web_sys::window() + .and_then(|window| window.document()) + .and_then(|document| document.get_element_by_id("content")) + .expect("Could not get document / content.") +} + /// Replaces the site body with a message telling the user to open the console and use that. #[cfg(target_arch = "wasm32")] pub fn add_web_nothing_to_see_msg() { - web_sys::window() - .and_then(|window| window.document()) - .and_then(|document| document.body()) - .expect("Could not get document / body.") - .set_inner_html("

Nothing to see here! Open the console!

"); + get_content_div().set_inner_html( + "

This is a compute example, so there's nothing to see here. Open the console!

", + ); } /// Outputs a vector of RGBA bytes as a png image with the given dimensions on the given path. @@ -43,7 +49,7 @@ pub fn output_image_native(image_data: Vec, texture_dims: (usize, usize), pa #[cfg(target_arch = "wasm32")] pub fn output_image_wasm(image_data: Vec, texture_dims: (usize, usize)) { let document = web_sys::window().unwrap().document().unwrap(); - let body = document.body().unwrap(); + let content_div = get_content_div(); let canvas = if let Some(found_canvas) = document.get_element_by_id("staging-canvas") { match found_canvas.dyn_into::() { @@ -121,14 +127,15 @@ pub fn output_image_wasm(image_data: Vec, texture_dims: (usize, usize)) { You can drag it to your desktop to download.", )); p.set_id("image-for-you-text"); - body.append_child(&p) - .expect("Failed to append \"image for you text\" to document body."); + content_div + .append_child(&p) + .expect("Failed to append \"image for you text\" to document."); } } #[cfg(target_arch = "wasm32")] fn create_staging_canvas(document: &web_sys::Document) -> web_sys::HtmlCanvasElement { - let body = document.body().expect("Failed to get document body."); + let content_div = get_content_div(); let new_canvas = document .create_element("canvas") .expect("Failed to create staging canvas.") @@ -137,22 +144,21 @@ fn create_staging_canvas(document: &web_sys::Document) -> web_sys::HtmlCanvasEle // We don't want to show the canvas, we just want it to exist in the background. new_canvas.set_attribute("hidden", "true").unwrap(); new_canvas.set_attribute("background-color", "red").unwrap(); - body.append_child(&new_canvas).unwrap(); + content_div.append_child(&new_canvas).unwrap(); log::info!("Created new staging canvas: {:?}", &new_canvas); new_canvas } #[cfg(target_arch = "wasm32")] fn create_output_image_element(document: &web_sys::Document) -> web_sys::HtmlImageElement { - let body = document.body().expect("Failed to get document body."); + let content_div = get_content_div(); let new_image = document .create_element("img") .expect("Failed to create output image element.") .dyn_into::() .unwrap(); new_image.set_id("output-image-target"); - body.append_child(&new_image) - .expect("Failed to append output image target to document body."); + content_div.replace_children_with_node_1(&new_image); log::info!("Created new output target image: {:?}", &new_image); new_image } diff --git a/examples/features/web-static/index.html b/examples/features/web-static/index.html index 135c04d81..3a2349cdf 100644 --- a/examples/features/web-static/index.html +++ b/examples/features/web-static/index.html @@ -50,6 +50,11 @@ margin: 0.5em 0; } + h1 { + margin-left: 0.75em; + margin-right: 0.75em; + } + .backend-list-container { display: flex; flex-direction: row; @@ -99,14 +104,18 @@ text-align: center; } - .main-canvas { - margin: 0; + #content { /* This allows the flexbox to grow to max size, this is needed for WebGPU */ - flex: 1; + flex: 1 1 100%; /* This forces CSS to ignore the width/height of the canvas, this is needed for WebGL */ contain: size; } + .main-canvas { + margin: 0; + width: 100%; + height: 100%; + } #menu-button { display: none; @@ -158,7 +167,9 @@ - +
+ +
- \ No newline at end of file + From 700a2e8ced7966d5a89c0635734e8c325397bbb6 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Mon, 31 Mar 2025 13:21:18 -0700 Subject: [PATCH 004/806] [naga] Update naga/xtask/Cargo.lock. --- naga/xtask/Cargo.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/naga/xtask/Cargo.lock b/naga/xtask/Cargo.lock index 122b2ded9..9e2b2f206 100644 --- a/naga/xtask/Cargo.lock +++ b/naga/xtask/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "anyhow" @@ -122,18 +122,18 @@ dependencies = [ [[package]] name = "nanoserde" -version = "0.1.37" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5de9cf844ab1e25a0353525bd74cb889843a6215fa4a0d156fd446f4857a1b99" +checksum = "a36fb3a748a4c9736ed7aeb5f2dfc99665247f1ce306abbddb2bf0ba2ac530a4" dependencies = [ "nanoserde-derive", ] [[package]] name = "nanoserde-derive" -version = "0.1.22" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e943b2c21337b7e3ec6678500687cdc741b7639ad457f234693352075c082204" +checksum = "a846cbc04412cf509efcd8f3694b114fc700a035fb5a37f21517f9fb019f1ebc" [[package]] name = "num_cpus" From 3d7ae9dc920536d41729e7bfd9548ea4bfc6fe44 Mon Sep 17 00:00:00 2001 From: Marc Pabst <2624210+marcpabst@users.noreply.github.com> Date: Tue, 1 Apr 2025 01:15:35 +0100 Subject: [PATCH 005/806] Allow to get raw swap chain from DX12 surface (#7399) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * allow to get raw swap_chain from dx12 surface * Update wgpu-hal/src/dx12/mod.rs Co-authored-by: Connor Fitzgerald * allow obtaining IDXGISwapChain3 directly --------- Co-authored-by: Marc Pabst Co-authored-by: Connor Fitzgerald Co-authored-by: Marc Pabst <“marcpabst@users.noreply.github.com”> --- wgpu-hal/src/dx12/mod.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/wgpu-hal/src/dx12/mod.rs b/wgpu-hal/src/dx12/mod.rs index 48fcbee6e..3099e7614 100644 --- a/wgpu-hal/src/dx12/mod.rs +++ b/wgpu-hal/src/dx12/mod.rs @@ -546,6 +546,12 @@ pub struct Surface { unsafe impl Send for Surface {} unsafe impl Sync for Surface {} +impl Surface { + pub fn swap_chain(&self) -> Option { + Some(self.swap_chain.read().as_ref()?.raw.clone()) + } +} + #[derive(Debug, Clone, Copy)] enum MemoryArchitecture { Unified { From 65fcacf683a23092279cebf23aa50aa2f4034017 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Mon, 31 Mar 2025 17:16:00 -0700 Subject: [PATCH 006/806] [naga tests] Silence dead code warning. (#7457) Silence warnings about `DummyInterpolationShader::entry_point` being unused in test builds with `wgsl-in` feature but without the `glsl-out` feature. --- naga/tests/validation.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/naga/tests/validation.rs b/naga/tests/validation.rs index 9c1b45394..9f70288e5 100644 --- a/naga/tests/validation.rs +++ b/naga/tests/validation.rs @@ -472,6 +472,7 @@ mod dummy_interpolation_shader { pub source: String, pub module: naga::Module, pub interpolate_attr: String, + #[cfg_attr(not(feature = "glsl-out"), expect(dead_code))] pub entry_point: &'static str, } From 02700ab162e22877024c2be481fa774a2b8b5b69 Mon Sep 17 00:00:00 2001 From: Kevin Reid Date: Mon, 31 Mar 2025 18:17:05 -0700 Subject: [PATCH 007/806] Move test and benchmark targets to standard Cargo autodiscovery layout. (#7436) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This will make it easier for contributors to understand the file layout, at the cost of said layout containing several more nested directories. I will personally appreciate not having to remember to look for `root.rs` instead of `main.rs`. I also renamed the test targets so that they do not *all* share the superfluous suffix “-test” (test targets live in a different namespace than other target types and packages, so the name can presume that it is always known that they are tests). The Naga snapshot data sets `naga/tests/{in,out}` have been left in their original positions. --- benches/Cargo.toml | 2 - .../{ => wgpu-benchmark}/bind_groups.rs | 0 .../computepass-bindless.wgsl | 0 .../{ => wgpu-benchmark}/computepass.rs | 0 .../{ => wgpu-benchmark}/computepass.wgsl | 0 .../{root.rs => wgpu-benchmark/main.rs} | 0 .../renderpass-bindless.wgsl | 0 .../{ => wgpu-benchmark}/renderpass.rs | 0 .../{ => wgpu-benchmark}/renderpass.wgsl | 0 .../{ => wgpu-benchmark}/resource_creation.rs | 0 .../benches/{ => wgpu-benchmark}/shader.rs | 1 + docs/testing.md | 48 +++++++++--------- naga/.gitattributes | 2 +- naga/Cargo.toml | 5 -- naga/tests/{ => naga}/example_wgsl.rs | 0 naga/tests/{root.rs => naga/main.rs} | 0 naga/tests/{ => naga}/snapshots.rs | 0 naga/tests/{ => naga}/spirv_capabilities.rs | 0 naga/tests/{ => naga}/validation.rs | 0 naga/tests/{ => naga}/wgsl_errors.rs | 0 player/Cargo.toml | 7 --- player/tests/{ => player}/data/all.ron | 0 player/tests/{ => player}/data/bind-group.ron | 0 .../tests/{ => player}/data/buffer-copy.ron | 0 .../data/clear-buffer-texture.ron | 0 .../tests/{ => player}/data/clear-texture.bin | Bin player/tests/{ => player}/data/data1.bin | Bin player/tests/{ => player}/data/empty.wgsl | 0 .../data/pipeline-statistics-query.ron | 0 player/tests/{ => player}/data/quad.bin | 0 player/tests/{ => player}/data/quad.ron | 0 player/tests/{ => player}/data/quad.wgsl | 0 player/tests/{ => player}/data/zero-16k.bin | Bin .../data/zero-init-buffer-for-binding.wgsl | 0 .../{ => player}/data/zero-init-buffer.ron | 0 .../data/zero-init-texture-binding.ron | 0 .../data/zero-init-texture-binding.wgsl | 0 .../data/zero-init-texture-copytobuffer.ron | 0 .../data/zero-init-texture-rendertarget.ron | 0 player/tests/{root.rs => player/main.rs} | 2 +- tests/Cargo.toml | 13 ++--- .../wgpu-compile}/fail/cpass_lifetime.rs | 0 .../wgpu-compile}/fail/cpass_lifetime.stderr | 0 .../wgpu-compile}/fail/rpass_lifetime.rs | 0 .../wgpu-compile}/fail/rpass_lifetime.stderr | 0 .../root.rs => tests/wgpu-compile/main.rs} | 0 .../root.rs => tests/wgpu-dependency/main.rs} | 0 .../wgpu-gpu}/3x3_colors.png | Bin .../wgpu-gpu}/bgra8unorm_storage.rs | 0 .../wgpu-gpu}/bind_group_layout_dedup.rs | 0 .../wgpu-gpu}/bind_groups.rs | 0 .../wgpu-gpu}/binding_array/buffers.rs | 0 .../wgpu-gpu}/binding_array/mod.rs | 0 .../binding_array/sampled_textures.rs | 0 .../wgpu-gpu}/binding_array/samplers.rs | 0 .../binding_array/storage_textures.rs | 0 tests/{gpu-tests => tests/wgpu-gpu}/buffer.rs | 0 .../wgpu-gpu}/buffer_copy.rs | 0 .../wgpu-gpu}/buffer_usages.rs | 0 .../wgpu-gpu}/clear_texture.rs | 0 .../wgpu-gpu}/cloneable_types.rs | 0 .../wgpu-gpu}/compute_pass_ownership.rs | 0 .../wgpu-gpu}/create_surface_error.rs | 0 tests/{gpu-tests => tests/wgpu-gpu}/device.rs | 0 .../wgpu-gpu}/dispatch_workgroups_indirect.rs | 0 .../wgpu-gpu}/draw_indirect.rs | 0 .../wgpu-gpu}/dual_source_blending.rs | 0 .../{gpu-tests => tests/wgpu-gpu}/encoder.rs | 0 .../wgpu-gpu}/external_texture.rs | 0 .../wgpu-gpu}/float32_filterable.rs | 0 .../image_atomics/image_32_atomics.wgsl | 0 .../image_atomics/image_64_atomics.wgsl | 0 .../wgpu-gpu}/image_atomics/mod.rs | 0 .../{gpu-tests => tests/wgpu-gpu}/instance.rs | 0 .../wgpu-gpu}/life_cycle.rs | 0 .../root.rs => tests/wgpu-gpu/main.rs} | 0 .../wgpu-gpu}/mem_leaks.rs | 0 .../wgpu-gpu}/nv12_texture/mod.rs | 0 .../wgpu-gpu}/nv12_texture/nv12_texture.wgsl | 0 .../wgpu-gpu}/occlusion_query/mod.rs | 0 .../wgpu-gpu}/occlusion_query/shader.wgsl | 0 .../wgpu-gpu}/oob_indexing.rs | 0 .../{gpu-tests => tests/wgpu-gpu}/pipeline.rs | 0 .../wgpu-gpu}/pipeline_cache.rs | 0 tests/{gpu-tests => tests/wgpu-gpu}/poll.rs | 0 .../wgpu-gpu}/push_constants.rs | 0 .../wgpu-gpu}/query_set.rs | 0 .../wgpu-gpu}/queue_transfer.rs | 0 .../wgpu-gpu}/ray_tracing/as_build.rs | 0 .../wgpu-gpu}/ray_tracing/as_create.rs | 0 .../ray_tracing/as_use_after_free.rs | 0 .../wgpu-gpu}/ray_tracing/mod.rs | 0 .../wgpu-gpu}/ray_tracing/scene/mesh_gen.rs | 0 .../wgpu-gpu}/ray_tracing/scene/mod.rs | 0 .../wgpu-gpu}/ray_tracing/shader.rs | 0 .../wgpu-gpu}/ray_tracing/shader.wgsl | 0 .../wgpu-gpu}/regression/issue_3349.fs.wgsl | 0 .../wgpu-gpu}/regression/issue_3349.rs | 0 .../wgpu-gpu}/regression/issue_3349.vs.wgsl | 0 .../wgpu-gpu}/regression/issue_3457.rs | 0 .../wgpu-gpu}/regression/issue_3457.wgsl | 0 .../wgpu-gpu}/regression/issue_4024.rs | 0 .../wgpu-gpu}/regression/issue_4122.rs | 0 .../wgpu-gpu}/regression/issue_4485.rs | 0 .../wgpu-gpu}/regression/issue_4485.wgsl | 0 .../wgpu-gpu}/regression/issue_4514.rs | 0 .../wgpu-gpu}/regression/issue_4514.wgsl | 0 .../wgpu-gpu}/regression/issue_5553.rs | 0 .../wgpu-gpu}/regression/issue_5553.wgsl | 0 .../wgpu-gpu}/regression/issue_6317.rs | 0 .../wgpu-gpu}/regression/issue_6467.rs | 0 .../wgpu-gpu}/regression/issue_6827.rs | 0 .../wgpu-gpu}/render_pass_ownership.rs | 0 .../wgpu-gpu}/resource_descriptor_accessor.rs | 0 .../wgpu-gpu}/resource_error.rs | 0 .../{gpu-tests => tests/wgpu-gpu}/samplers.rs | 0 .../wgpu-gpu}/scissor_tests/mod.rs | 0 .../wgpu-gpu}/scissor_tests/solid_white.wgsl | 0 .../wgpu-gpu}/shader/array_size_overrides.rs | 0 .../compilation_messages/error_shader.wgsl | 0 .../shader/compilation_messages/mod.rs | 0 .../successful_shader.wgsl | 0 .../wgpu-gpu}/shader/data_builtins.rs | 0 .../wgpu-gpu}/shader/mod.rs | 0 .../wgpu-gpu}/shader/numeric_builtins.rs | 0 .../wgpu-gpu}/shader/shader_test.wgsl | 0 .../wgpu-gpu}/shader/struct_layout.rs | 0 .../shader/workgroup_size_overrides.rs | 0 .../shader/zero_init_workgroup_mem.rs | 0 .../shader/zero_init_workgroup_mem.wgsl | 0 .../wgpu-gpu}/shader_primitive_index/mod.rs | 0 .../primitive_index.wgsl | 0 .../wgpu-gpu}/shader_view_format/mod.rs | 0 .../shader_view_format/view_format.wgsl | 0 .../wgpu-gpu}/subgroup_operations/mod.rs | 0 .../wgpu-gpu}/subgroup_operations/shader.wgsl | 0 .../wgpu-gpu}/texture_binding/mod.rs | 0 .../wgpu-gpu}/texture_binding/shader.wgsl | 0 .../texture_binding/single_scalar.wgsl | 0 .../wgpu-gpu}/texture_blit.rs | 0 .../wgpu-gpu}/texture_bounds.rs | 0 .../wgpu-gpu}/texture_view_creation.rs | 0 .../{gpu-tests => tests/wgpu-gpu}/transfer.rs | 0 .../wgpu-gpu}/transition_resources.rs | 0 .../wgpu-gpu}/vertex_formats/draw.vert.wgsl | 0 .../wgpu-gpu}/vertex_formats/mod.rs | 0 .../wgpu-gpu}/vertex_indices/draw.vert.wgsl | 0 .../wgpu-gpu}/vertex_indices/mod.rs | 0 .../wgpu-gpu}/write_texture.rs | 0 .../zero_init_texture_after_discard.rs | 0 .../wgpu-validation}/api/binding_arrays.rs | 0 .../wgpu-validation}/api/buffer.rs | 0 .../wgpu-validation}/api/buffer_slice.rs | 0 .../wgpu-validation}/api/instance.rs | 0 .../wgpu-validation}/api/mod.rs | 0 .../wgpu-validation}/api/texture.rs | 0 .../root.rs => tests/wgpu-validation/main.rs} | 0 .../wgpu-validation}/noop.rs | 0 158 files changed, 31 insertions(+), 49 deletions(-) rename benches/benches/{ => wgpu-benchmark}/bind_groups.rs (100%) rename benches/benches/{ => wgpu-benchmark}/computepass-bindless.wgsl (100%) rename benches/benches/{ => wgpu-benchmark}/computepass.rs (100%) rename benches/benches/{ => wgpu-benchmark}/computepass.wgsl (100%) rename benches/benches/{root.rs => wgpu-benchmark/main.rs} (100%) rename benches/benches/{ => wgpu-benchmark}/renderpass-bindless.wgsl (100%) rename benches/benches/{ => wgpu-benchmark}/renderpass.rs (100%) rename benches/benches/{ => wgpu-benchmark}/renderpass.wgsl (100%) rename benches/benches/{ => wgpu-benchmark}/resource_creation.rs (100%) rename benches/benches/{ => wgpu-benchmark}/shader.rs (99%) rename naga/tests/{ => naga}/example_wgsl.rs (100%) rename naga/tests/{root.rs => naga/main.rs} (100%) rename naga/tests/{ => naga}/snapshots.rs (100%) rename naga/tests/{ => naga}/spirv_capabilities.rs (100%) rename naga/tests/{ => naga}/validation.rs (100%) rename naga/tests/{ => naga}/wgsl_errors.rs (100%) rename player/tests/{ => player}/data/all.ron (100%) rename player/tests/{ => player}/data/bind-group.ron (100%) rename player/tests/{ => player}/data/buffer-copy.ron (100%) rename player/tests/{ => player}/data/clear-buffer-texture.ron (100%) rename player/tests/{ => player}/data/clear-texture.bin (100%) rename player/tests/{ => player}/data/data1.bin (100%) rename player/tests/{ => player}/data/empty.wgsl (100%) rename player/tests/{ => player}/data/pipeline-statistics-query.ron (100%) rename player/tests/{ => player}/data/quad.bin (100%) rename player/tests/{ => player}/data/quad.ron (100%) rename player/tests/{ => player}/data/quad.wgsl (100%) rename player/tests/{ => player}/data/zero-16k.bin (100%) rename player/tests/{ => player}/data/zero-init-buffer-for-binding.wgsl (100%) rename player/tests/{ => player}/data/zero-init-buffer.ron (100%) rename player/tests/{ => player}/data/zero-init-texture-binding.ron (100%) rename player/tests/{ => player}/data/zero-init-texture-binding.wgsl (100%) rename player/tests/{ => player}/data/zero-init-texture-copytobuffer.ron (100%) rename player/tests/{ => player}/data/zero-init-texture-rendertarget.ron (100%) rename player/tests/{root.rs => player/main.rs} (99%) rename tests/{compile-tests => tests/wgpu-compile}/fail/cpass_lifetime.rs (100%) rename tests/{compile-tests => tests/wgpu-compile}/fail/cpass_lifetime.stderr (100%) rename tests/{compile-tests => tests/wgpu-compile}/fail/rpass_lifetime.rs (100%) rename tests/{compile-tests => tests/wgpu-compile}/fail/rpass_lifetime.stderr (100%) rename tests/{compile-tests/root.rs => tests/wgpu-compile/main.rs} (100%) rename tests/{dependency-tests/root.rs => tests/wgpu-dependency/main.rs} (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/3x3_colors.png (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/bgra8unorm_storage.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/bind_group_layout_dedup.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/bind_groups.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/binding_array/buffers.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/binding_array/mod.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/binding_array/sampled_textures.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/binding_array/samplers.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/binding_array/storage_textures.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/buffer.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/buffer_copy.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/buffer_usages.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/clear_texture.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/cloneable_types.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/compute_pass_ownership.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/create_surface_error.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/device.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/dispatch_workgroups_indirect.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/draw_indirect.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/dual_source_blending.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/encoder.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/external_texture.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/float32_filterable.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/image_atomics/image_32_atomics.wgsl (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/image_atomics/image_64_atomics.wgsl (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/image_atomics/mod.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/instance.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/life_cycle.rs (100%) rename tests/{gpu-tests/root.rs => tests/wgpu-gpu/main.rs} (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/mem_leaks.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/nv12_texture/mod.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/nv12_texture/nv12_texture.wgsl (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/occlusion_query/mod.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/occlusion_query/shader.wgsl (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/oob_indexing.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/pipeline.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/pipeline_cache.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/poll.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/push_constants.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/query_set.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/queue_transfer.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/ray_tracing/as_build.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/ray_tracing/as_create.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/ray_tracing/as_use_after_free.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/ray_tracing/mod.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/ray_tracing/scene/mesh_gen.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/ray_tracing/scene/mod.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/ray_tracing/shader.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/ray_tracing/shader.wgsl (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/regression/issue_3349.fs.wgsl (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/regression/issue_3349.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/regression/issue_3349.vs.wgsl (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/regression/issue_3457.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/regression/issue_3457.wgsl (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/regression/issue_4024.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/regression/issue_4122.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/regression/issue_4485.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/regression/issue_4485.wgsl (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/regression/issue_4514.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/regression/issue_4514.wgsl (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/regression/issue_5553.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/regression/issue_5553.wgsl (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/regression/issue_6317.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/regression/issue_6467.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/regression/issue_6827.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/render_pass_ownership.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/resource_descriptor_accessor.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/resource_error.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/samplers.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/scissor_tests/mod.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/scissor_tests/solid_white.wgsl (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/shader/array_size_overrides.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/shader/compilation_messages/error_shader.wgsl (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/shader/compilation_messages/mod.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/shader/compilation_messages/successful_shader.wgsl (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/shader/data_builtins.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/shader/mod.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/shader/numeric_builtins.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/shader/shader_test.wgsl (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/shader/struct_layout.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/shader/workgroup_size_overrides.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/shader/zero_init_workgroup_mem.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/shader/zero_init_workgroup_mem.wgsl (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/shader_primitive_index/mod.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/shader_primitive_index/primitive_index.wgsl (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/shader_view_format/mod.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/shader_view_format/view_format.wgsl (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/subgroup_operations/mod.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/subgroup_operations/shader.wgsl (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/texture_binding/mod.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/texture_binding/shader.wgsl (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/texture_binding/single_scalar.wgsl (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/texture_blit.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/texture_bounds.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/texture_view_creation.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/transfer.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/transition_resources.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/vertex_formats/draw.vert.wgsl (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/vertex_formats/mod.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/vertex_indices/draw.vert.wgsl (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/vertex_indices/mod.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/write_texture.rs (100%) rename tests/{gpu-tests => tests/wgpu-gpu}/zero_init_texture_after_discard.rs (100%) rename tests/{validation-tests => tests/wgpu-validation}/api/binding_arrays.rs (100%) rename tests/{validation-tests => tests/wgpu-validation}/api/buffer.rs (100%) rename tests/{validation-tests => tests/wgpu-validation}/api/buffer_slice.rs (100%) rename tests/{validation-tests => tests/wgpu-validation}/api/instance.rs (100%) rename tests/{validation-tests => tests/wgpu-validation}/api/mod.rs (100%) rename tests/{validation-tests => tests/wgpu-validation}/api/texture.rs (100%) rename tests/{validation-tests/root.rs => tests/wgpu-validation/main.rs} (100%) rename tests/{validation-tests => tests/wgpu-validation}/noop.rs (100%) diff --git a/benches/Cargo.toml b/benches/Cargo.toml index c018aba58..f0b70229a 100644 --- a/benches/Cargo.toml +++ b/benches/Cargo.toml @@ -9,13 +9,11 @@ repository.workspace = true keywords.workspace = true license.workspace = true rust-version.workspace = true -autobenches = false publish = false [[bench]] name = "wgpu-benchmark" harness = false -path = "benches/root.rs" [features] # Uncomment these features to enable tracy and superluminal profiling. diff --git a/benches/benches/bind_groups.rs b/benches/benches/wgpu-benchmark/bind_groups.rs similarity index 100% rename from benches/benches/bind_groups.rs rename to benches/benches/wgpu-benchmark/bind_groups.rs diff --git a/benches/benches/computepass-bindless.wgsl b/benches/benches/wgpu-benchmark/computepass-bindless.wgsl similarity index 100% rename from benches/benches/computepass-bindless.wgsl rename to benches/benches/wgpu-benchmark/computepass-bindless.wgsl diff --git a/benches/benches/computepass.rs b/benches/benches/wgpu-benchmark/computepass.rs similarity index 100% rename from benches/benches/computepass.rs rename to benches/benches/wgpu-benchmark/computepass.rs diff --git a/benches/benches/computepass.wgsl b/benches/benches/wgpu-benchmark/computepass.wgsl similarity index 100% rename from benches/benches/computepass.wgsl rename to benches/benches/wgpu-benchmark/computepass.wgsl diff --git a/benches/benches/root.rs b/benches/benches/wgpu-benchmark/main.rs similarity index 100% rename from benches/benches/root.rs rename to benches/benches/wgpu-benchmark/main.rs diff --git a/benches/benches/renderpass-bindless.wgsl b/benches/benches/wgpu-benchmark/renderpass-bindless.wgsl similarity index 100% rename from benches/benches/renderpass-bindless.wgsl rename to benches/benches/wgpu-benchmark/renderpass-bindless.wgsl diff --git a/benches/benches/renderpass.rs b/benches/benches/wgpu-benchmark/renderpass.rs similarity index 100% rename from benches/benches/renderpass.rs rename to benches/benches/wgpu-benchmark/renderpass.rs diff --git a/benches/benches/renderpass.wgsl b/benches/benches/wgpu-benchmark/renderpass.wgsl similarity index 100% rename from benches/benches/renderpass.wgsl rename to benches/benches/wgpu-benchmark/renderpass.wgsl diff --git a/benches/benches/resource_creation.rs b/benches/benches/wgpu-benchmark/resource_creation.rs similarity index 100% rename from benches/benches/resource_creation.rs rename to benches/benches/wgpu-benchmark/resource_creation.rs diff --git a/benches/benches/shader.rs b/benches/benches/wgpu-benchmark/shader.rs similarity index 99% rename from benches/benches/shader.rs rename to benches/benches/wgpu-benchmark/shader.rs index fee85adbf..71552d8be 100644 --- a/benches/benches/shader.rs +++ b/benches/benches/wgpu-benchmark/shader.rs @@ -15,6 +15,7 @@ struct Inputs { } impl Inputs { + #[track_caller] fn from_dir(folder: &str, extension: &str) -> Self { let mut inputs = Vec::new(); let read_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")) diff --git a/docs/testing.md b/docs/testing.md index 1ddf86a56..dcca39404 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -36,10 +36,10 @@ This is a table of contents, in the form of the repository's directory structure - player - [tests](#player-tests) - tests - - [compile-tests](#wgpu-compile-tests) - - [dependency-tests](#wgpu-dependency-tests) - - [gpu-tests](#wgpu-gpu-tests) - - [validation-tests](#wgpu-validation-tests) + - [compile](#wgpu-compile-tests) + - [dependency](#wgpu-dependency-tests) + - [gpu](#wgpu-gpu-tests) + - [validation](#wgpu-validation-tests) And where applicable [unit-tests](#unit-tests) are scatteredthroughout the codebase. @@ -84,16 +84,16 @@ they should be easy to copy into a standalone project. ## `naga` Example Tests -- Located in: `naga/tests/example_wgsl` -- Run with `cargo nextest run --test naga-test example_wgsl` +- Located in: `naga/tests/naga/example_wgsl` +- Run with `cargo nextest run --test naga example_wgsl` This simple test ensures that all wgsl files in the `examples` directory can be parsed by `naga`'s `wgsl` parser and validate correctly. ## `naga` Snapshot Tests -- Located in: `naga/tests/snapshot`, `naga/tests/in`, and `naga/tests/out` -- Run with `cargo nextest run --test naga-test snapshots` +- Located in: `naga/tests/naga/snapshot`, `naga/tests/in`, and `naga/tests/out` +- Run with `cargo nextest run --test naga snapshots` - Data driven snapshot tests for `naga`'s input/output. These tests are snapshot tests for `naga`s parsers and code generators. @@ -118,8 +118,8 @@ will use the respective tool to validate the generated code. ## `naga` SPIR-V Capabilities Tests -- Located in: `naga/tests/spirv_capabilities` -- Run with `cargo nextest run --test naga-test spirv_capabilities` +- Located in: `naga/tests/naga/spirv_capabilities` +- Run with `cargo nextest run --test naga spirv_capabilities` - Uses the standard `#[test]` harness. These tests convert the given wgsl snippet to spirv and @@ -127,8 +127,8 @@ then assert that the spirv has enabled the expected capabilities. ## `naga` Validation Tests -- Located in: `naga/tests/validation` -- Run with `cargo nextest run --test naga-test validation` +- Located in: `naga/tests/naga/validation` +- Run with `cargo nextest run --test naga validation` These are hand rolled tests against the naga's validator. If you don't need to test the validator with a custom module, @@ -137,8 +137,8 @@ the [wgsl errors](#naga-wgsl-error-tests) tests. ## `naga` WGSL Error Tests -- Located in: `naga/tests/wgsl_errors` -- Run with `cargo nextest run --test naga-test wgsl_errors` +- Located in: `naga/tests/naga/wgsl_errors` +- Run with `cargo nextest run --test naga wgsl_errors` These are tests for the error messages that the `wgsl` frontend produces. Additionally you can check that a given validation error @@ -147,7 +147,7 @@ is produced by the validator from a given `wgsl` snippet. ## `player` Tests - Located in: `player/tests` -- Run with `cargo nextest run --test player-test` +- Run with `cargo nextest run --test player` - Data driven tests using the `player`'s replay system. - `wgpu` integration tests. @@ -161,9 +161,9 @@ These tests only run on your system's default GPU. ## `wgpu` Compile Tests -- Located in: `tests/compile-tests` -- Run with `cargo nextest run --test wgpu-compile-test` -- `trybuild` tests of all rust files in `tests/compile-tests/fail` directory. +- Located in: `tests/tests/wgpu-compile` +- Run with `cargo nextest run --test wgpu-compile` +- `trybuild` tests of all rust files in `tests/tests/wgpu-compile/fail` directory. These use the `trybuild` crate to test a few scenarios where the `wgpu` crate is expected to fail to compile. This mainly @@ -172,8 +172,8 @@ dropping passes, etc. ## `wgpu` Dependency Tests -- Located in: `tests/dependency-tests` -- Run with `cargo nextest run --test wgpu-dependency-test` +- Located in: `tests/tests/wgpu-dependency` +- Run with `cargo nextest run --test wgpu-dependency` - Tests against `cargo tree`. These tests ensure that the `wgpu` crate has the correct dependency @@ -184,8 +184,8 @@ This provides a way to ensure that our `toml` files are correct. ## `wgpu` GPU Tests -- Located in: `tests/gpu-tests` -- Run with `cargo xtask test --test wgpu-gpu-test` +- Located in: `tests/tests/wgpu-gpu` +- Run with `cargo xtask test --test wgpu-gpu` - Uses a custom `#[gpu_test]` harness. - `wgpu` integration tests, with access to `wgpu_test` helpers. @@ -209,8 +209,8 @@ See also the [example tests](#example-tests) for additional GPU tests. ## `wgpu` Validation Tests -- Located in: `tests/validation-tests` -- Run with `cargo nextest run --test wgpu-validation-test` +- Located in: `tests/tests/wgpu-validation` +- Run with `cargo nextest run --test wgpu-validation` - Use the standard `#[test]` harness. - `wgpu` integration tests, with access to `wgpu_test` helpers. diff --git a/naga/.gitattributes b/naga/.gitattributes index 622c348d1..1f0bd06f0 100644 --- a/naga/.gitattributes +++ b/naga/.gitattributes @@ -1 +1 @@ -tests/out/**/* text eol=lf +tests/naga/out/**/* text eol=lf diff --git a/naga/Cargo.toml b/naga/Cargo.toml index 1aa53e57a..d04bdc60b 100644 --- a/naga/Cargo.toml +++ b/naga/Cargo.toml @@ -9,7 +9,6 @@ keywords = ["shader", "SPIR-V", "GLSL", "MSL"] license = "MIT OR Apache-2.0" exclude = ["bin/**/*", "tests/**/*", "Cargo.lock", "target/**/*"] resolver = "2" -autotests = false # Override the workspace's `rust-version` key. Firefox uses `cargo vendor` to # copy the crates it actually uses out of the workspace, so it's meaningful for @@ -17,10 +16,6 @@ autotests = false # whole, if their code permits. See `../README.md` for details. rust-version = "1.82.0" -[[test]] -name = "naga-test" -path = "tests/root.rs" - [package.metadata.docs.rs] all-features = true diff --git a/naga/tests/example_wgsl.rs b/naga/tests/naga/example_wgsl.rs similarity index 100% rename from naga/tests/example_wgsl.rs rename to naga/tests/naga/example_wgsl.rs diff --git a/naga/tests/root.rs b/naga/tests/naga/main.rs similarity index 100% rename from naga/tests/root.rs rename to naga/tests/naga/main.rs diff --git a/naga/tests/snapshots.rs b/naga/tests/naga/snapshots.rs similarity index 100% rename from naga/tests/snapshots.rs rename to naga/tests/naga/snapshots.rs diff --git a/naga/tests/spirv_capabilities.rs b/naga/tests/naga/spirv_capabilities.rs similarity index 100% rename from naga/tests/spirv_capabilities.rs rename to naga/tests/naga/spirv_capabilities.rs diff --git a/naga/tests/validation.rs b/naga/tests/naga/validation.rs similarity index 100% rename from naga/tests/validation.rs rename to naga/tests/naga/validation.rs diff --git a/naga/tests/wgsl_errors.rs b/naga/tests/naga/wgsl_errors.rs similarity index 100% rename from naga/tests/wgsl_errors.rs rename to naga/tests/naga/wgsl_errors.rs diff --git a/player/Cargo.toml b/player/Cargo.toml index bf5297017..0f0346ece 100644 --- a/player/Cargo.toml +++ b/player/Cargo.toml @@ -12,19 +12,12 @@ rust-version.workspace = true publish = false [lib] -name = "player" -path = "src/lib.rs" test = false [[bin]] name = "play" -path = "src/bin/play.rs" test = false -[[test]] -name = "player-test" -path = "tests/root.rs" - [dependencies] wgpu-types = { workspace = true, features = ["serde"] } diff --git a/player/tests/data/all.ron b/player/tests/player/data/all.ron similarity index 100% rename from player/tests/data/all.ron rename to player/tests/player/data/all.ron diff --git a/player/tests/data/bind-group.ron b/player/tests/player/data/bind-group.ron similarity index 100% rename from player/tests/data/bind-group.ron rename to player/tests/player/data/bind-group.ron diff --git a/player/tests/data/buffer-copy.ron b/player/tests/player/data/buffer-copy.ron similarity index 100% rename from player/tests/data/buffer-copy.ron rename to player/tests/player/data/buffer-copy.ron diff --git a/player/tests/data/clear-buffer-texture.ron b/player/tests/player/data/clear-buffer-texture.ron similarity index 100% rename from player/tests/data/clear-buffer-texture.ron rename to player/tests/player/data/clear-buffer-texture.ron diff --git a/player/tests/data/clear-texture.bin b/player/tests/player/data/clear-texture.bin similarity index 100% rename from player/tests/data/clear-texture.bin rename to player/tests/player/data/clear-texture.bin diff --git a/player/tests/data/data1.bin b/player/tests/player/data/data1.bin similarity index 100% rename from player/tests/data/data1.bin rename to player/tests/player/data/data1.bin diff --git a/player/tests/data/empty.wgsl b/player/tests/player/data/empty.wgsl similarity index 100% rename from player/tests/data/empty.wgsl rename to player/tests/player/data/empty.wgsl diff --git a/player/tests/data/pipeline-statistics-query.ron b/player/tests/player/data/pipeline-statistics-query.ron similarity index 100% rename from player/tests/data/pipeline-statistics-query.ron rename to player/tests/player/data/pipeline-statistics-query.ron diff --git a/player/tests/data/quad.bin b/player/tests/player/data/quad.bin similarity index 100% rename from player/tests/data/quad.bin rename to player/tests/player/data/quad.bin diff --git a/player/tests/data/quad.ron b/player/tests/player/data/quad.ron similarity index 100% rename from player/tests/data/quad.ron rename to player/tests/player/data/quad.ron diff --git a/player/tests/data/quad.wgsl b/player/tests/player/data/quad.wgsl similarity index 100% rename from player/tests/data/quad.wgsl rename to player/tests/player/data/quad.wgsl diff --git a/player/tests/data/zero-16k.bin b/player/tests/player/data/zero-16k.bin similarity index 100% rename from player/tests/data/zero-16k.bin rename to player/tests/player/data/zero-16k.bin diff --git a/player/tests/data/zero-init-buffer-for-binding.wgsl b/player/tests/player/data/zero-init-buffer-for-binding.wgsl similarity index 100% rename from player/tests/data/zero-init-buffer-for-binding.wgsl rename to player/tests/player/data/zero-init-buffer-for-binding.wgsl diff --git a/player/tests/data/zero-init-buffer.ron b/player/tests/player/data/zero-init-buffer.ron similarity index 100% rename from player/tests/data/zero-init-buffer.ron rename to player/tests/player/data/zero-init-buffer.ron diff --git a/player/tests/data/zero-init-texture-binding.ron b/player/tests/player/data/zero-init-texture-binding.ron similarity index 100% rename from player/tests/data/zero-init-texture-binding.ron rename to player/tests/player/data/zero-init-texture-binding.ron diff --git a/player/tests/data/zero-init-texture-binding.wgsl b/player/tests/player/data/zero-init-texture-binding.wgsl similarity index 100% rename from player/tests/data/zero-init-texture-binding.wgsl rename to player/tests/player/data/zero-init-texture-binding.wgsl diff --git a/player/tests/data/zero-init-texture-copytobuffer.ron b/player/tests/player/data/zero-init-texture-copytobuffer.ron similarity index 100% rename from player/tests/data/zero-init-texture-copytobuffer.ron rename to player/tests/player/data/zero-init-texture-copytobuffer.ron diff --git a/player/tests/data/zero-init-texture-rendertarget.ron b/player/tests/player/data/zero-init-texture-rendertarget.ron similarity index 100% rename from player/tests/data/zero-init-texture-rendertarget.ron rename to player/tests/player/data/zero-init-texture-rendertarget.ron diff --git a/player/tests/root.rs b/player/tests/player/main.rs similarity index 99% rename from player/tests/root.rs rename to player/tests/player/main.rs index 44491a5f4..18f76e76e 100644 --- a/player/tests/root.rs +++ b/player/tests/player/main.rs @@ -246,5 +246,5 @@ impl Corpus { fn test_api() { env_logger::init(); - Corpus::run_from(PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/data/all.ron")) + Corpus::run_from(PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/player/data/all.ron")) } diff --git a/tests/Cargo.toml b/tests/Cargo.toml index fe1f98a05..110f1dcd0 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -9,27 +9,22 @@ repository.workspace = true keywords.workspace = true license.workspace = true rust-version.workspace = true -autotests = false publish = false [[test]] -name = "wgpu-compile-test" -path = "compile-tests/root.rs" +name = "wgpu-compile" harness = true [[test]] -name = "wgpu-dependency-test" -path = "dependency-tests/root.rs" +name = "wgpu-dependency" harness = true [[test]] -name = "wgpu-gpu-test" -path = "gpu-tests/root.rs" +name = "wgpu-gpu" harness = false [[test]] -name = "wgpu-validation-test" -path = "validation-tests/root.rs" +name = "wgpu-validation" harness = true [features] diff --git a/tests/compile-tests/fail/cpass_lifetime.rs b/tests/tests/wgpu-compile/fail/cpass_lifetime.rs similarity index 100% rename from tests/compile-tests/fail/cpass_lifetime.rs rename to tests/tests/wgpu-compile/fail/cpass_lifetime.rs diff --git a/tests/compile-tests/fail/cpass_lifetime.stderr b/tests/tests/wgpu-compile/fail/cpass_lifetime.stderr similarity index 100% rename from tests/compile-tests/fail/cpass_lifetime.stderr rename to tests/tests/wgpu-compile/fail/cpass_lifetime.stderr diff --git a/tests/compile-tests/fail/rpass_lifetime.rs b/tests/tests/wgpu-compile/fail/rpass_lifetime.rs similarity index 100% rename from tests/compile-tests/fail/rpass_lifetime.rs rename to tests/tests/wgpu-compile/fail/rpass_lifetime.rs diff --git a/tests/compile-tests/fail/rpass_lifetime.stderr b/tests/tests/wgpu-compile/fail/rpass_lifetime.stderr similarity index 100% rename from tests/compile-tests/fail/rpass_lifetime.stderr rename to tests/tests/wgpu-compile/fail/rpass_lifetime.stderr diff --git a/tests/compile-tests/root.rs b/tests/tests/wgpu-compile/main.rs similarity index 100% rename from tests/compile-tests/root.rs rename to tests/tests/wgpu-compile/main.rs diff --git a/tests/dependency-tests/root.rs b/tests/tests/wgpu-dependency/main.rs similarity index 100% rename from tests/dependency-tests/root.rs rename to tests/tests/wgpu-dependency/main.rs diff --git a/tests/gpu-tests/3x3_colors.png b/tests/tests/wgpu-gpu/3x3_colors.png similarity index 100% rename from tests/gpu-tests/3x3_colors.png rename to tests/tests/wgpu-gpu/3x3_colors.png diff --git a/tests/gpu-tests/bgra8unorm_storage.rs b/tests/tests/wgpu-gpu/bgra8unorm_storage.rs similarity index 100% rename from tests/gpu-tests/bgra8unorm_storage.rs rename to tests/tests/wgpu-gpu/bgra8unorm_storage.rs diff --git a/tests/gpu-tests/bind_group_layout_dedup.rs b/tests/tests/wgpu-gpu/bind_group_layout_dedup.rs similarity index 100% rename from tests/gpu-tests/bind_group_layout_dedup.rs rename to tests/tests/wgpu-gpu/bind_group_layout_dedup.rs diff --git a/tests/gpu-tests/bind_groups.rs b/tests/tests/wgpu-gpu/bind_groups.rs similarity index 100% rename from tests/gpu-tests/bind_groups.rs rename to tests/tests/wgpu-gpu/bind_groups.rs diff --git a/tests/gpu-tests/binding_array/buffers.rs b/tests/tests/wgpu-gpu/binding_array/buffers.rs similarity index 100% rename from tests/gpu-tests/binding_array/buffers.rs rename to tests/tests/wgpu-gpu/binding_array/buffers.rs diff --git a/tests/gpu-tests/binding_array/mod.rs b/tests/tests/wgpu-gpu/binding_array/mod.rs similarity index 100% rename from tests/gpu-tests/binding_array/mod.rs rename to tests/tests/wgpu-gpu/binding_array/mod.rs diff --git a/tests/gpu-tests/binding_array/sampled_textures.rs b/tests/tests/wgpu-gpu/binding_array/sampled_textures.rs similarity index 100% rename from tests/gpu-tests/binding_array/sampled_textures.rs rename to tests/tests/wgpu-gpu/binding_array/sampled_textures.rs diff --git a/tests/gpu-tests/binding_array/samplers.rs b/tests/tests/wgpu-gpu/binding_array/samplers.rs similarity index 100% rename from tests/gpu-tests/binding_array/samplers.rs rename to tests/tests/wgpu-gpu/binding_array/samplers.rs diff --git a/tests/gpu-tests/binding_array/storage_textures.rs b/tests/tests/wgpu-gpu/binding_array/storage_textures.rs similarity index 100% rename from tests/gpu-tests/binding_array/storage_textures.rs rename to tests/tests/wgpu-gpu/binding_array/storage_textures.rs diff --git a/tests/gpu-tests/buffer.rs b/tests/tests/wgpu-gpu/buffer.rs similarity index 100% rename from tests/gpu-tests/buffer.rs rename to tests/tests/wgpu-gpu/buffer.rs diff --git a/tests/gpu-tests/buffer_copy.rs b/tests/tests/wgpu-gpu/buffer_copy.rs similarity index 100% rename from tests/gpu-tests/buffer_copy.rs rename to tests/tests/wgpu-gpu/buffer_copy.rs diff --git a/tests/gpu-tests/buffer_usages.rs b/tests/tests/wgpu-gpu/buffer_usages.rs similarity index 100% rename from tests/gpu-tests/buffer_usages.rs rename to tests/tests/wgpu-gpu/buffer_usages.rs diff --git a/tests/gpu-tests/clear_texture.rs b/tests/tests/wgpu-gpu/clear_texture.rs similarity index 100% rename from tests/gpu-tests/clear_texture.rs rename to tests/tests/wgpu-gpu/clear_texture.rs diff --git a/tests/gpu-tests/cloneable_types.rs b/tests/tests/wgpu-gpu/cloneable_types.rs similarity index 100% rename from tests/gpu-tests/cloneable_types.rs rename to tests/tests/wgpu-gpu/cloneable_types.rs diff --git a/tests/gpu-tests/compute_pass_ownership.rs b/tests/tests/wgpu-gpu/compute_pass_ownership.rs similarity index 100% rename from tests/gpu-tests/compute_pass_ownership.rs rename to tests/tests/wgpu-gpu/compute_pass_ownership.rs diff --git a/tests/gpu-tests/create_surface_error.rs b/tests/tests/wgpu-gpu/create_surface_error.rs similarity index 100% rename from tests/gpu-tests/create_surface_error.rs rename to tests/tests/wgpu-gpu/create_surface_error.rs diff --git a/tests/gpu-tests/device.rs b/tests/tests/wgpu-gpu/device.rs similarity index 100% rename from tests/gpu-tests/device.rs rename to tests/tests/wgpu-gpu/device.rs diff --git a/tests/gpu-tests/dispatch_workgroups_indirect.rs b/tests/tests/wgpu-gpu/dispatch_workgroups_indirect.rs similarity index 100% rename from tests/gpu-tests/dispatch_workgroups_indirect.rs rename to tests/tests/wgpu-gpu/dispatch_workgroups_indirect.rs diff --git a/tests/gpu-tests/draw_indirect.rs b/tests/tests/wgpu-gpu/draw_indirect.rs similarity index 100% rename from tests/gpu-tests/draw_indirect.rs rename to tests/tests/wgpu-gpu/draw_indirect.rs diff --git a/tests/gpu-tests/dual_source_blending.rs b/tests/tests/wgpu-gpu/dual_source_blending.rs similarity index 100% rename from tests/gpu-tests/dual_source_blending.rs rename to tests/tests/wgpu-gpu/dual_source_blending.rs diff --git a/tests/gpu-tests/encoder.rs b/tests/tests/wgpu-gpu/encoder.rs similarity index 100% rename from tests/gpu-tests/encoder.rs rename to tests/tests/wgpu-gpu/encoder.rs diff --git a/tests/gpu-tests/external_texture.rs b/tests/tests/wgpu-gpu/external_texture.rs similarity index 100% rename from tests/gpu-tests/external_texture.rs rename to tests/tests/wgpu-gpu/external_texture.rs diff --git a/tests/gpu-tests/float32_filterable.rs b/tests/tests/wgpu-gpu/float32_filterable.rs similarity index 100% rename from tests/gpu-tests/float32_filterable.rs rename to tests/tests/wgpu-gpu/float32_filterable.rs diff --git a/tests/gpu-tests/image_atomics/image_32_atomics.wgsl b/tests/tests/wgpu-gpu/image_atomics/image_32_atomics.wgsl similarity index 100% rename from tests/gpu-tests/image_atomics/image_32_atomics.wgsl rename to tests/tests/wgpu-gpu/image_atomics/image_32_atomics.wgsl diff --git a/tests/gpu-tests/image_atomics/image_64_atomics.wgsl b/tests/tests/wgpu-gpu/image_atomics/image_64_atomics.wgsl similarity index 100% rename from tests/gpu-tests/image_atomics/image_64_atomics.wgsl rename to tests/tests/wgpu-gpu/image_atomics/image_64_atomics.wgsl diff --git a/tests/gpu-tests/image_atomics/mod.rs b/tests/tests/wgpu-gpu/image_atomics/mod.rs similarity index 100% rename from tests/gpu-tests/image_atomics/mod.rs rename to tests/tests/wgpu-gpu/image_atomics/mod.rs diff --git a/tests/gpu-tests/instance.rs b/tests/tests/wgpu-gpu/instance.rs similarity index 100% rename from tests/gpu-tests/instance.rs rename to tests/tests/wgpu-gpu/instance.rs diff --git a/tests/gpu-tests/life_cycle.rs b/tests/tests/wgpu-gpu/life_cycle.rs similarity index 100% rename from tests/gpu-tests/life_cycle.rs rename to tests/tests/wgpu-gpu/life_cycle.rs diff --git a/tests/gpu-tests/root.rs b/tests/tests/wgpu-gpu/main.rs similarity index 100% rename from tests/gpu-tests/root.rs rename to tests/tests/wgpu-gpu/main.rs diff --git a/tests/gpu-tests/mem_leaks.rs b/tests/tests/wgpu-gpu/mem_leaks.rs similarity index 100% rename from tests/gpu-tests/mem_leaks.rs rename to tests/tests/wgpu-gpu/mem_leaks.rs diff --git a/tests/gpu-tests/nv12_texture/mod.rs b/tests/tests/wgpu-gpu/nv12_texture/mod.rs similarity index 100% rename from tests/gpu-tests/nv12_texture/mod.rs rename to tests/tests/wgpu-gpu/nv12_texture/mod.rs diff --git a/tests/gpu-tests/nv12_texture/nv12_texture.wgsl b/tests/tests/wgpu-gpu/nv12_texture/nv12_texture.wgsl similarity index 100% rename from tests/gpu-tests/nv12_texture/nv12_texture.wgsl rename to tests/tests/wgpu-gpu/nv12_texture/nv12_texture.wgsl diff --git a/tests/gpu-tests/occlusion_query/mod.rs b/tests/tests/wgpu-gpu/occlusion_query/mod.rs similarity index 100% rename from tests/gpu-tests/occlusion_query/mod.rs rename to tests/tests/wgpu-gpu/occlusion_query/mod.rs diff --git a/tests/gpu-tests/occlusion_query/shader.wgsl b/tests/tests/wgpu-gpu/occlusion_query/shader.wgsl similarity index 100% rename from tests/gpu-tests/occlusion_query/shader.wgsl rename to tests/tests/wgpu-gpu/occlusion_query/shader.wgsl diff --git a/tests/gpu-tests/oob_indexing.rs b/tests/tests/wgpu-gpu/oob_indexing.rs similarity index 100% rename from tests/gpu-tests/oob_indexing.rs rename to tests/tests/wgpu-gpu/oob_indexing.rs diff --git a/tests/gpu-tests/pipeline.rs b/tests/tests/wgpu-gpu/pipeline.rs similarity index 100% rename from tests/gpu-tests/pipeline.rs rename to tests/tests/wgpu-gpu/pipeline.rs diff --git a/tests/gpu-tests/pipeline_cache.rs b/tests/tests/wgpu-gpu/pipeline_cache.rs similarity index 100% rename from tests/gpu-tests/pipeline_cache.rs rename to tests/tests/wgpu-gpu/pipeline_cache.rs diff --git a/tests/gpu-tests/poll.rs b/tests/tests/wgpu-gpu/poll.rs similarity index 100% rename from tests/gpu-tests/poll.rs rename to tests/tests/wgpu-gpu/poll.rs diff --git a/tests/gpu-tests/push_constants.rs b/tests/tests/wgpu-gpu/push_constants.rs similarity index 100% rename from tests/gpu-tests/push_constants.rs rename to tests/tests/wgpu-gpu/push_constants.rs diff --git a/tests/gpu-tests/query_set.rs b/tests/tests/wgpu-gpu/query_set.rs similarity index 100% rename from tests/gpu-tests/query_set.rs rename to tests/tests/wgpu-gpu/query_set.rs diff --git a/tests/gpu-tests/queue_transfer.rs b/tests/tests/wgpu-gpu/queue_transfer.rs similarity index 100% rename from tests/gpu-tests/queue_transfer.rs rename to tests/tests/wgpu-gpu/queue_transfer.rs diff --git a/tests/gpu-tests/ray_tracing/as_build.rs b/tests/tests/wgpu-gpu/ray_tracing/as_build.rs similarity index 100% rename from tests/gpu-tests/ray_tracing/as_build.rs rename to tests/tests/wgpu-gpu/ray_tracing/as_build.rs diff --git a/tests/gpu-tests/ray_tracing/as_create.rs b/tests/tests/wgpu-gpu/ray_tracing/as_create.rs similarity index 100% rename from tests/gpu-tests/ray_tracing/as_create.rs rename to tests/tests/wgpu-gpu/ray_tracing/as_create.rs diff --git a/tests/gpu-tests/ray_tracing/as_use_after_free.rs b/tests/tests/wgpu-gpu/ray_tracing/as_use_after_free.rs similarity index 100% rename from tests/gpu-tests/ray_tracing/as_use_after_free.rs rename to tests/tests/wgpu-gpu/ray_tracing/as_use_after_free.rs diff --git a/tests/gpu-tests/ray_tracing/mod.rs b/tests/tests/wgpu-gpu/ray_tracing/mod.rs similarity index 100% rename from tests/gpu-tests/ray_tracing/mod.rs rename to tests/tests/wgpu-gpu/ray_tracing/mod.rs diff --git a/tests/gpu-tests/ray_tracing/scene/mesh_gen.rs b/tests/tests/wgpu-gpu/ray_tracing/scene/mesh_gen.rs similarity index 100% rename from tests/gpu-tests/ray_tracing/scene/mesh_gen.rs rename to tests/tests/wgpu-gpu/ray_tracing/scene/mesh_gen.rs diff --git a/tests/gpu-tests/ray_tracing/scene/mod.rs b/tests/tests/wgpu-gpu/ray_tracing/scene/mod.rs similarity index 100% rename from tests/gpu-tests/ray_tracing/scene/mod.rs rename to tests/tests/wgpu-gpu/ray_tracing/scene/mod.rs diff --git a/tests/gpu-tests/ray_tracing/shader.rs b/tests/tests/wgpu-gpu/ray_tracing/shader.rs similarity index 100% rename from tests/gpu-tests/ray_tracing/shader.rs rename to tests/tests/wgpu-gpu/ray_tracing/shader.rs diff --git a/tests/gpu-tests/ray_tracing/shader.wgsl b/tests/tests/wgpu-gpu/ray_tracing/shader.wgsl similarity index 100% rename from tests/gpu-tests/ray_tracing/shader.wgsl rename to tests/tests/wgpu-gpu/ray_tracing/shader.wgsl diff --git a/tests/gpu-tests/regression/issue_3349.fs.wgsl b/tests/tests/wgpu-gpu/regression/issue_3349.fs.wgsl similarity index 100% rename from tests/gpu-tests/regression/issue_3349.fs.wgsl rename to tests/tests/wgpu-gpu/regression/issue_3349.fs.wgsl diff --git a/tests/gpu-tests/regression/issue_3349.rs b/tests/tests/wgpu-gpu/regression/issue_3349.rs similarity index 100% rename from tests/gpu-tests/regression/issue_3349.rs rename to tests/tests/wgpu-gpu/regression/issue_3349.rs diff --git a/tests/gpu-tests/regression/issue_3349.vs.wgsl b/tests/tests/wgpu-gpu/regression/issue_3349.vs.wgsl similarity index 100% rename from tests/gpu-tests/regression/issue_3349.vs.wgsl rename to tests/tests/wgpu-gpu/regression/issue_3349.vs.wgsl diff --git a/tests/gpu-tests/regression/issue_3457.rs b/tests/tests/wgpu-gpu/regression/issue_3457.rs similarity index 100% rename from tests/gpu-tests/regression/issue_3457.rs rename to tests/tests/wgpu-gpu/regression/issue_3457.rs diff --git a/tests/gpu-tests/regression/issue_3457.wgsl b/tests/tests/wgpu-gpu/regression/issue_3457.wgsl similarity index 100% rename from tests/gpu-tests/regression/issue_3457.wgsl rename to tests/tests/wgpu-gpu/regression/issue_3457.wgsl diff --git a/tests/gpu-tests/regression/issue_4024.rs b/tests/tests/wgpu-gpu/regression/issue_4024.rs similarity index 100% rename from tests/gpu-tests/regression/issue_4024.rs rename to tests/tests/wgpu-gpu/regression/issue_4024.rs diff --git a/tests/gpu-tests/regression/issue_4122.rs b/tests/tests/wgpu-gpu/regression/issue_4122.rs similarity index 100% rename from tests/gpu-tests/regression/issue_4122.rs rename to tests/tests/wgpu-gpu/regression/issue_4122.rs diff --git a/tests/gpu-tests/regression/issue_4485.rs b/tests/tests/wgpu-gpu/regression/issue_4485.rs similarity index 100% rename from tests/gpu-tests/regression/issue_4485.rs rename to tests/tests/wgpu-gpu/regression/issue_4485.rs diff --git a/tests/gpu-tests/regression/issue_4485.wgsl b/tests/tests/wgpu-gpu/regression/issue_4485.wgsl similarity index 100% rename from tests/gpu-tests/regression/issue_4485.wgsl rename to tests/tests/wgpu-gpu/regression/issue_4485.wgsl diff --git a/tests/gpu-tests/regression/issue_4514.rs b/tests/tests/wgpu-gpu/regression/issue_4514.rs similarity index 100% rename from tests/gpu-tests/regression/issue_4514.rs rename to tests/tests/wgpu-gpu/regression/issue_4514.rs diff --git a/tests/gpu-tests/regression/issue_4514.wgsl b/tests/tests/wgpu-gpu/regression/issue_4514.wgsl similarity index 100% rename from tests/gpu-tests/regression/issue_4514.wgsl rename to tests/tests/wgpu-gpu/regression/issue_4514.wgsl diff --git a/tests/gpu-tests/regression/issue_5553.rs b/tests/tests/wgpu-gpu/regression/issue_5553.rs similarity index 100% rename from tests/gpu-tests/regression/issue_5553.rs rename to tests/tests/wgpu-gpu/regression/issue_5553.rs diff --git a/tests/gpu-tests/regression/issue_5553.wgsl b/tests/tests/wgpu-gpu/regression/issue_5553.wgsl similarity index 100% rename from tests/gpu-tests/regression/issue_5553.wgsl rename to tests/tests/wgpu-gpu/regression/issue_5553.wgsl diff --git a/tests/gpu-tests/regression/issue_6317.rs b/tests/tests/wgpu-gpu/regression/issue_6317.rs similarity index 100% rename from tests/gpu-tests/regression/issue_6317.rs rename to tests/tests/wgpu-gpu/regression/issue_6317.rs diff --git a/tests/gpu-tests/regression/issue_6467.rs b/tests/tests/wgpu-gpu/regression/issue_6467.rs similarity index 100% rename from tests/gpu-tests/regression/issue_6467.rs rename to tests/tests/wgpu-gpu/regression/issue_6467.rs diff --git a/tests/gpu-tests/regression/issue_6827.rs b/tests/tests/wgpu-gpu/regression/issue_6827.rs similarity index 100% rename from tests/gpu-tests/regression/issue_6827.rs rename to tests/tests/wgpu-gpu/regression/issue_6827.rs diff --git a/tests/gpu-tests/render_pass_ownership.rs b/tests/tests/wgpu-gpu/render_pass_ownership.rs similarity index 100% rename from tests/gpu-tests/render_pass_ownership.rs rename to tests/tests/wgpu-gpu/render_pass_ownership.rs diff --git a/tests/gpu-tests/resource_descriptor_accessor.rs b/tests/tests/wgpu-gpu/resource_descriptor_accessor.rs similarity index 100% rename from tests/gpu-tests/resource_descriptor_accessor.rs rename to tests/tests/wgpu-gpu/resource_descriptor_accessor.rs diff --git a/tests/gpu-tests/resource_error.rs b/tests/tests/wgpu-gpu/resource_error.rs similarity index 100% rename from tests/gpu-tests/resource_error.rs rename to tests/tests/wgpu-gpu/resource_error.rs diff --git a/tests/gpu-tests/samplers.rs b/tests/tests/wgpu-gpu/samplers.rs similarity index 100% rename from tests/gpu-tests/samplers.rs rename to tests/tests/wgpu-gpu/samplers.rs diff --git a/tests/gpu-tests/scissor_tests/mod.rs b/tests/tests/wgpu-gpu/scissor_tests/mod.rs similarity index 100% rename from tests/gpu-tests/scissor_tests/mod.rs rename to tests/tests/wgpu-gpu/scissor_tests/mod.rs diff --git a/tests/gpu-tests/scissor_tests/solid_white.wgsl b/tests/tests/wgpu-gpu/scissor_tests/solid_white.wgsl similarity index 100% rename from tests/gpu-tests/scissor_tests/solid_white.wgsl rename to tests/tests/wgpu-gpu/scissor_tests/solid_white.wgsl diff --git a/tests/gpu-tests/shader/array_size_overrides.rs b/tests/tests/wgpu-gpu/shader/array_size_overrides.rs similarity index 100% rename from tests/gpu-tests/shader/array_size_overrides.rs rename to tests/tests/wgpu-gpu/shader/array_size_overrides.rs diff --git a/tests/gpu-tests/shader/compilation_messages/error_shader.wgsl b/tests/tests/wgpu-gpu/shader/compilation_messages/error_shader.wgsl similarity index 100% rename from tests/gpu-tests/shader/compilation_messages/error_shader.wgsl rename to tests/tests/wgpu-gpu/shader/compilation_messages/error_shader.wgsl diff --git a/tests/gpu-tests/shader/compilation_messages/mod.rs b/tests/tests/wgpu-gpu/shader/compilation_messages/mod.rs similarity index 100% rename from tests/gpu-tests/shader/compilation_messages/mod.rs rename to tests/tests/wgpu-gpu/shader/compilation_messages/mod.rs diff --git a/tests/gpu-tests/shader/compilation_messages/successful_shader.wgsl b/tests/tests/wgpu-gpu/shader/compilation_messages/successful_shader.wgsl similarity index 100% rename from tests/gpu-tests/shader/compilation_messages/successful_shader.wgsl rename to tests/tests/wgpu-gpu/shader/compilation_messages/successful_shader.wgsl diff --git a/tests/gpu-tests/shader/data_builtins.rs b/tests/tests/wgpu-gpu/shader/data_builtins.rs similarity index 100% rename from tests/gpu-tests/shader/data_builtins.rs rename to tests/tests/wgpu-gpu/shader/data_builtins.rs diff --git a/tests/gpu-tests/shader/mod.rs b/tests/tests/wgpu-gpu/shader/mod.rs similarity index 100% rename from tests/gpu-tests/shader/mod.rs rename to tests/tests/wgpu-gpu/shader/mod.rs diff --git a/tests/gpu-tests/shader/numeric_builtins.rs b/tests/tests/wgpu-gpu/shader/numeric_builtins.rs similarity index 100% rename from tests/gpu-tests/shader/numeric_builtins.rs rename to tests/tests/wgpu-gpu/shader/numeric_builtins.rs diff --git a/tests/gpu-tests/shader/shader_test.wgsl b/tests/tests/wgpu-gpu/shader/shader_test.wgsl similarity index 100% rename from tests/gpu-tests/shader/shader_test.wgsl rename to tests/tests/wgpu-gpu/shader/shader_test.wgsl diff --git a/tests/gpu-tests/shader/struct_layout.rs b/tests/tests/wgpu-gpu/shader/struct_layout.rs similarity index 100% rename from tests/gpu-tests/shader/struct_layout.rs rename to tests/tests/wgpu-gpu/shader/struct_layout.rs diff --git a/tests/gpu-tests/shader/workgroup_size_overrides.rs b/tests/tests/wgpu-gpu/shader/workgroup_size_overrides.rs similarity index 100% rename from tests/gpu-tests/shader/workgroup_size_overrides.rs rename to tests/tests/wgpu-gpu/shader/workgroup_size_overrides.rs diff --git a/tests/gpu-tests/shader/zero_init_workgroup_mem.rs b/tests/tests/wgpu-gpu/shader/zero_init_workgroup_mem.rs similarity index 100% rename from tests/gpu-tests/shader/zero_init_workgroup_mem.rs rename to tests/tests/wgpu-gpu/shader/zero_init_workgroup_mem.rs diff --git a/tests/gpu-tests/shader/zero_init_workgroup_mem.wgsl b/tests/tests/wgpu-gpu/shader/zero_init_workgroup_mem.wgsl similarity index 100% rename from tests/gpu-tests/shader/zero_init_workgroup_mem.wgsl rename to tests/tests/wgpu-gpu/shader/zero_init_workgroup_mem.wgsl diff --git a/tests/gpu-tests/shader_primitive_index/mod.rs b/tests/tests/wgpu-gpu/shader_primitive_index/mod.rs similarity index 100% rename from tests/gpu-tests/shader_primitive_index/mod.rs rename to tests/tests/wgpu-gpu/shader_primitive_index/mod.rs diff --git a/tests/gpu-tests/shader_primitive_index/primitive_index.wgsl b/tests/tests/wgpu-gpu/shader_primitive_index/primitive_index.wgsl similarity index 100% rename from tests/gpu-tests/shader_primitive_index/primitive_index.wgsl rename to tests/tests/wgpu-gpu/shader_primitive_index/primitive_index.wgsl diff --git a/tests/gpu-tests/shader_view_format/mod.rs b/tests/tests/wgpu-gpu/shader_view_format/mod.rs similarity index 100% rename from tests/gpu-tests/shader_view_format/mod.rs rename to tests/tests/wgpu-gpu/shader_view_format/mod.rs diff --git a/tests/gpu-tests/shader_view_format/view_format.wgsl b/tests/tests/wgpu-gpu/shader_view_format/view_format.wgsl similarity index 100% rename from tests/gpu-tests/shader_view_format/view_format.wgsl rename to tests/tests/wgpu-gpu/shader_view_format/view_format.wgsl diff --git a/tests/gpu-tests/subgroup_operations/mod.rs b/tests/tests/wgpu-gpu/subgroup_operations/mod.rs similarity index 100% rename from tests/gpu-tests/subgroup_operations/mod.rs rename to tests/tests/wgpu-gpu/subgroup_operations/mod.rs diff --git a/tests/gpu-tests/subgroup_operations/shader.wgsl b/tests/tests/wgpu-gpu/subgroup_operations/shader.wgsl similarity index 100% rename from tests/gpu-tests/subgroup_operations/shader.wgsl rename to tests/tests/wgpu-gpu/subgroup_operations/shader.wgsl diff --git a/tests/gpu-tests/texture_binding/mod.rs b/tests/tests/wgpu-gpu/texture_binding/mod.rs similarity index 100% rename from tests/gpu-tests/texture_binding/mod.rs rename to tests/tests/wgpu-gpu/texture_binding/mod.rs diff --git a/tests/gpu-tests/texture_binding/shader.wgsl b/tests/tests/wgpu-gpu/texture_binding/shader.wgsl similarity index 100% rename from tests/gpu-tests/texture_binding/shader.wgsl rename to tests/tests/wgpu-gpu/texture_binding/shader.wgsl diff --git a/tests/gpu-tests/texture_binding/single_scalar.wgsl b/tests/tests/wgpu-gpu/texture_binding/single_scalar.wgsl similarity index 100% rename from tests/gpu-tests/texture_binding/single_scalar.wgsl rename to tests/tests/wgpu-gpu/texture_binding/single_scalar.wgsl diff --git a/tests/gpu-tests/texture_blit.rs b/tests/tests/wgpu-gpu/texture_blit.rs similarity index 100% rename from tests/gpu-tests/texture_blit.rs rename to tests/tests/wgpu-gpu/texture_blit.rs diff --git a/tests/gpu-tests/texture_bounds.rs b/tests/tests/wgpu-gpu/texture_bounds.rs similarity index 100% rename from tests/gpu-tests/texture_bounds.rs rename to tests/tests/wgpu-gpu/texture_bounds.rs diff --git a/tests/gpu-tests/texture_view_creation.rs b/tests/tests/wgpu-gpu/texture_view_creation.rs similarity index 100% rename from tests/gpu-tests/texture_view_creation.rs rename to tests/tests/wgpu-gpu/texture_view_creation.rs diff --git a/tests/gpu-tests/transfer.rs b/tests/tests/wgpu-gpu/transfer.rs similarity index 100% rename from tests/gpu-tests/transfer.rs rename to tests/tests/wgpu-gpu/transfer.rs diff --git a/tests/gpu-tests/transition_resources.rs b/tests/tests/wgpu-gpu/transition_resources.rs similarity index 100% rename from tests/gpu-tests/transition_resources.rs rename to tests/tests/wgpu-gpu/transition_resources.rs diff --git a/tests/gpu-tests/vertex_formats/draw.vert.wgsl b/tests/tests/wgpu-gpu/vertex_formats/draw.vert.wgsl similarity index 100% rename from tests/gpu-tests/vertex_formats/draw.vert.wgsl rename to tests/tests/wgpu-gpu/vertex_formats/draw.vert.wgsl diff --git a/tests/gpu-tests/vertex_formats/mod.rs b/tests/tests/wgpu-gpu/vertex_formats/mod.rs similarity index 100% rename from tests/gpu-tests/vertex_formats/mod.rs rename to tests/tests/wgpu-gpu/vertex_formats/mod.rs diff --git a/tests/gpu-tests/vertex_indices/draw.vert.wgsl b/tests/tests/wgpu-gpu/vertex_indices/draw.vert.wgsl similarity index 100% rename from tests/gpu-tests/vertex_indices/draw.vert.wgsl rename to tests/tests/wgpu-gpu/vertex_indices/draw.vert.wgsl diff --git a/tests/gpu-tests/vertex_indices/mod.rs b/tests/tests/wgpu-gpu/vertex_indices/mod.rs similarity index 100% rename from tests/gpu-tests/vertex_indices/mod.rs rename to tests/tests/wgpu-gpu/vertex_indices/mod.rs diff --git a/tests/gpu-tests/write_texture.rs b/tests/tests/wgpu-gpu/write_texture.rs similarity index 100% rename from tests/gpu-tests/write_texture.rs rename to tests/tests/wgpu-gpu/write_texture.rs diff --git a/tests/gpu-tests/zero_init_texture_after_discard.rs b/tests/tests/wgpu-gpu/zero_init_texture_after_discard.rs similarity index 100% rename from tests/gpu-tests/zero_init_texture_after_discard.rs rename to tests/tests/wgpu-gpu/zero_init_texture_after_discard.rs diff --git a/tests/validation-tests/api/binding_arrays.rs b/tests/tests/wgpu-validation/api/binding_arrays.rs similarity index 100% rename from tests/validation-tests/api/binding_arrays.rs rename to tests/tests/wgpu-validation/api/binding_arrays.rs diff --git a/tests/validation-tests/api/buffer.rs b/tests/tests/wgpu-validation/api/buffer.rs similarity index 100% rename from tests/validation-tests/api/buffer.rs rename to tests/tests/wgpu-validation/api/buffer.rs diff --git a/tests/validation-tests/api/buffer_slice.rs b/tests/tests/wgpu-validation/api/buffer_slice.rs similarity index 100% rename from tests/validation-tests/api/buffer_slice.rs rename to tests/tests/wgpu-validation/api/buffer_slice.rs diff --git a/tests/validation-tests/api/instance.rs b/tests/tests/wgpu-validation/api/instance.rs similarity index 100% rename from tests/validation-tests/api/instance.rs rename to tests/tests/wgpu-validation/api/instance.rs diff --git a/tests/validation-tests/api/mod.rs b/tests/tests/wgpu-validation/api/mod.rs similarity index 100% rename from tests/validation-tests/api/mod.rs rename to tests/tests/wgpu-validation/api/mod.rs diff --git a/tests/validation-tests/api/texture.rs b/tests/tests/wgpu-validation/api/texture.rs similarity index 100% rename from tests/validation-tests/api/texture.rs rename to tests/tests/wgpu-validation/api/texture.rs diff --git a/tests/validation-tests/root.rs b/tests/tests/wgpu-validation/main.rs similarity index 100% rename from tests/validation-tests/root.rs rename to tests/tests/wgpu-validation/main.rs diff --git a/tests/validation-tests/noop.rs b/tests/tests/wgpu-validation/noop.rs similarity index 100% rename from tests/validation-tests/noop.rs rename to tests/tests/wgpu-validation/noop.rs From a9279de79328d28773742afa12294391970eeac0 Mon Sep 17 00:00:00 2001 From: Connor Fitzgerald Date: Mon, 31 Mar 2025 22:02:21 -0400 Subject: [PATCH 008/806] Fix assorted issues with WebGL (#7448) * Fix validation error when configuring the surface on WebGL * Remove unneeded `webgl` feature * Fix compilation of the `noop` backend on `wasm32` * Prevent `webgpu` examples from incorrectly falling back to WebGL * Reduce dependency set when building wasm examples * Fix various warnings --- Cargo.toml | 1 - examples/features/Cargo.toml | 3 ++- wgpu-core/src/conv.rs | 5 +---- wgpu-core/src/device/global.rs | 5 +++++ wgpu/Cargo.toml | 2 +- wgpu/src/api/queue.rs | 9 +-------- wgpu/src/backend/wgpu_core.rs | 9 +++++---- xtask/src/run_wasm.rs | 4 ++-- 8 files changed, 17 insertions(+), 21 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 559e281c0..64877fc6e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -68,7 +68,6 @@ wgpu = { version = "24.0.0", path = "./wgpu", default-features = false, features "dx12", "metal", "static-dxc", - "webgl", "noop", # This should be removed if we ever have non-test crates that depend on wgpu ] } wgpu-core = { version = "24.0.0", path = "./wgpu-core" } diff --git a/examples/features/Cargo.toml b/examples/features/Cargo.toml index ec79438af..2df3ca318 100644 --- a/examples/features/Cargo.toml +++ b/examples/features/Cargo.toml @@ -44,7 +44,6 @@ obj.workspace = true png.workspace = true pollster.workspace = true web-time.workspace = true -wgpu.workspace = true wgpu-types = { workspace = true, features = [ "trace", # TODO(#5974): this should be a dep on wgpu/trace and not wgpu-types at all ] } @@ -55,6 +54,7 @@ wgpu-test.workspace = true [target.'cfg(not(target_arch = "wasm32"))'.dependencies] env_logger.workspace = true +wgpu.workspace = true [target.'cfg(target_arch = "wasm32")'.dependencies] console_error_panic_hook.workspace = true @@ -62,6 +62,7 @@ console_log.workspace = true fern.workspace = true wasm-bindgen.workspace = true wasm-bindgen-futures.workspace = true +wgpu = { path = "../../wgpu", default-features = false, features = ["wgsl"] } # We need these features in the framework examples and tests web-sys = { workspace = true, features = [ "Location", diff --git a/wgpu-core/src/conv.rs b/wgpu-core/src/conv.rs index 5216ad0f6..5a5a27279 100644 --- a/wgpu-core/src/conv.rs +++ b/wgpu-core/src/conv.rs @@ -27,10 +27,7 @@ pub fn is_valid_copy_dst_texture_format( } } -#[cfg_attr( - any(not(target_arch = "wasm32"), target_os = "emscripten"), - allow(unused) -)] +#[cfg_attr(any(not(webgl)), expect(unused))] pub fn is_valid_external_image_copy_dst_texture_format(format: wgt::TextureFormat) -> bool { use wgt::TextureFormat as Tf; match format { diff --git a/wgpu-core/src/device/global.rs b/wgpu-core/src/device/global.rs index af928dfb0..d7c83d0b3 100644 --- a/wgpu-core/src/device/global.rs +++ b/wgpu-core/src/device/global.rs @@ -1880,6 +1880,11 @@ impl Global { Ok(wgt::PollStatus::Poll) => { unreachable!("Cannot get a Poll result from a Wait action.") } + Err(WaitIdleError::Timeout) if cfg!(target_arch = "wasm32") => { + // On wasm, you cannot actually successfully wait for the surface. + // However WebGL does not actually require you do this, so ignoring + // the failure is totally fine. See https://github.com/gfx-rs/wgpu/issues/7363 + } Err(e) => { break 'error e.into(); } diff --git a/wgpu/Cargo.toml b/wgpu/Cargo.toml index d9f0783e5..17c95e971 100644 --- a/wgpu/Cargo.toml +++ b/wgpu/Cargo.toml @@ -76,7 +76,7 @@ webgl = ["wgpu-core/webgl", "dep:wgpu-hal", "dep:smallvec"] ## but performs no computation. ## Because it lacks basic functionality, it is only actually used if explicitly enabled ## through `NoopBackendOptions`. -noop = ["wgpu-core/noop"] +noop = ["wgpu-core/noop", "dep:wgpu-hal", "dep:smallvec"] #! **Note:** In the documentation, if you see that an item depends on a backend, #! it means that the item is only available when that backend is enabled _and_ the backend diff --git a/wgpu/src/api/queue.rs b/wgpu/src/api/queue.rs index 7a03f8c0b..bf7ec4741 100644 --- a/wgpu/src/api/queue.rs +++ b/wgpu/src/api/queue.rs @@ -27,14 +27,7 @@ crate::cmp::impl_eq_ord_hash_proxy!(Queue => .inner); /// There is no analogue in the WebGPU specification. #[derive(Debug, Clone)] pub struct SubmissionIndex { - #[cfg_attr( - all( - target_arch = "wasm32", - not(target_os = "emscripten"), - not(feature = "webgl"), - ), - expect(dead_code) - )] + #[cfg_attr(not(wgpu_core), expect(dead_code))] pub(crate) index: u64, } #[cfg(send_sync)] diff --git a/wgpu/src/backend/wgpu_core.rs b/wgpu/src/backend/wgpu_core.rs index 926d7ddc2..2b9030ce3 100644 --- a/wgpu/src/backend/wgpu_core.rs +++ b/wgpu/src/backend/wgpu_core.rs @@ -399,10 +399,7 @@ fn map_texture_copy_view( } } -#[cfg_attr( - any(not(target_arch = "wasm32"), target_os = "emscripten"), - expect(unused) -)] +#[cfg_attr(not(webgl), expect(unused))] fn map_texture_tagged_copy_view( view: crate::CopyExternalImageDestInfo<&api::Texture>, ) -> wgc::command::CopyExternalImageDestInfo { @@ -1815,13 +1812,17 @@ impl dispatch::QueueInterface for CoreQueue { } } + // This method needs to exist if either webgpu or webgl is enabled, + // but we only actually have an implementation if webgl is enabled. #[cfg(any(webgpu, webgl))] + #[cfg_attr(not(webgl), expect(unused_variables))] fn copy_external_image_to_texture( &self, source: &crate::CopyExternalImageSourceInfo, dest: crate::CopyExternalImageDestInfo<&crate::api::Texture>, size: crate::Extent3d, ) { + #[cfg(webgl)] match self.context.0.queue_copy_external_image_to_texture( self.id, source, diff --git a/xtask/src/run_wasm.rs b/xtask/src/run_wasm.rs index d8048b3ca..eace62f2e 100644 --- a/xtask/src/run_wasm.rs +++ b/xtask/src/run_wasm.rs @@ -32,7 +32,7 @@ pub(crate) fn run_wasm(shell: Shell, mut args: Arguments) -> anyhow::Result<()> xshell::cmd!( shell, - "cargo build --target wasm32-unknown-unknown --bin wgpu-examples --no-default-features --features webgpu {release_flag...}" + "cargo build --target wasm32-unknown-unknown -p wgpu-examples --no-default-features --features webgpu {release_flag...}" ) .args(&cargo_args) .quiet() @@ -53,7 +53,7 @@ pub(crate) fn run_wasm(shell: Shell, mut args: Arguments) -> anyhow::Result<()> xshell::cmd!( shell, - "cargo build --target wasm32-unknown-unknown --bin wgpu-examples --no-default-features --features webgl {release_flag...}" + "cargo build --target wasm32-unknown-unknown -p wgpu-examples --no-default-features --features webgl {release_flag...}" ) .args(&cargo_args) .quiet() From ab38e8e4307fc7b6f81efac81c22b73ec09531b2 Mon Sep 17 00:00:00 2001 From: Josh Groves Date: Tue, 1 Apr 2025 11:17:39 -0230 Subject: [PATCH 009/806] Avoid overflows for extreme scissor coordinates (#7459) --- wgpu-core/src/command/render.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/wgpu-core/src/command/render.rs b/wgpu-core/src/command/render.rs index 72bb2fab6..67f3dd487 100644 --- a/wgpu-core/src/command/render.rs +++ b/wgpu-core/src/command/render.rs @@ -2408,7 +2408,9 @@ fn set_push_constant( fn set_scissor(state: &mut State, rect: Rect) -> Result<(), RenderPassErrorInner> { api_log!("RenderPass::set_scissor_rect {rect:?}"); - if rect.x + rect.w > state.info.extent.width || rect.y + rect.h > state.info.extent.height { + if rect.x.saturating_add(rect.w) > state.info.extent.width + || rect.y.saturating_add(rect.h) > state.info.extent.height + { return Err(RenderCommandError::InvalidScissorRect(rect, state.info.extent).into()); } let r = hal::Rect { From c4b781bdea20fdb7de7192be7af74d3c7fb4767a Mon Sep 17 00:00:00 2001 From: Erich Gubler Date: Tue, 1 Apr 2025 17:15:01 -0400 Subject: [PATCH 010/806] chore: there and back again: `hashbrown` 0.15 (#7461) This backs out commit 005bde99f96adde838e7bcd458576475673efcfd (#7081). --- Cargo.lock | 27 +++++++++++++-------------- Cargo.toml | 6 +++--- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0a2e220a4..df3f59f96 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -61,12 +61,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "allocator-api2" -version = "0.2.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" - [[package]] name = "android-activity" version = "0.5.2" @@ -1405,6 +1399,12 @@ dependencies = [ "spin", ] +[[package]] +name = "foldhash" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0d2fde1f7b3d48b8395d5f2de76c18a528bd6a9cdde438df747bfcba3e05d6f" + [[package]] name = "foreign-types" version = "0.5.0" @@ -1753,9 +1753,9 @@ dependencies = [ [[package]] name = "gpu-descriptor" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c08c1f623a8d0b722b8b99f821eb0ba672a1618f0d3b16ddbee1cedd2dd8557" +checksum = "dcf29e94d6d243368b7a56caa16bc213e4f9f8ed38c4d9557069527b5d5281ca" dependencies = [ "bitflags 2.9.0", "gpu-descriptor-types", @@ -1796,12 +1796,11 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.5" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" dependencies = [ - "ahash", - "allocator-api2", + "foldhash", "serde", ] @@ -2023,9 +2022,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.5.0" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" +checksum = "8c9c992b02b5b4c94ea26e32fe5bccb7aa7d9f390ab5c1221ff895bc7ea8b652" dependencies = [ "arbitrary", "equivalent", diff --git a/Cargo.toml b/Cargo.toml index 64877fc6e..5037cacee 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -107,13 +107,13 @@ flume = "0.11" futures-lite = "2" glam = "0.29" half = "2.5" # We require 2.5 to have `Arbitrary` support. -hashbrown = { version = "0.14.5", default-features = false, features = [ - "ahash", +hashbrown = { version = "0.15.2", default-features = false, features = [ + "default-hasher", "inline-more", ] } heck = "0.5.0" image = { version = "0.24", default-features = false, features = ["png"] } -indexmap = { version = "2.5.0", default-features = false } +indexmap = { version = "2.7.1", default-features = false } itertools = { version = "0.13.0" } ktx2 = "0.3" libc = { version = "0.2", default-features = false } From 6e6675a73c73d5be146c296c944d40022c5f4fbb Mon Sep 17 00:00:00 2001 From: sagudev <16504129+sagudev@users.noreply.github.com> Date: Sat, 8 Mar 2025 18:27:35 +0100 Subject: [PATCH 011/806] Revert [wgsl-out] Write const named expr as const declarations Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> --- naga/src/back/glsl/mod.rs | 3 +-- naga/src/back/hlsl/writer.rs | 4 +--- naga/src/back/mod.rs | 4 ---- naga/src/back/msl/writer.rs | 4 +--- naga/src/back/wgsl/writer.rs | 12 ++---------- 5 files changed, 5 insertions(+), 22 deletions(-) diff --git a/naga/src/back/glsl/mod.rs b/naga/src/back/glsl/mod.rs index 256fceb5e..785e5a861 100644 --- a/naga/src/back/glsl/mod.rs +++ b/naga/src/back/glsl/mod.rs @@ -64,7 +64,7 @@ use thiserror::Error; use crate::{ back::{self, Baked}, common, - proc::{self, ExpressionKindTracker, NameKey}, + proc::{self, NameKey}, valid, Handle, ShaderStage, TypeInner, }; use features::FeaturesManager; @@ -1678,7 +1678,6 @@ impl<'a, W: Write> Writer<'a, W> { info, expressions: &func.expressions, named_expressions: &func.named_expressions, - expr_kind_tracker: ExpressionKindTracker::from_arena(&func.expressions), }; self.named_expressions.clear(); diff --git a/naga/src/back/hlsl/writer.rs b/naga/src/back/hlsl/writer.rs index dd79174ac..a0d25e1d0 100644 --- a/naga/src/back/hlsl/writer.rs +++ b/naga/src/back/hlsl/writer.rs @@ -17,7 +17,7 @@ use super::{ use crate::{ back::{self, Baked}, common, - proc::{self, index, ExpressionKindTracker, NameKey}, + proc::{self, index, NameKey}, valid, Handle, Module, RayQueryFunction, Scalar, ScalarKind, ShaderStage, TypeInner, }; @@ -426,7 +426,6 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { info, expressions: &function.expressions, named_expressions: &function.named_expressions, - expr_kind_tracker: ExpressionKindTracker::from_arena(&function.expressions), }; let name = self.names[&NameKey::Function(handle)].clone(); @@ -467,7 +466,6 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { info, expressions: &ep.function.expressions, named_expressions: &ep.function.named_expressions, - expr_kind_tracker: ExpressionKindTracker::from_arena(&ep.function.expressions), }; self.write_wrapped_functions(module, &ctx)?; diff --git a/naga/src/back/mod.rs b/naga/src/back/mod.rs index dd9c7bd93..8eee9b6ff 100644 --- a/naga/src/back/mod.rs +++ b/naga/src/back/mod.rs @@ -11,8 +11,6 @@ Backend functions that export shader [`Module`](super::Module)s into binary and use alloc::string::String; -use crate::proc::ExpressionKindTracker; - #[cfg(dot_out)] pub mod dot; #[cfg(glsl_out)] @@ -128,8 +126,6 @@ pub struct FunctionCtx<'a> { pub expressions: &'a crate::Arena, /// Map of expressions that have associated variable names pub named_expressions: &'a crate::NamedExpressions, - /// For constness checks - pub expr_kind_tracker: ExpressionKindTracker, } impl FunctionCtx<'_> { diff --git a/naga/src/back/msl/writer.rs b/naga/src/back/msl/writer.rs index 83b8bd43d..77db02efc 100644 --- a/naga/src/back/msl/writer.rs +++ b/naga/src/back/msl/writer.rs @@ -17,7 +17,7 @@ use crate::{ arena::{Handle, HandleSet}, back::{self, Baked}, common, - proc::{self, index, ExpressionKindTracker, NameKey, TypeResolution}, + proc::{self, index, NameKey, TypeResolution}, valid, FastHashMap, FastHashSet, }; @@ -5572,7 +5572,6 @@ template info: &mod_info[fun_handle], expressions: &fun.expressions, named_expressions: &fun.named_expressions, - expr_kind_tracker: ExpressionKindTracker::from_arena(&fun.expressions), }; writeln!(self.out)?; @@ -5729,7 +5728,6 @@ template info: fun_info, expressions: &fun.expressions, named_expressions: &fun.named_expressions, - expr_kind_tracker: ExpressionKindTracker::from_arena(&fun.expressions), }; self.write_wrapped_functions(module, &ctx)?; diff --git a/naga/src/back/wgsl/writer.rs b/naga/src/back/wgsl/writer.rs index 9ca746e64..af4923c65 100644 --- a/naga/src/back/wgsl/writer.rs +++ b/naga/src/back/wgsl/writer.rs @@ -16,7 +16,7 @@ use crate::{ self, wgsl::{address_space_str, ToWgsl, TryToWgsl}, }, - proc::{self, ExpressionKindTracker, NameKey}, + proc::{self, NameKey}, valid, Handle, Module, ShaderStage, TypeInner, }; @@ -178,7 +178,6 @@ impl Writer { info: fun_info, expressions: &function.expressions, named_expressions: &function.named_expressions, - expr_kind_tracker: ExpressionKindTracker::from_arena(&function.expressions), }; // Write the function @@ -207,7 +206,6 @@ impl Writer { info: info.get_entry_point(index), expressions: &ep.function.expressions, named_expressions: &ep.function.named_expressions, - expr_kind_tracker: ExpressionKindTracker::from_arena(&ep.function.expressions), }; self.write_function(module, &ep.function, &func_ctx)?; @@ -1029,14 +1027,8 @@ impl Writer { func_ctx: &back::FunctionCtx, name: &str, ) -> BackendResult { - // Some functions are marked as const, but are not yet implemented as constant expression - let quantifier = if func_ctx.expr_kind_tracker.is_impl_const(handle) { - "const" - } else { - "let" - }; // Write variable name - write!(self.out, "{quantifier} {name}")?; + write!(self.out, "let {name}")?; if self.flags.contains(WriterFlags::EXPLICIT_TYPES) { write!(self.out, ": ")?; let ty = &func_ctx.info[handle].ty; From d937fabcd56f87203ee0736a08f73a22ee764e78 Mon Sep 17 00:00:00 2001 From: sagudev <16504129+sagudev@users.noreply.github.com> Date: Sat, 8 Mar 2025 18:31:10 +0100 Subject: [PATCH 012/806] Revert: Workaround for some builtins not implemented as constant expression Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> --- naga/src/proc/constant_evaluator.rs | 57 ++++------------------------- 1 file changed, 8 insertions(+), 49 deletions(-) diff --git a/naga/src/proc/constant_evaluator.rs b/naga/src/proc/constant_evaluator.rs index 406dbbef5..5b461075e 100644 --- a/naga/src/proc/constant_evaluator.rs +++ b/naga/src/proc/constant_evaluator.rs @@ -363,8 +363,6 @@ struct FunctionLocalData<'a> { #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)] pub enum ExpressionKind { - /// If const is also implemented as const - ImplConst, Const, Override, Runtime, @@ -392,21 +390,13 @@ impl ExpressionKindTracker { } pub fn is_const(&self, h: Handle) -> bool { - matches!( - self.type_of(h), - ExpressionKind::Const | ExpressionKind::ImplConst - ) - } - - /// Returns `true` if naga can also evaluate expression as const - pub fn is_impl_const(&self, h: Handle) -> bool { - matches!(self.type_of(h), ExpressionKind::ImplConst) + matches!(self.type_of(h), ExpressionKind::Const) } pub fn is_const_or_override(&self, h: Handle) -> bool { matches!( self.type_of(h), - ExpressionKind::Const | ExpressionKind::Override | ExpressionKind::ImplConst + ExpressionKind::Const | ExpressionKind::Override ) } @@ -427,14 +417,13 @@ impl ExpressionKindTracker { } fn type_of_with_expr(&self, expr: &Expression) -> ExpressionKind { - use crate::MathFunction as Mf; match *expr { Expression::Literal(_) | Expression::ZeroValue(_) | Expression::Constant(_) => { - ExpressionKind::ImplConst + ExpressionKind::Const } Expression::Override(_) => ExpressionKind::Override, Expression::Compose { ref components, .. } => { - let mut expr_type = ExpressionKind::ImplConst; + let mut expr_type = ExpressionKind::Const; for component in components { expr_type = expr_type.max(self.type_of(*component)) } @@ -445,16 +434,13 @@ impl ExpressionKindTracker { Expression::Access { base, index } => self.type_of(base).max(self.type_of(index)), Expression::Swizzle { vector, .. } => self.type_of(vector), Expression::Unary { expr, .. } => self.type_of(expr), - Expression::Binary { left, right, .. } => self - .type_of(left) - .max(self.type_of(right)) - .max(ExpressionKind::Const), + Expression::Binary { left, right, .. } => self.type_of(left).max(self.type_of(right)), Expression::Math { - fun, arg, arg1, arg2, arg3, + .. } => self .type_of(arg) .max( @@ -468,33 +454,8 @@ impl ExpressionKindTracker { .max( arg3.map(|arg| self.type_of(arg)) .unwrap_or(ExpressionKind::Const), - ) - .max( - if matches!( - fun, - Mf::Dot - | Mf::Outer - | Mf::Distance - | Mf::Length - | Mf::Normalize - | Mf::FaceForward - | Mf::Reflect - | Mf::Refract - | Mf::Ldexp - | Mf::Modf - | Mf::Mix - | Mf::Frexp - ) { - ExpressionKind::Const - } else { - ExpressionKind::ImplConst - }, ), - Expression::As { convert, expr, .. } => self.type_of(expr).max(if convert.is_some() { - ExpressionKind::ImplConst - } else { - ExpressionKind::Const - }), + Expression::As { expr, .. } => self.type_of(expr), Expression::Select { condition, accept, @@ -502,8 +463,7 @@ impl ExpressionKindTracker { } => self .type_of(condition) .max(self.type_of(accept)) - .max(self.type_of(reject)) - .max(ExpressionKind::Const), + .max(self.type_of(reject)), Expression::Relational { argument, .. } => self.type_of(argument), Expression::ArrayLength(expr) => self.type_of(expr), _ => ExpressionKind::Runtime, @@ -797,7 +757,6 @@ impl<'a> ConstantEvaluator<'a> { span: Span, ) -> Result, ConstantEvaluatorError> { match self.expression_kind_tracker.type_of_with_expr(&expr) { - ExpressionKind::ImplConst => self.try_eval_and_append_impl(&expr, span), ExpressionKind::Const => { let eval_result = self.try_eval_and_append_impl(&expr, span); // We should be able to evaluate `Const` expressions at this From 801b29cf01df1404472c395b4f7db5b1df78a1fe Mon Sep 17 00:00:00 2001 From: sagudev <16504129+sagudev@users.noreply.github.com> Date: Sat, 8 Mar 2025 18:33:08 +0100 Subject: [PATCH 013/806] Do not add local const to named expr Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> --- naga/src/front/wgsl/lower/mod.rs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/naga/src/front/wgsl/lower/mod.rs b/naga/src/front/wgsl/lower/mod.rs index 1fa3ecc83..af44242f1 100644 --- a/naga/src/front/wgsl/lower/mod.rs +++ b/naga/src/front/wgsl/lower/mod.rs @@ -1604,7 +1604,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { c.ty.map(|ast| self.resolve_ast_type(ast, &mut ectx.as_const())) .transpose()?; - let (ty, init) = self.type_and_init( + let (_ty, init) = self.type_and_init( c.name, Some(c.init), explicit_ty, @@ -1616,13 +1616,6 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { block.extend(emitter.finish(&ctx.function.expressions)); ctx.local_table .insert(c.handle, Declared::Const(Typed::Plain(init))); - // Only add constants of non-abstract types to the named expressions - // to prevent abstract types ending up in the IR. - let is_abstract = ctx.module.types[ty].inner.is_abstract(&ctx.module.types); - if !is_abstract { - ctx.named_expressions - .insert(init, (c.name.name.to_string(), c.name.span)); - } return Ok(()); } }, From f7f09357a621b200322447c733dac0b79d935452 Mon Sep 17 00:00:00 2001 From: sagudev <16504129+sagudev@users.noreply.github.com> Date: Sun, 9 Mar 2025 07:57:07 +0100 Subject: [PATCH 014/806] Update expectations Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> --- .../glsl/image.texture_sample.Fragment.glsl | 48 +++++----- naga/tests/out/hlsl/image.hlsl | 90 +++++++++---------- naga/tests/out/ir/local-const.compact.ron | 18 +--- naga/tests/out/ir/local-const.ron | 18 +--- naga/tests/out/msl/image.msl | 90 +++++++++---------- naga/tests/out/wgsl/access.wgsl | 4 +- naga/tests/out/wgsl/binding-arrays.wgsl | 4 +- naga/tests/out/wgsl/constructors.wgsl | 14 +-- naga/tests/out/wgsl/cross.wgsl | 2 +- naga/tests/out/wgsl/expressions.frag.wgsl | 4 +- naga/tests/out/wgsl/functions.wgsl | 14 +-- naga/tests/out/wgsl/image.wgsl | 90 +++++++++---------- naga/tests/out/wgsl/math-functions.wgsl | 26 +++--- naga/tests/out/wgsl/operators.wgsl | 52 +++++------ naga/tests/out/wgsl/prepostfix.frag.wgsl | 4 +- naga/tests/out/wgsl/shadow.wgsl | 2 +- naga/tests/out/wgsl/type-alias.wgsl | 14 +-- 17 files changed, 233 insertions(+), 261 deletions(-) diff --git a/naga/tests/out/glsl/image.texture_sample.Fragment.glsl b/naga/tests/out/glsl/image.texture_sample.Fragment.glsl index fc0d0db38..118e9e452 100644 --- a/naga/tests/out/glsl/image.texture_sample.Fragment.glsl +++ b/naga/tests/out/glsl/image.texture_sample.Fragment.glsl @@ -11,73 +11,73 @@ layout(location = 0) out vec4 _fs2p_location0; void main() { vec4 a = vec4(0.0); - vec2 tc = vec2(0.5); - vec3 tc3_ = vec3(0.5); - ivec2 offset = ivec2(3, 1); + vec2 _e1 = vec2(0.5); + vec3 _e3 = vec3(0.5); + ivec2 _e6 = ivec2(3, 1); vec4 _e11 = texture(_group_0_binding_0_fs, 0.5); vec4 _e12 = a; a = (_e12 + _e11); - vec4 _e16 = texture(_group_0_binding_1_fs, vec2(tc)); + vec4 _e16 = texture(_group_0_binding_1_fs, vec2(_e1)); vec4 _e17 = a; a = (_e17 + _e16); - vec4 _e24 = textureOffset(_group_0_binding_1_fs, vec2(tc), ivec2(3, 1)); + vec4 _e24 = textureOffset(_group_0_binding_1_fs, vec2(_e1), ivec2(3, 1)); vec4 _e25 = a; a = (_e25 + _e24); - vec4 _e29 = textureLod(_group_0_binding_1_fs, vec2(tc), 2.3); + vec4 _e29 = textureLod(_group_0_binding_1_fs, vec2(_e1), 2.3); vec4 _e30 = a; a = (_e30 + _e29); - vec4 _e34 = textureLodOffset(_group_0_binding_1_fs, vec2(tc), 2.3, ivec2(3, 1)); + vec4 _e34 = textureLodOffset(_group_0_binding_1_fs, vec2(_e1), 2.3, ivec2(3, 1)); vec4 _e35 = a; a = (_e35 + _e34); - vec4 _e40 = textureOffset(_group_0_binding_1_fs, vec2(tc), ivec2(3, 1), 2.0); + vec4 _e40 = textureOffset(_group_0_binding_1_fs, vec2(_e1), ivec2(3, 1), 2.0); vec4 _e41 = a; a = (_e41 + _e40); - vec4 _e46 = texture(_group_0_binding_4_fs, vec3(tc, 0u)); + vec4 _e46 = texture(_group_0_binding_4_fs, vec3(_e1, 0u)); vec4 _e47 = a; a = (_e47 + _e46); - vec4 _e52 = textureOffset(_group_0_binding_4_fs, vec3(tc, 0u), ivec2(3, 1)); + vec4 _e52 = textureOffset(_group_0_binding_4_fs, vec3(_e1, 0u), ivec2(3, 1)); vec4 _e53 = a; a = (_e53 + _e52); - vec4 _e58 = textureLod(_group_0_binding_4_fs, vec3(tc, 0u), 2.3); + vec4 _e58 = textureLod(_group_0_binding_4_fs, vec3(_e1, 0u), 2.3); vec4 _e59 = a; a = (_e59 + _e58); - vec4 _e64 = textureLodOffset(_group_0_binding_4_fs, vec3(tc, 0u), 2.3, ivec2(3, 1)); + vec4 _e64 = textureLodOffset(_group_0_binding_4_fs, vec3(_e1, 0u), 2.3, ivec2(3, 1)); vec4 _e65 = a; a = (_e65 + _e64); - vec4 _e71 = textureOffset(_group_0_binding_4_fs, vec3(tc, 0u), ivec2(3, 1), 2.0); + vec4 _e71 = textureOffset(_group_0_binding_4_fs, vec3(_e1, 0u), ivec2(3, 1), 2.0); vec4 _e72 = a; a = (_e72 + _e71); - vec4 _e77 = texture(_group_0_binding_4_fs, vec3(tc, 0)); + vec4 _e77 = texture(_group_0_binding_4_fs, vec3(_e1, 0)); vec4 _e78 = a; a = (_e78 + _e77); - vec4 _e83 = textureOffset(_group_0_binding_4_fs, vec3(tc, 0), ivec2(3, 1)); + vec4 _e83 = textureOffset(_group_0_binding_4_fs, vec3(_e1, 0), ivec2(3, 1)); vec4 _e84 = a; a = (_e84 + _e83); - vec4 _e89 = textureLod(_group_0_binding_4_fs, vec3(tc, 0), 2.3); + vec4 _e89 = textureLod(_group_0_binding_4_fs, vec3(_e1, 0), 2.3); vec4 _e90 = a; a = (_e90 + _e89); - vec4 _e95 = textureLodOffset(_group_0_binding_4_fs, vec3(tc, 0), 2.3, ivec2(3, 1)); + vec4 _e95 = textureLodOffset(_group_0_binding_4_fs, vec3(_e1, 0), 2.3, ivec2(3, 1)); vec4 _e96 = a; a = (_e96 + _e95); - vec4 _e102 = textureOffset(_group_0_binding_4_fs, vec3(tc, 0), ivec2(3, 1), 2.0); + vec4 _e102 = textureOffset(_group_0_binding_4_fs, vec3(_e1, 0), ivec2(3, 1), 2.0); vec4 _e103 = a; a = (_e103 + _e102); - vec4 _e108 = texture(_group_0_binding_6_fs, vec4(tc3_, 0u)); + vec4 _e108 = texture(_group_0_binding_6_fs, vec4(_e3, 0u)); vec4 _e109 = a; a = (_e109 + _e108); - vec4 _e114 = textureLod(_group_0_binding_6_fs, vec4(tc3_, 0u), 2.3); + vec4 _e114 = textureLod(_group_0_binding_6_fs, vec4(_e3, 0u), 2.3); vec4 _e115 = a; a = (_e115 + _e114); - vec4 _e121 = texture(_group_0_binding_6_fs, vec4(tc3_, 0u), 2.0); + vec4 _e121 = texture(_group_0_binding_6_fs, vec4(_e3, 0u), 2.0); vec4 _e122 = a; a = (_e122 + _e121); - vec4 _e127 = texture(_group_0_binding_6_fs, vec4(tc3_, 0)); + vec4 _e127 = texture(_group_0_binding_6_fs, vec4(_e3, 0)); vec4 _e128 = a; a = (_e128 + _e127); - vec4 _e133 = textureLod(_group_0_binding_6_fs, vec4(tc3_, 0), 2.3); + vec4 _e133 = textureLod(_group_0_binding_6_fs, vec4(_e3, 0), 2.3); vec4 _e134 = a; a = (_e134 + _e133); - vec4 _e140 = texture(_group_0_binding_6_fs, vec4(tc3_, 0), 2.0); + vec4 _e140 = texture(_group_0_binding_6_fs, vec4(_e3, 0), 2.0); vec4 _e141 = a; a = (_e141 + _e140); vec4 _e143 = a; diff --git a/naga/tests/out/hlsl/image.hlsl b/naga/tests/out/hlsl/image.hlsl index 28c4b326d..d41a5d945 100644 --- a/naga/tests/out/hlsl/image.hlsl +++ b/naga/tests/out/hlsl/image.hlsl @@ -258,73 +258,73 @@ float4 texture_sample() : SV_Target0 { float4 a = (float4)0; - float2 tc = (0.5).xx; - float3 tc3_ = (0.5).xxx; - int2 offset = int2(int(3), int(1)); + float2 _e1 = (0.5).xx; + float3 _e3 = (0.5).xxx; + int2 _e6 = int2(int(3), int(1)); float4 _e11 = image_1d.Sample(sampler_reg, 0.5); float4 _e12 = a; a = (_e12 + _e11); - float4 _e16 = image_2d.Sample(sampler_reg, tc); + float4 _e16 = image_2d.Sample(sampler_reg, _e1); float4 _e17 = a; a = (_e17 + _e16); - float4 _e24 = image_2d.Sample(sampler_reg, tc, int2(int2(int(3), int(1)))); + float4 _e24 = image_2d.Sample(sampler_reg, _e1, int2(int2(int(3), int(1)))); float4 _e25 = a; a = (_e25 + _e24); - float4 _e29 = image_2d.SampleLevel(sampler_reg, tc, 2.3); + float4 _e29 = image_2d.SampleLevel(sampler_reg, _e1, 2.3); float4 _e30 = a; a = (_e30 + _e29); - float4 _e34 = image_2d.SampleLevel(sampler_reg, tc, 2.3, int2(int2(int(3), int(1)))); + float4 _e34 = image_2d.SampleLevel(sampler_reg, _e1, 2.3, int2(int2(int(3), int(1)))); float4 _e35 = a; a = (_e35 + _e34); - float4 _e40 = image_2d.SampleBias(sampler_reg, tc, 2.0, int2(int2(int(3), int(1)))); + float4 _e40 = image_2d.SampleBias(sampler_reg, _e1, 2.0, int2(int2(int(3), int(1)))); float4 _e41 = a; a = (_e41 + _e40); - float4 _e46 = image_2d_array.Sample(sampler_reg, float3(tc, 0u)); + float4 _e46 = image_2d_array.Sample(sampler_reg, float3(_e1, 0u)); float4 _e47 = a; a = (_e47 + _e46); - float4 _e52 = image_2d_array.Sample(sampler_reg, float3(tc, 0u), int2(int2(int(3), int(1)))); + float4 _e52 = image_2d_array.Sample(sampler_reg, float3(_e1, 0u), int2(int2(int(3), int(1)))); float4 _e53 = a; a = (_e53 + _e52); - float4 _e58 = image_2d_array.SampleLevel(sampler_reg, float3(tc, 0u), 2.3); + float4 _e58 = image_2d_array.SampleLevel(sampler_reg, float3(_e1, 0u), 2.3); float4 _e59 = a; a = (_e59 + _e58); - float4 _e64 = image_2d_array.SampleLevel(sampler_reg, float3(tc, 0u), 2.3, int2(int2(int(3), int(1)))); + float4 _e64 = image_2d_array.SampleLevel(sampler_reg, float3(_e1, 0u), 2.3, int2(int2(int(3), int(1)))); float4 _e65 = a; a = (_e65 + _e64); - float4 _e71 = image_2d_array.SampleBias(sampler_reg, float3(tc, 0u), 2.0, int2(int2(int(3), int(1)))); + float4 _e71 = image_2d_array.SampleBias(sampler_reg, float3(_e1, 0u), 2.0, int2(int2(int(3), int(1)))); float4 _e72 = a; a = (_e72 + _e71); - float4 _e77 = image_2d_array.Sample(sampler_reg, float3(tc, int(0))); + float4 _e77 = image_2d_array.Sample(sampler_reg, float3(_e1, int(0))); float4 _e78 = a; a = (_e78 + _e77); - float4 _e83 = image_2d_array.Sample(sampler_reg, float3(tc, int(0)), int2(int2(int(3), int(1)))); + float4 _e83 = image_2d_array.Sample(sampler_reg, float3(_e1, int(0)), int2(int2(int(3), int(1)))); float4 _e84 = a; a = (_e84 + _e83); - float4 _e89 = image_2d_array.SampleLevel(sampler_reg, float3(tc, int(0)), 2.3); + float4 _e89 = image_2d_array.SampleLevel(sampler_reg, float3(_e1, int(0)), 2.3); float4 _e90 = a; a = (_e90 + _e89); - float4 _e95 = image_2d_array.SampleLevel(sampler_reg, float3(tc, int(0)), 2.3, int2(int2(int(3), int(1)))); + float4 _e95 = image_2d_array.SampleLevel(sampler_reg, float3(_e1, int(0)), 2.3, int2(int2(int(3), int(1)))); float4 _e96 = a; a = (_e96 + _e95); - float4 _e102 = image_2d_array.SampleBias(sampler_reg, float3(tc, int(0)), 2.0, int2(int2(int(3), int(1)))); + float4 _e102 = image_2d_array.SampleBias(sampler_reg, float3(_e1, int(0)), 2.0, int2(int2(int(3), int(1)))); float4 _e103 = a; a = (_e103 + _e102); - float4 _e108 = image_cube_array.Sample(sampler_reg, float4(tc3_, 0u)); + float4 _e108 = image_cube_array.Sample(sampler_reg, float4(_e3, 0u)); float4 _e109 = a; a = (_e109 + _e108); - float4 _e114 = image_cube_array.SampleLevel(sampler_reg, float4(tc3_, 0u), 2.3); + float4 _e114 = image_cube_array.SampleLevel(sampler_reg, float4(_e3, 0u), 2.3); float4 _e115 = a; a = (_e115 + _e114); - float4 _e121 = image_cube_array.SampleBias(sampler_reg, float4(tc3_, 0u), 2.0); + float4 _e121 = image_cube_array.SampleBias(sampler_reg, float4(_e3, 0u), 2.0); float4 _e122 = a; a = (_e122 + _e121); - float4 _e127 = image_cube_array.Sample(sampler_reg, float4(tc3_, int(0))); + float4 _e127 = image_cube_array.Sample(sampler_reg, float4(_e3, int(0))); float4 _e128 = a; a = (_e128 + _e127); - float4 _e133 = image_cube_array.SampleLevel(sampler_reg, float4(tc3_, int(0)), 2.3); + float4 _e133 = image_cube_array.SampleLevel(sampler_reg, float4(_e3, int(0)), 2.3); float4 _e134 = a; a = (_e134 + _e133); - float4 _e140 = image_cube_array.SampleBias(sampler_reg, float4(tc3_, int(0)), 2.0); + float4 _e140 = image_cube_array.SampleBias(sampler_reg, float4(_e3, int(0)), 2.0); float4 _e141 = a; a = (_e141 + _e140); float4 _e143 = a; @@ -335,30 +335,30 @@ float texture_sample_comparison() : SV_Target0 { float a_1 = (float)0; - float2 tc_1 = (0.5).xx; - float3 tc3_1 = (0.5).xxx; - float _e8 = image_2d_depth.SampleCmp(sampler_cmp, tc_1, 0.5); + float2 tc = (0.5).xx; + float3 tc3_ = (0.5).xxx; + float _e8 = image_2d_depth.SampleCmp(sampler_cmp, tc, 0.5); float _e9 = a_1; a_1 = (_e9 + _e8); - float _e14 = image_2d_array_depth.SampleCmp(sampler_cmp, float3(tc_1, 0u), 0.5); + float _e14 = image_2d_array_depth.SampleCmp(sampler_cmp, float3(tc, 0u), 0.5); float _e15 = a_1; a_1 = (_e15 + _e14); - float _e20 = image_2d_array_depth.SampleCmp(sampler_cmp, float3(tc_1, int(0)), 0.5); + float _e20 = image_2d_array_depth.SampleCmp(sampler_cmp, float3(tc, int(0)), 0.5); float _e21 = a_1; a_1 = (_e21 + _e20); - float _e25 = image_cube_depth.SampleCmp(sampler_cmp, tc3_1, 0.5); + float _e25 = image_cube_depth.SampleCmp(sampler_cmp, tc3_, 0.5); float _e26 = a_1; a_1 = (_e26 + _e25); - float _e30 = image_2d_depth.SampleCmpLevelZero(sampler_cmp, tc_1, 0.5); + float _e30 = image_2d_depth.SampleCmpLevelZero(sampler_cmp, tc, 0.5); float _e31 = a_1; a_1 = (_e31 + _e30); - float _e36 = image_2d_array_depth.SampleCmpLevelZero(sampler_cmp, float3(tc_1, 0u), 0.5); + float _e36 = image_2d_array_depth.SampleCmpLevelZero(sampler_cmp, float3(tc, 0u), 0.5); float _e37 = a_1; a_1 = (_e37 + _e36); - float _e42 = image_2d_array_depth.SampleCmpLevelZero(sampler_cmp, float3(tc_1, int(0)), 0.5); + float _e42 = image_2d_array_depth.SampleCmpLevelZero(sampler_cmp, float3(tc, int(0)), 0.5); float _e43 = a_1; a_1 = (_e43 + _e42); - float _e47 = image_cube_depth.SampleCmpLevelZero(sampler_cmp, tc3_1, 0.5); + float _e47 = image_cube_depth.SampleCmpLevelZero(sampler_cmp, tc3_, 0.5); float _e48 = a_1; a_1 = (_e48 + _e47); float _e50 = a_1; @@ -367,22 +367,22 @@ float texture_sample_comparison() : SV_Target0 float4 gather() : SV_Target0 { - float2 tc_2 = (0.5).xx; - float4 s2d = image_2d.GatherGreen(sampler_reg, tc_2); - float4 s2d_offset = image_2d.GatherAlpha(sampler_reg, tc_2, int2(int2(int(3), int(1)))); - float4 s2d_depth = image_2d_depth.GatherCmp(sampler_cmp, tc_2, 0.5); - float4 s2d_depth_offset = image_2d_depth.GatherCmp(sampler_cmp, tc_2, 0.5, int2(int2(int(3), int(1)))); - uint4 u = image_2d_u32_.Gather(sampler_reg, tc_2); - int4 i = image_2d_i32_.Gather(sampler_reg, tc_2); + float2 tc_1 = (0.5).xx; + float4 s2d = image_2d.GatherGreen(sampler_reg, tc_1); + float4 s2d_offset = image_2d.GatherAlpha(sampler_reg, tc_1, int2(int2(int(3), int(1)))); + float4 s2d_depth = image_2d_depth.GatherCmp(sampler_cmp, tc_1, 0.5); + float4 s2d_depth_offset = image_2d_depth.GatherCmp(sampler_cmp, tc_1, 0.5, int2(int2(int(3), int(1)))); + uint4 u = image_2d_u32_.Gather(sampler_reg, tc_1); + int4 i = image_2d_i32_.Gather(sampler_reg, tc_1); float4 f = (float4(u) + float4(i)); return ((((s2d + s2d_offset) + s2d_depth) + s2d_depth_offset) + f); } float4 depth_no_comparison() : SV_Target0 { - float2 tc_3 = (0.5).xx; - float s2d_1 = image_2d_depth.Sample(sampler_reg, tc_3); - float4 s2d_gather = image_2d_depth.Gather(sampler_reg, tc_3); - float s2d_level = image_2d_depth.SampleLevel(sampler_reg, tc_3, int(1)); + float2 tc_2 = (0.5).xx; + float s2d_1 = image_2d_depth.Sample(sampler_reg, tc_2); + float4 s2d_gather = image_2d_depth.Gather(sampler_reg, tc_2); + float s2d_level = image_2d_depth.SampleLevel(sampler_reg, tc_2, int(1)); return (((s2d_1).xxxx + s2d_gather) + (s2d_level).xxxx); } diff --git a/naga/tests/out/ir/local-const.compact.ron b/naga/tests/out/ir/local-const.compact.ron index 649d58333..c28243109 100644 --- a/naga/tests/out/ir/local-const.compact.ron +++ b/naga/tests/out/ir/local-const.compact.ron @@ -58,22 +58,8 @@ arguments: [], result: None, local_variables: [], - expressions: [ - Literal(I32(4)), - Literal(U32(4)), - Literal(F32(4.0)), - Constant(0), - Constant(1), - Constant(2), - ], - named_expressions: { - 0: "b", - 1: "c", - 2: "d", - 3: "bg", - 4: "cg", - 5: "dg", - }, + expressions: [], + named_expressions: {}, body: [ Emit(( start: 0, diff --git a/naga/tests/out/ir/local-const.ron b/naga/tests/out/ir/local-const.ron index 649d58333..c28243109 100644 --- a/naga/tests/out/ir/local-const.ron +++ b/naga/tests/out/ir/local-const.ron @@ -58,22 +58,8 @@ arguments: [], result: None, local_variables: [], - expressions: [ - Literal(I32(4)), - Literal(U32(4)), - Literal(F32(4.0)), - Constant(0), - Constant(1), - Constant(2), - ], - named_expressions: { - 0: "b", - 1: "c", - 2: "d", - 3: "bg", - 4: "cg", - 5: "dg", - }, + expressions: [], + named_expressions: {}, body: [ Emit(( start: 0, diff --git a/naga/tests/out/msl/image.msl b/naga/tests/out/msl/image.msl index 723ebd987..da4c41063 100644 --- a/naga/tests/out/msl/image.msl +++ b/naga/tests/out/msl/image.msl @@ -128,73 +128,73 @@ fragment texture_sampleOutput texture_sample( , metal::sampler sampler_reg [[user(fake0)]] ) { metal::float4 a = {}; - metal::float2 tc = metal::float2(0.5); - metal::float3 tc3_ = metal::float3(0.5); - metal::int2 offset = metal::int2(3, 1); + metal::float2 _e1 = metal::float2(0.5); + metal::float3 _e3 = metal::float3(0.5); + metal::int2 _e6 = metal::int2(3, 1); metal::float4 _e11 = image_1d.sample(sampler_reg, 0.5); metal::float4 _e12 = a; a = _e12 + _e11; - metal::float4 _e16 = image_2d.sample(sampler_reg, tc); + metal::float4 _e16 = image_2d.sample(sampler_reg, _e1); metal::float4 _e17 = a; a = _e17 + _e16; - metal::float4 _e24 = image_2d.sample(sampler_reg, tc, metal::int2(3, 1)); + metal::float4 _e24 = image_2d.sample(sampler_reg, _e1, metal::int2(3, 1)); metal::float4 _e25 = a; a = _e25 + _e24; - metal::float4 _e29 = image_2d.sample(sampler_reg, tc, metal::level(2.3)); + metal::float4 _e29 = image_2d.sample(sampler_reg, _e1, metal::level(2.3)); metal::float4 _e30 = a; a = _e30 + _e29; - metal::float4 _e34 = image_2d.sample(sampler_reg, tc, metal::level(2.3), offset); + metal::float4 _e34 = image_2d.sample(sampler_reg, _e1, metal::level(2.3), _e6); metal::float4 _e35 = a; a = _e35 + _e34; - metal::float4 _e40 = image_2d.sample(sampler_reg, tc, metal::bias(2.0), offset); + metal::float4 _e40 = image_2d.sample(sampler_reg, _e1, metal::bias(2.0), _e6); metal::float4 _e41 = a; a = _e41 + _e40; - metal::float4 _e46 = image_2d_array.sample(sampler_reg, tc, 0u); + metal::float4 _e46 = image_2d_array.sample(sampler_reg, _e1, 0u); metal::float4 _e47 = a; a = _e47 + _e46; - metal::float4 _e52 = image_2d_array.sample(sampler_reg, tc, 0u, offset); + metal::float4 _e52 = image_2d_array.sample(sampler_reg, _e1, 0u, _e6); metal::float4 _e53 = a; a = _e53 + _e52; - metal::float4 _e58 = image_2d_array.sample(sampler_reg, tc, 0u, metal::level(2.3)); + metal::float4 _e58 = image_2d_array.sample(sampler_reg, _e1, 0u, metal::level(2.3)); metal::float4 _e59 = a; a = _e59 + _e58; - metal::float4 _e64 = image_2d_array.sample(sampler_reg, tc, 0u, metal::level(2.3), offset); + metal::float4 _e64 = image_2d_array.sample(sampler_reg, _e1, 0u, metal::level(2.3), _e6); metal::float4 _e65 = a; a = _e65 + _e64; - metal::float4 _e71 = image_2d_array.sample(sampler_reg, tc, 0u, metal::bias(2.0), offset); + metal::float4 _e71 = image_2d_array.sample(sampler_reg, _e1, 0u, metal::bias(2.0), _e6); metal::float4 _e72 = a; a = _e72 + _e71; - metal::float4 _e77 = image_2d_array.sample(sampler_reg, tc, 0); + metal::float4 _e77 = image_2d_array.sample(sampler_reg, _e1, 0); metal::float4 _e78 = a; a = _e78 + _e77; - metal::float4 _e83 = image_2d_array.sample(sampler_reg, tc, 0, offset); + metal::float4 _e83 = image_2d_array.sample(sampler_reg, _e1, 0, _e6); metal::float4 _e84 = a; a = _e84 + _e83; - metal::float4 _e89 = image_2d_array.sample(sampler_reg, tc, 0, metal::level(2.3)); + metal::float4 _e89 = image_2d_array.sample(sampler_reg, _e1, 0, metal::level(2.3)); metal::float4 _e90 = a; a = _e90 + _e89; - metal::float4 _e95 = image_2d_array.sample(sampler_reg, tc, 0, metal::level(2.3), offset); + metal::float4 _e95 = image_2d_array.sample(sampler_reg, _e1, 0, metal::level(2.3), _e6); metal::float4 _e96 = a; a = _e96 + _e95; - metal::float4 _e102 = image_2d_array.sample(sampler_reg, tc, 0, metal::bias(2.0), offset); + metal::float4 _e102 = image_2d_array.sample(sampler_reg, _e1, 0, metal::bias(2.0), _e6); metal::float4 _e103 = a; a = _e103 + _e102; - metal::float4 _e108 = image_cube_array.sample(sampler_reg, tc3_, 0u); + metal::float4 _e108 = image_cube_array.sample(sampler_reg, _e3, 0u); metal::float4 _e109 = a; a = _e109 + _e108; - metal::float4 _e114 = image_cube_array.sample(sampler_reg, tc3_, 0u, metal::level(2.3)); + metal::float4 _e114 = image_cube_array.sample(sampler_reg, _e3, 0u, metal::level(2.3)); metal::float4 _e115 = a; a = _e115 + _e114; - metal::float4 _e121 = image_cube_array.sample(sampler_reg, tc3_, 0u, metal::bias(2.0)); + metal::float4 _e121 = image_cube_array.sample(sampler_reg, _e3, 0u, metal::bias(2.0)); metal::float4 _e122 = a; a = _e122 + _e121; - metal::float4 _e127 = image_cube_array.sample(sampler_reg, tc3_, 0); + metal::float4 _e127 = image_cube_array.sample(sampler_reg, _e3, 0); metal::float4 _e128 = a; a = _e128 + _e127; - metal::float4 _e133 = image_cube_array.sample(sampler_reg, tc3_, 0, metal::level(2.3)); + metal::float4 _e133 = image_cube_array.sample(sampler_reg, _e3, 0, metal::level(2.3)); metal::float4 _e134 = a; a = _e134 + _e133; - metal::float4 _e140 = image_cube_array.sample(sampler_reg, tc3_, 0, metal::bias(2.0)); + metal::float4 _e140 = image_cube_array.sample(sampler_reg, _e3, 0, metal::bias(2.0)); metal::float4 _e141 = a; a = _e141 + _e140; metal::float4 _e143 = a; @@ -212,30 +212,30 @@ fragment texture_sample_comparisonOutput texture_sample_comparison( , metal::depthcube image_cube_depth [[user(fake0)]] ) { float a_1 = {}; - metal::float2 tc_1 = metal::float2(0.5); - metal::float3 tc3_1 = metal::float3(0.5); - float _e8 = image_2d_depth.sample_compare(sampler_cmp, tc_1, 0.5); + metal::float2 tc = metal::float2(0.5); + metal::float3 tc3_ = metal::float3(0.5); + float _e8 = image_2d_depth.sample_compare(sampler_cmp, tc, 0.5); float _e9 = a_1; a_1 = _e9 + _e8; - float _e14 = image_2d_array_depth.sample_compare(sampler_cmp, tc_1, 0u, 0.5); + float _e14 = image_2d_array_depth.sample_compare(sampler_cmp, tc, 0u, 0.5); float _e15 = a_1; a_1 = _e15 + _e14; - float _e20 = image_2d_array_depth.sample_compare(sampler_cmp, tc_1, 0, 0.5); + float _e20 = image_2d_array_depth.sample_compare(sampler_cmp, tc, 0, 0.5); float _e21 = a_1; a_1 = _e21 + _e20; - float _e25 = image_cube_depth.sample_compare(sampler_cmp, tc3_1, 0.5); + float _e25 = image_cube_depth.sample_compare(sampler_cmp, tc3_, 0.5); float _e26 = a_1; a_1 = _e26 + _e25; - float _e30 = image_2d_depth.sample_compare(sampler_cmp, tc_1, 0.5); + float _e30 = image_2d_depth.sample_compare(sampler_cmp, tc, 0.5); float _e31 = a_1; a_1 = _e31 + _e30; - float _e36 = image_2d_array_depth.sample_compare(sampler_cmp, tc_1, 0u, 0.5); + float _e36 = image_2d_array_depth.sample_compare(sampler_cmp, tc, 0u, 0.5); float _e37 = a_1; a_1 = _e37 + _e36; - float _e42 = image_2d_array_depth.sample_compare(sampler_cmp, tc_1, 0, 0.5); + float _e42 = image_2d_array_depth.sample_compare(sampler_cmp, tc, 0, 0.5); float _e43 = a_1; a_1 = _e43 + _e42; - float _e47 = image_cube_depth.sample_compare(sampler_cmp, tc3_1, 0.5); + float _e47 = image_cube_depth.sample_compare(sampler_cmp, tc3_, 0.5); float _e48 = a_1; a_1 = _e48 + _e47; float _e50 = a_1; @@ -254,13 +254,13 @@ fragment gatherOutput gather( , metal::sampler sampler_cmp [[user(fake0)]] , metal::depth2d image_2d_depth [[user(fake0)]] ) { - metal::float2 tc_2 = metal::float2(0.5); - metal::float4 s2d = image_2d.gather(sampler_reg, tc_2, metal::int2(0), metal::component::y); - metal::float4 s2d_offset = image_2d.gather(sampler_reg, tc_2, metal::int2(3, 1), metal::component::w); - metal::float4 s2d_depth = image_2d_depth.gather_compare(sampler_cmp, tc_2, 0.5); - metal::float4 s2d_depth_offset = image_2d_depth.gather_compare(sampler_cmp, tc_2, 0.5, metal::int2(3, 1)); - metal::uint4 u = image_2d_u32_.gather(sampler_reg, tc_2); - metal::int4 i = image_2d_i32_.gather(sampler_reg, tc_2); + metal::float2 tc_1 = metal::float2(0.5); + metal::float4 s2d = image_2d.gather(sampler_reg, tc_1, metal::int2(0), metal::component::y); + metal::float4 s2d_offset = image_2d.gather(sampler_reg, tc_1, metal::int2(3, 1), metal::component::w); + metal::float4 s2d_depth = image_2d_depth.gather_compare(sampler_cmp, tc_1, 0.5); + metal::float4 s2d_depth_offset = image_2d_depth.gather_compare(sampler_cmp, tc_1, 0.5, metal::int2(3, 1)); + metal::uint4 u = image_2d_u32_.gather(sampler_reg, tc_1); + metal::int4 i = image_2d_i32_.gather(sampler_reg, tc_1); metal::float4 f = static_cast(u) + static_cast(i); return gatherOutput { (((s2d + s2d_offset) + s2d_depth) + s2d_depth_offset) + f }; } @@ -273,9 +273,9 @@ fragment depth_no_comparisonOutput depth_no_comparison( metal::sampler sampler_reg [[user(fake0)]] , metal::depth2d image_2d_depth [[user(fake0)]] ) { - metal::float2 tc_3 = metal::float2(0.5); - float s2d_1 = image_2d_depth.sample(sampler_reg, tc_3); - metal::float4 s2d_gather = image_2d_depth.gather(sampler_reg, tc_3); - float s2d_level = image_2d_depth.sample(sampler_reg, tc_3, metal::level(1)); + metal::float2 tc_2 = metal::float2(0.5); + float s2d_1 = image_2d_depth.sample(sampler_reg, tc_2); + metal::float4 s2d_gather = image_2d_depth.gather(sampler_reg, tc_2); + float s2d_level = image_2d_depth.sample(sampler_reg, tc_2, metal::level(1)); return depth_no_comparisonOutput { (metal::float4(s2d_1) + s2d_gather) + metal::float4(s2d_level) }; } diff --git a/naga/tests/out/wgsl/access.wgsl b/naga/tests/out/wgsl/access.wgsl index fd4f74252..2728676d2 100644 --- a/naga/tests/out/wgsl/access.wgsl +++ b/naga/tests/out/wgsl/access.wgsl @@ -179,8 +179,8 @@ fn member_ptr() -> i32 { } fn let_members_of_members() -> i32 { - const inner_1 = Outer().om_nom_nom; - const delishus_1 = inner_1.delicious; + let inner_1 = Outer().om_nom_nom; + let delishus_1 = inner_1.delicious; if (Outer().thing != u32(delishus_1)) { } return Outer().om_nom_nom.delicious; diff --git a/naga/tests/out/wgsl/binding-arrays.wgsl b/naga/tests/out/wgsl/binding-arrays.wgsl index 5bed8ef00..86bcfc1bf 100644 --- a/naga/tests/out/wgsl/binding-arrays.wgsl +++ b/naga/tests/out/wgsl/binding-arrays.wgsl @@ -34,8 +34,8 @@ fn main(fragment_in: FragmentIn) -> @location(0) vec4 { let uniform_index = uni.index; let non_uniform_index = fragment_in.index; - const uv = vec2(0f); - const pix = vec2(0i); + let uv = vec2(0f); + let pix = vec2(0i); let _e21 = textureDimensions(texture_array_unbounded[0]); let _e22 = u2_; u2_ = (_e22 + _e21); diff --git a/naga/tests/out/wgsl/constructors.wgsl b/naga/tests/out/wgsl/constructors.wgsl index f053e1f6e..039b4f971 100644 --- a/naga/tests/out/wgsl/constructors.wgsl +++ b/naga/tests/out/wgsl/constructors.wgsl @@ -19,12 +19,12 @@ fn main() { var foo: Foo; foo = Foo(vec4(1f), 1i); - const m0_ = mat2x2(vec2(1f, 0f), vec2(0f, 1f)); - const m1_ = mat4x4(vec4(1f, 0f, 0f, 0f), vec4(0f, 1f, 0f, 0f), vec4(0f, 0f, 1f, 0f), vec4(0f, 0f, 0f, 1f)); - const cit0_ = vec2(0u); - const cit1_ = mat2x2(vec2(0f), vec2(0f)); - const cit2_ = array(0i, 1i, 2i, 3i); - const ic4_ = vec2(0u, 0u); - const ic5_ = mat2x3(vec3(0f, 0f, 0f), vec3(0f, 0f, 0f)); + let m0_ = mat2x2(vec2(1f, 0f), vec2(0f, 1f)); + let m1_ = mat4x4(vec4(1f, 0f, 0f, 0f), vec4(0f, 1f, 0f, 0f), vec4(0f, 0f, 1f, 0f), vec4(0f, 0f, 0f, 1f)); + let cit0_ = vec2(0u); + let cit1_ = mat2x2(vec2(0f), vec2(0f)); + let cit2_ = array(0i, 1i, 2i, 3i); + let ic4_ = vec2(0u, 0u); + let ic5_ = mat2x3(vec3(0f, 0f, 0f), vec3(0f, 0f, 0f)); return; } diff --git a/naga/tests/out/wgsl/cross.wgsl b/naga/tests/out/wgsl/cross.wgsl index c0db534d1..7665a6216 100644 --- a/naga/tests/out/wgsl/cross.wgsl +++ b/naga/tests/out/wgsl/cross.wgsl @@ -1,5 +1,5 @@ @compute @workgroup_size(1, 1, 1) fn main() { - const a = vec3(0f, 0f, 1f); + let a = vec3(0f, 0f, 1f); return; } diff --git a/naga/tests/out/wgsl/expressions.frag.wgsl b/naga/tests/out/wgsl/expressions.frag.wgsl index 55c6b67e7..27fbb4ed3 100644 --- a/naga/tests/out/wgsl/expressions.frag.wgsl +++ b/naga/tests/out/wgsl/expressions.frag.wgsl @@ -268,12 +268,12 @@ fn testUnaryOpMat(a_16: mat3x3) { let _e3 = a_17; v_8 = -(_e3); let _e5 = a_17; - const _e7 = vec3(1f); + let _e7 = vec3(1f); let _e9 = (_e5 - mat3x3(_e7, _e7, _e7)); a_17 = _e9; v_8 = _e9; let _e10 = a_17; - const _e12 = vec3(1f); + let _e12 = vec3(1f); a_17 = (_e10 - mat3x3(_e12, _e12, _e12)); v_8 = _e10; return; diff --git a/naga/tests/out/wgsl/functions.wgsl b/naga/tests/out/wgsl/functions.wgsl index db7b81b14..79f000ce2 100644 --- a/naga/tests/out/wgsl/functions.wgsl +++ b/naga/tests/out/wgsl/functions.wgsl @@ -1,16 +1,16 @@ fn test_fma() -> vec2 { - const a = vec2(2f, 2f); - const b = vec2(0.5f, 0.5f); - const c = vec2(0.5f, 0.5f); + let a = vec2(2f, 2f); + let b = vec2(0.5f, 0.5f); + let c = vec2(0.5f, 0.5f); return fma(a, b, c); } fn test_integer_dot_product() -> i32 { - const a_2_ = vec2(1i); - const b_2_ = vec2(1i); + let a_2_ = vec2(1i); + let b_2_ = vec2(1i); let c_2_ = dot(a_2_, b_2_); - const a_3_ = vec3(1u); - const b_3_ = vec3(1u); + let a_3_ = vec3(1u); + let b_3_ = vec3(1u); let c_3_ = dot(a_3_, b_3_); let c_4_ = dot(vec4(4i), vec4(2i)); return c_4_; diff --git a/naga/tests/out/wgsl/image.wgsl b/naga/tests/out/wgsl/image.wgsl index c3ac10f54..701701a3c 100644 --- a/naga/tests/out/wgsl/image.wgsl +++ b/naga/tests/out/wgsl/image.wgsl @@ -112,73 +112,73 @@ fn levels_queries() -> @builtin(position) vec4 { fn texture_sample() -> @location(0) vec4 { var a: vec4; - const tc = vec2(0.5f); - const tc3_ = vec3(0.5f); - const offset = vec2(3i, 1i); + let _e1 = vec2(0.5f); + let _e3 = vec3(0.5f); + let _e6 = vec2(3i, 1i); let _e11 = textureSample(image_1d, sampler_reg, 0.5f); let _e12 = a; a = (_e12 + _e11); - let _e16 = textureSample(image_2d, sampler_reg, tc); + let _e16 = textureSample(image_2d, sampler_reg, _e1); let _e17 = a; a = (_e17 + _e16); - let _e24 = textureSample(image_2d, sampler_reg, tc, vec2(3i, 1i)); + let _e24 = textureSample(image_2d, sampler_reg, _e1, vec2(3i, 1i)); let _e25 = a; a = (_e25 + _e24); - let _e29 = textureSampleLevel(image_2d, sampler_reg, tc, 2.3f); + let _e29 = textureSampleLevel(image_2d, sampler_reg, _e1, 2.3f); let _e30 = a; a = (_e30 + _e29); - let _e34 = textureSampleLevel(image_2d, sampler_reg, tc, 2.3f, vec2(3i, 1i)); + let _e34 = textureSampleLevel(image_2d, sampler_reg, _e1, 2.3f, vec2(3i, 1i)); let _e35 = a; a = (_e35 + _e34); - let _e40 = textureSampleBias(image_2d, sampler_reg, tc, 2f, vec2(3i, 1i)); + let _e40 = textureSampleBias(image_2d, sampler_reg, _e1, 2f, vec2(3i, 1i)); let _e41 = a; a = (_e41 + _e40); - let _e46 = textureSample(image_2d_array, sampler_reg, tc, 0u); + let _e46 = textureSample(image_2d_array, sampler_reg, _e1, 0u); let _e47 = a; a = (_e47 + _e46); - let _e52 = textureSample(image_2d_array, sampler_reg, tc, 0u, vec2(3i, 1i)); + let _e52 = textureSample(image_2d_array, sampler_reg, _e1, 0u, vec2(3i, 1i)); let _e53 = a; a = (_e53 + _e52); - let _e58 = textureSampleLevel(image_2d_array, sampler_reg, tc, 0u, 2.3f); + let _e58 = textureSampleLevel(image_2d_array, sampler_reg, _e1, 0u, 2.3f); let _e59 = a; a = (_e59 + _e58); - let _e64 = textureSampleLevel(image_2d_array, sampler_reg, tc, 0u, 2.3f, vec2(3i, 1i)); + let _e64 = textureSampleLevel(image_2d_array, sampler_reg, _e1, 0u, 2.3f, vec2(3i, 1i)); let _e65 = a; a = (_e65 + _e64); - let _e71 = textureSampleBias(image_2d_array, sampler_reg, tc, 0u, 2f, vec2(3i, 1i)); + let _e71 = textureSampleBias(image_2d_array, sampler_reg, _e1, 0u, 2f, vec2(3i, 1i)); let _e72 = a; a = (_e72 + _e71); - let _e77 = textureSample(image_2d_array, sampler_reg, tc, 0i); + let _e77 = textureSample(image_2d_array, sampler_reg, _e1, 0i); let _e78 = a; a = (_e78 + _e77); - let _e83 = textureSample(image_2d_array, sampler_reg, tc, 0i, vec2(3i, 1i)); + let _e83 = textureSample(image_2d_array, sampler_reg, _e1, 0i, vec2(3i, 1i)); let _e84 = a; a = (_e84 + _e83); - let _e89 = textureSampleLevel(image_2d_array, sampler_reg, tc, 0i, 2.3f); + let _e89 = textureSampleLevel(image_2d_array, sampler_reg, _e1, 0i, 2.3f); let _e90 = a; a = (_e90 + _e89); - let _e95 = textureSampleLevel(image_2d_array, sampler_reg, tc, 0i, 2.3f, vec2(3i, 1i)); + let _e95 = textureSampleLevel(image_2d_array, sampler_reg, _e1, 0i, 2.3f, vec2(3i, 1i)); let _e96 = a; a = (_e96 + _e95); - let _e102 = textureSampleBias(image_2d_array, sampler_reg, tc, 0i, 2f, vec2(3i, 1i)); + let _e102 = textureSampleBias(image_2d_array, sampler_reg, _e1, 0i, 2f, vec2(3i, 1i)); let _e103 = a; a = (_e103 + _e102); - let _e108 = textureSample(image_cube_array, sampler_reg, tc3_, 0u); + let _e108 = textureSample(image_cube_array, sampler_reg, _e3, 0u); let _e109 = a; a = (_e109 + _e108); - let _e114 = textureSampleLevel(image_cube_array, sampler_reg, tc3_, 0u, 2.3f); + let _e114 = textureSampleLevel(image_cube_array, sampler_reg, _e3, 0u, 2.3f); let _e115 = a; a = (_e115 + _e114); - let _e121 = textureSampleBias(image_cube_array, sampler_reg, tc3_, 0u, 2f); + let _e121 = textureSampleBias(image_cube_array, sampler_reg, _e3, 0u, 2f); let _e122 = a; a = (_e122 + _e121); - let _e127 = textureSample(image_cube_array, sampler_reg, tc3_, 0i); + let _e127 = textureSample(image_cube_array, sampler_reg, _e3, 0i); let _e128 = a; a = (_e128 + _e127); - let _e133 = textureSampleLevel(image_cube_array, sampler_reg, tc3_, 0i, 2.3f); + let _e133 = textureSampleLevel(image_cube_array, sampler_reg, _e3, 0i, 2.3f); let _e134 = a; a = (_e134 + _e133); - let _e140 = textureSampleBias(image_cube_array, sampler_reg, tc3_, 0i, 2f); + let _e140 = textureSampleBias(image_cube_array, sampler_reg, _e3, 0i, 2f); let _e141 = a; a = (_e141 + _e140); let _e143 = a; @@ -189,30 +189,30 @@ fn texture_sample() -> @location(0) vec4 { fn texture_sample_comparison() -> @location(0) f32 { var a_1: f32; - const tc_1 = vec2(0.5f); - const tc3_1 = vec3(0.5f); - let _e8 = textureSampleCompare(image_2d_depth, sampler_cmp, tc_1, 0.5f); + let tc = vec2(0.5f); + let tc3_ = vec3(0.5f); + let _e8 = textureSampleCompare(image_2d_depth, sampler_cmp, tc, 0.5f); let _e9 = a_1; a_1 = (_e9 + _e8); - let _e14 = textureSampleCompare(image_2d_array_depth, sampler_cmp, tc_1, 0u, 0.5f); + let _e14 = textureSampleCompare(image_2d_array_depth, sampler_cmp, tc, 0u, 0.5f); let _e15 = a_1; a_1 = (_e15 + _e14); - let _e20 = textureSampleCompare(image_2d_array_depth, sampler_cmp, tc_1, 0i, 0.5f); + let _e20 = textureSampleCompare(image_2d_array_depth, sampler_cmp, tc, 0i, 0.5f); let _e21 = a_1; a_1 = (_e21 + _e20); - let _e25 = textureSampleCompare(image_cube_depth, sampler_cmp, tc3_1, 0.5f); + let _e25 = textureSampleCompare(image_cube_depth, sampler_cmp, tc3_, 0.5f); let _e26 = a_1; a_1 = (_e26 + _e25); - let _e30 = textureSampleCompareLevel(image_2d_depth, sampler_cmp, tc_1, 0.5f); + let _e30 = textureSampleCompareLevel(image_2d_depth, sampler_cmp, tc, 0.5f); let _e31 = a_1; a_1 = (_e31 + _e30); - let _e36 = textureSampleCompareLevel(image_2d_array_depth, sampler_cmp, tc_1, 0u, 0.5f); + let _e36 = textureSampleCompareLevel(image_2d_array_depth, sampler_cmp, tc, 0u, 0.5f); let _e37 = a_1; a_1 = (_e37 + _e36); - let _e42 = textureSampleCompareLevel(image_2d_array_depth, sampler_cmp, tc_1, 0i, 0.5f); + let _e42 = textureSampleCompareLevel(image_2d_array_depth, sampler_cmp, tc, 0i, 0.5f); let _e43 = a_1; a_1 = (_e43 + _e42); - let _e47 = textureSampleCompareLevel(image_cube_depth, sampler_cmp, tc3_1, 0.5f); + let _e47 = textureSampleCompareLevel(image_cube_depth, sampler_cmp, tc3_, 0.5f); let _e48 = a_1; a_1 = (_e48 + _e47); let _e50 = a_1; @@ -221,22 +221,22 @@ fn texture_sample_comparison() -> @location(0) f32 { @fragment fn gather() -> @location(0) vec4 { - const tc_2 = vec2(0.5f); - let s2d = textureGather(1, image_2d, sampler_reg, tc_2); - let s2d_offset = textureGather(3, image_2d, sampler_reg, tc_2, vec2(3i, 1i)); - let s2d_depth = textureGatherCompare(image_2d_depth, sampler_cmp, tc_2, 0.5f); - let s2d_depth_offset = textureGatherCompare(image_2d_depth, sampler_cmp, tc_2, 0.5f, vec2(3i, 1i)); - let u = textureGather(0, image_2d_u32_, sampler_reg, tc_2); - let i = textureGather(0, image_2d_i32_, sampler_reg, tc_2); + let tc_1 = vec2(0.5f); + let s2d = textureGather(1, image_2d, sampler_reg, tc_1); + let s2d_offset = textureGather(3, image_2d, sampler_reg, tc_1, vec2(3i, 1i)); + let s2d_depth = textureGatherCompare(image_2d_depth, sampler_cmp, tc_1, 0.5f); + let s2d_depth_offset = textureGatherCompare(image_2d_depth, sampler_cmp, tc_1, 0.5f, vec2(3i, 1i)); + let u = textureGather(0, image_2d_u32_, sampler_reg, tc_1); + let i = textureGather(0, image_2d_i32_, sampler_reg, tc_1); let f = (vec4(u) + vec4(i)); return ((((s2d + s2d_offset) + s2d_depth) + s2d_depth_offset) + f); } @fragment fn depth_no_comparison() -> @location(0) vec4 { - const tc_3 = vec2(0.5f); - let s2d_1 = textureSample(image_2d_depth, sampler_reg, tc_3); - let s2d_gather = textureGather(image_2d_depth, sampler_reg, tc_3); - let s2d_level = textureSampleLevel(image_2d_depth, sampler_reg, tc_3, 1i); + let tc_2 = vec2(0.5f); + let s2d_1 = textureSample(image_2d_depth, sampler_reg, tc_2); + let s2d_gather = textureGather(image_2d_depth, sampler_reg, tc_2); + let s2d_level = textureSampleLevel(image_2d_depth, sampler_reg, tc_2, 1i); return ((vec4(s2d_1) + s2d_gather) + vec4(s2d_level)); } diff --git a/naga/tests/out/wgsl/math-functions.wgsl b/naga/tests/out/wgsl/math-functions.wgsl index b4d876a7f..082afb933 100644 --- a/naga/tests/out/wgsl/math-functions.wgsl +++ b/naga/tests/out/wgsl/math-functions.wgsl @@ -1,25 +1,25 @@ @fragment fn main() { - const v = vec4(0f); + let v = vec4(0f); let a = degrees(1f); let b = radians(1f); let c = degrees(v); let d = radians(v); let e = saturate(v); let g = refract(v, v, 1f); - const sign_b = vec4(-1i, -1i, -1i, -1i); - const sign_d = vec4(-1f, -1f, -1f, -1f); + let sign_b = vec4(-1i, -1i, -1i, -1i); + let sign_d = vec4(-1f, -1f, -1f, -1f); let const_dot = dot(vec2(), vec2()); - const flb_b = vec2(-1i, -1i); - const flb_c = vec2(0u, 0u); - const ftb_c = vec2(0i, 0i); - const ftb_d = vec2(0u, 0u); - const ctz_e = vec2(32u, 32u); - const ctz_f = vec2(32i, 32i); - const ctz_g = vec2(0u, 0u); - const ctz_h = vec2(0i, 0i); - const clz_c = vec2(0i, 0i); - const clz_d = vec2(31u, 31u); + let flb_b = vec2(-1i, -1i); + let flb_c = vec2(0u, 0u); + let ftb_c = vec2(0i, 0i); + let ftb_d = vec2(0u, 0u); + let ctz_e = vec2(32u, 32u); + let ctz_f = vec2(32i, 32i); + let ctz_g = vec2(0u, 0u); + let ctz_h = vec2(0i, 0i); + let clz_c = vec2(0i, 0i); + let clz_d = vec2(31u, 31u); let lde_a = ldexp(1f, 2i); let lde_b = ldexp(vec2(1f, 2f), vec2(3i, 4i)); let modf_a = modf(1.5f); diff --git a/naga/tests/out/wgsl/operators.wgsl b/naga/tests/out/wgsl/operators.wgsl index 0927b831a..eaae0a429 100644 --- a/naga/tests/out/wgsl/operators.wgsl +++ b/naga/tests/out/wgsl/operators.wgsl @@ -11,7 +11,7 @@ fn builtins() -> vec4 { let m2_ = mix(v_f32_zero, v_f32_one, 0.1f); let b1_ = bitcast(1i); let b2_ = bitcast>(v_i32_one); - const v_i32_zero = vec4(0i, 0i, 0i, 0i); + let v_i32_zero = vec4(0i, 0i, 0i, 0i); return (((((vec4((vec4(s1_) + v_i32_zero)) + s2_) + m1_) + m2_) + vec4(b1_)) + b2_); } @@ -40,8 +40,8 @@ fn bool_cast(x: vec3) -> vec3 { } fn logical() { - const neg0_ = !(true); - const neg1_ = !(vec2(true)); + let neg0_ = !(true); + let neg1_ = !(vec2(true)); let or = (true || false); let and = (true && false); let bitwise_or0_ = (true | false); @@ -52,9 +52,9 @@ fn logical() { } fn arithmetic() { - const neg0_1 = -(1f); - const neg1_1 = -(vec2(1i)); - const neg2_ = -(vec2(1f)); + let neg0_1 = -(1f); + let neg1_1 = -(vec2(1i)); + let neg2_ = -(vec2(1f)); let add0_ = (2i + 1i); let add1_ = (2u + 1u); let add2_ = (2f + 1f); @@ -128,10 +128,10 @@ fn arithmetic() { } fn bit() { - const flip0_ = ~(1i); - const flip1_ = ~(1u); - const flip2_ = ~(vec2(1i)); - const flip3_ = ~(vec3(1u)); + let flip0_ = ~(1i); + let flip1_ = ~(1u); + let flip2_ = ~(vec2(1i)); + let flip3_ = ~(vec3(1u)); let or0_ = (2i | 1i); let or1_ = (2u | 1u); let or2_ = (vec2(2i) | vec2(1i)); @@ -234,22 +234,22 @@ fn assignment() { } fn negation_avoids_prefix_decrement() { - const i0_ = -(1i); - const i1_ = -(-(1i)); - const i2_ = -(-(1i)); - const i3_ = -(-(1i)); - const i4_ = -(-(-(1i))); - const i5_ = -(-(-(-(1i)))); - const i6_ = -(-(-(-(-(1i))))); - const i7_ = -(-(-(-(-(1i))))); - const f0_ = -(1f); - const f1_ = -(-(1f)); - const f2_ = -(-(1f)); - const f3_ = -(-(1f)); - const f4_ = -(-(-(1f))); - const f5_ = -(-(-(-(1f)))); - const f6_ = -(-(-(-(-(1f))))); - const f7_ = -(-(-(-(-(1f))))); + let i0_ = -(1i); + let i1_ = -(-(1i)); + let i2_ = -(-(1i)); + let i3_ = -(-(1i)); + let i4_ = -(-(-(1i))); + let i5_ = -(-(-(-(1i)))); + let i6_ = -(-(-(-(-(1i))))); + let i7_ = -(-(-(-(-(1i))))); + let f0_ = -(1f); + let f1_ = -(-(1f)); + let f2_ = -(-(1f)); + let f3_ = -(-(1f)); + let f4_ = -(-(-(1f))); + let f5_ = -(-(-(-(1f)))); + let f6_ = -(-(-(-(-(1f))))); + let f7_ = -(-(-(-(-(1f))))); return; } diff --git a/naga/tests/out/wgsl/prepostfix.frag.wgsl b/naga/tests/out/wgsl/prepostfix.frag.wgsl index 57e271acd..4249dad24 100644 --- a/naga/tests/out/wgsl/prepostfix.frag.wgsl +++ b/naga/tests/out/wgsl/prepostfix.frag.wgsl @@ -21,11 +21,11 @@ fn main_1() { vec = _e20; vec_target = _e20; let _e30 = mat; - const _e32 = vec3(1f); + let _e32 = vec3(1f); mat = (_e30 + mat4x3(_e32, _e32, _e32, _e32)); mat_target = _e30; let _e35 = mat; - const _e37 = vec3(1f); + let _e37 = vec3(1f); let _e39 = (_e35 - mat4x3(_e37, _e37, _e37, _e37)); mat = _e39; mat_target = _e39; diff --git a/naga/tests/out/wgsl/shadow.wgsl b/naga/tests/out/wgsl/shadow.wgsl index 8b198d2ed..e9d5bbf1b 100644 --- a/naga/tests/out/wgsl/shadow.wgsl +++ b/naga/tests/out/wgsl/shadow.wgsl @@ -40,7 +40,7 @@ fn fetch_shadow(light_id: u32, homogeneous_coords: vec4) -> f32 { if (homogeneous_coords.w <= 0f) { return 1f; } - const flip_correction = vec2(0.5f, -0.5f); + let flip_correction = vec2(0.5f, -0.5f); let proj_correction = (1f / homogeneous_coords.w); let light_local = (((homogeneous_coords.xy * flip_correction) * proj_correction) + vec2(0.5f, 0.5f)); let _e24 = textureSampleCompareLevel(t_shadow, sampler_shadow, light_local, i32(light_id), (homogeneous_coords.z * proj_correction)); diff --git a/naga/tests/out/wgsl/type-alias.wgsl b/naga/tests/out/wgsl/type-alias.wgsl index ffb8dcbb0..68df5a0f4 100644 --- a/naga/tests/out/wgsl/type-alias.wgsl +++ b/naga/tests/out/wgsl/type-alias.wgsl @@ -1,11 +1,11 @@ fn main() { - const a = vec3(0f, 0f, 0f); - const c = vec3(0f); - const b = vec3(vec2(0f), 0f); - const d = vec3(vec2(0f), 0f); - const e = vec3(d); - const f = mat2x2(vec2(1f, 2f), vec2(3f, 4f)); - const g = mat3x3(a, a, a); + let a = vec3(0f, 0f, 0f); + let c = vec3(0f); + let b = vec3(vec2(0f), 0f); + let d = vec3(vec2(0f), 0f); + let e = vec3(d); + let f = mat2x2(vec2(1f, 2f), vec2(3f, 4f)); + let g = mat3x3(a, a, a); return; } From 2c777f79f00939453cbb73fa3b837d4d0fc02501 Mon Sep 17 00:00:00 2001 From: Andy Leiserson Date: Wed, 2 Apr 2025 08:52:40 -0700 Subject: [PATCH 015/806] [naga wgsl-in] `vecN()` constructors and `let` type conversions (#7367) * Support `vecN()` constructors (fixes #7356) * Apply automatic conversions to the initializer for `let` bindings --- CHANGELOG.md | 1 + naga/src/front/wgsl/lower/construction.rs | 22 +- naga/src/front/wgsl/lower/mod.rs | 48 +- naga/src/proc/mod.rs | 2 + naga/tests/in/wgsl/abstract-types-const.wgsl | 27 +- naga/tests/in/wgsl/abstract-types-let.toml | 1 + naga/tests/in/wgsl/abstract-types-let.wgsl | 115 +++ naga/tests/in/wgsl/abstract-types-var.wgsl | 52 +- naga/tests/in/wgsl/constructors.wgsl | 9 +- naga/tests/in/wgsl/conversions.wgsl | 16 + naga/tests/in/wgsl/type-inference.wgsl | 64 ++ naga/tests/naga/wgsl_errors.rs | 6 +- .../out/glsl/constructors.main.Compute.glsl | 4 + .../out/glsl/conversions.main.Compute.glsl | 16 + .../out/glsl/type-inference.main.Compute.glsl | 50 ++ naga/tests/out/hlsl/constructors.hlsl | 4 + naga/tests/out/hlsl/conversions.hlsl | 10 + naga/tests/out/hlsl/conversions.ron | 12 + naga/tests/out/hlsl/type-inference.hlsl | 48 ++ naga/tests/out/hlsl/type-inference.ron | 12 + naga/tests/out/msl/abstract-types-const.msl | 25 +- naga/tests/out/msl/abstract-types-let.msl | 131 +++ naga/tests/out/msl/abstract-types-var.msl | 194 +++-- naga/tests/out/msl/constructors.msl | 16 +- naga/tests/out/msl/conversions.msl | 14 + naga/tests/out/msl/type-inference.msl | 48 ++ .../tests/out/spv/abstract-types-const.spvasm | 93 +- naga/tests/out/spv/abstract-types-let.spvasm | 144 ++++ naga/tests/out/spv/abstract-types-var.spvasm | 797 ++++++++++-------- naga/tests/out/spv/constructors.spvasm | 138 +-- naga/tests/out/spv/conversions.spvasm | 23 + naga/tests/out/spv/math-functions.spvasm | 48 +- naga/tests/out/spv/operators.spvasm | 142 ++-- naga/tests/out/spv/type-inference.spvasm | 72 ++ naga/tests/out/wgsl/abstract-types-const.wgsl | 19 +- naga/tests/out/wgsl/abstract-types-let.wgsl | 112 +++ naga/tests/out/wgsl/abstract-types-var.wgsl | 188 +++-- naga/tests/out/wgsl/constructors.wgsl | 4 + naga/tests/out/wgsl/conversions.wgsl | 9 + naga/tests/out/wgsl/type-inference.wgsl | 43 + 40 files changed, 2028 insertions(+), 751 deletions(-) create mode 100644 naga/tests/in/wgsl/abstract-types-let.toml create mode 100644 naga/tests/in/wgsl/abstract-types-let.wgsl create mode 100644 naga/tests/in/wgsl/conversions.wgsl create mode 100644 naga/tests/in/wgsl/type-inference.wgsl create mode 100644 naga/tests/out/glsl/conversions.main.Compute.glsl create mode 100644 naga/tests/out/glsl/type-inference.main.Compute.glsl create mode 100644 naga/tests/out/hlsl/conversions.hlsl create mode 100644 naga/tests/out/hlsl/conversions.ron create mode 100644 naga/tests/out/hlsl/type-inference.hlsl create mode 100644 naga/tests/out/hlsl/type-inference.ron create mode 100644 naga/tests/out/msl/abstract-types-let.msl create mode 100644 naga/tests/out/msl/conversions.msl create mode 100644 naga/tests/out/msl/type-inference.msl create mode 100644 naga/tests/out/spv/abstract-types-let.spvasm create mode 100644 naga/tests/out/spv/conversions.spvasm create mode 100644 naga/tests/out/spv/type-inference.spvasm create mode 100644 naga/tests/out/wgsl/abstract-types-let.wgsl create mode 100644 naga/tests/out/wgsl/conversions.wgsl create mode 100644 naga/tests/out/wgsl/type-inference.wgsl diff --git a/CHANGELOG.md b/CHANGELOG.md index 54c4780f6..3de1a4423 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -239,6 +239,7 @@ By @wumpf in [#7144](https://github.com/gfx-rs/wgpu/pull/7144) - Allow WGSL const declarations to have abstract types. By @jamienicol in [#7055](https://github.com/gfx-rs/wgpu/pull/7055) and [#7222](https://github.com/gfx-rs/wgpu/pull/7222). - Allows override-sized arrays to resolve to the same size without causing the type arena to panic. By @KentSlaney in [#7082](https://github.com/gfx-rs/wgpu/pull/7082). - Allow abstract types to be used for WGSL switch statement selector and case selector expressions. By @jamienicol in [#7250](https://github.com/gfx-rs/wgpu/pull/7250). +- Apply automatic conversions to `let` declarations, and accept `vecN()` as a constructor for vectors (in any context). By @andyleiserson in [#7367](https://github.com/gfx-rs/wgpu/pull/7367). #### General diff --git a/naga/src/front/wgsl/lower/construction.rs b/naga/src/front/wgsl/lower/construction.rs index fe5f4655e..286a893b9 100644 --- a/naga/src/front/wgsl/lower/construction.rs +++ b/naga/src/front/wgsl/lower/construction.rs @@ -167,11 +167,25 @@ impl<'source> Lowerer<'source, '_> { // Empty constructor (Components::None, dst_ty) => match dst_ty { Constructor::Type((result_ty, _)) => { - return ctx.append_expression(crate::Expression::ZeroValue(result_ty), span) + expr = crate::Expression::ZeroValue(result_ty); } - Constructor::PartialVector { .. } - | Constructor::PartialMatrix { .. } - | Constructor::PartialArray => { + Constructor::PartialVector { size } => { + // vec2(), vec3(), vec4() return vectors of abstractInts; the same + // is not true of the similar constructors for matrices or arrays. + // See https://www.w3.org/TR/WGSL/#vec2-builtin et seq. + let result_ty = ctx.module.types.insert( + crate::Type { + name: None, + inner: crate::TypeInner::Vector { + size, + scalar: crate::Scalar::ABSTRACT_INT, + }, + }, + span, + ); + expr = crate::Expression::ZeroValue(result_ty); + } + Constructor::PartialMatrix { .. } | Constructor::PartialArray => { // We have no arguments from which to infer the result type, so // partial constructors aren't acceptable here. return Err(Box::new(Error::TypeNotInferable(ty_span))); diff --git a/naga/src/front/wgsl/lower/mod.rs b/naga/src/front/wgsl/lower/mod.rs index af44242f1..909299f65 100644 --- a/naga/src/front/wgsl/lower/mod.rs +++ b/naga/src/front/wgsl/lower/mod.rs @@ -1490,41 +1490,39 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { let mut emitter = Emitter::default(); emitter.start(&ctx.function.expressions); - let value = - self.expression(l.init, &mut ctx.as_expression(block, &mut emitter))?; + let explicit_ty = l + .ty + .map(|ty| self.resolve_ast_type(ty, &mut ctx.as_const(block, &mut emitter))) + .transpose()?; + + let mut ectx = ctx.as_expression(block, &mut emitter); + + let (_ty, initializer) = self.type_and_init( + l.name, + Some(l.init), + explicit_ty, + AbstractRule::Concretize, + &mut ectx, + )?; + + // We passed `Some()` to `type_and_init`, so we + // will get a lowered initializer expression back. + let initializer = + initializer.expect("type_and_init did not return an initializer"); // The WGSL spec says that any expression that refers to a // `let`-bound variable is not a const expression. This // affects when errors must be reported, so we can't even // treat suitable `let` bindings as constant as an // optimization. - ctx.local_expression_kind_tracker.force_non_const(value); - - let explicit_ty = l - .ty - .map(|ty| self.resolve_ast_type(ty, &mut ctx.as_const(block, &mut emitter))) - .transpose()?; - - if let Some(ty) = explicit_ty { - let mut ctx = ctx.as_expression(block, &mut emitter); - let init_ty = ctx.register_type(value)?; - if !ctx.module.types[ty] - .inner - .equivalent(&ctx.module.types[init_ty].inner, &ctx.module.types) - { - return Err(Box::new(Error::InitializationTypeMismatch { - name: l.name.span, - expected: ctx.type_to_string(ty), - got: ctx.type_to_string(init_ty), - })); - } - } + ctx.local_expression_kind_tracker + .force_non_const(initializer); block.extend(emitter.finish(&ctx.function.expressions)); ctx.local_table - .insert(l.handle, Declared::Runtime(Typed::Plain(value))); + .insert(l.handle, Declared::Runtime(Typed::Plain(initializer))); ctx.named_expressions - .insert(value, (l.name.name.to_string(), l.name.span)); + .insert(initializer, (l.name.name.to_string(), l.name.span)); return Ok(()); } diff --git a/naga/src/proc/mod.rs b/naga/src/proc/mod.rs index 787a2f1a6..49089fda0 100644 --- a/naga/src/proc/mod.rs +++ b/naga/src/proc/mod.rs @@ -119,6 +119,8 @@ impl crate::Literal { (value, crate::ScalarKind::Sint, 8) => Some(Self::I64(value as _)), (1, crate::ScalarKind::Bool, crate::BOOL_WIDTH) => Some(Self::Bool(true)), (0, crate::ScalarKind::Bool, crate::BOOL_WIDTH) => Some(Self::Bool(false)), + (value, crate::ScalarKind::AbstractInt, 8) => Some(Self::AbstractInt(value as _)), + (value, crate::ScalarKind::AbstractFloat, 8) => Some(Self::AbstractFloat(value as _)), _ => None, } } diff --git a/naga/tests/in/wgsl/abstract-types-const.wgsl b/naga/tests/in/wgsl/abstract-types-const.wgsl index 0cf20b5d2..73be56a3a 100644 --- a/naga/tests/in/wgsl/abstract-types-const.wgsl +++ b/naga/tests/in/wgsl/abstract-types-const.wgsl @@ -12,8 +12,11 @@ // - all parameters' types are considered. // - all parameters are converted to the consensus type. -const xvupaiai: vec2 = vec2(42, 43); -const xvfpaiai: vec2 = vec2(44, 45); +const xvipaiai: vec2 = vec2(42, 43); +const xvupaiai: vec2 = vec2(44, 45); +const xvfpaiai: vec2 = vec2(46, 47); +const xvfpafaf: vec2 = vec2(48.0, 49.0); +const xvfpaiaf: vec2 = vec2(48, 49.0); const xvupuai: vec2 = vec2(42u, 43); const xvupaiu: vec2 = vec2(42, 43u); @@ -21,6 +24,11 @@ const xvupaiu: vec2 = vec2(42, 43u); const xvuuai: vec2 = vec2(42u, 43); const xvuaiu: vec2 = vec2(42, 43u); +const xvip____: vec2 = vec2(); +const xvup____: vec2 = vec2(); +const xvfp____: vec2 = vec2(); +const xmfp____: mat2x2f = mat2x2(vec2(), vec2()); + const xmfpaiaiaiai: mat2x2 = mat2x2(1, 2, 3, 4); const xmfpafaiaiai: mat2x2 = mat2x2(1.0, 2, 3, 4); const xmfpaiafaiai: mat2x2 = mat2x2(1, 2.0, 3, 4); @@ -41,9 +49,15 @@ const ivfs_af = vec2(1.0); const iafafaf = array(1.0, 2.0); const iafaiai = array(1, 2); -const iafpafaf = array(1.0, 2.0); -const iafpaiaf = array(1, 2.0); +const iaipaiai = array(1, 2); +const iafpaiaf = array(1, 2.0); const iafpafai = array(1.0, 2); +const iafpafaf = array(1.0, 2.0); + +const xaipaiai: array = array(1, 2); +const xaupaiai: array = array(1, 2); +const xafpaiaf: array = array(1, 2.0); +const xafpafai: array = array(1.0, 2); const xafpafaf: array = array(1.0, 2.0); struct S { @@ -61,6 +75,11 @@ const saf_iai: S = S(1.0, 1i, 1); const safai_u: S = S(1.0, 1, 1u); const safaiai: S = S(1.0, 1, 1); +const xvisai: vec2 = vec2(1); +const xvusai: vec2 = vec2(1); +const xvfsai: vec2 = vec2(1); +const xvfsaf: vec2 = vec2(1.0); + // Vector construction with spreads const ivfr_f__f = vec3(vec2(1.0f, 2.0f), 3.0f); const ivfr_f_af = vec3(vec2(1.0f, 2.0f), 3.0 ); diff --git a/naga/tests/in/wgsl/abstract-types-let.toml b/naga/tests/in/wgsl/abstract-types-let.toml new file mode 100644 index 000000000..881b2333f --- /dev/null +++ b/naga/tests/in/wgsl/abstract-types-let.toml @@ -0,0 +1 @@ +targets = "SPIRV | METAL | GLSL | WGSL" diff --git a/naga/tests/in/wgsl/abstract-types-let.wgsl b/naga/tests/in/wgsl/abstract-types-let.wgsl new file mode 100644 index 000000000..667f11513 --- /dev/null +++ b/naga/tests/in/wgsl/abstract-types-let.wgsl @@ -0,0 +1,115 @@ +// i/x: type inferred / explicit +// vX/mX/aX: vector / matrix / array of X +// where X: u/i/f: u32 / i32 / f32 +// s: vector splat +// r: vector spread (vector arg to vector constructor) +// p: "partial" constructor (type parameter inferred) +// u/i/f/ai/af: u32 / i32 / f32 / abstract float / abstract integer as parameter +// _: just for alignment + +// Ensure that: +// - the inferred type is correct. +// - all parameters' types are considered. +// - all parameters are converted to the consensus type. + +fn all_constant_arguments() { + let xvipaiai: vec2 = vec2(42, 43); + let xvupaiai: vec2 = vec2(44, 45); + let xvfpaiai: vec2 = vec2(46, 47); + let xvfpafaf: vec2 = vec2(48.0, 49.0); + let xvfpaiaf: vec2 = vec2(48, 49.0); + + let xvupuai: vec2 = vec2(42u, 43); + let xvupaiu: vec2 = vec2(42, 43u); + + let xvuuai: vec2 = vec2(42u, 43); + let xvuaiu: vec2 = vec2(42, 43u); + + let xvip____: vec2 = vec2(); + let xvup____: vec2 = vec2(); + let xvfp____: vec2 = vec2(); + let xmfp____: mat2x2f = mat2x2(vec2(), vec2()); + + let xmfpaiaiaiai: mat2x2 = mat2x2(1, 2, 3, 4); + let xmfpafaiaiai: mat2x2 = mat2x2(1.0, 2, 3, 4); + let xmfpaiafaiai: mat2x2 = mat2x2(1, 2.0, 3, 4); + let xmfpaiaiafai: mat2x2 = mat2x2(1, 2, 3.0, 4); + let xmfpaiaiaiaf: mat2x2 = mat2x2(1, 2, 3, 4.0); + + let xmfp_faiaiai: mat2x2 = mat2x2(1.0f, 2, 3, 4); + let xmfpai_faiai: mat2x2 = mat2x2(1, 2.0f, 3, 4); + let xmfpaiai_fai: mat2x2 = mat2x2(1, 2, 3.0f, 4); + let xmfpaiaiai_f: mat2x2 = mat2x2(1, 2, 3, 4.0f); + + let xvispai: vec2 = vec2(1); + let xvfspaf: vec2 = vec2(1.0); + let xvis_ai: vec2 = vec2(1); + let xvus_ai: vec2 = vec2(1); + let xvfs_ai: vec2 = vec2(1); + let xvfs_af: vec2 = vec2(1.0); + + let xafafaf: array = array(1.0, 2.0); + let xaf_faf: array = array(1.0f, 2.0); + let xafaf_f: array = array(1.0, 2.0f); + let xafaiai: array = array(1, 2); + let xai_iai: array = array(1i, 2); + let xaiai_i: array = array(1, 2i); + + let xaipaiai: array = array(1, 2); + let xafpaiai: array = array(1, 2); + let xafpaiaf: array = array(1, 2.0); + let xafpafai: array = array(1.0, 2); + let xafpafaf: array = array(1.0, 2.0); + + let xavipai: array, 1> = array(vec3(1)); + let xavfpai: array, 1> = array(vec3(1)); + let xavfpaf: array, 1> = array(vec3(1.0)); + + // Construction with splats + let xvisai: vec2 = vec2(1); + let xvusai: vec2 = vec2(1); + let xvfsai: vec2 = vec2(1); + let xvfsaf: vec2 = vec2(1.0); + + let iaipaiai = array(1, 2); + let iafpaiaf = array(1, 2.0); + let iafpafai = array(1.0, 2); + let iafpafaf = array(1.0, 2.0); +} + +fn mixed_constant_and_runtime_arguments() { + var u: u32; + var i: i32; + var f: f32; + + let xvupuai: vec2 = vec2(u, 43); + let xvupaiu: vec2 = vec2(42, u); + let xvfpfai: vec2 = vec2(f, 47); // differs slightly from const version + let xvfpfaf: vec2 = vec2(f, 49.0); + + let xvuuai: vec2 = vec2(u, 43); + let xvuaiu: vec2 = vec2(42, u); + + let xmfp_faiaiai: mat2x2 = mat2x2(f, 2, 3, 4); + let xmfpai_faiai: mat2x2 = mat2x2(1, f, 3, 4); + let xmfpaiai_fai: mat2x2 = mat2x2(1, 2, f, 4); + let xmfpaiaiai_f: mat2x2 = mat2x2(1, 2, 3, f); + + let xaf_faf: array = array(f, 2.0); + let xafaf_f: array = array(1.0, f); + let xaf_fai: array = array(f, 2); + let xafai_f: array = array(1, f); + let xai_iai: array = array(i, 2); + let xaiai_i: array = array(1, i); + + let xafp_faf: array = array(f, 2.0); + let xafpaf_f: array = array(1.0, f); + let xafp_fai: array = array(f, 2); + let xafpai_f: array = array(1, f); + let xaip_iai: array = array(i, 2); + let xaipai_i: array = array(1, i); + + let xvisi: vec2 = vec2(i); + let xvusu: vec2 = vec2(u); + let xvfsf: vec2 = vec2(f); +} diff --git a/naga/tests/in/wgsl/abstract-types-var.wgsl b/naga/tests/in/wgsl/abstract-types-var.wgsl index e12a14b37..8820431da 100644 --- a/naga/tests/in/wgsl/abstract-types-var.wgsl +++ b/naga/tests/in/wgsl/abstract-types-var.wgsl @@ -15,6 +15,8 @@ var xvipaiai: vec2 = vec2(42, 43); var xvupaiai: vec2 = vec2(44, 45); var xvfpaiai: vec2 = vec2(46, 47); +var xvfpafaf: vec2 = vec2(48.0, 49.0); +var xvfpaiaf: vec2 = vec2(48, 49.0); var xvupuai: vec2 = vec2(42u, 43); var xvupaiu: vec2 = vec2(42, 43u); @@ -22,6 +24,11 @@ var xvupaiu: vec2 = vec2(42, 43u); var xvuuai: vec2 = vec2(42u, 43); var xvuaiu: vec2 = vec2(42, 43u); +var xvip____: vec2 = vec2(); +var xvup____: vec2 = vec2(); +var xvfp____: vec2 = vec2(); +var xmfp____: mat2x2f = mat2x2(vec2(), vec2()); + var xmfpaiaiaiai: mat2x2 = mat2x2(1, 2, 3, 4); var xmfpafaiaiai: mat2x2 = mat2x2(1.0, 2, 3, 4); var xmfpaiafaiai: mat2x2 = mat2x2(1, 2.0, 3, 4); @@ -38,7 +45,8 @@ var xvfs_af: vec2 = vec2(1.0); var xafafaf: array = array(1.0, 2.0); var xafaiai: array = array(1, 2); -var xafpaiai: array = array(1, 2); +var xaipaiai: array = array(1, 2); +var xaupaiai: array = array(1, 2); var xafpaiaf: array = array(1, 2.0); var xafpafai: array = array(1.0, 2); var xafpafaf: array = array(1.0, 2.0); @@ -47,6 +55,12 @@ var xavipai: array, 1> = array(vec3(1)); var xavfpai: array, 1> = array(vec3(1)); var xavfpaf: array, 1> = array(vec3(1.0)); +// Construction with splats +var xvisai: vec2 = vec2(1); +var xvusai: vec2 = vec2(1); +var xvfsai: vec2 = vec2(1); +var xvfsaf: vec2 = vec2(1.0); + var ivispai = vec2(1); var ivfspaf = vec2(1.0); var ivis_ai = vec2(1); @@ -70,6 +84,8 @@ fn all_constant_arguments() { var xvipaiai: vec2 = vec2(42, 43); var xvupaiai: vec2 = vec2(44, 45); var xvfpaiai: vec2 = vec2(46, 47); + var xvfpafaf: vec2 = vec2(48.0, 49.0); + var xvfpaiaf: vec2 = vec2(48, 49.0); var xvupuai: vec2 = vec2(42u, 43); var xvupaiu: vec2 = vec2(42, 43u); @@ -77,6 +93,11 @@ fn all_constant_arguments() { var xvuuai: vec2 = vec2(42u, 43); var xvuaiu: vec2 = vec2(42, 43u); + var xvip____: vec2 = vec2(); + var xvup____: vec2 = vec2(); + var xvfp____: vec2 = vec2(); + var xmfp____: mat2x2f = mat2x2(vec2(), vec2()); + var xmfpaiaiaiai: mat2x2 = mat2x2(1, 2, 3, 4); var xmfpafaiaiai: mat2x2 = mat2x2(1.0, 2, 3, 4); var xmfpaiafaiai: mat2x2 = mat2x2(1, 2.0, 3, 4); @@ -112,6 +133,12 @@ fn all_constant_arguments() { var xavfpai: array, 1> = array(vec3(1)); var xavfpaf: array, 1> = array(vec3(1.0)); + // Construction with splats + var xvisai: vec2 = vec2(1); + var xvusai: vec2 = vec2(1); + var xvfsai: vec2 = vec2(1); + var xvfsaf: vec2 = vec2(1.0); + var iaipaiai = array(1, 2); var iafpaiaf = array(1, 2.0); var iafpafai = array(1.0, 2); @@ -121,6 +148,8 @@ fn all_constant_arguments() { xvipaiai = vec2(42, 43); xvupaiai = vec2(44, 45); xvfpaiai = vec2(46, 47); + xvfpafaf = vec2(48.0, 49.0); + xvfpaiaf = vec2(48, 49.0); xvupuai = vec2(42u, 43); xvupaiu = vec2(42, 43u); @@ -128,6 +157,11 @@ fn all_constant_arguments() { xvuuai = vec2(42u, 43); xvuaiu = vec2(42, 43u); + xvip____ = vec2(); + xvup____ = vec2(); + xvfp____ = vec2(); + xmfp____ = mat2x2(vec2(), vec2()); + xmfpaiaiaiai = mat2x2(1, 2, 3, 4); xmfpafaiaiai = mat2x2(1.0, 2, 3, 4); xmfpaiafaiai = mat2x2(1, 2.0, 3, 4); @@ -163,6 +197,12 @@ fn all_constant_arguments() { xavfpai = array(vec3(1)); xavfpaf = array(vec3(1.0)); + // Construction with splats + xvisai = vec2(1); + xvusai = vec2(1); + xvfsai = vec2(1); + xvfsaf = vec2(1.0); + iaipaiai = array(1, 2); iafpaiaf = array(1, 2.0); iafpafai = array(1.0, 2); @@ -176,6 +216,8 @@ fn mixed_constant_and_runtime_arguments() { var xvupuai: vec2 = vec2(u, 43); var xvupaiu: vec2 = vec2(42, u); + var xvfpfai: vec2 = vec2(f, 47); // differs slightly from const version + var xvfpfaf: vec2 = vec2(f, 49.0); var xvuuai: vec2 = vec2(u, 43); var xvuaiu: vec2 = vec2(42, u); @@ -199,6 +241,10 @@ fn mixed_constant_and_runtime_arguments() { var xaip_iai: array = array(i, 2); var xaipai_i: array = array(1, i); + var xvisi: vec2 = vec2(i); + var xvusu: vec2 = vec2(u); + var xvfsf: vec2 = vec2(f); + // Assignments to all of the above. xvupuai = vec2(u, 43); xvupaiu = vec2(42, u); @@ -224,4 +270,8 @@ fn mixed_constant_and_runtime_arguments() { xafpai_f = array(1, f); xaip_iai = array(i, 2); xaipai_i = array(1, i); + + xvisi = vec2(i); + xvusu = vec2(u); + xvfsf = vec2(f); } diff --git a/naga/tests/in/wgsl/constructors.wgsl b/naga/tests/in/wgsl/constructors.wgsl index 8157ebbf8..6033c1921 100644 --- a/naga/tests/in/wgsl/constructors.wgsl +++ b/naga/tests/in/wgsl/constructors.wgsl @@ -3,7 +3,7 @@ struct Foo { b: i32, } -// const const1 = vec3(0.0); // TODO: this is now a splat and we need to const eval it +const const1 = vec3(0.0); const const2 = vec3(0.0, 1.0, 2.0); const const3 = mat2x2(0.0, 1.0, 2.0, 3.0); const const4 = array, 1>(mat2x2(0.0, 1.0, 2.0, 3.0)); @@ -19,9 +19,8 @@ const cz6 = array(); const cz7 = Foo(); // constructors that infer their type from their parameters -// TODO: these also contain splats -// const cp1 = vec2(0u); -// const cp2 = mat2x2(vec2(0.), vec2(0.)); +const cp1 = vec2(0u); +const cp2 = mat2x2(vec2(0.), vec2(0.)); const cp3 = array(0, 1, 2, 3); @compute @workgroup_size(1) @@ -49,6 +48,8 @@ fn main() { let zvc5 = mat2x2(); let zvc6 = array(); let zvc7 = Foo(); + let zvc8: vec2 = vec2(); + let zvc9: vec2 = vec2(); // constructors that infer their type from their parameters let cit0 = vec2(0u); diff --git a/naga/tests/in/wgsl/conversions.wgsl b/naga/tests/in/wgsl/conversions.wgsl new file mode 100644 index 000000000..1209236a7 --- /dev/null +++ b/naga/tests/in/wgsl/conversions.wgsl @@ -0,0 +1,16 @@ +// Conversion of initializer expressions +// (the abstract-types-* tests have a bunch more like this) +const ic0: vec2f = vec2(1, 1) + vec2(1.0, 1.0); + +// Conversion by value constructors +//let vc0 = i32(1.0); // https://github.com/gfx-rs/wgpu/issues/7312 +// etc. (also create the locals versions below) + +@compute @workgroup_size(1) +fn main() { + const ic0: vec2f = vec2(1, 1) + vec2(1.0, 1.0); + + let lc0: vec2f = vec2(1, 1) + vec2(1.0, 1.0); + + var vc0: vec2f = vec2(1, 1) + vec2(1.0, 1.0); +} diff --git a/naga/tests/in/wgsl/type-inference.wgsl b/naga/tests/in/wgsl/type-inference.wgsl new file mode 100644 index 000000000..627445793 --- /dev/null +++ b/naga/tests/in/wgsl/type-inference.wgsl @@ -0,0 +1,64 @@ +const g0 = 1; +const g1 = 1u; +const g2 = 1.0; +const g3 = 1.0f; +const g4 = vec4(); +const g5 = vec4(1i); +const g6 = mat2x2(vec2(), vec2()); +const g7 = mat2x2(vec2(1.0, 1), vec2(1, 1)); + +@compute @workgroup_size(1) +fn main() { + // Expose some constants that wouldn't otherwise be in the output + // because they don't have concrete types. + var g0x = g0; + var g2x = g2; + var g7x = g7; + + const c0 = 1; + const c1 = 1u; + const c2 = 1.0; + const c3 = 1.0f; + const c4 = vec4(); + const c5 = vec4(1i); + const c6 = mat2x2(vec2(), vec2()); + const c7 = mat2x2(vec2(1.0, 1), vec2(1, 1)); + + // Local constants are not emitted in most cases. + // See logic for `Statement::Emit` in `back::wgsl::Writer::write_stmt`. + var c0x = c0; + var c1x = c1; + var c2x = c2; + var c3x = c3; + var c4x = c4; + var c5x = c5; + var c6x = c6; + var c7x = c7; + + let l0 = 1; + let l1 = 1u; + let l2 = 1.0; + let l3 = 1.0f; + let l4 = vec4(); + let l5 = vec4(1i); + let l6 = mat2x2(vec2(), vec2()); + let l7 = mat2x2(vec2(1.0, 1), vec2(1, 1)); + + // Let bindings that evaluate to literals or a `ZeroValue` expression are + // not emitted. See `ConstantEvaluator::append_expr`. `vec4(1i)` is emitted + // because it is translated to a `Splat` expression. + var l0x = l0; + var l1x = l1; + var l2x = l2; + var l3x = l3; + var l4x = l4; + + var v0 = 1; + var v1 = 1u; + var v2 = 1.0; + var v3 = 1.0f; + var v4 = vec4(); + var v5 = vec4(1i); + var v6 = mat2x2(vec2(), vec2()); + var v7 = mat2x2(vec2(1.0, 1), vec2(1, 1)); +} diff --git a/naga/tests/naga/wgsl_errors.rs b/naga/tests/naga/wgsl_errors.rs index 3f649c601..56133cbed 100644 --- a/naga/tests/naga/wgsl_errors.rs +++ b/naga/tests/naga/wgsl_errors.rs @@ -202,14 +202,14 @@ fn type_not_inferable() { check( r#" fn x() { - _ = vec2(); + _ = mat2x2(); } "#, r#"error: type can't be inferred ┌─ wgsl:3:21 │ -3 │ _ = vec2(); - │ ^^^^ type can't be inferred +3 │ _ = mat2x2(); + │ ^^^^^^ type can't be inferred "#, ); diff --git a/naga/tests/out/glsl/constructors.main.Compute.glsl b/naga/tests/out/glsl/constructors.main.Compute.glsl index ef31b76d9..baa772e5b 100644 --- a/naga/tests/out/glsl/constructors.main.Compute.glsl +++ b/naga/tests/out/glsl/constructors.main.Compute.glsl @@ -9,6 +9,7 @@ struct Foo { vec4 a; int b; }; +const vec3 const1_ = vec3(0.0); const mat2x2 const3_ = mat2x2(vec2(0.0, 1.0), vec2(2.0, 3.0)); const mat2x2 const4_[1] = mat2x2[1](mat2x2(vec2(0.0, 1.0), vec2(2.0, 3.0))); const bool cz0_ = false; @@ -19,6 +20,7 @@ const uvec2 cz4_ = uvec2(0u); const mat2x2 cz5_ = mat2x2(0.0); const Foo cz6_[3] = Foo[3](Foo(vec4(0.0), 0), Foo(vec4(0.0), 0), Foo(vec4(0.0), 0)); const Foo cz7_ = Foo(vec4(0.0), 0); +const uvec2 cp1_ = uvec2(0u); void main() { @@ -26,6 +28,8 @@ void main() { foo = Foo(vec4(1.0), 1); mat2x2 m0_ = mat2x2(vec2(1.0, 0.0), vec2(0.0, 1.0)); mat4x4 m1_ = mat4x4(vec4(1.0, 0.0, 0.0, 0.0), vec4(0.0, 1.0, 0.0, 0.0), vec4(0.0, 0.0, 1.0, 0.0), vec4(0.0, 0.0, 0.0, 1.0)); + uvec2 zvc8_ = uvec2(0u, 0u); + vec2 zvc9_ = vec2(0.0, 0.0); uvec2 cit0_ = uvec2(0u); mat2x2 cit1_ = mat2x2(vec2(0.0), vec2(0.0)); int cit2_[4] = int[4](0, 1, 2, 3); diff --git a/naga/tests/out/glsl/conversions.main.Compute.glsl b/naga/tests/out/glsl/conversions.main.Compute.glsl new file mode 100644 index 000000000..99f739cd6 --- /dev/null +++ b/naga/tests/out/glsl/conversions.main.Compute.glsl @@ -0,0 +1,16 @@ +#version 310 es + +precision highp float; +precision highp int; + +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +const vec2 ic0_ = vec2(2.0, 2.0); + + +void main() { + vec2 vc0_ = vec2(2.0, 2.0); + vec2 lc0_ = vec2(2.0, 2.0); + return; +} + diff --git a/naga/tests/out/glsl/type-inference.main.Compute.glsl b/naga/tests/out/glsl/type-inference.main.Compute.glsl new file mode 100644 index 000000000..08c9f63e3 --- /dev/null +++ b/naga/tests/out/glsl/type-inference.main.Compute.glsl @@ -0,0 +1,50 @@ +#version 310 es + +precision highp float; +precision highp int; + +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +const uint g1_ = 1u; +const float g3_ = 1.0; +const ivec4 g4_ = ivec4(0); +const ivec4 g5_ = ivec4(1); +const mat2x2 g6_ = mat2x2(vec2(0.0, 0.0), vec2(0.0, 0.0)); + + +void main() { + int g0x = 1; + float g2x = 1.0; + mat2x2 g7x = mat2x2(vec2(1.0, 1.0), vec2(1.0, 1.0)); + int c0x = 1; + uint c1x = 1u; + float c2x = 1.0; + float c3x = 1.0; + ivec4 c4x = ivec4(0); + ivec4 c5x = ivec4(1); + mat2x2 c6x = mat2x2(vec2(0.0, 0.0), vec2(0.0, 0.0)); + mat2x2 c7x = mat2x2(vec2(1.0, 1.0), vec2(1.0, 1.0)); + int l0x = 0; + uint l1x = 0u; + float l2x = 0.0; + float l3x = 0.0; + ivec4 l4x = ivec4(0); + int v0_ = 1; + uint v1_ = 1u; + float v2_ = 1.0; + float v3_ = 1.0; + ivec4 v4_ = ivec4(0); + ivec4 v5_ = ivec4(1); + mat2x2 v6_ = mat2x2(vec2(0.0, 0.0), vec2(0.0, 0.0)); + mat2x2 v7_ = mat2x2(vec2(1.0, 1.0), vec2(1.0, 1.0)); + ivec4 l5_ = ivec4(1); + mat2x2 l6_ = mat2x2(vec2(0.0, 0.0), vec2(0.0, 0.0)); + mat2x2 l7_ = mat2x2(vec2(1.0, 1.0), vec2(1.0, 1.0)); + l0x = 1; + l1x = 1u; + l2x = 1.0; + l3x = 1.0; + l4x = ivec4(0); + return; +} + diff --git a/naga/tests/out/hlsl/constructors.hlsl b/naga/tests/out/hlsl/constructors.hlsl index e21548b7a..31cc241e2 100644 --- a/naga/tests/out/hlsl/constructors.hlsl +++ b/naga/tests/out/hlsl/constructors.hlsl @@ -45,6 +45,7 @@ Foo ZeroValueFoo() { return (Foo)0; } +static const float3 const1_ = (0.0).xxx; static const float2x2 const3_ = float2x2(float2(0.0, 1.0), float2(2.0, 3.0)); static const float2x2 const4_[1] = Constructarray1_float2x2_(float2x2(float2(0.0, 1.0), float2(2.0, 3.0))); static const bool cz0_ = ZeroValuebool(); @@ -55,6 +56,7 @@ static const uint2 cz4_ = ZeroValueuint2(); static const float2x2 cz5_ = ZeroValuefloat2x2(); static const Foo cz6_[3] = ZeroValuearray3_Foo_(); static const Foo cz7_ = ZeroValueFoo(); +static const uint2 cp1_ = (0u).xx; Foo ConstructFoo(float4 arg0, int arg1) { Foo ret = (Foo)0; @@ -81,6 +83,8 @@ void main() foo = ConstructFoo((1.0).xxxx, int(1)); float2x2 m0_ = float2x2(float2(1.0, 0.0), float2(0.0, 1.0)); float4x4 m1_ = float4x4(float4(1.0, 0.0, 0.0, 0.0), float4(0.0, 1.0, 0.0, 0.0), float4(0.0, 0.0, 1.0, 0.0), float4(0.0, 0.0, 0.0, 1.0)); + uint2 zvc8_ = uint2(0u, 0u); + float2 zvc9_ = float2(0.0, 0.0); uint2 cit0_ = (0u).xx; float2x2 cit1_ = float2x2((0.0).xx, (0.0).xx); int cit2_[4] = Constructarray4_int_(int(0), int(1), int(2), int(3)); diff --git a/naga/tests/out/hlsl/conversions.hlsl b/naga/tests/out/hlsl/conversions.hlsl new file mode 100644 index 000000000..97b1c74df --- /dev/null +++ b/naga/tests/out/hlsl/conversions.hlsl @@ -0,0 +1,10 @@ +static const float2 ic0_ = float2(2.0, 2.0); + +[numthreads(1, 1, 1)] +void main() +{ + float2 vc0_ = float2(2.0, 2.0); + + float2 lc0_ = float2(2.0, 2.0); + return; +} diff --git a/naga/tests/out/hlsl/conversions.ron b/naga/tests/out/hlsl/conversions.ron new file mode 100644 index 000000000..a07b03300 --- /dev/null +++ b/naga/tests/out/hlsl/conversions.ron @@ -0,0 +1,12 @@ +( + vertex:[ + ], + fragment:[ + ], + compute:[ + ( + entry_point:"main", + target_profile:"cs_5_1", + ), + ], +) diff --git a/naga/tests/out/hlsl/type-inference.hlsl b/naga/tests/out/hlsl/type-inference.hlsl new file mode 100644 index 000000000..400b6f32f --- /dev/null +++ b/naga/tests/out/hlsl/type-inference.hlsl @@ -0,0 +1,48 @@ +int4 ZeroValueint4() { + return (int4)0; +} + +static const uint g1_ = 1u; +static const float g3_ = 1.0; +static const int4 g4_ = ZeroValueint4(); +static const int4 g5_ = (int(1)).xxxx; +static const float2x2 g6_ = float2x2(float2(0.0, 0.0), float2(0.0, 0.0)); + +[numthreads(1, 1, 1)] +void main() +{ + int g0x = int(1); + float g2x = 1.0; + float2x2 g7x = float2x2(float2(1.0, 1.0), float2(1.0, 1.0)); + int c0x = int(1); + uint c1x = 1u; + float c2x = 1.0; + float c3x = 1.0; + int4 c4x = ZeroValueint4(); + int4 c5x = (int(1)).xxxx; + float2x2 c6x = float2x2(float2(0.0, 0.0), float2(0.0, 0.0)); + float2x2 c7x = float2x2(float2(1.0, 1.0), float2(1.0, 1.0)); + int l0x = (int)0; + uint l1x = (uint)0; + float l2x = (float)0; + float l3x = (float)0; + int4 l4x = (int4)0; + int v0_ = int(1); + uint v1_ = 1u; + float v2_ = 1.0; + float v3_ = 1.0; + int4 v4_ = ZeroValueint4(); + int4 v5_ = (int(1)).xxxx; + float2x2 v6_ = float2x2(float2(0.0, 0.0), float2(0.0, 0.0)); + float2x2 v7_ = float2x2(float2(1.0, 1.0), float2(1.0, 1.0)); + + int4 l5_ = (int(1)).xxxx; + float2x2 l6_ = float2x2(float2(0.0, 0.0), float2(0.0, 0.0)); + float2x2 l7_ = float2x2(float2(1.0, 1.0), float2(1.0, 1.0)); + l0x = int(1); + l1x = 1u; + l2x = 1.0; + l3x = 1.0; + l4x = ZeroValueint4(); + return; +} diff --git a/naga/tests/out/hlsl/type-inference.ron b/naga/tests/out/hlsl/type-inference.ron new file mode 100644 index 000000000..a07b03300 --- /dev/null +++ b/naga/tests/out/hlsl/type-inference.ron @@ -0,0 +1,12 @@ +( + vertex:[ + ], + fragment:[ + ], + compute:[ + ( + entry_point:"main", + target_profile:"cs_5_1", + ), + ], +) diff --git a/naga/tests/out/msl/abstract-types-const.msl b/naga/tests/out/msl/abstract-types-const.msl index 35efedb44..69463268c 100644 --- a/naga/tests/out/msl/abstract-types-const.msl +++ b/naga/tests/out/msl/abstract-types-const.msl @@ -7,17 +7,30 @@ using metal::uint; struct type_7 { float inner[2]; }; +struct type_8 { + int inner[2]; +}; +struct type_9 { + uint inner[2]; +}; struct S { float f; int i; uint u; }; -constant metal::uint2 xvupaiai = metal::uint2(42u, 43u); -constant metal::float2 xvfpaiai = metal::float2(44.0, 45.0); +constant metal::int2 xvipaiai = metal::int2(42, 43); +constant metal::uint2 xvupaiai = metal::uint2(44u, 45u); +constant metal::float2 xvfpaiai = metal::float2(46.0, 47.0); +constant metal::float2 xvfpafaf = metal::float2(48.0, 49.0); +constant metal::float2 xvfpaiaf = metal::float2(48.0, 49.0); constant metal::uint2 xvupuai = metal::uint2(42u, 43u); constant metal::uint2 xvupaiu = metal::uint2(42u, 43u); constant metal::uint2 xvuuai = metal::uint2(42u, 43u); constant metal::uint2 xvuaiu = metal::uint2(42u, 43u); +constant metal::int2 xvip = metal::int2(0, 0); +constant metal::uint2 xvup = metal::uint2(0u, 0u); +constant metal::float2 xvfp = metal::float2(0.0, 0.0); +constant metal::float2x2 xmfp = metal::float2x2(metal::float2(0.0, 0.0), metal::float2(0.0, 0.0)); constant metal::float2x2 xmfpaiaiaiai = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(3.0, 4.0)); constant metal::float2x2 xmfpafaiaiai = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(3.0, 4.0)); constant metal::float2x2 xmfpaiafaiai = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(3.0, 4.0)); @@ -29,6 +42,10 @@ constant metal::float2 ivfs_ai = metal::float2(1.0); constant metal::float2 ivfs_af = metal::float2(1.0); constant type_7 iafafaf = type_7 {1.0, 2.0}; constant type_7 iafaiai = type_7 {1.0, 2.0}; +constant type_8 xaipaiai = type_8 {1, 2}; +constant type_9 xaupaiai = type_9 {1u, 2u}; +constant type_7 xafpaiaf = type_7 {1.0, 2.0}; +constant type_7 xafpafai = type_7 {1.0, 2.0}; constant type_7 xafpafaf = type_7 {1.0, 2.0}; constant S s_f_i_u = S {1.0, 1, 1u}; constant S s_f_iai = S {1.0, 1, 1u}; @@ -38,6 +55,10 @@ constant S saf_i_u = S {1.0, 1, 1u}; constant S saf_iai = S {1.0, 1, 1u}; constant S safai_u = S {1.0, 1, 1u}; constant S safaiai = S {1.0, 1, 1u}; +constant metal::int2 xvisai = metal::int2(1); +constant metal::uint2 xvusai = metal::uint2(1u); +constant metal::float2 xvfsai = metal::float2(1.0); +constant metal::float2 xvfsaf = metal::float2(1.0); constant metal::float3 ivfr_f_f = metal::float3(metal::float2(1.0, 2.0), 3.0); constant metal::float3 ivfr_f_af = metal::float3(metal::float2(1.0, 2.0), 3.0); constant metal::float3 ivfraf_f = metal::float3(metal::float2(1.0, 2.0), 3.0); diff --git a/naga/tests/out/msl/abstract-types-let.msl b/naga/tests/out/msl/abstract-types-let.msl new file mode 100644 index 000000000..4c89b8e6b --- /dev/null +++ b/naga/tests/out/msl/abstract-types-let.msl @@ -0,0 +1,131 @@ +// language: metal1.0 +#include +#include + +using metal::uint; + +struct type_7 { + float inner[2]; +}; +struct type_8 { + int inner[2]; +}; +struct type_10 { + metal::int3 inner[1]; +}; +struct type_12 { + metal::float3 inner[1]; +}; + +void all_constant_arguments( +) { + metal::int2 xvipaiai = metal::int2(42, 43); + metal::uint2 xvupaiai = metal::uint2(44u, 45u); + metal::float2 xvfpaiai = metal::float2(46.0, 47.0); + metal::float2 xvfpafaf = metal::float2(48.0, 49.0); + metal::float2 xvfpaiaf = metal::float2(48.0, 49.0); + metal::uint2 xvupuai = metal::uint2(42u, 43u); + metal::uint2 xvupaiu = metal::uint2(42u, 43u); + metal::uint2 xvuuai = metal::uint2(42u, 43u); + metal::uint2 xvuaiu = metal::uint2(42u, 43u); + metal::int2 xvip = metal::int2(0, 0); + metal::uint2 xvup = metal::uint2(0u, 0u); + metal::float2 xvfp = metal::float2(0.0, 0.0); + metal::float2x2 xmfp = metal::float2x2(metal::float2(0.0, 0.0), metal::float2(0.0, 0.0)); + metal::float2x2 xmfpaiaiaiai = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(3.0, 4.0)); + metal::float2x2 xmfpafaiaiai = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(3.0, 4.0)); + metal::float2x2 xmfpaiafaiai = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(3.0, 4.0)); + metal::float2x2 xmfpaiaiafai = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(3.0, 4.0)); + metal::float2x2 xmfpaiaiaiaf = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(3.0, 4.0)); + metal::float2x2 xmfp_faiaiai = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(3.0, 4.0)); + metal::float2x2 xmfpai_faiai = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(3.0, 4.0)); + metal::float2x2 xmfpaiai_fai = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(3.0, 4.0)); + metal::float2x2 xmfpaiaiai_f = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(3.0, 4.0)); + metal::int2 xvispai = metal::int2(1); + metal::float2 xvfspaf = metal::float2(1.0); + metal::int2 xvis_ai = metal::int2(1); + metal::uint2 xvus_ai = metal::uint2(1u); + metal::float2 xvfs_ai = metal::float2(1.0); + metal::float2 xvfs_af = metal::float2(1.0); + type_7 xafafaf = type_7 {1.0, 2.0}; + type_7 xaf_faf = type_7 {1.0, 2.0}; + type_7 xafaf_f = type_7 {1.0, 2.0}; + type_7 xafaiai = type_7 {1.0, 2.0}; + type_8 xai_iai = type_8 {1, 2}; + type_8 xaiai_i = type_8 {1, 2}; + type_8 xaipaiai = type_8 {1, 2}; + type_7 xafpaiai = type_7 {1.0, 2.0}; + type_7 xafpaiaf = type_7 {1.0, 2.0}; + type_7 xafpafai = type_7 {1.0, 2.0}; + type_7 xafpafaf = type_7 {1.0, 2.0}; + type_10 xavipai = type_10 {metal::int3(1)}; + type_12 xavfpai = type_12 {metal::float3(1.0)}; + type_12 xavfpaf = type_12 {metal::float3(1.0)}; + metal::int2 xvisai = metal::int2(1); + metal::uint2 xvusai = metal::uint2(1u); + metal::float2 xvfsai = metal::float2(1.0); + metal::float2 xvfsaf = metal::float2(1.0); + type_8 iaipaiai = type_8 {1, 2}; + type_7 iafpaiaf = type_7 {1.0, 2.0}; + type_7 iafpafai = type_7 {1.0, 2.0}; + type_7 iafpafaf = type_7 {1.0, 2.0}; + return; +} + +void mixed_constant_and_runtime_arguments( +) { + uint u = {}; + int i = {}; + float f = {}; + uint _e3 = u; + metal::uint2 xvupuai_1 = metal::uint2(_e3, 43u); + uint _e6 = u; + metal::uint2 xvupaiu_1 = metal::uint2(42u, _e6); + float _e9 = f; + metal::float2 xvfpfai = metal::float2(_e9, 47.0); + float _e12 = f; + metal::float2 xvfpfaf = metal::float2(_e12, 49.0); + uint _e15 = u; + metal::uint2 xvuuai_1 = metal::uint2(_e15, 43u); + uint _e18 = u; + metal::uint2 xvuaiu_1 = metal::uint2(42u, _e18); + float _e21 = f; + metal::float2x2 xmfp_faiaiai_1 = metal::float2x2(metal::float2(_e21, 2.0), metal::float2(3.0, 4.0)); + float _e28 = f; + metal::float2x2 xmfpai_faiai_1 = metal::float2x2(metal::float2(1.0, _e28), metal::float2(3.0, 4.0)); + float _e35 = f; + metal::float2x2 xmfpaiai_fai_1 = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(_e35, 4.0)); + float _e42 = f; + metal::float2x2 xmfpaiaiai_f_1 = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(3.0, _e42)); + float _e49 = f; + type_7 xaf_faf_1 = type_7 {_e49, 2.0}; + float _e52 = f; + type_7 xafaf_f_1 = type_7 {1.0, _e52}; + float _e55 = f; + type_7 xaf_fai = type_7 {_e55, 2.0}; + float _e58 = f; + type_7 xafai_f = type_7 {1.0, _e58}; + int _e61 = i; + type_8 xai_iai_1 = type_8 {_e61, 2}; + int _e64 = i; + type_8 xaiai_i_1 = type_8 {1, _e64}; + float _e67 = f; + type_7 xafp_faf = type_7 {_e67, 2.0}; + float _e70 = f; + type_7 xafpaf_f = type_7 {1.0, _e70}; + float _e73 = f; + type_7 xafp_fai = type_7 {_e73, 2.0}; + float _e76 = f; + type_7 xafpai_f = type_7 {1.0, _e76}; + int _e79 = i; + type_8 xaip_iai = type_8 {_e79, 2}; + int _e82 = i; + type_8 xaipai_i = type_8 {1, _e82}; + int _e85 = i; + metal::int2 xvisi = metal::int2(_e85); + uint _e87 = u; + metal::uint2 xvusu = metal::uint2(_e87); + float _e89 = f; + metal::float2 xvfsf = metal::float2(_e89); + return; +} diff --git a/naga/tests/out/msl/abstract-types-var.msl b/naga/tests/out/msl/abstract-types-var.msl index da88a396e..efb7998dd 100644 --- a/naga/tests/out/msl/abstract-types-var.msl +++ b/naga/tests/out/msl/abstract-types-var.msl @@ -10,10 +10,13 @@ struct type_7 { struct type_8 { int inner[2]; }; -struct type_10 { +struct type_9 { + uint inner[2]; +}; +struct type_11 { metal::int3 inner[1]; }; -struct type_12 { +struct type_13 { metal::float3 inner[1]; }; @@ -22,10 +25,16 @@ void all_constant_arguments( metal::int2 xvipaiai = metal::int2(42, 43); metal::uint2 xvupaiai = metal::uint2(44u, 45u); metal::float2 xvfpaiai = metal::float2(46.0, 47.0); + metal::float2 xvfpafaf = metal::float2(48.0, 49.0); + metal::float2 xvfpaiaf = metal::float2(48.0, 49.0); metal::uint2 xvupuai = metal::uint2(42u, 43u); metal::uint2 xvupaiu = metal::uint2(42u, 43u); metal::uint2 xvuuai = metal::uint2(42u, 43u); metal::uint2 xvuaiu = metal::uint2(42u, 43u); + metal::int2 xvip = metal::int2(0, 0); + metal::uint2 xvup = metal::uint2(0u, 0u); + metal::float2 xvfp = metal::float2(0.0, 0.0); + metal::float2x2 xmfp = metal::float2x2(metal::float2(0.0, 0.0), metal::float2(0.0, 0.0)); metal::float2x2 xmfpaiaiaiai = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(3.0, 4.0)); metal::float2x2 xmfpafaiaiai = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(3.0, 4.0)); metal::float2x2 xmfpaiafaiai = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(3.0, 4.0)); @@ -52,9 +61,13 @@ void all_constant_arguments( type_7 xafpaiaf = type_7 {1.0, 2.0}; type_7 xafpafai = type_7 {1.0, 2.0}; type_7 xafpafaf = type_7 {1.0, 2.0}; - type_10 xavipai = type_10 {metal::int3(1)}; - type_12 xavfpai = type_12 {metal::float3(1.0)}; - type_12 xavfpaf = type_12 {metal::float3(1.0)}; + type_11 xavipai = type_11 {metal::int3(1)}; + type_13 xavfpai = type_13 {metal::float3(1.0)}; + type_13 xavfpaf = type_13 {metal::float3(1.0)}; + metal::int2 xvisai = metal::int2(1); + metal::uint2 xvusai = metal::uint2(1u); + metal::float2 xvfsai = metal::float2(1.0); + metal::float2 xvfsaf = metal::float2(1.0); type_8 iaipaiai = type_8 {1, 2}; type_7 iafpaiaf = type_7 {1.0, 2.0}; type_7 iafpafai = type_7 {1.0, 2.0}; @@ -62,10 +75,16 @@ void all_constant_arguments( xvipaiai = metal::int2(42, 43); xvupaiai = metal::uint2(44u, 45u); xvfpaiai = metal::float2(46.0, 47.0); + xvfpafaf = metal::float2(48.0, 49.0); + xvfpaiaf = metal::float2(48.0, 49.0); xvupuai = metal::uint2(42u, 43u); xvupaiu = metal::uint2(42u, 43u); xvuuai = metal::uint2(42u, 43u); xvuaiu = metal::uint2(42u, 43u); + xvip = metal::int2(0, 0); + xvup = metal::uint2(0u, 0u); + xvfp = metal::float2(0.0, 0.0); + xmfp = metal::float2x2(metal::float2(0.0, 0.0), metal::float2(0.0, 0.0)); xmfpaiaiaiai = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(3.0, 4.0)); xmfpafaiaiai = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(3.0, 4.0)); xmfpaiafaiai = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(3.0, 4.0)); @@ -92,9 +111,13 @@ void all_constant_arguments( xafpaiaf = type_7 {1.0, 2.0}; xafpafai = type_7 {1.0, 2.0}; xafpafaf = type_7 {1.0, 2.0}; - xavipai = type_10 {metal::int3(1)}; - xavfpai = type_12 {metal::float3(1.0)}; - xavfpaf = type_12 {metal::float3(1.0)}; + xavipai = type_11 {metal::int3(1)}; + xavfpai = type_13 {metal::float3(1.0)}; + xavfpaf = type_13 {metal::float3(1.0)}; + xvisai = metal::int2(1); + xvusai = metal::uint2(1u); + xvfsai = metal::float2(1.0); + xvfsaf = metal::float2(1.0); iaipaiai = type_8 {1, 2}; iafpaiaf = type_7 {1.0, 2.0}; iafpafai = type_7 {1.0, 2.0}; @@ -109,6 +132,8 @@ void mixed_constant_and_runtime_arguments( float f = {}; metal::uint2 xvupuai_1 = {}; metal::uint2 xvupaiu_1 = {}; + metal::float2 xvfpfai = {}; + metal::float2 xvfpfaf = {}; metal::uint2 xvuuai_1 = {}; metal::uint2 xvuaiu_1 = {}; metal::float2x2 xmfp_faiaiai_1 = {}; @@ -127,85 +152,104 @@ void mixed_constant_and_runtime_arguments( type_7 xafpai_f = {}; type_8 xaip_iai = {}; type_8 xaipai_i = {}; + metal::int2 xvisi = {}; + metal::uint2 xvusu = {}; + metal::float2 xvfsf = {}; uint _e3 = u; xvupuai_1 = metal::uint2(_e3, 43u); uint _e7 = u; xvupaiu_1 = metal::uint2(42u, _e7); - uint _e11 = u; - xvuuai_1 = metal::uint2(_e11, 43u); - uint _e15 = u; - xvuaiu_1 = metal::uint2(42u, _e15); - float _e19 = f; - xmfp_faiaiai_1 = metal::float2x2(metal::float2(_e19, 2.0), metal::float2(3.0, 4.0)); + float _e11 = f; + xvfpfai = metal::float2(_e11, 47.0); + float _e15 = f; + xvfpfaf = metal::float2(_e15, 49.0); + uint _e19 = u; + xvuuai_1 = metal::uint2(_e19, 43u); + uint _e23 = u; + xvuaiu_1 = metal::uint2(42u, _e23); float _e27 = f; - xmfpai_faiai_1 = metal::float2x2(metal::float2(1.0, _e27), metal::float2(3.0, 4.0)); + xmfp_faiaiai_1 = metal::float2x2(metal::float2(_e27, 2.0), metal::float2(3.0, 4.0)); float _e35 = f; - xmfpaiai_fai_1 = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(_e35, 4.0)); + xmfpai_faiai_1 = metal::float2x2(metal::float2(1.0, _e35), metal::float2(3.0, 4.0)); float _e43 = f; - xmfpaiaiai_f_1 = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(3.0, _e43)); + xmfpaiai_fai_1 = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(_e43, 4.0)); float _e51 = f; - xaf_faf_1 = type_7 {_e51, 2.0}; - float _e55 = f; - xafaf_f_1 = type_7 {1.0, _e55}; + xmfpaiaiai_f_1 = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(3.0, _e51)); float _e59 = f; - xaf_fai = type_7 {_e59, 2.0}; + xaf_faf_1 = type_7 {_e59, 2.0}; float _e63 = f; - xafai_f = type_7 {1.0, _e63}; - int _e67 = i; - xai_iai_1 = type_8 {_e67, 2}; - int _e71 = i; - xaiai_i_1 = type_8 {1, _e71}; - float _e75 = f; - xafp_faf = type_7 {_e75, 2.0}; - float _e79 = f; - xafpaf_f = type_7 {1.0, _e79}; + xafaf_f_1 = type_7 {1.0, _e63}; + float _e67 = f; + xaf_fai = type_7 {_e67, 2.0}; + float _e71 = f; + xafai_f = type_7 {1.0, _e71}; + int _e75 = i; + xai_iai_1 = type_8 {_e75, 2}; + int _e79 = i; + xaiai_i_1 = type_8 {1, _e79}; float _e83 = f; - xafp_fai = type_7 {_e83, 2.0}; + xafp_faf = type_7 {_e83, 2.0}; float _e87 = f; - xafpai_f = type_7 {1.0, _e87}; - int _e91 = i; - xaip_iai = type_8 {_e91, 2}; - int _e95 = i; - xaipai_i = type_8 {1, _e95}; - uint _e99 = u; - xvupuai_1 = metal::uint2(_e99, 43u); - uint _e102 = u; - xvupaiu_1 = metal::uint2(42u, _e102); - uint _e105 = u; - xvuuai_1 = metal::uint2(_e105, 43u); - uint _e108 = u; - xvuaiu_1 = metal::uint2(42u, _e108); - float _e111 = f; - xmfp_faiaiai_1 = metal::float2x2(metal::float2(_e111, 2.0), metal::float2(3.0, 4.0)); - float _e118 = f; - xmfpai_faiai_1 = metal::float2x2(metal::float2(1.0, _e118), metal::float2(3.0, 4.0)); - float _e125 = f; - xmfpaiai_fai_1 = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(_e125, 4.0)); - float _e132 = f; - xmfpaiaiai_f_1 = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(3.0, _e132)); - float _e139 = f; - xaf_faf_1 = type_7 {_e139, 2.0}; + xafpaf_f = type_7 {1.0, _e87}; + float _e91 = f; + xafp_fai = type_7 {_e91, 2.0}; + float _e95 = f; + xafpai_f = type_7 {1.0, _e95}; + int _e99 = i; + xaip_iai = type_8 {_e99, 2}; + int _e103 = i; + xaipai_i = type_8 {1, _e103}; + int _e107 = i; + xvisi = metal::int2(_e107); + uint _e110 = u; + xvusu = metal::uint2(_e110); + float _e113 = f; + xvfsf = metal::float2(_e113); + uint _e116 = u; + xvupuai_1 = metal::uint2(_e116, 43u); + uint _e119 = u; + xvupaiu_1 = metal::uint2(42u, _e119); + uint _e122 = u; + xvuuai_1 = metal::uint2(_e122, 43u); + uint _e125 = u; + xvuaiu_1 = metal::uint2(42u, _e125); + float _e128 = f; + xmfp_faiaiai_1 = metal::float2x2(metal::float2(_e128, 2.0), metal::float2(3.0, 4.0)); + float _e135 = f; + xmfpai_faiai_1 = metal::float2x2(metal::float2(1.0, _e135), metal::float2(3.0, 4.0)); float _e142 = f; - xafaf_f_1 = type_7 {1.0, _e142}; - float _e145 = f; - xaf_fai = type_7 {_e145, 2.0}; - float _e148 = f; - xafai_f = type_7 {1.0, _e148}; - int _e151 = i; - xai_iai_1 = type_8 {_e151, 2}; - int _e154 = i; - xaiai_i_1 = type_8 {1, _e154}; - float _e157 = f; - xafp_faf = type_7 {_e157, 2.0}; - float _e160 = f; - xafpaf_f = type_7 {1.0, _e160}; - float _e163 = f; - xafp_fai = type_7 {_e163, 2.0}; - float _e166 = f; - xafpai_f = type_7 {1.0, _e166}; - int _e169 = i; - xaip_iai = type_8 {_e169, 2}; - int _e172 = i; - xaipai_i = type_8 {1, _e172}; + xmfpaiai_fai_1 = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(_e142, 4.0)); + float _e149 = f; + xmfpaiaiai_f_1 = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(3.0, _e149)); + float _e156 = f; + xaf_faf_1 = type_7 {_e156, 2.0}; + float _e159 = f; + xafaf_f_1 = type_7 {1.0, _e159}; + float _e162 = f; + xaf_fai = type_7 {_e162, 2.0}; + float _e165 = f; + xafai_f = type_7 {1.0, _e165}; + int _e168 = i; + xai_iai_1 = type_8 {_e168, 2}; + int _e171 = i; + xaiai_i_1 = type_8 {1, _e171}; + float _e174 = f; + xafp_faf = type_7 {_e174, 2.0}; + float _e177 = f; + xafpaf_f = type_7 {1.0, _e177}; + float _e180 = f; + xafp_fai = type_7 {_e180, 2.0}; + float _e183 = f; + xafpai_f = type_7 {1.0, _e183}; + int _e186 = i; + xaip_iai = type_8 {_e186, 2}; + int _e189 = i; + xaipai_i = type_8 {1, _e189}; + int _e192 = i; + xvisi = metal::int2(_e192); + uint _e194 = u; + xvusu = metal::uint2(_e194); + float _e196 = f; + xvfsf = metal::float2(_e196); return; } diff --git a/naga/tests/out/msl/constructors.msl b/naga/tests/out/msl/constructors.msl index 3e2c09622..a1d1c8a2e 100644 --- a/naga/tests/out/msl/constructors.msl +++ b/naga/tests/out/msl/constructors.msl @@ -8,25 +8,27 @@ struct Foo { metal::float4 a; int b; }; -struct type_5 { +struct type_6 { metal::float2x2 inner[1]; }; -struct type_9 { +struct type_10 { Foo inner[3]; }; -struct type_11 { +struct type_12 { int inner[4]; }; +constant metal::float3 const1_ = metal::float3(0.0); constant metal::float2x2 const3_ = metal::float2x2(metal::float2(0.0, 1.0), metal::float2(2.0, 3.0)); -constant type_5 const4_ = type_5 {metal::float2x2(metal::float2(0.0, 1.0), metal::float2(2.0, 3.0))}; +constant type_6 const4_ = type_6 {metal::float2x2(metal::float2(0.0, 1.0), metal::float2(2.0, 3.0))}; constant bool cz0_ = bool {}; constant int cz1_ = int {}; constant uint cz2_ = uint {}; constant float cz3_ = float {}; constant metal::uint2 cz4_ = metal::uint2 {}; constant metal::float2x2 cz5_ = metal::float2x2 {}; -constant type_9 cz6_ = type_9 {}; +constant type_10 cz6_ = type_10 {}; constant Foo cz7_ = Foo {}; +constant metal::uint2 cp1_ = metal::uint2(0u); kernel void main_( ) { @@ -34,9 +36,11 @@ kernel void main_( foo = Foo {metal::float4(1.0), 1}; metal::float2x2 m0_ = metal::float2x2(metal::float2(1.0, 0.0), metal::float2(0.0, 1.0)); metal::float4x4 m1_ = metal::float4x4(metal::float4(1.0, 0.0, 0.0, 0.0), metal::float4(0.0, 1.0, 0.0, 0.0), metal::float4(0.0, 0.0, 1.0, 0.0), metal::float4(0.0, 0.0, 0.0, 1.0)); + metal::uint2 zvc8_ = metal::uint2(0u, 0u); + metal::float2 zvc9_ = metal::float2(0.0, 0.0); metal::uint2 cit0_ = metal::uint2(0u); metal::float2x2 cit1_ = metal::float2x2(metal::float2(0.0), metal::float2(0.0)); - type_11 cit2_ = type_11 {0, 1, 2, 3}; + type_12 cit2_ = type_12 {0, 1, 2, 3}; metal::uint2 ic4_ = metal::uint2(0u, 0u); metal::float2x3 ic5_ = metal::float2x3(metal::float3(0.0, 0.0, 0.0), metal::float3(0.0, 0.0, 0.0)); return; diff --git a/naga/tests/out/msl/conversions.msl b/naga/tests/out/msl/conversions.msl new file mode 100644 index 000000000..9af4956b0 --- /dev/null +++ b/naga/tests/out/msl/conversions.msl @@ -0,0 +1,14 @@ +// language: metal1.0 +#include +#include + +using metal::uint; + +constant metal::float2 ic0_ = metal::float2(2.0, 2.0); + +kernel void main_( +) { + metal::float2 vc0_ = metal::float2(2.0, 2.0); + metal::float2 lc0_ = metal::float2(2.0, 2.0); + return; +} diff --git a/naga/tests/out/msl/type-inference.msl b/naga/tests/out/msl/type-inference.msl new file mode 100644 index 000000000..aa0b1ff8b --- /dev/null +++ b/naga/tests/out/msl/type-inference.msl @@ -0,0 +1,48 @@ +// language: metal1.0 +#include +#include + +using metal::uint; + +constant uint g1_ = 1u; +constant float g3_ = 1.0; +constant metal::int4 g4_ = metal::int4 {}; +constant metal::int4 g5_ = metal::int4(1); +constant metal::float2x2 g6_ = metal::float2x2(metal::float2(0.0, 0.0), metal::float2(0.0, 0.0)); + +kernel void main_( +) { + int g0x = 1; + float g2x = 1.0; + metal::float2x2 g7x = metal::float2x2(metal::float2(1.0, 1.0), metal::float2(1.0, 1.0)); + int c0x = 1; + uint c1x = 1u; + float c2x = 1.0; + float c3x = 1.0; + metal::int4 c4x = metal::int4 {}; + metal::int4 c5x = metal::int4(1); + metal::float2x2 c6x = metal::float2x2(metal::float2(0.0, 0.0), metal::float2(0.0, 0.0)); + metal::float2x2 c7x = metal::float2x2(metal::float2(1.0, 1.0), metal::float2(1.0, 1.0)); + int l0x = {}; + uint l1x = {}; + float l2x = {}; + float l3x = {}; + metal::int4 l4x = {}; + int v0_ = 1; + uint v1_ = 1u; + float v2_ = 1.0; + float v3_ = 1.0; + metal::int4 v4_ = metal::int4 {}; + metal::int4 v5_ = metal::int4(1); + metal::float2x2 v6_ = metal::float2x2(metal::float2(0.0, 0.0), metal::float2(0.0, 0.0)); + metal::float2x2 v7_ = metal::float2x2(metal::float2(1.0, 1.0), metal::float2(1.0, 1.0)); + metal::int4 l5_ = metal::int4(1); + metal::float2x2 l6_ = metal::float2x2(metal::float2(0.0, 0.0), metal::float2(0.0, 0.0)); + metal::float2x2 l7_ = metal::float2x2(metal::float2(1.0, 1.0), metal::float2(1.0, 1.0)); + l0x = 1; + l1x = 1u; + l2x = 1.0; + l3x = 1.0; + l4x = metal::int4 {}; + return; +} diff --git a/naga/tests/out/spv/abstract-types-const.spvasm b/naga/tests/out/spv/abstract-types-const.spvasm index af8cfb028..b1da55273 100644 --- a/naga/tests/out/spv/abstract-types-const.spvasm +++ b/naga/tests/out/spv/abstract-types-const.spvasm @@ -1,46 +1,69 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 36 +; Bound: 57 OpCapability Shader OpCapability Linkage %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpDecorate %10 ArrayStride 4 -OpMemberDecorate %12 0 Offset 0 -OpMemberDecorate %12 1 Offset 4 -OpMemberDecorate %12 2 Offset 8 +OpDecorate %12 ArrayStride 4 +OpDecorate %13 ArrayStride 4 +OpMemberDecorate %14 0 Offset 0 +OpMemberDecorate %14 1 Offset 4 +OpMemberDecorate %14 2 Offset 8 %2 = OpTypeVoid -%3 = OpTypeInt 32 0 +%3 = OpTypeInt 32 1 %4 = OpTypeVector %3 2 -%5 = OpTypeFloat 32 +%5 = OpTypeInt 32 0 %6 = OpTypeVector %5 2 -%7 = OpTypeMatrix %6 2 -%8 = OpTypeInt 32 1 -%9 = OpTypeVector %8 2 -%11 = OpConstant %3 2 -%10 = OpTypeArray %5 %11 -%12 = OpTypeStruct %5 %8 %3 -%13 = OpTypeVector %5 3 -%14 = OpConstant %3 42 -%15 = OpConstant %3 43 -%16 = OpConstantComposite %4 %14 %15 -%17 = OpConstant %5 44.0 -%18 = OpConstant %5 45.0 -%19 = OpConstantComposite %6 %17 %18 -%20 = OpConstant %5 1.0 -%21 = OpConstant %5 2.0 -%22 = OpConstantComposite %6 %20 %21 -%23 = OpConstant %5 3.0 -%24 = OpConstant %5 4.0 -%25 = OpConstantComposite %6 %23 %24 -%26 = OpConstantComposite %7 %22 %25 -%27 = OpConstant %8 1 -%28 = OpConstantComposite %9 %27 %27 -%29 = OpConstant %3 1 -%30 = OpConstantComposite %4 %29 %29 -%31 = OpConstantComposite %6 %20 %20 -%32 = OpConstantComposite %10 %20 %21 -%33 = OpConstantComposite %12 %20 %27 %29 -%34 = OpConstantComposite %13 %20 %21 %23 -%35 = OpConstantComposite %6 %21 %23 \ No newline at end of file +%7 = OpTypeFloat 32 +%8 = OpTypeVector %7 2 +%9 = OpTypeMatrix %8 2 +%11 = OpConstant %5 2 +%10 = OpTypeArray %7 %11 +%12 = OpTypeArray %3 %11 +%13 = OpTypeArray %5 %11 +%14 = OpTypeStruct %7 %3 %5 +%15 = OpTypeVector %7 3 +%16 = OpConstant %3 42 +%17 = OpConstant %3 43 +%18 = OpConstantComposite %4 %16 %17 +%19 = OpConstant %5 44 +%20 = OpConstant %5 45 +%21 = OpConstantComposite %6 %19 %20 +%22 = OpConstant %7 46.0 +%23 = OpConstant %7 47.0 +%24 = OpConstantComposite %8 %22 %23 +%25 = OpConstant %7 48.0 +%26 = OpConstant %7 49.0 +%27 = OpConstantComposite %8 %25 %26 +%28 = OpConstant %5 42 +%29 = OpConstant %5 43 +%30 = OpConstantComposite %6 %28 %29 +%31 = OpConstant %3 0 +%32 = OpConstantComposite %4 %31 %31 +%33 = OpConstant %5 0 +%34 = OpConstantComposite %6 %33 %33 +%35 = OpConstant %7 0.0 +%36 = OpConstantComposite %8 %35 %35 +%37 = OpConstantComposite %9 %36 %36 +%38 = OpConstant %7 1.0 +%39 = OpConstant %7 2.0 +%40 = OpConstantComposite %8 %38 %39 +%41 = OpConstant %7 3.0 +%42 = OpConstant %7 4.0 +%43 = OpConstantComposite %8 %41 %42 +%44 = OpConstantComposite %9 %40 %43 +%45 = OpConstant %3 1 +%46 = OpConstantComposite %4 %45 %45 +%47 = OpConstant %5 1 +%48 = OpConstantComposite %6 %47 %47 +%49 = OpConstantComposite %8 %38 %38 +%50 = OpConstantComposite %10 %38 %39 +%51 = OpConstant %3 2 +%52 = OpConstantComposite %12 %45 %51 +%53 = OpConstantComposite %13 %47 %11 +%54 = OpConstantComposite %14 %38 %45 %47 +%55 = OpConstantComposite %15 %38 %39 %41 +%56 = OpConstantComposite %8 %39 %41 \ No newline at end of file diff --git a/naga/tests/out/spv/abstract-types-let.spvasm b/naga/tests/out/spv/abstract-types-let.spvasm new file mode 100644 index 000000000..af8da8707 --- /dev/null +++ b/naga/tests/out/spv/abstract-types-let.spvasm @@ -0,0 +1,144 @@ +; SPIR-V +; Version: 1.1 +; Generator: rspirv +; Bound: 128 +OpCapability Shader +OpCapability Linkage +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpDecorate %10 ArrayStride 4 +OpDecorate %12 ArrayStride 4 +OpDecorate %14 ArrayStride 16 +OpDecorate %17 ArrayStride 16 +%2 = OpTypeVoid +%3 = OpTypeInt 32 1 +%4 = OpTypeVector %3 2 +%5 = OpTypeInt 32 0 +%6 = OpTypeVector %5 2 +%7 = OpTypeFloat 32 +%8 = OpTypeVector %7 2 +%9 = OpTypeMatrix %8 2 +%11 = OpConstant %5 2 +%10 = OpTypeArray %7 %11 +%12 = OpTypeArray %3 %11 +%13 = OpTypeVector %3 3 +%15 = OpConstant %5 1 +%14 = OpTypeArray %13 %15 +%16 = OpTypeVector %7 3 +%17 = OpTypeArray %16 %15 +%20 = OpTypeFunction %2 +%21 = OpConstant %3 42 +%22 = OpConstant %3 43 +%23 = OpConstantComposite %4 %21 %22 +%24 = OpConstant %5 44 +%25 = OpConstant %5 45 +%26 = OpConstantComposite %6 %24 %25 +%27 = OpConstant %7 46.0 +%28 = OpConstant %7 47.0 +%29 = OpConstantComposite %8 %27 %28 +%30 = OpConstant %7 48.0 +%31 = OpConstant %7 49.0 +%32 = OpConstantComposite %8 %30 %31 +%33 = OpConstant %5 42 +%34 = OpConstant %5 43 +%35 = OpConstantComposite %6 %33 %34 +%36 = OpConstant %3 0 +%37 = OpConstantComposite %4 %36 %36 +%38 = OpConstant %5 0 +%39 = OpConstantComposite %6 %38 %38 +%40 = OpConstant %7 0.0 +%41 = OpConstantComposite %8 %40 %40 +%42 = OpConstantComposite %9 %41 %41 +%43 = OpConstant %7 1.0 +%44 = OpConstant %7 2.0 +%45 = OpConstantComposite %8 %43 %44 +%46 = OpConstant %7 3.0 +%47 = OpConstant %7 4.0 +%48 = OpConstantComposite %8 %46 %47 +%49 = OpConstantComposite %9 %45 %48 +%50 = OpConstant %3 1 +%51 = OpConstantComposite %4 %50 %50 +%52 = OpConstantComposite %8 %43 %43 +%53 = OpConstantComposite %6 %15 %15 +%54 = OpConstantComposite %10 %43 %44 +%55 = OpConstant %3 2 +%56 = OpConstantComposite %12 %50 %55 +%57 = OpConstantComposite %13 %50 %50 %50 +%58 = OpConstantComposite %14 %57 +%59 = OpConstantComposite %16 %43 %43 %43 +%60 = OpConstantComposite %17 %59 +%65 = OpTypePointer Function %5 +%66 = OpConstantNull %5 +%68 = OpTypePointer Function %3 +%69 = OpConstantNull %3 +%71 = OpTypePointer Function %7 +%72 = OpConstantNull %7 +%19 = OpFunction %2 None %20 +%18 = OpLabel +OpBranch %61 +%61 = OpLabel +OpReturn +OpFunctionEnd +%63 = OpFunction %2 None %20 +%62 = OpLabel +%64 = OpVariable %65 Function %66 +%67 = OpVariable %68 Function %69 +%70 = OpVariable %71 Function %72 +OpBranch %73 +%73 = OpLabel +%74 = OpLoad %5 %64 +%75 = OpCompositeConstruct %6 %74 %34 +%76 = OpLoad %5 %64 +%77 = OpCompositeConstruct %6 %33 %76 +%78 = OpLoad %7 %70 +%79 = OpCompositeConstruct %8 %78 %28 +%80 = OpLoad %7 %70 +%81 = OpCompositeConstruct %8 %80 %31 +%82 = OpLoad %5 %64 +%83 = OpCompositeConstruct %6 %82 %34 +%84 = OpLoad %5 %64 +%85 = OpCompositeConstruct %6 %33 %84 +%86 = OpLoad %7 %70 +%87 = OpCompositeConstruct %8 %86 %44 +%88 = OpCompositeConstruct %9 %87 %48 +%89 = OpLoad %7 %70 +%90 = OpCompositeConstruct %8 %43 %89 +%91 = OpCompositeConstruct %9 %90 %48 +%92 = OpLoad %7 %70 +%93 = OpCompositeConstruct %8 %92 %47 +%94 = OpCompositeConstruct %9 %45 %93 +%95 = OpLoad %7 %70 +%96 = OpCompositeConstruct %8 %46 %95 +%97 = OpCompositeConstruct %9 %45 %96 +%98 = OpLoad %7 %70 +%99 = OpCompositeConstruct %10 %98 %44 +%100 = OpLoad %7 %70 +%101 = OpCompositeConstruct %10 %43 %100 +%102 = OpLoad %7 %70 +%103 = OpCompositeConstruct %10 %102 %44 +%104 = OpLoad %7 %70 +%105 = OpCompositeConstruct %10 %43 %104 +%106 = OpLoad %3 %67 +%107 = OpCompositeConstruct %12 %106 %55 +%108 = OpLoad %3 %67 +%109 = OpCompositeConstruct %12 %50 %108 +%110 = OpLoad %7 %70 +%111 = OpCompositeConstruct %10 %110 %44 +%112 = OpLoad %7 %70 +%113 = OpCompositeConstruct %10 %43 %112 +%114 = OpLoad %7 %70 +%115 = OpCompositeConstruct %10 %114 %44 +%116 = OpLoad %7 %70 +%117 = OpCompositeConstruct %10 %43 %116 +%118 = OpLoad %3 %67 +%119 = OpCompositeConstruct %12 %118 %55 +%120 = OpLoad %3 %67 +%121 = OpCompositeConstruct %12 %50 %120 +%122 = OpLoad %3 %67 +%123 = OpCompositeConstruct %4 %122 %122 +%124 = OpLoad %5 %64 +%125 = OpCompositeConstruct %6 %124 %124 +%126 = OpLoad %7 %70 +%127 = OpCompositeConstruct %8 %126 %126 +OpReturn +OpFunctionEnd \ No newline at end of file diff --git a/naga/tests/out/spv/abstract-types-var.spvasm b/naga/tests/out/spv/abstract-types-var.spvasm index 3c3f42b74..37354c2fc 100644 --- a/naga/tests/out/spv/abstract-types-var.spvasm +++ b/naga/tests/out/spv/abstract-types-var.spvasm @@ -1,15 +1,16 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 290 +; Bound: 350 OpCapability Shader OpCapability Linkage %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpDecorate %10 ArrayStride 4 OpDecorate %12 ArrayStride 4 -OpDecorate %14 ArrayStride 16 -OpDecorate %17 ArrayStride 16 +OpDecorate %13 ArrayStride 4 +OpDecorate %15 ArrayStride 16 +OpDecorate %18 ArrayStride 16 %2 = OpTypeVoid %3 = OpTypeInt 32 1 %4 = OpTypeVector %3 2 @@ -21,366 +22,444 @@ OpDecorate %17 ArrayStride 16 %11 = OpConstant %5 2 %10 = OpTypeArray %7 %11 %12 = OpTypeArray %3 %11 -%13 = OpTypeVector %3 3 -%15 = OpConstant %5 1 -%14 = OpTypeArray %13 %15 -%16 = OpTypeVector %7 3 -%17 = OpTypeArray %16 %15 -%18 = OpConstant %3 42 -%19 = OpConstant %3 43 -%20 = OpConstantComposite %4 %18 %19 -%21 = OpConstant %5 44 -%22 = OpConstant %5 45 -%23 = OpConstantComposite %6 %21 %22 -%24 = OpConstant %7 46.0 -%25 = OpConstant %7 47.0 -%26 = OpConstantComposite %8 %24 %25 -%27 = OpConstant %5 42 -%28 = OpConstant %5 43 -%29 = OpConstantComposite %6 %27 %28 -%30 = OpConstant %7 1.0 -%31 = OpConstant %7 2.0 -%32 = OpConstantComposite %8 %30 %31 -%33 = OpConstant %7 3.0 -%34 = OpConstant %7 4.0 -%35 = OpConstantComposite %8 %33 %34 -%36 = OpConstantComposite %9 %32 %35 -%37 = OpConstant %3 1 -%38 = OpConstantComposite %4 %37 %37 -%39 = OpConstantComposite %8 %30 %30 -%40 = OpConstantComposite %6 %15 %15 -%41 = OpConstantComposite %10 %30 %31 -%42 = OpConstant %3 2 -%43 = OpConstantComposite %12 %37 %42 -%44 = OpConstantComposite %13 %37 %37 %37 -%45 = OpConstantComposite %14 %44 -%46 = OpConstantComposite %16 %30 %30 %30 -%47 = OpConstantComposite %17 %46 -%49 = OpTypePointer Private %4 -%48 = OpVariable %49 Private %20 -%51 = OpTypePointer Private %6 -%50 = OpVariable %51 Private %23 -%53 = OpTypePointer Private %8 -%52 = OpVariable %53 Private %26 -%54 = OpVariable %51 Private %29 -%55 = OpVariable %51 Private %29 -%56 = OpVariable %51 Private %29 -%57 = OpVariable %51 Private %29 -%59 = OpTypePointer Private %9 -%58 = OpVariable %59 Private %36 -%60 = OpVariable %59 Private %36 -%61 = OpVariable %59 Private %36 -%62 = OpVariable %59 Private %36 -%63 = OpVariable %59 Private %36 -%64 = OpVariable %49 Private %38 -%65 = OpVariable %53 Private %39 -%66 = OpVariable %49 Private %38 -%67 = OpVariable %51 Private %40 -%68 = OpVariable %53 Private %39 -%69 = OpVariable %53 Private %39 -%71 = OpTypePointer Private %10 -%70 = OpVariable %71 Private %41 -%72 = OpVariable %71 Private %41 -%74 = OpTypePointer Private %12 -%73 = OpVariable %74 Private %43 -%75 = OpVariable %71 Private %41 -%76 = OpVariable %71 Private %41 -%77 = OpVariable %71 Private %41 -%79 = OpTypePointer Private %14 -%78 = OpVariable %79 Private %45 -%81 = OpTypePointer Private %17 -%80 = OpVariable %81 Private %47 -%82 = OpVariable %81 Private %47 -%83 = OpVariable %49 Private %38 -%84 = OpVariable %53 Private %39 -%85 = OpVariable %49 Private %38 -%86 = OpVariable %51 Private %40 -%87 = OpVariable %53 Private %39 -%88 = OpVariable %53 Private %39 -%89 = OpVariable %71 Private %41 -%90 = OpVariable %71 Private %41 -%91 = OpVariable %74 Private %43 -%92 = OpVariable %71 Private %41 -%93 = OpVariable %71 Private %41 -%94 = OpVariable %71 Private %41 -%95 = OpVariable %79 Private %45 -%96 = OpVariable %79 Private %45 -%97 = OpVariable %81 Private %47 -%100 = OpTypeFunction %2 -%102 = OpTypePointer Function %4 -%104 = OpTypePointer Function %6 -%106 = OpTypePointer Function %8 -%112 = OpTypePointer Function %9 -%128 = OpTypePointer Function %10 -%133 = OpTypePointer Function %12 -%141 = OpTypePointer Function %14 -%143 = OpTypePointer Function %17 -%153 = OpTypePointer Function %5 -%154 = OpConstantNull %5 -%156 = OpTypePointer Function %3 -%157 = OpConstantNull %3 -%159 = OpTypePointer Function %7 -%160 = OpConstantNull %7 -%162 = OpConstantNull %6 -%164 = OpConstantNull %6 -%166 = OpConstantNull %6 -%168 = OpConstantNull %6 -%170 = OpConstantNull %9 -%172 = OpConstantNull %9 -%174 = OpConstantNull %9 -%176 = OpConstantNull %9 -%178 = OpConstantNull %10 -%180 = OpConstantNull %10 -%182 = OpConstantNull %10 -%184 = OpConstantNull %10 -%186 = OpConstantNull %12 -%188 = OpConstantNull %12 -%190 = OpConstantNull %10 -%192 = OpConstantNull %10 -%194 = OpConstantNull %10 -%196 = OpConstantNull %10 -%198 = OpConstantNull %12 -%200 = OpConstantNull %12 -%99 = OpFunction %2 None %100 -%98 = OpLabel -%148 = OpVariable %128 Function %41 -%145 = OpVariable %133 Function %43 -%140 = OpVariable %141 Function %45 -%137 = OpVariable %128 Function %41 -%134 = OpVariable %133 Function %43 -%130 = OpVariable %128 Function %41 -%126 = OpVariable %106 Function %39 -%123 = OpVariable %102 Function %38 -%120 = OpVariable %112 Function %36 -%117 = OpVariable %112 Function %36 -%114 = OpVariable %112 Function %36 -%110 = OpVariable %104 Function %29 -%107 = OpVariable %104 Function %29 -%101 = OpVariable %102 Function %20 -%146 = OpVariable %128 Function %41 -%142 = OpVariable %143 Function %47 -%138 = OpVariable %128 Function %41 -%135 = OpVariable %133 Function %43 -%131 = OpVariable %128 Function %41 -%127 = OpVariable %128 Function %41 -%124 = OpVariable %104 Function %40 -%121 = OpVariable %102 Function %38 -%118 = OpVariable %112 Function %36 -%115 = OpVariable %112 Function %36 -%111 = OpVariable %112 Function %36 -%108 = OpVariable %104 Function %29 -%103 = OpVariable %104 Function %23 -%147 = OpVariable %128 Function %41 -%144 = OpVariable %143 Function %47 -%139 = OpVariable %128 Function %41 -%136 = OpVariable %128 Function %41 -%132 = OpVariable %133 Function %43 -%129 = OpVariable %128 Function %41 -%125 = OpVariable %106 Function %39 -%122 = OpVariable %106 Function %39 -%119 = OpVariable %112 Function %36 -%116 = OpVariable %112 Function %36 -%113 = OpVariable %112 Function %36 -%109 = OpVariable %104 Function %29 -%105 = OpVariable %106 Function %26 -OpBranch %149 -%149 = OpLabel -OpStore %101 %20 -OpStore %103 %23 -OpStore %105 %26 -OpStore %107 %29 -OpStore %108 %29 -OpStore %109 %29 -OpStore %110 %29 -OpStore %111 %36 -OpStore %113 %36 -OpStore %114 %36 -OpStore %115 %36 -OpStore %116 %36 -OpStore %117 %36 -OpStore %118 %36 -OpStore %119 %36 -OpStore %120 %36 -OpStore %121 %38 -OpStore %122 %39 -OpStore %123 %38 -OpStore %124 %40 -OpStore %125 %39 -OpStore %126 %39 -OpStore %127 %41 -OpStore %129 %41 -OpStore %130 %41 -OpStore %131 %41 -OpStore %132 %43 -OpStore %134 %43 -OpStore %135 %43 -OpStore %136 %41 -OpStore %137 %41 -OpStore %138 %41 -OpStore %139 %41 -OpStore %140 %45 +%13 = OpTypeArray %5 %11 +%14 = OpTypeVector %3 3 +%16 = OpConstant %5 1 +%15 = OpTypeArray %14 %16 +%17 = OpTypeVector %7 3 +%18 = OpTypeArray %17 %16 +%19 = OpConstant %3 42 +%20 = OpConstant %3 43 +%21 = OpConstantComposite %4 %19 %20 +%22 = OpConstant %5 44 +%23 = OpConstant %5 45 +%24 = OpConstantComposite %6 %22 %23 +%25 = OpConstant %7 46.0 +%26 = OpConstant %7 47.0 +%27 = OpConstantComposite %8 %25 %26 +%28 = OpConstant %7 48.0 +%29 = OpConstant %7 49.0 +%30 = OpConstantComposite %8 %28 %29 +%31 = OpConstant %5 42 +%32 = OpConstant %5 43 +%33 = OpConstantComposite %6 %31 %32 +%34 = OpConstant %3 0 +%35 = OpConstantComposite %4 %34 %34 +%36 = OpConstant %5 0 +%37 = OpConstantComposite %6 %36 %36 +%38 = OpConstant %7 0.0 +%39 = OpConstantComposite %8 %38 %38 +%40 = OpConstantComposite %9 %39 %39 +%41 = OpConstant %7 1.0 +%42 = OpConstant %7 2.0 +%43 = OpConstantComposite %8 %41 %42 +%44 = OpConstant %7 3.0 +%45 = OpConstant %7 4.0 +%46 = OpConstantComposite %8 %44 %45 +%47 = OpConstantComposite %9 %43 %46 +%48 = OpConstant %3 1 +%49 = OpConstantComposite %4 %48 %48 +%50 = OpConstantComposite %8 %41 %41 +%51 = OpConstantComposite %6 %16 %16 +%52 = OpConstantComposite %10 %41 %42 +%53 = OpConstant %3 2 +%54 = OpConstantComposite %12 %48 %53 +%55 = OpConstantComposite %13 %16 %11 +%56 = OpConstantComposite %14 %48 %48 %48 +%57 = OpConstantComposite %15 %56 +%58 = OpConstantComposite %17 %41 %41 %41 +%59 = OpConstantComposite %18 %58 +%61 = OpTypePointer Private %4 +%60 = OpVariable %61 Private %21 +%63 = OpTypePointer Private %6 +%62 = OpVariable %63 Private %24 +%65 = OpTypePointer Private %8 +%64 = OpVariable %65 Private %27 +%66 = OpVariable %65 Private %30 +%67 = OpVariable %65 Private %30 +%68 = OpVariable %63 Private %33 +%69 = OpVariable %63 Private %33 +%70 = OpVariable %63 Private %33 +%71 = OpVariable %63 Private %33 +%72 = OpVariable %61 Private %35 +%73 = OpVariable %63 Private %37 +%74 = OpVariable %65 Private %39 +%76 = OpTypePointer Private %9 +%75 = OpVariable %76 Private %40 +%77 = OpVariable %76 Private %47 +%78 = OpVariable %76 Private %47 +%79 = OpVariable %76 Private %47 +%80 = OpVariable %76 Private %47 +%81 = OpVariable %76 Private %47 +%82 = OpVariable %61 Private %49 +%83 = OpVariable %65 Private %50 +%84 = OpVariable %61 Private %49 +%85 = OpVariable %63 Private %51 +%86 = OpVariable %65 Private %50 +%87 = OpVariable %65 Private %50 +%89 = OpTypePointer Private %10 +%88 = OpVariable %89 Private %52 +%90 = OpVariable %89 Private %52 +%92 = OpTypePointer Private %12 +%91 = OpVariable %92 Private %54 +%94 = OpTypePointer Private %13 +%93 = OpVariable %94 Private %55 +%95 = OpVariable %89 Private %52 +%96 = OpVariable %89 Private %52 +%97 = OpVariable %89 Private %52 +%99 = OpTypePointer Private %15 +%98 = OpVariable %99 Private %57 +%101 = OpTypePointer Private %18 +%100 = OpVariable %101 Private %59 +%102 = OpVariable %101 Private %59 +%103 = OpVariable %61 Private %49 +%104 = OpVariable %63 Private %51 +%105 = OpVariable %65 Private %50 +%106 = OpVariable %65 Private %50 +%107 = OpVariable %61 Private %49 +%108 = OpVariable %65 Private %50 +%109 = OpVariable %61 Private %49 +%110 = OpVariable %63 Private %51 +%111 = OpVariable %65 Private %50 +%112 = OpVariable %65 Private %50 +%113 = OpVariable %89 Private %52 +%114 = OpVariable %89 Private %52 +%115 = OpVariable %92 Private %54 +%116 = OpVariable %89 Private %52 +%117 = OpVariable %89 Private %52 +%118 = OpVariable %89 Private %52 +%119 = OpVariable %99 Private %57 +%120 = OpVariable %99 Private %57 +%121 = OpVariable %101 Private %59 +%124 = OpTypeFunction %2 +%126 = OpTypePointer Function %4 +%128 = OpTypePointer Function %6 +%130 = OpTypePointer Function %8 +%141 = OpTypePointer Function %9 +%158 = OpTypePointer Function %10 +%163 = OpTypePointer Function %12 +%171 = OpTypePointer Function %15 +%173 = OpTypePointer Function %18 +%187 = OpTypePointer Function %5 +%188 = OpConstantNull %5 +%190 = OpTypePointer Function %3 +%191 = OpConstantNull %3 +%193 = OpTypePointer Function %7 +%194 = OpConstantNull %7 +%196 = OpConstantNull %6 +%198 = OpConstantNull %6 +%200 = OpConstantNull %8 +%202 = OpConstantNull %8 +%204 = OpConstantNull %6 +%206 = OpConstantNull %6 +%208 = OpConstantNull %9 +%210 = OpConstantNull %9 +%212 = OpConstantNull %9 +%214 = OpConstantNull %9 +%216 = OpConstantNull %10 +%218 = OpConstantNull %10 +%220 = OpConstantNull %10 +%222 = OpConstantNull %10 +%224 = OpConstantNull %12 +%226 = OpConstantNull %12 +%228 = OpConstantNull %10 +%230 = OpConstantNull %10 +%232 = OpConstantNull %10 +%234 = OpConstantNull %10 +%236 = OpConstantNull %12 +%238 = OpConstantNull %12 +%240 = OpConstantNull %4 +%242 = OpConstantNull %6 +%244 = OpConstantNull %8 +%123 = OpFunction %2 None %124 +%122 = OpLabel +%181 = OpVariable %158 Function %52 +%178 = OpVariable %130 Function %50 +%175 = OpVariable %126 Function %49 +%170 = OpVariable %171 Function %57 +%167 = OpVariable %158 Function %52 +%164 = OpVariable %163 Function %54 +%160 = OpVariable %158 Function %52 +%156 = OpVariable %130 Function %50 +%153 = OpVariable %126 Function %49 +%150 = OpVariable %141 Function %47 +%147 = OpVariable %141 Function %47 +%144 = OpVariable %141 Function %47 +%140 = OpVariable %141 Function %40 +%137 = OpVariable %126 Function %35 +%134 = OpVariable %128 Function %33 +%131 = OpVariable %130 Function %30 +%125 = OpVariable %126 Function %21 +%182 = OpVariable %158 Function %52 +%179 = OpVariable %163 Function %54 +%176 = OpVariable %128 Function %51 +%172 = OpVariable %173 Function %59 +%168 = OpVariable %158 Function %52 +%165 = OpVariable %163 Function %54 +%161 = OpVariable %158 Function %52 +%157 = OpVariable %158 Function %52 +%154 = OpVariable %128 Function %51 +%151 = OpVariable %126 Function %49 +%148 = OpVariable %141 Function %47 +%145 = OpVariable %141 Function %47 +%142 = OpVariable %141 Function %47 +%138 = OpVariable %128 Function %37 +%135 = OpVariable %128 Function %33 +%132 = OpVariable %130 Function %30 +%127 = OpVariable %128 Function %24 +%180 = OpVariable %158 Function %52 +%177 = OpVariable %130 Function %50 +%174 = OpVariable %173 Function %59 +%169 = OpVariable %158 Function %52 +%166 = OpVariable %158 Function %52 +%162 = OpVariable %163 Function %54 +%159 = OpVariable %158 Function %52 +%155 = OpVariable %130 Function %50 +%152 = OpVariable %130 Function %50 +%149 = OpVariable %141 Function %47 +%146 = OpVariable %141 Function %47 +%143 = OpVariable %141 Function %47 +%139 = OpVariable %130 Function %39 +%136 = OpVariable %128 Function %33 +%133 = OpVariable %128 Function %33 +%129 = OpVariable %130 Function %27 +OpBranch %183 +%183 = OpLabel +OpStore %125 %21 +OpStore %127 %24 +OpStore %129 %27 +OpStore %131 %30 +OpStore %132 %30 +OpStore %133 %33 +OpStore %134 %33 +OpStore %135 %33 +OpStore %136 %33 +OpStore %137 %35 +OpStore %138 %37 +OpStore %139 %39 +OpStore %140 %40 OpStore %142 %47 +OpStore %143 %47 OpStore %144 %47 -OpStore %145 %43 -OpStore %146 %41 -OpStore %147 %41 -OpStore %148 %41 +OpStore %145 %47 +OpStore %146 %47 +OpStore %147 %47 +OpStore %148 %47 +OpStore %149 %47 +OpStore %150 %47 +OpStore %151 %49 +OpStore %152 %50 +OpStore %153 %49 +OpStore %154 %51 +OpStore %155 %50 +OpStore %156 %50 +OpStore %157 %52 +OpStore %159 %52 +OpStore %160 %52 +OpStore %161 %52 +OpStore %162 %54 +OpStore %164 %54 +OpStore %165 %54 +OpStore %166 %52 +OpStore %167 %52 +OpStore %168 %52 +OpStore %169 %52 +OpStore %170 %57 +OpStore %172 %59 +OpStore %174 %59 +OpStore %175 %49 +OpStore %176 %51 +OpStore %177 %50 +OpStore %178 %50 +OpStore %179 %54 +OpStore %180 %52 +OpStore %181 %52 +OpStore %182 %52 OpReturn OpFunctionEnd -%151 = OpFunction %2 None %100 -%150 = OpLabel -%199 = OpVariable %133 Function %200 -%193 = OpVariable %128 Function %194 -%187 = OpVariable %133 Function %188 -%181 = OpVariable %128 Function %182 -%175 = OpVariable %112 Function %176 -%169 = OpVariable %112 Function %170 -%163 = OpVariable %104 Function %164 -%155 = OpVariable %156 Function %157 -%197 = OpVariable %133 Function %198 -%191 = OpVariable %128 Function %192 -%185 = OpVariable %133 Function %186 -%179 = OpVariable %128 Function %180 -%173 = OpVariable %112 Function %174 -%167 = OpVariable %104 Function %168 -%161 = OpVariable %104 Function %162 -%152 = OpVariable %153 Function %154 +%185 = OpFunction %2 None %124 +%184 = OpLabel +%239 = OpVariable %126 Function %240 +%233 = OpVariable %158 Function %234 +%227 = OpVariable %158 Function %228 +%221 = OpVariable %158 Function %222 +%215 = OpVariable %158 Function %216 +%209 = OpVariable %141 Function %210 +%203 = OpVariable %128 Function %204 +%197 = OpVariable %128 Function %198 +%189 = OpVariable %190 Function %191 +%243 = OpVariable %130 Function %244 +%237 = OpVariable %163 Function %238 +%231 = OpVariable %158 Function %232 +%225 = OpVariable %163 Function %226 +%219 = OpVariable %158 Function %220 +%213 = OpVariable %141 Function %214 +%207 = OpVariable %141 Function %208 +%201 = OpVariable %130 Function %202 %195 = OpVariable %128 Function %196 -%189 = OpVariable %128 Function %190 -%183 = OpVariable %128 Function %184 -%177 = OpVariable %128 Function %178 -%171 = OpVariable %112 Function %172 -%165 = OpVariable %104 Function %166 -%158 = OpVariable %159 Function %160 -OpBranch %201 -%201 = OpLabel -%202 = OpLoad %5 %152 -%203 = OpCompositeConstruct %6 %202 %28 -OpStore %161 %203 -%204 = OpLoad %5 %152 -%205 = OpCompositeConstruct %6 %27 %204 -OpStore %163 %205 -%206 = OpLoad %5 %152 -%207 = OpCompositeConstruct %6 %206 %28 -OpStore %165 %207 -%208 = OpLoad %5 %152 -%209 = OpCompositeConstruct %6 %27 %208 -OpStore %167 %209 -%210 = OpLoad %7 %158 -%211 = OpCompositeConstruct %8 %210 %31 -%212 = OpCompositeConstruct %9 %211 %35 -OpStore %169 %212 -%213 = OpLoad %7 %158 -%214 = OpCompositeConstruct %8 %30 %213 -%215 = OpCompositeConstruct %9 %214 %35 -OpStore %171 %215 -%216 = OpLoad %7 %158 -%217 = OpCompositeConstruct %8 %216 %34 -%218 = OpCompositeConstruct %9 %32 %217 -OpStore %173 %218 -%219 = OpLoad %7 %158 -%220 = OpCompositeConstruct %8 %33 %219 -%221 = OpCompositeConstruct %9 %32 %220 -OpStore %175 %221 -%222 = OpLoad %7 %158 -%223 = OpCompositeConstruct %10 %222 %31 -OpStore %177 %223 -%224 = OpLoad %7 %158 -%225 = OpCompositeConstruct %10 %30 %224 -OpStore %179 %225 -%226 = OpLoad %7 %158 -%227 = OpCompositeConstruct %10 %226 %31 -OpStore %181 %227 -%228 = OpLoad %7 %158 -%229 = OpCompositeConstruct %10 %30 %228 -OpStore %183 %229 -%230 = OpLoad %3 %155 -%231 = OpCompositeConstruct %12 %230 %42 -OpStore %185 %231 -%232 = OpLoad %3 %155 -%233 = OpCompositeConstruct %12 %37 %232 -OpStore %187 %233 -%234 = OpLoad %7 %158 -%235 = OpCompositeConstruct %10 %234 %31 -OpStore %189 %235 -%236 = OpLoad %7 %158 -%237 = OpCompositeConstruct %10 %30 %236 -OpStore %191 %237 -%238 = OpLoad %7 %158 -%239 = OpCompositeConstruct %10 %238 %31 -OpStore %193 %239 -%240 = OpLoad %7 %158 -%241 = OpCompositeConstruct %10 %30 %240 -OpStore %195 %241 -%242 = OpLoad %3 %155 -%243 = OpCompositeConstruct %12 %242 %42 -OpStore %197 %243 -%244 = OpLoad %3 %155 -%245 = OpCompositeConstruct %12 %37 %244 -OpStore %199 %245 -%246 = OpLoad %5 %152 -%247 = OpCompositeConstruct %6 %246 %28 -OpStore %161 %247 -%248 = OpLoad %5 %152 -%249 = OpCompositeConstruct %6 %27 %248 -OpStore %163 %249 -%250 = OpLoad %5 %152 -%251 = OpCompositeConstruct %6 %250 %28 -OpStore %165 %251 -%252 = OpLoad %5 %152 -%253 = OpCompositeConstruct %6 %27 %252 -OpStore %167 %253 -%254 = OpLoad %7 %158 -%255 = OpCompositeConstruct %8 %254 %31 -%256 = OpCompositeConstruct %9 %255 %35 -OpStore %169 %256 -%257 = OpLoad %7 %158 -%258 = OpCompositeConstruct %8 %30 %257 -%259 = OpCompositeConstruct %9 %258 %35 -OpStore %171 %259 -%260 = OpLoad %7 %158 -%261 = OpCompositeConstruct %8 %260 %34 -%262 = OpCompositeConstruct %9 %32 %261 -OpStore %173 %262 -%263 = OpLoad %7 %158 -%264 = OpCompositeConstruct %8 %33 %263 -%265 = OpCompositeConstruct %9 %32 %264 -OpStore %175 %265 -%266 = OpLoad %7 %158 -%267 = OpCompositeConstruct %10 %266 %31 -OpStore %177 %267 -%268 = OpLoad %7 %158 -%269 = OpCompositeConstruct %10 %30 %268 -OpStore %179 %269 -%270 = OpLoad %7 %158 -%271 = OpCompositeConstruct %10 %270 %31 -OpStore %181 %271 -%272 = OpLoad %7 %158 -%273 = OpCompositeConstruct %10 %30 %272 -OpStore %183 %273 -%274 = OpLoad %3 %155 -%275 = OpCompositeConstruct %12 %274 %42 -OpStore %185 %275 -%276 = OpLoad %3 %155 -%277 = OpCompositeConstruct %12 %37 %276 -OpStore %187 %277 -%278 = OpLoad %7 %158 -%279 = OpCompositeConstruct %10 %278 %31 -OpStore %189 %279 -%280 = OpLoad %7 %158 -%281 = OpCompositeConstruct %10 %30 %280 -OpStore %191 %281 -%282 = OpLoad %7 %158 -%283 = OpCompositeConstruct %10 %282 %31 -OpStore %193 %283 -%284 = OpLoad %7 %158 -%285 = OpCompositeConstruct %10 %30 %284 -OpStore %195 %285 -%286 = OpLoad %3 %155 -%287 = OpCompositeConstruct %12 %286 %42 -OpStore %197 %287 -%288 = OpLoad %3 %155 -%289 = OpCompositeConstruct %12 %37 %288 -OpStore %199 %289 +%186 = OpVariable %187 Function %188 +%241 = OpVariable %128 Function %242 +%235 = OpVariable %163 Function %236 +%229 = OpVariable %158 Function %230 +%223 = OpVariable %163 Function %224 +%217 = OpVariable %158 Function %218 +%211 = OpVariable %141 Function %212 +%205 = OpVariable %128 Function %206 +%199 = OpVariable %130 Function %200 +%192 = OpVariable %193 Function %194 +OpBranch %245 +%245 = OpLabel +%246 = OpLoad %5 %186 +%247 = OpCompositeConstruct %6 %246 %32 +OpStore %195 %247 +%248 = OpLoad %5 %186 +%249 = OpCompositeConstruct %6 %31 %248 +OpStore %197 %249 +%250 = OpLoad %7 %192 +%251 = OpCompositeConstruct %8 %250 %26 +OpStore %199 %251 +%252 = OpLoad %7 %192 +%253 = OpCompositeConstruct %8 %252 %29 +OpStore %201 %253 +%254 = OpLoad %5 %186 +%255 = OpCompositeConstruct %6 %254 %32 +OpStore %203 %255 +%256 = OpLoad %5 %186 +%257 = OpCompositeConstruct %6 %31 %256 +OpStore %205 %257 +%258 = OpLoad %7 %192 +%259 = OpCompositeConstruct %8 %258 %42 +%260 = OpCompositeConstruct %9 %259 %46 +OpStore %207 %260 +%261 = OpLoad %7 %192 +%262 = OpCompositeConstruct %8 %41 %261 +%263 = OpCompositeConstruct %9 %262 %46 +OpStore %209 %263 +%264 = OpLoad %7 %192 +%265 = OpCompositeConstruct %8 %264 %45 +%266 = OpCompositeConstruct %9 %43 %265 +OpStore %211 %266 +%267 = OpLoad %7 %192 +%268 = OpCompositeConstruct %8 %44 %267 +%269 = OpCompositeConstruct %9 %43 %268 +OpStore %213 %269 +%270 = OpLoad %7 %192 +%271 = OpCompositeConstruct %10 %270 %42 +OpStore %215 %271 +%272 = OpLoad %7 %192 +%273 = OpCompositeConstruct %10 %41 %272 +OpStore %217 %273 +%274 = OpLoad %7 %192 +%275 = OpCompositeConstruct %10 %274 %42 +OpStore %219 %275 +%276 = OpLoad %7 %192 +%277 = OpCompositeConstruct %10 %41 %276 +OpStore %221 %277 +%278 = OpLoad %3 %189 +%279 = OpCompositeConstruct %12 %278 %53 +OpStore %223 %279 +%280 = OpLoad %3 %189 +%281 = OpCompositeConstruct %12 %48 %280 +OpStore %225 %281 +%282 = OpLoad %7 %192 +%283 = OpCompositeConstruct %10 %282 %42 +OpStore %227 %283 +%284 = OpLoad %7 %192 +%285 = OpCompositeConstruct %10 %41 %284 +OpStore %229 %285 +%286 = OpLoad %7 %192 +%287 = OpCompositeConstruct %10 %286 %42 +OpStore %231 %287 +%288 = OpLoad %7 %192 +%289 = OpCompositeConstruct %10 %41 %288 +OpStore %233 %289 +%290 = OpLoad %3 %189 +%291 = OpCompositeConstruct %12 %290 %53 +OpStore %235 %291 +%292 = OpLoad %3 %189 +%293 = OpCompositeConstruct %12 %48 %292 +OpStore %237 %293 +%294 = OpLoad %3 %189 +%295 = OpCompositeConstruct %4 %294 %294 +OpStore %239 %295 +%296 = OpLoad %5 %186 +%297 = OpCompositeConstruct %6 %296 %296 +OpStore %241 %297 +%298 = OpLoad %7 %192 +%299 = OpCompositeConstruct %8 %298 %298 +OpStore %243 %299 +%300 = OpLoad %5 %186 +%301 = OpCompositeConstruct %6 %300 %32 +OpStore %195 %301 +%302 = OpLoad %5 %186 +%303 = OpCompositeConstruct %6 %31 %302 +OpStore %197 %303 +%304 = OpLoad %5 %186 +%305 = OpCompositeConstruct %6 %304 %32 +OpStore %203 %305 +%306 = OpLoad %5 %186 +%307 = OpCompositeConstruct %6 %31 %306 +OpStore %205 %307 +%308 = OpLoad %7 %192 +%309 = OpCompositeConstruct %8 %308 %42 +%310 = OpCompositeConstruct %9 %309 %46 +OpStore %207 %310 +%311 = OpLoad %7 %192 +%312 = OpCompositeConstruct %8 %41 %311 +%313 = OpCompositeConstruct %9 %312 %46 +OpStore %209 %313 +%314 = OpLoad %7 %192 +%315 = OpCompositeConstruct %8 %314 %45 +%316 = OpCompositeConstruct %9 %43 %315 +OpStore %211 %316 +%317 = OpLoad %7 %192 +%318 = OpCompositeConstruct %8 %44 %317 +%319 = OpCompositeConstruct %9 %43 %318 +OpStore %213 %319 +%320 = OpLoad %7 %192 +%321 = OpCompositeConstruct %10 %320 %42 +OpStore %215 %321 +%322 = OpLoad %7 %192 +%323 = OpCompositeConstruct %10 %41 %322 +OpStore %217 %323 +%324 = OpLoad %7 %192 +%325 = OpCompositeConstruct %10 %324 %42 +OpStore %219 %325 +%326 = OpLoad %7 %192 +%327 = OpCompositeConstruct %10 %41 %326 +OpStore %221 %327 +%328 = OpLoad %3 %189 +%329 = OpCompositeConstruct %12 %328 %53 +OpStore %223 %329 +%330 = OpLoad %3 %189 +%331 = OpCompositeConstruct %12 %48 %330 +OpStore %225 %331 +%332 = OpLoad %7 %192 +%333 = OpCompositeConstruct %10 %332 %42 +OpStore %227 %333 +%334 = OpLoad %7 %192 +%335 = OpCompositeConstruct %10 %41 %334 +OpStore %229 %335 +%336 = OpLoad %7 %192 +%337 = OpCompositeConstruct %10 %336 %42 +OpStore %231 %337 +%338 = OpLoad %7 %192 +%339 = OpCompositeConstruct %10 %41 %338 +OpStore %233 %339 +%340 = OpLoad %3 %189 +%341 = OpCompositeConstruct %12 %340 %53 +OpStore %235 %341 +%342 = OpLoad %3 %189 +%343 = OpCompositeConstruct %12 %48 %342 +OpStore %237 %343 +%344 = OpLoad %3 %189 +%345 = OpCompositeConstruct %4 %344 %344 +OpStore %239 %345 +%346 = OpLoad %5 %186 +%347 = OpCompositeConstruct %6 %346 %346 +OpStore %241 %347 +%348 = OpLoad %7 %192 +%349 = OpCompositeConstruct %8 %348 %348 +OpStore %243 %349 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/naga/tests/out/spv/constructors.spvasm b/naga/tests/out/spv/constructors.spvasm index afa7deded..233cb2735 100644 --- a/naga/tests/out/spv/constructors.spvasm +++ b/naga/tests/out/spv/constructors.spvasm @@ -1,84 +1,86 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 68 +; Bound: 70 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint GLCompute %38 "main" -OpExecutionMode %38 LocalSize 1 1 1 +OpEntryPoint GLCompute %41 "main" +OpExecutionMode %41 LocalSize 1 1 1 OpMemberDecorate %6 0 Offset 0 OpMemberDecorate %6 1 Offset 16 -OpDecorate %9 ArrayStride 16 -OpDecorate %14 ArrayStride 32 -OpDecorate %17 ArrayStride 4 +OpDecorate %10 ArrayStride 16 +OpDecorate %15 ArrayStride 32 +OpDecorate %18 ArrayStride 4 %2 = OpTypeVoid %3 = OpTypeFloat 32 %4 = OpTypeVector %3 4 %5 = OpTypeInt 32 1 %6 = OpTypeStruct %4 %5 -%8 = OpTypeVector %3 2 -%7 = OpTypeMatrix %8 2 -%11 = OpTypeInt 32 0 -%10 = OpConstant %11 1 -%9 = OpTypeArray %7 %10 -%12 = OpTypeBool -%13 = OpTypeVector %11 2 -%15 = OpConstant %11 3 -%14 = OpTypeArray %6 %15 -%16 = OpTypeMatrix %4 4 -%18 = OpConstant %11 4 -%17 = OpTypeArray %5 %18 -%20 = OpTypeVector %3 3 -%19 = OpTypeMatrix %20 2 +%7 = OpTypeVector %3 3 +%9 = OpTypeVector %3 2 +%8 = OpTypeMatrix %9 2 +%12 = OpTypeInt 32 0 +%11 = OpConstant %12 1 +%10 = OpTypeArray %8 %11 +%13 = OpTypeBool +%14 = OpTypeVector %12 2 +%16 = OpConstant %12 3 +%15 = OpTypeArray %6 %16 +%17 = OpTypeMatrix %4 4 +%19 = OpConstant %12 4 +%18 = OpTypeArray %5 %19 +%20 = OpTypeMatrix %7 2 %21 = OpConstant %3 0.0 -%22 = OpConstant %3 1.0 -%23 = OpConstant %3 2.0 -%24 = OpConstant %3 3.0 -%25 = OpConstantComposite %8 %21 %22 -%26 = OpConstantComposite %8 %23 %24 -%27 = OpConstantComposite %7 %25 %26 -%28 = OpConstantComposite %9 %27 -%29 = OpConstantNull %12 -%30 = OpConstantNull %5 -%31 = OpConstantNull %11 -%32 = OpConstantNull %3 -%33 = OpConstantNull %13 -%34 = OpConstantNull %7 -%35 = OpConstantNull %14 -%36 = OpConstantNull %6 -%39 = OpTypeFunction %2 -%40 = OpConstantComposite %4 %22 %22 %22 %22 -%41 = OpConstant %5 1 -%42 = OpConstantComposite %6 %40 %41 -%43 = OpConstantComposite %8 %22 %21 -%44 = OpConstantComposite %7 %43 %25 -%45 = OpConstantComposite %4 %22 %21 %21 %21 -%46 = OpConstantComposite %4 %21 %22 %21 %21 -%47 = OpConstantComposite %4 %21 %21 %22 %21 -%48 = OpConstantComposite %4 %21 %21 %21 %22 -%49 = OpConstantComposite %16 %45 %46 %47 %48 -%50 = OpConstant %11 0 -%51 = OpConstantComposite %13 %50 %50 -%52 = OpConstantComposite %8 %21 %21 -%53 = OpConstantComposite %7 %52 %52 -%54 = OpConstant %5 0 -%55 = OpConstant %5 2 -%56 = OpConstant %5 3 -%57 = OpConstantComposite %17 %54 %41 %55 %56 -%58 = OpConstantFalse %12 -%59 = OpConstantComposite %13 %50 %50 -%60 = OpConstantComposite %20 %21 %21 %21 -%61 = OpConstantComposite %19 %60 %60 -%62 = OpConstantNull %19 -%63 = OpConstantTrue %12 -%65 = OpTypePointer Function %6 -%66 = OpConstantNull %6 -%38 = OpFunction %2 None %39 -%37 = OpLabel -%64 = OpVariable %65 Function %66 -OpBranch %67 -%67 = OpLabel -OpStore %64 %42 +%22 = OpConstantComposite %7 %21 %21 %21 +%23 = OpConstant %3 1.0 +%24 = OpConstant %3 2.0 +%25 = OpConstant %3 3.0 +%26 = OpConstantComposite %9 %21 %23 +%27 = OpConstantComposite %9 %24 %25 +%28 = OpConstantComposite %8 %26 %27 +%29 = OpConstantComposite %10 %28 +%30 = OpConstantNull %13 +%31 = OpConstantNull %5 +%32 = OpConstantNull %12 +%33 = OpConstantNull %3 +%34 = OpConstantNull %14 +%35 = OpConstantNull %8 +%36 = OpConstantNull %15 +%37 = OpConstantNull %6 +%38 = OpConstant %12 0 +%39 = OpConstantComposite %14 %38 %38 +%42 = OpTypeFunction %2 +%43 = OpConstantComposite %4 %23 %23 %23 %23 +%44 = OpConstant %5 1 +%45 = OpConstantComposite %6 %43 %44 +%46 = OpConstantComposite %9 %23 %21 +%47 = OpConstantComposite %8 %46 %26 +%48 = OpConstantComposite %4 %23 %21 %21 %21 +%49 = OpConstantComposite %4 %21 %23 %21 %21 +%50 = OpConstantComposite %4 %21 %21 %23 %21 +%51 = OpConstantComposite %4 %21 %21 %21 %23 +%52 = OpConstantComposite %17 %48 %49 %50 %51 +%53 = OpConstantComposite %14 %38 %38 +%54 = OpConstantComposite %9 %21 %21 +%55 = OpConstantComposite %9 %21 %21 +%56 = OpConstantComposite %8 %55 %55 +%57 = OpConstant %5 0 +%58 = OpConstant %5 2 +%59 = OpConstant %5 3 +%60 = OpConstantComposite %18 %57 %44 %58 %59 +%61 = OpConstantFalse %13 +%62 = OpConstantComposite %7 %21 %21 %21 +%63 = OpConstantComposite %20 %62 %62 +%64 = OpConstantNull %20 +%65 = OpConstantTrue %13 +%67 = OpTypePointer Function %6 +%68 = OpConstantNull %6 +%41 = OpFunction %2 None %42 +%40 = OpLabel +%66 = OpVariable %67 Function %68 +OpBranch %69 +%69 = OpLabel +OpStore %66 %45 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/naga/tests/out/spv/conversions.spvasm b/naga/tests/out/spv/conversions.spvasm new file mode 100644 index 000000000..5dae778e1 --- /dev/null +++ b/naga/tests/out/spv/conversions.spvasm @@ -0,0 +1,23 @@ +; SPIR-V +; Version: 1.1 +; Generator: rspirv +; Bound: 13 +OpCapability Shader +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %8 "main" +OpExecutionMode %8 LocalSize 1 1 1 +%2 = OpTypeVoid +%4 = OpTypeFloat 32 +%3 = OpTypeVector %4 2 +%5 = OpConstant %4 2.0 +%6 = OpConstantComposite %3 %5 %5 +%9 = OpTypeFunction %2 +%11 = OpTypePointer Function %3 +%8 = OpFunction %2 None %9 +%7 = OpLabel +%10 = OpVariable %11 Function %6 +OpBranch %12 +%12 = OpLabel +OpReturn +OpFunctionEnd \ No newline at end of file diff --git a/naga/tests/out/spv/math-functions.spvasm b/naga/tests/out/spv/math-functions.spvasm index cfdab1f73..a85644d45 100644 --- a/naga/tests/out/spv/math-functions.spvasm +++ b/naga/tests/out/spv/math-functions.spvasm @@ -20,24 +20,24 @@ OpMemberDecorate %15 1 Offset 16 %2 = OpTypeVoid %3 = OpTypeFloat 32 %4 = OpTypeVector %3 4 -%6 = OpTypeInt 32 1 -%5 = OpTypeVector %6 4 -%7 = OpTypeVector %6 2 +%5 = OpTypeInt 32 1 +%6 = OpTypeVector %5 4 +%7 = OpTypeVector %5 2 %9 = OpTypeInt 32 0 %8 = OpTypeVector %9 2 %10 = OpTypeVector %3 2 %11 = OpTypeStruct %3 %3 %12 = OpTypeStruct %10 %10 %13 = OpTypeStruct %4 %4 -%14 = OpTypeStruct %3 %6 -%15 = OpTypeStruct %4 %5 +%14 = OpTypeStruct %3 %5 +%15 = OpTypeStruct %4 %6 %16 = OpTypeVector %3 3 %19 = OpTypeFunction %2 %20 = OpConstant %3 1.0 %21 = OpConstant %3 0.0 %22 = OpConstantComposite %4 %21 %21 %21 %21 -%23 = OpConstant %6 -1 -%24 = OpConstantComposite %5 %23 %23 %23 %23 +%23 = OpConstant %5 -1 +%24 = OpConstantComposite %6 %23 %23 %23 %23 %25 = OpConstant %3 -1.0 %26 = OpConstantComposite %4 %25 %25 %25 %25 %27 = OpConstantNull %7 @@ -45,19 +45,19 @@ OpMemberDecorate %15 1 Offset 16 %29 = OpConstantComposite %7 %23 %23 %30 = OpConstant %9 0 %31 = OpConstantComposite %8 %30 %30 -%32 = OpConstant %6 0 +%32 = OpConstant %5 0 %33 = OpConstantComposite %7 %32 %32 %34 = OpConstant %9 32 -%35 = OpConstant %6 32 +%35 = OpConstant %5 32 %36 = OpConstantComposite %8 %34 %34 %37 = OpConstantComposite %7 %35 %35 %38 = OpConstant %9 31 %39 = OpConstantComposite %8 %38 %38 -%40 = OpConstant %6 2 +%40 = OpConstant %5 2 %41 = OpConstant %3 2.0 %42 = OpConstantComposite %10 %20 %41 -%43 = OpConstant %6 3 -%44 = OpConstant %6 4 +%43 = OpConstant %5 3 +%44 = OpConstant %5 4 %45 = OpConstantComposite %7 %43 %44 %46 = OpConstant %3 1.5 %47 = OpConstantComposite %10 %46 %46 @@ -66,7 +66,7 @@ OpMemberDecorate %15 1 Offset 16 %50 = OpConstantComposite %16 %20 %20 %20 %51 = OpConstantComposite %4 %20 %20 %20 %20 %58 = OpConstantComposite %4 %20 %20 %20 %20 -%61 = OpConstantNull %6 +%61 = OpConstantNull %5 %18 = OpFunction %2 None %19 %17 = OpLabel OpBranch %52 @@ -77,14 +77,14 @@ OpBranch %52 %56 = OpExtInst %4 %1 Radians %22 %57 = OpExtInst %4 %1 FClamp %22 %22 %58 %59 = OpExtInst %4 %1 Refract %22 %22 %20 -%62 = OpCompositeExtract %6 %27 0 -%63 = OpCompositeExtract %6 %27 0 -%64 = OpIMul %6 %62 %63 -%65 = OpIAdd %6 %61 %64 -%66 = OpCompositeExtract %6 %27 1 -%67 = OpCompositeExtract %6 %27 1 -%68 = OpIMul %6 %66 %67 -%60 = OpIAdd %6 %65 %68 +%62 = OpCompositeExtract %5 %27 0 +%63 = OpCompositeExtract %5 %27 0 +%64 = OpIMul %5 %62 %63 +%65 = OpIAdd %5 %61 %64 +%66 = OpCompositeExtract %5 %27 1 +%67 = OpCompositeExtract %5 %27 1 +%68 = OpIMul %5 %66 %67 +%60 = OpIAdd %5 %65 %68 %69 = OpExtInst %3 %1 Ldexp %20 %40 %70 = OpExtInst %10 %1 Ldexp %42 %45 %71 = OpExtInst %11 %1 ModfStruct %46 @@ -103,10 +103,10 @@ OpBranch %52 %84 = OpExtInst %14 %1 FrexpStruct %46 %85 = OpCompositeExtract %3 %84 0 %86 = OpExtInst %14 %1 FrexpStruct %46 -%87 = OpCompositeExtract %6 %86 1 +%87 = OpCompositeExtract %5 %86 1 %88 = OpExtInst %15 %1 FrexpStruct %48 -%89 = OpCompositeExtract %5 %88 1 -%90 = OpCompositeExtract %6 %89 0 +%89 = OpCompositeExtract %6 %88 1 +%90 = OpCompositeExtract %5 %89 0 %91 = OpQuantizeToF16 %3 %20 %92 = OpQuantizeToF16 %10 %49 %93 = OpQuantizeToF16 %16 %50 diff --git a/naga/tests/out/spv/operators.spvasm b/naga/tests/out/spv/operators.spvasm index 0ffb7dc36..687f8eddc 100644 --- a/naga/tests/out/spv/operators.spvasm +++ b/naga/tests/out/spv/operators.spvasm @@ -17,12 +17,12 @@ OpDecorate %509 BuiltIn WorkgroupId %7 = OpTypeVector %8 4 %9 = OpTypeVector %3 2 %10 = OpTypeVector %3 3 -%11 = OpTypeMatrix %10 3 -%12 = OpTypeMatrix %10 4 -%13 = OpTypeMatrix %4 3 -%14 = OpTypeVector %5 3 -%16 = OpTypeInt 32 0 -%15 = OpTypeVector %16 3 +%12 = OpTypeInt 32 0 +%11 = OpTypeVector %12 3 +%13 = OpTypeMatrix %10 3 +%14 = OpTypeMatrix %10 4 +%15 = OpTypeMatrix %4 3 +%16 = OpTypeVector %5 3 %17 = OpConstant %3 1.0 %18 = OpConstantComposite %4 %17 %17 %17 %17 %19 = OpConstant %3 0.0 @@ -71,37 +71,37 @@ OpDecorate %509 BuiltIn WorkgroupId %127 = OpConstantComposite %7 %28 %28 %28 %28 %128 = OpConstantComposite %7 %30 %30 %30 %30 %139 = OpTypeFunction %5 %5 %5 -%151 = OpTypeFunction %16 %16 %16 -%155 = OpConstant %16 0 -%157 = OpConstant %16 1 +%151 = OpTypeFunction %12 %12 %12 +%155 = OpConstant %12 0 +%157 = OpConstant %12 1 %160 = OpTypeVector %5 2 %162 = OpTypeFunction %160 %160 %160 %166 = OpConstantComposite %160 %29 %29 %168 = OpConstantComposite %160 %60 %60 %169 = OpConstantComposite %160 %61 %61 %174 = OpConstantComposite %160 %23 %23 -%178 = OpTypeFunction %15 %15 %15 -%182 = OpConstantComposite %15 %155 %155 %155 -%184 = OpConstantComposite %15 %157 %157 %157 -%223 = OpTypeVector %16 2 +%178 = OpTypeFunction %11 %11 %11 +%182 = OpConstantComposite %11 %155 %155 %155 +%184 = OpConstantComposite %11 %157 %157 %157 +%223 = OpTypeVector %12 2 %225 = OpTypeFunction %223 %223 %223 %229 = OpConstantComposite %223 %155 %155 %231 = OpConstantComposite %223 %157 %157 -%243 = OpConstant %16 2 +%243 = OpConstant %12 2 %244 = OpConstantComposite %160 %82 %82 -%245 = OpConstantComposite %15 %243 %243 %243 +%245 = OpConstantComposite %11 %243 %243 %243 %246 = OpConstantComposite %4 %76 %76 %76 %76 %247 = OpConstantComposite %4 %17 %17 %17 %17 %248 = OpConstantComposite %223 %243 %243 -%249 = OpConstantNull %11 -%250 = OpConstantNull %12 +%249 = OpConstantNull %13 +%250 = OpConstantNull %14 %251 = OpConstantComposite %10 %76 %76 %76 -%252 = OpConstantNull %13 -%416 = OpConstantNull %14 +%252 = OpConstantNull %15 +%416 = OpConstantNull %16 %418 = OpTypePointer Function %5 %419 = OpConstantNull %5 -%421 = OpTypePointer Function %14 -%510 = OpTypePointer Input %15 +%421 = OpTypePointer Function %16 +%510 = OpTypePointer Input %11 %509 = OpVariable %510 Input %513 = OpConstantComposite %10 %17 %17 %17 %26 = OpFunction %4 None %27 @@ -211,13 +211,13 @@ OpFunctionEnd %149 = OpSDiv %5 %140 %148 OpReturnValue %149 OpFunctionEnd -%150 = OpFunction %16 None %151 -%152 = OpFunctionParameter %16 -%153 = OpFunctionParameter %16 +%150 = OpFunction %12 None %151 +%152 = OpFunctionParameter %12 +%153 = OpFunctionParameter %12 %154 = OpLabel %156 = OpIEqual %8 %153 %155 -%158 = OpSelect %16 %156 %157 %153 -%159 = OpUDiv %16 %152 %158 +%158 = OpSelect %12 %156 %157 %153 +%159 = OpUDiv %12 %152 %158 OpReturnValue %159 OpFunctionEnd %161 = OpFunction %160 None %162 @@ -233,13 +233,13 @@ OpFunctionEnd %176 = OpSDiv %160 %163 %175 OpReturnValue %176 OpFunctionEnd -%177 = OpFunction %15 None %178 -%179 = OpFunctionParameter %15 -%180 = OpFunctionParameter %15 +%177 = OpFunction %11 None %178 +%179 = OpFunctionParameter %11 +%180 = OpFunctionParameter %11 %181 = OpLabel %183 = OpIEqual %115 %180 %182 -%185 = OpSelect %15 %183 %184 %180 -%186 = OpUDiv %15 %179 %185 +%185 = OpSelect %11 %183 %184 %180 +%186 = OpUDiv %11 %179 %185 OpReturnValue %186 OpFunctionEnd %187 = OpFunction %5 None %139 @@ -255,13 +255,13 @@ OpFunctionEnd %197 = OpSRem %5 %188 %196 OpReturnValue %197 OpFunctionEnd -%198 = OpFunction %16 None %151 -%199 = OpFunctionParameter %16 -%200 = OpFunctionParameter %16 +%198 = OpFunction %12 None %151 +%199 = OpFunctionParameter %12 +%200 = OpFunctionParameter %12 %201 = OpLabel %202 = OpIEqual %8 %200 %155 -%203 = OpSelect %16 %202 %157 %200 -%204 = OpUMod %16 %199 %203 +%203 = OpSelect %12 %202 %157 %200 +%204 = OpUMod %12 %199 %203 OpReturnValue %204 OpFunctionEnd %205 = OpFunction %160 None %162 @@ -277,13 +277,13 @@ OpFunctionEnd %215 = OpSRem %160 %206 %214 OpReturnValue %215 OpFunctionEnd -%216 = OpFunction %15 None %178 -%217 = OpFunctionParameter %15 -%218 = OpFunctionParameter %15 +%216 = OpFunction %11 None %178 +%217 = OpFunctionParameter %11 +%218 = OpFunctionParameter %11 %219 = OpLabel %220 = OpIEqual %115 %218 %182 -%221 = OpSelect %15 %220 %184 %218 -%222 = OpUMod %15 %217 %221 +%221 = OpSelect %11 %220 %184 %218 +%222 = OpUMod %11 %217 %221 OpReturnValue %222 OpFunctionEnd %224 = OpFunction %223 None %225 @@ -312,34 +312,34 @@ OpBranch %253 %255 = OpSNegate %160 %174 %256 = OpFNegate %9 %97 %257 = OpIAdd %5 %82 %23 -%258 = OpIAdd %16 %243 %157 +%258 = OpIAdd %12 %243 %157 %259 = OpFAdd %3 %76 %17 %260 = OpIAdd %160 %244 %174 -%261 = OpIAdd %15 %245 %184 +%261 = OpIAdd %11 %245 %184 %262 = OpFAdd %4 %246 %247 %263 = OpISub %5 %82 %23 -%264 = OpISub %16 %243 %157 +%264 = OpISub %12 %243 %157 %265 = OpFSub %3 %76 %17 %266 = OpISub %160 %244 %174 -%267 = OpISub %15 %245 %184 +%267 = OpISub %11 %245 %184 %268 = OpFSub %4 %246 %247 %269 = OpIMul %5 %82 %23 -%270 = OpIMul %16 %243 %157 +%270 = OpIMul %12 %243 %157 %271 = OpFMul %3 %76 %17 %272 = OpIMul %160 %244 %174 -%273 = OpIMul %15 %245 %184 +%273 = OpIMul %11 %245 %184 %274 = OpFMul %4 %246 %247 %275 = OpFunctionCall %5 %138 %82 %23 -%276 = OpFunctionCall %16 %150 %243 %157 +%276 = OpFunctionCall %12 %150 %243 %157 %277 = OpFDiv %3 %76 %17 %278 = OpFunctionCall %160 %161 %244 %174 -%279 = OpFunctionCall %15 %177 %245 %184 +%279 = OpFunctionCall %11 %177 %245 %184 %280 = OpFDiv %4 %246 %247 %281 = OpFunctionCall %5 %187 %82 %23 -%282 = OpFunctionCall %16 %198 %243 %157 +%282 = OpFunctionCall %12 %198 %243 %157 %283 = OpFRem %3 %76 %17 %284 = OpFunctionCall %160 %205 %244 %174 -%285 = OpFunctionCall %15 %216 %245 %184 +%285 = OpFunctionCall %11 %216 %245 %184 %286 = OpFRem %4 %246 %247 OpBranch %287 %287 = OpLabel @@ -388,7 +388,7 @@ OpBranch %288 %330 = OpCompositeExtract %10 %249 2 %331 = OpCompositeExtract %10 %249 2 %332 = OpFAdd %10 %330 %331 -%323 = OpCompositeConstruct %11 %326 %329 %332 +%323 = OpCompositeConstruct %13 %326 %329 %332 %334 = OpCompositeExtract %10 %249 0 %335 = OpCompositeExtract %10 %249 0 %336 = OpFSub %10 %334 %335 @@ -398,12 +398,12 @@ OpBranch %288 %340 = OpCompositeExtract %10 %249 2 %341 = OpCompositeExtract %10 %249 2 %342 = OpFSub %10 %340 %341 -%333 = OpCompositeConstruct %11 %336 %339 %342 -%343 = OpMatrixTimesScalar %11 %249 %17 -%344 = OpMatrixTimesScalar %11 %249 %76 +%333 = OpCompositeConstruct %13 %336 %339 %342 +%343 = OpMatrixTimesScalar %13 %249 %17 +%344 = OpMatrixTimesScalar %13 %249 %76 %345 = OpMatrixTimesVector %10 %250 %247 %346 = OpVectorTimesMatrix %4 %251 %250 -%347 = OpMatrixTimesMatrix %11 %250 %252 +%347 = OpMatrixTimesMatrix %13 %250 %252 OpReturn OpFunctionEnd %349 = OpFunction %2 None %122 @@ -411,29 +411,29 @@ OpFunctionEnd OpBranch %350 %350 = OpLabel %351 = OpNot %5 %23 -%352 = OpNot %16 %157 +%352 = OpNot %12 %157 %353 = OpNot %160 %174 -%354 = OpNot %15 %184 +%354 = OpNot %11 %184 %355 = OpBitwiseOr %5 %82 %23 -%356 = OpBitwiseOr %16 %243 %157 +%356 = OpBitwiseOr %12 %243 %157 %357 = OpBitwiseOr %160 %244 %174 -%358 = OpBitwiseOr %15 %245 %184 +%358 = OpBitwiseOr %11 %245 %184 %359 = OpBitwiseAnd %5 %82 %23 -%360 = OpBitwiseAnd %16 %243 %157 +%360 = OpBitwiseAnd %12 %243 %157 %361 = OpBitwiseAnd %160 %244 %174 -%362 = OpBitwiseAnd %15 %245 %184 +%362 = OpBitwiseAnd %11 %245 %184 %363 = OpBitwiseXor %5 %82 %23 -%364 = OpBitwiseXor %16 %243 %157 +%364 = OpBitwiseXor %12 %243 %157 %365 = OpBitwiseXor %160 %244 %174 -%366 = OpBitwiseXor %15 %245 %184 +%366 = OpBitwiseXor %11 %245 %184 %367 = OpShiftLeftLogical %5 %82 %157 -%368 = OpShiftLeftLogical %16 %243 %157 +%368 = OpShiftLeftLogical %12 %243 %157 %369 = OpShiftLeftLogical %160 %244 %231 -%370 = OpShiftLeftLogical %15 %245 %184 +%370 = OpShiftLeftLogical %11 %245 %184 %371 = OpShiftRightArithmetic %5 %82 %157 -%372 = OpShiftRightLogical %16 %243 %157 +%372 = OpShiftRightLogical %12 %243 %157 %373 = OpShiftRightArithmetic %160 %244 %231 -%374 = OpShiftRightLogical %15 %245 %184 +%374 = OpShiftRightLogical %11 %245 %184 OpReturn OpFunctionEnd %376 = OpFunction %2 None %122 @@ -591,13 +591,13 @@ OpReturn OpFunctionEnd %512 = OpFunction %2 None %122 %508 = OpLabel -%511 = OpLoad %15 %509 +%511 = OpLoad %11 %509 OpBranch %514 %514 = OpLabel %515 = OpFunctionCall %4 %26 -%516 = OpCompositeExtract %16 %511 0 +%516 = OpCompositeExtract %12 %511 0 %517 = OpConvertUToF %3 %516 -%518 = OpCompositeExtract %16 %511 1 +%518 = OpCompositeExtract %12 %511 1 %519 = OpBitcast %5 %518 %520 = OpFunctionCall %4 %74 %517 %519 %521 = OpFunctionCall %10 %112 %513 diff --git a/naga/tests/out/spv/type-inference.spvasm b/naga/tests/out/spv/type-inference.spvasm new file mode 100644 index 000000000..adcaa8094 --- /dev/null +++ b/naga/tests/out/spv/type-inference.spvasm @@ -0,0 +1,72 @@ +; SPIR-V +; Version: 1.1 +; Generator: rspirv +; Bound: 57 +OpCapability Shader +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %18 "main" +OpExecutionMode %18 LocalSize 1 1 1 +%2 = OpTypeVoid +%3 = OpTypeInt 32 0 +%4 = OpTypeFloat 32 +%5 = OpTypeInt 32 1 +%6 = OpTypeVector %5 4 +%8 = OpTypeVector %4 2 +%7 = OpTypeMatrix %8 2 +%9 = OpConstant %3 1 +%10 = OpConstant %4 1.0 +%11 = OpConstantNull %6 +%12 = OpConstant %5 1 +%13 = OpConstantComposite %6 %12 %12 %12 %12 +%14 = OpConstant %4 0.0 +%15 = OpConstantComposite %8 %14 %14 +%16 = OpConstantComposite %7 %15 %15 +%19 = OpTypeFunction %2 +%20 = OpConstantComposite %8 %10 %10 +%21 = OpConstantComposite %7 %20 %20 +%23 = OpTypePointer Function %5 +%25 = OpTypePointer Function %4 +%27 = OpTypePointer Function %7 +%30 = OpTypePointer Function %3 +%34 = OpTypePointer Function %6 +%39 = OpConstantNull %5 +%41 = OpConstantNull %3 +%43 = OpConstantNull %4 +%45 = OpConstantNull %4 +%47 = OpConstantNull %6 +%18 = OpFunction %2 None %19 +%17 = OpLabel +%54 = OpVariable %27 Function %16 +%51 = OpVariable %25 Function %10 +%48 = OpVariable %23 Function %12 +%42 = OpVariable %25 Function %43 +%37 = OpVariable %27 Function %21 +%33 = OpVariable %34 Function %11 +%29 = OpVariable %30 Function %9 +%24 = OpVariable %25 Function %10 +%53 = OpVariable %34 Function %13 +%50 = OpVariable %25 Function %10 +%46 = OpVariable %34 Function %47 +%40 = OpVariable %30 Function %41 +%36 = OpVariable %27 Function %16 +%32 = OpVariable %25 Function %10 +%28 = OpVariable %23 Function %12 +%22 = OpVariable %23 Function %12 +%55 = OpVariable %27 Function %21 +%52 = OpVariable %34 Function %11 +%49 = OpVariable %30 Function %9 +%44 = OpVariable %25 Function %45 +%38 = OpVariable %23 Function %39 +%35 = OpVariable %34 Function %13 +%31 = OpVariable %25 Function %10 +%26 = OpVariable %27 Function %21 +OpBranch %56 +%56 = OpLabel +OpStore %38 %12 +OpStore %40 %9 +OpStore %42 %10 +OpStore %44 %10 +OpStore %46 %11 +OpReturn +OpFunctionEnd \ No newline at end of file diff --git a/naga/tests/out/wgsl/abstract-types-const.wgsl b/naga/tests/out/wgsl/abstract-types-const.wgsl index 649740f8c..5807ce098 100644 --- a/naga/tests/out/wgsl/abstract-types-const.wgsl +++ b/naga/tests/out/wgsl/abstract-types-const.wgsl @@ -4,12 +4,19 @@ struct S { u: u32, } -const xvupaiai: vec2 = vec2(42u, 43u); -const xvfpaiai: vec2 = vec2(44f, 45f); +const xvipaiai: vec2 = vec2(42i, 43i); +const xvupaiai: vec2 = vec2(44u, 45u); +const xvfpaiai: vec2 = vec2(46f, 47f); +const xvfpafaf: vec2 = vec2(48f, 49f); +const xvfpaiaf: vec2 = vec2(48f, 49f); const xvupuai: vec2 = vec2(42u, 43u); const xvupaiu: vec2 = vec2(42u, 43u); const xvuuai: vec2 = vec2(42u, 43u); const xvuaiu: vec2 = vec2(42u, 43u); +const xvip: vec2 = vec2(0i, 0i); +const xvup: vec2 = vec2(0u, 0u); +const xvfp: vec2 = vec2(0f, 0f); +const xmfp: mat2x2 = mat2x2(vec2(0f, 0f), vec2(0f, 0f)); const xmfpaiaiaiai: mat2x2 = mat2x2(vec2(1f, 2f), vec2(3f, 4f)); const xmfpafaiaiai: mat2x2 = mat2x2(vec2(1f, 2f), vec2(3f, 4f)); const xmfpaiafaiai: mat2x2 = mat2x2(vec2(1f, 2f), vec2(3f, 4f)); @@ -21,6 +28,10 @@ const ivfs_ai: vec2 = vec2(1f); const ivfs_af: vec2 = vec2(1f); const iafafaf: array = array(1f, 2f); const iafaiai: array = array(1f, 2f); +const xaipaiai: array = array(1i, 2i); +const xaupaiai: array = array(1u, 2u); +const xafpaiaf: array = array(1f, 2f); +const xafpafai: array = array(1f, 2f); const xafpafaf: array = array(1f, 2f); const s_f_i_u: S = S(1f, 1i, 1u); const s_f_iai: S = S(1f, 1i, 1u); @@ -30,6 +41,10 @@ const saf_i_u: S = S(1f, 1i, 1u); const saf_iai: S = S(1f, 1i, 1u); const safai_u: S = S(1f, 1i, 1u); const safaiai: S = S(1f, 1i, 1u); +const xvisai: vec2 = vec2(1i); +const xvusai: vec2 = vec2(1u); +const xvfsai: vec2 = vec2(1f); +const xvfsaf: vec2 = vec2(1f); const ivfr_f_f: vec3 = vec3(vec2(1f, 2f), 3f); const ivfr_f_af: vec3 = vec3(vec2(1f, 2f), 3f); const ivfraf_f: vec3 = vec3(vec2(1f, 2f), 3f); diff --git a/naga/tests/out/wgsl/abstract-types-let.wgsl b/naga/tests/out/wgsl/abstract-types-let.wgsl new file mode 100644 index 000000000..ea9cc2d3f --- /dev/null +++ b/naga/tests/out/wgsl/abstract-types-let.wgsl @@ -0,0 +1,112 @@ +fn all_constant_arguments() { + let xvipaiai = vec2(42i, 43i); + let xvupaiai = vec2(44u, 45u); + let xvfpaiai = vec2(46f, 47f); + let xvfpafaf = vec2(48f, 49f); + let xvfpaiaf = vec2(48f, 49f); + let xvupuai = vec2(42u, 43u); + let xvupaiu = vec2(42u, 43u); + let xvuuai = vec2(42u, 43u); + let xvuaiu = vec2(42u, 43u); + let xvip = vec2(0i, 0i); + let xvup = vec2(0u, 0u); + let xvfp = vec2(0f, 0f); + let xmfp = mat2x2(vec2(0f, 0f), vec2(0f, 0f)); + let xmfpaiaiaiai = mat2x2(vec2(1f, 2f), vec2(3f, 4f)); + let xmfpafaiaiai = mat2x2(vec2(1f, 2f), vec2(3f, 4f)); + let xmfpaiafaiai = mat2x2(vec2(1f, 2f), vec2(3f, 4f)); + let xmfpaiaiafai = mat2x2(vec2(1f, 2f), vec2(3f, 4f)); + let xmfpaiaiaiaf = mat2x2(vec2(1f, 2f), vec2(3f, 4f)); + let xmfp_faiaiai = mat2x2(vec2(1f, 2f), vec2(3f, 4f)); + let xmfpai_faiai = mat2x2(vec2(1f, 2f), vec2(3f, 4f)); + let xmfpaiai_fai = mat2x2(vec2(1f, 2f), vec2(3f, 4f)); + let xmfpaiaiai_f = mat2x2(vec2(1f, 2f), vec2(3f, 4f)); + let xvispai = vec2(1i); + let xvfspaf = vec2(1f); + let xvis_ai = vec2(1i); + let xvus_ai = vec2(1u); + let xvfs_ai = vec2(1f); + let xvfs_af = vec2(1f); + let xafafaf = array(1f, 2f); + let xaf_faf = array(1f, 2f); + let xafaf_f = array(1f, 2f); + let xafaiai = array(1f, 2f); + let xai_iai = array(1i, 2i); + let xaiai_i = array(1i, 2i); + let xaipaiai = array(1i, 2i); + let xafpaiai = array(1f, 2f); + let xafpaiaf = array(1f, 2f); + let xafpafai = array(1f, 2f); + let xafpafaf = array(1f, 2f); + let xavipai = array, 1>(vec3(1i)); + let xavfpai = array, 1>(vec3(1f)); + let xavfpaf = array, 1>(vec3(1f)); + let xvisai = vec2(1i); + let xvusai = vec2(1u); + let xvfsai = vec2(1f); + let xvfsaf = vec2(1f); + let iaipaiai = array(1i, 2i); + let iafpaiaf = array(1f, 2f); + let iafpafai = array(1f, 2f); + let iafpafaf = array(1f, 2f); + return; +} + +fn mixed_constant_and_runtime_arguments() { + var u: u32; + var i: i32; + var f: f32; + + let _e3 = u; + let xvupuai_1 = vec2(_e3, 43u); + let _e6 = u; + let xvupaiu_1 = vec2(42u, _e6); + let _e9 = f; + let xvfpfai = vec2(_e9, 47f); + let _e12 = f; + let xvfpfaf = vec2(_e12, 49f); + let _e15 = u; + let xvuuai_1 = vec2(_e15, 43u); + let _e18 = u; + let xvuaiu_1 = vec2(42u, _e18); + let _e21 = f; + let xmfp_faiaiai_1 = mat2x2(vec2(_e21, 2f), vec2(3f, 4f)); + let _e28 = f; + let xmfpai_faiai_1 = mat2x2(vec2(1f, _e28), vec2(3f, 4f)); + let _e35 = f; + let xmfpaiai_fai_1 = mat2x2(vec2(1f, 2f), vec2(_e35, 4f)); + let _e42 = f; + let xmfpaiaiai_f_1 = mat2x2(vec2(1f, 2f), vec2(3f, _e42)); + let _e49 = f; + let xaf_faf_1 = array(_e49, 2f); + let _e52 = f; + let xafaf_f_1 = array(1f, _e52); + let _e55 = f; + let xaf_fai = array(_e55, 2f); + let _e58 = f; + let xafai_f = array(1f, _e58); + let _e61 = i; + let xai_iai_1 = array(_e61, 2i); + let _e64 = i; + let xaiai_i_1 = array(1i, _e64); + let _e67 = f; + let xafp_faf = array(_e67, 2f); + let _e70 = f; + let xafpaf_f = array(1f, _e70); + let _e73 = f; + let xafp_fai = array(_e73, 2f); + let _e76 = f; + let xafpai_f = array(1f, _e76); + let _e79 = i; + let xaip_iai = array(_e79, 2i); + let _e82 = i; + let xaipai_i = array(1i, _e82); + let _e85 = i; + let xvisi = vec2(_e85); + let _e87 = u; + let xvusu = vec2(_e87); + let _e89 = f; + let xvfsf = vec2(_e89); + return; +} + diff --git a/naga/tests/out/wgsl/abstract-types-var.wgsl b/naga/tests/out/wgsl/abstract-types-var.wgsl index 58d5f414f..505cc2598 100644 --- a/naga/tests/out/wgsl/abstract-types-var.wgsl +++ b/naga/tests/out/wgsl/abstract-types-var.wgsl @@ -1,10 +1,16 @@ var xvipaiai_1: vec2 = vec2(42i, 43i); var xvupaiai_1: vec2 = vec2(44u, 45u); var xvfpaiai_1: vec2 = vec2(46f, 47f); +var xvfpafaf_1: vec2 = vec2(48f, 49f); +var xvfpaiaf_1: vec2 = vec2(48f, 49f); var xvupuai_2: vec2 = vec2(42u, 43u); var xvupaiu_2: vec2 = vec2(42u, 43u); var xvuuai_2: vec2 = vec2(42u, 43u); var xvuaiu_2: vec2 = vec2(42u, 43u); +var xvip_1: vec2 = vec2(0i, 0i); +var xvup_1: vec2 = vec2(0u, 0u); +var xvfp_1: vec2 = vec2(0f, 0f); +var xmfp_1: mat2x2 = mat2x2(vec2(0f, 0f), vec2(0f, 0f)); var xmfpaiaiaiai_1: mat2x2 = mat2x2(vec2(1f, 2f), vec2(3f, 4f)); var xmfpafaiaiai_1: mat2x2 = mat2x2(vec2(1f, 2f), vec2(3f, 4f)); var xmfpaiafaiai_1: mat2x2 = mat2x2(vec2(1f, 2f), vec2(3f, 4f)); @@ -18,13 +24,18 @@ var xvfs_ai_1: vec2 = vec2(1f); var xvfs_af_1: vec2 = vec2(1f); var xafafaf_1: array = array(1f, 2f); var xafaiai_1: array = array(1f, 2f); -var xafpaiai_1: array = array(1i, 2i); +var xaipaiai_1: array = array(1i, 2i); +var xaupaiai: array = array(1u, 2u); var xafpaiaf_1: array = array(1f, 2f); var xafpafai_1: array = array(1f, 2f); var xafpafaf_1: array = array(1f, 2f); var xavipai_1: array, 1> = array, 1>(vec3(1i)); var xavfpai_1: array, 1> = array, 1>(vec3(1f)); var xavfpaf_1: array, 1> = array, 1>(vec3(1f)); +var xvisai_1: vec2 = vec2(1i); +var xvusai_1: vec2 = vec2(1u); +var xvfsai_1: vec2 = vec2(1f); +var xvfsaf_1: vec2 = vec2(1f); var ivispai: vec2 = vec2(1i); var ivfspaf: vec2 = vec2(1f); var ivis_ai: vec2 = vec2(1i); @@ -45,10 +56,16 @@ fn all_constant_arguments() { var xvipaiai: vec2 = vec2(42i, 43i); var xvupaiai: vec2 = vec2(44u, 45u); var xvfpaiai: vec2 = vec2(46f, 47f); + var xvfpafaf: vec2 = vec2(48f, 49f); + var xvfpaiaf: vec2 = vec2(48f, 49f); var xvupuai: vec2 = vec2(42u, 43u); var xvupaiu: vec2 = vec2(42u, 43u); var xvuuai: vec2 = vec2(42u, 43u); var xvuaiu: vec2 = vec2(42u, 43u); + var xvip: vec2 = vec2(0i, 0i); + var xvup: vec2 = vec2(0u, 0u); + var xvfp: vec2 = vec2(0f, 0f); + var xmfp: mat2x2 = mat2x2(vec2(0f, 0f), vec2(0f, 0f)); var xmfpaiaiaiai: mat2x2 = mat2x2(vec2(1f, 2f), vec2(3f, 4f)); var xmfpafaiaiai: mat2x2 = mat2x2(vec2(1f, 2f), vec2(3f, 4f)); var xmfpaiafaiai: mat2x2 = mat2x2(vec2(1f, 2f), vec2(3f, 4f)); @@ -78,6 +95,10 @@ fn all_constant_arguments() { var xavipai: array, 1> = array, 1>(vec3(1i)); var xavfpai: array, 1> = array, 1>(vec3(1f)); var xavfpaf: array, 1> = array, 1>(vec3(1f)); + var xvisai: vec2 = vec2(1i); + var xvusai: vec2 = vec2(1u); + var xvfsai: vec2 = vec2(1f); + var xvfsaf: vec2 = vec2(1f); var iaipaiai: array = array(1i, 2i); var iafpaiaf: array = array(1f, 2f); var iafpafai: array = array(1f, 2f); @@ -86,10 +107,16 @@ fn all_constant_arguments() { xvipaiai = vec2(42i, 43i); xvupaiai = vec2(44u, 45u); xvfpaiai = vec2(46f, 47f); + xvfpafaf = vec2(48f, 49f); + xvfpaiaf = vec2(48f, 49f); xvupuai = vec2(42u, 43u); xvupaiu = vec2(42u, 43u); xvuuai = vec2(42u, 43u); xvuaiu = vec2(42u, 43u); + xvip = vec2(0i, 0i); + xvup = vec2(0u, 0u); + xvfp = vec2(0f, 0f); + xmfp = mat2x2(vec2(0f, 0f), vec2(0f, 0f)); xmfpaiaiaiai = mat2x2(vec2(1f, 2f), vec2(3f, 4f)); xmfpafaiaiai = mat2x2(vec2(1f, 2f), vec2(3f, 4f)); xmfpaiafaiai = mat2x2(vec2(1f, 2f), vec2(3f, 4f)); @@ -119,6 +146,10 @@ fn all_constant_arguments() { xavipai = array, 1>(vec3(1i)); xavfpai = array, 1>(vec3(1f)); xavfpaf = array, 1>(vec3(1f)); + xvisai = vec2(1i); + xvusai = vec2(1u); + xvfsai = vec2(1f); + xvfsaf = vec2(1f); iaipaiai = array(1i, 2i); iafpaiaf = array(1f, 2f); iafpafai = array(1f, 2f); @@ -132,6 +163,8 @@ fn mixed_constant_and_runtime_arguments() { var f: f32; var xvupuai_1: vec2; var xvupaiu_1: vec2; + var xvfpfai: vec2; + var xvfpfaf: vec2; var xvuuai_1: vec2; var xvuaiu_1: vec2; var xmfp_faiaiai_1: mat2x2; @@ -150,87 +183,106 @@ fn mixed_constant_and_runtime_arguments() { var xafpai_f: array; var xaip_iai: array; var xaipai_i: array; + var xvisi: vec2; + var xvusu: vec2; + var xvfsf: vec2; let _e3 = u; xvupuai_1 = vec2(_e3, 43u); let _e7 = u; xvupaiu_1 = vec2(42u, _e7); - let _e11 = u; - xvuuai_1 = vec2(_e11, 43u); - let _e15 = u; - xvuaiu_1 = vec2(42u, _e15); - let _e19 = f; - xmfp_faiaiai_1 = mat2x2(vec2(_e19, 2f), vec2(3f, 4f)); + let _e11 = f; + xvfpfai = vec2(_e11, 47f); + let _e15 = f; + xvfpfaf = vec2(_e15, 49f); + let _e19 = u; + xvuuai_1 = vec2(_e19, 43u); + let _e23 = u; + xvuaiu_1 = vec2(42u, _e23); let _e27 = f; - xmfpai_faiai_1 = mat2x2(vec2(1f, _e27), vec2(3f, 4f)); + xmfp_faiaiai_1 = mat2x2(vec2(_e27, 2f), vec2(3f, 4f)); let _e35 = f; - xmfpaiai_fai_1 = mat2x2(vec2(1f, 2f), vec2(_e35, 4f)); + xmfpai_faiai_1 = mat2x2(vec2(1f, _e35), vec2(3f, 4f)); let _e43 = f; - xmfpaiaiai_f_1 = mat2x2(vec2(1f, 2f), vec2(3f, _e43)); + xmfpaiai_fai_1 = mat2x2(vec2(1f, 2f), vec2(_e43, 4f)); let _e51 = f; - xaf_faf_1 = array(_e51, 2f); - let _e55 = f; - xafaf_f_1 = array(1f, _e55); + xmfpaiaiai_f_1 = mat2x2(vec2(1f, 2f), vec2(3f, _e51)); let _e59 = f; - xaf_fai = array(_e59, 2f); + xaf_faf_1 = array(_e59, 2f); let _e63 = f; - xafai_f = array(1f, _e63); - let _e67 = i; - xai_iai_1 = array(_e67, 2i); - let _e71 = i; - xaiai_i_1 = array(1i, _e71); - let _e75 = f; - xafp_faf = array(_e75, 2f); - let _e79 = f; - xafpaf_f = array(1f, _e79); + xafaf_f_1 = array(1f, _e63); + let _e67 = f; + xaf_fai = array(_e67, 2f); + let _e71 = f; + xafai_f = array(1f, _e71); + let _e75 = i; + xai_iai_1 = array(_e75, 2i); + let _e79 = i; + xaiai_i_1 = array(1i, _e79); let _e83 = f; - xafp_fai = array(_e83, 2f); + xafp_faf = array(_e83, 2f); let _e87 = f; - xafpai_f = array(1f, _e87); - let _e91 = i; - xaip_iai = array(_e91, 2i); - let _e95 = i; - xaipai_i = array(1i, _e95); - let _e99 = u; - xvupuai_1 = vec2(_e99, 43u); - let _e102 = u; - xvupaiu_1 = vec2(42u, _e102); - let _e105 = u; - xvuuai_1 = vec2(_e105, 43u); - let _e108 = u; - xvuaiu_1 = vec2(42u, _e108); - let _e111 = f; - xmfp_faiaiai_1 = mat2x2(vec2(_e111, 2f), vec2(3f, 4f)); - let _e118 = f; - xmfpai_faiai_1 = mat2x2(vec2(1f, _e118), vec2(3f, 4f)); - let _e125 = f; - xmfpaiai_fai_1 = mat2x2(vec2(1f, 2f), vec2(_e125, 4f)); - let _e132 = f; - xmfpaiaiai_f_1 = mat2x2(vec2(1f, 2f), vec2(3f, _e132)); - let _e139 = f; - xaf_faf_1 = array(_e139, 2f); + xafpaf_f = array(1f, _e87); + let _e91 = f; + xafp_fai = array(_e91, 2f); + let _e95 = f; + xafpai_f = array(1f, _e95); + let _e99 = i; + xaip_iai = array(_e99, 2i); + let _e103 = i; + xaipai_i = array(1i, _e103); + let _e107 = i; + xvisi = vec2(_e107); + let _e110 = u; + xvusu = vec2(_e110); + let _e113 = f; + xvfsf = vec2(_e113); + let _e116 = u; + xvupuai_1 = vec2(_e116, 43u); + let _e119 = u; + xvupaiu_1 = vec2(42u, _e119); + let _e122 = u; + xvuuai_1 = vec2(_e122, 43u); + let _e125 = u; + xvuaiu_1 = vec2(42u, _e125); + let _e128 = f; + xmfp_faiaiai_1 = mat2x2(vec2(_e128, 2f), vec2(3f, 4f)); + let _e135 = f; + xmfpai_faiai_1 = mat2x2(vec2(1f, _e135), vec2(3f, 4f)); let _e142 = f; - xafaf_f_1 = array(1f, _e142); - let _e145 = f; - xaf_fai = array(_e145, 2f); - let _e148 = f; - xafai_f = array(1f, _e148); - let _e151 = i; - xai_iai_1 = array(_e151, 2i); - let _e154 = i; - xaiai_i_1 = array(1i, _e154); - let _e157 = f; - xafp_faf = array(_e157, 2f); - let _e160 = f; - xafpaf_f = array(1f, _e160); - let _e163 = f; - xafp_fai = array(_e163, 2f); - let _e166 = f; - xafpai_f = array(1f, _e166); - let _e169 = i; - xaip_iai = array(_e169, 2i); - let _e172 = i; - xaipai_i = array(1i, _e172); + xmfpaiai_fai_1 = mat2x2(vec2(1f, 2f), vec2(_e142, 4f)); + let _e149 = f; + xmfpaiaiai_f_1 = mat2x2(vec2(1f, 2f), vec2(3f, _e149)); + let _e156 = f; + xaf_faf_1 = array(_e156, 2f); + let _e159 = f; + xafaf_f_1 = array(1f, _e159); + let _e162 = f; + xaf_fai = array(_e162, 2f); + let _e165 = f; + xafai_f = array(1f, _e165); + let _e168 = i; + xai_iai_1 = array(_e168, 2i); + let _e171 = i; + xaiai_i_1 = array(1i, _e171); + let _e174 = f; + xafp_faf = array(_e174, 2f); + let _e177 = f; + xafpaf_f = array(1f, _e177); + let _e180 = f; + xafp_fai = array(_e180, 2f); + let _e183 = f; + xafpai_f = array(1f, _e183); + let _e186 = i; + xaip_iai = array(_e186, 2i); + let _e189 = i; + xaipai_i = array(1i, _e189); + let _e192 = i; + xvisi = vec2(_e192); + let _e194 = u; + xvusu = vec2(_e194); + let _e196 = f; + xvfsf = vec2(_e196); return; } diff --git a/naga/tests/out/wgsl/constructors.wgsl b/naga/tests/out/wgsl/constructors.wgsl index 039b4f971..bcab8e699 100644 --- a/naga/tests/out/wgsl/constructors.wgsl +++ b/naga/tests/out/wgsl/constructors.wgsl @@ -3,6 +3,7 @@ struct Foo { b: i32, } +const const1_: vec3 = vec3(0f); const const3_: mat2x2 = mat2x2(vec2(0f, 1f), vec2(2f, 3f)); const const4_: array, 1> = array, 1>(mat2x2(vec2(0f, 1f), vec2(2f, 3f))); const cz0_: bool = bool(); @@ -13,6 +14,7 @@ const cz4_: vec2 = vec2(); const cz5_: mat2x2 = mat2x2(); const cz6_: array = array(); const cz7_: Foo = Foo(); +const cp1_: vec2 = vec2(0u); @compute @workgroup_size(1, 1, 1) fn main() { @@ -21,6 +23,8 @@ fn main() { foo = Foo(vec4(1f), 1i); let m0_ = mat2x2(vec2(1f, 0f), vec2(0f, 1f)); let m1_ = mat4x4(vec4(1f, 0f, 0f, 0f), vec4(0f, 1f, 0f, 0f), vec4(0f, 0f, 1f, 0f), vec4(0f, 0f, 0f, 1f)); + let zvc8_ = vec2(0u, 0u); + let zvc9_ = vec2(0f, 0f); let cit0_ = vec2(0u); let cit1_ = mat2x2(vec2(0f), vec2(0f)); let cit2_ = array(0i, 1i, 2i, 3i); diff --git a/naga/tests/out/wgsl/conversions.wgsl b/naga/tests/out/wgsl/conversions.wgsl new file mode 100644 index 000000000..2d24e5a53 --- /dev/null +++ b/naga/tests/out/wgsl/conversions.wgsl @@ -0,0 +1,9 @@ +const ic0_: vec2 = vec2(2f, 2f); + +@compute @workgroup_size(1, 1, 1) +fn main() { + var vc0_: vec2 = vec2(2f, 2f); + + let lc0_ = vec2(2f, 2f); + return; +} diff --git a/naga/tests/out/wgsl/type-inference.wgsl b/naga/tests/out/wgsl/type-inference.wgsl new file mode 100644 index 000000000..487752bb2 --- /dev/null +++ b/naga/tests/out/wgsl/type-inference.wgsl @@ -0,0 +1,43 @@ +const g1_: u32 = 1u; +const g3_: f32 = 1f; +const g4_: vec4 = vec4(); +const g5_: vec4 = vec4(1i); +const g6_: mat2x2 = mat2x2(vec2(0f, 0f), vec2(0f, 0f)); + +@compute @workgroup_size(1, 1, 1) +fn main() { + var g0x: i32 = 1i; + var g2x: f32 = 1f; + var g7x: mat2x2 = mat2x2(vec2(1f, 1f), vec2(1f, 1f)); + var c0x: i32 = 1i; + var c1x: u32 = 1u; + var c2x: f32 = 1f; + var c3x: f32 = 1f; + var c4x: vec4 = vec4(); + var c5x: vec4 = vec4(1i); + var c6x: mat2x2 = mat2x2(vec2(0f, 0f), vec2(0f, 0f)); + var c7x: mat2x2 = mat2x2(vec2(1f, 1f), vec2(1f, 1f)); + var l0x: i32; + var l1x: u32; + var l2x: f32; + var l3x: f32; + var l4x: vec4; + var v0_: i32 = 1i; + var v1_: u32 = 1u; + var v2_: f32 = 1f; + var v3_: f32 = 1f; + var v4_: vec4 = vec4(); + var v5_: vec4 = vec4(1i); + var v6_: mat2x2 = mat2x2(vec2(0f, 0f), vec2(0f, 0f)); + var v7_: mat2x2 = mat2x2(vec2(1f, 1f), vec2(1f, 1f)); + + let l5_ = vec4(1i); + let l6_ = mat2x2(vec2(0f, 0f), vec2(0f, 0f)); + let l7_ = mat2x2(vec2(1f, 1f), vec2(1f, 1f)); + l0x = 1i; + l1x = 1u; + l2x = 1f; + l3x = 1f; + l4x = vec4(); + return; +} From f11b3b98e3c957b5939743cb9b052e3cb8033fe4 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Tue, 28 Jan 2025 15:59:10 -0800 Subject: [PATCH 016/806] [naga] Move `TypeInner::automatically_converts_to` into `proc`. Make the associated function `TypeInner::automatically_converts_to` available outside the WGSL front end by moving it into the `proc::type_methods` module. --- naga/src/front/wgsl/lower/conversion.rs | 90 -------------------- naga/src/proc/type_methods.rs | 105 ++++++++++++++++++++++++ 2 files changed, 105 insertions(+), 90 deletions(-) diff --git a/naga/src/front/wgsl/lower/conversion.rs b/naga/src/front/wgsl/lower/conversion.rs index d750f20b1..9e6c0fa4b 100644 --- a/naga/src/front/wgsl/lower/conversion.rs +++ b/naga/src/front/wgsl/lower/conversion.rs @@ -339,96 +339,6 @@ impl<'source> super::ExpressionContext<'source, '_, '_> { } impl crate::TypeInner { - /// Determine whether `self` automatically converts to `goal`. - /// - /// If WGSL's automatic conversions (excluding the Load Rule) will - /// convert `self` to `goal`, then return a pair `(from, to)`, - /// where `from` and `to` are the scalar types of the leaf values - /// of `self` and `goal`. - /// - /// This function assumes that `self` and `goal` are different - /// types. Callers should first check whether any conversion is - /// needed at all. - /// - /// If the automatic conversions cannot convert `self` to `goal`, - /// return `None`. - fn automatically_converts_to( - &self, - goal: &Self, - types: &crate::UniqueArena, - ) -> Option<(crate::Scalar, crate::Scalar)> { - use crate::ScalarKind as Sk; - use crate::TypeInner as Ti; - - // Automatic conversions only change the scalar type of a value's leaves - // (e.g., `vec4` to `vec4`), never the type - // constructors applied to those scalar types (e.g., never scalar to - // `vec4`, or `vec2` to `vec3`). So first we check that the type - // constructors match, extracting the leaf scalar types in the process. - let expr_scalar; - let goal_scalar; - match (self, goal) { - (&Ti::Scalar(expr), &Ti::Scalar(goal)) => { - expr_scalar = expr; - goal_scalar = goal; - } - ( - &Ti::Vector { - size: expr_size, - scalar: expr, - }, - &Ti::Vector { - size: goal_size, - scalar: goal, - }, - ) if expr_size == goal_size => { - expr_scalar = expr; - goal_scalar = goal; - } - ( - &Ti::Matrix { - rows: expr_rows, - columns: expr_columns, - scalar: expr, - }, - &Ti::Matrix { - rows: goal_rows, - columns: goal_columns, - scalar: goal, - }, - ) if expr_rows == goal_rows && expr_columns == goal_columns => { - expr_scalar = expr; - goal_scalar = goal; - } - ( - &Ti::Array { - base: expr_base, - size: expr_size, - stride: _, - }, - &Ti::Array { - base: goal_base, - size: goal_size, - stride: _, - }, - ) if expr_size == goal_size => { - return types[expr_base] - .inner - .automatically_converts_to(&types[goal_base].inner, types); - } - _ => return None, - } - - match (expr_scalar.kind, goal_scalar.kind) { - (Sk::AbstractFloat, Sk::Float) => {} - (Sk::AbstractInt, Sk::Sint | Sk::Uint | Sk::AbstractFloat | Sk::Float) => {} - _ => return None, - } - - log::trace!(" okay: expr {expr_scalar:?}, goal {goal_scalar:?}"); - Some((expr_scalar, goal_scalar)) - } - fn automatically_convertible_scalar( &self, types: &crate::UniqueArena, diff --git a/naga/src/proc/type_methods.rs b/naga/src/proc/type_methods.rs index 07528c996..968cb4ce3 100644 --- a/naga/src/proc/type_methods.rs +++ b/naga/src/proc/type_methods.rs @@ -326,6 +326,111 @@ impl crate::TypeInner { | crate::TypeInner::BindingArray { .. } => false, } } + + /// Determine whether `self` automatically converts to `goal`. + /// + /// If Naga IR's automatic conversions will convert `self` to + /// `goal`, then return a pair `(from, to)`, where `from` and `to` + /// are the scalar types of the leaf values of `self` and `goal`. + /// + /// If `self` and `goal` are the same type, this will simply return + /// a pair `(S, S)`. + /// + /// If the automatic conversions cannot convert `self` to `goal`, + /// return `None`. + /// + /// Naga IR's automatic conversions will convert: + /// + /// - [`AbstractInt`] scalars to [`AbstractFloat`] or any numeric scalar type + /// + /// - [`AbstractFloat`] scalars to any floating-point scalar type + /// + /// - A [`Vector`] `{ size, scalar: S }` to `{ size, scalar: T }` + /// if they would convert `S` to `T` + /// + /// - An [`Array`] `{ base: S, size, stride }` to `{ base: T, size, stride }` + /// if they would convert `S` to `T` + /// + /// [`AbstractInt`]: crate::ScalarKind::AbstractInt + /// [`AbstractFloat`]: crate::ScalarKind::AbstractFloat + /// [`Vector`]: crate::TypeInner::Vector + /// [`Array`]: crate::TypeInner::Array + pub fn automatically_converts_to( + &self, + goal: &Self, + types: &crate::UniqueArena, + ) -> Option<(crate::Scalar, crate::Scalar)> { + use crate::ScalarKind as Sk; + use crate::TypeInner as Ti; + + // Automatic conversions only change the scalar type of a value's leaves + // (e.g., `vec4` to `vec4`), never the type + // constructors applied to those scalar types (e.g., never scalar to + // `vec4`, or `vec2` to `vec3`). So first we check that the type + // constructors match, extracting the leaf scalar types in the process. + let expr_scalar; + let goal_scalar; + match (self, goal) { + (&Ti::Scalar(expr), &Ti::Scalar(goal)) => { + expr_scalar = expr; + goal_scalar = goal; + } + ( + &Ti::Vector { + size: expr_size, + scalar: expr, + }, + &Ti::Vector { + size: goal_size, + scalar: goal, + }, + ) if expr_size == goal_size => { + expr_scalar = expr; + goal_scalar = goal; + } + ( + &Ti::Matrix { + rows: expr_rows, + columns: expr_columns, + scalar: expr, + }, + &Ti::Matrix { + rows: goal_rows, + columns: goal_columns, + scalar: goal, + }, + ) if expr_rows == goal_rows && expr_columns == goal_columns => { + expr_scalar = expr; + goal_scalar = goal; + } + ( + &Ti::Array { + base: expr_base, + size: expr_size, + stride: _, + }, + &Ti::Array { + base: goal_base, + size: goal_size, + stride: _, + }, + ) if expr_size == goal_size => { + return types[expr_base] + .inner + .automatically_converts_to(&types[goal_base].inner, types); + } + _ => return None, + } + + match (expr_scalar.kind, goal_scalar.kind) { + (Sk::AbstractFloat, Sk::Float) => {} + (Sk::AbstractInt, Sk::Sint | Sk::Uint | Sk::AbstractFloat | Sk::Float) => {} + _ => return None, + } + + log::trace!(" okay: expr {expr_scalar:?}, goal {goal_scalar:?}"); + Some((expr_scalar, goal_scalar)) + } } /// Helper trait for providing the min and max values exactly representable by From 6dcccc40a1b7204db29b9657fbd6064e5c9268fd Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Thu, 20 Mar 2025 17:10:38 -0700 Subject: [PATCH 017/806] [naga] Move predeclared type name generation to common code. Add a new module, `naga::common::predeclared`, which implements a new `struct_name` method on `naga::ir::PredeclaredType`, to produce the name of the struct type corresponding to that `PredeclaredType` value. Use this new method in `naga::front::type_gen`. --- naga/src/common/mod.rs | 1 + naga/src/common/predeclared.rs | 33 +++++++++++++++++++++++++++++++++ naga/src/front/type_gen.rs | 26 +++++--------------------- 3 files changed, 39 insertions(+), 21 deletions(-) create mode 100644 naga/src/common/predeclared.rs diff --git a/naga/src/common/mod.rs b/naga/src/common/mod.rs index 8ed039695..79b4e574a 100644 --- a/naga/src/common/mod.rs +++ b/naga/src/common/mod.rs @@ -1,5 +1,6 @@ //! Code common to the front and backends for specific languages. +pub mod predeclared; pub mod wgsl; /// Helper function that returns the string corresponding to the [`VectorSize`](crate::VectorSize) diff --git a/naga/src/common/predeclared.rs b/naga/src/common/predeclared.rs new file mode 100644 index 000000000..0c2004f7f --- /dev/null +++ b/naga/src/common/predeclared.rs @@ -0,0 +1,33 @@ +//! Generating names for predeclared types. + +use crate::ir; + +use alloc::format; +use alloc::string::String; + +impl ir::PredeclaredType { + pub fn struct_name(&self) -> String { + use crate::PredeclaredType as Pt; + match *self { + Pt::AtomicCompareExchangeWeakResult(scalar) => { + format!( + "__atomic_compare_exchange_result<{:?},{}>", + scalar.kind, scalar.width, + ) + } + Pt::ModfResult { size, scalar } => frexp_mod_name("modf", size, scalar), + Pt::FrexpResult { size, scalar } => frexp_mod_name("frexp", size, scalar), + } + } +} + +fn frexp_mod_name(function: &str, size: Option, scalar: ir::Scalar) -> String { + let bits = 8 * scalar.width; + match size { + Some(size) => { + let size = size as u8; + format!("__{function}_result_vec{size}_f{bits}") + } + None => format!("__{function}_result_f{bits}"), + } +} diff --git a/naga/src/front/type_gen.rs b/naga/src/front/type_gen.rs index 687d245b1..9a01b637d 100644 --- a/naga/src/front/type_gen.rs +++ b/naga/src/front/type_gen.rs @@ -2,7 +2,7 @@ Type generators. */ -use alloc::{format, string::ToString, vec}; +use alloc::{string::ToString, vec}; use crate::{arena::Handle, span::Span}; @@ -283,12 +283,11 @@ impl crate::Module { &mut self, special_type: crate::PredeclaredType, ) -> Handle { - use core::fmt::Write; - if let Some(value) = self.special_types.predeclared_types.get(&special_type) { return *value; } + let name = special_type.struct_name(); let ty = match special_type { crate::PredeclaredType::AtomicCompareExchangeWeakResult(scalar) => { let bool_ty = self.types.insert( @@ -307,10 +306,7 @@ impl crate::Module { ); crate::Type { - name: Some(format!( - "__atomic_compare_exchange_result<{:?},{}>", - scalar.kind, scalar.width, - )), + name: Some(name), inner: crate::TypeInner::Struct { members: vec![ crate::StructMember { @@ -352,14 +348,8 @@ impl crate::Module { (float_ty, scalar.width as u32) }; - let mut type_name = "__modf_result_".to_string(); - if let Some(size) = size { - let _ = write!(type_name, "vec{}_", size as u8); - } - let _ = write!(type_name, "f{}", scalar.width * 8); - crate::Type { - name: Some(type_name), + name: Some(name), inner: crate::TypeInner::Struct { members: vec![ crate::StructMember { @@ -425,14 +415,8 @@ impl crate::Module { (float_ty, int_ty, scalar.width as u32) }; - let mut type_name = "__frexp_result_".to_string(); - if let Some(size) = size { - let _ = write!(type_name, "vec{}_", size as u8); - } - let _ = write!(type_name, "f{}", scalar.width * 8); - crate::Type { - name: Some(type_name), + name: Some(name), inner: crate::TypeInner::Struct { members: vec![ crate::StructMember { From df5b45a1ab8c9cfd00940c834c5d5baced6d8a07 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Thu, 20 Mar 2025 17:16:05 -0700 Subject: [PATCH 018/806] [naga] Reorder the WGSL forms of `Scalar` types. In the implementation of `TryToWgsl` for `Scalar`, order types within each representation from smallest to largest. This is just a cleanup; the change has no effect on behavior. --- naga/src/common/wgsl/to_wgsl.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/naga/src/common/wgsl/to_wgsl.rs b/naga/src/common/wgsl/to_wgsl.rs index 82fe7c592..15221230c 100644 --- a/naga/src/common/wgsl/to_wgsl.rs +++ b/naga/src/common/wgsl/to_wgsl.rs @@ -268,9 +268,9 @@ impl TryToWgsl for crate::Scalar { use crate::Scalar; Some(match self { - Scalar::F64 => "f64", - Scalar::F32 => "f32", Scalar::F16 => "f16", + Scalar::F32 => "f32", + Scalar::F64 => "f64", Scalar::I32 => "i32", Scalar::U32 => "u32", Scalar::I64 => "i64", From e284e8055f99e2f9014c183b0afddc0cd77e4c68 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Sat, 22 Mar 2025 17:19:58 -0700 Subject: [PATCH 019/806] [naga] Put `Scalar::F16` constant in the right place. --- naga/src/proc/type_methods.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/naga/src/proc/type_methods.rs b/naga/src/proc/type_methods.rs index 968cb4ce3..f38ef5dc0 100644 --- a/naga/src/proc/type_methods.rs +++ b/naga/src/proc/type_methods.rs @@ -20,10 +20,6 @@ impl crate::ScalarKind { } impl crate::Scalar { - pub const F16: Self = Self { - kind: crate::ScalarKind::Float, - width: 2, - }; pub const I32: Self = Self { kind: crate::ScalarKind::Sint, width: 4, @@ -32,6 +28,10 @@ impl crate::Scalar { kind: crate::ScalarKind::Uint, width: 4, }; + pub const F16: Self = Self { + kind: crate::ScalarKind::Float, + width: 2, + }; pub const F32: Self = Self { kind: crate::ScalarKind::Float, width: 4, From 8f7dc8c070d7ede08e48cf7144be7264f4d420b3 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Sat, 22 Mar 2025 17:33:31 -0700 Subject: [PATCH 020/806] [naga] Add `DiagnosticDisplay` and `DiagnosticDebug` wrappers. Define two new types in `naga::common`, `DiagnosticDisplay` and `DiagnosticDebug`, that allow Naga IR types to be formatted using `core::fmt::Display` and `core::fmt::Debug`. In `naga::common::wgsl`, add supporting implementations of `TypeContext` for `GlobalCtx` and `UniqueArena` --- naga/src/common/diagnostic_debug.rs | 86 ++++++++++++++++++++++ naga/src/common/diagnostic_display.rs | 100 ++++++++++++++++++++++++++ naga/src/common/mod.rs | 5 ++ naga/src/common/wgsl/types.rs | 67 +++++++++++++++++ 4 files changed, 258 insertions(+) create mode 100644 naga/src/common/diagnostic_debug.rs create mode 100644 naga/src/common/diagnostic_display.rs diff --git a/naga/src/common/diagnostic_debug.rs b/naga/src/common/diagnostic_debug.rs new file mode 100644 index 000000000..e266c3d94 --- /dev/null +++ b/naga/src/common/diagnostic_debug.rs @@ -0,0 +1,86 @@ +//! Displaying Naga IR terms in debugging output. + +#[cfg(any(feature = "wgsl-in", feature = "wgsl-out"))] +use crate::common::wgsl::TypeContext; + +use crate::proc::TypeResolution; +use crate::{Handle, Scalar, Type, TypeInner, UniqueArena}; + +use core::fmt; + +/// A wrapper for displaying Naga IR terms in debugging output. +/// +/// This is like [`DiagnosticDisplay`], but requires weaker context +/// and produces correspondingly lower-fidelity output. For example, +/// this cannot show the override names for override-sized array +/// lengths. +/// +/// [`DiagnosticDisplay`]: super::DiagnosticDisplay +pub struct DiagnosticDebug(pub T); + +impl fmt::Debug for DiagnosticDebug<(Handle, &UniqueArena)> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let (handle, ctx) = self.0; + + #[cfg(any(feature = "wgsl-in", feature = "wgsl-out"))] + ctx.write_type(handle, f)?; + + #[cfg(not(any(feature = "wgsl-in", feature = "wgsl-out")))] + { + let _ = ctx; + write!(f, "{handle:?}")?; + } + + Ok(()) + } +} + +impl fmt::Debug for DiagnosticDebug<(&TypeInner, &UniqueArena)> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let (inner, ctx) = self.0; + + #[cfg(any(feature = "wgsl-in", feature = "wgsl-out"))] + ctx.write_type_inner(inner, f)?; + + #[cfg(not(any(feature = "wgsl-in", feature = "wgsl-out")))] + { + let _ = ctx; + write!(f, "{inner:?}")?; + } + + Ok(()) + } +} + +impl fmt::Debug for DiagnosticDebug<(&TypeResolution, &UniqueArena)> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let (resolution, ctx) = self.0; + + #[cfg(any(feature = "wgsl-in", feature = "wgsl-out"))] + ctx.write_type_resolution(resolution, f)?; + + #[cfg(not(any(feature = "wgsl-in", feature = "wgsl-out")))] + { + let _ = ctx; + write!(f, "{resolution:?}")?; + } + + Ok(()) + } +} + +impl fmt::Debug for DiagnosticDebug { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let scalar = self.0; + + #[cfg(any(feature = "wgsl-in", feature = "wgsl-out"))] + f.write_str(&crate::common::wgsl::TryToWgsl::to_wgsl_for_diagnostics( + scalar, + ))?; + + #[cfg(not(any(feature = "wgsl-in", feature = "wgsl-out")))] + write!(f, "{scalar:?}")?; + + Ok(()) + } +} diff --git a/naga/src/common/diagnostic_display.rs b/naga/src/common/diagnostic_display.rs new file mode 100644 index 000000000..a706ed706 --- /dev/null +++ b/naga/src/common/diagnostic_display.rs @@ -0,0 +1,100 @@ +//! Displaying Naga IR terms in diagnostic output. + +use crate::proc::GlobalCtx; +use crate::{Handle, Scalar, Type, TypeInner}; + +#[cfg(any(feature = "wgsl-in", feature = "wgsl-out"))] +use crate::common::wgsl::TypeContext; + +use core::fmt; + +/// A wrapper for displaying Naga IR terms in diagnostic output. +/// +/// For some Naga IR type `T`, `DiagnosticDisplay` implements +/// [`core::fmt::Display`] in a way that displays values of type `T` +/// appropriately for diagnostic messages presented to human readers. +/// +/// For example, the implementation of [`Display`] for +/// `DiagnosticDisplay` formats the type represented by the +/// given [`Scalar`] appropriately for users. +/// +/// Some types like `Handle` require contextual information like +/// a type arena to be displayed. In such cases, we implement [`Display`] +/// for a type like `DiagnosticDisplay<(Handle, GlobalCtx)>`, where +/// the [`GlobalCtx`] type provides the necessary context. +/// +/// If you only need debugging output, [`DiagnosticDebug`] uses +/// easier-to-obtain context types but still does a good enough job +/// for logging or debugging. +/// +/// [`Display`]: core::fmt::Display +/// [`Scalar`]: crate::Scalar +/// [`GlobalCtx`]: crate::proc::GlobalCtx +/// [`DiagnosticDebug`]: super::DiagnosticDebug +/// +/// ## Language-sensitive diagnostics +/// +/// Diagnostic output ought to depend on the source language from +/// which the IR was produced: diagnostics resulting from processing +/// GLSL code should use GLSL type syntax, for example. That means +/// that `DiagnosticDisplay` ought to include some indication of which +/// notation to use. +/// +/// For the moment, only WGSL output is implemented, so +/// `DiagnosticDisplay` lacks any support for this (#7268). However, +/// the plan is that all language-independent code in Naga should use +/// `DiagnosticDisplay` wherever appropriate, such that when its +/// definition is expanded to include some indication of the right +/// source language to use, any use site that does not supply this +/// indication will provoke a compile-time error. +pub struct DiagnosticDisplay(pub T); + +impl fmt::Display for DiagnosticDisplay<(Handle, GlobalCtx<'_>)> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let (handle, ref ctx) = self.0; + + #[cfg(any(feature = "wgsl-in", feature = "wgsl-out"))] + ctx.write_type(handle, f)?; + + #[cfg(not(any(feature = "wgsl-in", feature = "wgsl-out")))] + { + let _ = ctx; + write!(f, "{handle:?}")?; + } + + Ok(()) + } +} + +impl fmt::Display for DiagnosticDisplay<(&TypeInner, GlobalCtx<'_>)> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let (inner, ref ctx) = self.0; + + #[cfg(any(feature = "wgsl-in", feature = "wgsl-out"))] + ctx.write_type_inner(inner, f)?; + + #[cfg(not(any(feature = "wgsl-in", feature = "wgsl-out")))] + { + let _ = ctx; + write!(f, "{inner:?}")?; + } + + Ok(()) + } +} + +impl fmt::Display for DiagnosticDisplay { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let scalar = self.0; + + #[cfg(any(feature = "wgsl-in", feature = "wgsl-out"))] + f.write_str(&crate::common::wgsl::TryToWgsl::to_wgsl_for_diagnostics( + scalar, + ))?; + + #[cfg(not(any(feature = "wgsl-in", feature = "wgsl-out")))] + write!(f, "{scalar:?}")?; + + Ok(()) + } +} diff --git a/naga/src/common/mod.rs b/naga/src/common/mod.rs index 79b4e574a..86e8ecf96 100644 --- a/naga/src/common/mod.rs +++ b/naga/src/common/mod.rs @@ -1,8 +1,13 @@ //! Code common to the front and backends for specific languages. +mod diagnostic_debug; +mod diagnostic_display; pub mod predeclared; pub mod wgsl; +pub use diagnostic_debug::DiagnosticDebug; +pub use diagnostic_display::DiagnosticDisplay; + /// Helper function that returns the string corresponding to the [`VectorSize`](crate::VectorSize) pub const fn vector_size_str(size: crate::VectorSize) -> &'static str { match size { diff --git a/naga/src/common/wgsl/types.rs b/naga/src/common/wgsl/types.rs index 8c3e83159..786229b08 100644 --- a/naga/src/common/wgsl/types.rs +++ b/naga/src/common/wgsl/types.rs @@ -356,3 +356,70 @@ impl From for WriteTypeError { Self::Format(err) } } + +/// Format types as WGSL based on a [`GlobalCtx`]. +/// +/// This is probably good enough for diagnostic output, but it has some +/// limitations: +/// +/// - It does not apply [`Namer`] renamings, to avoid collisions. +/// +/// - It generates invalid WGSL for anonymous struct types. +/// +/// - It doesn't write the lengths of override-expression-sized arrays +/// correctly, unless the expression is just the override identifier. +/// +/// [`GlobalCtx`]: crate::proc::GlobalCtx +/// [`Namer`]: crate::proc::Namer +impl TypeContext for crate::proc::GlobalCtx<'_> { + fn lookup_type(&self, handle: Handle) -> &crate::Type { + &self.types[handle] + } + + fn type_name(&self, handle: Handle) -> &str { + self.types[handle] + .name + .as_deref() + .unwrap_or("{anonymous type}") + } + + fn write_override( + &self, + handle: Handle, + out: &mut W, + ) -> core::fmt::Result { + match self.overrides[handle].name { + Some(ref name) => out.write_str(name), + None => write!(out, "{{anonymous override {handle:?}}}"), + } + } +} + +/// Format types as WGSL based on a `UniqueArena`. +/// +/// This is probably only good enough for logging: +/// +/// - It does not apply any kind of [`Namer`] renamings. +/// +/// - It generates invalid WGSL for anonymous struct types. +/// +/// - It doesn't write override-sized arrays properly. +/// +/// [`Namer`]: crate::proc::Namer +impl TypeContext for crate::UniqueArena { + fn lookup_type(&self, handle: Handle) -> &crate::Type { + &self[handle] + } + + fn type_name(&self, handle: Handle) -> &str { + self[handle].name.as_deref().unwrap_or("{anonymous type}") + } + + fn write_override( + &self, + handle: Handle, + out: &mut W, + ) -> core::fmt::Result { + write!(out, "{{override {handle:?}}}") + } +} From def9d7142aaf8946463922da707a8e93aa650b5b Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Mon, 24 Mar 2025 14:03:38 -0700 Subject: [PATCH 021/806] [naga wgsl-in] Introduce `ExpressionContext::is_const` helper. In `naga::front::wgsl::lower`, add a new method, `ExpressionContext::is_const`, for looking up the constness of a given expression. Change existing code to use it. --- naga/src/front/wgsl/lower/mod.rs | 24 ++++++++++++++---------- typos.toml | 1 + 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/naga/src/front/wgsl/lower/mod.rs b/naga/src/front/wgsl/lower/mod.rs index 909299f65..d821c2592 100644 --- a/naga/src/front/wgsl/lower/mod.rs +++ b/naga/src/front/wgsl/lower/mod.rs @@ -526,6 +526,19 @@ impl<'source, 'temp, 'out> ExpressionContext<'source, 'temp, 'out> { } } + /// Return `true` if `handle` is a constant expression. + fn is_const(&self, handle: Handle) -> bool { + use ExpressionContextType as Ect; + match self.expr_type { + Ect::Runtime(ref ctx) | Ect::Constant(Some(ref ctx)) => { + ctx.local_expression_kind_tracker.is_const(handle) + } + Ect::Constant(None) | Ect::Override => { + self.global_expression_kind_tracker.is_const(handle) + } + } + } + fn get_expression_span(&self, handle: Handle) -> Span { match self.expr_type { ExpressionContextType::Runtime(ref ctx) @@ -2262,16 +2275,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { // We only have to explicitly do so for shifts as their operands may be // of different types - for other binary ops this is achieved by finding // the conversion consensus for both operands. - let expr_kind_tracker = match ctx.expr_type { - ExpressionContextType::Runtime(ref ctx) - | ExpressionContextType::Constant(Some(ref ctx)) => { - &ctx.local_expression_kind_tracker - } - ExpressionContextType::Constant(None) | ExpressionContextType::Override => { - &ctx.global_expression_kind_tracker - } - }; - if !expr_kind_tracker.is_const(right) { + if !ctx.is_const(right) { left = ctx.concretize(left)?; } } diff --git a/typos.toml b/typos.toml index f79b12d19..8bcf28218 100644 --- a/typos.toml +++ b/typos.toml @@ -27,6 +27,7 @@ ANDed = "ANDed" D3DCOLORtoUBYTE4 = "D3DCOLORtoUBYTE4" Derivate = "Derivate" inout = "inout" +Ect = "Ect" [type.wgsl] extend-glob = ["*.wgsl"] From a8a49993c21d755504eabdacc13e9cccdd810d14 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Mon, 24 Mar 2025 14:11:09 -0700 Subject: [PATCH 022/806] [naga] Add `TypeInner::scalar_for_conversions` helper function. Define a new helper function on `naga::ir::TypeInner`, `scalar_for_conversions`, that returns the leaf scalar of a type as relevant for WGSL-style automatic conversions. Specifically, this means that, unlike `TypeInner::scalar`, arrays are considered to have leaf scalars if their elements do. --- naga/src/proc/type_methods.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/naga/src/proc/type_methods.rs b/naga/src/proc/type_methods.rs index f38ef5dc0..25df0281d 100644 --- a/naga/src/proc/type_methods.rs +++ b/naga/src/proc/type_methods.rs @@ -102,6 +102,12 @@ impl crate::TypeInner { /// /// If `inner` is a scalar, vector, or matrix type, return /// its scalar type. Otherwise, return `None`. + /// + /// Note that this doesn't inspect [`Array`] types, as required + /// for automatic conversions. For that, see [`scalar_for_conversions`]. + /// + /// [`Array`]: crate::TypeInner::Array + /// [`scalar_for_conversions`]: crate::TypeInner::scalar_for_conversions pub const fn scalar(&self) -> Option { use crate::TypeInner as Ti; match *self { @@ -120,6 +126,31 @@ impl crate::TypeInner { self.scalar().map(|scalar| scalar.width) } + /// Return the leaf scalar type of `self`, as needed for automatic conversions. + /// + /// Unlike the [`scalar`] method, which only retrieves scalars for + /// [`Scalar`], [`Vector`], and [`Matrix`] this also looks into + /// [`Array`] types to find the leaf scalar. + /// + /// [`scalar`]: crate::TypeInner::scalar + /// [`Scalar`]: crate::TypeInner::Scalar + /// [`Vector`]: crate::TypeInner::Vector + /// [`Matrix`]: crate::TypeInner::Matrix + /// [`Array`]: crate::TypeInner::Array + pub fn scalar_for_conversions( + &self, + types: &crate::UniqueArena, + ) -> Option { + use crate::TypeInner as Ti; + match *self { + Ti::Scalar(scalar) | Ti::Vector { scalar, .. } | Ti::Matrix { scalar, .. } => { + Some(scalar) + } + Ti::Array { base, .. } => types[base].inner.scalar_for_conversions(types), + _ => None, + } + } + pub const fn pointer_space(&self) -> Option { match *self { Self::Pointer { space, .. } => Some(space), From d19e3b2b3eb6ab76a89ab68e64b7bfc8681361c4 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Mon, 24 Mar 2025 14:13:32 -0700 Subject: [PATCH 023/806] [naga wgsl-in] Minor doc fix. --- naga/src/front/wgsl/lower/conversion.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/naga/src/front/wgsl/lower/conversion.rs b/naga/src/front/wgsl/lower/conversion.rs index 9e6c0fa4b..7433d4e5c 100644 --- a/naga/src/front/wgsl/lower/conversion.rs +++ b/naga/src/front/wgsl/lower/conversion.rs @@ -71,7 +71,7 @@ impl<'source> super::ExpressionContext<'source, '_, '_> { self.convert_leaf_scalar(expr, expr_span, goal_scalar) } - /// Try to convert `expr`'s leaf scalar to `goal` using automatic conversions. + /// Try to convert `expr`'s leaf scalar to `goal_scalar` using automatic conversions. /// /// If no conversions are necessary, return `expr` unchanged. /// From 829294947871c926e1ca5f400518be52aa5df7f7 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Tue, 1 Apr 2025 10:14:31 -0700 Subject: [PATCH 024/806] [naga] Introduce `ForDebug` and `ForDebugWithTypes` traits Introduce traits to add `for_debug` methods to Naga IR types that can be formatted with `core::fmt::Debug`, given adequate context. --- naga/src/common/diagnostic_debug.rs | 40 +++++++++++++++++++++++++++++ naga/src/common/mod.rs | 2 +- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/naga/src/common/diagnostic_debug.rs b/naga/src/common/diagnostic_debug.rs index e266c3d94..efa3ec548 100644 --- a/naga/src/common/diagnostic_debug.rs +++ b/naga/src/common/diagnostic_debug.rs @@ -84,3 +84,43 @@ impl fmt::Debug for DiagnosticDebug { Ok(()) } } + +pub trait ForDebug: Sized { + /// Format this type using [`core::fmt::Debug`]. + /// + /// Return a value that implements the [`core::fmt::Debug`] trait + /// by displaying `self` in a language-appropriate way. For + /// example: + /// + /// # use naga::common::ForDebug; + /// # let scalar: naga::Scalar = naga::Scalar::F32; + /// log::debug!("My scalar: {:?}", scalar.for_debug()); + fn for_debug(self) -> DiagnosticDebug { + DiagnosticDebug(self) + } +} + +impl ForDebug for Scalar {} + +pub trait ForDebugWithTypes: Sized { + /// Format this type using [`core::fmt::Debug`]. + /// + /// Given an arena to look up type handles in, return a value that + /// implements the [`core::fmt::Debug`] trait by displaying `self` + /// in a language-appropriate way. For example: + /// + /// # use naga::{Span, Type, TypeInner, Scalar, UniqueArena}; + /// # use naga::common::ForDebugWithTypes; + /// # let mut types = UniqueArena::::default(); + /// # let inner = TypeInner::Scalar(Scalar::F32); + /// # let span = Span::UNDEFINED; + /// # let handle = types.insert(Type { name: None, inner }, span); + /// log::debug!("My type: {:?}", handle.for_debug(&types)); + fn for_debug(self, types: &UniqueArena) -> DiagnosticDebug<(Self, &UniqueArena)> { + DiagnosticDebug((self, types)) + } +} + +impl ForDebugWithTypes for Handle {} +impl ForDebugWithTypes for &TypeInner {} +impl ForDebugWithTypes for &TypeResolution {} diff --git a/naga/src/common/mod.rs b/naga/src/common/mod.rs index 86e8ecf96..34de0185b 100644 --- a/naga/src/common/mod.rs +++ b/naga/src/common/mod.rs @@ -5,7 +5,7 @@ mod diagnostic_display; pub mod predeclared; pub mod wgsl; -pub use diagnostic_debug::DiagnosticDebug; +pub use diagnostic_debug::{DiagnosticDebug, ForDebug, ForDebugWithTypes}; pub use diagnostic_display::DiagnosticDisplay; /// Helper function that returns the string corresponding to the [`VectorSize`](crate::VectorSize) From 7da699608d3b6dfc325f5df3f06b4b35ff62c4b7 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Mon, 17 Mar 2025 13:53:10 -0700 Subject: [PATCH 025/806] [naga] Support `MathFunction` overloads correctly. Define a new trait, `proc::builtins::OverloadSet`, for types that represent a Naga IR builtin function's set of overloads. The `OverloadSet` trait includes operations needed to validate calls, choose automatic type conversions, and generate diagnostics. Add a new function, `ir::MathFunction::overloads`, which returns the given `MathFunction`'s set of overloads as an `impl OverloadSet` value. Use this in the WGSL front end, the validator, and the typifier. To support `MathFunction::overloads`, provide two implementations of `OverloadSet`: - `List` is flexible but verbose. - `Regular` is concise but more restrictive. Some snapshot output is affected because `TypeResolution::Handle` values turn into `TypeResolution::Value`, since the function database constructs the return type directly. To work around #7405, avoid offering abstract-typed overloads of some functions. This addresses #6443 for `MathFunction`, although that issue covers other categories of operations as well. --- naga/src/common/diagnostic_display.rs | 19 +- naga/src/common/wgsl/types.rs | 37 + naga/src/front/wgsl/error.rs | 140 +++- naga/src/front/wgsl/lower/mod.rs | 241 +++++- naga/src/proc/mod.rs | 2 + naga/src/proc/overloads/any_overload_set.rs | 120 +++ naga/src/proc/overloads/constructor_set.rs | 174 +++++ naga/src/proc/overloads/list.rs | 182 +++++ naga/src/proc/overloads/mathfunction.rs | 221 ++++++ naga/src/proc/overloads/mod.rs | 237 ++++++ naga/src/proc/overloads/one_bits_iter.rs | 89 +++ naga/src/proc/overloads/regular.rs | 541 ++++++++++++++ naga/src/proc/overloads/rule.rs | 146 ++++ naga/src/proc/overloads/scalar_set.rs | 141 ++++ naga/src/proc/overloads/utils.rs | 113 +++ naga/src/proc/typifier.rs | 249 ++----- naga/src/valid/expression.rs | 691 ++---------------- .../in/wgsl/abstract-types-builtins.toml | 1 + .../in/wgsl/abstract-types-builtins.wgsl | 102 +++ naga/tests/naga/validation.rs | 85 ++- naga/tests/naga/wgsl_errors.rs | 188 +++++ naga/tests/out/analysis/shadow.info.ron | 26 +- .../tests/out/msl/abstract-types-builtins.msl | 66 ++ .../out/spv/abstract-types-builtins.spvasm | 77 ++ naga/tests/out/spv/shadow.spvasm | 6 +- .../out/wgsl/abstract-types-builtins.wgsl | 60 ++ typos.toml | 2 + 27 files changed, 3053 insertions(+), 903 deletions(-) create mode 100644 naga/src/proc/overloads/any_overload_set.rs create mode 100644 naga/src/proc/overloads/constructor_set.rs create mode 100644 naga/src/proc/overloads/list.rs create mode 100644 naga/src/proc/overloads/mathfunction.rs create mode 100644 naga/src/proc/overloads/mod.rs create mode 100644 naga/src/proc/overloads/one_bits_iter.rs create mode 100644 naga/src/proc/overloads/regular.rs create mode 100644 naga/src/proc/overloads/rule.rs create mode 100644 naga/src/proc/overloads/scalar_set.rs create mode 100644 naga/src/proc/overloads/utils.rs create mode 100644 naga/tests/in/wgsl/abstract-types-builtins.toml create mode 100644 naga/tests/in/wgsl/abstract-types-builtins.wgsl create mode 100644 naga/tests/out/msl/abstract-types-builtins.msl create mode 100644 naga/tests/out/spv/abstract-types-builtins.spvasm create mode 100644 naga/tests/out/wgsl/abstract-types-builtins.wgsl diff --git a/naga/src/common/diagnostic_display.rs b/naga/src/common/diagnostic_display.rs index a706ed706..994bebee2 100644 --- a/naga/src/common/diagnostic_display.rs +++ b/naga/src/common/diagnostic_display.rs @@ -1,6 +1,6 @@ //! Displaying Naga IR terms in diagnostic output. -use crate::proc::GlobalCtx; +use crate::proc::{GlobalCtx, Rule}; use crate::{Handle, Scalar, Type, TypeInner}; #[cfg(any(feature = "wgsl-in", feature = "wgsl-out"))] @@ -83,6 +83,23 @@ impl fmt::Display for DiagnosticDisplay<(&TypeInner, GlobalCtx<'_>)> { } } +impl fmt::Display for DiagnosticDisplay<(&str, &Rule, GlobalCtx<'_>)> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let (name, rule, ref ctx) = self.0; + + #[cfg(any(feature = "wgsl-in", feature = "wgsl-out"))] + ctx.write_type_rule(name, rule, f)?; + + #[cfg(not(any(feature = "wgsl-in", feature = "wgsl-out")))] + { + let _ = ctx; + write!(f, "{name}({:?}) -> {:?}", rule.arguments, rule.conclusion)?; + } + + Ok(()) + } +} + impl fmt::Display for DiagnosticDisplay { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let scalar = self.0; diff --git a/naga/src/common/wgsl/types.rs b/naga/src/common/wgsl/types.rs index 786229b08..c0a2675d7 100644 --- a/naga/src/common/wgsl/types.rs +++ b/naga/src/common/wgsl/types.rs @@ -133,6 +133,37 @@ pub trait TypeContext { } } + fn write_type_conclusion( + &self, + conclusion: &crate::proc::Conclusion, + out: &mut W, + ) -> core::fmt::Result { + use crate::proc::Conclusion as Co; + + match *conclusion { + Co::Value(ref inner) => self.write_type_inner(inner, out), + Co::Predeclared(ref predeclared) => out.write_str(&predeclared.struct_name()), + } + } + + fn write_type_rule( + &self, + name: &str, + rule: &crate::proc::Rule, + out: &mut W, + ) -> core::fmt::Result { + write!(out, "fn {name}(")?; + for (i, arg) in rule.arguments.iter().enumerate() { + if i > 0 { + out.write_str(", ")?; + } + self.write_type_resolution(arg, out)? + } + out.write_str(") -> ")?; + self.write_type_conclusion(&rule.conclusion, out)?; + Ok(()) + } + fn type_to_string(&self, handle: Handle) -> String { let mut buf = String::new(); self.write_type(handle, &mut buf).unwrap(); @@ -150,6 +181,12 @@ pub trait TypeContext { self.write_type_resolution(resolution, &mut buf).unwrap(); buf } + + fn type_rule_to_string(&self, name: &str, rule: &crate::proc::Rule) -> String { + let mut buf = String::new(); + self.write_type_rule(name, rule, &mut buf).unwrap(); + buf + } } fn try_write_type_inner(ctx: &C, inner: &TypeInner, out: &mut W) -> Result<(), WriteTypeError> diff --git a/naga/src/front/wgsl/error.rs b/naga/src/front/wgsl/error.rs index 4a1f3a30a..b7c55a52b 100644 --- a/naga/src/front/wgsl/error.rs +++ b/naga/src/front/wgsl/error.rs @@ -271,6 +271,75 @@ pub(crate) enum Error<'a> { expected: Range, found: u32, }, + /// No overload of this function accepts this many arguments. + TooManyArguments { + /// The name of the function being called. + function: String, + + /// The function name in the call expression. + call_span: Span, + + /// The first argument that is unacceptable. + arg_span: Span, + + /// Maximum number of arguments accepted by any overload of + /// this function. + max_arguments: u32, + }, + /// A value passed to a builtin function has a type that is not + /// accepted by any overload of the function. + WrongArgumentType { + /// The name of the function being called. + function: String, + + /// The function name in the call expression. + call_span: Span, + + /// The first argument whose type is unacceptable. + arg_span: Span, + + /// The index of the first argument whose type is unacceptable. + arg_index: u32, + + /// That argument's actual type. + arg_ty: String, + + /// The set of argument types that would have been accepted for + /// this argument, given the prior arguments. + allowed: Vec, + }, + /// A value passed to a builtin function has a type that is not + /// accepted, given the earlier arguments' types. + InconsistentArgumentType { + /// The name of the function being called. + function: String, + + /// The function name in the call expression. + call_span: Span, + + /// The first unacceptable argument. + arg_span: Span, + + /// The index of the first unacceptable argument. + arg_index: u32, + + /// The actual type of the first unacceptable argument. + arg_ty: String, + + /// The prior argument whose type made the `arg_span` argument + /// unacceptable. + inconsistent_span: Span, + + /// The index of the `inconsistent_span` argument. + inconsistent_index: u32, + + /// The type of the `inconsistent_span` argument. + inconsistent_ty: String, + + /// The types that would have been accepted instead of the + /// first unacceptable argument. + allowed: Vec, + }, FunctionReturnsVoid(Span), FunctionMustUseUnused(Span), FunctionMustUseReturnsVoid(Span, Span), @@ -402,7 +471,8 @@ impl<'a> Error<'a> { "workgroup size separator (`,`) or a closing parenthesis".to_string() } ExpectedToken::GlobalItem => concat!( - "global item (`struct`, `const`, `var`, `alias`, `fn`, `diagnostic`, `enable`, `requires`, `;`) ", + "global item (`struct`, `const`, `var`, `alias`, ", + "`fn`, `diagnostic`, `enable`, `requires`, `;`) ", "or the end of the file" ) .to_string(), @@ -831,6 +901,74 @@ impl<'a> Error<'a> { labels: vec![(span, "wrong number of arguments".into())], notes: vec![], }, + Error::TooManyArguments { + ref function, + call_span, + arg_span, + max_arguments, + } => ParseError { + message: format!("too many arguments passed to `{function}`"), + labels: vec![ + (call_span, "".into()), + (arg_span, format!("unexpected argument #{}", max_arguments + 1).into()) + ], + notes: vec![ + format!("The `{function}` function accepts at most {max_arguments} argument(s)") + ], + }, + Error::WrongArgumentType { + ref function, + call_span, + arg_span, + arg_index, + ref arg_ty, + ref allowed, + } => { + let message = format!( + "wrong type passed as argument #{} to `{function}`", + arg_index + 1, + ); + let labels = vec![ + (call_span, "".into()), + (arg_span, format!("argument #{} has type `{arg_ty}`", arg_index + 1).into()) + ]; + + let mut notes = vec![]; + notes.push(format!("`{function}` accepts the following types for argument #{}:", arg_index + 1)); + notes.extend(allowed.iter().map(|ty| format!("allowed type: {ty}"))); + + ParseError { message, labels, notes } + }, + Error::InconsistentArgumentType { + ref function, + call_span, + arg_span, + arg_index, + ref arg_ty, + inconsistent_span, + inconsistent_index, + ref inconsistent_ty, + ref allowed + } => { + let message = format!( + "inconsistent type passed as argument #{} to `{function}`", + arg_index + 1, + ); + let labels = vec![ + (call_span, "".into()), + (arg_span, format!("argument #{} has type {arg_ty}", arg_index + 1).into()), + (inconsistent_span, format!( + "this argument has type {inconsistent_ty}, which constrains subsequent arguments" + ).into()), + ]; + let mut notes = vec![ + format!("Because argument #{} has type {inconsistent_ty}, only the following types", inconsistent_index + 1), + format!("(or types that automatically convert to them) are accepted for argument #{}:", arg_index + 1), + ]; + notes.extend(allowed.iter().map(|ty| format!("allowed type: {ty}"))); + + ParseError { message, labels, notes } + } Error::FunctionReturnsVoid(span) => ParseError { message: "function does not return any value".to_string(), labels: vec![(span, "".into())], diff --git a/naga/src/front/wgsl/lower/mod.rs b/naga/src/front/wgsl/lower/mod.rs index d821c2592..af9573503 100644 --- a/naga/src/front/wgsl/lower/mod.rs +++ b/naga/src/front/wgsl/lower/mod.rs @@ -6,7 +6,7 @@ use alloc::{ }; use core::num::NonZeroU32; -use crate::common::wgsl::TypeContext; +use crate::common::wgsl::{TryToWgsl, TypeContext}; use crate::front::wgsl::error::{Error, ExpectedToken, InvalidAssignmentType}; use crate::front::wgsl::index::Index; use crate::front::wgsl::parse::number::Number; @@ -491,6 +491,19 @@ impl<'source, 'temp, 'out> ExpressionContext<'source, 'temp, 'out> { } } + /// Return a wrapper around `value` suitable for formatting. + /// + /// Return a wrapper around `value` that implements + /// [`core::fmt::Display`] in a form suitable for use in + /// diagnostic messages. + fn as_diagnostic_display( + &self, + value: T, + ) -> crate::common::DiagnosticDisplay<(T, crate::proc::GlobalCtx)> { + let ctx = self.module.to_ctx(); + crate::common::DiagnosticDisplay((value, ctx)) + } + fn append_expression( &mut self, expr: crate::Expression, @@ -2439,52 +2452,204 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { crate::Expression::Derivative { axis, ctrl, expr } } else if let Some(fun) = conv::map_standard_fun(function.name) { - let expected = fun.argument_count() as _; - let mut args = ctx.prepare_args(arguments, expected, span); + use crate::proc::OverloadSet as _; - let arg = self.expression(args.next()?, ctx)?; - let arg1 = args - .next() - .map(|x| self.expression(x, ctx)) - .ok() - .transpose()?; - let arg2 = args - .next() - .map(|x| self.expression(x, ctx)) - .ok() - .transpose()?; - let arg3 = args - .next() - .map(|x| self.expression(x, ctx)) - .ok() - .transpose()?; + let fun_overloads = fun.overloads(); + let mut remaining_overloads = fun_overloads.clone(); + let min_arguments = remaining_overloads.min_arguments(); + let max_arguments = remaining_overloads.max_arguments(); + if arguments.len() < min_arguments { + return Err(Box::new(Error::WrongArgumentCount { + span, + expected: min_arguments as u32..max_arguments as u32, + found: arguments.len() as u32, + })); + } + if arguments.len() > max_arguments { + return Err(Box::new(Error::TooManyArguments { + function: fun.to_wgsl_for_diagnostics(), + call_span: span, + arg_span: ctx.ast_expressions.get_span(arguments[max_arguments]), + max_arguments: max_arguments as _, + })); + } - args.finish()?; + log::debug!( + "Initial overloads: {:#?}", + remaining_overloads.for_debug(&ctx.module.types) + ); + let mut unconverted_arguments = Vec::with_capacity(arguments.len()); + for (arg_index, &arg) in arguments.iter().enumerate() { + let lowered = self.expression_for_abstract(arg, ctx)?; + let ty = resolve_inner!(ctx, lowered); + log::debug!( + "Supplying argument {arg_index} of type {}", + crate::common::DiagnosticDisplay((ty, ctx.module.to_ctx())) + ); + let next_remaining_overloads = + remaining_overloads.arg(arg_index, ty, &ctx.module.types); - if fun == crate::MathFunction::Modf || fun == crate::MathFunction::Frexp { - if let Some((size, scalar)) = match *resolve_inner!(ctx, arg) { - crate::TypeInner::Scalar(scalar) => Some((None, scalar)), - crate::TypeInner::Vector { size, scalar, .. } => { - Some((Some(size), scalar)) + // If any argument is not a constant expression, then no overloads + // that accept abstract values should be considered. + // (`OverloadSet::concrete_only` is supposed to help impose this + // restriction.) However, no `MathFunction` accepts a mix of + // abstract and concrete arguments, so we don't need to worry + // about that here. + + log::debug!( + "Remaining overloads: {:#?}", + next_remaining_overloads.for_debug(&ctx.module.types) + ); + + // If the set of remaining overloads is empty, then this argument's type + // was unacceptable. Diagnose the problem and produce an error message. + if next_remaining_overloads.is_empty() { + let function = fun.to_wgsl_for_diagnostics(); + let call_span = span; + let arg_span = ctx.ast_expressions.get_span(arg); + let arg_ty = ctx.as_diagnostic_display(ty).to_string(); + + // Is this type *ever* permitted for the arg_index'th argument? + // For example, `bool` is never permitted for `max`. + let only_this_argument = + fun_overloads.arg(arg_index, ty, &ctx.module.types); + if only_this_argument.is_empty() { + // No overload of `fun` accepts this type as the + // arg_index'th argument. Determine the set of types that + // would ever be allowed there. + let allowed: Vec = fun_overloads + .allowed_args(arg_index, &ctx.module.to_ctx()) + .iter() + .map(|ty| ctx.type_resolution_to_string(ty)) + .collect(); + + if allowed.is_empty() { + // No overload of `fun` accepts any argument at this + // index, so it's a simple case of excess arguments. + // However, since each `MathFunction`'s overloads all + // have the same arity, we should have detected this + // earlier. + unreachable!("expected all overloads to have the same arity"); + } + + // Some overloads of `fun` do accept this many arguments, + // but none accept one of this type. + return Err(Box::new(Error::WrongArgumentType { + function, + call_span, + arg_span, + arg_index: arg_index as u32, + arg_ty, + allowed, + })); } - _ => None, - } { - ctx.module.generate_predeclared_type( - if fun == crate::MathFunction::Modf { - crate::PredeclaredType::ModfResult { size, scalar } - } else { - crate::PredeclaredType::FrexpResult { size, scalar } - }, - ); + + // This argument's type is accepted by some overloads---just + // not those overloads that remain, given the prior arguments. + // For example, `max` accepts `f32` as its second argument - + // but not if the first was `i32`. + + // Build a list of the types that would have been accepted here, + // given the prior arguments. + let allowed: Vec = remaining_overloads + .allowed_args(arg_index, &ctx.module.to_ctx()) + .iter() + .map(|ty| ctx.type_resolution_to_string(ty)) + .collect(); + + // Re-run the argument list to determine which prior argument + // made this one unacceptable. + let mut remaining_overloads = fun_overloads; + for (prior_index, &prior_expr) in + unconverted_arguments.iter().enumerate() + { + let prior_ty = + ctx.typifier()[prior_expr].inner_with(&ctx.module.types); + remaining_overloads = remaining_overloads.arg( + prior_index, + prior_ty, + &ctx.module.types, + ); + if remaining_overloads + .arg(arg_index, ty, &ctx.module.types) + .is_empty() + { + // This is the argument that killed our dreams. + let inconsistent_span = + ctx.ast_expressions.get_span(arguments[prior_index]); + let inconsistent_ty = + ctx.as_diagnostic_display(prior_ty).to_string(); + + if allowed.is_empty() { + // Some overloads did accept `ty` at `arg_index`, but + // given the arguments up through `prior_expr`, we see + // no types acceptable at `arg_index`. This means that some + // overloads expect fewer arguments than others. However, + // each `MathFunction`'s overloads have the same arity, so this + // should be impossible. + unreachable!( + "expected all overloads to have the same arity" + ); + } + + // Report `arg`'s type as inconsistent with `prior_expr`'s + return Err(Box::new(Error::InconsistentArgumentType { + function, + call_span, + arg_span, + arg_index: arg_index as u32, + arg_ty, + inconsistent_span, + inconsistent_index: prior_index as u32, + inconsistent_ty, + allowed, + })); + } + } + unreachable!("Failed to eliminate argument type when re-tried"); } + remaining_overloads = next_remaining_overloads; + unconverted_arguments.push(lowered); + } + + // Select the most preferred type rule for this call, + // given the argument types supplied above. + let rule = remaining_overloads.most_preferred(); + + let mut converted_arguments = Vec::with_capacity(arguments.len()); + for (i, (&ast, unconverted)) in + arguments.iter().zip(unconverted_arguments).enumerate() + { + let goal_inner = rule.arguments[i].inner_with(&ctx.module.types); + let converted = match goal_inner.scalar_for_conversions(&ctx.module.types) { + Some(goal_scalar) => { + let arg_span = ctx.ast_expressions.get_span(ast); + ctx.try_automatic_conversion_for_leaf_scalar( + unconverted, + goal_scalar, + arg_span, + )? + } + // No conversion is necessary. + None => unconverted, + }; + + converted_arguments.push(converted); + } + + // If this function returns a predeclared type, register it + // in `Module::special_types`. The typifier will expect to + // be able to find it there. + if let crate::proc::Conclusion::Predeclared(predeclared) = rule.conclusion { + ctx.module.generate_predeclared_type(predeclared); } crate::Expression::Math { fun, - arg, - arg1, - arg2, - arg3, + arg: converted_arguments[0], + arg1: converted_arguments.get(1).cloned(), + arg2: converted_arguments.get(2).cloned(), + arg3: converted_arguments.get(3).cloned(), } } else if let Some(fun) = Texture::map(function.name) { self.texture_sample_helper(fun, arguments, span, ctx)? diff --git a/naga/src/proc/mod.rs b/naga/src/proc/mod.rs index 49089fda0..4ca4da554 100644 --- a/naga/src/proc/mod.rs +++ b/naga/src/proc/mod.rs @@ -7,6 +7,7 @@ mod emitter; pub mod index; mod layouter; mod namer; +mod overloads; mod terminator; mod type_methods; mod typifier; @@ -18,6 +19,7 @@ pub use emitter::Emitter; pub use index::{BoundsCheckPolicies, BoundsCheckPolicy, IndexableLength, IndexableLengthError}; pub use layouter::{Alignment, LayoutError, LayoutErrorInner, Layouter, TypeLayout}; pub use namer::{EntryPointIndex, NameKey, Namer}; +pub use overloads::{Conclusion, MissingSpecialType, OverloadSet, Rule}; pub use terminator::ensure_block_returns; use thiserror::Error; pub use type_methods::min_max_float_representable_by; diff --git a/naga/src/proc/overloads/any_overload_set.rs b/naga/src/proc/overloads/any_overload_set.rs new file mode 100644 index 000000000..f3228bb07 --- /dev/null +++ b/naga/src/proc/overloads/any_overload_set.rs @@ -0,0 +1,120 @@ +//! Dynamically dispatched [`OverloadSet`]s. + +use crate::common::DiagnosticDebug; +use crate::ir; +use crate::proc::overloads::{list, regular, OverloadSet, Rule}; +use crate::proc::{GlobalCtx, TypeResolution}; + +use alloc::vec::Vec; +use core::fmt; + +macro_rules! define_any_overload_set { + { $( $module:ident :: $name:ident, )* } => { + /// An [`OverloadSet`] that dynamically dispatches to concrete implementations. + #[derive(Clone)] + pub(in crate::proc::overloads) enum AnyOverloadSet { + $( + $name ( $module :: $name ), + )* + } + + $( + impl From<$module::$name> for AnyOverloadSet { + fn from(concrete: $module::$name) -> Self { + AnyOverloadSet::$name(concrete) + } + } + )* + + impl OverloadSet for AnyOverloadSet { + fn is_empty(&self) -> bool { + match *self { + $( + AnyOverloadSet::$name(ref x) => x.is_empty(), + )* + } + } + + fn min_arguments(&self) -> usize { + match *self { + $( + AnyOverloadSet::$name(ref x) => x.min_arguments(), + )* + } + } + + fn max_arguments(&self) -> usize { + match *self { + $( + AnyOverloadSet::$name(ref x) => x.max_arguments(), + )* + } + } + + fn arg( + &self, + i: usize, + ty: &ir::TypeInner, + types: &crate::UniqueArena, + ) -> Self { + match *self { + $( + AnyOverloadSet::$name(ref x) => AnyOverloadSet::$name(x.arg(i, ty, types)), + )* + } + } + + fn concrete_only(self, types: &crate::UniqueArena) -> Self { + match self { + $( + AnyOverloadSet::$name(x) => AnyOverloadSet::$name(x.concrete_only(types)), + )* + } + } + + fn most_preferred(&self) -> Rule { + match *self { + $( + AnyOverloadSet::$name(ref x) => x.most_preferred(), + )* + } + } + + fn overload_list(&self, gctx: &GlobalCtx<'_>) -> Vec { + match *self { + $( + AnyOverloadSet::$name(ref x) => x.overload_list(gctx), + )* + } + } + + fn allowed_args(&self, i: usize, gctx: &GlobalCtx<'_>) -> Vec { + match *self { + $( + AnyOverloadSet::$name(ref x) => x.allowed_args(i, gctx), + )* + } + } + + fn for_debug(&self, types: &crate::UniqueArena) -> impl fmt::Debug { + DiagnosticDebug((self, types)) + } + } + + impl fmt::Debug for DiagnosticDebug<(&AnyOverloadSet, &crate::UniqueArena)> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let (set, types) = self.0; + match *set { + $( + AnyOverloadSet::$name(ref x) => DiagnosticDebug((x, types)).fmt(f), + )* + } + } + } + } +} + +define_any_overload_set! { + list::List, + regular::Regular, +} diff --git a/naga/src/proc/overloads/constructor_set.rs b/naga/src/proc/overloads/constructor_set.rs new file mode 100644 index 000000000..eeb831d39 --- /dev/null +++ b/naga/src/proc/overloads/constructor_set.rs @@ -0,0 +1,174 @@ +//! A set of type constructors, represented as a bitset. + +use crate::ir; +use crate::proc::overloads::one_bits_iter::OneBitsIter; + +bitflags::bitflags! { + /// A set of type constructors. + #[derive(Copy, Clone, Debug, PartialEq)] + pub(crate) struct ConstructorSet: u16 { + const SCALAR = 1 << 0; + const VEC2 = 1 << 1; + const VEC3 = 1 << 2; + const VEC4 = 1 << 3; + const MAT2X2 = 1 << 4; + const MAT2X3 = 1 << 5; + const MAT2X4 = 1 << 6; + const MAT3X2 = 1 << 7; + const MAT3X3 = 1 << 8; + const MAT3X4 = 1 << 9; + const MAT4X2 = 1 << 10; + const MAT4X3 = 1 << 11; + const MAT4X4 = 1 << 12; + + const VECN = Self::VEC2.bits() + | Self::VEC3.bits() + | Self::VEC4.bits(); + } +} + +impl ConstructorSet { + /// Return the single-member set containing `inner`'s constructor. + pub const fn singleton(inner: &ir::TypeInner) -> ConstructorSet { + use ir::TypeInner as Ti; + use ir::VectorSize as Vs; + match *inner { + Ti::Scalar(_) => Self::SCALAR, + Ti::Vector { size, scalar: _ } => match size { + Vs::Bi => Self::VEC2, + Vs::Tri => Self::VEC3, + Vs::Quad => Self::VEC4, + }, + Ti::Matrix { + columns, + rows, + scalar: _, + } => match (columns, rows) { + (Vs::Bi, Vs::Bi) => Self::MAT2X2, + (Vs::Bi, Vs::Tri) => Self::MAT2X3, + (Vs::Bi, Vs::Quad) => Self::MAT2X4, + (Vs::Tri, Vs::Bi) => Self::MAT3X2, + (Vs::Tri, Vs::Tri) => Self::MAT3X3, + (Vs::Tri, Vs::Quad) => Self::MAT3X4, + (Vs::Quad, Vs::Bi) => Self::MAT4X2, + (Vs::Quad, Vs::Tri) => Self::MAT4X3, + (Vs::Quad, Vs::Quad) => Self::MAT4X4, + }, + _ => Self::empty(), + } + } + + pub const fn is_singleton(self) -> bool { + self.bits().is_power_of_two() + } + + /// Return an iterator over this set's members. + /// + /// Members are produced as singleton, in order from most general to least. + pub fn members(self) -> impl Iterator { + OneBitsIter::new(self.bits() as u64).map(|bit| Self::from_bits(bit as u16).unwrap()) + } + + /// Return the size of the sole element of `self`. + /// + /// # Panics + /// + /// Panic if `self` is not a singleton. + pub fn size(self) -> ConstructorSize { + use ir::VectorSize as Vs; + use ConstructorSize as Cs; + + match self { + ConstructorSet::SCALAR => Cs::Scalar, + ConstructorSet::VEC2 => Cs::Vector(Vs::Bi), + ConstructorSet::VEC3 => Cs::Vector(Vs::Tri), + ConstructorSet::VEC4 => Cs::Vector(Vs::Quad), + ConstructorSet::MAT2X2 => Cs::Matrix { + columns: Vs::Bi, + rows: Vs::Bi, + }, + ConstructorSet::MAT2X3 => Cs::Matrix { + columns: Vs::Bi, + rows: Vs::Tri, + }, + ConstructorSet::MAT2X4 => Cs::Matrix { + columns: Vs::Bi, + rows: Vs::Quad, + }, + ConstructorSet::MAT3X2 => Cs::Matrix { + columns: Vs::Tri, + rows: Vs::Bi, + }, + ConstructorSet::MAT3X3 => Cs::Matrix { + columns: Vs::Tri, + rows: Vs::Tri, + }, + ConstructorSet::MAT3X4 => Cs::Matrix { + columns: Vs::Tri, + rows: Vs::Quad, + }, + ConstructorSet::MAT4X2 => Cs::Matrix { + columns: Vs::Quad, + rows: Vs::Bi, + }, + ConstructorSet::MAT4X3 => Cs::Matrix { + columns: Vs::Quad, + rows: Vs::Tri, + }, + ConstructorSet::MAT4X4 => Cs::Matrix { + columns: Vs::Quad, + rows: Vs::Quad, + }, + _ => unreachable!("ConstructorSet was not a singleton"), + } + } +} + +/// The sizes a member of [`ConstructorSet`] might have. +#[derive(Clone, Copy)] +pub enum ConstructorSize { + /// The constructor is [`SCALAR`]. + /// + /// [`SCALAR`]: ConstructorSet::SCALAR + Scalar, + + /// The constructor is `VECN` for some `N`. + Vector(ir::VectorSize), + + /// The constructor is `MATCXR` for some `C` and `R`. + Matrix { + columns: ir::VectorSize, + rows: ir::VectorSize, + }, +} + +impl ConstructorSize { + /// Construct a [`TypeInner`] for a type with this size and the given `scalar`. + /// + /// [`TypeInner`]: ir::TypeInner + pub const fn to_inner(self, scalar: ir::Scalar) -> ir::TypeInner { + match self { + Self::Scalar => ir::TypeInner::Scalar(scalar), + Self::Vector(size) => ir::TypeInner::Vector { size, scalar }, + Self::Matrix { columns, rows } => ir::TypeInner::Matrix { + columns, + rows, + scalar, + }, + } + } +} + +macro_rules! constructor_set { + ( $( $constr:ident )|* ) => { + { + use $crate::proc::overloads::constructor_set::ConstructorSet; + ConstructorSet::empty() + $( + .union(ConstructorSet::$constr) + )* + } + } +} + +pub(in crate::proc::overloads) use constructor_set; diff --git a/naga/src/proc/overloads/list.rs b/naga/src/proc/overloads/list.rs new file mode 100644 index 000000000..62a8a83cc --- /dev/null +++ b/naga/src/proc/overloads/list.rs @@ -0,0 +1,182 @@ +//! An [`OverloadSet`] represented as a vector of rules. +//! +//! [`OverloadSet`]: crate::proc::overloads::OverloadSet + +use crate::common::{DiagnosticDebug, ForDebug, ForDebugWithTypes}; +use crate::ir; +use crate::proc::overloads::one_bits_iter::OneBitsIter; +use crate::proc::overloads::Rule; +use crate::proc::{GlobalCtx, TypeResolution}; + +use alloc::rc::Rc; +use alloc::vec::Vec; +use core::fmt; + +/// A simple list of overloads. +/// +/// Note that this type is not quite as general as it looks, in that +/// the implementation of `most_preferred` doesn't work for arbitrary +/// lists of overloads. See the documentation for [`List::rules`] for +/// details. +#[derive(Clone)] +pub(in crate::proc::overloads) struct List { + /// A bitmask of which elements of `rules` are included in the set. + members: u64, + + /// A list of type rules that are members of the set. + /// + /// These must be listed in order such that every rule in the list + /// is always more preferred than all subsequent rules in the + /// list. If there is no such arrangement of rules, then you + /// cannot use `List` to represent the overload set. + rules: Rc>, +} + +impl List { + pub(in crate::proc::overloads) fn from_rules(rules: Vec) -> List { + List { + members: len_to_full_mask(rules.len()), + rules: Rc::new(rules), + } + } + + fn members(&self) -> impl Iterator { + OneBitsIter::new(self.members).map(|mask| { + let index = mask.trailing_zeros() as usize; + (mask, &self.rules[index]) + }) + } + + fn filter(&self, mut pred: F) -> List + where + F: FnMut(&Rule) -> bool, + { + let mut filtered_members = 0; + for (mask, rule) in self.members() { + if pred(rule) { + filtered_members |= mask; + } + } + + List { + members: filtered_members, + rules: self.rules.clone(), + } + } +} + +impl crate::proc::overloads::OverloadSet for List { + fn is_empty(&self) -> bool { + self.members == 0 + } + + fn min_arguments(&self) -> usize { + self.members() + .fold(None, |best, (_, rule)| { + // This is different from `max_arguments` because + // `