mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-07-25 21:27:14 +02:00
misc: chore: Use collection expressions in Gpu project
This commit is contained in:
parent
ae90db2040
commit
aa0cb50c5d
41 changed files with 365 additions and 304 deletions
|
@ -112,10 +112,10 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||
/// </summary>
|
||||
public AutoDeleteCache()
|
||||
{
|
||||
_textures = new LinkedList<Texture>();
|
||||
_textures = [];
|
||||
|
||||
_shortCacheBuilder = new HashSet<ShortTextureCacheEntry>();
|
||||
_shortCache = new HashSet<ShortTextureCacheEntry>();
|
||||
_shortCacheBuilder = [];
|
||||
_shortCache = [];
|
||||
|
||||
_shortCacheLookup = new Dictionary<TextureDescriptor, ShortTextureCacheEntry>();
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||
public PoolCache(GpuContext context)
|
||||
{
|
||||
_context = context;
|
||||
_pools = new LinkedList<T>();
|
||||
_pools = [];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -10,8 +10,8 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||
/// </summary>
|
||||
struct SamplerDescriptor
|
||||
{
|
||||
private static readonly float[] _f5ToF32ConversionLut = new float[]
|
||||
{
|
||||
private static readonly float[] _f5ToF32ConversionLut =
|
||||
[
|
||||
0.0f,
|
||||
0.055555556f,
|
||||
0.1f,
|
||||
|
@ -43,13 +43,13 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||
0.45833334f,
|
||||
0.46153846f,
|
||||
0.4642857f,
|
||||
0.46666667f,
|
||||
};
|
||||
0.46666667f
|
||||
];
|
||||
|
||||
private static readonly float[] _maxAnisotropyLut = new float[]
|
||||
{
|
||||
1, 2, 4, 6, 8, 10, 12, 16,
|
||||
};
|
||||
private static readonly float[] _maxAnisotropyLut =
|
||||
[
|
||||
1, 2, 4, 6, 8, 10, 12, 16
|
||||
];
|
||||
|
||||
private const float Frac8ToF32 = 1.0f / 256.0f;
|
||||
|
||||
|
|
|
@ -260,8 +260,8 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||
|
||||
_viewStorage = this;
|
||||
|
||||
_views = new List<Texture>();
|
||||
_poolOwners = new List<TexturePoolOwner>();
|
||||
_views = [];
|
||||
_poolOwners = [];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -549,7 +549,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||
_channel = channel;
|
||||
_cacheFromBuffer = new Dictionary<CacheEntryFromBufferKey, CacheEntryFromBuffer>();
|
||||
_cacheFromPool = new Dictionary<CacheEntryFromPoolKey, CacheEntry>();
|
||||
_lruCache = new LinkedList<CacheEntryFromBuffer>();
|
||||
_lruCache = [];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1116,7 +1116,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||
{
|
||||
if (key.MatchesPool(pool))
|
||||
{
|
||||
(keysToRemove ??= new()).Add(key);
|
||||
(keysToRemove ??= []).Add(key);
|
||||
|
||||
if (key.IsImage)
|
||||
{
|
||||
|
|
|
@ -103,11 +103,11 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||
|
||||
for (int stage = 0; stage < stages; stage++)
|
||||
{
|
||||
_textureBindings[stage] = Array.Empty<TextureBindingInfo>();
|
||||
_imageBindings[stage] = Array.Empty<TextureBindingInfo>();
|
||||
_textureBindings[stage] = [];
|
||||
_imageBindings[stage] = [];
|
||||
}
|
||||
|
||||
_textureCounts = Array.Empty<int>();
|
||||
_textureCounts = [];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -58,15 +58,15 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||
_context = context;
|
||||
_physicalMemory = physicalMemory;
|
||||
|
||||
_textures = new MultiRangeList<Texture>();
|
||||
_partiallyMappedTextures = new HashSet<Texture>();
|
||||
_textures = [];
|
||||
_partiallyMappedTextures = [];
|
||||
|
||||
_texturesLock = new ReaderWriterLockSlim();
|
||||
|
||||
_textureOverlaps = new Texture[OverlapsBufferInitialCapacity];
|
||||
_overlapInfo = new OverlapInfo[OverlapsBufferInitialCapacity];
|
||||
|
||||
_cache = new AutoDeleteCache();
|
||||
_cache = [];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -892,7 +892,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||
// otherwise we only need the data that is copied from the existing texture, without loading the CPU data.
|
||||
bool updateNewTexture = texture.Width > overlap.Width || texture.Height > overlap.Height;
|
||||
|
||||
texture.InitializeGroup(true, true, new List<TextureIncompatibleOverlap>());
|
||||
texture.InitializeGroup(true, true, []);
|
||||
texture.InitializeData(false, updateNewTexture);
|
||||
|
||||
overlap.SynchronizeMemory();
|
||||
|
@ -947,7 +947,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||
bool hasLayerViews = false;
|
||||
bool hasMipViews = false;
|
||||
|
||||
List<TextureIncompatibleOverlap> incompatibleOverlaps = new();
|
||||
List<TextureIncompatibleOverlap> incompatibleOverlaps = [];
|
||||
|
||||
for (int index = 0; index < overlapsCount; index++)
|
||||
{
|
||||
|
|
|
@ -1019,7 +1019,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||
int endOffset = _allOffsets[viewEnd] + _sliceSizes[lastLevel];
|
||||
int size = endOffset - offset;
|
||||
|
||||
List<RegionHandle> result = new();
|
||||
List<RegionHandle> result = [];
|
||||
|
||||
for (int i = 0; i < TextureRange.Count; i++)
|
||||
{
|
||||
|
@ -1315,7 +1315,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||
|
||||
if (_isBuffer)
|
||||
{
|
||||
handles = Array.Empty<TextureGroupHandle>();
|
||||
handles = [];
|
||||
}
|
||||
else if (!(_hasMipViews || _hasLayerViews))
|
||||
{
|
||||
|
@ -1339,7 +1339,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||
|
||||
TextureGroupHandle groupHandle = new(this, 0, Storage.Size, _views, 0, 0, 0, _allOffsets.Length, cpuRegionHandles);
|
||||
|
||||
handles = new TextureGroupHandle[] { groupHandle };
|
||||
handles = [groupHandle];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1355,7 +1355,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||
|
||||
if (_is3D)
|
||||
{
|
||||
List<TextureGroupHandle> handlesList = new();
|
||||
List<TextureGroupHandle> handlesList = [];
|
||||
|
||||
for (int i = 0; i < levelHandles; i++)
|
||||
{
|
||||
|
@ -1438,8 +1438,8 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||
// Get the location of each texture within its storage, so we can find the handles to apply the dependency to.
|
||||
// This can consist of multiple disjoint regions, for example if this is a mip slice of an array texture.
|
||||
|
||||
List<(int BaseHandle, int RegionCount)> targetRange = new();
|
||||
List<(int BaseHandle, int RegionCount)> otherRange = new();
|
||||
List<(int BaseHandle, int RegionCount)> targetRange = [];
|
||||
List<(int BaseHandle, int RegionCount)> otherRange = [];
|
||||
|
||||
EvaluateRelevantHandles(firstLayer, firstLevel, other.Info.GetSlices(), other.Info.Levels, (baseHandle, regionCount, split) => targetRange.Add((baseHandle, regionCount)));
|
||||
otherGroup.EvaluateRelevantHandles(other, (baseHandle, regionCount, split) => otherRange.Add((baseHandle, regionCount)));
|
||||
|
|
|
@ -134,8 +134,8 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||
|
||||
Offset = offset;
|
||||
Size = (int)size;
|
||||
Overlaps = new List<Texture>();
|
||||
Dependencies = new List<TextureDependency>();
|
||||
Overlaps = [];
|
||||
Dependencies = [];
|
||||
|
||||
BaseSlice = baseSlice;
|
||||
SliceCount = sliceCount;
|
||||
|
|
|
@ -97,7 +97,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||
/// </summary>
|
||||
public TextureAliasList()
|
||||
{
|
||||
_aliases = new List<Alias>();
|
||||
_aliases = [];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue