fix(canvas): preserve chunk offsets on software DX12

# Conflicts:
#	crates/ui-egui/src/canvas/gpu_canvas/resources.rs
This commit is contained in:
yoriswind committed 2026-10-31 05:46:54 -07:00
1 parent 64be75b9fc
commit 6a61c23aa6
3 files changed
+33 -2

No files matched your search

+1 -1
View File
@@ -692,7 +692,7 @@ impl GpuCanvas {
multiview_mask: None,
});
pass.set_pipeline(pipe);
pass.set_bind_group(0, &bg, &[]);
pass.set_bind_group(0, &bg, &[0]);
pass.set_scissor_rect((r.x0 - tx) as u32, (r.y0 - ty) as u32, r.width(), r.height());
pass.draw(0..3, 0..1);
}
@@ -330,7 +330,7 @@ impl Resources {
};
let encode_bgl = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
label: Some("pc_encode"),
entries: &[unfilterable, uniform_entry(1, 16, wgpu::ShaderStages::FRAGMENT, false)],
entries: &[unfilterable, uniform_entry(1, 16, wgpu::ShaderStages::FRAGMENT, true)],
});
let encode_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("pc_encode"),
@@ -200,3 +200,34 @@ fn adjustment_dialog_zoomed_out_skips_the_reduced_copy_when_low_res_is_off() {
let full = mean(&row(&mut h));
assert!((full - committed).abs() < 8.0, "off: the preview matches the committed view ({full} vs {committed})");
}
/// Check the encoded texture directly, before canvas painting or adjustment previews.
#[test]
fn compositor_chunks_keep_their_columns() {
let _gpu = photocraft_testkit::gpu_lock();
let rs = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
egui_kittest::wgpu::create_render_state(egui_kittest::wgpu::default_wgpu_setup(), Default::default())
}));
let Ok(rs) = rs else {
eprintln!("skipping: no GPU adapter");
return;
};
eprintln!("canvas encode adapter {:?}", rs.adapter.get_info());
let gpu = photocraft_ui_egui::gpu_canvas::GpuCanvas::new(&rs);
let doc = columns_document();
let refresh = gpu.refresh(doc.id.0, &doc, None, None);
if refresh.kind == "full" {
eprintln!("skipping: GPU compositor unavailable: {:?}", refresh.fallback);
return;
}
assert_eq!(refresh.kind, "gpu-full", "{:?}", refresh.fallback);
let (format, size, texels) = gpu.read_texels(doc.id.0).expect("read back the encoded canvas");
assert_eq!(format, eframe::wgpu::TextureFormat::Rgba8Unorm);
assert_eq!(size, [W as u32, H as u32]);
assert_eq!(texels.len(), (W * H) as usize);
for (i, pixel) in texels.iter().enumerate() {
let x = i % W as usize;
let v = (x % 2) as f32;
assert_eq!(*pixel, [v, v, v, 1.0], "canvas pixel ({x}, {})", i / W as usize);
}
}