Commit Graph
4503 Commits
Author SHA1 Message Date
TheTurtle 507464a531 shader_recompiler: Reimplement B64 SALU opcodes with U64 masks (#4972)
* shader_recompiler: Use full U64 masks

WIP lacks proper ballot elim pass so codegen is not optimal but it worksTM

* shader_recompiler: Implement inverse ballot elimination pass

This pass pushes up InverseBallot instruction in the def chain in order to cancel out with corresponding Ballot instructions

* shader_recompiler: Handle composite construction and boolean select in constant propagation

* shader_recompiler: Add phi simplification pass

Implements pass for pulling out common operations into the phi itself as well as removing duplicated phis that result from that.
Inspired from InstCombinePHI in LLVM

* inverse_ballot_elimination_pass: Fold UndefU64

* phi_simplification_pass: Deduplicate phi users after phi deduplication

The act of deduplicating phis can also cause users to became identical

* shader_recompiler: Dont pull out ballot ops from phis

Also every time an instruction is pull out of a phi, also add any phi users to worklist

* shader_recompiler: Implement more aggressive DCE

inspired by LLVM ADCE, the pass can now also remove dead use cycles

* emit_spirv: Enable group ballot for SubgroupLtMask

* shader_recompiler: Avoid re-emitting register loads and ballots in structurization

This allows us to move ballot elim before structurization and it can work more efficiently that way

* ssa_rewrite_pass: More prints

* inverse_ballot_elim: Perform targeted CSE and simplfication for ballot elim

Takes the responsibility of instruction deduplication from phi elim and runs the needed subset of constant prop so running constant prop beforehand is not required

* clang format

* shader_recompiler: Rewrite phi simplfication pass

It now works with phi SCCs making it more robust and able to optimize more cases

* ir: Move instruction type special checks to instruction itself

IR::Value is not the correct place for those

* bring back localized simplification

* vector_alu: Add v_cmp_lt_u64

* phi_simplification_pass: Run local CSE after deduping SCCs

This can expose more opt possiblities
2026-09-08 19:07:02 +03:00
junminlee2004 63cc326dc5 renderer_vulkan: Handle QuadStrip as a triangle strip (#4977)
* Add support for QuadStrip primitive type

* Log warning for QuadStrip

Added a warning log for unimplemented primitive type handling.
2026-09-07 21:24:58 +03:00
georgemoralis b81daab3dd fixed DrawCenteredText with new imgui (#4978) 2026-09-07 12:59:50 +03:00
Gabriele C.andClaude Opus 5 3303b03e5b FileSys: Open host-backed files with POSIX-style full sharing (#4838)
* FileSys: Open host-backed files with POSIX-style full sharing

Guests code expect POSIX behaviour here: if a file is already open for writing
on one fd, opening it again on another one should still work. That is what our
other host backends already do, since the share mode is a Windows-only concept
and the POSIX path ignores it, but on Windows we default to denying writers and
the second open comes back as EACCES. It is easy to run into, since a title
reopening its own scratch files is perfectly normal: LittleBigPlanet 3 does it
constantly.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* FileSys: Shorten the host file sharing comment

The note above the HostFile constructor spent three lines restating what
the code already shows. Say why the sharing flags are there in one line,
and fix the grammar while at it.

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-06 18:38:48 +03:00
kalaposfos13 7055e65518 Fix cut off logging in log files after the signals rewrite (#4975)
* Put back Emulator::Shutdown() to assert_fail_impl

* as far as I can see this code is entirely irrelevant to logging being cut off on windows

* the default guest handler for SIGTRAP doesn't need to be handled differently ever since we remove the host handlers before asserting

* it works so ship it
2026-09-06 10:19:53 -05:00
Marcin Mikołajczyk 17ca6700f5 Include more info in image overlap log (#4974) 2026-09-06 00:18:37 +02:00
Stephen Miller a31770e2e8 Fix IR dumping (#4973) 2026-09-05 16:51:22 -05:00
Marcin Mikołajczyk 256546c430 Improve log message for fp rounding modes (#4970) 2026-09-05 14:40:11 -05: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
junminlee2004 22fb56d51c ime: pass AddPolyline thickness and flags in the imgui 1.92.8 order (#4969) 2026-09-05 00:41:54 +03:00
kalaposfos13 5802ad8d26 the boring fix (#4968) 2026-09-04 23:28:18 +03:00
georgemoralis f03636bf35 fix imgui crash (#4967) 2026-09-04 20:31:44 +03:00
junminlee2004 21d5639419 imgui: raise the font atlas cap from the backend's max texture size (#4964) 2026-09-04 19:18:00 +03:00
Vladislav Mikhalin 97c8feab18 video decoding: minor logic mistake (#4962) 2026-09-04 09:16:39 +03:00
georgemoralis 2eca0b5f0b Upstreaming imgui (#4960)
* added imgui upstream and updated ImGuiFileDialog with a needed update

* cmake fix

* update ImGuiChildFlags ,ImGuiWindowFlags in latest imgui

* revert to recheck

* big picture flags

* fixed texture descriptor

* migrated layer_extra to latest imgui

* updated text_editor to latest imgui
2026-09-03 15:40:23 +03:00
Stephen Miller f47e5f5cfe IMAGE_SAMPLE_D_O (#4958) 2026-09-03 08:50:18 +03:00
junminlee2004 473633c31a video_core: Decode sRGB for A2R10G10B10Srgb display buffers (#4957) 2026-09-03 03:46:03 +03: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
Marcin Mikołajczyk f3818e0319 Update sirit submodule (#4956) 2026-09-02 23:01:57 +03:00
Vladislav Mikhalin 0b93ac1751 we take security seriously here or whatever (#4955) 2026-09-02 22:00:42 +03:00
Vladislav Mikhalin ae1539d32a vdec2: support for h265/hevc (#4951)
* vdec2 hevc

* making someone happier

* you saw nothing

* neat nid
2026-09-02 13:08:58 +03:00
kalaposfos13 2b4592b77c Fix incorrect error return on attempting to create a file in a nonexistent folder in a writable mount (#4952)
I refuse to have a clang commit on a one line fix PR, so a force push it is.
2026-09-02 00:46:09 +03:00
georgemoralis 1403d31130 Some games open port with handle 255 , that is not an accepted port so don't complain about it (#4946) 2026-09-01 19:13:46 +03:00
Valdis Bogdāns e29cf71996 shader_recompiler: Enhance shared memory barrier handling and add divergent loop detection (#4941)
* shader_recompiler: Enhance shared memory barrier handling and add divergent loop detection

* Clang-format fixes as always.
2026-08-31 12:25:48 +03:00
AnishGRao 0134143b6d Force LOG_GENERIC behind check of should_log (#4942) 2026-08-31 08:26:03 +03:00
georgemoralis b8e60d2dac np_utility initial impelmentation (#4940)
* implemented sceNpLookup*  (similar of how np_score ,np_tus) functions

* Update CMakeLists.txt

* fixed logging

* cleanup logging

* more cleanup
2026-08-31 07:45:37 +03:00
kalaposfos13 297551e00c Use a system mapping for camera frame data and add a dummy sceCameraGetCalibData implementation (#4938)
* Well, I tried

* map the camera gpu pool a bit higher

* dummy sceCameraGetCalibData

* slight improvement to sceCameraGetCalibData

* remove this because it's just a hack that I tried just in case it does anything
2026-08-30 01:07:43 +03:00
kalaposfos13 e82c33507b LLE system computer vision libraries except VrTracker (#4937) 2026-08-29 23:55:44 +03:00
junminlee2004 012a15d4ff renderer_vulkan: do not auto-select a software rendering device (#4904) 2026-08-29 23:42: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
Mehran 3e458471e5 video_core: Emulate scaled min/max blending (#4768)
* video_core: Emulate scaled min/max blending

* video_core: Warn when scaled min/max blend emulation is used

* Emulate min/max alpha blend with operand-zeroing factors
2026-08-29 16:27:38 +03:00
junminlee2004 fc74821b41 shader_recompiler: decorate written storage buffers as Coherent (#4896)
* shader_recompiler: decorate written storage buffers as Coherent

* Revert "shader_recompiler: decorate written storage buffers as Coherent"

* shader_recompiler: derive Coherent decorations from guest V# mtype
2026-08-29 15:51:15 +03:00
Stephen Miller 391430a924 Update vk_rasterizer.cpp (#4934) 2026-08-29 10:45:18 +03:00
Vaibhav Srivastava e5d93d2cf0 docs: fix typo occured -> occurred (#4935)
Signed-off-by: Vaibhav Srivastava <vaibhavsri1712@gmail.com>
2026-08-29 10:45:05 +03:00
DanielSvoboda 388cff5177 Fix missing files.json handling (#4931) 2026-08-27 18:15:42 +03:00
georgemoralis d7114f9197 Tss support (#4930)
* initial TSS

* improved delete request
2026-08-27 17:08:47 +03:00
kalaposfos13 54ec7d00a0 Trigger a lightbar reset on controller connection (#4927)
Because the config is now parsed earlier than controller connection, we can no longer update the lightbar directly from the input config loading code, at least on startup. It's still used for mid-game input config reload though
2026-08-26 23:57:06 +03:00
DDK00011andliam e968c1fff3 common: free Windows thread descriptions (#4911)
Co-authored-by: liam <weaver.us168@gmail.com>
2026-08-26 10:30:38 +03:00
georgemoralis 83511183a2 Net Fixes (#4910)
* added method to retrieve all socket handles

* fixed some error codes

* copyright or kalaposfos will hunt me

* sceNetGetSockInfo added

* small fixups

* fixup
2026-08-26 10:00:33 +03:00
georgemoralis c9a5a014de Trophies online (shadNet) (#4914)
* updated client for trophies

* updated np_handler with trophy commands

* update np_trophy with shadnet commands
2026-08-25 19:18:40 +03:00
TheThunderTurner 616b126b34 Missing ps4/ps5 return function (#4912)
* return false

* i hope this is it

* move to process.cpp

* libkernel-libkernel

* logging

* logging
2026-08-25 09:04:05 -05:00
georgemoralis 7fb1a530c1 Http2 fixes (#4908)
* small http2 corrections - addons

* applied stephen's comments
2026-08-23 11:43:26 -05:00
squidbus 8ca1d49447 video_core: Use stb_image_write for screenshots (#4907) 2026-08-23 10:10:17 +03:00
Stephen Miller f51299942c Revert "Neo: MIMG instructions (#4414)" (#4902)
This reverts commit e4ff203093.
2026-08-22 23:42:04 +03:00
Stephen Miller f952ac205b Log unhandled metadata types instead of asserting (#4903) 2026-08-22 23:21:21 +03:00
TheTurtle f2928289f4 shader_recompiler: Add ssa destruction pass (#4901)
Using the new virtual register infrastructure we can destroy phi nodes back into register load/stores in a general way
2026-08-22 21:59:23 +03:00
TheTurtle 0aea6ef36f shader_recompiler: Add support for virtual registers (#4900)
Useful for expressing load/stores to non guest architectural state
Each virtual register is identified by a unique (index, type) pair
2026-08-22 20:06:28 +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 3e462bf01b fixed displaying of trophy name (#4898) 2026-08-22 10:41:45 -05:00
Stephen Miller 7d73848b23 Change default GetAuthorizationCode returns to be valid (#4893)
Apparently authentication codes should be 6 characters long, and issuer_id should always be 0x100. These details come from verbose game logs.
2026-08-22 13:03:42 +02:00