bone_sse: clean A/B testing, remove diagnostic comparison code
Remove the double-call REF/SSE bone output comparison diagnostic. Clean detour: REF baseline, SSE custom, simple toggle.
This commit is contained in:
@@ -299,92 +299,7 @@ fn transformDetour(this: u32, mat1: u32, mat2: u32, mat3: u32, mat4: u32) callco
|
||||
if (teardown_active) {
|
||||
transform_hook.callOriginal(.{ this, mat1, mat2, mat3, mat4 });
|
||||
} else if (ab_use_custom) {
|
||||
// DIAG: run REF first, snapshot bone output, run SSE, compare
|
||||
if (diag_cmp_count < 20 and !is_early and bone_count > 0 and t44_depth == 1) {
|
||||
const model_ctr = hook.readMem(u32, this + 0x30);
|
||||
const model_hdr = if (model_ctr != 0) hook.readMem(u32, model_ctr + 0x130) else 0;
|
||||
const bc = if (model_hdr != 0) hook.readMem(u32, model_hdr + 0x34) else 0;
|
||||
const bout = hook.readMem(u32, this + 0x94);
|
||||
const brt_base = hook.readMem(u32, this + 0x90);
|
||||
if (bc > 0 and bout != 0 and brt_base != 0) {
|
||||
// Run REF
|
||||
transformMatrix4x4_REF(this, mat1, mat2, mat3, mat4);
|
||||
// Snapshot bone output + bone runtime (up to 8 bones)
|
||||
const snap_bones = @min(bc, 8);
|
||||
const snap_len = snap_bones * @as(u32, 0x40);
|
||||
var snap: [8 * 0x40]u8 = undefined;
|
||||
for (0..snap_len) |i| {
|
||||
snap[i] = @as(*const u8, @ptrFromInt(bout + @as(u32, @intCast(i)))).*;
|
||||
}
|
||||
// Snapshot bone runtime
|
||||
const brt_snap_len = snap_bones * @as(u32, 0x118);
|
||||
var brt_snap: [8 * 0x118]u8 = undefined;
|
||||
for (0..brt_snap_len) |i| {
|
||||
brt_snap[i] = @as(*const u8, @ptrFromInt(brt_base + @as(u32, @intCast(i)))).*;
|
||||
}
|
||||
// Clear sync so SSE doesn't early-exit
|
||||
@as(*align(1) u32, @ptrFromInt(this + 0x40)).* = 0;
|
||||
// Run SSE
|
||||
transformMatrix4x4_SSE(this, mat1, mat2, mat3, mat4);
|
||||
// Compare
|
||||
var first_diff: ?u32 = null;
|
||||
var diff_count: u32 = 0;
|
||||
var bi: u32 = 0;
|
||||
while (bi < snap_bones) : (bi += 1) {
|
||||
var fi: u32 = 0;
|
||||
while (fi < 16) : (fi += 1) {
|
||||
const off = bi * 0x40 + fi * 4;
|
||||
const ref_val = @as(u32, snap[off]) | (@as(u32, snap[off + 1]) << 8) | (@as(u32, snap[off + 2]) << 16) | (@as(u32, snap[off + 3]) << 24);
|
||||
const sse_val = hook.readMem(u32, bout + off);
|
||||
if (ref_val != sse_val) {
|
||||
diff_count += 1;
|
||||
if (first_diff == null and diff_count <= 3) {
|
||||
first_diff = off;
|
||||
log.fmt("DIFF bone[{d}][{d}]: REF=0x{x:0>8} SSE=0x{x:0>8}\n", .{ bi, fi, ref_val, sse_val });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Compare bone runtime state
|
||||
var brt_diffs: u32 = 0;
|
||||
var first_brt_off: u32 = 0;
|
||||
var first_brt_ref: u32 = 0;
|
||||
var first_brt_sse: u32 = 0;
|
||||
{
|
||||
var bi2: u32 = 0;
|
||||
while (bi2 < snap_bones) : (bi2 += 1) {
|
||||
var off: u32 = 0;
|
||||
while (off < 0x118) : (off += 4) {
|
||||
const snap_off = bi2 * 0x118 + off;
|
||||
const ref_v = @as(u32, brt_snap[snap_off]) | (@as(u32, brt_snap[snap_off + 1]) << 8) | (@as(u32, brt_snap[snap_off + 2]) << 16) | (@as(u32, brt_snap[snap_off + 3]) << 24);
|
||||
const sse_v = hook.readMem(u32, brt_base + bi2 * 0x118 + off);
|
||||
if (ref_v != sse_v) {
|
||||
brt_diffs += 1;
|
||||
if (brt_diffs <= 3) {
|
||||
if (brt_diffs == 1) {
|
||||
first_brt_off = off;
|
||||
first_brt_ref = ref_v;
|
||||
first_brt_sse = sse_v;
|
||||
}
|
||||
log.fmt(" BRT bone[{d}]+0x{x:0>3}: REF=0x{x:0>8} SSE=0x{x:0>8}\n", .{ bi2, off, ref_v, sse_v });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (diff_count > 0 or brt_diffs > 0) {
|
||||
log.fmt(" out diffs: {d}, brt diffs: {d} in {d} bones\n", .{ diff_count, brt_diffs, snap_bones });
|
||||
} else {
|
||||
log.fmt("MATCH: {d} bones (out+brt) identical\n", .{snap_bones});
|
||||
}
|
||||
diag_cmp_count += 1;
|
||||
} else {
|
||||
transformMatrix4x4_SSE(this, mat1, mat2, mat3, mat4);
|
||||
}
|
||||
} else {
|
||||
transformMatrix4x4_SSE(this, mat1, mat2, mat3, mat4);
|
||||
}
|
||||
transformMatrix4x4_SSE(this, mat1, mat2, mat3, mat4);
|
||||
} else {
|
||||
transformMatrix4x4_REF(this, mat1, mat2, mat3, mat4);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user