diff options
author | Marcin KoĆcielnicki <koriakin@0x04.net> | 2016-12-04 23:15:32 +0100 |
---|---|---|
committer | Marcin KoĆcielnicki <koriakin@0x04.net> | 2016-12-04 23:15:32 +0100 |
commit | 6eab09b8ae6741700201c87366f48fb4b872a669 (patch) | |
tree | 8a7abeecc4628ed2ab9047757a2766bec8b75cd4 | |
parent | 0cb2c31a89c4f2ec67a189ac83c26e3b3837bbde (diff) |
hwtest/pgraph: vtx_x/vtx_y -> vtx_xy.
-rw-r--r-- | hwtest/nv01_pgraph.cc | 12 | ||||
-rw-r--r-- | hwtest/nv03_pgraph.cc | 30 | ||||
-rw-r--r-- | hwtest/nv04_pgraph.cc | 81 | ||||
-rw-r--r-- | hwtest/pgraph_mthd_sifm.cc | 12 | ||||
-rw-r--r-- | hwtest/pgraph_mthd_simple.cc | 2 | ||||
-rw-r--r-- | hwtest/pgraph_mthd_xy.cc | 178 | ||||
-rw-r--r-- | hwtest/pgraph_state.cc | 16 | ||||
-rw-r--r-- | hwtest/pgraph_state_tests.cc | 42 | ||||
-rw-r--r-- | include/nvhw/pgraph.h | 7 | ||||
-rw-r--r-- | nvhw/pgraph.c | 8 | ||||
-rw-r--r-- | nvhw/pgraph_xy.c | 32 | ||||
-rw-r--r-- | nvhw/pgraph_xy3.c | 17 | ||||
-rw-r--r-- | nvhw/pgraph_xy4.c | 6 |
13 files changed, 196 insertions, 247 deletions
diff --git a/hwtest/nv01_pgraph.cc b/hwtest/nv01_pgraph.cc index 14b9851a..8957299c 100644 --- a/hwtest/nv01_pgraph.cc +++ b/hwtest/nv01_pgraph.cc @@ -598,8 +598,8 @@ class RopSolidTest : public MthdTest { else epixel[i] = pixel[i]; } - exp.vtx_x[0] = x; - exp.vtx_y[0] = y; + exp.vtx_xy[0][0] = x; + exp.vtx_xy[0][1] = y; pgraph_clear_vtxid(&exp); pgraph_bump_vtxid(&exp); exp.xy_misc_1[0] &= ~0x03000001; @@ -690,10 +690,10 @@ class RopBlitTest : public MthdTest { orig.valid[0] |= 0xf10f; insrt(orig.access, 12, 5, 0x10); insrt(orig.pfb_config, 4, 3, 3); - orig.vtx_x[0] = sx; - orig.vtx_y[0] = sy; - orig.vtx_x[1] = x; - orig.vtx_y[1] = y; + orig.vtx_xy[0][0] = sx; + orig.vtx_xy[0][1] = sy; + orig.vtx_xy[1][0] = x; + orig.vtx_xy[1][1] = y; if (rnd()&1) insrt(orig.cliprect_min[rnd()&1], 0, 16, x); if (rnd()&1) diff --git a/hwtest/nv03_pgraph.cc b/hwtest/nv03_pgraph.cc index efde5f75..335014bf 100644 --- a/hwtest/nv03_pgraph.cc +++ b/hwtest/nv03_pgraph.cc @@ -422,13 +422,13 @@ static int test_rop_simple(struct hwtest_ctx *ctx) { nv03_pgraph_load_state(ctx, &orig); exp = orig; nv03_pgraph_mthd(ctx, &exp, grobj, gctx, addr, val); - exp.vtx_x[0] = x; - exp.vtx_y[0] = y; + exp.vtx_xy[0][0] = x; + exp.vtx_xy[0][1] = y; pgraph_clear_vtxid(&exp); pgraph_bump_vtxid(&exp); insrt(exp.xy_misc_1[1], 0, 1, 1); - int xcstat = nv03_pgraph_clip_status(&exp, exp.vtx_x[0], 0, false); - int ycstat = nv03_pgraph_clip_status(&exp, exp.vtx_y[0], 1, false); + int xcstat = nv03_pgraph_clip_status(&exp, exp.vtx_xy[0][0], 0, false); + int ycstat = nv03_pgraph_clip_status(&exp, exp.vtx_xy[0][1], 1, false); insrt(exp.xy_clip[0][0], 0, 4, xcstat); insrt(exp.xy_clip[0][0], 4, 4, xcstat); insrt(exp.xy_clip[1][0], 0, 4, ycstat); @@ -507,8 +507,8 @@ static int test_rop_zpoint(struct hwtest_ctx *ctx) { orig.debug[3] &= 0xfffdffff; int x = jrand48(ctx->rand48) & 0xff; int y = jrand48(ctx->rand48) & 0xff; - orig.vtx_x[0] = x; - orig.vtx_y[0] = y; + orig.vtx_xy[0][0] = x; + orig.vtx_xy[0][1] = y; orig.debug[3] &= ~(1 << 22); if (jrand48(ctx->rand48)&1) insrt(orig.cliprect_min[jrand48(ctx->rand48)&1], 0, 16, extr(val, 0, 8)); @@ -535,7 +535,7 @@ static int test_rop_zpoint(struct hwtest_ctx *ctx) { exp = orig; nv03_pgraph_mthd(ctx, &exp, grobj, gctx, addr, val); insrt(exp.misc32[1], 16, 16, extr(val, 16, 16)); - nv03_pgraph_vtx_add(&exp, 0, 0, exp.vtx_x[0], 1, 0, false); + nv03_pgraph_vtx_add(&exp, 0, 0, exp.vtx_xy[0][0], 1, 0, false); uint32_t zeta = extr(val, 16, 16); struct pgraph_color s = pgraph_expand_color(&exp, exp.misc32[0]); uint8_t ra = nv01_pgraph_dither_10to5(s.a << 2, x, y, false) >> 1; @@ -633,10 +633,10 @@ static int test_rop_blit(struct hwtest_ctx *ctx) { int y = jrand48(ctx->rand48) & 0xff; int sx = jrand48(ctx->rand48) & 0xff; int sy = jrand48(ctx->rand48) & 0xff; - orig.vtx_x[0] = sx; - orig.vtx_y[0] = sy; - orig.vtx_x[1] = x; - orig.vtx_y[1] = y; + orig.vtx_xy[0][0] = sx; + orig.vtx_xy[0][1] = sy; + orig.vtx_xy[1][0] = x; + orig.vtx_xy[1][1] = y; orig.debug[3] &= ~(1 << 22); nv03_pgraph_prep_mthd(&orig, &gctx, cls, addr); if (jrand48(ctx->rand48) & 1) @@ -660,10 +660,10 @@ static int test_rop_blit(struct hwtest_ctx *ctx) { pgraph_bump_vtxid(&exp); pgraph_bump_vtxid(&exp); insrt(exp.xy_misc_1[1], 0, 1, 1); - nv03_pgraph_vtx_add(&exp, 0, 2, exp.vtx_x[0], extr(val, 0, 16), 0, false); - nv03_pgraph_vtx_add(&exp, 1, 2, exp.vtx_y[0], extr(val, 16, 16), 0, false); - nv03_pgraph_vtx_add(&exp, 0, 3, exp.vtx_x[1], extr(val, 0, 16), 0, false); - nv03_pgraph_vtx_add(&exp, 1, 3, exp.vtx_y[1], extr(val, 16, 16), 0, false); + nv03_pgraph_vtx_add(&exp, 0, 2, exp.vtx_xy[0][0], extr(val, 0, 16), 0, false); + nv03_pgraph_vtx_add(&exp, 1, 2, exp.vtx_xy[0][1], extr(val, 16, 16), 0, false); + nv03_pgraph_vtx_add(&exp, 0, 3, exp.vtx_xy[1][0], extr(val, 0, 16), 0, false); + nv03_pgraph_vtx_add(&exp, 1, 3, exp.vtx_xy[1][1], extr(val, 16, 16), 0, false); nv03_pgraph_vtx_cmp(&exp, 0, 8, true); nv03_pgraph_vtx_cmp(&exp, 1, 8, true); if (pgraph_cliprect_pass(&exp, x, y)) { diff --git a/hwtest/nv04_pgraph.cc b/hwtest/nv04_pgraph.cc index b585f0fe..36c8b30d 100644 --- a/hwtest/nv04_pgraph.cc +++ b/hwtest/nv04_pgraph.cc @@ -573,8 +573,8 @@ static void nv04_pgraph_gen_state(struct hwtest_ctx *ctx, struct pgraph_state *s state->fifo_data_st2[0] = jrand48(ctx->rand48) & 0xffffffff; state->fifo_data_st2[1] = jrand48(ctx->rand48) & 0xffffffff; for (int i = 0; i < 32; i++) { - state->vtx_x[i] = jrand48(ctx->rand48); - state->vtx_y[i] = jrand48(ctx->rand48); + state->vtx_xy[i][0] = jrand48(ctx->rand48); + state->vtx_xy[i][1] = jrand48(ctx->rand48); } for (int i = 0; i < 16; i++) { state->vtx_u[i] = jrand48(ctx->rand48) & 0xffffffc0; @@ -776,8 +776,8 @@ static void nv04_pgraph_load_state(struct hwtest_ctx *ctx, struct pgraph_state * } if (ctx->chipset.card_type < 0x10) { for (int i = 0; i < 32; i++) { - nva_wr32(ctx->cnum, 0x400400 + i * 4, state->vtx_x[i]); - nva_wr32(ctx->cnum, 0x400480 + i * 4, state->vtx_y[i]); + nva_wr32(ctx->cnum, 0x400400 + i * 4, state->vtx_xy[i][0]); + nva_wr32(ctx->cnum, 0x400480 + i * 4, state->vtx_xy[i][1]); } for (int i = 0; i < 16; i++) { nva_wr32(ctx->cnum, 0x400d00 + i * 4, state->vtx_u[i]); @@ -786,8 +786,8 @@ static void nv04_pgraph_load_state(struct hwtest_ctx *ctx, struct pgraph_state * } } else { for (int i = 0; i < 10; i++) { - nva_wr32(ctx->cnum, 0x400400 + i * 4, state->vtx_x[i]); - nva_wr32(ctx->cnum, 0x400480 + i * 4, state->vtx_y[i]); + nva_wr32(ctx->cnum, 0x400400 + i * 4, state->vtx_xy[i][0]); + nva_wr32(ctx->cnum, 0x400480 + i * 4, state->vtx_xy[i][1]); } } nva_wr32(ctx->cnum, 0x400514, state->xy_a); @@ -1181,8 +1181,8 @@ static void nv04_pgraph_dump_state(struct hwtest_ctx *ctx, struct pgraph_state * state->ctx_format = nva_rd32(ctx->cnum, 0x400830); if (state->chipset.card_type < 0x10) { for (int i = 0; i < 32; i++) { - state->vtx_x[i] = nva_rd32(ctx->cnum, 0x400400 + i * 4); - state->vtx_y[i] = nva_rd32(ctx->cnum, 0x400480 + i * 4); + state->vtx_xy[i][0] = nva_rd32(ctx->cnum, 0x400400 + i * 4); + state->vtx_xy[i][1] = nva_rd32(ctx->cnum, 0x400480 + i * 4); } for (int i = 0; i < 16; i++) { state->vtx_u[i] = nva_rd32(ctx->cnum, 0x400d00 + i * 4); @@ -1191,8 +1191,8 @@ static void nv04_pgraph_dump_state(struct hwtest_ctx *ctx, struct pgraph_state * } } else { for (int i = 0; i < 10; i++) { - state->vtx_x[i] = nva_rd32(ctx->cnum, 0x400400 + i * 4); - state->vtx_y[i] = nva_rd32(ctx->cnum, 0x400480 + i * 4); + state->vtx_xy[i][0] = nva_rd32(ctx->cnum, 0x400400 + i * 4); + state->vtx_xy[i][1] = nva_rd32(ctx->cnum, 0x400480 + i * 4); } } for (int i = 0; i < 2; i++) { @@ -1390,8 +1390,8 @@ restart: CMP(xy_clip[1][1], "XY_CLIP[1][1]") if (orig->chipset.card_type < 0x10) { for (int i = 0; i < 32; i++) { - CMP(vtx_x[i], "VTX_X[%d]", i) - CMP(vtx_y[i], "VTX_Y[%d]", i) + CMP(vtx_xy[i][0], "VTX_X[%d]", i) + CMP(vtx_xy[i][1], "VTX_Y[%d]", i) } for (int i = 0; i < 16; i++) { CMP(vtx_u[i], "VTX_U[%d]", i) @@ -1400,8 +1400,8 @@ restart: } } else { for (int i = 0; i < 10; i++) { - CMP(vtx_x[i], "VTX_X[%d]", i) - CMP(vtx_y[i], "VTX_Y[%d]", i) + CMP(vtx_xy[i][0], "VTX_X[%d]", i) + CMP(vtx_xy[i][1], "VTX_Y[%d]", i) } } for (int i = 0; i < 2; i++) { @@ -1810,7 +1810,7 @@ static int test_mmio_write(struct hwtest_ctx *ctx) { else idx = nrand48(ctx->rand48) % 10; reg = 0x400400 + idx * 4; - exp.vtx_x[idx] = val; + exp.vtx_xy[idx][0] = val; nv04_pgraph_vtx_fixup(&exp, 0, 8, val); break; case 23: @@ -1819,7 +1819,7 @@ static int test_mmio_write(struct hwtest_ctx *ctx) { else idx = nrand48(ctx->rand48) % 10; reg = 0x400480 + idx * 4; - exp.vtx_y[idx] = val; + exp.vtx_xy[idx][0] = val; nv04_pgraph_vtx_fixup(&exp, 1, 8, val); break; case 24: @@ -2297,7 +2297,7 @@ static int test_mmio_vtx_write(struct hwtest_ctx *ctx) { if (jrand48(ctx->rand48) & 1) val = extrs(val, 0, 18); nva_wr32(ctx->cnum, reg, val); - (xy ? exp.vtx_y : exp.vtx_x)[idx] = val; + exp.vtx_xy[idx][xy] = val; nv04_pgraph_vtx_fixup(&exp, xy, 8, val); nv04_pgraph_dump_state(ctx, &real); if (nv04_pgraph_cmp_state(&orig, &exp, &real)) { @@ -5639,6 +5639,7 @@ static int test_mthd_dma_surf(struct hwtest_ctx *ctx) { static int test_mthd_clip(struct hwtest_ctx *ctx) { int i; + int vidx = ctx->chipset.card_type < 0x10 ? 13 : 9; for (i = 0; i < 10000; i++) { uint32_t val = jrand48(ctx->rand48); int idx = jrand48(ctx->rand48) & 1; @@ -5712,10 +5713,8 @@ static int test_mthd_clip(struct hwtest_ctx *ctx) { nv04_pgraph_gen_state(ctx, &orig); orig.notify &= ~0x10000; if (jrand48(ctx->rand48) & 1) { - insrt(orig.vtx_x[13], 16, 16, (jrand48(ctx->rand48) & 1) ? 0x8000 : 0x7fff); - insrt(orig.vtx_y[13], 16, 16, (jrand48(ctx->rand48) & 1) ? 0x8000 : 0x7fff); - insrt(orig.vtx_x[9], 16, 16, (jrand48(ctx->rand48) & 1) ? 0x8000 : 0x7fff); - insrt(orig.vtx_y[9], 16, 16, (jrand48(ctx->rand48) & 1) ? 0x8000 : 0x7fff); + insrt(orig.vtx_xy[vidx][0], 16, 16, (jrand48(ctx->rand48) & 1) ? 0x8000 : 0x7fff); + insrt(orig.vtx_xy[vidx][1], 16, 16, (jrand48(ctx->rand48) & 1) ? 0x8000 : 0x7fff); } uint32_t grobj[4]; nv04_pgraph_prep_mthd(ctx, grobj, &orig, cls, addr, val); @@ -5747,8 +5746,8 @@ static int test_mthd_clip_zero_size(struct hwtest_ctx *ctx) { nv04_pgraph_gen_state(ctx, &orig); orig.notify &= ~0x10000; if (jrand48(ctx->rand48) & 1) { - insrt(orig.vtx_x[vidx], 16, 16, (jrand48(ctx->rand48) & 1) ? 0x8000 : 0x7fff); - insrt(orig.vtx_y[vidx], 16, 16, (jrand48(ctx->rand48) & 1) ? 0x8000 : 0x7fff); + insrt(orig.vtx_xy[vidx][0], 16, 16, (jrand48(ctx->rand48) & 1) ? 0x8000 : 0x7fff); + insrt(orig.vtx_xy[vidx][1], 16, 16, (jrand48(ctx->rand48) & 1) ? 0x8000 : 0x7fff); } uint32_t grobj[4]; nv04_pgraph_prep_mthd(ctx, grobj, &orig, cls, addr, val); @@ -5756,16 +5755,16 @@ static int test_mthd_clip_zero_size(struct hwtest_ctx *ctx) { exp = orig; nv04_pgraph_mthd(&exp, grobj, 7); if (!extr(exp.intr, 4, 1)) { - exp.vtx_x[vidx] = extr(val, 0, 16); - exp.vtx_y[vidx] = extr(val, 16, 16); - int xcstat = nv04_pgraph_clip_status(&exp, exp.vtx_x[vidx], 0); + exp.vtx_xy[vidx][0] = extr(val, 0, 16); + exp.vtx_xy[vidx][1] = extr(val, 16, 16); + int xcstat = nv04_pgraph_clip_status(&exp, exp.vtx_xy[vidx][0], 0); insrt(exp.xy_clip[0][0], 4, 4, xcstat); - int ycstat = nv04_pgraph_clip_status(&exp, exp.vtx_y[vidx], 1); + int ycstat = nv04_pgraph_clip_status(&exp, exp.vtx_xy[vidx][1], 1); insrt(exp.xy_clip[1][0], 4, 4, ycstat); exp.uclip_min[0] = 0; exp.uclip_min[1] = 0; - exp.uclip_max[0] = exp.vtx_x[vidx]; - exp.uclip_max[1] = exp.vtx_y[vidx]; + exp.uclip_max[0] = exp.vtx_xy[vidx][0]; + exp.uclip_max[1] = exp.vtx_xy[vidx][1]; insrt(exp.valid[0], 28, 1, 0); insrt(exp.valid[0], 30, 1, 0); insrt(exp.xy_misc_1[0], 4, 2, 0); @@ -5822,8 +5821,8 @@ static int test_mthd_clip_hv(struct hwtest_ctx *ctx) { nv04_pgraph_gen_state(ctx, &orig); orig.notify &= ~0x10000; if (jrand48(ctx->rand48) & 1) { - insrt(orig.vtx_x[vidx], 16, 16, (jrand48(ctx->rand48) & 1) ? 0x8000 : 0x7fff); - insrt(orig.vtx_y[vidx], 16, 16, (jrand48(ctx->rand48) & 1) ? 0x8000 : 0x7fff); + insrt(orig.vtx_xy[vidx][0], 16, 16, (jrand48(ctx->rand48) & 1) ? 0x8000 : 0x7fff); + insrt(orig.vtx_xy[vidx][1], 16, 16, (jrand48(ctx->rand48) & 1) ? 0x8000 : 0x7fff); } uint32_t grobj[4]; nv04_pgraph_prep_mthd(ctx, grobj, &orig, cls, addr, val); @@ -5859,7 +5858,7 @@ static int test_mthd_clip_hv(struct hwtest_ctx *ctx) { max = min + extrs(val, 16, 16); else max = min + extr(val, 16, 16); - (xy ? exp.vtx_y : exp.vtx_x)[vidx] = min; + exp.vtx_xy[vidx][xy] = min; int cstat = nv04_pgraph_clip_status(&exp, min, xy); insrt(exp.xy_clip[xy][0], 0, 4, cstat); if (which == 1) { @@ -5871,7 +5870,7 @@ static int test_mthd_clip_hv(struct hwtest_ctx *ctx) { if (!xy) { umin[xy] = umax[xy] & 0xffff; umax[xy] = min & 0x3ffff; - exp.vtx_x[vidx] = exp.vtx_y[vidx] = max; + exp.vtx_xy[vidx][0] = exp.vtx_xy[vidx][1] = max; if (ctx->chipset.card_type < 0x10) { int xcstat = nv04_pgraph_clip_status(&exp, max, 0); insrt(exp.xy_clip[0][0], 4, 4, xcstat); @@ -7692,11 +7691,11 @@ static int test_mthd_d3d_tlv_uv(struct hwtest_ctx *ctx) { if (which < 3) insrt(exp.valid[1], 6 + which, 1, 1); if (fin) { - exp.vtx_x[vidx] = extr(exp.d3d_tlv_xy, 0, 16) | extr(exp.d3d_tlv_color, 16, 16) << 16; - exp.vtx_y[vidx] = extr(exp.d3d_tlv_xy, 16, 16) | extr(exp.d3d_tlv_color, 0, 16) << 16; - int xcstat = nv04_pgraph_clip_status(&exp, exp.vtx_x[vidx], 0); + exp.vtx_xy[vidx][0] = extr(exp.d3d_tlv_xy, 0, 16) | extr(exp.d3d_tlv_color, 16, 16) << 16; + exp.vtx_xy[vidx][1] = extr(exp.d3d_tlv_xy, 16, 16) | extr(exp.d3d_tlv_color, 0, 16) << 16; + int xcstat = nv04_pgraph_clip_status(&exp, exp.vtx_xy[vidx][0], 0); insrt(exp.xy_clip[0][vidx >> 3], 4 * (vidx & 7), 4, xcstat); - int ycstat = nv04_pgraph_clip_status(&exp, exp.vtx_y[vidx], 1); + int ycstat = nv04_pgraph_clip_status(&exp, exp.vtx_xy[vidx][1], 1); insrt(exp.xy_clip[1][vidx >> 3], 4 * (vidx & 7), 4, ycstat); exp.vtx_u[vidx] = exp.d3d_tlv_uv[0][0]; exp.vtx_v[vidx] = exp.d3d_tlv_uv[0][1]; @@ -7717,11 +7716,11 @@ static int test_mthd_d3d_tlv_uv(struct hwtest_ctx *ctx) { vidx &= 7; exp.vtx_u[vidx + 8] = exp.d3d_tlv_uv[1][0]; exp.vtx_v[vidx + 8] = exp.d3d_tlv_uv[1][1]; - exp.vtx_x[vidx + 8] = exp.d3d_tlv_fog_tri_col1; - exp.vtx_y[vidx + 8] = exp.d3d_tlv_z; + exp.vtx_xy[vidx + 8][0] = exp.d3d_tlv_fog_tri_col1; + exp.vtx_xy[vidx + 8][1] = exp.d3d_tlv_z; } else { - exp.vtx_x[vidx + 16] = exp.d3d_tlv_fog_tri_col1; - exp.vtx_y[vidx + 16] = exp.d3d_tlv_z; + exp.vtx_xy[vidx + 16][0] = exp.d3d_tlv_fog_tri_col1; + exp.vtx_xy[vidx + 16][1] = exp.d3d_tlv_z; } if (!extr(exp.surf_format, 8, 4) && extr(exp.debug[3], 22, 1)) nv04_pgraph_blowup(&exp, 0x0200); diff --git a/hwtest/pgraph_mthd_sifm.cc b/hwtest/pgraph_mthd_sifm.cc index dfcc1948..b6cce736 100644 --- a/hwtest/pgraph_mthd_sifm.cc +++ b/hwtest/pgraph_mthd_sifm.cc @@ -41,15 +41,15 @@ class MthdSifmVtxTest : public MthdTest { void emulate_mthd() override { insrt(exp.valid[0], 0, 1, 1); insrt(exp.valid[0], 12, 1, 1); - exp.vtx_x[0] = extrs(val, 0, 16); - exp.vtx_y[4] = extrs(val, 16, 16); + exp.vtx_xy[0][0] = extrs(val, 0, 16); + exp.vtx_xy[4][1] = extrs(val, 16, 16); insrt(exp.valid[0], 19, 1, 0); pgraph_clear_vtxid(&exp); pgraph_bump_vtxid(&exp); insrt(exp.xy_misc_1[0], 0, 1, 0); insrt(exp.xy_misc_1[1], 0, 1, 1); - int xcstat = nv03_pgraph_clip_status(&exp, exp.vtx_x[0], 0, false); - int ycstat = nv03_pgraph_clip_status(&exp, exp.vtx_y[4], 1, false); + int xcstat = nv03_pgraph_clip_status(&exp, exp.vtx_xy[0][0], 0, false); + int ycstat = nv03_pgraph_clip_status(&exp, exp.vtx_xy[4][1], 1, false); insrt(exp.xy_clip[0][0], 0, 4, xcstat); insrt(exp.xy_clip[1][0], 0, 4, ycstat); insrt(exp.xy_misc_3, 8, 1, 0); @@ -73,7 +73,7 @@ class MthdSifmRectTest : public MthdTest { void emulate_mthd() override { insrt(exp.valid[0], 1, 1, 1); insrt(exp.valid[0], 9, 1, 1); - nv03_pgraph_vtx_add(&exp, 0, 1, exp.vtx_x[0], extr(val, 0, 16), 0, false); + nv03_pgraph_vtx_add(&exp, 0, 1, exp.vtx_xy[0][0], extr(val, 0, 16), 0, false); nv03_pgraph_vtx_add(&exp, 1, 1, 0, extr(val, 16, 16), 0, false); pgraph_bump_vtxid(&exp); nv03_pgraph_vtx_cmp(&exp, 0, 8, true); @@ -130,7 +130,7 @@ class MthdSifmDvDyTest : public MthdTest { sv = 7; } insrt(exp.valid[0], 5, 1, 1); - exp.vtx_y[3] = val; + exp.vtx_xy[3][1] = val; insrt(exp.xy_misc_1[1], 24, 4, sv); } public: diff --git a/hwtest/pgraph_mthd_simple.cc b/hwtest/pgraph_mthd_simple.cc index 647038e6..6b5f1f75 100644 --- a/hwtest/pgraph_mthd_simple.cc +++ b/hwtest/pgraph_mthd_simple.cc @@ -346,7 +346,7 @@ class MthdIxmPitchTest : public MthdTest { } void emulate_mthd() override { if (chipset.card_type < 3) { - exp.vtx_x[6] = val; + exp.vtx_xy[6][0] = val; exp.valid[0] |= 0x040040; } else { insrt(exp.dma_pitch, 0, 16, val); diff --git a/hwtest/pgraph_mthd_xy.cc b/hwtest/pgraph_mthd_xy.cc index fd02adc9..e981067b 100644 --- a/hwtest/pgraph_mthd_xy.cc +++ b/hwtest/pgraph_mthd_xy.cc @@ -36,8 +36,8 @@ class MthdClipTest : public MthdTest { int repeats() override { return 10000; }; void adjust_orig_mthd() override { if (rnd() & 1) { - insrt(orig.vtx_x[15], 16, 15, (rnd() & 1) ? 0 : 0x7fff); - insrt(orig.vtx_y[15], 16, 15, (rnd() & 1) ? 0 : 0x7fff); + insrt(orig.vtx_xy[15][0], 16, 15, (rnd() & 1) ? 0 : 0x7fff); + insrt(orig.vtx_xy[15][1], 16, 15, (rnd() & 1) ? 0 : 0x7fff); } if (chipset.card_type < 3) { /* XXX: submitting on BLIT causes an actual blit */ @@ -571,14 +571,14 @@ class MthdVtxTest : public MthdTest { insrt(exp.xy_misc_4[1], 4+svidx, 1, 0); } if (noclip) { - exp.vtx_x[rvidx] = extrs(val, 16, 16); - exp.vtx_y[rvidx] = extrs(val, 0, 16); + exp.vtx_xy[rvidx][0] = extrs(val, 16, 16); + exp.vtx_xy[rvidx][1] = extrs(val, 0, 16); } else { - exp.vtx_x[rvidx] = extrs(val, 0, 16); - exp.vtx_y[rvidx] = extrs(val, 16, 16); + exp.vtx_xy[rvidx][0] = extrs(val, 0, 16); + exp.vtx_xy[rvidx][1] = extrs(val, 16, 16); } - int xcstat = nv03_pgraph_clip_status(&exp, exp.vtx_x[rvidx], 0, noclip); - int ycstat = nv03_pgraph_clip_status(&exp, exp.vtx_y[rvidx], 1, noclip); + int xcstat = nv03_pgraph_clip_status(&exp, exp.vtx_xy[rvidx][0], 0, noclip); + int ycstat = nv03_pgraph_clip_status(&exp, exp.vtx_xy[rvidx][1], 1, noclip); insrt(exp.xy_clip[0][vidx >> 3], 4*(vidx & 7), 4, xcstat); insrt(exp.xy_clip[1][vidx >> 3], 4*(vidx & 7), 4, ycstat); if (cls == 0x08 || cls == 0x18) { @@ -745,8 +745,8 @@ class MthdX32Test : public MthdTest { insrt(exp.xy_misc_4[0], 0+svidx, 1, 0); insrt(exp.xy_misc_4[0], 4+svidx, 1, (int32_t)val != sext(val, 15)); } - exp.vtx_x[vidx] = val; - int xcstat = nv03_pgraph_clip_status(&exp, exp.vtx_x[vidx], 0, false); + exp.vtx_xy[vidx][0] = val; + int xcstat = nv03_pgraph_clip_status(&exp, exp.vtx_xy[vidx][0], 0, false); insrt(exp.xy_clip[0][vidx >> 3], 4*(vidx & 7), 4, xcstat); if (cls == 0x08 || cls == 0x18) { insrt(exp.xy_clip[0][vidx >> 3], 4*((vidx|1) & 7), 4, xcstat); @@ -898,8 +898,8 @@ class MthdY32Test : public MthdTest { insrt(exp.xy_misc_4[1], 0+svidx, 1, 0); insrt(exp.xy_misc_4[1], 4+svidx, 1, (int32_t)val != sext(val, 15)); } - exp.vtx_y[vidx] = val; - int ycstat = nv03_pgraph_clip_status(&exp, exp.vtx_y[vidx], 1, false); + exp.vtx_xy[vidx][1] = val; + int ycstat = nv03_pgraph_clip_status(&exp, exp.vtx_xy[vidx][1], 1, false); if (cls == 0x08 || cls == 0x18) { insrt(exp.xy_clip[1][0], 0, 4, ycstat); insrt(exp.xy_clip[1][0], 4, 4, ycstat); @@ -1033,8 +1033,8 @@ class MthdIfcSizeTest : public MthdTest { int rcls = pgraph_class(&exp); if (chipset.card_type < 3) { if (is_out) { - exp.vtx_x[5] = extr(val, 0, 16); - exp.vtx_y[5] = extr(val, 16, 16); + exp.vtx_xy[5][0] = extr(val, 0, 16); + exp.vtx_xy[5][1] = extr(val, 16, 16); if (rcls <= 0xb && rcls >= 9) exp.valid[0] &= ~0xffffff; exp.valid[0] |= 0x020020; @@ -1044,9 +1044,9 @@ class MthdIfcSizeTest : public MthdTest { exp.valid[0] |= 0x100; } if (is_in) { - exp.vtx_y[1] = 0; - exp.vtx_x[3] = extr(val, 0, 16); - exp.vtx_y[3] = -extr(val, 16, 16); + exp.vtx_xy[1][1] = 0; + exp.vtx_xy[3][0] = extr(val, 0, 16); + exp.vtx_xy[3][1] = -extr(val, 16, 16); if (rcls >= 0x11 && rcls <= 0x13) insrt(exp.xy_misc_1[0], 0, 1, 0); if (!is_ifm) { @@ -1059,20 +1059,20 @@ class MthdIfcSizeTest : public MthdTest { if (rcls <= 0xb && rcls >= 9) exp.valid[0] |= 0x080080; exp.edgefill &= ~0x110; - if (exp.vtx_x[3] < 0x20 && rcls == 0x12) + if (exp.vtx_xy[3][0] < 0x20 && rcls == 0x12) exp.edgefill |= 0x100; if (rcls != 0x0d && rcls != 0x1d) { insrt(exp.xy_misc_4[0], 28, 2, 0); insrt(exp.xy_misc_4[1], 28, 2, 0); } - if (exp.vtx_x[3]) + if (exp.vtx_xy[3][0]) exp.xy_misc_4[0] |= 2 << 28; - if (exp.vtx_y[3]) + if (exp.vtx_xy[3][1]) exp.xy_misc_4[1] |= 2 << 28; bool zero; if (rcls == 0x14) { uint32_t pixels = 4 / nv01_pgraph_cpp_in(exp.ctx_switch[0]); - zero = (exp.vtx_x[3] == pixels || !exp.vtx_y[3]); + zero = (exp.vtx_xy[3][0] == pixels || !exp.vtx_xy[3][1]); } else { zero = extr(exp.xy_misc_4[0], 28, 2) == 0 || extr(exp.xy_misc_4[1], 28, 2) == 0; @@ -1083,14 +1083,14 @@ class MthdIfcSizeTest : public MthdTest { } else { if (is_out) { exp.valid[0] |= 0x2020; - exp.vtx_x[5] = extr(val, 0, 16); - exp.vtx_y[5] = extr(val, 16, 16); + exp.vtx_xy[5][0] = extr(val, 0, 16); + exp.vtx_xy[5][1] = extr(val, 16, 16); } if (is_in) { exp.valid[0] |= 0x8008; - exp.vtx_x[3] = extr(val, 0, 16); - exp.vtx_y[3] = -extr(val, 16, 16); - exp.vtx_y[7] = extr(val, 16, 16); + exp.vtx_xy[3][0] = extr(val, 0, 16); + exp.vtx_xy[3][1] = -extr(val, 16, 16); + exp.vtx_xy[7][1] = extr(val, 16, 16); if (!is_out) exp.misc24[0] = extr(val, 0, 16); nv03_pgraph_vtx_cmp(&exp, 0, 3, false); @@ -1161,26 +1161,19 @@ class MthdRectTest : public MthdTest { insrt(orig.ctx_cache[j][0], 13, 2, 0); } } - if (rnd() & 1) { - insrt(orig.vtx_x[0], 16, 15, (rnd() & 1) ? 0 : 0x7fff); - insrt(orig.vtx_y[0], 16, 15, (rnd() & 1) ? 0 : 0x7fff); - } - if (rnd() & 1) { - insrt(orig.vtx_x[1], 16, 15, (rnd() & 1) ? 0 : 0x7fff); - insrt(orig.vtx_y[1], 16, 15, (rnd() & 1) ? 0 : 0x7fff); - } - if (rnd() & 1) { + for (int j = 0; j < 2; j++) { if (rnd() & 1) { - orig.vtx_x[0] &= 0x8000ffff; - } else { - orig.vtx_x[0] |= 0x7fff0000; + insrt(orig.vtx_xy[0][j], 16, 15, (rnd() & 1) ? 0 : 0x7fff); } - } - if (rnd() & 1) { if (rnd() & 1) { - orig.vtx_y[0] &= 0x8000ffff; - } else { - orig.vtx_y[0] |= 0x7fff0000; + insrt(orig.vtx_xy[1][j], 16, 15, (rnd() & 1) ? 0 : 0x7fff); + } + if (rnd() & 1) { + if (rnd() & 1) { + orig.vtx_xy[0][j] &= 0x8000ffff; + } else { + orig.vtx_xy[0][j] |= 0x7fff0000; + } } } } @@ -1248,21 +1241,21 @@ class MthdRectTest : public MthdTest { int rcls = pgraph_class(&exp); if (rcls == 0x14) { pgraph_bump_vtxid(&exp); - exp.vtx_x[3] = extr(val, 0, 16); - exp.vtx_y[3] = extr(val, 16, 16); + exp.vtx_xy[3][0] = extr(val, 0, 16); + exp.vtx_xy[3][1] = extr(val, 16, 16); if (chipset.card_type < 3) { - nv01_pgraph_vtx_fixup(&exp, 0, 2, exp.vtx_x[3], 1, 0, 2); - nv01_pgraph_vtx_fixup(&exp, 1, 2, exp.vtx_y[3], 1, 0, 2); + nv01_pgraph_vtx_fixup(&exp, 0, 2, exp.vtx_xy[3][0], 1, 0, 2); + nv01_pgraph_vtx_fixup(&exp, 1, 2, exp.vtx_xy[3][1], 1, 0, 2); exp.valid[0] |= 0x4004; } else { nv03_pgraph_vtx_cmp(&exp, 0, 3, false); nv03_pgraph_vtx_cmp(&exp, 1, 3, false); - nv03_pgraph_vtx_add(&exp, 0, 2, exp.vtx_x[0], exp.vtx_x[3], 0, false); - nv03_pgraph_vtx_add(&exp, 1, 2, exp.vtx_y[0], exp.vtx_y[3], 0, false); + nv03_pgraph_vtx_add(&exp, 0, 2, exp.vtx_xy[0][0], exp.vtx_xy[3][0], 0, false); + nv03_pgraph_vtx_add(&exp, 1, 2, exp.vtx_xy[0][1], exp.vtx_xy[3][1], 0, false); exp.misc24[0] = extr(val, 0, 16); exp.valid[0] |= 0x404; } - pgraph_set_image_zero(&exp, !exp.vtx_x[3] || !exp.vtx_y[3]); + pgraph_set_image_zero(&exp, !exp.vtx_xy[3][0] || !exp.vtx_xy[3][1]); } else if (rcls == 0x10) { pgraph_bump_vtxid(&exp); pgraph_bump_vtxid(&exp); @@ -1274,10 +1267,10 @@ class MthdRectTest : public MthdTest { exp.valid[0] |= 0x00c00c; } else { insrt(exp.xy_misc_1[1], 0, 1, 1); - nv03_pgraph_vtx_add(&exp, 0, 2, exp.vtx_x[0], extr(val, 0, 16), 0, false); - nv03_pgraph_vtx_add(&exp, 1, 2, exp.vtx_y[0], extr(val, 16, 16), 0, false); - nv03_pgraph_vtx_add(&exp, 0, 3, exp.vtx_x[1], extr(val, 0, 16), 0, false); - nv03_pgraph_vtx_add(&exp, 1, 3, exp.vtx_y[1], extr(val, 16, 16), 0, false); + nv03_pgraph_vtx_add(&exp, 0, 2, exp.vtx_xy[0][0], extr(val, 0, 16), 0, false); + nv03_pgraph_vtx_add(&exp, 1, 2, exp.vtx_xy[0][1], extr(val, 16, 16), 0, false); + nv03_pgraph_vtx_add(&exp, 0, 3, exp.vtx_xy[1][0], extr(val, 0, 16), 0, false); + nv03_pgraph_vtx_add(&exp, 1, 3, exp.vtx_xy[1][1], extr(val, 16, 16), 0, false); nv03_pgraph_vtx_cmp(&exp, 0, 8, true); nv03_pgraph_vtx_cmp(&exp, 1, 8, true); exp.valid[0] |= 0xc0c; @@ -1291,11 +1284,11 @@ class MthdRectTest : public MthdTest { exp.valid[0] |= 0x1001 << vidx; } else { if (noclip) { - nv03_pgraph_vtx_add(&exp, 0, 1, exp.vtx_x[0], extr(val, 16, 16), 0, true); - nv03_pgraph_vtx_add(&exp, 1, 1, exp.vtx_y[0], extr(val, 0, 16), 0, true); + nv03_pgraph_vtx_add(&exp, 0, 1, exp.vtx_xy[0][0], extr(val, 16, 16), 0, true); + nv03_pgraph_vtx_add(&exp, 1, 1, exp.vtx_xy[0][1], extr(val, 0, 16), 0, true); } else { - nv03_pgraph_vtx_add(&exp, 0, 1, exp.vtx_x[0], extr(val, 0, 16), 0, false); - nv03_pgraph_vtx_add(&exp, 1, 1, exp.vtx_y[0], extr(val, 16, 16), 0, false); + nv03_pgraph_vtx_add(&exp, 0, 1, exp.vtx_xy[0][0], extr(val, 0, 16), 0, false); + nv03_pgraph_vtx_add(&exp, 1, 1, exp.vtx_xy[0][1], extr(val, 16, 16), 0, false); } if (noclip) { nv03_pgraph_vtx_cmp(&exp, 0, 2, false); @@ -1352,12 +1345,12 @@ class MthdIfcDataTest : public MthdTest { } for (int j = 0; j < 6; j++) { if (rnd() & 1) { - orig.vtx_x[j] &= 0xff; - orig.vtx_x[j] -= 0x80; + orig.vtx_xy[j][0] &= 0xff; + orig.vtx_xy[j][0] -= 0x80; } if (rnd() & 1) { - orig.vtx_y[j] &= 0xff; - orig.vtx_y[j] -= 0x80; + orig.vtx_xy[j][1] &= 0xff; + orig.vtx_xy[j][1] -= 0x80; } } if (rnd() & 3) @@ -1410,8 +1403,8 @@ class MthdIfcDataTest : public MthdTest { } int vidx; if (!(exp.xy_misc_1[0] & 1)) { - exp.vtx_x[6] = exp.vtx_x[4] + exp.vtx_x[5]; - exp.vtx_y[6] = exp.vtx_y[4] + exp.vtx_y[5]; + for (int j = 0; j < 2; j++) + exp.vtx_xy[6][j] = exp.vtx_xy[4][j] + exp.vtx_xy[5][j]; insrt(exp.xy_misc_1[0], 14, 1, 0); insrt(exp.xy_misc_1[0], 18, 1, 0); insrt(exp.xy_misc_1[0], 20, 1, 0); @@ -1421,8 +1414,8 @@ class MthdIfcDataTest : public MthdTest { exp.intr |= 1 << 12; goto done; } - nv01_pgraph_iclip_fixup(&exp, 0, exp.vtx_x[6], 0); - nv01_pgraph_iclip_fixup(&exp, 1, exp.vtx_y[6], 0); + nv01_pgraph_iclip_fixup(&exp, 0, exp.vtx_xy[6][0], 0); + nv01_pgraph_iclip_fixup(&exp, 1, exp.vtx_xy[6][1], 0); insrt(exp.xy_misc_1[0], 0, 1, 1); if (extr(exp.edgefill, 8, 1)) { /* XXX */ @@ -1431,16 +1424,16 @@ class MthdIfcDataTest : public MthdTest { } pgraph_clear_vtxid(&exp); vidx = 1; - exp.vtx_y[2] = exp.vtx_y[3] + 1; + exp.vtx_xy[2][1] = exp.vtx_xy[3][1] + 1; nv01_pgraph_vtx_cmp(&exp, 1, 2); nv01_pgraph_vtx_fixup(&exp, 1, 0, 0, 1, 4, 0); nv01_pgraph_vtx_fixup(&exp, 0, 0, 0, 1, 4, 0); - exp.vtx_x[2] = exp.vtx_x[3]; - exp.vtx_x[2] -= steps; + exp.vtx_xy[2][0] = exp.vtx_xy[3][0]; + exp.vtx_xy[2][0] -= steps; nv01_pgraph_vtx_cmp(&exp, 0, 2); - nv01_pgraph_vtx_add(&exp, 0, vidx, vidx, exp.vtx_x[vidx ^ 1], steps, 0); + nv01_pgraph_vtx_add(&exp, 0, vidx, vidx, exp.vtx_xy[vidx ^ 1][0], steps, 0); if (extr(exp.xy_misc_4[0], 28, 1)) { - nv01_pgraph_vtx_add(&exp, 0, vidx, vidx, exp.vtx_x[2], exp.vtx_x[vidx], 0); + nv01_pgraph_vtx_add(&exp, 0, vidx, vidx, exp.vtx_xy[2][0], exp.vtx_xy[vidx][0], 0); } if ((exp.xy_misc_4[0] & 0xc0) || (exp.xy_misc_4[1] & 0xf0)) exp.intr |= 1 << 12; @@ -1467,22 +1460,22 @@ restart:; vidx = 1; bool check_y = false; if (extr(exp.xy_misc_4[1], 28, 1)) { - exp.vtx_y[2]++; - nv01_pgraph_vtx_add(&exp, 1, 0, 0, exp.vtx_y[0], exp.vtx_y[1], 1); + exp.vtx_xy[2][1]++; + nv01_pgraph_vtx_add(&exp, 1, 0, 0, exp.vtx_xy[0][1], exp.vtx_xy[1][1], 1); check_y = true; } else { - exp.vtx_x[4] += exp.vtx_x[3]; - exp.vtx_y[2] = exp.vtx_y[3] + 1; + exp.vtx_xy[4][0] += exp.vtx_xy[3][0]; + exp.vtx_xy[2][1] = exp.vtx_xy[3][1] + 1; nv01_pgraph_vtx_fixup(&exp, 1, 0, 0, 1, 4, 0); } nv01_pgraph_vtx_cmp(&exp, 1, 2); nv01_pgraph_vtx_fixup(&exp, 0, 0, 0, 1, 4, 0); if (extr(exp.xy_misc_4[0], 28, 1)) { - nv01_pgraph_vtx_add(&exp, 0, vidx, vidx, exp.vtx_x[vidx ^ 1], ~exp.vtx_x[2], 1); - exp.vtx_x[2] += exp.vtx_x[3]; + nv01_pgraph_vtx_add(&exp, 0, vidx, vidx, exp.vtx_xy[vidx ^ 1][0], ~exp.vtx_xy[2][0], 1); + exp.vtx_xy[2][0] += exp.vtx_xy[3][0]; nv01_pgraph_vtx_cmp(&exp, 0, 2); if (extr(exp.xy_misc_4[0], 28, 1)) { - nv01_pgraph_vtx_add(&exp, 0, vidx, vidx, exp.vtx_x[2], exp.vtx_x[vidx], 0); + nv01_pgraph_vtx_add(&exp, 0, vidx, vidx, exp.vtx_xy[2][0], exp.vtx_xy[vidx][0], 0); if (exp.xy_misc_4[0] & 0x10) exp.intr |= 1 << 12; check_y = true; @@ -1500,21 +1493,21 @@ restart:; } goto restart; } - exp.vtx_x[2] = exp.vtx_x[3]; + exp.vtx_xy[2][0] = exp.vtx_xy[3][0]; } - exp.vtx_x[2] -= steps; + exp.vtx_xy[2][0] -= steps; nv01_pgraph_vtx_cmp(&exp, 0, 2); - nv01_pgraph_vtx_add(&exp, 0, vidx, vidx, exp.vtx_x[vidx ^ 1], steps, 0); + nv01_pgraph_vtx_add(&exp, 0, vidx, vidx, exp.vtx_xy[vidx ^ 1][0], steps, 0); if (extr(exp.xy_misc_4[0], 28, 1)) { - nv01_pgraph_vtx_add(&exp, 0, vidx, vidx, exp.vtx_x[2], exp.vtx_x[vidx], 0); + nv01_pgraph_vtx_add(&exp, 0, vidx, vidx, exp.vtx_xy[2][0], exp.vtx_xy[vidx][0], 0); } } else { pgraph_bump_vtxid(&exp); if (extr(exp.xy_misc_4[0], 29, 1)) { - exp.vtx_x[2] -= steps; + exp.vtx_xy[2][0] -= steps; nv01_pgraph_vtx_cmp(&exp, 0, 2); } else if (extr(exp.xy_misc_4[1], 28, 1)) { - exp.vtx_y[2]++; + exp.vtx_xy[2][1]++; } } done: @@ -1555,8 +1548,8 @@ class MthdZPointZetaTest : public MthdTest { } } if (!(rnd() & 7)) { - insrt(orig.vtx_x[0], 2, 29, (rnd() & 1) ? 0 : -1); - insrt(orig.vtx_y[0], 2, 29, (rnd() & 1) ? 0 : -1); + insrt(orig.vtx_xy[0][0], 2, 29, (rnd() & 1) ? 0 : -1); + insrt(orig.vtx_xy[0][1], 2, 29, (rnd() & 1) ? 0 : -1); } orig.debug[2] &= 0xffdfffff; orig.debug[3] &= 0xfffeffff; @@ -1570,7 +1563,7 @@ class MthdZPointZetaTest : public MthdTest { void emulate_mthd() override { insrt(exp.misc32[1], 16, 16, extr(val, 16, 16)); pgraph_prep_draw(&exp, false, false); - nv03_pgraph_vtx_add(&exp, 0, 0, exp.vtx_x[0], 1, 0, false); + nv03_pgraph_vtx_add(&exp, 0, 0, exp.vtx_xy[0][0], 1, 0, false); } public: MthdZPointZetaTest(hwtest::TestOptions &opt, uint32_t seed) : MthdTest(opt, seed) {} @@ -1595,10 +1588,7 @@ class MthdSifcDiffTest : public MthdTest { } void emulate_mthd() override { insrt(exp.valid[0], 5 + xy * 8, 1, 1); - if (xy) - exp.vtx_y[5] = val; - else - exp.vtx_x[5] = val; + exp.vtx_xy[5][xy] = val; pgraph_clear_vtxid(&exp); insrt(exp.xy_misc_1[0], 0, 1, 0); insrt(exp.xy_misc_1[1], 0, 1, 0); @@ -1624,9 +1614,9 @@ class MthdSifcVtxTest : public MthdTest { } void emulate_mthd() override { exp.valid[0] |= 0x9018; - exp.vtx_x[4] = extr(val, 0, 16) << 16; - exp.vtx_y[3] = -exp.vtx_y[7]; - exp.vtx_y[4] = extr(val, 16, 16) << 16; + exp.vtx_xy[4][0] = extr(val, 0, 16) << 16; + exp.vtx_xy[3][1] = -exp.vtx_xy[7][1]; + exp.vtx_xy[4][1] = extr(val, 16, 16) << 16; insrt(exp.valid[0], 19, 1, 0); pgraph_clear_vtxid(&exp); insrt(exp.xy_misc_1[0], 0, 1, 0); diff --git a/hwtest/pgraph_state.cc b/hwtest/pgraph_state.cc index 02b76c94..6ace924a 100644 --- a/hwtest/pgraph_state.cc +++ b/hwtest/pgraph_state.cc @@ -54,8 +54,8 @@ void nv01_pgraph_gen_state(int cnum, std::mt19937 &rnd, struct pgraph_state *sta state->ctx_control = rnd() & 0x11010103; for (int i = 0; i < pgraph_vtx_count(state); i++) { - state->vtx_x[i] = rnd(); - state->vtx_y[i] = rnd(); + state->vtx_xy[i][0] = rnd(); + state->vtx_xy[i][1] = rnd(); } if (state->chipset.card_type < 3) { for (int i = 0; i < 14; i++) @@ -217,8 +217,8 @@ void nv01_pgraph_load_state(int cnum, struct pgraph_state *state) { } } for (int i = 0; i < pgraph_vtx_count(state); i++) { - nva_wr32(cnum, 0x400400 + i * 4, state->vtx_x[i]); - nva_wr32(cnum, 0x400480 + i * 4, state->vtx_y[i]); + nva_wr32(cnum, 0x400400 + i * 4, state->vtx_xy[i][0]); + nva_wr32(cnum, 0x400480 + i * 4, state->vtx_xy[i][1]); } if (state->chipset.card_type < 3) { for (int i = 0; i < 14; i++) @@ -391,8 +391,8 @@ void nv01_pgraph_dump_state(int cnum, struct pgraph_state *state) { } } for (int i = 0; i < pgraph_vtx_count(state); i++) { - state->vtx_x[i] = nva_rd32(cnum, 0x400400 + i * 4); - state->vtx_y[i] = nva_rd32(cnum, 0x400480 + i * 4); + state->vtx_xy[i][0] = nva_rd32(cnum, 0x400400 + i * 4); + state->vtx_xy[i][1] = nva_rd32(cnum, 0x400480 + i * 4); } if (state->chipset.card_type < 3) { for (int i = 0; i < 14; i++) { @@ -564,8 +564,8 @@ restart: } } for (int i = 0; i < pgraph_vtx_count(orig); i++) { - CMP(vtx_x[i], "VTX_X[%d]", i) - CMP(vtx_y[i], "VTX_Y[%d]", i) + CMP(vtx_xy[i][0], "VTX_X[%d]", i) + CMP(vtx_xy[i][1], "VTX_Y[%d]", i) } if (orig->chipset.card_type < 3) { for (int i = 0; i < 14; i++) { diff --git a/hwtest/pgraph_state_tests.cc b/hwtest/pgraph_state_tests.cc index f649027d..6db1dc56 100644 --- a/hwtest/pgraph_state_tests.cc +++ b/hwtest/pgraph_state_tests.cc @@ -149,6 +149,7 @@ protected: void mutate() override { val = rnd(); int idx; + bool xy; if (chipset.card_type < 3) { switch (rnd() % 50) { default: @@ -171,27 +172,17 @@ protected: break; case 4: idx = rnd() % 18; - reg = 0x400400 + idx * 4; - exp.vtx_x[idx] = val; - nv01_pgraph_vtx_fixup(&exp, 0, idx, val, 0, -1, 0); + xy = rnd() & 1; + reg = 0x400400 + idx * 4 + xy * 0x80; + exp.vtx_xy[idx][xy] = val; + nv01_pgraph_vtx_fixup(&exp, xy, idx, val, 0, -1, 0); break; case 5: idx = rnd() % 18; - reg = 0x400480 + idx * 4; - exp.vtx_y[idx] = val; - nv01_pgraph_vtx_fixup(&exp, 1, idx, val, 0, -1, 0); - break; - case 6: - idx = rnd() % 18; - reg = 0x400500 + idx * 4; - exp.vtx_x[idx] = val; - nv01_pgraph_vtx_fixup(&exp, 0, idx, val, 1, -1, idx & 3); - break; - case 7: - idx = rnd() % 18; - reg = 0x400580 + idx * 4; - exp.vtx_y[idx] = val; - nv01_pgraph_vtx_fixup(&exp, 1, idx, val, 1, -1, idx & 3); + xy = rnd() & 1; + reg = 0x400500 + idx * 4 + xy * 0x80; + exp.vtx_xy[idx][xy] = val; + nv01_pgraph_vtx_fixup(&exp, xy, idx, val, 1, -1, idx & 3); break; case 8: idx = rnd() % 14; @@ -395,15 +386,10 @@ protected: break; case 7: idx = rnd() & 0x1f; - reg = 0x400400 + idx * 4; - exp.vtx_x[idx] = val; - nv03_pgraph_vtx_fixup(&exp, 0, 8, val); - break; - case 8: - idx = rnd() & 0x1f; - reg = 0x400480 + idx * 4; - exp.vtx_y[idx] = val; - nv03_pgraph_vtx_fixup(&exp, 1, 8, val); + xy = rnd() & 1; + reg = 0x400400 + idx * 4 + xy * 0x80; + exp.vtx_xy[idx][xy] = val; + nv03_pgraph_vtx_fixup(&exp, xy, 8, val); break; case 9: idx = rnd() & 0xf; @@ -774,7 +760,7 @@ protected: if (chipset.card_type < 3) { nv01_pgraph_vtx_fixup(&exp, xy, idx, val, rel, -1, rel ? idx & 3 : 0); } else { - (xy ? exp.vtx_y : exp.vtx_x)[idx] = val; + exp.vtx_xy[idx][xy] = val; nv03_pgraph_vtx_fixup(&exp, xy, 8, val); } } diff --git a/include/nvhw/pgraph.h b/include/nvhw/pgraph.h index 7f3183a9..089f4ec7 100644 --- a/include/nvhw/pgraph.h +++ b/include/nvhw/pgraph.h @@ -82,8 +82,7 @@ struct pgraph_state { uint32_t trap_addr; uint32_t trap_data[2]; uint32_t trap_grctx; - uint32_t vtx_x[32]; - uint32_t vtx_y[32]; + uint32_t vtx_xy[32][2]; uint32_t vtx_beta[14]; uint32_t vtx_z[16]; uint32_t vtx_u[16]; @@ -324,7 +323,7 @@ static inline int pgraph_vtx_count(struct pgraph_state *state) { } static inline void nv01_pgraph_vtx_cmp(struct pgraph_state *state, int xy, int idx) { - int32_t val = (xy ? state->vtx_y : state->vtx_x)[idx]; + int32_t val = state->vtx_xy[idx][xy]; int stat = 0; if (val < 0) stat = 1; @@ -334,7 +333,7 @@ static inline void nv01_pgraph_vtx_cmp(struct pgraph_state *state, int xy, int i } static inline void nv03_pgraph_vtx_cmp(struct pgraph_state *state, int xy, int idx, bool weird) { - int32_t val = (xy ? state->vtx_y : state->vtx_x)[idx]; + int32_t val = state->vtx_xy[idx][xy]; if (weird) val <<= 1; int stat = 0; diff --git a/nvhw/pgraph.c b/nvhw/pgraph.c index 6ee45e45..d161bfe8 100644 --- a/nvhw/pgraph.c +++ b/nvhw/pgraph.c @@ -1041,9 +1041,9 @@ void pgraph_prep_draw(struct pgraph_state *state, bool poly, bool noclip) { case 0x7: if ((state->valid[0] & 0x10203) != 0x10203) insrt(state->intr, 16, 1, 1); - if ((uint32_t)extrs(state->vtx_x[1], 0, 16) != state->vtx_x[1]) + if ((uint32_t)extrs(state->vtx_xy[1][0], 0, 16) != state->vtx_xy[1][0]) insrt(state->intr, 12, 1, 1); - if ((uint32_t)extrs(state->vtx_y[1], 0, 16) != state->vtx_y[1]) + if ((uint32_t)extrs(state->vtx_xy[1][1], 0, 16) != state->vtx_xy[1][1]) insrt(state->intr, 12, 1, 1); if (!(state->intr & 0x01111000)) { insrt(state->valid[0], 0, 16, 0); @@ -1055,9 +1055,9 @@ void pgraph_prep_draw(struct pgraph_state *state, bool poly, bool noclip) { insrt(state->intr, 16, 1, 1); if (!noclip && !extr(state->valid[0], 20, 1)) insrt(state->intr, 16, 1, 1); - if ((uint32_t)extrs(state->vtx_x[1], 0, 16) != state->vtx_x[1]) + if ((uint32_t)extrs(state->vtx_xy[1][0], 0, 16) != state->vtx_xy[1][0]) insrt(state->intr, 12, 1, 1); - if ((uint32_t)extrs(state->vtx_y[1], 0, 16) != state->vtx_y[1]) + if ((uint32_t)extrs(state->vtx_xy[1][1], 0, 16) != state->vtx_xy[1][1]) insrt(state->intr, 12, 1, 1); if (!(state->intr & 0x01111000)) { insrt(state->valid[0], 0, 2, 0); diff --git a/nvhw/pgraph_xy.c b/nvhw/pgraph_xy.c index 502dbc0b..7715e4db 100644 --- a/nvhw/pgraph_xy.c +++ b/nvhw/pgraph_xy.c @@ -107,15 +107,12 @@ void nv01_pgraph_vtx_fixup(struct pgraph_state *state, int xy, int idx, int32_t bool is_tex_class = nv01_pgraph_is_tex_class(state); int32_t cbase = extrs(state->dst_canvas_min, 16 * xy, 16); if (ridx != -1) - cbase = (xy ? state->vtx_y : state->vtx_x)[ridx]; + cbase = state->vtx_xy[ridx][xy]; if (is_tex_class && state->xy_misc_1[0] & 1 << 25 && ridx == -1) cbase <<= 4; if (rel) coord += cbase; - if (xy == 0) - state->vtx_x[idx] = coord; - else - state->vtx_y[idx] = coord; + state->vtx_xy[idx][xy] = coord; int oob = !is_tex_class && (coord >= 0x8000 || coord < -0x8000); int cstat = nv01_pgraph_clip_status(state, coord, xy, is_tex_class); int carry = rel && (uint32_t)coord < (uint32_t)cbase; @@ -128,10 +125,7 @@ void nv01_pgraph_vtx_fixup(struct pgraph_state *state, int xy, int idx, int32_t void nv01_pgraph_vtx_add(struct pgraph_state *state, int xy, int idx, int sid, uint32_t a, uint32_t b, uint32_t c) { bool is_tex_class = nv01_pgraph_is_tex_class(state); uint64_t val = (uint64_t)a + b + c; - if (xy == 0) - state->vtx_x[idx] = val; - else - state->vtx_y[idx] = val; + state->vtx_xy[idx][xy] = val; int oob = !is_tex_class && ((int32_t)val >= 0x8000 || (int32_t)val < -0x8000); int cstat = nv01_pgraph_clip_status(state, val, xy, is_tex_class); nv01_pgraph_set_xym2(state, xy, idx, sid, val >> 32 & 1, oob, cstat); @@ -180,10 +174,7 @@ void nv01_pgraph_uclip_fixup(struct pgraph_state *state, int xy, int idx, int32_ coord += cbase; state->uclip_min[xy] = state->uclip_max[xy]; state->uclip_max[xy] = coord & 0x3ffff; - if (!xy) - state->vtx_x[15] = coord; - else - state->vtx_y[15] = coord; + state->vtx_xy[15][xy] = coord; state->xy_misc_1[0] &= ~0x0177000; if (!idx) { insrt(state->xy_misc_1[0], 24, 1, 0); @@ -244,13 +235,12 @@ void nv01_pgraph_set_clip(struct pgraph_state *state, int is_size, uint32_t val) svidx = 0; dvidx = 2; mvidx = dvidx%4; - state->vtx_x[3] = val & 0xffff; - state->vtx_y[3] = val >> 16 & 0xffff; + state->vtx_xy[3][xy] = extr(val, xy * 16, 16); } if (is_tex_class && state->xy_misc_1[0] & 1 << 25) cbase <<= 4; if (is_size) { - base = xy ? state->vtx_y[svidx] : state->vtx_x[svidx]; + base = state->vtx_xy[svidx][xy]; } else { new = (int16_t)new; base = cbase; @@ -260,10 +250,7 @@ void nv01_pgraph_set_clip(struct pgraph_state *state, int is_size, uint32_t val) int32_t vcoord = new; if (is_tex) vcoord <<= 15, vcoord |= 1 << 14; - if (!xy) - state->vtx_x[dvidx] = vcoord; - else - state->vtx_y[dvidx] = vcoord; + state->vtx_xy[dvidx][xy] = vcoord; state->uclip_min[xy] = state->uclip_max[xy]; state->uclip_max[xy] = new & 0x3ffff; int cstat = nv01_pgraph_clip_status(state, new, xy, is_tex_class && is_size); @@ -310,10 +297,7 @@ void nv01_pgraph_set_vtx(struct pgraph_state *state, int xy, int idx, int32_t co if (is_tex_class) oob |= extr(state->xy_misc_4[xy], sid+4, 1); uint32_t val = (is_tex_class && !is32) ? coord << 15 | 0x4000 : coord; - if (xy == 0) - state->vtx_x[idx] = val; - else - state->vtx_y[idx] = val; + state->vtx_xy[idx][xy] = val; int cstat = nv01_pgraph_clip_status(state, is32 ? coord : extrs(coord, fract * 4, 18 - fract * 4), xy, is_tex_class && is32); nv01_pgraph_set_xym2(state, xy, idx, sid, carry, oob, cstat); if (idx >= 16) { diff --git a/nvhw/pgraph_xy3.c b/nvhw/pgraph_xy3.c index ca16b165..40bfdcc3 100644 --- a/nvhw/pgraph_xy3.c +++ b/nvhw/pgraph_xy3.c @@ -129,10 +129,7 @@ void nv03_pgraph_uclip_fixup(struct pgraph_state *state, int uo, int xy, int idx uint32_t *umax = uo ? state->oclip_max : state->uclip_max; umin[xy] = umax[xy]; umax[xy] = coord & 0x3ffff; - if (!xy) - state->vtx_x[13] = coord; - else - state->vtx_y[13] = coord; + state->vtx_xy[13][xy] = coord; state->xy_misc_1[uo] &= ~0x00177000; if (idx) { int32_t clip_min[2], clip_max[2]; @@ -177,7 +174,7 @@ void nv03_pgraph_set_clip(struct pgraph_state *state, int which, int idx, uint32 int32_t orig = coord; int32_t ovcoord; bool carry = false; - int32_t base = xy ? state->vtx_y[13] : state->vtx_x[13]; + int32_t base = state->vtx_xy[13][xy]; bool ovf = false; if (is_size) { coord += (uint32_t)base; @@ -191,10 +188,7 @@ void nv03_pgraph_set_clip(struct pgraph_state *state, int which, int idx, uint32 } else { ovcoord = coord = (int16_t)coord; } - if (!xy) - state->vtx_x[13] = ovcoord; - else - state->vtx_y[13] = ovcoord; + state->vtx_xy[13][xy] = ovcoord; if (is_o) { state->oclip_min[xy] = state->oclip_max[xy]; state->oclip_max[xy] = coord & 0x3ffff; @@ -237,10 +231,7 @@ void nv03_pgraph_vtx_add(struct pgraph_state *state, int xy, int idx, uint32_t a if (extr(a, 31, 1) == extr(b, 31, 1) && extr(a, 31, 1) != extr(val, 31, 1)) { ovval = extr(a, 31, 1) ? 0x80000000 : 0x7fffffff; } - if (xy == 0) - state->vtx_x[idx] = ovval; - else - state->vtx_y[idx] = ovval; + state->vtx_xy[idx][xy] = ovval; int oob = ((int32_t)val >= 0x8000 || (int32_t)val < -0x8000); int cstat = nv03_pgraph_clip_status(state, val, xy, noclip); nv03_pgraph_set_xym2(state, xy, idx, val >> 32 & 1, oob, cstat); diff --git a/nvhw/pgraph_xy4.c b/nvhw/pgraph_xy4.c index 76723f84..e099bfd1 100644 --- a/nvhw/pgraph_xy4.c +++ b/nvhw/pgraph_xy4.c @@ -327,7 +327,7 @@ void nv04_pgraph_uclip_write(struct pgraph_state *state, int which, int xy, int insrt(state->xy_misc_1[which], 4+xy, 1, 0); } int vidx = state->chipset.card_type < 0x10 ? 13 : 9; - (xy ? state->vtx_y : state->vtx_x)[vidx] = coord; + state->vtx_xy[vidx][xy] = coord; int cls = extr(state->ctx_switch[0], 0, 8); if (cls == 0x53 && state->chipset.chipset == 4 && which == 0) umin[xy] = 0; @@ -650,7 +650,7 @@ void nv04_pgraph_set_clip(struct pgraph_state *state, int which, int idx, uint32 int vidx = state->chipset.card_type < 0x10 ? 13 : 9; for (int xy = 0; xy < 2; xy++) { int32_t coord; - int32_t base = xy ? state->vtx_y[vidx] : state->vtx_x[vidx]; + int32_t base = state->vtx_xy[vidx][xy]; int32_t orig = extr(val, xy*16, 16); bool ovf = false; if (is_size) { @@ -663,7 +663,7 @@ void nv04_pgraph_set_clip(struct pgraph_state *state, int which, int idx, uint32 } else { coord = extrs(val, xy * 16, 16); } - (xy ? state->vtx_y : state->vtx_x)[vidx] = coord; + state->vtx_xy[vidx][xy] = coord; int cstat = nv04_pgraph_clip_status(state, coord, xy); insrt(state->xy_clip[xy][0], 4 * idx, 4, cstat); umin[xy] = umax[xy] & 0xffff; |