Intel OpenGL: restore the grid and sketch axes (#8053) (#11573)

* claim: #8053

* Intel OpenGL: restore the grid and sketch axes
This commit is contained in:
Hainlein4711 authored and GitHub committed 2026-11-04 05:49:15 +00:00
1 parent 03b5248dc1
commit 464f4ac748
2 files changed
+52 -1

No files matched your search

+3 -1
View File
@@ -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);
+49
View File
@@ -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 });