Initial support for separate GPU address spaces (#2394)
* Make GPU memory manager a member of GPU channel * Move physical memory instance to the memory manager, and the caches to the physical memory * PR feedback
This commit is contained in:
parent
8cc872fb60
commit
fbb4019ed5
44 changed files with 780 additions and 481 deletions
|
@ -16,11 +16,13 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
|||
/// <param name="argument">Method call argument</param>
|
||||
public void Dispatch(GpuState state, int argument)
|
||||
{
|
||||
FlushUboDirty();
|
||||
var memoryManager = state.Channel.MemoryManager;
|
||||
|
||||
FlushUboDirty(memoryManager);
|
||||
|
||||
uint qmdAddress = (uint)state.Get<int>(MethodOffset.DispatchParamsAddress);
|
||||
|
||||
var qmd = _context.MemoryManager.Read<ComputeQmd>((ulong)qmdAddress << 8);
|
||||
var qmd = state.Channel.MemoryManager.Read<ComputeQmd>((ulong)qmdAddress << 8);
|
||||
|
||||
GpuVa shaderBaseAddress = state.Get<GpuVa>(MethodOffset.ShaderBaseAddress);
|
||||
|
||||
|
@ -43,7 +45,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
|||
state.Channel.BufferManager.SetComputeUniformBuffer(index, gpuVa, size);
|
||||
}
|
||||
|
||||
ShaderBundle cs = ShaderCache.GetComputeShader(
|
||||
ShaderBundle cs = memoryManager.Physical.ShaderCache.GetComputeShader(
|
||||
state,
|
||||
shaderGpuVa,
|
||||
qmd.CtaThreadDimension0,
|
||||
|
@ -82,7 +84,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
|||
|
||||
cbDescAddress += (ulong)cbDescOffset;
|
||||
|
||||
SbDescriptor cbDescriptor = _context.PhysicalMemory.Read<SbDescriptor>(cbDescAddress);
|
||||
SbDescriptor cbDescriptor = state.Channel.MemoryManager.Physical.Read<SbDescriptor>(cbDescAddress);
|
||||
|
||||
state.Channel.BufferManager.SetComputeUniformBuffer(cb.Slot, cbDescriptor.PackAddress(), (uint)cbDescriptor.Size);
|
||||
}
|
||||
|
@ -97,7 +99,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
|||
|
||||
sbDescAddress += (ulong)sbDescOffset;
|
||||
|
||||
SbDescriptor sbDescriptor = _context.PhysicalMemory.Read<SbDescriptor>(sbDescAddress);
|
||||
SbDescriptor sbDescriptor = state.Channel.MemoryManager.Physical.Read<SbDescriptor>(sbDescAddress);
|
||||
|
||||
state.Channel.BufferManager.SetComputeStorageBuffer(sb.Slot, sbDescriptor.PackAddress(), (uint)sbDescriptor.Size, sb.Flags);
|
||||
}
|
||||
|
|
|
@ -79,13 +79,13 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
|
|||
// TODO: Acquire operations (Wait), interrupts for invalid combinations.
|
||||
if (operation == SemaphoredOperation.Release)
|
||||
{
|
||||
_context.MemoryManager.Write(address, value);
|
||||
_parent.MemoryManager.Write(address, value);
|
||||
}
|
||||
else if (operation == SemaphoredOperation.Reduction)
|
||||
{
|
||||
bool signed = _state.State.SemaphoredFormat == SemaphoredFormat.Signed;
|
||||
|
||||
int mem = _context.MemoryManager.Read<int>(address);
|
||||
int mem = _parent.MemoryManager.Read<int>(address);
|
||||
|
||||
switch (_state.State.SemaphoredReduction)
|
||||
{
|
||||
|
@ -115,7 +115,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
|
|||
break;
|
||||
}
|
||||
|
||||
_context.MemoryManager.Write(address, value);
|
||||
_parent.MemoryManager.Write(address, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using Ryujinx.Graphics.Gpu.Memory;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
@ -53,11 +54,11 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
|
|||
/// <summary>
|
||||
/// Fetch the command buffer.
|
||||
/// </summary>
|
||||
public void Fetch(GpuContext context)
|
||||
public void Fetch(MemoryManager memoryManager)
|
||||
{
|
||||
if (Words == null)
|
||||
{
|
||||
Words = MemoryMarshal.Cast<byte, int>(context.MemoryManager.GetSpan(EntryAddress, (int)EntryCount * 4, true)).ToArray();
|
||||
Words = MemoryMarshal.Cast<byte, int>(memoryManager.GetSpan(EntryAddress, (int)EntryCount * 4, true)).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -155,7 +156,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
|
|||
|
||||
if (beforeBarrier && commandBuffer.Type == CommandBufferType.Prefetch)
|
||||
{
|
||||
commandBuffer.Fetch(_context);
|
||||
commandBuffer.Fetch(processor.MemoryManager);
|
||||
}
|
||||
|
||||
if (commandBuffer.Type == CommandBufferType.NoPrefetch)
|
||||
|
@ -182,13 +183,13 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
|
|||
public void DispatchCalls()
|
||||
{
|
||||
// Use this opportunity to also dispose any pending channels that were closed.
|
||||
_context.DisposePendingChannels();
|
||||
_context.RunDeferredActions();
|
||||
|
||||
// Process command buffers.
|
||||
while (_ibEnable && !_interrupt && _commandBufferQueue.TryDequeue(out CommandBuffer entry))
|
||||
{
|
||||
_currentCommandBuffer = entry;
|
||||
_currentCommandBuffer.Fetch(_context);
|
||||
_currentCommandBuffer.Fetch(entry.Processor.MemoryManager);
|
||||
|
||||
// If we are changing the current channel,
|
||||
// we need to force all the host state to be updated.
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using Ryujinx.Graphics.Gpu.State;
|
||||
using Ryujinx.Graphics.Gpu.Memory;
|
||||
using Ryujinx.Graphics.Gpu.State;
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
|
@ -13,6 +14,9 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
|
|||
private const int MacroIndexMask = MacrosCount - 1;
|
||||
|
||||
private readonly GpuContext _context;
|
||||
private readonly GpuChannel _channel;
|
||||
|
||||
public MemoryManager MemoryManager => _channel.MemoryManager;
|
||||
|
||||
/// <summary>
|
||||
/// Internal GPFIFO state.
|
||||
|
@ -39,6 +43,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
|
|||
public GPFifoProcessor(GpuContext context, GpuChannel channel)
|
||||
{
|
||||
_context = context;
|
||||
_channel = channel;
|
||||
|
||||
_fifoClass = new GPFifoClass(context, this);
|
||||
_subChannels = new GpuState[8];
|
||||
|
|
|
@ -40,10 +40,10 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
|||
_buffer = new int[count];
|
||||
}
|
||||
|
||||
ulong dstBaseAddress = _context.MemoryManager.Translate(_params.DstAddress.Pack());
|
||||
ulong dstBaseAddress = state.Channel.MemoryManager.Translate(_params.DstAddress.Pack());
|
||||
|
||||
// Trigger read tracking, to flush any managed resources in the destination region.
|
||||
_context.PhysicalMemory.GetSpan(dstBaseAddress, _size, true);
|
||||
state.Channel.MemoryManager.Physical.GetSpan(dstBaseAddress, _size, true);
|
||||
|
||||
_finished = false;
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
|||
|
||||
if (_offset * 4 >= _size)
|
||||
{
|
||||
FinishTransfer();
|
||||
FinishTransfer(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -69,15 +69,16 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
|||
/// <summary>
|
||||
/// Performs actual copy of the inline data after the transfer is finished.
|
||||
/// </summary>
|
||||
private void FinishTransfer()
|
||||
/// <param name="state">Current GPU state</param>
|
||||
private void FinishTransfer(GpuState state)
|
||||
{
|
||||
Span<byte> data = MemoryMarshal.Cast<int, byte>(_buffer).Slice(0, _size);
|
||||
|
||||
if (_isLinear && _params.LineCount == 1)
|
||||
{
|
||||
ulong address = _context.MemoryManager.Translate(_params.DstAddress.Pack());
|
||||
ulong address = state.Channel.MemoryManager.Translate(_params.DstAddress.Pack());
|
||||
|
||||
_context.PhysicalMemory.Write(address, data);
|
||||
state.Channel.MemoryManager.Physical.Write(address, data);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -91,7 +92,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
|||
|
||||
int srcOffset = 0;
|
||||
|
||||
ulong dstBaseAddress = _context.MemoryManager.Translate(_params.DstAddress.Pack());
|
||||
ulong dstBaseAddress = state.Channel.MemoryManager.Translate(_params.DstAddress.Pack());
|
||||
|
||||
for (int y = _params.DstY; y < _params.DstY + _params.LineCount; y++)
|
||||
{
|
||||
|
@ -109,7 +110,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
|||
|
||||
Span<byte> pixel = data.Slice(srcOffset, 16);
|
||||
|
||||
_context.PhysicalMemory.Write(dstAddress, pixel);
|
||||
state.Channel.MemoryManager.Physical.Write(dstAddress, pixel);
|
||||
}
|
||||
|
||||
for (; x < x2; x++, srcOffset++)
|
||||
|
@ -120,7 +121,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
|||
|
||||
Span<byte> pixel = data.Slice(srcOffset, 1);
|
||||
|
||||
_context.PhysicalMemory.Write(dstAddress, pixel);
|
||||
state.Channel.MemoryManager.Physical.Write(dstAddress, pixel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Graphics.GAL;
|
||||
using Ryujinx.Graphics.Gpu.Memory;
|
||||
using Ryujinx.Graphics.Gpu.State;
|
||||
|
||||
namespace Ryujinx.Graphics.Gpu.Engine
|
||||
|
@ -23,11 +24,11 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
|||
case Condition.Never:
|
||||
return ConditionalRenderEnabled.False;
|
||||
case Condition.ResultNonZero:
|
||||
return CounterNonZero(condState.Address.Pack());
|
||||
return CounterNonZero(state, condState.Address.Pack());
|
||||
case Condition.Equal:
|
||||
return CounterCompare(condState.Address.Pack(), true);
|
||||
return CounterCompare(state, condState.Address.Pack(), true);
|
||||
case Condition.NotEqual:
|
||||
return CounterCompare(condState.Address.Pack(), false);
|
||||
return CounterCompare(state, condState.Address.Pack(), false);
|
||||
}
|
||||
|
||||
Logger.Warning?.Print(LogClass.Gpu, $"Invalid conditional render condition \"{condState.Condition}\".");
|
||||
|
@ -38,11 +39,12 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
|||
/// <summary>
|
||||
/// Checks if the counter value at a given GPU memory address is non-zero.
|
||||
/// </summary>
|
||||
/// <param name="state">GPU state</param>
|
||||
/// <param name="gpuVa">GPU virtual address of the counter value</param>
|
||||
/// <returns>True if the value is not zero, false otherwise. Returns host if handling with host conditional rendering</returns>
|
||||
private ConditionalRenderEnabled CounterNonZero(ulong gpuVa)
|
||||
private ConditionalRenderEnabled CounterNonZero(GpuState state, ulong gpuVa)
|
||||
{
|
||||
ICounterEvent evt = _counterCache.FindEvent(gpuVa);
|
||||
ICounterEvent evt = state.Channel.MemoryManager.CounterCache.FindEvent(gpuVa);
|
||||
|
||||
if (evt == null)
|
||||
{
|
||||
|
@ -56,30 +58,31 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
|||
else
|
||||
{
|
||||
evt.Flush();
|
||||
return (_context.MemoryManager.Read<ulong>(gpuVa) != 0) ? ConditionalRenderEnabled.True : ConditionalRenderEnabled.False;
|
||||
return (state.Channel.MemoryManager.Read<ulong>(gpuVa) != 0) ? ConditionalRenderEnabled.True : ConditionalRenderEnabled.False;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the counter at a given GPU memory address passes a specified equality comparison.
|
||||
/// </summary>
|
||||
/// <param name="state">GPU state</param>
|
||||
/// <param name="gpuVa">GPU virtual address</param>
|
||||
/// <param name="isEqual">True to check if the values are equal, false to check if they are not equal</param>
|
||||
/// <returns>True if the condition is met, false otherwise. Returns host if handling with host conditional rendering</returns>
|
||||
private ConditionalRenderEnabled CounterCompare(ulong gpuVa, bool isEqual)
|
||||
private ConditionalRenderEnabled CounterCompare(GpuState state, ulong gpuVa, bool isEqual)
|
||||
{
|
||||
ICounterEvent evt = FindEvent(gpuVa);
|
||||
ICounterEvent evt2 = FindEvent(gpuVa + 16);
|
||||
ICounterEvent evt = FindEvent(state.Channel.MemoryManager.CounterCache, gpuVa);
|
||||
ICounterEvent evt2 = FindEvent(state.Channel.MemoryManager.CounterCache, gpuVa + 16);
|
||||
|
||||
bool useHost;
|
||||
|
||||
if (evt != null && evt2 == null)
|
||||
{
|
||||
useHost = _context.Renderer.Pipeline.TryHostConditionalRendering(evt, _context.MemoryManager.Read<ulong>(gpuVa + 16), isEqual);
|
||||
useHost = _context.Renderer.Pipeline.TryHostConditionalRendering(evt, state.Channel.MemoryManager.Read<ulong>(gpuVa + 16), isEqual);
|
||||
}
|
||||
else if (evt == null && evt2 != null)
|
||||
{
|
||||
useHost = _context.Renderer.Pipeline.TryHostConditionalRendering(evt2, _context.MemoryManager.Read<ulong>(gpuVa), isEqual);
|
||||
useHost = _context.Renderer.Pipeline.TryHostConditionalRendering(evt2, state.Channel.MemoryManager.Read<ulong>(gpuVa), isEqual);
|
||||
}
|
||||
else if (evt != null && evt2 != null)
|
||||
{
|
||||
|
@ -99,8 +102,8 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
|||
evt?.Flush();
|
||||
evt2?.Flush();
|
||||
|
||||
ulong x = _context.MemoryManager.Read<ulong>(gpuVa);
|
||||
ulong y = _context.MemoryManager.Read<ulong>(gpuVa + 16);
|
||||
ulong x = state.Channel.MemoryManager.Read<ulong>(gpuVa);
|
||||
ulong y = state.Channel.MemoryManager.Read<ulong>(gpuVa + 16);
|
||||
|
||||
return (isEqual ? x == y : x != y) ? ConditionalRenderEnabled.True : ConditionalRenderEnabled.False;
|
||||
}
|
||||
|
@ -110,11 +113,12 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
|||
/// Tries to find a counter that is supposed to be written at the specified address,
|
||||
/// returning the related event.
|
||||
/// </summary>
|
||||
/// <param name="counterCache">GPU counter cache to search on</param>
|
||||
/// <param name="gpuVa">GPU virtual address where the counter is supposed to be written</param>
|
||||
/// <returns>The counter event, or null if not present</returns>
|
||||
private ICounterEvent FindEvent(ulong gpuVa)
|
||||
private static ICounterEvent FindEvent(CounterCache counterCache, ulong gpuVa)
|
||||
{
|
||||
return _counterCache.FindEvent(gpuVa);
|
||||
return counterCache.FindEvent(gpuVa);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
|||
return;
|
||||
}
|
||||
|
||||
FlushUboDirty();
|
||||
FlushUboDirty(state.Channel.MemoryManager);
|
||||
|
||||
if (copy2D)
|
||||
{
|
||||
|
@ -98,21 +98,27 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
|||
dst.MemoryLayout.UnpackGobBlocksInZ(),
|
||||
dstBpp);
|
||||
|
||||
ulong srcBaseAddress = _context.MemoryManager.Translate(cbp.SrcAddress.Pack());
|
||||
ulong dstBaseAddress = _context.MemoryManager.Translate(cbp.DstAddress.Pack());
|
||||
ulong srcBaseAddress = state.Channel.MemoryManager.Translate(cbp.SrcAddress.Pack());
|
||||
ulong dstBaseAddress = state.Channel.MemoryManager.Translate(cbp.DstAddress.Pack());
|
||||
|
||||
(int srcBaseOffset, int srcSize) = srcCalculator.GetRectangleRange(src.RegionX, src.RegionY, cbp.XCount, cbp.YCount);
|
||||
(int dstBaseOffset, int dstSize) = dstCalculator.GetRectangleRange(dst.RegionX, dst.RegionY, cbp.XCount, cbp.YCount);
|
||||
|
||||
ReadOnlySpan<byte> srcSpan = _context.PhysicalMemory.GetSpan(srcBaseAddress + (ulong)srcBaseOffset, srcSize, true);
|
||||
Span<byte> dstSpan = _context.PhysicalMemory.GetSpan(dstBaseAddress + (ulong)dstBaseOffset, dstSize).ToArray();
|
||||
ReadOnlySpan<byte> srcSpan = state.Channel.MemoryManager.Physical.GetSpan(srcBaseAddress + (ulong)srcBaseOffset, srcSize, true);
|
||||
Span<byte> dstSpan = state.Channel.MemoryManager.Physical.GetSpan(dstBaseAddress + (ulong)dstBaseOffset, dstSize).ToArray();
|
||||
|
||||
bool completeSource = IsTextureCopyComplete(cbp, src, srcLinear, srcBpp, cbp.SrcStride);
|
||||
bool completeDest = IsTextureCopyComplete(cbp, dst, dstLinear, dstBpp, cbp.DstStride);
|
||||
|
||||
if (completeSource && completeDest)
|
||||
{
|
||||
Image.Texture target = TextureCache.FindTexture(dst, cbp, swizzle, dstLinear);
|
||||
Image.Texture target = state.Channel.MemoryManager.Physical.TextureCache.FindTexture(
|
||||
state.Channel.MemoryManager,
|
||||
dst,
|
||||
cbp,
|
||||
swizzle,
|
||||
dstLinear);
|
||||
|
||||
if (target != null)
|
||||
{
|
||||
ReadOnlySpan<byte> data;
|
||||
|
@ -154,7 +160,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
|||
{
|
||||
srcSpan.CopyTo(dstSpan); // No layout conversion has to be performed, just copy the data entirely.
|
||||
|
||||
_context.PhysicalMemory.Write(dstBaseAddress + (ulong)dstBaseOffset, dstSpan);
|
||||
state.Channel.MemoryManager.Physical.Write(dstBaseAddress + (ulong)dstBaseOffset, dstSpan);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -195,7 +201,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
|||
_ => throw new NotSupportedException($"Unable to copy ${srcBpp} bpp pixel format.")
|
||||
};
|
||||
|
||||
_context.PhysicalMemory.Write(dstBaseAddress + (ulong)dstBaseOffset, dstSpan);
|
||||
state.Channel.MemoryManager.Physical.Write(dstBaseAddress + (ulong)dstBaseOffset, dstSpan);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -209,13 +215,21 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
|||
swizzle.UnpackComponentSize() == 4)
|
||||
{
|
||||
// Fast path for clears when remap is enabled.
|
||||
BufferCache.ClearBuffer(cbp.DstAddress, (uint)size * 4, state.Get<uint>(MethodOffset.CopyBufferConstA));
|
||||
state.Channel.MemoryManager.Physical.BufferCache.ClearBuffer(
|
||||
state.Channel.MemoryManager,
|
||||
cbp.DstAddress,
|
||||
(uint)size * 4,
|
||||
state.Get<uint>(MethodOffset.CopyBufferConstA));
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: Implement remap functionality.
|
||||
// Buffer to buffer copy.
|
||||
BufferCache.CopyBuffer(cbp.SrcAddress, cbp.DstAddress, (uint)size);
|
||||
state.Channel.MemoryManager.Physical.BufferCache.CopyBuffer(
|
||||
state.Channel.MemoryManager,
|
||||
cbp.SrcAddress,
|
||||
cbp.DstAddress,
|
||||
(uint)size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,8 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
|||
/// <param name="argument">Method call argument</param>
|
||||
private void CopyTexture(GpuState state, int argument)
|
||||
{
|
||||
var memoryManager = state.Channel.MemoryManager;
|
||||
|
||||
var dstCopyTexture = state.Get<CopyTexture>(MethodOffset.CopyDstTexture);
|
||||
var srcCopyTexture = state.Get<CopyTexture>(MethodOffset.CopySrcTexture);
|
||||
|
||||
|
@ -80,7 +82,13 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
|||
srcX1 = 0;
|
||||
}
|
||||
|
||||
Texture srcTexture = TextureCache.FindOrCreateTexture(srcCopyTexture, offset, srcCopyTextureFormat, true, srcHint);
|
||||
Texture srcTexture = memoryManager.Physical.TextureCache.FindOrCreateTexture(
|
||||
memoryManager,
|
||||
srcCopyTexture,
|
||||
offset,
|
||||
srcCopyTextureFormat,
|
||||
true,
|
||||
srcHint);
|
||||
|
||||
if (srcTexture == null)
|
||||
{
|
||||
|
@ -101,7 +109,13 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
|||
dstCopyTextureFormat = dstCopyTexture.Format.Convert();
|
||||
}
|
||||
|
||||
Texture dstTexture = TextureCache.FindOrCreateTexture(dstCopyTexture, 0, dstCopyTextureFormat, srcTexture.ScaleMode == TextureScaleMode.Scaled, dstHint);
|
||||
Texture dstTexture = memoryManager.Physical.TextureCache.FindOrCreateTexture(
|
||||
memoryManager,
|
||||
dstCopyTexture,
|
||||
0,
|
||||
dstCopyTextureFormat,
|
||||
srcTexture.ScaleMode == TextureScaleMode.Scaled,
|
||||
dstHint);
|
||||
|
||||
if (dstTexture == null)
|
||||
{
|
||||
|
|
|
@ -12,8 +12,6 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
|||
private const int NsToTicksFractionNumerator = 384;
|
||||
private const int NsToTicksFractionDenominator = 625;
|
||||
|
||||
private readonly CounterCache _counterCache = new CounterCache();
|
||||
|
||||
/// <summary>
|
||||
/// Writes a GPU counter to guest memory.
|
||||
/// </summary>
|
||||
|
@ -39,7 +37,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
|||
{
|
||||
var rs = state.Get<SemaphoreState>(MethodOffset.ReportState);
|
||||
|
||||
_context.MemoryManager.Write(rs.Address.Pack(), rs.Payload);
|
||||
state.Channel.MemoryManager.Write(rs.Address.Pack(), rs.Payload);
|
||||
|
||||
_context.AdvanceSequence();
|
||||
}
|
||||
|
@ -85,7 +83,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
|||
|
||||
if (counter?.Invalid != true)
|
||||
{
|
||||
_context.MemoryManager.Write(gpuVa, counterData);
|
||||
state.Channel.MemoryManager.Write(gpuVa, counterData);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -105,7 +103,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
|||
break;
|
||||
}
|
||||
|
||||
_counterCache.AddOrUpdate(gpuVa, counter);
|
||||
state.Channel.MemoryManager.CounterCache.AddOrUpdate(gpuVa, counter);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -66,7 +66,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
|||
|
||||
int index = (argument >> 4) & 0x1f;
|
||||
|
||||
FlushUboDirty();
|
||||
FlushUboDirty(state.Channel.MemoryManager);
|
||||
|
||||
if (enable)
|
||||
{
|
||||
|
|
|
@ -16,11 +16,12 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
|||
/// <summary>
|
||||
/// Flushes any queued ubo updates.
|
||||
/// </summary>
|
||||
private void FlushUboDirty()
|
||||
/// <param name="memoryManager">GPU memory manager where the uniform buffer is mapped</param>
|
||||
private void FlushUboDirty(MemoryManager memoryManager)
|
||||
{
|
||||
if (_ubFollowUpAddress != 0)
|
||||
{
|
||||
BufferCache.ForceDirty(_ubFollowUpAddress - _ubByteCount, _ubByteCount);
|
||||
memoryManager.Physical.BufferCache.ForceDirty(memoryManager, _ubFollowUpAddress - _ubByteCount, _ubByteCount);
|
||||
|
||||
_ubFollowUpAddress = 0;
|
||||
}
|
||||
|
@ -39,13 +40,14 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
|||
|
||||
if (_ubFollowUpAddress != address)
|
||||
{
|
||||
FlushUboDirty();
|
||||
FlushUboDirty(state.Channel.MemoryManager);
|
||||
|
||||
_ubByteCount = 0;
|
||||
_ubBeginCpuAddress = _context.MemoryManager.Translate(address);
|
||||
_ubBeginCpuAddress = state.Channel.MemoryManager.Translate(address);
|
||||
}
|
||||
|
||||
_context.PhysicalMemory.WriteUntracked(_ubBeginCpuAddress + _ubByteCount, MemoryMarshal.Cast<int, byte>(MemoryMarshal.CreateSpan(ref argument, 1)));
|
||||
var byteData = MemoryMarshal.Cast<int, byte>(MemoryMarshal.CreateSpan(ref argument, 1));
|
||||
state.Channel.MemoryManager.Physical.WriteUntracked(_ubBeginCpuAddress + _ubByteCount, byteData);
|
||||
|
||||
_ubFollowUpAddress = address + 4;
|
||||
_ubByteCount += 4;
|
||||
|
@ -68,13 +70,14 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
|||
|
||||
if (_ubFollowUpAddress != address)
|
||||
{
|
||||
FlushUboDirty();
|
||||
FlushUboDirty(state.Channel.MemoryManager);
|
||||
|
||||
_ubByteCount = 0;
|
||||
_ubBeginCpuAddress = _context.MemoryManager.Translate(address);
|
||||
_ubBeginCpuAddress = state.Channel.MemoryManager.Translate(address);
|
||||
}
|
||||
|
||||
_context.PhysicalMemory.WriteUntracked(_ubBeginCpuAddress + _ubByteCount, MemoryMarshal.Cast<int, byte>(data));
|
||||
var byteData = MemoryMarshal.Cast<int, byte>(data);
|
||||
state.Channel.MemoryManager.Physical.WriteUntracked(_ubBeginCpuAddress + _ubByteCount, byteData);
|
||||
|
||||
_ubFollowUpAddress = address + size;
|
||||
_ubByteCount += size;
|
||||
|
|
|
@ -22,21 +22,6 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
|||
private readonly GpuContext _context;
|
||||
private readonly ShaderProgramInfo[] _currentProgramInfo;
|
||||
|
||||
/// <summary>
|
||||
/// In-memory shader cache.
|
||||
/// </summary>
|
||||
public ShaderCache ShaderCache { get; }
|
||||
|
||||
/// <summary>
|
||||
/// GPU buffer manager.
|
||||
/// </summary>
|
||||
public BufferCache BufferCache { get; }
|
||||
|
||||
/// <summary>
|
||||
/// GPU texture manager.
|
||||
/// </summary>
|
||||
public TextureCache TextureCache { get; }
|
||||
|
||||
private bool _isAnyVbInstanced;
|
||||
private bool _vsUsesInstanceId;
|
||||
private byte _vsClipDistancesWritten;
|
||||
|
@ -53,16 +38,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
|||
{
|
||||
_context = context;
|
||||
|
||||
ShaderCache = new ShaderCache(_context);
|
||||
|
||||
_currentProgramInfo = new ShaderProgramInfo[Constants.ShaderStages];
|
||||
|
||||
BufferCache = new BufferCache(context);
|
||||
TextureCache = new TextureCache(context);
|
||||
|
||||
context.MemoryManager.MemoryUnmapped += _counterCache.MemoryUnmappedHandler;
|
||||
context.MemoryManager.MemoryUnmapped += TextureCache.MemoryUnmappedHandler;
|
||||
context.MemoryManager.MemoryUnmapped += BufferCache.MemoryUnmappedHandler;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -130,7 +106,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
|||
_prevTfEnable = false;
|
||||
}
|
||||
|
||||
FlushUboDirty();
|
||||
FlushUboDirty(state.Channel.MemoryManager);
|
||||
|
||||
// Shaders must be the first one to be updated if modified, because
|
||||
// some of the other state depends on information from the currently
|
||||
|
@ -342,7 +318,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
|||
|
||||
sbDescAddress += (ulong)sbDescOffset;
|
||||
|
||||
SbDescriptor sbDescriptor = _context.PhysicalMemory.Read<SbDescriptor>(sbDescAddress);
|
||||
SbDescriptor sbDescriptor = state.Channel.MemoryManager.Physical.Read<SbDescriptor>(sbDescAddress);
|
||||
|
||||
state.Channel.BufferManager.SetGraphicsStorageBuffer(stage, sb.Slot, sbDescriptor.PackAddress(), (uint)sbDescriptor.Size, sb.Flags);
|
||||
}
|
||||
|
@ -357,6 +333,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
|||
/// <param name="singleUse">If this is not -1, it indicates that only the given indexed target will be used.</param>
|
||||
private void UpdateRenderTargetState(GpuState state, bool useControl, int singleUse = -1)
|
||||
{
|
||||
var memoryManager = state.Channel.MemoryManager;
|
||||
var rtControl = state.Get<RtControl>(MethodOffset.RtControl);
|
||||
|
||||
int count = useControl ? rtControl.UnpackCount() : Constants.TotalRenderTargets;
|
||||
|
@ -384,7 +361,12 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
|||
continue;
|
||||
}
|
||||
|
||||
Texture color = TextureCache.FindOrCreateTexture(colorState, samplesInX, samplesInY, sizeHint);
|
||||
Texture color = memoryManager.Physical.TextureCache.FindOrCreateTexture(
|
||||
memoryManager,
|
||||
colorState,
|
||||
samplesInX,
|
||||
samplesInY,
|
||||
sizeHint);
|
||||
|
||||
changedScale |= state.Channel.TextureManager.SetRenderTargetColor(index, color);
|
||||
}
|
||||
|
@ -398,7 +380,13 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
|||
var dsState = state.Get<RtDepthStencilState>(MethodOffset.RtDepthStencilState);
|
||||
var dsSize = state.Get<Size3D>(MethodOffset.RtDepthStencilSize);
|
||||
|
||||
depthStencil = TextureCache.FindOrCreateTexture(dsState, dsSize, samplesInX, samplesInY, sizeHint);
|
||||
depthStencil = memoryManager.Physical.TextureCache.FindOrCreateTexture(
|
||||
memoryManager,
|
||||
dsState,
|
||||
dsSize,
|
||||
samplesInX,
|
||||
samplesInY,
|
||||
sizeHint);
|
||||
}
|
||||
|
||||
changedScale |= state.Channel.TextureManager.SetRenderTargetDepthStencil(depthStencil);
|
||||
|
@ -1012,7 +1000,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
|||
addressesArray[index] = baseAddress + shader.Offset;
|
||||
}
|
||||
|
||||
ShaderBundle gs = ShaderCache.GetGraphicsShader(state, addresses);
|
||||
ShaderBundle gs = state.Channel.MemoryManager.Physical.ShaderCache.GetGraphicsShader(state, addresses);
|
||||
|
||||
byte oldVsClipDistancesWritten = _vsClipDistancesWritten;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue