mirror of
https://github.com/EmbarkStudios/rust-gpu.git
synced 2024-11-21 22:34:34 +00:00
Split out a new -types
crate so spirv-builder
stops loading LLVM via dylibs. (#856)
* Split out a new `-types` crate so `spirv-builder` stops loading LLVM via dylibs. * example-wgpu-runner: halve `max_push_constant_size` so it works on RADV/Fiji.
This commit is contained in:
parent
595f8e7a9c
commit
5ac500d5b9
10
Cargo.lock
generated
10
Cargo.lock
generated
@ -2006,6 +2006,7 @@ dependencies = [
|
||||
"pretty_assertions",
|
||||
"rspirv",
|
||||
"rustc-demangle",
|
||||
"rustc_codegen_spirv-types",
|
||||
"sanitize-filename",
|
||||
"serde",
|
||||
"serde_json",
|
||||
@ -2015,6 +2016,14 @@ dependencies = [
|
||||
"tempfile",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc_codegen_spirv-types"
|
||||
version = "0.4.0-alpha.12"
|
||||
dependencies = [
|
||||
"rspirv",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustfix"
|
||||
version = "0.5.1"
|
||||
@ -2223,6 +2232,7 @@ dependencies = [
|
||||
"notify",
|
||||
"raw-string",
|
||||
"rustc_codegen_spirv",
|
||||
"rustc_codegen_spirv-types",
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
|
@ -13,6 +13,7 @@ members = [
|
||||
"examples/multibuilder",
|
||||
|
||||
"crates/rustc_codegen_spirv",
|
||||
"crates/rustc_codegen_spirv-types",
|
||||
"crates/spirv-builder",
|
||||
"crates/spirv-std",
|
||||
"crates/spirv-std/shared",
|
||||
|
12
crates/rustc_codegen_spirv-types/Cargo.toml
Normal file
12
crates/rustc_codegen_spirv-types/Cargo.toml
Normal file
@ -0,0 +1,12 @@
|
||||
[package]
|
||||
name = "rustc_codegen_spirv-types"
|
||||
description = "SPIR-V backend types shared between rustc_codegen_spirv and spirv-builder"
|
||||
version = "0.4.0-alpha.12"
|
||||
authors = ["Embark <opensource@embark-studios.com>"]
|
||||
edition = "2018"
|
||||
license = "MIT OR Apache-2.0"
|
||||
repository = "https://github.com/EmbarkStudios/rust-gpu"
|
||||
|
||||
[dependencies]
|
||||
rspirv = "0.11"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
@ -1,5 +1,5 @@
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::BTreeMap;
|
||||
use std::fmt::Write;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
@ -7,7 +7,7 @@ use std::path::{Path, PathBuf};
|
||||
#[serde(untagged)]
|
||||
pub enum ModuleResult {
|
||||
SingleModule(PathBuf),
|
||||
MultiModule(FxHashMap<String, PathBuf>),
|
||||
MultiModule(BTreeMap<String, PathBuf>),
|
||||
}
|
||||
|
||||
impl ModuleResult {
|
||||
@ -20,7 +20,7 @@ impl ModuleResult {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn unwrap_multi(&self) -> &FxHashMap<String, PathBuf> {
|
||||
pub fn unwrap_multi(&self) -> &BTreeMap<String, PathBuf> {
|
||||
match self {
|
||||
ModuleResult::MultiModule(result) => result,
|
||||
ModuleResult::SingleModule(_) => {
|
||||
@ -46,28 +46,24 @@ impl CompileResult {
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
struct Trie {
|
||||
struct Trie<'a> {
|
||||
present: bool,
|
||||
children: FxHashMap<String, Box<Trie>>,
|
||||
children: BTreeMap<&'a str, Trie<'a>>,
|
||||
}
|
||||
|
||||
impl Trie {
|
||||
fn create_from<'a>(entry_points: impl IntoIterator<Item = &'a str>) -> Self {
|
||||
impl<'a> Trie<'a> {
|
||||
fn create_from(entry_points: impl IntoIterator<Item = &'a str>) -> Self {
|
||||
let mut result = Trie::default();
|
||||
for entry in entry_points {
|
||||
result.insert(entry.split("::").map(|x| x.to_owned()));
|
||||
result.insert(entry.split("::"));
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
fn insert(&mut self, mut sequence: impl Iterator<Item = String>) {
|
||||
fn insert(&mut self, mut sequence: impl Iterator<Item = &'a str>) {
|
||||
match sequence.next() {
|
||||
None => self.present = true,
|
||||
Some(next) => self
|
||||
.children
|
||||
.entry(next)
|
||||
.or_insert_with(Default::default)
|
||||
.insert(sequence),
|
||||
Some(next) => self.children.entry(next).or_default().insert(sequence),
|
||||
}
|
||||
}
|
||||
|
6
crates/rustc_codegen_spirv-types/src/lib.rs
Normal file
6
crates/rustc_codegen_spirv-types/src/lib.rs
Normal file
@ -0,0 +1,6 @@
|
||||
//! Types used by both `rustc_codegen_spirv` and `spirv-builder`.
|
||||
|
||||
pub use rspirv::spirv::Capability;
|
||||
|
||||
mod compile_result;
|
||||
pub use compile_result::*;
|
@ -45,6 +45,7 @@ serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
smallvec = "1.6.1"
|
||||
spirv-tools = { version = "0.8", default-features = false }
|
||||
rustc_codegen_spirv-types = { path = "../rustc_codegen_spirv-types", version = "0.4.0-alpha.12" }
|
||||
|
||||
[dev-dependencies]
|
||||
pipe = "0.4"
|
||||
|
@ -137,7 +137,6 @@ mod attr;
|
||||
mod builder;
|
||||
mod builder_spirv;
|
||||
mod codegen_cx;
|
||||
mod compile_result;
|
||||
mod decorations;
|
||||
mod link;
|
||||
mod linker;
|
||||
@ -149,8 +148,6 @@ mod target_feature;
|
||||
|
||||
use builder::Builder;
|
||||
use codegen_cx::CodegenCx;
|
||||
pub use compile_result::*;
|
||||
pub use rspirv;
|
||||
use rspirv::binary::Assemble;
|
||||
use rustc_ast::expand::allocator::AllocatorKind;
|
||||
use rustc_codegen_ssa::back::lto::{LtoModuleCodegen, SerializedModule, ThinModule};
|
||||
|
@ -1,13 +1,12 @@
|
||||
use crate::codegen_cx::{CodegenArgs, ModuleOutputType, SpirvMetadata};
|
||||
use crate::{
|
||||
linker, CompileResult, ModuleResult, SpirvCodegenBackend, SpirvModuleBuffer, SpirvThinBuffer,
|
||||
};
|
||||
use crate::{linker, SpirvCodegenBackend, SpirvModuleBuffer, SpirvThinBuffer};
|
||||
use ar::{Archive, GnuBuilder, Header};
|
||||
use rspirv::binary::Assemble;
|
||||
use rustc_codegen_spirv_types::{CompileResult, ModuleResult};
|
||||
use rustc_codegen_ssa::back::lto::{LtoModuleCodegen, SerializedModule, ThinModule, ThinShared};
|
||||
use rustc_codegen_ssa::back::write::CodegenContext;
|
||||
use rustc_codegen_ssa::{CodegenResults, NativeLib, METADATA_FILENAME};
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_errors::FatalError;
|
||||
use rustc_middle::bug;
|
||||
use rustc_middle::dep_graph::WorkProduct;
|
||||
@ -156,15 +155,22 @@ fn link_exe(
|
||||
}
|
||||
}
|
||||
linker::LinkResult::MultipleModules(map) => {
|
||||
let mut hashmap = FxHashMap::default();
|
||||
let entry_points = map.keys().cloned().collect();
|
||||
for (name, spv_binary) in map {
|
||||
let mut module_filename = out_dir.clone();
|
||||
module_filename.push(sanitize_filename::sanitize(&name));
|
||||
post_link_single_module(sess, &cg_args, spv_binary.assemble(), &module_filename);
|
||||
hashmap.insert(name, module_filename);
|
||||
}
|
||||
let module_result = ModuleResult::MultiModule(hashmap);
|
||||
let map = map
|
||||
.into_iter()
|
||||
.map(|(name, spv_binary)| {
|
||||
let mut module_filename = out_dir.clone();
|
||||
module_filename.push(sanitize_filename::sanitize(&name));
|
||||
post_link_single_module(
|
||||
sess,
|
||||
&cg_args,
|
||||
spv_binary.assemble(),
|
||||
&module_filename,
|
||||
);
|
||||
(name, module_filename)
|
||||
})
|
||||
.collect();
|
||||
let module_result = ModuleResult::MultiModule(map);
|
||||
CompileResult {
|
||||
module: module_result,
|
||||
entry_points,
|
||||
|
@ -17,6 +17,7 @@ memchr = "2.4"
|
||||
raw-string = "0.3.5"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
rustc_codegen_spirv-types = { path = "../rustc_codegen_spirv-types" }
|
||||
# See comment in lib.rs invoke_rustc for why this is here
|
||||
rustc_codegen_spirv = { path = "../rustc_codegen_spirv", default-features = false }
|
||||
|
||||
|
@ -86,8 +86,8 @@ use std::io::BufReader;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::{Command, Stdio};
|
||||
|
||||
pub use rustc_codegen_spirv::rspirv::spirv::Capability;
|
||||
pub use rustc_codegen_spirv::{CompileResult, ModuleResult};
|
||||
pub use rustc_codegen_spirv_types::Capability;
|
||||
pub use rustc_codegen_spirv_types::{CompileResult, ModuleResult};
|
||||
|
||||
#[derive(Debug)]
|
||||
#[non_exhaustive]
|
||||
|
@ -1,7 +1,7 @@
|
||||
use std::{collections::HashSet, sync::mpsc::sync_channel};
|
||||
|
||||
use notify::{Event, RecursiveMode, Watcher};
|
||||
use rustc_codegen_spirv::CompileResult;
|
||||
use rustc_codegen_spirv_types::CompileResult;
|
||||
|
||||
use crate::{leaf_deps, SpirvBuilder, SpirvBuilderError};
|
||||
|
||||
|
@ -59,7 +59,7 @@ async fn run(
|
||||
|
||||
let features = wgpu::Features::PUSH_CONSTANTS;
|
||||
let limits = wgpu::Limits {
|
||||
max_push_constant_size: 256,
|
||||
max_push_constant_size: 128,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user