Nugget
Loading...
Searching...
No Matches
raster-expected-phase20.h
Go to the documentation of this file.
1/*
2
3MIT License
4
5Copyright (c) 2026 PCSX-Redux authors
6
7Permission is hereby granted, free of charge, to any person obtaining a copy
8of this software and associated documentation files (the "Software"), to deal
9in the Software without restriction, including without limitation the rights
10to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11copies of the Software, and to permit persons to whom the Software is
12furnished to do so, subject to the following conditions:
13
14The above copyright notice and this permission notice shall be included in all
15copies or substantial portions of the Software.
16
17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23SOFTWARE.
24
25*/
26
27#pragma once
28
29// Phase-20 expected hardware-truth values for the affine UV
30// row-walk drift sweep.
31//
32// Five triangles T_LONG_K (K in {1, 3, 5, 8, 16}), identical 10x20
33// screen footprint:
34// A=(5, 5)/(0, 0) B=(15, 5)/(K, 0) C=(5, 25)/(0, 2K)
35// per-axis stride dU/dx = dV/dy = K/10 (same as phase-18). Probes
36// at x=7 (column under the vertical AC edge, row-start X always
37// integer) and y in {5, 8, 11, 14, 17, 20}. Y=20 is 15 rows below
38// the top edge - five rows deeper than the deepest probe in
39// phases 17-19.
40//
41// Predictions under phases-17/18/19 confirmed model
42// u_sampled = floor(u_real + 0.5), v_sampled = floor(v_real + 0.5)
43// with u_real = (K/10) * (x - 5), v_real = (K/10) * (y - 5).
44// If hardware's edge walker drifts over long Y traversal, deep
45// probes (y=14, 17, 20) surface the deviation.
46//
47// Texture: phase-17 TEX17. Probe decoding:
48// vram(u, v) = u | (v << 5) | (((u + v) & 31) | 1) << 10
49//
50// Status markers:
51// HW_VERIFIED confirmed on SCPH-5501 hardware.
52// HW_TODO sentinel; this probe is uncaptured.
53
54#include "raster-helpers.h"
56
57#define HW_TODO 0xCAFEu
58
59// --------------------------------------------------------------------------
60// K=01 (dU/dx = dV/dy = 0.1)
61// u_real(7, *) = 0.2 -> u_sampled = 0
62// v_real(7, y) = 0.1*(y-5): 0.0, 0.3, 0.6, 0.9, 1.2, 1.5 at y=5,8,11,14,17,20
63// v_sampled = floor(v_real + 0.5): 0, 0, 1, 1, 1, 2
64// --------------------------------------------------------------------------
65
66#define EXPECT_LONG_K01_Y05 0x0400u /* HW_VERIFIED: UV(0, 0) */
67#define EXPECT_LONG_K01_Y08 0x0400u /* HW_VERIFIED: UV(0, 0) */
68#define EXPECT_LONG_K01_Y11 0x0420u /* HW_VERIFIED: UV(0, 1) */
69#define EXPECT_LONG_K01_Y14 0x0420u /* HW_VERIFIED: UV(0, 1) */
70#define EXPECT_LONG_K01_Y17 0x0420u /* HW_VERIFIED: UV(0, 1) */
71#define EXPECT_LONG_K01_Y20 0x0420u /* HW_VERIFIED: UV(0, 1) - row-walk drift: stride 0.1 truncates to 6553/0x10000 in 16.16, 15 steps under-estimates v_real to 1.4999 (< 1.5), floor(1.9999) = 1 instead of the ideal model's 2 */
72
73// --------------------------------------------------------------------------
74// K=03 (dU/dx = dV/dy = 0.3)
75// u_real(7, *) = 0.6 -> u_sampled = 1
76// v_real(7, y) = 0.3*(y-5): 0, 0.9, 1.8, 2.7, 3.6, 4.5
77// v_sampled: 0, 1, 2, 3, 4, 5
78// --------------------------------------------------------------------------
79
80#define EXPECT_LONG_K03_Y05 0x0401u /* HW_VERIFIED: UV(1, 0) */
81#define EXPECT_LONG_K03_Y08 0x0C21u /* HW_VERIFIED: UV(1, 1) */
82#define EXPECT_LONG_K03_Y11 0x0C41u /* HW_VERIFIED: UV(1, 2) */
83#define EXPECT_LONG_K03_Y14 0x1461u /* HW_VERIFIED: UV(1, 3) */
84#define EXPECT_LONG_K03_Y17 0x1481u /* HW_VERIFIED: UV(1, 4) */
85#define EXPECT_LONG_K03_Y20 0x1481u /* HW_VERIFIED: UV(1, 4) - row-walk drift: stride 0.3 truncates to 19660/0x10000, 15 steps under-estimates v_real to 4.4997 (< 4.5), floor(4.9997) = 4 instead of the ideal model's 5 */
86
87// --------------------------------------------------------------------------
88// K=05 (dU/dx = dV/dy = 0.5)
89// u_real(7, *) = 1.0 -> u_sampled = 1
90// v_real(7, y) = 0.5*(y-5): 0, 1.5, 3.0, 4.5, 6.0, 7.5
91// v_sampled: 0, 2, 3, 5, 6, 8
92// --------------------------------------------------------------------------
93
94#define EXPECT_LONG_K05_Y05 0x0401u /* HW_VERIFIED: UV(1, 0) */
95#define EXPECT_LONG_K05_Y08 0x0C41u /* HW_VERIFIED: UV(1, 2) */
96#define EXPECT_LONG_K05_Y11 0x1461u /* HW_VERIFIED: UV(1, 3) */
97#define EXPECT_LONG_K05_Y14 0x1CA1u /* HW_VERIFIED: UV(1, 5) */
98#define EXPECT_LONG_K05_Y17 0x1CC1u /* HW_VERIFIED: UV(1, 6) */
99#define EXPECT_LONG_K05_Y20 0x2501u /* HW_VERIFIED: UV(1, 8) */
100
101// --------------------------------------------------------------------------
102// K=08 (dU/dx = dV/dy = 0.8)
103// u_real(7, *) = 1.6 -> u_sampled = 2
104// v_real(7, y) = 0.8*(y-5): 0, 2.4, 4.8, 7.2, 9.6, 12.0
105// v_sampled: 0, 2, 5, 7, 10, 12
106// --------------------------------------------------------------------------
107
108#define EXPECT_LONG_K08_Y05 0x0C02u /* HW_VERIFIED: UV(2, 0) */
109#define EXPECT_LONG_K08_Y08 0x1442u /* HW_VERIFIED: UV(2, 2) */
110#define EXPECT_LONG_K08_Y11 0x1CA2u /* HW_VERIFIED: UV(2, 5) */
111#define EXPECT_LONG_K08_Y14 0x24E2u /* HW_VERIFIED: UV(2, 7) */
112#define EXPECT_LONG_K08_Y17 0x3542u /* HW_VERIFIED: UV(2, 10) */
113#define EXPECT_LONG_K08_Y20 0x3D82u /* HW_VERIFIED: UV(2, 12) */
114
115// --------------------------------------------------------------------------
116// K=16 (dU/dx = dV/dy = 1.6)
117// u_real(7, *) = 3.2 -> u_sampled = 3
118// v_real(7, y) = 1.6*(y-5): 0, 4.8, 9.6, 14.4, 19.2, 24.0
119// v_sampled: 0, 5, 10, 14, 19, 24
120// --------------------------------------------------------------------------
121
122#define EXPECT_LONG_K16_Y05 0x0C03u /* HW_VERIFIED: UV(3, 0) */
123#define EXPECT_LONG_K16_Y08 0x24A3u /* HW_VERIFIED: UV(3, 5) */
124#define EXPECT_LONG_K16_Y11 0x3543u /* HW_VERIFIED: UV(3, 10) */
125#define EXPECT_LONG_K16_Y14 0x45C3u /* HW_VERIFIED: UV(3, 14) */
126#define EXPECT_LONG_K16_Y17 0x5E63u /* HW_VERIFIED: UV(3, 19) */
127#define EXPECT_LONG_K16_Y20 0x6F03u /* HW_VERIFIED: UV(3, 24) */