From ea7f2626b11af249510b27001fb6addd7f9210a9 Mon Sep 17 00:00:00 2001 From: Bingus Date: Mon, 29 May 2023 16:44:56 -0700 Subject: Optimized gradient data packing. --- wgpu/src/quad/gradient.rs | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) (limited to 'wgpu/src/quad') diff --git a/wgpu/src/quad/gradient.rs b/wgpu/src/quad/gradient.rs index 2b56d594..1b45c9f4 100644 --- a/wgpu/src/quad/gradient.rs +++ b/wgpu/src/quad/gradient.rs @@ -96,36 +96,24 @@ impl Pipeline { as u64, step_mode: wgpu::VertexStepMode::Instance, attributes: &wgpu::vertex_attr_array!( - // Color 1 - 1 => Float32x4, - // Color 2 - 2 => Float32x4, - // Color 3 - 3 => Float32x4, - // Color 4 - 4 => Float32x4, - // Color 5 - 5 => Float32x4, - // Color 6 - 6 => Float32x4, - // Color 7 - 7 => Float32x4, - // Color 8 - 8 => Float32x4, + // Colors 1-4 + 1 => Uint32x4, + // Colors 5-8 + 2 => Uint32x4, // Offsets 1-4 - 9 => Float32x4, + 3 => Float32x4, // Offsets 5-8 - 10 => Float32x4, + 4 => Float32x4, // Direction - 11 => Float32x4, + 5 => Float32x4, // Position & Scale - 12 => Float32x4, + 6 => Float32x4, // Border color - 13 => Float32x4, + 7 => Float32x4, // Border radius - 14 => Float32x4, + 8 => Float32x4, // Border width - 15 => Float32 + 9 => Float32 ), }, ], -- cgit From 677f564f087b009842207e6df74aed343454ea17 Mon Sep 17 00:00:00 2001 From: Bingus Date: Wed, 7 Jun 2023 10:47:57 -0700 Subject: Switched to packing using f16s to maintain acceptable precision. --- wgpu/src/quad/gradient.rs | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'wgpu/src/quad') diff --git a/wgpu/src/quad/gradient.rs b/wgpu/src/quad/gradient.rs index 1b45c9f4..6db37252 100644 --- a/wgpu/src/quad/gradient.rs +++ b/wgpu/src/quad/gradient.rs @@ -96,24 +96,26 @@ impl Pipeline { as u64, step_mode: wgpu::VertexStepMode::Instance, attributes: &wgpu::vertex_attr_array!( - // Colors 1-4 + // Colors 1-2 1 => Uint32x4, - // Colors 5-8 + // Colors 3-4 2 => Uint32x4, - // Offsets 1-4 - 3 => Float32x4, - // Offsets 5-8 - 4 => Float32x4, + // Colors 5-6 + 3 => Uint32x4, + // Colors 7-8 + 4 => Uint32x4, + // Offsets 1-8 + 5 => Uint32x4, // Direction - 5 => Float32x4, - // Position & Scale 6 => Float32x4, - // Border color + // Position & Scale 7 => Float32x4, - // Border radius + // Border color 8 => Float32x4, + // Border radius + 9 => Float32x4, // Border width - 9 => Float32 + 10 => Float32 ), }, ], -- cgit