mirror of
https://github.com/RetroPortingToolKit/psxrecomp
synced 2026-10-26 18:25:35 -04:00
Skip PGXP counters on vertex probes instead of copying them
pgxp_probe_precise_vertex runs once per rectangle corner on the GPU path and saved and restored the whole PGXPStats record around each call. The shared lookup already knows it is a probe; let it skip the counters. The test now walks the value-mismatch and tolerance-reject branches too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+16
-13
@@ -1093,7 +1093,11 @@ static int pgxp_get_precise_vertex_impl(uint32_t addr, uint32_t packet_word,
|
||||
int32_t int_x, int32_t int_y,
|
||||
int32_t *x16, int32_t *y16,
|
||||
uint16_t *sz, int probe) {
|
||||
s_stats.lookups++;
|
||||
/* A probe asks the same question without recording it (the rectangle
|
||||
* shortcut runs one per corner before drawing): it skips every counter
|
||||
* instead of copying the whole statistics record around the call. */
|
||||
const int count = !probe;
|
||||
if (count) s_stats.lookups++;
|
||||
|
||||
int32_t px = 0, py = 0;
|
||||
uint16_t pz = 0;
|
||||
@@ -1108,7 +1112,7 @@ static int pgxp_get_precise_vertex_impl(uint32_t addr, uint32_t packet_word,
|
||||
py = pv->y16;
|
||||
pz = (pv->flags & PGXP_F_VZ) ? pv->z : 0;
|
||||
have = PGXP_SRC_DATAFLOW;
|
||||
} else {
|
||||
} else if (count) {
|
||||
s_stats.value_mismatch++;
|
||||
}
|
||||
}
|
||||
@@ -1135,25 +1139,27 @@ static int pgxp_get_precise_vertex_impl(uint32_t addr, uint32_t packet_word,
|
||||
* tolerance clamp. */
|
||||
const int why = pgxp_accept(px, py, int_x, int_y, packet_word);
|
||||
if (why == 1) {
|
||||
s_stats.trunc_reject++;
|
||||
if (count) s_stats.trunc_reject++;
|
||||
have = 0;
|
||||
} else if (why == 2) {
|
||||
s_stats.tolerance_reject++;
|
||||
if (count) s_stats.tolerance_reject++;
|
||||
have = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!have) {
|
||||
s_stats.native++;
|
||||
if (count) s_stats.native++;
|
||||
*x16 = int_x << 16;
|
||||
*y16 = int_y << 16;
|
||||
*sz = 0;
|
||||
return PGXP_SRC_NATIVE;
|
||||
}
|
||||
|
||||
if (have == PGXP_SRC_DATAFLOW) s_stats.dataflow_hit++;
|
||||
else s_stats.fallback_hit++;
|
||||
if (pz != 0) s_stats.w_valid++;
|
||||
if (count) {
|
||||
if (have == PGXP_SRC_DATAFLOW) s_stats.dataflow_hit++;
|
||||
else s_stats.fallback_hit++;
|
||||
if (pz != 0) s_stats.w_valid++;
|
||||
}
|
||||
*x16 = px;
|
||||
*y16 = py;
|
||||
*sz = pz;
|
||||
@@ -1170,13 +1176,10 @@ extern "C" int pgxp_get_precise_vertex(uint32_t addr, uint32_t packet_word,
|
||||
|
||||
extern "C" int pgxp_probe_precise_vertex(uint32_t addr, uint32_t packet_word,
|
||||
int32_t int_x, int32_t int_y) {
|
||||
const PGXPStats saved = s_stats;
|
||||
int32_t x16, y16;
|
||||
uint16_t sz;
|
||||
const int src = pgxp_get_precise_vertex_impl(addr, packet_word, int_x, int_y,
|
||||
&x16, &y16, &sz, 1);
|
||||
s_stats = saved;
|
||||
return src;
|
||||
return pgxp_get_precise_vertex_impl(addr, packet_word, int_x, int_y,
|
||||
&x16, &y16, &sz, 1);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
@@ -596,7 +596,14 @@ int main(void) {
|
||||
CHECK(pgxp_probe_precise_vertex(ADDR_A, PACKED, 160, 80) ==
|
||||
PGXP_SRC_DATAFLOW);
|
||||
CHECK(pgxp_probe_precise_vertex(ADDR_A, PACKED, 161, 80) ==
|
||||
PGXP_SRC_NATIVE);
|
||||
PGXP_SRC_NATIVE); /* truncation reject */
|
||||
CHECK(pgxp_probe_precise_vertex(ADDR_A, PACKED ^ 1u, 160, 80) ==
|
||||
PGXP_SRC_NATIVE); /* value mismatch */
|
||||
const float tolerance_was = pgxp_tolerance();
|
||||
pgxp_set_tolerance(0.1f);
|
||||
CHECK(pgxp_probe_precise_vertex(ADDR_A, PACKED, 160, 80) ==
|
||||
PGXP_SRC_NATIVE); /* tolerance reject */
|
||||
pgxp_set_tolerance(tolerance_was);
|
||||
pgxp_get_stats(&b);
|
||||
CHECK(std::memcmp(&a, &b, sizeof a) == 0);
|
||||
pgxp_note_rect_bypass(1);
|
||||
|
||||
Reference in New Issue
Block a user