mirror of
https://github.com/GreemDev/Ryujinx
synced 2024-12-02 06:22:06 +01:00
Vertex buffer data
This commit is contained in:
parent
7f41e7dbd4
commit
2890fc1069
2 changed files with 29 additions and 0 deletions
14
src/Ryujinx.Graphics.Metal/Handle.cs
Normal file
14
src/Ryujinx.Graphics.Metal/Handle.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
using Ryujinx.Graphics.GAL;
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Ryujinx.Graphics.Metal
|
||||
{
|
||||
static class Handle
|
||||
{
|
||||
public static IntPtr ToIntPtr(this BufferHandle handle)
|
||||
{
|
||||
return Unsafe.As<BufferHandle, IntPtr>(ref handle);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -27,6 +27,7 @@ namespace Ryujinx.Graphics.Metal
|
|||
|
||||
private RenderEncoderState _renderEncoderState;
|
||||
private MTLVertexDescriptor _vertexDescriptor = new();
|
||||
private MTLBuffer[] _vertexBuffers;
|
||||
|
||||
private MTLBuffer _indexBuffer;
|
||||
private MTLIndexType _indexType;
|
||||
|
@ -120,6 +121,14 @@ namespace Ryujinx.Graphics.Metal
|
|||
var renderCommandEncoder = _commandBuffer.RenderCommandEncoder(descriptor);
|
||||
_renderEncoderState.SetEncoderState(renderCommandEncoder, _vertexDescriptor);
|
||||
|
||||
for (int i = 0; i < _vertexBuffers.Length; i++)
|
||||
{
|
||||
if (_vertexBuffers[i] != null)
|
||||
{
|
||||
renderCommandEncoder.SetVertexBuffer(_vertexBuffers[i], 0, (ulong)i);
|
||||
}
|
||||
}
|
||||
|
||||
_currentEncoder = renderCommandEncoder;
|
||||
return renderCommandEncoder;
|
||||
}
|
||||
|
@ -542,11 +551,17 @@ namespace Ryujinx.Graphics.Metal
|
|||
|
||||
public void SetVertexBuffers(ReadOnlySpan<VertexBufferDescriptor> vertexBuffers)
|
||||
{
|
||||
_vertexBuffers = new MTLBuffer[vertexBuffers.Length];
|
||||
|
||||
for (int i = 0; i < vertexBuffers.Length; i++)
|
||||
{
|
||||
if (vertexBuffers[i].Stride != 0)
|
||||
{
|
||||
_vertexDescriptor.Layouts.Object((ulong)i).Stride = (ulong)vertexBuffers[i].Stride;
|
||||
_vertexBuffers[i] = _device.NewBuffer(
|
||||
vertexBuffers[i].Buffer.Handle.ToIntPtr(),
|
||||
(ulong)vertexBuffers[i].Buffer.Size,
|
||||
MTLResourceOptions.ResourceStorageModeManaged);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue