SH2ZAM·SEGA SATURN / MATH LABView source ↗

COMPILED FOR SH-2

Saturn math.
Before and after.

The same mesh, with and without SH2ZAM.

Sega Saturn with turquoise flexing arms above the word GAINZ

Ring world

Loading mesh…

SH-2 transform cost

Loading evidence…
Without SH2ZAM
With SH2ZAM

PLAIN FIXED-POINT C

—modeled cycles / mesh— cycles / vertex

SH2ZAM · NATIVE MAC.L

—modeled cycles / mesh— cycles / vertex

TRANSFORM COST SAVED

—Awaiting model evidence

Checking model evidence…

Compiled SH-2 code · per-matrix setup included · instruction model, not a console timing capture.

Same geometry. Checked precision.

A low-poly planet and concentric rings, transformed in lockstep.

Float32 referenceSH2ZAM output
12 SECOND LOOPVISUAL PRECISION CHECK
Loading visual check…Float error — world unitsScreen offset —

The preview runs in your browser. Performance figures above come from the recorded SH-2 model.

Optimize the whole workload

Awaiting native capture

Reuse one rotation across a mesh, index repeated spatial queries, and improve the existing scalar kernels. Every cost below includes setup and output writes on the same compiled SH-2 model.

RECORDED CONTROL

—modeled cycles / workloadAwaiting native evidence

NEW IMPLEMENTATION

—modeled cycles / workloadSetup included

WORKLOAD COST SAVED

—Not measured

No validated workload capture is available yet.

Every recorded control and implementation
ImplementationCycles / workloadCycles / itemSelected control / path
Awaiting native capture

Only exact, validated native observations will appear here.

Every workload, including slower cases

The overview uses each case’s fastest recorded control. Rotation uses the new optional MAC.L batch; spatial queries use the index. Scalar kernels compare against the latest prior revision, 3374d77.

WorkloadProfile / sizeFastest controlNew cyclesChange
Not measured
Raw samples, precision & build provenance

All seven changing-input samples, in recorded order

One SH-2 CPU, flat RAM. The model excludes cache and bus delays, pipeline and multiplier contention, interrupts, peripherals, and second-CPU traffic. No browser timings, Saturn milliseconds, or FPS estimates are used.

Math library improvements

Awaiting native capture

The existing math APIs, before and after optimization. Both versions are compiled for SH-2. This compares library revisions; the transform comparison above uses an independent baseline.

Modeled cycles / call
Input profilePrior SH2ZAM 10786b6Optimized SH2ZAMCost changePrecision
Bounded——Not measuredAwaiting checks
Tiny——Not measuredAwaiting checks
Full range——Not measuredAwaiting checks

Awaiting a validated native SH-2 capture. No math performance figures are available yet.

What changes in your code

Integration examples ↗

Without SH2ZAM · one fixed-point row

// Bounds qualified for this matrix.
int64_t sum =
    (int64_t)row[0] * x
  + (int64_t)row[1] * y
  + (int64_t)row[2] * z;
// SH-2 arithmetic shift floors once.
out = (int32_t)((sum >> 16) + row[3]);
Complete baseline source ↗

With SH2ZAM · optional native MAC.L

sh2z_mesh_view_t mesh;
sh2z_transform_plan_t plan;

// Once for an immutable mesh:
if (!sh2z_mesh_view_init(&mesh, vertices, count))
    return false;

// Each new matrix:
if (!sh2z_transform_plan_init(&plan, &mesh, &matrix))
    return false;
return sh2z_transform_plan_execute_mac(
    out, &plan, 0, count);
API and contracts ↗

MAC.L is an optional experimental API. It uses native accumulation when bounds qualify and SR.S is clear; otherwise it uses the prepared fallback.

Results & measurement details

Every implementation receives the same quantized vertices and matrices. Costs are medians across 21 poses; matrix qualification is included once per whole mesh. Mesh scanning and input conversion happen once, outside the measured transform.

ImplementationCycles / meshCycles / vertexBaseline / path
Plain fixed-point C without SH2ZAM———
Software float without SH2ZAM———
SH2ZAM prepared C———
SH2ZAM native MAC.L optional API———
SH2ZAM native DMULS.L optional API———
SH2ZAM prior safe batch———

The fixed-point baseline uses independent C arithmetic with three unrolled rows, cached matrix values and one rounding step per dot product. It does not call SH2ZAM. All native paths are built with the same SH-2 compiler and optimization flags.

The instruction model uses flat RAM. It excludes cache and bus delays, pipeline and multiplier contention, interrupts, peripherals and the second CPU. These figures describe modeled transform work; they are not whole-game FPS or measured Saturn milliseconds.

Physical SaturnNot measuredConsole benchmark ↗