summaryrefslogtreecommitdiff
path: root/hwtest/pgraph_mthd.h
blob: 6a005f8cc810d3454d05f935b630be1d9394043c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
/*
 * Copyright (C) 2016 Marcin Kościelnicki <koriakin@0x04.net>
 * All Rights Reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice (including the next
 * paragraph) shall be included in all copies or substantial portions of the
 * Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 */

#ifndef HWTEST_PGRAPH_MTHD_H
#define HWTEST_PGRAPH_MTHD_H

#include "pgraph.h"

namespace hwtest {
namespace pgraph {

class MthdTest : public StateTest {
protected:
	uint32_t cls, mthd, subc, val;
	int trapbit;
	bool sync;
	uint32_t grobj[4], egrobj[4], rgrobj[4], gctx, pobj[4];
	virtual void choose_mthd() = 0;
	virtual void emulate_mthd_pre() {};
	virtual void emulate_mthd() = 0;
	virtual bool special_notify() { return false; }
	virtual bool can_buf_notify() { return false; }
	virtual bool can_warn() { return false; }
	virtual bool is_valid_val() { return true; }
	virtual bool is_valid_mthd() { return true; }
	virtual bool takes_dma() { return false; }
	virtual bool takes_ctxobj() { return false; }
	virtual void adjust_orig_mthd() { }
	virtual int gen_nv3_fmt() { return rnd() & 7; }
	virtual bool fix_alt_cls() { return true; }
	void warn(uint32_t err);
	void adjust_orig() override;
	void mutate() override;
	void print_fail() override;
	bool other_fail() override;
	MthdTest(hwtest::TestOptions &opt, uint32_t seed) : StateTest(opt, seed), trapbit(-1) {}
};

class SingleMthdTest : public MthdTest {
protected:
	int idx;
private:
	void choose_mthd() override {
		cls = s_cls;
		idx = rnd() % s_num;
		mthd = s_mthd + idx * s_stride;
		trapbit = s_trapbit;
	}
public:
	uint32_t s_cls, s_mthd, s_stride, s_num;
	int s_trapbit;
	std::string name;
	SingleMthdTest(hwtest::TestOptions &opt, uint32_t seed, const std::string &name, int trapbit, uint32_t cls, uint32_t mthd, uint32_t num = 1, uint32_t stride = 4)
	: MthdTest(opt, seed), s_cls(cls), s_mthd(mthd), s_stride(stride), s_num(num), s_trapbit(trapbit), name(name) {}
};

class MthdNop : public SingleMthdTest {
	bool supported() override {
		return chipset.card_type >= 4;
	}
	void adjust_orig_mthd() override;
	void emulate_mthd_pre() override;
	void emulate_mthd() override;
	bool is_valid_val() override;
	using SingleMthdTest::SingleMthdTest;
};

class MthdSync : public SingleMthdTest {
	void emulate_mthd() override {}
	bool is_valid_mthd() override { return !sync; }
	using SingleMthdTest::SingleMthdTest;
};

class MthdMissing : public SingleMthdTest {
	bool supported() override {
		return chipset.card_type >= 4 && chipset.card_type < 0x20;
	}
	void emulate_mthd() override {
		insrt(exp.intr, 4, 1, 1);
		exp.fifo_enable = 0;
	}
	using SingleMthdTest::SingleMthdTest;
};

class MthdPmTrigger : public SingleMthdTest {
	bool supported() override {
		return chipset.card_type >= 0x10;
	}
	void emulate_mthd() override {
		if (!extr(exp.debug[3], 15, 1)) {
			nv04_pgraph_blowup(&exp, 0x40);
		}
	}
	using SingleMthdTest::SingleMthdTest;
};

class MthdNotify : public SingleMthdTest {
	bool special_notify() override { return true; }
	void adjust_orig_mthd() override;
	bool is_valid_val() override;
	bool is_valid_mthd() override;
	void emulate_mthd() override;
	using SingleMthdTest::SingleMthdTest;
};

class MthdDmaNotify : public SingleMthdTest {
	bool supported() override {
		return chipset.card_type >= 4;
	}
	bool takes_dma() override { return true; }
	void emulate_mthd() override;
	using SingleMthdTest::SingleMthdTest;
};

enum {
	DMA_R = 0,
	DMA_W = 1,
	DMA_CLR = 2,
	DMA_ALIGN = 4,
};

class MthdDmaGrobj : public SingleMthdTest {
	int which, ecls;
	bool clr, align;
	bool supported() override {
		return chipset.card_type >= 4;
	}
	bool takes_dma() override { return true; }
	void emulate_mthd() override;
public:
	MthdDmaGrobj(hwtest::TestOptions &opt, uint32_t seed, const std::string &name, int trapbit, uint32_t cls, uint32_t mthd, int which, int flags)
	: SingleMthdTest(opt, seed, name, trapbit, cls, mthd), which(which) {
		if (flags & DMA_W)
			ecls = 3;
		else
			ecls = 2;
		clr = !!(flags & DMA_CLR);
		align = !!(flags & DMA_ALIGN);
	}
};

class UntestedMthd : public SingleMthdTest {
	int run() override {
		return HWTEST_RES_UNPREP;
	}
	void emulate_mthd() override { }
	using SingleMthdTest::SingleMthdTest;
};

class MthdSolidColor : public SingleMthdTest {
	void emulate_mthd() override;
	using SingleMthdTest::SingleMthdTest;
};

class MthdBitmapColor0 : public SingleMthdTest {
	void emulate_mthd() override;
	using SingleMthdTest::SingleMthdTest;
};

class MthdBitmapColor1 : public SingleMthdTest {
	void emulate_mthd() override;
	using SingleMthdTest::SingleMthdTest;
};

class MthdBitmapFormat : public SingleMthdTest {
	bool supported() override;
	bool is_valid_val() override;
	void adjust_orig_mthd() override;
	void emulate_mthd() override;
	using SingleMthdTest::SingleMthdTest;
};

enum {
	SURF_NV3 = 0,
	SURF_NV4 = 1,
	SURF_NV10 = 2,
};

class MthdDmaSurf : public SingleMthdTest {
	int which;
	int kind;
	bool supported() override {
		return chipset.card_type >= 4;
	}
	bool takes_dma() override { return true; }
	void emulate_mthd() override;
public:
	MthdDmaSurf(hwtest::TestOptions &opt, uint32_t seed, const std::string &name, int trapbit, uint32_t cls, uint32_t mthd, int which, int flags)
	: SingleMthdTest(opt, seed, name, trapbit, cls, mthd), which(which), kind(flags) {}
};

class MthdSurfOffset : public SingleMthdTest {
	int which;
	int kind;
	bool is_valid_val() override;
	void emulate_mthd() override;
public:
	MthdSurfOffset(hwtest::TestOptions &opt, uint32_t seed, const std::string &name, int trapbit, uint32_t cls, uint32_t mthd, int which, int flags)
	: SingleMthdTest(opt, seed, name, trapbit, cls, mthd), which(which), kind(flags) {}
};

class MthdSurfPitch2 : public SingleMthdTest {
	int which_a, which_b;
	int kind;
	bool is_valid_val() override;
	void emulate_mthd() override;
public:
	MthdSurfPitch2(hwtest::TestOptions &opt, uint32_t seed, const std::string &name, int trapbit, uint32_t cls, uint32_t mthd, int which_a, int which_b, int flags)
	: SingleMthdTest(opt, seed, name, trapbit, cls, mthd), which_a(which_a), which_b(which_b), kind(flags) {}
};

class MthdSurf3DFormat : public SingleMthdTest {
	bool is_celsius;
	bool is_valid_val() override;
	void adjust_orig_mthd() override {
		if (rnd() & 1) {
			val &= 0x0f0f331f;
			val ^= 1 << (rnd() & 0x1f);
		}
	}
	void emulate_mthd() override;
	using SingleMthdTest::SingleMthdTest;
public:
	MthdSurf3DFormat(hwtest::TestOptions &opt, uint32_t seed, const std::string &name, int trapbit, uint32_t cls, uint32_t mthd, bool is_celsius)
	: SingleMthdTest(opt, seed, name, trapbit, cls, mthd), is_celsius(is_celsius) {}
};

class MthdPatch : public SingleMthdTest {
	bool supported() override { return chipset.card_type == 4; }
	bool is_valid_val() override {
		return val < 2 || chipset.chipset >= 5;
	}
	void adjust_orig_mthd() override {
		if (rnd() & 1) {
			val &= 0xf;
			val ^= 1 << (rnd() & 0x1f);
		}
	}
	void emulate_mthd() override;
	using SingleMthdTest::SingleMthdTest;
};

class MthdOperation : public SingleMthdTest {
	bool is_new;
	bool supported() override { return chipset.chipset >= 5; }
	bool is_valid_val() override {
		return val < (is_new ? 6 : 3);
	}
	bool is_valid_mthd() override {
		return extr(exp.debug[3], 30, 1);
	}
	void adjust_orig_mthd() override {
		if (rnd() & 1) {
			val &= 0xf;
			val ^= 1 << (rnd() & 0x1f);
		}
	}
	void emulate_mthd() override;
public:
	MthdOperation(hwtest::TestOptions &opt, uint32_t seed, const std::string &name, int trapbit, uint32_t cls, uint32_t mthd, bool is_new)
	: SingleMthdTest(opt, seed, name, trapbit, cls, mthd), is_new(is_new) {}
};

class MthdDither : public SingleMthdTest {
	bool supported() override { return chipset.chipset >= 0x10; }
	bool is_valid_val() override {
		return val < 3;
	}
	void adjust_orig_mthd() override {
		if (rnd() & 1) {
			val &= 0xf;
			val ^= 1 << (rnd() & 0x1f);
		}
	}
	void emulate_mthd() override;
	using SingleMthdTest::SingleMthdTest;
};

class MthdCtxChroma : public SingleMthdTest {
	bool is_new;
	bool supported() override {
		return chipset.chipset >= 5;
	}
	bool is_valid_mthd() override {
		return extr(exp.debug[3], 29, 1);
	}
	bool takes_ctxobj() override { return true; }
	void emulate_mthd() override;
public:
	MthdCtxChroma(hwtest::TestOptions &opt, uint32_t seed, const std::string &name, int trapbit, uint32_t cls, uint32_t mthd, bool is_new)
	: SingleMthdTest(opt, seed, name, trapbit, cls, mthd), is_new(is_new) {}
};

class MthdCtxClip : public SingleMthdTest {
	bool supported() override {
		return chipset.chipset >= 5;
	}
	bool is_valid_mthd() override {
		return extr(exp.debug[3], 29, 1);
	}
	bool takes_ctxobj() override { return true; }
	void emulate_mthd() override;
	using SingleMthdTest::SingleMthdTest;
};

class MthdCtxPattern : public SingleMthdTest {
	bool is_new;
	bool supported() override {
		return chipset.chipset >= 5;
	}
	bool is_valid_mthd() override {
		return extr(exp.debug[3], 29, 1);
	}
	bool takes_ctxobj() override { return true; }
	void emulate_mthd() override;
public:
	MthdCtxPattern(hwtest::TestOptions &opt, uint32_t seed, const std::string &name, int trapbit, uint32_t cls, uint32_t mthd, bool is_new)
	: SingleMthdTest(opt, seed, name, trapbit, cls, mthd), is_new(is_new) {}
};

class MthdCtxRop : public SingleMthdTest {
	bool supported() override {
		return chipset.chipset >= 5;
	}
	bool is_valid_mthd() override {
		return extr(exp.debug[3], 29, 1);
	}
	bool takes_ctxobj() override { return true; }
	void emulate_mthd() override;
	using SingleMthdTest::SingleMthdTest;
};

class MthdCtxBeta : public SingleMthdTest {
	bool supported() override {
		return chipset.chipset >= 5;
	}
	bool is_valid_mthd() override {
		return extr(exp.debug[3], 29, 1);
	}
	bool takes_ctxobj() override { return true; }
	void emulate_mthd() override;
	using SingleMthdTest::SingleMthdTest;
};

class MthdCtxBeta4 : public SingleMthdTest {
	bool supported() override {
		return chipset.chipset >= 5;
	}
	bool is_valid_mthd() override {
		return extr(exp.debug[3], 29, 1);
	}
	bool takes_ctxobj() override { return true; }
	void emulate_mthd() override;
	using SingleMthdTest::SingleMthdTest;
};

class MthdCtxSurf : public SingleMthdTest {
	int which;
	bool supported() override {
		return chipset.chipset >= 5;
	}
	bool is_valid_mthd() override {
		return extr(exp.debug[3], 29, 1);
	}
	bool takes_ctxobj() override { return true; }
	void emulate_mthd() override;
	using SingleMthdTest::SingleMthdTest;
public:
	MthdCtxSurf(hwtest::TestOptions &opt, uint32_t seed, const std::string &name, int trapbit, uint32_t cls, uint32_t mthd, int which)
	: SingleMthdTest(opt, seed, name, trapbit, cls, mthd), which(which) {}
};

enum {
	SURF2D_NV4 = 0,
	SURF2D_NV10 = 1,
	SURF2D_SWZOK = 2,
};

class MthdCtxSurf2D : public SingleMthdTest {
	bool new_ok;
	bool swz_ok;
	bool supported() override {
		return chipset.chipset >= 5;
	}
	bool is_valid_mthd() override {
		if (chipset.card_type >= 0x20 && ((cls & 0xff) == 0x7b || cls == 0x79))
			return true;
		return extr(exp.debug[3], 29, 1);
	}
	bool takes_ctxobj() override { return true; }
	void emulate_mthd() override;
	using SingleMthdTest::SingleMthdTest;
public:
	MthdCtxSurf2D(hwtest::TestOptions &opt, uint32_t seed, const std::string &name, int trapbit, uint32_t cls, uint32_t mthd, int flags)
	: SingleMthdTest(opt, seed, name, trapbit, cls, mthd) {
		new_ok = !!(flags & SURF2D_NV10);
		swz_ok = !!(flags & SURF2D_SWZOK);
	}
};

class MthdCtxSurf3D : public SingleMthdTest {
	bool new_ok;
	bool takes_ctxobj() override { return true; }
	void emulate_mthd() override;
	using SingleMthdTest::SingleMthdTest;
public:
	MthdCtxSurf3D(hwtest::TestOptions &opt, uint32_t seed, const std::string &name, int trapbit, uint32_t cls, uint32_t mthd, int flags)
	: SingleMthdTest(opt, seed, name, trapbit, cls, mthd) {
		new_ok = !!(flags & SURF2D_NV10);
	}
};

class MthdClipXy : public SingleMthdTest {
	int which_clip;
	bool is_max;
	void adjust_orig_mthd() override {
		if (!(rnd() & 3)) {
			val &= ~0xffff;
		}
		if (!(rnd() & 3)) {
			val &= ~0xffff0000;
		}
		if (rnd() & 1) {
			val ^= 1 << (rnd() & 0x1f);
		}
	}
	void emulate_mthd() override;
	using SingleMthdTest::SingleMthdTest;
public:
	MthdClipXy(hwtest::TestOptions &opt, uint32_t seed, const std::string &name, int trapbit, uint32_t cls, uint32_t mthd, int which_clip, bool is_max)
	: SingleMthdTest(opt, seed, name, trapbit, cls, mthd), which_clip(which_clip), is_max(is_max) {}
};

class MthdClipRect : public SingleMthdTest {
	int which_clip;
	void adjust_orig_mthd() override {
		if (!(rnd() & 3)) {
			val &= ~0xffff;
		}
		if (!(rnd() & 3)) {
			val &= ~0xffff0000;
		}
		if (rnd() & 1) {
			val ^= 1 << (rnd() & 0x1f);
		}
	}
	void emulate_mthd() override;
	using SingleMthdTest::SingleMthdTest;
public:
	MthdClipRect(hwtest::TestOptions &opt, uint32_t seed, const std::string &name, int trapbit, uint32_t cls, uint32_t mthd, int which_clip)
	: SingleMthdTest(opt, seed, name, trapbit, cls, mthd), which_clip(which_clip) {}
};

class MthdClipHv : public SingleMthdTest {
	int which_clip;
	int which_hv;
	bool supported() override {
		return chipset.chipset >= 5;
	}
	void adjust_orig_mthd() override {
		if (!(rnd() & 3)) {
			val &= ~0xffff;
		}
		if (!(rnd() & 3)) {
			val &= ~0xffff0000;
		}
		if (rnd() & 1) {
			val ^= 1 << (rnd() & 0x1f);
		}
	}
	bool is_valid_mthd() override {
		return chipset.card_type >= 0x10 || extr(exp.debug[3], 25, 1);
	}
	bool is_valid_val() override;
	void emulate_mthd() override;
public:
	MthdClipHv(hwtest::TestOptions &opt, uint32_t seed, const std::string &name, int trapbit, uint32_t cls, uint32_t mthd, int which_clip, int which_hv)
	: SingleMthdTest(opt, seed, name, trapbit, cls, mthd), which_clip(which_clip), which_hv(which_hv) {}
};

class MthdFlipSet : public SingleMthdTest {
	int which_set;
	int which;
	void adjust_orig_mthd() override {
		if (rnd() & 1) {
			val &= 0xf;
			val ^= 1 << (rnd() & 0x1f);
		}
	}
	bool is_valid_val() override {
		return val < 8;
	}
	void emulate_mthd() override;
public:
	MthdFlipSet(hwtest::TestOptions &opt, uint32_t seed, const std::string &name, int trapbit, uint32_t cls, uint32_t mthd, int which_set, int which)
	: SingleMthdTest(opt, seed, name, trapbit, cls, mthd), which_set(which_set), which(which) {}
};

class MthdFlipBumpWrite : public SingleMthdTest {
	int which_set;
	void emulate_mthd() override;
public:
	MthdFlipBumpWrite(hwtest::TestOptions &opt, uint32_t seed, const std::string &name, int trapbit, uint32_t cls, uint32_t mthd, int which_set)
	: SingleMthdTest(opt, seed, name, trapbit, cls, mthd), which_set(which_set) {}
};

enum {
	VTX_FIRST = 1,
	VTX_POLY = 2,
	VTX_DRAW = 4,
	VTX_FRACT = 8,
	VTX_NOCLIP = 0x10,
	VTX_IFC = 0x20,
	VTX_CHECK = 0x40,
	VTX_TFC = 0x80,
};

class MthdVtxXy : public SingleMthdTest {
	bool first, poly, draw, fract, noclip, ifc, check, tfc;
	bool is_valid_val() override {
		if (tfc && val & 7)
			return false;
		if (!check)
			return true;
		if (chipset.card_type < 4)
			return true;
		return !(val & 0x80008000);
	}
	void adjust_orig_mthd() override;
	void emulate_mthd() override;
	bool other_fail() override;
public:
	MthdVtxXy(hwtest::TestOptions &opt, uint32_t seed, const std::string &name, int trapbit, uint32_t cls, uint32_t mthd, uint32_t num, uint32_t stride, int flags)
	: SingleMthdTest(opt, seed, name, trapbit, cls, mthd, num, stride) {
		first = !!(flags & VTX_FIRST);
		poly = !!(flags & VTX_POLY);
		draw = !!(flags & VTX_DRAW);
		fract = !!(flags & VTX_FRACT);
		noclip = !!(flags & VTX_NOCLIP);
		ifc = !!(flags & VTX_IFC);
		check = !!(flags & VTX_CHECK);
		tfc = !!(flags & VTX_TFC);
	}
};

class MthdVtxX32 : public SingleMthdTest {
	bool first, poly;
	void adjust_orig_mthd() override;
	void emulate_mthd() override;
public:
	MthdVtxX32(hwtest::TestOptions &opt, uint32_t seed, const std::string &name, int trapbit, uint32_t cls, uint32_t mthd, uint32_t num, uint32_t stride, int flags)
	: SingleMthdTest(opt, seed, name, trapbit, cls, mthd, num, stride) {
		first = !!(flags & VTX_FIRST);
		poly = !!(flags & VTX_POLY);
	}
};

class MthdVtxY32 : public SingleMthdTest {
	bool poly, draw;
	void adjust_orig_mthd() override;
	void emulate_mthd() override;
	bool other_fail() override;
public:
	MthdVtxY32(hwtest::TestOptions &opt, uint32_t seed, const std::string &name, int trapbit, uint32_t cls, uint32_t mthd, uint32_t num, uint32_t stride, int flags)
	: SingleMthdTest(opt, seed, name, trapbit, cls, mthd, num, stride) {
		poly = !!(flags & VTX_POLY);
		draw = !!(flags & VTX_DRAW);
	}
};

class MthdRect : public SingleMthdTest {
	bool draw, noclip;
	void adjust_orig_mthd() override;
	void emulate_mthd() override;
	bool other_fail() override;
public:
	MthdRect(hwtest::TestOptions &opt, uint32_t seed, const std::string &name, int trapbit, uint32_t cls, uint32_t mthd, uint32_t num, uint32_t stride, int flags)
	: SingleMthdTest(opt, seed, name, trapbit, cls, mthd, num, stride) {
		draw = !!(flags & VTX_DRAW);
		noclip = !!(flags & VTX_NOCLIP);
	}
};

enum {
	IFC_IFM = 1,
	IFC_IN = 2,
	IFC_OUT = 4,
	IFC_TFC = 8,
	IFC_BITMAP = 0x10,
};

class MthdIfcSize : public SingleMthdTest {
	bool is_ifm, is_in, is_out, is_tfc, is_bitmap;
	void adjust_orig_mthd() override {
		if (chipset.card_type < 3) {
			if (!(rnd() & 3))
				insrt(orig.access, 12, 5, rnd() & 1 ? 0x12 : 0x14);
		}
		if (!(rnd() & 3))
			val &= 0xff00ff;
		if (!(rnd() & 3))
			val &= 0xffff000f;
	}
	void emulate_mthd() override;
	bool is_valid_val() override {
		return !is_tfc || !(val & 7);
	}
public:
	MthdIfcSize(hwtest::TestOptions &opt, uint32_t seed, const std::string &name, int trapbit, uint32_t cls, uint32_t mthd, int flags)
	: SingleMthdTest(opt, seed, name, trapbit, cls, mthd) {
		is_ifm = !!(flags & IFC_IFM);
		is_in = !!(flags & IFC_IN);
		is_out = !!(flags & IFC_OUT);
		is_tfc = !!(flags & IFC_TFC);
		is_bitmap = !!(flags & IFC_BITMAP);
	}
};

class MthdBitmapData : public SingleMthdTest {
	bool twocolor;
	void adjust_orig_mthd() override;
	void emulate_mthd_pre() override;
	void emulate_mthd() override;
public:
	MthdBitmapData(hwtest::TestOptions &opt, uint32_t seed, const std::string &name, int trapbit, uint32_t cls, uint32_t mthd, uint32_t num, uint32_t stride, bool twocolor)
	: SingleMthdTest(opt, seed, name, trapbit, cls, mthd, num, stride), twocolor(twocolor) {}
};

}
}

#endif