Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions framework/patches/runtime/include/dynamic_resolution.h.patch
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
diff --git a/runtime/include/dynamic_resolution.h b/runtime/include/dynamic_resolution.h
index d43c26adc8b035a9c40bdc1572365914c2bfe3a8..0bc01df3d0fe8888bd2b63861dac15652a567f0a 100644
index d43c26adc8b035a9c40bdc1572365914c2bfe3a8..9e9bc42fe9f5944ddc900499ee1df02c852b16cc 100644
--- a/runtime/include/dynamic_resolution.h
+++ b/runtime/include/dynamic_resolution.h
@@ -83,6 +83,7 @@
double wall_s; /* this interval's wall time */
double work_s; /* see LOAD above */
int held; /* the host holds: not a sample, the window restarts */
+ int measured_frames;
+ int measured_frames; /* -1 for missing timing, 0 for a default single-frame sample */
} DynresSample;

typedef struct DynresController {
Expand Down
15 changes: 8 additions & 7 deletions framework/patches/runtime/src/dynamic_resolution.c.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/runtime/src/dynamic_resolution.c b/runtime/src/dynamic_resolution.c
index e99e75aab0af7e3b7b1af10b6f6a4a0de444a6a1..20296601907e47da8e59e23e7d5995bf7e2e563d 100644
index e99e75aab0af7e3b7b1af10b6f6a4a0de444a6a1..35588959c2664a7901a5b780240993557d70b419 100644
--- a/runtime/src/dynamic_resolution.c
+++ b/runtime/src/dynamic_resolution.c
@@ -77,8 +77,8 @@
Expand Down Expand Up @@ -107,22 +107,23 @@ index e99e75aab0af7e3b7b1af10b6f6a4a0de444a6a1..20296601907e47da8e59e23e7d5995bf
c->up_streak_s += dur;
else {
c->up_streak_s = 0.0;
@@ -285,6 +293,7 @@
@@ -285,6 +293,8 @@
return c->level;
}
double work = s->work_s < 0.0 ? 0.0 : s->work_s;
+ if (s->measured_frames != 1) c->up_ready = 0;
+ const int measured_frames = s->measured_frames == 0 ? 1 : s->measured_frames;
+ if (measured_frames != 1) c->up_ready = 0;
if (c->up_ready) {
/* Up steps land in an interval whose idle time covers the step. */
double idle = s->period_s - work;
@@ -292,7 +301,11 @@
@@ -292,7 +302,11 @@
return step_up(c, now_s, c->last_load, c->level + 1, "headroom");
}
c->win_period += s->period_s;
- c->win_work += work;
+ if (s->measured_frames != 1) c->win_unpaired = 1;
+ if (s->measured_frames > 0) {
+ c->win_measured += s->measured_frames * s->period_s;
+ if (measured_frames != 1) c->win_unpaired = 1;
+ if (measured_frames > 0) {
+ c->win_measured += measured_frames * s->period_s;
+ c->win_work += work;
+ }
c->win_wall += s->wall_s;
Expand Down
4 changes: 2 additions & 2 deletions framework/patches/runtime/src/main.cpp.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/runtime/src/main.cpp b/runtime/src/main.cpp
index 886c0db0e1bdc3ab1284a6ff9b920d6a3f75440d..773cc0e471aa0c99f0b484b1b6aed5f9253088c3 100644
index 886c0db0e1bdc3ab1284a6ff9b920d6a3f75440d..5afab762ef1df736518e0b6a149b34ea93e805ae 100644
--- a/runtime/src/main.cpp
+++ b/runtime/src/main.cpp
@@ -1,3 +1,4 @@
Expand Down Expand Up @@ -1527,7 +1527,7 @@ index 886c0db0e1bdc3ab1284a6ff9b920d6a3f75440d..773cc0e471aa0c99f0b484b1b6aed5f9
else if (now_s >= g_dynres.ctl.hold_until) g_dynres.hold_reason = "";

- DynresSample smp{ period, wall, work, held };
+ DynresSample smp{ period, wall, work, held, work > 0.0 };
+ DynresSample smp{ period, wall, work, held, work > 0.0 ? 1 : -1 };
const int level = dynres_sample(&g_dynres.ctl, now_s, &smp);
if (g_dynres.trace && g_dynres.ctl.windows != g_dynres.last_windows) {
g_dynres.last_windows = g_dynres.ctl.windows;
Expand Down
2 changes: 1 addition & 1 deletion src/game/render/adaptive_resolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ void frame() {
const DynresSample sample{kPeriod, judged_wall(wall, slow, g.late, kPeriod, g.controller.p.gap_factor),
work * g_work_scale,
held(world, game_menu || menu_shown(psx_host_ui_gl_flags()), g_replaying, psx_netplay_active() != 0),
measured_frames};
measured_frames ? measured_frames : -1};
g.late = gpu_bound(wall, gpu_per_frame, kPeriod, g.controller.p.late_factor);
g.last = now;
g.busy_ms = busy_ms;
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/adaptive_resolution_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void incomplete_timing_skips_down_step_verification() {
int level = 3;
for (int index = 0; index < 4; ++index) {
now += 1.5 * period;
const DynresSample sample{period, 1.5 * period, index < 3 ? 1.6 * period : 0.0, 0, index < 3};
const DynresSample sample{period, 1.5 * period, index < 3 ? 1.6 * period : 0.0, 0, index < 3 ? 1 : -1};
level = dynres_sample(&controller, now, &sample);
}
expect(level == 2 && !controller.post_active, "an incomplete window can ask for a lower resolution without scheduling verification");
Expand Down Expand Up @@ -148,7 +148,7 @@ void batched_gpu_results_cover_every_measured_frame() {
dynres_init(&controller, &params, 1, 3, 3);
double now = 10.0;
for (const int frames : window) {
const DynresSample sample{period, period, frames * period * 0.75, 0, frames};
const DynresSample sample{period, period, frames * period * 0.75, 0, frames ? frames : -1};
dynres_sample(&controller, now += period, &sample);
}
expect(controller.last_valid && !controller.last_complete && controller.last_load == 0.75,
Expand All @@ -158,7 +158,7 @@ void batched_gpu_results_cover_every_measured_frame() {
dynres_init(&controller, &params, 1, 3, 2);
double now = 10.0;
for (const int frames : readings[0]) {
const DynresSample sample{period, period, frames * period * 0.25, 0, frames};
const DynresSample sample{period, period, frames * period * 0.25, 0, frames ? frames : -1};
dynres_sample(&controller, now += period, &sample);
}
const DynresSample quiet{period, period, period * 0.25, 0, 1};
Expand Down
16 changes: 11 additions & 5 deletions tests/unit/disruptor_render_arena_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,22 +102,28 @@ int main() {
psx_mod_write_word(0x800775D0u, 87u);
psx_mod_write_word(0x800775C0u, 605u);
psx_mod_write_word(0x80077624u, 255u);
psx_mod_write_word(disruptor::stock_frames::kTicks, 101u);
cpu.gpr[4] = kContexts[1];
renderer_entry(&cpu, kRendererEntry);
psx_mod_write_word(0x80077624u, 0u);
psx_mod_write_word(0x800775BCu, 948u);
psx_mod_write_word(0x800775D0u, 231u);
psx_mod_write_word(0x800775C0u, 417u);
psx_mod_write_word(disruptor::stock_frames::kTicks, 103u);
cpu.gpr[4] = kContexts[0];
margin = 0;
renderer_entry(&cpu, kRendererEntry);
int32_t eye[3]{};
require(disruptor_draw_camera(240, 12, eye) == 255 && eye[0] == 317 && eye[1] == 87 && eye[2] == 605 &&
disruptor_draw_camera(0, 12, eye) == 0 && eye[0] == 948 && eye[1] == 231 && eye[2] == 417,
"each draw page keeps the heading used to build its geometry");
int64_t tick = -1;
require(disruptor_draw_camera(240, 12, eye, &tick) == 255 && eye[0] == 317 && eye[1] == 87 && eye[2] == 605 && tick == 101,
"the first draw page keeps its heading, camera position and tick");
require(disruptor_draw_camera(0, 12, eye, &tick) == 0 && eye[0] == 948 && eye[1] == 231 && eye[2] == 417 && tick == 103,
"the second draw page keeps its heading, camera position and tick");
disruptor_reset_draw_headings();
require(disruptor_draw_camera(240, 12, nullptr) == 12 && disruptor_draw_camera(0, 11, eye) == 11 &&
eye[0] == 948 && eye[1] == 231 && eye[2] == 417, "a restored state inherited a draw page heading");
tick = -1;
require(disruptor_draw_camera(240, 12, nullptr, nullptr) == 12 && disruptor_draw_camera(0, 11, eye, &tick) == 11 &&
eye[0] == 948 && eye[1] == 231 && eye[2] == 417 && tick == -1,
"a restored state inherited draw page camera data");
require(!allocated, "4:3 allocated an enhancement arena");
margin = 267;
allocation_fails = true;
Expand Down