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:
ruckus7382sfgsgdf
2026-11-20 17:06:21 -06:00
parent b0e46adb48
commit 6c7117635c
265 changed files with 26893 additions and 2549 deletions

View File

@@ -1,18 +1,18 @@
"""The Debug tab's layout (gpu/vk/debug_tab_layout.h, gpu/vk/vk_menu.cpp draw_debug_rows; no game).
"""The Debug tab drawn as every other tab of the options (gpu/vk/vk_menu.cpp debug_list, draw_options; no game).
Looked at in pictures (tests/ui_preview.cpp), the tab had three faults. Its rows were cut off in the middle of the column
where they scrolled past the first or the last whole row, while every other tab lets them go under the header and toward
the guides. The Developer row with more than two values (Replay helper threads) had a wider cell than the rows around
it, so the cells' left edges did not line up. And a still (a headless shot, the preview) drew every list at its top
whatever was selected, because only a window's frames stepped the scroll's easing.
The lab's playtest (11-17) showed the Debug tab styled apart from the rest: its headings ("Player", "Story & amiibo") a
plain gold line instead of the game's separator with its mark, a blank row's room between its groups, its own column
geometry (names further left, value cells wider than on every other tab), and its buttons orange without an arrow where
the System tab's were the dark panel with one. Before that it had its own layout (debug_tab_layout.h, gone now) for two
columns that fitted at no window size.
Compiles and runs tests/debug_tab_layout_test.cpp: the cells' widths with the tab's own measures (one column, every cell
the width the widest asks, the Developer row's among them), the same at 1, 1.5, 2 and 3 times the size (the layout scales
with the window's height: two columns fit at no window size), a long name that takes the room, a column wide enough for
two, and never a cell under its narrowest.
Reads the source for the rest: draw_debug_rows takes its widths from that function, clips and culls its rows by the
column's own clip (not by the first and last whole row), and gives the mouse the same; a still is drawn settled.
Now the tab is a list as the others are: draw_options draws it with the same rows, cells, headings and scroll, in the
order debug_list gives (the Debug tools switch, each group of tools under its heading, the Developer heading and its
rows). This compiles debug_list and debug_step from the source with a made-up table of rows and checks: no blank entry,
a group with no row shown has no heading, every heading has a row under it, the tools gone with the switch off leave the
switch and the Developer rows, and Up and Down walk the rows over the headings. The rest is read in the source: one
drawing loop for every tab, the headings ui::heading's, one action-button style (action_cell: the orange plate with its
arrow) on every tab, and a still drawn settled.
python -I -B tests/test_debug_tab_layout.py [--cxx g++]
"""
@@ -21,7 +21,7 @@ import subprocess
import tempfile
from pathlib import Path
RUN_ALL_ARGS = ["--cxx", "g++"]
RUN_ALL_ARGS = ["--cxx", "{cxx}"]
ROOT = Path(__file__).resolve().parents[1]
@@ -41,37 +41,156 @@ def function(text, head):
return text[start:end]
FIXTURE = r'''#include <cstdio>
#include <cstdlib>
#include <initializer_list>
#include <string_view>
#include <vector>
#define CHECK(x) do { if (!(x)) { std::fprintf(stderr, "FAIL:%d %s\n", __LINE__, #x); std::exit(1); } } while (0)
enum MenuTab { TAB_DISPLAY = 0, TAB_DEBUG = 5 };
struct { int debug_tools, reuse, robust; } opts;
struct Row { MenuTab tab; const char* name; int* value; signed char cheat; bool heading; };
// (the tab's rows in the table's order, as vk_menu.cpp has them: the switch, the tools by their number, Developer)
Row rows[] = {{TAB_DISPLAY, "Elsewhere", &opts.reuse, -1, false}, {TAB_DEBUG, "Debug tools", &opts.debug_tools, -1, false},
{TAB_DEBUG, "Heart protection", nullptr, 0, false}, {TAB_DEBUG, "No-clip flight", nullptr, 1, false},
{TAB_DEBUG, "Mark position", nullptr, 2, false}, {TAB_DEBUG, "Return to mark", nullptr, 3, false},
{TAB_DEBUG, "Set time", nullptr, 4, false}, {TAB_DEBUG, "Inventory item", nullptr, 5, false},
{TAB_DEBUG, "Change quantity", nullptr, 6, false}, {TAB_DEBUG, "Free camera", nullptr, 7, false},
{TAB_DEBUG, "Teleport", nullptr, 8, false}, {TAB_DEBUG, "Switch age", nullptr, 9, false},
{TAB_DEBUG, "Inventory", nullptr, 10, false}, {TAB_DEBUG, "Game flags", nullptr, 11, false},
{TAB_DEBUG, "Cutscenes", nullptr, 12, false}, {TAB_DEBUG, "Scan amiibo", nullptr, 13, false},
{TAB_DEBUG, "Developer", nullptr, -1, true}, {TAB_DEBUG, "Descriptor reuse", &opts.reuse, -1, false},
{TAB_DEBUG, "Robust buffers", &opts.robust, -1, false}};
constexpr int kRows = sizeof rows / sizeof rows[0];
static bool hidden[kRows];
static bool row_shown(int i) { return !hidden[i]; }
int tab_row_count(int t) {
int c = 0;
for (int i = 0; i < kRows; i++) if (rows[i].tab == (MenuTab)t && row_shown(i)) c++;
return c;
}
int tab_row_to_global(int t, int local_idx) {
int count = 0;
for (int i = 0; i < kRows; i++)
if (rows[i].tab == (MenuTab)t && row_shown(i)) {
if (count == local_idx) return i;
count++;
}
return 0;
}
@DEBUG@
static std::vector<const char*> names() { // (the list as drawn: a heading's title or a row's name)
int list[kDebugList];
const int n = debug_list(list);
std::vector<const char*> out;
for (int j = 0; j < n; j++) out.push_back(list[j] < 0 ? debug_groups[-1 - list[j]].title : rows[tab_row_to_global(TAB_DEBUG, list[j])].name);
return out;
}
static bool same(const std::vector<const char*>& got, std::initializer_list<const char*> want) {
if (got.size() != want.size()) return false;
size_t i = 0;
for (const char* w : want) {
if (std::string_view(got[i]) != w) return false;
i++;
}
return true;
}
static void show(const std::vector<const char*>& v) { for (const char* s : v) std::fprintf(stderr, " %s\n", s); }
static int local(const char* name) { // (a row's number on the tab)
const int n = tab_row_count(TAB_DEBUG);
for (int k = 0; k < n; k++) if (std::string_view(rows[tab_row_to_global(TAB_DEBUG, k)].name) == name) return k;
return -1;
}
int main() {
hidden[7] = hidden[8] = true; // (Inventory item and Change quantity: never on the tab)
std::vector<const char*> v = names();
if (!same(v, {"Debug tools", "Player", "Heart protection", "No-clip flight", "Switch age", "Inventory", "Story & amiibo",
"Game flags", "Cutscenes", "Scan amiibo", "Travel", "Teleport", "Mark position", "Return to mark",
"Camera & world", "Free camera", "Set time", "Developer", "Descriptor reuse", "Robust buffers"})) {
show(v);
CHECK(!"the tab's list with every tool");
}
// (the tools off: they are not shown, nor their headings)
for (int i = 2; i <= 15; i++) hidden[i] = true;
v = names();
if (!same(v, {"Debug tools", "Developer", "Descriptor reuse", "Robust buffers"})) {
show(v);
CHECK(!"the tab's list with the tools off");
}
// (a group none of whose rows is shown: no heading, no room)
for (int i = 2; i <= 15; i++) hidden[i] = i == 7 || i == 8 || i == 4 || i == 5 || i == 10;
v = names();
if (!same(v, {"Debug tools", "Player", "Heart protection", "No-clip flight", "Switch age", "Inventory", "Story & amiibo",
"Game flags", "Cutscenes", "Scan amiibo", "Camera & world", "Free camera", "Set time", "Developer",
"Descriptor reuse", "Robust buffers"})) {
show(v);
CHECK(!"the tab's list without the Travel rows");
}
// Up and Down: the rows in the list's order, over the headings, round at the ends
CHECK(debug_step(local("Debug tools"), 1) == local("Heart protection"));
CHECK(debug_step(local("Inventory"), 1) == local("Game flags"));
CHECK(debug_step(local("Set time"), 1) == local("Descriptor reuse"));
CHECK(debug_step(local("Robust buffers"), 1) == local("Debug tools"));
CHECK(debug_step(local("Debug tools"), -1) == local("Robust buffers"));
CHECK(debug_step(local("Game flags"), -1) == local("Inventory"));
std::puts("ok");
}
'''
def main():
p = argparse.ArgumentParser(description=__doc__)
p.add_argument("--cxx", default="g++")
a = p.parse_args()
menu = (ROOT / "gpu/vk/vk_menu.cpp").read_text(encoding="utf-8")
draw = function(menu, "void draw_debug_rows(")
check("void draw_debug_rows(ui::Ctx& c, float cx0, float cx1, float top, float bottom, float clip0, float clip1, int sel) {" in draw
and "draw_debug_rows(c, cx0, cx1, top, bottom, clip0, clip1, sel);" in function(menu, "void draw_options(ui::Ctx& c) {"),
"the Debug tab is not given the column's clip")
check("c.d->PushClipRect(ImVec2(cx0, clip0), ImVec2(cx1, std::max(clip0, clip1)), true);" in draw, "the Debug tab's rows are not clipped as the other tabs'")
check(draw.count("if (y + pitch <= clip0 || y >= clip1)") == 2 and "<= top || y >= bottom" not in draw,
"a row or a heading is left out, or cut, at the first or last whole row")
check("hits.add(x0, std::max(y, clip0), x1, std::min(y + rh, clip1), menu_hit::kRow, k, va.x, vb.x, 0, 0, 0, vm);" in draw,
"the mouse's rows are not what shows of them") # ((Triforce) vm: where a toggle's halves meet, tests/test_menu_hit.py)
check("scroll_rows(TAB_DEBUG, visual_count, sel_at, top, bottom, pitch, &shown)" in draw, "the scroll no longer counts whole rows between top and bottom")
check("debug_tab::widths(col_w, right - left, name_need, cell_full, cell_tight, span_need)" in draw
and "if (i == 0 || i >= dev) span_need = std::max(span_need, need(" in draw, "the cells' widths are not debug_tab_layout.h's")
check("const float width = in_tools ? cell_w[vcol[i]] : span_w;" in draw, "the switch's and the Developer rows' cells are not one width")
ui = (ROOT / "gpu/vk/vk_ui.h").read_text(encoding="utf-8")
check("draw_debug_rows" not in menu and not (ROOT / "gpu/vk/debug_tab_layout.h").exists(),
"the Debug tab still has a layout of its own")
draw = function(menu, "void draw_options(ui::Ctx& c) {")
# one list, one loop, for every tab: the Debug tab's entries are debug_list's
check("if (cur_tab == TAB_DEBUG) listed = debug_list(list);" in draw and "return;" not in draw[:draw.index("PushClipRect")],
"the Debug tab is not drawn by the tabs' own loop")
check("scroll_rows(cur_tab, listed, sel_at, top, bottom, pitch, &shown)" in draw, "the Debug tab's list does not scroll as the others")
# its headings the game's separator and title, as the others'
check("ui::heading(c, ImVec2(rx0, y), ImVec2(rx1, y + rh), rx0 + ui::lu(c, 72), i < 0 ? debug_groups[-1 - i].title : r.name);" in draw
and "AddLine(" not in draw, "a Debug group's heading is not the game's separator and title")
check("separator(c, " in function(ui, "inline void heading("), "ui::heading has no separator")
# its rows the same cells: the tools' toggles, Link's age, choices and buttons
check("} else if (r.cheat >= 0) {" in draw and 'halves_cell(c, va, vb, "On", "Off", cheat_value(r.cheat) != "On", selected, false);' in draw
and 'halves_cell(c, va, vb, "Kid", "Adult", link_age.load(std::memory_order_relaxed) == 1, selected, false);' in draw,
"the debug tools' toggles are not the tabs' halves")
# one action-button style: the orange plate with its arrow, on the System tab's rows as on the Debug tab's
action = function(menu, "void action_cell(")
check("choice_cell(c, a, b, word, sel, false, !fixed, fixed);" in action, "action_cell is not the orange plate with its arrow")
check("else action_cell(c, va, vb, v.empty() ? buttons[r.cheat] : v, selected, r.cheat == 9);" in draw
and 'else action_cell(c, va, vb, ends ? r.name : share_row(r) ? share_label(share_row(r)) : "Open", selected);' in draw,
"the Debug tab's buttons and the page, save, Restart and Quit rows are not one style")
check(", false, true, false, true)" not in draw, "a row still draws its button as the dark panel")
# the rows clipped as the other tabs': none under the header
check("if (y < clip0 || y > clip1) continue;" in draw, "a row is drawn with its top under the header")
check("hits.add(rx0, std::max(y, clip0), rx1, std::min(y + rh, clip1), menu_hit::kRow, i, va.x, vb.x, t0, t1, 0, vm);" in draw,
"the mouse's rows are not what shows of them")
# Up and Down on the tab walk debug_list's order
tick = function(menu, "void menu_tick() {")
check("selected = debug_step(selected, press[2] ? 1 : -1);" in tick, "Up and Down do not walk the Debug tab's order")
# a still is drawn settled: only menu_record, a window's frames, steps the easing
image = function(menu, "void menu_record_image(")
record = function(menu, "void menu_record(VkCommandBuffer cmd, uint32_t index")
check("if (!ease_live) ease_step = 1.0f;" in image and image.index("if (!ease_live) ease_step = 1.0f;") < image.index("draw_menu(c"),
"a still does not draw the lists where the selection asks")
check("ease_live = true;" in record and "ease_live = true" not in image, "the window's frames do not keep their easing")
with tempfile.TemporaryDirectory() as tmp:
exe = Path(tmp) / "debug_tab_layout_test.exe"
subprocess.run([a.cxx, "-std=c++20", "-O1", "-Wall", "-Wextra", "-Werror", str(ROOT / "tests/debug_tab_layout_test.cpp"), "-o", str(exe)], check=True)
start = menu.index("struct DebugGroup {")
debug = menu[start:menu.index("/// (Triforce) A row that does something or opens a page")]
fixture = FIXTURE.replace("@DEBUG@", debug)
with tempfile.TemporaryDirectory(prefix="debug-tab-") as tmp:
cpp, exe = Path(tmp) / "fixture.cpp", Path(tmp) / "fixture.exe"
cpp.write_text(fixture, encoding="utf-8")
subprocess.run([a.cxx, "-std=c++20", "-O1", "-Wall", "-Wextra", "-Werror", str(cpp), "-o", str(exe)], check=True)
run = subprocess.run([str(exe)], capture_output=True, text=True)
if run.returncode or run.stdout.strip() != "ok":
raise SystemExit("FAIL: tests/debug_tab_layout_test.cpp (exit %d)\n%s%s" % (run.returncode, run.stdout, run.stderr))
print("PASS: the Debug tab's cells line up, its rows are clipped as the other tabs', and a still is drawn settled")
raise SystemExit("FAIL: the Debug tab's list (exit %d)\n%s%s" % (run.returncode, run.stdout, run.stderr))
print("PASS: the Debug tab is a list as the other tabs are: their rows, headings, buttons and scroll, no blank rows")
if __name__ == "__main__":