Nugget
Loading...
Searching...
No Matches
raster-expected-phase14.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-14 expected values. Predictions follow psx-spx documented
30// limits: per-edge dx ±1023, per-edge dy ±511. Tests at boundary +
31// over-limit. HW_TODO placeholders for the textured-triangle UV-
32// dependent anchor values - hardware-truth captured on first run.
33
34#include "raster-helpers.h"
35#include "texture-fixtures.h"
36
37// ---- Triangle (GP0 0x20) ----
38#define CT_TRI_DX_1023 RASTER_VRAM_RED /* HW_TODO renders (in limit) */
39#define CT_TRI_DX_1024 RASTER_SENTINEL /* HW_TODO drop boundary */
40#define CT_TRI_DX_1025 RASTER_SENTINEL /* HW_TODO drop */
41#define CT_TRI_DX_2047 RASTER_SENTINEL /* HW_TODO drop */
42#define CT_TRI_DY_511 RASTER_VRAM_RED /* HW_TODO renders */
43#define CT_TRI_DY_512 RASTER_SENTINEL /* HW_TODO drop boundary */
44#define CT_TRI_DY_513 RASTER_SENTINEL /* HW_TODO drop */
45#define CT_TRI_DY_1023 RASTER_SENTINEL /* HW_TODO drop */
46
47// ---- Gouraud triangle (GP0 0x30) ----
48#define CT_GTRI_DX_1023 RASTER_VRAM_RED /* HW_TODO */
49#define CT_GTRI_DX_1024 RASTER_SENTINEL /* HW_TODO */
50#define CT_GTRI_DX_2047 RASTER_SENTINEL /* HW_TODO */
51
52// ---- Textured triangle (GP0 0x24) ----
53// Anchor (5, 3) under UV interpolation across a 1023x20 triangle
54// samples at near-degenerate UV. Hardware truth: 0x001f at (5, 3).
55#define CT_TEXTRI_DX_1023 0x001fu /* renders, texture sample */
56#define CT_TEXTRI_DX_1024 RASTER_SENTINEL /* drop */
57#define CT_TEXTRI_DX_2047 RASTER_SENTINEL /* drop */
58
59// ---- Quad (GP0 0x28) ----
60#define CT_QUAD_DX_1023 RASTER_VRAM_GREEN /* HW_TODO */
61#define CT_QUAD_DX_1024 RASTER_SENTINEL /* HW_TODO */
62#define CT_QUAD_DX_2047 RASTER_SENTINEL /* HW_TODO */
63#define CT_QUAD_DY_511 RASTER_VRAM_GREEN /* HW_TODO */
64#define CT_QUAD_DY_512 RASTER_SENTINEL /* HW_TODO */
65
66// ---- Textured quad (GP0 0x2C) ----
67// Anchor (5, 3) sample. Hardware truth: 0x03e0.
68#define CT_TEXQUAD_DX_1023 0x03e0u /* renders, texture sample */
69#define CT_TEXQUAD_DX_1024 RASTER_SENTINEL /* drop */
70#define CT_TEXQUAD_DX_2047 RASTER_SENTINEL /* drop */
71
72// ---- Line (GP0 0x40) ----
73#define CT_LINE_DX_1023 RASTER_VRAM_BLUE /* HW_TODO */
74#define CT_LINE_DX_1024 RASTER_SENTINEL /* HW_TODO */
75#define CT_LINE_DX_2047 RASTER_SENTINEL /* HW_TODO */
76
77// ---- Variable-size rect (GP0 0x60) ----
78// HARDWARE FINDING (verified 2026-05-16): the actual rect-size mask
79// is `dim & 0x3FF` (width) / `dim & 0x1FF` (height), NOT psx-spx's
80// `((dim - 1) & mask) + 1`. So:
81// W = 1023 -> effective 1023 (renders)
82// W = 1024 -> effective 0 (drop - no pixels drawn)
83// W = 1025 -> effective 1 (renders single column, anchor outside)
84// H = 511 -> effective 511 (renders)
85// H = 512 -> effective 0 (drop)
86// H = 513 -> effective 1 (single row, anchor outside)
87// Both psx-spx formulas overestimate the maximum effective dimension
88// by exactly the same +1 amount the documentation's "((W-1) & mask) + 1"
89// shape is meant to provide.
90#define CT_RECT_W_1023 RASTER_VRAM_WHITE /* renders, width 1023 */
91#define CT_RECT_W_1024 RASTER_SENTINEL /* effective 0 -> no draw */
92#define CT_RECT_W_1025 RASTER_SENTINEL /* effective 1 -> single column */
93#define CT_RECT_H_511 RASTER_VRAM_WHITE /* renders, height 511 */
94#define CT_RECT_H_512 RASTER_SENTINEL /* effective 0 -> no draw */
95#define CT_RECT_H_513 RASTER_SENTINEL /* effective 1 -> single row */
96
97// ---- Per-vertex absolute coordinate ----
98#define CT_TRI_VERTEX_ABS_OVER RASTER_SENTINEL /* HW_TODO dropped */
99
100/* Pre-truncation probes. If hardware truncates vertex to 11-bit signed
101 first then applies per-edge cull, both probes render identically to
102 the baseline at anchor (RASTER_VRAM_RED). If a pre-truncation per-
103 vertex absolute-coord rule exists, probes drop and anchor reads
104 sentinel. Placeholders use RASTER_VRAM_RED - matches the "no extra
105 rule" hypothesis until hardware says otherwise. */
106#define CT_TRI_PRETRUNC_BIT11 RASTER_VRAM_RED
107#define CT_TRI_PRETRUNC_BIT15 RASTER_VRAM_RED