unstable-naga

This commit is contained in:
Alex Janka 2024-07-20 17:45:38 +10:00
parent e9f2789703
commit 71d1ddfa2a
7 changed files with 57 additions and 54 deletions

62
Cargo.lock generated
View file

@ -275,30 +275,15 @@ dependencies = [
"virtue", "virtue",
] ]
[[package]]
name = "bit-set"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1"
dependencies = [
"bit-vec 0.6.3",
]
[[package]] [[package]]
name = "bit-set" name = "bit-set"
version = "0.6.0" version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0481a0e032742109b1133a095184ee93d88f3dc9e0d28a5d033dc77a073f44f" checksum = "f0481a0e032742109b1133a095184ee93d88f3dc9e0d28a5d033dc77a073f44f"
dependencies = [ dependencies = [
"bit-vec 0.7.0", "bit-vec",
] ]
[[package]]
name = "bit-vec"
version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb"
[[package]] [[package]]
name = "bit-vec" name = "bit-vec"
version = "0.7.0" version = "0.7.0"
@ -1763,7 +1748,7 @@ dependencies = [
"librashader-presets", "librashader-presets",
"librashader-spirv-cross", "librashader-spirv-cross",
"matches", "matches",
"naga 0.20.0", "naga",
"rspirv", "rspirv",
"rustc-hash", "rustc-hash",
"serde", "serde",
@ -2084,26 +2069,6 @@ dependencies = [
"simd-adler32", "simd-adler32",
] ]
[[package]]
name = "naga"
version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e536ae46fcab0876853bd4a632ede5df4b1c2527a58f6c5a4150fe86be858231"
dependencies = [
"arrayvec",
"bit-set 0.5.3",
"bitflags 2.6.0",
"codespan-reporting",
"indexmap 2.2.6",
"log",
"num-traits",
"petgraph",
"rustc-hash",
"spirv",
"termcolor",
"thiserror",
]
[[package]] [[package]]
name = "naga" name = "naga"
version = "22.0.0" version = "22.0.0"
@ -2111,13 +2076,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09eeccb9b50f4f7839b214aa3e08be467159506a986c18e0702170ccf720a453" checksum = "09eeccb9b50f4f7839b214aa3e08be467159506a986c18e0702170ccf720a453"
dependencies = [ dependencies = [
"arrayvec", "arrayvec",
"bit-set 0.6.0", "bit-set",
"bitflags 2.6.0", "bitflags 2.6.0",
"cfg_aliases", "cfg_aliases",
"codespan-reporting", "codespan-reporting",
"hexf-parse", "hexf-parse",
"indexmap 2.2.6", "indexmap 2.2.6",
"log", "log",
"petgraph",
"pp-rs",
"rustc-hash", "rustc-hash",
"spirv", "spirv",
"termcolor", "termcolor",
@ -2551,6 +2518,15 @@ version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22686f4785f02a4fcc856d3b3bb19bf6c8160d103f7a99cc258bddd0251dc7f2" checksum = "22686f4785f02a4fcc856d3b3bb19bf6c8160d103f7a99cc258bddd0251dc7f2"
[[package]]
name = "pp-rs"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb458bb7f6e250e6eb79d5026badc10a3ebb8f9a15d1fff0f13d17c71f4d6dee"
dependencies = [
"unicode-xid",
]
[[package]] [[package]]
name = "ppv-lite86" name = "ppv-lite86"
version = "0.2.17" version = "0.2.17"
@ -3689,7 +3665,7 @@ dependencies = [
"document-features", "document-features",
"js-sys", "js-sys",
"log", "log",
"naga 22.0.0", "naga",
"parking_lot", "parking_lot",
"profiling", "profiling",
"raw-window-handle 0.6.2", "raw-window-handle 0.6.2",
@ -3710,13 +3686,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0f191908a21968991463fcf3b42cb6c9648c0fb7fa301b8fc733bc21a9ed9bd" checksum = "e0f191908a21968991463fcf3b42cb6c9648c0fb7fa301b8fc733bc21a9ed9bd"
dependencies = [ dependencies = [
"arrayvec", "arrayvec",
"bit-vec 0.7.0", "bit-vec",
"bitflags 2.6.0", "bitflags 2.6.0",
"cfg_aliases", "cfg_aliases",
"document-features", "document-features",
"indexmap 2.2.6", "indexmap 2.2.6",
"log", "log",
"naga 22.0.0", "naga",
"once_cell", "once_cell",
"parking_lot", "parking_lot",
"profiling", "profiling",
@ -3737,7 +3713,7 @@ dependencies = [
"android_system_properties", "android_system_properties",
"arrayvec", "arrayvec",
"ash 0.38.0+1.3.281", "ash 0.38.0+1.3.281",
"bit-set 0.6.0", "bit-set",
"bitflags 2.6.0", "bitflags 2.6.0",
"block", "block",
"cfg_aliases", "cfg_aliases",
@ -3755,7 +3731,7 @@ dependencies = [
"libloading 0.8.3", "libloading 0.8.3",
"log", "log",
"metal", "metal",
"naga 22.0.0", "naga",
"ndk-sys", "ndk-sys",
"objc", "objc",
"once_cell", "once_cell",

View file

@ -24,9 +24,9 @@ librashader-presets = { path = "../librashader-presets", version = "0.2.7" }
spirv_cross = { package = "librashader-spirv-cross", version = "0.25.1", optional = true } spirv_cross = { package = "librashader-spirv-cross", version = "0.25.1", optional = true }
naga = { version = "0.20.0", optional = true } naga = { version = "22.0.0", optional = true }
rspirv = { version = "0.12.0", optional = true } rspirv = { version = "0.12.0", optional = true }
spirv = { version = "0.3.0", optional = true} spirv = { version = "0.3.0", optional = true }
serde = { version = "1.0", features = ["derive"], optional = true } serde = { version = "1.0", features = ["derive"], optional = true }
@ -42,7 +42,20 @@ optional = true
default = ["cross", "naga", "serialize", "wgsl", "msl"] default = ["cross", "naga", "serialize", "wgsl", "msl"]
dxil = ["spirv_cross/hlsl", "spirv-to-dxil"] dxil = ["spirv_cross/hlsl", "spirv-to-dxil"]
wgsl = ["cross", "naga/wgsl-out", "spirv", "rspirv"] wgsl = ["cross", "naga/wgsl-out", "spirv", "rspirv"]
cross = [ "spirv_cross", "spirv_cross/glsl", "spirv_cross/hlsl", "spirv_cross/msl" ] cross = [
naga = [ "rspirv", "spirv", "naga/spv-in", "naga/spv-out", "naga/wgsl-out", "naga/msl-out" ] "spirv_cross",
serialize = [ "serde" ] "spirv_cross/glsl",
msl = [ "spirv_cross/msl", "naga/msl-out" ] "spirv_cross/hlsl",
"spirv_cross/msl",
]
naga = [
"rspirv",
"spirv",
"naga/spv-in",
"naga/spv-out",
"naga/wgsl-out",
"naga/msl-out",
]
unstable-naga = ["naga", "naga/glsl-in"]
serialize = ["serde"]
msl = ["spirv_cross/msl", "naga/msl-out"]

View file

@ -130,7 +130,10 @@ mod test {
use librashader_preprocess::ShaderSource; use librashader_preprocess::ShaderSource;
pub fn test() { pub fn test() {
let result = ShaderSource::load("../test/basic.slang").unwrap(); let result = ShaderSource::load(&librashader_common::ShaderStorage::Path(
"../test/basic.slang".into(),
))
.unwrap();
let _cross = Glslang::compile(&result).unwrap(); let _cross = Glslang::compile(&result).unwrap();
} }
} }

View file

@ -35,7 +35,6 @@ mod test {
use crate::reflect::naga::NagaLoweringOptions; use crate::reflect::naga::NagaLoweringOptions;
use crate::reflect::semantics::{Semantic, ShaderSemantics, UniformSemantic, UniqueSemantics}; use crate::reflect::semantics::{Semantic, ShaderSemantics, UniformSemantic, UniqueSemantics};
use crate::reflect::ReflectShader; use crate::reflect::ReflectShader;
use bitflags::Flags;
use librashader_common::map::FastHashMap; use librashader_common::map::FastHashMap;
use librashader_preprocess::ShaderSource; use librashader_preprocess::ShaderSource;
@ -43,7 +42,10 @@ mod test {
pub fn test_into() { pub fn test_into() {
// let result = ShaderSource::load("../test/shaders_slang/crt/shaders/crt-royale/src/crt-royale-scanlines-horizontal-apply-mask.slang").unwrap(); // let result = ShaderSource::load("../test/shaders_slang/crt/shaders/crt-royale/src/crt-royale-scanlines-horizontal-apply-mask.slang").unwrap();
// let result = ShaderSource::load("../test/shaders_slang/crt/shaders/crt-royale/src/crt-royale-scanlines-horizontal-apply-mask.slang").unwrap(); // let result = ShaderSource::load("../test/shaders_slang/crt/shaders/crt-royale/src/crt-royale-scanlines-horizontal-apply-mask.slang").unwrap();
let result = ShaderSource::load("../test/basic.slang").unwrap(); let result = ShaderSource::load(&librashader_common::ShaderStorage::Path(
"../test/basic.slang".into(),
))
.unwrap();
let mut uniform_semantics: FastHashMap<String, UniformSemantic> = Default::default(); let mut uniform_semantics: FastHashMap<String, UniformSemantic> = Default::default();

View file

@ -57,7 +57,10 @@ mod test {
use librashader_preprocess::ShaderSource; use librashader_preprocess::ShaderSource;
#[test] #[test]
pub fn compile_shader() { pub fn compile_shader() {
let result = ShaderSource::load("../test/basic.slang").unwrap(); let result = ShaderSource::load(&librashader_common::ShaderStorage::Path(
"../test/basic.slang".into(),
))
.unwrap();
let _spirv = compile_spirv(&result).unwrap(); let _spirv = compile_spirv(&result).unwrap();
} }
} }

View file

@ -57,6 +57,8 @@ impl CompileShader<MSL> for NagaReflect {
let pipeline_options = PipelineOptions { let pipeline_options = PipelineOptions {
allow_and_force_point_size: false, allow_and_force_point_size: false,
vertex_pulling_transform: false,
vertex_buffer_mappings: Vec::new(),
}; };
let msl = naga::back::msl::write_string(module, &info, &options, &pipeline_options)?; let msl = naga::back::msl::write_string(module, &info, &options, &pipeline_options)?;

View file

@ -111,7 +111,11 @@ runtime-metal = [
# reflection # reflection
reflect-cross = ["reflect", "librashader-reflect/cross"] reflect-cross = ["reflect", "librashader-reflect/cross"]
reflect-dxil = ["reflect", "librashader-reflect/dxil"] reflect-dxil = ["reflect", "librashader-reflect/dxil"]
reflect-naga = ["reflect", "librashader-reflect/naga"] reflect-naga = [
"reflect",
"librashader-reflect/naga",
"librashader-reflect/unstable-naga",
]
runtime-all = [ runtime-all = [
"runtime-gl", "runtime-gl",