Skip to content

Commit

Permalink
Update to nightly-2024-05-20.
Browse files Browse the repository at this point in the history
  • Loading branch information
LegNeato committed Oct 14, 2024
1 parent 666f1fc commit c3b732d
Show file tree
Hide file tree
Showing 14 changed files with 46 additions and 21 deletions.
4 changes: 2 additions & 2 deletions crates/rustc_codegen_spirv/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ use std::process::{Command, ExitCode};
/// `cargo publish`. We need to figure out a way to do this properly, but let's hardcode it for now :/
//const REQUIRED_RUST_TOOLCHAIN: &str = include_str!("../../rust-toolchain.toml");
const REQUIRED_RUST_TOOLCHAIN: &str = r#"[toolchain]
channel = "nightly-2024-04-24"
channel = "nightly-2024-05-20"
components = ["rust-src", "rustc-dev", "llvm-tools"]
# commit_hash = 244da22fabd9fa677bbd0ac601a88e5ca6917526"#;
# commit_hash = d84b9037541f45dc2c52a41d723265af211c0497"#;

fn get_rustc_commit_hash() -> Result<String, Box<dyn Error>> {
let rustc = std::env::var("RUSTC").unwrap_or_else(|_| String::from("rustc"));
Expand Down
11 changes: 6 additions & 5 deletions crates/rustc_codegen_spirv/src/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ use rustc_span::DUMMY_SP;
use rustc_span::{Span, Symbol};
use rustc_target::abi::call::{ArgAbi, ArgAttributes, FnAbi, PassMode};
use rustc_target::abi::{
Abi, Align, FieldsShape, LayoutS, Primitive, Scalar, Size, TagEncoding, VariantIdx, Variants,
Abi, Align, FieldsShape, Float, LayoutS, Primitive, Scalar, Size, TagEncoding, VariantIdx,
Variants,
};
use rustc_target::spec::abi::Abi as SpecAbi;
use std::cell::RefCell;
Expand Down Expand Up @@ -504,10 +505,10 @@ fn trans_scalar<'tcx>(
Primitive::Int(width, signedness) => {
SpirvType::Integer(width.size().bits() as u32, signedness).def(span, cx)
}
Primitive::F16 => SpirvType::Float(16).def(span, cx),
Primitive::F32 => SpirvType::Float(32).def(span, cx),
Primitive::F64 => SpirvType::Float(64).def(span, cx),
Primitive::F128 => SpirvType::Float(128).def(span, cx),
Primitive::Float(Float::F16) => SpirvType::Float(16).def(span, cx),
Primitive::Float(Float::F32) => SpirvType::Float(32).def(span, cx),
Primitive::Float(Float::F64) => SpirvType::Float(64).def(span, cx),
Primitive::Float(Float::F128) => SpirvType::Float(128).def(span, cx),
Primitive::Pointer(_) => {
let pointee_ty = dig_scalar_pointee(cx, ty, offset);
// Pointers can be recursive. So, record what we're currently translating, and if we're already translating
Expand Down
8 changes: 4 additions & 4 deletions crates/rustc_codegen_spirv/src/builder/builder_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let exit_bb = self.append_sibling_block("memset_exit");

let count = self.udiv(size_bytes, size_elem_const);
let index = self.alloca(count.ty, zero_align);
let index = self.alloca(Size::from_bytes(size_bytes.ty), zero_align);
self.store(zero, index, zero_align);
self.br(header_bb);

Expand Down Expand Up @@ -1413,8 +1413,8 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
val
}

fn alloca(&mut self, ty: Self::Type, _align: Align) -> Self::Value {
let ptr_ty = self.type_ptr_to(ty);
fn alloca(&mut self, ty: Size, _align: Align) -> Self::Value {
let ptr_ty = self.type_ptr_to(ty.bits_usize() as u32);
// "All OpVariable instructions in a function must be the first instructions in the first block."
let mut builder = self.emit();
builder.select_block(Some(0)).unwrap();
Expand Down Expand Up @@ -1446,7 +1446,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
result_id.with_type(ptr_ty)
}

fn byte_array_alloca(&mut self, _len: Self::Value, _align: Align) -> Self::Value {
fn dynamic_alloca(&mut self, _size: Self::Value, _align: Align) -> Self::Value {
self.fatal("array alloca not supported yet")
}

Expand Down
14 changes: 7 additions & 7 deletions crates/rustc_codegen_spirv/src/codegen_cx/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use rustc_middle::bug;
use rustc_middle::mir::interpret::{alloc_range, ConstAllocation, GlobalAlloc, Scalar};
use rustc_middle::ty::layout::LayoutOf;
use rustc_span::{Span, DUMMY_SP};
use rustc_target::abi::{self, AddressSpace, HasDataLayout, Integer, Primitive, Size};
use rustc_target::abi::{self, AddressSpace, Float, HasDataLayout, Integer, Primitive, Size};

impl<'tcx> CodegenCx<'tcx> {
pub fn def_constant(&self, ty: Word, val: SpirvConst<'_, 'tcx>) -> SpirvValue {
Expand Down Expand Up @@ -273,21 +273,21 @@ impl<'tcx> ConstMethods<'tcx> for CodegenCx<'tcx> {
other.debug(ty, self)
)),
},
Primitive::F16 => self
Primitive::Float(Float::F16) => self
.tcx
.dcx()
.fatal("scalar_to_backend Primitive::F16 not supported"),
Primitive::F32 => {
Primitive::Float(Float::F32) => {
let res = self.constant_f32(DUMMY_SP, f32::from_bits(data as u32));
assert_eq!(res.ty, ty);
res
}
Primitive::F64 => {
Primitive::Float(Float::F64) => {
let res = self.constant_f64(DUMMY_SP, f64::from_bits(data as u64));
assert_eq!(res.ty, ty);
res
}
Primitive::F128 => self
Primitive::Float(Float::F128) => self
.tcx
.dcx()
.fatal("scalar_to_backend Primitive::F128 not supported"),
Expand Down Expand Up @@ -488,8 +488,8 @@ impl<'tcx> CodegenCx<'tcx> {
Primitive::Int(integer, int_signedness)
}
SpirvType::Float(float_size) => match float_size {
32 => Primitive::F32,
64 => Primitive::F64,
32 => Primitive::Float(Float::F32),
64 => Primitive::Float(Float::F64),
other => {
self.tcx
.dcx()
Expand Down
3 changes: 3 additions & 0 deletions examples/runners/ash/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,8 @@ cfg-if = "1.0.0"
shared = { path = "../../shaders/shared" }
spirv-builder = { workspace = true, default-features = false }

[lints.rust]
unexpected_cfgs = { level = "allow", check-cfg = ['cfg(target_arch, values("spirv"))'] }

[target.'cfg(target_os = "macos")'.dependencies]
ash-molten = { version = "0.13.1", features = ["pre-built"] }
3 changes: 3 additions & 0 deletions examples/runners/wgpu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ clap = { version = "4", features = ["derive"] }
strum = { version = "0.25.0", default-features = false, features = ["std", "derive"] }
bytemuck = "1.6.3"

[lints.rust]
unexpected_cfgs = { level = "allow", check-cfg = ['cfg(target_arch, values("spirv"))'] }

[target.'cfg(not(any(target_os = "android", target_arch = "wasm32")))'.dependencies]
env_logger = "0.11.0"
spirv-builder = { workspace = true, features = ["watch"] }
Expand Down
3 changes: 3 additions & 0 deletions examples/shaders/compute-shader/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@ crate-type = ["dylib", "lib"]
[dependencies]
spirv-std = { workspace = true }

[lints.rust]
unexpected_cfgs = { level = "allow", check-cfg = ['cfg(target_arch, values("spirv"))'] }

[target.'cfg(not(target_arch = "spirv"))'.dependencies]
rayon = "1.5"
2 changes: 1 addition & 1 deletion examples/shaders/compute-shader/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![cfg_attr(target_arch = "spirv", no_std)]
// HACK(eddyb) can't easily see warnings otherwise from `spirv-builder` builds.
#![deny(warnings)]
//#![deny(warnings)]

use glam::UVec3;
use spirv_std::{glam, spirv};
Expand Down
3 changes: 3 additions & 0 deletions examples/shaders/mouse-shader/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ crate-type = ["dylib"]
[dependencies]
shared = { path = "../../shaders/shared" }
spirv-std = { workspace = true }

[lints.rust]
unexpected_cfgs = { level = "allow", check-cfg = ['cfg(target_arch, values("spirv"))'] }
3 changes: 3 additions & 0 deletions examples/shaders/reduce/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ crate-type = ["dylib", "lib"]

[dependencies]
spirv-std = { workspace = true }

[lints.rust]
unexpected_cfgs = { level = "allow", check-cfg = ['cfg(target_arch, values("spirv"))'] }
3 changes: 3 additions & 0 deletions examples/shaders/shared/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ repository.workspace = true
[dependencies]
spirv-std = { workspace = true }
bytemuck = { version = "1.18.0", features = ["derive"] }

[lints.rust]
unexpected_cfgs = { level = "allow", check-cfg = ['cfg(target_arch, values("spirv"))'] }
3 changes: 3 additions & 0 deletions examples/shaders/simplest-shader/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ crate-type = ["dylib"]
[dependencies]
spirv-std = { workspace = true }
shared = { path = "../shared" }

[lints.rust]
unexpected_cfgs = { level = "allow", check-cfg = ['cfg(target_arch, values("spirv"))'] }
3 changes: 3 additions & 0 deletions examples/shaders/sky-shader/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ crate-type = ["lib", "dylib"]
[dependencies]
shared = { path = "../../shaders/shared" }
spirv-std = { workspace = true }

[lints.rust]
unexpected_cfgs = { level = "allow", check-cfg = ['cfg(target_arch, values("spirv"))'] }
4 changes: 2 additions & 2 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[toolchain]
channel = "nightly-2024-04-24"
channel = "nightly-2024-05-20"
components = ["rust-src", "rustc-dev", "llvm-tools"]
# commit_hash = 244da22fabd9fa677bbd0ac601a88e5ca6917526
# commit_hash = d84b9037541f45dc2c52a41d723265af211c0497

# Whenever changing the nightly channel, update the commit hash above, and make
# sure to change `REQUIRED_TOOLCHAIN` in `crates/rustc_codegen_spirv/build.rs` also.

0 comments on commit c3b732d

Please sign in to comment.