Skip to content

Commit

Permalink
Merge #3714
Browse files Browse the repository at this point in the history
3714: Update naga to gfx-20 r=kvark a=kvark

See gfx-rs/naga#652 (comment)

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
  • Loading branch information
bors[bot] and kvark authored Apr 4, 2021
2 parents f65477f + ca65098 commit 99e75ef
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/backend/gl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ optional = true

[dependencies.naga]
git = "https://github.com/gfx-rs/naga"
tag = "gfx-19"
tag = "gfx-20"
features = ["spv-in", "glsl-out"]

[target.'cfg(target_arch = "wasm32")'.dependencies]
Expand Down
8 changes: 5 additions & 3 deletions src/backend/gl/src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,11 @@ impl Device {
.cloned()
.collect();
let mut flags = spv::WriterFlags::empty();
if cfg!(debug_assertions) {
flags |= spv::WriterFlags::DEBUG;
}
flags.set(spv::WriterFlags::DEBUG, cfg!(debug_assertions));
flags.set(
spv::WriterFlags::ADJUST_COORDINATE_SPACE,
!features.contains(hal::Features::NDC_Y_UP),
);
spv::Options {
lang_version: (1, 0),
flags,
Expand Down
4 changes: 2 additions & 2 deletions src/backend/metal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ workspace = "../../.."
edition = "2018"

[features]
default = []
default = ["cross"] #TEMP
signpost = []
cross = ["spirv_cross", "auxil", "naga/spv-out"]

Expand Down Expand Up @@ -52,7 +52,7 @@ optional = true

[dependencies.naga]
git = "https://github.com/gfx-rs/naga"
tag = "gfx-19"
tag = "gfx-20"
features = ["spv-in", "msl-out"]

# This forces docs.rs to build the crate on mac, otherwise the build fails
Expand Down
32 changes: 24 additions & 8 deletions src/backend/metal/src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,11 @@ impl adapter::PhysicalDevice<Backend> for PhysicalDevice {
.cloned()
.collect();
let mut flags = spv::WriterFlags::empty();
if cfg!(debug_assertions) {
flags |= spv::WriterFlags::DEBUG;
}
flags.set(spv::WriterFlags::DEBUG, cfg!(debug_assertions));
flags.set(
spv::WriterFlags::ADJUST_COORDINATE_SPACE,
!requested_features.contains(hal::Features::NDC_Y_UP),
);
spv::Options {
lang_version: (1, 0),
flags,
Expand Down Expand Up @@ -743,7 +745,17 @@ impl Device {
compiler_options.enable_point_size_builtin =
primitive_class == MTLPrimitiveTopologyClass::Point;
}
let _ = primitive_class;
let options_clone;
let naga_options = match primitive_class {
MTLPrimitiveTopologyClass::Point => {
options_clone = naga::back::msl::Options {
allow_point_size: true,
..layout.naga_options.clone()
};
&options_clone
}
_ => &layout.naga_options,
};

let info = match pipeline_cache {
#[cfg(feature = "cross")]
Expand All @@ -769,7 +781,7 @@ impl Device {
if ep.module.prefer_naga {
result = match ep.module.naga {
Ok(ref shader) => {
Self::compile_shader_library_naga(device, shader, &layout.naga_options)
Self::compile_shader_library_naga(device, shader, naga_options)
}
Err(ref e) => Err(e.clone()),
}
Expand All @@ -788,7 +800,7 @@ impl Device {
if result.is_err() && !ep.module.prefer_naga {
result = match ep.module.naga {
Ok(ref shader) => {
Self::compile_shader_library_naga(device, shader, &layout.naga_options)
Self::compile_shader_library_naga(device, shader, naga_options)
}
Err(ref e) => Err(e.clone()),
}
Expand Down Expand Up @@ -1384,6 +1396,7 @@ impl hal::device::Device<Backend> for Device {
binding_map,
spirv_cross_compatibility: cfg!(feature = "cross"),
fake_missing_bindings: false,
allow_point_size: false,
};

Ok(n::PipelineLayout {
Expand Down Expand Up @@ -1862,8 +1875,11 @@ impl hal::device::Device<Backend> for Device {
#[cfg(feature = "cross")]
spv: raw_data.to_vec(),
naga: {
let parser =
naga::front::spv::Parser::new(raw_data.iter().cloned(), &Default::default());
let options = naga::front::spv::Options {
adjust_coordinate_space: !self.features.contains(hal::Features::NDC_Y_UP),
flow_graph_dump_prefix: None,
};
let parser = naga::front::spv::Parser::new(raw_data.iter().cloned(), &options);
match parser.parse() {
Ok(module) => {
debug!("Naga module {:#?}", module);
Expand Down
2 changes: 1 addition & 1 deletion src/backend/vulkan/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ inplace_it = "0.3.3"

[dependencies.naga]
git = "https://github.com/gfx-rs/naga"
tag = "gfx-19"
tag = "gfx-20"
features = ["spv-out"]
optional = true

Expand Down
8 changes: 5 additions & 3 deletions src/backend/vulkan/src/physical_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -868,9 +868,11 @@ impl adapter::PhysicalDevice<Backend> for PhysicalDevice {
.cloned()
.collect();
let mut flags = spv::WriterFlags::empty();
if cfg!(debug_assertions) {
flags |= spv::WriterFlags::DEBUG;
}
flags.set(spv::WriterFlags::DEBUG, cfg!(debug_assertions));
flags.set(
spv::WriterFlags::ADJUST_COORDINATE_SPACE,
!requested_features.contains(hal::Features::NDC_Y_UP),
);
spv::Options {
lang_version: (1, 0),
flags,
Expand Down
2 changes: 1 addition & 1 deletion src/hal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ path = "src/lib.rs"

[dependencies]
bitflags = "1.0"
naga = { git = "https://github.com/gfx-rs/naga", tag = "gfx-19" }
naga = { git = "https://github.com/gfx-rs/naga", tag = "gfx-20" }
raw-window-handle = "0.3"
serde = { version = "1", features = ["serde_derive"], optional = true }
thiserror = "1"
Expand Down

0 comments on commit 99e75ef

Please sign in to comment.