bench: add remaining silicon functions, total 38 benchmarks

Added 8 more silicon SSE functions to benchmark: normalizeVec3,
testOBBFrustum, calculateSinCos, translateBoundingVol, addToColorAccum,
packParticleColor, setParticleAlpha, and addVec3ToAccumulator (export fn).

Notable results from new entries:
  packParticleColor: 6.8x (109->16) MISMATCH -- alpha byte diff
  setParticleAlpha:  3.4x (24->7)
  calculateSinCos:   3.0x (138->45)
  normalizeVec3:     1.8x (18->10)
  testOBBFrustum:    1.3x (107->81)

3 MISMATCHes total (mulMat3x4, mulMat3x4InPlace, packParticleColor)
need correctness investigation -- likely matrix layout and struct
byte-order differences.
This commit is contained in:
MarcelineVQ
2026-03-15 12:08:59 -07:00
parent 55b4931fcb
commit 7c88423a41
2 changed files with 184 additions and 0 deletions
+46
View File
@@ -288,6 +288,52 @@ export fn si_normalizeVec3InPlace(vec: u32) void {
}
}
// --- 0x71BC70: addVec3ToAccumulator (136K/7.5s) ---
// Adds vec3 to this+0x54, adds scaled copy (global at 0x81207C) to diagonal at +0x84/+0xA8/+0xCC
export fn si_addVec3ToAccumulator(this: u32, vec: u32, scale_addr: u32) void {
const obj: [*]f32 = @ptrFromInt(this);
const v: [*]const f32 = @ptrFromInt(vec);
const scale: f32 = @as(*const f32, @ptrFromInt(scale_addr)).*;
obj[21] += v[0];
obj[22] += v[1];
obj[23] += v[2];
obj[33] += v[0] * scale;
obj[42] += v[1] * scale;
obj[51] += v[2] * scale;
}
// --- 0x71BF60: addToColorAccumulator (10K/7.5s) ---
// Accumulates color vec3 into this+0x6C (float offset 27)
export fn si_addToColorAccumulator(this: u32, color: u32) void {
const obj: [*]f32 = @ptrFromInt(this);
const c: [*]const f32 = @ptrFromInt(color);
obj[27] += c[0];
obj[28] += c[1];
obj[29] += c[2];
}
// --- 0x7B7A80: packParticleColor (2K/7.5s) ---
// Reads alpha at obj+0x12F, packs ARGB into u32 at obj+0x12C
export fn si_packParticleColor(obj: u32, r_bits: u32, g_bits: u32, b_bits: u32) void {
const base: [*]u8 = @ptrFromInt(obj);
const out: *align(1) u32 = @ptrCast(base + 0x12C);
const alpha = base[0x12F];
const r: f32 = @bitCast(r_bits);
const g: f32 = @bitCast(g_bits);
const b: f32 = @bitCast(b_bits);
const rb: u8 = @intFromFloat(@min(@max(r * 255.0, 0.0), 255.0));
const gb: u8 = @intFromFloat(@min(@max(g * 255.0, 0.0), 255.0));
const bb: u8 = @intFromFloat(@min(@max(b * 255.0, 0.0), 255.0));
out.* = @as(u32, alpha) << 24 | @as(u32, rb) << 16 | @as(u32, gb) << 8 | @as(u32, bb);
}
// --- 0x7B7B10: setParticleAlpha (2K/7.5s) ---
export fn si_setParticleAlpha(obj: u32, alpha_bits: u32) void {
const base: [*]u8 = @ptrFromInt(obj);
const alpha: f32 = @bitCast(alpha_bits);
base[0x12F] = @intFromFloat(@min(@max(alpha * 255.0, 0.0), 255.0));
}
// --- 0x602630: vec3Dot ---
export fn si_vec3Dot(a: u32, b: u32) f64 {
const va: [*]const f32 = @ptrFromInt(a);