From 46cc7b55f02fc9e9cbe0637d710b5e5a6c76eaef Mon Sep 17 00:00:00 2001 From: gdkchan Date: Sun, 5 Jun 2022 21:24:28 -0300 Subject: [PATCH] Fix instanced indexed inline draws (#3383) --- .../Engine/Threed/DrawManager.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Ryujinx.Graphics.Gpu/Engine/Threed/DrawManager.cs b/Ryujinx.Graphics.Gpu/Engine/Threed/DrawManager.cs index 44d2d393d..7e35fd2de 100644 --- a/Ryujinx.Graphics.Gpu/Engine/Threed/DrawManager.cs +++ b/Ryujinx.Graphics.Gpu/Engine/Threed/DrawManager.cs @@ -18,6 +18,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed private bool _instancedDrawPending; private bool _instancedIndexed; + private bool _instancedIndexedInline; private int _instancedFirstIndex; private int _instancedFirstVertex; @@ -135,6 +136,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed _instancedDrawPending = true; _instancedIndexed = _drawState.DrawIndexed; + _instancedIndexedInline = _drawState.IbStreamer.HasInlineIndexData; _instancedFirstIndex = firstIndex; _instancedFirstVertex = (int)_state.State.FirstVertex; @@ -451,7 +453,21 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed { _instancedDrawPending = false; - if (_instancedIndexed) + if (_instancedIndexedInline) + { + int inlineIndexCount = _drawState.IbStreamer.GetAndResetInlineIndexCount(); + BufferRange br = new BufferRange(_drawState.IbStreamer.GetInlineIndexBuffer(), 0, inlineIndexCount * 4); + + _channel.BufferManager.SetIndexBuffer(br, IndexType.UInt); + + _context.Renderer.Pipeline.DrawIndexed( + inlineIndexCount, + _instanceIndex + 1, + _instancedFirstIndex, + _instancedFirstVertex, + _instancedFirstInstance); + } + else if (_instancedIndexed) { _context.Renderer.Pipeline.DrawIndexed( _instancedIndexCount,