summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Koƛcielnicki <koriakin@0x04.net>2016-12-26 22:14:24 +0000
committerMarcin Koƛcielnicki <koriakin@0x04.net>2016-12-26 22:14:24 +0000
commitdf2ad5c55885ed4b0fd72931b1ae86f083386deb (patch)
tree75f688cb79f90d5d0b067c1c811ed8eff1cdf719
parentfc51424ed7197d0571b8ef9cdbbfa3b18b185199 (diff)
hwtest/pgraph: Convert celsius rc mthd tests.
-rw-r--r--hwtest/nv04_pgraph.cc259
-rw-r--r--hwtest/pgraph_class_celsius.cc279
2 files changed, 272 insertions, 266 deletions
diff --git a/hwtest/nv04_pgraph.cc b/hwtest/nv04_pgraph.cc
index 4b0d5915..a5b6a3d0 100644
--- a/hwtest/nv04_pgraph.cc
+++ b/hwtest/nv04_pgraph.cc
@@ -408,261 +408,6 @@ static int test_invalid_mthd_celsius(struct hwtest_ctx *ctx) {
return HWTEST_RES_PASS;
}
-static int test_mthd_celsius_rc_in(struct hwtest_ctx *ctx) {
- int i;
- for (i = 0; i < 10000; i++) {
- uint32_t val = jrand48(ctx->rand48);
- if (jrand48(ctx->rand48) & 1) {
- if (jrand48(ctx->rand48) & 1) {
- insrt(val, 0, 4, 0xd);
- }
- if (jrand48(ctx->rand48) & 1) {
- insrt(val, 8, 4, 0xd);
- }
- if (jrand48(ctx->rand48) & 1) {
- insrt(val, 16, 4, 0xd);
- }
- if (jrand48(ctx->rand48) & 1) {
- insrt(val, 24, 4, 0xd);
- }
- if (jrand48(ctx->rand48) & 1) {
- val |= 1 << (jrand48(ctx->rand48) & 0x1f);
- }
- if (jrand48(ctx->rand48) & 1) {
- val |= 1 << (jrand48(ctx->rand48) & 0x1f);
- }
- }
- uint32_t cls, mthd;
- int idx;
- int trapbit;
- bool color = jrand48(ctx->rand48) & 1;
- idx = jrand48(ctx->rand48) & 1;
- cls = get_random_celsius(ctx);
- mthd = 0x260 + idx * 4 + color * 8;
- trapbit = 23 + color;
- uint32_t addr = (jrand48(ctx->rand48) & 0xe000) | mthd;
- struct pgraph_state orig, exp, real;
- nv04_pgraph_gen_state(ctx, &orig);
- orig.notify &= ~0x10000;
- uint32_t grobj[4];
- nv04_pgraph_prep_mthd(ctx, grobj, &orig, cls, addr, val);
- nv04_pgraph_load_state(ctx, &orig);
- exp = orig;
- nv04_pgraph_mthd(&exp, grobj, trapbit);
- if (!extr(exp.intr, 4, 1)) {
- bool bad = false;
- for (int j = 0; j < 4; j++) {
- int reg = extr(val, 8 * j, 4);
- if (reg == 6 || reg == 7 || reg == 0xa || reg == 0xb || reg >= 0xe)
- bad = true;
- }
- if (extr(exp.debug[3], 20, 1) && bad)
- nv04_pgraph_blowup(&exp, 2);
- if (!exp.intr) {
- exp.celsius_rc_in[color][idx] = val;
- }
- }
- nv04_pgraph_dump_state(ctx, &real);
- if (nv04_pgraph_cmp_state(&orig, &exp, &real)) {
- printf("Iter %d mthd %02x.%04x %08x\n", i, cls, addr, val);
- return HWTEST_RES_FAIL;
- }
- }
- return HWTEST_RES_PASS;
-}
-
-static int test_mthd_celsius_rc_factor(struct hwtest_ctx *ctx) {
- int i;
- for (i = 0; i < 10000; i++) {
- uint32_t val = jrand48(ctx->rand48);
- uint32_t cls, mthd;
- int idx;
- int trapbit;
- idx = jrand48(ctx->rand48) & 1;
- cls = get_random_celsius(ctx);
- mthd = 0x270 + idx * 4;
- trapbit = 25;
- uint32_t addr = (jrand48(ctx->rand48) & 0xe000) | mthd;
- struct pgraph_state orig, exp, real;
- nv04_pgraph_gen_state(ctx, &orig);
- orig.notify &= ~0x10000;
- uint32_t grobj[4];
- nv04_pgraph_prep_mthd(ctx, grobj, &orig, cls, addr, val);
- nv04_pgraph_load_state(ctx, &orig);
- exp = orig;
- nv04_pgraph_mthd(&exp, grobj, trapbit);
- if (!extr(exp.intr, 4, 1)) {
- if (!exp.intr) {
- exp.celsius_rc_factor[idx] = val;
- }
- }
- nv04_pgraph_dump_state(ctx, &real);
- if (nv04_pgraph_cmp_state(&orig, &exp, &real)) {
- printf("Iter %d mthd %02x.%04x %08x\n", i, cls, addr, val);
- return HWTEST_RES_FAIL;
- }
- }
- return HWTEST_RES_PASS;
-}
-
-static int test_mthd_celsius_rc_out(struct hwtest_ctx *ctx) {
- int i;
- for (i = 0; i < 10000; i++) {
- uint32_t val = jrand48(ctx->rand48);
- if (jrand48(ctx->rand48) & 1) {
- if (jrand48(ctx->rand48) & 1) {
- insrt(val, 18, 14, 0);
- }
- if (jrand48(ctx->rand48) & 1) {
- insrt(val, 28, 2, 1);
- }
- if (jrand48(ctx->rand48) & 1) {
- insrt(val, 12, 2, 0);
- }
- if (jrand48(ctx->rand48) & 1) {
- insrt(val, 0, 4, 0xd);
- }
- if (jrand48(ctx->rand48) & 1) {
- insrt(val, 4, 4, 0xd);
- }
- if (jrand48(ctx->rand48) & 1) {
- insrt(val, 8, 4, 0xd);
- }
- if (jrand48(ctx->rand48) & 1) {
- val |= 1 << (jrand48(ctx->rand48) & 0x1f);
- }
- if (jrand48(ctx->rand48) & 1) {
- val |= 1 << (jrand48(ctx->rand48) & 0x1f);
- }
- }
- uint32_t cls, mthd;
- int idx;
- int trapbit;
- bool color = jrand48(ctx->rand48) & 1;
- idx = jrand48(ctx->rand48) & 1;
- cls = get_random_celsius(ctx);
- mthd = 0x278 + idx * 4 + color * 8;
- trapbit = 26 + color;
- uint32_t addr = (jrand48(ctx->rand48) & 0xe000) | mthd;
- struct pgraph_state orig, exp, real;
- nv04_pgraph_gen_state(ctx, &orig);
- orig.notify &= ~0x10000;
- uint32_t grobj[4];
- nv04_pgraph_prep_mthd(ctx, grobj, &orig, cls, addr, val);
- nv04_pgraph_load_state(ctx, &orig);
- exp = orig;
- nv04_pgraph_mthd(&exp, grobj, trapbit);
- if (!extr(exp.intr, 4, 1)) {
- bool bad = false;
- uint32_t rval;
- int op = extr(val, 15, 3);
- if (op == 5 || op == 7)
- bad = true;
- if (!color) {
- rval = val & 0x3cfff;
- if (extr(val, 12, 2))
- bad = true;
- if (extr(val, 27, 3))
- bad = true;
- } else if (!idx) {
- rval = val & 0x3ffff;
- if (extr(val, 27, 3))
- bad = true;
- } else {
- rval = val & 0x3803ffff;
- int cnt = extr(val, 28, 2);
- if (cnt == 0 || cnt == 3)
- bad = true;
- }
- for (int j = 0; j < 3; j++) {
- int reg = extr(val, 4 * j, 4);
- if (reg != 0 && reg != 4 && reg != 5 && reg != 8 && reg != 9 && reg != 0xc && reg != 0xd)
- bad = true;
- }
- if (extr(val, 18, 9))
- bad = true;
- if (extr(val, 30, 2))
- bad = true;
- if (extr(exp.debug[3], 20, 1) && bad)
- nv04_pgraph_blowup(&exp, 2);
- if (!exp.intr) {
- exp.celsius_rc_out[color][idx] = rval;
- }
- }
- nv04_pgraph_dump_state(ctx, &real);
- if (nv04_pgraph_cmp_state(&orig, &exp, &real)) {
- printf("Iter %d mthd %02x.%04x %08x\n", i, cls, addr, val);
- return HWTEST_RES_FAIL;
- }
- }
- return HWTEST_RES_PASS;
-}
-
-static int test_mthd_celsius_rc_final(struct hwtest_ctx *ctx) {
- int i;
- for (i = 0; i < 10000; i++) {
- uint32_t val = jrand48(ctx->rand48);
- int which = jrand48(ctx->rand48) & 1;
- if (jrand48(ctx->rand48) & 1) {
- val &= which ? 0x3f3f3fe0 : 0x3f3f3f3f;
- if (jrand48(ctx->rand48) & 1) {
- val |= 1 << (jrand48(ctx->rand48) & 0x1f);
- }
- if (jrand48(ctx->rand48) & 1) {
- val |= 1 << (jrand48(ctx->rand48) & 0x1f);
- }
- }
- uint32_t cls, mthd;
- int trapbit;
- cls = get_random_celsius(ctx);
- mthd = 0x288 + which * 4;
- trapbit = 28 + which;
- uint32_t addr = (jrand48(ctx->rand48) & 0xe000) | mthd;
- struct pgraph_state orig, exp, real;
- nv04_pgraph_gen_state(ctx, &orig);
- orig.notify &= ~0x10000;
- uint32_t grobj[4];
- nv04_pgraph_prep_mthd(ctx, grobj, &orig, cls, addr, val);
- nv04_pgraph_load_state(ctx, &orig);
- exp = orig;
- nv04_pgraph_mthd(&exp, grobj, trapbit);
- if (!extr(exp.intr, 4, 1)) {
- bool bad = false;
- uint32_t rval;
- if (!which) {
- rval = val & 0x3f3f3f3f;
- if (val & 0xc0c0c0c0)
- bad = true;
- for (int j = 0; j < 4; j++) {
- int reg = extr(val, 8 * j, 4);
- if (reg == 6 || reg == 7 || reg == 0xa || reg == 0xb)
- bad = true;
- }
- } else {
- rval = val & 0x3f3f3fe0;
- if (val & 0xc0c0c01f)
- bad = true;
- for (int j = 1; j < 4; j++) {
- int reg = extr(val, 8 * j, 4);
- if (reg == 6 || reg == 7 || reg == 0xa || reg == 0xb || reg >= 0xe)
- bad = true;
- }
- }
- if (extr(exp.debug[3], 20, 1) && bad)
- nv04_pgraph_blowup(&exp, 2);
- if (!exp.intr) {
- exp.celsius_rc_final[which] = rval;
- }
- }
- nv04_pgraph_dump_state(ctx, &real);
- if (nv04_pgraph_cmp_state(&orig, &exp, &real)) {
- printf("Iter %d mthd %02x.%04x %08x\n", i, cls, addr, val);
- return HWTEST_RES_FAIL;
- }
- }
- return HWTEST_RES_PASS;
-}
-
static int test_mthd_celsius_unk290(struct hwtest_ctx *ctx) {
int i;
for (i = 0; i < 10000; i++) {
@@ -795,10 +540,6 @@ HWTEST_DEF_GROUP(invalid_mthd,
)
HWTEST_DEF_GROUP(celsius_mthd,
- HWTEST_TEST(test_mthd_celsius_rc_in, 0),
- HWTEST_TEST(test_mthd_celsius_rc_factor, 0),
- HWTEST_TEST(test_mthd_celsius_rc_out, 0),
- HWTEST_TEST(test_mthd_celsius_rc_final, 0),
HWTEST_TEST(test_mthd_celsius_unk290, 0),
HWTEST_TEST(test_mthd_celsius_light_model, 0),
)
diff --git a/hwtest/pgraph_class_celsius.cc b/hwtest/pgraph_class_celsius.cc
index 0a51684f..b8d0c646 100644
--- a/hwtest/pgraph_class_celsius.cc
+++ b/hwtest/pgraph_class_celsius.cc
@@ -375,6 +375,211 @@ class MthdCelsiusTexPalette : public SingleMthdTest {
using SingleMthdTest::SingleMthdTest;
};
+class MthdCelsiusRcInAlpha : public SingleMthdTest {
+ void adjust_orig_mthd() override {
+ if (rnd() & 1) {
+ if (rnd() & 1) {
+ insrt(val, 0, 4, 0xd);
+ }
+ if (rnd() & 1) {
+ insrt(val, 8, 4, 0xd);
+ }
+ if (rnd() & 1) {
+ insrt(val, 16, 4, 0xd);
+ }
+ if (rnd() & 1) {
+ insrt(val, 24, 4, 0xd);
+ }
+ if (rnd() & 1) {
+ val |= 1 << (rnd() & 0x1f);
+ }
+ if (rnd() & 1) {
+ val |= 1 << (rnd() & 0x1f);
+ }
+ }
+ }
+ bool is_valid_val() override {
+ for (int j = 0; j < 4; j++) {
+ int reg = extr(val, 8 * j, 4);
+ if (reg == 6 || reg == 7 || reg == 0xa || reg == 0xb || reg >= 0xe)
+ return false;
+ }
+ return true;
+ }
+ void emulate_mthd() override {
+ if (!extr(exp.nsource, 1, 1)) {
+ exp.celsius_rc_in[0][idx] = val;
+ }
+ }
+ using SingleMthdTest::SingleMthdTest;
+};
+
+class MthdCelsiusRcInColor : public SingleMthdTest {
+ void adjust_orig_mthd() override {
+ if (rnd() & 1) {
+ if (rnd() & 1) {
+ insrt(val, 0, 4, 0xd);
+ }
+ if (rnd() & 1) {
+ insrt(val, 8, 4, 0xd);
+ }
+ if (rnd() & 1) {
+ insrt(val, 16, 4, 0xd);
+ }
+ if (rnd() & 1) {
+ insrt(val, 24, 4, 0xd);
+ }
+ if (rnd() & 1) {
+ val |= 1 << (rnd() & 0x1f);
+ }
+ if (rnd() & 1) {
+ val |= 1 << (rnd() & 0x1f);
+ }
+ }
+ }
+ bool is_valid_val() override {
+ for (int j = 0; j < 4; j++) {
+ int reg = extr(val, 8 * j, 4);
+ if (reg == 6 || reg == 7 || reg == 0xa || reg == 0xb || reg >= 0xe)
+ return false;
+ }
+ return true;
+ }
+ void emulate_mthd() override {
+ if (!extr(exp.nsource, 1, 1)) {
+ exp.celsius_rc_in[1][idx] = val;
+ }
+ }
+ using SingleMthdTest::SingleMthdTest;
+};
+
+class MthdCelsiusRcFactor : public SingleMthdTest {
+ void emulate_mthd() override {
+ if (!extr(exp.nsource, 1, 1)) {
+ exp.celsius_rc_factor[idx] = val;
+ }
+ }
+ using SingleMthdTest::SingleMthdTest;
+};
+
+class MthdCelsiusRcOutAlpha : public SingleMthdTest {
+ void adjust_orig_mthd() override {
+ if (rnd() & 1) {
+ if (rnd() & 1) {
+ insrt(val, 18, 14, 0);
+ }
+ if (rnd() & 1) {
+ insrt(val, 28, 2, 1);
+ }
+ if (rnd() & 1) {
+ insrt(val, 12, 2, 0);
+ }
+ if (rnd() & 1) {
+ insrt(val, 0, 4, 0xd);
+ }
+ if (rnd() & 1) {
+ insrt(val, 4, 4, 0xd);
+ }
+ if (rnd() & 1) {
+ insrt(val, 8, 4, 0xd);
+ }
+ if (rnd() & 1) {
+ val |= 1 << (rnd() & 0x1f);
+ }
+ if (rnd() & 1) {
+ val |= 1 << (rnd() & 0x1f);
+ }
+ }
+ }
+ bool is_valid_val() override {
+ int op = extr(val, 15, 3);
+ if (op == 5 || op == 7)
+ return false;
+ if (extr(val, 12, 2))
+ return false;
+ for (int j = 0; j < 3; j++) {
+ int reg = extr(val, 4 * j, 4);
+ if (reg != 0 && reg != 4 && reg != 5 && reg != 8 && reg != 9 && reg != 0xc && reg != 0xd)
+ return false;
+ }
+ if (extr(val, 18, 14))
+ return false;
+ return true;
+ }
+ void emulate_mthd() override {
+ if (!extr(exp.nsource, 1, 1)) {
+ exp.celsius_rc_out[0][idx] = val & 0x3cfff;
+ }
+ }
+ using SingleMthdTest::SingleMthdTest;
+};
+
+class MthdCelsiusRcOutColor : public SingleMthdTest {
+ void adjust_orig_mthd() override {
+ if (rnd() & 1) {
+ if (rnd() & 1) {
+ insrt(val, 18, 14, 0);
+ }
+ if (rnd() & 1) {
+ insrt(val, 28, 2, 1);
+ }
+ if (rnd() & 1) {
+ insrt(val, 12, 2, 0);
+ }
+ if (rnd() & 1) {
+ insrt(val, 0, 4, 0xd);
+ }
+ if (rnd() & 1) {
+ insrt(val, 4, 4, 0xd);
+ }
+ if (rnd() & 1) {
+ insrt(val, 8, 4, 0xd);
+ }
+ if (rnd() & 1) {
+ val |= 1 << (rnd() & 0x1f);
+ }
+ if (rnd() & 1) {
+ val |= 1 << (rnd() & 0x1f);
+ }
+ }
+ }
+ bool is_valid_val() override {
+ int op = extr(val, 15, 3);
+ if (op == 5 || op == 7)
+ return false;
+ if (!idx) {
+ if (extr(val, 27, 3))
+ return false;
+ } else {
+ int cnt = extr(val, 28, 2);
+ if (cnt == 0 || cnt == 3)
+ return false;
+ }
+ for (int j = 0; j < 3; j++) {
+ int reg = extr(val, 4 * j, 4);
+ if (reg != 0 && reg != 4 && reg != 5 && reg != 8 && reg != 9 && reg != 0xc && reg != 0xd)
+ return false;
+ }
+ if (extr(val, 18, 9))
+ return false;
+ if (extr(val, 30, 2))
+ return false;
+ return true;
+ }
+ void emulate_mthd() override {
+ uint32_t rval;
+ if (!idx) {
+ rval = val & 0x3ffff;
+ } else {
+ rval = val & 0x3803ffff;
+ }
+ if (!extr(exp.nsource, 1, 1)) {
+ exp.celsius_rc_out[1][idx] = rval;
+ }
+ }
+ using SingleMthdTest::SingleMthdTest;
+};
+
class MthdDmaClipid : public SingleMthdTest {
bool takes_dma() override { return true; }
void emulate_mthd() override {
@@ -406,6 +611,66 @@ class MthdDmaClipid : public SingleMthdTest {
using SingleMthdTest::SingleMthdTest;
};
+class MthdCelsiusRcFinal0 : public SingleMthdTest {
+ void adjust_orig_mthd() override {
+ if (rnd() & 1) {
+ val &= 0x3f3f3f3f;
+ if (rnd() & 1) {
+ val |= 1 << (rnd() & 0x1f);
+ }
+ if (rnd() & 1) {
+ val |= 1 << (rnd() & 0x1f);
+ }
+ }
+ }
+ bool is_valid_val() override {
+ if (val & 0xc0c0c0c0)
+ return false;
+ for (int j = 0; j < 4; j++) {
+ int reg = extr(val, 8 * j, 4);
+ if (reg == 6 || reg == 7 || reg == 0xa || reg == 0xb)
+ return false;
+ }
+ return true;
+ }
+ void emulate_mthd() override {
+ if (!extr(exp.nsource, 1, 1)) {
+ exp.celsius_rc_final[0] = val & 0x3f3f3f3f;
+ }
+ }
+ using SingleMthdTest::SingleMthdTest;
+};
+
+class MthdCelsiusRcFinal1 : public SingleMthdTest {
+ void adjust_orig_mthd() override {
+ if (rnd() & 1) {
+ val &= 0x3f3f3fe0;
+ if (rnd() & 1) {
+ val |= 1 << (rnd() & 0x1f);
+ }
+ if (rnd() & 1) {
+ val |= 1 << (rnd() & 0x1f);
+ }
+ }
+ }
+ bool is_valid_val() override {
+ if (val & 0xc0c0c01f)
+ return false;
+ for (int j = 1; j < 4; j++) {
+ int reg = extr(val, 8 * j, 4);
+ if (reg == 6 || reg == 7 || reg == 0xa || reg == 0xb || reg >= 0xe)
+ return false;
+ }
+ return true;
+ }
+ void emulate_mthd() override {
+ if (!extr(exp.nsource, 1, 1)) {
+ exp.celsius_rc_final[1] = val & 0x3f3f3fe0;
+ }
+ }
+ using SingleMthdTest::SingleMthdTest;
+};
+
class MthdDmaZcull : public SingleMthdTest {
bool takes_dma() override { return true; }
void emulate_mthd() override {
@@ -761,13 +1026,13 @@ std::vector<SingleMthdTest *> Celsius::mthds() {
new MthdCelsiusTexRect(opt, rnd(), "tex_rect", 20, cls, 0x240, 2),
new MthdCelsiusTexFilter(opt, rnd(), "tex_filter", 21, cls, 0x248, 2),
new MthdCelsiusTexPalette(opt, rnd(), "tex_palette", 22, cls, 0x250, 2),
- new UntestedMthd(opt, rnd(), "meh", 23, cls, 0x260, 2), // XXX
- new UntestedMthd(opt, rnd(), "meh", 24, cls, 0x268, 2), // XXX
- new UntestedMthd(opt, rnd(), "meh", 25, cls, 0x270, 2), // XXX
- new UntestedMthd(opt, rnd(), "meh", 26, cls, 0x278, 2), // XXX
- new UntestedMthd(opt, rnd(), "meh", 27, cls, 0x280, 2), // XXX
- new UntestedMthd(opt, rnd(), "meh", 28, cls, 0x288), // XXX
- new UntestedMthd(opt, rnd(), "meh", 29, cls, 0x28c), // XXX
+ new MthdCelsiusRcInAlpha(opt, rnd(), "rc_in_alpha", 23, cls, 0x260, 2),
+ new MthdCelsiusRcInColor(opt, rnd(), "rc_in_color", 24, cls, 0x268, 2),
+ new MthdCelsiusRcFactor(opt, rnd(), "rc_factor", 25, cls, 0x270, 2),
+ new MthdCelsiusRcOutAlpha(opt, rnd(), "rc_out_alpha", 26, cls, 0x278, 2),
+ new MthdCelsiusRcOutColor(opt, rnd(), "rc_out_color", 27, cls, 0x280, 2),
+ new MthdCelsiusRcFinal0(opt, rnd(), "rc_final_0", 28, cls, 0x288),
+ new MthdCelsiusRcFinal1(opt, rnd(), "rc_final_1", 29, cls, 0x28c),
new UntestedMthd(opt, rnd(), "meh", 30, cls, 0x290), // XXX
new UntestedMthd(opt, rnd(), "meh", 31, cls, 0x294), // XXX
new UntestedMthd(opt, rnd(), "meh", -1, cls, 0x298), // XXX