Skip to content

Commit

Permalink
Formatting woes
Browse files Browse the repository at this point in the history
  • Loading branch information
cwfitzgerald committed Jul 2, 2021
1 parent a336c9e commit 2bdc54a
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 52 deletions.
129 changes: 78 additions & 51 deletions wgpu/examples/hello-compute/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,75 +8,102 @@ use common::{initialize_test, TestParameters};

#[test]
fn test_compute_1() {
initialize_test(TestParameters::default().specific_failure(Some(wgpu::Backends::GL), None, Some("V3D"), false), |ctx| {
let input = &[1, 2, 3, 4];
initialize_test(
TestParameters::default().specific_failure(
Some(wgpu::Backends::GL),
None,
Some("V3D"),
false,
),
|ctx| {
let input = &[1, 2, 3, 4];

pollster::block_on(assert_execute_gpu(
&ctx.device,
&ctx.queue,
input,
&[0, 1, 7, 2],
));
});
pollster::block_on(assert_execute_gpu(
&ctx.device,
&ctx.queue,
input,
&[0, 1, 7, 2],
));
},
);
}

#[test]
fn test_compute_2() {
initialize_test(TestParameters::default().specific_failure(Some(wgpu::Backends::GL), None, Some("V3D"), false), |ctx| {
let input = &[5, 23, 10, 9];
initialize_test(
TestParameters::default().specific_failure(
Some(wgpu::Backends::GL),
None,
Some("V3D"),
false,
),
|ctx| {
let input = &[5, 23, 10, 9];

pollster::block_on(assert_execute_gpu(
&ctx.device,
&ctx.queue,
input,
&[5, 15, 6, 19],
));
});
pollster::block_on(assert_execute_gpu(
&ctx.device,
&ctx.queue,
input,
&[5, 15, 6, 19],
));
},
);
}

#[test]
fn test_compute_overflow() {
initialize_test(TestParameters::default().specific_failure(Some(wgpu::Backends::GL), None, Some("V3D"), false), |ctx| {
let input = &[77031, 837799, 8400511, 63728127];
pollster::block_on(assert_execute_gpu(
&ctx.device,
&ctx.queue,
input,
&[350, 524, OVERFLOW, OVERFLOW],
));
});
initialize_test(
TestParameters::default().specific_failure(
Some(wgpu::Backends::GL),
None,
Some("V3D"),
false,
),
|ctx| {
let input = &[77031, 837799, 8400511, 63728127];
pollster::block_on(assert_execute_gpu(
&ctx.device,
&ctx.queue,
input,
&[350, 524, OVERFLOW, OVERFLOW],
));
},
);
}

#[test]
fn test_multithreaded_compute() {
initialize_test(TestParameters::default().backend_failures(wgpu::Backends::GL), |ctx| {
use std::{sync::mpsc, thread, time::Duration};
initialize_test(
TestParameters::default().backend_failures(wgpu::Backends::GL),
|ctx| {
use std::{sync::mpsc, thread, time::Duration};

let ctx = Arc::new(ctx);
let ctx = Arc::new(ctx);

let thread_count = 8;
let thread_count = 8;

let (tx, rx) = mpsc::channel();
for _ in 0..thread_count {
let tx = tx.clone();
let ctx = Arc::clone(&ctx);
thread::spawn(move || {
let input = &[100, 100, 100];
pollster::block_on(assert_execute_gpu(
&ctx.device,
&ctx.queue,
input,
&[25, 25, 25],
));
tx.send(true).unwrap();
});
}
let (tx, rx) = mpsc::channel();
for _ in 0..thread_count {
let tx = tx.clone();
let ctx = Arc::clone(&ctx);
thread::spawn(move || {
let input = &[100, 100, 100];
pollster::block_on(assert_execute_gpu(
&ctx.device,
&ctx.queue,
input,
&[25, 25, 25],
));
tx.send(true).unwrap();
});
}

for _ in 0..thread_count {
rx.recv_timeout(Duration::from_secs(10))
.expect("A thread never completed.");
}
});
for _ in 0..thread_count {
rx.recv_timeout(Duration::from_secs(10))
.expect("A thread never completed.");
}
},
);
}

async fn assert_execute_gpu(
Expand Down
2 changes: 1 addition & 1 deletion wgpu/examples/skybox/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ fn skybox_astc() {
height: 768,
optional_features: wgpu::Features::TEXTURE_COMPRESSION_ASTC_LDR,
base_test_parameters: framework::test_common::TestParameters::default(),
tolerance: 5, // TODO
tolerance: 5, // TODO
max_outliers: 10, // TODO
});
}

0 comments on commit 2bdc54a

Please sign in to comment.