From 4a4e2f7c72301ba1dfb207f00c7c2fa0e9674223 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Tue, 31 Dec 2019 16:19:44 -0300 Subject: Add XML documentation to Ryujinx.Graphics.Gpu.Engine --- Ryujinx.Graphics.Gpu/Engine/Methods.cs | 133 ++++++++++++++++++++++++++++++++- 1 file changed, 132 insertions(+), 1 deletion(-) (limited to 'Ryujinx.Graphics.Gpu/Engine/Methods.cs') diff --git a/Ryujinx.Graphics.Gpu/Engine/Methods.cs b/Ryujinx.Graphics.Gpu/Engine/Methods.cs index 35f09ad3..0a52bee9 100644 --- a/Ryujinx.Graphics.Gpu/Engine/Methods.cs +++ b/Ryujinx.Graphics.Gpu/Engine/Methods.cs @@ -12,6 +12,9 @@ namespace Ryujinx.Graphics.Gpu.Engine { using Texture = Image.Texture; + /// + /// GPU method implementations. + /// partial class Methods { private readonly GpuContext _context; @@ -20,12 +23,23 @@ namespace Ryujinx.Graphics.Gpu.Engine private readonly ShaderProgramInfo[] _currentProgramInfo; - public BufferManager BufferManager { get; } + /// + /// GPU buffer manager. + /// + public BufferManager BufferManager { get; } + + /// + /// GPU texture manager. + /// public TextureManager TextureManager { get; } private bool _isAnyVbInstanced; private bool _vsUsesInstanceId; + /// + /// Creates a new instance of the GPU methods class. + /// + /// GPU context public Methods(GpuContext context) { _context = context; @@ -38,6 +52,10 @@ namespace Ryujinx.Graphics.Gpu.Engine TextureManager = new TextureManager(context); } + /// + /// Register callback for GPU method calls that triggers an action on the GPU. + /// + /// GPU state where the triggers will be registered public void RegisterCallbacks(GpuState state) { state.RegisterCallback(MethodOffset.LaunchDma, LaunchDma); @@ -72,6 +90,10 @@ namespace Ryujinx.Graphics.Gpu.Engine state.RegisterCallback(MethodOffset.UniformBufferBindFragment, UniformBufferBindFragment); } + /// + /// Updates host state based on the current guest GPU state. + /// + /// Guest GPU state private void UpdateState(GpuState state) { // Shaders must be the first one to be updated if modified, because @@ -175,6 +197,10 @@ namespace Ryujinx.Graphics.Gpu.Engine CommitBindings(); } + /// + /// Ensures that the bindings are visible to the host GPU. + /// This actually performs the binding using the host graphics API. + /// private void CommitBindings() { UpdateStorageBuffers(); @@ -183,6 +209,9 @@ namespace Ryujinx.Graphics.Gpu.Engine TextureManager.CommitGraphicsBindings(); } + /// + /// Updates storage buffer bindings. + /// private void UpdateStorageBuffers() { for (int stage = 0; stage < _currentProgramInfo.Length; stage++) @@ -213,6 +242,11 @@ namespace Ryujinx.Graphics.Gpu.Engine } } + /// + /// Updates render targets (color and depth-stencil buffers) based on current render target state. + /// + /// Current GPU state + /// Use draw buffers information from render target control register private void UpdateRenderTargetState(GpuState state, bool useControl) { var rtControl = state.Get(MethodOffset.RtControl); @@ -267,12 +301,21 @@ namespace Ryujinx.Graphics.Gpu.Engine } } + /// + /// Checks if a render target color buffer is used. + /// + /// Color buffer information + /// True if the specified buffer is enabled/used, false otherwise private static bool IsRtEnabled(RtColorState colorState) { // Colors are disabled by writing 0 to the format. return colorState.Format != 0 && colorState.WidthOrStride != 0; } + /// + /// Updates host depth test state based on current GPU state. + /// + /// Current GPU state private void UpdateDepthTestState(GpuState state) { _context.Renderer.Pipeline.SetDepthTest(new DepthTestDescriptor( @@ -281,6 +324,10 @@ namespace Ryujinx.Graphics.Gpu.Engine state.Get(MethodOffset.DepthTestFunc))); } + /// + /// Updates host viewport transform and clipping state based on current GPU state. + /// + /// Current GPU state private void UpdateViewportTransform(GpuState state) { DepthMode depthMode = state.Get(MethodOffset.DepthMode); @@ -343,6 +390,10 @@ namespace Ryujinx.Graphics.Gpu.Engine _context.Renderer.Pipeline.SetViewports(0, viewports); } + /// + /// Updates host depth bias (also called polygon offset) state based on current GPU state. + /// + /// Current GPU state private void UpdateDepthBiasState(GpuState state) { var depthBias = state.Get(MethodOffset.DepthBiasState); @@ -360,6 +411,10 @@ namespace Ryujinx.Graphics.Gpu.Engine _context.Renderer.Pipeline.SetDepthBias(enables, factor, units, clamp); } + /// + /// Updates host stencil test state based on current GPU state. + /// + /// Current GPU state private void UpdateStencilTestState(GpuState state) { var backMasks = state.Get (MethodOffset.StencilBackMasks); @@ -413,6 +468,10 @@ namespace Ryujinx.Graphics.Gpu.Engine backMask)); } + /// + /// Updates current sampler pool address and size based on guest GPU state. + /// + /// Current GPU state private void UpdateSamplerPoolState(GpuState state) { var texturePool = state.Get(MethodOffset.TexturePoolState); @@ -427,6 +486,10 @@ namespace Ryujinx.Graphics.Gpu.Engine TextureManager.SetGraphicsSamplerPool(samplerPool.Address.Pack(), maximumId, samplerIndex); } + /// + /// Updates current texture pool address and size based on guest GPU state. + /// + /// Current GPU state private void UpdateTexturePoolState(GpuState state) { var texturePool = state.Get(MethodOffset.TexturePoolState); @@ -436,6 +499,10 @@ namespace Ryujinx.Graphics.Gpu.Engine TextureManager.SetGraphicsTextureBufferIndex(state.Get(MethodOffset.TextureBufferIndex)); } + /// + /// Updates host vertex attributes based on guest GPU state. + /// + /// Current GPU state private void UpdateVertexAttribState(GpuState state) { VertexAttribDescriptor[] vertexAttribs = new VertexAttribDescriptor[16]; @@ -460,6 +527,10 @@ namespace Ryujinx.Graphics.Gpu.Engine _context.Renderer.Pipeline.SetVertexAttribs(vertexAttribs); } + /// + /// Updates host primitive restart based on guest GPU state. + /// + /// Current GPU state private void UpdatePrimitiveRestartState(GpuState state) { PrimitiveRestartState primitiveRestart = state.Get(MethodOffset.PrimitiveRestartState); @@ -469,6 +540,10 @@ namespace Ryujinx.Graphics.Gpu.Engine primitiveRestart.Index); } + /// + /// Updates host index buffer binding based on guest GPU state. + /// + /// Current GPU state private void UpdateIndexBufferState(GpuState state) { var indexBuffer = state.Get(MethodOffset.IndexBufferState); @@ -500,6 +575,10 @@ namespace Ryujinx.Graphics.Gpu.Engine UpdateVertexBufferState(state); } + /// + /// Updates host vertex buffer bindings based on guest GPU state. + /// + /// Current GPU state private void UpdateVertexBufferState(GpuState state) { _isAnyVbInstanced = false; @@ -550,6 +629,10 @@ namespace Ryujinx.Graphics.Gpu.Engine } } + /// + /// Updates host face culling and orientation based on guest GPU state. + /// + /// Current GPU state private void UpdateFaceState(GpuState state) { var face = state.Get(MethodOffset.FaceState); @@ -559,6 +642,11 @@ namespace Ryujinx.Graphics.Gpu.Engine _context.Renderer.Pipeline.SetFrontFace(face.FrontFace); } + /// + /// Updates host render target color masks, based on guest GPU state. + /// This defines with color channels are written to each color buffer. + /// + /// Current GPU state private void UpdateRtColorMask(GpuState state) { bool rtColorMaskShared = state.Get(MethodOffset.RtColorMaskShared); @@ -582,6 +670,10 @@ namespace Ryujinx.Graphics.Gpu.Engine _context.Renderer.Pipeline.SetRenderTargetColorMasks(componentMasks); } + /// + /// Updates host render target color buffer blending state, based on guest state. + /// + /// Current GPU state private void UpdateBlendState(GpuState state) { bool blendIndependent = state.Get(MethodOffset.BlendIndependent); @@ -623,6 +715,9 @@ namespace Ryujinx.Graphics.Gpu.Engine } } + /// + /// Storage buffer address and size information. + /// private struct SbDescriptor { public uint AddressLow; @@ -636,6 +731,10 @@ namespace Ryujinx.Graphics.Gpu.Engine } } + /// + /// Updates host shaders based on the guest GPU state. + /// + /// Current GPU state private void UpdateShaderState(GpuState state) { ShaderAddresses addresses = new ShaderAddresses(); @@ -726,6 +825,11 @@ namespace Ryujinx.Graphics.Gpu.Engine _context.Renderer.Pipeline.SetProgram(gs.HostProgram); } + /// + /// Gets viewport transform enable. + /// + /// Current GPU state + /// Viewport transform enable public bool GetViewportTransformEnable(GpuState state) { // FIXME: We should read ViewportTransformEnable, but it seems that some games writes 0 there? @@ -734,6 +838,11 @@ namespace Ryujinx.Graphics.Gpu.Engine return true; } + /// + /// Gets texture target from a sampler type. + /// + /// Sampler type + /// Texture target value private static Target GetTarget(SamplerType type) { type &= ~(SamplerType.Indexed | SamplerType.Shadow); @@ -776,16 +885,38 @@ namespace Ryujinx.Graphics.Gpu.Engine return Target.Texture2D; } + /// + /// Issues a texture barrier. + /// This waits until previous texture writes from the GPU to finish, before + /// performing new operations with said textures. + /// + /// Current GPU state + /// Method call argument private void TextureBarrier(GpuState state, int argument) { _context.Renderer.Pipeline.TextureBarrier(); } + /// + /// Invalidates all modified textures on the cache. + /// + /// Current GPU state + /// Method call argument private void InvalidateTextures(GpuState state, int argument) { TextureManager.Flush(); } + /// + /// Issues a texture barrier. + /// This waits until previous texture writes from the GPU to finish, before + /// performing new operations with said textures. + /// This performs a per-tile wait, it is only valid if both the previous write + /// and current access has the same access patterns. + /// This may be faster than the regular barrier on tile-based rasterizers. + /// + /// + /// private void TextureBarrierTiled(GpuState state, int argument) { _context.Renderer.Pipeline.TextureBarrierTiled(); -- cgit v1.2.3