mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
Make tests properly request their own limits
This commit is contained in:
committed by
Dzmitry Malyshau
parent
80da80b497
commit
e9b13b74c4
@@ -340,7 +340,8 @@ fn boids() {
|
||||
height: 768,
|
||||
optional_features: wgpu::Features::default(),
|
||||
base_test_parameters: framework::test_common::TestParameters::default()
|
||||
.downlevel_flags(wgpu::DownlevelFlags::COMPUTE_SHADERS),
|
||||
.downlevel_flags(wgpu::DownlevelFlags::COMPUTE_SHADERS)
|
||||
.limits(wgpu::Limits::downlevel_defaults()),
|
||||
tolerance: 0,
|
||||
max_outliers: 2500, // Currently bounded by WARP
|
||||
});
|
||||
|
||||
@@ -11,6 +11,7 @@ fn test_compute_1() {
|
||||
initialize_test(
|
||||
TestParameters::default()
|
||||
.downlevel_flags(wgpu::DownlevelFlags::COMPUTE_SHADERS)
|
||||
.limits(wgpu::Limits::downlevel_defaults())
|
||||
.specific_failure(None, None, Some("V3D"), true),
|
||||
|ctx| {
|
||||
let input = &[1, 2, 3, 4];
|
||||
@@ -30,6 +31,7 @@ fn test_compute_2() {
|
||||
initialize_test(
|
||||
TestParameters::default()
|
||||
.downlevel_flags(wgpu::DownlevelFlags::COMPUTE_SHADERS)
|
||||
.limits(wgpu::Limits::downlevel_defaults())
|
||||
.specific_failure(None, None, Some("V3D"), true),
|
||||
|ctx| {
|
||||
let input = &[5, 23, 10, 9];
|
||||
@@ -49,6 +51,7 @@ fn test_compute_overflow() {
|
||||
initialize_test(
|
||||
TestParameters::default()
|
||||
.downlevel_flags(wgpu::DownlevelFlags::COMPUTE_SHADERS)
|
||||
.limits(wgpu::Limits::downlevel_defaults())
|
||||
.specific_failure(None, None, Some("V3D"), true),
|
||||
|ctx| {
|
||||
let input = &[77031, 837799, 8400511, 63728127];
|
||||
@@ -67,6 +70,7 @@ fn test_multithreaded_compute() {
|
||||
initialize_test(
|
||||
TestParameters::default()
|
||||
.downlevel_flags(wgpu::DownlevelFlags::COMPUTE_SHADERS)
|
||||
.limits(wgpu::Limits::downlevel_defaults())
|
||||
.specific_failure(None, None, Some("V3D"), true),
|
||||
|ctx| {
|
||||
use std::{sync::mpsc, thread, time::Duration};
|
||||
|
||||
@@ -60,6 +60,7 @@ pub struct FailureCase {
|
||||
pub struct TestParameters {
|
||||
pub required_features: Features,
|
||||
pub required_downlevel_properties: DownlevelCapabilities,
|
||||
pub required_limits: Limits,
|
||||
// Backends where test should fail.
|
||||
pub failures: Vec<FailureCase>,
|
||||
}
|
||||
@@ -69,6 +70,7 @@ impl Default for TestParameters {
|
||||
Self {
|
||||
required_features: Features::empty(),
|
||||
required_downlevel_properties: lowest_downlevel_properties(),
|
||||
required_limits: Limits::downlevel_webgl2_defaults(),
|
||||
failures: Vec::new(),
|
||||
}
|
||||
}
|
||||
@@ -85,9 +87,10 @@ bitflags::bitflags! {
|
||||
|
||||
// Builder pattern to make it easier
|
||||
impl TestParameters {
|
||||
/// Set of common features that most tests require.
|
||||
pub fn test_features(self) -> Self {
|
||||
/// Set of common features that most internal tests require for readback.
|
||||
pub fn test_features_limits(self) -> Self {
|
||||
self.features(Features::MAPPABLE_PRIMARY_BUFFERS | Features::VERTEX_WRITABLE_STORAGE)
|
||||
.limits(wgpu::Limits::downlevel_defaults())
|
||||
}
|
||||
|
||||
/// Set the list of features this test requires.
|
||||
@@ -101,6 +104,12 @@ impl TestParameters {
|
||||
self
|
||||
}
|
||||
|
||||
/// Set the limits needed for the test.
|
||||
pub fn limits(mut self, limits: Limits) -> Self {
|
||||
self.required_limits = limits;
|
||||
self
|
||||
}
|
||||
|
||||
/// Mark the test as always failing, equivilant to specific_failure(None, None, None)
|
||||
pub fn failure(mut self) -> Self {
|
||||
self.failures.push(FailureCase {
|
||||
@@ -159,7 +168,6 @@ pub fn initialize_test(parameters: TestParameters, test_function: impl FnOnce(Te
|
||||
))
|
||||
.expect("could not find sutable adapter on the system");
|
||||
|
||||
let required_limits = Limits::downlevel_webgl2_defaults();
|
||||
let adapter_info = adapter.get_info();
|
||||
let adapter_lowercase_name = adapter_info.name.to_lowercase();
|
||||
let adapter_features = adapter.features();
|
||||
@@ -172,7 +180,7 @@ pub fn initialize_test(parameters: TestParameters, test_function: impl FnOnce(Te
|
||||
return;
|
||||
}
|
||||
|
||||
if adapter_limits < required_limits {
|
||||
if !parameters.required_limits.check_limits(&adapter_limits) {
|
||||
println!("TEST SKIPPED: LIMIT TOO LOW");
|
||||
return;
|
||||
}
|
||||
@@ -200,7 +208,7 @@ pub fn initialize_test(parameters: TestParameters, test_function: impl FnOnce(Te
|
||||
let (device, queue) = pollster::block_on(initialize_device(
|
||||
&adapter,
|
||||
parameters.required_features,
|
||||
required_limits.clone(),
|
||||
parameters.required_limits.clone(),
|
||||
));
|
||||
|
||||
let context = TestingContext {
|
||||
@@ -209,7 +217,7 @@ pub fn initialize_test(parameters: TestParameters, test_function: impl FnOnce(Te
|
||||
adapter_downlevel_capabilities,
|
||||
device,
|
||||
device_features: parameters.required_features,
|
||||
device_limits: required_limits,
|
||||
device_limits: parameters.required_limits,
|
||||
queue,
|
||||
};
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@ fn pulling_common(
|
||||
|
||||
#[test]
|
||||
fn draw() {
|
||||
initialize_test(TestParameters::default().test_features(), |ctx| {
|
||||
initialize_test(TestParameters::default().test_features_limits(), |ctx| {
|
||||
pulling_common(ctx, &[0, 1, 2, 3, 4, 5], |cmb| {
|
||||
cmb.draw(0..6, 0..1);
|
||||
})
|
||||
@@ -143,7 +143,7 @@ fn draw() {
|
||||
fn draw_vertex_offset() {
|
||||
initialize_test(
|
||||
TestParameters::default()
|
||||
.test_features()
|
||||
.test_features_limits()
|
||||
.backend_failure(wgpu::Backends::DX11),
|
||||
|ctx| {
|
||||
pulling_common(ctx, &[0, 1, 2, 3, 4, 5], |cmb| {
|
||||
@@ -156,7 +156,7 @@ fn draw_vertex_offset() {
|
||||
|
||||
#[test]
|
||||
fn draw_instanced() {
|
||||
initialize_test(TestParameters::default().test_features(), |ctx| {
|
||||
initialize_test(TestParameters::default().test_features_limits(), |ctx| {
|
||||
pulling_common(ctx, &[0, 1, 2, 3, 4, 5], |cmb| {
|
||||
cmb.draw(0..3, 0..2);
|
||||
})
|
||||
@@ -167,7 +167,7 @@ fn draw_instanced() {
|
||||
fn draw_instanced_offset() {
|
||||
initialize_test(
|
||||
TestParameters::default()
|
||||
.test_features()
|
||||
.test_features_limits()
|
||||
.backend_failure(wgpu::Backends::DX11),
|
||||
|ctx| {
|
||||
pulling_common(ctx, &[0, 1, 2, 3, 4, 5], |cmb| {
|
||||
|
||||
Reference in New Issue
Block a user