1
0
Fork 0
mirror of https://github.com/Ryujinx/Ryujinx.git synced 2024-12-20 13:52:00 +00:00

Set Vertex Descriptor properly

This commit is contained in:
Isaac Marovitz 2023-10-10 17:53:51 -04:00 committed by Isaac Marovitz
parent 5c9d1bd0da
commit db9de66437
2 changed files with 15 additions and 6 deletions

View file

@ -526,12 +526,12 @@ namespace Ryujinx.Graphics.Metal
public void SetVertexAttribs(ReadOnlySpan<VertexAttribDescriptor> vertexAttribs) public void SetVertexAttribs(ReadOnlySpan<VertexAttribDescriptor> vertexAttribs)
{ {
Logger.Warning?.Print(LogClass.Gpu, "Not Implemented!"); _renderEncoderState.UpdateVertexAttributes(vertexAttribs);
} }
public void SetVertexBuffers(ReadOnlySpan<VertexBufferDescriptor> vertexBuffers) public void SetVertexBuffers(ReadOnlySpan<VertexBufferDescriptor> vertexBuffers)
{ {
_renderEncoderState.UpdateVertexDescriptor(vertexBuffers); _renderEncoderState.UpdateVertexBuffers(vertexBuffers);
} }
public unsafe void SetViewports(ReadOnlySpan<Viewport> viewports) public unsafe void SetViewports(ReadOnlySpan<Viewport> viewports)

View file

@ -103,17 +103,26 @@ namespace Ryujinx.Graphics.Metal
}); });
} }
public void UpdateVertexDescriptor(ReadOnlySpan<VertexBufferDescriptor> vertexBuffers) public void UpdateVertexAttributes(ReadOnlySpan<VertexAttribDescriptor> vertexAttribs)
{ {
// Reset Vertex Descriptor
_vertexDescriptor = new(); _vertexDescriptor = new();
for (int i = 0; i < vertexAttribs.Length; i++)
{
// TODO: Format should not be hardcoded
_vertexDescriptor.Attributes.Object((ulong)i).Format = MTLVertexFormat.Float4;
_vertexDescriptor.Attributes.Object((ulong)i).BufferIndex = (ulong)vertexAttribs[i].BufferIndex;
_vertexDescriptor.Attributes.Object((ulong)i).Offset = (ulong)vertexAttribs[i].Offset;
}
}
public void UpdateVertexBuffers(ReadOnlySpan<VertexBufferDescriptor> vertexBuffers)
{
for (int i = 0; i < vertexBuffers.Length; i++) for (int i = 0; i < vertexBuffers.Length; i++)
{ {
if (vertexBuffers[i].Stride != 0) if (vertexBuffers[i].Stride != 0)
{ {
// TODO: Format should not be hardcoded
_vertexDescriptor.Attributes.Object((ulong)i).Format = MTLVertexFormat.Float4;
_vertexDescriptor.Attributes.Object((ulong)i).BufferIndex = (ulong)i;
_vertexDescriptor.Layouts.Object((ulong)i).Stride = (ulong)vertexBuffers[i].Stride; _vertexDescriptor.Layouts.Object((ulong)i).Stride = (ulong)vertexBuffers[i].Stride;
} }
} }