aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2022-06-10 23:44:49 -0300
committerGitHub <noreply@github.com>2022-06-10 23:44:49 -0300
commit9a9349f0f4e3c6e80bacc782a8d4a4766f89ea74 (patch)
tree616b0a223bc9a46f30b4d2129c4a59fdd68475dc
parent46cc7b55f02fc9e9cbe0637d710b5e5a6c76eaef (diff)
Fix instanced indexed inline draw index count (#3389)1.1.143
-rw-r--r--Ryujinx.Graphics.Gpu/Engine/Threed/DrawManager.cs28
-rw-r--r--Ryujinx.Graphics.Gpu/Engine/Threed/IbStreamer.cs5
2 files changed, 18 insertions, 15 deletions
diff --git a/Ryujinx.Graphics.Gpu/Engine/Threed/DrawManager.cs b/Ryujinx.Graphics.Gpu/Engine/Threed/DrawManager.cs
index 7e35fd2d..ab371314 100644
--- a/Ryujinx.Graphics.Gpu/Engine/Threed/DrawManager.cs
+++ b/Ryujinx.Graphics.Gpu/Engine/Threed/DrawManager.cs
@@ -135,14 +135,16 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
{
_instancedDrawPending = true;
+ int ibCount = _drawState.IbStreamer.InlineIndexCount;
+
_instancedIndexed = _drawState.DrawIndexed;
- _instancedIndexedInline = _drawState.IbStreamer.HasInlineIndexData;
+ _instancedIndexedInline = ibCount != 0;
_instancedFirstIndex = firstIndex;
_instancedFirstVertex = (int)_state.State.FirstVertex;
_instancedFirstInstance = (int)_state.State.FirstInstance;
- _instancedIndexCount = indexCount;
+ _instancedIndexCount = ibCount != 0 ? ibCount : indexCount;
var drawState = _state.State.VertexBufferDrawState;
@@ -453,23 +455,19 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
{
_instancedDrawPending = false;
- if (_instancedIndexedInline)
+ bool indexedInline = _instancedIndexedInline;
+
+ if (_instancedIndexed || indexedInline)
{
- int inlineIndexCount = _drawState.IbStreamer.GetAndResetInlineIndexCount();
- BufferRange br = new BufferRange(_drawState.IbStreamer.GetInlineIndexBuffer(), 0, inlineIndexCount * 4);
+ if (indexedInline)
+ {
+ int inlineIndexCount = _drawState.IbStreamer.GetAndResetInlineIndexCount();
+ BufferRange br = new BufferRange(_drawState.IbStreamer.GetInlineIndexBuffer(), 0, inlineIndexCount * 4);
- _channel.BufferManager.SetIndexBuffer(br, IndexType.UInt);
+ _channel.BufferManager.SetIndexBuffer(br, IndexType.UInt);
+ }
_context.Renderer.Pipeline.DrawIndexed(
- inlineIndexCount,
- _instanceIndex + 1,
- _instancedFirstIndex,
- _instancedFirstVertex,
- _instancedFirstInstance);
- }
- else if (_instancedIndexed)
- {
- _context.Renderer.Pipeline.DrawIndexed(
_instancedIndexCount,
_instanceIndex + 1,
_instancedFirstIndex,
diff --git a/Ryujinx.Graphics.Gpu/Engine/Threed/IbStreamer.cs b/Ryujinx.Graphics.Gpu/Engine/Threed/IbStreamer.cs
index 96b2ed9c..4862bca1 100644
--- a/Ryujinx.Graphics.Gpu/Engine/Threed/IbStreamer.cs
+++ b/Ryujinx.Graphics.Gpu/Engine/Threed/IbStreamer.cs
@@ -21,6 +21,11 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
public bool HasInlineIndexData => _inlineIndexCount != 0;
/// <summary>
+ /// Total numbers of indices that have been pushed.
+ /// </summary>
+ public int InlineIndexCount => _inlineIndexCount;
+
+ /// <summary>
/// Gets the handle for the host buffer currently holding the inline index buffer data.
/// </summary>
/// <returns>Host buffer handle</returns>