Skip to content

PSX3DS v0.2.5 — Real-HW Performance Boost & Texel-Exact PICA200 Sampling

Choose a tag to compare

@codescv codescv released this 11 Nov 05:46
· 8 commits to main since this release

PSX3DS v0.2.5 — Real-Hardware Performance Boost (Eliminate PICA200 Readback/Sync Stalls, Early Scissor Culling, 128-Slot Stale-First TexCache) & Texel-Exact Hardware Sampling

v0.2.5 resolves the two issues reported on real New 3DS hardware running World Soccer Jikkyou Winning Eleven 3 - Final Ver. (Japan) (SLPM_861.62 + SCPH5500.BIN): ~20 FPS real-hardware framerate bottlenecks and display/texture sampling glitches (broken menu text, dotted player shadows, and off-by-one/wrapped polygon texel rows).


English Release Notes

1. Eliminate Per-Frame PICA200 Readback & Re-Upload Stalls on No-Op GP0(0x80) (src/gpu/gpu.c, src/gpu_hw/gpu_citro3d.c)

  • Root Cause: Winning Eleven 3 issues an unmasked self-copy GP0(0x80) (0, 0) -> (0, 0) of 2 x 512 at the end of every frame. Previously this forced hw_sync_to_shadow (C3D_FrameEnd(0) + synchronous C3D_SyncTextureCopy DMA readback + D-cache invalidation + CPU Morton un-swizzle) followed by a CPU tile upload and a second GPU stall on the next frame — two full PICA200 pipeline stalls per frame.
  • Fix: gpu_vram_copy_is_noop() short-circuits unmasked self-copies (sx == dx mod 1024, sy == dy mod 512, check_mask == 0, set_mask == 0) while preserving cycle-accurate command scheduling and full execution when mask bits are active. Masked GP0(0xA0) CPU->VRAM loads now also synchronize destination shadow VRAM before testing mask bit 15.

2. Early Scissor Bounding-Box Culling & Reduced GSPGPU / PICA200 Sync Overhead (src/gpu_hw/gpu_citro3d.c)

  • Early Scissor Culling: Primitives completely outside the active drawing area (~39% of draw calls in Winning Eleven 3 3D matches, including flashing off-screen stadium billboard CLUTs) are now culled at the top of hw_draw() before texture-page decoding, CLUT hashing, or batch breaks. flush_cpu_dirty_if_needed() now tests only the scissor-clipped primitive bounding box.
  • Single Vertex D-Cache Flush per Submission: Vertex ring buffers (expanded to 8192 vertices x 2) now call GSPGPU_FlushDataCache once per C3D_FrameEnd() submission instead of once per batch (eliminating ~360 GSPGPU IPC syscalls per match frame on real 3DS hardware).
  • Stall-Free upload_tex Updates: flush_cpu_dirty_if_needed() now stalls the open GPU frame only if upload_tex was already sampled in that open frame, and flushes D-cache only for the dirty 8-pixel tile-row span instead of the full 1 MiB texture.

3. 128-Slot Lazy TexCache & clut_dirty Victim Priority (src/gpu_hw/gpu_texcache.c, include/psx3ds/gpu_hw.h)

  • Root Cause: Animated palettes rewritten every frame left stale clut_dirty slots in the cache until all slots filled and began evicting clean, active 3D match textures.
  • Fix: Victim selection now recycles free allocated slots, texel_dirty slots, and stale clut_dirty slots before evicting any clean active texture (while keeping A <-> B palette toggles zero-redecode when capacity permits). Capacity is expanded to 128 lazily allocated slots on New 3DS (capped at a 24 MiB LINEAR RAM budget) and 32 slots on Old 3DS (small_mem).

4. Coalesced ARM11 L1 I-Cache Invalidation & Idle Bottom-Screen UI Throttling (src/jit/arm_jit.c, src/platform/3ds/jit_mem_3ds.c, src/platform/3ds/main_3ds.c)

  • Coalesced svc 0x94: jit_compile_at_pc() now cleans D-cache per block (jit_mem_commit_dcache) and executes a single ARM11 L1 I-cache + BTB invalidation (jit_mem_flush_icache) after the entire eager compilation pass (up to 33 blocks) finishes, before returning to native execution.
  • Bottom-Screen UI Throttling: During active gameplay with no new button/touch input, the software-rendered bottom status UI now redraws every 16th frame (~3.75 Hz) instead of every 4th frame, redrawing immediately on any input.

5. Texel-Exact PS1 Hardware Polygon & Sprite Sampling (src/gpu_hw/gpu_citro3d.c)

  • Root Cause: PICA200 samples fragment centers in bottom-up t = 1.0 - v / H texture coordinates under GPU_REPEAT. Polygon vertices (PRIM_TRI / PRIM_QUAD) lacked the PS1 +0.5 texel offset and integer pixel sample alignment, causing v = 0 edges to wrap to row 255, constant/decreasing v to sample row v - 1 (corrupting "Europe Zone" -> "Europe Zore"), and minified polygons to turn player shadows into dotted lines.
  • Fix: Vertex UVs now use 1/16-texel fixed point (HW_UV_SHIFT = 4), the VRAM render-target projection shifts geometry by +7/16 pixel to align PICA200 pixel centers with PS1 integer sample points, set_uv_transform applies a 1/64-texel floor nudge across the flipped t axis, and tri_uv_to_hw applies floor(u + 0.5) with per-triangle (du/dx + du/dy) / 16 gradient compensation. Menus/dialogs now match gpu_soft pixel-for-pixel (0.00% diff) and 3D match scenes match within 0.05% (Gouraud rounding only).

中文更新说明 (v0.2.5)

  1. 大幅优化 New 3DS 实机帧率(消除每帧 GPU 回读停顿与高频同步开销):
    • 跳过无掩码自拷贝 GP0(0x80):《实况足球 3 最终版》在每一帧末尾都会发送 (0,0) -> (0,0) 2x512 的自拷贝指令,旧版会触发整帧 PICA200 同步回读与次帧重传(每帧 2 次 GPU 管线停顿)。现已通过 gpu_vram_copy_is_noop() 直接短路跳过,比赛与菜单实测 readbacks = 0、stalls = 0、ring_wraps = 0。
    • 提前视口裁剪(Early Scissor Culling):在解码纹理页前提前剔除完全落在绘图裁剪区外的图元(剔除《实况足球 3》比赛画面约 39% 的场外无效绘制与场边闪烁广告牌调色板)。
    • 合并顶点缓冲 D-Cache 刷新与 upload_tex 按需同步:每帧提交(C3D_FrameEnd)仅执行 1 次顶点 D-Cache 刷新(消除每帧约 360 次 GSPGPU_FlushDataCache 系统调用),顶点环扩容至 8192;CPU 脏瓦片上传仅在当前未闭合帧已采样过 upload_tex 时才等待同步,且仅刷新脏瓦片所在行区间。
    • 128 槽位纹理缓存与动态调色板优先回收:优先回收已失效的动态调色板(clut_dirty)与脏纹素槽位,绝不驱逐活跃干净纹理(比赛纹理缓存命中率达 99.94%);New 3DS 扩容至 128 槽位(24 MiB 线性内存上限按需分配),Old 3DS 扩容至 32 槽位。
    • 合并 JIT L1 指令缓存刷新与下屏 UI 降频:jit_compile_at_pc 预编译整批代码块后仅执行一次 svc 0x94 全量 I-Cache 刷新;游戏无按键/触控输入时下屏软件 UI 降频至每 16 帧刷新一次。
  2. 彻底修复多边形与 UI 贴图采样显示错误:
    • 引入 1/16 纹素定点 UV、VRAM 投影 +7/16 像素对齐、翻转 t 轴 1/64 纹素向下取整偏置,以及三角形梯度补偿 tri_uv_to_hw,精确还原 PS1 硬件整数像素采样与 floor(u + 0.5) 纹素寻址。
    • 彻底修复了菜单文字错位断裂(如 "Europe Zone" 误显示为 "Europe Zore")、v = 0 贴图边缘回绕至第 255 行、球员脚下阴影变成断续黑点线、以及带掩码 GP0(0xA0) 写入未先行同步目标区域等问题。