diff --git a/examples/headless/src/main.rs b/examples/headless/src/main.rs index c145d06..0397e5e 100644 --- a/examples/headless/src/main.rs +++ b/examples/headless/src/main.rs @@ -99,7 +99,6 @@ async fn render(mut scenes: SceneSet, index: usize, args: &Args) -> Result<()> { base_color: None, }; (example_scene.function)(&mut builder, &mut scene_params); - builder.finish(); let mut transform = Affine::IDENTITY; let (width, height) = if let Some(resolution) = scene_params.resolution { let ratio = resolution.x / resolution.y; @@ -139,7 +138,6 @@ async fn render(mut scenes: SceneSet, index: usize, args: &Args) -> Result<()> { let mut scene = Scene::new(); let mut builder = SceneBuilder::for_scene(&mut scene); builder.append(&fragment, Some(transform)); - builder.finish(); let size = Extent3d { width, height, diff --git a/examples/with_bevy/src/main.rs b/examples/with_bevy/src/main.rs index f98ce73..cbd24fd 100644 --- a/examples/with_bevy/src/main.rs +++ b/examples/with_bevy/src/main.rs @@ -103,7 +103,6 @@ impl ExtractComponent for VelloScene { let mut scene = Scene::default(); let mut builder = SceneBuilder::for_scene(&mut scene); builder.append(&fragment.0, None); - builder.finish(); Some(Self(scene, target.0.clone())) } } diff --git a/examples/with_winit/src/main.rs b/examples/with_winit/src/main.rs index a1ca03f..d1faa04 100644 --- a/examples/with_winit/src/main.rs +++ b/examples/with_winit/src/main.rs @@ -172,7 +172,6 @@ async fn run(event_loop: EventLoop, window: Window, args: Args, mut s base_color: None, }; (example_scene.function)(&mut builder, &mut scene_params); - builder.finish(); // If the user specifies a base color in the CLI we use that. Otherwise we use any // color specified by the scene. The default is black. diff --git a/shader/shared/config.wgsl b/shader/shared/config.wgsl index 7ab9ec6..1063134 100644 --- a/shader/shared/config.wgsl +++ b/shader/shared/config.wgsl @@ -1,5 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense +// This must be kept in sync with the struct in src/encoding/resolve.rs struct Config { width_in_tiles: u32, height_in_tiles: u32, diff --git a/src/encoding/resolve.rs b/src/encoding/resolve.rs index d1f8771..5c77c49 100644 --- a/src/encoding/resolve.rs +++ b/src/encoding/resolve.rs @@ -109,6 +109,9 @@ impl Layout { } /// Scene configuration. +/// +/// This data structure must be kept in sync with the definition in +/// shaders/shared/config.wgsl. #[derive(Clone, Copy, Debug, Default, Zeroable, Pod)] #[repr(C)] pub struct Config { @@ -120,6 +123,8 @@ pub struct Config { pub target_width: u32, /// Height of the target in pixels. pub target_height: u32, + /// The base background color applied to the target before any blends. + pub base_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 9cf93c3..4ad5083 100644 --- a/src/render.rs +++ b/src/render.rs @@ -3,9 +3,8 @@ use bytemuck::{Pod, Zeroable}; use crate::{ - encoding::Encoding, + encoding::{Config, Encoding, Layout}, engine::{BufProxy, ImageFormat, ImageProxy, Recording, ResourceProxy}, - peniko::Color, shaders::{self, FullShaders, Shaders}, RenderParams, Scene, }; @@ -43,7 +42,6 @@ const TAG_MONOID_FULL_SIZE: u64 = 20; const PATH_BBOX_SIZE: u64 = 24; const CUBIC_SIZE: u64 = 48; const DRAWMONOID_SIZE: u64 = 16; -const MAX_DRAWINFO_SIZE: u64 = 44; const CLIP_BIC_SIZE: u64 = 8; const CLIP_EL_SIZE: u64 = 32; const CLIP_INP_SIZE: u64 = 8; @@ -55,28 +53,6 @@ const BIN_HEADER_SIZE: u64 = 8; const TILE_SIZE: u64 = 8; const SEGMENT_SIZE: u64 = 24; -// This data structure must be kept in sync with encoding::Config and the definition in -// shaders/shared/config.wgsl. -#[repr(C)] -#[derive(Clone, Copy, Debug, Default, Zeroable, Pod)] -struct Config { - width_in_tiles: u32, - height_in_tiles: u32, - target_width: u32, - target_height: u32, - base_color: u32, - n_drawobj: u32, - n_path: u32, - n_clip: u32, - bin_data_start: u32, - pathtag_base: u32, - pathdata_base: u32, - drawtag_base: u32, - drawdata_base: u32, - transform_base: u32, - linewidth_base: u32, -} - fn size_to_words(byte_size: usize) -> u32 { (byte_size / std::mem::size_of::()) as u32 } @@ -121,8 +97,11 @@ fn render(scene: &Scene, shaders: &Shaders) -> (Recording, BufProxy) { height_in_tiles: 64, target_width: 64 * 16, target_height: 64 * 16, - pathtag_base, - pathdata_base, + layout: Layout { + path_tag_base: pathtag_base, + path_data_base: pathdata_base, + ..Default::default() + }, ..Default::default() }; let scene_buf = recording.upload("scene", scene);