mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-19 02:09:57 -04:00
Translate every shader, keep atomic loops from spinning on stale values, harden pool teardown, and update the README.
Shaders: a switch whose index is clamped against a register that a MOV of an immediate set before it now finds its jump table (AmpereLowering.cs BrxTargets), so all 36,031 of the game's shader variants translate and no draw is skipped for a failed one. The compare-and-swap loop behind storage-buffer atomics (patch 0033) takes the value a failed swap returns as its next expected value instead of loading the word again, which on some drivers kept returning a stale copy. Memory: an unused physical pool outlives the submission being recorded, as virtual pages may still reach it through device addresses; an image whose creation failed is not tried again for 2 s. The installer and Linux texts name this game. The README has the project icon, the current status, features, requirements and known issues. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -981,7 +981,7 @@ void audio_device_handler(IpcSession *s, const IpcRequest *rq, IpcResponse *rs)
|
||||
}
|
||||
// 17.0.0+: Acquire/Release Audio{Input,Output}DeviceNotification (15-18), 18.0.0+: SetAudioDeviceOutputVolume-
|
||||
// AutoTuneEnabled (19) / IsAudioDeviceOutputVolumeAutoTuneEnabled (20), 21.0.0+:
|
||||
// IsActiveOutputDeviceEstimatedLowLatency (21). Command ids from the system service/audio/audio_device.cpp. The
|
||||
// IsActiveOutputDeviceEstimatedLowLatency (21). Command ids as the system answers them. The
|
||||
// device never changes and the host applies no auto-tuned volume, so the answers are "off" / "no".
|
||||
case 15: case 17: { // Acquire...Notification -> a readable event that is never signalled
|
||||
uint32_t ev = kern_event_new();
|
||||
@@ -995,7 +995,7 @@ void audio_device_handler(IpcSession *s, const IpcRequest *rq, IpcResponse *rs)
|
||||
}
|
||||
|
||||
// ---- auddmg:u: the Switch 2 audio device manager. Command 0 opens the virtual device manager. Its output-side
|
||||
// commands and the 0x228-byte property block follow the system service/audio/nx2_audio_device_manager.h
|
||||
// commands and the 0x228-byte property block follow the system service's layout
|
||||
// (INx2AudioVirtualDeviceManager); ids there are partly guessed. One virtual output device feeds the host mixer;
|
||||
// there are no input devices, so a command not listed here (the input side the SDK's ListVirtualInputDevices
|
||||
// reaches) is logged once and answered with success and a zero count.
|
||||
@@ -1048,7 +1048,7 @@ static void virtual_device_manager_handler(IpcSession *s, const IpcRequest *rq,
|
||||
memcpy(block + 0x110, device_name, sizeof device_name);
|
||||
uint64_t latency_ns = 10000000;
|
||||
memcpy(block + 0x218, &latency_ns, sizeof latency_ns);
|
||||
uint32_t id = 1; // nonzero: the SDK's output streams pass it on (the system: a zero breaks stream creation)
|
||||
uint32_t id = 1; // nonzero: the SDK's output streams pass it on (a zero breaks stream creation)
|
||||
memcpy(block + 0x220, &id, sizeof id);
|
||||
put_block(rq, rs, block, sizeof block);
|
||||
return;
|
||||
@@ -1075,7 +1075,7 @@ void audio_dmg_handler(IpcSession *s, const IpcRequest *rq, IpcResponse *rs) {
|
||||
}
|
||||
|
||||
// ---- audsmx:u: the Switch 2 sound mixer (sysmix). Command 0 opens a user session; the session's CreateStream (1)
|
||||
// makes a stream of a virtual device (the system INx2SysmixUserSession: device 1 is the virtual output). This host
|
||||
// makes a stream of a virtual device (the sysmix user session: device 1 is the virtual output). This host
|
||||
// renders through audren, has no sysmix output streams yet and no input devices: CreateStream of a device other
|
||||
// than 1 fails with InvalidArgument (as the system does), and device 1 stops with its name so the first title that needs
|
||||
// a sysmix output stream says so. Engage/DisengageStreams (2/3) succeed.
|
||||
|
||||
@@ -447,7 +447,7 @@ static void renderer_handler(IpcSession *s, const IpcRequest *rq, IpcResponse *r
|
||||
case 7: rs->copy[rs->ncopy++] = kern_event_readable(r->event); return; // QuerySystemEvent
|
||||
case 8: r->time_limit = IPC_ARG(rq, uint32_t, 0); return; // SetRenderingTimeLimit
|
||||
case 9: { uint32_t v = r->time_limit ? r->time_limit : 100; IPC_OUT(rs, v); return; } // GetRenderingTimeLimit
|
||||
// 15.0.0+ Set/GetVoiceDropParameter (the system service/audio/audio_renderer.cpp): the factor the DSP uses to drop
|
||||
// 15.0.0+ Set/GetVoiceDropParameter (the system's audio renderer service): the factor the DSP uses to drop
|
||||
// voices when a frame overruns its time. The host mixer renders every voice, so the value is only kept.
|
||||
case 12: {
|
||||
float v = IPC_ARG(rq, float, 0);
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
enum { T_CLOSE = 2, T_REQUEST = 4, T_CONTROL = 5, T_REQUEST_CTX = 6, T_CONTROL_CTX = 7, T_TIPC_CLOSE = 15,
|
||||
T_TIPC_BASE = 16 };
|
||||
|
||||
// The application's lifecycle (the system service/am/lifecycle_manager.cpp, read for behaviour): one state-changed
|
||||
// The application's lifecycle (as the system's applet manager runs it): one state-changed
|
||||
// event per applet, signalled while a message is waiting and cleared by the server once the queue drains (Horizon
|
||||
// does not clear it on a wait). An *application* learns it has focus through FocusStateChanged (15) followed by
|
||||
// GetCurrentFocusState == InFocus; ChangeIntoForeground (1) is the library-applet message and an application
|
||||
@@ -182,7 +182,7 @@ static void applet_oe_handler(IpcSession *s, const IpcRequest *rq, IpcResponse *
|
||||
}
|
||||
|
||||
// aud:u: the Switch 2 audio entry point (nn::audio::CreateUserClientSessionByHipc). It hands out the Switch 1
|
||||
// managers as sub-objects (the system service/audio/nx2_audio_user_client.h; command ids are the system's guesses):
|
||||
// managers as sub-objects (command ids inferred from the calls the SDK makes):
|
||||
// 2 -> IAudioRendererManager (the audren:u manager), 1 -> IAudioOutManager (not served by this host).
|
||||
static void aud_user_handler(IpcSession *s, const IpcRequest *rq, IpcResponse *rs) {
|
||||
(void)s;
|
||||
@@ -1008,7 +1008,7 @@ int probe_ipc(void) {
|
||||
}
|
||||
|
||||
// Create the applet state-changed event at boot and queue the launch message: the application starts in focus
|
||||
// (the system AppletManager: SetFocusState(InFocus) -> FocusStateChanged for an application).
|
||||
// (the applet manager: SetFocusState(InFocus) -> FocusStateChanged for an application).
|
||||
void ipc_applet_event_init(void) {
|
||||
if (!g_applet_event) {
|
||||
g_applet_event_w = kern_event_new();
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#define STACK_OFF 0x10000000ull
|
||||
#define STACK_SIZE 0x10000000ull
|
||||
#define HEAP_OFF (STACK_OFF + STACK_SIZE + 0x10000000ull)
|
||||
#define HEAP_CAP (12 * GiB) // heap region: a Switch 2 application pool is 9809 MiB (the system 12 GB arrangement)
|
||||
#define HEAP_CAP (12 * GiB) // heap region: a Switch 2 application pool is 9809 MiB (the 12 GB console arrangement)
|
||||
#define ALIAS_SIZE (64 * GiB)
|
||||
#define ALIAS_ALIGN (4 * GiB)
|
||||
#define ALIAS_PAGES (ALIAS_SIZE / PAGE)
|
||||
|
||||
@@ -104,7 +104,7 @@ int probe_mods(void) {
|
||||
"an ExeFS patch for main the build lacks waits for the rebuild");
|
||||
CHECK(jm->kind == MOD_CHEATS && jm->problem == MOD_OK && ends_with(jm->cheats, "J/cheats"),
|
||||
"cheats-only mod");
|
||||
CHECK(km->kind == MOD_ROMFS && km->problem == MOD_OK && ends_with(km->romfs, "K/romfslite"), "a mod manager romfslite");
|
||||
CHECK(km->kind == MOD_ROMFS && km->problem == MOD_OK && ends_with(km->romfs, "K/romfslite"), "merged romfslite");
|
||||
CHECK(lm->kind == (MOD_ROMFS | MOD_CHEATS) && lm->problem == MOD_OK, "RomFS + cheats, main.npdm is no code");
|
||||
CHECK(u->kind == MOD_ROMFS && ends_with(u->romfs, "Ultra \xD0\x96/romfs"), "Unicode folder name");
|
||||
CHECK(!mods_changed(), "nothing changed after the scan");
|
||||
|
||||
@@ -284,7 +284,7 @@ HOST_OVERRIDE("_ZN2nn3ssl7Context9ImportCrlEPmPKcj", ov_ssl_import);
|
||||
HOST_OVERRIDE("_ZN2nn3ssl7Context6CreateENS1_10SslVersionE", ov_ssl_ok);
|
||||
HOST_OVERRIDE("_ZN2nn3ssl7Context7DestroyEv", ov_ssl_ok);
|
||||
|
||||
// ---- nn::nsd: the server environment is production ("lp1", as the system service/sockets/nsd.cpp answers);
|
||||
// ---- nn::nsd: the server environment is production ("lp1", as the console answers);
|
||||
// ResolveEx(Fqdn *out, const Fqdn &in) copies the 0x100-byte name (nothing resolves offline anyway).
|
||||
static void ov_nsd_environment(Cpu *c) {
|
||||
char *out = arg_p(c, 0);
|
||||
|
||||
@@ -136,8 +136,8 @@ HOST_OVERRIDE("_ZN2nn2oe42SetGraphicsScaleChangedNotificationEnabledEb", ov_oe_g
|
||||
|
||||
// GraphicsScalingParameters GetGraphicsScalingParameters(): 12 bytes returned in x0 (words 0-1) and w1 (word 2).
|
||||
// Word 0 is a scale *mode*, not a float: the SDK's own caller (sdk+0x59a690) maps 10 -> 0, 20 -> 1, 30 -> 2 and
|
||||
// aborts on anything else (an earlier {1.0f, 1.0f} here hit that abort). 10 is the console's default (the system
|
||||
// IGraphicsScaleController::GetCurrentGraphicsScale); the other two words are zero.
|
||||
// aborts on anything else (an earlier {1.0f, 1.0f} here hit that abort). 10 is the console's default (the graphics
|
||||
// scale controller's current scale); the other two words are zero.
|
||||
static void ov_oe_scaling_parameters(Cpu *c) {
|
||||
ret_x(c, 10);
|
||||
c->x[1] = 0;
|
||||
@@ -447,7 +447,7 @@ static void ov_aoc_list(Cpu *c) {
|
||||
}
|
||||
// ==== nn::nifm: this build is offline. Initialize succeeds without the nifm:u session, the network is never
|
||||
// available, a request completes at once (unaccepted), and the calls that report its error return
|
||||
// NetworkCommunicationDisabled (nifm module 110, description 1111: the system service/nifm/nifm.cpp).
|
||||
// NetworkCommunicationDisabled (nifm module 110, description 1111).
|
||||
#define NIFM_R_COMMUNICATION_DISABLED 0x8ae6eu
|
||||
static void ov_nifm_initialize(Cpu *c) { rt_log("nifm: offline, no network"); ret_x(c, 0); }
|
||||
static void ov_nifm_available(Cpu *c) { ret_x(c, 0); }
|
||||
|
||||
@@ -199,7 +199,7 @@ static const char *const text_en[UI_TEXT_COUNT] = {
|
||||
|
||||
[UI_MENU_MODS_BUILTIN] = "Built into the port", [UI_MENU_MODS_INSTALLED] = "Installed mods",
|
||||
[UI_MENU_MODS_NONE] = "No mods yet. Unpack a mod into the mods folder, one folder per mod with its romfs folder "
|
||||
"inside, and restart the game. a mod manager can export its merged mods into a folder there too.",
|
||||
"inside, and restart the game. A mod manager can export its merged mods into a folder there too.",
|
||||
[UI_MENU_MODS_OPEN] = "Open mods folder",
|
||||
[UI_MENU_MODS_OPEN_DESC] = "Shows the folder the game loads mods from. It is created if it is missing.",
|
||||
[UI_MENU_MODS_ROW_DESC] = "Game files it replaces: %u. New files it adds: %u.",
|
||||
@@ -710,7 +710,7 @@ static const char *const text_ru[UI_TEXT_COUNT] = {
|
||||
|
||||
[UI_MENU_MODS_BUILTIN] = "Встроенные в порт", [UI_MENU_MODS_INSTALLED] = "Установленные моды",
|
||||
[UI_MENU_MODS_NONE] = "Модов пока нет. Распакуйте мод в папку mods, каждый мод в свою папку с папкой romfs внутри, и "
|
||||
"перезапустите игру. a mod manager тоже может выгрузить туда объединённые моды отдельной папкой.",
|
||||
"перезапустите игру. Менеджер модов тоже может выгрузить туда объединённые моды отдельной папкой.",
|
||||
[UI_MENU_MODS_OPEN] = "Открыть папку модов",
|
||||
[UI_MENU_MODS_OPEN_DESC] = "Показывает папку, из которой игра загружает моды. Если её нет, она будет создана.",
|
||||
[UI_MENU_MODS_ROW_DESC] = "Заменяет файлов игры: %u. Добавляет новых файлов: %u.",
|
||||
@@ -1040,7 +1040,7 @@ static const char *const text_pt_br[UI_TEXT_COUNT] = {
|
||||
[UI_MENU_TAB_MODS] = "Mods",
|
||||
[UI_MENU_MODS_BUILTIN] = "Embutidos no port", [UI_MENU_MODS_INSTALLED] = "Mods instalados",
|
||||
[UI_MENU_MODS_NONE] = "Nenhum mod ainda. Descompacte um mod na pasta mods, uma pasta por mod com a pasta romfs dentro, "
|
||||
"e reinicie o jogo. O a mod manager também pode exportar os mods mesclados para uma pasta ali.",
|
||||
"e reinicie o jogo. Um gerenciador de mods também pode exportar os mods mesclados para uma pasta ali.",
|
||||
[UI_MENU_MODS_OPEN] = "Abrir pasta de mods",
|
||||
[UI_MENU_MODS_OPEN_DESC] = "Mostra a pasta de onde o jogo carrega os mods. Ela é criada se não existir.",
|
||||
[UI_MENU_MODS_ROW_DESC] = "Arquivos do jogo que substitui: %u. Arquivos novos que adiciona: %u.",
|
||||
@@ -1557,7 +1557,7 @@ static const char *const text_zh_hans[UI_TEXT_COUNT] = {
|
||||
[UI_MENU_TAB_MODS] = "模组",
|
||||
[UI_MENU_MODS_BUILTIN] = "移植版内置", [UI_MENU_MODS_INSTALLED] = "已安装的模组",
|
||||
[UI_MENU_MODS_NONE] = "还没有模组。把模组解压到 mods 文件夹,每个模组一个文件夹,里面放 romfs 文件夹,然后重启游戏。"
|
||||
"a mod manager 也可以把合并后的模组导出到那里的一个文件夹。",
|
||||
"模组管理器也可以把合并后的模组导出到那里的一个文件夹。",
|
||||
[UI_MENU_MODS_OPEN] = "打开模组文件夹",
|
||||
[UI_MENU_MODS_OPEN_DESC] = "显示游戏加载模组的文件夹。不存在时会创建它。",
|
||||
[UI_MENU_MODS_ROW_DESC] = "替换的游戏文件:%u。新增的文件:%u。",
|
||||
|
||||
@@ -369,6 +369,9 @@ void vk_pool_fini(pool_t *p) {
|
||||
// name them (the game frees a pool only once the GPU is done with it, but its CPU writes may still be queued).
|
||||
if (r->mbuf) mirror_retiring(r), vk_completion_add(vk_sync_issued() + 1, mirror_retire, r);
|
||||
else if (r->gpa_rec && !r->used) vk_completion_add(vk_sync_issued() + 1, gpa_retire, r); // the queue was not drained
|
||||
// an unused physical pool may still be read through the virtual pages that mapped it (device addresses, which do not
|
||||
// mark it used): its buffer outlives the submission being recorded too
|
||||
else if (r->kind == POOL_PHYS && !r->used) vk_completion_add(vk_sync_issued() + 1, gpa_retire, r);
|
||||
else destroy_rec(c, r);
|
||||
}
|
||||
|
||||
|
||||
@@ -1055,16 +1055,38 @@ static int alias_copy(Tex *e, const Tex *src) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Descriptors whose image creation failed (VRAM exhausted, an unsupported format): not tried again for 2 s, so a
|
||||
// draw that names one every frame does not repeat a failing allocation on every use. Texture lock held.
|
||||
#define FAILED_HOLD 32
|
||||
static struct {
|
||||
TexKey k;
|
||||
uint64_t until_ns;
|
||||
} failed_hold[FAILED_HOLD];
|
||||
static unsigned failed_next;
|
||||
|
||||
static int create_held(const TexKey *k) {
|
||||
uint64_t now = plat_now_ns();
|
||||
for (int i = 0; i < FAILED_HOLD; i++)
|
||||
if (failed_hold[i].until_ns > now && !memcmp(&failed_hold[i].k, k, sizeof *k)) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void create_failed(const TexKey *k) {
|
||||
unsigned i = failed_next++ % FAILED_HOLD;
|
||||
failed_hold[i].k = *k, failed_hold[i].until_ns = plat_now_ns() + 2000000000ull;
|
||||
}
|
||||
|
||||
static Tex *entry_of(const tex_t *t) {
|
||||
TexKey k;
|
||||
make_key(t, &k);
|
||||
Tex *e = nvn_hm_get(&by_key, &k);
|
||||
if (!e) {
|
||||
if (create_held(&k)) return NULL;
|
||||
if (tex_alias < 0) {
|
||||
tex_alias = cfg_bool("NX2NAVI_TEX_ALIAS");
|
||||
rt_log("vk: texture aliases: %s", tex_alias ? "a new image takes the live image's content" : "a new image starts empty");
|
||||
}
|
||||
if (!(e = create_tex(t, &k, tex_alias))) return NULL;
|
||||
if (!(e = create_tex(t, &k, tex_alias))) return create_failed(&k), NULL;
|
||||
perf_count(PERF_CNT_TEX_NEW);
|
||||
// released entries of another descriptor at this address are replaced by the new one; a live one holding
|
||||
// GPU-written content is the alias source, preferring the one that differs only in swizzle (same_but_swizzle)
|
||||
|
||||
Reference in New Issue
Block a user