Skip to content

Commit

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

Picks up another set of fixes from Naga, such as gfx-rs/naga#491, gfx-rs/naga#505, gfx-rs/naga#506, and others

Co-authored-by: Dzmitry Malyshau <[email protected]>
  • Loading branch information
bors[bot] and kvark authored Feb 21, 2021
2 parents 5de59e3 + 2c8aa94 commit a76e687
Show file tree
Hide file tree
Showing 7 changed files with 26 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-11"
tag = "gfx-12"
features = ["spv-in", "glsl-out"]

[target.'cfg(target_arch = "wasm32")'.dependencies]
Expand Down
26 changes: 14 additions & 12 deletions src/backend/gl/src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -522,17 +522,12 @@ impl Device {

fn reflect_shader(
module: &naga::Module,
entry_point: &(naga::ShaderStage, String),
ep_info: &naga::proc::analyzer::FunctionInfo,
texture_mapping: FastHashMap<String, naga::back::glsl::TextureMapping>,
context: CompilationContext,
) {
let ep = &module.entry_points[entry_point];
for ((_, var), usage) in module
.global_variables
.iter()
.zip(ep.function.global_usage.iter())
{
if usage.is_empty() {
for (handle, var) in module.global_variables.iter() {
if ep_info[handle].is_empty() {
continue;
}
let register = match var.class {
Expand Down Expand Up @@ -609,13 +604,15 @@ impl Device {
Ok(texture_mapping) => {
Self::reflect_shader(
&shader.module,
&options.entry_point,
shader
.analysis
.get_entry_point(options.shader_stage, &options.entry_point),
texture_mapping,
context,
);
let source = String::from_utf8(output).unwrap();
debug!("Naga generated shader:\n{}", source);
Self::create_shader_module_raw(gl, &source, options.entry_point.0)
Self::create_shader_module_raw(gl, &source, options.shader_stage)
}
Err(e) => {
warn!("Naga GLSL write: {}", e);
Expand All @@ -641,7 +638,8 @@ impl Device {
Version::Desktop(value)
}
},
entry_point: (stage, ep.entry.to_string()),
shader_stage: stage,
entry_point: ep.entry.to_string(),
};

let mut result = Err(d::ShaderError::CompilationFailed(String::new()));
Expand Down Expand Up @@ -1216,7 +1214,11 @@ impl d::Device<B> for Device {
Ok(n::ShaderModule {
prefer_naga: true,
#[cfg(feature = "cross")]
spv: match naga::back::spv::write_vec(&shader.module, &self.spv_options) {
spv: match naga::back::spv::write_vec(
&shader.module,
&shader.analysis,
&self.spv_options,
) {
Ok(spv) => spv,
Err(e) => {
return Err((d::ShaderError::CompilationFailed(format!("{}", e)), shader))
Expand Down
2 changes: 1 addition & 1 deletion src/backend/metal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ optional = true

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

# This forces docs.rs to build the crate on mac, otherwise the build fails
Expand Down
9 changes: 7 additions & 2 deletions src/backend/metal/src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1390,8 +1390,9 @@ impl hal::device::Device<Backend> for Device {
MTLLanguageVersion::V2_2 => (2, 2),
MTLLanguageVersion::V2_3 => (2, 3),
},
spirv_cross_compatibility: true,
binding_map,
spirv_cross_compatibility: cfg!(feature = "cross"),
fake_missing_bindings: false,
};

Ok(n::PipelineLayout {
Expand Down Expand Up @@ -1893,7 +1894,11 @@ impl hal::device::Device<Backend> for Device {
Ok(n::ShaderModule {
prefer_naga: true,
#[cfg(feature = "cross")]
spv: match naga::back::spv::write_vec(&shader.module, &self.spv_options) {
spv: match naga::back::spv::write_vec(
&shader.module,
&shader.analysis,
&self.spv_options,
) {
Ok(spv) => spv,
Err(e) => {
return Err((d::ShaderError::CompilationFailed(format!("{}", e)), shader))
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-11"
tag = "gfx-12"
features = ["spv-out"]
optional = true

Expand Down
2 changes: 1 addition & 1 deletion src/backend/vulkan/src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ impl d::Device<B> for super::Device {
&self,
shader: d::NagaShader,
) -> Result<n::ShaderModule, (d::ShaderError, d::NagaShader)> {
match naga::back::spv::write_vec(&shader.module, &self.naga_options) {
match naga::back::spv::write_vec(&shader.module, &shader.analysis, &self.naga_options) {
Ok(spv) => self.create_shader_module(&spv).map_err(|e| (e, shader)),
Err(e) => return Err((d::ShaderError::CompilationFailed(format!("{}", e)), shader)),
}
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-11" }
naga = { git = "https://github.com/gfx-rs/naga", tag = "gfx-12" }
raw-window-handle = "0.3"
serde = { version = "1", features = ["serde_derive"], optional = true }
thiserror = "1"
Expand Down

0 comments on commit a76e687

Please sign in to comment.