fixes after rebase

* remove SceneBuilder::finish() calls
* remove old Config struct
* comment about syncing structs in config.wgsl
This commit is contained in:
Chad Brokaw 2023-03-03 20:46:50 -05:00
parent fca106a5ce
commit 15efb8b3f6
6 changed files with 12 additions and 31 deletions

View file

@ -99,7 +99,6 @@ async fn render(mut scenes: SceneSet, index: usize, args: &Args) -> Result<()> {
base_color: None, base_color: None,
}; };
(example_scene.function)(&mut builder, &mut scene_params); (example_scene.function)(&mut builder, &mut scene_params);
builder.finish();
let mut transform = Affine::IDENTITY; let mut transform = Affine::IDENTITY;
let (width, height) = if let Some(resolution) = scene_params.resolution { let (width, height) = if let Some(resolution) = scene_params.resolution {
let ratio = resolution.x / resolution.y; 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 scene = Scene::new();
let mut builder = SceneBuilder::for_scene(&mut scene); let mut builder = SceneBuilder::for_scene(&mut scene);
builder.append(&fragment, Some(transform)); builder.append(&fragment, Some(transform));
builder.finish();
let size = Extent3d { let size = Extent3d {
width, width,
height, height,

View file

@ -103,7 +103,6 @@ impl ExtractComponent for VelloScene {
let mut scene = Scene::default(); let mut scene = Scene::default();
let mut builder = SceneBuilder::for_scene(&mut scene); let mut builder = SceneBuilder::for_scene(&mut scene);
builder.append(&fragment.0, None); builder.append(&fragment.0, None);
builder.finish();
Some(Self(scene, target.0.clone())) Some(Self(scene, target.0.clone()))
} }
} }

View file

@ -172,7 +172,6 @@ async fn run(event_loop: EventLoop<UserEvent>, window: Window, args: Args, mut s
base_color: None, base_color: None,
}; };
(example_scene.function)(&mut builder, &mut scene_params); (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 // 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. // color specified by the scene. The default is black.

View file

@ -1,5 +1,6 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense // 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 { struct Config {
width_in_tiles: u32, width_in_tiles: u32,
height_in_tiles: u32, height_in_tiles: u32,

View file

@ -109,6 +109,9 @@ impl Layout {
} }
/// Scene configuration. /// 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)] #[derive(Clone, Copy, Debug, Default, Zeroable, Pod)]
#[repr(C)] #[repr(C)]
pub struct Config { pub struct Config {
@ -120,6 +123,8 @@ pub struct Config {
pub target_width: u32, pub target_width: u32,
/// Height of the target in pixels. /// Height of the target in pixels.
pub target_height: u32, pub target_height: u32,
/// The base background color applied to the target before any blends.
pub base_color: u32,
/// Layout of packed scene data. /// Layout of packed scene data.
pub layout: Layout, pub layout: Layout,
/// Size of binning buffer allocation (in u32s). /// Size of binning buffer allocation (in u32s).

View file

@ -3,9 +3,8 @@
use bytemuck::{Pod, Zeroable}; use bytemuck::{Pod, Zeroable};
use crate::{ use crate::{
encoding::Encoding, encoding::{Config, Encoding, Layout},
engine::{BufProxy, ImageFormat, ImageProxy, Recording, ResourceProxy}, engine::{BufProxy, ImageFormat, ImageProxy, Recording, ResourceProxy},
peniko::Color,
shaders::{self, FullShaders, Shaders}, shaders::{self, FullShaders, Shaders},
RenderParams, Scene, RenderParams, Scene,
}; };
@ -43,7 +42,6 @@ const TAG_MONOID_FULL_SIZE: u64 = 20;
const PATH_BBOX_SIZE: u64 = 24; const PATH_BBOX_SIZE: u64 = 24;
const CUBIC_SIZE: u64 = 48; const CUBIC_SIZE: u64 = 48;
const DRAWMONOID_SIZE: u64 = 16; const DRAWMONOID_SIZE: u64 = 16;
const MAX_DRAWINFO_SIZE: u64 = 44;
const CLIP_BIC_SIZE: u64 = 8; const CLIP_BIC_SIZE: u64 = 8;
const CLIP_EL_SIZE: u64 = 32; const CLIP_EL_SIZE: u64 = 32;
const CLIP_INP_SIZE: u64 = 8; const CLIP_INP_SIZE: u64 = 8;
@ -55,28 +53,6 @@ const BIN_HEADER_SIZE: u64 = 8;
const TILE_SIZE: u64 = 8; const TILE_SIZE: u64 = 8;
const SEGMENT_SIZE: u64 = 24; 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 { fn size_to_words(byte_size: usize) -> u32 {
(byte_size / std::mem::size_of::<u32>()) as u32 (byte_size / std::mem::size_of::<u32>()) as u32
} }
@ -121,8 +97,11 @@ fn render(scene: &Scene, shaders: &Shaders) -> (Recording, BufProxy) {
height_in_tiles: 64, height_in_tiles: 64,
target_width: 64 * 16, target_width: 64 * 16,
target_height: 64 * 16, target_height: 64 * 16,
pathtag_base, layout: Layout {
pathdata_base, path_tag_base: pathtag_base,
path_data_base: pathdata_base,
..Default::default()
},
..Default::default() ..Default::default()
}; };
let scene_buf = recording.upload("scene", scene); let scene_buf = recording.upload("scene", scene);