Triforce v0.8.5

A Randomizer page in the launcher, a new title screen with Mods and Save Select tabs, scaling changes applied in game, the Jabu-Jabu bars fixed, renderer frame-time work and the brightness-flash fix, and fixes from the 0.8.4 reports.
This commit is contained in:
ruckus7382sfgsgdf
2026-11-28 10:54:41 -06:00
parent 2df08c751e
commit b527e29adb
203 changed files with 18821 additions and 2051 deletions

View File

@@ -185,4 +185,106 @@ inline int64_t fallback_held_ns(const FallbackResult& r) {
return held_ns(true, true, r.rec_ns, r.total_ns);
}
// ---- (Triforce, 11-27) A readback waits for the LAST part of the recording that writes it back ----
// The owner's random brightness changes: in a still view the picture flashed brighter for a frame, then stepped down, a few times
// a minute (3 times at Hyrule Field in a four-scene held-camera benchmark run, on v0.8.4 as on the GPU pass). Each flash is
// one present after the game read its exposure meter (a 64-byte sum the GPU adds to each frame; the CPU reads it and sets it to 0)
// back as all zeros, after a wait for the meter's write-back (RX_VK_LOG_READBACK_ZERO: "waited 1", and the GPU's done value still
// below the write-back's value after the wait). A recording made in parts (vk_replay.cpp maybe_split: RX_VK_CHUNK's counted parts,
// 240 draws on NVIDIA's driver, or Threaded rendering's pass-end parts) writes back at each part's end, and every part's
// write-backs are noted under the recording's own value (Recording::value, vk_memory.cpp mem_rec_value). The readback's wait
// (vk_replay.cpp invalidate, on the game's submitting thread's replay with nothing forced: the default) looked that value up in
// value_rec, which keeps the recording's FIRST part (emplace; RX_VK_REC_LAST, off, keeps a later one only when the value comes
// again). So a read that came between the first part's submit and the last one's waited for the first part alone and read what
// guest memory held then: the CPU's 0, the GPU's sum still in a later part. The sum landed after the read, over the CPU's next 0,
// and the next frame added to it (2x): the step down. The capture's wait (vk_timeline_wait) already looks its writer up at the
// recording's end (Finished); this is the readback's side.
// Now the readback looks up the newest part submitted of the recording by its value, and whether that part ended the recording
// (Parts, noted at each submit). An ended recording: its last part is waited for, as the old wait waited for the first. A
// recording that goes on: the part known is waited for (the old wait, never longer), then the readback looks again between 1 ms
// slices of the submissions' timeline, until the recording has ended (then its last part) or the timeline reaches the value
// (everything up to it done). A value not known at all is the caller's fallback, as before. RX_VK_RB_REC_END=0: the first part, as
// before. tests/test_readback_rec_end.py
/// A recording's parts by its own value: the newest part submitted (its number on the recordings' timeline) and whether that part
/// ended the recording. A later recording made under the same value (a stopped submission's, replayed again) takes the entry over
/// from its first part on. The oldest go past cap
struct Parts {
struct Entry {
uint64_t seq = 0; // (0: not known)
bool ended = false;
};
std::map<uint64_t, Entry> by_value;
size_t cap = 8192;
/// A submit of recording value as number seq: ends, the submit that ends it (finish_recording, a present's); else a part
void submitted(uint64_t value, uint64_t seq, bool ends) {
if (!value || !seq) return;
Entry& e = by_value[value];
if (seq < e.seq) return; // (the numbers rise: an older submit's note after a newer one changes nothing)
e.seq = seq, e.ended = ends;
while (by_value.size() > cap) by_value.erase(by_value.begin());
}
/// The same from the submit's side (vk_replay.cpp submit_recording): part, a submit that does not end the recording. (The
/// `!` is here so that the submit's code keeps the control flow its renderer profile was recorded with)
void part_submitted(uint64_t value, uint64_t seq, bool part) { submitted(value, seq, !part); }
Entry of(uint64_t value) const {
const auto it = by_value.find(value);
return it == by_value.end() ? Entry{} : it->second;
}
};
/// RX_VK_RB_REC_END's text: on unset or empty; set, its number (atoi, as the renderer's other switches: 0 or a word is off)
inline bool rec_end_on(const char* text) { return !(text && *text && std::atoi(text) == 0); }
/// What a readback's wait by recordings did
struct ReadbackWait {
bool known = false; // (the writer's recording was known: false, the caller's fallback waits)
bool ok = false; // (the wait came back done: false after an error, a lost device)
bool went_on = false; // (its recording went on past the part first found: what the old wait would have stopped at)
int64_t slices = 0; // (1 ms slices of the submissions' timeline while the recording went on)
};
/// The readback's wait over the calls it makes, so that a test can run it against a made-up GPU. d has:
/// uint64_t first_part() the old lookup (value_rec): the recording's first part, 0 while not known
/// Parts::Entry look() the newest part of the recording by its value, and whether it ended the recording
/// int rec_wait(seq) the held submits flushed, the recordings' timeline waited for with no bound: 0 done, 2 an error
/// void flush() the held submits flushed (nothing when none is held)
/// int slice() the submissions' timeline waited for kSliceNs: 0 reached, 1 not yet, 2 an error
/// rec_end: the rule (RX_VK_RB_REC_END); off, the first part alone, as before
template <class D>
ReadbackWait readback_wait(bool rec_end, D& d) {
ReadbackWait r;
if (!rec_end) {
const uint64_t seq = d.first_part();
if (!seq) return r;
r.known = true;
r.ok = d.rec_wait(seq) == 0;
return r;
}
Parts::Entry e = d.look();
if (!e.seq) return r;
r.known = true;
for (;;) {
if (d.rec_wait(e.seq) != 0) return r;
if (e.ended) break;
r.went_on = true; // (a part: the recording's later parts write back too)
for (;;) {
d.flush(); // (a batched submit's recording is noted once the batch goes out: RX_VK_PEND_HELD)
const Parts::Entry n = d.look();
if (n.ended || n.seq != e.seq) {
e = n;
break;
}
const int s = d.slice();
r.slices++;
if (s == 0) { // (the timeline at the value: every recording up to it done, its last part too)
r.ok = true;
return r;
}
if (s != 1) return r;
}
}
r.ok = true;
return r;
}
} // namespace mkwvk::wb_rec_wait