From 99ffc061d30c92f224c6b839290e181b6179893d Mon Sep 17 00:00:00 2001 From: riperiperi Date: Fri, 17 Jun 2022 17:09:14 +0100 Subject: Optimize Texture Binding and Shader Specialization Checks (#3399) * Changes 1 * Changes 2 * Better ModifiedSequence handling This should handle PreciseEvents properly, and simplifies a few things. * Minor changes, remove debug log * Handle stage.Info being null Hopefully fixes Catherine crash * Fix shader specialization fast texture lookup * Fix some things. * Address Feedback Part 1 * Make method static. --- Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs | 24 ++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'Ryujinx.Graphics.Gpu/Engine/Threed') diff --git a/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs b/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs index f648479b..c64c760a 100644 --- a/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs +++ b/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs @@ -201,7 +201,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed // of the shader for the new state. if (_shaderSpecState != null) { - if (!_shaderSpecState.MatchesGraphics(_channel, GetPoolState(), GetGraphicsState())) + if (!_shaderSpecState.MatchesGraphics(_channel, GetPoolState(), GetGraphicsState(), false)) { ForceShaderUpdate(); } @@ -275,7 +275,12 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed { UpdateStorageBuffers(); - _channel.TextureManager.CommitGraphicsBindings(); + if (!_channel.TextureManager.CommitGraphicsBindings(_shaderSpecState)) + { + // Shader must be reloaded. + UpdateShaderState(); + } + _channel.BufferManager.CommitGraphicsBindings(); } @@ -1150,6 +1155,9 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed return; } + int maxTextureBinding = -1; + int maxImageBinding = -1; + Span textureBindings = _channel.TextureManager.RentGraphicsTextureBindings(stage, info.Textures.Count); if (info.UsesRtLayer) @@ -1169,6 +1177,11 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed descriptor.CbufSlot, descriptor.HandleIndex, descriptor.Flags); + + if (descriptor.Binding > maxTextureBinding) + { + maxTextureBinding = descriptor.Binding; + } } TextureBindingInfo[] imageBindings = _channel.TextureManager.RentGraphicsImageBindings(stage, info.Images.Count); @@ -1187,8 +1200,15 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed descriptor.CbufSlot, descriptor.HandleIndex, descriptor.Flags); + + if (descriptor.Binding > maxImageBinding) + { + maxImageBinding = descriptor.Binding; + } } + _channel.TextureManager.SetGraphicsMaxBindings(maxTextureBinding, maxImageBinding); + _channel.BufferManager.SetGraphicsStorageBufferBindings(stage, info.SBuffers); _channel.BufferManager.SetGraphicsUniformBufferBindings(stage, info.CBuffers); } -- cgit v1.2.3