Nugget
Loading...
Searching...
No Matches
row-walk-drift.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-20 row-walk-drift suite. Five triangles (K in {1, 3, 5, 8, 16})
28// with identical 10x20 screen footprint. Six probes per K at x=7 and
29// y in {5, 8, 11, 14, 17, 20}.
30
32
33// Triangle T_LONG_K_N: A=(5,5)/(0,0) B=(15,5)/(N,0) C=(5,25)/(0,2N)
34// dU/dx = N/10, dV/dy = N/10. Triangle is 10 wide, 20 tall. Right
35// edge BC has slope -0.5; probes at x=7 are well to the left of BC
36// at every probed y so row-start X stays at 5.
37
38static void drawT_LONG_K01(void) {
39 rasterReset();
40 rasterClearTestRegion(0, 0, 24, 28);
41 setTexpage(TEX17_TX, TEX17_TY, 2);
42 setTextureWindow(0, 0, 0, 0);
43 rasterTexTri(TEX_MOD_NEUTRAL,
44 5, 5, 0, 0,
45 15, 5, 1, 0,
46 5, 25, 0, 2,
48 rasterFlushPrimitive();
49}
50
51static void drawT_LONG_K03(void) {
52 rasterReset();
53 rasterClearTestRegion(0, 0, 24, 28);
54 setTexpage(TEX17_TX, TEX17_TY, 2);
55 setTextureWindow(0, 0, 0, 0);
56 rasterTexTri(TEX_MOD_NEUTRAL,
57 5, 5, 0, 0,
58 15, 5, 3, 0,
59 5, 25, 0, 6,
61 rasterFlushPrimitive();
62}
63
64static void drawT_LONG_K05(void) {
65 rasterReset();
66 rasterClearTestRegion(0, 0, 24, 28);
67 setTexpage(TEX17_TX, TEX17_TY, 2);
68 setTextureWindow(0, 0, 0, 0);
69 rasterTexTri(TEX_MOD_NEUTRAL,
70 5, 5, 0, 0,
71 15, 5, 5, 0,
72 5, 25, 0, 10,
74 rasterFlushPrimitive();
75}
76
77static void drawT_LONG_K08(void) {
78 rasterReset();
79 rasterClearTestRegion(0, 0, 24, 28);
80 setTexpage(TEX17_TX, TEX17_TY, 2);
81 setTextureWindow(0, 0, 0, 0);
82 rasterTexTri(TEX_MOD_NEUTRAL,
83 5, 5, 0, 0,
84 15, 5, 8, 0,
85 5, 25, 0, 16,
87 rasterFlushPrimitive();
88}
89
90static void drawT_LONG_K16(void) {
91 rasterReset();
92 rasterClearTestRegion(0, 0, 24, 28);
93 setTexpage(TEX17_TX, TEX17_TY, 2);
94 setTextureWindow(0, 0, 0, 0);
95 rasterTexTri(TEX_MOD_NEUTRAL,
96 5, 5, 0, 0,
97 15, 5, 16, 0,
98 5, 25, 0, 32, /* 8-bit UV holds 32 cleanly; probes only reach v=24 */
100 rasterFlushPrimitive();
101}
102
103) // CESTER_BODY
104
105// --------------------------------------------------------------------------
106// K=01 probes
107// --------------------------------------------------------------------------
108
109CESTER_TEST(ar_long_k01_y05, gpu_raster_phase20,
110 drawT_LONG_K01();
112)
113
114CESTER_TEST(ar_long_k01_y08, gpu_raster_phase20,
115 drawT_LONG_K01();
117)
118
119CESTER_TEST(ar_long_k01_y11, gpu_raster_phase20,
120 drawT_LONG_K01();
122)
123
124CESTER_TEST(ar_long_k01_y14, gpu_raster_phase20,
125 drawT_LONG_K01();
127)
128
129CESTER_TEST(ar_long_k01_y17, gpu_raster_phase20,
130 drawT_LONG_K01();
132)
133
134CESTER_TEST(ar_long_k01_y20, gpu_raster_phase20,
135 drawT_LONG_K01();
137)
138
139// --------------------------------------------------------------------------
140// K=03 probes
141// --------------------------------------------------------------------------
142
143CESTER_TEST(ar_long_k03_y05, gpu_raster_phase20,
144 drawT_LONG_K03();
146)
147
148CESTER_TEST(ar_long_k03_y08, gpu_raster_phase20,
149 drawT_LONG_K03();
151)
152
153CESTER_TEST(ar_long_k03_y11, gpu_raster_phase20,
154 drawT_LONG_K03();
156)
157
158CESTER_TEST(ar_long_k03_y14, gpu_raster_phase20,
159 drawT_LONG_K03();
161)
162
163CESTER_TEST(ar_long_k03_y17, gpu_raster_phase20,
164 drawT_LONG_K03();
166)
167
168CESTER_TEST(ar_long_k03_y20, gpu_raster_phase20,
169 drawT_LONG_K03();
171)
172
173// --------------------------------------------------------------------------
174// K=05 probes
175// --------------------------------------------------------------------------
176
177CESTER_TEST(ar_long_k05_y05, gpu_raster_phase20,
178 drawT_LONG_K05();
180)
181
182CESTER_TEST(ar_long_k05_y08, gpu_raster_phase20,
183 drawT_LONG_K05();
185)
186
187CESTER_TEST(ar_long_k05_y11, gpu_raster_phase20,
188 drawT_LONG_K05();
190)
191
192CESTER_TEST(ar_long_k05_y14, gpu_raster_phase20,
193 drawT_LONG_K05();
195)
196
197CESTER_TEST(ar_long_k05_y17, gpu_raster_phase20,
198 drawT_LONG_K05();
200)
201
202CESTER_TEST(ar_long_k05_y20, gpu_raster_phase20,
203 drawT_LONG_K05();
205)
206
207// --------------------------------------------------------------------------
208// K=08 probes
209// --------------------------------------------------------------------------
210
211CESTER_TEST(ar_long_k08_y05, gpu_raster_phase20,
212 drawT_LONG_K08();
214)
215
216CESTER_TEST(ar_long_k08_y08, gpu_raster_phase20,
217 drawT_LONG_K08();
219)
220
221CESTER_TEST(ar_long_k08_y11, gpu_raster_phase20,
222 drawT_LONG_K08();
224)
225
226CESTER_TEST(ar_long_k08_y14, gpu_raster_phase20,
227 drawT_LONG_K08();
229)
230
231CESTER_TEST(ar_long_k08_y17, gpu_raster_phase20,
232 drawT_LONG_K08();
234)
235
236CESTER_TEST(ar_long_k08_y20, gpu_raster_phase20,
237 drawT_LONG_K08();
239)
240
241// --------------------------------------------------------------------------
242// K=16 probes
243// --------------------------------------------------------------------------
244
245CESTER_TEST(ar_long_k16_y05, gpu_raster_phase20,
246 drawT_LONG_K16();
248)
249
250CESTER_TEST(ar_long_k16_y08, gpu_raster_phase20,
251 drawT_LONG_K16();
253)
254
255CESTER_TEST(ar_long_k16_y11, gpu_raster_phase20,
256 drawT_LONG_K16();
258)
259
260CESTER_TEST(ar_long_k16_y14, gpu_raster_phase20,
261 drawT_LONG_K16();
263)
264
265CESTER_TEST(ar_long_k16_y17, gpu_raster_phase20,
266 drawT_LONG_K16();
268)
269
270CESTER_TEST(ar_long_k16_y20, gpu_raster_phase20,
271 drawT_LONG_K16();
273)
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_LONG_K03_Y05
Definition raster-expected-phase20.h:80
#define EXPECT_LONG_K01_Y17
Definition raster-expected-phase20.h:70
#define EXPECT_LONG_K08_Y17
Definition raster-expected-phase20.h:112
#define EXPECT_LONG_K08_Y20
Definition raster-expected-phase20.h:113
#define EXPECT_LONG_K08_Y08
Definition raster-expected-phase20.h:109
#define EXPECT_LONG_K03_Y20
Definition raster-expected-phase20.h:85
#define EXPECT_LONG_K05_Y11
Definition raster-expected-phase20.h:96
#define EXPECT_LONG_K03_Y17
Definition raster-expected-phase20.h:84
#define EXPECT_LONG_K16_Y14
Definition raster-expected-phase20.h:125
#define EXPECT_LONG_K16_Y08
Definition raster-expected-phase20.h:123
#define EXPECT_LONG_K16_Y17
Definition raster-expected-phase20.h:126
#define EXPECT_LONG_K01_Y14
Definition raster-expected-phase20.h:69
#define EXPECT_LONG_K08_Y11
Definition raster-expected-phase20.h:110
#define EXPECT_LONG_K03_Y08
Definition raster-expected-phase20.h:81
#define EXPECT_LONG_K01_Y20
Definition raster-expected-phase20.h:71
#define EXPECT_LONG_K01_Y05
Definition raster-expected-phase20.h:66
#define EXPECT_LONG_K08_Y14
Definition raster-expected-phase20.h:111
#define EXPECT_LONG_K16_Y11
Definition raster-expected-phase20.h:124
#define EXPECT_LONG_K08_Y05
Definition raster-expected-phase20.h:108
#define EXPECT_LONG_K05_Y14
Definition raster-expected-phase20.h:97
#define EXPECT_LONG_K05_Y20
Definition raster-expected-phase20.h:99
#define EXPECT_LONG_K01_Y11
Definition raster-expected-phase20.h:68
#define EXPECT_LONG_K05_Y05
Definition raster-expected-phase20.h:94
#define EXPECT_LONG_K05_Y17
Definition raster-expected-phase20.h:98
#define EXPECT_LONG_K03_Y11
Definition raster-expected-phase20.h:82
#define EXPECT_LONG_K16_Y05
Definition raster-expected-phase20.h:122
#define EXPECT_LONG_K05_Y08
Definition raster-expected-phase20.h:95
#define EXPECT_LONG_K16_Y20
Definition raster-expected-phase20.h:127
#define EXPECT_LONG_K01_Y08
Definition raster-expected-phase20.h:67
#define EXPECT_LONG_K03_Y14
Definition raster-expected-phase20.h:83
#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