Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [PR#1031](https://github.com/EmbarkStudios/rust-gpu/pull/1031) added `Components` generic parameter to `Image` type, allowing images to return lower dimensional vectors and even scalars from the sampling API

### Changed 🛠
- [PR#1040](https://github.com/EmbarkStudios/rust-gpu/pull/1040) refactored "zombie" (delayed error) reporting to use SPIR-V `OpSource`, be more helpful, and added `--no-early-report-zombies` to delay it even further
(see also [the `--no-early-report-zombies` codegen args docs](docs/src/codegen-args.md#--no-early-report-zombies))
- [PR#1035](https://github.com/EmbarkStudios/rust-gpu/pull/1035) reduced the number of CGUs ("codegen units") used by `spirv-builder` to just `1`
- [PR#1011](https://github.com/EmbarkStudios/rust-gpu/pull/1011) made `NonWritable` all read-only storage buffers (i.e. those typed `&T`, where `T` doesn't have interior mutability)
- [PR#1029](https://github.com/EmbarkStudios/rust-gpu/pull/1029) fixed SampledImage::sample() fns being unnecessarily marked as unsafe
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/rustc_codegen_spirv/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ spirv-tools = { version = "0.9", default-features = false }
rustc_codegen_spirv-types.workspace = true
spirt = "0.1.0"
lazy_static = "1.4.0"
itertools = "0.10.5"

[dev-dependencies]
pipe = "0.4"
Expand Down
2 changes: 1 addition & 1 deletion crates/rustc_codegen_spirv/src/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ impl<'tcx> RecursivePointeeCache<'tcx> {
cx.zombie_with_span(
new_id,
span,
"Cannot create self-referential types, even through pointers",
"cannot create self-referential types, even through pointers",
);
Some(new_id)
}
Expand Down
49 changes: 24 additions & 25 deletions crates/rustc_codegen_spirv/src/builder/builder_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
if invalid_seq_cst {
self.zombie(
semantics.def(self),
"Cannot use AtomicOrdering=SequentiallyConsistent on Vulkan memory model. Check if AcquireRelease fits your needs.",
"cannot use AtomicOrdering=SequentiallyConsistent on Vulkan memory model \
(check if AcquireRelease fits your needs)",
);
}
semantics
Expand Down Expand Up @@ -352,11 +353,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
}

fn zombie_convert_ptr_to_u(&self, def: Word) {
self.zombie(def, "Cannot convert pointers to integers");
self.zombie(def, "cannot convert pointers to integers");
}

fn zombie_convert_u_to_ptr(&self, def: Word) {
self.zombie(def, "Cannot convert integers to pointers");
self.zombie(def, "cannot convert integers to pointers");
}

fn zombie_ptr_equal(&self, def: Word, inst: &str) {
Expand Down Expand Up @@ -656,12 +657,15 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {

fn set_span(&mut self, span: Span) {
self.current_span = Some(span);
let loc = self.cx.tcx.sess.source_map().lookup_char_pos(span.lo());
let file = self
.builder
.def_string(format!("{}", loc.file.name.prefer_remapped()));
self.emit()
.line(file, loc.line as u32, loc.col_display as u32);

// We may not always have valid spans.
// FIXME(eddyb) reduce the sources of this as much as possible.
if span.is_dummy() {
self.emit().no_line();
} else {
let (file, line, col) = self.builder.file_line_col_for_op_line(span);
self.emit().line(file.file_name_op_string_id, line, col);
}
}

// FIXME(eddyb) change `Self::Function` to be more like a function index.
Expand Down Expand Up @@ -1450,21 +1454,16 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
.with_type(dest_ty);

if val_is_ptr || dest_is_ptr {
if self.is_system_crate(self.span()) {
self.zombie(
result.def(self),
&format!(
"Cannot cast between pointer and non-pointer types. From: {}. To: {}.",
self.debug_type(val.ty),
self.debug_type(dest_ty)
),
);
} else {
self.struct_err("Cannot cast between pointer and non-pointer types")
.note(&format!("from: {}", self.debug_type(val.ty)))
.note(&format!("to: {}", self.debug_type(dest_ty)))
.emit();
}
self.zombie(
result.def(self),
&format!(
"cannot cast between pointer and non-pointer types\
\nfrom `{}`\
\n to `{}`",
self.debug_type(val.ty),
self.debug_type(dest_ty)
),
);
}

result
Expand Down Expand Up @@ -1881,7 +1880,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
empty(),
)
.unwrap();
self.zombie(dst.def(self), "Cannot memcpy dynamically sized data");
self.zombie(dst.def(self), "cannot memcpy dynamically sized data");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use rustc_target::abi::{Align, Size};
impl<'a, 'tcx> Builder<'a, 'tcx> {
fn load_err(&mut self, original_type: Word, invalid_type: Word) -> SpirvValue {
let mut err = self.struct_err(&format!(
"Cannot load type {} in an untyped buffer load",
"cannot load type {} in an untyped buffer load",
self.debug_type(original_type)
));
if original_type != invalid_type {
Expand Down Expand Up @@ -206,7 +206,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {

fn store_err(&mut self, original_type: Word, value: SpirvValue) -> Result<(), ErrorGuaranteed> {
let mut err = self.struct_err(&format!(
"Cannot store type {} in an untyped buffer store",
"cannot store type {} in an untyped buffer store",
self.debug_type(original_type)
));
if original_type != value.ty {
Expand Down
4 changes: 2 additions & 2 deletions crates/rustc_codegen_spirv/src/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
.with_type(result_type);
self.zombie(
result.def(self),
"Cannot offset a pointer to an arbitrary element",
"cannot offset a pointer to an arbitrary element",
);
result
}
Expand All @@ -219,7 +219,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let width = match self.lookup_type(shift.ty) {
SpirvType::Integer(width, _) => width,
other => self.fatal(&format!(
"Cannot rotate non-integer type: {}",
"cannot rotate non-integer type: {}",
other.debug(shift.ty, self)
)),
};
Expand Down
Loading