Triforce v0.8.5.2

Hotfix: the brightness flashes fixed without the fps cost (the readback wait only for ranges the CPU resets), and the Discord status names where Link is by default.
This commit is contained in:
ruckus7382sfgsgdf
2026-11-28 15:45:28 -06:00
parent 0f7d57ac14
commit 8cb23131f9
13 changed files with 412 additions and 54 deletions

View File

@@ -213,6 +213,12 @@ struct Parts {
struct Entry {
uint64_t seq = 0; // (0: not known)
bool ended = false;
// ((Triforce, 11-28) Start next frame early (tail_early.h): the part the scene ended with, where the tail began
// (scene_part), and that part again once the tail passed its verdict (scene_seq). A tail that passes wrote nothing the
// game reads back, so the scene's part is the last that writes back what a readback waits for: the readback stops
// there, not at the tail's end. Waiting for the tail cost the owner ~20 fps at his save (game-thread reads of ~6.5 ms))
uint64_t scene_part = 0;
uint64_t scene_seq = 0;
};
std::map<uint64_t, Entry> by_value;
size_t cap = 8192;
@@ -227,16 +233,39 @@ struct Parts {
/// 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); }
/// ((Triforce, 11-28) the early tail began after the part just submitted for value (vk_replay.cpp tail_begin)
void tail_began(uint64_t value) {
const auto it = by_value.find(value);
if (it != by_value.end()) it->second.scene_part = it->second.seq;
}
/// ((Triforce, 11-28) value's early tail passed its verdict (vk_replay.cpp tail_end): readbacks stop at the scene's part
void tail_passed(uint64_t value) {
const auto it = by_value.find(value);
if (it != by_value.end() && it->second.scene_part) it->second.scene_seq = it->second.scene_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: ((Triforce, 0.8.5.1)) OFF unless set to a number other than 0. On, the game's worker threads' reads of
/// its double-buffered GPU results waited ~5 ms for the whole frame's recording (the owner's save: 70 fps for 85-91). The fix for
/// the brightness flashes comes back without that cost (only the GPU work the game waited for)
inline bool rec_end_on(const char* text) { return text && *text && std::atoi(text) != 0; }
/// RX_VK_RB_REC_END's modes. ((Triforce, 11-28) 0.8.5 waited for the last part at every readback (kRecEndAll): the update's
/// workers' reads of results the CPU only reads waited ~5 ms each (98 -> 82 fps in Hyrule Field at the owner's settings);
/// 0.8.5.1 turned it off. Now, by default, a readback waits for the last part where the CPU writes the range after reading it
/// (kRecEndCpuWritten: the exposure meter, whose late read lost the CPU's 0 and flashed), and for the first part, as before,
/// where it only reads it (a frame late at worst, then the next read has it). vk_memory.cpp memory_rb_cpu_written
enum RecEnd { kRecEndOff = 0, kRecEndAll = 1, kRecEndCpuWritten = 2 };
/// The mode from the switch's text: unset or empty, 2 (the CPU-written ranges); 0 or a word (atoi, as the renderer's other
/// switches), off: the first part, as before; 1, every readback, as 0.8.5; another number, 2
inline int rec_end_mode(const char* text) {
if (!text || !*text) return kRecEndCpuWritten;
const int v = std::atoi(text);
return v == 0 ? kRecEndOff : v == 1 ? kRecEndAll : kRecEndCpuWritten;
}
/// Whether a readback takes the last-part rule: by the mode, and in mode 2 whether the CPU writes its range (cpu_written)
inline bool rec_end_applies(int mode, bool cpu_written) { return mode == kRecEndAll || (mode == kRecEndCpuWritten && cpu_written); }
/// The switch on at all (a mode other than 0)
inline bool rec_end_on(const char* text) { return rec_end_mode(text) != kRecEndOff; }
/// What a readback's wait by recordings did
struct ReadbackWait {
@@ -266,13 +295,24 @@ ReadbackWait readback_wait(bool rec_end, D& d) {
if (!e.seq) return r;
r.known = true;
for (;;) {
if (d.rec_wait(e.seq) != 0) return r;
if (e.ended) break;
// ((Triforce, 11-28) an early tail that passed: its scene's part is the last that writes back anything the game reads)
uint64_t target = e.scene_seq ? e.scene_seq : e.seq;
// ((Triforce, 11-28) the tail begun (every part of the scene submitted, their write-backs noted): a range one of the scene's
// parts copied back is waited for at that part. Nothing after the tail's start writes it back but the tail, which only
// writes what its verdict allows; a range no scene part covered is the tail's, the last part as before. The worker
// threads' reads came while the tail was still being recorded, before its verdict: ~6 ms each at the owner's save)
bool at_range = false;
if (!e.ended && !e.scene_seq && e.scene_part) {
const uint64_t rs = d.range_seq();
if (rs && rs <= e.scene_part) target = rs, at_range = true;
}
if (d.rec_wait(target) != 0) return r;
if (e.ended || e.scene_seq || at_range) 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) {
if (n.ended || n.seq != e.seq || n.scene_seq || n.scene_part != e.scene_part) {
e = n;
break;
}