Fix counted indirect draws

Fixes Monster Hunter Rise and Apollo Justice
This commit is contained in:
Isaac Marovitz 2024-09-07 21:38:01 +02:00
parent e81329c7b0
commit 53cd0c0e7a
No known key found for this signature in database
GPG Key ID: 97250B2B09A132E1
1 changed files with 22 additions and 10 deletions

View File

@ -521,6 +521,11 @@ namespace Ryujinx.Graphics.Metal
} }
public void DrawIndexedIndirect(BufferRange indirectBuffer) public void DrawIndexedIndirect(BufferRange indirectBuffer)
{
DrawIndexedIndirectOffset(indirectBuffer);
}
public void DrawIndexedIndirectOffset(BufferRange indirectBuffer, int offset = 0)
{ {
// TODO: Reindex unsupported topologies // TODO: Reindex unsupported topologies
if (TopologyUnsupported(_encoderStateManager.Topology)) if (TopologyUnsupported(_encoderStateManager.Topology))
@ -534,7 +539,7 @@ namespace Ryujinx.Graphics.Metal
var primitiveType = TopologyRemap(_encoderStateManager.Topology).Convert(); var primitiveType = TopologyRemap(_encoderStateManager.Topology).Convert();
(MTLBuffer indexBuffer, int offset, MTLIndexType type) = _encoderStateManager.IndexBuffer.GetIndexBuffer(_renderer, Cbs); (MTLBuffer indexBuffer, int indexOffset, MTLIndexType type) = _encoderStateManager.IndexBuffer.GetIndexBuffer(_renderer, Cbs);
if (indexBuffer.NativePtr != IntPtr.Zero && buffer.NativePtr != IntPtr.Zero) if (indexBuffer.NativePtr != IntPtr.Zero && buffer.NativePtr != IntPtr.Zero)
{ {
@ -544,20 +549,26 @@ namespace Ryujinx.Graphics.Metal
primitiveType, primitiveType,
type, type,
indexBuffer, indexBuffer,
(ulong)offset, (ulong)indexOffset,
buffer, buffer,
(ulong)indirectBuffer.Offset); (ulong)(indirectBuffer.Offset + offset));
} }
} }
public void DrawIndexedIndirectCount(BufferRange indirectBuffer, BufferRange parameterBuffer, int maxDrawCount, int stride) public void DrawIndexedIndirectCount(BufferRange indirectBuffer, BufferRange parameterBuffer, int maxDrawCount, int stride)
{ {
// TODO: Properly support count for (int i = 0; i < maxDrawCount; i++)
{
DrawIndexedIndirect(indirectBuffer); DrawIndexedIndirectOffset(indirectBuffer, stride * i);
}
} }
public void DrawIndirect(BufferRange indirectBuffer) public void DrawIndirect(BufferRange indirectBuffer)
{
DrawIndirectOffset(indirectBuffer);
}
public void DrawIndirectOffset(BufferRange indirectBuffer, int offset = 0)
{ {
if (TopologyUnsupported(_encoderStateManager.Topology)) if (TopologyUnsupported(_encoderStateManager.Topology))
{ {
@ -575,14 +586,15 @@ namespace Ryujinx.Graphics.Metal
renderCommandEncoder.DrawPrimitives( renderCommandEncoder.DrawPrimitives(
primitiveType, primitiveType,
buffer, buffer,
(ulong)indirectBuffer.Offset); (ulong)(indirectBuffer.Offset + offset));
} }
public void DrawIndirectCount(BufferRange indirectBuffer, BufferRange parameterBuffer, int maxDrawCount, int stride) public void DrawIndirectCount(BufferRange indirectBuffer, BufferRange parameterBuffer, int maxDrawCount, int stride)
{ {
// TODO: Properly support count for (int i = 0; i < maxDrawCount; i++)
{
DrawIndirect(indirectBuffer); DrawIndirectOffset(indirectBuffer, stride * i);
}
} }
public void DrawTexture(ITexture texture, ISampler sampler, Extents2DF srcRegion, Extents2DF dstRegion) public void DrawTexture(ITexture texture, ISampler sampler, Extents2DF srcRegion, Extents2DF dstRegion)