diff --git a/shader/fine.wgsl b/shader/fine.wgsl index e0d885b..bfcfb66 100644 --- a/shader/fine.wgsl +++ b/shader/fine.wgsl @@ -187,6 +187,9 @@ fn main( let xy = vec2(f32(global_id.x * PIXELS_PER_THREAD), f32(global_id.y)); #ifdef full var rgba: array, PIXELS_PER_THREAD>; + for (var i = 0u; i < PIXELS_PER_THREAD; i += 1u) { + rgba[i] = unpack4x8unorm(config.clear_color).wzyx; + } var blend_stack: array, BLEND_STACK_SPLIT>; var clip_depth = 0u; var area: array; diff --git a/shader/shared/config.wgsl b/shader/shared/config.wgsl index f586f47..af5ff3d 100644 --- a/shader/shared/config.wgsl +++ b/shader/shared/config.wgsl @@ -7,6 +7,11 @@ struct Config { target_width: u32, target_height: u32, + // The initial color applied to the pixels in a tile during the fine stage. + // This is only used in the full pipeline. The format is packed RGBA8 in MSB + // order. + clear_color: u32, + n_drawobj: u32, n_path: u32, n_clip: u32, diff --git a/src/encoding/packed.rs b/src/encoding/packed.rs index 55ffc17..2ee7c67 100644 --- a/src/encoding/packed.rs +++ b/src/encoding/packed.rs @@ -60,6 +60,8 @@ pub struct Config { pub target_width: u32, /// Height of the target in pixels. pub target_height: u32, + /// The initial background color applied to the target + pub clear_color: u32, /// Layout of packed scene data. pub layout: Layout, /// Size of binning buffer allocation (in u32s). diff --git a/src/render.rs b/src/render.rs index 5874dbc..7c06908 100644 --- a/src/render.rs +++ b/src/render.rs @@ -5,6 +5,7 @@ use bytemuck::{Pod, Zeroable}; use crate::{ encoding::Encoding, engine::{BufProxy, ImageFormat, ImageProxy, Recording, ResourceProxy}, + peniko::Color, shaders::{self, FullShaders, Shaders}, Scene, }; @@ -21,6 +22,8 @@ pub struct Render { ptcl_size: u32, width_in_tiles: u32, height_in_tiles: u32, + /// The background color applied to the target + clear_color: Color, fine: Option, } @@ -61,6 +64,7 @@ struct Config { height_in_tiles: u32, target_width: u32, target_height: u32, + clear_color: u32, n_drawobj: u32, n_path: u32, n_clip: u32, @@ -216,6 +220,7 @@ impl Render { ptcl_size: (1 << 25) / 4 as u32, width_in_tiles: 0, height_in_tiles: 0, + clear_color: Color::BLACK, fine: None, } } @@ -265,6 +270,7 @@ impl Render { height_in_tiles: new_height / 16, target_width: width, target_height: height, + clear_color: self.clear_color.to_premul_u32(), binning_size: self.binning_info_size - info_size, tiles_size: self.tiles_size, segments_size: self.segments_size,