Skip to content

Commit

Permalink
Merge branch 'linebender:main' into controlflow
Browse files Browse the repository at this point in the history
  • Loading branch information
TheNachoBIT authored Sep 10, 2024
2 parents f5767ac + 3c9343b commit 77d06b9
Show file tree
Hide file tree
Showing 26 changed files with 385 additions and 63 deletions.
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ thiserror = "1.0.61"
# NOTE: Make sure to keep this in sync with the version badge in README.md and vello/README.md
wgpu = { version = "22.0.0" }
log = "0.4.21"
image = { version = "0.25.1", default-features = false }
image = { version = "0.25.2", default-features = false }

# Used for examples
clap = "4.5.4"
Expand Down
2 changes: 1 addition & 1 deletion examples/scenes/src/images.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl ImageCache {
}

fn decode_image(data: &[u8]) -> anyhow::Result<Image> {
let image = image::io::Reader::new(std::io::Cursor::new(data))
let image = image::ImageReader::new(std::io::Cursor::new(data))
.with_guessed_format()?
.decode()?;
let width = image.width();
Expand Down
52 changes: 52 additions & 0 deletions examples/scenes/src/test_scenes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export_scenes!(
longpathdash_round(impls::longpathdash(Cap::Round), "longpathdash (round caps)", false),
mmark(crate::mmark::MMark::new(80_000), "mmark", false),
many_draw_objects(many_draw_objects),
blurred_rounded_rect(blurred_rounded_rect),
);

/// Implementations for the test scenes.
Expand Down Expand Up @@ -1694,4 +1695,55 @@ mod impls {
splash_screen(scene, params);
}
}

pub(super) fn blurred_rounded_rect(scene: &mut Scene, params: &mut SceneParams) {
params.resolution = Some(Vec2::new(1200., 1200.));
params.base_color = Some(Color::WHITE);

let rect = Rect::from_center_size((0.0, 0.0), (300.0, 240.0));
let radius = 50.0;
scene.draw_blurred_rounded_rect(
Affine::translate((300.0, 300.0)),
rect,
Color::BLUE,
radius,
params.time.sin() * 50.0 + 50.0,
);

// Skewed affine transformation.
scene.draw_blurred_rounded_rect(
Affine::translate((900.0, 300.0)) * Affine::skew(20f64.to_radians().tan(), 0.0),
rect,
Color::BLACK,
radius,
params.time.sin() * 50.0 + 50.0,
);

// Stretch affine transformation.
scene.draw_blurred_rounded_rect(
Affine::translate((600.0, 600.0)) * Affine::scale_non_uniform(2.2, 0.9),
rect,
Color::BLACK,
radius,
params.time.sin() * 50.0 + 50.0,
);

// Circle.
scene.draw_blurred_rounded_rect(
Affine::IDENTITY,
Rect::new(100.0, 800.0, 400.0, 1100.0),
Color::BLACK,
150.0,
params.time.sin() * 50.0 + 50.0,
);

// Radius larger than one size.
scene.draw_blurred_rounded_rect(
Affine::IDENTITY,
Rect::new(600.0, 800.0, 900.0, 900.0),
Color::BLACK,
150.0,
params.time.sin() * 50.0 + 50.0,
);
}
}
22 changes: 11 additions & 11 deletions vello/src/debug/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl DebugRenderer {

let clear_tint = engine.add_render_shader(
device,
"clear-tint",
"vello.debug.clear_tint",
&module,
"full_screen_quad_vert",
"solid_color_frag",
Expand All @@ -60,7 +60,7 @@ impl DebugRenderer {
);
let bboxes = engine.add_render_shader(
device,
"bbox-debug",
"vello.debug.bbox",
&module,
"bbox_vert",
"solid_color_frag",
Expand Down Expand Up @@ -91,7 +91,7 @@ impl DebugRenderer {
);
let linesoup = engine.add_render_shader(
device,
"linesoup-debug",
"vello.debug.linesoup",
&module,
"linesoup_vert",
"solid_color_frag",
Expand Down Expand Up @@ -122,7 +122,7 @@ impl DebugRenderer {
);
let linesoup_points = engine.add_render_shader(
device,
"linepoints-debug",
"vello.debug.linesoup_points",
&module,
"linepoints_vert",
"sdf_circle_frag",
Expand Down Expand Up @@ -162,7 +162,7 @@ impl DebugRenderer {
);
let unpaired_points = engine.add_render_shader(
device,
"linepoints-debug",
"vello.debug.unpaired_points",
&module,
"linepoints_vert",
"sdf_circle_frag",
Expand Down Expand Up @@ -230,10 +230,10 @@ impl DebugRenderer {
} else {
(
unpaired_pts.len(),
Some(
recording
.upload("unpaired points", bytemuck::cast_slice(&unpaired_pts[..])),
),
Some(recording.upload(
"vello.debug.unpaired_points",
bytemuck::cast_slice(&unpaired_pts[..]),
)),
)
}
} else {
Expand All @@ -245,15 +245,15 @@ impl DebugRenderer {
height: params.height,
};
let uniforms_buf = ResourceProxy::Buffer(
recording.upload_uniform("uniforms", bytemuck::bytes_of(&uniforms)),
recording.upload_uniform("vello.debug_uniforms", bytemuck::bytes_of(&uniforms)),
);

let linepoints_uniforms = [
LinepointsUniforms::new(Color::DARK_CYAN, 10.),
LinepointsUniforms::new(Color::RED, 80.),
];
let linepoints_uniforms_buf = recording.upload_uniform(
"linepoints uniforms",
"vello.debug.linepoints_uniforms",
bytemuck::bytes_of(&linepoints_uniforms),
);

Expand Down
2 changes: 1 addition & 1 deletion vello/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ impl BlitPipeline {
});
let shader_id = engine.add_render_shader(
device,
"blit",
"vello.blit",
&module,
"vs_main",
"fs_main",
Expand Down
62 changes: 35 additions & 27 deletions vello/src/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,22 +178,25 @@ impl Render {
// is zero.
packed.resize(size_of::<u32>(), u8::MAX);
}
let scene_buf = ResourceProxy::Buffer(recording.upload("scene", packed));
let scene_buf = ResourceProxy::Buffer(recording.upload("vello.scene", packed));
let config_buf = ResourceProxy::Buffer(
recording.upload_uniform("config", bytemuck::bytes_of(&cpu_config.gpu)),
recording.upload_uniform("vello.config", bytemuck::bytes_of(&cpu_config.gpu)),
);
let info_bin_data_buf = ResourceProxy::new_buf(
buffer_sizes.bin_data.size_in_bytes() as u64,
"info_bin_data_buf",
"vello.info_bin_data_buf",
);
let tile_buf =
ResourceProxy::new_buf(buffer_sizes.tiles.size_in_bytes().into(), "tile_buf");
let segments_buf =
ResourceProxy::new_buf(buffer_sizes.segments.size_in_bytes().into(), "segments_buf");
let ptcl_buf = ResourceProxy::new_buf(buffer_sizes.ptcl.size_in_bytes().into(), "ptcl_buf");
ResourceProxy::new_buf(buffer_sizes.tiles.size_in_bytes().into(), "vello.tile_buf");
let segments_buf = ResourceProxy::new_buf(
buffer_sizes.segments.size_in_bytes().into(),
"vello.segments_buf",
);
let ptcl_buf =
ResourceProxy::new_buf(buffer_sizes.ptcl.size_in_bytes().into(), "vello.ptcl_buf");
let reduced_buf = ResourceProxy::new_buf(
buffer_sizes.path_reduced.size_in_bytes().into(),
"reduced_buf",
"vello.reduced_buf",
);
// TODO: really only need pathtag_wgs - 1
recording.dispatch(
Expand All @@ -207,7 +210,7 @@ impl Render {
if use_large_path_scan {
let reduced2_buf = ResourceProxy::new_buf(
buffer_sizes.path_reduced2.size_in_bytes().into(),
"reduced2_buf",
"vello.reduced2_buf",
);
recording.dispatch(
shaders.pathtag_reduce2,
Expand All @@ -229,7 +232,7 @@ impl Render {

let tagmonoid_buf = ResourceProxy::new_buf(
buffer_sizes.path_monoids.size_in_bytes().into(),
"tagmonoid_buf",
"vello.tagmonoid_buf",
);
let pathtag_scan = if use_large_path_scan {
shaders.pathtag_scan_large
Expand All @@ -248,18 +251,21 @@ impl Render {
}
let path_bbox_buf = ResourceProxy::new_buf(
buffer_sizes.path_bboxes.size_in_bytes().into(),
"path_bbox_buf",
"vello.path_bbox_buf",
);
recording.dispatch(
shaders.bbox_clear,
wg_counts.bbox_clear,
[config_buf, path_bbox_buf],
);
let bump_buf = BufferProxy::new(buffer_sizes.bump_alloc.size_in_bytes().into(), "bump_buf");
let bump_buf = BufferProxy::new(
buffer_sizes.bump_alloc.size_in_bytes().into(),
"vello.bump_buf",
);
recording.clear_all(bump_buf);
let bump_buf = ResourceProxy::Buffer(bump_buf);
let lines_buf =
ResourceProxy::new_buf(buffer_sizes.lines.size_in_bytes().into(), "lines_buf");
ResourceProxy::new_buf(buffer_sizes.lines.size_in_bytes().into(), "vello.lines_buf");
recording.dispatch(
shaders.flatten,
wg_counts.flatten,
Expand All @@ -274,7 +280,7 @@ impl Render {
);
let draw_reduced_buf = ResourceProxy::new_buf(
buffer_sizes.draw_reduced.size_in_bytes().into(),
"draw_reduced_buf",
"vello.draw_reduced_buf",
);
recording.dispatch(
shaders.draw_reduce,
Expand All @@ -283,11 +289,11 @@ impl Render {
);
let draw_monoid_buf = ResourceProxy::new_buf(
buffer_sizes.draw_monoids.size_in_bytes().into(),
"draw_monoid_buf",
"vello.draw_monoid_buf",
);
let clip_inp_buf = ResourceProxy::new_buf(
buffer_sizes.clip_inps.size_in_bytes().into(),
"clip_inp_buf",
"vello.clip_inp_buf",
);
recording.dispatch(
shaders.draw_leaf,
Expand All @@ -303,11 +309,13 @@ impl Render {
],
);
recording.free_resource(draw_reduced_buf);
let clip_el_buf =
ResourceProxy::new_buf(buffer_sizes.clip_els.size_in_bytes().into(), "clip_el_buf");
let clip_el_buf = ResourceProxy::new_buf(
buffer_sizes.clip_els.size_in_bytes().into(),
"vello.clip_el_buf",
);
let clip_bic_buf = ResourceProxy::new_buf(
buffer_sizes.clip_bics.size_in_bytes().into(),
"clip_bic_buf",
"vello.clip_bic_buf",
);
if wg_counts.clip_reduce.0 > 0 {
recording.dispatch(
Expand All @@ -318,7 +326,7 @@ impl Render {
}
let clip_bbox_buf = ResourceProxy::new_buf(
buffer_sizes.clip_bboxes.size_in_bytes().into(),
"clip_bbox_buf",
"vello.clip_bbox_buf",
);
if wg_counts.clip_leaf.0 > 0 {
recording.dispatch(
Expand All @@ -340,11 +348,11 @@ impl Render {
recording.free_resource(clip_el_buf);
let draw_bbox_buf = ResourceProxy::new_buf(
buffer_sizes.draw_bboxes.size_in_bytes().into(),
"draw_bbox_buf",
"vello.draw_bbox_buf",
);
let bin_header_buf = ResourceProxy::new_buf(
buffer_sizes.bin_headers.size_in_bytes().into(),
"bin_header_buf",
"vello.bin_header_buf",
);
recording.dispatch(
shaders.binning,
Expand All @@ -365,7 +373,7 @@ impl Render {
// Note: this only needs to be rounded up because of the workaround to store the tile_offset
// in storage rather than workgroup memory.
let path_buf =
ResourceProxy::new_buf(buffer_sizes.paths.size_in_bytes().into(), "path_buf");
ResourceProxy::new_buf(buffer_sizes.paths.size_in_bytes().into(), "vello.path_buf");
recording.dispatch(
shaders.tile_alloc,
wg_counts.tile_alloc,
Expand All @@ -382,7 +390,7 @@ impl Render {
recording.free_resource(tagmonoid_buf);
let indirect_count_buf = BufferProxy::new(
buffer_sizes.indirect_count.size_in_bytes().into(),
"indirect_count",
"vello.indirect_count",
);
recording.dispatch(
shaders.path_count_setup,
Expand All @@ -391,7 +399,7 @@ impl Render {
);
let seg_counts_buf = ResourceProxy::new_buf(
buffer_sizes.seg_counts.size_in_bytes().into(),
"seg_counts_buf",
"vello.seg_counts_buf",
);
recording.dispatch_indirect(
shaders.path_count,
Expand Down Expand Up @@ -453,7 +461,7 @@ impl Render {
let out_image = ImageProxy::new(params.width, params.height, ImageFormat::Rgba8);
let blend_spill_buf = BufferProxy::new(
buffer_sizes.blend_spill.size_in_bytes().into(),
"blend_spill",
"vello.blend_spill",
);
self.fine_wg_count = Some(wg_counts.fine);
self.fine_resources = Some(FineResources {
Expand Down Expand Up @@ -530,7 +538,7 @@ impl Render {
AaConfig::Msaa8 => make_mask_lut(),
_ => unreachable!(),
};
let buf = recording.upload("mask lut", mask_lut);
let buf = recording.upload("vello.mask_lut", mask_lut);
self.mask_buf = Some(buf.into());
}
let fine_shader = match fine.aa_config {
Expand Down
Loading

0 comments on commit 77d06b9

Please sign in to comment.