aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Gpu/Engine
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2021-09-28 20:55:12 -0300
committerGitHub <noreply@github.com>2021-09-29 01:55:12 +0200
commitfd7567a6b56fcb82a52b85097582fc0a67038457 (patch)
tree175c9992d0cca4c05b80857d66af4bbdce09cba7 /Ryujinx.Graphics.Gpu/Engine
parent312be74861dae16311f4376e32195f8a4fd372c6 (diff)
Only make render target 2D textures layered if needed (#2646)
* Only make render target 2D textures layered if needed * Shader cache version bump * Ensure topology is updated on channel swap
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Engine')
-rw-r--r--Ryujinx.Graphics.Gpu/Engine/Threed/DrawManager.cs14
-rw-r--r--Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs9
-rw-r--r--Ryujinx.Graphics.Gpu/Engine/Threed/ThreedClass.cs1
3 files changed, 21 insertions, 3 deletions
diff --git a/Ryujinx.Graphics.Gpu/Engine/Threed/DrawManager.cs b/Ryujinx.Graphics.Gpu/Engine/Threed/DrawManager.cs
index e01938bd..82aff204 100644
--- a/Ryujinx.Graphics.Gpu/Engine/Threed/DrawManager.cs
+++ b/Ryujinx.Graphics.Gpu/Engine/Threed/DrawManager.cs
@@ -13,6 +13,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
private readonly GpuChannel _channel;
private readonly DeviceStateWithShadow<ThreedClassState> _state;
private readonly DrawState _drawState;
+ private bool _topologySet;
private bool _instancedDrawPending;
private bool _instancedIndexed;
@@ -44,6 +45,14 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
}
/// <summary>
+ /// Marks the entire state as dirty, forcing a full host state update before the next draw.
+ /// </summary>
+ public void ForceStateDirty()
+ {
+ _topologySet = false;
+ }
+
+ /// <summary>
/// Pushes four 8-bit index buffer elements.
/// </summary>
/// <param name="argument">Method call argument</param>
@@ -224,11 +233,11 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
_instanceIndex = 0;
}
- if (_drawState.Topology != topology)
+ if (_drawState.Topology != topology || !_topologySet)
{
_context.Renderer.Pipeline.SetPrimitiveTopology(topology);
-
_drawState.Topology = topology;
+ _topologySet = true;
}
}
@@ -331,6 +340,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
_context.Renderer.Pipeline.SetPrimitiveTopology(topology);
_drawState.Topology = topology;
+ _topologySet = true;
ConditionalRenderEnabled renderEnable = ConditionalRendering.GetRenderEnable(
_context,
diff --git a/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs b/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs
index f429ae90..f9d16803 100644
--- a/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs
+++ b/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs
@@ -6,7 +6,6 @@ using Ryujinx.Graphics.Gpu.Shader;
using Ryujinx.Graphics.Shader;
using Ryujinx.Graphics.Texture;
using System;
-using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@@ -31,6 +30,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
private readonly ShaderProgramInfo[] _currentProgramInfo;
+ private bool _vtgWritesRtLayer;
private byte _vsClipDistancesWritten;
private bool _prevDrawIndexed;
@@ -334,6 +334,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
Image.Texture color = memoryManager.Physical.TextureCache.FindOrCreateTexture(
memoryManager,
colorState,
+ _vtgWritesRtLayer,
samplesInX,
samplesInY,
sizeHint);
@@ -956,6 +957,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
_drawState.VsUsesInstanceId = gs.Shaders[0]?.Info.UsesInstanceId ?? false;
_vsClipDistancesWritten = gs.Shaders[0]?.Info.ClipDistancesWritten ?? 0;
+ _vtgWritesRtLayer = false;
if (oldVsClipDistancesWritten != _vsClipDistancesWritten)
{
@@ -979,6 +981,11 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
Span<TextureBindingInfo> textureBindings = _channel.TextureManager.RentGraphicsTextureBindings(stage, info.Textures.Count);
+ if (info.UsesRtLayer)
+ {
+ _vtgWritesRtLayer = true;
+ }
+
for (int index = 0; index < info.Textures.Count; index++)
{
var descriptor = info.Textures[index];
diff --git a/Ryujinx.Graphics.Gpu/Engine/Threed/ThreedClass.cs b/Ryujinx.Graphics.Gpu/Engine/Threed/ThreedClass.cs
index 3d02af96..d4f228e9 100644
--- a/Ryujinx.Graphics.Gpu/Engine/Threed/ThreedClass.cs
+++ b/Ryujinx.Graphics.Gpu/Engine/Threed/ThreedClass.cs
@@ -139,6 +139,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
public void ForceStateDirty()
{
+ _drawManager.ForceStateDirty();
_stateUpdater.SetAllDirty();
}