Nugget
Loading...
Searching...
No Matches
raster-expected-phase22.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-22 expected hardware-truth values for SLANTED gouraud color
30// interpolation.
31//
32// Coverage gap closed: phase-7 characterizes gouraud color on
33// AXIS-ALIGNED triangles (apex at the origin, one vertical + one
34// horizontal edge). phase-3 characterizes SLANTED triangles but only
35// FLAT shaded. phase-17..20 characterize SLANTED triangles but only
36// TEXTURED. None of them exercises a slanted, untextured, gouraud
37// triangle - where the per-row left-edge color seed lands at a
38// FRACTIONAL x and the horizontal span delta both accumulate, so their
39// truncations compound. That primitive is what this phase oracles.
40//
41// Naming: SG = Slanted Gouraud. Probe macros are SG<case>_<x>_<y>; the
42// few that sit exactly on a drawn vertex are SG<case>_V<k>_<x>_<y>.
43// All probes are interior or on a covered vertex - none target a
44// top-left-excluded (bottom/right) vertex, which would read sentinel.
45//
46// Color encoding: VRAM 5:5:5 with R at bits 4:0, G at bits 9:5, B at
47// bits 14:10, mask at bit 15. Values below are VRAM-side as read back
48// via GP0(0xC0). Dither OFF throughout.
49//
50// HW_VERIFIED status:
51// All values below are silicon truth, captured by running this
52// .ps-exe on real PS1 hardware via the ps1-hwdev farm and grepping
53// the ^OBS lines (dither off; the dither-off gouraud path agrees
54// across GPU generations). The SG_AB values additionally cross-check
55// the 24 pixels independently measured during the libgouraud A/B work.
56
57// --------------------------------------------------------------------------
58// SG_AB - cross-check triangle reused from the libgouraud A/B work.
59// v0=(20,20) R=255, v1=(200,60) G=255, v2=(90,230) B=255.
60// Command colors are full 8-bit 0xFF (NOT the rasterCmdColor
61// 5-bit<<3 = 0xF8 idiom the other cases use) so these probes
62// reproduce the exact triangle the 24 silicon pixels were captured
63// from. The two encode the same 5-bit channel at the vertices
64// (0xFF>>3 == 0xF8>>3 == 31) but the gouraud interpolant start value
65// differs (255 vs 248), which can move an interior pixel by the very
66// LSB this phase measures - so the cross-check must use 0xFF.
67// --------------------------------------------------------------------------
68#define SG_AB_26_22 0x003e
69#define SG_AB_24_23 0x001f
70#define SG_AB_26_23 0x003e
71#define SG_AB_27_24 0x003e
72#define SG_AB_30_24 0x003d
73#define SG_AB_32_24 0x005d
74#define SG_AB_37_24 0x007c
75#define SG_AB_27_25 0x003e
76#define SG_AB_32_25 0x005d
77#define SG_AB_22_26 0x001f
78#define SG_AB_27_26 0x003e
79#define SG_AB_35_26 0x005d
80#define SG_AB_25_27 0x041e
81#define SG_AB_28_27 0x003d
82#define SG_AB_33_27 0x005d
83#define SG_AB_38_27 0x007c
84#define SG_AB_41_27 0x007b
85#define SG_AB_43_27 0x009b
86#define SG_AB_49_27 0x00ba
87#define SG_AB_28_28 0x043d
88#define SG_AB_29_28 0x043d
89#define SG_AB_30_28 0x043d
90#define SG_AB_33_28 0x005d
91#define SG_AB_49_28 0x00ba
92
93// --------------------------------------------------------------------------
94// SG1 - medium slanted RGB triangle.
95// v0=(8,4) R=31, v1=(58,22) G=31, v2=(22,52) B=31. Interior probes.
96// --------------------------------------------------------------------------
97#define SG1_29_26 0x294a
98#define SG1_24_24 0x28ed
99#define SG1_36_28 0x29c6
100#define SG1_20_20 0x20b1
101#define SG1_30_32 0x3926
102#define SG1_40_24 0x1a46
103
104// --------------------------------------------------------------------------
105// SG2 - flatter slanted RGB triangle, apex-low.
106// v0=(40,6) R=31, v1=(70,48) G=31, v2=(6,40) B=31. v2 is a covered
107// (left) vertex - vertex-exactness probe.
108// --------------------------------------------------------------------------
109#define SG2_V2_6_40 0x7c00
110#define SG2_39_31 0x294a
111#define SG2_30_30 0x38ca
112#define SG2_48_32 0x15ca
113#define SG2_40_20 0x14d3
114#define SG2_20_34 0x5466
115
116// --------------------------------------------------------------------------
117// SG_R - R-only slanted gradient. Apex R=31, base verts R=0. Isolates a
118// single channel's accumulator on a slanted shape.
119// v0=(6,6) R=31, v1=(54,18) R=0, v2=(18,50) R=0.
120// --------------------------------------------------------------------------
121#define SGR_8_8 0x001c
122#define SGR_26_25 0x000a
123#define SGR_16_16 0x0014
124#define SGR_22_28 0x000a
125#define SGR_31_20 0x000a
126#define SGR_13_22 0x0012
127
128// --------------------------------------------------------------------------
129// SG3 - narrow / steep slanted triangle.
130// v0=(30,4) R=31, v1=(40,50) G=31, v2=(20,46) B=31. v2 is a covered
131// (left) vertex - vertex-exactness probe.
132// --------------------------------------------------------------------------
133#define SG3_V2_20_46 0x7c00
134#define SG3_30_33 0x294a
135#define SG3_30_22 0x18d2
136#define SG3_31_40 0x2dc5
137#define SG3_28_30 0x30cc
138#define SG3_33_38 0x1e07