mirror of
https://git.triforceproject.com/triforce/source
synced 2026-11-21 00:59:59 -04:00
Triforce v0.6.0 "Sage Of Power"
Faster frames (the replay's memory work, held submits, helper threads, collection and capture cuts), the game letting old areas go (QueryMemoryInfo), the 0.5.2 stutter fixed, AMD RX 5000/6000 and integrated-GPU fixes, the GPU device chosen by name, the in-game menus and launcher reworked, controller, Linux and benchmark fixes.
This commit is contained in:
@@ -11,13 +11,44 @@
|
||||
namespace mkwvk::framegen_rows {
|
||||
|
||||
/// opts.framegen (saved as frame_generation): 0 Off, 1 Auto, 2 to 8 the multiplier, as before (an options file from before
|
||||
/// keeps its meaning), then 9: AMD FSR 4, one frame made by AMD's library between each two of the game's
|
||||
/// keeps its meaning), then 9: AMD FSR frame generation, one frame made by AMD's library between each two of the game's
|
||||
/// ((Triforce, FG-1) whichever version AMD's library has for the card: FSR 4's on an RX 9000, FSR 3.1's elsewhere. The
|
||||
/// name FSR4 stays: it is the value's, saved in options files as 9)
|
||||
enum { OFF = 0, AUTO = 1, kMaxMult = 8, FSR4 = 9, kRowMax = FSR4 };
|
||||
|
||||
/// ((Triforce, FG-9) RX_VK_FRAMEGEN_MULT=<0..9>, over the options file for a lab run: the row's whole range, 9 AMD's frame
|
||||
/// generation among it (it ran 2 to 8 alone before, and a 9 became the renderer's own 8x). Not a number: 2, as before
|
||||
inline int env_row(const char* e) {
|
||||
if (!e || !*e) return 2;
|
||||
int v = 0;
|
||||
if (std::sscanf(e, "%d", &v) != 1) return 2;
|
||||
return v < OFF ? (int)OFF : v > kRowMax ? (int)kRowMax : v;
|
||||
}
|
||||
|
||||
/// ((Triforce, FG-1) The row's value 9 by the version AMD's library makes the frames with: "AMD FSR (3.1.6)", "AMD FSR
|
||||
/// (4.0.2)"; "AMD FSR" before it is known. out holds n bytes
|
||||
inline const char* row_label(char* out, size_t n, const char* version) {
|
||||
if (!out || !n) return "";
|
||||
unsigned v[3] = {0, 0, 0};
|
||||
const bool known = version && std::sscanf(version, "%u.%u.%u", &v[0], &v[1], &v[2]) == 3;
|
||||
if (known) std::snprintf(out, n, "AMD FSR (%u.%u.%u)", v[0], v[1], v[2]);
|
||||
else std::snprintf(out, n, "AMD FSR");
|
||||
return out;
|
||||
}
|
||||
|
||||
/// Why AMD FSR 4 cannot make the frames here (the row says it); FG_OK when it can. FG_NOT_YET: not asked, the device is not
|
||||
/// made yet
|
||||
enum Why { FG_OK, FG_NOT_BUILT, FG_ENV_OFF, FG_NOT_YET, FG_NO_LIBRARY, FG_NO_FILE, FG_NO_MODEL, FG_FAILED, FG_WHY_COUNT };
|
||||
|
||||
/// ((Triforce) Why, in words, for the log line a run with the row at AMD FSR gets when AMD's library cannot make its frames)
|
||||
constexpr const char* why_name(Why w) {
|
||||
return w == FG_OK ? "it can" : w == FG_NOT_BUILT ? "not in this build (HOOKSHOT_FSR, Windows)"
|
||||
: w == FG_ENV_OFF ? "switched off (RX_VK_FSR4_FG=0 or RX_VK_FSR4=0)" : w == FG_NOT_YET ? "not asked yet (no device)"
|
||||
: w == FG_NO_LIBRARY ? "AMD's loader is not beside the game" : w == FG_NO_FILE ? "amd_fidelityfx_framegeneration_vk.dll is not beside it"
|
||||
: w == FG_NO_MODEL ? "AMD's library lists no frame generation it can take for this GPU"
|
||||
: w == FG_FAILED ? "it failed earlier in this run" : "?";
|
||||
}
|
||||
|
||||
/// The row's last value on this PC: AMD FSR 4 where it is offered, 8x elsewhere (the row as it was)
|
||||
constexpr int row_hi(bool fsr4_offered) { return fsr4_offered ? (int)FSR4 : (int)kMaxMult; }
|
||||
/// What the row shows, and what runs, for a value: itself, or 2x for a saved AMD FSR 4 on a PC where it is not offered
|
||||
@@ -38,16 +69,17 @@ inline bool parse_version(const char* name, unsigned v[3]) {
|
||||
v[0] = v[1] = v[2] = 0;
|
||||
return name && std::sscanf(name, "%u.%u.%u", &v[0], &v[1], &v[2]) == 3;
|
||||
}
|
||||
/// Of the frame generation versions AMD's library lists for this GPU, the one contexts are made with: the newest FSR 4, the
|
||||
/// first of equal ones; -1 when it lists none. An FSR 3.1 frame generation alone is not FSR 4: it never stands in under
|
||||
/// FSR 4's name, as vk_fsr4.cpp's upscaler takes no FSR 3.1 either. any (RX_VK_FSR4_FG=1, for trying the path on a card
|
||||
/// without FSR 4): the newest of whatever is listed
|
||||
inline int pick_version(const char* const* names, int n, bool any) {
|
||||
/// Of the frame generation versions AMD's library lists for this GPU, the one contexts are made with: the newest, the first
|
||||
/// of equal ones, so FSR 4's (4.x) wherever it is listed (RX 9000), else FSR 3.1's (3.1.x: RX 6000 and 7000, whose driver
|
||||
/// lists 3.1.6 alone, NX2navi 5bdf583 on the owner's RX 7900 XT); -1 when it lists none it can read. ((Triforce, FG-1)
|
||||
/// Before, a list of FSR 3.1 alone gave -1 and the row never offered AMD's frame generation on those cards. The row names
|
||||
/// the version it runs, row_label.) only_fsr4 (RX_VK_FSR4_FG=4): 4.x or nothing, as it was
|
||||
inline int pick_version(const char* const* names, int n, bool only_fsr4) {
|
||||
int best = -1;
|
||||
unsigned bv[3] = {0, 0, 0};
|
||||
for (int i = 0; i < n; i++) {
|
||||
unsigned v[3];
|
||||
if (!parse_version(names[i], v) || (!any && v[0] != 4)) continue;
|
||||
if (!parse_version(names[i], v) || (only_fsr4 && v[0] != 4)) continue;
|
||||
const bool newer = v[0] != bv[0] ? v[0] > bv[0] : v[1] != bv[1] ? v[1] > bv[1] : v[2] > bv[2];
|
||||
if (best < 0 || newer) best = i, bv[0] = v[0], bv[1] = v[1], bv[2] = v[2];
|
||||
}
|
||||
@@ -67,14 +99,34 @@ inline Pose pose_of(const float v[12]) {
|
||||
}
|
||||
return p;
|
||||
}
|
||||
/// A camera cut between two frames frame_ms apart: the camera moved over 5 units, or turned over 10 degrees while it
|
||||
/// moved over half a unit, for each 60th of a second (a slower frame may move in proportion, up to four times; the game's
|
||||
/// world is in metres, its near plane at 0.1). A made frame between the two pictures of a cut would blend two views that
|
||||
/// have nothing to do with each other: such a frame starts a new history and none is made. The thresholds are NX2navi's,
|
||||
/// from its camera traces of the same game (a median of 0.05 m and 0.08 degrees a frame in play, area loads of 5 to
|
||||
/// 180 m in one frame)
|
||||
inline bool camera_cut(const Pose& before, const Pose& now, float frame_ms) {
|
||||
const float scale = !(frame_ms > 0.0f) ? 1.0f : frame_ms < 16.667f ? 1.0f : frame_ms > 66.667f ? 4.0f : frame_ms / 16.667f;
|
||||
/// What counts as a camera cut: the turn (with a move) in degrees for each 60th of a second, and the least the time between
|
||||
/// the two frames is scaled to (in 60ths of a second; four at the most)
|
||||
struct CutRule {
|
||||
float turn_degrees;
|
||||
float min_scale;
|
||||
};
|
||||
/// Frame generation's (vk_fsr4.cpp fsr4fg): NX2navi's first thresholds (6e87c92), 10 degrees, never less than one 60th
|
||||
constexpr CutRule kFrameGenCut{10.0f, 1.0f};
|
||||
/// The upscalers' (FSR 3.1: vk_fsr3_inputs.cpp; DLSS and FSR 4: vk_temporal.cpp's chain): NX2navi's 2495391, 30 degrees.
|
||||
/// A quick swing of the camera around Link turns it 11 to 18 degrees and moves it 0.9 to 1.4 m a frame: at 10 degrees each
|
||||
/// frame of the swing started a new history, the scene at its render size for those frames, blocky at the smaller modes.
|
||||
/// ((Triforce) never less than one 60th, as frame generation's: NX2navi scaled from a quarter of one, but the time here is
|
||||
/// the CPU's between two recordings of the upscale, not the game's step, and the replay records frames back to back
|
||||
/// after a stall (a shader compile, an area load): a few ms apart, which at a quarter took a 1.25 m move, or a 7.5 degree
|
||||
/// turn with 0.125 m, for a cut, an ordinary swing among them. Above 60 fps a cut is the same move as at 60: an area load
|
||||
/// (5 to 180 m in a frame) or a jump of the camera still is one)
|
||||
constexpr CutRule kUpscalerCut{30.0f, 1.0f};
|
||||
|
||||
/// A camera cut between two frames frame_ms apart: the camera moved over 5 units, or turned over the rule's degrees while
|
||||
/// it moved over half a unit, for each 60th of a second (a slower frame may move in proportion, up to four times, a faster
|
||||
/// one down to the rule's least; the game's world is in metres, its near plane at 0.1). A made frame between the two
|
||||
/// pictures of a cut would blend two views that have nothing to do with each other: such a frame starts a new history and
|
||||
/// none is made; an upscaler's history from before a cut is no use after it. The thresholds are NX2navi's, from its camera
|
||||
/// traces of the same game (a median of 0.05 m and 0.08 degrees a frame in play, area loads of 5 to 180 m in one frame)
|
||||
inline bool camera_cut(const Pose& before, const Pose& now, float frame_ms, const CutRule& rule = kFrameGenCut) {
|
||||
const float least = rule.min_scale > 0.0f ? rule.min_scale : 1.0f;
|
||||
const float k = frame_ms / 16.667f;
|
||||
const float scale = !(frame_ms > 0.0f) ? 1.0f : k < least ? least : k > 4.0f ? 4.0f : k;
|
||||
float move2 = 0.0f, dot = 0.0f, la = 0.0f, lb = 0.0f;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
const float d = now.pos[i] - before.pos[i];
|
||||
@@ -84,8 +136,8 @@ inline bool camera_cut(const Pose& before, const Pose& now, float frame_ms) {
|
||||
const float move = std::sqrt(move2);
|
||||
const float cosine = dot / std::sqrt(la * lb);
|
||||
const float turn = std::acos(cosine < -1.0f ? -1.0f : cosine > 1.0f ? 1.0f : cosine); // (radians)
|
||||
constexpr float kTenDegrees = 0.17453293f;
|
||||
return move > 5.0f * scale || (turn > kTenDegrees * scale && move > 0.5f * scale);
|
||||
const float turn_limit = rule.turn_degrees * 0.017453293f; // (radians)
|
||||
return move > 5.0f * scale || (turn > turn_limit * scale && move > 0.5f * scale);
|
||||
}
|
||||
|
||||
/// What a present with the row at AMD FSR 4 shows between the game's last frame and this one
|
||||
@@ -93,8 +145,52 @@ enum Made {
|
||||
MADE, ///< AMD's library made the frame
|
||||
OWN, ///< it did not take this present (no scene's depth and motion: a menu, a movie; not available; failed): the
|
||||
///< renderer's own interpolation makes the frame, as at 2x
|
||||
SKIP ///< a new history (the first frame, a gap, a camera cut): AMD's library was given the frame and no frame is made
|
||||
SKIP, ///< a new history (the first frame, a gap, a camera cut): AMD's library was given the frame and no frame is made
|
||||
/// ((Triforce, FG-2) the scene's depth and motion are there but AMD's library is not given the frame: no picture
|
||||
/// without the HUD this frame. The game's frame is shown alone: never a made frame of AMD's with the HUD moved in it
|
||||
/// (NX2navi 5bdf583's rule), and not the renderer's own in its place. (HDR Native and an RGBA16F scene, which hold for
|
||||
/// every present, are OWN: held_made)
|
||||
GAME
|
||||
};
|
||||
/// Whether a present's answer shows the game's frame alone, nothing made or blended before it (SKIP, GAME)
|
||||
constexpr bool game_frame_alone(Made m) { return m == SKIP || m == GAME; }
|
||||
|
||||
/// ((Triforce, FG-2) Why a present with the scene's depth and motion was not given to AMD's library, for its log.
|
||||
/// HELD_HDR_NATIVE: the game's own HDR (present_native_pq), whose picture without the HUD only the game could encode.
|
||||
/// HELD_HDR_SCENE: a run whose scene is RenoDX's RGBA16F (vk_temporal.cpp temporal_scene_format), whose upscale output is
|
||||
/// no picture without the HUD this renderer can encode as the presented one is. HELD_NO_HUDLESS: this frame has none
|
||||
enum Held { HELD_NONE, HELD_NO_HUDLESS, HELD_HDR_NATIVE, HELD_HDR_SCENE, HELD_COUNT };
|
||||
/// The reason, from what the present has: the game's own HDR first, then the run's RGBA16F scene (neither can have a
|
||||
/// picture without the HUD), then the picture without the HUD of this frame
|
||||
constexpr Held held_for(bool hdr_native, bool hdr_scene, bool have_hudless) {
|
||||
return hdr_native ? HELD_HDR_NATIVE : hdr_scene ? HELD_HDR_SCENE : !have_hudless ? HELD_NO_HUDLESS : HELD_NONE;
|
||||
}
|
||||
/// ((Triforce) Whether a reason holds for every present while it lasts (HDR Native, the RGBA16F scene), not for one frame
|
||||
/// that is missing its picture without the HUD. Then AMD's library is not asked at all (fsr4fg::frames_wanted: no inputs
|
||||
/// are made for it) and the renderer's own interpolation makes the one frame, as at 2x (OWN), which is what a saved 9 ran
|
||||
/// as on an RX 6000 or 7000 before AMD's FSR 3.1 frame generation was offered there. Only a frame missing its picture
|
||||
/// without the HUD shows the game's frame alone (GAME)
|
||||
constexpr bool held_whole_run(Held h) { return h == HELD_HDR_NATIVE || h == HELD_HDR_SCENE; }
|
||||
/// What a held present shows: the renderer's own frame for a reason that lasts, the game's frame alone for a missing picture
|
||||
constexpr Made held_made(Held h) { return held_whole_run(h) ? OWN : GAME; }
|
||||
|
||||
/// ((Triforce, FG-2) The picture without the HUD is taken at the gameplay upscale's output (its size ow x oh), the present
|
||||
/// is the window texture (sw x sh) cropped to x, y, w, h (vk_present_rect.h present_source_rect). The part of the output that
|
||||
/// is the present's crop, scaled when the two sizes differ (the handheld size's scaled crop, NX2navi 81cdd67), in whole
|
||||
/// pixels inside the output; all zero when there is nothing to take
|
||||
struct SourceRect {
|
||||
int32_t x0 = 0, y0 = 0, x1 = 0, y1 = 0;
|
||||
};
|
||||
inline SourceRect hudless_source(uint32_t ow, uint32_t oh, uint32_t sw, uint32_t sh, uint32_t x, uint32_t y, uint32_t w,
|
||||
uint32_t h) {
|
||||
SourceRect r;
|
||||
if (!ow || !oh || !sw || !sh || !w || !h || x >= sw || y >= sh) return r;
|
||||
const uint64_t rx = x + w > sw ? sw : (uint64_t)x + w, ry = y + h > sh ? sh : (uint64_t)y + h;
|
||||
r.x0 = (int32_t)((uint64_t)x * ow / sw), r.y0 = (int32_t)((uint64_t)y * oh / sh);
|
||||
r.x1 = (int32_t)(rx * ow / sw), r.y1 = (int32_t)(ry * oh / sh);
|
||||
if (r.x1 <= r.x0 || r.y1 <= r.y0) r = SourceRect{};
|
||||
return r;
|
||||
}
|
||||
|
||||
/// A frame generation context as it was made: the presented picture's size, the largest scene it takes, and whether the
|
||||
/// scene's far plane is at infinity (a context is made for one kind of depth)
|
||||
|
||||
Reference in New Issue
Block a user