Triforce v0.8.0

Evil HD (SMAA Ultra, 16x filtering, full textures, ambient occlusion with bounce light, sunlight shafts, foliage drawn 4x as far, the remastered texture pack's loader and the launcher's download of it), FSR 3.1 frame generation for every GPU, Intel XeSS, FSR 4 model choice, ReShade presets, Auto (this PC), HUD placement, the options menu in 13 languages, a second input for every control, hold to toggle, DualSense speaker and haptics, NFC from the player's own dumps, the above-60 fps game fixes, the Debug tab's flight and Inventory fixes, the launcher's full settings, and over 250 fixes.
This commit is contained in:
ruckus7382sfgsgdf
2026-11-25 10:21:32 -06:00
parent 861702476a
commit 4fa4f9188b
881 changed files with 179428 additions and 15581 deletions

View File

@@ -24,6 +24,7 @@
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <cstdlib>
namespace target_pool {
@@ -55,4 +56,92 @@ inline bool idle_out(uint64_t now, uint64_t since, uint64_t idle, bool taken_bef
return now - since > (taken_before ? std::max(idle, kIdleTaken) : idle);
}
// ---- (Triforce, RX_VK_TARGET_REUSE_MEMORY, off by default) a render target whose shape missed the pool takes a pooled
// image's memory ----
// OoT sizes each nearby character's shadow map anew every frame (397, 439, 479 ... texels a side), so its shape never comes
// back to the pool while an image of nearly the same size was just put in it; each was a new allocation, on a Steam Deck a
// kernel call that compacts memory (measured there: about 3.2 ms a frame of a camera turn in VMA's block allocations, 92% of
// them render targets made after the pool missed). With the switch a target that misses the pool is bound to the memory of a
// pooled image it fits in (vk_texture.cpp pool_take_memory), and at 2 the targets of the pooled kind are made on allocations
// of a size class so the next one a little larger fits (vk_vma.cpp create_image_in_class). Measured on a Steam Deck OLED at
// Render 50% in a Hyrule Field camera turn: 33.6 fps against 32.6, 1% low 15.7 against 13.1; not separated at Render 100%,
// no gain shown on a Steam Deck LCD, not run on a discrete card. The picture is the same: the image starts UNDEFINED and is
// cleared as a new one is.
/// RX_VK_TARGET_REUSE_MEMORY: 0 off (unset: off, as before), 1 a pooled image's memory taken by size, 2 also the size classes
inline int reuse_level(const char* env) {
if (!env || !*env) return 0;
const int v = atoi(env);
return v <= 0 ? 0 : v >= 2 ? 2 : 1;
}
enum class Fit : uint8_t { fits, own_memory, type, alignment, too_small, too_big };
inline uint64_t class_bytes(uint64_t need, uint64_t block);
/// Whether a pooled render target's allocation can hold a new image of another shape, or why not: a memory type the new image
/// can use, an offset its alignment divides, at least its size and at most 1.5 times it (or its own size class, which under
/// 1 MB may be more), and not memory of its own (bound to the one image it was made for)
inline Fit verdict(uint64_t pooled_bytes, uint64_t pooled_offset, uint32_t pooled_memory_type, bool pooled_dedicated,
uint64_t need_bytes, uint64_t need_alignment, uint32_t need_memory_type_bits) {
if (pooled_dedicated) return Fit::own_memory;
if (pooled_memory_type >= 32 || !(need_memory_type_bits >> pooled_memory_type & 1)) return Fit::type;
if (need_alignment > 1 && pooled_offset % need_alignment) return Fit::alignment;
if (!need_bytes || pooled_bytes < need_bytes) return Fit::too_small;
return pooled_bytes * 2 <= need_bytes * 3 || pooled_bytes <= class_bytes(need_bytes, UINT64_MAX) ? Fit::fits : Fit::too_big;
}
inline bool fits(uint64_t pooled_bytes, uint64_t pooled_offset, uint32_t pooled_memory_type, bool pooled_dedicated,
uint64_t need_bytes, uint64_t need_alignment, uint32_t need_memory_type_bits) {
return need_bytes && verdict(pooled_bytes, pooled_offset, pooled_memory_type, pooled_dedicated, need_bytes, need_alignment,
need_memory_type_bits) == Fit::fits;
}
/// Presents an image waits in the pool before a target of another shape may take its memory: a shape made every frame takes
/// its image back within the present it came in, and taking that one would only make the next of its shape miss
inline constexpr uint64_t kSizeTakeIdle = 1;
inline bool takeable_by_size(uint64_t now, uint64_t since, uint64_t min_idle) { return now - since >= min_idle; }
/// Why a target that missed the pool was not given a pooled image's memory either (the status line's "not reused by size")
enum class Miss : uint8_t { empty, too_new, unusable, too_small, too_big, between, over_block, requirements, not_bound, count };
struct Tally {
uint32_t too_new = 0, unusable = 0, too_small = 0, too_big = 0;
uint64_t largest_small = 0; // (bytes: the largest of the smaller ones)
};
inline void add(Tally& t, bool takeable, Fit f, uint64_t pooled_bytes) {
if (!takeable) t.too_new++;
else if (f == Fit::too_small) t.too_small++, t.largest_small = std::max(t.largest_small, pooled_bytes);
else if (f == Fit::too_big) t.too_big++;
else if (f != Fit::fits) t.unusable++;
}
/// A scan of a pool that was not empty, none of it taken
inline Miss miss_reason(const Tally& t) {
if (t.too_small || t.too_big) return !t.too_big ? Miss::too_small : !t.too_small ? Miss::too_big : Miss::between;
return t.unusable ? Miss::unusable : Miss::too_new;
}
/// The short wait on an integrated GPU while the take by size is on (RX_VK_TARGET_REUSE_MEMORY 1 or 2): a shape not coming
/// back is then the next new shape's allocation, and there each allocation is a kernel call (a Steam Deck's camera turn: 8
/// presents left 1,006-1,104 new targets with the pool empty, 64 left 22-29). The pool's byte bound and tiers still hold it
inline constexpr uint64_t kIdleReuse = 64;
/// The short wait (a shape never taken from the pool): RX_VK_POOL_IDLE as set (at least 1), else kIdleReuse while the take by
/// size is on on an integrated GPU, kIdle otherwise
inline uint64_t idle_presents(const char* env, int reuse_level, bool integrated) {
if (env && *env) return (uint64_t)std::max(1, atoi(env));
return reuse_level >= 1 && integrated ? kIdleReuse : kIdle;
}
/// Size classes (RX_VK_TARGET_REUSE_MEMORY=2): from 64 KiB in steps of a quarter, each a multiple of 64 KiB, the largest the
/// block; where fewer than 8 fit a block a class holds no fewer to a block than the requirement rounded to 64 KiB would. At most
/// a quarter over the requirement rounded to 64 KiB. 0: none (nothing, or over a block)
inline constexpr uint64_t kClassFloor = 64 << 10, kClassAlign = 64 << 10;
inline uint64_t class_bytes(uint64_t need, uint64_t block) {
if (!need || need > block) return 0;
const auto up = [](uint64_t x) { return (x + kClassAlign - 1) / kClassAlign * kClassAlign; };
uint64_t c = kClassFloor;
while (c < need) c = up(c * 5 / 4);
const uint64_t per_block = block / up(need);
if (per_block < 8) c = std::min(c, block / per_block / kClassAlign * kClassAlign);
return std::min(c, block);
}
/// The pool's index of class allocations: by memory type and class
inline uint64_t class_key(uint32_t memory_type, uint64_t class_bytes) { return class_bytes << 6 | (memory_type & 63); }
} // namespace target_pool