Skip to content

Commit

Permalink
Merge #3695
Browse files Browse the repository at this point in the history
3695: Update naga to gfx-18 r=kvark a=Gordon-F

When trying to update my dev environment to the latest `naga`, I saw that api changes a little bit. This PR update to latest available naga (a0b5717fed0bd1c8536fb2204f308d6db39d295f)

Hope this will be helpful 😄 

PR checklist:
- [ ] `make` succeeds (on *nix)
- [ ] `make reftests` succeeds
- [x] tested examples with the following backends: OpenGL


Co-authored-by: Gordon-F <[email protected]>
  • Loading branch information
bors[bot] and Gordon-F committed Mar 25, 2021
2 parents 52f77a6 + 689c296 commit 2ac006f
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 28 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-17"
tag = "gfx-18"
features = ["spv-in", "glsl-out"]

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

fn reflect_shader(
module: &naga::Module,
ep_info: &naga::proc::analyzer::FunctionInfo,
ep_info: &naga::valid::FunctionInfo,
reflection_info: naga::back::glsl::ReflectionInfo,
context: CompilationContext,
) {
Expand Down Expand Up @@ -605,11 +605,11 @@ impl Device {
) -> Result<n::Shader, d::ShaderError> {
let mut output = Vec::new();
let mut writer =
naga::back::glsl::Writer::new(&mut output, &shader.module, &shader.analysis, options)
naga::back::glsl::Writer::new(&mut output, &shader.module, &shader.info, options)
.map_err(|e| {
log::warn!("Naga GLSL init: {}", e);
d::ShaderError::CompilationFailed(format!("{:?}", e))
})?;
log::warn!("Naga GLSL init: {}", e);
d::ShaderError::CompilationFailed(format!("{:?}", e))
})?;

let entry_point_index = (&shader.module.entry_points)
.into_iter()
Expand All @@ -623,7 +623,7 @@ impl Device {
Ok(reflection_info) => {
Self::reflect_shader(
&shader.module,
shader.analysis.get_entry_point(entry_point_index),
shader.info.get_entry_point(entry_point_index),
reflection_info,
context,
);
Expand Down Expand Up @@ -1207,8 +1207,10 @@ impl d::Device<B> for Device {
match parser.parse() {
Ok(module) => {
log::debug!("Naga module {:#?}", module);
match naga::proc::Validator::new().validate(&module) {
Ok(analysis) => Some(d::NagaShader { module, analysis }),
match naga::valid::Validator::new(naga::valid::ValidationFlags::empty())
.validate(&module)
{
Ok(info) => Some(d::NagaShader { module, info }),
Err(e) => {
log::warn!("Naga validation failed: {:?}", e);
None
Expand All @@ -1231,11 +1233,7 @@ impl d::Device<B> for Device {
Ok(n::ShaderModule {
prefer_naga: true,
#[cfg(feature = "cross")]
spv: match naga::back::spv::write_vec(
&shader.module,
&shader.analysis,
&self.spv_options,
) {
spv: match naga::back::spv::write_vec(&shader.module, &shader.info, &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-17"
tag = "gfx-18"
features = ["spv-in", "msl-out"]

# This forces docs.rs to build the crate on mac, otherwise the build fails
Expand Down
14 changes: 6 additions & 8 deletions src/backend/metal/src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ impl Device {
naga_options: &naga::back::msl::Options,
) -> Result<n::ModuleInfo, String> {
let (source, info) =
match naga::back::msl::write_string(&shader.module, &shader.analysis, naga_options) {
match naga::back::msl::write_string(&shader.module, &shader.info, naga_options) {
Ok(pair) => pair,
Err(e) => {
warn!("Naga: {:?}", e);
Expand Down Expand Up @@ -1876,8 +1876,10 @@ impl hal::device::Device<Backend> for Device {
match parser.parse() {
Ok(module) => {
debug!("Naga module {:#?}", module);
match naga::proc::Validator::new().validate(&module) {
Ok(analysis) => Ok(d::NagaShader { module, analysis }),
match naga::valid::Validator::new(naga::valid::ValidationFlags::empty())
.validate(&module)
{
Ok(info) => Ok(d::NagaShader { module, info }),
Err(e) => Err(format!("Naga validation: {:?}", e)),
}
}
Expand All @@ -1894,11 +1896,7 @@ 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,
&shader.analysis,
&self.spv_options,
) {
spv: match naga::back::spv::write_vec(&shader.module, &shader.info, &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-17"
tag = "gfx-18"
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 @@ -963,7 +963,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, &shader.analysis, &self.naga_options) {
match naga::back::spv::write_vec(&shader.module, &shader.info, &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-17" }
naga = { git = "https://github.com/gfx-rs/naga", tag = "gfx-18" }
raw-window-handle = "0.3"
serde = { version = "1", features = ["serde_derive"], optional = true }
thiserror = "1"
Expand Down
4 changes: 2 additions & 2 deletions src/hal/src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ pub enum ShaderModuleDesc<'a> {
pub struct NagaShader {
/// Shader module IR.
pub module: naga::Module,
/// Analysis of the module.
pub analysis: naga::proc::analyzer::Analysis,
/// Analysis information of the module.
pub info: naga::valid::ModuleInfo,
}

/// Logical device handle, responsible for creating and managing resources
Expand Down

0 comments on commit 2ac006f

Please sign in to comment.