Make structs readonly when applicable (#4002)

* Make all structs readonly when applicable. It should reduce amount of needless defensive copies

* Make structs with trivial boilerplate equality code record structs

* Remove unnecessary readonly modifiers from TextureCreateInfo

* Make BitMap structs readonly too
This commit is contained in:
Andrey Sukharev
2022-12-05 16:47:39 +03:00
committed by GitHub
parent ae13f0ab4d
commit 4da44e09cb
133 changed files with 156 additions and 378 deletions

View File

@ -1,6 +1,6 @@
namespace Ryujinx.Graphics.Vulkan
{
struct BitMap
readonly struct BitMap
{
public const int IntSize = 64;

View File

@ -2,7 +2,7 @@
namespace Ryujinx.Graphics.Vulkan
{
struct BufferState : IDisposable
readonly struct BufferState : IDisposable
{
public static BufferState Null => new BufferState(null, 0, 0);

View File

@ -106,7 +106,7 @@ namespace Ryujinx.Graphics.Vulkan
}
}
struct TopologyConversionIndirectCacheKey : ICacheKey
readonly struct TopologyConversionIndirectCacheKey : ICacheKey
{
private readonly TopologyConversionCacheKey _baseKey;
private readonly BufferHolder _indirectDataBuffer;
@ -178,7 +178,7 @@ namespace Ryujinx.Graphics.Vulkan
}
}
struct Dependency
readonly struct Dependency
{
private readonly BufferHolder _buffer;
private readonly int _offset;

View File

@ -3,7 +3,7 @@ using System;
namespace Ryujinx.Graphics.Vulkan
{
struct CommandBufferScoped : IDisposable
readonly struct CommandBufferScoped : IDisposable
{
private readonly CommandBufferPool _pool;
public CommandBuffer CommandBuffer { get; }

View File

@ -3,7 +3,7 @@ using System;
namespace Ryujinx.Graphics.Vulkan
{
struct DisposableBuffer : IDisposable
readonly struct DisposableBuffer : IDisposable
{
private readonly Vk _api;
private readonly Device _device;

View File

@ -3,7 +3,7 @@ using System;
namespace Ryujinx.Graphics.Vulkan
{
struct DisposableBufferView : System.IDisposable
readonly struct DisposableBufferView : System.IDisposable
{
private readonly Vk _api;
private readonly Device _device;

View File

@ -3,7 +3,7 @@ using System;
namespace Ryujinx.Graphics.Vulkan
{
struct DisposableFramebuffer : IDisposable
readonly struct DisposableFramebuffer : IDisposable
{
private readonly Vk _api;
private readonly Device _device;

View File

@ -3,7 +3,7 @@ using System;
namespace Ryujinx.Graphics.Vulkan
{
struct DisposableImage : IDisposable
readonly struct DisposableImage : IDisposable
{
private readonly Vk _api;
private readonly Device _device;

View File

@ -3,7 +3,7 @@ using System;
namespace Ryujinx.Graphics.Vulkan
{
struct DisposableImageView : IDisposable
readonly struct DisposableImageView : IDisposable
{
private readonly Vk _api;
private readonly Device _device;

View File

@ -3,7 +3,7 @@ using System;
namespace Ryujinx.Graphics.Vulkan
{
struct DisposableMemory : IDisposable
readonly struct DisposableMemory : IDisposable
{
private readonly Vk _api;
private readonly Device _device;

View File

@ -3,7 +3,7 @@ using System;
namespace Ryujinx.Graphics.Vulkan
{
struct DisposablePipeline : IDisposable
readonly struct DisposablePipeline : IDisposable
{
private readonly Vk _api;
private readonly Device _device;

View File

@ -3,7 +3,7 @@ using System;
namespace Ryujinx.Graphics.Vulkan
{
struct DisposableRenderPass : IDisposable
readonly struct DisposableRenderPass : IDisposable
{
private readonly Vk _api;
private readonly Device _device;

View File

@ -3,7 +3,7 @@ using System;
namespace Ryujinx.Graphics.Vulkan
{
struct DisposableSampler : IDisposable
readonly struct DisposableSampler : IDisposable
{
private readonly Vk _api;
private readonly Device _device;

View File

@ -2,7 +2,7 @@
namespace Ryujinx.Graphics.Vulkan
{
struct HardwareCapabilities
readonly struct HardwareCapabilities
{
public readonly bool SupportsIndexTypeUint8;
public readonly bool SupportsCustomBorderColor;

View File

@ -3,7 +3,7 @@ using System;
namespace Ryujinx.Graphics.Vulkan
{
struct MemoryAllocation : IDisposable
readonly struct MemoryAllocation : IDisposable
{
private readonly MemoryAllocatorBlockList _owner;
private readonly MemoryAllocatorBlockList.Block _block;

View File

@ -17,7 +17,7 @@ namespace Ryujinx.Graphics.Vulkan
public ulong Size { get; }
public bool Mapped => HostPointer != IntPtr.Zero;
private struct Range : IComparable<Range>
private readonly struct Range : IComparable<Range>
{
public ulong Offset { get; }
public ulong Size { get; }

View File

@ -14,7 +14,7 @@ namespace Ryujinx.Graphics.Vulkan
private readonly VulkanRenderer _gd;
private readonly BufferHolder _buffer;
private struct PendingCopy
private readonly struct PendingCopy
{
public FenceHolder Fence { get; }
public int Size { get; }