Your browser sucks, JavaScript disabled! Gunnar's console needs JavaScript and WebAssembly. Git over SSH on port 2222 does not.

nordisk/facett

facett-demo/tests/sens_check.rs

//! **Fix #12 sensitivity guard** — proves the pre-fix behaviour was a real panic.
//!
//! The old `GpuMapRenderer::upload` created ONE `geom` buffer sized to the whole
//! way set. A country (Sweden ≈ 1.05 GB of `Vertex`) exceeds wgpu's
//! `max_buffer_size` (256 MiB), so that single `Device::create_buffer` raised a
//! Validation Error → panic. This test replicates exactly that call (one buffer
//! larger than the device cap) and asserts it panics — the failure mode the
//! chunked upload (`tests/gpu_chunk.rs`) eliminates.
//!
//! Pair: `gpu_chunk.rs` is the fails-on-bug/passes-on-fix functional test (it
//! uploads the same country in chunks WITHOUT panic); this is its `#[should_panic]`
//! mate, documenting the exact validation the fix routes around.

fn render_state() -> egui_wgpu::RenderState {
    egui_kittest::wgpu::create_render_state(egui_kittest::wgpu::default_wgpu_setup(), Default::default())
}

#[test]
#[should_panic]
fn prefix_single_buffer_upload_of_a_country_panics() {
    use egui_wgpu::wgpu;
    let rs = render_state();
    let cap = rs.device.limits().max_buffer_size;
    // The OLD upload created ONE geom buffer of the full vertex byte size. Sweden
    // = ~1.05 GB > the 256 MiB cap. This is the exact call the bug made.
    let size = cap + 64 * 1024 * 1024; // > device cap, like a country's geom
    let _buf = rs.device.create_buffer(&wgpu::BufferDescriptor {
        label: Some("geom-prefix-single"),
        size,
        usage: wgpu::BufferUsages::STORAGE | wgpu::BufferUsages::COPY_DST,
        mapped_at_creation: false,
    });
    eprintln!("UNREACHABLE if the validation panics as expected");
}