0
0
Fork 0

Make max anisotropy configurable (#1043)

* Make max anisotropy configurable

* Move opengl command to opengl project

* Add GUI option
This commit is contained in:
Xpl0itR 2020-03-30 22:38:52 +01:00 committed by GitHub
parent 5a52ca5071
commit 12d49c37d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 108 additions and 10 deletions

View file

@ -19,10 +19,15 @@ namespace Ryujinx.Configuration
/// <summary> /// <summary>
/// The current version of the file format /// The current version of the file format
/// </summary> /// </summary>
public const int CurrentVersion = 3; public const int CurrentVersion = 4;
public int Version { get; set; } public int Version { get; set; }
/// <summary>
/// Max Anisotropy. Values range from 0 - 16. Set to -1 to let the game decide.
/// </summary>
public float MaxAnisotropy { get; set; }
/// <summary> /// <summary>
/// Dumps shaders in this local directory /// Dumps shaders in this local directory
/// </summary> /// </summary>

View file

@ -235,6 +235,11 @@ namespace Ryujinx.Configuration
/// </summary> /// </summary>
public class GraphicsSection public class GraphicsSection
{ {
/// <summary>
/// Max Anisotropy. Values range from 0 - 16. Set to -1 to let the game decide.
/// </summary>
public ReactiveObject<float> MaxAnisotropy { get; private set; }
/// <summary> /// <summary>
/// Dumps shaders in this local directory /// Dumps shaders in this local directory
/// </summary> /// </summary>
@ -247,6 +252,7 @@ namespace Ryujinx.Configuration
public GraphicsSection() public GraphicsSection()
{ {
MaxAnisotropy = new ReactiveObject<float>();
ShadersDumpPath = new ReactiveObject<string>(); ShadersDumpPath = new ReactiveObject<string>();
EnableVsync = new ReactiveObject<bool>(); EnableVsync = new ReactiveObject<bool>();
} }
@ -302,6 +308,7 @@ namespace Ryujinx.Configuration
ConfigurationFileFormat configurationFile = new ConfigurationFileFormat ConfigurationFileFormat configurationFile = new ConfigurationFileFormat
{ {
Version = ConfigurationFileFormat.CurrentVersion, Version = ConfigurationFileFormat.CurrentVersion,
MaxAnisotropy = Graphics.MaxAnisotropy,
GraphicsShadersDumpPath = Graphics.ShadersDumpPath, GraphicsShadersDumpPath = Graphics.ShadersDumpPath,
LoggingEnableDebug = Logger.EnableDebug, LoggingEnableDebug = Logger.EnableDebug,
LoggingEnableStub = Logger.EnableStub, LoggingEnableStub = Logger.EnableStub,
@ -349,6 +356,7 @@ namespace Ryujinx.Configuration
public void LoadDefault() public void LoadDefault()
{ {
Graphics.MaxAnisotropy.Value = -1;
Graphics.ShadersDumpPath.Value = ""; Graphics.ShadersDumpPath.Value = "";
Logger.EnableDebug.Value = false; Logger.EnableDebug.Value = false;
Logger.EnableStub.Value = true; Logger.EnableStub.Value = true;
@ -487,6 +495,16 @@ namespace Ryujinx.Configuration
configurationFileUpdated = true; configurationFileUpdated = true;
} }
if (configurationFileFormat.Version < 4)
{
Common.Logging.Logger.PrintWarning(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 4.");
configurationFileFormat.MaxAnisotropy = -1;
configurationFileUpdated = true;
}
Graphics.MaxAnisotropy.Value = configurationFileFormat.MaxAnisotropy;
Graphics.ShadersDumpPath.Value = configurationFileFormat.GraphicsShadersDumpPath; Graphics.ShadersDumpPath.Value = configurationFileFormat.GraphicsShadersDumpPath;
Logger.EnableDebug.Value = configurationFileFormat.LoggingEnableDebug; Logger.EnableDebug.Value = configurationFileFormat.LoggingEnableDebug;
Logger.EnableStub.Value = configurationFileFormat.LoggingEnableStub; Logger.EnableStub.Value = configurationFileFormat.LoggingEnableStub;

View file

@ -8,16 +8,20 @@ namespace Ryujinx.Graphics.GAL
public int MaximumComputeSharedMemorySize { get; } public int MaximumComputeSharedMemorySize { get; }
public int StorageBufferOffsetAlignment { get; } public int StorageBufferOffsetAlignment { get; }
public float MaxSupportedAnisotropy { get; }
public Capabilities( public Capabilities(
bool supportsAstcCompression, bool supportsAstcCompression,
bool supportsNonConstantTextureOffset, bool supportsNonConstantTextureOffset,
int maximumComputeSharedMemorySize, int maximumComputeSharedMemorySize,
int storageBufferOffsetAlignment) int storageBufferOffsetAlignment,
float maxSupportedAnisotropy)
{ {
SupportsAstcCompression = supportsAstcCompression; SupportsAstcCompression = supportsAstcCompression;
SupportsNonConstantTextureOffset = supportsNonConstantTextureOffset; SupportsNonConstantTextureOffset = supportsNonConstantTextureOffset;
MaximumComputeSharedMemorySize = maximumComputeSharedMemorySize; MaximumComputeSharedMemorySize = maximumComputeSharedMemorySize;
StorageBufferOffsetAlignment = storageBufferOffsetAlignment; StorageBufferOffsetAlignment = storageBufferOffsetAlignment;
MaxSupportedAnisotropy = maxSupportedAnisotropy;
} }
} }
} }

View file

@ -5,6 +5,11 @@ namespace Ryujinx.Graphics.Gpu
/// </summary> /// </summary>
public static class GraphicsConfig public static class GraphicsConfig
{ {
/// <summary>
/// Max Anisotropy. Values range from 0 - 16. Set to -1 to let the game decide.
/// </summary>
public static float MaxAnisotropy;
/// <summary> /// <summary>
/// Base directory used to write shader code dumps. /// Base directory used to write shader code dumps.
/// Set to null to disable code dumping. /// Set to null to disable code dumping.

View file

@ -40,7 +40,11 @@ namespace Ryujinx.Graphics.Gpu.Image
float maxLod = descriptor.UnpackMaxLod(); float maxLod = descriptor.UnpackMaxLod();
float mipLodBias = descriptor.UnpackMipLodBias(); float mipLodBias = descriptor.UnpackMipLodBias();
float maxAnisotropy = descriptor.UnpackMaxAnisotropy(); float maxRequestedAnisotropy = GraphicsConfig.MaxAnisotropy >= 0 && GraphicsConfig.MaxAnisotropy <= 16 ? GraphicsConfig.MaxAnisotropy : descriptor.UnpackMaxAnisotropy();
float maxSupportedAnisotropy = context.Capabilities.MaxSupportedAnisotropy;
if (maxRequestedAnisotropy > maxSupportedAnisotropy)
maxRequestedAnisotropy = maxSupportedAnisotropy;
HostSampler = context.Renderer.CreateSampler(new SamplerCreateInfo( HostSampler = context.Renderer.CreateSampler(new SamplerCreateInfo(
minFilter, minFilter,
@ -54,7 +58,7 @@ namespace Ryujinx.Graphics.Gpu.Image
minLod, minLod,
maxLod, maxLod,
mipLodBias, mipLodBias,
maxAnisotropy)); maxRequestedAnisotropy));
} }
/// <summary> /// <summary>

View file

@ -22,12 +22,16 @@ namespace Ryujinx.Graphics.OpenGL
public static GpuVendor Vendor => _gpuVendor.Value; public static GpuVendor Vendor => _gpuVendor.Value;
private static Lazy<float> _maxSupportedAnisotropy = new Lazy<float>(GL.GetFloat((GetPName)All.MaxTextureMaxAnisotropy));
public static bool SupportsAstcCompression => _supportsAstcCompression.Value; public static bool SupportsAstcCompression => _supportsAstcCompression.Value;
public static bool SupportsNonConstantTextureOffset => _gpuVendor.Value == GpuVendor.Nvidia; public static bool SupportsNonConstantTextureOffset => _gpuVendor.Value == GpuVendor.Nvidia;
public static int MaximumComputeSharedMemorySize => _maximumComputeSharedMemorySize.Value; public static int MaximumComputeSharedMemorySize => _maximumComputeSharedMemorySize.Value;
public static int StorageBufferOffsetAlignment => _storageBufferOffsetAlignment.Value; public static int StorageBufferOffsetAlignment => _storageBufferOffsetAlignment.Value;
public static float MaxSupportedAnisotropy => _maxSupportedAnisotropy.Value;
private static bool HasExtension(string name) private static bool HasExtension(string name)
{ {
int numExtensions = GL.GetInteger(GetPName.NumExtensions); int numExtensions = GL.GetInteger(GetPName.NumExtensions);

View file

@ -67,7 +67,8 @@ namespace Ryujinx.Graphics.OpenGL
HwCapabilities.SupportsAstcCompression, HwCapabilities.SupportsAstcCompression,
HwCapabilities.SupportsNonConstantTextureOffset, HwCapabilities.SupportsNonConstantTextureOffset,
HwCapabilities.MaximumComputeSharedMemorySize, HwCapabilities.MaximumComputeSharedMemorySize,
HwCapabilities.StorageBufferOffsetAlignment); HwCapabilities.StorageBufferOffsetAlignment,
HwCapabilities.MaxSupportedAnisotropy);
} }
public ulong GetCounter(CounterType type) public ulong GetCounter(CounterType type)

View file

@ -1,5 +1,6 @@
{ {
"version": 2, "version": 4,
"max_anisotropy": -1,
"graphics_shaders_dump_path": "", "graphics_shaders_dump_path": "",
"logging_enable_debug": false, "logging_enable_debug": false,
"logging_enable_stub": true, "logging_enable_stub": true,
@ -12,6 +13,7 @@
"enable_file_log": true, "enable_file_log": true,
"system_language": "AmericanEnglish", "system_language": "AmericanEnglish",
"system_region": "USA", "system_region": "USA",
"system_time_zone": "UTC",
"docked_mode": false, "docked_mode": false,
"enable_discord_integration": true, "enable_discord_integration": true,
"enable_vsync": true, "enable_vsync": true,

View file

@ -308,6 +308,7 @@ namespace Ryujinx.Ui
HLE.Switch device = InitializeSwitchInstance(); HLE.Switch device = InitializeSwitchInstance();
// TODO: Move this somewhere else + reloadable? // TODO: Move this somewhere else + reloadable?
Graphics.Gpu.GraphicsConfig.MaxAnisotropy = ConfigurationState.Instance.Graphics.MaxAnisotropy;
Graphics.Gpu.GraphicsConfig.ShadersDumpPath = ConfigurationState.Instance.Graphics.ShadersDumpPath; Graphics.Gpu.GraphicsConfig.ShadersDumpPath = ConfigurationState.Instance.Graphics.ShadersDumpPath;
if (Directory.Exists(path)) if (Directory.Exists(path))

View file

@ -52,6 +52,7 @@ namespace Ryujinx.Ui
[GUI] ToggleButton _browseDir; [GUI] ToggleButton _browseDir;
[GUI] ToggleButton _removeDir; [GUI] ToggleButton _removeDir;
[GUI] Entry _graphicsShadersDumpPath; [GUI] Entry _graphicsShadersDumpPath;
[GUI] ComboBoxText _anisotropy;
[GUI] Image _controller1Image; [GUI] Image _controller1Image;
[GUI] ComboBoxText _controller1Type; [GUI] ComboBoxText _controller1Type;
@ -215,6 +216,7 @@ namespace Ryujinx.Ui
_systemLanguageSelect.SetActiveId(ConfigurationState.Instance.System.Language.Value.ToString()); _systemLanguageSelect.SetActiveId(ConfigurationState.Instance.System.Language.Value.ToString());
_systemRegionSelect .SetActiveId(ConfigurationState.Instance.System.Region.Value.ToString()); _systemRegionSelect .SetActiveId(ConfigurationState.Instance.System.Region.Value.ToString());
_systemTimeZoneSelect.SetActiveId(timeZoneContentManager.SanityCheckDeviceLocationName()); _systemTimeZoneSelect.SetActiveId(timeZoneContentManager.SanityCheckDeviceLocationName());
_anisotropy .SetActiveId(ConfigurationState.Instance.Graphics.MaxAnisotropy.Value.ToString());
_controller1Type .SetActiveId(ConfigurationState.Instance.Hid.ControllerType.Value.ToString()); _controller1Type .SetActiveId(ConfigurationState.Instance.Hid.ControllerType.Value.ToString());
Controller_Changed(null, null, _controller1Type.ActiveId, _controller1Image); Controller_Changed(null, null, _controller1Type.ActiveId, _controller1Image);
@ -458,6 +460,7 @@ namespace Ryujinx.Ui
ConfigurationState.Instance.System.Language.Value = (Language)Enum.Parse(typeof(Language), _systemLanguageSelect.ActiveId); ConfigurationState.Instance.System.Language.Value = (Language)Enum.Parse(typeof(Language), _systemLanguageSelect.ActiveId);
ConfigurationState.Instance.System.Region.Value = (Configuration.System.Region)Enum.Parse(typeof(Configuration.System.Region), _systemRegionSelect.ActiveId); ConfigurationState.Instance.System.Region.Value = (Configuration.System.Region)Enum.Parse(typeof(Configuration.System.Region), _systemRegionSelect.ActiveId);
ConfigurationState.Instance.Graphics.MaxAnisotropy.Value = float.Parse(_anisotropy.ActiveId);
ConfigurationState.Instance.Hid.ControllerType.Value = (ControllerType)Enum.Parse(typeof(ControllerType), _controller1Type.ActiveId); ConfigurationState.Instance.Hid.ControllerType.Value = (ControllerType)Enum.Parse(typeof(ControllerType), _controller1Type.ActiveId);
ConfigurationState.Instance.Ui.CustomThemePath.Value = _custThemePath.Buffer.Text; ConfigurationState.Instance.Ui.CustomThemePath.Value = _custThemePath.Buffer.Text;
ConfigurationState.Instance.Graphics.ShadersDumpPath.Value = _graphicsShadersDumpPath.Buffer.Text; ConfigurationState.Instance.Graphics.ShadersDumpPath.Value = _graphicsShadersDumpPath.Buffer.Text;

View file

@ -177,8 +177,8 @@
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">2</property>
<property name="padding">5</property> <property name="padding">5</property>
<property name="position">2</property>
</packing> </packing>
</child> </child>
<child> <child>
@ -247,6 +247,11 @@
</packing> </packing>
</child> </child>
</object> </object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child> </child>
</object> </object>
<packing> <packing>
@ -1452,6 +1457,52 @@
</packing> </packing>
</child> </child>
</object> </object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">5</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Graphics Shaders Dump Path</property>
<property name="label" translatable="yes">Anisotropic Filtering:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">5</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkComboBoxText" id="_anisotropy">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Change System TimeZone</property>
<property name="active_id">-1</property>
<items>
<item id="-1" translatable="yes">Auto</item>
<item id="2" translatable="yes">2x</item>
<item id="4" translatable="yes">4x</item>
<item id="8" translatable="yes">8x</item>
<item id="16" translatable="yes">16x</item>
</items>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>