mirror of
https://git.triforceproject.com/triforce/source
synced 2026-11-27 19:48:49 -04:00
Triforce v0.8.3
Fixes from the 0.8 reports: a mod's code patches go in together or not at all and a mod whose code is refused is off whole; nn::crypto random bytes from the host (a crash at start); shader preparation on three quarters of the CPU threads; Evil HD ornaments and shoot leaves kept to 75 m and 70 m (flicker); the RADV lighting flicker fix; 3D BC images through block attachments on AMD RDNA 1/2 Windows (rainbow lights).
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
// else on the PC, and nothing of the game runs during the preparation: there the other half of the processors stood idle
|
||||
// through a wait of minutes (165 s with 12 workers on a 24-thread PC). NX2navi prepares on every processor it is given.
|
||||
//
|
||||
// So: every processor, 64 at most, unless the process was started above normal priority (half, as before). Nothing
|
||||
// So: every processor (three quarters of them since 11-25, below), 64 at most, unless the process was started above normal priority (half, as before). Nothing
|
||||
// bounded the memory a worker takes: each holds one program's translation at a time and the driver's compiler for one
|
||||
// pipeline, and how much the driver's part is has not been measured here (the compute programs go first, so every worker
|
||||
// is in the driver's compiler at once when the preparation begins). So the workers past half are given only what RAM is
|
||||
@@ -45,9 +45,14 @@ inline constexpr unsigned kAmdOlderMost = 8;
|
||||
|
||||
/// cpus: the logical processors; ram_free: the physical memory free now, 0 when it is not known; above_normal: the process
|
||||
/// was started above normal priority; asked: RX_VK_PREPARE_THREADS, 0 or less when it is not set
|
||||
/// ((Triforce, 11-25) the most by default: three quarters of the processors, never fewer than half. Two players' PCs in one day
|
||||
/// with every processor busy for the whole preparation after 0.8's update: one at 100 °C, one switched itself off. The quarter
|
||||
/// left keeps the PC's own work and its fans ahead; RX_VK_PREPARE_THREADS still asks for any number)
|
||||
inline unsigned three_quarters(unsigned cpus) { return std::max(half(cpus), std::clamp(cpus - cpus / 4, 1u, 64u)); }
|
||||
|
||||
inline unsigned count(unsigned cpus, uint64_t ram_free, bool above_normal, int asked) {
|
||||
if (asked > 0) return (unsigned)std::min(asked, 64);
|
||||
const unsigned least = half(cpus), most = std::clamp(cpus, 1u, 64u);
|
||||
const unsigned least = half(cpus), most = three_quarters(cpus);
|
||||
if (above_normal || !ram_free) return least;
|
||||
return (unsigned)std::clamp<uint64_t>(ram_free / kRamAWorker, least, most);
|
||||
}
|
||||
|
||||
@@ -446,6 +446,8 @@ void vk_timeline_wait_from(uint64_t v, int who);
|
||||
// ((Triforce) RX_VK_LATE_QUEUE: the highest timeline value on the queue; a wait for a sent one (no flush; false: not reached in 1 s);
|
||||
// the late pages' fixes applied (dev.present_mu held; queue_flush_locked does it first); vk_memory.cpp's side
|
||||
uint64_t vk_timeline_signal_sent();
|
||||
/// ((Triforce, 11-23) whether the replay's submits are held (RX_VK_BATCH: on by default with RADV): vk_memory.cpp late_queue_on
|
||||
bool vk_batch_holds();
|
||||
bool vk_timeline_wait_sent(uint64_t v);
|
||||
void late_fix_flush_locked();
|
||||
void vk_late_queue_stats(int64_t* waits, int64_t* wait_ns, int64_t* timeouts);
|
||||
|
||||
@@ -4206,15 +4206,32 @@ inline const uint8_t* cap_page_bytes(const Capture& c, uint32_t slot) {
|
||||
// while the GPU finishes the frame before. Not deferred, as before: a value not sent yet, a late page in a texture's storage (its
|
||||
// shadow and uploads read the capture at the take), more than kLateFixMax pending. Triforce's earlier experiments that dropped
|
||||
// the wait (RX_VK_LATE_NEW, the lab's nolatewait) took the bytes WITHOUT waiting and stepped the exposure; this still waits
|
||||
// ((Triforce, 11-23, the Linux RADV lighting flicker: tickets 451323, 973820, 240338, 474460, 626285, 374015) NOT with held
|
||||
// submits (RX_VK_BATCH, on by default with Mesa's RADV). A held submit goes into the batch without late_fix_flush_locked (only
|
||||
// the batch's flush applies the fixes: a poll 2 ms on, a present, a wait), so the fixes stay pending far longer than "until the
|
||||
// next submit". Meanwhile the replay's reads of those slots read guest memory as it is then (memory_read_as_submitted), and the
|
||||
// fix itself copies guest memory as it is at the flush: by then the game's CPU has gone on into the next frame and written those
|
||||
// pages again, so the capture carries another frame's bytes there (OoT's exposure meter and the per-frame pools beside it). In
|
||||
// every RADV log of the tickets the flicker starts where the late pages stop being texture storage (the take waited until then)
|
||||
// and are put off to the queue instead: the RX_VK_LATE_QUEUE line goes from "0 put off, 60-100 texture storage, 0 replay reads
|
||||
// of a pending slot" to "150-230 put off, 0 texture storage, 250-2100 replay reads of a pending slot", 50-90 s into play, and
|
||||
// stays there until the game ends. NVIDIA on Linux defers as many with 0 such reads (no held submits: the next submit applies
|
||||
// them); AMD on Windows has none. So while submits are held the take waits, as before 11-20. RX_VK_LATE_QUEUE unset: moved to
|
||||
// the queue unless submits are held; =1: moved to the queue with held submits too (v0.7.0 as shipped); =0: the take waits, on
|
||||
// any driver, as before. Asked at each take: whether submits are held is known once the replay has its batch timeline
|
||||
bool late_queue_on() {
|
||||
static const bool v = [] {
|
||||
// (on by default since 11-20: 79.8 -> 80.4 fps, three alternating rounds each at the owner's save (every round ahead),
|
||||
// frame log clean: no cell blinks or whole-frame steps against none. RX_VK_LATE_QUEUE=0: the take waits, as before)
|
||||
const bool on = !(getenv("RX_VK_LATE_QUEUE") && atoi(getenv("RX_VK_LATE_QUEUE")) == 0);
|
||||
logf("vk: late pages' wait %s (RX_VK_LATE_QUEUE)", on ? "moved to the queue" : "at the capture's take, as before");
|
||||
return on;
|
||||
static const int env = [] { // (-1 unset, 0 off, 1 on)
|
||||
const char* e = getenv("RX_VK_LATE_QUEUE");
|
||||
return e && *e ? (atoi(e) != 0 ? 1 : 0) : -1;
|
||||
}();
|
||||
return v;
|
||||
const bool on = env == 1 || (env == -1 && !vk_batch_holds());
|
||||
static std::atomic<int> said{-1}; // (the last answer logged: a line when it is first asked and when it changes)
|
||||
if (said.exchange(on ? 1 : 0, std::memory_order_relaxed) != (on ? 1 : 0))
|
||||
logf("vk: late pages' wait %s (RX_VK_LATE_QUEUE%s)",
|
||||
on ? "moved to the queue" : "at the capture's take, as before",
|
||||
env == -1 ? (on ? "; =0: at the take" : ": submits are held (RX_VK_BATCH), so the take waits; =1: moved to the queue, as v0.7.0")
|
||||
: env == 1 ? "=1" : "=0");
|
||||
return on;
|
||||
}
|
||||
struct LateFix {
|
||||
uint64_t value = 0; // (the late pages' write-back: their slots copied again once it is done)
|
||||
|
||||
@@ -536,6 +536,7 @@ void split_part_submitted(VkCommandBuffer cmd, bool uploads) {
|
||||
// again into their captures' buffers, as the take did after its wait. At most 250 ms at a time, 4 times: a submission the event
|
||||
// ordering holds behind a later one cannot hold the queue's lock for ever (the fix goes in as it is, counted)
|
||||
uint64_t vk_timeline_signal_sent() { return stall_ct.queue_top.load(std::memory_order_relaxed); }
|
||||
bool vk_batch_holds() { return batch_on(); } // ((Triforce, 11-23) vk_memory.cpp late_queue_on: no late pages put off while submits are held)
|
||||
bool vk_timeline_wait_sent(uint64_t v) {
|
||||
if (!timeline) return true;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
|
||||
@@ -1084,17 +1084,21 @@ VkImageView make_view(Texture* tex, VkImageViewType type, VkFormat f, VkImageAsp
|
||||
/// 0 not at all: the pass is left out, the volumes stay zero and trees are bare at mid distance.
|
||||
/// NVIDIA's Pascal and older (device IDs below 0x1e00: GTX 10 series, GTX 900) take the usage and the per-slice views, then
|
||||
/// lose the device on the first draw or even a clear into one (a GTX 1080 and a GTX 1070, driver 581.80, at the area load
|
||||
/// after the opening cutscene and at every save load): 2 there, where it was 0. RX_VK_BC3D_TARGET=0, 1 or 2: that way
|
||||
/// after the opening cutscene and at every save load): 2 there, where it was 0. ((Triforce, 11-25) And AMD's Windows driver for
|
||||
/// RDNA 1 and 2 (vk_vendor.h amd_older_compiler): its raw views draw wrong values into the volumes, and the effects that read
|
||||
/// them showed bright rainbow lights on the walls (an RX 6900 XT, driver 26.11.2, Goron City; the player's own
|
||||
/// RX_VK_BC3D_TARGET=2 fixed it). RX_VK_BC3D_TARGET=0, 1 or 2: that way
|
||||
int bc3d_way() {
|
||||
static const int way = [] {
|
||||
const char* e = getenv("RX_VK_BC3D_TARGET");
|
||||
const bool old_nvidia = dev.props.vendorID == 0x10de && dev.props.deviceID < 0x1e00;
|
||||
const int v = e && *e ? std::clamp(atoi(e), 0, 2) : old_nvidia ? 2 : 1;
|
||||
const bool amd_older = dev.amd_older_compiler;
|
||||
const int v = e && *e ? std::clamp(atoi(e), 0, 2) : old_nvidia || amd_older ? 2 : 1;
|
||||
if (v != 1)
|
||||
logf("vk: 3D BC images are drawn into %s (%s; NVIDIA before Turing loses the device on raw views of them; "
|
||||
"RX_VK_BC3D_TARGET=1: raw views, 2: block attachments, 0: not at all)",
|
||||
logf("vk: 3D BC images are drawn into %s (%s; NVIDIA before Turing loses the device on raw views of them, AMD's driver "
|
||||
"for RDNA 1 and 2 draws wrong values through them; RX_VK_BC3D_TARGET=1: raw views, 2: block attachments, 0: not at all)",
|
||||
v ? "through uncompressed block attachments of their own" : "not at all: the noise pass is left out",
|
||||
e && *e ? "RX_VK_BC3D_TARGET" : "NVIDIA device id below 0x1e00");
|
||||
e && *e ? "RX_VK_BC3D_TARGET" : old_nvidia ? "NVIDIA device id below 0x1e00" : "AMD's driver for RDNA 1 and 2");
|
||||
return v;
|
||||
}();
|
||||
return way;
|
||||
|
||||
Reference in New Issue
Block a user