Remove dead code in DecoderImpl, fix weird harmless double-assign in TextEditor, fix FindStreams return check, fix broken memset and clean up a bit of Aio code, fix type for compare check in sceNpCmpNpIdInOrder, slightly de-slopify comments in sceNpCheckPlus, fix OrbisNpState defines based on extracted VSH defines, fix scePlayGoConvertLanguage types, fix scePlayGoGetProgress nullptr dereference, fix (I think?) missing break in HullShaderTransform, and fix (I think?) vk::Format result table definition.
Needs review, I think most of this is fine, but I'd like a second opinion.
Co-authored-by: georgemoralis <giorgosmrls@gmail.com>
* implement-s-bitset-b64
* Add 64-bit bitset operations to scalar ALU
* Fix clang-format trailing whitespace
* shader_recompiler: use 64-bit BitFieldInsert for S_BITSET_B64
Adds BitFieldInsert64 IR opcode and EmitBitFieldInsert64 in the SPIR-V
backend (OpBitFieldInsert with 64-bit Result Type), per SPIR-V spec
support for wider integer bitfield ops. offset/count stay 32-bit,
matching the existing ShiftLeftLogical64/ShiftRightLogical64
convention. S_BITSET_B64 now uses it instead of the manual
shift/or/andn2 sequence.
Addresses review comment from @raphaelthegreat.
* Rename BitFieldInsert to BitFieldInsert32
* Refactor S_BITSET_B64 to use 32-bit offset
* Consolidate BitFieldInsert function signatures
* Update BitFieldInsert to support U32 and U64
Refactor BitFieldInsert to handle both U32 and U64 types.
* Rename EmitBitFieldInsert to EmitBitFieldInsert32 *again
* I hope this is the last time.
* constant_prop_pass: fix bitfield
---------
Co-authored-by: raphaelthegreat <geoster3d@gmail.com>
* Include fiber names in thread names, if the thread is running a fiber
* yet another openorbis libkernel-libkernel export
* Move more shutdown routines to Emulator::Shutdown
* 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
* 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>
* 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
* 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>
* 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>
* 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
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
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