Add a clear_color uniform

Introduced an RGBA8 config parameter to apply as a base blend color in
the fine stage of the full pipeline.
This commit is contained in:
Arman Uguray 2023-03-02 09:26:31 -08:00
parent 61ae3cde03
commit 8eabc12a72
4 changed files with 16 additions and 0 deletions

View file

@ -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<vec4<f32>, PIXELS_PER_THREAD>;
for (var i = 0u; i < PIXELS_PER_THREAD; i += 1u) {
rgba[i] = unpack4x8unorm(config.clear_color).wzyx;
}
var blend_stack: array<array<u32, PIXELS_PER_THREAD>, BLEND_STACK_SPLIT>;
var clip_depth = 0u;
var area: array<f32, PIXELS_PER_THREAD>;

View file

@ -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,

View file

@ -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).

View file

@ -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<FineResources>,
}
@ -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,