diff --git a/src/Ryujinx.Graphics.Gpu/Image/AutoDeleteCache.cs b/src/Ryujinx.Graphics.Gpu/Image/AutoDeleteCache.cs
index f37978293..9be776037 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/AutoDeleteCache.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/AutoDeleteCache.cs
@@ -53,11 +53,6 @@ namespace Ryujinx.Graphics.Gpu.Image
private ulong MaxTextureSizeCapacity = 2 * GiB;
private const ulong MinTextureSizeCapacity = 512 * MiB;
private const ulong DefaultTextureSizeCapacity = 1 * GiB;
- private const ulong TextureSizeCapacity4GiB = 2 * GiB;
- private const ulong TextureSizeCapacity6GiB = 4 * GiB;
- private const ulong TextureSizeCapacity8GiB = 6 * GiB;
- private const ulong TextureSizeCapacity10GiB = 10 * GiB;
- private const ulong TextureSizeCapacity12GiB = 12 * GiB;
private const float MemoryScaleFactor = 0.50f;
private ulong _maxCacheMemoryUsage = DefaultTextureSizeCapacity;
@@ -82,25 +77,18 @@ namespace Ryujinx.Graphics.Gpu.Image
/// The amount of physical CPU Memory available on the device.
public void Initialize(GpuContext context, ulong cpuMemorySize)
{
- var cpuMemorySizeGiB = cpuMemorySize / GiB;
- var MaximumGpuMemoryGiB = context.Capabilities.MaximumGpuMemory / GiB;
+ ulong cpuMemorySizeGiB = cpuMemorySize / GiB;
+ ulong MaximumGpuMemoryGiB = context.Capabilities.MaximumGpuMemory / GiB;
+ ulong TextureSizeCapacity = cpuMemorySize - (2 * GiB);
- if (context.Capabilities.MaximumGpuMemory == 0)
- {
- MaxTextureSizeCapacity = DefaultTextureSizeCapacity;
- }
- else
- MaxTextureSizeCapacity = cpuMemorySizeGiB switch
- {
- < 6 when MaximumGpuMemoryGiB < 6 => DefaultTextureSizeCapacity,
- < 6 => TextureSizeCapacity4GiB,
- 6 => TextureSizeCapacity6GiB,
- 8 => TextureSizeCapacity8GiB,
- 10 => TextureSizeCapacity10GiB,
- _ => TextureSizeCapacity12GiB
- };
+ MaxTextureSizeCapacity =
+ context.Capabilities.MaximumGpuMemory == 0 || cpuMemorySizeGiB < 6 && MaximumGpuMemoryGiB < 6
+ ? DefaultTextureSizeCapacity
+ : cpuMemorySizeGiB < 10
+ ? TextureSizeCapacity
+ : cpuMemorySize;
- var cacheMemory = (ulong)(context.Capabilities.MaximumGpuMemory * MemoryScaleFactor);
+ ulong cacheMemory = (ulong)(context.Capabilities.MaximumGpuMemory * MemoryScaleFactor);
_maxCacheMemoryUsage = Math.Clamp(cacheMemory, MinTextureSizeCapacity, MaxTextureSizeCapacity);
@@ -177,10 +165,10 @@ namespace Ryujinx.Graphics.Gpu.Image
///
private void RemoveLeastUsedTexture()
{
- if (_textures.First != null)
- {
- Texture oldestTexture = _textures.First.Value;
+ Texture oldestTexture = _textures.First?.Value;
+ if (oldestTexture != null)
+ {
_totalSize -= oldestTexture.Size;
if (!oldestTexture.CheckModified(false))
@@ -206,11 +194,11 @@ namespace Ryujinx.Graphics.Gpu.Image
/// The texture to be removed from the cache
/// True to remove the texture if it was on the cache
/// True if the texture was found and removed, false otherwise
- public bool Remove(Texture texture, bool flush)
+ public void Remove(Texture texture, bool flush)
{
if (texture.CacheNode == null)
{
- return false;
+ return;
}
// Remove our reference to this texture.
@@ -225,7 +213,7 @@ namespace Ryujinx.Graphics.Gpu.Image
texture.CacheNode = null;
- return texture.DecrementReferenceCount();
+ texture.DecrementReferenceCount();
}
///
@@ -241,10 +229,8 @@ namespace Ryujinx.Graphics.Gpu.Image
{
return entry.Texture;
}
- else
- {
- _shortCacheLookup.Remove(descriptor);
- }
+
+ _shortCacheLookup.Remove(descriptor);
}
return null;