* am/gui: Implement Wake-up message.
This implement the ability to send a Wake-up (Resume) message to the guest.
Sometime games needs to Sleep and Wake-up the switch to unlock some ingame features.
* Address gdkchan feedback
* Implement TreeMap from scratch.
Begin implementation of MemoryBlockManager
* Implement GetFreePosition using MemoryBlocks
* Implementation of Memory Management using a Tree.
Still some issues to work around, but promising thus far.
* Resolved invalid mapping issue.
Performance appears promising.
* Add tick metrics
* Use the logger instead
* Use debug loggin instead of info.
* Remove unnecessary code. Add descriptions of added functions.
* Improve memory allocation even further. As well as improve speed of position fetching.
* Add TreeDictionary to Ryujinx Commons
Removed Unnecessary Usigns
* Add a Performance Profiler + Improve ReserveFixed
* Begin transition to allocation in nvdrv
* Create singleton nvmemallocator
* Moved Allocation into Nv Related Files
As requested by gdkchan, any allocation of memory has been moved into the driver files.
Mapping remains in the GPU MemoryManager.
* Remove unnecessary usings
* Add missing descriptions
* Correct descriptions
* Fix formatting.
* Remove unnecessary whitespace
* Formatting / Convention Updates
* Changes / Fixes
Made syntax and convention changes as requested by gdkchan.
Fixed an issue where IsRegionUsed would return the wrong boolean.
Fixed an issue where GetFreePosition was asked for an address instead of a size.
* Undo commenting of Assert in shader cache
* Update Ryujinx.Common/Collections/TreeDictionary.cs
Co-authored-by: gdkchan <gab.dark.100@gmail.com>
* Resolved many suggestions
* Implement Improved TreeDictionary
Based off of Pseudo code and custom implementations.
* Rename _set to _dictionary
* Remove unused code
* Remove unused code.
* Remove unnecessary MapLow function.
* Resolve data-structure based issues
* Make adjustments to memory management.
Deactive de-allocation for now, it causes more harm than good.
* Minor refactorings + Re-implement deallocation
Also cleaned up unnecessary code.
* Add Tests for TreeDictionary
* Update data structure to properly balance the tree
* Experimental Implementation:
1. Reduce Time to Next Node to O(1) Runtime
2. Reduce While Loop Ct To 2 (In Most Cases)
* Address issues w/ Deallocating Memory
* Final Build
+ Fully Implement Dictionary Interface for new Data Structure
+ Cover All Memory Allocation Edge Cases, particularly w/ Games that De-Allocate a lot.
* Minor Corrections
Give TreeDictionary its own count (do not depend on inner dictionary)
Properly remove adjacent allocations
* Add AsList
* Fix bug where internal dictionary wasn't being updated w/ new node for overwritten key.
* Address comments in review.
* Fix issue where block wouldn't break out (Fixes UE4 issues)
* Update descriptions
* Update descriptions
* Reduce Node visibility to protect TreeDictionary Integrity + Remove usage of struct.
* Update tests to use new TreeDictionary implementation.
* Remove usage of dictionary in TreeDictionary
* Refactoring / Renaming
* Remove unneeded memoryblock class.
* Add space for while
* Add space for if
* Formatting / descriptions
* Clarified some descriptions
* Reduce visibility of memory allocator
* Edit method names to make more sense as memory blocks are no longer in use.
* Make names consistent.
* Protect against npe when sucessorof is called against keys that don't exist. (Not in use by memory manager, this is for other prs that might use this data structure)
* Possible edge-case resolve
* Update Ryujinx.Common/Collections/TreeDictionary.cs
Co-authored-by: gdkchan <gab.dark.100@gmail.com>
* Update Ryujinx.HLE/HOS/Services/Nv/NvMemoryAllocator.cs
Co-authored-by: gdkchan <gab.dark.100@gmail.com>
* Reduce # of unnecessary duplicate variables / Reduce visibility of variables only internally used.
* Rename count to _count
* Update Description of Add method.
* Fix copypasta
* Address comments
* Address comments
* Remove whitespace
* Address comments, condense variables.
* Consolidate vars
* Fix whitespace.
* Nit
* Fix exception msg
* Fix arrayIndex check
* Fix arrayIndex check + indexer
* Remove whitespace from cast
Co-authored-by: gdkchan <gab.dark.100@gmail.com>
* Rewrite scheduler context switch code
* Fix race in UnmapIpcRestorePermission
* Fix thread exit issue that could leave the scheduler in a invalid state
* Change context switch method to not wait on guest thread, remove spin wait, use SignalAndWait to pass control
* Remove multi-core setting (it is always on now)
* Re-enable assert
* Remove multicore from default config and schema
* Fix race in KTimeManager
This implement IApplicationFunctions GetHealthWarningDisappearedSystemEvent call which is needed by Mario Kart 8 in Chinese version. Call was checked by RE.
We still have to determine where to signals some AM events.
Thanks to Kakasita on our Discord to reported this and confirm this works fine!
* Make sure to not leak copy handles passed in request
Following last gdkchan's PR this make sure to close copy handles that
are passed by guest when it should.
* fix comment copy pasta
* IPC refactor part 2: Use ReplyAndReceive on HLE services and remove special handling from kernel
* Fix for applet transfer memory + some nits
* Keep handles if possible to avoid server handle table exhaustion
* Fix IPC ZeroFill bug
* am: Correctly implement CreateManagedDisplayLayer and implement CreateManagedDisplaySeparableLayer
CreateManagedDisplaySeparableLayer is requires since 10.x+ when appletResourceUserId != 0
* Make it exit properly
* Make ServiceNotImplementedException show the full message again
* Allow yielding execution to avoid starving other threads
* Only wait if active
* Merge IVirtualMemoryManager and IAddressSpaceManager
* Fix Ro loading data from the wrong process
Co-authored-by: Thog <me@thog.eu>
* audout: Implement GetAudioOutBufferCount, GetAudioOutPlayedSampleCount and FlushAudioOutBuffers
This PR implement audout service calls:
- GetAudioOutBufferCount
- GetAudioOutPlayedSampleCount
- FlushAudioOutBuffers
The RE calls just give some hints about no extra checks.
Since we use a totally different implementation because of our backend, I can't do something better for now.
SetAudioOutVolume and GetAudioOutVolume are fixed too by set/get the volume of the current opened track, previous implementation was wrong.
This fix#1133, fix#1258 and fix#1519.
Thanks to @jduncanator for this help during the implementation and all his precious advices.
* Fix some debug leftovers
* Address jD feedback
This PR fix an issue I've made in #1688 which is enabled VR as default.
It could cause rendering issues in games when VR mode isn't used, as users have reported in Smash:
* am/lbl/hid/pctl: Enabled VR Rendering
This PR enable VR rendering on games which support it through the Toy-Con VR Goggles.
Please remember Ryujinx currently don't support console SixAxis sensor and for now, in some games, the view can't be moved.
Everything is implemented accordingly to RE:
- am: ICommonStateGetter: SetVrModeEnabled, BeginVrModeEx, EndVrModeEx.
- lbl: ILblController: SetBrightnessReflectionDelayLevel, GetBrightnessReflectionDelayLevel, SetCurrentAmbientLightSensorMapping, GetCurrentAmbientLightSensorMapping, SetCurrentBrightnessSettingForVrMode, GetCurrentBrightnessSettingForVrMode, EnableVrMode, DisableVrMode, IsVrModeEnabled.
- pctl: IParentalControlService: ConfirmStereoVisionPermission, ConfirmStereoVisionRestrictionConfigurable, GetStereoVisionRestriction, SetStereoVisionRestriction, ResetConfirmedStereoVisionPermission, IsStereoVisionPermitted.
- hid: IHidServer: ResetSevenSixAxisSensorTimestamp is stubbed because we don't support console SixAxisSensor for now.
Maybe we could add a setting later to enable or disable VR. But I think it's fine to keep this always available since you have to enable it in games.
* Fix permission flag check
* Address gdkchan feedback
* apm: Refactoring/Unstub service
This PR implement some IPC calls of apm service:
- nn::apm::IManager is fully implemented.
- nn::apm::ISession is fully implemented (close#1633).
- nn::apm::ISystemManager is partially implemented.
nn::appletAE::ICommonStateGetter have some calls which are just a layer of apm IPC calls. What we did in some calls was wrong, it's fixed now!
Everything is checked with RE.
* abstract Apm *Server as Thog requested
* abstract ISession and fix other classes
* Address gdkchan feedback
* Fix class
* Fix Logging
* fix stalling when server is offline
* add retry timer to fail server connections, fix alt slot number
* fix alt slot key issue
* fix crash when saving controller config with empty fields
* code fixes
* add index check in motion hid update, made HandleResponse async
Co-authored-by: Emmanuel <nhv3@localhost.localdomain>
This fix a mistake I made during my original reimplementation of SurfaceFlinger by disabling async buffer.
This fix a memory corruption on Super Mario All-Stars 3D (Super Mario Sunshine & Super
Mario Galaxy now go ingame).
Thanks to @gdkchan for tracing the memory corruption.
* Return "NotAvailable" when no UserChannel data is present.
* Return ObjectInvalid for undefined parameter kinds.
* No need to specify which, there's only one.
* Just works as a literal string.
* Changes to allow explicit management of service threads
* Remove now unused code
* Remove ThreadCounter, its no longer needed
* Allow and use separate server per service, also fix exit issues
* New policy change: PTC version now uses PR number
* hos/gui: Add a check of NCA program index in titleid
This add a check to `ApplicationLoader` for the last 2 digits of the game TitleId who seems to be the NCA program index.
We currently return the last index, instead of the lower one.
Same check is added to ApplicationLibrary in the UI.
I've cleaned up both file too.
* hle: implement partial relaunch logic
TODO: make the emulator auto relauch.
* Handle auto relaunch
* hle: Unify update usage system
* hle: Implement support of multi programs in update system
* Add some documentation
* Address rip's comment
Co-authored-by: Ac_K <Acoustik666@gmail.com>
This project wasn't really used by anyone and isn't worth mantaining.
This commit remove the profiler entirely from Ryujinx and remove the associated CI tasks.
* Clean up and update readme
THis clean up and improve the README a bit.
* Apply suggestions from code review
Co-authored-by: EmulationFanatic <62343878+EmulationFanatic@users.noreply.github.com>
Co-authored-by: EmulationFanatic <62343878+EmulationFanatic@users.noreply.github.com>
* Initial commit
Enable proper LED patterns
Toggle Hotkeys only on focus
Ignore Handheld on Docked mode
Remove PrimaryController
Validate NpadIdType
Rewrite NpadDevices to process config in update loop
Cleanup
* Notify in log periodically when no matched controllers
* Remove duplicate StructArrayHelpers in favor of Common.Memory
Fix struct padding CS0169 warns in Touchscreen
* Remove GTK markup from Controller Applet
Use IList instead of List
Explicit list capacity in 1ms loop
Fix formatting
* Restrict ControllerWindow to show valid controller types
Add selected player name to ControllerWindow title
* ControllerWindow: Fix controller type initial value
NpadDevices: Simplify default battery charge
* Address AcK's comments
Use explicit types and fix formatting
* Remove HashSet for SupportedPlayers
Fixes potential exceptions due to race
* Fix ControllerSupportArg struct packing
Also comes with two revisions of struct for 4/8 players max.
* account: Implement IManagerForApplication calls and IAsyncContext
This implement:
- IManagerForApplication::EnsureIdTokenCacheAsync (accordingly to RE) but the Async task is stubbed.
- IAsyncContext interface (accordingly to RE).
- IManagerForApplication::LoadIdTokenCache (checked with RE, and stubbed).
I've tried some games but now they needs some `sfdnsres` calls, some other boots and crashes with other issues.
Maybe we should disable the connection somewhere to lets the game think we are offline. I have done many attempts, without success, but since the code is here now, it's better than nothing.
(I've cleaned up `using` of IGeneralService too)
Closes#629 and closes#630
* change AccountId
* Fix gdkchan's comments
* use CompletedTask
Changes:
Implement software surround downmixing (fix#796).
Fix a crash when no audio renderer were created when stopping emulation.
NOTE: This PR also disable support of 5.1 surround on the OpenAL backend as we cannot detect if the hardware directly support it. (the downmixing applied by OpenAL on Windows is terribly slow)
* Amadeus: Final Act
This is my requiem, I present to you Amadeus, a complete reimplementation of the Audio Renderer!
This reimplementation is based on my reversing of every version of the audio system module that I carried for the past 10 months.
This supports every revision (at the time of writing REV1 to REV8 included) and all features proposed by the Audio Renderer on real hardware.
Because this component could be used outside an emulation context, and to avoid possible "inspirations" not crediting the project, I decided to license the Ryujinx.Audio.Renderer project under LGPLv3.
- FE3H voices in videos and chapter intro are not present.
- Games that use two audio renderer **at the same time** are probably going to have issues right now **until we rewrite the audio output interface** (Crash Team Racing is the only known game to use two renderer at the same time).
- Persona 5 Scrambler now goes ingame but audio is garbage. This is caused by the fact that the game engine is syncing audio and video in a really aggressive way. This will disappears the day this game run at full speed.
* Make timing more precise when sleeping on Windows
Improve precision to a 1ms resolution on Windows NT based OS.
This is used to avoid having totally erratic timings and unify all
Windows users to the same resolution.
NOTE: This is only active when emulation is running.
* Logger class changes only
Now compile-time checking is possible with the help of Nullable Value
types.
* Misc formatting
* Manual optimizations
PrintGuestLog
PrintGuestStackTrace
Surfaceflinger DequeueBuffer
* Reduce SendVibrationXX log level to Debug
* Add Notice log level
This level is always enabled and used to print system info, etc...
Also, rewrite LogColor to switch expression as colors are static
* Unify unhandled exception event handlers
* Print enabled LogLevels during init
* Re-add App Exit disposes in proper order
nit: switch case spacing
* Revert PrintGuestStackTrace to Info logs due to #1407
PrintGuestStackTrace is now called in some critical error handlers
so revert to old behavior as KThread isn't part of Guest.
* Batch replace Logger statements
* Implement SwKbd GUI
* Relocate UI handler to Emu Context from Config
Also create a common interface for UI handlers in the context and specialize for Gtk
Add basic input length validation in InputDialog
* Add Transfer Memory support to AppletCreator
Read Initial Text for SwKbd using Transfer Memory
* Improve InputDialog widget
Improve length validation
Has extra label to show validition info
Handle potential errors and log them
* Misc improvements
* Improve string validation
* Improve error handling
* Remove tuple in struct
* Address formatting nits
* Add proper Cancel functionality
Also handle GUI errors in UI handler
* Address jD's comments
* Fix _uiHandler init
* Address AcK's comments
* friend: Implement GetPlayHistoryRegistrationKey
This implement IServiceCreator::GetPlayHistoryRegistrationKey call accordingly to RE.
Close#1110
* Fix comments
* Fix guid and comment some codes
* Improve guid casting and remove unused vars
* ns/nim: Stub eShop related calls
As we aren't able to process purchase on the eShop throught the emulator, I have:
- Stub IPurchaseEventManager::SetDefaultDeliveryTarget (with RE check).
- Implement IPurchaseEventManager::GetPurchasedEventReadableHandle (with RE check).
As we can't do any eShop async call throught the emulator, I have:
- Stub IShopServiceAccessServerInterface::CreateServerInterface
- Stub IShopServiceAccessServer::CreateAccessorInterface
- Stub IShopServiceAccessor::IShopServiceAsync
Close#1084 and #1322
* fix handle copy
* Fix align
* Fix readonly event
* Add new structures from official docs, start migrating GPFifo
* Finish migration to new GPFifo processor
* Implement fast constant buffer data upload
* Migrate to new GPFifo class
* XML docs
This implement GetIndirectLayerImageRequiredMemoryInfo call from vi service, accordingly to RE.
Thanks to Thog and gdkchan for helping me to understand some GPU things.
Close#942
* Add multiple calls to am service
This implement/stub some am calls:
- SetAutoSleepDisabled
- IsAutoSleepDisabled
- SetAlbumImageTakenNotificationEnabled
- EnableApplicationCrashReport
- GetPreviousProgramIndex
- NeedsToExitProcess
- RequestForAppletToGetForeground
- GetIndirectLayerConsumerHandle
All checked by RE.
Additionnaly to that, there is some cleanup here and there.
Fix#1387, #1324, #1165, #1163, #1065
* Fix casting
* Thread safe assign
* Initial NVDEC and VIC implementation
* Update FFmpeg.AutoGen to 4.3.0
* Add nvdec dependencies for Windows
* Unify some VP9 structures
* Rename VP9 structure fields
* Improvements to Video API
* XML docs for Common.Memory
* Remove now unused or redundant overloads from MemoryAccessor
* NVDEC UV surface read/write scalar paths
* Add FIXME comments about hacky things/stuff that will need to be fixed in the future
* Cleaned up VP9 memory allocation
* Remove some debug logs
* Rename some VP9 structs
* Remove unused struct
* No need to compile Ryujinx.Graphics.Host1x with unsafe anymore
* Name AsyncWorkQueue threads to make debugging easier
* Make Vp9PictureInfo a ref struct
* LayoutConverter no longer needs the depth argument (broken by rebase)
* Pooling of VP9 buffers, plus fix a memory leak on VP9
* Really wish VS could rename projects properly...
* Address feedback
* Remove using
* Catch OperationCanceledException
* Add licensing informations
* Add THIRDPARTY.md to release too
Co-authored-by: Thog <me@thog.eu>
* Implement Modding Support
* Executables: Rewrite to use contiguous mem and Spans
* Reorder ExeFs, Npdm, ControlData and SaveData calls
After discussion with gdkchan, it was decided it's best to call
LoadExeFs after all other loads are done as it starts the guest process.
* Build RomFs manually instead of Layering FS
Layered FS approach has considerable latency when building the final
romfs. So, we manually replace files in a single romfs instance.
* Add RomFs modding via storage file
* Fix and cleanup MemPatch
* Add dynamically loaded NRO patching
* Support exefs file replacement
* Rewrite ModLoader to use mods-search architecture
* Disable PPTC when exefs patches are detected
Disable PPTC on exefs replacements too
* Rewrite ModLoader, again
* Increased maintainability and matches Atmosphere closely
* Creates base mods structure if it doesn't exist
* Add Exefs partition replacement
* IPSwitch: Fix nsobid parsing
* Move mod logs to new LogClass
* Allow custom suffixes to title dirs again
* Address nits
* Add a per-App "Open Mods Directory" context menu item
Creates the path if not present.
* Normalize tooltips verbiage
* Use LocalStorage and remove unused namespaces
* prepo: Update implementation for 10.x changes
On 10.x, Nintendo changed yet another time the prepo SaveReport &
SaveReportWithUser command ids.
This PR add support for command 10104 & 10105 and update naming of the
old variants to match switchbrew.
* Fix misalign and remove a ToString
* Address jD's comment
* Fix compilation warnings and use new LibHac APIs for executable loading
* Migrate NSO loader to the new reader and fix kip loader
* Fix CS0162 restore
* Remove extra return lines
* Address Moose's comment
* Initial rebased AddOnContent support
* Fix bounds calculation
* Use existing GameCard in VFS per Xpl0itR's suggestion
+ Add dummy IPurchaseEventManager per AcK's suggestion
* Support multiple containers
* Add option to selectively disable addons
* Import tickets from AOC FS
* Load all nsps in base directory automatically
* Revert LoadNsp renaming
Removes conflicts with Mods PR. Not much is lost, old names were fine.
* Address AcK's comments
* Address Thog's comments
Dispose opened nsp files
Fix potential bug by clearing metadata on load
* Stubbed ImportServerPki
* thought it might be nice to name this variable properly
* i really need to name variables better
* Change Var
Co-authored-by: Thog <thog@protonmail.com>
* Change .ReadBytes(5) to IPC send buffer
Co-authored-by: Thog <thog@protonmail.com>
* Add description comment
Co-authored-by: Thog <thog@protonmail.com>
* fix build issue
* Resolve final suggestion
Co-authored-by: Thog <thog@protonmail.com>
* uhh
* it should work now shut up
* aligned variables just look so much nicer :)
* better variable alignment
* aligned
Co-authored-by: Thog <thog@protonmail.com>
* SurfaceFlinger: fix some bugs
This fixes some bugs in the current implementation and make it closer to
the real implementation.
* Fix align of some variables
* pctl: refactoring IParentalControlServiceFactory and IParentalControlService call
Our previous implementation was totally guessed. Now it's implemented according to RE, even if it's stubbed because we will not support Parental Control for now.
* unknownFlag > permissionFlag
* nvdrv: Partially implementation of GetStatus
This implement GetStatus call according to RE.
Since we don't handle tranfert memory on the initialize of the service, it's fine sets fields at 0 for now.
Tested on Undertale.
Fix#635
* Fix struct
The error code was taken from Switchbrew (https://switchbrew.org/wiki/Error_codes)
Even if TimeServiceNotInitialized's "description" is 0, the result "value" of "(0 << ErrorCodeShift) | ModuleId" is 0x74 so it is not the same as "Success" (0)
* am: Implement GetFriendInvitationStorageChannelEvent
This implement GetFriendInvitationStorageChannelEvent according to RE, needed by Streets of Rage 4
* Fix handle name
* add GetNotificationStorageChannelEvent
* Add two error codes to Mii
The two errors added are InvalidDatabaseSignatureValue and InvalidDatabaseEntryCount, which were taken from Switchbrew (https://switchbrew.org/wiki/Error_codes)
* Fix typo
* Remove unnecessary empty line
* Add various result codes to Loader
The error codes were taken from Switchbrew (switchbrew.org/wiki/Error_codes)
For the last 9 errors, Switchbrew says: ACID/ACI0 don't match for descriptor (descriptor)
* Fix typo
* Implement a new physical memory manager and replace DeviceMemory
* Proper generic constraints
* Fix debug build
* Add memory tests
* New CPU memory manager and general code cleanup
* Remove host memory management from CPU project, use Ryujinx.Memory instead
* Fix tests
* Document exceptions on MemoryBlock
* Fix leak on unix memory allocation
* Proper disposal of some objects on tests
* Fix JitCache not being set as initialized
* GetRef without checks for 8-bits and 16-bits CAS
* Add MemoryBlock destructor
* Throw in separate method to improve codegen
* Address PR feedback
* QueryModified improvements
* Fix memory write tracking not marking all pages as modified in some cases
* Simplify MarkRegionAsModified
* Remove XML doc for ghost param
* Add back optimization to avoid useless buffer updates
* Add Ryujinx.Cpu project, move MemoryManager there and remove MemoryBlockWrapper
* Some nits
* Do not perform address translation when size is 0
* Address PR feedback and format NativeInterface class
* Remove ghost parameter description
* Update Ryujinx.Cpu to .NET Core 3.1
* Address PR feedback
* Fix build
* Return a well defined value for GetPhysicalAddress with invalid VA, and do not return unmapped ranges as modified
* Typo
* Add various error codes to BCAT
The error codes were taken from Switchbrew (switchbrew.org/wiki/Error_codes)
As for InternetRequestDenied, it seems that this error is common for multiple services like Account for example
I already added this error code in Account in PR #1182
* Add some results codes from Libhac and keep names consistent
* nvservice: add a lock to NvHostEvent
* Disable surface flinger release fence and readd infinite timeout
* FenceAction: Add a timeout of 1 seconds as this shouldn't wait forever anyuway
* surfaceflinger: remove leftovers from the release fence
* Don't allow infinite timeout on syncpoint while printing all timeout for better debugging
InternetRequestDenied (I can't find a better name) was taken from Switchbrew (switchbrew.org/wiki/Error_codes)
Regarding this error, SwitchBrew notes: "IsAnyInternetRequestAccepted with the output from GetClientId returned false."
* nvservices: mitigate abort with heavy load on the GPU processing thread.
This should fix Mario Tennis and LM3 regressions with syncpoints.
NOTE: Mario Tennis seems to have another issue related to the texture
cache that happens randomly when starting a match.
PS: Also add a debug logger for all known ioctl call to facilitate
debugging and add a missing UpdateMin in EventSignal.
* Address LDj3SNuD's comment
* Address gdkchan's comment