Hacks to generate data for scanline experiments Extremely hacky, most configuration is done by editing source code. To get Li BF and prim counts, set tile to 2x2. To get our strip prim count, set tile to 1x4. To get our tile count (for sorting), set tile to 4x4. Transform scale is hardcoded; should be 2.0 for paris and 10.0 for tiger. Note bbox is also hardcoded (in scanline.rs) but is currently calibrated wrong (should be tiles). Commandline is: cargo run --release -p headless -- ~/paris-30k.svg -x 2048 -y 2048 > log No warranty at all; this is just a snapshot of my internal branch I'm using to gather data.
diff --git a/examples/headless/src/main.rs b/examples/headless/src/main.rs index 33165f9..dc3cfa4 100644 --- a/examples/headless/src/main.rs +++ b/examples/headless/src/main.rs
@@ -7,10 +7,8 @@ use clap::{CommandFactory, Parser}; use scenes::{ImageCache, SceneParams, SceneSet, SimpleText}; use vello::{ - block_on_wgpu, - kurbo::{Affine, Vec2}, - util::RenderContext, - RendererOptions, Scene, SceneBuilder, SceneFragment, + block_on_wgpu, kurbo::Affine, util::RenderContext, RendererOptions, Scene, SceneBuilder, + SceneFragment, }; use wgpu::{ BufferDescriptor, BufferUsages, CommandEncoderDescriptor, Extent3d, ImageCopyBuffer, @@ -89,7 +87,7 @@ device, RendererOptions { surface_format: None, - use_cpu: false, + use_cpu: true, antialiasing_support: vello::AaSupport::area_only(), }, ) @@ -112,26 +110,29 @@ .function .render(&mut builder, &mut scene_params); let mut transform = Affine::IDENTITY; - let (width, height) = if let Some(resolution) = scene_params.resolution { - let ratio = resolution.x / resolution.y; - let (new_width, new_height) = match (args.x_resolution, args.y_resolution) { - (None, None) => (resolution.x.ceil() as u32, resolution.y.ceil() as u32), - (None, Some(y)) => ((ratio * (y as f64)).ceil() as u32, y), - (Some(x), None) => (x, ((x as f64) / ratio).ceil() as u32), - (Some(x), Some(y)) => (x, y), - }; - let factor = Vec2::new(new_width as f64, new_height as f64); - let scale_factor = (factor.x / resolution.x).min(factor.y / resolution.y); - transform *= Affine::scale(scale_factor); - (new_width, new_height) - } else { - match (args.x_resolution, args.y_resolution) { - (None, None) => (1000, 1000), - (None, Some(y)) => (y, y), - (Some(x), None) => (x, x), - (Some(x), Some(y)) => (x, y), - } - }; + // let (width, height) = if let Some(resolution) = scene_params.resolution { + // let ratio = resolution.x / resolution.y; + // let (new_width, new_height) = match (args.x_resolution, args.y_resolution) { + // (None, None) => (resolution.x.ceil() as u32, resolution.y.ceil() as u32), + // (None, Some(y)) => ((ratio * (y as f64)).ceil() as u32, y), + // (Some(x), None) => (x, ((x as f64) / ratio).ceil() as u32), + // (Some(x), Some(y)) => (x, y), + // }; + // let factor = Vec2::new(new_width as f64, new_height as f64); + // let scale_factor = (factor.x / resolution.x).min(factor.y / resolution.y); + // let scale_factor = 2.8; + // transform *= Affine::scale(scale_factor); + // (new_width, new_height) + // } else { + // match (args.x_resolution, args.y_resolution) { + // (None, None) => (1000, 1000), + // (None, Some(y)) => (y, y), + // (Some(x), None) => (x, x), + // (Some(x), Some(y)) => (x, y), + // } + // }; + let (width, height) = (args.x_resolution.unwrap(), args.y_resolution.unwrap()); + transform *= Affine::scale(2.0); let render_params = vello::RenderParams { base_color: args .args
diff --git a/src/cpu_shader/flatten.rs b/src/cpu_shader/flatten.rs index fba7173..f744463 100644 --- a/src/cpu_shader/flatten.rs +++ b/src/cpu_shader/flatten.rs
@@ -140,6 +140,7 @@ p0: p0.to_array(), p1: p1.to_array(), }; + //println!("line {:?}", lines[line_ix]); } fn write_line_with_transform(
diff --git a/src/cpu_shader/mod.rs b/src/cpu_shader/mod.rs index 16d261f..f0c1464 100644 --- a/src/cpu_shader/mod.rs +++ b/src/cpu_shader/mod.rs
@@ -23,6 +23,7 @@ mod path_tiling_setup; mod pathtag_reduce; mod pathtag_scan; +mod scanline; mod tile_alloc; mod util; @@ -41,6 +42,7 @@ pub use path_tiling_setup::path_tiling_setup; pub use pathtag_reduce::pathtag_reduce; pub use pathtag_scan::pathtag_scan; +pub use scanline::scanline; pub use tile_alloc::tile_alloc; // Common definitions
diff --git a/src/render.rs b/src/render.rs index 22e0a13..5735be6 100644 --- a/src/render.rs +++ b/src/render.rs
@@ -212,6 +212,7 @@ lines_buf, ], ); + recording.dispatch(shaders.scanline, (1, 1, 1), [bump_buf, lines_buf]); let draw_reduced_buf = ResourceProxy::new_buf( buffer_sizes.draw_reduced.size_in_bytes().into(), "draw_reduced_buf",
diff --git a/src/shaders.rs b/src/shaders.rs index 3facd60..c7dbd50 100644 --- a/src/shaders.rs +++ b/src/shaders.rs
@@ -84,6 +84,7 @@ // 2-level dispatch works for CPU pathtag scan even for large // inputs, 3-level is not yet implemented. pub pathtag_is_cpu: bool, + pub scanline: ShaderId, } #[cfg(feature = "wgpu")] @@ -303,6 +304,12 @@ } pipelines }; + let scanline = add_shader!( + scanline, + [Buffer, BufReadOnly], + &empty, + CpuShaderType::Present(cpu_shader::scanline) + ); Ok(FullShaders { pathtag_reduce, pathtag_reduce2, @@ -327,6 +334,7 @@ fine_msaa8, fine_msaa16, pathtag_is_cpu: options.use_cpu, + scanline, }) }