Take the test/fx-prs branch of asdaasdsaddf's fork (as one commit)
Double-precision shader instructions (v_cvt_f32_f64, v_add_f64 sums, the makeDouble overload name and flag), a first half of a paired interpolation read as data, sooner eviction of idle textures and caches under memory pressure, a retried DirectStorage destination write, the texture catch-up budget, VICTORY_FIRSTLANE_OWN, and zlib-rs in place of miniz_oxide. Left out: the fork's personal launcher scripts and its readme. Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
1 parent
2119b0e44c
commit
3bff182ef4
22 files changed
+1147
-64
No files matched your search
@@ -29,9 +29,53 @@ pub struct Record<'a> {
|
||||
impl Record<'_> {
|
||||
/// The container, or `None` if the stream is corrupt.
|
||||
pub fn unpack(&self) -> Option<Vec<u8>> {
|
||||
miniz_oxide::inflate::decompress_to_vec_with_limit(self.packed, self.unpacked_size)
|
||||
.ok()
|
||||
.filter(|out| out.len() == self.unpacked_size)
|
||||
let mut state = zlib_rs::Inflate::new(false, 15);
|
||||
let mut out = Vec::new();
|
||||
let (mut in_pos, mut out_pos) = (0usize, 0usize);
|
||||
loop {
|
||||
if out_pos == self.unpacked_size {
|
||||
let mut extra = [0u8; 1];
|
||||
let status = state
|
||||
.decompress(
|
||||
&self.packed[in_pos..],
|
||||
&mut extra,
|
||||
zlib_rs::InflateFlush::NoFlush,
|
||||
)
|
||||
.ok()?;
|
||||
return (status == zlib_rs::Status::StreamEnd
|
||||
&& state.total_out() as usize == self.unpacked_size)
|
||||
.then_some(out);
|
||||
}
|
||||
if out_pos == out.len() {
|
||||
let next_len = if out.is_empty() {
|
||||
self.unpacked_size
|
||||
.min(self.packed.len().saturating_mul(4).max(4096))
|
||||
} else {
|
||||
out.len().saturating_mul(2).min(self.unpacked_size)
|
||||
};
|
||||
out.resize(next_len, 0);
|
||||
}
|
||||
let status = state
|
||||
.decompress(
|
||||
&self.packed[in_pos..],
|
||||
&mut out[out_pos..],
|
||||
zlib_rs::InflateFlush::NoFlush,
|
||||
)
|
||||
.ok()?;
|
||||
let next_in = state.total_in() as usize;
|
||||
let next_out = state.total_out() as usize;
|
||||
match status {
|
||||
zlib_rs::Status::StreamEnd => {
|
||||
out.truncate(next_out);
|
||||
return (next_out == self.unpacked_size).then_some(out);
|
||||
}
|
||||
zlib_rs::Status::Ok if next_in != in_pos || next_out != out_pos => {
|
||||
in_pos = next_in;
|
||||
out_pos = next_out;
|
||||
}
|
||||
zlib_rs::Status::Ok | zlib_rs::Status::BufError => return None,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +127,13 @@ mod tests {
|
||||
use super::*;
|
||||
|
||||
fn record_bytes(name: &str, kind: u8, payload: &[u8]) -> Vec<u8> {
|
||||
let packed = miniz_oxide::deflate::compress_to_vec(payload, 6);
|
||||
let mut buf = vec![0u8; zlib_rs::compress_bound(payload.len())];
|
||||
let config = zlib_rs::DeflateConfig {
|
||||
window_bits: -15,
|
||||
..zlib_rs::DeflateConfig::new(6)
|
||||
};
|
||||
let (packed, rc) = zlib_rs::compress_slice(&mut buf, payload, config);
|
||||
assert_eq!(rc, zlib_rs::ReturnCode::Ok);
|
||||
let n = (packed.len() + 12) as u32;
|
||||
let mut out = vec![0xF4, 0x01, 0, 0, name.len() as u8 + 1];
|
||||
out.extend_from_slice(name.as_bytes());
|
||||
@@ -91,7 +141,7 @@ mod tests {
|
||||
for v in [n, 0x000D_DCE7, n, payload.len() as u32] {
|
||||
out.extend_from_slice(&v.to_le_bytes());
|
||||
}
|
||||
out.extend_from_slice(&packed);
|
||||
out.extend_from_slice(packed);
|
||||
out
|
||||
}
|
||||
|
||||
@@ -133,4 +183,36 @@ mod tests {
|
||||
let r = records(&file).next().unwrap();
|
||||
assert_eq!(r.unpack(), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn handles_empty_and_rejects_mismatched_or_truncated_streams() {
|
||||
let empty = record_bytes("CS_empty", 0x3c, &[]);
|
||||
assert_eq!(records(&empty).next().unwrap().unpack(), Some(Vec::new()));
|
||||
|
||||
let payload: Vec<u8> = (0..16_384u32)
|
||||
.map(|i| (i.wrapping_mul(31) ^ (i >> 5)) as u8)
|
||||
.collect();
|
||||
let good = record_bytes("PS_big", 0x32, &payload);
|
||||
let r = records(&good).next().unwrap();
|
||||
assert_eq!(r.unpack(), Some(payload.clone()));
|
||||
|
||||
// Oversized stream (declared unpacked_size smaller than actual output).
|
||||
let mut smaller = good.clone();
|
||||
smaller[r.offset + 8..r.offset + 12]
|
||||
.copy_from_slice(&((payload.len() - 1) as u32).to_le_bytes());
|
||||
assert_eq!(records(&smaller).next().unwrap().unpack(), None);
|
||||
|
||||
// Under-filled stream (declared unpacked_size larger than actual output).
|
||||
let mut larger = good.clone();
|
||||
larger[r.offset + 8..r.offset + 12]
|
||||
.copy_from_slice(&((payload.len() + 1) as u32).to_le_bytes());
|
||||
assert_eq!(records(&larger).next().unwrap().unpack(), None);
|
||||
|
||||
// Truncated raw deflate stream.
|
||||
let mut truncated = good[..good.len() - 1].to_vec();
|
||||
let new_n = (truncated.len() - r.offset) as u32;
|
||||
truncated[r.offset - 4..r.offset].copy_from_slice(&new_n.to_le_bytes());
|
||||
truncated[r.offset + 4..r.offset + 8].copy_from_slice(&new_n.to_le_bytes());
|
||||
assert_eq!(records(&truncated).next().unwrap().unpack(), None);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user