From 0391fc37d4ad10d32f26067024510fc7a1f08823 Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Mon, 5 Oct 2020 14:40:34 -0400 Subject: [PATCH 1/5] Only request features that are needed --- wgpu-core/src/instance.rs | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/wgpu-core/src/instance.rs b/wgpu-core/src/instance.rs index da7b9779b..ed879f108 100644 --- a/wgpu-core/src/instance.rs +++ b/wgpu-core/src/instance.rs @@ -657,7 +657,7 @@ impl Global { let mut enabled_features = available_features & wishful_features; if enabled_features != wishful_features { tracing::warn!( - "Missing features: {:?}", + "Missing internal features: {:?}", wishful_features - enabled_features ); } @@ -665,44 +665,35 @@ impl Global { // Features enabled_features.set( hal::Features::TEXTURE_DESCRIPTOR_ARRAY, - adapter - .features + desc.features .contains(wgt::Features::SAMPLED_TEXTURE_BINDING_ARRAY), ); enabled_features.set( hal::Features::SHADER_SAMPLED_IMAGE_ARRAY_DYNAMIC_INDEXING, - adapter - .features + desc.features .contains(wgt::Features::SAMPLED_TEXTURE_ARRAY_DYNAMIC_INDEXING), ); enabled_features.set( hal::Features::SHADER_SAMPLED_IMAGE_ARRAY_DYNAMIC_INDEXING, - adapter - .features + desc.features .contains(wgt::Features::SAMPLED_TEXTURE_ARRAY_DYNAMIC_INDEXING), ); enabled_features.set( hal::Features::SAMPLED_TEXTURE_DESCRIPTOR_INDEXING, - adapter - .features + desc.features .contains(wgt::Features::SAMPLED_TEXTURE_ARRAY_NON_UNIFORM_INDEXING), ); enabled_features.set( hal::Features::UNSIZED_DESCRIPTOR_ARRAY, - adapter - .features - .contains(wgt::Features::UNSIZED_BINDING_ARRAY), + desc.features.contains(wgt::Features::UNSIZED_BINDING_ARRAY), ); enabled_features.set( hal::Features::MULTI_DRAW_INDIRECT, - adapter - .features - .contains(wgt::Features::MULTI_DRAW_INDIRECT), + desc.features.contains(wgt::Features::MULTI_DRAW_INDIRECT), ); enabled_features.set( hal::Features::DRAW_INDIRECT_COUNT, - adapter - .features + desc.features .contains(wgt::Features::MULTI_DRAW_INDIRECT_COUNT), ); From 776f3b6d81ed8015ba79a750c5cfeb1b74379155 Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Mon, 5 Oct 2020 14:42:17 -0400 Subject: [PATCH 2/5] Enable RBA if available --- wgpu-core/src/device/queue.rs | 2 +- wgpu-core/src/instance.rs | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/wgpu-core/src/device/queue.rs b/wgpu-core/src/device/queue.rs index 20fd27c58..f5ae7f2f2 100644 --- a/wgpu-core/src/device/queue.rs +++ b/wgpu-core/src/device/queue.rs @@ -289,7 +289,7 @@ impl Global { None => {} } - if size.width == 0 || size.height == 0 || size.width == 0 { + if size.width == 0 || size.height == 0 || size.depth == 0 { tracing::trace!("Ignoring write_texture of size 0"); return Ok(()); } diff --git a/wgpu-core/src/instance.rs b/wgpu-core/src/instance.rs index ed879f108..700b9c930 100644 --- a/wgpu-core/src/instance.rs +++ b/wgpu-core/src/instance.rs @@ -648,7 +648,8 @@ impl Global { let available_features = adapter.raw.physical_device.features(); // Check features that are always needed - let wishful_features = hal::Features::VERTEX_STORES_AND_ATOMICS + let wishful_features = hal::Features::ROBUST_BUFFER_ACCESS + | hal::Features::VERTEX_STORES_AND_ATOMICS | hal::Features::FRAGMENT_STORES_AND_ATOMICS | hal::Features::NDC_Y_UP | hal::Features::INDEPENDENT_BLENDING @@ -673,11 +674,6 @@ impl Global { desc.features .contains(wgt::Features::SAMPLED_TEXTURE_ARRAY_DYNAMIC_INDEXING), ); - enabled_features.set( - hal::Features::SHADER_SAMPLED_IMAGE_ARRAY_DYNAMIC_INDEXING, - desc.features - .contains(wgt::Features::SAMPLED_TEXTURE_ARRAY_DYNAMIC_INDEXING), - ); enabled_features.set( hal::Features::SAMPLED_TEXTURE_DESCRIPTOR_INDEXING, desc.features From 5b073e8dbe92c8362c8a78d6754f75cd45fdddaa Mon Sep 17 00:00:00 2001 From: Kunal Mohan Date: Wed, 23 Sep 2020 00:30:50 +0530 Subject: [PATCH 3/5] Prevent an invalid texture from being registered in device_create_texture --- wgpu-core/src/device/mod.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/wgpu-core/src/device/mod.rs b/wgpu-core/src/device/mod.rs index 173551dcf..b81a742a2 100644 --- a/wgpu-core/src/device/mod.rs +++ b/wgpu-core/src/device/mod.rs @@ -1226,6 +1226,16 @@ impl Global { let device = device_guard .get(device_id) .map_err(|_| DeviceError::Invalid)?; + + let texture_features = conv::texture_features(desc.format); + if texture_features != wgt::Features::empty() && !device.features.contains(texture_features) + { + return Err(resource::CreateTextureError::MissingFeature( + texture_features, + desc.format, + )); + } + let texture = device.create_texture(device_id, desc)?; let num_levels = texture.full_range.levels.end; let num_layers = texture.full_range.layers.end; @@ -1240,15 +1250,6 @@ impl Global { None => (), }; - let texture_features = conv::texture_features(desc.format); - if texture_features != wgt::Features::empty() && !device.features.contains(texture_features) - { - return Err(resource::CreateTextureError::MissingFeature( - texture_features, - desc.format, - )); - } - device .trackers .lock() From 9d34b75442750b89d4a922bbfe253d8e181a72df Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Mon, 5 Oct 2020 14:46:52 -0400 Subject: [PATCH 4/5] Bump version to 0.6.4 --- CHANGELOG.md | 5 +++++ Cargo.lock | 2 +- wgpu-core/Cargo.toml | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6fef82531..9e4cc7947 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Change Log +## wgpu-core-0.6.4 (2020-10-05) + - don't request device features that aren't needed + - fix texture depth == 0 checks + - fix the order of texture feature checks + ## wgpu-core-0.6.3 (2020-09-04) - fix group bindings that aren't related to the current pipeline diff --git a/Cargo.lock b/Cargo.lock index 8276797b4..0d59743fa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1619,7 +1619,7 @@ dependencies = [ [[package]] name = "wgpu-core" -version = "0.6.3" +version = "0.6.4" dependencies = [ "arrayvec", "bitflags", diff --git a/wgpu-core/Cargo.toml b/wgpu-core/Cargo.toml index 9592b6ad4..1ed57474a 100644 --- a/wgpu-core/Cargo.toml +++ b/wgpu-core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wgpu-core" -version = "0.6.3" +version = "0.6.4" authors = ["wgpu developers"] edition = "2018" description = "WebGPU core logic on gfx-hal" From 416f49c1a7dc4ddc313798e513aafb4852f0871f Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Mon, 5 Oct 2020 14:59:58 -0400 Subject: [PATCH 5/5] Generator dependency update --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0d59743fa..def87599f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -389,9 +389,9 @@ dependencies = [ [[package]] name = "generator" -version = "0.6.21" +version = "0.6.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "add72f17bb81521258fcc8a7a3245b1e184e916bfbe34f0ea89558f440df5c68" +checksum = "f5e13c8f4607ff74f6d0fa37007cb95492531333f46bb9744f772d9e7830855c" dependencies = [ "cc", "libc",