diff options
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Image/TextureManager.cs')
-rw-r--r-- | Ryujinx.Graphics.Gpu/Image/TextureManager.cs | 56 |
1 files changed, 52 insertions, 4 deletions
diff --git a/Ryujinx.Graphics.Gpu/Image/TextureManager.cs b/Ryujinx.Graphics.Gpu/Image/TextureManager.cs index a1c29291..628c3159 100644 --- a/Ryujinx.Graphics.Gpu/Image/TextureManager.cs +++ b/Ryujinx.Graphics.Gpu/Image/TextureManager.cs @@ -1,5 +1,6 @@ using Ryujinx.Graphics.GAL; using Ryujinx.Graphics.Gpu.Engine.Types; +using Ryujinx.Graphics.Gpu.Shader; using System; namespace Ryujinx.Graphics.Gpu.Image @@ -10,9 +11,11 @@ namespace Ryujinx.Graphics.Gpu.Image class TextureManager : IDisposable { private readonly GpuContext _context; + private readonly GpuChannel _channel; private readonly TextureBindingsManager _cpBindingsManager; private readonly TextureBindingsManager _gpBindingsManager; + private readonly TexturePoolCache _texturePoolCache; private readonly Texture[] _rtColors; private readonly ITexture[] _rtHostColors; @@ -35,6 +38,7 @@ namespace Ryujinx.Graphics.Gpu.Image public TextureManager(GpuContext context, GpuChannel channel) { _context = context; + _channel = channel; TexturePoolCache texturePoolCache = new TexturePoolCache(context); @@ -43,6 +47,7 @@ namespace Ryujinx.Graphics.Gpu.Image _cpBindingsManager = new TextureBindingsManager(context, channel, texturePoolCache, scales, isCompute: true); _gpBindingsManager = new TextureBindingsManager(context, channel, texturePoolCache, scales, isCompute: false); + _texturePoolCache = texturePoolCache; _rtColors = new Texture[Constants.TotalRenderTargets]; _rtHostColors = new ITexture[Constants.TotalRenderTargets]; @@ -100,6 +105,16 @@ namespace Ryujinx.Graphics.Gpu.Image } /// <summary> + /// Sets the max binding indexes on the compute pipeline. + /// </summary> + /// <param name="maxTextureBinding">The maximum texture binding</param> + /// <param name="maxImageBinding">The maximum image binding</param> + public void SetComputeMaxBindings(int maxTextureBinding, int maxImageBinding) + { + _cpBindingsManager.SetMaxBindings(maxTextureBinding, maxImageBinding); + } + + /// <summary> /// Sets the texture constant buffer index on the graphics pipeline. /// </summary> /// <param name="index">The texture constant buffer index</param> @@ -109,6 +124,16 @@ namespace Ryujinx.Graphics.Gpu.Image } /// <summary> + /// Sets the max binding indexes on the graphics pipeline. + /// </summary> + /// <param name="maxTextureBinding">The maximum texture binding</param> + /// <param name="maxImageBinding">The maximum image binding</param> + public void SetGraphicsMaxBindings(int maxTextureBinding, int maxImageBinding) + { + _gpBindingsManager.SetMaxBindings(maxTextureBinding, maxImageBinding); + } + + /// <summary> /// Sets the current sampler pool on the compute pipeline. /// </summary> /// <param name="gpuVa">The start GPU virtual address of the sampler pool</param> @@ -335,25 +360,48 @@ namespace Ryujinx.Graphics.Gpu.Image /// <summary> /// Commits bindings on the compute pipeline. /// </summary> - public void CommitComputeBindings() + /// <param name="specState">Specialization state for the bound shader</param> + /// <returns>True if all bound textures match the current shader specialization state, false otherwise</returns> + public bool CommitComputeBindings(ShaderSpecializationState specState) { // Every time we switch between graphics and compute work, // we must rebind everything. // Since compute work happens less often, we always do that // before and after the compute dispatch. _cpBindingsManager.Rebind(); - _cpBindingsManager.CommitBindings(); + bool result = _cpBindingsManager.CommitBindings(specState); _gpBindingsManager.Rebind(); + + return result; } /// <summary> /// Commits bindings on the graphics pipeline. /// </summary> - public void CommitGraphicsBindings() + /// <param name="specState">Specialization state for the bound shader</param> + /// <returns>True if all bound textures match the current shader specialization state, false otherwise</returns> + public bool CommitGraphicsBindings(ShaderSpecializationState specState) { - _gpBindingsManager.CommitBindings(); + bool result = _gpBindingsManager.CommitBindings(specState); UpdateRenderTargets(); + + return result; + } + + /// <summary> + /// Returns a texture pool from the cache, with the given address and maximum id. + /// </summary> + /// <param name="poolGpuVa">GPU virtual address of the texture pool</param> + /// <param name="maximumId">Maximum ID of the texture pool</param> + /// <returns>The texture pool</returns> + public TexturePool GetTexturePool(ulong poolGpuVa, int maximumId) + { + ulong poolAddress = _channel.MemoryManager.Translate(poolGpuVa); + + TexturePool texturePool = _texturePoolCache.FindOrCreate(_channel, poolAddress, maximumId); + + return texturePool; } /// <summary> |