BlueGit

golden-age paperdoll-renderer

fmt: rustfmt after parallel IO/PBO (Tim t1063u)

timfa Grok Bot · pushed by timfa

Authored 2026-11-10 · 4 days ago

Hash
dc7edb1b416f53fd82543ca196b16e718f026660
Parent
e9252b20
2 files changed +19 −23
src/lib.rs +1 −1
@@ -27,11 +27,11 @@ pub mod i18n;
27 27 pub mod i18n_table;
28 28 pub mod icon;
29 29 pub mod import;
30 pub mod io_queue;
30 31 pub mod notify;
31 32 pub mod preview;
32 33 pub mod preview2d;
33 34 pub mod preview_gl;
34 pub mod io_queue;
35 35 pub mod production;
36 36 pub mod project;
37 37 pub mod recent;
@@ -27,11 +27,11 @@ pub mod i18n;
27pub mod i18n_table;
27pub mod i18n_table;
28pub mod icon;
28pub mod icon;
29pub mod import;
29pub mod import;
30pub mod io_queue;
30pub mod notify;
31pub mod notify;
31pub mod preview;
32pub mod preview;
32pub mod preview2d;
33pub mod preview2d;
33pub mod preview_gl;
34pub mod preview_gl;
34pub mod io_queue;
35pub mod production;
35pub mod production;
36pub mod project;
36pub mod project;
37pub mod recent;
37pub mod recent;
src/production.rs +18 −22
@@ -677,7 +677,13 @@ impl GpuRenderer {
677 677 Ok(())
678 678 }
679 679
680 unsafe fn ensure_pbo(&mut self, gl: &glow::Context, slot: usize, w: u32, h: u32) -> Result<(), String> {
680 unsafe fn ensure_pbo(
681 &mut self,
682 gl: &glow::Context,
683 slot: usize,
684 w: u32,
685 h: u32,
686 ) -> Result<(), String> {
681 687 let pixels = w as usize * h as usize;
682 688 let sizes = [pixels * 4, pixels * 4, pixels * 4, pixels * 4];
683 689 let ring = &mut self.readback[slot];
@@ -805,10 +811,7 @@ impl GpuRenderer {
805 811 );
806 812 gl.buffer_data_u8_slice(
807 813 glow::ELEMENT_ARRAY_BUFFER,
808 std::slice::from_raw_parts(
809 draw.indices.as_ptr().cast(),
810 draw.indices.len() * 4,
811 ),
814 std::slice::from_raw_parts(draw.indices.as_ptr().cast(), draw.indices.len() * 4),
812 815 glow::STREAM_DRAW,
813 816 );
814 817 gl.uniform_4_f32(
@@ -828,12 +831,9 @@ impl GpuRenderer {
828 831 i32::from(draw.flat_normals),
829 832 );
830 833 let mut temp = Vec::new();
831 for (unit, (name, tex)) in [
832 ("u_albedo", &draw.albedo),
833 ("u_shiny", &draw.shiny),
834 ]
835 .into_iter()
836 .enumerate()
834 for (unit, (name, tex)) in [("u_albedo", &draw.albedo), ("u_shiny", &draw.shiny)]
835 .into_iter()
836 .enumerate()
837 837 {
838 838 gl.active_texture(glow::TEXTURE0 + unit as u32);
839 839 gl.uniform_1_i32(gl.get_uniform_location(p, name).as_ref(), unit as i32);
@@ -897,11 +897,7 @@ impl GpuRenderer {
897 897 Ok(())
898 898 }
899 899
900 unsafe fn readback_into_slice(
901 gl: &glow::Context,
902 w: u32,
903 h: u32,
904 ) -> Result<Buffers, String> {
900 unsafe fn readback_into_slice(gl: &glow::Context, w: u32, h: u32) -> Result<Buffers, String> {
905 901 let pixels = w as usize * h as usize;
906 902 let mut maps = Vec::new();
907 903 gl.pixel_store_i32(glow::PACK_ALIGNMENT, 1);
@@ -1182,7 +1178,8 @@ impl GpuRenderer {
1182 1178 let (tx, rx) = mpsc::sync_channel(1);
1183 1179 self.submit(gl, scene, tx);
1184 1180 let _ = self.poll_readbacks(gl, true);
1185 rx.recv().map_err(|_| "GPU-antwoord ontbreekt".to_string())?
1181 rx.recv()
1182 .map_err(|_| "GPU-antwoord ontbreekt".to_string())?
1186 1183 }
1187 1184 }
1188 1185
@@ -1665,7 +1662,6 @@ impl GpuRequest {
1665 1662 }
1666 1663 }
1667 1664
1668
1669 1665 /// Latest-wins live preview frame (Tim t1064u). The render worker overwrites this
1670 1666 /// slot without waiting for the UI; the UI may skip intermediate frames.
1671 1667 #[derive(Debug, Clone)]
@@ -2101,7 +2097,9 @@ fn execute_target(
2101 2097 let mut atlas_cells: BTreeMap<String, Arc<Vec<u8>>> = BTreeMap::new();
2102 2098 let mut io = Some(IoQueue::start(session, seed_sha, Arc::clone(cancel)));
2103 2099 let work = (|| {
2104 let io = io.as_ref().ok_or_else(|| "IO-queue ontbreekt".to_string())?;
2100 let io = io
2101 .as_ref()
2102 .ok_or_else(|| "IO-queue ontbreekt".to_string())?;
2105 2103 let mut inflight: VecDeque<InflightGpu> = VecDeque::new();
2106 2104
2107 2105 let drain_one = |item: InflightGpu,
@@ -2202,9 +2200,7 @@ fn execute_target(
2202 2200 .depth_t
2203 2201 .iter()
2204 2202 .enumerate()
2205 .map(|(i, t)| {
2206 (f64::from(*t), f64::from(target.depth[i * 2 + 1]) / 65535.)
2207 })
2203 .map(|(i, t)| (f64::from(*t), f64::from(target.depth[i * 2 + 1]) / 65535.))
2208 2204 .collect();
2209 2205 let bytes = encode_depth_png_fmt(
2210 2206 job.target_width,
@@ -677,7 +677,13 @@ impl GpuRenderer {
677 Ok(())
677 Ok(())
678 }
678 }
679
679
680 unsafe fn ensure_pbo(&mut self, gl: &glow::Context, slot: usize, w: u32, h: u32) -> Result<(), String> {
680 unsafe fn ensure_pbo(
681 &mut self,
682 gl: &glow::Context,
683 slot: usize,
684 w: u32,
685 h: u32,
686 ) -> Result<(), String> {
681 let pixels = w as usize * h as usize;
687 let pixels = w as usize * h as usize;
682 let sizes = [pixels * 4, pixels * 4, pixels * 4, pixels * 4];
688 let sizes = [pixels * 4, pixels * 4, pixels * 4, pixels * 4];
683 let ring = &mut self.readback[slot];
689 let ring = &mut self.readback[slot];
@@ -805,10 +811,7 @@ impl GpuRenderer {
805 );
811 );
806 gl.buffer_data_u8_slice(
812 gl.buffer_data_u8_slice(
807 glow::ELEMENT_ARRAY_BUFFER,
813 glow::ELEMENT_ARRAY_BUFFER,
808 std::slice::from_raw_parts(
814 std::slice::from_raw_parts(draw.indices.as_ptr().cast(), draw.indices.len() * 4),
809 draw.indices.as_ptr().cast(),
810 draw.indices.len() * 4,
811 ),
812 glow::STREAM_DRAW,
815 glow::STREAM_DRAW,
813 );
816 );
814 gl.uniform_4_f32(
817 gl.uniform_4_f32(
@@ -828,12 +831,9 @@ impl GpuRenderer {
828 i32::from(draw.flat_normals),
831 i32::from(draw.flat_normals),
829 );
832 );
830 let mut temp = Vec::new();
833 let mut temp = Vec::new();
831 for (unit, (name, tex)) in [
834 for (unit, (name, tex)) in [("u_albedo", &draw.albedo), ("u_shiny", &draw.shiny)]
832 ("u_albedo", &draw.albedo),
835 .into_iter()
833 ("u_shiny", &draw.shiny),
836 .enumerate()
834 ]
835 .into_iter()
836 .enumerate()
837 {
837 {
838 gl.active_texture(glow::TEXTURE0 + unit as u32);
838 gl.active_texture(glow::TEXTURE0 + unit as u32);
839 gl.uniform_1_i32(gl.get_uniform_location(p, name).as_ref(), unit as i32);
839 gl.uniform_1_i32(gl.get_uniform_location(p, name).as_ref(), unit as i32);
@@ -897,11 +897,7 @@ impl GpuRenderer {
897 Ok(())
897 Ok(())
898 }
898 }
899
899
900 unsafe fn readback_into_slice(
900 unsafe fn readback_into_slice(gl: &glow::Context, w: u32, h: u32) -> Result<Buffers, String> {
901 gl: &glow::Context,
902 w: u32,
903 h: u32,
904 ) -> Result<Buffers, String> {
905 let pixels = w as usize * h as usize;
901 let pixels = w as usize * h as usize;
906 let mut maps = Vec::new();
902 let mut maps = Vec::new();
907 gl.pixel_store_i32(glow::PACK_ALIGNMENT, 1);
903 gl.pixel_store_i32(glow::PACK_ALIGNMENT, 1);
@@ -1182,7 +1178,8 @@ impl GpuRenderer {
1182 let (tx, rx) = mpsc::sync_channel(1);
1178 let (tx, rx) = mpsc::sync_channel(1);
1183 self.submit(gl, scene, tx);
1179 self.submit(gl, scene, tx);
1184 let _ = self.poll_readbacks(gl, true);
1180 let _ = self.poll_readbacks(gl, true);
1185 rx.recv().map_err(|_| "GPU-antwoord ontbreekt".to_string())?
1181 rx.recv()
1182 .map_err(|_| "GPU-antwoord ontbreekt".to_string())?
1186 }
1183 }
1187}
1184}
1188
1185
@@ -1665,7 +1662,6 @@ impl GpuRequest {
1665 }
1662 }
1666}
1663}
1667
1664
1668
1669/// Latest-wins live preview frame (Tim t1064u). The render worker overwrites this
1665/// Latest-wins live preview frame (Tim t1064u). The render worker overwrites this
1670/// slot without waiting for the UI; the UI may skip intermediate frames.
1666/// slot without waiting for the UI; the UI may skip intermediate frames.
1671#[derive(Debug, Clone)]
1667#[derive(Debug, Clone)]
@@ -2101,7 +2097,9 @@ fn execute_target(
2101 let mut atlas_cells: BTreeMap<String, Arc<Vec<u8>>> = BTreeMap::new();
2097 let mut atlas_cells: BTreeMap<String, Arc<Vec<u8>>> = BTreeMap::new();
2102 let mut io = Some(IoQueue::start(session, seed_sha, Arc::clone(cancel)));
2098 let mut io = Some(IoQueue::start(session, seed_sha, Arc::clone(cancel)));
2103 let work = (|| {
2099 let work = (|| {
2104 let io = io.as_ref().ok_or_else(|| "IO-queue ontbreekt".to_string())?;
2100 let io = io
2101 .as_ref()
2102 .ok_or_else(|| "IO-queue ontbreekt".to_string())?;
2105 let mut inflight: VecDeque<InflightGpu> = VecDeque::new();
2103 let mut inflight: VecDeque<InflightGpu> = VecDeque::new();
2106
2104
2107 let drain_one = |item: InflightGpu,
2105 let drain_one = |item: InflightGpu,
@@ -2202,9 +2200,7 @@ fn execute_target(
2202 .depth_t
2200 .depth_t
2203 .iter()
2201 .iter()
2204 .enumerate()
2202 .enumerate()
2205 .map(|(i, t)| {
2203 .map(|(i, t)| (f64::from(*t), f64::from(target.depth[i * 2 + 1]) / 65535.))
2206 (f64::from(*t), f64::from(target.depth[i * 2 + 1]) / 65535.)
2207 })
2208 .collect();
2204 .collect();
2209 let bytes = encode_depth_png_fmt(
2205 let bytes = encode_depth_png_fmt(
2210 job.target_width,
2206 job.target_width,