aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2021-10-18Another workaround for NVIDIA driver 496.13 shader bug (#2750)riperiperi
* Another workaround for NVIDIA driver 496.13 shader bug This might work better than the other one. Give this a test to see if it fixes/doesn't fix issues with the other one. The problem seems to be when any variable assignment happens with a negation. `temp_1 = -temp_0;` seems to trigger weird behaviour, but `temp_1 = 0.0 - temp_0;` does not. This also might to extend towards integer types? * Update cache version * Add disclaimer comment * Wording
2021-10-18Add an early `TailMerge` pass (#2721)FICTURE7
* Add an early `TailMerge` pass Some translations can have a lot of guest calls and since for each guest call there is a call guard which may return. This can produce a lot of epilogue code for returns. This pass merges the epilogue into a single block. ``` Using filter 'hcq'. Using metric 'code size'. Total diff: -1648111 (-7.19 %) (bytes): Base: 22913847 Diff: 21265736 Improved: 4567, regressed: 14, unchanged: 144 ``` * Set PTC version * Address feedback * Handle `void` returning functions * Actually handle `void` returning functions * Fix `RegisterToLocal` logging
2021-10-18Initial tessellation shader support (#2534)gdkchan
* Initial tessellation shader support * Nits * Re-arrange built-in table * This is not needed anymore * PR feedback
2021-10-17Add missing U8/S8 types from shader I2I instruction (#2740)gdkchan
* Add missing U8/S8 types from shader I2I instruction * Better names * Fix dstIsSignedInt
2021-10-17Extend bindless elimination to work with masked and shifted handles (#2727)gdkchan
* Extent bindless elimination to work with masked handles * Extend bindless elimination to catch shifted pattern, refactor handle packing/unpacking
2021-10-17Implement SHF (funnel shift) shader instruction (#2702)gdkchan
* Implement SHF shader instruction * Shader cache version bump * Better name
2021-10-13Fix regression with foreground software keyboard (#2732)Caian Benedicto
2021-10-12Force index buffer update for games using Vulkan (#2726)gdkchan
2021-10-12Enqueue frame before signalling the frame is ready. (#2722)riperiperi
It seems that certain games (Link's Awakening, Xenoblade DE) had their fences reached already when posting framebuffers, so the signal that a frame was ready would go out _before_ the frame was enqueued, and the render loop would fail to dequeue anything and "skip" a frame. This was resulting in their performance lowering dramatically after some loading transitions, as a frame signal would be consumed and presentation would be one frame behind. It's possible this might have eventually caused deadlocks in these games or others, if it happened twice.
2021-10-12Don't force scaling on 2D copy sources (#2701)riperiperi
Some games (GameMaker Studio) build texture atlases out of sprites during initialization, using the 2D copy method. These copies are done from textures loaded into memory, not rendered, so they are not scaled to begin with. I had set srcTexture in these copies to force scaling, but really it only needs to scale if the texture already exists and was scaled by rendering or something else. I just set that to false, so it doesn't change if the texture is scaled or not. This will also avoid the destination being scaled if the source wasn't. The copy can handle mismatching scales just fine. This prevents scaling artifacts in GMS games, and maybe others (not Super Mario Maker 2, that has another issue).
2021-10-12nvdec: Adding Vp8 codec support (#2707)Ac_K
* first try * second try * working update * Final impl * Fixes nits * Fix everything * remove leftover * Update FFmpegContext.cs * Update Surface.cs * Addresses gdkchan feedback * bool not byte * Addresses gdkchan feedback
2021-10-12Rewrite shader decoding stage (#2698)gdkchan
* Rewrite shader decoding stage * Fix P2R constant buffer encoding * Fix PSET/PSETP * PR feedback * Log unimplemented shader instructions * Implement NOP * Remove using * PR feedback
2021-10-12spl: Implement IGeneralInterface GetConfig (#2705)Ac_K
* spl: Implement IGeneralInterface GetConfig This PR implement the GetConfig call of the spl service. This is currently needed for some homebrews which currently needs Ignore Missing Service to boot. Now it's fixed. Implementation was done using Atmosphère code and REing too. * Addresses gdkchan feedback
2021-10-12Inline software keyboard without input pop up dialog (#2180)Caian Benedicto
* Initial implementation * Refactor dynamic text input keys out to facilitate configuration via UI * Fix code styling * Add per applet indirect layer handles * Remove static functions from SoftwareKeyboardRenderer * Remove inline keyboard reset delay * Remove inline keyboard V2 responses * Add inline keyboard soft-lock recovering * Add comments * Forward accept and cancel key names to the keyboard and add soft-lock prevention line * Add dummy window to handle paste events * Rework inline keyboard state machine and graphics * Implement IHostUiHandler interfaces on headless WindowBase class * Add inline keyboard assets * Fix coding style * Fix coding style * Change mode cycling shortcut to F6 * Fix invalid calc size error in games using extended calc * Remove unnecessary namespaces
2021-10-08Optimize LSRA (#2563)FICTURE7
* Optimize `TryAllocateRegWithtoutSpill` a bit * Add a fast path for when all registers are live. * Do not query `GetOverlapPosition` if the register is already in use (i.e: free position is 0). * Do not allocate child split list if not parent * Turn `LiveRange` into a reference struct `LiveRange` is now a reference wrapping struct like `Operand` and `Operation`. It has also been changed into a singly linked-list. In micro-benchmarks traversing the linked-list was faster than binary search on `List<T>`. Even for quite large input sizes (e.g: 1,000,000), surprisingly. Could be because the code gen for traversing the linked-list is much much cleaner and there is no virtual dispatch happening when checking if intervals overlaps. * Turn `LiveInterval` into an iterator The LSRA allocates in forward order and never inspect previous `LiveInterval` once they are expired. Something similar can be done for the `LiveRange`s within the `LiveInterval`s themselves. The `LiveInterval` is turned into a iterator which expires `LiveRange` within it. The iterator is moved forward along with interval walking code, i.e: AllocateInterval(context, interval, cIndex). * Remove `LinearScanAllocator.Sources` Local methods are less susceptible to do allocations than lambdas. * Optimize `GetOverlapPosition(interval)` a bit Time complexity should be in O(n+m) instead of O(nm) now. * Optimize `NumberLocals` a bit Use the same idea as in `HybridAllocator` to store the visited state in the MSB of the Operand's value instead of using a `HashSet<T>`. * Optimize `InsertSplitCopies` a bit Avoid allocating a redundant `CopyResolver`. * Optimize `InsertSplitCopiesAtEdges` a bit Avoid redundant allocations of `CopyResolver`. * Use stack allocation for `freePositions` Avoid redundant computations. * Add `UseList` Replace `SortedIntegerList` with an even more specialized data structure. It allocates memory on the arena allocators and does not require copying use positions when splitting it. * Turn `LiveInterval` into a reference struct `LiveInterval` is now a reference wrapping struct like `Operand` and `Operation`. The rationale behind turning this in a reference wrapping struct is because a `LiveInterval` is associated with each local variable, and these intervals may themselves be split further. I've seen translations having up to 8000 local variables. To make the `LiveInterval` unmanaged, a new data structure called `LiveIntervalList` was added to store child splits. This differs from `SortedList<,>` because it can contain intervals with the same start position. Really wished we got some more of C++ template in C#. :^( * Optimize `GetChildSplit` a bit No need to inspect the remaining ranges if we've reached a range which starts after position, since the split list is ordered. * Optimize `CopyResolver` a bit Lazily allocate the fill, spill and parallel copy structures since most of the time only one of them is needed. * Optimize `BitMap.Enumerator` a bit Marking `MoveNext` as `AggressiveInlining` allows RyuJIT to promote the `Enumerator` struct into registers completely, reducing load/store code a lot since it does not have to store the struct on the stack for ABI purposes. * Use stack allocation for `use/blockedPositions` * Optimize `AllocateWithSpill` a bit * Address feedback * Make `LiveInterval.AddRange(,)` more conservative Produces no diff against master, but just for good measure.
2021-10-07Added support for Pixel Format X8B8G8R8 (#2716)C1fer
* Added support for Pixel Format X8B8G8R8 Fixes cutscenes on Metroid Dread. * Removed unnecessary case execution. * Update Ryujinx.Graphics.Vic/Image/SurfaceWriter.cs Co-authored-by: gdkchan <gab.dark.100@gmail.com> Co-authored-by: gdkchan <gab.dark.100@gmail.com>
2021-10-07Merge pull request #2713 from riperiperi/fix/modified-inheritriperiperi
Reregister flush actions when taking a buffer's modified range list.
2021-10-07Avoid potential raceriperiperi
2021-10-07Reregister flush actions when taking a buffer's modified range list.riperiperi
Fixes a regression from #2663 where buffer flush would not happen after a resize. Specifically caused the world map in Yoshi's Crafted World to flash. I have other planned changes to this class so this might change soon, but this regression could affect a lot so it couldn't wait.
2021-10-05Add `Operand.Label` support to `Assembler` (#2680)FICTURE7
* Add `Operand.Label` support to `Assembler` This adds label support to `Assembler` and enables branch tightening when compiling with relocatables. Jump management and patching has been moved to the `Assembler`. * Move instruction table to `Assembler.Table` * Set PTC internal version * Rename `Assembler.Table` to `AssemblerTable`
2021-10-05Fix DisplayInfo struct (#2708)gdkchan
2021-10-04Smaller initial size for ModifiedRangeList & directly inherit range list (#2663)riperiperi
This fixes a potential regression with the new range list changes, where the cost for creating new ones would be rather large due to creating a 1024 size array. Also reduces cost for range list inheritance by using the first existing range list as a base, rather than creating a new one then adding both lists to it. The growth size for the RangeList is now identical to its initial size. Every 32 elements was probably a little too common - now it is 1024 for most things and 8 for the buffer modified range list. The Unmapped and SyncMethod methods have been changed to ensure that they behave properly if the range list is set null. Cleaned up a few calls to use the null-conditional operator.
2021-10-04Relax sampler pool requirement (#2703)gdkchan
2021-10-04Unref frames before decoding with FFMPEG (#2704)gdkchan
2021-09-29Replace CacheResourceWrite with more general "precise" write (#2684)riperiperi
* Replace CacheResourceWrite with more general "precise" write The goal of CacheResourceWrite was to notify GPU resources when they were modified directly, by looking up the modified address/size in a structure and calling a method on each resource. The downside of this is that each resource cache has to be queried individually, they all have to implement their own way to do this, and it can only signal to resources using the same PhysicalMemory instance. This PR adds the ability to signal a write as "precise" on the tracking, which signals a special handler (if present) which can be used to avoid unnecessary flush actions, or maybe even more. For buffers, precise writes specifically do not flush, and instead punch a hole in the modified range list to indicate that the data on GPU has been replaced. The downside is that precise actions must ignore the page protection bits and always signal - as they need to notify the target resource to ignore the sequence number optimization. I had to reintroduce the sequence number increment after I2M, as removing it was causing issues in rabbids kingdom battle. However - all resources modified by I2M are notified directly to lower their sequence number, so the problem is likely that another unrelated resource is not being properly updated. Thankfully, doing this does not affect performance in the games I tested. This should fix regressions from #2624. Test any games that were broken by that. (RF4, rabbids kingdom battle) I've also added a sequence number increment to ThreedClass.IncrementSyncpoint, as it seems to fix buffer corruption in OpenGL homebrew. (this was a regression from removing sequence number increment from constant buffer update - another unrelated resource thing) * Add tests. * Add XML docs for GpuRegionHandle * Skip UpdateProtection if only precise actions were called This allows precise actions to skip reprotection costs.
2021-09-29Force copy when auto-deleting a texture with dependencies (#2687)riperiperi
When a texture is deleted by falling to the bottom of the AutoDeleteCache, its data is flushed to preserve any GPU writes that occurred. This ensures that the data appears in any textures recreated in the future, but didn't account for a texture that already existed with a copy dependency. This change forces copy dependencies to complete if a texture falls out from from the AutoDeleteCache. (not removed via overlap, as that would be wasted effort) Fixes broken lighting caused by pausing in SMO's Metro Kingdom. May fix some other issues.
2021-09-29Only make render target 2D textures layered if needed (#2646)gdkchan
* Only make render target 2D textures layered if needed * Shader cache version bump * Ensure topology is updated on channel swap
2021-09-29Optimize `HybridAllocator` (#2637)FICTURE7
* Store constant `Operand`s in the `LocalInfo` Since the spill slot and register assigned is fixed, we can just store the `Operand` reference in the `LocalInfo` struct. This allows skipping hitting the intern-table for a look up. * Skip `Uses`/`Assignments` management Since the `HybridAllocator` is the last pass and we do not care about uses/assignments we can skip managing that when setting destinations or sources. * Make `GetLocalInfo` inlineable Also fix a possible issue where with numbered locals. See or-assignment operator in `SetVisited(local)` before patch. * Do not run `BlockPlacement` in LCQ With the host mapped memory manager, there is a lot less cold code to split from hot code. So disabling this in LCQ gives some extra throughput - where we need it. * Address Mou-Ikkai's feedback * Apply suggestions from code review Co-authored-by: VocalFan <45863583+Mou-Ikkai@users.noreply.github.com> * Move check to an assert Co-authored-by: VocalFan <45863583+Mou-Ikkai@users.noreply.github.com>
2021-09-29Use normal memory store path for DC ZVA (#2693)riperiperi
Seems like this is used as an optimized way to clear memory in homebrew applications. Unfortunately, calling the software fallback method every 8 bytes was not very optimal. The existing EmitStore is used by passing in ZR as the register to get a 0 write.
2021-09-29clkrst: Stub/Implement IClkrstManager and IClkrstSession calls (#2692)Ac_K
This PR stubs and implements some clkrst call because they are used to overclock the Switch hardware and it's pointless in our case as we emulate the system. Everything was done checked by RE. Fixes #2686
2021-09-29NVDEC (H264): Use separate contexts per channel and decode frames in DTS ↵gdkchan
order (#2671) * Use separate NVDEC contexts per channel (for FFMPEG) * Remove NVDEC -> VIC frame override hack * Add missing bottom_field_pic_order_in_frame_present_flag * Make FFMPEG logging static * nit: Remove empty lines * New FFMPEG decoding approach -- call h264_decode_frame directly, trim surface cache to reduce memory usage * Fix case * Silence warnings * PR feedback * Per-decoder rather than per-codec ownership of surfaces on the cache
2021-09-29Fix PTC count table relocation patching (#2666)FICTURE7
Fix an issue introduced in #2190 where by 2 different count table entry addresses were used for LCQ functions. E.g: ```asm .L1: mov rbp,COUNT_TABLE_0 ;; This gets an address. mov ebp,[rbp] lea esi,[rbp+1] mov rdi,COUNT_TABLE_1 ;; This gets another address. mov [rdi],esi cmp ebp,64h je near .L34 ``` This caused LCQ functions to not tier up when they're loaded from the PTC cache. This does not happen when they're freshly compiled. This PR fixes the issue by ensuring only a single counter is created per translation.
2021-09-29irs: Stub some service calls (#2665)Ac_K
This PR stubs some irs service calls which are needed to get some games playable or at least bootable since we don't support IR data throught real JoyCon for now. - Stubs `IIrSensorServer` `StopImageProcessor`, `RunMomentProcessor`, `RunClusteringProcessor`, `RunImageTransferProcessor`, `GetImageTransferProcessorState`, `RunTeraPluginProcessor`. All calls are a bit checked by RE. Closes #2267, #2248, #2126 Night Vision and SpyAlarm are now bootable (but still unplayable due to the lack of the IR data):
2021-09-28Share scales array for graphics and compute (#2653)gdkchan
2021-09-28Quick README update for game compatibility. (#2694)VocalFan
2021-09-19Fast path for Inline2Memory buffer write that skips write tracking (#2624)riperiperi
* Fast path for Inline2Memory buffer write This PR adds a method to PhysicalMemory that attempts to write all cached resources directly, so that memory tracking can be avoided. The goal of this is both to avoid flushing buffer data, and to avoid raising the sequence number when data is written, which causes buffer and texture handles to be re-checked. This currently only targets buffers, with a side check on textures that falls back to a tracked write if any exist within the target range. It's not expected to write textures from here - this is just a mechanism to protect us if someone does decide to do that. It's possible to add a fast path for this in future (and for ShaderCache, once that starts using tracking) The forced read before inline2memory begins has been skipped, as the data is fully written when the transfer is completed anyways. This allows us to flush on read in emergency situations, but still write the new data over the flushed data. Improves performance on Xenoblade 2 and DE, which was flushing buffer data on the GPU thread when trying to write compute data. May improve performance in other games that write SSBOs from compute, and update data in the same/nearby pages often. Super Smash Bros Ultimate should probably be tested to make sure the vertex explosions haven't returned, as I think that's what this AdvanceSequence was for. * ForceDirty before write, to make sure data does not flush over the new write
2021-09-19Implement and use an Interval Tree for the MultiRangeList (#2641)riperiperi
* Implement and use an Interval Tree for the MultiRangeList * Feedback * Address Feedback * Missed this somehow
2021-09-19Use shader subgroup extensions if shader ballot is not supported (#2627)gdkchan
* Use shader subgroup extensions if shader ballot is not supported * Shader cache version bump + cleanup * The type is still required on the table
2021-09-19Array based RangeList that caches Address/EndAddress (#2642)riperiperi
* Array based RangeList that caches Address/EndAddress In isolation, this was more than 2x faster than the RangeList that checks using the interface. In practice I'm seeing much better results than I expected. The array is used because checking it is slightly faster than using a list, which loses time to struct copies, but I still want that data locality. A method has been added to the list to update the cached end address, as some users of the RangeList currently modify it dynamically. Greatly improves performance in Super Mario Odyssey, Xenoblade and any other GPU limited games. * Address Feedback
2021-09-19Set texture/image bindings in place rather than allocating and passing an ↵riperiperi
array (#2647) * Remove allocations for texture bindings and state * Rent rather than stackalloc + copy A bit faster.
2021-09-19amadeus: Fix regression from #2654 on ListAudioDeviceNameMary
2021-09-19vi: Unify resolutions values and accurate implementation of them. (#2640)Ac_K
* vi: Unify resolutions values and accurate implementation of them. To continue what was made in #2618, I've REd `vi` service a bit. Now values and checks related to displays are more accurate. - `am` GetDefaultDisplayResolution / GetDefaultDisplayResolutionChangeEvent have more informations on what the service does. - `vi:u/vi:m/vi:s` GetDisplayService are now accurate. - `IApplicationDisplay` GetRelayService, GetSystemDisplayService, GetManagerDisplayService, GetIndirectDisplayTransactionService, ListDisplays, OpenDisplay, OpenDefaultDisplay, CloseDisplay, GetDisplayResolution are now properly implemented. - Some other calls are cleaned or have extra checks accordingly to RE. Additionnaly, `IFriendService` have some wrong aligned things, and `pm:info` service placeholder was missing. * just use _openedDisplayInfo.Remove() * use context.Memory.Fill() * fix some casting * remove unneeded comment * cleanup * uses TryAdd * displayId > ulong * GetDisplayResolution > ulong * UL
2021-09-19amadeus: Update to REV10 (#2654)Mary
* amadeus: Update to REV10 This implements all the changes made with REV10 on 13.0.0. * Address Ack's comment * Address gdkchan's comment
2021-09-18Fix problems added by Pause (#2645)mpnico
* Disable Pause/Resume menu instead of trying to hide them * Fix Resume menu being active before renderer starts * Fix emulator not being able to close properly
2021-09-16gui: Hotfix for FileChooserNative during section extraction (#2644)Ac_K
Fix a regression introduced in #2633, FileChooserNative parent can't be set to null because it's running in modal.
2021-09-15Adjustments to framerate metric and addition of frametime (#2638)MutantAura
* Adjust framerate data and add frametime * Update PerformanceStatistics.cs * Revert deletions of average framerate * Update Ryujinx.csproj * Remove separate GTK column * Increase FPS precision * general cleanup * even generaler cleanup * fix dumb * Remove legacy code * Update PerformanceStatistics.cs * Update PerformanceStatistics.cs
2021-09-15Add Linux Unicorn patch + desc. (#2609)Michael Gielda
2021-09-15hos: Cleanup the project (#2634)Ac_K
* hos: Cleanup the project Since a lot of changes has been done on the HOS project, there are some leftover here and there, or class just used in one service, things at wrong places, and more. This PR fixes that, additionnally to that, I've realigned some vars because I though it make the code more readable. * Address gdkchan feedback * addresses Thog feedback * Revert ElfSymbol
2021-09-14gui: Replace FileChooserDialog by FileChooserNative (#2633)Ac_K
We currently use the FileChooser from GTK, which is a bit mess. Instead of it we could use the native FileChooser from all specifics OS. This is what this PR attempt to fix. It could be nice to get a test under linux since I've only tested it under Windows without any issues. Fixes #2584
2021-09-14Refactor `PtcInfo` (#2625)FICTURE7
* Refactor `PtcInfo` This change reduces the coupling of `PtcInfo` by moving relocation tracking to the backend. `RelocEntry`s remains as `RelocEntry`s through out the pipeline until it actually needs to be written to the PTC streams. Keeping this representation makes inspecting and manipulating relocations after compilations less painful. This is something I needed to do to patch relocations to 0 to diff dumps. Contributes to #1125. * Turn `Symbol` & `RelocInfo` into readonly structs * Add documentation to `CompiledFunction` * Remove `Compiler.Compile<T>` Remove `Compiler.Compile<T>` and replace it by `Map<T>` of the `CompiledFunction` returned.