mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-12-16 16:46:34 +00:00
Compare commits
9 Commits
ffe5ba784c
...
7bbe0dd09c
Author | SHA1 | Date | |
---|---|---|---|
|
7bbe0dd09c | ||
|
5dbba07e33 | ||
|
d86249cb0a | ||
|
04d68ca616 | ||
|
b49b348c96 | ||
|
6aaec6da5d | ||
|
dc3614248c | ||
|
3f6fca2921 | ||
|
89c2c6c76b |
@ -71,6 +71,8 @@ namespace Ryujinx.Graphics.GAL
|
||||
|
||||
public readonly int GatherBiasPrecision;
|
||||
|
||||
public readonly ulong MaximumGpuMemory;
|
||||
|
||||
public Capabilities(
|
||||
TargetApi api,
|
||||
string vendorName,
|
||||
@ -131,7 +133,8 @@ namespace Ryujinx.Graphics.GAL
|
||||
int shaderSubgroupSize,
|
||||
int storageBufferOffsetAlignment,
|
||||
int textureBufferOffsetAlignment,
|
||||
int gatherBiasPrecision)
|
||||
int gatherBiasPrecision,
|
||||
ulong maximumGpuMemory)
|
||||
{
|
||||
Api = api;
|
||||
VendorName = vendorName;
|
||||
@ -193,6 +196,7 @@ namespace Ryujinx.Graphics.GAL
|
||||
StorageBufferOffsetAlignment = storageBufferOffsetAlignment;
|
||||
TextureBufferOffsetAlignment = textureBufferOffsetAlignment;
|
||||
GatherBiasPrecision = gatherBiasPrecision;
|
||||
MaximumGpuMemory = maximumGpuMemory;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@ -46,7 +47,11 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||
{
|
||||
private const int MinCountForDeletion = 32;
|
||||
private const int MaxCapacity = 2048;
|
||||
private const ulong MaxTextureSizeCapacity = 1024 * 1024 * 1024; // MB;
|
||||
private const ulong MinTextureSizeCapacity = 512 * 1024 * 1024;
|
||||
private const ulong MaxTextureSizeCapacity = 4UL * 1024 * 1024 * 1024;
|
||||
private const ulong DefaultTextureSizeCapacity = 1UL * 1024 * 1024 * 1024;
|
||||
private const float MemoryScaleFactor = 0.50f;
|
||||
private ulong _maxCacheMemoryUsage = 0;
|
||||
|
||||
private readonly LinkedList<Texture> _textures;
|
||||
private ulong _totalSize;
|
||||
@ -56,6 +61,25 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||
|
||||
private readonly Dictionary<TextureDescriptor, ShortTextureCacheEntry> _shortCacheLookup;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the cache, setting the maximum texture capacity for the specified GPU context.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// If the backend GPU has 0 memory capacity, the cache size defaults to `DefaultTextureSizeCapacity`.
|
||||
/// </remarks>
|
||||
/// <param name="context">The GPU context that the cache belongs to</param>
|
||||
public void Initialize(GpuContext context)
|
||||
{
|
||||
var cacheMemory = (ulong)(context.Capabilities.MaximumGpuMemory * MemoryScaleFactor);
|
||||
|
||||
_maxCacheMemoryUsage = Math.Clamp(cacheMemory, MinTextureSizeCapacity, MaxTextureSizeCapacity);
|
||||
|
||||
if (context.Capabilities.MaximumGpuMemory == 0)
|
||||
{
|
||||
_maxCacheMemoryUsage = DefaultTextureSizeCapacity;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the automatic deletion cache.
|
||||
/// </summary>
|
||||
@ -85,7 +109,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||
texture.CacheNode = _textures.AddLast(texture);
|
||||
|
||||
if (_textures.Count > MaxCapacity ||
|
||||
(_totalSize > MaxTextureSizeCapacity && _textures.Count >= MinCountForDeletion))
|
||||
(_totalSize > _maxCacheMemoryUsage && _textures.Count >= MinCountForDeletion))
|
||||
{
|
||||
RemoveLeastUsedTexture();
|
||||
}
|
||||
@ -110,7 +134,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||
_textures.AddLast(texture.CacheNode);
|
||||
}
|
||||
|
||||
if (_totalSize > MaxTextureSizeCapacity && _textures.Count >= MinCountForDeletion)
|
||||
if (_totalSize > _maxCacheMemoryUsage && _textures.Count >= MinCountForDeletion)
|
||||
{
|
||||
RemoveLeastUsedTexture();
|
||||
}
|
||||
|
@ -68,6 +68,14 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||
_cache = new AutoDeleteCache();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the cache, setting the maximum texture capacity for the specified GPU context.
|
||||
/// </summary>
|
||||
public void Initialize()
|
||||
{
|
||||
_cache.Initialize(_context);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles marking of textures written to a memory region being (partially) remapped.
|
||||
/// </summary>
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Ryujinx.Common.Memory;
|
||||
using Ryujinx.Graphics.Gpu.Image;
|
||||
using Ryujinx.Memory;
|
||||
using Ryujinx.Memory.Range;
|
||||
using System;
|
||||
@ -64,6 +65,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||
MemoryUnmapped += Physical.BufferCache.MemoryUnmappedHandler;
|
||||
MemoryUnmapped += VirtualRangeCache.MemoryUnmappedHandler;
|
||||
MemoryUnmapped += CounterCache.MemoryUnmappedHandler;
|
||||
Physical.TextureCache.Initialize();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -22,7 +22,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
|
||||
private const ushort FileFormatVersionMajor = 1;
|
||||
private const ushort FileFormatVersionMinor = 2;
|
||||
private const uint FileFormatVersionPacked = ((uint)FileFormatVersionMajor << 16) | FileFormatVersionMinor;
|
||||
private const uint CodeGenVersion = 7331;
|
||||
private const uint CodeGenVersion = 7353;
|
||||
|
||||
private const string SharedTocFileName = "shared.toc";
|
||||
private const string SharedDataFileName = "shared.data";
|
||||
|
@ -202,7 +202,8 @@ namespace Ryujinx.Graphics.OpenGL
|
||||
shaderSubgroupSize: Constants.MaxSubgroupSize,
|
||||
storageBufferOffsetAlignment: HwCapabilities.StorageBufferOffsetAlignment,
|
||||
textureBufferOffsetAlignment: HwCapabilities.TextureBufferOffsetAlignment,
|
||||
gatherBiasPrecision: intelWindows || amdWindows ? 8 : 0); // Precision is 8 for these vendors on Vulkan.
|
||||
gatherBiasPrecision: intelWindows || amdWindows ? 8 : 0, // Precision is 8 for these vendors on Vulkan.
|
||||
maximumGpuMemory: 0);
|
||||
}
|
||||
|
||||
public void SetBufferData(BufferHandle buffer, int offset, ReadOnlySpan<byte> data)
|
||||
|
@ -190,7 +190,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||
|
||||
if (stage == ShaderStage.Vertex)
|
||||
{
|
||||
InitializePositionOutput(context);
|
||||
InitializeVertexOutputs(context);
|
||||
}
|
||||
|
||||
UInt128 usedAttributes = context.TranslatorContext.AttributeUsage.NextInputAttributesComponents;
|
||||
@ -236,12 +236,20 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||
}
|
||||
}
|
||||
|
||||
private static void InitializePositionOutput(EmitterContext context)
|
||||
private static void InitializeVertexOutputs(EmitterContext context)
|
||||
{
|
||||
for (int c = 0; c < 4; c++)
|
||||
{
|
||||
context.Store(StorageKind.Output, IoVariable.Position, null, Const(c), ConstF(c == 3 ? 1f : 0f));
|
||||
}
|
||||
|
||||
if (context.Program.ClipDistancesWritten != 0)
|
||||
{
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
context.Store(StorageKind.Output, IoVariable.ClipDistance, null, Const(i), ConstF(0f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void InitializeOutput(EmitterContext context, int location, bool perPatch)
|
||||
|
@ -781,7 +781,26 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
shaderSubgroupSize: (int)Capabilities.SubgroupSize,
|
||||
storageBufferOffsetAlignment: (int)limits.MinStorageBufferOffsetAlignment,
|
||||
textureBufferOffsetAlignment: (int)limits.MinTexelBufferOffsetAlignment,
|
||||
gatherBiasPrecision: IsIntelWindows || IsAmdWindows ? (int)Capabilities.SubTexelPrecisionBits : 0);
|
||||
gatherBiasPrecision: IsIntelWindows || IsAmdWindows ? (int)Capabilities.SubTexelPrecisionBits : 0,
|
||||
maximumGpuMemory: GetTotalGPUMemory());
|
||||
}
|
||||
|
||||
private ulong GetTotalGPUMemory()
|
||||
{
|
||||
ulong totalMemory = 0;
|
||||
|
||||
Api.GetPhysicalDeviceMemoryProperties(_physicalDevice.PhysicalDevice, out PhysicalDeviceMemoryProperties memoryProperties);
|
||||
|
||||
for (int i = 0; i < memoryProperties.MemoryHeapCount; i++)
|
||||
{
|
||||
var heap = memoryProperties.MemoryHeaps[i];
|
||||
if ((heap.Flags & MemoryHeapFlags.DeviceLocalBit) == MemoryHeapFlags.DeviceLocalBit)
|
||||
{
|
||||
totalMemory += heap.Size;
|
||||
}
|
||||
}
|
||||
|
||||
return totalMemory;
|
||||
}
|
||||
|
||||
public HardwareInfo GetHardwareInfo()
|
||||
@ -865,6 +884,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
private void PrintGpuInformation()
|
||||
{
|
||||
Logger.Notice.Print(LogClass.Gpu, $"{GpuVendor} {GpuRenderer} ({GpuVersion})");
|
||||
Logger.Notice.Print(LogClass.Gpu, $"GPU Memory: {GetTotalGPUMemory() / (1024 * 1024)} MiB");
|
||||
}
|
||||
|
||||
public void Initialize(GraphicsDebugLevel logLevel)
|
||||
|
@ -313,6 +313,33 @@ namespace Ryujinx.Input.SDL2
|
||||
return value * ConvertRate;
|
||||
}
|
||||
|
||||
private JoyconConfigControllerStick<GamepadInputId, Common.Configuration.Hid.Controller.StickInputId> GetLogicalJoyStickConfig(StickInputId inputId)
|
||||
{
|
||||
switch (inputId)
|
||||
{
|
||||
case StickInputId.Left:
|
||||
if (_configuration.RightJoyconStick.Joystick == Common.Configuration.Hid.Controller.StickInputId.Left)
|
||||
{
|
||||
return _configuration.RightJoyconStick;
|
||||
}
|
||||
else
|
||||
{
|
||||
return _configuration.LeftJoyconStick;
|
||||
}
|
||||
case StickInputId.Right:
|
||||
if (_configuration.LeftJoyconStick.Joystick == Common.Configuration.Hid.Controller.StickInputId.Right)
|
||||
{
|
||||
return _configuration.LeftJoyconStick;
|
||||
}
|
||||
else
|
||||
{
|
||||
return _configuration.RightJoyconStick;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public (float, float) GetStick(StickInputId inputId)
|
||||
{
|
||||
if (inputId == StickInputId.Unbound)
|
||||
@ -343,24 +370,26 @@ namespace Ryujinx.Input.SDL2
|
||||
|
||||
if (HasConfiguration)
|
||||
{
|
||||
if ((inputId == StickInputId.Left && _configuration.LeftJoyconStick.InvertStickX) ||
|
||||
(inputId == StickInputId.Right && _configuration.RightJoyconStick.InvertStickX))
|
||||
{
|
||||
resultX = -resultX;
|
||||
}
|
||||
var joyconStickConfig = GetLogicalJoyStickConfig(inputId);
|
||||
|
||||
if ((inputId == StickInputId.Left && _configuration.LeftJoyconStick.InvertStickY) ||
|
||||
(inputId == StickInputId.Right && _configuration.RightJoyconStick.InvertStickY))
|
||||
if (joyconStickConfig != null)
|
||||
{
|
||||
resultY = -resultY;
|
||||
}
|
||||
if (joyconStickConfig.InvertStickX)
|
||||
{
|
||||
resultX = -resultX;
|
||||
}
|
||||
|
||||
if ((inputId == StickInputId.Left && _configuration.LeftJoyconStick.Rotate90CW) ||
|
||||
(inputId == StickInputId.Right && _configuration.RightJoyconStick.Rotate90CW))
|
||||
{
|
||||
float temp = resultX;
|
||||
resultX = resultY;
|
||||
resultY = -temp;
|
||||
if (joyconStickConfig.InvertStickY)
|
||||
{
|
||||
resultY = -resultY;
|
||||
}
|
||||
|
||||
if (joyconStickConfig.Rotate90CW)
|
||||
{
|
||||
float temp = resultX;
|
||||
resultX = resultY;
|
||||
resultY = -temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,6 +53,7 @@ namespace Ryujinx.SDL2.Common
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_SetHint(SDL_HINT_APP_NAME, "Ryujinx");
|
||||
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE, "1");
|
||||
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE, "1");
|
||||
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
|
||||
|
@ -45,7 +45,6 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
||||
|
||||
private PlayerIndex _playerId;
|
||||
private int _controller;
|
||||
private int _controllerNumber;
|
||||
private string _controllerImage;
|
||||
private int _device;
|
||||
private object _configViewModel;
|
||||
@ -439,6 +438,24 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
||||
|
||||
public void LoadDevices()
|
||||
{
|
||||
string GetGamepadName(IGamepad gamepad, int controllerNumber)
|
||||
{
|
||||
return $"{GetShortGamepadName(gamepad.Name)} ({controllerNumber})";
|
||||
}
|
||||
|
||||
string GetUniqueGamepadName(IGamepad gamepad, ref int controllerNumber)
|
||||
{
|
||||
var name = GetGamepadName(gamepad, controllerNumber);
|
||||
|
||||
if (Devices.Any(controller => controller.Name == name))
|
||||
{
|
||||
controllerNumber++;
|
||||
name = GetGamepadName(gamepad, controllerNumber);
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
lock (Devices)
|
||||
{
|
||||
Devices.Clear();
|
||||
@ -455,23 +472,18 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
||||
}
|
||||
}
|
||||
|
||||
var controllerNumber = 0;
|
||||
foreach (string id in _mainWindow.InputManager.GamepadDriver.GamepadsIds)
|
||||
{
|
||||
using IGamepad gamepad = _mainWindow.InputManager.GamepadDriver.GetGamepad(id);
|
||||
|
||||
if (gamepad != null)
|
||||
{
|
||||
if (Devices.Any(controller => GetShortGamepadId(controller.Id) == GetShortGamepadId(gamepad.Id)))
|
||||
{
|
||||
_controllerNumber++;
|
||||
}
|
||||
|
||||
Devices.Add((DeviceType.Controller, id, $"{GetShortGamepadName(gamepad.Name)} ({_controllerNumber})"));
|
||||
var name = GetUniqueGamepadName(gamepad, ref controllerNumber);
|
||||
Devices.Add((DeviceType.Controller, id, name));
|
||||
}
|
||||
}
|
||||
|
||||
_controllerNumber = 0;
|
||||
|
||||
DeviceList.AddRange(Devices.Select(x => x.Name));
|
||||
Device = Math.Min(Device, DeviceList.Count);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user