Skip to content

Commit

Permalink
Stub in new test.
Browse files Browse the repository at this point in the history
  • Loading branch information
bradwerth committed Jun 25, 2024
1 parent e5448ed commit 7f864f7
Show file tree
Hide file tree
Showing 3 changed files with 515 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/tests/root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ mod texture_bounds;
mod texture_view_creation;
mod transfer;
mod vertex_indices;
mod vertex_formats;
mod write_texture;
mod zero_init_texture_after_discard;

Expand Down
221 changes: 221 additions & 0 deletions tests/tests/vertex_formats/draw.vert.wgsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,221 @@
struct EveryFormat {
// One location and attribute for each format in
// https://gpuweb.github.io/gpuweb/#dictdef-gpuvertexattribute
// ordered so we have 4-byte aligned packing.

// Start with all the formats that are already 4-byte aligned.
@location(0) uint8x4: vec4<u32>,
@location(1) sint8x4: vec4<i32>,
@location(2) unorm8x4: vec4<f32>,
@location(3) snorm8x4: vec4<f32>,
@location(4) uint16x2: vec2<u32>,
@location(5) uint16x4: vec4<u32>,
@location(6) sint16x2: vec2<i32>,
@location(7) sint16x4: vec4<i32>,
@location(8) unorm16x2: vec2<f32>,
@location(9) unorm16x4: vec4<f32>,
@location(10) snorm16x2: vec2<f32>,
@location(11) snorm16x4: vec4<f32>,
@location(12) float16x2: vec2<f16>,
@location(13) float16x4: vec4<f16>,
@location(14) float32: f32,
@location(15) float32x2: vec2<f32>,
@location(16) float32x3: vec3<f32>,
@location(17) float32x4: vec4<f32>,
@location(18) uint32: u32,
@location(19) uint32x2: vec2<u32>,
@location(20) uint32x3: vec3<u32>,
@location(21) uint32x4: vec4<u32>,
@location(22) sint32: i32,
@location(23) sint32x2: vec2<i32>,
@location(24) sint32x3: vec3<i32>,
@location(25) sint32x4: vec4<i32>,
@location(26) unorm10_10_10_2: vec4<f32>,

// Now all the formats that are 2-byte aligned.
@location(27) uint8x2: vec2<u32>,
@location(28) sint8x2: vec2<i32>,
@location(29) unorm8x2: vec2<f32>,
@location(30) snorm8x2: vec2<f32>,
}

struct Checksums {
@location(0) uint: u32,
@location(1) sint: i32,
@location(2) unorm: f32,
@location(3) snorm: f32,
@location(4) float16: f16,
@location(5) float32: f32,
}

@vertex
fn vertex_main(v_in: EveryFormat) -> Checksums
{
// Accumulate all uint into one checksum value.
var all_uint: u32 = 0;
all_uint = accumulate_uint(all_uint, v_in.uint8x2.x);
all_uint = accumulate_uint(all_uint, v_in.uint8x2.y);

all_uint = accumulate_uint(all_uint, v_in.uint8x4.x);
all_uint = accumulate_uint(all_uint, v_in.uint8x4.y);
all_uint = accumulate_uint(all_uint, v_in.uint8x4.z);
all_uint = accumulate_uint(all_uint, v_in.uint8x4.w);

all_uint = accumulate_uint(all_uint, v_in.uint16x2.x);
all_uint = accumulate_uint(all_uint, v_in.uint16x2.y);

all_uint = accumulate_uint(all_uint, v_in.uint16x4.x);
all_uint = accumulate_uint(all_uint, v_in.uint16x4.y);
all_uint = accumulate_uint(all_uint, v_in.uint16x4.z);
all_uint = accumulate_uint(all_uint, v_in.uint16x4.w);

all_uint = accumulate_uint(all_uint, v_in.uint32);

all_uint = accumulate_uint(all_uint, v_in.uint32x2.x);
all_uint = accumulate_uint(all_uint, v_in.uint32x2.y);

all_uint = accumulate_uint(all_uint, v_in.uint32x3.x);
all_uint = accumulate_uint(all_uint, v_in.uint32x3.y);
all_uint = accumulate_uint(all_uint, v_in.uint32x3.z);

all_uint = accumulate_uint(all_uint, v_in.uint32x4.x);
all_uint = accumulate_uint(all_uint, v_in.uint32x4.y);
all_uint = accumulate_uint(all_uint, v_in.uint32x4.z);
all_uint = accumulate_uint(all_uint, v_in.uint32x4.w);


// Accumulate all sint into one checksum value.
var all_sint: i32 = 0;
all_sint = accumulate_sint(all_sint, v_in.sint8x2.x);
all_sint = accumulate_sint(all_sint, v_in.sint8x2.y);

all_sint = accumulate_sint(all_sint, v_in.sint8x4.x);
all_sint = accumulate_sint(all_sint, v_in.sint8x4.y);
all_sint = accumulate_sint(all_sint, v_in.sint8x4.z);
all_sint = accumulate_sint(all_sint, v_in.sint8x4.w);

all_sint = accumulate_sint(all_sint, v_in.sint16x2.x);
all_sint = accumulate_sint(all_sint, v_in.sint16x2.y);

all_sint = accumulate_sint(all_sint, v_in.sint16x4.x);
all_sint = accumulate_sint(all_sint, v_in.sint16x4.y);
all_sint = accumulate_sint(all_sint, v_in.sint16x4.z);
all_sint = accumulate_sint(all_sint, v_in.sint16x4.w);

all_sint = accumulate_sint(all_sint, v_in.sint32);

all_sint = accumulate_sint(all_sint, v_in.sint32x2.x);
all_sint = accumulate_sint(all_sint, v_in.sint32x2.y);

all_sint = accumulate_sint(all_sint, v_in.sint32x3.x);
all_sint = accumulate_sint(all_sint, v_in.sint32x3.y);
all_sint = accumulate_sint(all_sint, v_in.sint32x3.z);

all_sint = accumulate_sint(all_sint, v_in.sint32x4.x);
all_sint = accumulate_sint(all_sint, v_in.sint32x4.y);
all_sint = accumulate_sint(all_sint, v_in.sint32x4.z);
all_sint = accumulate_sint(all_sint, v_in.sint32x4.w);


// Accumulate all unorm into one checksum value.
var all_unorm: f32 = 0.0;
all_unorm = accumulate_unorm(all_unorm, v_in.unorm8x2.x);
all_unorm = accumulate_unorm(all_unorm, v_in.unorm8x2.y);

all_unorm = accumulate_unorm(all_unorm, v_in.unorm8x4.x);
all_unorm = accumulate_unorm(all_unorm, v_in.unorm8x4.y);
all_unorm = accumulate_unorm(all_unorm, v_in.unorm8x4.z);
all_unorm = accumulate_unorm(all_unorm, v_in.unorm8x4.w);

all_unorm = accumulate_unorm(all_unorm, v_in.unorm16x2.x);
all_unorm = accumulate_unorm(all_unorm, v_in.unorm16x2.y);

all_unorm = accumulate_unorm(all_unorm, v_in.unorm16x4.x);
all_unorm = accumulate_unorm(all_unorm, v_in.unorm16x4.y);
all_unorm = accumulate_unorm(all_unorm, v_in.unorm16x4.z);
all_unorm = accumulate_unorm(all_unorm, v_in.unorm16x4.w);

all_unorm = accumulate_unorm(all_unorm, v_in.unorm10_10_10_2.x);
all_unorm = accumulate_unorm(all_unorm, v_in.unorm10_10_10_2.y);
all_unorm = accumulate_unorm(all_unorm, v_in.unorm10_10_10_2.z);
all_unorm = accumulate_unorm(all_unorm, v_in.unorm10_10_10_2.w);


// Accumulate all snorm into one checksum value.
var all_snorm: f32 = 0.0;
all_snorm = accumulate_snorm(all_snorm, v_in.snorm8x2.x);
all_snorm = accumulate_snorm(all_snorm, v_in.snorm8x2.y);

all_snorm = accumulate_snorm(all_snorm, v_in.snorm8x4.x);
all_snorm = accumulate_snorm(all_snorm, v_in.snorm8x4.y);
all_snorm = accumulate_snorm(all_snorm, v_in.snorm8x4.z);
all_snorm = accumulate_snorm(all_snorm, v_in.snorm8x4.w);

all_snorm = accumulate_snorm(all_snorm, v_in.snorm16x2.x);
all_snorm = accumulate_snorm(all_snorm, v_in.snorm16x2.y);

all_snorm = accumulate_snorm(all_snorm, v_in.snorm16x4.x);
all_snorm = accumulate_snorm(all_snorm, v_in.snorm16x4.y);
all_snorm = accumulate_snorm(all_snorm, v_in.snorm16x4.z);
all_snorm = accumulate_snorm(all_snorm, v_in.snorm16x4.w);


// Accumulate all float16 into one checksum value.
var all_float16: f16 = 0.0;
all_float16 = accumulate_float16(all_float16, v_in.float16x2.x);
all_float16 = accumulate_float16(all_float16, v_in.float16x2.y);


// Accumulate all float32 into one checksum value.
var all_float32: f32 = 0.0;
all_float32 = accumulate_float32(all_float32, v_in.float32);

all_float32 = accumulate_float32(all_float32, v_in.float32x2.x);
all_float32 = accumulate_float32(all_float32, v_in.float32x2.y);

all_float32 = accumulate_float32(all_float32, v_in.float32x3.x);
all_float32 = accumulate_float32(all_float32, v_in.float32x3.y);
all_float32 = accumulate_float32(all_float32, v_in.float32x3.z);

all_float32 = accumulate_float32(all_float32, v_in.float32x4.x);
all_float32 = accumulate_float32(all_float32, v_in.float32x4.y);
all_float32 = accumulate_float32(all_float32, v_in.float32x4.z);
all_float32 = accumulate_float32(all_float32, v_in.float32x4.w);


// Build the Checksum structure and return it.
var v_out: Checksums;

v_out.uint = all_uint;
v_out.sint = all_sint;
v_out.unorm = all_unorm;
v_out.snorm = all_snorm;
v_out.float16 = all_float16;
v_out.float32 = all_float32;

return v_out;
}

fn accumulate_uint(accum: u32, val: u32) -> u32 {
return accum + val;
}

fn accumulate_sint(accum: i32, val: i32) -> i32 {
return accum + val;
}

fn accumulate_unorm(accum: f32, val: f32) -> f32 {
return accum + val;
}

fn accumulate_snorm(accum: f32, val: f32) -> f32 {
return accum + val;
}

fn accumulate_float16(accum: f16, val: f16) -> f16 {
return accum + val;
}

fn accumulate_float32(accum: f32, val: f32) -> f32 {
return accum + val;
}
Loading

0 comments on commit 7f864f7

Please sign in to comment.