mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-12-20 12:12:00 +00:00
Be smart and use a bitmask not a list
This commit is contained in:
parent
102c87e623
commit
14c58f62eb
1 changed files with 3 additions and 4 deletions
|
@ -564,8 +564,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
private static MTLVertexDescriptor BuildVertexDescriptor(VertexBufferDescriptor[] bufferDescriptors, VertexAttribDescriptor[] attribDescriptors)
|
private static MTLVertexDescriptor BuildVertexDescriptor(VertexBufferDescriptor[] bufferDescriptors, VertexAttribDescriptor[] attribDescriptors)
|
||||||
{
|
{
|
||||||
var vertexDescriptor = new MTLVertexDescriptor();
|
var vertexDescriptor = new MTLVertexDescriptor();
|
||||||
|
uint indexMask = 0;
|
||||||
var usedIndexes = new List<int>();
|
|
||||||
|
|
||||||
// TODO: Handle 'zero' buffers
|
// TODO: Handle 'zero' buffers
|
||||||
for (int i = 0; i < attribDescriptors.Length; i++)
|
for (int i = 0; i < attribDescriptors.Length; i++)
|
||||||
|
@ -573,7 +572,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
var attrib = vertexDescriptor.Attributes.Object((ulong)i);
|
var attrib = vertexDescriptor.Attributes.Object((ulong)i);
|
||||||
// TODO: Format should not be hardcoded
|
// TODO: Format should not be hardcoded
|
||||||
attrib.Format = MTLVertexFormat.Float4;
|
attrib.Format = MTLVertexFormat.Float4;
|
||||||
usedIndexes.Add(attribDescriptors[i].BufferIndex);
|
indexMask |= 1u << attribDescriptors[i].BufferIndex;
|
||||||
attrib.BufferIndex = (ulong)attribDescriptors[i].BufferIndex;
|
attrib.BufferIndex = (ulong)attribDescriptors[i].BufferIndex;
|
||||||
attrib.Offset = (ulong)attribDescriptors[i].Offset;
|
attrib.Offset = (ulong)attribDescriptors[i].Offset;
|
||||||
}
|
}
|
||||||
|
@ -581,7 +580,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
for (int i = 0; i < bufferDescriptors.Length; i++)
|
for (int i = 0; i < bufferDescriptors.Length; i++)
|
||||||
{
|
{
|
||||||
var layout = vertexDescriptor.Layouts.Object((ulong)i);
|
var layout = vertexDescriptor.Layouts.Object((ulong)i);
|
||||||
layout.Stride = usedIndexes.Contains(i) ? (ulong)bufferDescriptors[i].Stride : 0;
|
layout.Stride = (indexMask & (1u << i)) != 0 ? (ulong)bufferDescriptors[i].Stride : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return vertexDescriptor;
|
return vertexDescriptor;
|
||||||
|
|
Loading…
Reference in a new issue