summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Koƛcielnicki <koriakin@0x04.net>2016-12-31 02:48:59 +0000
committerMarcin Koƛcielnicki <koriakin@0x04.net>2016-12-31 02:48:59 +0000
commit3a8cd6d329de2c24c28e0a9eef72ffc1766efb7e (patch)
treeb17e10b2158bb088a324dedc64b6e206a13d583b
parentf3a6b4e3c8d08a9d2b16e388b7cafb9f28701497 (diff)
hwtest/pgraph: Nailed down surf3d_format method on Kelvin.
-rw-r--r--hwtest/pgraph_class_surf.cc84
-rw-r--r--hwtest/pgraph_mthd.cc3
-rw-r--r--hwtest/pgraph_mthd.h13
3 files changed, 83 insertions, 17 deletions
diff --git a/hwtest/pgraph_class_surf.cc b/hwtest/pgraph_class_surf.cc
index 2480897c..77208032 100644
--- a/hwtest/pgraph_class_surf.cc
+++ b/hwtest/pgraph_class_surf.cc
@@ -361,7 +361,17 @@ bool MthdSurf3DFormat::is_valid_val() {
if (fmt == 0 || fmt > (is_celsius ? 0xa : 8))
return false;
int zfmt = extr(val, 4, 4);
- if (((cls == 0x53 || cls == 0x93 || cls == 0x96) && extr(exp.ctx_switch[0], 22, 1)) || cls == 0x98 || cls == 0x99) {
+ bool considered_new = false;
+ if ((cls == 0x53 || cls == 0x93 || cls == 0x96) && extr(exp.ctx_switch[0], 22, 1))
+ considered_new = true;
+ if ((cls == 0x56 || cls == 0x85) && extr(exp.ctx_switch[0], 22, 1) && chipset.card_type >= 0x20)
+ considered_new = true;
+ if (cls == 0x98 || cls == 0x99)
+ considered_new = true;
+ if ((cls & 0xff) == 0x97) {
+ if (zfmt != 1 && zfmt != 2)
+ return false;
+ } else if (considered_new) {
if (zfmt > 1)
return false;
} else {
@@ -369,30 +379,54 @@ bool MthdSurf3DFormat::is_valid_val() {
return false;
}
int mode = extr(val, 8, 4);
+ unsigned max_swz = 0xb;
if (mode == 0 || mode > 2)
return false;
- if (zfmt == 1 && mode == 2 && cls != 0x53 && cls != 0x93)
- return false;
- if (zfmt == 1 && (fmt == 9 || fmt == 0xa))
- return false;
- if (cls == 0x99) {
+ if ((cls & 0xff) == 0x97) {
int v = extr(val, 12, 4);
- if (v != 0 && v != 3)
+ if (v > (cls == 0x597 ? 4 : 2))
+ return false;
+ if (v && mode == 2)
+ return false;
+ max_swz = 0xc;
+ int expz;
+ if (fmt < 4)
+ expz = 1;
+ else if (fmt < 9)
+ expz = 2;
+ else
+ expz = 0;
+ if (mode == 2 && zfmt != expz && expz != 0)
+ return false;
+ if (!extr(val, 16, 8) && extr(val, 24, 8))
+ return false;
+ if (cls == 0x597 && (fmt == 6 || fmt == 7))
return false;
} else {
- if (extr(val, 12, 4))
+ if (zfmt == 1 && mode == 2 && cls != 0x53 && cls != 0x93)
return false;
+ if (zfmt == 1 && (fmt == 9 || fmt == 0xa))
+ return false;
+ if (cls == 0x99) {
+ int v = extr(val, 12, 4);
+ if (v != 0 && v != 3)
+ return false;
+ } else {
+ if (extr(val, 12, 4))
+ return false;
+ }
}
- if (extr(val, 16, 8) > 0xb)
+ if (extr(val, 16, 8) > max_swz)
return false;
- if (extr(val, 24, 8) > 0xb)
+ if (extr(val, 24, 8) > max_swz)
return false;
return true;
}
void MthdSurf3DFormat::emulate_mthd() {
int fmt = 0;
- switch (val & 0xf) {
+ int sfmt = val & 0xf;
+ switch (sfmt) {
case 1:
fmt = 0x2;
break;
@@ -428,10 +462,30 @@ void MthdSurf3DFormat::emulate_mthd() {
}
insrt(exp.surf_format, 8, 4, fmt);
insrt(exp.surf_type, 0, 2, extr(val, 8, 2));
- if (nv04_pgraph_is_nv11p(&chipset))
- insrt(exp.surf_type, 4, 1, extr(val, 4, 1));
- if (nv04_pgraph_is_nv17p(&chipset))
- insrt(exp.surf_type, 5, 1, extr(val, 12, 1));
+ if (chipset.card_type < 0x20) {
+ if (nv04_pgraph_is_nv11p(&chipset))
+ insrt(exp.surf_type, 4, 1, extr(val, 4, 1));
+ if (nv04_pgraph_is_nv17p(&chipset))
+ insrt(exp.surf_type, 5, 1, extr(val, 12, 1));
+ } else {
+ if (nv04_pgraph_is_nv25p(&chipset))
+ insrt(exp.surf_type, 4, 3, extr(val, 12, 3));
+ else
+ insrt(exp.surf_type, 4, 2, extr(val, 12, 2));
+ if ((cls & 0xff) == 0x97) {
+ int zfmt = extr(val, 4, 4);
+ if (zfmt > 2)
+ zfmt = 0;
+ insrt(exp.surf_format, 12, 4, zfmt);
+ } else {
+ int zfmt = extr(val, 4, 1) ? 1 : 2;
+ if (sfmt == 1 || sfmt == 2 || sfmt == 3 || sfmt == 9 || sfmt == 0xa)
+ zfmt = 1;
+ if (!fmt)
+ zfmt = 0;
+ insrt(exp.surf_format, 12, 4, zfmt);
+ }
+ }
insrt(exp.surf_swizzle[0], 16, 4, extr(val, 16, 4));
insrt(exp.surf_swizzle[0], 24, 4, extr(val, 24, 4));
}
diff --git a/hwtest/pgraph_mthd.cc b/hwtest/pgraph_mthd.cc
index 5353e764..b76ad0a2 100644
--- a/hwtest/pgraph_mthd.cc
+++ b/hwtest/pgraph_mthd.cc
@@ -336,6 +336,9 @@ void MthdTest::adjust_orig() {
val = rnd();
subc = rnd() & 7;
gctx = rnd();
+ if (rnd() & 3 && chipset.card_type >= 3) {
+ insrt(orig.debug[3], 20, 2, 1);
+ }
choose_mthd();
adjust_orig_mthd();
if (!special_notify()) {
diff --git a/hwtest/pgraph_mthd.h b/hwtest/pgraph_mthd.h
index a722d5b9..126643f7 100644
--- a/hwtest/pgraph_mthd.h
+++ b/hwtest/pgraph_mthd.h
@@ -274,8 +274,17 @@ class MthdSurf3DFormat : public SingleMthdTest {
bool is_valid_val() override;
void adjust_orig_mthd() override {
if (rnd() & 1) {
- val &= 0x0f0f331f;
- val ^= 1 << (rnd() & 0x1f);
+ val &= 0x0f0f373f;
+ if (rnd() & 3)
+ insrt(val, 8, 4, rnd() & 1 ? 2 : 1);
+ if (rnd() & 3)
+ insrt(val, 12, 4, 0);
+ if (rnd() & 3)
+ insrt(val, 16, 4, rnd() % 0xd);
+ if (rnd() & 3)
+ insrt(val, 20, 4, rnd() % 0xd);
+ if (rnd() & 1)
+ val ^= 1 << (rnd() & 0x1f);
}
}
void emulate_mthd() override;