Nugget
Loading...
Searching...
No Matches
stride-sign-cross.c
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// Phase-19 stride-sign + cross-axis sweep. Six triangles, identical
28// 10x10 screen footprint to phase-18. Probes are the same five
29// screen positions across all families.
30
32
33// ---- T_NEG_U_K05: dU/dx = -0.5 (mirror of phase-18's K=5) -------------
34// A=(5,5)/(5,0) B=(15,5)/(0,0) C=(5,15)/(5,5)
35// u(x,y) = 7.5 - 0.5*x v(x,y) = 0.5*y - 2.5
36static void drawT_NEG_U_K05(void) {
37 rasterReset();
38 rasterClearTestRegion(0, 0, 24, 16);
39 setTexpage(TEX17_TX, TEX17_TY, 2);
40 setTextureWindow(0, 0, 0, 0);
41 rasterTexTri(TEX_MOD_NEUTRAL,
42 5, 5, 5, 0,
43 15, 5, 0, 0,
44 5, 15, 5, 5,
46 rasterFlushPrimitive();
47}
48
49// ---- T_NEG_V_K05: dV/dy = -0.5 ----------------------------------------
50// A=(5,5)/(0,5) B=(15,5)/(5,5) C=(5,15)/(0,0)
51// u(x,y) = 0.5*x - 2.5 v(x,y) = 7.5 - 0.5*y
52static void drawT_NEG_V_K05(void) {
53 rasterReset();
54 rasterClearTestRegion(0, 0, 24, 16);
55 setTexpage(TEX17_TX, TEX17_TY, 2);
56 setTextureWindow(0, 0, 0, 0);
57 rasterTexTri(TEX_MOD_NEUTRAL,
58 5, 5, 0, 5,
59 15, 5, 5, 5,
60 5, 15, 0, 0,
62 rasterFlushPrimitive();
63}
64
65// ---- T_NEG_BOTH_K05: dU/dx = -0.5, dV/dy = -0.5 -----------------------
66// A=(5,5)/(5,5) B=(15,5)/(0,5) C=(5,15)/(5,0)
67// u(x,y) = 7.5 - 0.5*x v(x,y) = 7.5 - 0.5*y
68static void drawT_NEG_BOTH_K05(void) {
69 rasterReset();
70 rasterClearTestRegion(0, 0, 24, 16);
71 setTexpage(TEX17_TX, TEX17_TY, 2);
72 setTextureWindow(0, 0, 0, 0);
73 rasterTexTri(TEX_MOD_NEUTRAL,
74 5, 5, 5, 5,
75 15, 5, 0, 5,
76 5, 15, 5, 0,
78 rasterFlushPrimitive();
79}
80
81// ---- T_NEG_U_K16: dU/dx = -1.6 (stretched negative) -------------------
82// A=(5,5)/(16,0) B=(15,5)/(0,0) C=(5,15)/(16,16)
83// u(x,y) = 24 - 1.6*x v(x,y) = 1.6*y - 8
84static void drawT_NEG_U_K16(void) {
85 rasterReset();
86 rasterClearTestRegion(0, 0, 24, 16);
87 setTexpage(TEX17_TX, TEX17_TY, 2);
88 setTextureWindow(0, 0, 0, 0);
89 rasterTexTri(TEX_MOD_NEUTRAL,
90 5, 5, 16, 0,
91 15, 5, 0, 0,
92 5, 15, 16, 16,
94 rasterFlushPrimitive();
95}
96
97// ---- T_CROSS_45_K05: 45-degree UV rotation, mild ----------------------
98// A=(5,5)/(5,0) B=(15,5)/(10,5) C=(5,15)/(0,5)
99// dU/dx = 0.5, dU/dy = -0.5, dV/dx = 0.5, dV/dy = 0.5
100// u(x,y) = 0.5*x - 0.5*y + 5 v(x,y) = 0.5*x + 0.5*y - 5
101static void drawT_CROSS_45_K05(void) {
102 rasterReset();
103 rasterClearTestRegion(0, 0, 24, 16);
104 setTexpage(TEX17_TX, TEX17_TY, 2);
105 setTextureWindow(0, 0, 0, 0);
106 rasterTexTri(TEX_MOD_NEUTRAL,
107 5, 5, 5, 0,
108 15, 5, 10, 5,
109 5, 15, 0, 5,
111 rasterFlushPrimitive();
112}
113
114// ---- T_CROSS_90_K16: 90-degree UV rotation, stretched -----------------
115// A=(5,5)/(0,0) B=(15,5)/(0,16) C=(5,15)/(16,0)
116// dU/dx = 0, dU/dy = 1.6, dV/dx = 1.6, dV/dy = 0
117// u(x,y) = 1.6*y - 8 v(x,y) = 1.6*x - 8
118static void drawT_CROSS_90_K16(void) {
119 rasterReset();
120 rasterClearTestRegion(0, 0, 24, 16);
121 setTexpage(TEX17_TX, TEX17_TY, 2);
122 setTextureWindow(0, 0, 0, 0);
123 rasterTexTri(TEX_MOD_NEUTRAL,
124 5, 5, 0, 0,
125 15, 5, 0, 16,
126 5, 15, 16, 0,
128 rasterFlushPrimitive();
129}
130
131) // CESTER_BODY
132
133// --------------------------------------------------------------------------
134// T_NEG_U_K05 probes
135// --------------------------------------------------------------------------
136
137CESTER_TEST(ar_neg_u_k05_vertex, gpu_raster_phase19,
138 drawT_NEG_U_K05();
140)
141
142CESTER_TEST(ar_neg_u_k05_top_near, gpu_raster_phase19,
143 drawT_NEG_U_K05();
145)
146
147CESTER_TEST(ar_neg_u_k05_left_near, gpu_raster_phase19,
148 drawT_NEG_U_K05();
150)
151
152CESTER_TEST(ar_neg_u_k05_interior, gpu_raster_phase19,
153 drawT_NEG_U_K05();
155)
156
157CESTER_TEST(ar_neg_u_k05_top_far, gpu_raster_phase19,
158 drawT_NEG_U_K05();
160)
161
162// --------------------------------------------------------------------------
163// T_NEG_V_K05 probes
164// --------------------------------------------------------------------------
165
166CESTER_TEST(ar_neg_v_k05_vertex, gpu_raster_phase19,
167 drawT_NEG_V_K05();
169)
170
171CESTER_TEST(ar_neg_v_k05_top_near, gpu_raster_phase19,
172 drawT_NEG_V_K05();
174)
175
176CESTER_TEST(ar_neg_v_k05_left_near, gpu_raster_phase19,
177 drawT_NEG_V_K05();
179)
180
181CESTER_TEST(ar_neg_v_k05_interior, gpu_raster_phase19,
182 drawT_NEG_V_K05();
184)
185
186CESTER_TEST(ar_neg_v_k05_top_far, gpu_raster_phase19,
187 drawT_NEG_V_K05();
189)
190
191// --------------------------------------------------------------------------
192// T_NEG_BOTH_K05 probes
193// --------------------------------------------------------------------------
194
195CESTER_TEST(ar_neg_both_k05_vertex, gpu_raster_phase19,
196 drawT_NEG_BOTH_K05();
198)
199
200CESTER_TEST(ar_neg_both_k05_top_near, gpu_raster_phase19,
201 drawT_NEG_BOTH_K05();
203)
204
205CESTER_TEST(ar_neg_both_k05_left_near, gpu_raster_phase19,
206 drawT_NEG_BOTH_K05();
208)
209
210CESTER_TEST(ar_neg_both_k05_interior, gpu_raster_phase19,
211 drawT_NEG_BOTH_K05();
213)
214
215CESTER_TEST(ar_neg_both_k05_top_far, gpu_raster_phase19,
216 drawT_NEG_BOTH_K05();
218)
219
220// --------------------------------------------------------------------------
221// T_NEG_U_K16 probes
222// --------------------------------------------------------------------------
223
224CESTER_TEST(ar_neg_u_k16_vertex, gpu_raster_phase19,
225 drawT_NEG_U_K16();
227)
228
229CESTER_TEST(ar_neg_u_k16_top_near, gpu_raster_phase19,
230 drawT_NEG_U_K16();
232)
233
234CESTER_TEST(ar_neg_u_k16_left_near, gpu_raster_phase19,
235 drawT_NEG_U_K16();
237)
238
239CESTER_TEST(ar_neg_u_k16_interior, gpu_raster_phase19,
240 drawT_NEG_U_K16();
242)
243
244CESTER_TEST(ar_neg_u_k16_top_far, gpu_raster_phase19,
245 drawT_NEG_U_K16();
247)
248
249// --------------------------------------------------------------------------
250// T_CROSS_45_K05 probes
251// --------------------------------------------------------------------------
252
253CESTER_TEST(ar_cross_45_k05_vertex, gpu_raster_phase19,
254 drawT_CROSS_45_K05();
256)
257
258CESTER_TEST(ar_cross_45_k05_top_near, gpu_raster_phase19,
259 drawT_CROSS_45_K05();
261)
262
263CESTER_TEST(ar_cross_45_k05_left_near, gpu_raster_phase19,
264 drawT_CROSS_45_K05();
266)
267
268CESTER_TEST(ar_cross_45_k05_interior, gpu_raster_phase19,
269 drawT_CROSS_45_K05();
271)
272
273CESTER_TEST(ar_cross_45_k05_top_far, gpu_raster_phase19,
274 drawT_CROSS_45_K05();
276)
277
278// --------------------------------------------------------------------------
279// T_CROSS_90_K16 probes
280// --------------------------------------------------------------------------
281
282CESTER_TEST(ar_cross_90_k16_vertex, gpu_raster_phase19,
283 drawT_CROSS_90_K16();
285)
286
287CESTER_TEST(ar_cross_90_k16_top_near, gpu_raster_phase19,
288 drawT_CROSS_90_K16();
290)
291
292CESTER_TEST(ar_cross_90_k16_left_near, gpu_raster_phase19,
293 drawT_CROSS_90_K16();
295)
296
297CESTER_TEST(ar_cross_90_k16_interior, gpu_raster_phase19,
298 drawT_CROSS_90_K16();
300)
301
302CESTER_TEST(ar_cross_90_k16_top_far, gpu_raster_phase19,
303 drawT_CROSS_90_K16();
305)
CESTER_BODY(static int s_got40;static int s_got80;static uint32_t s_cause;static uint32_t s_epc;static uint32_t s_from;static uint32_t *s_resume;static uint32_t *s_regs;static uint32_t(*s_customhandler)()=NULL;static uint32_t s_oldIMASK;static uint32_t s_oldDPCR;static uint32_t s_oldDICR;uint32_t handler(uint32_t *regs, uint32_t from) { if(from==0x40) s_got40=1;if(from==0x80) s_got80=1;uint32_t cause;uint32_t epc;s_from=from;asm("mfc0 %0, $13\nnop\nmfc0 %1, $14\nnop" :"=r"(cause), "=r"(epc));s_cause=cause;s_epc=epc;if(s_customhandler) { return s_customhandler();} else { return s_resume ?((uint32_t) s_resume) :(epc+4);} } void installExceptionHandlers(uint32_t(*handler)(uint32_t *regs, uint32_t from));void uninstallExceptionHandlers();uint32_t branchbranch1();uint32_t branchbranch2();uint32_t jumpjump1();uint32_t jumpjump2();uint32_t cpu_LWR_LWL_half(uint32_t buff[], uint32_t initial);uint32_t cpu_LWR_LWL_nodelay(uint32_t buff[], uint32_t initial);uint32_t cpu_LWR_LWL_delayed(uint32_t buff[], uint32_t initial);uint32_t cpu_LWR_LWL_load_different(uint32_t buff[], uint32_t initial);uint32_t cpu_LW_LWR(uint32_t buff[], uint32_t initial);uint32_t cpu_delayed_load(uint32_t buff[], uint32_t override);uint32_t cpu_delayed_load_cancelled(uint32_t buff[], uint32_t override);uint64_t cpu_delayed_load_load(uint32_t buff[], uint32_t override);uint32_t linkandload();uint32_t lwandlink();uint32_t nolink();static int s_interruptsWereEnabled;) CESTER_BEFORE_EACH(cpu_tests
CESTER_TEST(cpu_cop0_basic_write_bp, cpu_tests, uint32_t expectedEPC;uint32_t t;volatile uint32_t *ptr=(volatile uint32_t *) 0x58; *ptr=1;__asm__ volatile("" " lui %0, 0b1100101010000000\n" " mtc0 %0, $7\n" " li %0, 0x58\n" " mtc0 %0, $5\n" " li %0, 0xfffffff0\n" " mtc0 %0, $9\n" :"=r"(t));cester_assert_uint_eq(1, *ptr);__asm__ volatile("la %0, 1f\n1:\nsw $0, 0x58($0)" :"=r"(expectedEPC));__asm__ volatile("mtc0 $0, $7\n");cester_assert_uint_eq(0, *ptr);cester_assert_uint_eq(1, s_got40);cester_assert_uint_eq(0, s_got80);cester_assert_uint_eq(0x40, s_from);cester_assert_uint_eq(expectedEPC, s_epc);) CESTER_TEST(cpu_cop0_kseg_write_bp
#define EXPECT_NEG_U_K05_INTERIOR
Definition raster-expected-phase19.h:83
#define EXPECT_CROSS_90_K16_TOP_NEAR
Definition raster-expected-phase19.h:161
#define EXPECT_NEG_U_K05_LEFT_NEAR
Definition raster-expected-phase19.h:82
#define EXPECT_NEG_U_K05_TOP_FAR
Definition raster-expected-phase19.h:84
#define EXPECT_CROSS_45_K05_INTERIOR
Definition raster-expected-phase19.h:147
#define EXPECT_NEG_U_K16_TOP_FAR
Definition raster-expected-phase19.h:132
#define EXPECT_NEG_V_K05_TOP_NEAR
Definition raster-expected-phase19.h:97
#define EXPECT_NEG_U_K16_TOP_NEAR
Definition raster-expected-phase19.h:129
#define EXPECT_NEG_U_K05_VERTEX
Definition raster-expected-phase19.h:80
#define EXPECT_NEG_V_K05_INTERIOR
Definition raster-expected-phase19.h:99
#define EXPECT_NEG_BOTH_K05_INTERIOR
Definition raster-expected-phase19.h:115
#define EXPECT_NEG_BOTH_K05_LEFT_NEAR
Definition raster-expected-phase19.h:114
#define EXPECT_CROSS_90_K16_INTERIOR
Definition raster-expected-phase19.h:163
#define EXPECT_CROSS_90_K16_VERTEX
Definition raster-expected-phase19.h:160
#define EXPECT_NEG_V_K05_TOP_FAR
Definition raster-expected-phase19.h:100
#define EXPECT_NEG_V_K05_VERTEX
Definition raster-expected-phase19.h:96
#define EXPECT_NEG_BOTH_K05_TOP_NEAR
Definition raster-expected-phase19.h:113
#define EXPECT_CROSS_90_K16_TOP_FAR
Definition raster-expected-phase19.h:164
#define EXPECT_NEG_U_K16_INTERIOR
Definition raster-expected-phase19.h:131
#define EXPECT_NEG_U_K16_LEFT_NEAR
Definition raster-expected-phase19.h:130
#define EXPECT_NEG_V_K05_LEFT_NEAR
Definition raster-expected-phase19.h:98
#define EXPECT_CROSS_45_K05_TOP_NEAR
Definition raster-expected-phase19.h:145
#define EXPECT_NEG_U_K05_TOP_NEAR
Definition raster-expected-phase19.h:81
#define EXPECT_NEG_U_K16_VERTEX
Definition raster-expected-phase19.h:128
#define EXPECT_CROSS_45_K05_VERTEX
Definition raster-expected-phase19.h:144
#define EXPECT_CROSS_90_K16_LEFT_NEAR
Definition raster-expected-phase19.h:162
#define EXPECT_NEG_BOTH_K05_TOP_FAR
Definition raster-expected-phase19.h:116
#define EXPECT_NEG_BOTH_K05_VERTEX
Definition raster-expected-phase19.h:112
#define EXPECT_CROSS_45_K05_TOP_FAR
Definition raster-expected-phase19.h:148
#define EXPECT_CROSS_45_K05_LEFT_NEAR
Definition raster-expected-phase19.h:146
#define TEX17_TY
Definition texture-fixture-phase17.h:58
#define TEX17_TPAGE
Definition texture-fixture-phase17.h:65
#define TEX17_TX
Definition texture-fixture-phase17.h:57
#define PHASE17_ASSERT_PIXEL_EQ(expected, x_, y_)
Definition texture-fixture-phase17.h:102
#define TEX17_CLUT_FIELD
Definition texture-fixture-phase17.h:66
#define TEX_MOD_NEUTRAL
Definition texture-fixtures.h:328