Skip to content

Commit 1dba169

Browse files
committed
fix test
1 parent 02bf10b commit 1dba169

File tree

2 files changed

+23
-20
lines changed

2 files changed

+23
-20
lines changed

tests/tests/wgpu-gpu/shader_barycentric/barycentric.wgsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ fn vs_main(@location(0) xy: vec2<f32>) -> @builtin(position) vec4<f32> {
55

66
@fragment
77
fn fs_main(@builtin(barycentric) bary: vec3<f32>) -> @location(0) vec4<f32> {
8-
return vec4<f32>(bary, 1.0);
8+
return vec4<f32>(bary * 1.1 - 0.05, 1.0);
99
}

tests/tests/wgpu-gpu/shader_barycentric/mod.rs

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use wgpu::util::DeviceExt;
22
use wgpu_test::{gpu_test, GpuTestConfiguration, TestParameters, TestingContext};
33

44
pub fn all_tests(vec: &mut Vec<wgpu_test::GpuTestInitializer>) {
5-
vec.push(DRAW);
5+
vec.push(BARYCENTRIC);
66
}
77

88
//
@@ -26,36 +26,26 @@ pub fn all_tests(vec: &mut Vec<wgpu_test::GpuTestInitializer>) {
2626
//
2727
// The fragment shader outputs color based on builtin(barycentric):
2828
//
29-
// return vec4<f32>(bary, 1.0);
29+
// return vec4<f32>(bary * 1.1 - 0.05, 1.0);
3030
//
3131

3232
#[gpu_test]
33-
static DRAW: GpuTestConfiguration = GpuTestConfiguration::new()
33+
static BARYCENTRIC: GpuTestConfiguration = GpuTestConfiguration::new()
3434
.parameters(
3535
TestParameters::default()
3636
.test_features_limits()
3737
.features(wgpu::Features::SHADER_BARYCENTRICS),
3838
)
39-
.run_async(|ctx| async move {
40-
//
41-
// +-----+-----+
42-
// |blue |white|
43-
// +-----+-----+
44-
// | red |green|
45-
// +-----+-----+
46-
//
47-
let expected = [
48-
0, 0, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 0, 255, 0, 255,
49-
];
50-
draw(ctx, &expected).await;
51-
});
39+
.run_async(barycentric);
5240

53-
async fn draw(ctx: TestingContext, expected: &[u8]) {
41+
async fn barycentric(ctx: TestingContext) {
5442
let shader = ctx
5543
.device
5644
.create_shader_module(wgpu::include_wgsl!("barycentric.wgsl"));
5745

58-
let two_triangles_xy: [f32; 6] = [-0.5, -0.5, 0.5, -0.5, -0.5, 0.5];
46+
let n = -0.505;
47+
let p = 0.51;
48+
let two_triangles_xy: [f32; 6] = [n, n, p, n, n, p];
5949
let vertex_buffer = ctx
6050
.device
6151
.create_buffer_init(&wgpu::util::BufferInitDescriptor {
@@ -157,5 +147,18 @@ async fn draw(ctx: TestingContext, expected: &[u8]) {
157147
}
158148
readback_buffer.copy_from(&ctx.device, &mut encoder, &color_texture);
159149
ctx.queue.submit(Some(encoder.finish()));
160-
readback_buffer.assert_buffer_contents(&ctx, expected).await;
150+
151+
//
152+
// +-----+-----+
153+
// |blue |white|
154+
// +-----+-----+
155+
// | red |green|
156+
// +-----+-----+
157+
//
158+
let expected = [
159+
0, 0, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 0, 255, 0, 255,
160+
];
161+
readback_buffer
162+
.assert_buffer_contents(&ctx, &expected)
163+
.await;
161164
}

0 commit comments

Comments
 (0)