Nugget
Loading...
Searching...
No Matches
raster-expected-phase2.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-2 expected hardware-truth values.
30//
31// Same workflow as phase-1's raster-expected.h: best-guess placeholders
32// tagged HW_TODO. Run on hardware via Unirom + psxup.py, grep `^OBS` on
33// the captured log for ground truth, patch these macros, commit. Redux
34// runs then produce the soft-renderer punch list as cester FAIL lines.
35
36#include "raster-helpers.h"
37
38// --------------------------------------------------------------------------
39// Line endpoints suite
40// --------------------------------------------------------------------------
41//
42// Best-guess model: PS1 GP0(40) line draws Bresenham with endpoint
43// INCLUSIVE (both start and end pixels). This is the conventional choice
44// for raster lines on early-90s silicon.
45
46// Horizontal 1-pixel line: vertices (5, 10), (10, 10). Expect pixels
47// (5,10), (6,10), (7,10), (8,10), (9,10), (10,10) drawn (6 pixels).
48#define EXPECT_LINE_H_PIXEL_4_10 RASTER_SENTINEL /* HW_VERIFIED 2026-05-15 before start */
49#define EXPECT_LINE_H_PIXEL_5_10 RASTER_VRAM_GREEN /* HW_VERIFIED 2026-05-15 start point */
50#define EXPECT_LINE_H_PIXEL_7_10 RASTER_VRAM_GREEN /* HW_VERIFIED 2026-05-15 interior */
51#define EXPECT_LINE_H_PIXEL_10_10 RASTER_VRAM_GREEN /* HW_VERIFIED 2026-05-15 end point (inclusive?) */
52#define EXPECT_LINE_H_PIXEL_11_10 RASTER_SENTINEL /* HW_VERIFIED 2026-05-15 past end */
53#define EXPECT_LINE_H_PIXEL_5_11 RASTER_SENTINEL /* HW_VERIFIED 2026-05-15 below line */
54
55// Vertical line: vertices (10, 5), (10, 10).
56#define EXPECT_LINE_V_PIXEL_10_4 RASTER_SENTINEL /* HW_VERIFIED 2026-05-15 */
57#define EXPECT_LINE_V_PIXEL_10_5 RASTER_VRAM_RED /* HW_VERIFIED 2026-05-15 start */
58#define EXPECT_LINE_V_PIXEL_10_7 RASTER_VRAM_RED /* HW_VERIFIED 2026-05-15 interior */
59#define EXPECT_LINE_V_PIXEL_10_10 RASTER_VRAM_RED /* HW_VERIFIED 2026-05-15 end (inclusive?) */
60#define EXPECT_LINE_V_PIXEL_10_11 RASTER_SENTINEL /* HW_VERIFIED 2026-05-15 past end */
61
62// Diagonal +45 deg (slope 1): (5, 5), (10, 10). Bresenham steps both
63// axes one per step; expect (5,5),(6,6),(7,7),(8,8),(9,9),(10,10).
64#define EXPECT_LINE_D45_PIXEL_5_5 RASTER_VRAM_BLUE /* HW_VERIFIED 2026-05-15 start */
65#define EXPECT_LINE_D45_PIXEL_7_7 RASTER_VRAM_BLUE /* HW_VERIFIED 2026-05-15 interior */
66#define EXPECT_LINE_D45_PIXEL_10_10 RASTER_VRAM_BLUE /* HW_VERIFIED 2026-05-15 end */
67#define EXPECT_LINE_D45_PIXEL_5_6 RASTER_SENTINEL /* HW_VERIFIED 2026-05-15 off-diagonal */
68#define EXPECT_LINE_D45_PIXEL_6_5 RASTER_SENTINEL /* HW_VERIFIED 2026-05-15 off-diagonal */
69
70// Diagonal -45 deg (slope -1): (5, 10), (10, 5).
71#define EXPECT_LINE_DN45_PIXEL_5_10 RASTER_VRAM_WHITE /* HW_VERIFIED 2026-05-15 start */
72#define EXPECT_LINE_DN45_PIXEL_7_8 RASTER_VRAM_WHITE /* HW_VERIFIED 2026-05-15 interior */
73#define EXPECT_LINE_DN45_PIXEL_10_5 RASTER_VRAM_WHITE /* HW_VERIFIED 2026-05-15 end */
74
75// Zero-length line: start == end. Best-guess: hardware draws the single
76// start pixel.
77#define EXPECT_LINE_ZERO_PIXEL_20_20 RASTER_VRAM_RED /* HW_VERIFIED 2026-05-15 */
78#define EXPECT_LINE_ZERO_PIXEL_21_20 RASTER_SENTINEL /* HW_VERIFIED 2026-05-15 */
79
80// Shallow line (more horizontal than vertical): (0, 0), (10, 3). Major
81// axis is X; Bresenham steps X each iter, Y on accumulator overflow.
82// Best-guess pixel set under standard Bresenham:
83// (0,0)(1,0)(2,1)(3,1)(4,1)(5,2)(6,2)(7,2)(8,2)(9,3)(10,3)
84// - 11 pixels (endpoint inclusive on both ends).
85#define EXPECT_LINE_SHALLOW_PIXEL_0_0 RASTER_VRAM_GREEN /* HW_VERIFIED 2026-05-15 start */
86#define EXPECT_LINE_SHALLOW_PIXEL_5_2 RASTER_VRAM_GREEN /* HW_VERIFIED 2026-05-15 midpoint */
87#define EXPECT_LINE_SHALLOW_PIXEL_10_3 RASTER_VRAM_GREEN /* HW_VERIFIED 2026-05-15 end */
88#define EXPECT_LINE_SHALLOW_PIXEL_2_0 RASTER_SENTINEL /* HW_VERIFIED 2026-05-15 Bresenham picks y=1 here */
89
90// --------------------------------------------------------------------------
91// Mask-bit suite
92// --------------------------------------------------------------------------
93//
94// GP0(E6) sets two state bits: set-mask (every pixel drawn gets bit 15
95// set in VRAM) and check-mask (skip pixels with bit 15 already set).
96// Best-guess: hardware writes 0x801F for "RED + mask bit set" rather
97// than 0x001F.
98
99// Set-mask only: triangle drawn at (0,0)(4,0)(0,4) RED with E6 = 0x01.
100// Each drawn pixel should be 0x801F (RED with mask bit).
101#define EXPECT_MASK_SET_PIXEL_0_0 0x801fu /* HW_VERIFIED 2026-05-15 RED OR mask bit */
102#define EXPECT_MASK_SET_PIXEL_2_1 0x801fu /* HW_VERIFIED 2026-05-15 */
103#define EXPECT_MASK_SET_PIXEL_4_0 RASTER_SENTINEL /* HW_VERIFIED 2026-05-15 right edge excluded */
104
105// Check-mask after set-mask: overlay a second triangle with E6 = 0x02
106// (check only). Pixels already drawn (with bit 15 set) should be
107// preserved; pixels not yet drawn should fill normally.
108//
109// Setup: first draw RED tri A (sets mask bits via E6=0x01), then second
110// draw GREEN at OVERLAPPING geometry with E6=0x02 (check only, no set).
111// Pixel (1, 0) is in both triangles - was 0x801f (mask-set RED), should
112// stay 0x801f after the GREEN attempt is rejected. Pixel (5, 0) is only
113// in GREEN tri - was sentinel, should become VRAM_GREEN (0x03E0).
114#define EXPECT_MASK_CHECK_PIXEL_1_0_preserved 0x801fu /* HW_VERIFIED 2026-05-15 */
115#define EXPECT_MASK_CHECK_PIXEL_5_0_filled RASTER_VRAM_GREEN /* HW_VERIFIED 2026-05-15 */
116
117// --------------------------------------------------------------------------
118// Texture window suite
119// --------------------------------------------------------------------------
120//
121// Pure characterization at first - textured primitives need a texpage
122// + CLUT setup, and the test surface (which TIM gets uploaded, where in
123// VRAM the texture lives, etc.) is its own design problem. Phase 2.5
124// or beyond. Placeholders left empty here; suite file may stay as
125// scaffolding initially.