SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
Intel OpenGL: restore the grid and sketch axes (#8053) (#11573)
Hainlein4711464f4ac7486a
diff --git a/assets/shaders/viewport.wgsl b/assets/shaders/viewport.wgslindex 92e7bdde5e..fd7ca921a3 100644--- a/assets/shaders/viewport.wgsl+++ b/assets/shaders/viewport.wgsl@@ -802,7 +802,9 @@ fn vs_line(@builtin(vertex_index) vi: u32, @location(0) a: vec3<f32>, @location(let sb = cb.xy / max(cb.w, 1e-6) * half;var dir = sb - sa;let len = length(dir);- if (len < 1e-6) { dir = vec2<f32>(1.0, 0.0); } else { dir = dir / len; }+ // Intel OpenGL can miscompile vector/scalar division here (#8053). Scalar+ // quotients keep the same direction and the fallback for a point.+ if (len < 1e-6) { dir = vec2<f32>(1.0, 0.0); } else { dir = vec2<f32>(dir.x / len, dir.y / len); }let nrm = vec2<f32>(-dir.y, dir.x);// Two triangles: corners (t, side).var ts = array<f32, 6>(0.0, 1.0, 1.0, 0.0, 1.0, 0.0);diff --git a/crates/gpu/src/view.rs b/crates/gpu/src/view.rsindex e977febc5c..7ad8aba7f2 100644--- a/crates/gpu/src/view.rs+++ b/crates/gpu/src/view.rs@@ -4681,6 +4681,55 @@ mod tests {mod glass_tests {use super::*;+ /// Intel UHD 620 OpenGL collapsed long line quads or expanded short ones across the+ /// viewport with vector/scalar direction division (#8053). Exercise the actual+ /// OpenGL shader rather than the native headless selector, which skips GL on Windows.+ #[test]+ fn opengl_draws_grid_lines_in_every_direction_and_at_a_point() {+ let mut descriptor = crate::instance_descriptor_from_env();+ descriptor.backends = wgpu::Backends::GL;+ let instance = wgpu::Instance::new(descriptor);+ let policy = crate::select::Policy::from_env().expect("a valid GPU test policy");+ let Some((adapter, _)) = crate::select::pick_among(pollster::block_on(instance.enumerate_adapters(wgpu::Backends::GL)), policy) else {+ eprintln!("skipped: no OpenGL adapter qualifies under {}", policy.name());+ return;+ };+ eprintln!("OpenGL regression adapter: {:?}", adapter.get_info());+ let (device, queue) = pollster::block_on(adapter.request_device(&wgpu::DeviceDescriptor {+ required_limits: wgpu::Limits::downlevel_webgl2_defaults().using_resolution(adapter.limits()),+ ..Default::default()+ }))+ .expect("the OpenGL adapter opens a device");+ let window = GpuTarget { format: wgpu::TextureFormat::Rgba8Unorm, depth: None, samples: 1, tess: false, oit: false };+ // Ten world units span 32 pixels here; a four-pixel line covers over 100 pixels.+ // A point or a very short line stays a small cap, never a fill over the viewport.+ let cases = [+ ([-5.0, 0.0, 0.0], [5.0, 0.0, 0.0], 100..=256),+ ([5.0, 0.0, 0.0], [-5.0, 0.0, 0.0], 100..=256),+ ([0.0, -5.0, 0.0], [0.0, 5.0, 0.0], 100..=256),+ ([0.0, 5.0, 0.0], [0.0, -5.0, 0.0], 100..=256),+ ([-5.0, -5.0, 0.0], [5.0, 5.0, 0.0], 120..=256),+ ([5.0, 5.0, 0.0], [-5.0, -5.0, 0.0], 120..=256),+ ([-5.0, 5.0, 0.0], [5.0, -5.0, 0.0], 120..=256),+ ([0.0; 3], [0.0; 3], 10..=64),+ ([0.0; 3], [0.0001, 0.0001, 0.0], 10..=64),+ ];+ for offscreen in [false, true] {+ let target = if offscreen { GpuTarget { depth: Some(wgpu::TextureFormat::Depth24PlusStencil8), ..window } } else { window };+ let mut renderer = Renderer::with_window_target(&device, target, window, None);+ for (index, (a, b, expected)) in cases.iter().enumerate() {+ let mut scene = GpuScene::default();+ let red = scene.color([255, 0, 0, 255]);+ scene.under_line(*a, *b, red, 4.0);+ let mut frame = test_frame(scene, 1.0);+ frame.key = index as u64 + 1;+ let pixels = render_frame(&mut renderer, &device, &queue, &frame, false);+ let coloured = pixels.as_chunks::<4>().0.iter().filter(|p| p[0] > 240 && p[1] < 30 && p[2] < 30).count();+ assert!(expected.contains(&coloured), "{a:?} to {b:?}, offscreen {offscreen}: {coloured} line pixels, expected {expected:?}");+ }+ }+ }+#[test]fn ground_shadow_does_not_require_order_independent_transparency() {let batch = || Some(Batch { parts: Vec::new(), chunk: TRI_SIZE * 6 });