Commit Graph
43 Commits
Author SHA1 Message Date
georgemoralisandMetr1k 2a2f1003b0 Major net rewrite (#5236)
* p2p crypto schema

* adding p2p keyring

* p2p framing and testing

* fixups

* test fix

* missing definations

* implementation of host functions

* tcp/transport of p2p packets

* improvements in binding

* guest_net ,improvements and  test cases

* all mighty clang

* fixing macOS tests failures

* misc

* net_rewrite : net_errors , types and translation schemas

* updated fixed chunks transfer on windows

* bye bye old net

* small updates for the new net

* settings and tests

* net lib first draft

* allow more than 1 P2P instances on from same pc

* improved shadnet replies

* possible fix for jojo

* cleanup

* move net files to libaries/net

* fixed macOS tests

* mighty clang

* fixed cmakelists

* don't cosume inviation event on client (test code)

* fix macOS tests

* Large multi-file rework for Signaling and Matching2 network handling / optimization.  Consolidates Matching2-signaling and signaling to one process (signaling_handler)

General cleanup and consolidation of matching2 context management > nphandler

Removal of a lot

SIgnaling overall structure cleanup.

Matching2: added get and set roommemberdatainternal and the proper type / shadnet call / request / reply.

Consolidated signaling/matching2 typedefs to np_types2

Utilized Codex as a reviewer and for general cleanup.

* all mighty clang

* fixed member attributes

* fixed MAPPED address for matching signaling

* Fixed sceNpMatching2SignalingGetLocalNetInfo

* fixups on net core/library based on fw

* improved errno

* spilt p2p to net_p2p

* some cleanups

* fix for localinfo

* clang

* fix up

* cleanups

* cleanups

* added KernelFstat

* fixed fstat

* one more fix for fstat...

* cleanup old deprecated code

* cleanup

* General logging cleanup across NP changes.  Thanks Stephen!

* cleanup based on stephen's suggestions

* fixup

* fixing tests

* blah

* fixup

* improve memory pools

* cleaunp

* force https disable option

* clang

* @stephen's fixes

* added network field in settings and ported old network ones

---------

Co-authored-by: Metr1k <blackkn1ght1991@gmail.com>
2026-10-06 19:14:56 +03: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
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
xop 282e5c792b shader_recompiler: Set SCC carry-out on S_ADDC_U32 (#5030) 2026-09-27 14:46:31 -07:00
kalaposfos13 cc3d367ec7 Rewrite LIB_FUNCTION and LIB_OBJ macros to call a common function to optimize binary size (#5144)
* Rewrite LIB_FUNCTION and LIB_OBJ macros to call a common function to optimize binary size

* fix tests
2026-09-27 23:44:06 +03:00
xop e518a65157 shader_recompiler: Fix S_SUBB_U32 SCC wrap (#5031) 2026-09-27 08:05:52 -07:00
Connor Garey db73ae0b0e Remove unused code from emulator-settings set of files. (#4963)
* Remove unused code.

* Remove related tests.
2026-09-26 12:17:15 +03:00
Leo Camus 4e44354708 ngs2: propagate SystemSetup validation errors (#5016)
SystemSetup stored the result of SystemSetupCore in a u32, so the
`result < 0` guards could never be taken and an invalid system option
was reported back to the guest as ORBIS_OK.
2026-09-26 11:55:25 +03:00
kalaposfos13 722e6d61be Config and input fixes (#5035)
* Fix config corruption on close and replace error with unreachable for failing to load configs

* Clean up config init code a bit

* Fix some hotkeys accidentally triggering twice

* Add unreachable for user_settings as well

* sir clang offnir, the all-formatting

* oops lmao

* oh come on why does clang-format have to find some new random edge case every few months

* update tests that failed

* fuck if i know what this was supposed to be

* :we:
2026-09-26 11:11:50 +03:00
TheTurtle 2b5666b310 common: Optimize logger by replacing hash map with table lookup and hide implementation details in cpp file (#5106)
* common: Optimize logger by replacing hash map with table lookup and hide implementation details in cpp file

Also bring back assertion noinline functions, this makes call sites of ASSERT/UNREACHABLE much cleaner

* clang format

* review comments

* fix tests

* fix build pt1

* fix build pt2

* fix build pt3
2026-09-25 20:01:03 +03:00
Valdis Bogdāns 2335629296 shader_recompiler: Support P10/P20 V_INTERP_MOV_F32 selectors (#5087)
* shader_recompiler: Support P10/P20 V_INTERP_MOV_F32 selectors

* shader_recompiler: Correct V_INTERP_MOV P10/P20 handling

Reconstruct P10 and P20 unless both flat_shade and OFFSET5 enable passthrough mode.

Suggested-by: raphaelthegreat

* shader_recompiler: Add PsInput passthrough helper

Move the flat_shade and OFFSET5 check into PsInput::IsPassthrough().

Suggested-by: raphaelthegreat
2026-09-25 19:23:22 +03:00
313fb953da shader_recompiler: Write VCC on V_SUBB_U32 / V_SUBBREV_U32 (#5032)
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: TheTurtle <47210458+raphaelthegreat@users.noreply.github.com>
2026-09-24 16:22:27 +03:00
ba15ec90cb shader_recompiler: Set SCC overflow on S_ADDK_I32 (#5033)
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: TheTurtle <47210458+raphaelthegreat@users.noreply.github.com>
2026-09-24 16:17:49 +03:00
xopandCursor 98bc32052c shader_recompiler: Test S_BITCMP_B64 against the full 64-bit src (#5034)
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-24 16:13:39 +03:00
Valdis BogdānsandTheTurtle a48d16dcc2 shader_recompiler: Add pull-model barycentric support (#5084)
* shader_recompiler: Add pull-model barycentric support

* shader_recompiler: fix pull-model barycentric component indexing

---------

Co-authored-by: TheTurtle <47210458+raphaelthegreat@users.noreply.github.com>
2026-09-24 14:23:02 +03:00
826842e8b6 video_core: respect SPI_BARYC_CNTL front-face encoding (#4862)
* video_core: respect SPI_BARYC_CNTL front-face encoding

- Read FRONT_FACE_ALL_BITS from SPI_BARYC_CNTL
- Emit +1.0/-1.0 when sign encoding is selected
- Emit integer 1/0 when all-bits encoding is selected
- Carry the register state through FragmentRuntimeInfo
- Add a boolean IR attribute path for FrontFacing
- Include the mode in shader specialization and cache metadata
- Add regression tests covering both AMD-defined encodings

Fixes according Roamic, Raphael, and IndecisiveTurtle recommendations.

* shader_recompiler: Remove unused IsFrontFace attribute and enhance front face handling in translation, rebase

* shader_recompiler: Fix front-face test compilation

- Use the current hw.fs runtime-info layout for front-face encoding.
- Update the regression helper to the HwStage and SwStage APIs.
- Address test compilation feedback from @raphaelthegreat

---------

Co-authored-by: w1naenator <valdis.bogdans@hotmail.com>
Co-authored-by: TheTurtle <47210458+raphaelthegreat@users.noreply.github.com>
2026-09-24 00:46:07 +03:00
TheTurtle 9cab1ecba4 shader_recompiler: Refactor runtime info as two tagged unions (#5027)
GCN has the concept of hardware and software stages. Software stages are the shader stages exposed in graphics APIs like opengl/vulkan, and each software stage runs on a hardware stage.
Depending on how many and what software stages are used in a graphics pipeline, the hardware stage a software one is executed on can change, so the mapping is not fixed.
The following table from ACO describes the various combinations for HW-SW stages: https://gitlab.freedesktop.org/mesa/mesa/-/blob/c90ae5f7/src/amd/compiler/README.md#gfx6-8

Certain software stages like the vertex and tess eval shader can run a lot of different hardware stages, which creates problems because runtime info is a tagged union on HW stage.
Current main uses struct inheritance to make it work, but that will get clunky when more data is added to other stages. In general there is a lack of separation between what data
is required when a HW stage is used and what for SW stage.

An example is the tess_emulated_primitive variable. This is used for skipping exports in a software vertex shader when tessellation stages have been inserted after it
for Quad/RectList emulation, because it is undefined behavior to not export them from the last geometry stage. Having this data field in the HW vertex info is not semantically
correct because HW vertex is always the last geometry stage that runs. So this only works when there isnt any HW geometry shader active, as the HW vertex shader is not normally processed in that case.

Another example is shader specialization previously checked the HW vertex stage to specialize the fetch shader. This only works on simple VS+PS pipelines when HW VS runs the SW VS.
Fetch shader is part of the SW VS state, its run on first geometry stage not the last, and this issue got exposed because of the new state separation.

This commit refactors runtime info to contain two tagged unions, one from SW stage and the other HW stage. This makes it obvious what is the scope of each state.
When recompiler does a switch on sw stage, it becomes more apparent it should only access sw state members unless it also checks which hw stage it runs on, which will result in less bugs
2026-09-14 01:30:16 +03:00
Lander Gallastegiandraphaelthegreat 1cf28cbc96 shader_recompiler: split resource tracking and flatten load from buffer for sharp source (#4782)
* shader_recompiler: Split resource tracking into 2 parts and flatten load from buffer if used as sharp source

clang-format

fix inmediate sample raw

defer sharp not found asserts

flip asserts

disable aniso pattern

fix disable aniso

some fixes

non immediate

fix PushPtr

fix PushPtr for non immediate

don't assert on offset computation failures

robust bfs

some xbyak fixes

add bitwise ops

umin umax and bit extract

correct rshift lshift 0st immediate

fix and in memory

some minor code fixes

consider ReadConstBuffer as valid finding

fix xbyak

fix magic_enum for opcodes

fix building (yes, i didn't test)

don't corrupt stack when bailing out

ReadConstBuffer compute offset

use canonical inst for readconst non-imm offset

mark all readconstbuffer sharp dwords

consider r128 images

FindSharpLocation

handle non-imm offset readconstbuffer

don't handle immediates when constant folding

proper check for ReadConst to get flatbuf offset

clang-format

fix stupidity

invert condition

separate search dominant function

handle phis loke other insts in gvn

use same logic for phis in gvn than for flatten pass

apparently idk how logic works

revert back to old logic

min/max immediate in constant folding

add offset insts to gvn inst to hash args

assert that ReadConstsBuffer insts have usage as buffer sharp

separate dominance search from bfs

chang gvn phi handling

remove unused includes

fix reuse

readconst transform add address

* shader_recompiler: Move readconst address add simplification to flatten pass

* shader_recompiler: Remove unnecessary phi handling

Now sharp tracking should be much simpler since its on the unstructured control flow graph

* shader_recompiler: Only enable DMA if some ReadConst could not be flattened

* shader_recompiler: Improve phi eliminaton of readlane elimination with worklist

* shader_recompiler: Cascade flattening failure in ReadConst tree, bind null sharp when source could not be flattened

* shader_recompiler: Further improve robustness of tracking

- Track all dwords of T# with SSA
- Ensure sharp dwords are sequential in flatbuf memory
- Substitue null descriptors on tracking failures

* shader_recompiler: Add new sharp fetching object

* shader_recompiler: Add new sampler pattern

* shader_recompiler: Add texture cube to 2d array pattern

* control_flow_graph: Remove unreachable blocks

Fix bloodborne

* shader_recompiler: Add yet another sampler pattern

* shader_recompiler: Add sampler aniso pattern

* flatten_extended_userdata: Only search through allowed instructions

* some fixes

* :kek:

* tests: Fix tests compile

---------

Co-authored-by: raphaelthegreat <geoster3d@gmail.com>
2026-09-04 20:10:46 -05:00
georgemoralisandGabriele C db126323b9 Http module fixups and implementations (#4933)
* Some games open port with handle 255 , that is not an accepted port so don't complain about it

* Net: Send the User-Agent configured on the HTTP template

* simplified comment

* default http user-agent

* added dummy nputility module

* match User Agent 100% with decompile

* return result to np_auth and some more debug code

* implemented sceNpLookup*  (similar of how np_score ,np_tus) functions

* improved accept encoding for gzip

* removedd invalid test after last change , GZIP encoding is not default true

* Implemented Cached  Redirected Connection

* Inflate only when the response is actually GZIP-encoded and the flag is enabled

* simplify GetLibhttpSystemVersionString

* fixed tests

* old file removed

---------

Co-authored-by: Gabriele C <sgdc3.mail@gmail.com>
2026-09-03 00:18:12 +03:00
TheTurtle 2651debdd0 shader_recompiler: Structurize later in the pipeline and cleanup (#4906)
The code regarding structurization has not changed much since the very first commit of the recompiler.
The algorithm has proven very reliable in practice however it doesnt produce optimal code.
More specifically the algorithm does not know to emit if-else statements, it can only emit ifs
The following code

```
a = 0
if (cond) goto L1
a = 1
goto L2
L1:
use(a)
L2
```

will emit the following

```
if (cond) %0 = 1
else %1 = 0

%3 = phi(%0, %1)

if (!cond) use(%3)

```

if the structurizer knew about else statement it could have emited much more optimal code

```
%0 = 0
if (cond)
%1 = 1
else
use(%0)
```

In general while suboptimal, this is harmless. It does matter though for one specific case; K$ pointer chasing
if "a" were a resource descriptor load, then the program ends up with a phi node with 2 possible sources which results in ambiguity.

The obvious solution is to improve the structurizer codegen to reduce these semantically redundant phis.
Relying on structurizer quality for correctness is generally fragile however.

On main this issue is solved by performing dominance and reachability analysis on the original unstructured CFG.
The phi tree is scanned and all possible sources are collected. Then sources are examined in pairs (a, b), if b dominates a, then a can be removed

The goal of this PR is to solve the same issues but in a more fundemental way; most IR passes do not care about structurization
and some like readlane elimination that duplicate phis also benefit from unstructured graphs. So defer structurization until the end of compilation

The new pipeline builds an unstructured graph of IR blocks and runs SSA rewrite on those. The SSA pass has been reworked again to remove
recursion and not rely on def lookups during phi trivialization. This allows removing Opcode::Identity, its removal pass and all special checks for it
in various places inside the recompiler.

When optimization passes are done, phis are lowered back to hardware registers. This is possible with the new RegTag structure that intrusively
stores register information for every phi. This used to be stored with a hash map inside ssa pass, but having this information later in the pipeline is of benefit

After structurization the ssa is repaired to fixup any dominance violations that have resulted and ssa rewrite runs again to resolve added goto variables,
conditions and bring lowered phis back to ssa form

changes

remove identity op

remove some heap allocs

cleanup and split headers

repair ssa after structurization

faster phi lowering

use more ir builder

fix
2026-08-29 21:14:06 +03:00
TheTurtle 245d88590d shader_recompiler: Improve ssa rewrite pass correctness and readability (#4899)
The ssa rewrite pass is based on the spirv-opt pass of the same name:
https://github.com/KhronosGroup/SPIRV-Tools/blob/main/source/opt/ssa_rewrite_pass.cpp

This commit brings the pass closer to that reference implementation.
Notably this fixes applying the pass to unstructured graphs which seems to be broken otherwise

Additionally the manual stack iteration of ReadVariable has been replaced with recusion
which is much easier to reason about

Undef handling has also been changed, before each block would define its own Undef instruction,
now the pass will keep track and reuse compatible instructions add insert them to the first block
2026-08-22 19:07:50 +03:00
georgemoralis 0deda5e2a4 stubbed fs (#4879) 2026-08-19 10:27:15 -05:00
georgemoralis 46ae080038 stubbed signals (#4873) 2026-08-19 00:36:12 +03:00
Valdis Bogdānsandw1naenator dff1aad042 Add experimental Windows static red-zone protection (#4802)
- Analyze EH function boundaries and relocate faultable guest instructions through red-zone-safe trampolines.
- Integrate Windows exception handling and existing CPU patches without an external debugger.
- Add a Windows-only per-game setting, coverage diagnostics, and configuration tests.

Co-authored-by: w1naenator <valdis.bogdans@hotmail.com>
2026-08-06 09:34:10 +03:00
MathieuARS 06d4872c55 shader_recompiler: propagate V_ADD_I32 carry-out (#4736) 2026-07-21 16:20:23 +03:00
MathieuARS 4c72de0732 core: initialize NGS2 rack query output (#4735) 2026-07-20 20:49:49 +03:00
Al Jibran 3aef2190ca Fix flaky GCN tests (#4693)
fix: flaky tests due to uninitialized values
fix: segfault during teardown while running gcn tests

fix: vulkan validation error by enabling shaderFloat16 in GCN runner
2026-07-13 09:18:35 +03:00
Niram7777 6a20ebacde Save shader list, memory map and module list widgets (#4578)
* Save shader list, memory map and module list widgets

* Test discovery fix timeout...
2026-06-14 20:17:18 +03:00
kalaposfos13andgeorgemoralis 852539829a Reset controller colours on emulator shutdown (#4537)
* Reset controller colours on emulator shutdown

* bruh moment

* Don't use the destructor for this

* clang, formatter of night

* forgot to stage this file

* ffs

* fix tests

* fixed tests?

* gcn tests fixed?

* now?

* possible fixed

---------

Co-authored-by: georgemoralis <giorgosmrls@gmail.com>
2026-06-08 00:39:50 +03:00
georgemoralis a2c4e68d24 Http part7 (#4462)
* sceHttpAddRequestHeader

* added sceHttpRemoveRequestHeader

* implemented a few more functions

* added sceHttpSetProxy

* cleanup

* more cleanup

* fix tests?

* fix tests part2

* Added debug in SendRequest

* improved debug

* forgot

* added real http connection path

* fixes for wipeout

* add custom redirect as it doesn't match the httplib one

* more debug messages

* clang is not my friend

* argg

* make kernelstub configurable

* added url override

* fixup

* ..

* stephen's reviews

* more stephen reviews

* http tests

* fixed tests

* fixed a single tests isssue

* one more fix

* argg
2026-06-07 19:14:42 +03:00
georgemoralis 94786d70ca Http part2 (#4441)
* more uri work based on decompile and tests

* fix includes

* fix loader stubs

* cleanups

* sceHttpParseStatusLine matches decompile and tests

* sceHttpParseResponseHeader implemenation and tests

* try fixing no-internet path in sendrequest

* minimal state machine to support proper erroring of no-internet available

* more improvements

* more implementation based on stephen's comments

* some more fixes based on decompile
2026-05-17 22:54:34 +03:00
squidbus ac61f4aee2 shader_recompiler: Strip out manual bounds checking (#4380) 2026-05-09 10:05:18 -07:00
Marcin Mikołajczyk 34b35b526e Neo: Float16 packed math (#4354) 2026-05-04 15:21:20 -07:00
Marcin Mikołajczyk 26eaa3e3af Neo: 16bit shift instructions (#4351) 2026-05-04 10:13:42 -07:00
Marcin Mikołajczyk a3e25efad5 Neo: V_MAD_MIX opcodes (#4338) 2026-04-30 16:56:27 -07:00
Marcin Mikołajczyk 76729835d7 Neo: bit and alu instructions (#4332) 2026-04-28 14:54:15 -07:00
Marcin Mikołajczyk d47b0524ce V_ADD3_U32 and V_OR3_B32 (#4326) 2026-04-27 13:35:37 -07:00
Marcin MikołajczykandMatías Buzzo fba374442c file_sys: apply case-insensitive search to mods_path on GNU/Linux and macOS (#4312) (#4310)
The case-insensitive fallback search() in GetHostPath is only
invoked for patch_path and host_path, so mods whose file or folder
capitalization does not exactly match the guest path are silently
bypassed even when the files are present. Mirror the existing
search(patch_path) pass for mods_path, placed first to preserve
mod > patch > base precedence.

Co-authored-by: Matías Buzzo <matias@mbuzzo.com>
2026-04-27 18:07:05 +03:00
Marcin Mikołajczyk 99f2480e21 Neo: V_*_F16 arithmetic ops (#4311) 2026-04-25 12:51:02 +02:00
Marcin Mikołajczyk 012b4a6ef5 Define GCN instructions in tests (#4289) 2026-04-20 08:48:02 +03:00
Marcin Mikołajczyk 963d10f220 Test framework for GCN pipeline (#4272)
* Test framework for GCN pipeline

* Try fixing test compilation on CI
2026-04-19 22:15:08 +03:00
Niram7777 854b291c63 Spdlog migration (#4069)
* spdlog migration

* gitmodule instead of cmake
2026-04-19 00:57:05 +03:00
georgemoralis 31b2d9ccd7 Introducing testing suite using google test (#4170)
* initial tests for testing Setting<T>

* argg

* keep switch off

* added ci

* fix ci

* merging tests to build.yml

* fixing linux ttests/?

* one more try for ci

* more linux fix for ci

* more ci fixes

* try to fix ctests now

* should fix now

* trying fixing linux tests

* some more tests

* more tests (68 tests) and clang format
2026-03-26 00:31:53 +02:00