mirror of
https://github.com/Ryubing/Ryujinx.git
synced 2025-11-21 18:40:56 -05:00
Metal: Unsupported topology indexed draw conversion (#40)
* Convert unsupported indexed buffer topologies * Fix index count and dispatch size * Cleanup * Fix typos
This commit is contained in:
committed by
Evan Husted
parent
38b2cf9b83
commit
51e85ed38b
@@ -62,5 +62,42 @@ namespace Ryujinx.Graphics.Metal
|
||||
|
||||
return (new MTLBuffer(IntPtr.Zero), 0, MTLIndexType.UInt16);
|
||||
}
|
||||
|
||||
public (MTLBuffer, int, MTLIndexType) GetConvertedIndexBuffer(
|
||||
MetalRenderer renderer,
|
||||
CommandBufferScoped cbs,
|
||||
int firstIndex,
|
||||
int indexCount,
|
||||
int convertedCount,
|
||||
IndexBufferPattern pattern)
|
||||
{
|
||||
// Convert the index buffer using the given pattern.
|
||||
int indexSize = GetIndexSize();
|
||||
|
||||
int firstIndexOffset = firstIndex * indexSize;
|
||||
|
||||
var autoBuffer = renderer.BufferManager.GetBufferTopologyConversion(cbs, _handle, _offset + firstIndexOffset, indexCount * indexSize, pattern, indexSize);
|
||||
|
||||
int size = convertedCount * 4;
|
||||
|
||||
if (autoBuffer != null)
|
||||
{
|
||||
DisposableBuffer buffer = autoBuffer.Get(cbs, 0, size);
|
||||
|
||||
return (buffer.Value, 0, MTLIndexType.UInt32);
|
||||
}
|
||||
|
||||
return (new MTLBuffer(IntPtr.Zero), 0, MTLIndexType.UInt32);
|
||||
}
|
||||
|
||||
private int GetIndexSize()
|
||||
{
|
||||
return _type switch
|
||||
{
|
||||
IndexType.UInt => 4,
|
||||
IndexType.UShort => 2,
|
||||
_ => 1,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user