Skip to content

Add best practice: Real-time 2D sprite blending and alpha modulation with AMMX - #52

Open
Rudi7503 wants to merge 1 commit into
ApolloTeam-dev:mainfrom
Rudi7503:feature/fast-alpha-blitting-pmula
Open

Rudi7503 wants to merge 1 commit into
ApolloTeam-dev:mainfrom
Rudi7503:feature/fast-alpha-blitting-pmula

Conversation

@Rudi7503

Copy link
Copy Markdown

Summary

This PR adds a best-practice guide (core/best-practices/fast-alpha-blitting-pmula.md) documenting real-time 2D sprite blending, saturating math, and alpha modulation techniques using 64-bit AMMX instructions, derived from game engine bottlenecks (such as the native Hurrican port).

Key Insights & Hardware Evidence

Measured on physical Vampire V4 Standalone hardware (Core 11350 @ 92 MHz) using the Harness v6 benchmark suite:

Blit / Blend Operation Kernel ID Net Cycles / Iteration Fill Rate (92 MHz) Architectural Feature
Ultra-Fast Qword Blend BLT-018 0.6 cyc 1,226.7 Mpx/s Saturating SIMD add, > 1.2 GPx/s throughput
Color-Key Transparency Filter BLT-013 1.6 cyc 460.0 Mpx/s 1-cycle parallel color key match for 4/8 pixels
Alpha Blit Basic Step BLT-006 1.6 cyc 460.0 Mpx/s Parallel channel modulation
Masked Qword Blit BLT-012 2.6 cyc 283.1 Mpx/s Tail masking via storeilm
Subtractive Blend (Shadows) BLT-014 4.6 cyc 160.0 Mpx/s Saturating vector subtraction psubusw
Multiplicative Blend (Darkening) BLT-015 4.6 cyc 160.0 Mpx/s Fixed-point darkening
Particle Shading (8 Pixels) BLT-016 12.6 cyc 58.4 Mpx/s 8 particles rendered simultaneously
  • Zero Blitter-Wait Stalls: Replaces synchronous custom-chip blitter polling with asynchronous L1-cached AMMX CPU streaming directly to video RAM.
  • Saturating Vector Math: Utilizes paddusw and psubusw to eliminate branch mispredictions when clamping color components to $FFFF and $0000.
  • Validation: Conforms to AKB schema, passes check_links.py, check_frontmatter.py, and snippet compiles with vasmm68k_mot 2.0f.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant