Merge branch 'main' into failure

This commit is contained in:
Raph Levien 2023-05-31 17:34:46 -07:00
commit f60cb0c31b
16 changed files with 87 additions and 77 deletions

View file

@ -20,9 +20,21 @@ jobs:
- uses: dtolnay/rust-toolchain@stable - uses: dtolnay/rust-toolchain@stable
- name: Install native dependencies - name: Install native dependencies
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev
- run: cargo check --workspace - run: cargo check --workspace
# Check vello (the default crate) without the features used by `with_winit` for debugging
- run: cargo check
# --exclude with_bevy # for when bevy has an outdated wgpu version # --exclude with_bevy # for when bevy has an outdated wgpu version
# -Dwarnings # for when we have fixed unused code warnings # -Dwarnings # for when we have fixed unused code warnings
clippy:
runs-on: ubuntu-latest
name: Enforce clippy lints
steps:
- uses: actions/checkout@v2
- uses: dtolnay/rust-toolchain@stable
- name: Install native dependencies
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev
- run: cargo clippy --all-targets --workspace -- -D warnings
wasm: wasm:
runs-on: ubuntu-latest runs-on: ubuntu-latest

View file

@ -26,7 +26,7 @@ fn main() {
.and_then(|p| Path::new(&p).parent().map(|p| p.to_owned())) .and_then(|p| Path::new(&p).parent().map(|p| p.to_owned()))
.unwrap_or(PathBuf::from("../../")); .unwrap_or(PathBuf::from("../../"));
let shader_dir = Path::new(&workspace_dir).join("shader"); let shader_dir = Path::new(&workspace_dir).join("shader");
let mut shaders = compile::ShaderInfo::from_dir(&shader_dir); let mut shaders = compile::ShaderInfo::from_dir(shader_dir);
// Drop the HashMap and sort by name so that we get deterministic order. // Drop the HashMap and sort by name so that we get deterministic order.
let mut shaders = shaders.drain().collect::<Vec<_>>(); let mut shaders = shaders.drain().collect::<Vec<_>>();
@ -34,7 +34,7 @@ fn main() {
let mut buf = String::default(); let mut buf = String::default();
write_types(&mut buf, &shaders).unwrap(); write_types(&mut buf, &shaders).unwrap();
write_shaders(&mut buf, &shaders).unwrap(); write_shaders(&mut buf, &shaders).unwrap();
std::fs::write(&dest_path, &buf).unwrap(); std::fs::write(dest_path, &buf).unwrap();
println!("cargo:rerun-if-changed=../shader"); println!("cargo:rerun-if-changed=../shader");
} }
@ -93,12 +93,12 @@ fn write_shaders(
wg_bufs wg_bufs
)?; )?;
if cfg!(feature = "wgsl") { if cfg!(feature = "wgsl") {
writeln!(buf, " wgsl: Cow::Borrowed(&{:?}),", info.source)?; writeln!(buf, " wgsl: Cow::Borrowed({:?}),", info.source)?;
} }
if cfg!(feature = "msl") { if cfg!(feature = "msl") {
writeln!( writeln!(
buf, buf,
" msl: Cow::Borrowed(&{:?}),", " msl: Cow::Borrowed({:?}),",
compile::msl::translate(info).unwrap() compile::msl::translate(info).unwrap()
)?; )?;
} }

View file

@ -21,7 +21,7 @@ fn main() -> Result<()> {
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
env_logger::init(); env_logger::init();
let args = Args::parse(); let args = Args::parse();
let scenes = args.args.select_scene_set(|| Args::command())?; let scenes = args.args.select_scene_set(Args::command)?;
if let Some(scenes) = scenes { if let Some(scenes) = scenes {
let mut scene_idx = None; let mut scene_idx = None;
for (idx, scene) in scenes.scenes.iter().enumerate() { for (idx, scene) in scenes.scenes.iter().enumerate() {
@ -41,8 +41,8 @@ fn main() -> Result<()> {
args.scene args.scene
))?; ))?;
if !(parsed < scenes.scenes.len()) { if parsed >= scenes.scenes.len() {
if scenes.scenes.len() == 0 { if scenes.scenes.is_empty() {
bail!("Cannot select a scene, as there are no scenes") bail!("Cannot select a scene, as there are no scenes")
} }
bail!( bail!(
@ -86,7 +86,7 @@ async fn render(mut scenes: SceneSet, index: usize, args: &Args) -> Result<()> {
let device = &device_handle.device; let device = &device_handle.device;
let queue = &device_handle.queue; let queue = &device_handle.queue;
let mut renderer = vello::Renderer::new( let mut renderer = vello::Renderer::new(
&device, device,
&RendererOptions { &RendererOptions {
surface_format: None, surface_format: None,
}, },
@ -120,20 +120,14 @@ async fn render(mut scenes: SceneSet, index: usize, args: &Args) -> Result<()> {
}; };
let factor = Vec2::new(new_width as f64, new_height as f64); 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 = (factor.x / resolution.x).min(factor.y / resolution.y);
transform = transform * Affine::scale(scale_factor); transform *= Affine::scale(scale_factor);
(new_width, new_height) (new_width, new_height)
} else { } else {
match (args.x_resolution, args.y_resolution) { match (args.x_resolution, args.y_resolution) {
(None, None) => (1000, 1000), (None, None) => (1000, 1000),
(None, Some(y)) => { (None, Some(y)) => (y, y),
let y = y.try_into()?; (Some(x), None) => (x, x),
(y, y) (Some(x), Some(y)) => (x, y),
}
(Some(x), None) => {
let x = x.try_into()?;
(x, x)
}
(Some(x), Some(y)) => (x.try_into()?, y.try_into()?),
} }
}; };
let render_params = vello::RenderParams { let render_params = vello::RenderParams {
@ -165,11 +159,11 @@ async fn render(mut scenes: SceneSet, index: usize, args: &Args) -> Result<()> {
}); });
let view = target.create_view(&wgpu::TextureViewDescriptor::default()); let view = target.create_view(&wgpu::TextureViewDescriptor::default());
renderer renderer
.render_to_texture(&device, &queue, &scene, &view, &render_params) .render_to_texture(device, queue, &scene, &view, &render_params)
.or_else(|_| bail!("Got non-Send/Sync error from rendering"))?; .or_else(|_| bail!("Got non-Send/Sync error from rendering"))?;
// (width * 4).next_multiple_of(256) // (width * 4).next_multiple_of(256)
let padded_byte_width = { let padded_byte_width = {
let w = width as u32 * 4; let w = width * 4;
match w % 256 { match w % 256 {
0 => w, 0 => w,
r => w + (256 - r), r => w + (256 - r),
@ -202,7 +196,7 @@ async fn render(mut scenes: SceneSet, index: usize, args: &Args) -> Result<()> {
let (sender, receiver) = futures_intrusive::channel::shared::oneshot_channel(); let (sender, receiver) = futures_intrusive::channel::shared::oneshot_channel();
buf_slice.map_async(wgpu::MapMode::Read, move |v| sender.send(v).unwrap()); buf_slice.map_async(wgpu::MapMode::Read, move |v| sender.send(v).unwrap());
if let Some(recv_result) = block_on_wgpu(&device, receiver.receive()) { if let Some(recv_result) = block_on_wgpu(device, receiver.receive()) {
recv_result?; recv_result?;
} else { } else {
bail!("channel was closed"); bail!("channel was closed");

View file

@ -40,7 +40,7 @@ impl Download {
if let Some(downloads) = &self.downloads { if let Some(downloads) = &self.downloads {
to_download = downloads to_download = downloads
.iter() .iter()
.map(|it| Self::parse_download(&it)) .map(|it| Self::parse_download(it))
.collect(); .collect();
} else { } else {
let mut accepted = self.auto; let mut accepted = self.auto;
@ -52,7 +52,7 @@ impl Download {
}) })
.collect::<Vec<_>>(); .collect::<Vec<_>>();
if !accepted { if !accepted {
if downloads.len() != 0 { if !downloads.is_empty() {
println!( println!(
"Would you like to download a set of default svg files? These files are:" "Would you like to download a set of default svg files? These files are:"
); );
@ -140,7 +140,7 @@ impl SVGDownload {
let mut file = std::fs::OpenOptions::new() let mut file = std::fs::OpenOptions::new()
.create_new(true) .create_new(true)
.write(true) .write(true)
.open(&self.file_path(directory)) .open(self.file_path(directory))
.context("Creating file")?; .context("Creating file")?;
let mut reader = ureq::get(&self.url).call()?.into_reader(); let mut reader = ureq::get(&self.url).call()?.into_reader();
@ -152,14 +152,8 @@ impl SVGDownload {
if reader.read_exact(&mut [0]).is_ok() { if reader.read_exact(&mut [0]).is_ok() {
bail!("Size limit exceeded"); bail!("Size limit exceeded");
} }
if limit_exact { if limit_exact && file.stream_position().context("Checking file limit")? != size_limit {
if file bail!("Builtin downloaded file was not as expected");
.seek(std::io::SeekFrom::Current(0))
.context("Checking file limit")?
!= size_limit
{
bail!("Builtin downloaded file was not as expected");
}
} }
Ok(()) Ok(())
} }

View file

@ -99,7 +99,7 @@ impl Arguments {
if self.test_scenes { if self.test_scenes {
Ok(test_scenes()) Ok(test_scenes())
} else if let Some(svgs) = &self.svgs { } else if let Some(svgs) = &self.svgs {
scene_from_files(&svgs) scene_from_files(svgs)
} else { } else {
default_scene(command) default_scene(command)
} }

View file

@ -1,5 +1,7 @@
//! A benchmark based on MotionMark 1.2's path benchmark. //! A benchmark based on MotionMark 1.2's path benchmark.
use std::cmp::Ordering;
use rand::{seq::SliceRandom, Rng}; use rand::{seq::SliceRandom, Rng};
use vello::peniko::Color; use vello::peniko::Color;
use vello::{ use vello::{
@ -40,19 +42,21 @@ impl MMark {
fn resize(&mut self, n: usize) { fn resize(&mut self, n: usize) {
let old_n = self.elements.len(); let old_n = self.elements.len();
if n < old_n { match n.cmp(&old_n) {
self.elements.truncate(n) Ordering::Less => self.elements.truncate(n),
} else if n > old_n { Ordering::Greater => {
let mut last = self let mut last = self
.elements .elements
.last() .last()
.map(|e| e.grid_point) .map(|e| e.grid_point)
.unwrap_or(GridPoint((GRID_WIDTH / 2, GRID_HEIGHT / 2))); .unwrap_or(GridPoint((GRID_WIDTH / 2, GRID_HEIGHT / 2)));
self.elements.extend((old_n..n).map(|_| { self.elements.extend((old_n..n).map(|_| {
let element = Element::new_rand(last); let element = Element::new_rand(last);
last = element.grid_point; last = element.grid_point;
element element
})); }));
}
_ => (),
} }
} }
} }
@ -149,7 +153,7 @@ impl Element {
)), )),
) )
}; };
let color = COLORS.choose(&mut rng).unwrap().clone(); let color = *COLORS.choose(&mut rng).unwrap();
let width = rng.gen::<f64>().powi(5) * 20.0 + 1.0; let width = rng.gen::<f64>().powi(5) * 20.0 + 1.0;
let is_split = rng.gen(); let is_split = rng.gen();
Element { Element {
@ -170,11 +174,11 @@ impl GridPoint {
let offset = OFFSETS.choose(&mut rng).unwrap(); let offset = OFFSETS.choose(&mut rng).unwrap();
let mut x = last.0 .0 + offset.0; let mut x = last.0 .0 + offset.0;
if x < 0 || x > GRID_WIDTH { if !(0..=GRID_WIDTH).contains(&x) {
x -= offset.0 * 2; x -= offset.0 * 2;
} }
let mut y = last.0 .1 + offset.1; let mut y = last.0 .1 + offset.1;
if y < 0 || y > GRID_HEIGHT { if !(0..=GRID_HEIGHT).contains(&y) {
y -= offset.1 * 2; y -= offset.1 * 2;
} }
GridPoint((x, y)) GridPoint((x, y))

View file

@ -37,6 +37,7 @@ pub struct SimpleText {
} }
impl SimpleText { impl SimpleText {
#[allow(clippy::new_without_default)]
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {
gcx: GlyphContext::new(), gcx: GlyphContext::new(),
@ -45,6 +46,7 @@ impl SimpleText {
} }
} }
#[allow(clippy::too_many_arguments)]
pub fn add_run<'a>( pub fn add_run<'a>(
&mut self, &mut self,
builder: &mut SceneBuilder, builder: &mut SceneBuilder,
@ -69,6 +71,7 @@ impl SimpleText {
); );
} }
#[allow(clippy::too_many_arguments)]
pub fn add_var_run<'a>( pub fn add_var_run<'a>(
&mut self, &mut self,
builder: &mut SceneBuilder, builder: &mut SceneBuilder,
@ -118,7 +121,7 @@ impl SimpleText {
} }
let gid = charmap.map(ch).unwrap_or_default(); let gid = charmap.map(ch).unwrap_or_default();
let advance = glyph_metrics.advance_width(gid).unwrap_or_default(); let advance = glyph_metrics.advance_width(gid).unwrap_or_default();
let x = pen_x as f32; let x = pen_x;
pen_x += advance; pen_x += advance;
Some(Glyph { Some(Glyph {
id: gid.to_u16() as u32, id: gid.to_u16() as u32,
@ -139,10 +142,7 @@ impl SimpleText {
text: &str, text: &str,
) { ) {
let default_font = FontRef::new(ROBOTO_FONT).unwrap(); let default_font = FontRef::new(ROBOTO_FONT).unwrap();
let font = font let font = font.and_then(to_font_ref).unwrap_or(default_font);
.map(|font| to_font_ref(font))
.flatten()
.unwrap_or(default_font);
let fello_size = vello::fello::Size::new(size); let fello_size = vello::fello::Size::new(size);
let charmap = font.charmap(); let charmap = font.charmap();
let metrics = font.metrics(fello_size, Default::default()); let metrics = font.metrics(fello_size, Default::default());
@ -171,7 +171,7 @@ impl SimpleText {
} }
} }
fn to_font_ref<'a>(font: &'a Font) -> Option<FontRef<'a>> { fn to_font_ref(font: &Font) -> Option<FontRef<'_>> {
use vello::fello::raw::FileRef; use vello::fello::raw::FileRef;
let file_ref = FileRef::new(font.data.as_ref()).ok()?; let file_ref = FileRef::new(font.data.as_ref()).ok()?;
match file_ref { match file_ref {

View file

@ -75,8 +75,7 @@ fn example_scene_of(file: PathBuf) -> ExampleScene {
.unwrap_or_else(|| "unknown".to_string()); .unwrap_or_else(|| "unknown".to_string());
ExampleScene { ExampleScene {
function: Box::new(svg_function_of(name.clone(), move || { function: Box::new(svg_function_of(name.clone(), move || {
let contents = std::fs::read_to_string(&file).expect("failed to read svg file"); std::fs::read_to_string(file).expect("failed to read svg file")
contents
})), })),
config: crate::SceneConfig { config: crate::SceneConfig {
animated: false, animated: false,
@ -91,7 +90,7 @@ pub fn svg_function_of<R: AsRef<str>>(
) -> impl FnMut(&mut SceneBuilder, &mut SceneParams) { ) -> impl FnMut(&mut SceneBuilder, &mut SceneParams) {
fn render_svg_contents(name: &str, contents: &str) -> (SceneFragment, Vec2) { fn render_svg_contents(name: &str, contents: &str) -> (SceneFragment, Vec2) {
let start = Instant::now(); let start = Instant::now();
let svg = usvg::Tree::from_str(&contents, &usvg::Options::default()) let svg = usvg::Tree::from_str(contents, &usvg::Options::default())
.expect("failed to parse svg file"); .expect("failed to parse svg file");
eprintln!("Parsed svg {name} in {:?}", start.elapsed()); eprintln!("Parsed svg {name} in {:?}", start.elapsed());
let start = Instant::now(); let start = Instant::now();
@ -112,7 +111,7 @@ pub fn svg_function_of<R: AsRef<str>>(
let mut contents = Some(contents); let mut contents = Some(contents);
move |builder, params| { move |builder, params| {
if let Some((scene_frag, resolution)) = cached_scene.as_mut() { if let Some((scene_frag, resolution)) = cached_scene.as_mut() {
builder.append(&scene_frag, None); builder.append(scene_frag, None);
params.resolution = Some(*resolution); params.resolution = Some(*resolution);
return; return;
} }

View file

@ -167,7 +167,7 @@ fn animated_text(sb: &mut SceneBuilder, params: &mut SceneParams) {
Fill::NonZero, Fill::NonZero,
"And some vello\ntext with a newline", "And some vello\ntext with a newline",
); );
let th = params.time as f64; let th = params.time;
let center = Point::new(500.0, 500.0); let center = Point::new(500.0, 500.0);
let mut p1 = center; let mut p1 = center;
p1.x += 400.0 * th.cos(); p1.x += 400.0 * th.cos();
@ -186,7 +186,7 @@ fn animated_text(sb: &mut SceneBuilder, params: &mut SceneParams) {
None, None,
&rect, &rect,
); );
let alpha = (params.time as f64).sin() as f32 * 0.5 + 0.5; let alpha = params.time.sin() as f32 * 0.5 + 0.5;
sb.push_layer(Mix::Normal, alpha, Affine::IDENTITY, &rect); sb.push_layer(Mix::Normal, alpha, Affine::IDENTITY, &rect);
sb.fill( sb.fill(
Fill::NonZero, Fill::NonZero,
@ -284,12 +284,11 @@ fn gradient_extend(sb: &mut SceneBuilder, params: &mut SceneParams) {
); );
} }
let extend_modes = [Extend::Pad, Extend::Repeat, Extend::Reflect]; let extend_modes = [Extend::Pad, Extend::Repeat, Extend::Reflect];
for x in 0..3 { for (x, extend) in extend_modes.iter().enumerate() {
let extend = extend_modes[x];
for y in 0..2 { for y in 0..2 {
let is_radial = y & 1 != 0; let is_radial = y & 1 != 0;
let transform = Affine::translate((x as f64 * 350.0 + 50.0, y as f64 * 350.0 + 100.0)); let transform = Affine::translate((x as f64 * 350.0 + 50.0, y as f64 * 350.0 + 100.0));
square(sb, is_radial, transform, extend); square(sb, is_radial, transform, *extend);
} }
} }
for (i, label) in ["Pad", "Repeat", "Reflect"].iter().enumerate() { for (i, label) in ["Pad", "Repeat", "Reflect"].iter().enumerate() {
@ -305,6 +304,7 @@ fn gradient_extend(sb: &mut SceneBuilder, params: &mut SceneParams) {
} }
} }
#[allow(clippy::too_many_arguments)]
fn two_point_radial(sb: &mut SceneBuilder, _params: &mut SceneParams) { fn two_point_radial(sb: &mut SceneBuilder, _params: &mut SceneParams) {
fn make( fn make(
sb: &mut SceneBuilder, sb: &mut SceneBuilder,
@ -604,7 +604,7 @@ fn render_blend_square(sb: &mut SceneBuilder, blend: BlendMode, transform: Affin
(125., 200., Color::rgb8(64, 192, 255)), (125., 200., Color::rgb8(64, 192, 255)),
]; ];
for (x, y, c) in GRADIENTS { for (x, y, c) in GRADIENTS {
let mut color2 = c.clone(); let mut color2 = *c;
color2.a = 0; color2.a = 0;
let radial = Gradient::new_radial((*x, *y), 100.0).with_stops([*c, color2]); let radial = Gradient::new_radial((*x, *y), 100.0).with_stops([*c, color2]);
sb.fill(Fill::NonZero, transform, &radial, None, &rect); sb.fill(Fill::NonZero, transform, &radial, None, &rect);

View file

@ -63,7 +63,7 @@ fn render_scenes(
.0 .0
.render_to_texture( .render_to_texture(
device.wgpu_device(), device.wgpu_device(),
&*queue, &queue,
&scene.0, &scene.0,
&gpu_image.texture_view, &gpu_image.texture_view,
&params, &params,

View file

@ -100,6 +100,8 @@ fn run(
let mut images = ImageCache::new(); let mut images = ImageCache::new();
let mut stats = stats::Stats::new(); let mut stats = stats::Stats::new();
let mut stats_shown = true; let mut stats_shown = true;
// Currently not updated in wasm builds
#[allow(unused_mut)]
let mut scene_complexity: Option<BumpAllocators> = None; let mut scene_complexity: Option<BumpAllocators> = None;
let mut complexity_shown = false; let mut complexity_shown = false;
let mut vsync_on = true; let mut vsync_on = true;
@ -327,13 +329,13 @@ fn run(
// TODO: Apply svg view_box, somehow // TODO: Apply svg view_box, somehow
let factor = Vec2::new(width as f64, height as f64); let factor = Vec2::new(width as f64, height as f64);
let scale_factor = (factor.x / resolution.x).min(factor.y / resolution.y); let scale_factor = (factor.x / resolution.x).min(factor.y / resolution.y);
transform = transform * Affine::scale(scale_factor); transform *= Affine::scale(scale_factor);
} }
builder.append(&fragment, Some(transform)); builder.append(&fragment, Some(transform));
if stats_shown { if stats_shown {
snapshot.draw_layer( snapshot.draw_layer(
&mut builder, &mut builder,
&mut scene_params.text, scene_params.text,
width as f64, width as f64,
height as f64, height as f64,
stats.samples(), stats.samples(),
@ -455,7 +457,7 @@ fn create_window(event_loop: &winit::event_loop::EventLoopWindowTarget<UserEvent
.with_inner_size(LogicalSize::new(1044, 800)) .with_inner_size(LogicalSize::new(1044, 800))
.with_resizable(true) .with_resizable(true)
.with_title("Vello demo") .with_title("Vello demo")
.build(&event_loop) .build(event_loop)
.unwrap() .unwrap()
} }
@ -492,7 +494,7 @@ pub fn main() -> Result<()> {
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
env_logger::init(); env_logger::init();
let args = Args::parse(); let args = Args::parse();
let scenes = args.args.select_scene_set(|| Args::command())?; let scenes = args.args.select_scene_set(Args::command)?;
if let Some(scenes) = scenes { if let Some(scenes) = scenes {
let event_loop = EventLoopBuilder::<UserEvent>::with_user_event().build(); let event_loop = EventLoopBuilder::<UserEvent>::with_user_event().build();
#[allow(unused_mut)] #[allow(unused_mut)]

View file

@ -33,6 +33,7 @@ pub struct Snapshot {
} }
impl Snapshot { impl Snapshot {
#[allow(clippy::too_many_arguments)]
pub fn draw_layer<'a, T>( pub fn draw_layer<'a, T>(
&self, &self,
sb: &mut SceneBuilder, sb: &mut SceneBuilder,
@ -69,7 +70,7 @@ impl Snapshot {
]; ];
if let Some(bump) = &bump { if let Some(bump) = &bump {
if bump.failed >= 1 { if bump.failed >= 1 {
labels.push(format!("Allocation Failed!")); labels.push("Allocation Failed!".into());
} }
labels.push(format!("binning: {}", bump.binning)); labels.push(format!("binning: {}", bump.binning));
labels.push(format!("ptcl: {}", bump.ptcl)); labels.push(format!("ptcl: {}", bump.ptcl));
@ -89,7 +90,7 @@ impl Snapshot {
text_size, text_size,
Some(&Brush::Solid(Color::WHITE)), Some(&Brush::Solid(Color::WHITE)),
offset * Affine::translate((left_margin, (i + 1) as f64 * text_height)), offset * Affine::translate((left_margin, (i + 1) as f64 * text_height)),
&label, label,
); );
} }
text.add( text.add(
@ -132,6 +133,7 @@ impl Snapshot {
let sample_ms = ((*sample as f64) * 0.001).min(display_max); let sample_ms = ((*sample as f64) * 0.001).min(display_max);
let h = sample_ms / display_max; let h = sample_ms / display_max;
let s = Affine::scale_non_uniform(1., -h); let s = Affine::scale_non_uniform(1., -h);
#[allow(clippy::match_overlapping_arm)]
let color = match *sample { let color = match *sample {
..=16_667 => Color::rgb8(100, 143, 255), ..=16_667 => Color::rgb8(100, 143, 255),
..=33_334 => Color::rgb8(255, 176, 0), ..=33_334 => Color::rgb8(255, 176, 0),

View file

@ -63,6 +63,7 @@ pub struct BufProxy {
#[derive(Copy, Clone, PartialEq, Eq)] #[derive(Copy, Clone, PartialEq, Eq)]
pub enum ImageFormat { pub enum ImageFormat {
Rgba8, Rgba8,
#[allow(unused)]
Bgra8, Bgra8,
} }
@ -81,6 +82,7 @@ pub enum ResourceProxy {
} }
pub enum ExternalResource<'a> { pub enum ExternalResource<'a> {
#[allow(unused)]
Buf(BufProxy, &'a Buffer), Buf(BufProxy, &'a Buffer),
Image(ImageProxy, &'a TextureView), Image(ImageProxy, &'a TextureView),
} }
@ -800,7 +802,7 @@ impl ResourcePool {
fn get_buf( fn get_buf(
&mut self, &mut self,
size: u64, size: u64,
name: &'static str, #[allow(unused)] name: &'static str,
usage: BufferUsages, usage: BufferUsages,
device: &Device, device: &Device,
) -> Buffer { ) -> Buffer {
@ -809,7 +811,7 @@ impl ResourcePool {
size: rounded_size, size: rounded_size,
usages: usage, usages: usage,
#[cfg(feature = "buffer_labels")] #[cfg(feature = "buffer_labels")]
name: name, name,
}; };
if let Some(buf_vec) = self.bufs.get_mut(&props) { if let Some(buf_vec) = self.bufs.get_mut(&props) {
if let Some(buf) = buf_vec.pop() { if let Some(buf) = buf_vec.pop() {

View file

@ -230,7 +230,7 @@ impl Renderer {
return Err("channel was closed".into()); return Err("channel was closed".into());
} }
let mapped = buf_slice.get_mapped_range(); let mapped = buf_slice.get_mapped_range();
bump = Some(bytemuck::pod_read_unaligned(&*mapped)); bump = Some(bytemuck::pod_read_unaligned(&mapped));
} }
// TODO: apply logic to determine whether we need to rerun coarse, and also // TODO: apply logic to determine whether we need to rerun coarse, and also
// allocate the blend stack as needed. // allocate the blend stack as needed.

View file

@ -2,7 +2,7 @@
use crate::{ use crate::{
engine::{BufProxy, ImageFormat, ImageProxy, Recording, ResourceProxy}, engine::{BufProxy, ImageFormat, ImageProxy, Recording, ResourceProxy},
shaders::{self, FullShaders}, shaders::FullShaders,
RenderParams, Scene, RenderParams, Scene,
}; };
use vello_encoding::{Encoding, WorkgroupSize}; use vello_encoding::{Encoding, WorkgroupSize};

View file

@ -5,6 +5,7 @@ use std::{
vec, vec,
}; };
#[allow(unused)]
pub fn get_imports(shader_dir: &Path) -> HashMap<String, String> { pub fn get_imports(shader_dir: &Path) -> HashMap<String, String> {
let mut imports = HashMap::new(); let mut imports = HashMap::new();
let imports_dir = shader_dir.join("shared"); let imports_dir = shader_dir.join("shared");