Load ZBIC-compressed NSO modules with checked sizes and reads. Keep LZ4 support and ordinary ZSTD separate. Allow the embedded codec to build with AddressSanitizer.
Adapted from Eden PR #4482 by PavelBARABANOV and Eden contributors:
https://git.eden-emu.dev/eden-emu/eden/pulls/4482
The pinned ZBIC dependency comes from kinnay/zbic and retains its original notices.
Return checked application metadata and icons, handle early controller disconnects, and register limited StreamPlay interfaces for firmware 23 or newer.
NS and StreamPlay compatibility support adapted from Eden. Preserve its copyright and license notices.
Only viewport 0 and scissor 0 were set in this case. The pipeline uses every supported viewport, so the others kept old values. Fill them all with the surface clip.
The HLE macro hint is part of the pipeline key, but it only changes the
shader code when a constant buffer value is replaced. When no value is
replaced, the pipeline is the same as the one without the hint, so it was
built twice.
Now the two keys share one pipeline in that case. Pipelines with a
replaced value are still built on their own.
Games leave unused sampler slots with an invalid handle such as 0xFFFFFFFF.
The texture cache already binds a null image view for them, but the shader
environment read the texture type and format from memory past the texture
table, so the result depended on unrelated data and was stored in the
pipeline cache.
* Fix macOS hang when closing the emulator after running a game
On exit, the static g_time_zone_binary_romfs in nxemu-os still held a
loader-owned interface. Its destructor ran from exit() after the loader
module was destroyed, faulting on a dangling pointer. ResetTimeZoneBinary()
(called from ~TimeManager) now releases it while the loader is alive.
The fault turned into a permanent hang because dynarmic's macOS
MachHandler left its task-wide EXC_BAD_ACCESS port installed and its
detached pump thread running after the CPU module was unloaded. Any later
fault was sent to a port nobody served. The handler now saves and restores
the previous exception ports, destroys its receive right and joins the
pump thread on destruction.
* Restore signal handlers when the CPU module is unloaded on Linux/Android
The dynarmic POSIX handler (x86_64) and the NCE handlers (arm64) installed
SIGSEGV and related handlers from the CPU module and never removed them.
After the module is unloaded, a later fault would jump into unmapped code.
Save the previous handlers and restore them on teardown.
Publish completion separately from success, wake waiters after build failures and skip direct and indirect draws using an invalid pipeline. Restore rescaling constants when switching pipelines. Adapt Eden c51365dd91.
Select global-memory buffers by their constant-buffer index and descriptor offset, rather than their position in the descriptor list. Preserve balanced GLASM conditionals and correct 64-bit storage exchange types. Keep existing address-load and range-check code. Adapt Eden fe2591888d.
Use an inverse local conditional branch followed by an unconditional branch for unbound or distant targets. Keep the original one-instruction form for bound near targets and preserve registers and NZCV. Adapt Eden 57c538a73d.
Own deferred framebuffer and fence data, consume composition on the GPU worker, and cancel pending work safely during layer removal and shutdown. Wait outside the VI lock only when a framebuffer transition or deferred presentation is needed. Preserve acquired static layers and handle single-slot producer pressure without reusing released buffers. Retire completed requests promptly and avoid locking for empty waits.
Mark viewports dirty when the surface clip changes, and refresh scissors whenever viewports are updated. Both depend on the surface clip and the window origin.
The page_size check was too restrictive: an explicit big-page request on
an nvmap handle that is not big-page aligned failed instead of falling
back to small pages, which made system applets abort with fatal error
0x272.
The normal viewport path already flips Y when the window origin is lower left. The disabled-transform path did not, so the image was upside down in that case.
Always update both the front and back cached values. With one-sided stencil, the back cache now gets the front value, because both faces are set on the GPU.
The line check was inverted, so the line state was set on every pipeline except lines. Detect lines from the output of the last stage before rasterization, and only use line modes the device supports. Line smoothing is ignored on multisampled targets, as in OpenGL.
Only enable alpha to one when the device supports it. Only enable alpha to coverage and alpha to one when the fragment shader writes color 0, and never together with smooth lines, which Vulkan does not allow.
Also use a line strip output in the generated layer passthrough geometry shader for line lists. It used a triangle strip and read a vertex that does not exist.