fix(hatch): finite GPU sentinel for boundary loop separators (#386, #416)

Hatch/wipeout boundary sub-loops were separated by NaN vertices that the
fill shaders detected with `p.x == p.x`. Intel Mesa folds that NaN
self-compare to `true` under fast math, so separators read as real
vertices, the ray-cast crossing count broke, and fills bled outside
their boundary — only on Intel iGPUs. GPU uploads now rewrite the
separators to a finite 1e30 sentinel (GPU_BOUNDARY_SEP) and the shaders
test `abs(x) < 1e29`, which every driver evaluates identically. The
CPU-side NaN representation is unchanged.

Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
Hakan SevenandClaude Fable 5 committed 2026-07-22 21:45:37 +03:00
1 parent 0c578b03f3
commit 805da6428a
7 files changed
+46 -10

No files matched your search

+11
View File
@@ -133,6 +133,13 @@ pub enum HatchPattern {
},
}
/// GPU-side separator between disconnected boundary sub-loops. A finite
/// magnitude sentinel instead of NaN: shaders detect it with a plain
/// `abs(x) < 1e29` compare, which every driver evaluates identically,
/// unlike NaN self-comparison (#386, #416). Boundary verts are local
/// (anchor-relative), so real coordinates never approach it.
pub const GPU_BOUNDARY_SEP: f32 = 1.0e30;
/// A hatched region defined by a closed polygon boundary.
#[derive(Clone, Debug)]
pub struct HatchModel {
@@ -152,6 +159,10 @@ pub struct HatchModel {
/// World-XY coordinates of the boundary polygon vertices, stored as
/// f32 offsets from `world_origin`. NaN-NaN sentinels separate
/// disconnected paths and must be preserved un-shifted by consumers.
/// GPU uploads rewrite them to [`GPU_BOUNDARY_SEP`] — some drivers
/// (Intel Mesa) fold the shader-side `x == x` NaN test to `true`
/// under fast math, which turned separators into real vertices and
/// bled fills outside their boundary (#386, #416).
pub boundary: Arc<Vec<[f32; 2]>>,
/// Exact absolute-WCS boundary in f64, set only by the draw commands so a
/// typed boundary vertex is persisted without the f32 quantization the