diff options
| author | gdkchan <gab.dark.100@gmail.com> | 2020-05-23 06:46:09 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-23 11:46:09 +0200 |
| commit | 5011640b3086b86b0f0b39b60fdb2aa946d4f5c8 (patch) | |
| tree | 1bd60b7714886dfe282ca1e52cfa6fca97912cdf /Ryujinx.Graphics.Gpu | |
| parent | cc8dbdd3fb58a02e1c3fc3b9d0b1c35bc7b9d00f (diff) | |
Spanify Graphics Abstraction Layer (#1226)
* Spanify Graphics Abstraction Layer
* Be explicit about BufferHandle size
Diffstat (limited to 'Ryujinx.Graphics.Gpu')
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Constants.cs | 5 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Engine/Methods.cs | 8 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Memory/Buffer.cs | 16 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Memory/BufferManager.cs | 7 |
4 files changed, 21 insertions, 15 deletions
diff --git a/Ryujinx.Graphics.Gpu/Constants.cs b/Ryujinx.Graphics.Gpu/Constants.cs index 1ae90273..ac6b6139 100644 --- a/Ryujinx.Graphics.Gpu/Constants.cs +++ b/Ryujinx.Graphics.Gpu/Constants.cs @@ -46,6 +46,11 @@ namespace Ryujinx.Graphics.Gpu public const int ShaderStages = 5; /// <summary> + /// Maximum number of vertex attributes. + /// </summary> + public const int TotalVertexAttribs = 16; + + /// <summary> /// Maximum number of vertex buffers. /// </summary> public const int TotalVertexBuffers = 16; diff --git a/Ryujinx.Graphics.Gpu/Engine/Methods.cs b/Ryujinx.Graphics.Gpu/Engine/Methods.cs index 5ead87a0..acb5ad5c 100644 --- a/Ryujinx.Graphics.Gpu/Engine/Methods.cs +++ b/Ryujinx.Graphics.Gpu/Engine/Methods.cs @@ -570,9 +570,9 @@ namespace Ryujinx.Graphics.Gpu.Engine /// <param name="state">Current GPU state</param> private void UpdateVertexAttribState(GpuState state) { - VertexAttribDescriptor[] vertexAttribs = new VertexAttribDescriptor[16]; + Span<VertexAttribDescriptor> vertexAttribs = stackalloc VertexAttribDescriptor[Constants.TotalVertexAttribs]; - for (int index = 0; index < 16; index++) + for (int index = 0; index < Constants.TotalVertexAttribs; index++) { var vertexAttrib = state.Get<VertexAttribState>(MethodOffset.VertexAttribState, index); @@ -660,7 +660,7 @@ namespace Ryujinx.Graphics.Gpu.Engine { _isAnyVbInstanced = false; - for (int index = 0; index < 16; index++) + for (int index = 0; index < Constants.TotalVertexBuffers; index++) { var vertexBuffer = state.Get<VertexBufferState>(MethodOffset.VertexBufferState, index); @@ -728,7 +728,7 @@ namespace Ryujinx.Graphics.Gpu.Engine { bool rtColorMaskShared = state.Get<Boolean32>(MethodOffset.RtColorMaskShared); - uint[] componentMasks = new uint[Constants.TotalRenderTargets]; + Span<uint> componentMasks = stackalloc uint[Constants.TotalRenderTargets]; for (int index = 0; index < Constants.TotalRenderTargets; index++) { 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); |
