Please clippy

This commit is contained in:
Connor Fitzgerald
2021-07-03 22:08:05 -04:00
parent 861e84b178
commit e2bcb72bf4
3 changed files with 76 additions and 57 deletions

View File

@@ -49,14 +49,14 @@ fn create_indices() -> Vec<u16> {
#[derive(Copy, Clone)]
enum Color {
RED,
GREEN,
Red,
Green,
}
fn create_texture_data(color: Color) -> [u8; 4] {
match color {
Color::RED => [255, 0, 0, 255],
Color::GREEN => [0, 255, 0, 255],
Color::Red => [255, 0, 0, 255],
Color::Green => [0, 255, 0, 255],
}
}
@@ -122,8 +122,8 @@ impl framework::Example for Example {
usage: wgpu::BufferUsages::INDEX,
});
let red_texture_data = create_texture_data(Color::RED);
let green_texture_data = create_texture_data(Color::GREEN);
let red_texture_data = create_texture_data(Color::Red);
let green_texture_data = create_texture_data(Color::Green);
let texture_descriptor = wgpu::TextureDescriptor {
size: wgpu::Extent3d::default(),
@@ -253,11 +253,11 @@ impl framework::Example for Example {
});
Self {
pipeline,
bind_group,
vertex_buffer,
index_buffer,
index_format,
bind_group,
pipeline,
uniform_workaround,
}
}
@@ -340,8 +340,7 @@ fn texture_arrays_uniform() {
image_path: "/examples/texture-arrays/screenshot.png",
width: 1024,
height: 768,
optional_features: wgpu::Features::SAMPLED_TEXTURE_ARRAY_DYNAMIC_INDEXING
| wgpu::Features::PUSH_CONSTANTS,
optional_features: wgpu::Features::TEXTURE_BINDING_ARRAY | wgpu::Features::PUSH_CONSTANTS,
base_test_parameters: framework::test_common::TestParameters::default().failure(),
tolerance: 0,
max_outliers: 0,
@@ -355,7 +354,8 @@ fn texture_arrays_non_uniform() {
image_path: "/examples/texture-arrays/screenshot.png",
width: 1024,
height: 768,
optional_features: wgpu::Features::SAMPLED_TEXTURE_ARRAY_NON_UNIFORM_INDEXING,
optional_features: wgpu::Features::TEXTURE_BINDING_ARRAY
| wgpu::Features::RESOURCE_BINDING_ARRAY_NON_UNIFORM_INDEXING,
base_test_parameters: framework::test_common::TestParameters::default().failure(),
tolerance: 0,
max_outliers: 0,
@@ -369,7 +369,8 @@ fn texture_arrays_unsized_non_uniform() {
image_path: "/examples/texture-arrays/screenshot.png",
width: 1024,
height: 768,
optional_features: wgpu::Features::SAMPLED_TEXTURE_ARRAY_NON_UNIFORM_INDEXING
optional_features: wgpu::Features::TEXTURE_BINDING_ARRAY
| wgpu::Features::RESOURCE_BINDING_ARRAY_NON_UNIFORM_INDEXING
| wgpu::Features::UNSIZED_BINDING_ARRAY,
base_test_parameters: framework::test_common::TestParameters::default().failure(),
tolerance: 0,

View File

@@ -1,3 +1,5 @@
#![allow(clippy::type_complexity)]
use std::{
fmt,
future::Future,
@@ -1262,8 +1264,8 @@ impl crate::Context for Context {
unsafe fn device_create_shader_module_spirv(
&self,
device: &Self::DeviceId,
desc: &crate::ShaderModuleDescriptorSpirV,
_device: &Self::DeviceId,
_desc: &crate::ShaderModuleDescriptorSpirV,
) -> Self::ShaderModuleId {
unreachable!("SPIRV_SHADER_PASSTHROUGH is not enabled for this backend")
}
@@ -1289,7 +1291,7 @@ impl crate::Context for Context {
if let Some(s) = size {
mapped_buffer_binding.size(s.get() as f64);
}
JsValue::from(mapped_buffer_binding.clone())
JsValue::from(mapped_buffer_binding)
}
crate::BindingResource::BufferArray(..) => {
panic!("Web backend does not support arrays of buffers")
@@ -1498,7 +1500,6 @@ impl crate::Context for Context {
_device: &Self::DeviceId,
_desc: &wgt::QuerySetDescriptor<crate::Label>,
) -> Self::QuerySetId {
()
}
fn device_create_command_encoder(

View File

@@ -71,13 +71,20 @@ fn lowest_downlevel_properties() -> DownlevelCapabilities {
}
}
pub struct FailureCase {
backends: Option<wgpu::Backends>,
vendor: Option<usize>,
adapter: Option<String>,
segfault: bool,
}
// This information determines if a test should run.
pub struct TestParameters {
pub required_features: Features,
pub required_limits: Limits,
pub required_downlevel_properties: DownlevelCapabilities,
// Backends where test should fail.
pub failures: Vec<(Option<wgpu::Backends>, Option<usize>, Option<String>, bool)>,
pub failures: Vec<FailureCase>,
}
impl Default for TestParameters {
@@ -126,13 +133,23 @@ impl TestParameters {
/// Mark the test as always failing, equivilant to specific_failure(None, None, None)
pub fn failure(mut self) -> Self {
self.failures.push((None, None, None, false));
self.failures.push(FailureCase {
backends: None,
vendor: None,
adapter: None,
segfault: false,
});
self
}
/// Mark the test as always failing on a specific backend, equivilant to specific_failure(backend, None, None)
pub fn backend_failure(mut self, backends: wgpu::Backends) -> Self {
self.failures.push((Some(backends), None, None, false));
self.failures.push(FailureCase {
backends: Some(backends),
vendor: None,
adapter: None,
segfault: false,
});
self
}
@@ -150,12 +167,12 @@ impl TestParameters {
device: Option<&'static str>,
segfault: bool,
) -> Self {
self.failures.push((
self.failures.push(FailureCase {
backends,
vendor,
device.as_ref().map(AsRef::as_ref).map(str::to_lowercase),
adapter: device.as_ref().map(AsRef::as_ref).map(str::to_lowercase),
segfault,
));
});
self
}
}
@@ -222,45 +239,45 @@ pub fn initialize_test(parameters: TestParameters, test_function: impl FnOnce(Te
queue,
};
let failure_reason = parameters.failures.iter().find_map(
|(backend_failure, vendor_failure, adapter_failure, segfault)| {
let always =
backend_failure.is_none() && vendor_failure.is_none() && adapter_failure.is_none();
let failure_reason = parameters.failures.iter().find_map(|failure| {
let always =
failure.backends.is_none() && failure.vendor.is_none() && failure.adapter.is_none();
let expect_failure_backend =
backend_failure.map(|f| f.contains(wgpu::Backends::from(adapter_info.backend)));
let expect_failure_vendor = vendor_failure.map(|v| v == adapter_info.vendor);
let expect_failure_adapter = adapter_failure
.as_deref()
.map(|f| adapter_lowercase_name.contains(f));
let expect_failure_backend = failure
.backends
.map(|f| f.contains(wgpu::Backends::from(adapter_info.backend)));
let expect_failure_vendor = failure.vendor.map(|v| v == adapter_info.vendor);
let expect_failure_adapter = failure
.adapter
.as_deref()
.map(|f| adapter_lowercase_name.contains(f));
if expect_failure_backend.unwrap_or(true)
&& expect_failure_vendor.unwrap_or(true)
&& expect_failure_adapter.unwrap_or(true)
{
if always {
Some((FailureReasons::ALWAYS, *segfault))
} else {
let mut reason = FailureReasons::empty();
reason.set(
FailureReasons::BACKEND,
expect_failure_backend.unwrap_or(false),
);
reason.set(
FailureReasons::VENDOR,
expect_failure_vendor.unwrap_or(false),
);
reason.set(
FailureReasons::ADAPTER,
expect_failure_adapter.unwrap_or(false),
);
Some((reason, *segfault))
}
if expect_failure_backend.unwrap_or(true)
&& expect_failure_vendor.unwrap_or(true)
&& expect_failure_adapter.unwrap_or(true)
{
if always {
Some((FailureReasons::ALWAYS, failure.segfault))
} else {
None
let mut reason = FailureReasons::empty();
reason.set(
FailureReasons::BACKEND,
expect_failure_backend.unwrap_or(false),
);
reason.set(
FailureReasons::VENDOR,
expect_failure_vendor.unwrap_or(false),
);
reason.set(
FailureReasons::ADAPTER,
expect_failure_adapter.unwrap_or(false),
);
Some((reason, failure.segfault))
}
},
);
} else {
None
}
});
if let Some((reason, true)) = failure_reason {
println!(