Upstream graphics state fixes: rectangle attributes, sampler bounds, A8 copies, depth footprints

Ports of 6f36cdf (normalized attributes of rectangle lists), 97c8783
(A8_UNORM is not of the R8 typeless family), b956320 (copy footprints of
depth-stencil textures), c1c3281 (the descriptor ring's wrap), e6fe8ec and
e34cb53 (CreateSamplerX bounds), 691236d (appended elements are aligned).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
localandClaude Opus 5.5 committed 2026-11-24 23:25:15 -06:00
1 parent 011735ff80
commit 75cfb234e5
5 files changed
+344 -30

No files matched your search

+46 -2
View File
@@ -55,6 +55,8 @@ enum Kind {
F16,
Unorm8,
Unorm16,
Snorm8,
Snorm16,
}
/// Component count and kind of the vertex formats rectangles use.
@@ -69,7 +71,16 @@ fn components(format: u32) -> Option<(usize, Kind)> {
54 => (1, Kind::F16),
11 => (4, Kind::Unorm16),
35 => (2, Kind::Unorm16),
56 => (1, Kind::Unorm16),
28 | 29 | 87 | 91 => (4, Kind::Unorm8),
49 => (2, Kind::Unorm8),
61 => (1, Kind::Unorm8),
13 => (4, Kind::Snorm16),
37 => (2, Kind::Snorm16),
58 => (1, Kind::Snorm16),
31 => (4, Kind::Snorm8),
51 => (2, Kind::Snorm8),
63 => (1, Kind::Snorm8),
_ => return None,
})
}
@@ -78,8 +89,8 @@ impl Kind {
fn bytes(self) -> usize {
match self {
Kind::F32 => 4,
Kind::F16 | Kind::Unorm16 => 2,
Kind::Unorm8 => 1,
Kind::F16 | Kind::Unorm16 | Kind::Snorm16 => 2,
Kind::Unorm8 | Kind::Snorm8 => 1,
}
}
@@ -90,6 +101,8 @@ impl Kind {
Kind::F16 => half_to_f32(u16::from_le_bytes([b[0], b[1]])),
Kind::Unorm16 => f32::from(u16::from_le_bytes([b[0], b[1]])) / 65535.0,
Kind::Unorm8 => f32::from(b[0]) / 255.0,
Kind::Snorm16 => (f32::from(i16::from_le_bytes([b[0], b[1]])) / 32767.0).max(-1.0),
Kind::Snorm8 => (f32::from(b[0] as i8) / 127.0).max(-1.0),
}
}
@@ -103,6 +116,10 @@ impl Kind {
b.copy_from_slice(&((v.clamp(0.0, 1.0) * 65535.0).round() as u16).to_le_bytes())
}
Kind::Unorm8 => b[0] = (v.clamp(0.0, 1.0) * 255.0).round() as u8,
Kind::Snorm16 => {
b.copy_from_slice(&((v.clamp(-1.0, 1.0) * 32767.0).round() as i16).to_le_bytes())
}
Kind::Snorm8 => b[0] = (v.clamp(-1.0, 1.0) * 127.0).round() as i8 as u8,
}
}
}
@@ -218,6 +235,33 @@ mod tests {
assert_eq!(dst[40..], vertex(4.0, 6.0)[..]);
}
#[test]
fn normalized_attributes_are_interpolated_in_their_own_range() {
let vertex = |rg: [u8; 2], u16_value: u16, u8_value: u8, snorm8: i8, snorm16: i16| {
[
&rg[..],
&u16_value.to_le_bytes(),
&[u8_value, snorm8 as u8],
&snorm16.to_le_bytes(),
]
.concat()
};
let src = [
vertex([3, 250], 1000, 10, i8::MIN, -23000),
vertex([8, 200], 500, 3, -120, -18000),
vertex([20, 253], 10000, 100, -120, -32000),
]
.concat();
let mut dst = [0; 6 * 8];
expand_rects(
&src,
&mut dst,
8,
&[(0, 49), (2, 56), (4, 61), (5, 63), (6, 58)],
);
assert_eq!(dst[40..], vertex([15, 255], 10500, 107, -127, -32767));
}
/// `half_to_f32` reads subnormals, so an f16 rectangle output must be
/// able to write them back instead of flushing every one to zero.
#[test]