diff --git a/src/Ryujinx.Graphics.Metal/BufferHolder.cs b/src/Ryujinx.Graphics.Metal/BufferHolder.cs index 5a44dc1fe..630571658 100644 --- a/src/Ryujinx.Graphics.Metal/BufferHolder.cs +++ b/src/Ryujinx.Graphics.Metal/BufferHolder.cs @@ -302,7 +302,7 @@ namespace Ryujinx.Graphics.Metal return null; } - I8ToI16CacheKey key = new I8ToI16CacheKey(_renderer); + I8ToI16CacheKey key = new(_renderer); if (!_cachedConvertedBuffers.TryGetValue(offset, size, key, out BufferHolder holder)) { @@ -325,7 +325,7 @@ namespace Ryujinx.Graphics.Metal return null; } - TopologyConversionCacheKey key = new TopologyConversionCacheKey(_renderer, pattern, indexSize); + TopologyConversionCacheKey key = new(_renderer, pattern, indexSize); if (!_cachedConvertedBuffers.TryGetValue(offset, size, key, out BufferHolder holder)) { diff --git a/src/Ryujinx.Graphics.Metal/BufferManager.cs b/src/Ryujinx.Graphics.Metal/BufferManager.cs index 166f5b4f2..73a8d6fe7 100644 --- a/src/Ryujinx.Graphics.Metal/BufferManager.cs +++ b/src/Ryujinx.Graphics.Metal/BufferManager.cs @@ -74,7 +74,7 @@ namespace Ryujinx.Graphics.Metal return BufferHandle.Null; } - BufferHolder holder = new BufferHolder(_renderer, _pipeline, buffer, size); + BufferHolder holder = new(_renderer, _pipeline, buffer, size); BufferCount++; diff --git a/src/Ryujinx.Graphics.Metal/CommandBufferEncoder.cs b/src/Ryujinx.Graphics.Metal/CommandBufferEncoder.cs index c9a337bb0..3bc30e239 100644 --- a/src/Ryujinx.Graphics.Metal/CommandBufferEncoder.cs +++ b/src/Ryujinx.Graphics.Metal/CommandBufferEncoder.cs @@ -149,7 +149,7 @@ class CommandBufferEncoder { EndCurrentPass(); - using MTLBlitPassDescriptor descriptor = new MTLBlitPassDescriptor(); + using MTLBlitPassDescriptor descriptor = new(); MTLBlitCommandEncoder blitCommandEncoder = _commandBuffer.BlitCommandEncoder(descriptor); CurrentEncoder = blitCommandEncoder; diff --git a/src/Ryujinx.Graphics.Metal/DepthStencilCache.cs b/src/Ryujinx.Graphics.Metal/DepthStencilCache.cs index 92a24b99d..47d996010 100644 --- a/src/Ryujinx.Graphics.Metal/DepthStencilCache.cs +++ b/src/Ryujinx.Graphics.Metal/DepthStencilCache.cs @@ -25,7 +25,7 @@ namespace Ryujinx.Graphics.Metal ref StencilUid frontUid = ref descriptor.FrontFace; - using MTLStencilDescriptor frontFaceStencil = new MTLStencilDescriptor + using MTLStencilDescriptor frontFaceStencil = new() { StencilFailureOperation = frontUid.StencilFailureOperation, DepthFailureOperation = frontUid.DepthFailureOperation, @@ -37,7 +37,7 @@ namespace Ryujinx.Graphics.Metal ref StencilUid backUid = ref descriptor.BackFace; - using MTLStencilDescriptor backFaceStencil = new MTLStencilDescriptor + using MTLStencilDescriptor backFaceStencil = new() { StencilFailureOperation = backUid.StencilFailureOperation, DepthFailureOperation = backUid.DepthFailureOperation, @@ -47,7 +47,7 @@ namespace Ryujinx.Graphics.Metal WriteMask = backUid.WriteMask }; - MTLDepthStencilDescriptor mtlDescriptor = new MTLDepthStencilDescriptor + MTLDepthStencilDescriptor mtlDescriptor = new() { DepthCompareFunction = descriptor.DepthCompareFunction, DepthWriteEnabled = descriptor.DepthWriteEnabled diff --git a/src/Ryujinx.Graphics.Metal/EncoderState.cs b/src/Ryujinx.Graphics.Metal/EncoderState.cs index 28b59736a..64c50d71b 100644 --- a/src/Ryujinx.Graphics.Metal/EncoderState.cs +++ b/src/Ryujinx.Graphics.Metal/EncoderState.cs @@ -165,7 +165,7 @@ namespace Ryujinx.Graphics.Metal { // Inherit render target related information without causing a render encoder split. - RenderTargetCopy oldState = new RenderTargetCopy + RenderTargetCopy oldState = new() { Scissors = other.Scissors, RenderTargets = other.RenderTargets, diff --git a/src/Ryujinx.Graphics.Metal/EncoderStateManager.cs b/src/Ryujinx.Graphics.Metal/EncoderStateManager.cs index bfd9a0348..7901e5a52 100644 --- a/src/Ryujinx.Graphics.Metal/EncoderStateManager.cs +++ b/src/Ryujinx.Graphics.Metal/EncoderStateManager.cs @@ -125,7 +125,7 @@ namespace Ryujinx.Graphics.Metal public readonly MTLRenderCommandEncoder CreateRenderCommandEncoder() { // Initialise Pass & State - using MTLRenderPassDescriptor renderPassDescriptor = new MTLRenderPassDescriptor(); + using MTLRenderPassDescriptor renderPassDescriptor = new(); for (int i = 0; i < Constants.MaxColorAttachments; i++) { @@ -185,7 +185,7 @@ namespace Ryujinx.Graphics.Metal public readonly MTLComputeCommandEncoder CreateComputeCommandEncoder() { - using MTLComputePassDescriptor descriptor = new MTLComputePassDescriptor(); + using MTLComputePassDescriptor descriptor = new(); MTLComputeCommandEncoder computeCommandEncoder = _pipeline.CommandBuffer.ComputeCommandEncoder(descriptor); return computeCommandEncoder; diff --git a/src/Ryujinx.Graphics.Metal/HelperShader.cs b/src/Ryujinx.Graphics.Metal/HelperShader.cs index e72ab6991..48b9b9f3a 100644 --- a/src/Ryujinx.Graphics.Metal/HelperShader.cs +++ b/src/Ryujinx.Graphics.Metal/HelperShader.cs @@ -239,7 +239,7 @@ namespace Ryujinx.Graphics.Metal buffer.Holder.SetDataUnchecked(buffer.Offset, region); _pipeline.SetUniformBuffers([new BufferAssignment(0, buffer.Range)]); - Rectangle rect = new Rectangle( + Rectangle rect = new( MathF.Min(dstRegion.X1, dstRegion.X2), MathF.Min(dstRegion.Y1, dstRegion.Y2), MathF.Abs(dstRegion.X2 - dstRegion.X1), @@ -365,7 +365,7 @@ namespace Ryujinx.Graphics.Metal Span viewports = stackalloc Viewport[16]; - Rectangle rect = new Rectangle( + Rectangle rect = new( MathF.Min(dstRegion.X1, dstRegion.X2), MathF.Min(dstRegion.Y1, dstRegion.Y2), MathF.Abs(dstRegion.X2 - dstRegion.X1), @@ -527,7 +527,7 @@ namespace Ryujinx.Graphics.Metal Span viewports = stackalloc Viewport[16]; - Rectangle rect = new Rectangle( + Rectangle rect = new( MathF.Min(dstRegion.X1, dstRegion.X2), MathF.Min(dstRegion.Y1, dstRegion.Y2), MathF.Abs(dstRegion.X2 - dstRegion.X1), diff --git a/src/Ryujinx.Graphics.Metal/MetalRenderer.cs b/src/Ryujinx.Graphics.Metal/MetalRenderer.cs index cfda31e66..3ed60103e 100644 --- a/src/Ryujinx.Graphics.Metal/MetalRenderer.cs +++ b/src/Ryujinx.Graphics.Metal/MetalRenderer.cs @@ -253,7 +253,7 @@ namespace Ryujinx.Graphics.Metal public ICounterEvent ReportCounter(CounterType type, EventHandler resultHandler, float divisor, bool hostReserved) { // https://developer.apple.com/documentation/metal/gpu_counters_and_counter_sample_buffers/creating_a_counter_sample_buffer_to_store_a_gpu_s_counter_data_during_a_pass?language=objc - CounterEvent counterEvent = new CounterEvent(); + CounterEvent counterEvent = new(); resultHandler?.Invoke(counterEvent, type == CounterType.SamplesPassed ? (ulong)1 : 0); return counterEvent; } diff --git a/src/Ryujinx.Graphics.Metal/Pipeline.cs b/src/Ryujinx.Graphics.Metal/Pipeline.cs index d7fbebada..aebcb5493 100644 --- a/src/Ryujinx.Graphics.Metal/Pipeline.cs +++ b/src/Ryujinx.Graphics.Metal/Pipeline.cs @@ -149,8 +149,8 @@ namespace Ryujinx.Graphics.Metal public void Present(CAMetalDrawable drawable, Texture src, Extents2D srcRegion, Extents2D dstRegion, bool isLinear) { // TODO: Clean this up - TextureCreateInfo textureInfo = new TextureCreateInfo((int)drawable.Texture.Width, (int)drawable.Texture.Height, (int)drawable.Texture.Depth, (int)drawable.Texture.MipmapLevelCount, (int)drawable.Texture.SampleCount, 0, 0, 0, Format.B8G8R8A8Unorm, 0, Target.Texture2D, SwizzleComponent.Red, SwizzleComponent.Green, SwizzleComponent.Blue, SwizzleComponent.Alpha); - Texture dst = new Texture(_device, _renderer, this, textureInfo, drawable.Texture, 0, 0); + TextureCreateInfo textureInfo = new((int)drawable.Texture.Width, (int)drawable.Texture.Height, (int)drawable.Texture.Depth, (int)drawable.Texture.MipmapLevelCount, (int)drawable.Texture.SampleCount, 0, 0, 0, Format.B8G8R8A8Unorm, 0, Target.Texture2D, SwizzleComponent.Red, SwizzleComponent.Green, SwizzleComponent.Blue, SwizzleComponent.Alpha); + Texture dst = new(_device, _renderer, this, textureInfo, drawable.Texture, 0, 0); _renderer.HelperShader.BlitColor(Cbs, src, dst, srcRegion, dstRegion, isLinear, true); diff --git a/src/Ryujinx.Graphics.Metal/Program.cs b/src/Ryujinx.Graphics.Metal/Program.cs index 780725400..a24ad754d 100644 --- a/src/Ryujinx.Graphics.Metal/Program.cs +++ b/src/Ryujinx.Graphics.Metal/Program.cs @@ -56,7 +56,7 @@ namespace Ryujinx.Graphics.Metal { ShaderSource shader = _shaders[i]; - using MTLCompileOptions compileOptions = new MTLCompileOptions + using MTLCompileOptions compileOptions = new() { PreserveInvariance = true, LanguageVersion = MTLLanguageVersion.Version31, diff --git a/src/Ryujinx.Graphics.Metal/SamplerHolder.cs b/src/Ryujinx.Graphics.Metal/SamplerHolder.cs index f1270443b..a448b26fe 100644 --- a/src/Ryujinx.Graphics.Metal/SamplerHolder.cs +++ b/src/Ryujinx.Graphics.Metal/SamplerHolder.cs @@ -21,7 +21,7 @@ namespace Ryujinx.Graphics.Metal MTLSamplerBorderColor borderColor = GetConstrainedBorderColor(info.BorderColor, out _); - using MTLSamplerDescriptor descriptor = new MTLSamplerDescriptor + using MTLSamplerDescriptor descriptor = new() { BorderColor = borderColor, MinFilter = minFilter, diff --git a/src/Ryujinx.Graphics.Metal/State/PipelineState.cs b/src/Ryujinx.Graphics.Metal/State/PipelineState.cs index 1fa83e8d7..14073dbe1 100644 --- a/src/Ryujinx.Graphics.Metal/State/PipelineState.cs +++ b/src/Ryujinx.Graphics.Metal/State/PipelineState.cs @@ -118,7 +118,7 @@ namespace Ryujinx.Graphics.Metal private readonly MTLVertexDescriptor BuildVertexDescriptor() { - MTLVertexDescriptor vertexDescriptor = new MTLVertexDescriptor(); + MTLVertexDescriptor vertexDescriptor = new(); for (int i = 0; i < VertexAttributeDescriptionsCount; i++) { @@ -146,7 +146,7 @@ namespace Ryujinx.Graphics.Metal private MTLRenderPipelineDescriptor CreateRenderDescriptor(Program program) { - MTLRenderPipelineDescriptor renderPipelineDescriptor = new MTLRenderPipelineDescriptor(); + MTLRenderPipelineDescriptor renderPipelineDescriptor = new(); for (int i = 0; i < Constants.MaxColorAttachments; i++) { @@ -217,7 +217,7 @@ namespace Ryujinx.Graphics.Metal using MTLRenderPipelineDescriptor descriptor = CreateRenderDescriptor(program); - NSError error = new NSError(IntPtr.Zero); + NSError error = new(IntPtr.Zero); pipelineState = device.NewRenderPipelineState(descriptor, ref error); if (error != IntPtr.Zero) { @@ -240,7 +240,7 @@ namespace Ryujinx.Graphics.Metal throw new InvalidOperationException($"Local thread size for compute cannot be 0 in any dimension."); } - MTLComputePipelineDescriptor descriptor = new MTLComputePipelineDescriptor + MTLComputePipelineDescriptor descriptor = new() { ComputeFunction = program.ComputeFunction, MaxTotalThreadsPerThreadgroup = maxThreads, @@ -259,7 +259,7 @@ namespace Ryujinx.Graphics.Metal using MTLComputePipelineDescriptor descriptor = CreateComputeDescriptor(program); - NSError error = new NSError(IntPtr.Zero); + NSError error = new(IntPtr.Zero); pipelineState = device.NewComputePipelineState(descriptor, MTLPipelineOption.None, 0, ref error); if (error != IntPtr.Zero) { diff --git a/src/Ryujinx.Graphics.Metal/Texture.cs b/src/Ryujinx.Graphics.Metal/Texture.cs index 749da7d48..754bf1742 100644 --- a/src/Ryujinx.Graphics.Metal/Texture.cs +++ b/src/Ryujinx.Graphics.Metal/Texture.cs @@ -18,7 +18,7 @@ namespace Ryujinx.Graphics.Metal { MTLPixelFormat pixelFormat = FormatTable.GetFormat(Info.Format); - MTLTextureDescriptor descriptor = new MTLTextureDescriptor + MTLTextureDescriptor descriptor = new() { PixelFormat = pixelFormat, Usage = MTLTextureUsage.Unknown, diff --git a/src/Ryujinx.Graphics.Metal/TextureCopy.cs b/src/Ryujinx.Graphics.Metal/TextureCopy.cs index b91a3cd89..afd3e961f 100644 --- a/src/Ryujinx.Graphics.Metal/TextureCopy.cs +++ b/src/Ryujinx.Graphics.Metal/TextureCopy.cs @@ -33,8 +33,8 @@ namespace Ryujinx.Graphics.Metal ulong bytesPerRow = (ulong)BitUtils.AlignUp(blockWidth * info.BytesPerPixel, 4); ulong bytesPerImage = bytesPerRow * (ulong)blockHeight; - MTLOrigin origin = new MTLOrigin { x = (ulong)x, y = (ulong)y, z = is3D ? (ulong)dstLayer : 0 }; - MTLSize region = new MTLSize { width = (ulong)width, height = (ulong)height, depth = 1 }; + MTLOrigin origin = new() { x = (ulong)x, y = (ulong)y, z = is3D ? (ulong)dstLayer : 0 }; + MTLSize region = new() { width = (ulong)width, height = (ulong)height, depth = 1 }; uint layer = is3D ? 0 : (uint)dstLayer; diff --git a/src/Ryujinx.Graphics.Metal/Window.cs b/src/Ryujinx.Graphics.Metal/Window.cs index f3c9133ab..0b6c6c4d2 100644 --- a/src/Ryujinx.Graphics.Metal/Window.cs +++ b/src/Ryujinx.Graphics.Metal/Window.cs @@ -47,7 +47,7 @@ namespace Ryujinx.Graphics.Metal if (_requestedWidth != 0 && _requestedHeight != 0) { // TODO: This is actually a CGSize, but there is no overload for that, so fill the first two fields of rect with the size. - NSRect rect = new NSRect(_requestedWidth, _requestedHeight, 0, 0); + NSRect rect = new(_requestedWidth, _requestedHeight, 0, 0); ObjectiveC.objc_msgSend(_metalLayer, "setDrawableSize:", rect); @@ -62,7 +62,7 @@ namespace Ryujinx.Graphics.Metal { ResizeIfNeeded(); - CAMetalDrawable drawable = new CAMetalDrawable(ObjectiveC.IntPtr_objc_msgSend(_metalLayer, "nextDrawable")); + CAMetalDrawable drawable = new(ObjectiveC.IntPtr_objc_msgSend(_metalLayer, "nextDrawable")); _width = (int)drawable.Texture.Width; _height = (int)drawable.Texture.Height;