From 32764f95602611e9daa50362330d760e8ed83fda Mon Sep 17 00:00:00 2001 From: gdkchan Date: Sun, 29 Dec 2019 20:26:37 -0300 Subject: Add XML documentation to Ryujinx.Graphics.Gpu.Image --- Ryujinx.Graphics.Gpu/Image/TextureManager.cs | 159 +++++++++++++++++++++++++-- 1 file changed, 150 insertions(+), 9 deletions(-) (limited to 'Ryujinx.Graphics.Gpu/Image/TextureManager.cs') diff --git a/Ryujinx.Graphics.Gpu/Image/TextureManager.cs b/Ryujinx.Graphics.Gpu/Image/TextureManager.cs index 6e1b8c60..4f6d5e58 100644 --- a/Ryujinx.Graphics.Gpu/Image/TextureManager.cs +++ b/Ryujinx.Graphics.Gpu/Image/TextureManager.cs @@ -8,28 +8,37 @@ using System; namespace Ryujinx.Graphics.Gpu.Image { + /// + /// Texture manager. + /// class TextureManager { private const int OverlapsBufferInitialCapacity = 10; private const int OverlapsBufferMaxCapacity = 10000; - private GpuContext _context; + private readonly GpuContext _context; - private TextureBindingsManager _cpBindingsManager; - private TextureBindingsManager _gpBindingsManager; + private readonly TextureBindingsManager _cpBindingsManager; + private readonly TextureBindingsManager _gpBindingsManager; - private Texture[] _rtColors; - private Texture _rtDepthStencil; + private readonly Texture[] _rtColors; - private ITexture[] _rtHostColors; - private ITexture _rtHostDs; + private Texture _rtDepthStencil; - private RangeList _textures; + private readonly ITexture[] _rtHostColors; + + private ITexture _rtHostDs; + + private readonly RangeList _textures; private Texture[] _textureOverlaps; - private AutoDeleteCache _cache; + private readonly AutoDeleteCache _cache; + /// + /// Constructs a new instance of the texture manager. + /// + /// The GPU context that the texture manager belongs to public TextureManager(GpuContext context) { _context = context; @@ -50,66 +59,126 @@ namespace Ryujinx.Graphics.Gpu.Image _cache = new AutoDeleteCache(); } + /// + /// Sets texture bindings on the compute pipeline. + /// + /// The texture bindings public void SetComputeTextures(TextureBindingInfo[] bindings) { _cpBindingsManager.SetTextures(0, bindings); } + /// + /// Sets texture bindings on the graphics pipeline. + /// + /// The index of the shader stage to bind the textures + /// The texture bindings public void SetGraphicsTextures(int stage, TextureBindingInfo[] bindings) { _gpBindingsManager.SetTextures(stage, bindings); } + /// + /// Sets image bindings on the compute pipeline. + /// + /// The image bindings public void SetComputeImages(TextureBindingInfo[] bindings) { _cpBindingsManager.SetImages(0, bindings); } + /// + /// Sets image bindings on the graphics pipeline. + /// + /// The index of the shader stage to bind the images + /// The image bindings public void SetGraphicsImages(int stage, TextureBindingInfo[] bindings) { _gpBindingsManager.SetImages(stage, bindings); } + /// + /// Sets the texture constant buffer index on the compute pipeline. + /// + /// The texture constant buffer index public void SetComputeTextureBufferIndex(int index) { _cpBindingsManager.SetTextureBufferIndex(index); } + /// + /// Sets the texture constant buffer index on the graphics pipeline. + /// + /// The texture constant buffer index public void SetGraphicsTextureBufferIndex(int index) { _gpBindingsManager.SetTextureBufferIndex(index); } + /// + /// Sets the current sampler pool on the compute pipeline. + /// + /// The start GPU virtual address of the sampler pool + /// The maximum ID of the sampler pool + /// The indexing type of the sampler public void SetComputeSamplerPool(ulong gpuVa, int maximumId, SamplerIndex samplerIndex) { _cpBindingsManager.SetSamplerPool(gpuVa, maximumId, samplerIndex); } + /// + /// Sets the current sampler pool on the graphics pipeline. + /// + /// The start GPU virtual address of the sampler pool + /// The maximum ID of the sampler pool + /// The indexing type of the sampler public void SetGraphicsSamplerPool(ulong gpuVa, int maximumId, SamplerIndex samplerIndex) { _gpBindingsManager.SetSamplerPool(gpuVa, maximumId, samplerIndex); } + /// + /// Sets the current texture pool on the compute pipeline. + /// + /// The start GPU virtual address of the texture pool + /// The maximum ID of the texture pool public void SetComputeTexturePool(ulong gpuVa, int maximumId) { _cpBindingsManager.SetTexturePool(gpuVa, maximumId); } + /// + /// Sets the current texture pool on the graphics pipeline. + /// + /// The start GPU virtual address of the texture pool + /// The maximum ID of the texture pool public void SetGraphicsTexturePool(ulong gpuVa, int maximumId) { _gpBindingsManager.SetTexturePool(gpuVa, maximumId); } + /// + /// Sets the render target color buffer. + /// + /// The index of the color buffer to set (up to 8) + /// The color buffer texture public void SetRenderTargetColor(int index, Texture color) { _rtColors[index] = color; } + /// + /// Sets the render target depth-stencil buffer. + /// + /// The depth-stencil buffer texture public void SetRenderTargetDepthStencil(Texture depthStencil) { _rtDepthStencil = depthStencil; } + /// + /// Commits bindings on the compute pipeline. + /// public void CommitComputeBindings() { // Every time we switch between graphics and compute work, @@ -121,6 +190,9 @@ namespace Ryujinx.Graphics.Gpu.Image _gpBindingsManager.Rebind(); } + /// + /// Commits bindings on the graphics pipeline. + /// public void CommitGraphicsBindings() { _gpBindingsManager.CommitBindings(); @@ -128,11 +200,21 @@ namespace Ryujinx.Graphics.Gpu.Image UpdateRenderTargets(); } + /// + /// Gets a texture descriptor used on the graphics pipeline. + /// + /// Current GPU state + /// Index of the shader stage where the texture is bound + /// Shader "fake" handle of the texture + /// The texture descriptor public TextureDescriptor GetGraphicsTextureDescriptor(GpuState state, int stageIndex, int handle) { return _gpBindingsManager.GetTextureDescriptor(state, stageIndex, handle); } + /// + /// Update host framebuffer attachments based on currently bound render target buffers. + /// private void UpdateRenderTargets() { bool anyChanged = false; @@ -162,6 +244,11 @@ namespace Ryujinx.Graphics.Gpu.Image } } + /// + /// Tries to find a existing texture, or create a new one if not found. + /// + /// Copy texture to find or create + /// The texture public Texture FindOrCreateTexture(CopyTexture copyTexture) { ulong address = _context.MemoryManager.Translate(copyTexture.Address.Pack()); @@ -210,6 +297,13 @@ namespace Ryujinx.Graphics.Gpu.Image return texture; } + /// + /// Tries to find a existing texture, or create a new one if not found. + /// + /// Color buffer texture to find or create + /// Number of samples in the X direction, for MSAA + /// Number of samples in the Y direction, for MSAA + /// The texture public Texture FindOrCreateTexture(RtColorState colorState, int samplesInX, int samplesInY) { ulong address = _context.MemoryManager.Translate(colorState.Address.Pack()); @@ -286,6 +380,14 @@ namespace Ryujinx.Graphics.Gpu.Image return texture; } + /// + /// Tries to find a existing texture, or create a new one if not found. + /// + /// Depth-stencil buffer texture to find or create + /// Size of the depth-stencil texture + /// Number of samples in the X direction, for MSAA + /// Number of samples in the Y direction, for MSAA + /// The texture public Texture FindOrCreateTexture(RtDepthStencilState dsState, Size3D size, int samplesInX, int samplesInY) { ulong address = _context.MemoryManager.Translate(dsState.Address.Pack()); @@ -327,6 +429,12 @@ namespace Ryujinx.Graphics.Gpu.Image return texture; } + /// + /// Tries to find a existing texture, or create a new one if not found. + /// + /// Texture information of the texture to be found or created + /// The texture search flags, defines texture comparison rules + /// The texture public Texture FindOrCreateTexture(TextureInfo info, TextureSearchFlags flags = TextureSearchFlags.None) { bool isSamplerTexture = (flags & TextureSearchFlags.Sampler) != 0; @@ -480,6 +588,9 @@ namespace Ryujinx.Graphics.Gpu.Image return texture; } + /// + /// Resizes the temporary buffer used for range list intersection results, if it has grown too much. + /// private void ShrinkOverlapsBufferIfNeeded() { if (_textureOverlaps.Length > OverlapsBufferMaxCapacity) @@ -488,6 +599,14 @@ namespace Ryujinx.Graphics.Gpu.Image } } + /// + /// Adjusts the size of the texture information for a given mipmap level, + /// based on the size of a parent texture. + /// + /// The parent texture + /// The texture information to be adjusted + /// The first level of the texture view + /// The adjusted texture information with the new size private static TextureInfo AdjustSizes(Texture parent, TextureInfo info, int firstLevel) { // When the texture is used as view of another texture, we must @@ -551,6 +670,14 @@ namespace Ryujinx.Graphics.Gpu.Image info.SwizzleA); } + + /// + /// Gets a texture creation information from texture information. + /// This can be used to create new host textures. + /// + /// Texture information + /// GPU capabilities + /// The texture creation information public static TextureCreateInfo GetCreateInfo(TextureInfo info, Capabilities caps) { FormatInfo formatInfo = info.FormatInfo; @@ -590,6 +717,9 @@ namespace Ryujinx.Graphics.Gpu.Image info.SwizzleA); } + /// + /// Flushes all the textures in the cache that have been modified since the last call. + /// public void Flush() { foreach (Texture texture in _cache) @@ -603,6 +733,11 @@ namespace Ryujinx.Graphics.Gpu.Image } } + /// + /// Flushes textures in the cache inside a given range that have been modified since the last call. + /// + /// The range start address + /// The range size public void Flush(ulong address, ulong size) { foreach (Texture texture in _cache) @@ -616,6 +751,12 @@ namespace Ryujinx.Graphics.Gpu.Image } } + /// + /// Removes a texture from the cache. + /// This only removes the texture from the internal list, not from the auto-deletion cache. + /// It may still have live references after the removal. + /// + /// The texture to be removed public void RemoveTextureFromCache(Texture texture) { _textures.Remove(texture); -- cgit v1.2.3