814: Update to latest wgpu, naga, gfx. r=kvark a=Gordon-F

Update to latest wgpu, naga, gfx and enable `EXPERIMENTAL_TRANSLATION` with GL backend for `boids`, `cube` and `hello-compute`.

Co-authored-by: Gordon-F <ishaposhnik@icloud.com>
This commit is contained in:
bors[bot]
2021-03-25 23:54:46 +00:00
committed by GitHub
11 changed files with 22 additions and 19 deletions

View File

@@ -28,20 +28,20 @@ cross = ["wgc/cross"]
[target.'cfg(not(target_arch = "wasm32"))'.dependencies.wgc]
package = "wgpu-core"
git = "https://github.com/gfx-rs/wgpu"
rev = "9c98ebc48cc53ec696e073da510bef9a819b1916"
rev = "b7ba481a9170e5b9c6364b2eb16080e527462039"
features = ["raw-window-handle"]
[target.'cfg(target_arch = "wasm32")'.dependencies.wgc]
package = "wgpu-core"
git = "https://github.com/gfx-rs/wgpu"
rev = "9c98ebc48cc53ec696e073da510bef9a819b1916"
rev = "b7ba481a9170e5b9c6364b2eb16080e527462039"
features = ["raw-window-handle"]
optional = true
[dependencies.wgt]
package = "wgpu-types"
git = "https://github.com/gfx-rs/wgpu"
rev = "9c98ebc48cc53ec696e073da510bef9a819b1916"
rev = "b7ba481a9170e5b9c6364b2eb16080e527462039"
[dependencies]
arrayvec = "0.5"
@@ -70,13 +70,13 @@ env_logger = "0.8"
# used to test all the example shaders
[dev-dependencies.naga]
git = "https://github.com/gfx-rs/naga"
tag = "gfx-17"
tag = "gfx-18"
features = ["wgsl-in"]
# used to generate SPIR-V for the Web target
[target.'cfg(target_arch = "wasm32")'.dependencies.naga]
git = "https://github.com/gfx-rs/naga"
tag = "gfx-17"
tag = "gfx-18"
features = ["wgsl-in", "spv-out"]
[[example]]

View File

@@ -37,7 +37,7 @@ impl framework::Example for Example {
// load and compile the shader
let mut flags = wgpu::ShaderFlags::VALIDATION;
match adapter.get_info().backend {
wgt::Backend::Vulkan | wgt::Backend::Metal => {
wgt::Backend::Vulkan | wgt::Backend::Metal | wgt::Backend::Gl => {
flags |= wgpu::ShaderFlags::EXPERIMENTAL_TRANSLATION;
}
_ => {} //TODO

View File

@@ -250,7 +250,7 @@ impl framework::Example for Example {
let mut flags = wgpu::ShaderFlags::VALIDATION;
match adapter.get_info().backend {
wgpu::Backend::Metal | wgpu::Backend::Vulkan => {
wgpu::Backend::Metal | wgpu::Backend::Vulkan | wgpu::Backend::Gl => {
flags |= wgpu::ShaderFlags::EXPERIMENTAL_TRANSLATION
}
_ => (), //TODO

View File

@@ -58,7 +58,7 @@ async fn execute_gpu(numbers: Vec<u32>) -> Vec<u32> {
// Loads the shader from the SPIR-V file.arrayvec
let mut flags = wgpu::ShaderFlags::VALIDATION;
match adapter.get_info().backend {
wgpu::Backend::Vulkan | wgpu::Backend::Metal => {
wgpu::Backend::Vulkan | wgpu::Backend::Metal | wgpu::Backend::Gl => {
flags |= wgpu::ShaderFlags::EXPERIMENTAL_TRANSLATION;
}
_ => {}

View File

@@ -127,7 +127,7 @@ impl Example {
dimension: None,
aspect: wgpu::TextureAspect::All,
base_mip_level: mip,
level_count: NonZeroU32::new(1),
mip_level_count: NonZeroU32::new(1),
base_array_layer: 0,
array_layer_count: None,
})

View File

@@ -369,7 +369,7 @@ impl framework::Example for Example {
dimension: Some(wgpu::TextureViewDimension::D2),
aspect: wgpu::TextureAspect::All,
base_mip_level: 0,
level_count: None,
mip_level_count: None,
base_array_layer: i as u32,
array_layer_count: NonZeroU32::new(1),
}))

View File

@@ -1369,7 +1369,7 @@ impl crate::Context for Context {
dimension: desc.dimension,
aspect: desc.aspect,
base_mip_level: desc.base_mip_level,
level_count: desc.level_count,
mip_level_count: desc.mip_level_count,
base_array_layer: desc.base_array_layer,
array_layer_count: desc.array_layer_count,
};

View File

@@ -22,8 +22,7 @@ impl Error for ContextError {
impl super::Context {
pub(super) fn format_error(&self, err: &(impl Error + 'static)) -> String {
let mut err_descs = Vec::new();
err_descs.push(self.format_pretty_any(err));
let mut err_descs = vec![self.format_pretty_any(err)];
let mut source_opt = err.source();
while let Some(source) = source_opt {

View File

@@ -1131,7 +1131,7 @@ impl crate::Context for Context {
web_sys::GpuShaderModuleDescriptor::new(&js_sys::Uint32Array::from(&**spv))
}
crate::ShaderSource::Wgsl(ref code) => {
use naga::{back::spv, front::wgsl, proc::Validator};
use naga::{back::spv, front::wgsl, valid::Validator};
let module = wgsl::parse_str(code).unwrap();
let mut capabilities = HashSet::default();
capabilities.insert(spv::Capability::Shader);
@@ -1140,7 +1140,9 @@ impl crate::Context for Context {
flags: spv::WriterFlags::empty(),
capabilities,
};
let analysis = Validator::new().validate(&module).unwrap();
let analysis = Validator::new(naga::valid::ValidationFlags::all())
.validate(&module)
.unwrap();
let words = spv::write_vec(&module, &analysis, &options).unwrap();
web_sys::GpuShaderModuleDescriptor::new(&js_sys::Uint32Array::from(&words[..]))
}
@@ -1609,7 +1611,7 @@ impl crate::Context for Context {
mapped.array_layer_count(count.get());
}
mapped.base_mip_level(desc.base_mip_level);
if let Some(count) = desc.level_count {
if let Some(count) = desc.mip_level_count {
mapped.mip_level_count(count.get());
}
if let Some(label) = desc.label {

View File

@@ -1068,7 +1068,7 @@ pub struct TextureViewDescriptor<'a> {
/// Mip level count.
/// If `Some(count)`, `base_mip_level + count` must be less or equal to underlying texture mip count.
/// If `None`, considered to include the rest of the mipmap levels, but at least 1 in total.
pub level_count: Option<NonZeroU32>,
pub mip_level_count: Option<NonZeroU32>,
/// Base array layer.
pub base_array_layer: u32,
/// Layer count.

View File

@@ -1,4 +1,4 @@
use naga::{front::wgsl, proc::Validator};
use naga::{front::wgsl, valid::Validator};
use std::{fs, path::PathBuf};
#[test]
@@ -41,7 +41,9 @@ fn parse_example_wgsl() {
let module = wgsl::parse_str(&shader).unwrap();
//TODO: re-use the validator
Validator::new().validate(&module).unwrap();
Validator::new(naga::valid::ValidationFlags::all())
.validate(&module)
.unwrap();
}
}
}