mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-22 18:59:04 +02:00
Without clip control, OpenGL maps clip z -w..w to window depth 0..1, and the PSP's Z 0 at z/w = -1 isn't reproduced exactly by the rasterizer (see the previous commit). Now clip z is 0..w everywhere, which without clip control lands in window depth 0.5..1. Z 0 is z/w = 0, exact. Everything that writes or reads window depth directly uses 0.5 + 0.5 * depth (ShaderLanguageDesc::depthHalfRange, DepthToWindow / DepthFromWindow): depth clears, fragment depth writes, depth uploads, depth readbacks (including the debugger's) and depal from depth. Hardware clipping now only happens below -w, so a clip plane at Z 0 takes over unless depth clamp is on, which ShaderManagerGLES passes as a min Z of -1. The hardware clamp works in window depth and can't clamp at 0.5, so clamping moves to the fragment shader. That shader wrote Z / 65535 against Z / 65536 for every other draw, which broke depth ties with them; it now writes Z / 65536. Fixes the Burnout Dominator lens flare on macOS OpenGL. 0.5..1 costs a bit of depth precision, which shows on a float depth buffer (ATV Offroad Fury Pro is 6% worse here), less so on D24. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>