diff --git a/Ryujinx.Graphics.Gpu/State/BlendState.cs b/Ryujinx.Graphics.Gpu/State/BlendState.cs index a98f2b03..609bcc29 100644 --- a/Ryujinx.Graphics.Gpu/State/BlendState.cs +++ b/Ryujinx.Graphics.Gpu/State/BlendState.cs @@ -2,6 +2,9 @@ using Ryujinx.Graphics.GAL; namespace Ryujinx.Graphics.Gpu.State { + /// + /// Color buffer blending parameters. + /// struct BlendState { public Boolean32 SeparateAlpha; diff --git a/Ryujinx.Graphics.Gpu/State/BlendStateCommon.cs b/Ryujinx.Graphics.Gpu/State/BlendStateCommon.cs index 16584531..a11cd5b1 100644 --- a/Ryujinx.Graphics.Gpu/State/BlendStateCommon.cs +++ b/Ryujinx.Graphics.Gpu/State/BlendStateCommon.cs @@ -2,6 +2,9 @@ using Ryujinx.Graphics.GAL; namespace Ryujinx.Graphics.Gpu.State { + /// + /// Color buffer blending parameters, shared by all color buffers. + /// struct BlendStateCommon { public Boolean32 SeparateAlpha; diff --git a/Ryujinx.Graphics.Gpu/State/Boolean32.cs b/Ryujinx.Graphics.Gpu/State/Boolean32.cs index 3db912d4..ff701d9e 100644 --- a/Ryujinx.Graphics.Gpu/State/Boolean32.cs +++ b/Ryujinx.Graphics.Gpu/State/Boolean32.cs @@ -1,5 +1,8 @@ namespace Ryujinx.Graphics.Gpu.State { + /// + /// Boolean value, stored as a 32-bits integer in memory. + /// struct Boolean32 { private uint _value; diff --git a/Ryujinx.Graphics.Gpu/State/ClearColors.cs b/Ryujinx.Graphics.Gpu/State/ClearColors.cs index 584c4791..b9f7b684 100644 --- a/Ryujinx.Graphics.Gpu/State/ClearColors.cs +++ b/Ryujinx.Graphics.Gpu/State/ClearColors.cs @@ -1,5 +1,8 @@ namespace Ryujinx.Graphics.Gpu.State { + /// + /// Color buffer clear color. + /// struct ClearColors { public float Red; diff --git a/Ryujinx.Graphics.Gpu/State/Condition.cs b/Ryujinx.Graphics.Gpu/State/Condition.cs index 41cce519..5afdbe3e 100644 --- a/Ryujinx.Graphics.Gpu/State/Condition.cs +++ b/Ryujinx.Graphics.Gpu/State/Condition.cs @@ -1,5 +1,8 @@ namespace Ryujinx.Graphics.Gpu.State { + /// + /// Condition for conditional rendering. + /// enum Condition { Never, diff --git a/Ryujinx.Graphics.Gpu/State/ConditionState.cs b/Ryujinx.Graphics.Gpu/State/ConditionState.cs index 24302c60..bad266d9 100644 --- a/Ryujinx.Graphics.Gpu/State/ConditionState.cs +++ b/Ryujinx.Graphics.Gpu/State/ConditionState.cs @@ -1,5 +1,8 @@ namespace Ryujinx.Graphics.Gpu.State { + /// + /// Condition parameters for conditional rendering. + /// struct ConditionState { public GpuVa Address; diff --git a/Ryujinx.Graphics.Gpu/State/CopyBufferParams.cs b/Ryujinx.Graphics.Gpu/State/CopyBufferParams.cs index 2876dedd..7393c969 100644 --- a/Ryujinx.Graphics.Gpu/State/CopyBufferParams.cs +++ b/Ryujinx.Graphics.Gpu/State/CopyBufferParams.cs @@ -1,5 +1,8 @@ namespace Ryujinx.Graphics.Gpu.State { + /// + /// Buffer to buffer copy parameters. + /// struct CopyBufferParams { public GpuVa SrcAddress; diff --git a/Ryujinx.Graphics.Gpu/State/CopyBufferSwizzle.cs b/Ryujinx.Graphics.Gpu/State/CopyBufferSwizzle.cs index 24071372..5b3d7076 100644 --- a/Ryujinx.Graphics.Gpu/State/CopyBufferSwizzle.cs +++ b/Ryujinx.Graphics.Gpu/State/CopyBufferSwizzle.cs @@ -1,19 +1,34 @@ namespace Ryujinx.Graphics.Gpu.State { + /// + /// Buffer to buffer copy vector swizzle parameters. + /// struct CopyBufferSwizzle { public uint Swizzle; + /// + /// Unpacks the size of each vector component of the copy. + /// + /// Vector component size public int UnpackComponentSize() { return (int)((Swizzle >> 16) & 3) + 1; } + /// + /// Unpacks the number of components of the source vector of the copy. + /// + /// Number of vector components public int UnpackSrcComponentsCount() { return (int)((Swizzle >> 20) & 7) + 1; } + /// + /// Unpacks the number of components of the destination vector of the copy. + /// + /// Number of vector components public int UnpackDstComponentsCount() { return (int)((Swizzle >> 24) & 7) + 1; diff --git a/Ryujinx.Graphics.Gpu/State/CopyBufferTexture.cs b/Ryujinx.Graphics.Gpu/State/CopyBufferTexture.cs index cb63c607..98d113a3 100644 --- a/Ryujinx.Graphics.Gpu/State/CopyBufferTexture.cs +++ b/Ryujinx.Graphics.Gpu/State/CopyBufferTexture.cs @@ -1,5 +1,8 @@ namespace Ryujinx.Graphics.Gpu.State { + /// + /// Buffer to texture copy parameters. + /// struct CopyBufferTexture { public MemoryLayout MemoryLayout; diff --git a/Ryujinx.Graphics.Gpu/State/CopyRegion.cs b/Ryujinx.Graphics.Gpu/State/CopyRegion.cs index cad9a5db..a256594b 100644 --- a/Ryujinx.Graphics.Gpu/State/CopyRegion.cs +++ b/Ryujinx.Graphics.Gpu/State/CopyRegion.cs @@ -1,5 +1,8 @@ namespace Ryujinx.Graphics.Gpu.State { + /// + /// Texture copy region. + /// struct CopyRegion { public int DstX; diff --git a/Ryujinx.Graphics.Gpu/State/CopyTexture.cs b/Ryujinx.Graphics.Gpu/State/CopyTexture.cs index 83e7e430..df723d0d 100644 --- a/Ryujinx.Graphics.Gpu/State/CopyTexture.cs +++ b/Ryujinx.Graphics.Gpu/State/CopyTexture.cs @@ -1,5 +1,8 @@ namespace Ryujinx.Graphics.Gpu.State { + /// + /// Texture to texture (with optional resizing) copy parameters. + /// struct CopyTexture { public RtFormat Format; diff --git a/Ryujinx.Graphics.Gpu/State/CopyTextureControl.cs b/Ryujinx.Graphics.Gpu/State/CopyTextureControl.cs index c49cf276..cfc64fc4 100644 --- a/Ryujinx.Graphics.Gpu/State/CopyTextureControl.cs +++ b/Ryujinx.Graphics.Gpu/State/CopyTextureControl.cs @@ -1,5 +1,8 @@ namespace Ryujinx.Graphics.Gpu.State { + /// + /// Texture to texture copy control. + /// struct CopyTextureControl { public uint Packed; diff --git a/Ryujinx.Graphics.Gpu/State/DepthBiasState.cs b/Ryujinx.Graphics.Gpu/State/DepthBiasState.cs index 45d9c93f..75270625 100644 --- a/Ryujinx.Graphics.Gpu/State/DepthBiasState.cs +++ b/Ryujinx.Graphics.Gpu/State/DepthBiasState.cs @@ -1,5 +1,8 @@ namespace Ryujinx.Graphics.Gpu.State { + /// + /// Depth bias (also called polygon offset) parameters. + /// struct DepthBiasState { public Boolean32 PointEnable; diff --git a/Ryujinx.Graphics.Gpu/State/FaceState.cs b/Ryujinx.Graphics.Gpu/State/FaceState.cs index 2e62968c..10dec3b9 100644 --- a/Ryujinx.Graphics.Gpu/State/FaceState.cs +++ b/Ryujinx.Graphics.Gpu/State/FaceState.cs @@ -2,6 +2,9 @@ using Ryujinx.Graphics.GAL; namespace Ryujinx.Graphics.Gpu.State { + /// + /// Face culling and orientation parameters. + /// struct FaceState { public Boolean32 CullEnable; diff --git a/Ryujinx.Graphics.Gpu/State/GpuState.cs b/Ryujinx.Graphics.Gpu/State/GpuState.cs index 509f6715..8f851bca 100644 --- a/Ryujinx.Graphics.Gpu/State/GpuState.cs +++ b/Ryujinx.Graphics.Gpu/State/GpuState.cs @@ -3,6 +3,9 @@ using System.Runtime.InteropServices; namespace Ryujinx.Graphics.Gpu.State { + /// + /// GPU state. + /// class GpuState { private const int RegistersCount = 0xe00; @@ -11,6 +14,9 @@ namespace Ryujinx.Graphics.Gpu.State private int[] _backingMemory; + /// + /// GPU register information. + /// private struct Register { public MethodCallback Callback; @@ -25,6 +31,9 @@ namespace Ryujinx.Graphics.Gpu.State private Register[] _registers; + /// + /// Creates a new instance of the GPU state. + /// public GpuState() { _backingMemory = new int[RegistersCount]; @@ -56,6 +65,10 @@ namespace Ryujinx.Graphics.Gpu.State InitializeDefaultState(); } + /// + /// Calls a GPU method, using this state. + /// + /// The GPU method to be called public void CallMethod(MethodParams meth) { Register register = _registers[meth.Method]; @@ -67,24 +80,31 @@ namespace Ryujinx.Graphics.Gpu.State _backingMemory[meth.Method] = meth.Argument; - MethodCallback callback = register.Callback; - - if (callback != null) - { - callback(this, meth.Argument); - } + register.Callback?.Invoke(this, meth.Argument); } + /// + /// Reads data from a GPU register at the given offset. + /// + /// Offset to be read + /// Data at the register public int Read(int offset) { return _backingMemory[offset]; } + /// + /// Writes a offset value at the uniform buffer offset register. + /// + /// The offset to be written public void SetUniformBufferOffset(int offset) { _backingMemory[(int)MethodOffset.UniformBufferState + 3] = offset; } + /// + /// Initializes registers with the default state. + /// private void InitializeDefaultState() { // Depth ranges. @@ -107,6 +127,12 @@ namespace Ryujinx.Graphics.Gpu.State } } + /// + /// Registers a callback that is called every time a GPU method, or methods are called. + /// + /// Offset of the method + /// Word count of the methods region + /// Calllback to be called public void RegisterCallback(MethodOffset offset, int count, MethodCallback callback) { for (int index = 0; index < count; index++) @@ -115,11 +141,21 @@ namespace Ryujinx.Graphics.Gpu.State } } + /// + /// Registers a callback that is called every time a GPU method is called. + /// + /// Offset of the method + /// Calllback to be called public void RegisterCallback(MethodOffset offset, MethodCallback callback) { _registers[(int)offset].Callback = callback; } + /// + /// Checks if a given register has been modified since the last call to this method. + /// + /// Register offset + /// True if modified, false otherwise public bool QueryModified(MethodOffset offset) { bool modified = _registers[(int)offset].Modified; @@ -129,6 +165,12 @@ namespace Ryujinx.Graphics.Gpu.State return modified; } + /// + /// Checks if two registers have been modified since the last call to this method. + /// + /// First register offset + /// Second register offset + /// True if any register was modified, false otherwise public bool QueryModified(MethodOffset m1, MethodOffset m2) { bool modified = _registers[(int)m1].Modified || @@ -140,6 +182,13 @@ namespace Ryujinx.Graphics.Gpu.State return modified; } + /// + /// Checks if two registers have been modified since the last call to this method. + /// + /// First register offset + /// Second register offset + /// Third register offset + /// True if any register was modified, false otherwise public bool QueryModified(MethodOffset m1, MethodOffset m2, MethodOffset m3) { bool modified = _registers[(int)m1].Modified || @@ -153,6 +202,14 @@ namespace Ryujinx.Graphics.Gpu.State return modified; } + /// + /// Checks if two registers have been modified since the last call to this method. + /// + /// First register offset + /// Second register offset + /// Third register offset + /// Fourth register offset + /// True if any register was modified, false otherwise public bool QueryModified(MethodOffset m1, MethodOffset m2, MethodOffset m3, MethodOffset m4) { bool modified = _registers[(int)m1].Modified || @@ -168,6 +225,15 @@ namespace Ryujinx.Graphics.Gpu.State return modified; } + /// + /// Checks if two registers have been modified since the last call to this method. + /// + /// First register offset + /// Second register offset + /// Third register offset + /// Fourth register offset + /// Fifth register offset + /// True if any register was modified, false otherwise public bool QueryModified( MethodOffset m1, MethodOffset m2, @@ -190,6 +256,13 @@ namespace Ryujinx.Graphics.Gpu.State return modified; } + /// + /// Gets indexed data from a given register offset. + /// + /// Type of the data + /// Register offset + /// Index for indexed data + /// The data at the specified location public T Get(MethodOffset offset, int index) where T : struct { Register register = _registers[(int)offset]; @@ -202,6 +275,12 @@ namespace Ryujinx.Graphics.Gpu.State return Get(offset + index * register.Stride); } + /// + /// Gets data from a given register offset. + /// + /// Type of the data + /// Register offset + /// The data at the specified location public T Get(MethodOffset offset) where T : struct { return MemoryMarshal.Cast(_backingMemory.AsSpan().Slice((int)offset))[0]; diff --git a/Ryujinx.Graphics.Gpu/State/GpuStateTable.cs b/Ryujinx.Graphics.Gpu/State/GpuStateTable.cs index 268b1fdc..db8d141e 100644 --- a/Ryujinx.Graphics.Gpu/State/GpuStateTable.cs +++ b/Ryujinx.Graphics.Gpu/State/GpuStateTable.cs @@ -4,15 +4,37 @@ using System.Runtime.InteropServices; namespace Ryujinx.Graphics.Gpu.State { + /// + /// GPU State item sizes table. + /// static class GpuStateTable { + /// + /// GPU state table item, with size for structures, and count for indexed state data. + /// public struct TableItem { + /// + /// Offset of the data. + /// public MethodOffset Offset { get; } - public int Size { get; } + /// + /// Size in words. + /// + public int Size { get; } + + /// + /// Count for indexed data, or 1 if not indexed. + /// public int Count { get; } + /// + /// Constructs the table item structure. + /// + /// Data offset + /// Data type + /// Data count, for indexed data public TableItem(MethodOffset offset, Type type, int count) { int sizeInBytes = Marshal.SizeOf(type); @@ -25,6 +47,9 @@ namespace Ryujinx.Graphics.Gpu.State } } + /// + /// Table of GPU state structure sizes and counts. + /// public static TableItem[] Table = new TableItem[] { new TableItem(MethodOffset.RtColorState, typeof(RtColorState), 8), diff --git a/Ryujinx.Graphics.Gpu/State/GpuVa.cs b/Ryujinx.Graphics.Gpu/State/GpuVa.cs index 4bb56a10..d2ae5eb9 100644 --- a/Ryujinx.Graphics.Gpu/State/GpuVa.cs +++ b/Ryujinx.Graphics.Gpu/State/GpuVa.cs @@ -1,10 +1,17 @@ namespace Ryujinx.Graphics.Gpu.State { + /// + /// Split GPU virtual address. + /// struct GpuVa { public uint High; public uint Low; + /// + /// Packs the split address into a 64-bits address value. + /// + /// public ulong Pack() { return Low | ((ulong)High << 32); diff --git a/Ryujinx.Graphics.Gpu/State/IndexBufferState.cs b/Ryujinx.Graphics.Gpu/State/IndexBufferState.cs index 8a07bb52..b7868bb9 100644 --- a/Ryujinx.Graphics.Gpu/State/IndexBufferState.cs +++ b/Ryujinx.Graphics.Gpu/State/IndexBufferState.cs @@ -2,6 +2,10 @@ using Ryujinx.Graphics.GAL; namespace Ryujinx.Graphics.Gpu.State { + /// + /// GPU index buffer state. + /// This is used on indexed draws. + /// struct IndexBufferState { public GpuVa Address; diff --git a/Ryujinx.Graphics.Gpu/State/Inline2MemoryParams.cs b/Ryujinx.Graphics.Gpu/State/Inline2MemoryParams.cs index 10d24900..45555be2 100644 --- a/Ryujinx.Graphics.Gpu/State/Inline2MemoryParams.cs +++ b/Ryujinx.Graphics.Gpu/State/Inline2MemoryParams.cs @@ -1,5 +1,8 @@ namespace Ryujinx.Graphics.Gpu.State { + /// + /// Inline-to-memory copy parameters. + /// struct Inline2MemoryParams { public int LineLengthIn; diff --git a/Ryujinx.Graphics.Gpu/State/MemoryLayout.cs b/Ryujinx.Graphics.Gpu/State/MemoryLayout.cs index 8e53a36a..9b72b097 100644 --- a/Ryujinx.Graphics.Gpu/State/MemoryLayout.cs +++ b/Ryujinx.Graphics.Gpu/State/MemoryLayout.cs @@ -1,5 +1,8 @@ namespace Ryujinx.Graphics.Gpu.State { + /// + /// Memory layout parameters, for block linear textures. + /// struct MemoryLayout { public uint Packed; diff --git a/Ryujinx.Graphics.Gpu/State/MethodOffset.cs b/Ryujinx.Graphics.Gpu/State/MethodOffset.cs index 5e43eb51..ddc17d15 100644 --- a/Ryujinx.Graphics.Gpu/State/MethodOffset.cs +++ b/Ryujinx.Graphics.Gpu/State/MethodOffset.cs @@ -1,5 +1,8 @@ namespace Ryujinx.Graphics.Gpu.State { + /// + /// GPU method offset. + /// enum MethodOffset { I2mParams = 0x60, diff --git a/Ryujinx.Graphics.Gpu/State/PoolState.cs b/Ryujinx.Graphics.Gpu/State/PoolState.cs index 3d51eb7e..eeb56918 100644 --- a/Ryujinx.Graphics.Gpu/State/PoolState.cs +++ b/Ryujinx.Graphics.Gpu/State/PoolState.cs @@ -1,5 +1,8 @@ namespace Ryujinx.Graphics.Gpu.State { + /// + /// Texture or sampler pool state. + /// struct PoolState { public GpuVa Address; diff --git a/Ryujinx.Graphics.Gpu/State/PrimitiveRestartState.cs b/Ryujinx.Graphics.Gpu/State/PrimitiveRestartState.cs index 0b4e1024..96795083 100644 --- a/Ryujinx.Graphics.Gpu/State/PrimitiveRestartState.cs +++ b/Ryujinx.Graphics.Gpu/State/PrimitiveRestartState.cs @@ -1,5 +1,8 @@ namespace Ryujinx.Graphics.Gpu.State { + /// + /// Primitive restart state. + /// struct PrimitiveRestartState { public Boolean32 Enable; diff --git a/Ryujinx.Graphics.Gpu/State/PrimitiveTopology.cs b/Ryujinx.Graphics.Gpu/State/PrimitiveTopology.cs index 02df9ac1..bb9eb5a7 100644 --- a/Ryujinx.Graphics.Gpu/State/PrimitiveTopology.cs +++ b/Ryujinx.Graphics.Gpu/State/PrimitiveTopology.cs @@ -2,6 +2,9 @@ using Ryujinx.Graphics.GAL; namespace Ryujinx.Graphics.Gpu.State { + /// + /// Draw primitive type. + /// enum PrimitiveType { Points, @@ -23,28 +26,32 @@ namespace Ryujinx.Graphics.Gpu.State static class PrimitiveTypeConverter { - public static PrimitiveTopology Convert(this PrimitiveType topology) + /// + /// Converts the primitive type into something that can be used with the host API. + /// + /// The primitive type to convert + /// A host compatible enum value + public static PrimitiveTopology Convert(this PrimitiveType type) { - switch (topology) + return type switch { - case PrimitiveType.Points: return PrimitiveTopology.Points; - case PrimitiveType.Lines: return PrimitiveTopology.Lines; - case PrimitiveType.LineLoop: return PrimitiveTopology.LineLoop; - case PrimitiveType.LineStrip: return PrimitiveTopology.LineStrip; - case PrimitiveType.Triangles: return PrimitiveTopology.Triangles; - case PrimitiveType.TriangleStrip: return PrimitiveTopology.TriangleStrip; - case PrimitiveType.TriangleFan: return PrimitiveTopology.TriangleFan; - case PrimitiveType.Quads: return PrimitiveTopology.Quads; - case PrimitiveType.QuadStrip: return PrimitiveTopology.QuadStrip; - case PrimitiveType.Polygon: return PrimitiveTopology.Polygon; - case PrimitiveType.LinesAdjacency: return PrimitiveTopology.LinesAdjacency; - case PrimitiveType.LineStripAdjacency: return PrimitiveTopology.LineStripAdjacency; - case PrimitiveType.TrianglesAdjacency: return PrimitiveTopology.TrianglesAdjacency; - case PrimitiveType.TriangleStripAdjacency: return PrimitiveTopology.TriangleStripAdjacency; - case PrimitiveType.Patches: return PrimitiveTopology.Patches; - } - - return PrimitiveTopology.Triangles; + PrimitiveType.Points => PrimitiveTopology.Points, + PrimitiveType.Lines => PrimitiveTopology.Lines, + PrimitiveType.LineLoop => PrimitiveTopology.LineLoop, + PrimitiveType.LineStrip => PrimitiveTopology.LineStrip, + PrimitiveType.Triangles => PrimitiveTopology.Triangles, + PrimitiveType.TriangleStrip => PrimitiveTopology.TriangleStrip, + PrimitiveType.TriangleFan => PrimitiveTopology.TriangleFan, + PrimitiveType.Quads => PrimitiveTopology.Quads, + PrimitiveType.QuadStrip => PrimitiveTopology.QuadStrip, + PrimitiveType.Polygon => PrimitiveTopology.Polygon, + PrimitiveType.LinesAdjacency => PrimitiveTopology.LinesAdjacency, + PrimitiveType.LineStripAdjacency => PrimitiveTopology.LineStripAdjacency, + PrimitiveType.TrianglesAdjacency => PrimitiveTopology.TrianglesAdjacency, + PrimitiveType.TriangleStripAdjacency => PrimitiveTopology.TriangleStripAdjacency, + PrimitiveType.Patches => PrimitiveTopology.Patches, + _ => PrimitiveTopology.Triangles + }; } } } \ No newline at end of file diff --git a/Ryujinx.Graphics.Gpu/State/ReportCounterType.cs b/Ryujinx.Graphics.Gpu/State/ReportCounterType.cs index 38a0de71..cface55d 100644 --- a/Ryujinx.Graphics.Gpu/State/ReportCounterType.cs +++ b/Ryujinx.Graphics.Gpu/State/ReportCounterType.cs @@ -1,5 +1,8 @@ namespace Ryujinx.Graphics.Gpu.State { + /// + /// Counter type for GPU counter reporting. + /// enum ReportCounterType { Zero = 0, diff --git a/Ryujinx.Graphics.Gpu/State/ReportMode.cs b/Ryujinx.Graphics.Gpu/State/ReportMode.cs index 84af3d75..e557f4ca 100644 --- a/Ryujinx.Graphics.Gpu/State/ReportMode.cs +++ b/Ryujinx.Graphics.Gpu/State/ReportMode.cs @@ -1,5 +1,8 @@ namespace Ryujinx.Graphics.Gpu.State { + /// + /// GPU counter report mode. + /// enum ReportMode { Semaphore = 0, diff --git a/Ryujinx.Graphics.Gpu/State/ReportState.cs b/Ryujinx.Graphics.Gpu/State/ReportState.cs index 212281aa..7430ea31 100644 --- a/Ryujinx.Graphics.Gpu/State/ReportState.cs +++ b/Ryujinx.Graphics.Gpu/State/ReportState.cs @@ -1,5 +1,8 @@ namespace Ryujinx.Graphics.Gpu.State { + /// + /// GPU counter report state. + /// struct ReportState { public GpuVa Address; diff --git a/Ryujinx.Graphics.Gpu/State/ResetCounterType.cs b/Ryujinx.Graphics.Gpu/State/ResetCounterType.cs index 49b3b6da..aaf575e1 100644 --- a/Ryujinx.Graphics.Gpu/State/ResetCounterType.cs +++ b/Ryujinx.Graphics.Gpu/State/ResetCounterType.cs @@ -1,5 +1,8 @@ namespace Ryujinx.Graphics.Gpu.State { + /// + /// Counter type for GPU counter reset. + /// enum ResetCounterType { SamplesPassed = 1, diff --git a/Ryujinx.Graphics.Gpu/State/RtColorMask.cs b/Ryujinx.Graphics.Gpu/State/RtColorMask.cs index 5992673f..4aa5c331 100644 --- a/Ryujinx.Graphics.Gpu/State/RtColorMask.cs +++ b/Ryujinx.Graphics.Gpu/State/RtColorMask.cs @@ -1,24 +1,44 @@ namespace Ryujinx.Graphics.Gpu.State { + /// + /// Render target color buffer mask. + /// This defines which color channels are written to the color buffer. + /// struct RtColorMask { public uint Packed; + /// + /// Unpacks red channel enable. + /// + /// True to write the new red channel color, false to keep the old value public bool UnpackRed() { return (Packed & 0x1) != 0; } + /// + /// Unpacks green channel enable. + /// + /// True to write the new green channel color, false to keep the old value public bool UnpackGreen() { return (Packed & 0x10) != 0; } + /// + /// Unpacks blue channel enable. + /// + /// True to write the new blue channel color, false to keep the old value public bool UnpackBlue() { return (Packed & 0x100) != 0; } + /// + /// Unpacks alpha channel enable. + /// + /// True to write the new alpha channel color, false to keep the old value public bool UnpackAlpha() { return (Packed & 0x1000) != 0; diff --git a/Ryujinx.Graphics.Gpu/State/RtColorState.cs b/Ryujinx.Graphics.Gpu/State/RtColorState.cs index beec2593..9261526a 100644 --- a/Ryujinx.Graphics.Gpu/State/RtColorState.cs +++ b/Ryujinx.Graphics.Gpu/State/RtColorState.cs @@ -1,5 +1,8 @@ namespace Ryujinx.Graphics.Gpu.State { + /// + /// Render target color buffer state. + /// struct RtColorState { public GpuVa Address; diff --git a/Ryujinx.Graphics.Gpu/State/RtControl.cs b/Ryujinx.Graphics.Gpu/State/RtControl.cs index 4c6fbc34..2e28660b 100644 --- a/Ryujinx.Graphics.Gpu/State/RtControl.cs +++ b/Ryujinx.Graphics.Gpu/State/RtControl.cs @@ -1,14 +1,26 @@ namespace Ryujinx.Graphics.Gpu.State { + /// + /// Render target draw buffers control. + /// struct RtControl { public uint Packed; + /// + /// Unpacks the number of active draw buffers. + /// + /// Number of active draw buffers public int UnpackCount() { return (int)(Packed & 0xf); } + /// + /// Unpacks the color attachment index for a given draw buffer. + /// + /// Index of the draw buffer + /// Attachment index public int UnpackPermutationIndex(int index) { return (int)((Packed >> (4 + index * 3)) & 7); diff --git a/Ryujinx.Graphics.Gpu/State/RtDepthStencilState.cs b/Ryujinx.Graphics.Gpu/State/RtDepthStencilState.cs index bfa812cb..abc28fca 100644 --- a/Ryujinx.Graphics.Gpu/State/RtDepthStencilState.cs +++ b/Ryujinx.Graphics.Gpu/State/RtDepthStencilState.cs @@ -1,5 +1,8 @@ namespace Ryujinx.Graphics.Gpu.State { + /// + /// Render target depth-stencil buffer state. + /// struct RtDepthStencilState { public GpuVa Address; diff --git a/Ryujinx.Graphics.Gpu/State/RtFormat.cs b/Ryujinx.Graphics.Gpu/State/RtFormat.cs index 7f9ad63d..e6490336 100644 --- a/Ryujinx.Graphics.Gpu/State/RtFormat.cs +++ b/Ryujinx.Graphics.Gpu/State/RtFormat.cs @@ -3,6 +3,9 @@ using Ryujinx.Graphics.Gpu.Image; namespace Ryujinx.Graphics.Gpu.State { + /// + /// Render target buffer texture format. + /// enum RtFormat { D32Float = 0xa, @@ -69,73 +72,77 @@ namespace Ryujinx.Graphics.Gpu.State static class RtFormatConverter { + /// + /// Converts the render target buffer texture format to a host compatible format. + /// + /// Render target format + /// Host compatible format enum value public static FormatInfo Convert(this RtFormat format) { - switch (format) + return format switch { - case RtFormat.D32Float: return new FormatInfo(Format.D32Float, 1, 1, 4); - case RtFormat.D16Unorm: return new FormatInfo(Format.D16Unorm, 1, 1, 2); - case RtFormat.D24UnormS8Uint: return new FormatInfo(Format.D24UnormS8Uint, 1, 1, 4); - case RtFormat.D24Unorm: return new FormatInfo(Format.D24UnormS8Uint, 1, 1, 4); - case RtFormat.S8UintD24Unorm: return new FormatInfo(Format.D24UnormS8Uint, 1, 1, 4); - case RtFormat.S8Uint: return new FormatInfo(Format.S8Uint, 1, 1, 1); - case RtFormat.D32FloatS8Uint: return new FormatInfo(Format.D32FloatS8Uint, 1, 1, 8); - case RtFormat.R32G32B32A32Float: return new FormatInfo(Format.R32G32B32A32Float, 1, 1, 16); - case RtFormat.R32G32B32A32Sint: return new FormatInfo(Format.R32G32B32A32Sint, 1, 1, 16); - case RtFormat.R32G32B32A32Uint: return new FormatInfo(Format.R32G32B32A32Uint, 1, 1, 16); - case RtFormat.R32G32B32X32Float: return new FormatInfo(Format.R32G32B32A32Float, 1, 1, 16); - case RtFormat.R32G32B32X32Sint: return new FormatInfo(Format.R32G32B32A32Sint, 1, 1, 16); - case RtFormat.R32G32B32X32Uint: return new FormatInfo(Format.R32G32B32A32Uint, 1, 1, 16); - case RtFormat.R16G16B16X16Unorm: return new FormatInfo(Format.R16G16B16A16Unorm, 1, 1, 8); - case RtFormat.R16G16B16X16Snorm: return new FormatInfo(Format.R16G16B16A16Snorm, 1, 1, 8); - case RtFormat.R16G16B16X16Sint: return new FormatInfo(Format.R16G16B16A16Sint, 1, 1, 8); - case RtFormat.R16G16B16X16Uint: return new FormatInfo(Format.R16G16B16A16Uint, 1, 1, 8); - case RtFormat.R16G16B16A16Float: return new FormatInfo(Format.R16G16B16A16Float, 1, 1, 8); - case RtFormat.R32G32Float: return new FormatInfo(Format.R32G32Float, 1, 1, 8); - case RtFormat.R32G32Sint: return new FormatInfo(Format.R32G32Sint, 1, 1, 8); - case RtFormat.R32G32Uint: return new FormatInfo(Format.R32G32Uint, 1, 1, 8); - case RtFormat.R16G16B16X16Float: return new FormatInfo(Format.R16G16B16A16Float, 1, 1, 8); - case RtFormat.B8G8R8A8Unorm: return new FormatInfo(Format.B8G8R8A8Unorm, 1, 1, 4); - case RtFormat.B8G8R8A8Srgb: return new FormatInfo(Format.B8G8R8A8Srgb, 1, 1, 4); - case RtFormat.R10G10B10A2Unorm: return new FormatInfo(Format.R10G10B10A2Unorm, 1, 1, 4); - case RtFormat.R10G10B10A2Uint: return new FormatInfo(Format.R10G10B10A2Uint, 1, 1, 4); - case RtFormat.R8G8B8A8Unorm: return new FormatInfo(Format.R8G8B8A8Unorm, 1, 1, 4); - case RtFormat.R8G8B8A8Srgb: return new FormatInfo(Format.R8G8B8A8Srgb, 1, 1, 4); - case RtFormat.R8G8B8X8Snorm: return new FormatInfo(Format.R8G8B8A8Snorm, 1, 1, 4); - case RtFormat.R8G8B8X8Sint: return new FormatInfo(Format.R8G8B8A8Sint, 1, 1, 4); - case RtFormat.R8G8B8X8Uint: return new FormatInfo(Format.R8G8B8A8Uint, 1, 1, 4); - case RtFormat.R16G16Unorm: return new FormatInfo(Format.R16G16Unorm, 1, 1, 4); - case RtFormat.R16G16Snorm: return new FormatInfo(Format.R16G16Snorm, 1, 1, 4); - case RtFormat.R16G16Sint: return new FormatInfo(Format.R16G16Sint, 1, 1, 4); - case RtFormat.R16G16Uint: return new FormatInfo(Format.R16G16Uint, 1, 1, 4); - case RtFormat.R16G16Float: return new FormatInfo(Format.R16G16Float, 1, 1, 4); - case RtFormat.R11G11B10Float: return new FormatInfo(Format.R11G11B10Float, 1, 1, 4); - case RtFormat.R32Sint: return new FormatInfo(Format.R32Sint, 1, 1, 4); - case RtFormat.R32Uint: return new FormatInfo(Format.R32Uint, 1, 1, 4); - case RtFormat.R32Float: return new FormatInfo(Format.R32Float, 1, 1, 4); - case RtFormat.B8G8R8X8Unorm: return new FormatInfo(Format.B8G8R8A8Unorm, 1, 1, 4); - case RtFormat.B8G8R8X8Srgb: return new FormatInfo(Format.B8G8R8A8Srgb, 1, 1, 4); - case RtFormat.B5G6R5Unorm: return new FormatInfo(Format.B5G6R5Unorm, 1, 1, 2); - case RtFormat.B5G5R5A1Unorm: return new FormatInfo(Format.B5G5R5A1Unorm, 1, 1, 2); - case RtFormat.R8G8Unorm: return new FormatInfo(Format.R8G8Unorm, 1, 1, 2); - case RtFormat.R8G8Snorm: return new FormatInfo(Format.R8G8Snorm, 1, 1, 2); - case RtFormat.R8G8Sint: return new FormatInfo(Format.R8G8Sint, 1, 1, 2); - case RtFormat.R8G8Uint: return new FormatInfo(Format.R8G8Uint, 1, 1, 2); - case RtFormat.R16Unorm: return new FormatInfo(Format.R16Unorm, 1, 1, 2); - case RtFormat.R16Snorm: return new FormatInfo(Format.R16Snorm, 1, 1, 2); - case RtFormat.R16Sint: return new FormatInfo(Format.R16Sint, 1, 1, 2); - case RtFormat.R16Uint: return new FormatInfo(Format.R16Uint, 1, 1, 2); - case RtFormat.R16Float: return new FormatInfo(Format.R16Float, 1, 1, 2); - case RtFormat.R8Unorm: return new FormatInfo(Format.R8Unorm, 1, 1, 1); - case RtFormat.R8Snorm: return new FormatInfo(Format.R8Snorm, 1, 1, 1); - case RtFormat.R8Sint: return new FormatInfo(Format.R8Sint, 1, 1, 1); - case RtFormat.R8Uint: return new FormatInfo(Format.R8Uint, 1, 1, 1); - case RtFormat.B5G5R5X1Unorm: return new FormatInfo(Format.B5G5R5X1Unorm, 1, 1, 2); - case RtFormat.R8G8B8X8Unorm: return new FormatInfo(Format.R8G8B8A8Unorm, 1, 1, 4); - case RtFormat.R8G8B8X8Srgb: return new FormatInfo(Format.R8G8B8A8Srgb, 1, 1, 4); - } - - return FormatInfo.Default; + RtFormat.D32Float => new FormatInfo(Format.D32Float, 1, 1, 4), + RtFormat.D16Unorm => new FormatInfo(Format.D16Unorm, 1, 1, 2), + RtFormat.D24UnormS8Uint => new FormatInfo(Format.D24UnormS8Uint, 1, 1, 4), + RtFormat.D24Unorm => new FormatInfo(Format.D24UnormS8Uint, 1, 1, 4), + RtFormat.S8UintD24Unorm => new FormatInfo(Format.D24UnormS8Uint, 1, 1, 4), + RtFormat.S8Uint => new FormatInfo(Format.S8Uint, 1, 1, 1), + RtFormat.D32FloatS8Uint => new FormatInfo(Format.D32FloatS8Uint, 1, 1, 8), + RtFormat.R32G32B32A32Float => new FormatInfo(Format.R32G32B32A32Float, 1, 1, 16), + RtFormat.R32G32B32A32Sint => new FormatInfo(Format.R32G32B32A32Sint, 1, 1, 16), + RtFormat.R32G32B32A32Uint => new FormatInfo(Format.R32G32B32A32Uint, 1, 1, 16), + RtFormat.R32G32B32X32Float => new FormatInfo(Format.R32G32B32A32Float, 1, 1, 16), + RtFormat.R32G32B32X32Sint => new FormatInfo(Format.R32G32B32A32Sint, 1, 1, 16), + RtFormat.R32G32B32X32Uint => new FormatInfo(Format.R32G32B32A32Uint, 1, 1, 16), + RtFormat.R16G16B16X16Unorm => new FormatInfo(Format.R16G16B16A16Unorm, 1, 1, 8), + RtFormat.R16G16B16X16Snorm => new FormatInfo(Format.R16G16B16A16Snorm, 1, 1, 8), + RtFormat.R16G16B16X16Sint => new FormatInfo(Format.R16G16B16A16Sint, 1, 1, 8), + RtFormat.R16G16B16X16Uint => new FormatInfo(Format.R16G16B16A16Uint, 1, 1, 8), + RtFormat.R16G16B16A16Float => new FormatInfo(Format.R16G16B16A16Float, 1, 1, 8), + RtFormat.R32G32Float => new FormatInfo(Format.R32G32Float, 1, 1, 8), + RtFormat.R32G32Sint => new FormatInfo(Format.R32G32Sint, 1, 1, 8), + RtFormat.R32G32Uint => new FormatInfo(Format.R32G32Uint, 1, 1, 8), + RtFormat.R16G16B16X16Float => new FormatInfo(Format.R16G16B16A16Float, 1, 1, 8), + RtFormat.B8G8R8A8Unorm => new FormatInfo(Format.B8G8R8A8Unorm, 1, 1, 4), + RtFormat.B8G8R8A8Srgb => new FormatInfo(Format.B8G8R8A8Srgb, 1, 1, 4), + RtFormat.R10G10B10A2Unorm => new FormatInfo(Format.R10G10B10A2Unorm, 1, 1, 4), + RtFormat.R10G10B10A2Uint => new FormatInfo(Format.R10G10B10A2Uint, 1, 1, 4), + RtFormat.R8G8B8A8Unorm => new FormatInfo(Format.R8G8B8A8Unorm, 1, 1, 4), + RtFormat.R8G8B8A8Srgb => new FormatInfo(Format.R8G8B8A8Srgb, 1, 1, 4), + RtFormat.R8G8B8X8Snorm => new FormatInfo(Format.R8G8B8A8Snorm, 1, 1, 4), + RtFormat.R8G8B8X8Sint => new FormatInfo(Format.R8G8B8A8Sint, 1, 1, 4), + RtFormat.R8G8B8X8Uint => new FormatInfo(Format.R8G8B8A8Uint, 1, 1, 4), + RtFormat.R16G16Unorm => new FormatInfo(Format.R16G16Unorm, 1, 1, 4), + RtFormat.R16G16Snorm => new FormatInfo(Format.R16G16Snorm, 1, 1, 4), + RtFormat.R16G16Sint => new FormatInfo(Format.R16G16Sint, 1, 1, 4), + RtFormat.R16G16Uint => new FormatInfo(Format.R16G16Uint, 1, 1, 4), + RtFormat.R16G16Float => new FormatInfo(Format.R16G16Float, 1, 1, 4), + RtFormat.R11G11B10Float => new FormatInfo(Format.R11G11B10Float, 1, 1, 4), + RtFormat.R32Sint => new FormatInfo(Format.R32Sint, 1, 1, 4), + RtFormat.R32Uint => new FormatInfo(Format.R32Uint, 1, 1, 4), + RtFormat.R32Float => new FormatInfo(Format.R32Float, 1, 1, 4), + RtFormat.B8G8R8X8Unorm => new FormatInfo(Format.B8G8R8A8Unorm, 1, 1, 4), + RtFormat.B8G8R8X8Srgb => new FormatInfo(Format.B8G8R8A8Srgb, 1, 1, 4), + RtFormat.B5G6R5Unorm => new FormatInfo(Format.B5G6R5Unorm, 1, 1, 2), + RtFormat.B5G5R5A1Unorm => new FormatInfo(Format.B5G5R5A1Unorm, 1, 1, 2), + RtFormat.R8G8Unorm => new FormatInfo(Format.R8G8Unorm, 1, 1, 2), + RtFormat.R8G8Snorm => new FormatInfo(Format.R8G8Snorm, 1, 1, 2), + RtFormat.R8G8Sint => new FormatInfo(Format.R8G8Sint, 1, 1, 2), + RtFormat.R8G8Uint => new FormatInfo(Format.R8G8Uint, 1, 1, 2), + RtFormat.R16Unorm => new FormatInfo(Format.R16Unorm, 1, 1, 2), + RtFormat.R16Snorm => new FormatInfo(Format.R16Snorm, 1, 1, 2), + RtFormat.R16Sint => new FormatInfo(Format.R16Sint, 1, 1, 2), + RtFormat.R16Uint => new FormatInfo(Format.R16Uint, 1, 1, 2), + RtFormat.R16Float => new FormatInfo(Format.R16Float, 1, 1, 2), + RtFormat.R8Unorm => new FormatInfo(Format.R8Unorm, 1, 1, 1), + RtFormat.R8Snorm => new FormatInfo(Format.R8Snorm, 1, 1, 1), + RtFormat.R8Sint => new FormatInfo(Format.R8Sint, 1, 1, 1), + RtFormat.R8Uint => new FormatInfo(Format.R8Uint, 1, 1, 1), + RtFormat.B5G5R5X1Unorm => new FormatInfo(Format.B5G5R5X1Unorm, 1, 1, 2), + RtFormat.R8G8B8X8Unorm => new FormatInfo(Format.R8G8B8A8Unorm, 1, 1, 4), + RtFormat.R8G8B8X8Srgb => new FormatInfo(Format.R8G8B8A8Srgb, 1, 1, 4), + _ => FormatInfo.Default + }; } } } \ No newline at end of file diff --git a/Ryujinx.Graphics.Gpu/State/SamplerIndex.cs b/Ryujinx.Graphics.Gpu/State/SamplerIndex.cs index 651983f1..c2aaff43 100644 --- a/Ryujinx.Graphics.Gpu/State/SamplerIndex.cs +++ b/Ryujinx.Graphics.Gpu/State/SamplerIndex.cs @@ -1,5 +1,8 @@ namespace Ryujinx.Graphics.Gpu.State { + /// + /// Sampler pool indexing mode. + /// enum SamplerIndex { Independently = 0, diff --git a/Ryujinx.Graphics.Gpu/State/ShaderState.cs b/Ryujinx.Graphics.Gpu/State/ShaderState.cs index e5c9c35a..62c7ed4d 100644 --- a/Ryujinx.Graphics.Gpu/State/ShaderState.cs +++ b/Ryujinx.Graphics.Gpu/State/ShaderState.cs @@ -1,5 +1,8 @@ namespace Ryujinx.Graphics.Gpu.State { + /// + /// Graphics shader stage state. + /// struct ShaderState { public uint Control; @@ -19,6 +22,11 @@ namespace Ryujinx.Graphics.Gpu.State public uint Unknown0x38; public uint Unknown0x3c; + /// + /// Unpacks shader enable information. + /// Must be ignored for vertex shaders, those are always enabled. + /// + /// True if the stage is enabled, false otherwise public bool UnpackEnable() { return (Control & 1) != 0; diff --git a/Ryujinx.Graphics.Gpu/State/ShaderType.cs b/Ryujinx.Graphics.Gpu/State/ShaderType.cs index 703159f4..58506821 100644 --- a/Ryujinx.Graphics.Gpu/State/ShaderType.cs +++ b/Ryujinx.Graphics.Gpu/State/ShaderType.cs @@ -1,5 +1,8 @@ namespace Ryujinx.Graphics.Gpu.State { + /// + /// Shader stage name. + /// enum ShaderType { Vertex, diff --git a/Ryujinx.Graphics.Gpu/State/Size3D.cs b/Ryujinx.Graphics.Gpu/State/Size3D.cs index 82771389..0fa3314a 100644 --- a/Ryujinx.Graphics.Gpu/State/Size3D.cs +++ b/Ryujinx.Graphics.Gpu/State/Size3D.cs @@ -1,5 +1,8 @@ namespace Ryujinx.Graphics.Gpu.State { + /// + /// 3D, 2D or 1D texture size. + /// struct Size3D { public int Width; diff --git a/Ryujinx.Graphics.Gpu/State/StateWriteFlags.cs b/Ryujinx.Graphics.Gpu/State/StateWriteFlags.cs deleted file mode 100644 index 32d5127a..00000000 --- a/Ryujinx.Graphics.Gpu/State/StateWriteFlags.cs +++ /dev/null @@ -1,34 +0,0 @@ -namespace Ryujinx.Graphics.Gpu.State -{ - enum StateWriteFlags - { - InputAssemblerGroup = - VertexAttribState | - PrimitiveRestartState | - IndexBufferState | - VertexBufferState, - - RenderTargetGroup = - RtColorState | - RtDepthStencilState, - - RtColorState = 1 << 0, - ViewportTransform = 1 << 1, - DepthBiasState = 1 << 2, - RtDepthStencilState = 1 << 3, - DepthTestState = 1 << 4, - VertexAttribState = 1 << 5, - StencilTestState = 1 << 6, - SamplerPoolState = 1 << 7, - TexturePoolState = 1 << 8, - PrimitiveRestartState = 1 << 9, - IndexBufferState = 1 << 10, - FaceState = 1 << 11, - RtColorMask = 1 << 12, - VertexBufferState = 1 << 13, - BlendState = 1 << 14, - ShaderState = 1 << 15, - - Any = -1 - } -} diff --git a/Ryujinx.Graphics.Gpu/State/StencilBackMasks.cs b/Ryujinx.Graphics.Gpu/State/StencilBackMasks.cs index d3779f87..f9ee613f 100644 --- a/Ryujinx.Graphics.Gpu/State/StencilBackMasks.cs +++ b/Ryujinx.Graphics.Gpu/State/StencilBackMasks.cs @@ -1,5 +1,8 @@ namespace Ryujinx.Graphics.Gpu.State { + /// + /// Stencil test masks for back tests. + /// struct StencilBackMasks { public int FuncRef; diff --git a/Ryujinx.Graphics.Gpu/State/StencilBackTestState.cs b/Ryujinx.Graphics.Gpu/State/StencilBackTestState.cs index 842ffa0e..0169b5e7 100644 --- a/Ryujinx.Graphics.Gpu/State/StencilBackTestState.cs +++ b/Ryujinx.Graphics.Gpu/State/StencilBackTestState.cs @@ -2,6 +2,9 @@ using Ryujinx.Graphics.GAL; namespace Ryujinx.Graphics.Gpu.State { + /// + /// Stencil back test state. + /// struct StencilBackTestState { public Boolean32 TwoSided; diff --git a/Ryujinx.Graphics.Gpu/State/StencilTestState.cs b/Ryujinx.Graphics.Gpu/State/StencilTestState.cs index f76f77a7..a50de6e6 100644 --- a/Ryujinx.Graphics.Gpu/State/StencilTestState.cs +++ b/Ryujinx.Graphics.Gpu/State/StencilTestState.cs @@ -2,6 +2,9 @@ using Ryujinx.Graphics.GAL; namespace Ryujinx.Graphics.Gpu.State { + /// + /// Stencil front test state and masks. + /// struct StencilTestState { public Boolean32 Enable; diff --git a/Ryujinx.Graphics.Gpu/State/UniformBufferState.cs b/Ryujinx.Graphics.Gpu/State/UniformBufferState.cs index 80e4b6bc..15fe556e 100644 --- a/Ryujinx.Graphics.Gpu/State/UniformBufferState.cs +++ b/Ryujinx.Graphics.Gpu/State/UniformBufferState.cs @@ -1,5 +1,8 @@ namespace Ryujinx.Graphics.Gpu.State { + /// + /// Uniform buffer state for the uniform buffer currently being modified. + /// struct UniformBufferState { public int Size; diff --git a/Ryujinx.Graphics.Gpu/State/VertexAttribState.cs b/Ryujinx.Graphics.Gpu/State/VertexAttribState.cs index 0e327a75..897da797 100644 --- a/Ryujinx.Graphics.Gpu/State/VertexAttribState.cs +++ b/Ryujinx.Graphics.Gpu/State/VertexAttribState.cs @@ -1,19 +1,34 @@ namespace Ryujinx.Graphics.Gpu.State { + /// + /// Vertex buffer attribute state. + /// struct VertexAttribState { public uint Attribute; + /// + /// Unpacks the index of the vertex buffer this attribute belongs to. + /// + /// Vertex buffer index public int UnpackBufferIndex() { return (int)(Attribute & 0x1f); } + /// + /// Unpacks the offset, in bytes, of the attribute on the vertex buffer. + /// + /// Attribute offset in bytes public int UnpackOffset() { return (int)((Attribute >> 7) & 0x3fff); } + /// + /// Unpacks the Maxwell attribute format integer. + /// + /// Attribute format integer public uint UnpackFormat() { return Attribute & 0x3fe00000; diff --git a/Ryujinx.Graphics.Gpu/State/VertexBufferDrawState.cs b/Ryujinx.Graphics.Gpu/State/VertexBufferDrawState.cs index c2f3b7bb..b1c9a087 100644 --- a/Ryujinx.Graphics.Gpu/State/VertexBufferDrawState.cs +++ b/Ryujinx.Graphics.Gpu/State/VertexBufferDrawState.cs @@ -1,5 +1,8 @@ namespace Ryujinx.Graphics.Gpu.State { + /// + /// Draw state for non-indexed draws. + /// struct VertexBufferDrawState { public int First; diff --git a/Ryujinx.Graphics.Gpu/State/VertexBufferState.cs b/Ryujinx.Graphics.Gpu/State/VertexBufferState.cs index a8bd2c92..e514f2a9 100644 --- a/Ryujinx.Graphics.Gpu/State/VertexBufferState.cs +++ b/Ryujinx.Graphics.Gpu/State/VertexBufferState.cs @@ -1,16 +1,27 @@ namespace Ryujinx.Graphics.Gpu.State { + /// + /// Vertex buffer state. + /// struct VertexBufferState { public uint Control; public GpuVa Address; public int Divisor; + /// + /// Vertex buffer stride, defined as the number of bytes occupied by each vertex in memory. + /// + /// Vertex buffer stride public int UnpackStride() { return (int)(Control & 0xfff); } + /// + /// Vertex buffer enable. + /// + /// True if the vertex buffer is enabled, false otherwise public bool UnpackEnable() { return (Control & (1 << 12)) != 0; diff --git a/Ryujinx.Graphics.Gpu/State/ViewportExtents.cs b/Ryujinx.Graphics.Gpu/State/ViewportExtents.cs index 4be2db90..6675c909 100644 --- a/Ryujinx.Graphics.Gpu/State/ViewportExtents.cs +++ b/Ryujinx.Graphics.Gpu/State/ViewportExtents.cs @@ -1,5 +1,8 @@ namespace Ryujinx.Graphics.Gpu.State { + /// + /// Viewport extents for viewport clipping, also includes depth range. + /// struct ViewportExtents { public ushort X; diff --git a/Ryujinx.Graphics.Gpu/State/ViewportTransform.cs b/Ryujinx.Graphics.Gpu/State/ViewportTransform.cs index 335b039c..c7db311d 100644 --- a/Ryujinx.Graphics.Gpu/State/ViewportTransform.cs +++ b/Ryujinx.Graphics.Gpu/State/ViewportTransform.cs @@ -2,6 +2,9 @@ using Ryujinx.Graphics.GAL; namespace Ryujinx.Graphics.Gpu.State { + /// + /// Viewport transform parameters, for viewport transformation. + /// struct ViewportTransform { public float ScaleX; @@ -13,21 +16,37 @@ namespace Ryujinx.Graphics.Gpu.State public uint Swizzle; public uint SubpixelPrecisionBias; + /// + /// Unpacks viewport swizzle of the position X component. + /// + /// Swizzle enum value public ViewportSwizzle UnpackSwizzleX() { return (ViewportSwizzle)(Swizzle & 7); } + /// + /// Unpacks viewport swizzle of the position Y component. + /// + /// Swizzle enum value public ViewportSwizzle UnpackSwizzleY() { return (ViewportSwizzle)((Swizzle >> 4) & 7); } + /// + /// Unpacks viewport swizzle of the position Z component. + /// + /// Swizzle enum value public ViewportSwizzle UnpackSwizzleZ() { return (ViewportSwizzle)((Swizzle >> 8) & 7); } + /// + /// Unpacks viewport swizzle of the position W component. + /// + /// Swizzle enum value public ViewportSwizzle UnpackSwizzleW() { return (ViewportSwizzle)((Swizzle >> 12) & 7);