mirror of
https://git.triforceproject.com/triforce/source
synced 2026-11-28 20:08:51 -04:00
Triforce v0.8.5
A Randomizer page in the launcher, a new title screen with Mods and Save Select tabs, scaling changes applied in game, the Jabu-Jabu bars fixed, renderer frame-time work and the brightness-flash fix, and fixes from the 0.8.4 reports.
This commit is contained in:
@@ -361,7 +361,21 @@ Code parse_code(const uint8_t* ctl, const uint8_t* area, uint32_t end) {
|
||||
// (triforce 11-08) EvilOOT's lowering (lower_to_maxwell.h: high GPRs shadowed in more register banks), and Triforce's old
|
||||
// one (lower_to_maxwell_regmap.h: REGMAP_nx2 extended registers) for a program it rejects, so that nothing drawn before is
|
||||
// lost. RX_VK_OLD_LOWERING=1: the old one for every program, as before
|
||||
static const bool old_lowering = getenv("RX_VK_OLD_LOWERING") != nullptr;
|
||||
// ((11-28) lab: RX_VK_OLD_LOWERING=<key prefix>,...: the old one for those programs only, for the Jabu-Jabu bars)
|
||||
static const char* const old_env = getenv("RX_VK_OLD_LOWERING");
|
||||
bool old_lowering = old_env != nullptr;
|
||||
if (old_env && strcmp(old_env, "1") != 0) {
|
||||
char hex[24];
|
||||
snprintf(hex, sizeof hex, "%016llx", (unsigned long long)c.key);
|
||||
old_lowering = false;
|
||||
for (const char* q = old_env; *q && !old_lowering;) {
|
||||
const char* e = q;
|
||||
while (*e && *e != ',') e++;
|
||||
old_lowering = e > q && !strncmp(hex, q, (size_t)(e - q));
|
||||
q = *e ? e + 1 : e;
|
||||
}
|
||||
if (old_lowering) logf("vk: NVN2 program %s (stage %u): the old lowering, as RX_VK_OLD_LOWERING asks", hex, st);
|
||||
}
|
||||
Shader::Ampere::LoweredProgram lowered;
|
||||
if (!old_lowering) lowered = Shader::Ampere::LowerToMaxwell(native);
|
||||
if (old_lowering || !lowered) {
|
||||
@@ -3953,7 +3967,19 @@ void translate_mesh_into(Program& p, const NvnState& s, const Code* task, const
|
||||
mrt.mesh_fallback_task = task_t != nullptr;
|
||||
mrt.mesh_fallback_task_threads = task_t ? task_t->program.workgroup_size[0] : 0;
|
||||
mrt.mesh_fallback_layout = fallback ? mesh_fallback_layout() : 0;
|
||||
const std::vector<uint32_t> mspirv = Shader::Backend::SPIRV::EmitSPIRV(fallback ? profile_pinned() : profile_graphics(VK_SHADER_STAGE_MESH_BIT_EXT), mrt, mesh_t->program, bindings);
|
||||
std::vector<uint32_t> mspirv = Shader::Backend::SPIRV::EmitSPIRV(fallback ? profile_pinned() : profile_graphics(VK_SHADER_STAGE_MESH_BIT_EXT), mrt, mesh_t->program, bindings);
|
||||
// ((11-28) lab: RX_VK_SPV_SWAP_DIR: the mesh stage from <key>_mesh.spv there too, as the fragment stage below)
|
||||
if (const char* sd = getenv("RX_VK_SPV_SWAP_DIR"); sd && !fallback) {
|
||||
char path[512];
|
||||
snprintf(path, sizeof path, "%s/%016llx_mesh.spv", sd, (unsigned long long)p.key);
|
||||
if (FILE* f = fopen(path, "rb")) {
|
||||
std::vector<uint32_t> w;
|
||||
uint32_t x;
|
||||
while (fread(&x, 4, 1, f) == 1) w.push_back(x);
|
||||
fclose(f);
|
||||
if (!w.empty()) mspirv = std::move(w), logf("vk: mesh stage of %016llx swapped for %s", (unsigned long long)p.key, path);
|
||||
}
|
||||
}
|
||||
kept.push_back(mspirv);
|
||||
Stage ms;
|
||||
ms.nvn_stage = bank_stage(mesh);
|
||||
@@ -4031,7 +4057,20 @@ void translate_mesh_into(Program& p, const NvnState& s, const Code* task, const
|
||||
if (fs->program.info.loads.Generic(i) && !mesh_t->program.info.stores.Generic(i))
|
||||
frt.point_coord_generics.set(i);
|
||||
for (int i = 0; i < 8; i++) frt.color_output_types[i] = static_cast<Shader::AttributeType>(color_types[i]);
|
||||
const std::vector<uint32_t> fspirv = Shader::Backend::SPIRV::EmitSPIRV(profile_graphics(VK_SHADER_STAGE_FRAGMENT_BIT), frt, fs->program, bindings);
|
||||
std::vector<uint32_t> fspirv = Shader::Backend::SPIRV::EmitSPIRV(profile_graphics(VK_SHADER_STAGE_FRAGMENT_BIT), frt, fs->program, bindings);
|
||||
// ((11-28) lab: RX_VK_SPV_SWAP_DIR=<folder>: a mesh program's fragment stage from <key>_frag.spv there when there is
|
||||
// one (a hand-edited translation, with RX_VK_NO_PROGRAM_CACHE=1), for the Jabu-Jabu bars)
|
||||
if (const char* sd = getenv("RX_VK_SPV_SWAP_DIR")) {
|
||||
char path[512];
|
||||
snprintf(path, sizeof path, "%s/%016llx_frag.spv", sd, (unsigned long long)p.key);
|
||||
if (FILE* f = fopen(path, "rb")) {
|
||||
std::vector<uint32_t> w;
|
||||
uint32_t x;
|
||||
while (fread(&x, 4, 1, f) == 1) w.push_back(x);
|
||||
fclose(f);
|
||||
if (!w.empty()) fspirv = std::move(w), logf("vk: fragment stage of %016llx swapped for %s", (unsigned long long)p.key, path);
|
||||
}
|
||||
}
|
||||
kept.push_back(fspirv);
|
||||
Stage f;
|
||||
f.nvn_stage = 1;
|
||||
@@ -4707,6 +4746,142 @@ std::string program_cache_path() {
|
||||
disk_init();
|
||||
return disk_on ? disk_path : std::string();
|
||||
}
|
||||
} // namespace mkwvk
|
||||
#include "lab_ab.h"
|
||||
#include "pickwide.h"
|
||||
namespace mkwvk {
|
||||
// ---- ((Triforce, 11-26, the GPU audit's C02) A draw's program by a wider memo in front of program_for: pickwide.h has the rule ----
|
||||
// Here, outside the translation stamp: it changes no translation, no record and no key a record is picked by. It returns a program
|
||||
// only where that is the last one program_for gave these inputs on this thread and one pass over its answers (or the generations
|
||||
// that pass was made at) says it is of the bound textures' types; everything else is program_for, in the stamp, token for token as
|
||||
// it was. A draw that goes to program_for pays nothing here but the find and the note of what it gave (the inputs and a pointer
|
||||
// copied): the pass is made when those inputs are next seen, so a program drawn once before its entry is replaced is never
|
||||
// walked a third time.
|
||||
// program_for's own line ("vk: program picks: N kept ... of N") counts only the picks that come to it. What it reads of the stamp's side it reads as program_for's memo and its two walks do: prog_stage_sig, answer_stage_mask,
|
||||
// answer_handle, answer_of, canonical_answer.
|
||||
namespace {
|
||||
enum PwCount { PW_MEMO, PW_PAST_UB, PW_PASS, PW_FULL, PW_ASKED, PW_UNKEPT, PW_COMPARED, PW_DIFFER, PW_WRONG, PW_FIRST, PW_COUNT };
|
||||
std::atomic<int64_t> pw_count[PW_COUNT];
|
||||
thread_local int64_t pw_mine[PW_COUNT]; // (this thread's, added to pw_count by pw_flush: no shared line written at a draw)
|
||||
thread_local uint32_t pw_picks = 0;
|
||||
// (a recording thread's own, as the picks are; made at its first pick and left to the process: a pointer, since with llvm-mingw
|
||||
// every use of a thread_local Table, which holds vectors, would go through its TLS wrapper and the file's TLS init function, as
|
||||
// tests/test_tls_objects.py says of vk_draw.cpp's)
|
||||
thread_local pickwide::Table* pw_table = nullptr;
|
||||
thread_local int pw_mode_was = -1;
|
||||
|
||||
/// This thread's counts added to the totals: at every 256th pick, at a change of mode, and at once at a check-mode difference
|
||||
/// (the totals are what check mode is read by, and a helper thread may record nothing more for the rest of the run)
|
||||
void pw_flush() {
|
||||
for (int k = 0; k < PW_COUNT; k++)
|
||||
if (pw_mine[k]) pw_count[k].fetch_add(pw_mine[k], std::memory_order_relaxed), pw_mine[k] = 0;
|
||||
}
|
||||
|
||||
/// RX_VK_PICK_WIDE (read once; logged when not the default), off in the lab's "nopickwide" phases
|
||||
pickwide::Mode pw_mode() {
|
||||
static const pickwide::Mode env = [] {
|
||||
const pickwide::Mode m = pickwide::mode(getenv("RX_VK_PICK_WIDE"));
|
||||
if (m != pickwide::Mode::On)
|
||||
logf("vk: program picks: the wide memo %s (RX_VK_PICK_WIDE=%s)",
|
||||
m == pickwide::Mode::Off ? "off: program_for's pair of last picks and its two walks, as before"
|
||||
: "checked: a draw the memo answers is asked of program_for too, whose program is drawn; the "
|
||||
"frame line counts the differences",
|
||||
getenv("RX_VK_PICK_WIDE"));
|
||||
return m;
|
||||
}();
|
||||
return pickwide::in_phase(env, lab_ab::on("nopickwide"));
|
||||
}
|
||||
/// The variant's types, canonical, an answer each: what one pass compares a bound texture's with
|
||||
void pw_canon(const Program& p, pickwide::Entry& e) {
|
||||
e.canon.resize(p.answers.size());
|
||||
for (size_t i = 0; i < e.canon.size(); i++) e.canon[i] = canonical_answer(p, p.answers[i], p.answers[i].type);
|
||||
}
|
||||
/// One pass over p's answers (pickwide.h one_pass): whether the textures bound now are of the variant's types
|
||||
bool pw_pass(const NvnState& s, const Program& p, pickwide::Entry& e, pickwide::Walk* w) {
|
||||
return pickwide::one_pass(
|
||||
e, p.answers.size(), [&](size_t i) { return answer_handle(s, p, p.answers[i]); },
|
||||
[](uint32_t id) { return texture_slot_version((int)id); },
|
||||
[&](size_t i, uint32_t h) {
|
||||
const Program::Answer& a = p.answers[i];
|
||||
return canonical_answer(p, a, answer_of(h, a.image)) == e.canon[i];
|
||||
},
|
||||
w);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
const Program* program_for_wide(const NvnState& s, const uint8_t color_types[8]) {
|
||||
static_assert(pickwide::kStages == kNvnStages, "pickwide.h kStages is NvnState::tex_gen's count");
|
||||
const pickwide::Mode mode = pw_mode();
|
||||
if ((int)mode != pw_mode_was) { // (a lab phase began or ended: program_for moved its picks without the memo, or will)
|
||||
if (pw_table) pickwide::clear(*pw_table);
|
||||
pw_mode_was = (int)mode;
|
||||
pw_flush(); // (what this thread counted before: the off path below does not flush, and a run can end in a nopickwide phase)
|
||||
}
|
||||
if (mode == pickwide::Mode::Off || !s.has_prog) return program_for(s, ProgramKind::Graphics, color_types);
|
||||
if (!pw_table) pw_table = new pickwide::Table();
|
||||
pickwide::Table& t = *pw_table;
|
||||
if ((++pw_picks & 255) == 0) pw_flush();
|
||||
static const pickwide::Rules rules =
|
||||
pickwide::rules(getenv("RX_VK_PICK_BIND_GEN") != nullptr, getenv("RX_VK_DEFERRED_LATE") != nullptr);
|
||||
const pickwide::Now now{s.prog.serial, prog_stage_sig(s.prog), s.bind_gen, registrations_generation(), ub_generation(), s.nvattr,
|
||||
s.vattr, color_types, s.tex_gen};
|
||||
const Program* mine = nullptr; // (the memo's; null: program_for)
|
||||
pickwide::Entry* e = pickwide::find(t, now);
|
||||
if (e) {
|
||||
const Program* const p = static_cast<const Program*>(e->p);
|
||||
if (!p->ready.load(std::memory_order_acquire) || p->failed) {
|
||||
pickwide::drop(*e), e = nullptr;
|
||||
} else if (!e->walked) { // (noted at its last draw, program_for's: its first pass, every answer asked)
|
||||
pw_canon(*p, *e);
|
||||
pickwide::Walk w;
|
||||
const bool ok = pw_pass(s, *p, *e, &w);
|
||||
pw_mine[PW_ASKED] += w.checked;
|
||||
if (ok) pickwide::found(*e, now, answer_stage_mask(*p)), mine = p, pw_mine[PW_PASS]++, pw_mine[PW_FIRST]++;
|
||||
else pickwide::drop(*e), e = nullptr, pw_mine[PW_UNKEPT]++; // (finished under the pick, or other textures since)
|
||||
} else if (const pickwide::Stand st = pickwide::stands(*e, now, rules); st != pickwide::Stand::No) {
|
||||
mine = p, pw_mine[PW_MEMO]++, pw_mine[PW_PAST_UB] += st == pickwide::Stand::PastUpdate;
|
||||
} else { // (its textures moved, or a slot was registered: asked in one pass)
|
||||
pickwide::Walk w;
|
||||
if (pw_pass(s, *p, *e, &w)) pickwide::restamp(*e, now), mine = p, pw_mine[PW_PASS]++;
|
||||
pw_mine[PW_ASKED] += w.checked;
|
||||
}
|
||||
}
|
||||
if (mine && mode == pickwide::Mode::On) return mine;
|
||||
const Program* const full = program_for(s, ProgramKind::Graphics, color_types);
|
||||
if (mine) { // (RX_VK_PICK_WIDE=check: program_for's is drawn, the memo's compared)
|
||||
pw_mine[PW_COMPARED]++;
|
||||
if (mine == full) return full;
|
||||
pickwide::Entry probe; // (every answer of the memo's asked afresh: of the bound textures' types, or a wrong variant)
|
||||
pw_canon(*mine, probe);
|
||||
const bool of_types = pw_pass(s, *mine, probe, nullptr);
|
||||
pw_mine[PW_DIFFER]++, pw_mine[PW_WRONG] += !of_types;
|
||||
pw_flush(); // (the whole batch: its compares go out with its differences)
|
||||
static std::atomic<int> told{0};
|
||||
if (told.fetch_add(1, std::memory_order_relaxed) < 20)
|
||||
logf("vk: program picks: RX_VK_PICK_WIDE=check: the memo's program %016llx variant %016llx, program_for's %016llx variant "
|
||||
"%016llx%s; the memo's is %s the bound textures' types",
|
||||
(unsigned long long)mine->key, (unsigned long long)mine->variant, (unsigned long long)(full ? full->key : 0),
|
||||
(unsigned long long)(full ? full->variant : 0),
|
||||
!full ? " (no program: the draw is left out)" : !full->ready.load(std::memory_order_acquire) ? " (not ready)" : "",
|
||||
of_types ? "of" : "NOT of");
|
||||
} else {
|
||||
pw_mine[PW_FULL]++;
|
||||
}
|
||||
if (full && full->ready.load(std::memory_order_acquire) && !full->failed) {
|
||||
// (only noted for these inputs, in their entry where one is left (its pass failed, or check mode's differed): nothing of
|
||||
// the program is read here. It is kept once a pass, every answer asked, finds it of the bound textures' types, and that
|
||||
// is at these inputs' next draw: a draw that had to go to program_for does not pay a third walk for a draw that may not come)
|
||||
pickwide::note(e ? *e : pickwide::place(t, now), now, full);
|
||||
} else if (e) {
|
||||
pickwide::drop(*e);
|
||||
}
|
||||
return full;
|
||||
}
|
||||
|
||||
void program_wide_stats(int64_t out[kProgramWideStats]) {
|
||||
static_assert(kProgramWideStats == PW_COUNT, "vk_shader.h kProgramWideStats is PW_COUNT");
|
||||
for (int k = 0; k < PW_COUNT; k++) out[k] = pw_count[k].load(std::memory_order_relaxed);
|
||||
}
|
||||
// ---- (Triforce) Inside the translation stamp again ----
|
||||
|
||||
/// (hookshot, the prediction: vk_predict.cpp) every kept graphics program variant, read without making its modules.
|
||||
|
||||
Reference in New Issue
Block a user