Skip to content

Commit 4bd6b70

Browse files
committed
Merge remote-tracking branch 'upstream/main' into dev-zmr233
2 parents 5a43b12 + e6d017d commit 4bd6b70

29 files changed

+404
-185
lines changed

.github/workflows/ci.yaml

Lines changed: 19 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,7 @@ jobs:
1717
name: Test
1818
strategy:
1919
matrix:
20-
include:
21-
- os: ubuntu-24.04
22-
target: x86_64-unknown-linux-gnu
23-
- os: windows-2022
24-
target: x86_64-pc-windows-msvc
25-
- os: macOS-latest
26-
target: aarch64-apple-darwin
20+
os: [ ubuntu-24.04, windows-2022, macOS-latest ]
2721
runs-on: ${{ matrix.os }}
2822
env:
2923
RUSTUP_UNPACK_RAM: "26214400"
@@ -38,13 +32,14 @@ jobs:
3832
- if: ${{ runner.os == 'Linux' }}
3933
name: Linux - Install native dependencies
4034
run: sudo apt install libwayland-cursor0 libxkbcommon-dev libwayland-dev
41-
# cargo version is a random command that forces the installation of rust-toolchain
35+
# just need a random command that forces the installation of rust-toolchain
36+
# figure out native target triple while we're at it
4237
- name: install rust-toolchain
43-
run: cargo version
38+
run: echo "TARGET=$(rustc --print host-tuple)" >> "$GITHUB_ENV"
4439
# Fetch dependencies in a separate step to clearly show how long each part
4540
# of the testing takes
4641
- name: cargo fetch --locked
47-
run: cargo fetch --locked --target ${{ matrix.target }}
42+
run: cargo fetch --locked --target $TARGET
4843

4944
# Core crates
5045
# Compiled in --release because cargo compiletest would otherwise compile in release again.
@@ -80,10 +75,8 @@ jobs:
8075
name: Android
8176
strategy:
8277
matrix:
83-
include:
84-
- os: ubuntu-24.04
85-
target: aarch64-linux-android
86-
host: x86_64-unknown-linux-gnu
78+
os: [ ubuntu-24.04 ]
79+
target: [ aarch64-linux-android ]
8780
runs-on: ${{ matrix.os }}
8881
env:
8982
RUSTUP_UNPACK_RAM: "26214400"
@@ -95,11 +88,8 @@ jobs:
9588
with:
9689
version: 1.4.309.0
9790
cache: true
98-
# cargo version is a random command that forces the installation of rust-toolchain
9991
- name: install rust-toolchain
10092
run: cargo version
101-
# Fetch dependencies in a separate step to clearly show how long each part
102-
# of the testing takes
10393
- name: cargo fetch --locked
10494
run: cargo fetch --locked --target ${{ matrix.target }}
10595

@@ -130,13 +120,7 @@ jobs:
130120
name: Compiletest
131121
strategy:
132122
matrix:
133-
include:
134-
- os: ubuntu-24.04
135-
target: x86_64-unknown-linux-gnu
136-
- os: windows-2022
137-
target: x86_64-pc-windows-msvc
138-
- os: macOS-latest
139-
target: aarch64-apple-darwin
123+
os: [ ubuntu-24.04, windows-2022, macOS-latest ]
140124
runs-on: ${{ matrix.os }}
141125
steps:
142126
- uses: actions/checkout@v4
@@ -145,25 +129,18 @@ jobs:
145129
with:
146130
version: 1.4.309.0
147131
cache: true
148-
# cargo version is a random command that forces the installation of rust-toolchain
149132
- name: install rust-toolchain
150-
run: cargo version
133+
run: echo "TARGET=$(rustc --print host-tuple)" >> "$GITHUB_ENV"
151134
- name: cargo fetch --locked
152-
run: cargo fetch --locked --target ${{ matrix.target }}
135+
run: cargo fetch --locked --target $TARGET
153136
- name: compiletest
154-
run: cargo run -p compiletests --release --no-default-features --features "use-installed-tools" -- --target-env vulkan1.1,vulkan1.2,spv1.3
137+
run: cargo run -p compiletests --release --no-default-features --features "use-installed-tools" -- --target-env vulkan1.1,vulkan1.2,vulkan1.3,vulkan1.4,spv1.3
155138

156139
difftest:
157140
name: Difftest
158141
strategy:
159142
matrix:
160-
include:
161-
- os: ubuntu-24.04
162-
target: x86_64-unknown-linux-gnu
163-
- os: windows-2022
164-
target: x86_64-pc-windows-msvc
165-
- os: macOS-latest
166-
target: aarch64-apple-darwin
143+
os: [ ubuntu-24.04, windows-2022, macOS-latest ]
167144
runs-on: ${{ matrix.os }}
168145
steps:
169146
- uses: actions/checkout@v4
@@ -182,13 +159,12 @@ jobs:
182159
sudo add-apt-repository ppa:kisak/turtle -y
183160
sudo apt-get update
184161
sudo apt install -y xvfb libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers
185-
# cargo version is a random command that forces the installation of rust-toolchain
186162
- name: install rust-toolchain
187-
run: cargo version
163+
run: echo "TARGET=$(rustc --print host-tuple)" >> "$GITHUB_ENV"
188164
- name: cargo fetch --locked
189-
run: cargo fetch --locked --target ${{ matrix.target }}
165+
run: cargo fetch --locked --target $TARGET
190166
- name: cargo fetch --locked difftests
191-
run: cargo fetch --locked --manifest-path=tests/difftests/tests/Cargo.toml --target ${{ matrix.target }}
167+
run: cargo fetch --locked --manifest-path=tests/difftests/tests/Cargo.toml --target $TARGET
192168
- name: test difftest
193169
run: cargo test -p "difftest*" --release --no-default-features --features "use-installed-tools"
194170
- name: difftests
@@ -246,3 +222,7 @@ jobs:
246222
steps:
247223
- uses: actions/checkout@v4
248224
- uses: EmbarkStudios/cargo-deny-action@v2
225+
226+
defaults:
227+
run:
228+
shell: bash

Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ spirv-builder = { path = "./crates/spirv-builder", version = "=0.9.0", default-f
4646
spirv-std = { path = "./crates/spirv-std", version = "=0.9.0" }
4747
spirv-std-types = { path = "./crates/spirv-std/shared", version = "=0.9.0" }
4848
spirv-std-macros = { path = "./crates/spirv-std/macros", version = "=0.9.0" }
49-
spirv-tools = { version = "0.11", default-features = false }
49+
spirv-tools = { version = "0.12", default-features = false }
5050
rustc_codegen_spirv = { path = "./crates/rustc_codegen_spirv", version = "=0.9.0", default-features = false }
5151
rustc_codegen_spirv-types = { path = "./crates/rustc_codegen_spirv-types", version = "=0.9.0" }
5252
rustc_codegen_spirv-target-specs = { path = "crates/rustc_codegen_spirv-target-specs", version = "=0.9.0" }

crates/rustc_codegen_spirv-target-specs/src/include_str.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ pub const TARGET_SPECS: &[(&str, &str)] = &[
4444
"spirv-unknown-spv1.5.json",
4545
include_str!("../target-specs/spirv-unknown-spv1.5.json"),
4646
),
47+
(
48+
"spirv-unknown-spv1.6.json",
49+
include_str!("../target-specs/spirv-unknown-spv1.6.json"),
50+
),
4751
(
4852
"spirv-unknown-vulkan1.0.json",
4953
include_str!("../target-specs/spirv-unknown-vulkan1.0.json"),
@@ -60,4 +64,12 @@ pub const TARGET_SPECS: &[(&str, &str)] = &[
6064
"spirv-unknown-vulkan1.2.json",
6165
include_str!("../target-specs/spirv-unknown-vulkan1.2.json"),
6266
),
67+
(
68+
"spirv-unknown-vulkan1.3.json",
69+
include_str!("../target-specs/spirv-unknown-vulkan1.3.json"),
70+
),
71+
(
72+
"spirv-unknown-vulkan1.4.json",
73+
include_str!("../target-specs/spirv-unknown-vulkan1.4.json"),
74+
),
6375
];
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"allows-weak-linkage": false,
3+
"arch": "spirv",
4+
"crt-objects-fallback": "false",
5+
"crt-static-allows-dylibs": true,
6+
"data-layout": "e-m:e-p:32:32:32-i64:64-n8:16:32:64",
7+
"dll-prefix": "",
8+
"dll-suffix": ".spv.json",
9+
"dynamic-linking": true,
10+
"emit-debug-gdb-scripts": false,
11+
"env": "spv1.6",
12+
"linker-flavor": "unix",
13+
"linker-is-gnu": false,
14+
"llvm-target": "spirv-unknown-spv1.6",
15+
"main-needs-argc-argv": false,
16+
"metadata": {
17+
"description": null,
18+
"host_tools": null,
19+
"std": null,
20+
"tier": null
21+
},
22+
"os": "unknown",
23+
"panic-strategy": "abort",
24+
"simd-types-indirect": false,
25+
"target-pointer-width": "32"
26+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"allows-weak-linkage": false,
3+
"arch": "spirv",
4+
"crt-objects-fallback": "false",
5+
"crt-static-allows-dylibs": true,
6+
"data-layout": "e-m:e-p:32:32:32-i64:64-n8:16:32:64",
7+
"dll-prefix": "",
8+
"dll-suffix": ".spv.json",
9+
"dynamic-linking": true,
10+
"emit-debug-gdb-scripts": false,
11+
"env": "vulkan1.3",
12+
"linker-flavor": "unix",
13+
"linker-is-gnu": false,
14+
"llvm-target": "spirv-unknown-vulkan1.3",
15+
"main-needs-argc-argv": false,
16+
"metadata": {
17+
"description": null,
18+
"host_tools": null,
19+
"std": null,
20+
"tier": null
21+
},
22+
"os": "unknown",
23+
"panic-strategy": "abort",
24+
"simd-types-indirect": false,
25+
"target-pointer-width": "32"
26+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"allows-weak-linkage": false,
3+
"arch": "spirv",
4+
"crt-objects-fallback": "false",
5+
"crt-static-allows-dylibs": true,
6+
"data-layout": "e-m:e-p:32:32:32-i64:64-n8:16:32:64",
7+
"dll-prefix": "",
8+
"dll-suffix": ".spv.json",
9+
"dynamic-linking": true,
10+
"emit-debug-gdb-scripts": false,
11+
"env": "vulkan1.4",
12+
"linker-flavor": "unix",
13+
"linker-is-gnu": false,
14+
"llvm-target": "spirv-unknown-vulkan1.4",
15+
"main-needs-argc-argv": false,
16+
"metadata": {
17+
"description": null,
18+
"host_tools": null,
19+
"std": null,
20+
"tier": null
21+
},
22+
"os": "unknown",
23+
"panic-strategy": "abort",
24+
"simd-types-indirect": false,
25+
"target-pointer-width": "32"
26+
}

crates/rustc_codegen_spirv/src/builder/byte_addressable_buffer.rs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ use crate::maybe_pqp_cg_ssa as rustc_codegen_ssa;
44
use super::Builder;
55
use crate::builder_spirv::{SpirvValue, SpirvValueExt, SpirvValueKind};
66
use crate::spirv_type::SpirvType;
7-
use rspirv::spirv::Word;
7+
use rspirv::spirv::{Decoration, Word};
8+
use rustc_codegen_spirv_types::Capability;
89
use rustc_codegen_ssa::traits::BuilderMethods;
910
use rustc_errors::ErrorGuaranteed;
1011
use rustc_span::DUMMY_SP;
@@ -41,11 +42,20 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
4142
};
4243
let u32_ty = SpirvType::Integer(32, false).def(DUMMY_SP, self);
4344
let u32_ptr = self.type_ptr_to(u32_ty);
45+
let array = array.def(self);
46+
let actual_index = actual_index.def(self);
4447
let ptr = self
4548
.emit()
46-
.in_bounds_access_chain(u32_ptr, None, array.def(self), [actual_index.def(self)])
49+
.in_bounds_access_chain(u32_ptr, None, array, [actual_index])
4750
.unwrap()
4851
.with_type(u32_ptr);
52+
if self.builder.has_capability(Capability::ShaderNonUniform) {
53+
// apply NonUniform to the operation and the index
54+
self.emit()
55+
.decorate(ptr.def(self), Decoration::NonUniform, []);
56+
self.emit()
57+
.decorate(actual_index, Decoration::NonUniform, []);
58+
}
4959
self.load(u32_ty, ptr, Align::ONE)
5060
}
5161

@@ -233,11 +243,20 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
233243
};
234244
let u32_ty = SpirvType::Integer(32, false).def(DUMMY_SP, self);
235245
let u32_ptr = self.type_ptr_to(u32_ty);
246+
let array = array.def(self);
247+
let actual_index = actual_index.def(self);
236248
let ptr = self
237249
.emit()
238-
.in_bounds_access_chain(u32_ptr, None, array.def(self), [actual_index.def(self)])
250+
.in_bounds_access_chain(u32_ptr, None, array, [actual_index])
239251
.unwrap()
240252
.with_type(u32_ptr);
253+
if self.builder.has_capability(Capability::ShaderNonUniform) {
254+
// apply NonUniform to the operation and the index
255+
self.emit()
256+
.decorate(ptr.def(self), Decoration::NonUniform, []);
257+
self.emit()
258+
.decorate(actual_index, Decoration::NonUniform, []);
259+
}
241260
self.store(value, ptr, Align::ONE);
242261
Ok(())
243262
}

crates/rustc_codegen_spirv/src/linker/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,11 @@ pub fn link(
472472
duplicates::remove_duplicate_debuginfo(&mut output);
473473
}
474474

475+
{
476+
let _timer = sess.timer("link_remove_non_uniform");
477+
simple_passes::remove_non_uniform_decorations(sess, &mut output)?;
478+
}
479+
475480
// NOTE(eddyb) SPIR-T pipeline is entirely limited to this block.
476481
{
477482
let (spv_words, module_or_err, lower_from_spv_timer) =

crates/rustc_codegen_spirv/src/linker/simple_passes.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use super::{Result, get_name, get_names};
22
use rspirv::dr::{Block, Function, Module};
3-
use rspirv::spirv::{ExecutionModel, Op, Word};
3+
use rspirv::spirv::{Decoration, ExecutionModel, Op, Word};
4+
use rustc_codegen_spirv_types::Capability;
45
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
56
use rustc_session::Session;
67
use std::iter::once;
@@ -264,3 +265,19 @@ pub fn check_fragment_insts(sess: &Session, module: &Module) -> Result<()> {
264265
}
265266
}
266267
}
268+
269+
/// Remove all [`Decoration::NonUniform`] if this module does *not* have [`Capability::ShaderNonUniform`].
270+
/// This allows image asm to always declare `NonUniform` and not worry about conditional compilation.
271+
pub fn remove_non_uniform_decorations(_sess: &Session, module: &mut Module) -> Result<()> {
272+
let has_shader_non_uniform_capability = module.capabilities.iter().any(|inst| {
273+
inst.class.opcode == Op::Capability
274+
&& inst.operands[0].unwrap_capability() == Capability::ShaderNonUniform
275+
});
276+
if !has_shader_non_uniform_capability {
277+
module.annotations.retain(|inst| {
278+
!(inst.class.opcode == Op::Decorate
279+
&& inst.operands[1].unwrap_decoration() == Decoration::NonUniform)
280+
});
281+
}
282+
Ok(())
283+
}

0 commit comments

Comments
 (0)