diff --git a/src/backend/gl/Cargo.toml b/src/backend/gl/Cargo.toml index 284d9881025..88aba6c3ed6 100644 --- a/src/backend/gl/Cargo.toml +++ b/src/backend/gl/Cargo.toml @@ -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] diff --git a/src/backend/gl/src/device.rs b/src/backend/gl/src/device.rs index 01430be7846..c1f0d805ce2 100644 --- a/src/backend/gl/src/device.rs +++ b/src/backend/gl/src/device.rs @@ -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, 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 { @@ -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); @@ -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())); @@ -1216,7 +1214,11 @@ impl d::Device 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)) diff --git a/src/backend/metal/Cargo.toml b/src/backend/metal/Cargo.toml index 83381310761..0378d1535a9 100644 --- a/src/backend/metal/Cargo.toml +++ b/src/backend/metal/Cargo.toml @@ -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 diff --git a/src/backend/metal/src/device.rs b/src/backend/metal/src/device.rs index c23a1099b24..f223f96df2d 100644 --- a/src/backend/metal/src/device.rs +++ b/src/backend/metal/src/device.rs @@ -1390,8 +1390,9 @@ impl hal::device::Device 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 { @@ -1893,7 +1894,11 @@ impl hal::device::Device 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)) diff --git a/src/backend/vulkan/Cargo.toml b/src/backend/vulkan/Cargo.toml index 2432c8947d1..8b7804d889b 100644 --- a/src/backend/vulkan/Cargo.toml +++ b/src/backend/vulkan/Cargo.toml @@ -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 diff --git a/src/backend/vulkan/src/device.rs b/src/backend/vulkan/src/device.rs index 4c0fdd7cf3d..570600213f7 100644 --- a/src/backend/vulkan/src/device.rs +++ b/src/backend/vulkan/src/device.rs @@ -945,7 +945,7 @@ impl d::Device for super::Device { &self, shader: d::NagaShader, ) -> Result { - 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)), } diff --git a/src/hal/Cargo.toml b/src/hal/Cargo.toml index e7f047ef57f..aad465fb37f 100644 --- a/src/hal/Cargo.toml +++ b/src/hal/Cargo.toml @@ -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"