2020-05-03 02:00:53 +00:00
using Gtk ;
2022-01-12 11:22:19 +00:00
using LibHac.Tools.FsSystem ;
2021-02-26 00:11:56 +00:00
using Ryujinx.Audio.Backends.OpenAL ;
2021-05-05 21:37:09 +00:00
using Ryujinx.Audio.Backends.SDL2 ;
2021-02-26 00:11:56 +00:00
using Ryujinx.Audio.Backends.SoundIo ;
2020-08-02 14:41:24 +00:00
using Ryujinx.Common.Configuration ;
2020-07-03 23:16:49 +00:00
using Ryujinx.Common.Configuration.Hid ;
Add a Multithreading layer for the GAL, multi-thread shader compilation at runtime (#2501)
* Initial Implementation
About as fast as nvidia GL multithreading, can be improved with faster command queuing.
* Struct based command list
Speeds up a bit. Still a lot of time lost to resource copy.
* Do shader init while the render thread is active.
* Introduce circular span pool V1
Ideally should be able to use structs instead of references for storing these spans on commands. Will try that next.
* Refactor SpanRef some more
Use a struct to represent SpanRef, rather than a reference.
* Flush buffers on background thread
* Use a span for UpdateRenderScale.
Much faster than copying the array.
* Calculate command size using reflection
* WIP parallel shaders
* Some minor optimisation
* Only 2 max refs per command now.
The command with 3 refs is gone. :relieved:
* Don't cast on the GPU side
* Remove redundant casts, force sync on window present
* Fix Shader Cache
* Fix host shader save.
* Fixup to work with new renderer stuff
* Make command Run static, use array of delegates as lookup
Profile says this takes less time than the previous way.
* Bring up to date
* Add settings toggle. Fix Muiltithreading Off mode.
* Fix warning.
* Release tracking lock for flushes
* Fix Conditional Render fast path with threaded gal
* Make handle iteration safe when releasing the lock
This is mostly temporary.
* Attempt to set backend threading on driver
Only really works on nvidia before launching a game.
* Fix race condition with BufferModifiedRangeList, exceptions in tracking actions
* Update buffer set commands
* Some cleanup
* Only use stutter workaround when using opengl renderer non-threaded
* Add host-conditional reservation of counter events
There has always been the possibility that conditional rendering could use a query object just as it is disposed by the counter queue. This change makes it so that when the host decides to use host conditional rendering, the query object is reserved so that it cannot be deleted. Counter events can optionally start reserved, as the threaded implementation can reserve them before the backend creates them, and there would otherwise be a short amount of time where the counter queue could dispose the event before a call to reserve it could be made.
* Address Feedback
* Make counter flush tracked again.
Hopefully does not cause any issues this time.
* Wait for FlushTo on the main queue thread.
Currently assumes only one thread will want to FlushTo (in this case, the GPU thread)
* Add SDL2 headless integration
* Add HLE macro commands.
Co-authored-by: Mary <mary@mary.zone>
2021-08-26 22:31:29 +00:00
using Ryujinx.Common.GraphicsDriver ;
2020-12-01 20:44:04 +00:00
using Ryujinx.Configuration ;
2020-05-03 02:00:53 +00:00
using Ryujinx.Configuration.System ;
using Ryujinx.HLE.FileSystem ;
2020-12-01 20:44:04 +00:00
using Ryujinx.HLE.HOS.Services.Time.TimeZone ;
2021-01-08 08:14:13 +00:00
using Ryujinx.Ui.Helper ;
Add a Multithreading layer for the GAL, multi-thread shader compilation at runtime (#2501)
* Initial Implementation
About as fast as nvidia GL multithreading, can be improved with faster command queuing.
* Struct based command list
Speeds up a bit. Still a lot of time lost to resource copy.
* Do shader init while the render thread is active.
* Introduce circular span pool V1
Ideally should be able to use structs instead of references for storing these spans on commands. Will try that next.
* Refactor SpanRef some more
Use a struct to represent SpanRef, rather than a reference.
* Flush buffers on background thread
* Use a span for UpdateRenderScale.
Much faster than copying the array.
* Calculate command size using reflection
* WIP parallel shaders
* Some minor optimisation
* Only 2 max refs per command now.
The command with 3 refs is gone. :relieved:
* Don't cast on the GPU side
* Remove redundant casts, force sync on window present
* Fix Shader Cache
* Fix host shader save.
* Fixup to work with new renderer stuff
* Make command Run static, use array of delegates as lookup
Profile says this takes less time than the previous way.
* Bring up to date
* Add settings toggle. Fix Muiltithreading Off mode.
* Fix warning.
* Release tracking lock for flushes
* Fix Conditional Render fast path with threaded gal
* Make handle iteration safe when releasing the lock
This is mostly temporary.
* Attempt to set backend threading on driver
Only really works on nvidia before launching a game.
* Fix race condition with BufferModifiedRangeList, exceptions in tracking actions
* Update buffer set commands
* Some cleanup
* Only use stutter workaround when using opengl renderer non-threaded
* Add host-conditional reservation of counter events
There has always been the possibility that conditional rendering could use a query object just as it is disposed by the counter queue. This change makes it so that when the host decides to use host conditional rendering, the query object is reserved so that it cannot be deleted. Counter events can optionally start reserved, as the threaded implementation can reserve them before the backend creates them, and there would otherwise be a short amount of time where the counter queue could dispose the event before a call to reserve it could be made.
* Address Feedback
* Make counter flush tracked again.
Hopefully does not cause any issues this time.
* Wait for FlushTo on the main queue thread.
Currently assumes only one thread will want to FlushTo (in this case, the GPU thread)
* Add SDL2 headless integration
* Add HLE macro commands.
Co-authored-by: Mary <mary@mary.zone>
2021-08-26 22:31:29 +00:00
using Ryujinx.Ui.Widgets ;
2020-05-03 02:00:53 +00:00
using System ;
using System.Collections.Generic ;
2020-12-01 20:44:04 +00:00
using System.Globalization ;
2020-05-03 02:00:53 +00:00
using System.IO ;
2021-01-18 20:33:58 +00:00
using System.Reflection ;
2020-07-21 03:33:23 +00:00
using System.Threading.Tasks ;
2020-07-03 23:16:49 +00:00
2020-05-03 02:00:53 +00:00
using GUI = Gtk . Builder . ObjectAttribute ;
2021-01-08 08:14:13 +00:00
namespace Ryujinx.Ui.Windows
2020-05-03 02:00:53 +00:00
{
public class SettingsWindow : Window
{
2021-01-08 08:14:13 +00:00
private readonly MainWindow _parent ;
2020-08-09 20:46:06 +00:00
private readonly ListStore _gameDirsBoxStore ;
private readonly ListStore _audioBackendStore ;
private readonly TimeZoneContentManager _timeZoneContentManager ;
private readonly HashSet < string > _validTzRegions ;
2020-05-03 02:00:53 +00:00
2021-12-23 16:33:56 +00:00
private long _systemTimeOffset ;
private float _previousVolumeLevel ;
2020-05-03 02:00:53 +00:00
#pragma warning disable CS0649 , IDE0044
2022-02-18 00:08:07 +00:00
[GUI] CheckButton _traceLogToggle ;
2020-07-21 04:14:42 +00:00
[GUI] CheckButton _errorLogToggle ;
[GUI] CheckButton _warningLogToggle ;
[GUI] CheckButton _infoLogToggle ;
[GUI] CheckButton _stubLogToggle ;
[GUI] CheckButton _debugLogToggle ;
[GUI] CheckButton _fileLogToggle ;
[GUI] CheckButton _guestLogToggle ;
[GUI] CheckButton _fsAccessLogToggle ;
[GUI] Adjustment _fsLogSpinAdjustment ;
2020-08-02 14:41:24 +00:00
[GUI] ComboBoxText _graphicsDebugLevel ;
2020-07-21 04:14:42 +00:00
[GUI] CheckButton _dockedModeToggle ;
[GUI] CheckButton _discordToggle ;
2020-09-29 20:05:25 +00:00
[GUI] CheckButton _checkUpdatesToggle ;
2021-01-14 22:30:52 +00:00
[GUI] CheckButton _showConfirmExitToggle ;
2021-02-15 21:48:21 +00:00
[GUI] CheckButton _hideCursorOnIdleToggle ;
2020-07-21 04:14:42 +00:00
[GUI] CheckButton _vSyncToggle ;
2020-11-12 23:15:34 +00:00
[GUI] CheckButton _shaderCacheToggle ;
2020-07-21 04:14:42 +00:00
[GUI] CheckButton _ptcToggle ;
2021-12-26 14:17:13 +00:00
[GUI] CheckButton _internetToggle ;
2020-07-21 04:14:42 +00:00
[GUI] CheckButton _fsicToggle ;
POWER - Performance Optimizations With Extensive Ramifications (#2286)
* Refactoring of KMemoryManager class
* Replace some trivial uses of DRAM address with VA
* Get rid of GetDramAddressFromVa
* Abstracting more operations on derived page table class
* Run auto-format on KPageTableBase
* Managed to make TryConvertVaToPa private, few uses remains now
* Implement guest physical pages ref counting, remove manual freeing
* Make DoMmuOperation private and call new abstract methods only from the base class
* Pass pages count rather than size on Map/UnmapMemory
* Change memory managers to take host pointers
* Fix a guest memory leak and simplify KPageTable
* Expose new methods for host range query and mapping
* Some refactoring of MapPagesFromClientProcess to allow proper page ref counting and mapping without KPageLists
* Remove more uses of AddVaRangeToPageList, now only one remains (shared memory page checking)
* Add a SharedMemoryStorage class, will be useful for host mapping
* Sayonara AddVaRangeToPageList, you served us well
* Start to implement host memory mapping (WIP)
* Support memory tracking through host exception handling
* Fix some access violations from HLE service guest memory access and CPU
* Fix memory tracking
* Fix mapping list bugs, including a race and a error adding mapping ranges
* Simple page table for memory tracking
* Simple "volatile" region handle mode
* Update UBOs directly (experimental, rough)
* Fix the overlap check
* Only set non-modified buffers as volatile
* Fix some memory tracking issues
* Fix possible race in MapBufferFromClientProcess (block list updates were not locked)
* Write uniform update to memory immediately, only defer the buffer set.
* Fix some memory tracking issues
* Pass correct pages count on shared memory unmap
* Armeilleure Signal Handler v1 + Unix changes
Unix currently behaves like windows, rather than remapping physical
* Actually check if the host platform is unix
* Fix decommit on linux.
* Implement windows 10 placeholder shared memory, fix a buffer issue.
* Make PTC version something that will never match with master
* Remove testing variable for block count
* Add reference count for memory manager, fix dispose
Can still deadlock with OpenAL
* Add address validation, use page table for mapped check, add docs
Might clean up the page table traversing routines.
* Implement batched mapping/tracking.
* Move documentation, fix tests.
* Cleanup uniform buffer update stuff.
* Remove unnecessary assignment.
* Add unsafe host mapped memory switch
On by default. Would be good to turn this off for untrusted code (homebrew, exefs mods) and give the user the option to turn it on manually, though that requires some UI work.
* Remove C# exception handlers
They have issues due to current .NET limitations, so the meilleure one fully replaces them for now.
* Fix MapPhysicalMemory on the software MemoryManager.
* Null check for GetHostAddress, docs
* Add configuration for setting memory manager mode (not in UI yet)
* Add config to UI
* Fix type mismatch on Unix signal handler code emit
* Fix 6GB DRAM mode.
The size can be greater than `uint.MaxValue` when the DRAM is >4GB.
* Address some feedback.
* More detailed error if backing memory cannot be mapped.
* SetLastError on all OS functions for consistency
* Force pages dirty with UBO update instead of setting them directly.
Seems to be much faster across a few games. Need retesting.
* Rebase, configuration rework, fix mem tracking regression
* Fix race in FreePages
* Set memory managers null after decrementing ref count
* Remove readonly keyword, as this is now modified.
* Use a local variable for the signal handler rather than a register.
* Fix bug with buffer resize, and index/uniform buffer binding.
Should fix flickering in games.
* Add InvalidAccessHandler to MemoryTracking
Doesn't do anything yet
* Call invalid access handler on unmapped read/write.
Same rules as the regular memory manager.
* Make unsafe mapped memory its own MemoryManagerType
* Move FlushUboDirty into UpdateState.
* Buffer dirty cache, rather than ubo cache
Much cleaner, may be reusable for Inline2Memory updates.
* This doesn't return anything anymore.
* Add sigaction remove methods, correct a few function signatures.
* Return empty list of physical regions for size 0.
* Also on AddressSpaceManager
Co-authored-by: gdkchan <gab.dark.100@gmail.com>
2021-05-24 20:52:44 +00:00
[GUI] RadioButton _mmSoftware ;
[GUI] RadioButton _mmHost ;
[GUI] RadioButton _mmHostUnsafe ;
2021-04-04 12:06:59 +00:00
[GUI] CheckButton _expandRamToggle ;
2020-07-21 04:14:42 +00:00
[GUI] CheckButton _ignoreToggle ;
[GUI] CheckButton _directKeyboardAccess ;
2021-06-24 00:09:08 +00:00
[GUI] CheckButton _directMouseAccess ;
2020-07-21 04:14:42 +00:00
[GUI] ComboBoxText _systemLanguageSelect ;
[GUI] ComboBoxText _systemRegionSelect ;
[GUI] Entry _systemTimeZoneEntry ;
[GUI] EntryCompletion _systemTimeZoneCompletion ;
2020-08-09 20:46:06 +00:00
[GUI] Box _audioBackendBox ;
[GUI] ComboBox _audioBackendSelect ;
2021-12-23 16:33:56 +00:00
[GUI] Label _audioVolumeLabel ;
[GUI] Scale _audioVolumeSlider ;
2020-07-21 04:14:42 +00:00
[GUI] SpinButton _systemTimeYearSpin ;
[GUI] SpinButton _systemTimeMonthSpin ;
[GUI] SpinButton _systemTimeDaySpin ;
[GUI] SpinButton _systemTimeHourSpin ;
[GUI] SpinButton _systemTimeMinuteSpin ;
[GUI] Adjustment _systemTimeYearSpinAdjustment ;
[GUI] Adjustment _systemTimeMonthSpinAdjustment ;
[GUI] Adjustment _systemTimeDaySpinAdjustment ;
[GUI] Adjustment _systemTimeHourSpinAdjustment ;
[GUI] Adjustment _systemTimeMinuteSpinAdjustment ;
[GUI] CheckButton _custThemeToggle ;
[GUI] Entry _custThemePath ;
[GUI] ToggleButton _browseThemePath ;
[GUI] Label _custThemePathLabel ;
[GUI] TreeView _gameDirsBox ;
[GUI] Entry _addGameDirBox ;
Add a Multithreading layer for the GAL, multi-thread shader compilation at runtime (#2501)
* Initial Implementation
About as fast as nvidia GL multithreading, can be improved with faster command queuing.
* Struct based command list
Speeds up a bit. Still a lot of time lost to resource copy.
* Do shader init while the render thread is active.
* Introduce circular span pool V1
Ideally should be able to use structs instead of references for storing these spans on commands. Will try that next.
* Refactor SpanRef some more
Use a struct to represent SpanRef, rather than a reference.
* Flush buffers on background thread
* Use a span for UpdateRenderScale.
Much faster than copying the array.
* Calculate command size using reflection
* WIP parallel shaders
* Some minor optimisation
* Only 2 max refs per command now.
The command with 3 refs is gone. :relieved:
* Don't cast on the GPU side
* Remove redundant casts, force sync on window present
* Fix Shader Cache
* Fix host shader save.
* Fixup to work with new renderer stuff
* Make command Run static, use array of delegates as lookup
Profile says this takes less time than the previous way.
* Bring up to date
* Add settings toggle. Fix Muiltithreading Off mode.
* Fix warning.
* Release tracking lock for flushes
* Fix Conditional Render fast path with threaded gal
* Make handle iteration safe when releasing the lock
This is mostly temporary.
* Attempt to set backend threading on driver
Only really works on nvidia before launching a game.
* Fix race condition with BufferModifiedRangeList, exceptions in tracking actions
* Update buffer set commands
* Some cleanup
* Only use stutter workaround when using opengl renderer non-threaded
* Add host-conditional reservation of counter events
There has always been the possibility that conditional rendering could use a query object just as it is disposed by the counter queue. This change makes it so that when the host decides to use host conditional rendering, the query object is reserved so that it cannot be deleted. Counter events can optionally start reserved, as the threaded implementation can reserve them before the backend creates them, and there would otherwise be a short amount of time where the counter queue could dispose the event before a call to reserve it could be made.
* Address Feedback
* Make counter flush tracked again.
Hopefully does not cause any issues this time.
* Wait for FlushTo on the main queue thread.
Currently assumes only one thread will want to FlushTo (in this case, the GPU thread)
* Add SDL2 headless integration
* Add HLE macro commands.
Co-authored-by: Mary <mary@mary.zone>
2021-08-26 22:31:29 +00:00
[GUI] ComboBoxText _galThreading ;
2020-07-21 04:14:42 +00:00
[GUI] Entry _graphicsShadersDumpPath ;
[GUI] ComboBoxText _anisotropy ;
2020-12-16 02:19:07 +00:00
[GUI] ComboBoxText _aspectRatio ;
2020-07-21 04:14:42 +00:00
[GUI] ComboBoxText _resScaleCombo ;
[GUI] Entry _resScaleText ;
[GUI] ToggleButton _configureController1 ;
[GUI] ToggleButton _configureController2 ;
[GUI] ToggleButton _configureController3 ;
[GUI] ToggleButton _configureController4 ;
[GUI] ToggleButton _configureController5 ;
[GUI] ToggleButton _configureController6 ;
[GUI] ToggleButton _configureController7 ;
[GUI] ToggleButton _configureController8 ;
[GUI] ToggleButton _configureControllerH ;
2020-09-29 21:32:42 +00:00
2020-05-03 02:00:53 +00:00
#pragma warning restore CS0649 , IDE0044
2021-01-08 08:14:13 +00:00
public SettingsWindow ( MainWindow parent , VirtualFileSystem virtualFileSystem , HLE . FileSystem . Content . ContentManager contentManager ) : this ( parent , new Builder ( "Ryujinx.Ui.Windows.SettingsWindow.glade" ) , virtualFileSystem , contentManager ) { }
2020-05-03 02:00:53 +00:00
2021-01-08 08:14:13 +00:00
private SettingsWindow ( MainWindow parent , Builder builder , VirtualFileSystem virtualFileSystem , HLE . FileSystem . Content . ContentManager contentManager ) : base ( builder . GetObject ( "_settingsWin" ) . Handle )
2020-05-03 02:00:53 +00:00
{
2021-01-18 20:33:58 +00:00
Icon = new Gdk . Pixbuf ( Assembly . GetExecutingAssembly ( ) , "Ryujinx.Ui.Resources.Logo_Ryujinx.png" ) ;
2021-01-08 08:14:13 +00:00
_parent = parent ;
2020-05-03 02:00:53 +00:00
2021-01-08 08:14:13 +00:00
builder . Autoconnect ( this ) ;
2020-05-03 02:00:53 +00:00
2020-07-21 04:14:42 +00:00
_timeZoneContentManager = new TimeZoneContentManager ( ) ;
2022-01-12 11:22:19 +00:00
_timeZoneContentManager . InitializeInstance ( virtualFileSystem , contentManager , IntegrityCheckLevel . None ) ;
2020-07-21 04:14:42 +00:00
_validTzRegions = new HashSet < string > ( _timeZoneContentManager . LocationNameCache . Length , StringComparer . Ordinal ) ; // Zone regions are identifiers. Must match exactly.
2021-01-08 08:14:13 +00:00
// Bind Events.
_configureController1 . Pressed + = ( sender , args ) = > ConfigureController_Pressed ( sender , PlayerIndex . Player1 ) ;
_configureController2 . Pressed + = ( sender , args ) = > ConfigureController_Pressed ( sender , PlayerIndex . Player2 ) ;
_configureController3 . Pressed + = ( sender , args ) = > ConfigureController_Pressed ( sender , PlayerIndex . Player3 ) ;
_configureController4 . Pressed + = ( sender , args ) = > ConfigureController_Pressed ( sender , PlayerIndex . Player4 ) ;
_configureController5 . Pressed + = ( sender , args ) = > ConfigureController_Pressed ( sender , PlayerIndex . Player5 ) ;
_configureController6 . Pressed + = ( sender , args ) = > ConfigureController_Pressed ( sender , PlayerIndex . Player6 ) ;
_configureController7 . Pressed + = ( sender , args ) = > ConfigureController_Pressed ( sender , PlayerIndex . Player7 ) ;
_configureController8 . Pressed + = ( sender , args ) = > ConfigureController_Pressed ( sender , PlayerIndex . Player8 ) ;
_configureControllerH . Pressed + = ( sender , args ) = > ConfigureController_Pressed ( sender , PlayerIndex . Handheld ) ;
2020-07-21 04:14:42 +00:00
_systemTimeZoneEntry . FocusOutEvent + = TimeZoneEntry_FocusOut ;
2020-05-03 02:00:53 +00:00
2020-07-07 02:41:07 +00:00
_resScaleCombo . Changed + = ( sender , args ) = > _resScaleText . Visible = _resScaleCombo . ActiveId = = "-1" ;
Add a Multithreading layer for the GAL, multi-thread shader compilation at runtime (#2501)
* Initial Implementation
About as fast as nvidia GL multithreading, can be improved with faster command queuing.
* Struct based command list
Speeds up a bit. Still a lot of time lost to resource copy.
* Do shader init while the render thread is active.
* Introduce circular span pool V1
Ideally should be able to use structs instead of references for storing these spans on commands. Will try that next.
* Refactor SpanRef some more
Use a struct to represent SpanRef, rather than a reference.
* Flush buffers on background thread
* Use a span for UpdateRenderScale.
Much faster than copying the array.
* Calculate command size using reflection
* WIP parallel shaders
* Some minor optimisation
* Only 2 max refs per command now.
The command with 3 refs is gone. :relieved:
* Don't cast on the GPU side
* Remove redundant casts, force sync on window present
* Fix Shader Cache
* Fix host shader save.
* Fixup to work with new renderer stuff
* Make command Run static, use array of delegates as lookup
Profile says this takes less time than the previous way.
* Bring up to date
* Add settings toggle. Fix Muiltithreading Off mode.
* Fix warning.
* Release tracking lock for flushes
* Fix Conditional Render fast path with threaded gal
* Make handle iteration safe when releasing the lock
This is mostly temporary.
* Attempt to set backend threading on driver
Only really works on nvidia before launching a game.
* Fix race condition with BufferModifiedRangeList, exceptions in tracking actions
* Update buffer set commands
* Some cleanup
* Only use stutter workaround when using opengl renderer non-threaded
* Add host-conditional reservation of counter events
There has always been the possibility that conditional rendering could use a query object just as it is disposed by the counter queue. This change makes it so that when the host decides to use host conditional rendering, the query object is reserved so that it cannot be deleted. Counter events can optionally start reserved, as the threaded implementation can reserve them before the backend creates them, and there would otherwise be a short amount of time where the counter queue could dispose the event before a call to reserve it could be made.
* Address Feedback
* Make counter flush tracked again.
Hopefully does not cause any issues this time.
* Wait for FlushTo on the main queue thread.
Currently assumes only one thread will want to FlushTo (in this case, the GPU thread)
* Add SDL2 headless integration
* Add HLE macro commands.
Co-authored-by: Mary <mary@mary.zone>
2021-08-26 22:31:29 +00:00
_galThreading . Changed + = ( sender , args ) = >
{
if ( _galThreading . ActiveId ! = ConfigurationState . Instance . Graphics . BackendThreading . Value . ToString ( ) )
{
GtkDialog . CreateInfoDialog ( "Warning - Backend Threading" , "Ryujinx must be restarted after changing this option for it to apply fully. Depending on your platform, you may need to manually disable your driver's own multithreading when using Ryujinx's." ) ;
}
} ;
2020-07-07 02:41:07 +00:00
2021-01-08 08:14:13 +00:00
// Setup Currents.
2022-02-18 00:08:07 +00:00
if ( ConfigurationState . Instance . Logger . EnableTrace )
{
_traceLogToggle . Click ( ) ;
}
2020-05-03 02:00:53 +00:00
if ( ConfigurationState . Instance . Logger . EnableFileLog )
{
_fileLogToggle . Click ( ) ;
}
if ( ConfigurationState . Instance . Logger . EnableError )
{
_errorLogToggle . Click ( ) ;
}
if ( ConfigurationState . Instance . Logger . EnableWarn )
{
_warningLogToggle . Click ( ) ;
}
if ( ConfigurationState . Instance . Logger . EnableInfo )
{
_infoLogToggle . Click ( ) ;
}
if ( ConfigurationState . Instance . Logger . EnableStub )
{
_stubLogToggle . Click ( ) ;
}
if ( ConfigurationState . Instance . Logger . EnableDebug )
{
_debugLogToggle . Click ( ) ;
}
if ( ConfigurationState . Instance . Logger . EnableGuest )
{
_guestLogToggle . Click ( ) ;
}
if ( ConfigurationState . Instance . Logger . EnableFsAccessLog )
{
_fsAccessLogToggle . Click ( ) ;
}
2022-02-13 13:50:07 +00:00
foreach ( GraphicsDebugLevel level in Enum . GetValues < GraphicsDebugLevel > ( ) )
2020-08-02 14:41:24 +00:00
{
_graphicsDebugLevel . Append ( level . ToString ( ) , level . ToString ( ) ) ;
}
_graphicsDebugLevel . SetActiveId ( ConfigurationState . Instance . Logger . GraphicsDebugLevel . Value . ToString ( ) ) ;
2020-05-03 02:00:53 +00:00
if ( ConfigurationState . Instance . System . EnableDockedMode )
{
_dockedModeToggle . Click ( ) ;
}
if ( ConfigurationState . Instance . EnableDiscordIntegration )
{
_discordToggle . Click ( ) ;
}
2020-09-29 20:05:25 +00:00
if ( ConfigurationState . Instance . CheckUpdatesOnStart )
{
_checkUpdatesToggle . Click ( ) ;
}
2021-01-14 22:30:52 +00:00
if ( ConfigurationState . Instance . ShowConfirmExit )
{
_showConfirmExitToggle . Click ( ) ;
}
2021-02-15 21:48:21 +00:00
if ( ConfigurationState . Instance . HideCursorOnIdle )
{
_hideCursorOnIdleToggle . Click ( ) ;
}
2020-05-03 02:00:53 +00:00
if ( ConfigurationState . Instance . Graphics . EnableVsync )
{
_vSyncToggle . Click ( ) ;
}
2020-11-12 23:15:34 +00:00
if ( ConfigurationState . Instance . Graphics . EnableShaderCache )
{
_shaderCacheToggle . Click ( ) ;
}
2020-06-16 18:28:02 +00:00
if ( ConfigurationState . Instance . System . EnablePtc )
{
_ptcToggle . Click ( ) ;
}
2021-12-26 14:17:13 +00:00
if ( ConfigurationState . Instance . System . EnableInternetAccess )
{
_internetToggle . Click ( ) ;
}
2020-05-03 02:00:53 +00:00
if ( ConfigurationState . Instance . System . EnableFsIntegrityChecks )
{
_fsicToggle . Click ( ) ;
}
POWER - Performance Optimizations With Extensive Ramifications (#2286)
* Refactoring of KMemoryManager class
* Replace some trivial uses of DRAM address with VA
* Get rid of GetDramAddressFromVa
* Abstracting more operations on derived page table class
* Run auto-format on KPageTableBase
* Managed to make TryConvertVaToPa private, few uses remains now
* Implement guest physical pages ref counting, remove manual freeing
* Make DoMmuOperation private and call new abstract methods only from the base class
* Pass pages count rather than size on Map/UnmapMemory
* Change memory managers to take host pointers
* Fix a guest memory leak and simplify KPageTable
* Expose new methods for host range query and mapping
* Some refactoring of MapPagesFromClientProcess to allow proper page ref counting and mapping without KPageLists
* Remove more uses of AddVaRangeToPageList, now only one remains (shared memory page checking)
* Add a SharedMemoryStorage class, will be useful for host mapping
* Sayonara AddVaRangeToPageList, you served us well
* Start to implement host memory mapping (WIP)
* Support memory tracking through host exception handling
* Fix some access violations from HLE service guest memory access and CPU
* Fix memory tracking
* Fix mapping list bugs, including a race and a error adding mapping ranges
* Simple page table for memory tracking
* Simple "volatile" region handle mode
* Update UBOs directly (experimental, rough)
* Fix the overlap check
* Only set non-modified buffers as volatile
* Fix some memory tracking issues
* Fix possible race in MapBufferFromClientProcess (block list updates were not locked)
* Write uniform update to memory immediately, only defer the buffer set.
* Fix some memory tracking issues
* Pass correct pages count on shared memory unmap
* Armeilleure Signal Handler v1 + Unix changes
Unix currently behaves like windows, rather than remapping physical
* Actually check if the host platform is unix
* Fix decommit on linux.
* Implement windows 10 placeholder shared memory, fix a buffer issue.
* Make PTC version something that will never match with master
* Remove testing variable for block count
* Add reference count for memory manager, fix dispose
Can still deadlock with OpenAL
* Add address validation, use page table for mapped check, add docs
Might clean up the page table traversing routines.
* Implement batched mapping/tracking.
* Move documentation, fix tests.
* Cleanup uniform buffer update stuff.
* Remove unnecessary assignment.
* Add unsafe host mapped memory switch
On by default. Would be good to turn this off for untrusted code (homebrew, exefs mods) and give the user the option to turn it on manually, though that requires some UI work.
* Remove C# exception handlers
They have issues due to current .NET limitations, so the meilleure one fully replaces them for now.
* Fix MapPhysicalMemory on the software MemoryManager.
* Null check for GetHostAddress, docs
* Add configuration for setting memory manager mode (not in UI yet)
* Add config to UI
* Fix type mismatch on Unix signal handler code emit
* Fix 6GB DRAM mode.
The size can be greater than `uint.MaxValue` when the DRAM is >4GB.
* Address some feedback.
* More detailed error if backing memory cannot be mapped.
* SetLastError on all OS functions for consistency
* Force pages dirty with UBO update instead of setting them directly.
Seems to be much faster across a few games. Need retesting.
* Rebase, configuration rework, fix mem tracking regression
* Fix race in FreePages
* Set memory managers null after decrementing ref count
* Remove readonly keyword, as this is now modified.
* Use a local variable for the signal handler rather than a register.
* Fix bug with buffer resize, and index/uniform buffer binding.
Should fix flickering in games.
* Add InvalidAccessHandler to MemoryTracking
Doesn't do anything yet
* Call invalid access handler on unmapped read/write.
Same rules as the regular memory manager.
* Make unsafe mapped memory its own MemoryManagerType
* Move FlushUboDirty into UpdateState.
* Buffer dirty cache, rather than ubo cache
Much cleaner, may be reusable for Inline2Memory updates.
* This doesn't return anything anymore.
* Add sigaction remove methods, correct a few function signatures.
* Return empty list of physical regions for size 0.
* Also on AddressSpaceManager
Co-authored-by: gdkchan <gab.dark.100@gmail.com>
2021-05-24 20:52:44 +00:00
switch ( ConfigurationState . Instance . System . MemoryManagerMode . Value )
{
case MemoryManagerMode . SoftwarePageTable :
_mmSoftware . Click ( ) ;
break ;
case MemoryManagerMode . HostMapped :
_mmHost . Click ( ) ;
break ;
case MemoryManagerMode . HostMappedUnsafe :
_mmHostUnsafe . Click ( ) ;
break ;
}
2021-04-04 12:06:59 +00:00
if ( ConfigurationState . Instance . System . ExpandRam )
{
_expandRamToggle . Click ( ) ;
}
2020-05-03 02:00:53 +00:00
if ( ConfigurationState . Instance . System . IgnoreMissingServices )
{
_ignoreToggle . Click ( ) ;
}
if ( ConfigurationState . Instance . Hid . EnableKeyboard )
{
_directKeyboardAccess . Click ( ) ;
}
2021-06-24 00:09:08 +00:00
if ( ConfigurationState . Instance . Hid . EnableMouse )
{
_directMouseAccess . Click ( ) ;
}
2020-05-03 02:00:53 +00:00
if ( ConfigurationState . Instance . Ui . EnableCustomTheme )
{
_custThemeToggle . Click ( ) ;
}
2020-07-21 04:14:42 +00:00
// Custom EntryCompletion Columns. If added to glade, need to override more signals
ListStore tzList = new ListStore ( typeof ( string ) , typeof ( string ) , typeof ( string ) ) ;
_systemTimeZoneCompletion . Model = tzList ;
CellRendererText offsetCol = new CellRendererText ( ) ;
CellRendererText abbrevCol = new CellRendererText ( ) ;
_systemTimeZoneCompletion . PackStart ( offsetCol , false ) ;
_systemTimeZoneCompletion . AddAttribute ( offsetCol , "text" , 0 ) ;
_systemTimeZoneCompletion . TextColumn = 1 ; // Regions Column
_systemTimeZoneCompletion . PackStart ( abbrevCol , false ) ;
_systemTimeZoneCompletion . AddAttribute ( abbrevCol , "text" , 2 ) ;
int maxLocationLength = 0 ;
foreach ( var ( offset , location , abbr ) in _timeZoneContentManager . ParseTzOffsets ( ) )
{
var hours = Math . DivRem ( offset , 3600 , out int seconds ) ;
var minutes = Math . Abs ( seconds ) / 60 ;
var abbr2 = ( abbr . StartsWith ( '+' ) | | abbr . StartsWith ( '-' ) ) ? string . Empty : abbr ;
tzList . AppendValues ( $"UTC{hours:+0#;-0#;+00}:{minutes:D2} " , location , abbr2 ) ;
_validTzRegions . Add ( location ) ;
maxLocationLength = Math . Max ( maxLocationLength , location . Length ) ;
}
_systemTimeZoneEntry . WidthChars = Math . Max ( 20 , maxLocationLength + 1 ) ; // Ensure minimum Entry width
2021-05-16 15:12:14 +00:00
_systemTimeZoneEntry . Text = _timeZoneContentManager . SanityCheckDeviceLocationName ( ConfigurationState . Instance . System . TimeZone ) ;
2020-07-21 04:14:42 +00:00
_systemTimeZoneCompletion . MatchFunc = TimeZoneMatchFunc ;
2020-05-03 02:00:53 +00:00
_systemLanguageSelect . SetActiveId ( ConfigurationState . Instance . System . Language . Value . ToString ( ) ) ;
_systemRegionSelect . SetActiveId ( ConfigurationState . Instance . System . Region . Value . ToString ( ) ) ;
Add a Multithreading layer for the GAL, multi-thread shader compilation at runtime (#2501)
* Initial Implementation
About as fast as nvidia GL multithreading, can be improved with faster command queuing.
* Struct based command list
Speeds up a bit. Still a lot of time lost to resource copy.
* Do shader init while the render thread is active.
* Introduce circular span pool V1
Ideally should be able to use structs instead of references for storing these spans on commands. Will try that next.
* Refactor SpanRef some more
Use a struct to represent SpanRef, rather than a reference.
* Flush buffers on background thread
* Use a span for UpdateRenderScale.
Much faster than copying the array.
* Calculate command size using reflection
* WIP parallel shaders
* Some minor optimisation
* Only 2 max refs per command now.
The command with 3 refs is gone. :relieved:
* Don't cast on the GPU side
* Remove redundant casts, force sync on window present
* Fix Shader Cache
* Fix host shader save.
* Fixup to work with new renderer stuff
* Make command Run static, use array of delegates as lookup
Profile says this takes less time than the previous way.
* Bring up to date
* Add settings toggle. Fix Muiltithreading Off mode.
* Fix warning.
* Release tracking lock for flushes
* Fix Conditional Render fast path with threaded gal
* Make handle iteration safe when releasing the lock
This is mostly temporary.
* Attempt to set backend threading on driver
Only really works on nvidia before launching a game.
* Fix race condition with BufferModifiedRangeList, exceptions in tracking actions
* Update buffer set commands
* Some cleanup
* Only use stutter workaround when using opengl renderer non-threaded
* Add host-conditional reservation of counter events
There has always been the possibility that conditional rendering could use a query object just as it is disposed by the counter queue. This change makes it so that when the host decides to use host conditional rendering, the query object is reserved so that it cannot be deleted. Counter events can optionally start reserved, as the threaded implementation can reserve them before the backend creates them, and there would otherwise be a short amount of time where the counter queue could dispose the event before a call to reserve it could be made.
* Address Feedback
* Make counter flush tracked again.
Hopefully does not cause any issues this time.
* Wait for FlushTo on the main queue thread.
Currently assumes only one thread will want to FlushTo (in this case, the GPU thread)
* Add SDL2 headless integration
* Add HLE macro commands.
Co-authored-by: Mary <mary@mary.zone>
2021-08-26 22:31:29 +00:00
_galThreading . SetActiveId ( ConfigurationState . Instance . Graphics . BackendThreading . Value . ToString ( ) ) ;
2020-07-07 02:41:07 +00:00
_resScaleCombo . SetActiveId ( ConfigurationState . Instance . Graphics . ResScale . Value . ToString ( ) ) ;
2020-05-03 02:00:53 +00:00
_anisotropy . SetActiveId ( ConfigurationState . Instance . Graphics . MaxAnisotropy . Value . ToString ( ) ) ;
2020-12-16 02:19:07 +00:00
_aspectRatio . SetActiveId ( ( ( int ) ConfigurationState . Instance . Graphics . AspectRatio . Value ) . ToString ( ) ) ;
2020-05-03 02:00:53 +00:00
_custThemePath . Buffer . Text = ConfigurationState . Instance . Ui . CustomThemePath ;
2020-07-07 02:41:07 +00:00
_resScaleText . Buffer . Text = ConfigurationState . Instance . Graphics . ResScaleCustom . Value . ToString ( ) ;
_resScaleText . Visible = _resScaleCombo . ActiveId = = "-1" ;
2020-05-03 02:00:53 +00:00
_graphicsShadersDumpPath . Buffer . Text = ConfigurationState . Instance . Graphics . ShadersDumpPath ;
_fsLogSpinAdjustment . Value = ConfigurationState . Instance . System . FsGlobalAccessLogMode ;
_systemTimeOffset = ConfigurationState . Instance . System . SystemTimeOffset ;
_gameDirsBox . AppendColumn ( "" , new CellRendererText ( ) , "text" , 0 ) ;
_gameDirsBoxStore = new ListStore ( typeof ( string ) ) ;
_gameDirsBox . Model = _gameDirsBoxStore ;
foreach ( string gameDir in ConfigurationState . Instance . Ui . GameDirs . Value )
{
_gameDirsBoxStore . AppendValues ( gameDir ) ;
}
if ( _custThemeToggle . Active = = false )
{
_custThemePath . Sensitive = false ;
_custThemePathLabel . Sensitive = false ;
_browseThemePath . Sensitive = false ;
}
//Setup system time spinners
UpdateSystemTimeSpinners ( ) ;
2020-08-09 20:46:06 +00:00
_audioBackendStore = new ListStore ( typeof ( string ) , typeof ( AudioBackend ) ) ;
TreeIter openAlIter = _audioBackendStore . AppendValues ( "OpenAL" , AudioBackend . OpenAl ) ;
TreeIter soundIoIter = _audioBackendStore . AppendValues ( "SoundIO" , AudioBackend . SoundIo ) ;
2021-05-05 21:37:09 +00:00
TreeIter sdl2Iter = _audioBackendStore . AppendValues ( "SDL2" , AudioBackend . SDL2 ) ;
2020-08-09 20:46:06 +00:00
TreeIter dummyIter = _audioBackendStore . AppendValues ( "Dummy" , AudioBackend . Dummy ) ;
_audioBackendSelect = ComboBox . NewWithModelAndEntry ( _audioBackendStore ) ;
_audioBackendSelect . EntryTextColumn = 0 ;
_audioBackendSelect . Entry . IsEditable = false ;
switch ( ConfigurationState . Instance . System . AudioBackend . Value )
{
case AudioBackend . OpenAl :
_audioBackendSelect . SetActiveIter ( openAlIter ) ;
break ;
case AudioBackend . SoundIo :
_audioBackendSelect . SetActiveIter ( soundIoIter ) ;
break ;
2021-05-05 21:37:09 +00:00
case AudioBackend . SDL2 :
_audioBackendSelect . SetActiveIter ( sdl2Iter ) ;
break ;
2020-08-09 20:46:06 +00:00
case AudioBackend . Dummy :
_audioBackendSelect . SetActiveIter ( dummyIter ) ;
break ;
default :
throw new ArgumentOutOfRangeException ( ) ;
}
_audioBackendBox . Add ( _audioBackendSelect ) ;
_audioBackendSelect . Show ( ) ;
2021-12-23 16:33:56 +00:00
_previousVolumeLevel = ConfigurationState . Instance . System . AudioVolume ;
_audioVolumeLabel = new Label ( "Volume: " ) ;
_audioVolumeSlider = new Scale ( Orientation . Horizontal , 0 , 100 , 1 ) ;
_audioVolumeLabel . MarginStart = 10 ;
_audioVolumeSlider . ValuePos = PositionType . Right ;
_audioVolumeSlider . WidthRequest = 200 ;
_audioVolumeSlider . Value = _previousVolumeLevel * 100 ;
_audioVolumeSlider . ValueChanged + = VolumeSlider_OnChange ;
_audioBackendBox . Add ( _audioVolumeLabel ) ;
_audioBackendBox . Add ( _audioVolumeSlider ) ;
_audioVolumeLabel . Show ( ) ;
_audioVolumeSlider . Show ( ) ;
2020-08-09 20:46:06 +00:00
bool openAlIsSupported = false ;
bool soundIoIsSupported = false ;
2021-05-05 21:37:09 +00:00
bool sdl2IsSupported = false ;
2020-08-09 20:46:06 +00:00
Task . Run ( ( ) = >
{
2021-02-26 00:11:56 +00:00
openAlIsSupported = OpenALHardwareDeviceDriver . IsSupported ;
soundIoIsSupported = SoundIoHardwareDeviceDriver . IsSupported ;
2021-05-05 21:37:09 +00:00
sdl2IsSupported = SDL2HardwareDeviceDriver . IsSupported ;
2020-08-09 20:46:06 +00:00
} ) ;
// This function runs whenever the dropdown is opened
_audioBackendSelect . SetCellDataFunc ( _audioBackendSelect . Cells [ 0 ] , ( layout , cell , model , iter ) = >
{
cell . Sensitive = ( ( AudioBackend ) _audioBackendStore . GetValue ( iter , 1 ) ) switch
{
AudioBackend . OpenAl = > openAlIsSupported ,
AudioBackend . SoundIo = > soundIoIsSupported ,
2021-05-05 21:37:09 +00:00
AudioBackend . SDL2 = > sdl2IsSupported ,
2020-08-09 20:46:06 +00:00
AudioBackend . Dummy = > true ,
_ = > throw new ArgumentOutOfRangeException ( )
} ;
} ) ;
2020-05-03 02:00:53 +00:00
}
private void UpdateSystemTimeSpinners ( )
{
//Bind system time events
_systemTimeYearSpin . ValueChanged - = SystemTimeSpin_ValueChanged ;
_systemTimeMonthSpin . ValueChanged - = SystemTimeSpin_ValueChanged ;
_systemTimeDaySpin . ValueChanged - = SystemTimeSpin_ValueChanged ;
_systemTimeHourSpin . ValueChanged - = SystemTimeSpin_ValueChanged ;
_systemTimeMinuteSpin . ValueChanged - = SystemTimeSpin_ValueChanged ;
//Apply actual system time + SystemTimeOffset to system time spin buttons
DateTime systemTime = DateTime . Now . AddSeconds ( _systemTimeOffset ) ;
_systemTimeYearSpinAdjustment . Value = systemTime . Year ;
_systemTimeMonthSpinAdjustment . Value = systemTime . Month ;
_systemTimeDaySpinAdjustment . Value = systemTime . Day ;
_systemTimeHourSpinAdjustment . Value = systemTime . Hour ;
_systemTimeMinuteSpinAdjustment . Value = systemTime . Minute ;
//Format spin buttons text to include leading zeros
_systemTimeYearSpin . Text = systemTime . Year . ToString ( "0000" ) ;
_systemTimeMonthSpin . Text = systemTime . Month . ToString ( "00" ) ;
_systemTimeDaySpin . Text = systemTime . Day . ToString ( "00" ) ;
_systemTimeHourSpin . Text = systemTime . Hour . ToString ( "00" ) ;
_systemTimeMinuteSpin . Text = systemTime . Minute . ToString ( "00" ) ;
//Bind system time events
_systemTimeYearSpin . ValueChanged + = SystemTimeSpin_ValueChanged ;
_systemTimeMonthSpin . ValueChanged + = SystemTimeSpin_ValueChanged ;
_systemTimeDaySpin . ValueChanged + = SystemTimeSpin_ValueChanged ;
_systemTimeHourSpin . ValueChanged + = SystemTimeSpin_ValueChanged ;
_systemTimeMinuteSpin . ValueChanged + = SystemTimeSpin_ValueChanged ;
}
2020-11-13 00:50:28 +00:00
private void SaveSettings ( )
{
List < string > gameDirs = new List < string > ( ) ;
_gameDirsBoxStore . GetIterFirst ( out TreeIter treeIter ) ;
for ( int i = 0 ; i < _gameDirsBoxStore . IterNChildren ( ) ; i + + )
{
gameDirs . Add ( ( string ) _gameDirsBoxStore . GetValue ( treeIter , 0 ) ) ;
_gameDirsBoxStore . IterNext ( ref treeIter ) ;
}
if ( ! float . TryParse ( _resScaleText . Buffer . Text , out float resScaleCustom ) | | resScaleCustom < = 0.0f )
{
resScaleCustom = 1.0f ;
}
if ( _validTzRegions . Contains ( _systemTimeZoneEntry . Text ) )
{
ConfigurationState . Instance . System . TimeZone . Value = _systemTimeZoneEntry . Text ;
}
POWER - Performance Optimizations With Extensive Ramifications (#2286)
* Refactoring of KMemoryManager class
* Replace some trivial uses of DRAM address with VA
* Get rid of GetDramAddressFromVa
* Abstracting more operations on derived page table class
* Run auto-format on KPageTableBase
* Managed to make TryConvertVaToPa private, few uses remains now
* Implement guest physical pages ref counting, remove manual freeing
* Make DoMmuOperation private and call new abstract methods only from the base class
* Pass pages count rather than size on Map/UnmapMemory
* Change memory managers to take host pointers
* Fix a guest memory leak and simplify KPageTable
* Expose new methods for host range query and mapping
* Some refactoring of MapPagesFromClientProcess to allow proper page ref counting and mapping without KPageLists
* Remove more uses of AddVaRangeToPageList, now only one remains (shared memory page checking)
* Add a SharedMemoryStorage class, will be useful for host mapping
* Sayonara AddVaRangeToPageList, you served us well
* Start to implement host memory mapping (WIP)
* Support memory tracking through host exception handling
* Fix some access violations from HLE service guest memory access and CPU
* Fix memory tracking
* Fix mapping list bugs, including a race and a error adding mapping ranges
* Simple page table for memory tracking
* Simple "volatile" region handle mode
* Update UBOs directly (experimental, rough)
* Fix the overlap check
* Only set non-modified buffers as volatile
* Fix some memory tracking issues
* Fix possible race in MapBufferFromClientProcess (block list updates were not locked)
* Write uniform update to memory immediately, only defer the buffer set.
* Fix some memory tracking issues
* Pass correct pages count on shared memory unmap
* Armeilleure Signal Handler v1 + Unix changes
Unix currently behaves like windows, rather than remapping physical
* Actually check if the host platform is unix
* Fix decommit on linux.
* Implement windows 10 placeholder shared memory, fix a buffer issue.
* Make PTC version something that will never match with master
* Remove testing variable for block count
* Add reference count for memory manager, fix dispose
Can still deadlock with OpenAL
* Add address validation, use page table for mapped check, add docs
Might clean up the page table traversing routines.
* Implement batched mapping/tracking.
* Move documentation, fix tests.
* Cleanup uniform buffer update stuff.
* Remove unnecessary assignment.
* Add unsafe host mapped memory switch
On by default. Would be good to turn this off for untrusted code (homebrew, exefs mods) and give the user the option to turn it on manually, though that requires some UI work.
* Remove C# exception handlers
They have issues due to current .NET limitations, so the meilleure one fully replaces them for now.
* Fix MapPhysicalMemory on the software MemoryManager.
* Null check for GetHostAddress, docs
* Add configuration for setting memory manager mode (not in UI yet)
* Add config to UI
* Fix type mismatch on Unix signal handler code emit
* Fix 6GB DRAM mode.
The size can be greater than `uint.MaxValue` when the DRAM is >4GB.
* Address some feedback.
* More detailed error if backing memory cannot be mapped.
* SetLastError on all OS functions for consistency
* Force pages dirty with UBO update instead of setting them directly.
Seems to be much faster across a few games. Need retesting.
* Rebase, configuration rework, fix mem tracking regression
* Fix race in FreePages
* Set memory managers null after decrementing ref count
* Remove readonly keyword, as this is now modified.
* Use a local variable for the signal handler rather than a register.
* Fix bug with buffer resize, and index/uniform buffer binding.
Should fix flickering in games.
* Add InvalidAccessHandler to MemoryTracking
Doesn't do anything yet
* Call invalid access handler on unmapped read/write.
Same rules as the regular memory manager.
* Make unsafe mapped memory its own MemoryManagerType
* Move FlushUboDirty into UpdateState.
* Buffer dirty cache, rather than ubo cache
Much cleaner, may be reusable for Inline2Memory updates.
* This doesn't return anything anymore.
* Add sigaction remove methods, correct a few function signatures.
* Return empty list of physical regions for size 0.
* Also on AddressSpaceManager
Co-authored-by: gdkchan <gab.dark.100@gmail.com>
2021-05-24 20:52:44 +00:00
MemoryManagerMode memoryMode = MemoryManagerMode . SoftwarePageTable ;
if ( _mmHost . Active )
{
memoryMode = MemoryManagerMode . HostMapped ;
}
if ( _mmHostUnsafe . Active )
{
memoryMode = MemoryManagerMode . HostMappedUnsafe ;
}
Add a Multithreading layer for the GAL, multi-thread shader compilation at runtime (#2501)
* Initial Implementation
About as fast as nvidia GL multithreading, can be improved with faster command queuing.
* Struct based command list
Speeds up a bit. Still a lot of time lost to resource copy.
* Do shader init while the render thread is active.
* Introduce circular span pool V1
Ideally should be able to use structs instead of references for storing these spans on commands. Will try that next.
* Refactor SpanRef some more
Use a struct to represent SpanRef, rather than a reference.
* Flush buffers on background thread
* Use a span for UpdateRenderScale.
Much faster than copying the array.
* Calculate command size using reflection
* WIP parallel shaders
* Some minor optimisation
* Only 2 max refs per command now.
The command with 3 refs is gone. :relieved:
* Don't cast on the GPU side
* Remove redundant casts, force sync on window present
* Fix Shader Cache
* Fix host shader save.
* Fixup to work with new renderer stuff
* Make command Run static, use array of delegates as lookup
Profile says this takes less time than the previous way.
* Bring up to date
* Add settings toggle. Fix Muiltithreading Off mode.
* Fix warning.
* Release tracking lock for flushes
* Fix Conditional Render fast path with threaded gal
* Make handle iteration safe when releasing the lock
This is mostly temporary.
* Attempt to set backend threading on driver
Only really works on nvidia before launching a game.
* Fix race condition with BufferModifiedRangeList, exceptions in tracking actions
* Update buffer set commands
* Some cleanup
* Only use stutter workaround when using opengl renderer non-threaded
* Add host-conditional reservation of counter events
There has always been the possibility that conditional rendering could use a query object just as it is disposed by the counter queue. This change makes it so that when the host decides to use host conditional rendering, the query object is reserved so that it cannot be deleted. Counter events can optionally start reserved, as the threaded implementation can reserve them before the backend creates them, and there would otherwise be a short amount of time where the counter queue could dispose the event before a call to reserve it could be made.
* Address Feedback
* Make counter flush tracked again.
Hopefully does not cause any issues this time.
* Wait for FlushTo on the main queue thread.
Currently assumes only one thread will want to FlushTo (in this case, the GPU thread)
* Add SDL2 headless integration
* Add HLE macro commands.
Co-authored-by: Mary <mary@mary.zone>
2021-08-26 22:31:29 +00:00
BackendThreading backendThreading = Enum . Parse < BackendThreading > ( _galThreading . ActiveId ) ;
if ( ConfigurationState . Instance . Graphics . BackendThreading ! = backendThreading )
{
DriverUtilities . ToggleOGLThreading ( backendThreading = = BackendThreading . Off ) ;
}
2020-11-13 00:50:28 +00:00
ConfigurationState . Instance . Logger . EnableError . Value = _errorLogToggle . Active ;
2022-02-18 00:08:07 +00:00
ConfigurationState . Instance . Logger . EnableTrace . Value = _traceLogToggle . Active ;
2020-11-13 00:50:28 +00:00
ConfigurationState . Instance . Logger . EnableWarn . Value = _warningLogToggle . Active ;
ConfigurationState . Instance . Logger . EnableInfo . Value = _infoLogToggle . Active ;
ConfigurationState . Instance . Logger . EnableStub . Value = _stubLogToggle . Active ;
ConfigurationState . Instance . Logger . EnableDebug . Value = _debugLogToggle . Active ;
ConfigurationState . Instance . Logger . EnableGuest . Value = _guestLogToggle . Active ;
ConfigurationState . Instance . Logger . EnableFsAccessLog . Value = _fsAccessLogToggle . Active ;
ConfigurationState . Instance . Logger . EnableFileLog . Value = _fileLogToggle . Active ;
ConfigurationState . Instance . Logger . GraphicsDebugLevel . Value = Enum . Parse < GraphicsDebugLevel > ( _graphicsDebugLevel . ActiveId ) ;
ConfigurationState . Instance . System . EnableDockedMode . Value = _dockedModeToggle . Active ;
ConfigurationState . Instance . EnableDiscordIntegration . Value = _discordToggle . Active ;
ConfigurationState . Instance . CheckUpdatesOnStart . Value = _checkUpdatesToggle . Active ;
2021-01-14 22:30:52 +00:00
ConfigurationState . Instance . ShowConfirmExit . Value = _showConfirmExitToggle . Active ;
2021-02-15 21:48:21 +00:00
ConfigurationState . Instance . HideCursorOnIdle . Value = _hideCursorOnIdleToggle . Active ;
2020-11-13 00:50:28 +00:00
ConfigurationState . Instance . Graphics . EnableVsync . Value = _vSyncToggle . Active ;
ConfigurationState . Instance . Graphics . EnableShaderCache . Value = _shaderCacheToggle . Active ;
ConfigurationState . Instance . System . EnablePtc . Value = _ptcToggle . Active ;
2021-12-26 14:17:13 +00:00
ConfigurationState . Instance . System . EnableInternetAccess . Value = _internetToggle . Active ;
2020-11-13 00:50:28 +00:00
ConfigurationState . Instance . System . EnableFsIntegrityChecks . Value = _fsicToggle . Active ;
POWER - Performance Optimizations With Extensive Ramifications (#2286)
* Refactoring of KMemoryManager class
* Replace some trivial uses of DRAM address with VA
* Get rid of GetDramAddressFromVa
* Abstracting more operations on derived page table class
* Run auto-format on KPageTableBase
* Managed to make TryConvertVaToPa private, few uses remains now
* Implement guest physical pages ref counting, remove manual freeing
* Make DoMmuOperation private and call new abstract methods only from the base class
* Pass pages count rather than size on Map/UnmapMemory
* Change memory managers to take host pointers
* Fix a guest memory leak and simplify KPageTable
* Expose new methods for host range query and mapping
* Some refactoring of MapPagesFromClientProcess to allow proper page ref counting and mapping without KPageLists
* Remove more uses of AddVaRangeToPageList, now only one remains (shared memory page checking)
* Add a SharedMemoryStorage class, will be useful for host mapping
* Sayonara AddVaRangeToPageList, you served us well
* Start to implement host memory mapping (WIP)
* Support memory tracking through host exception handling
* Fix some access violations from HLE service guest memory access and CPU
* Fix memory tracking
* Fix mapping list bugs, including a race and a error adding mapping ranges
* Simple page table for memory tracking
* Simple "volatile" region handle mode
* Update UBOs directly (experimental, rough)
* Fix the overlap check
* Only set non-modified buffers as volatile
* Fix some memory tracking issues
* Fix possible race in MapBufferFromClientProcess (block list updates were not locked)
* Write uniform update to memory immediately, only defer the buffer set.
* Fix some memory tracking issues
* Pass correct pages count on shared memory unmap
* Armeilleure Signal Handler v1 + Unix changes
Unix currently behaves like windows, rather than remapping physical
* Actually check if the host platform is unix
* Fix decommit on linux.
* Implement windows 10 placeholder shared memory, fix a buffer issue.
* Make PTC version something that will never match with master
* Remove testing variable for block count
* Add reference count for memory manager, fix dispose
Can still deadlock with OpenAL
* Add address validation, use page table for mapped check, add docs
Might clean up the page table traversing routines.
* Implement batched mapping/tracking.
* Move documentation, fix tests.
* Cleanup uniform buffer update stuff.
* Remove unnecessary assignment.
* Add unsafe host mapped memory switch
On by default. Would be good to turn this off for untrusted code (homebrew, exefs mods) and give the user the option to turn it on manually, though that requires some UI work.
* Remove C# exception handlers
They have issues due to current .NET limitations, so the meilleure one fully replaces them for now.
* Fix MapPhysicalMemory on the software MemoryManager.
* Null check for GetHostAddress, docs
* Add configuration for setting memory manager mode (not in UI yet)
* Add config to UI
* Fix type mismatch on Unix signal handler code emit
* Fix 6GB DRAM mode.
The size can be greater than `uint.MaxValue` when the DRAM is >4GB.
* Address some feedback.
* More detailed error if backing memory cannot be mapped.
* SetLastError on all OS functions for consistency
* Force pages dirty with UBO update instead of setting them directly.
Seems to be much faster across a few games. Need retesting.
* Rebase, configuration rework, fix mem tracking regression
* Fix race in FreePages
* Set memory managers null after decrementing ref count
* Remove readonly keyword, as this is now modified.
* Use a local variable for the signal handler rather than a register.
* Fix bug with buffer resize, and index/uniform buffer binding.
Should fix flickering in games.
* Add InvalidAccessHandler to MemoryTracking
Doesn't do anything yet
* Call invalid access handler on unmapped read/write.
Same rules as the regular memory manager.
* Make unsafe mapped memory its own MemoryManagerType
* Move FlushUboDirty into UpdateState.
* Buffer dirty cache, rather than ubo cache
Much cleaner, may be reusable for Inline2Memory updates.
* This doesn't return anything anymore.
* Add sigaction remove methods, correct a few function signatures.
* Return empty list of physical regions for size 0.
* Also on AddressSpaceManager
Co-authored-by: gdkchan <gab.dark.100@gmail.com>
2021-05-24 20:52:44 +00:00
ConfigurationState . Instance . System . MemoryManagerMode . Value = memoryMode ;
2021-04-04 12:06:59 +00:00
ConfigurationState . Instance . System . ExpandRam . Value = _expandRamToggle . Active ;
2020-11-13 00:50:28 +00:00
ConfigurationState . Instance . System . IgnoreMissingServices . Value = _ignoreToggle . Active ;
ConfigurationState . Instance . Hid . EnableKeyboard . Value = _directKeyboardAccess . Active ;
2021-06-24 00:09:08 +00:00
ConfigurationState . Instance . Hid . EnableMouse . Value = _directMouseAccess . Active ;
2020-11-13 00:50:28 +00:00
ConfigurationState . Instance . Ui . EnableCustomTheme . Value = _custThemeToggle . Active ;
ConfigurationState . Instance . System . Language . Value = Enum . Parse < Language > ( _systemLanguageSelect . ActiveId ) ;
ConfigurationState . Instance . System . Region . Value = Enum . Parse < Configuration . System . Region > ( _systemRegionSelect . ActiveId ) ;
ConfigurationState . Instance . System . SystemTimeOffset . Value = _systemTimeOffset ;
ConfigurationState . Instance . Ui . CustomThemePath . Value = _custThemePath . Buffer . Text ;
ConfigurationState . Instance . Graphics . ShadersDumpPath . Value = _graphicsShadersDumpPath . Buffer . Text ;
ConfigurationState . Instance . Ui . GameDirs . Value = gameDirs ;
ConfigurationState . Instance . System . FsGlobalAccessLogMode . Value = ( int ) _fsLogSpinAdjustment . Value ;
2020-12-01 20:44:04 +00:00
ConfigurationState . Instance . Graphics . MaxAnisotropy . Value = float . Parse ( _anisotropy . ActiveId , CultureInfo . InvariantCulture ) ;
2020-12-16 02:19:07 +00:00
ConfigurationState . Instance . Graphics . AspectRatio . Value = Enum . Parse < AspectRatio > ( _aspectRatio . ActiveId ) ;
Add a Multithreading layer for the GAL, multi-thread shader compilation at runtime (#2501)
* Initial Implementation
About as fast as nvidia GL multithreading, can be improved with faster command queuing.
* Struct based command list
Speeds up a bit. Still a lot of time lost to resource copy.
* Do shader init while the render thread is active.
* Introduce circular span pool V1
Ideally should be able to use structs instead of references for storing these spans on commands. Will try that next.
* Refactor SpanRef some more
Use a struct to represent SpanRef, rather than a reference.
* Flush buffers on background thread
* Use a span for UpdateRenderScale.
Much faster than copying the array.
* Calculate command size using reflection
* WIP parallel shaders
* Some minor optimisation
* Only 2 max refs per command now.
The command with 3 refs is gone. :relieved:
* Don't cast on the GPU side
* Remove redundant casts, force sync on window present
* Fix Shader Cache
* Fix host shader save.
* Fixup to work with new renderer stuff
* Make command Run static, use array of delegates as lookup
Profile says this takes less time than the previous way.
* Bring up to date
* Add settings toggle. Fix Muiltithreading Off mode.
* Fix warning.
* Release tracking lock for flushes
* Fix Conditional Render fast path with threaded gal
* Make handle iteration safe when releasing the lock
This is mostly temporary.
* Attempt to set backend threading on driver
Only really works on nvidia before launching a game.
* Fix race condition with BufferModifiedRangeList, exceptions in tracking actions
* Update buffer set commands
* Some cleanup
* Only use stutter workaround when using opengl renderer non-threaded
* Add host-conditional reservation of counter events
There has always been the possibility that conditional rendering could use a query object just as it is disposed by the counter queue. This change makes it so that when the host decides to use host conditional rendering, the query object is reserved so that it cannot be deleted. Counter events can optionally start reserved, as the threaded implementation can reserve them before the backend creates them, and there would otherwise be a short amount of time where the counter queue could dispose the event before a call to reserve it could be made.
* Address Feedback
* Make counter flush tracked again.
Hopefully does not cause any issues this time.
* Wait for FlushTo on the main queue thread.
Currently assumes only one thread will want to FlushTo (in this case, the GPU thread)
* Add SDL2 headless integration
* Add HLE macro commands.
Co-authored-by: Mary <mary@mary.zone>
2021-08-26 22:31:29 +00:00
ConfigurationState . Instance . Graphics . BackendThreading . Value = backendThreading ;
2020-11-13 00:50:28 +00:00
ConfigurationState . Instance . Graphics . ResScale . Value = int . Parse ( _resScaleCombo . ActiveId ) ;
ConfigurationState . Instance . Graphics . ResScaleCustom . Value = resScaleCustom ;
2021-12-23 16:33:56 +00:00
ConfigurationState . Instance . System . AudioVolume . Value = ( float ) _audioVolumeSlider . Value / 100.0f ;
_previousVolumeLevel = ConfigurationState . Instance . System . AudioVolume . Value ;
2020-11-13 00:50:28 +00:00
if ( _audioBackendSelect . GetActiveIter ( out TreeIter activeIter ) )
{
2021-04-13 19:58:47 +00:00
ConfigurationState . Instance . System . AudioBackend . Value = ( AudioBackend ) _audioBackendStore . GetValue ( activeIter , 1 ) ;
2020-11-13 00:50:28 +00:00
}
2021-01-08 08:14:13 +00:00
ConfigurationState . Instance . ToFileFormat ( ) . SaveConfig ( Program . ConfigurationPath ) ;
_parent . UpdateGraphicsConfig ( ) ;
ThemeHelper . ApplyTheme ( ) ;
2020-11-13 00:50:28 +00:00
}
2021-01-08 08:14:13 +00:00
//
// Events
//
2020-12-16 02:19:07 +00:00
private void TimeZoneEntry_FocusOut ( object sender , FocusOutEventArgs e )
2020-07-21 04:14:42 +00:00
{
if ( ! _validTzRegions . Contains ( _systemTimeZoneEntry . Text ) )
{
2021-05-16 15:12:14 +00:00
_systemTimeZoneEntry . Text = _timeZoneContentManager . SanityCheckDeviceLocationName ( ConfigurationState . Instance . System . TimeZone ) ;
2020-07-21 04:14:42 +00:00
}
}
private bool TimeZoneMatchFunc ( EntryCompletion compl , string key , TreeIter iter )
{
key = key . Trim ( ) . Replace ( ' ' , '_' ) ;
return ( ( string ) compl . Model . GetValue ( iter , 1 ) ) . Contains ( key , StringComparison . OrdinalIgnoreCase ) | | // region
( ( string ) compl . Model . GetValue ( iter , 2 ) ) . StartsWith ( key , StringComparison . OrdinalIgnoreCase ) | | // abbr
2021-01-08 08:14:13 +00:00
( ( string ) compl . Model . GetValue ( iter , 0 ) ) [ 3. . ] . StartsWith ( key ) ; // offset
2020-07-21 04:14:42 +00:00
}
2020-12-16 02:19:07 +00:00
private void SystemTimeSpin_ValueChanged ( object sender , EventArgs e )
2020-05-03 02:00:53 +00:00
{
int year = _systemTimeYearSpin . ValueAsInt ;
int month = _systemTimeMonthSpin . ValueAsInt ;
int day = _systemTimeDaySpin . ValueAsInt ;
int hour = _systemTimeHourSpin . ValueAsInt ;
int minute = _systemTimeMinuteSpin . ValueAsInt ;
if ( ! DateTime . TryParse ( year + "-" + month + "-" + day + " " + hour + ":" + minute , out DateTime newTime ) )
{
UpdateSystemTimeSpinners ( ) ;
return ;
}
newTime = newTime . AddSeconds ( DateTime . Now . Second ) . AddMilliseconds ( DateTime . Now . Millisecond ) ;
long systemTimeOffset = ( long ) Math . Ceiling ( ( newTime - DateTime . Now ) . TotalMinutes ) * 60L ;
if ( _systemTimeOffset ! = systemTimeOffset )
{
_systemTimeOffset = systemTimeOffset ;
UpdateSystemTimeSpinners ( ) ;
}
}
private void AddDir_Pressed ( object sender , EventArgs args )
{
if ( Directory . Exists ( _addGameDirBox . Buffer . Text ) )
{
_gameDirsBoxStore . AppendValues ( _addGameDirBox . Buffer . Text ) ;
}
else
{
2021-09-14 21:52:08 +00:00
FileChooserNative fileChooser = new FileChooserNative ( "Choose the game directory to add to the list" , this , FileChooserAction . SelectFolder , "Add" , "Cancel" )
2020-07-03 22:57:03 +00:00
{
SelectMultiple = true
} ;
2020-05-03 02:00:53 +00:00
if ( fileChooser . Run ( ) = = ( int ) ResponseType . Accept )
{
2020-07-03 22:57:03 +00:00
foreach ( string directory in fileChooser . Filenames )
{
bool directoryAdded = false ;
2020-12-09 22:20:05 +00:00
2020-07-03 22:57:03 +00:00
if ( _gameDirsBoxStore . GetIterFirst ( out TreeIter treeIter ) )
{
do
{
if ( directory . Equals ( ( string ) _gameDirsBoxStore . GetValue ( treeIter , 0 ) ) )
{
directoryAdded = true ;
break ;
}
} while ( _gameDirsBoxStore . IterNext ( ref treeIter ) ) ;
}
if ( ! directoryAdded )
{
_gameDirsBoxStore . AppendValues ( directory ) ;
}
}
2020-05-03 02:00:53 +00:00
}
fileChooser . Dispose ( ) ;
}
_addGameDirBox . Buffer . Text = "" ;
2021-01-08 08:14:13 +00:00
( ( ToggleButton ) sender ) . SetStateFlags ( StateFlags . Normal , true ) ;
2020-05-03 02:00:53 +00:00
}
private void RemoveDir_Pressed ( object sender , EventArgs args )
{
TreeSelection selection = _gameDirsBox . Selection ;
if ( selection . GetSelected ( out TreeIter treeIter ) )
{
_gameDirsBoxStore . Remove ( ref treeIter ) ;
}
2021-01-08 08:14:13 +00:00
( ( ToggleButton ) sender ) . SetStateFlags ( StateFlags . Normal , true ) ;
2020-05-03 02:00:53 +00:00
}
private void CustThemeToggle_Activated ( object sender , EventArgs args )
{
_custThemePath . Sensitive = _custThemeToggle . Active ;
_custThemePathLabel . Sensitive = _custThemeToggle . Active ;
_browseThemePath . Sensitive = _custThemeToggle . Active ;
}
private void BrowseThemeDir_Pressed ( object sender , EventArgs args )
{
2021-09-14 21:52:08 +00:00
using ( FileChooserNative fileChooser = new FileChooserNative ( "Choose the theme to load" , this , FileChooserAction . Open , "Select" , "Cancel" ) )
2020-05-03 02:00:53 +00:00
{
2021-09-14 21:52:08 +00:00
FileFilter filter = new FileFilter ( )
{
Name = "Theme Files"
} ;
filter . AddPattern ( "*.css" ) ;
fileChooser . AddFilter ( filter ) ;
2020-05-03 02:00:53 +00:00
2021-01-08 08:14:13 +00:00
if ( fileChooser . Run ( ) = = ( int ) ResponseType . Accept )
{
_custThemePath . Buffer . Text = fileChooser . Filename ;
}
}
2020-05-03 02:00:53 +00:00
2021-01-08 08:14:13 +00:00
_browseThemePath . SetStateFlags ( StateFlags . Normal , true ) ;
2020-05-03 02:00:53 +00:00
}
2021-01-08 08:14:13 +00:00
private void ConfigureController_Pressed ( object sender , PlayerIndex playerIndex )
2020-05-03 02:00:53 +00:00
{
2021-01-08 08:14:13 +00:00
( ( ToggleButton ) sender ) . SetStateFlags ( StateFlags . Normal , true ) ;
2020-05-03 02:00:53 +00:00
2021-04-14 10:28:43 +00:00
ControllerWindow controllerWindow = new ControllerWindow ( _parent , playerIndex ) ;
2021-02-20 00:34:41 +00:00
controllerWindow . SetSizeRequest ( ( int ) ( controllerWindow . DefaultWidth * Program . WindowScaleFactor ) , ( int ) ( controllerWindow . DefaultHeight * Program . WindowScaleFactor ) ) ;
controllerWindow . Show ( ) ;
2020-05-03 02:00:53 +00:00
}
2021-12-23 16:33:56 +00:00
private void VolumeSlider_OnChange ( object sender , EventArgs args )
{
ConfigurationState . Instance . System . AudioVolume . Value = ( float ) ( _audioVolumeSlider . Value / 100 ) ;
}
2020-05-03 02:00:53 +00:00
private void SaveToggle_Activated ( object sender , EventArgs args )
{
2020-11-13 00:50:28 +00:00
SaveSettings ( ) ;
2020-05-03 02:00:53 +00:00
Dispose ( ) ;
}
2020-11-13 00:50:28 +00:00
private void ApplyToggle_Activated ( object sender , EventArgs args )
{
SaveSettings ( ) ;
}
2020-05-03 02:00:53 +00:00
private void CloseToggle_Activated ( object sender , EventArgs args )
{
2021-12-23 16:33:56 +00:00
ConfigurationState . Instance . System . AudioVolume . Value = _previousVolumeLevel ;
2020-05-03 02:00:53 +00:00
Dispose ( ) ;
}
}
2021-02-15 21:48:21 +00:00
}