Nugget
Loading...
Searching...
No Matches
raster-expected-phase18.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-18 expected hardware-truth values for the affine UV
30// stride-magnitude sweep.
31//
32// Triangle T_AXIS_K is A=(5, 5)/(0, 0) B=(15, 5)/(K, 0) C=(5, 15)/(0, K).
33// Per-axis stride dU/dx = dV/dy = K/10. Probes are five fixed screen
34// positions shared across all K:
35//
36// P_VERTEX (5, 5) u_real = 0, v_real = 0
37// P_TOP_NEAR (6, 5) u_real = K/10, v_real = 0
38// P_LEFT_NEAR (5, 6) u_real = 0, v_real = K/10
39// P_INTERIOR (8, 8) u_real = 3K/10, v_real = 3K/10
40// P_TOP_FAR (12, 5) u_real = 7K/10, v_real = 0
41//
42// Bias model (phase-17 HARDWARE FINDING, phase-18 confirmed):
43// u_sampled = ((u_real << 16) + 0x8000) >> 16 = floor(u_real + 0.5)
44// i.e. constant +0.5 LSB bias before truncate-to-int, independent of
45// dU/dx magnitude. Phase-17 confirmed this at AR_COMPRESS (dV/dy=0.3)
46// and AR_STRETCH (dU/dx=3). Phase-18 widens the K sweep to
47// K in {1, 2, 3, 5, 8, 16}; SCPH-5501 returned 30/30 matching the
48// model's predictions, so the bias is uniform across per-axis
49// stride magnitudes covering 0.1 .. 1.6 texels-per-screen-pixel.
50//
51// Texture: phase-17 TEX17 32x32 signature texture, texel(u, v) =
52// vram555(u, v, ((u+v)&31)|1). So expected VRAM at sampled (u, v):
53// vram(u, v) = u | (v << 5) | (((u+v)&31)|1) << 10
54// Sample table (u, v) -> vram:
55// (0, 0) -> 0x0400
56// (1, 0) -> 0x0401
57// (0, 1) -> 0x0420
58// (1, 1) -> 0x0C21
59// (2, 0) -> 0x0C02
60// (0, 2) -> 0x0C40
61// (2, 2) -> 0x1442
62// (4, 0) -> 0x1404
63// (5, 5) -> 0x2CA5
64// (6, 0) -> 0x1C06
65// (11, 0) -> 0x2C0B
66//
67// Status markers:
68// HW_VERIFIED confirmed on SCPH-5501 hardware.
69// HW_TODO sentinel; this probe is uncaptured.
70
71#include "raster-helpers.h"
73
74#define HW_TODO 0xCAFEu
75
76// --------------------------------------------------------------------------
77// K=1 (stride 0.1)
78// P_VERTEX u_real=0.0 v_real=0.0 -> (0, 0)
79// P_TOP_NEAR u_real=0.1 v_real=0.0 -> (0, 0)
80// P_LEFT_NEAR u_real=0.0 v_real=0.1 -> (0, 0)
81// P_INTERIOR u_real=0.3 v_real=0.3 -> (0, 0)
82// P_TOP_FAR u_real=0.7 v_real=0.0 -> (1, 0)
83// --------------------------------------------------------------------------
84
85#define EXPECT_K01_VERTEX 0x0400u /* HW_VERIFIED: UV(0, 0) */
86#define EXPECT_K01_TOP_NEAR 0x0400u /* HW_VERIFIED: UV(0, 0) */
87#define EXPECT_K01_LEFT_NEAR 0x0400u /* HW_VERIFIED: UV(0, 0) */
88#define EXPECT_K01_INTERIOR 0x0400u /* HW_VERIFIED: UV(0, 0) */
89#define EXPECT_K01_TOP_FAR 0x0401u /* HW_VERIFIED: UV(1, 0) */
90
91// --------------------------------------------------------------------------
92// K=2 (stride 0.2)
93// P_VERTEX u_real=0.0 v_real=0.0 -> (0, 0)
94// P_TOP_NEAR u_real=0.2 v_real=0.0 -> (0, 0)
95// P_LEFT_NEAR u_real=0.0 v_real=0.2 -> (0, 0)
96// P_INTERIOR u_real=0.6 v_real=0.6 -> (1, 1)
97// P_TOP_FAR u_real=1.4 v_real=0.0 -> (1, 0)
98// --------------------------------------------------------------------------
99
100#define EXPECT_K02_VERTEX 0x0400u /* HW_VERIFIED: UV(0, 0) */
101#define EXPECT_K02_TOP_NEAR 0x0400u /* HW_VERIFIED: UV(0, 0) */
102#define EXPECT_K02_LEFT_NEAR 0x0400u /* HW_VERIFIED: UV(0, 0) */
103#define EXPECT_K02_INTERIOR 0x0C21u /* HW_VERIFIED: UV(1, 1) */
104#define EXPECT_K02_TOP_FAR 0x0401u /* HW_VERIFIED: UV(1, 0) */
105
106// --------------------------------------------------------------------------
107// K=3 (stride 0.3)
108// P_VERTEX u_real=0.0 v_real=0.0 -> (0, 0)
109// P_TOP_NEAR u_real=0.3 v_real=0.0 -> (0, 0)
110// P_LEFT_NEAR u_real=0.0 v_real=0.3 -> (0, 0)
111// P_INTERIOR u_real=0.9 v_real=0.9 -> (1, 1)
112// P_TOP_FAR u_real=2.1 v_real=0.0 -> (2, 0)
113// --------------------------------------------------------------------------
114
115#define EXPECT_K03_VERTEX 0x0400u /* HW_VERIFIED: UV(0, 0) */
116#define EXPECT_K03_TOP_NEAR 0x0400u /* HW_VERIFIED: UV(0, 0) */
117#define EXPECT_K03_LEFT_NEAR 0x0400u /* HW_VERIFIED: UV(0, 0) */
118#define EXPECT_K03_INTERIOR 0x0C21u /* HW_VERIFIED: UV(1, 1) */
119#define EXPECT_K03_TOP_FAR 0x0C02u /* HW_VERIFIED: UV(2, 0) */
120
121// --------------------------------------------------------------------------
122// K=5 (stride 0.5 - right at the half-step boundary)
123// P_VERTEX u_real=0.0 v_real=0.0 -> (0, 0)
124// P_TOP_NEAR u_real=0.5 v_real=0.0 -> (1, 0)
125// P_LEFT_NEAR u_real=0.0 v_real=0.5 -> (0, 1)
126// P_INTERIOR u_real=1.5 v_real=1.5 -> (2, 2)
127// P_TOP_FAR u_real=3.5 v_real=0.0 -> (4, 0)
128// --------------------------------------------------------------------------
129
130#define EXPECT_K05_VERTEX 0x0400u /* HW_VERIFIED: UV(0, 0) */
131#define EXPECT_K05_TOP_NEAR 0x0401u /* HW_VERIFIED: UV(1, 0) */
132#define EXPECT_K05_LEFT_NEAR 0x0420u /* HW_VERIFIED: UV(0, 1) */
133#define EXPECT_K05_INTERIOR 0x1442u /* HW_VERIFIED: UV(2, 2) */
134#define EXPECT_K05_TOP_FAR 0x1404u /* HW_VERIFIED: UV(4, 0) */
135
136// --------------------------------------------------------------------------
137// K=8 (stride 0.8 - near 1:1)
138// P_VERTEX u_real=0.0 v_real=0.0 -> (0, 0)
139// P_TOP_NEAR u_real=0.8 v_real=0.0 -> (1, 0)
140// P_LEFT_NEAR u_real=0.0 v_real=0.8 -> (0, 1)
141// P_INTERIOR u_real=2.4 v_real=2.4 -> (2, 2)
142// P_TOP_FAR u_real=5.6 v_real=0.0 -> (6, 0)
143// --------------------------------------------------------------------------
144
145#define EXPECT_K08_VERTEX 0x0400u /* HW_VERIFIED: UV(0, 0) */
146#define EXPECT_K08_TOP_NEAR 0x0401u /* HW_VERIFIED: UV(1, 0) */
147#define EXPECT_K08_LEFT_NEAR 0x0420u /* HW_VERIFIED: UV(0, 1) */
148#define EXPECT_K08_INTERIOR 0x1442u /* HW_VERIFIED: UV(2, 2) */
149#define EXPECT_K08_TOP_FAR 0x1C06u /* HW_VERIFIED: UV(6, 0) */
150
151// --------------------------------------------------------------------------
152// K=16 (stride 1.6 - stretched)
153// P_VERTEX u_real=0.0 v_real=0.0 -> (0, 0)
154// P_TOP_NEAR u_real=1.6 v_real=0.0 -> (2, 0)
155// P_LEFT_NEAR u_real=0.0 v_real=1.6 -> (0, 2)
156// P_INTERIOR u_real=4.8 v_real=4.8 -> (5, 5)
157// P_TOP_FAR u_real=11.2 v_real=0.0 -> (11, 0)
158// --------------------------------------------------------------------------
159
160#define EXPECT_K16_VERTEX 0x0400u /* HW_VERIFIED: UV(0, 0) */
161#define EXPECT_K16_TOP_NEAR 0x0C02u /* HW_VERIFIED: UV(2, 0) */
162#define EXPECT_K16_LEFT_NEAR 0x0C40u /* HW_VERIFIED: UV(0, 2) */
163#define EXPECT_K16_INTERIOR 0x2CA5u /* HW_VERIFIED: UV(5, 5) */
164#define EXPECT_K16_TOP_FAR 0x2C0Bu /* HW_VERIFIED: UV(11, 0) */