diff --git a/src/Ryujinx.Graphics.Device/DeviceState.cs b/src/Ryujinx.Graphics.Device/DeviceState.cs index 0dd4f5904..11d8e3ac2 100644 --- a/src/Ryujinx.Graphics.Device/DeviceState.cs +++ b/src/Ryujinx.Graphics.Device/DeviceState.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; +using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -32,15 +33,15 @@ namespace Ryujinx.Graphics.Device _debugLogCallback = debugLogCallback; } - var fields = typeof(TState).GetFields(); + FieldInfo[] fields = typeof(TState).GetFields(); int offset = 0; for (int fieldIndex = 0; fieldIndex < fields.Length; fieldIndex++) { - var field = fields[fieldIndex]; + FieldInfo field = fields[fieldIndex]; - var currentFieldOffset = (int)Marshal.OffsetOf(field.Name); - var nextFieldOffset = fieldIndex + 1 == fields.Length ? Unsafe.SizeOf() : (int)Marshal.OffsetOf(fields[fieldIndex + 1].Name); + int currentFieldOffset = (int)Marshal.OffsetOf(field.Name); + int nextFieldOffset = fieldIndex + 1 == fields.Length ? Unsafe.SizeOf() : (int)Marshal.OffsetOf(fields[fieldIndex + 1].Name); int sizeOfField = nextFieldOffset - currentFieldOffset; @@ -48,7 +49,7 @@ namespace Ryujinx.Graphics.Device { int index = (offset + i) / RegisterSize; - if (callbacks != null && callbacks.TryGetValue(field.Name, out var cb)) + if (callbacks != null && callbacks.TryGetValue(field.Name, out RwCallback cb)) { if (cb.Read != null) { @@ -81,7 +82,7 @@ namespace Ryujinx.Graphics.Device { uint alignedOffset = index * RegisterSize; - var readCallback = Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(_readCallbacks), (nint)index); + Func readCallback = Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(_readCallbacks), (nint)index); if (readCallback != null) { return readCallback(); @@ -119,7 +120,7 @@ namespace Ryujinx.Graphics.Device uint alignedOffset = index * RegisterSize; DebugWrite(alignedOffset, data); - ref var storage = ref GetRefIntAlignedUncheck(index); + ref int storage = ref GetRefIntAlignedUncheck(index); changed = storage != data; storage = data; diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Compute/ComputeClass.cs b/src/Ryujinx.Graphics.Gpu/Engine/Compute/ComputeClass.cs index cd8144724..0784fdca8 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/Compute/ComputeClass.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/Compute/ComputeClass.cs @@ -2,6 +2,7 @@ using Ryujinx.Graphics.Device; using Ryujinx.Graphics.Gpu.Engine.InlineToMemory; using Ryujinx.Graphics.Gpu.Engine.Threed; using Ryujinx.Graphics.Gpu.Engine.Types; +using Ryujinx.Graphics.Gpu.Memory; using Ryujinx.Graphics.Gpu.Shader; using Ryujinx.Graphics.Shader; using System; @@ -90,7 +91,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute /// Method call argument private void SendSignalingPcasB(int argument) { - var memoryManager = _channel.MemoryManager; + MemoryManager memoryManager = _channel.MemoryManager; // Since we're going to change the state, make sure any pending instanced draws are done. _3dEngine.PerformDeferredDraws(); @@ -100,7 +101,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute uint qmdAddress = _state.State.SendPcasA; - var qmd = _channel.MemoryManager.Read((ulong)qmdAddress << 8); + ComputeQmd qmd = _channel.MemoryManager.Read((ulong)qmdAddress << 8); ulong shaderGpuVa = ((ulong)_state.State.SetProgramRegionAAddressUpper << 32) | _state.State.SetProgramRegionB; diff --git a/src/Ryujinx.Graphics.Gpu/Engine/DeviceStateWithShadow.cs b/src/Ryujinx.Graphics.Gpu/Engine/DeviceStateWithShadow.cs index a2e5b1164..ccfba79a4 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/DeviceStateWithShadow.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/DeviceStateWithShadow.cs @@ -80,7 +80,7 @@ namespace Ryujinx.Graphics.Gpu.Engine [MethodImpl(MethodImplOptions.AggressiveInlining)] public void WriteWithRedundancyCheck(int offset, int value, out bool changed) { - var shadowRamControl = _state.State.SetMmeShadowRamControlMode; + SetMmeShadowRamControlMode shadowRamControl = _state.State.SetMmeShadowRamControlMode; if (shadowRamControl == SetMmeShadowRamControlMode.MethodPassthrough || offset < 0x200) { _state.WriteWithRedundancyCheck(offset, value, out changed); diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Dma/DmaClass.cs b/src/Ryujinx.Graphics.Gpu/Engine/Dma/DmaClass.cs index cdeae0040..4ee15dfef 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/Dma/DmaClass.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/Dma/DmaClass.cs @@ -190,7 +190,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma /// The LaunchDma call argument private void DmaCopy(int argument) { - var memoryManager = _channel.MemoryManager; + MemoryManager memoryManager = _channel.MemoryManager; CopyFlags copyFlags = (CopyFlags)argument; @@ -225,8 +225,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma int srcBpp = remap ? srcComponents * componentSize : 1; int dstBpp = remap ? dstComponents * componentSize : 1; - var dst = Unsafe.As(ref _state.State.SetDstBlockSize); - var src = Unsafe.As(ref _state.State.SetSrcBlockSize); + DmaTexture dst = Unsafe.As(ref _state.State.SetDstBlockSize); + DmaTexture src = Unsafe.As(ref _state.State.SetSrcBlockSize); int srcRegionX = 0, srcRegionY = 0, dstRegionX = 0, dstRegionY = 0; @@ -245,7 +245,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma int srcStride = (int)_state.State.PitchIn; int dstStride = (int)_state.State.PitchOut; - var srcCalculator = new OffsetCalculator( + OffsetCalculator srcCalculator = new OffsetCalculator( src.Width, src.Height, srcStride, @@ -254,7 +254,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma src.MemoryLayout.UnpackGobBlocksInZ(), srcBpp); - var dstCalculator = new OffsetCalculator( + OffsetCalculator dstCalculator = new OffsetCalculator( dst.Width, dst.Height, dstStride, @@ -293,7 +293,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma if (completeSource && completeDest && !srcLinear && isIdentityRemap) { - var source = memoryManager.Physical.TextureCache.FindTexture( + Image.Texture source = memoryManager.Physical.TextureCache.FindTexture( memoryManager, srcGpuVa, srcBpp, @@ -309,7 +309,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma { source.SynchronizeMemory(); - var target = memoryManager.Physical.TextureCache.FindOrCreateTexture( + Image.Texture target = memoryManager.Physical.TextureCache.FindOrCreateTexture( memoryManager, source.Info.FormatInfo, dstGpuVa, @@ -339,7 +339,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma if (completeSource && completeDest && !(dstLinear && !srcLinear) && isIdentityRemap) { - var target = memoryManager.Physical.TextureCache.FindTexture( + Image.Texture target = memoryManager.Physical.TextureCache.FindTexture( memoryManager, dstGpuVa, dstBpp, diff --git a/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoProcessor.cs b/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoProcessor.cs index 984a9cff8..c0f8ccf76 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoProcessor.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoProcessor.cs @@ -159,7 +159,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo int availableCount = commandBuffer.Length - offset; int consumeCount = Math.Min(_state.MethodCount, availableCount); - var data = commandBuffer.Slice(offset, consumeCount); + ReadOnlySpan data = commandBuffer.Slice(offset, consumeCount); if (_state.SubChannel == 0) { diff --git a/src/Ryujinx.Graphics.Gpu/Engine/InlineToMemory/InlineToMemoryClass.cs b/src/Ryujinx.Graphics.Gpu/Engine/InlineToMemory/InlineToMemoryClass.cs index 78099f74a..aad97ad81 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/InlineToMemory/InlineToMemoryClass.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/InlineToMemory/InlineToMemoryClass.cs @@ -1,6 +1,7 @@ using Ryujinx.Common; using Ryujinx.Common.Memory; using Ryujinx.Graphics.Device; +using Ryujinx.Graphics.Gpu.Memory; using Ryujinx.Graphics.Texture; using System; using System.Collections.Generic; @@ -168,9 +169,9 @@ namespace Ryujinx.Graphics.Gpu.Engine.InlineToMemory /// private void FinishTransfer() { - var memoryManager = _channel.MemoryManager; + MemoryManager memoryManager = _channel.MemoryManager; - var data = MemoryMarshal.Cast(_buffer)[.._size]; + Span data = MemoryMarshal.Cast(_buffer)[.._size]; if (_isLinear && _lineCount == 1) { @@ -184,7 +185,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.InlineToMemory // Right now the copy code at the bottom assumes that it is used on both which might be incorrect. if (!_isLinear) { - var target = memoryManager.Physical.TextureCache.FindTexture( + Image.Texture target = memoryManager.Physical.TextureCache.FindTexture( memoryManager, _dstGpuVa, 1, @@ -199,7 +200,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.InlineToMemory if (target != null) { target.SynchronizeMemory(); - var dataCopy = MemoryOwner.RentCopy(data); + MemoryOwner dataCopy = MemoryOwner.RentCopy(data); target.SetData(dataCopy, 0, 0, new GAL.Rectangle(_dstX, _dstY, _lineLengthIn / target.Info.FormatInfo.BytesPerPixel, _lineCount)); target.SignalModified(); @@ -207,7 +208,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.InlineToMemory } } - var dstCalculator = new OffsetCalculator( + OffsetCalculator dstCalculator = new OffsetCalculator( _dstWidth, _dstHeight, _dstStride, diff --git a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLE.cs b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLE.cs index 475d1ee4e..f62a4c01a 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLE.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLE.cs @@ -285,12 +285,12 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME /// First argument of the call private void DrawArraysInstanced(IDeviceState state, int arg0) { - var topology = (PrimitiveTopology)arg0; + PrimitiveTopology topology = (PrimitiveTopology)arg0; - var count = FetchParam(); - var instanceCount = FetchParam(); - var firstVertex = FetchParam(); - var firstInstance = FetchParam(); + FifoWord count = FetchParam(); + FifoWord instanceCount = FetchParam(); + FifoWord firstVertex = FetchParam(); + FifoWord firstInstance = FetchParam(); if (ShouldSkipDraw(state, instanceCount.Word)) { @@ -314,13 +314,13 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME /// First argument of the call private void DrawElements(IDeviceState state, int arg0) { - var topology = (PrimitiveTopology)arg0; + PrimitiveTopology topology = (PrimitiveTopology)arg0; - var indexAddressHigh = FetchParam(); - var indexAddressLow = FetchParam(); - var indexType = FetchParam(); - var firstIndex = 0; - var indexCount = FetchParam(); + FifoWord indexAddressHigh = FetchParam(); + FifoWord indexAddressLow = FetchParam(); + FifoWord indexType = FetchParam(); + int firstIndex = 0; + FifoWord indexCount = FetchParam(); _processor.ThreedClass.UpdateIndexBuffer( (uint)indexAddressHigh.Word, @@ -344,13 +344,13 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME /// First argument of the call private void DrawElementsInstanced(IDeviceState state, int arg0) { - var topology = (PrimitiveTopology)arg0; + PrimitiveTopology topology = (PrimitiveTopology)arg0; - var count = FetchParam(); - var instanceCount = FetchParam(); - var firstIndex = FetchParam(); - var firstVertex = FetchParam(); - var firstInstance = FetchParam(); + FifoWord count = FetchParam(); + FifoWord instanceCount = FetchParam(); + FifoWord firstIndex = FetchParam(); + FifoWord firstVertex = FetchParam(); + FifoWord firstInstance = FetchParam(); if (ShouldSkipDraw(state, instanceCount.Word)) { @@ -374,17 +374,17 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME /// First argument of the call private void DrawElementsIndirect(IDeviceState state, int arg0) { - var topology = (PrimitiveTopology)arg0; + PrimitiveTopology topology = (PrimitiveTopology)arg0; - var count = FetchParam(); - var instanceCount = FetchParam(); - var firstIndex = FetchParam(); - var firstVertex = FetchParam(); - var firstInstance = FetchParam(); + FifoWord count = FetchParam(); + FifoWord instanceCount = FetchParam(); + FifoWord firstIndex = FetchParam(); + FifoWord firstVertex = FetchParam(); + FifoWord firstInstance = FetchParam(); ulong indirectBufferGpuVa = count.GpuVa; - var bufferCache = _processor.MemoryManager.Physical.BufferCache; + BufferCache bufferCache = _processor.MemoryManager.Physical.BufferCache; bool useBuffer = bufferCache.CheckModified(_processor.MemoryManager, indirectBufferGpuVa, IndirectIndexedDataEntrySize, out ulong indirectBufferAddress); @@ -432,7 +432,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME int startDraw = arg0; int endDraw = arg1; - var topology = (PrimitiveTopology)arg2; + PrimitiveTopology topology = (PrimitiveTopology)arg2; int paddingWords = arg3; int stride = paddingWords * 4 + 0x14; @@ -468,12 +468,12 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME for (int i = 0; i < maxDrawCount; i++) { - var count = FetchParam(); + FifoWord count = FetchParam(); #pragma warning disable IDE0059 // Remove unnecessary value assignment - var instanceCount = FetchParam(); - var firstIndex = FetchParam(); - var firstVertex = FetchParam(); - var firstInstance = FetchParam(); + FifoWord instanceCount = FetchParam(); + FifoWord firstIndex = FetchParam(); + FifoWord firstVertex = FetchParam(); + FifoWord firstInstance = FetchParam(); #pragma warning restore IDE0059 if (i == 0) @@ -492,7 +492,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME } } - var bufferCache = _processor.MemoryManager.Physical.BufferCache; + BufferCache bufferCache = _processor.MemoryManager.Physical.BufferCache; ulong indirectBufferSize = (ulong)maxDrawCount * (ulong)stride; @@ -526,7 +526,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME /// The call argument, or a 0 value with null address if the FIFO is empty private FifoWord FetchParam() { - if (!Fifo.TryDequeue(out var value)) + if (!Fifo.TryDequeue(out FifoWord value)) { Logger.Warning?.Print(LogClass.Gpu, "Macro attempted to fetch an inexistent argument."); diff --git a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLETable.cs b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLETable.cs index e3080228e..1df68a50f 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLETable.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLETable.cs @@ -90,13 +90,13 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME /// True if there is a implementation available and supported, false otherwise public static bool TryGetMacroHLEFunction(ReadOnlySpan code, Capabilities caps, out MacroHLEFunctionName name) { - var mc = MemoryMarshal.Cast(code); + ReadOnlySpan mc = MemoryMarshal.Cast(code); for (int i = 0; i < _table.Length; i++) { - ref var entry = ref _table[i]; + ref TableEntry entry = ref _table[i]; - var hash = Hash128.ComputeHash(mc[..entry.Length]); + Hash128 hash = Hash128.ComputeHash(mc[..entry.Length]); if (hash == entry.Hash) { if (IsMacroHLESupported(caps, entry.Name)) diff --git a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroInterpreter.cs b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroInterpreter.cs index dd60688d6..707265184 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroInterpreter.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroInterpreter.cs @@ -369,7 +369,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME /// The call argument, or 0 if the FIFO is empty private int FetchParam() { - if (!Fifo.TryDequeue(out var value)) + if (!Fifo.TryDequeue(out FifoWord value)) { Logger.Warning?.Print(LogClass.Gpu, "Macro attempted to fetch an inexistent argument."); diff --git a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroJitContext.cs b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroJitContext.cs index 01bff8e89..174af9739 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroJitContext.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroJitContext.cs @@ -20,7 +20,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME /// The call argument, or 0 if the FIFO is empty public int FetchParam() { - if (!Fifo.TryDequeue(out var value)) + if (!Fifo.TryDequeue(out FifoWord value)) { Logger.Warning?.Print(LogClass.Gpu, "Macro attempted to fetch an inexistent argument."); diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendFunctions.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendFunctions.cs index 13e5d2a86..020db62be 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendFunctions.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendFunctions.cs @@ -221,7 +221,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender sb.AppendLine($"private static Dictionary _entries = new()"); sb.AppendLine("{"); - foreach (var entry in Table) + foreach (AdvancedBlendUcode entry in Table) { Hash128 hash = Hash128.ComputeHash(MemoryMarshal.Cast(entry.Code)); diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendManager.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendManager.cs index ce3d2c236..18428eda9 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendManager.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendManager.cs @@ -66,7 +66,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender descriptor = default; - if (!AdvancedBlendPreGenTable.Entries.TryGetValue(hash, out var entry)) + if (!AdvancedBlendPreGenTable.Entries.TryGetValue(hash, out AdvancedBlendEntry entry)) { return false; } diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/ComputeDraw/VtgAsComputeContext.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/ComputeDraw/VtgAsComputeContext.cs index 34f2cfcad..15f1a4a33 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/ComputeDraw/VtgAsComputeContext.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/ComputeDraw/VtgAsComputeContext.cs @@ -65,7 +65,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.ComputeDraw { if (disposing) { - foreach (var texture in _cache.Values) + foreach (ITexture texture in _cache.Values) { texture.Release(); } @@ -603,7 +603,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.ComputeDraw DestroyIfNotNull(ref _geometryIndexDataBuffer.Handle); DestroyIfNotNull(ref _sequentialIndexBuffer); - foreach (var indexBuffer in _topologyRemapBuffers.Values) + foreach (IndexBuffer indexBuffer in _topologyRemapBuffers.Values) { _context.Renderer.DeleteBuffer(indexBuffer.Handle); } diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/ComputeDraw/VtgAsComputeState.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/ComputeDraw/VtgAsComputeState.cs index 2de324392..8a667b408 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/ComputeDraw/VtgAsComputeState.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/ComputeDraw/VtgAsComputeState.cs @@ -127,7 +127,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.ComputeDraw for (int index = 0; index < Constants.TotalVertexAttribs; index++) { - var vertexAttrib = _state.State.VertexAttribState[index]; + VertexAttribState vertexAttrib = _state.State.VertexAttribState[index]; if (!FormatTable.TryGetSingleComponentAttribFormat(vertexAttrib.UnpackFormat(), out Format format, out int componentsCount)) { @@ -153,7 +153,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.ComputeDraw int bufferIndex = vertexAttrib.UnpackBufferIndex(); GpuVa endAddress = _state.State.VertexBufferEndAddress[bufferIndex]; - var vertexBuffer = _state.State.VertexBufferState[bufferIndex]; + VertexBufferState vertexBuffer = _state.State.VertexBufferState[bufferIndex]; bool instanced = _state.State.VertexBufferInstanced[bufferIndex]; ulong address = vertexBuffer.Address.Pack(); @@ -351,7 +351,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.ComputeDraw /// Size of the buffer in bytes private readonly void SetBufferTexture(ResourceReservations reservations, int index, Format format, ulong address, ulong size) { - var memoryManager = _channel.MemoryManager; + MemoryManager memoryManager = _channel.MemoryManager; BufferRange range = memoryManager.Physical.BufferCache.GetBufferRange(memoryManager.GetPhysicalRegions(address, size), BufferStage.VertexBuffer); @@ -392,7 +392,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.ComputeDraw indexOffset <<= shift; size <<= shift; - var memoryManager = _channel.MemoryManager; + MemoryManager memoryManager = _channel.MemoryManager; ulong misalign = address & ((ulong)_context.Capabilities.TextureBufferOffsetAlignment - 1); BufferRange range = memoryManager.Physical.BufferCache.GetBufferRange( diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/ConstantBufferUpdater.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/ConstantBufferUpdater.cs index 2095fcd7a..6fc49fc8d 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/ConstantBufferUpdater.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/ConstantBufferUpdater.cs @@ -1,3 +1,4 @@ +using Ryujinx.Graphics.Gpu.Memory; using System; using System.Runtime.InteropServices; @@ -92,7 +93,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed if (enable) { - var uniformBuffer = _state.State.UniformBufferState; + UniformBufferState uniformBuffer = _state.State.UniformBufferState; ulong address = uniformBuffer.Address.Pack(); @@ -111,7 +112,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed { if (_ubFollowUpAddress != 0) { - var memoryManager = _channel.MemoryManager; + MemoryManager memoryManager = _channel.MemoryManager; Span data = MemoryMarshal.Cast(_ubData.AsSpan(0, (int)(_ubByteCount / 4))); @@ -131,7 +132,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed /// New uniform buffer data word public void Update(int argument) { - var uniformBuffer = _state.State.UniformBufferState; + UniformBufferState uniformBuffer = _state.State.UniformBufferState; ulong address = uniformBuffer.Address.Pack() + (uint)uniformBuffer.Offset; @@ -157,7 +158,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed /// Data to be written to the uniform buffer public void Update(ReadOnlySpan data) { - var uniformBuffer = _state.State.UniformBufferState; + UniformBufferState uniformBuffer = _state.State.UniformBufferState; ulong address = uniformBuffer.Address.Pack() + (uint)uniformBuffer.Offset; diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/DrawManager.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/DrawManager.cs index 56ef64c6e..2537b79b7 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/DrawManager.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/DrawManager.cs @@ -471,7 +471,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed int textureId = _state.State.DrawTextureTextureId; int samplerId = _state.State.DrawTextureSamplerId; - (var texture, var sampler) = _channel.TextureManager.GetGraphicsTextureAndSampler(textureId, samplerId); + (Image.Texture texture, Sampler sampler) = _channel.TextureManager.GetGraphicsTextureAndSampler(textureId, samplerId); srcX0 *= texture.ScaleFactor; srcY0 *= texture.ScaleFactor; @@ -684,8 +684,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed if (hasCount) { - var indirectBuffer = memory.BufferCache.GetBufferRange(indirectBufferRange, BufferStage.Indirect); - var parameterBuffer = memory.BufferCache.GetBufferRange(parameterBufferRange, BufferStage.Indirect); + BufferRange indirectBuffer = memory.BufferCache.GetBufferRange(indirectBufferRange, BufferStage.Indirect); + BufferRange parameterBuffer = memory.BufferCache.GetBufferRange(parameterBufferRange, BufferStage.Indirect); if (indexed) { @@ -698,7 +698,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed } else { - var indirectBuffer = memory.BufferCache.GetBufferRange(indirectBufferRange, BufferStage.Indirect); + BufferRange indirectBuffer = memory.BufferCache.GetBufferRange(indirectBufferRange, BufferStage.Indirect); if (indexed) { @@ -820,7 +820,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed // If there is a mismatch on the host clip region and the one explicitly defined by the guest // on the screen scissor state, then we need to force only one texture to be bound to avoid // host clipping. - var screenScissorState = _state.State.ScreenScissorState; + ScreenScissorState screenScissorState = _state.State.ScreenScissorState; bool clearAffectedByStencilMask = (_state.State.ClearFlags & 1) != 0; bool clearAffectedByScissor = (_state.State.ClearFlags & 0x100) != 0; @@ -833,7 +833,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed if (fullClear && clearAffectedByScissor && _state.State.ScissorState[0].Enable) { - ref var scissorState = ref _state.State.ScissorState[0]; + ref ScissorState scissorState = ref _state.State.ScissorState[0]; fullClear = scissorState.X1 == screenScissorState.X && scissorState.Y1 == screenScissorState.Y && @@ -894,7 +894,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed if (clearAffectedByScissor && _state.State.ScissorState[0].Enable) { - ref var scissorState = ref _state.State.ScissorState[0]; + ref ScissorState scissorState = ref _state.State.ScissorState[0]; scissorX = Math.Max(scissorX, scissorState.X1); scissorY = Math.Max(scissorY, scissorState.Y1); @@ -923,7 +923,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed if (componentMask != 0) { - var clearColor = _state.State.ClearColors; + ClearColors clearColor = _state.State.ClearColors; ColorF color = new(clearColor.Red, clearColor.Green, clearColor.Blue, clearColor.Alpha); diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/SpecializationStateUpdater.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/SpecializationStateUpdater.cs index dbd4efc8f..4eea80687 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/SpecializationStateUpdater.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/SpecializationStateUpdater.cs @@ -288,7 +288,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed { int rtIndex = rtControl.UnpackPermutationIndex(index); - var colorState = state[rtIndex]; + RtColorState colorState = state[rtIndex]; if (index < count && StateUpdater.IsRtEnabled(colorState)) { diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdateTracker.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdateTracker.cs index ea9fc9e31..4f9e57f76 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdateTracker.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdateTracker.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Numerics; +using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -58,13 +59,13 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed _registerToGroupMapping = new byte[BlockSize]; _callbacks = new Action[entries.Length]; - var fieldToDelegate = new Dictionary(); + Dictionary fieldToDelegate = new Dictionary(); for (int entryIndex = 0; entryIndex < entries.Length; entryIndex++) { - var entry = entries[entryIndex]; + StateUpdateCallbackEntry entry = entries[entryIndex]; - foreach (var fieldName in entry.FieldNames) + foreach (string fieldName in entry.FieldNames) { fieldToDelegate.Add(fieldName, entryIndex); } @@ -72,15 +73,15 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed _callbacks[entryIndex] = entry.Callback; } - var fields = typeof(TState).GetFields(); + FieldInfo[] fields = typeof(TState).GetFields(); int offset = 0; for (int fieldIndex = 0; fieldIndex < fields.Length; fieldIndex++) { - var field = fields[fieldIndex]; + FieldInfo field = fields[fieldIndex]; - var currentFieldOffset = (int)Marshal.OffsetOf(field.Name); - var nextFieldOffset = fieldIndex + 1 == fields.Length ? Unsafe.SizeOf() : (int)Marshal.OffsetOf(fields[fieldIndex + 1].Name); + int currentFieldOffset = (int)Marshal.OffsetOf(field.Name); + int nextFieldOffset = fieldIndex + 1 == fields.Length ? Unsafe.SizeOf() : (int)Marshal.OffsetOf(fields[fieldIndex + 1].Name); int sizeOfField = nextFieldOffset - currentFieldOffset; diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs index 1dc77b52d..d8e53124b 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs @@ -3,6 +3,7 @@ using Ryujinx.Graphics.GAL; using Ryujinx.Graphics.Gpu.Engine.Threed.Blender; using Ryujinx.Graphics.Gpu.Engine.Types; using Ryujinx.Graphics.Gpu.Image; +using Ryujinx.Graphics.Gpu.Memory; using Ryujinx.Graphics.Gpu.Shader; using Ryujinx.Graphics.Shader; using Ryujinx.Graphics.Texture; @@ -463,8 +464,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed /// If this is not -1, it indicates that only the given indexed target will be used. public void UpdateRenderTargetState(RenderTargetUpdateFlags updateFlags, int singleUse = -1) { - var memoryManager = _channel.MemoryManager; - var rtControl = _state.State.RtControl; + MemoryManager memoryManager = _channel.MemoryManager; + RtControl rtControl = _state.State.RtControl; bool useControl = updateFlags.HasFlag(RenderTargetUpdateFlags.UseControl); bool layered = updateFlags.HasFlag(RenderTargetUpdateFlags.Layered); @@ -473,12 +474,12 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed int count = useControl ? rtControl.UnpackCount() : Constants.TotalRenderTargets; - var msaaMode = _state.State.RtMsaaMode; + TextureMsaaMode msaaMode = _state.State.RtMsaaMode; int samplesInX = msaaMode.SamplesInX(); int samplesInY = msaaMode.SamplesInY(); - var scissor = _state.State.ScreenScissorState; + ScreenScissorState scissor = _state.State.ScreenScissorState; Size sizeHint = new((scissor.X + scissor.Width) * samplesInX, (scissor.Y + scissor.Height) * samplesInY, 1); int clipRegionWidth = int.MaxValue; @@ -491,7 +492,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed { int rtIndex = useControl ? rtControl.UnpackPermutationIndex(index) : index; - var colorState = _state.State.RtColorState[rtIndex]; + RtColorState colorState = _state.State.RtColorState[rtIndex]; if (index >= count || !IsRtEnabled(colorState) || (singleColor && index != singleUse)) { @@ -541,8 +542,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed if (dsEnable && updateFlags.HasFlag(RenderTargetUpdateFlags.UpdateDepthStencil)) { - var dsState = _state.State.RtDepthStencilState; - var dsSize = _state.State.RtDepthStencilSize; + RtDepthStencilState dsState = _state.State.RtDepthStencilState; + Size3D dsSize = _state.State.RtDepthStencilSize; depthStencil = memoryManager.Physical.TextureCache.FindOrCreateTexture( memoryManager, @@ -643,7 +644,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed if (_state.State.YControl.HasFlag(YControl.NegateY)) { - ref var screenScissor = ref _state.State.ScreenScissorState; + ref ScreenScissorState screenScissor = ref _state.State.ScreenScissorState; y = screenScissor.Height - height - y; if (y < 0) @@ -721,8 +722,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed /// private void UpdateViewportTransform() { - var yControl = _state.State.YControl; - var face = _state.State.FaceState; + YControl yControl = _state.State.YControl; + FaceState face = _state.State.FaceState; bool disableTransform = _state.State.ViewportTransformEnable == 0; bool yNegate = yControl.HasFlag(YControl.NegateY); @@ -736,17 +737,17 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed { if (disableTransform) { - ref var scissor = ref _state.State.ScreenScissorState; + ref ScreenScissorState scissor = ref _state.State.ScreenScissorState; float rScale = _channel.TextureManager.RenderTargetScale; - var scissorRect = new Rectangle(0, 0, (scissor.X + scissor.Width) * rScale, (scissor.Y + scissor.Height) * rScale); + Rectangle scissorRect = new Rectangle(0, 0, (scissor.X + scissor.Width) * rScale, (scissor.Y + scissor.Height) * rScale); viewports[index] = new Viewport(scissorRect, ViewportSwizzle.PositiveX, ViewportSwizzle.PositiveY, ViewportSwizzle.PositiveZ, ViewportSwizzle.PositiveW, 0, 1); continue; } - ref var transform = ref _state.State.ViewportTransform[index]; - ref var extents = ref _state.State.ViewportExtents[index]; + ref ViewportTransform transform = ref _state.State.ViewportTransform[index]; + ref ViewportExtents extents = ref _state.State.ViewportExtents[index]; float scaleX = MathF.Abs(transform.ScaleX); float scaleY = transform.ScaleY; @@ -841,7 +842,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed /// private void UpdateDepthBiasState() { - var depthBias = _state.State.DepthBiasState; + DepthBiasState depthBias = _state.State.DepthBiasState; float factor = _state.State.DepthBiasFactor; float units = _state.State.DepthBiasUnits; @@ -862,9 +863,9 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed /// private void UpdateStencilTestState() { - var backMasks = _state.State.StencilBackMasks; - var test = _state.State.StencilTestState; - var backTest = _state.State.StencilBackTestState; + StencilBackMasks backMasks = _state.State.StencilBackMasks; + StencilTestState test = _state.State.StencilTestState; + StencilBackTestState backTest = _state.State.StencilBackTestState; CompareOp backFunc; StencilOp backSFail; @@ -934,10 +935,10 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed /// private void UpdateSamplerPoolState() { - var texturePool = _state.State.TexturePoolState; - var samplerPool = _state.State.SamplerPoolState; + PoolState texturePool = _state.State.TexturePoolState; + PoolState samplerPool = _state.State.SamplerPoolState; - var samplerIndex = _state.State.SamplerIndex; + SamplerIndex samplerIndex = _state.State.SamplerIndex; int maximumId = samplerIndex == SamplerIndex.ViaHeaderIndex ? texturePool.MaximumId @@ -951,7 +952,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed /// private void UpdateTexturePoolState() { - var texturePool = _state.State.TexturePoolState; + PoolState texturePool = _state.State.TexturePoolState; _channel.TextureManager.SetGraphicsTexturePool(texturePool.Address.Pack(), texturePool.MaximumId); _channel.TextureManager.SetGraphicsTextureBufferIndex((int)_state.State.TextureBufferIndex); @@ -971,7 +972,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed for (int index = 0; index < Constants.TotalVertexAttribs; index++) { - var vertexAttrib = _state.State.VertexAttribState[index]; + VertexAttribState vertexAttrib = _state.State.VertexAttribState[index]; int bufferIndex = vertexAttrib.UnpackBufferIndex(); @@ -1065,7 +1066,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed /// private void UpdateIndexBufferState() { - var indexBuffer = _state.State.IndexBufferState; + IndexBufferState indexBuffer = _state.State.IndexBufferState; if (_drawState.IndexCount == 0) { @@ -1109,7 +1110,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed for (int index = 0; index < Constants.TotalVertexBuffers; index++) { - var vertexBuffer = _state.State.VertexBufferState[index]; + VertexBufferState vertexBuffer = _state.State.VertexBufferState[index]; if (!vertexBuffer.UnpackEnable()) { @@ -1193,8 +1194,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed /// private void UpdateFaceState() { - var yControl = _state.State.YControl; - var face = _state.State.FaceState; + YControl yControl = _state.State.YControl; + FaceState face = _state.State.FaceState; _pipeline.CullEnable = face.CullEnable; _pipeline.CullMode = face.CullFace; @@ -1233,7 +1234,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed for (int index = 0; index < Constants.TotalRenderTargets; index++) { - var colorMask = _state.State.RtColorMask[rtColorMaskShared ? 0 : index]; + RtColorMask colorMask = _state.State.RtColorMask[rtColorMaskShared ? 0 : index]; uint componentMask; @@ -1256,7 +1257,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed { if (_state.State.BlendUcodeEnable != BlendUcodeEnable.Disabled) { - if (_context.Capabilities.SupportsBlendEquationAdvanced && _blendManager.TryGetAdvancedBlend(out var blendDescriptor)) + if (_context.Capabilities.SupportsBlendEquationAdvanced && _blendManager.TryGetAdvancedBlend(out AdvancedBlendDescriptor blendDescriptor)) { // Try to HLE it using advanced blend on the host if we can. _context.Renderer.Pipeline.SetBlendState(blendDescriptor); @@ -1278,9 +1279,9 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed for (int index = 0; index < Constants.TotalRenderTargets; index++) { bool enable = _state.State.BlendEnable[index]; - var blend = _state.State.BlendState[index]; + BlendState blend = _state.State.BlendState[index]; - var descriptor = new BlendDescriptor( + BlendDescriptor descriptor = new BlendDescriptor( enable, blendConstant, blend.ColorOp, @@ -1306,9 +1307,9 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed else { bool enable = _state.State.BlendEnable[0]; - var blend = _state.State.BlendStateCommon; + BlendStateCommon blend = _state.State.BlendStateCommon; - var descriptor = new BlendDescriptor( + BlendDescriptor descriptor = new BlendDescriptor( enable, blendConstant, blend.ColorOp, @@ -1409,7 +1410,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed /// private void UpdateShaderState() { - var shaderCache = _channel.MemoryManager.Physical.ShaderCache; + ShaderCache shaderCache = _channel.MemoryManager.Physical.ShaderCache; _vtgWritesRtLayer = false; @@ -1420,7 +1421,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed for (int index = 0; index < 6; index++) { - var shader = _state.State.ShaderState[index]; + ShaderState shader = _state.State.ShaderState[index]; if (!shader.UnpackEnable() && index != 1) { continue; @@ -1525,7 +1526,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed /// private void UpdateSupportBufferViewportSize() { - ref var transform = ref _state.State.ViewportTransform[0]; + ref ViewportTransform transform = ref _state.State.ViewportTransform[0]; float scaleX = MathF.Abs(transform.ScaleX); float scaleY = transform.ScaleY; @@ -1564,8 +1565,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed /// Current depth mode private DepthMode GetDepthMode() { - ref var transform = ref _state.State.ViewportTransform[0]; - ref var extents = ref _state.State.ViewportExtents[0]; + ref ViewportTransform transform = ref _state.State.ViewportTransform[0]; + ref ViewportExtents extents = ref _state.State.ViewportExtents[0]; DepthMode depthMode; diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/ThreedClass.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/ThreedClass.cs index ab1d27a1c..618743018 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/ThreedClass.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/ThreedClass.cs @@ -82,8 +82,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed _i2mClass = new InlineToMemoryClass(context, channel, initializeState: false); - var spec = new SpecializationStateUpdater(context); - var drawState = new DrawState(); + SpecializationStateUpdater spec = new SpecializationStateUpdater(context); + DrawState drawState = new DrawState(); _drawManager = new DrawManager(context, channel, _state, drawState, spec); _blendManager = new AdvancedBlendManager(_state); @@ -253,8 +253,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed } else { - ref var lhsVec = ref Unsafe.As>(ref lhs); - ref var rhsVec = ref Unsafe.As>(ref rhs); + ref Vector128 lhsVec = ref Unsafe.As>(ref lhs); + ref Vector128 rhsVec = ref Unsafe.As>(ref rhs); return Vector128.EqualsAll(lhsVec, rhsVec) && Vector128.EqualsAll(Unsafe.Add(ref lhsVec, 1), Unsafe.Add(ref rhsVec, 1)); @@ -267,8 +267,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed /// Blend enable public void UpdateBlendEnable(ref Array8 enable) { - var shadow = ShadowMode; - ref var state = ref _state.State.BlendEnable; + SetMmeShadowRamControlMode shadow = ShadowMode; + ref Array8 state = ref _state.State.BlendEnable; if (shadow.IsReplay()) { @@ -294,8 +294,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed /// Color masks public void UpdateColorMasks(ref Array8 masks) { - var shadow = ShadowMode; - ref var state = ref _state.State.RtColorMask; + SetMmeShadowRamControlMode shadow = ShadowMode; + ref Array8 state = ref _state.State.RtColorMask; if (shadow.IsReplay()) { @@ -323,12 +323,12 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed /// Type of the binding public void UpdateIndexBuffer(uint addrHigh, uint addrLow, IndexType type) { - var shadow = ShadowMode; - ref var state = ref _state.State.IndexBufferState; + SetMmeShadowRamControlMode shadow = ShadowMode; + ref IndexBufferState state = ref _state.State.IndexBufferState; if (shadow.IsReplay()) { - ref var shadowState = ref _state.ShadowState.IndexBufferState; + ref IndexBufferState shadowState = ref _state.ShadowState.IndexBufferState; addrHigh = shadowState.Address.High; addrLow = shadowState.Address.Low; type = shadowState.Type; @@ -345,7 +345,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed if (shadow.IsTrack()) { - ref var shadowState = ref _state.ShadowState.IndexBufferState; + ref IndexBufferState shadowState = ref _state.ShadowState.IndexBufferState; shadowState.Address.High = addrHigh; shadowState.Address.Low = addrLow; shadowState.Type = type; @@ -360,12 +360,12 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed /// Low part of the address public void UpdateUniformBufferState(int size, uint addrHigh, uint addrLow) { - var shadow = ShadowMode; - ref var state = ref _state.State.UniformBufferState; + SetMmeShadowRamControlMode shadow = ShadowMode; + ref UniformBufferState state = ref _state.State.UniformBufferState; if (shadow.IsReplay()) { - ref var shadowState = ref _state.ShadowState.UniformBufferState; + ref UniformBufferState shadowState = ref _state.ShadowState.UniformBufferState; size = shadowState.Size; addrHigh = shadowState.Address.High; addrLow = shadowState.Address.Low; @@ -377,7 +377,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed if (shadow.IsTrack()) { - ref var shadowState = ref _state.ShadowState.UniformBufferState; + ref UniformBufferState shadowState = ref _state.ShadowState.UniformBufferState; shadowState.Size = size; shadowState.Address.High = addrHigh; shadowState.Address.Low = addrLow; @@ -391,8 +391,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed /// Offset to update with public void SetShaderOffset(int index, uint offset) { - var shadow = ShadowMode; - ref var shaderState = ref _state.State.ShaderState[index]; + SetMmeShadowRamControlMode shadow = ShadowMode; + ref ShaderState shaderState = ref _state.State.ShaderState[index]; if (shadow.IsReplay()) { @@ -418,8 +418,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed /// Uniform buffer state public void UpdateUniformBufferState(UniformBufferState ubState) { - var shadow = ShadowMode; - ref var state = ref _state.State.UniformBufferState; + SetMmeShadowRamControlMode shadow = ShadowMode; + ref UniformBufferState state = ref _state.State.UniformBufferState; if (shadow.IsReplay()) { diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Twod/TwodClass.cs b/src/Ryujinx.Graphics.Gpu/Engine/Twod/TwodClass.cs index 0dd9481df..60a558d56 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/Twod/TwodClass.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/Twod/TwodClass.cs @@ -3,6 +3,7 @@ using Ryujinx.Graphics.Device; using Ryujinx.Graphics.GAL; using Ryujinx.Graphics.Gpu.Engine.Types; using Ryujinx.Graphics.Gpu.Image; +using Ryujinx.Graphics.Gpu.Memory; using Ryujinx.Graphics.Texture; using Ryujinx.Memory; using System; @@ -123,7 +124,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod /// Bytes per pixel private void UnscaledFullCopy(TwodTexture src, TwodTexture dst, int w, int h, int bpp) { - var srcCalculator = new OffsetCalculator( + OffsetCalculator srcCalculator = new OffsetCalculator( w, h, src.Stride, @@ -134,7 +135,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod (int _, int srcSize) = srcCalculator.GetRectangleRange(0, 0, w, h); - var memoryManager = _channel.MemoryManager; + MemoryManager memoryManager = _channel.MemoryManager; ulong srcGpuVa = src.Address.Pack(); ulong dstGpuVa = dst.Address.Pack(); @@ -228,10 +229,10 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod /// Method call argument private void PixelsFromMemorySrcY0Int(int argument) { - var memoryManager = _channel.MemoryManager; + MemoryManager memoryManager = _channel.MemoryManager; - var dstCopyTexture = Unsafe.As(ref _state.State.SetDstFormat); - var srcCopyTexture = Unsafe.As(ref _state.State.SetSrcFormat); + TwodTexture dstCopyTexture = Unsafe.As(ref _state.State.SetDstFormat); + TwodTexture srcCopyTexture = Unsafe.As(ref _state.State.SetSrcFormat); long srcX = ((long)_state.State.SetPixelsFromMemorySrcX0Int << 32) | (long)(ulong)_state.State.SetPixelsFromMemorySrcX0Frac; long srcY = ((long)_state.State.PixelsFromMemorySrcY0Int << 32) | (long)(ulong)_state.State.SetPixelsFromMemorySrcY0Frac; @@ -268,10 +269,10 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod // The source and destination textures should at least be as big as the region being requested. // The hints will only resize within alignment constraints, so out of bound copies won't resize in most cases. - var srcHint = new Size(srcX2, srcY2, 1); - var dstHint = new Size(dstX2, dstY2, 1); + Size srcHint = new Size(srcX2, srcY2, 1); + Size dstHint = new Size(dstX2, dstY2, 1); - var srcCopyTextureFormat = srcCopyTexture.Format.Convert(); + FormatInfo srcCopyTextureFormat = srcCopyTexture.Format.Convert(); int srcWidthAligned = srcCopyTexture.Stride / srcCopyTextureFormat.BytesPerPixel; @@ -304,7 +305,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod // are the same, as we can't blit between different depth formats. bool srcDepthAlias = srcCopyTexture.Format == dstCopyTexture.Format; - var srcTexture = memoryManager.Physical.TextureCache.FindOrCreateTexture( + Image.Texture srcTexture = memoryManager.Physical.TextureCache.FindOrCreateTexture( memoryManager, srcCopyTexture, offset, @@ -341,7 +342,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod dstCopyTextureFormat = dstCopyTexture.Format.Convert(); } - var dstTexture = memoryManager.Physical.TextureCache.FindOrCreateTexture( + Image.Texture dstTexture = memoryManager.Physical.TextureCache.FindOrCreateTexture( memoryManager, dstCopyTexture, 0, diff --git a/src/Ryujinx.Graphics.Gpu/GpuChannel.cs b/src/Ryujinx.Graphics.Gpu/GpuChannel.cs index 33618a15b..047cbcca6 100644 --- a/src/Ryujinx.Graphics.Gpu/GpuChannel.cs +++ b/src/Ryujinx.Graphics.Gpu/GpuChannel.cs @@ -57,7 +57,7 @@ namespace Ryujinx.Graphics.Gpu /// The new memory manager to be bound public void BindMemory(MemoryManager memoryManager) { - var oldMemoryManager = Interlocked.Exchange(ref _memoryManager, memoryManager ?? throw new ArgumentNullException(nameof(memoryManager))); + MemoryManager oldMemoryManager = Interlocked.Exchange(ref _memoryManager, memoryManager ?? throw new ArgumentNullException(nameof(memoryManager))); memoryManager.Physical.IncrementReferenceCount(); @@ -85,7 +85,7 @@ namespace Ryujinx.Graphics.Gpu { TextureManager.ReloadPools(); - var memoryManager = Volatile.Read(ref _memoryManager); + MemoryManager memoryManager = Volatile.Read(ref _memoryManager); memoryManager?.Physical.BufferCache.QueuePrune(); } @@ -138,7 +138,7 @@ namespace Ryujinx.Graphics.Gpu _processor.Dispose(); TextureManager.Dispose(); - var oldMemoryManager = Interlocked.Exchange(ref _memoryManager, null); + MemoryManager oldMemoryManager = Interlocked.Exchange(ref _memoryManager, null); if (oldMemoryManager != null) { oldMemoryManager.Physical.BufferCache.NotifyBuffersModified -= BufferManager.Rebind; diff --git a/src/Ryujinx.Graphics.Gpu/GpuContext.cs b/src/Ryujinx.Graphics.Gpu/GpuContext.cs index f7e8f1bf8..fa877cf8a 100644 --- a/src/Ryujinx.Graphics.Gpu/GpuContext.cs +++ b/src/Ryujinx.Graphics.Gpu/GpuContext.cs @@ -167,7 +167,7 @@ namespace Ryujinx.Graphics.Gpu /// Thrown when is invalid public MemoryManager CreateMemoryManager(ulong pid, ulong cpuMemorySize) { - if (!PhysicalMemoryRegistry.TryGetValue(pid, out var physicalMemory)) + if (!PhysicalMemoryRegistry.TryGetValue(pid, out PhysicalMemory physicalMemory)) { throw new ArgumentException("The PID is invalid or the process was not registered", nameof(pid)); } @@ -183,7 +183,7 @@ namespace Ryujinx.Graphics.Gpu /// Thrown when is invalid public DeviceMemoryManager CreateDeviceMemoryManager(ulong pid) { - if (!PhysicalMemoryRegistry.TryGetValue(pid, out var physicalMemory)) + if (!PhysicalMemoryRegistry.TryGetValue(pid, out PhysicalMemory physicalMemory)) { throw new ArgumentException("The PID is invalid or the process was not registered", nameof(pid)); } @@ -199,7 +199,7 @@ namespace Ryujinx.Graphics.Gpu /// Thrown if was already registered public void RegisterProcess(ulong pid, Cpu.IVirtualMemoryManagerTracked cpuMemory) { - var physicalMemory = new PhysicalMemory(this, cpuMemory); + PhysicalMemory physicalMemory = new PhysicalMemory(this, cpuMemory); if (!PhysicalMemoryRegistry.TryAdd(pid, physicalMemory)) { throw new ArgumentException("The PID was already registered", nameof(pid)); @@ -214,7 +214,7 @@ namespace Ryujinx.Graphics.Gpu /// ID of the process public void UnregisterProcess(ulong pid) { - if (PhysicalMemoryRegistry.TryRemove(pid, out var physicalMemory)) + if (PhysicalMemoryRegistry.TryRemove(pid, out PhysicalMemory physicalMemory)) { physicalMemory.ShaderCache.ShaderCacheStateChanged -= ShaderCacheStateUpdate; physicalMemory.Dispose(); @@ -289,7 +289,7 @@ namespace Ryujinx.Graphics.Gpu { HostInitalized.WaitOne(); - foreach (var physicalMemory in PhysicalMemoryRegistry.Values) + foreach (PhysicalMemory physicalMemory in PhysicalMemoryRegistry.Values) { physicalMemory.ShaderCache.Initialize(cancellationToken); } @@ -329,7 +329,7 @@ namespace Ryujinx.Graphics.Gpu /// public void ProcessShaderCacheQueue() { - foreach (var physicalMemory in PhysicalMemoryRegistry.Values) + foreach (PhysicalMemory physicalMemory in PhysicalMemoryRegistry.Values) { physicalMemory.ShaderCache.ProcessShaderCacheQueue(); } @@ -404,12 +404,12 @@ namespace Ryujinx.Graphics.Gpu if (force || _pendingSync || (syncpoint && SyncpointActions.Count > 0)) { - foreach (var action in SyncActions) + foreach (ISyncActionHandler action in SyncActions) { action.SyncPreAction(syncpoint); } - foreach (var action in SyncpointActions) + foreach (ISyncActionHandler action in SyncpointActions) { action.SyncPreAction(syncpoint); } @@ -450,7 +450,7 @@ namespace Ryujinx.Graphics.Gpu _gpuReadyEvent.Dispose(); // Has to be disposed before processing deferred actions, as it will produce some. - foreach (var physicalMemory in PhysicalMemoryRegistry.Values) + foreach (PhysicalMemory physicalMemory in PhysicalMemoryRegistry.Values) { physicalMemory.Dispose(); } diff --git a/src/Ryujinx.Graphics.Gpu/Image/AutoDeleteCache.cs b/src/Ryujinx.Graphics.Gpu/Image/AutoDeleteCache.cs index 74967b190..b1a416e23 100644 --- a/src/Ryujinx.Graphics.Gpu/Image/AutoDeleteCache.cs +++ b/src/Ryujinx.Graphics.Gpu/Image/AutoDeleteCache.cs @@ -80,7 +80,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// The amount of physical CPU Memory Avaiable on the device. public void Initialize(GpuContext context, ulong cpuMemorySize) { - var cpuMemorySizeGiB = cpuMemorySize / GiB; + ulong cpuMemorySizeGiB = cpuMemorySize / GiB; if (cpuMemorySizeGiB < 6 || context.Capabilities.MaximumGpuMemory == 0) { @@ -100,7 +100,7 @@ namespace Ryujinx.Graphics.Gpu.Image MaxTextureSizeCapacity = TextureSizeCapacity12GiB; } - var cacheMemory = (ulong)(context.Capabilities.MaximumGpuMemory * MemoryScaleFactor); + ulong cacheMemory = (ulong)(context.Capabilities.MaximumGpuMemory * MemoryScaleFactor); _maxCacheMemoryUsage = Math.Clamp(cacheMemory, MinTextureSizeCapacity, MaxTextureSizeCapacity); @@ -232,7 +232,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// The texture if found, null otherwise public Texture FindShortCache(in TextureDescriptor descriptor) { - if (_shortCacheLookup.Count > 0 && _shortCacheLookup.TryGetValue(descriptor, out var entry)) + if (_shortCacheLookup.Count > 0 && _shortCacheLookup.TryGetValue(descriptor, out ShortTextureCacheEntry entry)) { if (entry.InvalidatedSequence == entry.Texture.InvalidatedSequence) { @@ -277,7 +277,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// Last used texture descriptor public void AddShortCache(Texture texture, ref TextureDescriptor descriptor) { - var entry = new ShortTextureCacheEntry(descriptor, texture); + ShortTextureCacheEntry entry = new ShortTextureCacheEntry(descriptor, texture); _shortCacheBuilder.Add(entry); _shortCacheLookup.Add(entry.Descriptor, entry); @@ -296,7 +296,7 @@ namespace Ryujinx.Graphics.Gpu.Image { if (texture.ShortCacheEntry != null) { - var entry = new ShortTextureCacheEntry(texture); + ShortTextureCacheEntry entry = new ShortTextureCacheEntry(texture); _shortCacheBuilder.Add(entry); @@ -314,7 +314,7 @@ namespace Ryujinx.Graphics.Gpu.Image { HashSet toRemove = _shortCache; - foreach (var entry in toRemove) + foreach (ShortTextureCacheEntry entry in toRemove) { entry.Texture.DecrementReferenceCount(); diff --git a/src/Ryujinx.Graphics.Gpu/Image/FormatTable.cs b/src/Ryujinx.Graphics.Gpu/Image/FormatTable.cs index da9e5c3a9..45e1971a8 100644 --- a/src/Ryujinx.Graphics.Gpu/Image/FormatTable.cs +++ b/src/Ryujinx.Graphics.Gpu/Image/FormatTable.cs @@ -704,7 +704,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// True if the format is valid, false otherwise public static bool TryGetSingleComponentAttribFormat(uint encoded, out Format format, out int componentsCount) { - bool result = _singleComponentAttribFormats.TryGetValue((VertexAttributeFormat)encoded, out var tuple); + bool result = _singleComponentAttribFormats.TryGetValue((VertexAttributeFormat)encoded, out (Format, int) tuple); format = tuple.Item1; componentsCount = tuple.Item2; diff --git a/src/Ryujinx.Graphics.Gpu/Image/Texture.cs b/src/Ryujinx.Graphics.Gpu/Image/Texture.cs index 7ee2e5cf0..51ce195f4 100644 --- a/src/Ryujinx.Graphics.Gpu/Image/Texture.cs +++ b/src/Ryujinx.Graphics.Gpu/Image/Texture.cs @@ -536,7 +536,7 @@ namespace Ryujinx.Graphics.Gpu.Image // All views must be recreated against the new storage. - foreach (var view in _views) + foreach (Texture view in _views) { Logger.Debug?.Print(LogClass.Gpu, $" Recreating view {Info.Width}x{Info.Height} {Info.FormatInfo.Format}."); view.ScaleFactor = scale; @@ -553,7 +553,7 @@ namespace Ryujinx.Graphics.Gpu.Image { ScaleMode = newScaleMode; - foreach (var view in _views) + foreach (Texture view in _views) { view.ScaleMode = newScaleMode; } @@ -899,7 +899,7 @@ namespace Ryujinx.Graphics.Gpu.Image { using (result) { - var converted = PixelConverter.ConvertR4G4ToR4G4B4A4(result.Span, width); + MemoryOwner converted = PixelConverter.ConvertR4G4ToR4G4B4A4(result.Span, width); if (_context.Capabilities.SupportsR4G4B4A4Format) { @@ -1650,7 +1650,7 @@ namespace Ryujinx.Graphics.Gpu.Image { lock (_poolOwners) { - foreach (var owner in _poolOwners) + foreach (TexturePoolOwner owner in _poolOwners) { owner.Pool.ForceRemove(this, owner.ID, deferred); } @@ -1680,7 +1680,7 @@ namespace Ryujinx.Graphics.Gpu.Image { ulong address = 0; - foreach (var owner in _poolOwners) + foreach (TexturePoolOwner owner in _poolOwners) { if (address == 0 || address == owner.GpuAddress) { diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureCache.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureCache.cs index ff7f11142..71de06e2c 100644 --- a/src/Ryujinx.Graphics.Gpu/Image/TextureCache.cs +++ b/src/Ryujinx.Graphics.Gpu/Image/TextureCache.cs @@ -128,7 +128,7 @@ namespace Ryujinx.Graphics.Gpu.Image // Any texture that has been unmapped at any point or is partially unmapped // should update their pool references after the remap completes. - foreach (var texture in _partiallyMappedTextures) + foreach (Texture texture in _partiallyMappedTextures) { texture.UpdatePoolMappings(); } @@ -253,7 +253,7 @@ namespace Ryujinx.Graphics.Gpu.Image for (int i = 0; i < overlapCount; i++) { - var other = _textureOverlaps[i]; + Texture other = _textureOverlaps[i]; if (texture != other && (texture.IsViewCompatible(other.Info, other.Range, true, other.LayerSize, _context.Capabilities, out _, out _) != TextureViewCompatibility.Incompatible || @@ -486,7 +486,7 @@ namespace Ryujinx.Graphics.Gpu.Image int layerSize = !isLinear ? colorState.LayerSize * 4 : 0; - var flags = TextureSearchFlags.WithUpscale; + TextureSearchFlags flags = TextureSearchFlags.WithUpscale; if (discard) { @@ -560,7 +560,7 @@ namespace Ryujinx.Graphics.Gpu.Image target, formatInfo); - var flags = TextureSearchFlags.WithUpscale; + TextureSearchFlags flags = TextureSearchFlags.WithUpscale; if (discard) { @@ -947,7 +947,7 @@ namespace Ryujinx.Graphics.Gpu.Image bool hasLayerViews = false; bool hasMipViews = false; - var incompatibleOverlaps = new List(); + List incompatibleOverlaps = new List(); for (int index = 0; index < overlapsCount; index++) { diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureGroup.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureGroup.cs index 2db5c6290..47a66747b 100644 --- a/src/Ryujinx.Graphics.Gpu/Image/TextureGroup.cs +++ b/src/Ryujinx.Graphics.Gpu/Image/TextureGroup.cs @@ -231,7 +231,7 @@ namespace Ryujinx.Graphics.Gpu.Image { bool flushed = false; - foreach (var overlap in _incompatibleOverlaps) + foreach (TextureIncompatibleOverlap overlap in _incompatibleOverlaps) { flushed |= overlap.Group.Storage.FlushModified(true); } @@ -403,7 +403,7 @@ namespace Ryujinx.Graphics.Gpu.Image { if (_loadNeeded[baseHandle + i]) { - var info = GetHandleInformation(baseHandle + i); + (int BaseLayer, int BaseLevel, int Levels, int Layers, int Index) info = GetHandleInformation(baseHandle + i); // Ensure the data for this handle is loaded in the span. if (spanEndIndex <= i - 1) @@ -426,7 +426,7 @@ namespace Ryujinx.Graphics.Gpu.Image } } - var endInfo = spanEndIndex == i ? info : GetHandleInformation(baseHandle + spanEndIndex); + (int BaseLayer, int BaseLevel, int Levels, int Layers, int Index) endInfo = spanEndIndex == i ? info : GetHandleInformation(baseHandle + spanEndIndex); spanBase = _allOffsets[info.Index]; int spanLast = _allOffsets[endInfo.Index + endInfo.Layers * endInfo.Levels - 1]; @@ -479,7 +479,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// True if flushes should be tracked, false otherwise private bool ShouldFlushTriggerTracking() { - foreach (var overlap in _incompatibleOverlaps) + foreach (TextureIncompatibleOverlap overlap in _incompatibleOverlaps) { if (overlap.Group._flushIncompatibleOverlaps) { @@ -637,7 +637,7 @@ namespace Ryujinx.Graphics.Gpu.Image bool canImport = Storage.Info.IsLinear && Storage.Info.Stride >= Storage.Info.Width * Storage.Info.FormatInfo.BytesPerPixel; - var hostPointer = canImport ? _physicalMemory.GetHostPointer(Storage.Range) : 0; + IntPtr hostPointer = canImport ? _physicalMemory.GetHostPointer(Storage.Range) : 0; if (hostPointer != 0 && _context.Renderer.PrepareHostMapping(hostPointer, Storage.Size)) { @@ -1019,7 +1019,7 @@ namespace Ryujinx.Graphics.Gpu.Image int endOffset = _allOffsets[viewEnd] + _sliceSizes[lastLevel]; int size = endOffset - offset; - var result = new List(); + List result = new List(); for (int i = 0; i < TextureRange.Count; i++) { @@ -1053,7 +1053,7 @@ namespace Ryujinx.Graphics.Gpu.Image offset = _allOffsets[viewStart]; ulong maxSize = Storage.Size - (ulong)offset; - var groupHandle = new TextureGroupHandle( + TextureGroupHandle groupHandle = new TextureGroupHandle( this, offset, Math.Min(maxSize, (ulong)size), @@ -1160,17 +1160,17 @@ namespace Ryujinx.Graphics.Gpu.Image /// The offset of the old handles in relation to the new ones private void InheritHandles(TextureGroupHandle[] oldHandles, TextureGroupHandle[] handles, int relativeOffset) { - foreach (var group in handles) + foreach (TextureGroupHandle group in handles) { - foreach (var handle in group.Handles) + foreach (RegionHandle handle in group.Handles) { bool dirty = false; - foreach (var oldGroup in oldHandles) + foreach (TextureGroupHandle oldGroup in oldHandles) { if (group.OverlapsWith(oldGroup.Offset + relativeOffset, oldGroup.Size)) { - foreach (var oldHandle in oldGroup.Handles) + foreach (RegionHandle oldHandle in oldGroup.Handles) { if (handle.OverlapsWith(oldHandle.Address, oldHandle.Size)) { @@ -1194,7 +1194,7 @@ namespace Ryujinx.Graphics.Gpu.Image } } - foreach (var oldGroup in oldHandles) + foreach (TextureGroupHandle oldGroup in oldHandles) { oldGroup.Modified = false; } @@ -1254,7 +1254,7 @@ namespace Ryujinx.Graphics.Gpu.Image continue; } - foreach (var oldGroup in _handles) + foreach (TextureGroupHandle oldGroup in _handles) { if (!groupHandle.OverlapsWith(oldGroup.Offset, oldGroup.Size)) { @@ -1265,7 +1265,7 @@ namespace Ryujinx.Graphics.Gpu.Image { bool hasMatch = false; - foreach (var oldHandle in oldGroup.Handles) + foreach (RegionHandle oldHandle in oldGroup.Handles) { if (oldHandle.RangeEquals(handle)) { @@ -1292,9 +1292,9 @@ namespace Ryujinx.Graphics.Gpu.Image InheritHandles(_handles, handles, 0); - foreach (var oldGroup in _handles) + foreach (TextureGroupHandle oldGroup in _handles) { - foreach (var oldHandle in oldGroup.Handles) + foreach (RegionHandle oldHandle in oldGroup.Handles) { oldHandle.Dispose(); } @@ -1320,12 +1320,12 @@ namespace Ryujinx.Graphics.Gpu.Image else if (!(_hasMipViews || _hasLayerViews)) { // Single dirty region. - var cpuRegionHandles = new RegionHandle[TextureRange.Count]; + RegionHandle[] cpuRegionHandles = new RegionHandle[TextureRange.Count]; int count = 0; for (int i = 0; i < TextureRange.Count; i++) { - var currentRange = TextureRange.GetSubRange(i); + MemoryRange currentRange = TextureRange.GetSubRange(i); if (currentRange.Address != MemoryManager.PteUnmapped) { cpuRegionHandles[count++] = GenerateHandle(currentRange.Address, currentRange.Size); @@ -1337,7 +1337,7 @@ namespace Ryujinx.Graphics.Gpu.Image Array.Resize(ref cpuRegionHandles, count); } - var groupHandle = new TextureGroupHandle(this, 0, Storage.Size, _views, 0, 0, 0, _allOffsets.Length, cpuRegionHandles); + TextureGroupHandle groupHandle = new TextureGroupHandle(this, 0, Storage.Size, _views, 0, 0, 0, _allOffsets.Length, cpuRegionHandles); handles = new TextureGroupHandle[] { groupHandle }; } @@ -1355,7 +1355,7 @@ namespace Ryujinx.Graphics.Gpu.Image if (_is3D) { - var handlesList = new List(); + List handlesList = new List(); 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. - var targetRange = new List<(int BaseHandle, int RegionCount)>(); - var otherRange = new List<(int BaseHandle, int RegionCount)>(); + List<(int BaseHandle, int RegionCount)> targetRange = new List<(int BaseHandle, int RegionCount)>(); + List<(int BaseHandle, int RegionCount)> otherRange = new List<(int BaseHandle, int RegionCount)>(); 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))); diff --git a/src/Ryujinx.Graphics.Gpu/Image/TexturePool.cs b/src/Ryujinx.Graphics.Gpu/Image/TexturePool.cs index 3bf122412..3effc39b1 100644 --- a/src/Ryujinx.Graphics.Gpu/Image/TexturePool.cs +++ b/src/Ryujinx.Graphics.Gpu/Image/TexturePool.cs @@ -118,7 +118,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// Texture with the requested format, or null if not found public Texture Find(Format format) { - foreach (var alias in _aliases) + foreach (Alias alias in _aliases) { if (alias.Format == format) { @@ -134,7 +134,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// public void Destroy() { - foreach (var entry in _aliases) + foreach (Alias entry in _aliases) { entry.Texture.DecrementReferenceCount(); } @@ -361,7 +361,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// If true, queue the dereference to happen on the render thread, otherwise dereference immediately public void ForceRemove(Texture texture, int id, bool deferred) { - var previous = Interlocked.Exchange(ref Items[id], null); + Texture previous = Interlocked.Exchange(ref Items[id], null); if (deferred) { diff --git a/src/Ryujinx.Graphics.Gpu/Memory/Buffer.cs b/src/Ryujinx.Graphics.Gpu/Memory/Buffer.cs index e060e0b4f..6cc603b76 100644 --- a/src/Ryujinx.Graphics.Gpu/Memory/Buffer.cs +++ b/src/Ryujinx.Graphics.Gpu/Memory/Buffer.cs @@ -735,7 +735,7 @@ namespace Ryujinx.Graphics.Gpu.Memory { _context.Renderer.BackgroundContextAction(() => { - var ranges = _modifiedRanges; + BufferModifiedRangeList ranges = _modifiedRanges; if (ranges != null) { @@ -850,7 +850,7 @@ namespace Ryujinx.Graphics.Gpu.Memory { if (_virtualDependencies != null) { - foreach (var virtualBuffer in _virtualDependencies) + foreach (MultiRangeBuffer virtualBuffer in _virtualDependencies) { CopyToDependantVirtualBuffer(virtualBuffer, address, size); } @@ -875,7 +875,7 @@ namespace Ryujinx.Graphics.Gpu.Memory [MethodImpl(MethodImplOptions.NoInlining)] private void CopyFromDependantVirtualBuffersImpl() { - foreach (var virtualBuffer in _virtualDependencies.OrderBy(x => x.ModificationSequenceNumber)) + foreach (MultiRangeBuffer virtualBuffer in _virtualDependencies.OrderBy(x => x.ModificationSequenceNumber)) { virtualBuffer.ConsumeModifiedRegion(this, (mAddress, mSize) => { @@ -914,7 +914,7 @@ namespace Ryujinx.Graphics.Gpu.Memory { byte[] storage = dataSpan.ToArray(); - foreach (var virtualBuffer in _virtualDependencies.OrderBy(x => x.ModificationSequenceNumber)) + foreach (MultiRangeBuffer virtualBuffer in _virtualDependencies.OrderBy(x => x.ModificationSequenceNumber)) { virtualBuffer.ConsumeModifiedRegion(address, size, (mAddress, mSize) => { diff --git a/src/Ryujinx.Graphics.Gpu/Memory/BufferBackingState.cs b/src/Ryujinx.Graphics.Gpu/Memory/BufferBackingState.cs index 3f65131e6..56bc9143f 100644 --- a/src/Ryujinx.Graphics.Gpu/Memory/BufferBackingState.cs +++ b/src/Ryujinx.Graphics.Gpu/Memory/BufferBackingState.cs @@ -81,7 +81,7 @@ namespace Ryujinx.Graphics.Gpu.Memory { // Storage buffer bindings may require special treatment. - var rawStage = stage & BufferStage.StageMask; + BufferStage rawStage = stage & BufferStage.StageMask; if (rawStage == BufferStage.Fragment) { @@ -225,7 +225,7 @@ namespace Ryujinx.Graphics.Gpu.Memory // Storage write. _writeCount++; - var rawStage = stage & BufferStage.StageMask; + BufferStage rawStage = stage & BufferStage.StageMask; if (rawStage == BufferStage.Fragment) { diff --git a/src/Ryujinx.Graphics.Gpu/Memory/BufferCache.cs b/src/Ryujinx.Graphics.Gpu/Memory/BufferCache.cs index 66d2cdb62..2368da90f 100644 --- a/src/Ryujinx.Graphics.Gpu/Memory/BufferCache.cs +++ b/src/Ryujinx.Graphics.Gpu/Memory/BufferCache.cs @@ -412,7 +412,7 @@ namespace Ryujinx.Graphics.Gpu.Memory dstOffset += subRange.Size; } - foreach (var buffer in physicalBuffers) + foreach (Buffer buffer in physicalBuffers) { buffer.CopyToDependantVirtualBuffer(virtualBuffer); } @@ -1037,7 +1037,7 @@ namespace Ryujinx.Graphics.Gpu.Memory /// List used to track entries to delete private static void Prune(Dictionary dictionary, ref List toDelete) { - foreach (var entry in dictionary) + foreach (KeyValuePair entry in dictionary) { if (entry.Value.UnmappedSequence != entry.Value.Buffer.UnmappedSequence) { diff --git a/src/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs b/src/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs index 409867e09..a07e3445b 100644 --- a/src/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs +++ b/src/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs @@ -478,7 +478,7 @@ namespace Ryujinx.Graphics.Gpu.Memory /// public void CommitComputeBindings() { - var bufferCache = _channel.MemoryManager.Physical.BufferCache; + BufferCache bufferCache = _channel.MemoryManager.Physical.BufferCache; BindBuffers(bufferCache, _cpStorageBuffers, isStorage: true); BindBuffers(bufferCache, _cpUniformBuffers, isStorage: false); @@ -499,10 +499,10 @@ namespace Ryujinx.Graphics.Gpu.Memory { if (_bufferTextures.Count > 0) { - foreach (var binding in _bufferTextures) + foreach (BufferTextureBinding binding in _bufferTextures) { - var isStore = binding.BindingInfo.Flags.HasFlag(TextureUsageFlags.ImageStore); - var range = bufferCache.GetBufferRange(binding.Range, BufferStageUtils.TextureBuffer(binding.Stage, binding.BindingInfo.Flags), isStore); + bool isStore = binding.BindingInfo.Flags.HasFlag(TextureUsageFlags.ImageStore); + BufferRange range = bufferCache.GetBufferRange(binding.Range, BufferStageUtils.TextureBuffer(binding.Stage, binding.BindingInfo.Flags), isStore); binding.Texture.SetStorage(range); // The texture must be rebound to use the new storage if it was updated. @@ -524,19 +524,19 @@ namespace Ryujinx.Graphics.Gpu.Memory { ITexture[] textureArray = new ITexture[1]; - foreach (var binding in _bufferTextureArrays) + foreach (BufferTextureArrayBinding binding in _bufferTextureArrays) { - var range = bufferCache.GetBufferRange(binding.Range, BufferStage.None); + BufferRange range = bufferCache.GetBufferRange(binding.Range, BufferStage.None); binding.Texture.SetStorage(range); textureArray[0] = binding.Texture; binding.Array.SetTextures(binding.Index, textureArray); } - foreach (var binding in _bufferImageArrays) + foreach (BufferTextureArrayBinding binding in _bufferImageArrays) { - var isStore = binding.BindingInfo.Flags.HasFlag(TextureUsageFlags.ImageStore); - var range = bufferCache.GetBufferRange(binding.Range, BufferStage.None, isStore); + bool isStore = binding.BindingInfo.Flags.HasFlag(TextureUsageFlags.ImageStore); + BufferRange range = bufferCache.GetBufferRange(binding.Range, BufferStage.None, isStore); binding.Texture.SetStorage(range); textureArray[0] = binding.Texture; @@ -555,7 +555,7 @@ namespace Ryujinx.Graphics.Gpu.Memory /// True if the index buffer is in use public void CommitGraphicsBindings(bool indexed) { - var bufferCache = _channel.MemoryManager.Physical.BufferCache; + BufferCache bufferCache = _channel.MemoryManager.Physical.BufferCache; if (indexed) { @@ -750,19 +750,19 @@ namespace Ryujinx.Graphics.Gpu.Memory for (ShaderStage stage = ShaderStage.Vertex; stage <= ShaderStage.Fragment; stage++) { - ref var buffers = ref bindings[(int)stage - 1]; + ref BuffersPerStage buffers = ref bindings[(int)stage - 1]; BufferStage bufferStage = BufferStageUtils.FromShaderStage(stage); for (int index = 0; index < buffers.Count; index++) { - ref var bindingInfo = ref buffers.Bindings[index]; + ref BufferDescriptor bindingInfo = ref buffers.Bindings[index]; BufferBounds bounds = buffers.Buffers[bindingInfo.Slot]; if (!bounds.IsUnmapped) { - var isWrite = bounds.Flags.HasFlag(BufferUsageFlags.Write); - var range = isStorage + bool isWrite = bounds.Flags.HasFlag(BufferUsageFlags.Write); + BufferRange range = isStorage ? bufferCache.GetBufferRangeAligned(bounds.Range, bufferStage | BufferStageUtils.FromUsage(bounds.Flags), isWrite) : bufferCache.GetBufferRange(bounds.Range, bufferStage); @@ -792,14 +792,14 @@ namespace Ryujinx.Graphics.Gpu.Memory for (int index = 0; index < buffers.Count; index++) { - ref var bindingInfo = ref buffers.Bindings[index]; + ref BufferDescriptor bindingInfo = ref buffers.Bindings[index]; BufferBounds bounds = buffers.Buffers[bindingInfo.Slot]; if (!bounds.IsUnmapped) { - var isWrite = bounds.Flags.HasFlag(BufferUsageFlags.Write); - var range = isStorage + bool isWrite = bounds.Flags.HasFlag(BufferUsageFlags.Write); + BufferRange range = isStorage ? bufferCache.GetBufferRangeAligned(bounds.Range, BufferStageUtils.ComputeStorage(bounds.Flags), isWrite) : bufferCache.GetBufferRange(bounds.Range, BufferStage.Compute); @@ -841,11 +841,11 @@ namespace Ryujinx.Graphics.Gpu.Memory { for (ShaderStage stage = ShaderStage.Vertex; stage <= ShaderStage.Fragment; stage++) { - ref var buffers = ref bindings[(int)stage - 1]; + ref BuffersPerStage buffers = ref bindings[(int)stage - 1]; for (int index = 0; index < buffers.Count; index++) { - ref var binding = ref buffers.Bindings[index]; + ref BufferDescriptor binding = ref buffers.Bindings[index]; BufferBounds bounds = buffers.Buffers[binding.Slot]; diff --git a/src/Ryujinx.Graphics.Gpu/Memory/BufferModifiedRangeList.cs b/src/Ryujinx.Graphics.Gpu/Memory/BufferModifiedRangeList.cs index c5a12c1fc..105082f31 100644 --- a/src/Ryujinx.Graphics.Gpu/Memory/BufferModifiedRangeList.cs +++ b/src/Ryujinx.Graphics.Gpu/Memory/BufferModifiedRangeList.cs @@ -117,7 +117,7 @@ namespace Ryujinx.Graphics.Gpu.Memory lock (_lock) { // Slices a given region using the modified regions in the list. Calls the action for the new slices. - ref var overlaps = ref ThreadStaticArray.Get(); + ref BufferModifiedRange[] overlaps = ref ThreadStaticArray.Get(); int count = FindOverlapsNonOverlapping(address, size, ref overlaps); @@ -156,7 +156,7 @@ namespace Ryujinx.Graphics.Gpu.Memory lock (_lock) { // We may overlap with some existing modified regions. They must be cut into by the new entry. - ref var overlaps = ref ThreadStaticArray.Get(); + ref BufferModifiedRange[] overlaps = ref ThreadStaticArray.Get(); int count = FindOverlapsNonOverlapping(address, size, ref overlaps); @@ -210,7 +210,7 @@ namespace Ryujinx.Graphics.Gpu.Memory { int count = 0; - ref var overlaps = ref ThreadStaticArray.Get(); + ref BufferModifiedRange[] overlaps = ref ThreadStaticArray.Get(); // Range list must be consistent for this operation. lock (_lock) @@ -239,7 +239,7 @@ namespace Ryujinx.Graphics.Gpu.Memory { int count = 0; - ref var overlaps = ref ThreadStaticArray.Get(); + ref BufferModifiedRange[] overlaps = ref ThreadStaticArray.Get(); // Range list must be consistent for this operation. lock (_lock) @@ -355,7 +355,7 @@ namespace Ryujinx.Graphics.Gpu.Memory int rangeCount = 0; - ref var overlaps = ref ThreadStaticArray.Get(); + ref BufferModifiedRange[] overlaps = ref ThreadStaticArray.Get(); // Range list must be consistent for this operation lock (_lock) diff --git a/src/Ryujinx.Graphics.Gpu/Memory/BufferUpdater.cs b/src/Ryujinx.Graphics.Gpu/Memory/BufferUpdater.cs index 02090c04f..a5ee3ab70 100644 --- a/src/Ryujinx.Graphics.Gpu/Memory/BufferUpdater.cs +++ b/src/Ryujinx.Graphics.Gpu/Memory/BufferUpdater.cs @@ -73,7 +73,7 @@ namespace Ryujinx.Graphics.Gpu.Memory if (binding >= 0) { - var range = new BufferRange(_handle, 0, data.Length); + BufferRange range = new BufferRange(_handle, 0, data.Length); _renderer.Pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(0, range) }); } }; diff --git a/src/Ryujinx.Graphics.Gpu/Memory/GpuRegionHandle.cs b/src/Ryujinx.Graphics.Gpu/Memory/GpuRegionHandle.cs index bdb7cf2c2..77eb7c4a4 100644 --- a/src/Ryujinx.Graphics.Gpu/Memory/GpuRegionHandle.cs +++ b/src/Ryujinx.Graphics.Gpu/Memory/GpuRegionHandle.cs @@ -14,7 +14,7 @@ namespace Ryujinx.Graphics.Gpu.Memory { get { - foreach (var regionHandle in _cpuRegionHandles) + foreach (RegionHandle regionHandle in _cpuRegionHandles) { if (regionHandle.Dirty) { @@ -44,7 +44,7 @@ namespace Ryujinx.Graphics.Gpu.Memory /// public void Dispose() { - foreach (var regionHandle in _cpuRegionHandles) + foreach (RegionHandle regionHandle in _cpuRegionHandles) { regionHandle.Dispose(); } @@ -57,7 +57,7 @@ namespace Ryujinx.Graphics.Gpu.Memory /// Action to call on read or write public void RegisterAction(RegionSignal action) { - foreach (var regionHandle in _cpuRegionHandles) + foreach (RegionHandle regionHandle in _cpuRegionHandles) { regionHandle.RegisterAction(action); } @@ -70,7 +70,7 @@ namespace Ryujinx.Graphics.Gpu.Memory /// Action to call on read or write public void RegisterPreciseAction(PreciseRegionSignal action) { - foreach (var regionHandle in _cpuRegionHandles) + foreach (RegionHandle regionHandle in _cpuRegionHandles) { regionHandle.RegisterPreciseAction(action); } @@ -81,7 +81,7 @@ namespace Ryujinx.Graphics.Gpu.Memory /// public void Reprotect(bool asDirty = false) { - foreach (var regionHandle in _cpuRegionHandles) + foreach (RegionHandle regionHandle in _cpuRegionHandles) { regionHandle.Reprotect(asDirty); } @@ -92,7 +92,7 @@ namespace Ryujinx.Graphics.Gpu.Memory /// public void ForceDirty() { - foreach (var regionHandle in _cpuRegionHandles) + foreach (RegionHandle regionHandle in _cpuRegionHandles) { regionHandle.ForceDirty(); } diff --git a/src/Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs b/src/Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs index 59e618c02..5ee5ce456 100644 --- a/src/Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs +++ b/src/Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs @@ -458,7 +458,7 @@ namespace Ryujinx.Graphics.Gpu.Memory int pages = (int)((endVaRounded - va) / PageSize); - var regions = new List(); + List regions = new List(); for (int page = 0; page < pages - 1; page++) { diff --git a/src/Ryujinx.Graphics.Gpu/Memory/MultiRangeBuffer.cs b/src/Ryujinx.Graphics.Gpu/Memory/MultiRangeBuffer.cs index d92b0836e..19ef56bb1 100644 --- a/src/Ryujinx.Graphics.Gpu/Memory/MultiRangeBuffer.cs +++ b/src/Ryujinx.Graphics.Gpu/Memory/MultiRangeBuffer.cs @@ -149,7 +149,7 @@ namespace Ryujinx.Graphics.Gpu.Memory if (_dependencies != null) { - foreach (var dependency in _dependencies) + foreach (PhysicalDependency dependency in _dependencies) { if (dependency.PhysicalBuffer == buffer && dependency.VirtualOffset >= minimumVirtOffset) { @@ -231,7 +231,7 @@ namespace Ryujinx.Graphics.Gpu.Memory { if (_dependencies != null) { - foreach (var dependency in _dependencies) + foreach (PhysicalDependency dependency in _dependencies) { dependency.PhysicalBuffer.RemoveVirtualDependency(this); } diff --git a/src/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs b/src/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs index b22cc01b8..d9dd7f1d9 100644 --- a/src/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs +++ b/src/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs @@ -102,10 +102,10 @@ namespace Ryujinx.Graphics.Gpu.Memory { if (range.Count == 1) { - var singleRange = range.GetSubRange(0); + MemoryRange singleRange = range.GetSubRange(0); if (singleRange.Address != MemoryManager.PteUnmapped) { - var regions = _cpuMemory.GetHostRegions(singleRange.Address, singleRange.Size); + IEnumerable regions = _cpuMemory.GetHostRegions(singleRange.Address, singleRange.Size); if (regions != null && regions.Count() == 1) { @@ -139,7 +139,7 @@ namespace Ryujinx.Graphics.Gpu.Memory { if (range.Count == 1) { - var singleRange = range.GetSubRange(0); + MemoryRange singleRange = range.GetSubRange(0); if (singleRange.Address != MemoryManager.PteUnmapped) { return _cpuMemory.GetSpan(singleRange.Address, (int)singleRange.Size, tracked); @@ -152,7 +152,7 @@ namespace Ryujinx.Graphics.Gpu.Memory for (int i = 0; i < range.Count; i++) { - var currentRange = range.GetSubRange(i); + MemoryRange currentRange = range.GetSubRange(i); int size = (int)currentRange.Size; if (currentRange.Address != MemoryManager.PteUnmapped) { @@ -199,7 +199,7 @@ namespace Ryujinx.Graphics.Gpu.Memory int offset = 0; for (int i = 0; i < range.Count; i++) { - var currentRange = range.GetSubRange(i); + MemoryRange currentRange = range.GetSubRange(i); int size = (int)currentRange.Size; if (currentRange.Address != MemoryManager.PteUnmapped) { @@ -322,7 +322,7 @@ namespace Ryujinx.Graphics.Gpu.Memory { if (range.Count == 1) { - var singleRange = range.GetSubRange(0); + MemoryRange singleRange = range.GetSubRange(0); if (singleRange.Address != MemoryManager.PteUnmapped) { writeCallback(singleRange.Address, data); @@ -334,7 +334,7 @@ namespace Ryujinx.Graphics.Gpu.Memory for (int i = 0; i < range.Count; i++) { - var currentRange = range.GetSubRange(i); + MemoryRange currentRange = range.GetSubRange(i); int size = (int)currentRange.Size; if (currentRange.Address != MemoryManager.PteUnmapped) { @@ -382,12 +382,12 @@ namespace Ryujinx.Graphics.Gpu.Memory /// The memory tracking handle public GpuRegionHandle BeginTracking(MultiRange range, ResourceKind kind) { - var cpuRegionHandles = new RegionHandle[range.Count]; + RegionHandle[] cpuRegionHandles = new RegionHandle[range.Count]; int count = 0; for (int i = 0; i < range.Count; i++) { - var currentRange = range.GetSubRange(i); + MemoryRange currentRange = range.GetSubRange(i); if (currentRange.Address != MemoryManager.PteUnmapped) { cpuRegionHandles[count++] = _cpuMemory.BeginTracking(currentRange.Address, currentRange.Size, (int)kind); diff --git a/src/Ryujinx.Graphics.Gpu/Memory/SupportBufferUpdater.cs b/src/Ryujinx.Graphics.Gpu/Memory/SupportBufferUpdater.cs index fc444f49c..20831fa99 100644 --- a/src/Ryujinx.Graphics.Gpu/Memory/SupportBufferUpdater.cs +++ b/src/Ryujinx.Graphics.Gpu/Memory/SupportBufferUpdater.cs @@ -19,7 +19,7 @@ namespace Ryujinx.Graphics.Gpu.Memory /// Renderer that the support buffer will be used with public SupportBufferUpdater(IRenderer renderer) : base(renderer) { - var defaultScale = new Vector4 { X = 1f, Y = 0f, Z = 0f, W = 0f }; + Vector4 defaultScale = new Vector4 { X = 1f, Y = 0f, Z = 0f, W = 0f }; _data.RenderScale.AsSpan().Fill(defaultScale); DirtyRenderScale(0, SupportBuffer.RenderScaleMaxCount); } diff --git a/src/Ryujinx.Graphics.Gpu/Shader/CachedShaderBindings.cs b/src/Ryujinx.Graphics.Gpu/Shader/CachedShaderBindings.cs index 018c5fdc0..a4bcbc6f5 100644 --- a/src/Ryujinx.Graphics.Gpu/Shader/CachedShaderBindings.cs +++ b/src/Ryujinx.Graphics.Gpu/Shader/CachedShaderBindings.cs @@ -60,7 +60,7 @@ namespace Ryujinx.Graphics.Gpu.Shader { Target target = descriptor.Type != SamplerType.None ? ShaderTexture.GetTarget(descriptor.Type) : default; - var result = new TextureBindingInfo( + TextureBindingInfo result = new TextureBindingInfo( target, descriptor.Set, descriptor.Binding, @@ -88,7 +88,7 @@ namespace Ryujinx.Graphics.Gpu.Shader Target target = ShaderTexture.GetTarget(descriptor.Type); FormatInfo formatInfo = ShaderTexture.GetFormatInfo(descriptor.Format); - var result = new TextureBindingInfo( + TextureBindingInfo result = new TextureBindingInfo( target, formatInfo, descriptor.Set, diff --git a/src/Ryujinx.Graphics.Gpu/Shader/ComputeShaderCacheHashTable.cs b/src/Ryujinx.Graphics.Gpu/Shader/ComputeShaderCacheHashTable.cs index 0119a6a33..49516b310 100644 --- a/src/Ryujinx.Graphics.Gpu/Shader/ComputeShaderCacheHashTable.cs +++ b/src/Ryujinx.Graphics.Gpu/Shader/ComputeShaderCacheHashTable.cs @@ -26,7 +26,7 @@ namespace Ryujinx.Graphics.Gpu.Shader /// Program to be added public void Add(CachedShaderProgram program) { - var specList = _cache.GetOrAdd(program.Shaders[0].Code, new ShaderSpecializationList()); + ShaderSpecializationList specList = _cache.GetOrAdd(program.Shaders[0].Code, new ShaderSpecializationList()); specList.Add(program); _shaderPrograms.Add(program); } @@ -51,7 +51,7 @@ namespace Ryujinx.Graphics.Gpu.Shader { program = null; ShaderCodeAccessor codeAccessor = new(channel.MemoryManager, gpuVa); - bool hasSpecList = _cache.TryFindItem(codeAccessor, out var specList, out cachedGuestCode); + bool hasSpecList = _cache.TryFindItem(codeAccessor, out ShaderSpecializationList specList, out cachedGuestCode); return hasSpecList && specList.TryFindForCompute(channel, poolState, computeState, out program); } @@ -62,7 +62,7 @@ namespace Ryujinx.Graphics.Gpu.Shader /// Programs added to the table public IEnumerable GetPrograms() { - foreach (var program in _shaderPrograms) + foreach (CachedShaderProgram program in _shaderPrograms) { yield return program; } diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheGuestStorage.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheGuestStorage.cs index 22af88d31..237ae18ec 100644 --- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheGuestStorage.cs +++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheGuestStorage.cs @@ -180,8 +180,8 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache /// public void ClearCache() { - using var tocFileStream = DiskCacheCommon.OpenFile(_basePath, TocFileName, writable: true); - using var dataFileStream = DiskCacheCommon.OpenFile(_basePath, DataFileName, writable: true); + using FileStream tocFileStream = DiskCacheCommon.OpenFile(_basePath, TocFileName, writable: true); + using FileStream dataFileStream = DiskCacheCommon.OpenFile(_basePath, DataFileName, writable: true); tocFileStream.SetLength(0); dataFileStream.SetLength(0); @@ -258,8 +258,8 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache /// Index of the shader on the cache public int AddShader(ReadOnlySpan data, ReadOnlySpan cb1Data) { - using var tocFileStream = DiskCacheCommon.OpenFile(_basePath, TocFileName, writable: true); - using var dataFileStream = DiskCacheCommon.OpenFile(_basePath, DataFileName, writable: true); + using FileStream tocFileStream = DiskCacheCommon.OpenFile(_basePath, TocFileName, writable: true); + using FileStream dataFileStream = DiskCacheCommon.OpenFile(_basePath, DataFileName, writable: true); TocHeader header = new(); @@ -267,9 +267,9 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache uint hash = CalcHash(data, cb1Data); - if (_toc.TryGetValue(hash, out var list)) + if (_toc.TryGetValue(hash, out List list)) { - foreach (var entry in list) + foreach (TocMemoryEntry entry in list) { if (data.Length != entry.CodeSize || cb1Data.Length != entry.Cb1DataSize) { @@ -427,7 +427,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache /// Index of the data on the cache private void AddTocMemoryEntry(uint dataOffset, uint codeSize, uint cb1DataSize, uint hash, int index) { - if (!_toc.TryGetValue(hash, out var list)) + if (!_toc.TryGetValue(hash, out List list)) { _toc.Add(hash, list = new List()); } diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheHostStorage.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheHostStorage.cs index b6b811389..4ef0caced 100644 --- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheHostStorage.cs +++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheHostStorage.cs @@ -301,11 +301,11 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache try { - using var tocFileStream = DiskCacheCommon.OpenFile(_basePath, SharedTocFileName, writable: false); - using var dataFileStream = DiskCacheCommon.OpenFile(_basePath, SharedDataFileName, writable: false); + using FileStream tocFileStream = DiskCacheCommon.OpenFile(_basePath, SharedTocFileName, writable: false); + using FileStream dataFileStream = DiskCacheCommon.OpenFile(_basePath, SharedDataFileName, writable: false); - using var guestTocFileStream = _guestStorage.OpenTocFileStream(); - using var guestDataFileStream = _guestStorage.OpenDataFileStream(); + using Stream guestTocFileStream = _guestStorage.OpenTocFileStream(); + using Stream guestDataFileStream = _guestStorage.OpenDataFileStream(); BinarySerializer tocReader = new(tocFileStream); BinarySerializer dataReader = new(dataFileStream); @@ -547,11 +547,11 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache /// A collection of disk cache output streams public DiskCacheOutputStreams GetOutputStreams(GpuContext context) { - var tocFileStream = DiskCacheCommon.OpenFile(_basePath, SharedTocFileName, writable: true); - var dataFileStream = DiskCacheCommon.OpenFile(_basePath, SharedDataFileName, writable: true); + FileStream tocFileStream = DiskCacheCommon.OpenFile(_basePath, SharedTocFileName, writable: true); + FileStream dataFileStream = DiskCacheCommon.OpenFile(_basePath, SharedDataFileName, writable: true); - var hostTocFileStream = DiskCacheCommon.OpenFile(_basePath, GetHostTocFileName(context), writable: true); - var hostDataFileStream = DiskCacheCommon.OpenFile(_basePath, GetHostDataFileName(context), writable: true); + FileStream hostTocFileStream = DiskCacheCommon.OpenFile(_basePath, GetHostTocFileName(context), writable: true); + FileStream hostDataFileStream = DiskCacheCommon.OpenFile(_basePath, GetHostDataFileName(context), writable: true); return new DiskCacheOutputStreams(tocFileStream, dataFileStream, hostTocFileStream, hostDataFileStream); } @@ -569,7 +569,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache for (int index = 0; index < program.Shaders.Length; index++) { - var shader = program.Shaders[index]; + CachedShaderStage shader = program.Shaders[index]; if (shader == null || (shader.Info != null && shader.Info.Stage == ShaderStage.Compute)) { continue; @@ -578,8 +578,8 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache stagesBitMask |= 1u << index; } - var tocFileStream = streams != null ? streams.TocFileStream : DiskCacheCommon.OpenFile(_basePath, SharedTocFileName, writable: true); - var dataFileStream = streams != null ? streams.DataFileStream : DiskCacheCommon.OpenFile(_basePath, SharedDataFileName, writable: true); + FileStream tocFileStream = streams != null ? streams.TocFileStream : DiskCacheCommon.OpenFile(_basePath, SharedTocFileName, writable: true); + FileStream dataFileStream = streams != null ? streams.DataFileStream : DiskCacheCommon.OpenFile(_basePath, SharedDataFileName, writable: true); ulong timestamp = (ulong)DateTime.UtcNow.Subtract(DateTime.UnixEpoch).TotalSeconds; @@ -610,7 +610,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache for (int index = 0; index < program.Shaders.Length; index++) { - var shader = program.Shaders[index]; + CachedShaderStage shader = program.Shaders[index]; if (shader == null) { continue; @@ -655,8 +655,8 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache /// GPU context public void ClearSharedCache() { - using var tocFileStream = DiskCacheCommon.OpenFile(_basePath, SharedTocFileName, writable: true); - using var dataFileStream = DiskCacheCommon.OpenFile(_basePath, SharedDataFileName, writable: true); + using FileStream tocFileStream = DiskCacheCommon.OpenFile(_basePath, SharedTocFileName, writable: true); + using FileStream dataFileStream = DiskCacheCommon.OpenFile(_basePath, SharedDataFileName, writable: true); tocFileStream.SetLength(0); dataFileStream.SetLength(0); @@ -668,8 +668,8 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache /// GPU context public void ClearHostCache(GpuContext context) { - using var tocFileStream = DiskCacheCommon.OpenFile(_basePath, GetHostTocFileName(context), writable: true); - using var dataFileStream = DiskCacheCommon.OpenFile(_basePath, GetHostDataFileName(context), writable: true); + using FileStream tocFileStream = DiskCacheCommon.OpenFile(_basePath, GetHostTocFileName(context), writable: true); + using FileStream dataFileStream = DiskCacheCommon.OpenFile(_basePath, GetHostDataFileName(context), writable: true); tocFileStream.SetLength(0); dataFileStream.SetLength(0); @@ -690,8 +690,8 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache DiskCacheOutputStreams streams, ulong timestamp) { - var tocFileStream = streams != null ? streams.HostTocFileStream : DiskCacheCommon.OpenFile(_basePath, GetHostTocFileName(context), writable: true); - var dataFileStream = streams != null ? streams.HostDataFileStream : DiskCacheCommon.OpenFile(_basePath, GetHostDataFileName(context), writable: true); + FileStream tocFileStream = streams != null ? streams.HostTocFileStream : DiskCacheCommon.OpenFile(_basePath, GetHostTocFileName(context), writable: true); + FileStream dataFileStream = streams != null ? streams.HostDataFileStream : DiskCacheCommon.OpenFile(_basePath, GetHostDataFileName(context), writable: true); if (tocFileStream.Length == 0) { @@ -853,25 +853,25 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache for (int index = 0; index < info.CBuffers.Count; index++) { - var entry = info.CBuffers[index]; + BufferDescriptor entry = info.CBuffers[index]; dataWriter.WriteWithMagicAndSize(ref entry, BufdMagic); } for (int index = 0; index < info.SBuffers.Count; index++) { - var entry = info.SBuffers[index]; + BufferDescriptor entry = info.SBuffers[index]; dataWriter.WriteWithMagicAndSize(ref entry, BufdMagic); } for (int index = 0; index < info.Textures.Count; index++) { - var entry = info.Textures[index]; + TextureDescriptor entry = info.Textures[index]; dataWriter.WriteWithMagicAndSize(ref entry, TexdMagic); } for (int index = 0; index < info.Images.Count; index++) { - var entry = info.Images[index]; + TextureDescriptor entry = info.Images[index]; dataWriter.WriteWithMagicAndSize(ref entry, TexdMagic); } } diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ParallelDiskCacheLoader.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ParallelDiskCacheLoader.cs index eb0f72af1..9424a1084 100644 --- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ParallelDiskCacheLoader.cs +++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ParallelDiskCacheLoader.cs @@ -303,10 +303,10 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache Logger.Info?.Print(LogClass.Gpu, $"Rebuilding {_programList.Count} shaders..."); - using var streams = _hostStorage.GetOutputStreams(_context); + using DiskCacheOutputStreams streams = _hostStorage.GetOutputStreams(_context); int packagedShaders = 0; - foreach (var kv in _programList) + foreach (KeyValuePair kv in _programList) { if (!Active) { diff --git a/src/Ryujinx.Graphics.Gpu/Shader/GpuAccessor.cs b/src/Ryujinx.Graphics.Gpu/Shader/GpuAccessor.cs index 4e9134291..c7d86a47e 100644 --- a/src/Ryujinx.Graphics.Gpu/Shader/GpuAccessor.cs +++ b/src/Ryujinx.Graphics.Gpu/Shader/GpuAccessor.cs @@ -4,6 +4,7 @@ using Ryujinx.Graphics.Shader; using Ryujinx.Graphics.Shader.Translation; using System; using System.Runtime.InteropServices; +using TextureDescriptor = Ryujinx.Graphics.Gpu.Image.TextureDescriptor; namespace Ryujinx.Graphics.Gpu.Shader { @@ -177,7 +178,7 @@ namespace Ryujinx.Graphics.Gpu.Shader public TextureFormat QueryTextureFormat(int handle, int cbufSlot) { _state.SpecializationState?.RecordTextureFormat(_stageIndex, handle, cbufSlot); - var descriptor = GetTextureDescriptor(handle, cbufSlot); + TextureDescriptor descriptor = GetTextureDescriptor(handle, cbufSlot); return ConvertToTextureFormat(descriptor.UnpackFormat(), descriptor.UnpackSrgb()); } diff --git a/src/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs b/src/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs index b50ea174d..3ff92896b 100644 --- a/src/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs +++ b/src/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs @@ -205,7 +205,7 @@ namespace Ryujinx.Graphics.Gpu.Shader GpuChannelComputeState computeState, ulong gpuVa) { - if (_cpPrograms.TryGetValue(gpuVa, out var cpShader) && IsShaderEqual(channel, poolState, computeState, cpShader, gpuVa)) + if (_cpPrograms.TryGetValue(gpuVa, out CachedShaderProgram cpShader) && IsShaderEqual(channel, poolState, computeState, cpShader, gpuVa)) { return cpShader; } @@ -255,8 +255,8 @@ namespace Ryujinx.Graphics.Gpu.Shader { channel.TextureManager.UpdateRenderTargets(); - var rtControl = state.RtControl; - var msaaMode = state.RtMsaaMode; + RtControl rtControl = state.RtControl; + TextureMsaaMode msaaMode = state.RtMsaaMode; pipeline.SamplesCount = msaaMode.SamplesInX() * msaaMode.SamplesInY(); @@ -266,7 +266,7 @@ namespace Ryujinx.Graphics.Gpu.Shader { int rtIndex = rtControl.UnpackPermutationIndex(index); - var colorState = state.RtColorState[rtIndex]; + RtColorState colorState = state.RtColorState[rtIndex]; if (index >= count || colorState.Format == 0 || colorState.WidthOrStride == 0) { @@ -311,12 +311,12 @@ namespace Ryujinx.Graphics.Gpu.Shader ref GpuChannelGraphicsState graphicsState, ShaderAddresses addresses) { - if (_gpPrograms.TryGetValue(addresses, out var gpShaders) && IsShaderEqual(channel, ref poolState, ref graphicsState, gpShaders, addresses)) + if (_gpPrograms.TryGetValue(addresses, out CachedShaderProgram gpShaders) && IsShaderEqual(channel, ref poolState, ref graphicsState, gpShaders, addresses)) { return gpShaders; } - if (_graphicsShaderCache.TryFind(channel, ref poolState, ref graphicsState, addresses, out gpShaders, out var cachedGuestCode)) + if (_graphicsShaderCache.TryFind(channel, ref poolState, ref graphicsState, addresses, out gpShaders, out CachedGraphicsGuestCode cachedGuestCode)) { _gpPrograms[addresses] = gpShaders; return gpShaders; @@ -587,7 +587,7 @@ namespace Ryujinx.Graphics.Gpu.Shader for (int i = 0; i < Constants.TotalTransformFeedbackBuffers; i++) { - var tf = state.TfState[i]; + TfState tf = state.TfState[i]; descs[i] = new TransformFeedbackDescriptor( tf.BufferIndex, @@ -693,7 +693,7 @@ namespace Ryujinx.Graphics.Gpu.Shader /// The generated translator context public static TranslatorContext DecodeComputeShader(IGpuAccessor gpuAccessor, TargetApi api, ulong gpuVa) { - var options = CreateTranslationOptions(api, DefaultFlags | TranslationFlags.Compute); + TranslationOptions options = CreateTranslationOptions(api, DefaultFlags | TranslationFlags.Compute); return Translator.CreateContext(gpuVa, gpuAccessor, options); } @@ -710,7 +710,7 @@ namespace Ryujinx.Graphics.Gpu.Shader /// The generated translator context public static TranslatorContext DecodeGraphicsShader(IGpuAccessor gpuAccessor, TargetApi api, TranslationFlags flags, ulong gpuVa) { - var options = CreateTranslationOptions(api, flags); + TranslationOptions options = CreateTranslationOptions(api, flags); return Translator.CreateContext(gpuVa, gpuAccessor, options); } @@ -736,7 +736,7 @@ namespace Ryujinx.Graphics.Gpu.Shader { ulong cb1DataAddress = channel.BufferManager.GetGraphicsUniformBufferAddress(0, 1); - var memoryManager = channel.MemoryManager; + MemoryManager memoryManager = channel.MemoryManager; codeA ??= memoryManager.GetSpan(vertexA.Address, vertexA.Size).ToArray(); codeB ??= memoryManager.GetSpan(currentStage.Address, currentStage.Size).ToArray(); @@ -774,7 +774,7 @@ namespace Ryujinx.Graphics.Gpu.Shader /// Compiled graphics shader code private static TranslatedShader TranslateShader(ShaderDumper dumper, GpuChannel channel, TranslatorContext context, byte[] code, bool asCompute) { - var memoryManager = channel.MemoryManager; + MemoryManager memoryManager = channel.MemoryManager; ulong cb1DataAddress = context.Stage == ShaderStage.Compute ? channel.BufferManager.GetComputeUniformBufferAddress(1) diff --git a/src/Ryujinx.Graphics.Gpu/Shader/ShaderCacheHashTable.cs b/src/Ryujinx.Graphics.Gpu/Shader/ShaderCacheHashTable.cs index e65a1dec9..562837791 100644 --- a/src/Ryujinx.Graphics.Gpu/Shader/ShaderCacheHashTable.cs +++ b/src/Ryujinx.Graphics.Gpu/Shader/ShaderCacheHashTable.cs @@ -156,7 +156,7 @@ namespace Ryujinx.Graphics.Gpu.Shader { IdTable idTable = new(); - foreach (var shader in program.Shaders) + foreach (CachedShaderStage shader in program.Shaders) { if (shader == null) { @@ -221,7 +221,7 @@ namespace Ryujinx.Graphics.Gpu.Shader out CachedShaderProgram program, out CachedGraphicsGuestCode guestCode) { - var memoryManager = channel.MemoryManager; + MemoryManager memoryManager = channel.MemoryManager; IdTable idTable = new(); guestCode = new CachedGraphicsGuestCode(); @@ -270,9 +270,9 @@ namespace Ryujinx.Graphics.Gpu.Shader /// Programs added to the table public IEnumerable GetPrograms() { - foreach (var specList in _shaderPrograms.Values) + foreach (ShaderSpecializationList specList in _shaderPrograms.Values) { - foreach (var program in specList) + foreach (CachedShaderProgram program in specList) { yield return program; } diff --git a/src/Ryujinx.Graphics.Gpu/Shader/ShaderInfoBuilder.cs b/src/Ryujinx.Graphics.Gpu/Shader/ShaderInfoBuilder.cs index e283d0832..50061db60 100644 --- a/src/Ryujinx.Graphics.Gpu/Shader/ShaderInfoBuilder.cs +++ b/src/Ryujinx.Graphics.Gpu/Shader/ShaderInfoBuilder.cs @@ -372,8 +372,8 @@ namespace Ryujinx.Graphics.Gpu.Shader { int totalSets = _resourceDescriptors.Length; - var descriptors = new ResourceDescriptorCollection[totalSets]; - var usages = new ResourceUsageCollection[totalSets]; + ResourceDescriptorCollection[] descriptors = new ResourceDescriptorCollection[totalSets]; + ResourceUsageCollection[] usages = new ResourceUsageCollection[totalSets]; for (int index = 0; index < totalSets; index++) { diff --git a/src/Ryujinx.Graphics.Gpu/Shader/ShaderSpecializationList.cs b/src/Ryujinx.Graphics.Gpu/Shader/ShaderSpecializationList.cs index 3c2f0b9be..25ed6e7ef 100644 --- a/src/Ryujinx.Graphics.Gpu/Shader/ShaderSpecializationList.cs +++ b/src/Ryujinx.Graphics.Gpu/Shader/ShaderSpecializationList.cs @@ -33,7 +33,7 @@ namespace Ryujinx.Graphics.Gpu.Shader ref GpuChannelGraphicsState graphicsState, out CachedShaderProgram program) { - foreach (var entry in _entries) + foreach (CachedShaderProgram entry in _entries) { bool vertexAsCompute = entry.VertexAsCompute != null; bool usesDrawParameters = entry.Shaders[1]?.Info.UsesDrawParameters ?? false; @@ -65,7 +65,7 @@ namespace Ryujinx.Graphics.Gpu.Shader /// True if a compatible program is found, false otherwise public bool TryFindForCompute(GpuChannel channel, GpuChannelPoolState poolState, GpuChannelComputeState computeState, out CachedShaderProgram program) { - foreach (var entry in _entries) + foreach (CachedShaderProgram entry in _entries) { if (entry.SpecializationState.MatchesCompute(channel, ref poolState, computeState, true)) { diff --git a/src/Ryujinx.Graphics.Gpu/Shader/ShaderSpecializationState.cs b/src/Ryujinx.Graphics.Gpu/Shader/ShaderSpecializationState.cs index 1230c0580..4bb4392e1 100644 --- a/src/Ryujinx.Graphics.Gpu/Shader/ShaderSpecializationState.cs +++ b/src/Ryujinx.Graphics.Gpu/Shader/ShaderSpecializationState.cs @@ -6,10 +6,12 @@ using Ryujinx.Graphics.Gpu.Shader.DiskCache; using Ryujinx.Graphics.Shader; using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Linq; using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; +using TextureDescriptor = Ryujinx.Graphics.Shader.TextureDescriptor; namespace Ryujinx.Graphics.Gpu.Shader { @@ -214,23 +216,23 @@ namespace Ryujinx.Graphics.Gpu.Shader CachedShaderStage stage = stages[i]; if (stage?.Info != null) { - var textures = stage.Info.Textures; - var images = stage.Info.Images; + ReadOnlyCollection textures = stage.Info.Textures; + ReadOnlyCollection images = stage.Info.Images; - var texBindings = new Box[textures.Count]; - var imageBindings = new Box[images.Count]; + Box[] texBindings = new Box[textures.Count]; + Box[] imageBindings = new Box[images.Count]; int stageIndex = Math.Max(i - 1, 0); // Don't count VertexA for looking up spec state. No-Op for compute. for (int j = 0; j < textures.Count; j++) { - var texture = textures[j]; + TextureDescriptor texture = textures[j]; texBindings[j] = GetTextureSpecState(stageIndex, texture.HandleIndex, texture.CbufSlot); } for (int j = 0; j < images.Count; j++) { - var image = images[j]; + TextureDescriptor image = images[j]; imageBindings[j] = GetTextureSpecState(stageIndex, image.HandleIndex, image.CbufSlot); } @@ -753,7 +755,7 @@ namespace Ryujinx.Graphics.Gpu.Shader ReadOnlySpan cachedTextureBuffer = Span.Empty; ReadOnlySpan cachedSamplerBuffer = Span.Empty; - foreach (var kv in _allTextures) + foreach (KeyValuePair> kv in _allTextures) { TextureKey textureKey = kv.Key; @@ -1009,10 +1011,10 @@ namespace Ryujinx.Graphics.Gpu.Shader ushort count = (ushort)_textureSpecialization.Count; dataWriter.Write(ref count); - foreach (var kv in _textureSpecialization) + foreach (KeyValuePair> kv in _textureSpecialization) { - var textureKey = kv.Key; - var textureState = kv.Value; + TextureKey textureKey = kv.Key; + Box textureState = kv.Value; dataWriter.WriteWithMagicAndSize(ref textureKey, TexkMagic); dataWriter.WriteWithMagicAndSize(ref textureState.Value, TexsMagic); @@ -1023,10 +1025,10 @@ namespace Ryujinx.Graphics.Gpu.Shader count = (ushort)_textureArrayFromBufferSpecialization.Count; dataWriter.Write(ref count); - foreach (var kv in _textureArrayFromBufferSpecialization) + foreach (KeyValuePair kv in _textureArrayFromBufferSpecialization) { - var textureKey = kv.Key; - var length = kv.Value; + TextureKey textureKey = kv.Key; + int length = kv.Value; dataWriter.WriteWithMagicAndSize(ref textureKey, TexkMagic); dataWriter.Write(ref length); @@ -1038,10 +1040,10 @@ namespace Ryujinx.Graphics.Gpu.Shader count = (ushort)_textureArrayFromPoolSpecialization.Count; dataWriter.Write(ref count); - foreach (var kv in _textureArrayFromPoolSpecialization) + foreach (KeyValuePair kv in _textureArrayFromPoolSpecialization) { - var textureKey = kv.Key; - var length = kv.Value; + bool textureKey = kv.Key; + int length = kv.Value; dataWriter.WriteWithMagicAndSize(ref textureKey, TexkMagic); dataWriter.Write(ref length); diff --git a/src/Ryujinx.Graphics.Gpu/Synchronization/SynchronizationManager.cs b/src/Ryujinx.Graphics.Gpu/Synchronization/SynchronizationManager.cs index 1042a4db8..b68a64a47 100644 --- a/src/Ryujinx.Graphics.Gpu/Synchronization/SynchronizationManager.cs +++ b/src/Ryujinx.Graphics.Gpu/Synchronization/SynchronizationManager.cs @@ -87,7 +87,7 @@ namespace Ryujinx.Graphics.Gpu.Synchronization } using ManualResetEvent waitEvent = new(false); - var info = _syncpoints[id].RegisterCallback(threshold, (x) => waitEvent.Set()); + SyncpointWaiterHandle info = _syncpoints[id].RegisterCallback(threshold, (x) => waitEvent.Set()); if (info == null) { diff --git a/src/Ryujinx.Graphics.Gpu/Window.cs b/src/Ryujinx.Graphics.Gpu/Window.cs index 59cd4c8a6..5c3463f2a 100644 --- a/src/Ryujinx.Graphics.Gpu/Window.cs +++ b/src/Ryujinx.Graphics.Gpu/Window.cs @@ -1,5 +1,6 @@ using Ryujinx.Graphics.GAL; using Ryujinx.Graphics.Gpu.Image; +using Ryujinx.Graphics.Gpu.Memory; using Ryujinx.Graphics.Texture; using Ryujinx.Memory.Range; using System; @@ -137,7 +138,7 @@ namespace Ryujinx.Graphics.Gpu Action releaseCallback, object userObj) { - if (!_context.PhysicalMemoryRegistry.TryGetValue(pid, out var physicalMemory)) + if (!_context.PhysicalMemoryRegistry.TryGetValue(pid, out PhysicalMemory physicalMemory)) { return false; } diff --git a/src/Ryujinx.Graphics.Host1x/Devices.cs b/src/Ryujinx.Graphics.Host1x/Devices.cs index 9de2b81a9..984a5abd6 100644 --- a/src/Ryujinx.Graphics.Host1x/Devices.cs +++ b/src/Ryujinx.Graphics.Host1x/Devices.cs @@ -20,7 +20,7 @@ namespace Ryujinx.Graphics.Host1x public void Dispose() { - foreach (var device in _devices.Values) + foreach (IDeviceState device in _devices.Values) { if (device is ThiDevice thi) { diff --git a/src/Ryujinx.Graphics.Host1x/Host1xDevice.cs b/src/Ryujinx.Graphics.Host1x/Host1xDevice.cs index 2db74ce5e..62fcef348 100644 --- a/src/Ryujinx.Graphics.Host1x/Host1xDevice.cs +++ b/src/Ryujinx.Graphics.Host1x/Host1xDevice.cs @@ -46,7 +46,7 @@ namespace Ryujinx.Graphics.Host1x public void RegisterDevice(ClassId classId, IDeviceState device) { - var thi = new ThiDevice(classId, device ?? throw new ArgumentNullException(nameof(device)), _syncptIncrMgr); + ThiDevice thi = new ThiDevice(classId, device ?? throw new ArgumentNullException(nameof(device)), _syncptIncrMgr); _devices.RegisterDevice(classId, thi); }