Commit Graph
4503 Commits
Author SHA1 Message Date
TheTurtle c495290879 shader_recompiler: Improve NaN handling (#5257)
* 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
2026-10-04 13:37:56 -07:00
Paris Oplopoios 16e79a4296 cpu_patches: Enable static patching on Linux (#5253) 2026-10-04 12:41:49 -07:00
Ultra 9f796b30ba fix reuse (#5256) 2026-10-04 17:41:11 +02:00
TheTurtle 098292a23c buffer_cache: Remove duplicate SynchronizeMemoryFromImage (#5255) 2026-10-04 18:10:19 +03:00
Marcin Mikołajczyk b3452cf6a9 Add AGENTS.md (#5242) 2026-10-04 12:15:51 +02:00
Chris Chreece 1ac65aa7a2 buffer_cache: allocate sparse backing with device address support (#5233)
* 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.
2026-10-04 13:00:55 +03:00
Stephen Millerandmetr1k-91 f73709cada Shutdown NpHandler before restarting (#5244)
Co-authored-by: metr1k-91 <257131562+metr1k-91@users.noreply.github.com>
2026-10-03 22:23:49 -05:00
Lucas Daniel Duarte Cabral 145932bf59 texture_cache: scan only the first page in FindImageFromRange (#5240)
* 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.
2026-10-04 02:21:45 +03:00
Chris Chreece 43e4c4703e renderer_vulkan: cover presentation waits and fragment texture reads [skip ci] (#5231)
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.
2026-10-03 23:13:01 +03:00
Stephen Miller f572b33883 Common: Fix incorrect log class names (#5237)
Missed these when fixing the other cases
2026-10-03 09:52:29 -07:00
kalaposfos13 9a8ae4417b Camera code cleanup and fixes (#5211)
* 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
2026-10-03 16:31:45 +03:00
TheTurtle 8e23388af8 video_core: Renderer optimizations pt2 (texture cache edition) (#5219)
* 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
2026-10-03 09:08:26 +03:00
rainmakerv2 8cd2ea8c41 Big picture: recursive folder scanning (#5223)
* 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
2026-10-03 08:51:03 +03:00
junminlee2004 ead912cf95 cpu_patches: Apply comprehensive SSE4a CPU patches on macOS (#5216)
* 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
2026-10-02 13:49:03 -07:00
Marcin Mitura 62653e388c kernel/time: Implement monotonic real-time network clock (#5217) 2026-10-02 13:19:15 -07:00
georgemoralis bf794b3fe7 started 0.19.1 WIP 2026-10-02 17:05:15 +03:00
georgemoralis c7e065d1b4 tagged 0.19.0 release v.0.19.0 2026-10-02 16:24:13 +03:00
squidbus 3912336fdf externals: Update mesa-kosmickrisp (#5214) 2026-10-01 19:42:03 -07:00
Marcin Mitura 4355d9eb73 kernel: Fix sceKernelReserveVirtualRange alignment and add ClearName (#5208)
- 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)
2026-10-01 17:15:43 -07:00
TheTurtle 0f6d1b870e common: Rework slot vector (#5212) 2026-10-01 16:39:47 -07:00
Kravickas ef08b1e1fd V_ALIGNBIT_B32 / V_ALIGNBYTE_B32 fixup (#5186) 2026-10-02 01:40:59 +03:00
Marcin Mitura d8548fc36b kernel: Implement sceKernelReleaseFlexibleMemory and POSIX mlock/munlock aliases (#5182)
- 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
2026-10-01 15:39:48 -07:00
nikmparis217-ux 7e77898756 video_core: Fix mip layout and detiling of tiled textures (#5196) 2026-10-02 01:16:18 +03:00
artemkaVGandClaude Opus 5.5 fecfbed092 texture_cache: Avoid associating color images with stencil (#5118)
* 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>
2026-10-01 17:08:11 +03:00
Kravickas dd43d1cac9 V_CVT_PK_U8_F32 fixup (#5194) 2026-10-01 14:45:59 +03:00
squidbus 5ae2caf310 shader_recompiler: Fix OpImageTexelPointer coords for 1D (#5203) 2026-10-01 14:38:35 +03:00
Stephen Miller d9cf41ba0a Allow InverseBallot folding to fail on unhandled immediate arguments (#5202)
InverseBallotEliminationPass is mainly an optimization. Makes no sense to crash the emulator when this wouldn't actually cause issues.
2026-09-30 21:12:52 -05:00
squidbus 12927c1b9a shader_recompiler: Remove unused IAddCarry32 (#5201) 2026-09-30 18:52:36 -07:00
TheTurtle 259e815af1 resource_patching: Patch thread id add instead of id itself (#5199)
* resource_patching: Patch thread id add instead of id itself

* constant_propagation: Fold ISub32 with zero right arg
2026-10-01 03:02:41 +03:00
TheTurtle d1cb90dbbe translate: Restore simplier ADDC implementation (#5200) 2026-10-01 03:02:36 +03:00
Marcin Mitura 2338a06f92 video_core: Fix sparse backing offsets, barriers, and memory budgeting (#5193)
- Fix sparse backing offset calculation in BufferCache (block shift)
- Enforce image memory barriers when previous state contains write flags
- Adjust dynamic GC pressure and staging buffer trim thresholds
- Track GDS buffer write access in Rasterizer buffer binding
- Ensure a minimum physical memory floor on integrated GPUs
2026-09-30 16:19:33 +03:00
artemkaVGandClaude Opus 5.5 3f21ee0bec shader_recompiler: Lower PackedAncillary from attribute loads (#5141)
* 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>
2026-09-30 13:07:00 +03:00
Kravickas 94e2177815 V_BFM_B32 fixup (#5185) 2026-09-29 16:36:55 -07:00
squidbus 81489374e5 memory_patcher: Support patching other executables (#5184) 2026-09-29 16:00:17 -07:00
squidbus e754ce62eb spirv: Fix gradient and offset for 1D images (#5171) 2026-09-29 13:57:11 -07:00
nikmparis217-uxandnikmparis217-ux 8c91be2b45 shader_recompiler: Read user data from the flat buffer (#5181)
Co-authored-by: nikmparis217-ux <295578344+nikmparis217-ux@users.noreply.github.com>
2026-09-29 23:36:59 +03:00
nikmparis217-uxandnikmparis217-ux 1a0f5be8df vk_rasterizer: Bind a default sampler for S# with undefined fields (#5137)
Co-authored-by: nikmparis217-ux <295578344+nikmparis217-ux@users.noreply.github.com>
2026-09-29 23:36:44 +03:00
Marcin Mitura eb2fb486ef kernel: Implement sceKernelGetProcessType (#5178)
- Handle calling process PID aliases (GLOBAL_PID, -1, 0)
- Return PTYPE_BIG_APP for emulated process
- Return ORBIS_KERNEL_ERROR_ESRCH for non-existent processes instead of ENOSYS
- Add OrbisKernelProcessType enum definition (PTYPE_BIG_APP, PTYPE_MINI_APP, PTYPE_SYSTEM, PTYPE_NONGAME_MINI_APP)
2026-09-29 13:04:19 -07:00
Marcin Mitura c810d6e14f core: Fix system_reserved_addr initialization typo (#5177) 2026-09-29 12:42:50 -07:00
georgemoralis cecd03b74a scePthreadRwlockTimedrdlock / scePthreadRwlockTimedwrlock fix (#5175)
* 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
2026-09-29 08:01:53 -05:00
Stephen Miller 736b5ba8c2 Core: Fix recently added settings (#5172)
* 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.
2026-09-29 08:40:58 +03:00
squidbus e35735c2ed Revert "Do not turn off auto patching when IPC is enabled (#5164)" (#5170)
This reverts commit 197655f80e.
2026-09-28 16:40:30 -07:00
nikmparis217-uxandnikmparis217-ux c01ae7e6e8 page_manager: Keep the fault probe within the faulting page (#5150)
Co-authored-by: nikmparis217-ux <295578344+nikmparis217-ux@users.noreply.github.com>
2026-09-29 01:30:21 +03:00
Stephen Miller 359234bbb5 Perform bounds checking in is_allocated (#5158)
Garbage indexes could get marked as allocated, provided the oob index happens to point to a bit that's set to 1.
2026-09-29 01:29:06 +03:00
nikmparis217-uxandnikmparis217-ux 4c7b287f18 shader_recompiler: Eliminate readlanes before the tessellation and ring passes (#5169)
Co-authored-by: nikmparis217-ux <295578344+nikmparis217-ux@users.noreply.github.com>
2026-09-29 01:26:47 +03:00
nikmparis217-uxandnikmparis217-ux fb6367d290 shader_recompiler: Put 32-bit literals in the high dword of 64-bit floats (#5114)
Co-authored-by: nikmparis217-ux <295578344+nikmparis217-ux@users.noreply.github.com>
2026-09-28 14:46:53 -07:00
TheTurtle fca10b266d video_core: Remove batching (#5165) 2026-09-28 23:41:34 +03:00
kalaposfos13 197655f80e Do not turn off auto patching when IPC is enabled (#5164)
* Do not turn off auto patching when IPC is enabled

* Advertise the new patching behaviour to launchers via IPC
2026-09-28 10:47:43 -07:00
Vladislav Mikhalin 4d3853fe48 revert vdec2 to its original form (#5160) 2026-09-28 16:15:55 +03:00
squidbus 9fdaeb03ce vk_instance: Disable list restart on KosmicKrisp (#5161) 2026-09-28 01:07:35 -07:00