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.
The source layer slot is a cache invalidate register, not a layer. Set it to zero to stop the false warning. Also remove StampQueryResult, which is never called.
Notification dialogs requested from worker threads (the firmware install
thread) created an NSWindow off the main thread and aborted. They now run
on the main run loop.
The OK and No buttons had two click handlers attached, so the second one
ran after the first had torn the window down and threw bad_weak_ptr.
Raise the soft open file limit at startup: apps launched from Finder get
256, which a firmware install exceeds, leaving the firmware half copied.
* Fix MoltenVK rendering compatibility
Gate unsupported dynamic state and compute subgroup requests, cap push descriptors, use canonical uniform views, match integer fragment outputs, and honor tiled-cache barriers. Disable blending on integer targets in static and dynamic state, including pipeline transitions.
Redirect unused duplicate attachments to cached transient scratch targets with lazy-memory preference and a normal-memory fallback. Isolate masked color and stencil clears by target and layer, preserve component masks, and match integer output types and MSAA samples. Cache duplicate groups and diagnostics, and avoid empty helper render passes. Preserve genuine duplicate writers and warn rather than discard output.
Respect advertised compute subgroup stages on all drivers and scalarize wide global buffer accesses when descriptor aliases are unavailable. Destroy framebuffer owners in dependency order during move assignment.
Adapt Eden 9237eebc4f, a42ae226c8, 873acb9a42, 3795e4e4fc, 884d2ac228, 643f11d972 and 39841b35da. Preserve the Ryubing duplicate-attachment MIT notice.
* Apply integer render target fixes on all drivers
Typed fragment outputs and disabled blending on integer targets are Vulkan rules, not MoltenVK ones. Refresh the dynamic blend enable when a render target format changes. Skip the alpha test when the first color output is an integer.
* Enable portability subset and fix MoltenVK vertex and SSBO bindings
Enable VK_KHR_portability_subset when the device exposes it, as the Vulkan specification requires, and query its features.
Keep static vertex attribute formats within their binding stride on MoltenVK and on hosts without vertexAttributeAccessBeyondStride. Trailing components are dropped only when the vertex shader never reads them; otherwise the original format is kept. Strides of enabled streams join the pipeline key only in this mode, and cached pipelines built without it are skipped on load.
Make storage buffer bindings visible to every graphics stage using descriptors on MoltenVK, which can otherwise lose their resource usage across stages (KhronosGroup/MoltenVK#1870). The layout is widened only while the per-stage storage buffer and resource limits still hold.
Adapt the Ryubing vertex attribute format reduction and storage buffer stage workaround for MoltenVK.
* Emit signed texel offsets for texture gather
The IR carries gather offsets as unsigned vectors and they were passed to
OpImageGather unchanged. SPIRV-Cross then emits a uint2 offset, for which
Metal has no gather overload, so the shader fails to compile under MoltenVK
and pipeline creation throws VK_ERROR_INITIALIZATION_FAILED.
Emit the offsets as signed integers, including the ConstOffsets array.