VERY experimental Nintendo Switch 2 emulator
  • C++ 64.9%
  • cpp 25.3%
  • POV-Ray SDL 3.2%
  • Kotlin 2.8%
  • Python 1.5%
  • Other 2.2%
Find a file
Daniel Jesús Martín Flores d17f0eee8b
host1x, nvdrv: make destroying an Nvdec or Vic device safe (#2622)
* nvdrv: complete a channel's syncpoint when the guest closes the channel

Submit raises the channel syncpoint's max by the list's increments and
returns their fence at once. Nothing waits for the lists before a
close: Module::Close calls OnClose, and Host1x::StopDevice destroys the
device and joins its thread. That thread stops between lists, so lists
still queued at the close are dropped with their IncSyncpt.

Whether a game closes a channel with work in flight is up to the game.
Skipping a movie by destroying the decoder can do it, and emulated
decoding is slower than the hardware's, which widens the window.

The host value then stays short of the max:

- A guest thread waiting on one of those fences is never signalled.
- So is another device's list in WaitHost on it, a Vic list waiting on
  Nvdec, for example.
- The syncpoint is reused by the next channel (syncpts_accumulated) with
  the deficit, so that channel's fences resolve submits late.

nvdrv had nothing for this. FreeSyncpoint only clears the reservation,
and nvdec/vic recycle the syncpoint without touching its values. As far
as I read Linux's host1x driver today:

- drivers/gpu/host1x/cdma.c, host1x_cdma_update_sync_queue: its
  recovery path does "CPU increments for the remaining syncpts" of a
  partly executed job.
- drivers/gpu/host1x/syncpt.c, syncpt_release: sets max_val to the
  value read from the hardware.

I did not read the hardware-specific parts.

nvhost_nvdec and nvhost_vic's OnClose now call
SyncpointManager::CompleteSyncpoint after StopDevice, when the device's
thread is joined and nothing else increments the syncpoint.
CompleteSyncpoint increments host1x's guest and then host value up to
the max, as the dropped IncSyncpts would have, running the actions
they meet. It then updates the min.

- It does all guest increments, then all host ones. Nothing compares
  the two banks.
- A value already at or ahead of the max is left alone. So is a
  shortfall over 2^16, which is logged, since such values are not this
  channel's increments.
- Raising the values, rather than lowering the max as Linux's release
  does, also releases the waiters on the dropped fences.

A host action that a destroyed nvhost_ctrl left registered, for a wait
on one of those fences, now runs at the close instead of at a later
increment. #2621 removes such stale actions.

The tests, at the nvdrv syncpoint manager over a standalone Host1x:

- Three increments are submitted and one runs.
- Completing runs the host and guest actions waiting on the fence, but
  not one past it.
- The values equal the max and the syncpoint has expired.
- Completing again changes nothing.
- The next submit's fence is reached by its own increment.
- Values at or ahead of the max, or short by over 2^16, are left as
  they are.

The OnClose calls are checked by reading only. Building nvhost_nvdec
or nvhost_vic needs System::Host1x(), which a test System does not
have.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RcHkcxAKTuSh2fpgFJdwbE
Claude-Session: https://claude.ai/code/session_01RcHkcxSN7aBbebPQ17pqcF

* video_core: stop a CDmaPusher's thread before Nvdec's or Vic's part is gone

CDmaPusher's thread runs the command lists that Nvdec and Vic are given.
For every method write it calls the pure ProcessMethod, and that call
reaches the device's members: Nvdec's decoder, Vic's scratch surfaces
and registers. It checks its stop token only between lists.
~CDmaPusher was defaulted, so the jthread was stopped and joined only
when that member was destroyed. That is after ~Nvdec or ~Vic and after
their members, the decoder included, were already gone.

A list still running at that point uses a destroyed decoder in the
middle of ProcessMethod, and its next method aborts on a pure virtual
call. Nvdec and Vic live in Host1x::devices. They are destroyed when the
guest closes the channel (StopDevice) and at shutdown, when
System::ShutdownMainProcess resets host1x_core after the services and
the GPU. On the shutdown path nothing waits for the device's lists
first. Closing a game during a movie can do this with a frame still
being decoded.

CDmaPusher::StopThread requests the stop and joins; it does nothing once
the thread is joined. The thread's wait takes the stop token, so the
stop cannot be lost. A stop now also ends the list in progress at its
next word. What follows in a list can use the device, run syncpoint
actions whose owners are gone, or read guest memory through a GPU
already reset. ~Nvdec and ~Vic call StopThread first. The base
destructor still calls it, and logs an error naming the contract if it
finds the thread still running there.

The test makes a CDmaPusher with a list of two device method writes in
a mapped page of a test process. It holds the thread in the first
ProcessMethod until the stop has been requested, whoever requests it.
Two checks, neither of which depends on timing:

- The first method must not still be running once the derived
  destructor has ended. Without the derived call, the base's destructor
  is what requests the stop, after the derived part is gone; the check
  then failed in 5 of 5 runs.
- The second method, after the stop point, must not run. Without the
  word-loop check it did, in 5 of 5 runs.

With both, 20 of 20 runs pass. The test's state lives outside the
pusher, so a thread that runs on after the pusher is destroyed still
reads valid memory. If the test itself stalls past its 5 s bound for
the stop, it ends the run with a message saying so, instead of failing
correct code. The fixture is in a named namespace, so
GCC calls ProcessMethod through the vtable as it does for Nvdec and
Vic. The test does not cover Nvdec's and Vic's own calls, which are
checked by reading; if one goes missing, the base's error says so.

Dropping the list in progress also drops its IncSyncpt. When the
guest closes the channel, the commit before this one completes the
channel's syncpoint after StopDevice. So a device waiting on that
fence, or a guest thread, is not left behind, and the syncpoint is
reused without a deficit.

This does not make closing during a movie safe on its own. Between
services.reset() and host1x_core.reset() in ShutdownMainProcess the
devices' lists still run unstopped, and after the stop at most one more
word runs. An IncSyncpt among them runs host actions that nvhost_ctrl
registered for event waits and left behind when it was destroyed. That
is a separate fix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RcHkcxAKTuSh2fpgFJdwbE
Claude-Session: https://claude.ai/code/session_01RcHkcxSN7aBbebPQ17pqcF

* video_core: end a Control syncpoint wait when its CDmaPusher is destroyed

A command list in class Control can wait for a host syncpoint
(WaitSyncpt, WaitSyncpt32). Control::Execute waited in
SyncpointManager::WaitHost, on a condition variable with no stop check
and no time limit. The pusher's thread is joined when the device is
destroyed, so a wait that never ends makes destroying it, and closing
the game, hang.

This can happen at shutdown. The syncpoint is incremented by the GPU's
fences or by another device's list (Vic waiting on Nvdec, for example).
ShutdownMainProcess resets the GPU before Host1x, which drops its
pending fence operations. Host1x::devices is destroyed in reverse fd
order, so a device destroyed first drops its queued lists. The waiting
device's join then never returns. This was the same before the
CDmaPusher stop change, as the jthread's destructor joined too.

SyncpointManager::WaitHost gets an overload that takes a stop token and
returns whether the value was reached. A std::stop_callback, made
before guard is taken, notifies the condition variable under guard. The
wait's predicate also checks the token, so a stop requested between
the waiter's check and its sleep still wakes it. Control::ProcessMethod
and Execute, and CDmaPusher::ExecuteCommand, pass the pusher thread's
token down. Once the wait returns, the stop ends the list at its next
word (see the CDmaPusher stop change this builds on).

Tests:

- A stopped WaitHost returns false. A waiter already asleep is woken by
  the increment that reaches its value and returns true.
- A CDmaPusher runs a list that reaches a Control WaitSyncpt on a
  syncpoint nothing increments, followed by a device method. It is
  destroyed in time, and the device method after the wait does not run.
  With the old wait this test aborts past its 5 s bound (3 of 3 runs);
  with this change, 20 of 20 runs pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RcHkcxAKTuSh2fpgFJdwbE
Claude-Session: https://claude.ai/code/session_01RcHkcxSN7aBbebPQ17pqcF

* tests: give the CDmaPusher tests an application process

A CDmaPusher's thread starts from System::ApplicationMemory(), which
dereferences the application process. The pusher tests had none, so
that was a member call on a null pointer. It was harmless in ordinary
builds, since an empty list never reads the memory. With LICHII_FUZZERS
(-fsanitize=undefined -fno-sanitize-recover=undefined) the tests
target is built with UBSan too, if LICHII_TESTS is on, and there it
aborts the test on the worker thread before its checks run.

Tests::Host1xTestProcess (tests/video_core/host1x_test_process.h) makes
the test's one-page process the application process for its lifetime,
and the two pusher tests now use it for their command lists. The process
is never created as a kernel object, so its reference count stays at 0:
the kernel's open and close of its application process neither keep it
nor destroy it, and no full process initialization is needed. It is
declared before the pusher, so the pusher's thread is joined first.

Reported by CodeRabbit on #2622.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RcHkcxAKTuSh2fpgFJdwbE
Claude-Session: https://claude.ai/code/session_01RcHkcxSN7aBbebPQ17pqcF

* nvdrv: document CompleteSyncpoint's shortfall limit and what a skipped bank leaves

CompleteSyncpoint completes each bank only when it is at most 1 << 16
increments short of the maximum. A bank further behind is logged and
left, so its fences are not signalled by the close. The comment
promised that every submitted increment completes. It now states the
limit and what is left behind:

- event waits stay pending until something else reaches their value or
  the guest gives up;
- a wait nvhost_ctrl escalates after three cleared waits (WaitHost
  with the application stalled) blocks until then, as before
  completion existed.

Comment only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RcHkcxAKTuSh2fpgFJdwbE
Claude-Session: https://claude.ai/code/session_01RcHkcxSN7aBbebPQ17pqcF

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 17:36:14 +00:00
.ci build: rename the yuzu build names, targets and directories to Lichii (#1541) 2026-11-12 23:06:42 +00:00
.circleci ci: disable CircleCI with a no-op config (#1735) 2026-11-14 08:49:43 +00:00
.forgejo/workflows [ci] Only update translations once a week (#4256) 2026-08-08 05:46:52 +02:00
.github ci: scope release retests and recover from API failures (#2583) 2026-11-25 16:20:27 +00:00
.patch cpmfile: patch sirit to include <cstdlib> for std::abort (#2491) 2026-11-24 14:36:20 +00:00
.reuse build: rename the yuzu build names, targets and directories to Lichii (#1541) 2026-11-12 23:06:42 +00:00
.tx [cmake] feat: FFmpeg CI, allow 16kb android builds, update translations for transifex (#2543) 2025-09-23 19:38:11 +02:00
CMakeModules build: MinGW fixes (process memory counters, NX converter, keep symbols) (#1481) 2026-11-15 11:33:33 +00:00
dist lichii: archive build 386 and stage the next What's New notes (#2582) 2026-11-25 15:00:11 +00:00
docs shader_warm: avoid opening every loose RomFS asset (#2605) 2026-11-25 23:46:30 +00:00
externals input: build SDL3 with libusb on Windows for Switch 2 controllers 2026-11-17 00:41:53 +00:00
hooks build: rename the yuzu build names, targets and directories to Lichii (#1541) 2026-11-12 23:06:42 +00:00
LICENSES general: fix trailing whitespace 2024-01-08 09:34:32 -05:00
src host1x, nvdrv: make destroying an Nvdec or Vic device safe (#2622) 2026-11-27 17:36:14 +00:00
tests/gpu_traces nx2: opt-in GPU render thread (Fritchii-style render follower), off by default (#2425) 2026-11-22 08:18:15 +00:00
tools ci: scope release retests and recover from API failures (#2583) 2026-11-25 16:20:27 +00:00
.codespellrc Remove yuzu SPDX copyright lines 2026-11-12 22:38:29 +01:00
.git-blame-ignore-revs Remove yuzu SPDX copyright lines 2026-11-12 22:38:29 +01:00
.gitattributes Remove yuzu SPDX copyright lines 2026-11-12 22:38:29 +01:00
.gitignore vulkan: save the driver pipeline cache at the end of the load on Intel Windows again (#1838) 2026-11-16 19:43:13 +00:00
.shellcheckrc [tools, cmake] refactor: update/hash check scripts, use tags for some more deps, proper CPMUtil separation (#2666) 2025-10-05 03:04:53 +02:00
AGENTS.md shader: lower TLD.SCR.LZ.MS with a uniform-register handle (#2647) (#2653) 2026-11-27 03:32:47 +00:00
CHANGELOG.md tests: fix linking with OpenGL disabled (port of #1223) (#1715) 2026-11-14 05:34:23 +00:00
CMakeLists.txt frame gen: call the built-in frame generation "Lichii Optical Flow", not FSR 3 (#1633) 2026-11-20 19:12:39 +00:00
CONTRIBUTING.md docs: clarify authorized testing and diagnostic sharing (#2096) 2026-11-17 18:35:25 +00:00
cpmfile.json cpmfile: patch sirit to include <cstdlib> for std::abort (#2491) 2026-11-24 14:36:20 +00:00
Doxyfile build: rename the yuzu build names, targets and directories to Lichii (#1541) 2026-11-12 23:06:42 +00:00
eglantine.profdata Added FSR 4 and AMD Boost 2026-10-31 22:20:08 +01:00
LICENSE.txt chore: make yuzu REUSE compliant 2022-07-27 12:53:49 +02:00
lichii-windows.profdata ci: adopt danieljesus Windows PGO refresh from #1884 2026-11-17 18:29:46 +00:00
NX2_GPU_THREAD_SPLIT.md video_core: GPU thread split on by default for Switch 2 titles; cheaper front paths 2026-10-29 20:49:48 -04:00
NX2_NOTES.md build: rename the yuzu build names, targets and directories to Lichii (#1541) 2026-11-12 23:06:42 +00:00
README.md ci: stop shipping Linux ARM64 PGO builds (#2532) 2026-11-24 14:19:41 +00:00
shell.nix nixos update and load mesa driver for all gpus (#1250) 2026-11-14 02:23:55 +00:00
VERSION ci: whole new ci, needs a lot of review, this is draft 2026-11-04 21:19:45 +01:00

⚠️ Lichii has no official website ⚠️

Caution

Lichii has no official website. The only site run by this project is the game compatibility website, lichii.zortos.me, for compatibility reports only. Download Lichii only from this repository's releases page. Any other "Lichii" website or download (such as lichii.org) is not ours and may contain malware (#545).

Lichii

Lichii

Total downloads Latest release downloads Latest release

Lichii is an experimental, open-source Nintendo Switch and Switch 2 emulator written in C++. It builds on Eglantine, Eden, yuzu and Sudachi, preserving their contributions while developing this fork's game compatibility and renderer fixes.

This is an independent fork, not an official release of those upstream projects. Lichii is not affiliated with Nintendo.

Visit the Lichii game compatibility website to find games and compare community compatibility reports.

Downloads and setup

Download Lichii only from this repository's releases page. Lichii has no other download site: archives offered elsewhere, such as lichii.org, are not built by this project, and one has been reported to install malware (#545).

Linux ARM64 now ships only the standard AppImage and tarball. If no update appears on an older ARM64 PGO build, download the standard ARM64 package from the releases page.

On Windows, extract the entire build archive and run lichii.exe. Use homebrew you have permission to run, or your own games and system files dumped from a console you own, where permitted by applicable law. Games, keys and firmware are not included. The project does not provide download sources for them. Owning a console or game does not by itself establish permission to bypass access controls or redistribute its files.

Existing saves and settings

Lichii uses its own profile: %APPDATA%\lichii on Windows, and the lichii directories under $XDG_DATA_HOME, $XDG_CONFIG_HOME and $XDG_CACHE_HOME on Linux and macOS. Without XDG overrides, these are ~/.local/share/lichii, ~/.config/lichii and ~/.cache/lichii. An existing portable user/ directory still takes priority and is not imported or changed by the wizard.

On the first non-portable GUI launch, Lichii offers to import Eden and other detected emulator profiles. Back up %APPDATA%\eden first on Windows, or the old data, config and cache directories on Unix, and close the source emulator. Choose Keep Old Data to copy without changing the source, then check your saves and relaunch. Existing destination data is retained in backup directories rather than merged. Move also retains a source backup until you remove it yourself; Link deliberately shares settings and saves. Paths outside the imported data root remain shared and unchanged. An interrupted import offers recovery on the next launch. eden-cli, including --help and --version, refuses to initialize configuration until you import or explicitly choose Start fresh in the GUI.

Compatibility and issue reports

Compatibility and performance vary by game, hardware and driver. Rendering errors, stutters and crashes remain possible. Passing automated tests does not establish that a game renders correctly, and this project makes no universal frame-rate guarantee.

Browse community compatibility reports for results with each player's build and setup.

Desktop reporting requires a build containing PR #303 and is not available in build 88. In builds that include it, play and stop a Switch 2 game, then right-click that game and choose Submit compatibility report. Only the latest session in the current Lichii process is eligible.

Confirm the matching website catalog entry and review the editable machine, game, setup, and enabled add-on details prefilled where available. Check the public preview and give explicit consent before submitting. Nothing uploads automatically, and the native v1 reporter does not read or upload logs or files.

When reporting an issue, include:

  • The exact build, game version, CPU, GPU and driver version.
  • Relevant settings and steps to reproduce the problem.
  • A screenshot and the log from the affected session, after checking it for personal information.

Do not upload game files, keys, firmware or private account information. Bug bundles, GPU traces, shader dumps, pipeline caches and crash dumps can also contain game data. Do not attach them to public reports; ask a maintainer for handling instructions before sharing them. Plain-text logs should be checked for sensitive information before posting.

Building and contributing

See the build guide, user documentation and coding guidelines. Some inherited documentation and internal build target names still use upstream names. The GUI build target is lichii; its output is lichii.exe on Windows and lichii on other desktop platforms.

Keep changes focused and distinguish code-level checks from actual gameplay testing.

Artwork

Art created by YOB (yobslab) The supplied Lichii logo, icon and library artwork are in dist/branding. Windows, Linux and macOS icon resources are generated from that artwork by Generate-LichiiIcons.ps1.

Support Lichii

Lichii is free and stays free. If you want to help, you can donate in crypto. Donations help pay for the AI tools and build machines used to develop this open-source project faster.

Solana (SOL)

JepEjfyWjGjhJvHSrqj52KtLjcbbbmUh1iGqerYBF4w

Ethereum (ETH)

0x055ABa1b80Bc35C836Ce7E9F47c2b3d6C75b5534

Bitcoin (BTC)

bc1qcvxdpf4qvdhqp8ee4s355cjmxrzsphsdwpl8w4

BNB Smart Chain (BNB)

0x055ABa1b80Bc35C836Ce7E9F47c2b3d6C75b5534

Polygon

0x055ABa1b80Bc35C836Ce7E9F47c2b3d6C75b5534

Send each coin on its matching network. Coins sent on the wrong network can't be recovered.

Note

Donations are voluntary gifts and are non-refundable. A donation does not buy any product, service, perk, early access, exclusive build, priority support or say in the project. Every release stays free and public for everyone.

Credits and license

Lichii inherits the work of the Eglantine, Eden, yuzu and Sudachi projects and their contributors, including Eglantine's original developer Camille LaVey. Upstream attribution and third-party license obligations continue to apply.

See LICENSE.txt and the source files for applicable license terms.