From fd7567a6b56fcb82a52b85097582fc0a67038457 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Tue, 28 Sep 2021 20:55:12 -0300 Subject: 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 --- Ryujinx.Graphics.Gpu/Engine/Threed/DrawManager.cs | 14 ++++++++++++-- Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs | 9 ++++++++- Ryujinx.Graphics.Gpu/Engine/Threed/ThreedClass.cs | 1 + 3 files changed, 21 insertions(+), 3 deletions(-) (limited to 'Ryujinx.Graphics.Gpu/Engine') 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 _state; private readonly DrawState _drawState; + private bool _topologySet; private bool _instancedDrawPending; private bool _instancedIndexed; @@ -43,6 +44,14 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed _drawState = drawState; } + /// + /// Marks the entire state as dirty, forcing a full host state update before the next draw. + /// + public void ForceStateDirty() + { + _topologySet = false; + } + /// /// Pushes four 8-bit index buffer elements. /// @@ -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 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 /// public void ForceStateDirty() { + _drawManager.ForceStateDirty(); _stateUpdater.SetAllDirty(); } -- cgit v1.2.3