re: the twins' correct block validates -- distinctness is a real fix; eng_02_l is not
debug_try_anchor asks validate_block directly at the capture-proven offsets. Both 119-vert twin buffers are accepted by both twins (so the correct block lost the first-match race, and a distinct assignment fixes it); the drawn 51-vert bridge buffer is accepted by both bridge resources; eng_02_l's proven offset is rejected outright, even with the pad widened to 64 -- a validator gap, not a selection one. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -613,6 +613,66 @@ impl Xbg7Model {
|
||||
}
|
||||
}
|
||||
|
||||
/// Diagnostic: would the anchor scan accept `vb` as the vertex buffer of the
|
||||
/// named resource's first sub-mesh? A runtime capture proves which offset the
|
||||
/// engine drew from, so this answers whether the correct block is *acceptable*
|
||||
/// and merely lost the first-match race, or is rejected outright by
|
||||
/// `validate_block`. Returns `(vtx_count, index_count, accepted_pad)`.
|
||||
pub fn debug_try_anchor(
|
||||
bytes: &[u8],
|
||||
name: &str,
|
||||
vb: usize,
|
||||
max_pad: usize,
|
||||
) -> Option<(usize, usize, usize)> {
|
||||
if bytes.len() < 16 || &bytes[..4] != b"XPR2" {
|
||||
return None;
|
||||
}
|
||||
let mut cur = Cursor::new(bytes);
|
||||
let header = Xpr2Header::read(&mut cur).ok()?;
|
||||
const DIR_BASE: usize = 0x10;
|
||||
for _ in 0..header.num_resources {
|
||||
let Ok(e) = Xpr2ResourceEntry::read(&mut cur) else { break };
|
||||
if &e.type_tag != b"XBG7" {
|
||||
continue;
|
||||
}
|
||||
let desc = e.data_offset as usize + DIR_BASE;
|
||||
let desc_end = (desc + e.descriptor_size as usize).min(bytes.len());
|
||||
if desc >= bytes.len() || desc_end <= desc {
|
||||
continue;
|
||||
}
|
||||
let rname = read_cstr(bytes, e.name_offset as usize + DIR_BASE)
|
||||
.unwrap_or_else(|| "XBG7".to_string());
|
||||
if rname != name {
|
||||
continue;
|
||||
}
|
||||
let d = &bytes[desc..desc_end];
|
||||
let markers = all_index_markers(d);
|
||||
let decl = parse_vertex_decl(d)?;
|
||||
let (vtx_count, index_count) = *markers.first()?;
|
||||
let idx_bytes = index_count * 2;
|
||||
for pad in 0..=max_pad {
|
||||
if vb < idx_bytes + pad {
|
||||
continue;
|
||||
}
|
||||
let mc = if pad == 0 { 0.0 } else { 0.85 };
|
||||
if validate_block(
|
||||
bytes,
|
||||
vb - idx_bytes - pad,
|
||||
vb,
|
||||
vtx_count,
|
||||
index_count,
|
||||
&decl,
|
||||
mc,
|
||||
true,
|
||||
) {
|
||||
return Some((vtx_count, index_count, pad));
|
||||
}
|
||||
}
|
||||
return None;
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
/// Diagnostic: the candidate vertex-buffer starts the stage anchor scan will
|
||||
/// consider for a given `stride`, for one container. A runtime capture names the
|
||||
/// offsets the engine really drew from (see `examples/shared_vbase_check.rs`), so
|
||||
|
||||
Reference in New Issue
Block a user