aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Gpu/Memory
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2020-05-23 06:46:09 -0300
committerGitHub <noreply@github.com>2020-05-23 11:46:09 +0200
commit5011640b3086b86b0f0b39b60fdb2aa946d4f5c8 (patch)
tree1bd60b7714886dfe282ca1e52cfa6fca97912cdf /Ryujinx.Graphics.Gpu/Memory
parentcc8dbdd3fb58a02e1c3fc3b9d0b1c35bc7b9d00f (diff)
Spanify Graphics Abstraction Layer (#1226)
* Spanify Graphics Abstraction Layer * Be explicit about BufferHandle size
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Memory')
-rw-r--r--Ryujinx.Graphics.Gpu/Memory/Buffer.cs16
-rw-r--r--Ryujinx.Graphics.Gpu/Memory/BufferManager.cs7
2 files changed, 12 insertions, 11 deletions
diff --git a/Ryujinx.Graphics.Gpu/Memory/Buffer.cs b/Ryujinx.Graphics.Gpu/Memory/Buffer.cs
index 4dd96878..5fe85d2e 100644
--- a/Ryujinx.Graphics.Gpu/Memory/Buffer.cs
+++ b/Ryujinx.Graphics.Gpu/Memory/Buffer.cs
@@ -11,9 +11,9 @@ namespace Ryujinx.Graphics.Gpu.Memory
private readonly GpuContext _context;
/// <summary>
- /// Host buffer object.
+ /// Host buffer handle.
/// </summary>
- public IBuffer HostBuffer { get; }
+ public BufferHandle Handle { get; }
/// <summary>
/// Start address of the buffer in guest memory.
@@ -46,7 +46,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
Address = address;
Size = size;
- HostBuffer = context.Renderer.CreateBuffer((int)size);
+ Handle = context.Renderer.CreateBuffer((int)size);
_modifiedRanges = new (ulong, ulong)[size / PhysicalMemory.PageSize];
@@ -66,7 +66,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
{
int offset = (int)(address - Address);
- return new BufferRange(HostBuffer, offset, (int)size);
+ return new BufferRange(Handle, offset, (int)size);
}
/// <summary>
@@ -125,7 +125,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
int offset = (int)(mAddress - Address);
- HostBuffer.SetData(offset, _context.PhysicalMemory.GetSpan(mAddress, (int)mSize));
+ _context.Renderer.SetBufferData(Handle, offset, _context.PhysicalMemory.GetSpan(mAddress, (int)mSize));
}
}
@@ -136,7 +136,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
/// <param name="dstOffset">The offset of the destination buffer to copy into</param>
public void CopyTo(Buffer destination, int dstOffset)
{
- HostBuffer.CopyTo(destination.HostBuffer, 0, dstOffset, (int)Size);
+ _context.Renderer.Pipeline.CopyBuffer(Handle, destination.Handle, 0, dstOffset, (int)Size);
}
/// <summary>
@@ -149,7 +149,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
{
int offset = (int)(address - Address);
- byte[] data = HostBuffer.GetData(offset, (int)size);
+ byte[] data = _context.Renderer.GetBufferData(Handle, offset, (int)size);
_context.PhysicalMemory.Write(address, data);
}
@@ -159,7 +159,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
/// </summary>
public void Dispose()
{
- HostBuffer.Dispose();
+ _context.Renderer.DeleteBuffer(Handle);
}
}
} \ No newline at end of file
diff --git a/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs b/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs
index 2fe0ecbb..39d1cd6f 100644
--- a/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs
+++ b/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs
@@ -477,7 +477,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
{
_vertexBuffersDirty = false;
- VertexBufferDescriptor[] vertexBuffers = new VertexBufferDescriptor[Constants.TotalVertexBuffers];
+ Span<VertexBufferDescriptor> vertexBuffers = stackalloc VertexBufferDescriptor[Constants.TotalVertexBuffers];
for (int index = 0; (vbEnableMask >> index) != 0; index++)
{
@@ -666,8 +666,9 @@ namespace Ryujinx.Graphics.Gpu.Memory
int srcOffset = (int)(srcAddress - srcBuffer.Address);
int dstOffset = (int)(dstAddress - dstBuffer.Address);
- srcBuffer.HostBuffer.CopyTo(
- dstBuffer.HostBuffer,
+ _context.Renderer.Pipeline.CopyBuffer(
+ srcBuffer.Handle,
+ dstBuffer.Handle,
srcOffset,
dstOffset,
(int)size);