mirror of
https://github.com/Ryubing/Ryujinx.git
synced 2025-03-15 04:14:47 +00:00
misc: chore: Use explicit types in GPU, Device, and Host1x projects
This commit is contained in:
parent
5099548856
commit
1ae349efb1
55 changed files with 350 additions and 339 deletions
|
@ -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<TState>(field.Name);
|
||||
var nextFieldOffset = fieldIndex + 1 == fields.Length ? Unsafe.SizeOf<TState>() : (int)Marshal.OffsetOf<TState>(fields[fieldIndex + 1].Name);
|
||||
int currentFieldOffset = (int)Marshal.OffsetOf<TState>(field.Name);
|
||||
int nextFieldOffset = fieldIndex + 1 == fields.Length ? Unsafe.SizeOf<TState>() : (int)Marshal.OffsetOf<TState>(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<int> 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;
|
||||
|
||||
|
|
|
@ -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
|
|||
/// <param name="argument">Method call argument</param>
|
||||
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<ComputeQmd>((ulong)qmdAddress << 8);
|
||||
ComputeQmd qmd = _channel.MemoryManager.Read<ComputeQmd>((ulong)qmdAddress << 8);
|
||||
|
||||
ulong shaderGpuVa = ((ulong)_state.State.SetProgramRegionAAddressUpper << 32) | _state.State.SetProgramRegionB;
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -190,7 +190,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma
|
|||
/// <param name="argument">The LaunchDma call argument</param>
|
||||
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<uint, DmaTexture>(ref _state.State.SetDstBlockSize);
|
||||
var src = Unsafe.As<uint, DmaTexture>(ref _state.State.SetSrcBlockSize);
|
||||
DmaTexture dst = Unsafe.As<uint, DmaTexture>(ref _state.State.SetDstBlockSize);
|
||||
DmaTexture src = Unsafe.As<uint, DmaTexture>(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,
|
||||
|
|
|
@ -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<int> data = commandBuffer.Slice(offset, consumeCount);
|
||||
|
||||
if (_state.SubChannel == 0)
|
||||
{
|
||||
|
|
|
@ -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
|
|||
/// </summary>
|
||||
private void FinishTransfer()
|
||||
{
|
||||
var memoryManager = _channel.MemoryManager;
|
||||
MemoryManager memoryManager = _channel.MemoryManager;
|
||||
|
||||
var data = MemoryMarshal.Cast<int, byte>(_buffer)[.._size];
|
||||
Span<byte> data = MemoryMarshal.Cast<int, byte>(_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<byte>.RentCopy(data);
|
||||
MemoryOwner<byte> dataCopy = MemoryOwner<byte>.RentCopy(data);
|
||||
target.SetData(dataCopy, 0, 0, new GAL.Rectangle<int>(_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,
|
||||
|
|
|
@ -285,12 +285,12 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
|
|||
/// <param name="arg0">First argument of the call</param>
|
||||
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
|
|||
/// <param name="arg0">First argument of the call</param>
|
||||
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
|
|||
/// <param name="arg0">First argument of the call</param>
|
||||
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
|
|||
/// <param name="arg0">First argument of the call</param>
|
||||
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
|
|||
/// <returns>The call argument, or a 0 value with null address if the FIFO is empty</returns>
|
||||
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.");
|
||||
|
||||
|
|
|
@ -90,13 +90,13 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
|
|||
/// <returns>True if there is a implementation available and supported, false otherwise</returns>
|
||||
public static bool TryGetMacroHLEFunction(ReadOnlySpan<int> code, Capabilities caps, out MacroHLEFunctionName name)
|
||||
{
|
||||
var mc = MemoryMarshal.Cast<int, byte>(code);
|
||||
ReadOnlySpan<byte> mc = MemoryMarshal.Cast<int, byte>(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))
|
||||
|
|
|
@ -369,7 +369,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
|
|||
/// <returns>The call argument, or 0 if the FIFO is empty</returns>
|
||||
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.");
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
|
|||
/// <returns>The call argument, or 0 if the FIFO is empty</returns>
|
||||
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.");
|
||||
|
||||
|
|
|
@ -221,7 +221,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
|
|||
sb.AppendLine($"private static Dictionary<Hash128, AdvancedBlendEntry> _entries = new()");
|
||||
sb.AppendLine("{");
|
||||
|
||||
foreach (var entry in Table)
|
||||
foreach (AdvancedBlendUcode entry in Table)
|
||||
{
|
||||
Hash128 hash = Hash128.ComputeHash(MemoryMarshal.Cast<uint, byte>(entry.Code));
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
|||
/// <param name="size">Size of the buffer in bytes</param>
|
||||
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(
|
||||
|
|
|
@ -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<byte> data = MemoryMarshal.Cast<int, byte>(_ubData.AsSpan(0, (int)(_ubByteCount / 4)));
|
||||
|
||||
|
@ -131,7 +132,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
|
|||
/// <param name="argument">New uniform buffer data word</param>
|
||||
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
|
|||
/// <param name="data">Data to be written to the uniform buffer</param>
|
||||
public void Update(ReadOnlySpan<int> data)
|
||||
{
|
||||
var uniformBuffer = _state.State.UniformBufferState;
|
||||
UniformBufferState uniformBuffer = _state.State.UniformBufferState;
|
||||
|
||||
ulong address = uniformBuffer.Address.Pack() + (uint)uniformBuffer.Offset;
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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))
|
||||
{
|
||||
|
|
|
@ -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<string, int>();
|
||||
Dictionary<string, int> fieldToDelegate = new Dictionary<string, int>();
|
||||
|
||||
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<TState>(field.Name);
|
||||
var nextFieldOffset = fieldIndex + 1 == fields.Length ? Unsafe.SizeOf<TState>() : (int)Marshal.OffsetOf<TState>(fields[fieldIndex + 1].Name);
|
||||
int currentFieldOffset = (int)Marshal.OffsetOf<TState>(field.Name);
|
||||
int nextFieldOffset = fieldIndex + 1 == fields.Length ? Unsafe.SizeOf<TState>() : (int)Marshal.OffsetOf<TState>(fields[fieldIndex + 1].Name);
|
||||
|
||||
int sizeOfField = nextFieldOffset - currentFieldOffset;
|
||||
|
||||
|
|
|
@ -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
|
|||
/// <param name="singleUse">If this is not -1, it indicates that only the given indexed target will be used.</param>
|
||||
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
|
|||
/// </summary>
|
||||
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<float>(0, 0, (scissor.X + scissor.Width) * rScale, (scissor.Y + scissor.Height) * rScale);
|
||||
Rectangle<float> scissorRect = new Rectangle<float>(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
|
|||
/// </summary>
|
||||
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
|
|||
/// </summary>
|
||||
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
|
|||
/// </summary>
|
||||
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
|
|||
/// </summary>
|
||||
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
|
|||
/// </summary>
|
||||
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
|
|||
/// </summary>
|
||||
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
|
|||
/// </summary>
|
||||
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
|
|||
/// </summary>
|
||||
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
|
|||
/// <returns>Current depth mode</returns>
|
||||
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;
|
||||
|
||||
|
|
|
@ -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<T, Vector128<uint>>(ref lhs);
|
||||
ref var rhsVec = ref Unsafe.As<T, Vector128<uint>>(ref rhs);
|
||||
ref Vector128<uint> lhsVec = ref Unsafe.As<T, Vector128<uint>>(ref lhs);
|
||||
ref Vector128<uint> rhsVec = ref Unsafe.As<T, Vector128<uint>>(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
|
|||
/// <param name="masks">Blend enable</param>
|
||||
public void UpdateBlendEnable(ref Array8<Boolean32> enable)
|
||||
{
|
||||
var shadow = ShadowMode;
|
||||
ref var state = ref _state.State.BlendEnable;
|
||||
SetMmeShadowRamControlMode shadow = ShadowMode;
|
||||
ref Array8<Boolean32> state = ref _state.State.BlendEnable;
|
||||
|
||||
if (shadow.IsReplay())
|
||||
{
|
||||
|
@ -294,8 +294,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
|
|||
/// <param name="masks">Color masks</param>
|
||||
public void UpdateColorMasks(ref Array8<RtColorMask> masks)
|
||||
{
|
||||
var shadow = ShadowMode;
|
||||
ref var state = ref _state.State.RtColorMask;
|
||||
SetMmeShadowRamControlMode shadow = ShadowMode;
|
||||
ref Array8<RtColorMask> state = ref _state.State.RtColorMask;
|
||||
|
||||
if (shadow.IsReplay())
|
||||
{
|
||||
|
@ -323,12 +323,12 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
|
|||
/// <param name="type">Type of the binding</param>
|
||||
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
|
|||
/// <param name="addrLow">Low part of the address</param>
|
||||
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
|
|||
/// <param name="offset">Offset to update with</param>
|
||||
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
|
|||
/// <param name="ubState">Uniform buffer state</param>
|
||||
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())
|
||||
{
|
||||
|
|
|
@ -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
|
|||
/// <param name="bpp">Bytes per pixel</param>
|
||||
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
|
|||
/// <param name="argument">Method call argument</param>
|
||||
private void PixelsFromMemorySrcY0Int(int argument)
|
||||
{
|
||||
var memoryManager = _channel.MemoryManager;
|
||||
MemoryManager memoryManager = _channel.MemoryManager;
|
||||
|
||||
var dstCopyTexture = Unsafe.As<uint, TwodTexture>(ref _state.State.SetDstFormat);
|
||||
var srcCopyTexture = Unsafe.As<uint, TwodTexture>(ref _state.State.SetSrcFormat);
|
||||
TwodTexture dstCopyTexture = Unsafe.As<uint, TwodTexture>(ref _state.State.SetDstFormat);
|
||||
TwodTexture srcCopyTexture = Unsafe.As<uint, TwodTexture>(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,
|
||||
|
|
|
@ -57,7 +57,7 @@ namespace Ryujinx.Graphics.Gpu
|
|||
/// <param name="memoryManager">The new memory manager to be bound</param>
|
||||
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;
|
||||
|
|
|
@ -167,7 +167,7 @@ namespace Ryujinx.Graphics.Gpu
|
|||
/// <exception cref="ArgumentException">Thrown when <paramref name="pid"/> is invalid</exception>
|
||||
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
|
|||
/// <exception cref="ArgumentException">Thrown when <paramref name="pid"/> is invalid</exception>
|
||||
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
|
|||
/// <exception cref="ArgumentException">Thrown if <paramref name="pid"/> was already registered</exception>
|
||||
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
|
|||
/// <param name="pid">ID of the process</param>
|
||||
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
|
|||
/// </summary>
|
||||
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();
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||
/// <param name="cpuMemorySize">The amount of physical CPU Memory Avaiable on the device.</param>
|
||||
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
|
|||
/// <returns>The texture if found, null otherwise</returns>
|
||||
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
|
|||
/// <param name="descriptor">Last used texture descriptor</param>
|
||||
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<ShortTextureCacheEntry> toRemove = _shortCache;
|
||||
|
||||
foreach (var entry in toRemove)
|
||||
foreach (ShortTextureCacheEntry entry in toRemove)
|
||||
{
|
||||
entry.Texture.DecrementReferenceCount();
|
||||
|
||||
|
|
|
@ -704,7 +704,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||
/// <returns>True if the format is valid, false otherwise</returns>
|
||||
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;
|
||||
|
|
|
@ -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<byte> 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)
|
||||
{
|
||||
|
|
|
@ -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<TextureIncompatibleOverlap>();
|
||||
List<TextureIncompatibleOverlap> incompatibleOverlaps = new List<TextureIncompatibleOverlap>();
|
||||
|
||||
for (int index = 0; index < overlapsCount; index++)
|
||||
{
|
||||
|
|
|
@ -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
|
|||
/// <returns>True if flushes should be tracked, false otherwise</returns>
|
||||
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<RegionHandle>();
|
||||
List<RegionHandle> result = new List<RegionHandle>();
|
||||
|
||||
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
|
|||
/// <param name="relativeOffset">The offset of the old handles in relation to the new ones</param>
|
||||
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<TextureGroupHandle>();
|
||||
List<TextureGroupHandle> handlesList = new List<TextureGroupHandle>();
|
||||
|
||||
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)));
|
||||
|
|
|
@ -118,7 +118,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||
/// <returns>Texture with the requested format, or null if not found</returns>
|
||||
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
|
|||
/// </summary>
|
||||
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
|
|||
/// <param name="deferred">If true, queue the dereference to happen on the render thread, otherwise dereference immediately</param>
|
||||
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)
|
||||
{
|
||||
|
|
|
@ -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) =>
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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
|
|||
/// <param name="toDelete">List used to track entries to delete</param>
|
||||
private static void Prune(Dictionary<ulong, BufferCacheEntry> dictionary, ref List<ulong> toDelete)
|
||||
{
|
||||
foreach (var entry in dictionary)
|
||||
foreach (KeyValuePair<ulong, BufferCacheEntry> entry in dictionary)
|
||||
{
|
||||
if (entry.Value.UnmappedSequence != entry.Value.Buffer.UnmappedSequence)
|
||||
{
|
||||
|
|
|
@ -478,7 +478,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||
/// </summary>
|
||||
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<ITextureArray> 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<IImageArray> 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
|
|||
/// <param name="indexed">True if the index buffer is in use</param>
|
||||
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];
|
||||
|
||||
|
|
|
@ -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<BufferModifiedRange>.Get();
|
||||
ref BufferModifiedRange[] overlaps = ref ThreadStaticArray<BufferModifiedRange>.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<BufferModifiedRange>.Get();
|
||||
ref BufferModifiedRange[] overlaps = ref ThreadStaticArray<BufferModifiedRange>.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<BufferModifiedRange>.Get();
|
||||
ref BufferModifiedRange[] overlaps = ref ThreadStaticArray<BufferModifiedRange>.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<BufferModifiedRange>.Get();
|
||||
ref BufferModifiedRange[] overlaps = ref ThreadStaticArray<BufferModifiedRange>.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<BufferModifiedRange>.Get();
|
||||
ref BufferModifiedRange[] overlaps = ref ThreadStaticArray<BufferModifiedRange>.Get();
|
||||
|
||||
// Range list must be consistent for this operation
|
||||
lock (_lock)
|
||||
|
|
|
@ -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) });
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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
|
|||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
foreach (var regionHandle in _cpuRegionHandles)
|
||||
foreach (RegionHandle regionHandle in _cpuRegionHandles)
|
||||
{
|
||||
regionHandle.Dispose();
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||
/// <param name="action">Action to call on read or write</param>
|
||||
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
|
|||
/// <param name="action">Action to call on read or write</param>
|
||||
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
|
|||
/// </summary>
|
||||
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
|
|||
/// </summary>
|
||||
public void ForceDirty()
|
||||
{
|
||||
foreach (var regionHandle in _cpuRegionHandles)
|
||||
foreach (RegionHandle regionHandle in _cpuRegionHandles)
|
||||
{
|
||||
regionHandle.ForceDirty();
|
||||
}
|
||||
|
|
|
@ -458,7 +458,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||
|
||||
int pages = (int)((endVaRounded - va) / PageSize);
|
||||
|
||||
var regions = new List<MemoryRange>();
|
||||
List<MemoryRange> regions = new List<MemoryRange>();
|
||||
|
||||
for (int page = 0; page < pages - 1; page++)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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<HostMemoryRange> 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
|
|||
/// <returns>The memory tracking handle</returns>
|
||||
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);
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||
/// <param name="renderer">Renderer that the support buffer will be used with</param>
|
||||
public SupportBufferUpdater(IRenderer renderer) : base(renderer)
|
||||
{
|
||||
var defaultScale = new Vector4<float> { X = 1f, Y = 0f, Z = 0f, W = 0f };
|
||||
Vector4<float> defaultScale = new Vector4<float> { X = 1f, Y = 0f, Z = 0f, W = 0f };
|
||||
_data.RenderScale.AsSpan().Fill(defaultScale);
|
||||
DirtyRenderScale(0, SupportBuffer.RenderScaleMaxCount);
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
/// <param name="program">Program to be added</param>
|
||||
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
|
|||
/// <returns>Programs added to the table</returns>
|
||||
public IEnumerable<CachedShaderProgram> GetPrograms()
|
||||
{
|
||||
foreach (var program in _shaderPrograms)
|
||||
foreach (CachedShaderProgram program in _shaderPrograms)
|
||||
{
|
||||
yield return program;
|
||||
}
|
||||
|
|
|
@ -180,8 +180,8 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
|
|||
/// </summary>
|
||||
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
|
|||
/// <returns>Index of the shader on the cache</returns>
|
||||
public int AddShader(ReadOnlySpan<byte> data, ReadOnlySpan<byte> 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<TocMemoryEntry> 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
|
|||
/// <param name="index">Index of the data on the cache</param>
|
||||
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<TocMemoryEntry> list))
|
||||
{
|
||||
_toc.Add(hash, list = new List<TocMemoryEntry>());
|
||||
}
|
||||
|
|
|
@ -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
|
|||
/// <returns>A collection of disk cache output streams</returns>
|
||||
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
|
|||
/// <param name="context">GPU context</param>
|
||||
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
|
|||
/// <param name="context">GPU context</param>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<int, (CachedShaderProgram, byte[])> kv in _programList)
|
||||
{
|
||||
if (!Active)
|
||||
{
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
|||
/// <returns>The generated translator context</returns>
|
||||
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
|
|||
/// <returns>The generated translator context</returns>
|
||||
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
|
|||
/// <returns>Compiled graphics shader code</returns>
|
||||
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)
|
||||
|
|
|
@ -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
|
|||
/// <returns>Programs added to the table</returns>
|
||||
public IEnumerable<CachedShaderProgram> 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;
|
||||
}
|
||||
|
|
|
@ -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++)
|
||||
{
|
||||
|
|
|
@ -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
|
|||
/// <returns>True if a compatible program is found, false otherwise</returns>
|
||||
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))
|
||||
{
|
||||
|
|
|
@ -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<TextureDescriptor> textures = stage.Info.Textures;
|
||||
ReadOnlyCollection<TextureDescriptor> images = stage.Info.Images;
|
||||
|
||||
var texBindings = new Box<TextureSpecializationState>[textures.Count];
|
||||
var imageBindings = new Box<TextureSpecializationState>[images.Count];
|
||||
Box<TextureSpecializationState>[] texBindings = new Box<TextureSpecializationState>[textures.Count];
|
||||
Box<TextureSpecializationState>[] imageBindings = new Box<TextureSpecializationState>[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<int> cachedTextureBuffer = Span<int>.Empty;
|
||||
ReadOnlySpan<int> cachedSamplerBuffer = Span<int>.Empty;
|
||||
|
||||
foreach (var kv in _allTextures)
|
||||
foreach (KeyValuePair<TextureKey, Box<TextureSpecializationState>> 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<TextureKey, Box<TextureSpecializationState>> kv in _textureSpecialization)
|
||||
{
|
||||
var textureKey = kv.Key;
|
||||
var textureState = kv.Value;
|
||||
TextureKey textureKey = kv.Key;
|
||||
Box<TextureSpecializationState> 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<TextureKey, int> 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<bool, int> 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);
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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<object> releaseCallback,
|
||||
object userObj)
|
||||
{
|
||||
if (!_context.PhysicalMemoryRegistry.TryGetValue(pid, out var physicalMemory))
|
||||
if (!_context.PhysicalMemoryRegistry.TryGetValue(pid, out PhysicalMemory physicalMemory))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue