Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 37 additions & 20 deletions crates/processing_ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub extern "C" fn processing_surface_create(
scale_factor: f32,
) -> u64 {
error::clear_error();
error::check(|| surface_create_windows(window_handle, width, height, scale_factor))
error::check(|| surface_create_windows(window_handle, width, height, scale_factor, false))
.map(|e| e.to_bits())
.unwrap_or(0)
}
Expand All @@ -87,7 +87,14 @@ pub extern "C" fn processing_surface_create_wayland(
) -> u64 {
error::clear_error();
error::check(|| {
surface_create_wayland(window_handle, display_handle, width, height, scale_factor)
surface_create_wayland(
window_handle,
display_handle,
width,
height,
scale_factor,
false,
)
})
.map(|e| e.to_bits())
.unwrap_or(0)
Expand All @@ -110,9 +117,18 @@ pub extern "C" fn processing_surface_create_x11(
scale_factor: f32,
) -> u64 {
error::clear_error();
error::check(|| surface_create_x11(window_handle, display_handle, width, height, scale_factor))
.map(|e| e.to_bits())
.unwrap_or(0)
error::check(|| {
surface_create_x11(
window_handle,
display_handle,
width,
height,
scale_factor,
false,
)
})
.map(|e| e.to_bits())
.unwrap_or(0)
}

/// Create a WebGPU surface on Linux. The display server is auto-detected from
Expand All @@ -133,7 +149,14 @@ pub extern "C" fn processing_surface_create(
) -> u64 {
error::clear_error();
error::check(|| {
surface_create_linux(window_handle, display_handle, width, height, scale_factor)
surface_create_linux(
window_handle,
display_handle,
width,
height,
scale_factor,
false,
)
})
.map(|e| e.to_bits())
.unwrap_or(0)
Expand Down Expand Up @@ -2982,63 +3005,57 @@ pub extern "C" fn processing_filter_set_passes(filter_id: u64, passes: u32) {
#[unsafe(no_mangle)]
pub extern "C" fn processing_filter_blur() -> u64 {
error::clear_error();
error::check(|| filter_blur())
.map(|e| e.to_bits())
.unwrap_or(0)
error::check(filter_blur).map(|e| e.to_bits()).unwrap_or(0)
}

#[unsafe(no_mangle)]
pub extern "C" fn processing_filter_invert() -> u64 {
error::clear_error();
error::check(|| filter_invert())
error::check(filter_invert)
.map(|e| e.to_bits())
.unwrap_or(0)
}

#[unsafe(no_mangle)]
pub extern "C" fn processing_filter_gray() -> u64 {
error::clear_error();
error::check(|| filter_gray())
.map(|e| e.to_bits())
.unwrap_or(0)
error::check(filter_gray).map(|e| e.to_bits()).unwrap_or(0)
}

#[unsafe(no_mangle)]
pub extern "C" fn processing_filter_threshold() -> u64 {
error::clear_error();
error::check(|| filter_threshold())
error::check(filter_threshold)
.map(|e| e.to_bits())
.unwrap_or(0)
}

#[unsafe(no_mangle)]
pub extern "C" fn processing_filter_posterize() -> u64 {
error::clear_error();
error::check(|| filter_posterize())
error::check(filter_posterize)
.map(|e| e.to_bits())
.unwrap_or(0)
}

#[unsafe(no_mangle)]
pub extern "C" fn processing_filter_opaque() -> u64 {
error::clear_error();
error::check(|| filter_opaque())
error::check(filter_opaque)
.map(|e| e.to_bits())
.unwrap_or(0)
}

#[unsafe(no_mangle)]
pub extern "C" fn processing_filter_erode() -> u64 {
error::clear_error();
error::check(|| filter_erode())
.map(|e| e.to_bits())
.unwrap_or(0)
error::check(filter_erode).map(|e| e.to_bits()).unwrap_or(0)
}

#[unsafe(no_mangle)]
pub extern "C" fn processing_filter_dilate() -> u64 {
error::clear_error();
error::check(|| filter_dilate())
error::check(filter_dilate)
.map(|e| e.to_bits())
.unwrap_or(0)
}
Expand Down
8 changes: 4 additions & 4 deletions crates/processing_pyo3/src/graphics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ use crate::cuda::CudaImage;

/// Flatten `*args` of numbers (or a single list/tuple of numbers) into a `Vec<f32>`.
fn flatten_floats(args: &Bound<'_, PyTuple>) -> PyResult<Vec<f32>> {
if args.len() == 1 {
if let Ok(seq) = args.get_item(0)?.extract::<Vec<f32>>() {
return Ok(seq);
}
if args.len() == 1
&& let Ok(seq) = args.get_item(0)?.extract::<Vec<f32>>()
{
return Ok(seq);
}
let mut out = Vec::with_capacity(args.len());
for item in args.iter() {
Expand Down
8 changes: 4 additions & 4 deletions crates/processing_pyo3/src/particles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ static PHYSICS_COMPUTES: std::sync::Mutex<Option<HashMap<String, Entity>>> =

fn physics_compute(name: &str) -> PyResult<Option<Entity>> {
let lower = name.to_ascii_lowercase();
if let Some(cache) = PHYSICS_COMPUTES.lock().unwrap().as_ref() {
if let Some(&e) = cache.get(&lower) {
return Ok(Some(e));
}
if let Some(cache) = PHYSICS_COMPUTES.lock().unwrap().as_ref()
&& let Some(&e) = cache.get(&lower)
{
return Ok(Some(e));
}
let created = if lower == c::NOISE {
particles_kernel_noise()
Expand Down
8 changes: 4 additions & 4 deletions crates/processing_render/src/graphics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,10 +463,10 @@ pub fn set_bloom(

commands.entity(entity).insert((bloom, Hdr));

if let Ok(mut tm) = tonemapping_query.get_mut(entity) {
if *tm == Tonemapping::None {
*tm = Tonemapping::TonyMcMapface;
}
if let Ok(mut tm) = tonemapping_query.get_mut(entity)
&& *tm == Tonemapping::None
{
*tm = Tonemapping::TonyMcMapface;
}

Ok(())
Expand Down
8 changes: 4 additions & 4 deletions crates/processing_render/src/particles/point_render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ impl Specializer<RenderPipeline> for RasterSpecializer {
target.format = key.format;
target.blend = key.blend;
}
if key.blend.is_some() {
if let Some(depth) = descriptor.depth_stencil.as_mut() {
depth.depth_write_enabled = Some(false);
}
if key.blend.is_some()
&& let Some(depth) = descriptor.depth_stencil.as_mut()
{
depth.depth_write_enabled = Some(false);
}
Ok(key)
}
Expand Down
2 changes: 1 addition & 1 deletion crates/processing_render/src/particles/scatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ fn extract_scatter_geometry(mesh: &mut Mesh) -> Result<(Vec<[f32; 3]>, Vec<u32>)
}
};

if dense_indices.len() % 3 != 0 {
if !dense_indices.len().is_multiple_of(3) {
return Err(ProcessingError::InvalidArgument(
"scatter source mesh has a non-triangle index list".to_string(),
));
Expand Down
10 changes: 5 additions & 5 deletions crates/processing_render/src/render/primitive/shape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ pub fn build_direct_fill(mesh: &mut Mesh, builder: &ShapeBuilder, color: Color)

match builder.kind {
ShapeKind::Triangles => {
for chunk in vertices.chunks_exact(3) {
for chunk in vertices.as_chunks::<3>().0 {
push_triangle(
mesh, color, chunk[0].0, chunk[0].1, chunk[1].0, chunk[1].1, chunk[2].0,
chunk[2].1,
Expand Down Expand Up @@ -296,7 +296,7 @@ pub fn build_direct_fill(mesh: &mut Mesh, builder: &ShapeBuilder, color: Color)
}
}
ShapeKind::Quads => {
for chunk in vertices.chunks_exact(4) {
for chunk in vertices.as_chunks::<4>().0 {
push_quad(
mesh, color, chunk[0].0, chunk[0].1, chunk[1].0, chunk[1].1, chunk[2].0,
chunk[2].1, chunk[3].0, chunk[3].1,
Expand Down Expand Up @@ -344,7 +344,7 @@ pub fn build_direct_stroke(

match builder.kind {
ShapeKind::Lines => {
for chunk in vertices.chunks_exact(2) {
for chunk in vertices.as_chunks::<2>().0 {
let mut pb = Path::builder();
pb.begin(Point::new(chunk[0].0, chunk[0].1));
pb.line_to(Point::new(chunk[1].0, chunk[1].1));
Expand All @@ -359,7 +359,7 @@ pub fn build_direct_stroke(
}
}
ShapeKind::Triangles => {
for chunk in vertices.chunks_exact(3) {
for chunk in vertices.as_chunks::<3>().0 {
stroke_polygon(
mesh,
&[chunk[0], chunk[1], chunk[2]],
Expand Down Expand Up @@ -407,7 +407,7 @@ pub fn build_direct_stroke(
}
}
ShapeKind::Quads => {
for chunk in vertices.chunks_exact(4) {
for chunk in vertices.as_chunks::<4>().0 {
stroke_polygon(
mesh,
&[chunk[0], chunk[1], chunk[2], chunk[3]],
Expand Down
3 changes: 2 additions & 1 deletion examples/particles_animated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ fn sketch() -> error::Result<()> {
graphics,
DrawCommand::Particles {
particles: p,
geometry: sphere,
geometry: Some(sphere),
topology: Default::default(),
},
)?;
graphics_end_draw(graphics)?;
Expand Down
3 changes: 2 additions & 1 deletion examples/particles_basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ fn sketch() -> error::Result<()> {
graphics,
DrawCommand::Particles {
particles: p,
geometry: sphere,
geometry: Some(sphere),
topology: Default::default(),
},
)?;
graphics_end_draw(graphics)?;
Expand Down
3 changes: 2 additions & 1 deletion examples/particles_colored.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ fn sketch() -> error::Result<()> {
graphics,
DrawCommand::Particles {
particles: p,
geometry: sphere,
geometry: Some(sphere),
topology: Default::default(),
},
)?;
graphics_end_draw(graphics)?;
Expand Down
3 changes: 2 additions & 1 deletion examples/particles_colored_pbr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ fn sketch() -> error::Result<()> {
graphics,
DrawCommand::Particles {
particles: p,
geometry: sphere,
geometry: Some(sphere),
topology: Default::default(),
},
)?;
graphics_end_draw(graphics)?;
Expand Down
3 changes: 2 additions & 1 deletion examples/particles_emit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ fn sketch() -> error::Result<()> {
graphics,
DrawCommand::Particles {
particles: p,
geometry: sphere,
geometry: Some(sphere),
topology: Default::default(),
},
)?;
graphics_end_draw(graphics)?;
Expand Down
3 changes: 2 additions & 1 deletion examples/particles_emit_gpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ fn sketch() -> error::Result<()> {
graphics,
DrawCommand::Particles {
particles: p,
geometry: particle,
geometry: Some(particle),
topology: Default::default(),
},
)?;
graphics_end_draw(graphics)?;
Expand Down
3 changes: 2 additions & 1 deletion examples/particles_from_mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ fn sketch() -> error::Result<()> {
graphics,
DrawCommand::Particles {
particles: p,
geometry: particle,
geometry: Some(particle),
topology: Default::default(),
},
)?;
graphics_end_draw(graphics)?;
Expand Down
3 changes: 2 additions & 1 deletion examples/particles_lifecycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ fn sketch() -> error::Result<()> {
graphics,
DrawCommand::Particles {
particles: p,
geometry: sphere,
geometry: Some(sphere),
topology: Default::default(),
},
)?;
graphics_end_draw(graphics)?;
Expand Down
3 changes: 2 additions & 1 deletion examples/particles_noise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ fn sketch() -> error::Result<()> {
graphics,
DrawCommand::Particles {
particles: p,
geometry: particle,
geometry: Some(particle),
topology: Default::default(),
},
)?;
graphics_end_draw(graphics)?;
Expand Down
3 changes: 2 additions & 1 deletion examples/particles_oriented.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ fn sketch() -> error::Result<()> {
graphics,
DrawCommand::Particles {
particles: p,
geometry: cube,
geometry: Some(cube),
topology: Default::default(),
},
)?;
graphics_end_draw(graphics)?;
Expand Down
3 changes: 2 additions & 1 deletion examples/particles_scatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ fn sketch() -> error::Result<()> {
graphics,
DrawCommand::Particles {
particles: p,
geometry: particle,
geometry: Some(particle),
topology: Default::default(),
},
)?;
graphics_end_draw(graphics)?;
Expand Down
3 changes: 2 additions & 1 deletion examples/particles_scatter_volume.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ fn sketch() -> error::Result<()> {
graphics,
DrawCommand::Particles {
particles: p,
geometry: particle,
geometry: Some(particle),
topology: Default::default(),
},
)?;
graphics_end_draw(graphics)?;
Expand Down
3 changes: 2 additions & 1 deletion examples/particles_stress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ fn sketch() -> error::Result<()> {
graphics,
DrawCommand::Particles {
particles: p,
geometry: cube,
geometry: Some(cube),
topology: Default::default(),
},
)?;
graphics_end_draw(graphics)?;
Expand Down
3 changes: 2 additions & 1 deletion examples/particles_text_whirl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,8 @@ fn sketch() -> error::Result<()> {
graphics,
DrawCommand::Particles {
particles: p,
geometry: particle,
geometry: Some(particle),
topology: Default::default(),
},
)?;
graphics_end_draw(graphics)?;
Expand Down
Loading