* translate: Handle NaN semantics of legacy instruction variants
* translate: Use unordered float compares for v_cmp_n* instructions
The ACO compiler in mesa emits those variants for unordered compares so use those to get correct NaN behavior
* spirv_emit_float_point: Proper NaN semantics for three number compare instructions
Manual mentions DX10 NaN handling for all of them and for V_MED3_F32 specifically if any input is NaN it fallbacks to MIN3 instruction so implement those properly using NMin/NMax
* translate: Honor DX10_CLAMP mode bit
Switch FPSaturate to using NClamp instead of FClamp, to match HLSL saturate which returns 0.f with NaN input. Otherwise use normal FClamp which propagates the NaN instead
* emit_spirv_floating_pont: Dont use amd extension
* buffer_cache: allocate sparse backing with device address support [skip ci]
AI-assisted extraction and verification by Codex.
Human code/comment review and human-written PR text required before upstream submission.
Source integration: e6cf874a170c528068627bb43f2c6bc2e89e4375.
Original commits: 1e6bb5a6.
* buffer_cache: remove allocation comment after review [skip ci]
Remove the two-line comment requested in upstream PR #5233. No executable code changes.
Validation: exact diff review only; no rebuild or tests for comment removal.
AI-assisted edit by Codex.
* texture_cache: scan only the first page in FindImageFromRange
FindImageFromRange only accepts images whose guest address equals the
requested address, and every image is registered in all of its pages, so
the candidates are always found in the first page. Walking every page and
image of a large texel buffer range cost ~35-45 us per call and showed up as
the top per-draw cost in inFamous Second Son.
Also skip the lock in RegionManager::ForEachModifiedRange when no bit of
the requested type is set; the caller would be a no-op in that case.
inFamous Second Son (Salmon Bay dock): 23.2 -> 30.7 FPS.
* texture_cache: add ForEachImageWithAddress, drop region_manager change
Look up only the bucket of the first page and only images with the exact
address, as suggested in review. The lockless early out in
ForEachModifiedRange is removed since ChangeRegionState updates the state
bits before the tracker.
* texture_cache: drop redundant address check and comment
Image addresses are 256-byte aligned, so a matching key already implies the
same address.
AI-assisted extraction and verification by Codex.
Human code/comment review and human-written PR text required before upstream submission.
Source integration: e6cf874a170c528068627bb43f2c6bc2e89e4375.
Original commits: 287e0d09.
* Split the HLE camera library into multiple source files for readability
* copyright 2026
* calibration functions
* Pull out camera config type table to a separate header
* Do not assume the base format is always RGBA8888 for RAW8/RAW16 outputs
If a game registers YUV422 for eye 1 and RAW16 for eye 2, that made the HLE library register YUY2 as the SDL format before, but then tried to use it as RGBA88888, which lead to overidexing and reading from unmapped pages
* Cleanup Turtle's cleanup
* copyright 2024-2026
* the loathsome clang-formatter
* sir clang offnir, the all formatting
* texture_cache: Use common small vector
* texture_cache: Remove unused functions
* texture_cache: Remove tail/head track functions
They can be integrated into main Track with much less code
* texture_cache: Remove samplers mutex
Samplers are only accessed by gpu thread so no need for this
* texture_cache: Move locking to per image
The only functions that run from different threads are InvalidateMemory and UnmapMemory, in both the overlapping images are untracked. Untracking must be an atomic operation, i.e a the gpu thread cannot observe the image as untracked (track_addr/track_addr_end == 0) before the image drops its page references from the page manager. So only these two need to be put under a critical section
Also includes a change to make ForEachImageInRange stateless, otherwise a lock would be required for this as well
* texture_cache: Store image address/size inside bucket entry
This avoids looking up the image data itself and taking a cache miss every time you want to test if image overlaps. We only pay the access cost for an image that will actually participate in overlap resolution
* vk_rasterizer: Dont use piecewise_construct for image bindings
Optimize some overhead out
* image_info: Move image info size and mip layour calculation into a standalone constexpr function
We can now use it to build a constexpr table
* image_info: Precompile common BCn configurations for faster size calculation
* image_info: Optimize construction and intrusive LRU cache
* Move functions like SurfaceFormat and NumBitsPerBlock to headers to allow them to inline here
* Load sharp to a local temporary as the start to avoid the compiler constantly reloading the pointer due to aliasing dangers
This could also be resolved with __restrict but this is more idiomatic c++
* Store props with a single byte store instead of doing individial bit insertions
* Remove redudant zero initializations that added extra instructions at the start
Now UpdateSize is also tail-called. Construction dropped by 0.5% cpu time
LRU cache had overhead on every Touch call, so make it intrusive to the objects themselves to avoid extra storage and deque indexing overhead
* clang format
* fix linux build
* fix linux gcc build
* add recursive scanning - force depth 2 for now, make configurable later
* make setting configurable
* match item widths
* correctly load language as specific, fix profile button naming with multiple same titleid entries
* catch fs errors, while ensuring all other items are scanned
* cpu_patches: Apply CPU patches ahead of time on macOS
* module: Use one static patching flag for Windows and macOS
* cpu_patches: Patch SSE4a instructions between the functions of the EH frame table
* emulator: Log the red zone patching setting on macOS
* Revert "emulator: Log the red zone patching setting on macOS"
* module: Share one static patching block between Windows and macOS
- Fix alignment validation in sceKernelReserveVirtualRange to check both power-of-2 and 16KB page alignment per libkernel.sprx (0x1861e)
- Enforce 2GB maximum alignment bound per libkernel.sprx
- Implement sceKernelClearVirtualRangeName (NID mkgXxsoxWHg)
- Match libkernel 16 KB page alignment and madvise/VirtualAlloc(MEM_RESET) page release semantics
- Return ORBIS_KERNEL_ERROR_EINVAL on failure or invalid parameters
- Add posix_mlock/munlock with parameter checks and wrap sceKernelMlock/munlock
- Register POSIX and SCE NID mappings in libkernel and libScePosix
* vk_rasterizer: Only redirect stencil reads for stencil-compatible formats
The stencil-to-depth association is keyed on the stencil plane address
alone, so it also lands on unrelated surfaces that reuse that memory.
Following it for a non-stencil format builds a view of the depth-stencil
image in another compatibility class with a Depth|Stencil aspect, and
storage writes through that view corrupt the depth buffer. Only redirect
when the request can actually be a stencil view.
Together with readbacks set to Precise this fixes the missing world
geometry in Uncharted: Drake's Fortune Remastered (CUSA03280).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* texture_cache: Only link stencil images with a stencil format
Don't associate a color image with the depth buffer in the first place,
as suggested in review, instead of skipping the redirect in BindTextures.
FindDepthTarget now only links the placeholder or an image with a stencil
compatible format at the stencil address, and doesn't create a
placeholder over a color image. The BindTextures check is reverted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* texture_cache: Keep dummy stencil associations at reused addresses
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* shader_recompiler: Zero PackedAncillary left over after lowering
LowerPackedAncillary replaces the raw ancillary VGPR value with zero once
it lowers a bitfield extract from it. Since #5116 moved
LowerHardwareIntrinsics after dead code elimination, a dead extract is
already gone at that point, so the raw value is never zeroed and reaches
the SPIR-V emitter, which cannot emit it. God of War III (CUSA01715)
crashes on fs 0xeb50917148e7d775, where the shader reuses VGPR4 and one
path still carries the ancillary value into a Phi.
Zero any GetAttributeU32 PackedAncillary still left after the lowering
loop. The pass order from #5116 is kept, and shaders that compiled
before are unaffected, since the emitter could not handle the raw value.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* shader_recompiler: Lower PackedAncillary from its load
Start from the GetAttributeU32 that loads PackedAncillary, lower the
bitfield extracts that use it and then always replace the load with
zero, as suggested in review. This no longer depends on an extract
surviving DCE, so the separate loop after lowering is removed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* scePthreadRwlockTimedrdlock / scePthreadRwlockTimedwrlock take a relative timeout in microseconds (SceKernelUseconds), not a pointer to an absolute timespec like the POSIX calls.
* changed naming to proper
* make rwlock happy
* Fix config annoyances
Removed a million "Windows static guest red-zone protection" logs, removed the excessively wordy logging for red-zone being enabled, made the red-zone patches setting a proper setting in our general category (with backwards-compat for the old setting behavior so users don't need to change anything and GUI doesn't need adjusting)
Also fixed implementation for the userfaultfd and inline_fetch_parsing config settings introduced in recent PRs. Due to oversights from those respective devs, neither setting was actually getting read from the config.
* Nuke the red-zone config tests
These were all dependent on the old behavior. There's no point in these now that red zone patches are a proper config setting.