mirror of
https://github.com/EmbarkStudios/rust-gpu.git
synced 2024-11-24 07:45:05 +00:00
Update spirt
for better OpExtInst
support (https://github.com/EmbarkStudios/spirt/pull/45).
This commit is contained in:
parent
4c7c97f2ac
commit
a48588b11b
@ -46,6 +46,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
(see its documentation for more details about each available panic handling strategy)
|
||||
|
||||
### Changed 🛠
|
||||
- [PR#1083](https://github.com/EmbarkStudios/rust-gpu/pull/1083) updated SPIR-T to get pretty-printer
|
||||
improvements (especially for `OpExtInst`, including Rust-GPU's custom ones), and started more
|
||||
aggressively deduplicating custom debuginfo instructions (to make SPIR-T dumps more readable)
|
||||
- [PR#1079](https://github.com/EmbarkStudios/rust-gpu/pull/1079) revised `spirv-builder`'s `README.md`,
|
||||
and added a way for `docs.rs` to be able to build it (via `cargo +stable doc --no-default-features`)
|
||||
- [PR#1070](https://github.com/EmbarkStudios/rust-gpu/pull/1070) made panics (via the `abort` intrinsic)
|
||||
|
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -2280,7 +2280,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "spirt"
|
||||
version = "0.2.0"
|
||||
source = "git+https://github.com/EmbarkStudios/spirt?branch=main#cd21d968127035ad3707829849d0466368649299"
|
||||
source = "git+https://github.com/EmbarkStudios/spirt?branch=main#82daf2516710504986cdc35e0e27455326aeef90"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"bytemuck",
|
||||
|
@ -15,6 +15,18 @@ use smallvec::SmallVec;
|
||||
/// See `CUSTOM_EXT_INST_SET`'s docs for further constraints on the full name.
|
||||
pub const CUSTOM_EXT_INST_SET_PREFIX: &str = concat!("Rust.", env!("CARGO_PKG_NAME"), ".");
|
||||
|
||||
macro_rules! join_cargo_pkg_version_major_minor_patch {
|
||||
($sep:literal) => {
|
||||
concat!(
|
||||
env!("CARGO_PKG_VERSION_MAJOR"),
|
||||
$sep,
|
||||
env!("CARGO_PKG_VERSION_MINOR"),
|
||||
$sep,
|
||||
env!("CARGO_PKG_VERSION_PATCH"),
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
/// `OpExtInstImport` "instruction set" name for all Rust-GPU instructions.
|
||||
///
|
||||
@ -30,10 +42,6 @@ lazy_static! {
|
||||
/// if the definitions of the custom instructions have changed - this is
|
||||
/// achieved by hashing the `SCHEMA` constant from `def_custom_insts!` below
|
||||
pub static ref CUSTOM_EXT_INST_SET: String = {
|
||||
const VER_MAJOR: &str = env!("CARGO_PKG_VERSION_MAJOR");
|
||||
const VER_MINOR: &str = env!("CARGO_PKG_VERSION_MINOR");
|
||||
const VER_PATCH: &str = env!("CARGO_PKG_VERSION_PATCH");
|
||||
|
||||
let schema_hash = {
|
||||
use rustc_data_structures::stable_hasher::StableHasher;
|
||||
use std::hash::Hash;
|
||||
@ -43,11 +51,47 @@ lazy_static! {
|
||||
let (lo, hi) = hasher.finalize();
|
||||
(lo as u128) | ((hi as u128) << 64)
|
||||
};
|
||||
|
||||
format!("{CUSTOM_EXT_INST_SET_PREFIX}{VER_MAJOR}_{VER_MINOR}_{VER_PATCH}.{schema_hash:x}")
|
||||
let version = join_cargo_pkg_version_major_minor_patch!("_");
|
||||
format!("{CUSTOM_EXT_INST_SET_PREFIX}{version}.{schema_hash:x}")
|
||||
};
|
||||
}
|
||||
|
||||
pub fn register_to_spirt_context(cx: &spirt::Context) {
|
||||
use spirt::spv::spec::{ExtInstSetDesc, ExtInstSetInstructionDesc};
|
||||
cx.register_custom_ext_inst_set(
|
||||
&CUSTOM_EXT_INST_SET,
|
||||
ExtInstSetDesc {
|
||||
// HACK(eddyb) this is the most compact form I've found, that isn't
|
||||
// outright lossy by omitting "Rust vs Rust-GPU" or the version.
|
||||
short_alias: Some(
|
||||
concat!("Rust-GPU ", join_cargo_pkg_version_major_minor_patch!(".")).into(),
|
||||
),
|
||||
instructions: SCHEMA
|
||||
.iter()
|
||||
.map(|&(i, name, operand_names)| {
|
||||
(
|
||||
i,
|
||||
ExtInstSetInstructionDesc {
|
||||
name: name.into(),
|
||||
operand_names: operand_names
|
||||
.iter()
|
||||
.map(|name| {
|
||||
name.strip_prefix("..")
|
||||
.unwrap_or(name)
|
||||
.replace('_', " ")
|
||||
.into()
|
||||
})
|
||||
.collect(),
|
||||
is_debuginfo: name.contains("Debug")
|
||||
|| name.contains("InlinedCallFrame"),
|
||||
},
|
||||
)
|
||||
})
|
||||
.collect(),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
macro_rules! def_custom_insts {
|
||||
($($num:literal => $name:ident $({ $($field:ident),+ $(, ..$variadic_field:ident)? $(,)? })?),+ $(,)?) => {
|
||||
const SCHEMA: &[(u32, &str, &[&str])] = &[
|
||||
|
@ -409,6 +409,7 @@ pub fn link(
|
||||
spirv_tools::binary::from_binary(&spv_words).to_vec()
|
||||
};
|
||||
let cx = std::rc::Rc::new(spirt::Context::new());
|
||||
crate::custom_insts::register_to_spirt_context(&cx);
|
||||
let mut module = {
|
||||
let _timer = sess.timer("spirt::Module::lower_from_spv_file");
|
||||
match spirt::Module::lower_from_spv_bytes(cx.clone(), spv_bytes) {
|
||||
|
Loading…
Reference in New Issue
Block a user