aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Gpu/State
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2021-07-07 20:56:06 -0300
committerGitHub <noreply@github.com>2021-07-07 20:56:06 -0300
commit8b44eb1c981d7106be37107755c7c71c3c3c0ce4 (patch)
tree70c3a8d7286d827941c41dee2ec3cb3273c1e6d7 /Ryujinx.Graphics.Gpu/State
parent31cbd09a75a9d5f4814c3907a060e0961eb2bb15 (diff)
Separate GPU engines and make state follow official docs (part 1/2) (#2422)
* Use DeviceState for compute and i2m * Migrate 2D class, more comments * Migrate DMA copy engine * Remove now unused code * Replace GpuState by GpuAccessorState on GpuAcessor, since compute no longer has a GpuState * More comments * Add logging (disabled) * Add back i2m on 3D engine
Diffstat (limited to 'Ryujinx.Graphics.Gpu/State')
-rw-r--r--Ryujinx.Graphics.Gpu/State/BufferSwizzleComponent.cs16
-rw-r--r--Ryujinx.Graphics.Gpu/State/CopyBufferParams.cs17
-rw-r--r--Ryujinx.Graphics.Gpu/State/CopyBufferSwizzle.cs75
-rw-r--r--Ryujinx.Graphics.Gpu/State/CopyTextureControl.cs22
-rw-r--r--Ryujinx.Graphics.Gpu/State/GpuState.cs33
-rw-r--r--Ryujinx.Graphics.Gpu/State/SbDescriptor.cs20
6 files changed, 45 insertions, 138 deletions
diff --git a/Ryujinx.Graphics.Gpu/State/BufferSwizzleComponent.cs b/Ryujinx.Graphics.Gpu/State/BufferSwizzleComponent.cs
deleted file mode 100644
index 5c23cb2d..00000000
--- a/Ryujinx.Graphics.Gpu/State/BufferSwizzleComponent.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-namespace Ryujinx.Graphics.Gpu.State
-{
- /// <summary>
- /// Buffer swizzle component.
- /// </summary>
- enum BufferSwizzleComponent
- {
- SrcX,
- SrcY,
- SrcZ,
- SrcW,
- ConstA,
- ConstB,
- NoWrite
- }
-}
diff --git a/Ryujinx.Graphics.Gpu/State/CopyBufferParams.cs b/Ryujinx.Graphics.Gpu/State/CopyBufferParams.cs
deleted file mode 100644
index 67c3e214..00000000
--- a/Ryujinx.Graphics.Gpu/State/CopyBufferParams.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-namespace Ryujinx.Graphics.Gpu.State
-{
- /// <summary>
- /// Buffer to buffer copy parameters.
- /// </summary>
- struct CopyBufferParams
- {
-#pragma warning disable CS0649
- public GpuVa SrcAddress;
- public GpuVa DstAddress;
- public int SrcStride;
- public int DstStride;
- public int XCount;
- public int YCount;
-#pragma warning restore CS0649
- }
-} \ No newline at end of file
diff --git a/Ryujinx.Graphics.Gpu/State/CopyBufferSwizzle.cs b/Ryujinx.Graphics.Gpu/State/CopyBufferSwizzle.cs
deleted file mode 100644
index 94b650c4..00000000
--- a/Ryujinx.Graphics.Gpu/State/CopyBufferSwizzle.cs
+++ /dev/null
@@ -1,75 +0,0 @@
-namespace Ryujinx.Graphics.Gpu.State
-{
- /// <summary>
- /// Buffer to buffer copy vector swizzle parameters.
- /// </summary>
- struct CopyBufferSwizzle
- {
-#pragma warning disable CS0649
- public uint Swizzle;
-#pragma warning restore CS0649
-
- /// <summary>
- /// Unpacks the source for the buffer destination vector X component.
- /// </summary>
- /// <returns>Destination component</returns>
- public BufferSwizzleComponent UnpackDstX()
- {
- return (BufferSwizzleComponent)(Swizzle & 7);
- }
-
- /// <summary>
- /// Unpacks the source for the buffer destination vector Y component.
- /// </summary>
- /// <returns>Destination component</returns>
- public BufferSwizzleComponent UnpackDstY()
- {
- return (BufferSwizzleComponent)((Swizzle >> 4) & 7);
- }
-
- /// <summary>
- /// Unpacks the source for the buffer destination vector Z component.
- /// </summary>
- /// <returns>Destination component</returns>
- public BufferSwizzleComponent UnpackDstZ()
- {
- return (BufferSwizzleComponent)((Swizzle >> 8) & 7);
- }
-
- /// <summary>
- /// Unpacks the source for the buffer destination vector W component.
- /// </summary>
- /// <returns>Destination component</returns>
- public BufferSwizzleComponent UnpackDstW()
- {
- return (BufferSwizzleComponent)((Swizzle >> 12) & 7);
- }
-
- /// <summary>
- /// Unpacks the size of each vector component of the copy.
- /// </summary>
- /// <returns>Vector component size</returns>
- public int UnpackComponentSize()
- {
- return (int)((Swizzle >> 16) & 3) + 1;
- }
-
- /// <summary>
- /// Unpacks the number of components of the source vector of the copy.
- /// </summary>
- /// <returns>Number of vector components</returns>
- public int UnpackSrcComponentsCount()
- {
- return (int)((Swizzle >> 20) & 7) + 1;
- }
-
- /// <summary>
- /// Unpacks the number of components of the destination vector of the copy.
- /// </summary>
- /// <returns>Number of vector components</returns>
- public int UnpackDstComponentsCount()
- {
- return (int)((Swizzle >> 24) & 7) + 1;
- }
- }
-} \ No newline at end of file
diff --git a/Ryujinx.Graphics.Gpu/State/CopyTextureControl.cs b/Ryujinx.Graphics.Gpu/State/CopyTextureControl.cs
deleted file mode 100644
index d6256f68..00000000
--- a/Ryujinx.Graphics.Gpu/State/CopyTextureControl.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-namespace Ryujinx.Graphics.Gpu.State
-{
- /// <summary>
- /// Texture to texture copy control.
- /// </summary>
- struct CopyTextureControl
- {
-#pragma warning disable CS0649
- public uint Packed;
-#pragma warning restore CS0649
-
- public bool UnpackOriginCorner()
- {
- return (Packed & 1u) != 0;
- }
-
- public bool UnpackLinearFilter()
- {
- return (Packed & (1u << 4)) != 0;
- }
- }
-} \ No newline at end of file
diff --git a/Ryujinx.Graphics.Gpu/State/GpuState.cs b/Ryujinx.Graphics.Gpu/State/GpuState.cs
index ff4d7829..0b209da7 100644
--- a/Ryujinx.Graphics.Gpu/State/GpuState.cs
+++ b/Ryujinx.Graphics.Gpu/State/GpuState.cs
@@ -1,4 +1,5 @@
-using Ryujinx.Graphics.Gpu.Image;
+using Ryujinx.Graphics.Device;
+using Ryujinx.Graphics.Gpu.Image;
using System;
using System.Runtime.InteropServices;
@@ -33,6 +34,8 @@ namespace Ryujinx.Graphics.Gpu.State
private readonly Register[] _registers;
+ private readonly IDeviceState _deviceState;
+
/// <summary>
/// Gets or sets the shadow ram control used for this sub-channel.
/// </summary>
@@ -47,9 +50,11 @@ namespace Ryujinx.Graphics.Gpu.State
/// Creates a new instance of the GPU state.
/// </summary>
/// <param name="channel">Channel that the sub-channel state belongs to</param>
- public GpuState(GpuChannel channel)
+ /// <param name="deviceState">Optional device state that will replace the internal backing storage</param>
+ public GpuState(GpuChannel channel, IDeviceState deviceState = null)
{
Channel = channel;
+ _deviceState = deviceState;
_memory = new int[RegistersCount];
_shadow = new int[RegistersCount];
@@ -107,16 +112,23 @@ namespace Ryujinx.Graphics.Gpu.State
}
}
- Register register = _registers[meth.Method];
-
- if (_memory[meth.Method] != value)
+ if (_deviceState != null)
{
- _registers[(int)register.BaseOffset].Modified = true;
+ _deviceState.Write(meth.Method * 4, meth.Argument);
}
+ else
+ {
+ Register register = _registers[meth.Method];
+
+ if (_memory[meth.Method] != value)
+ {
+ _registers[(int)register.BaseOffset].Modified = true;
+ }
- _memory[meth.Method] = value;
+ _memory[meth.Method] = value;
- register.Callback?.Invoke(this, value);
+ register.Callback?.Invoke(this, value);
+ }
}
/// <summary>
@@ -126,6 +138,11 @@ namespace Ryujinx.Graphics.Gpu.State
/// <returns>Data at the register</returns>
public int Read(int offset)
{
+ if (_deviceState != null)
+ {
+ return _deviceState.Read(offset * 4);
+ }
+
return _memory[offset];
}
diff --git a/Ryujinx.Graphics.Gpu/State/SbDescriptor.cs b/Ryujinx.Graphics.Gpu/State/SbDescriptor.cs
new file mode 100644
index 00000000..9723b719
--- /dev/null
+++ b/Ryujinx.Graphics.Gpu/State/SbDescriptor.cs
@@ -0,0 +1,20 @@
+namespace Ryujinx.Graphics.Gpu.State
+{
+ /// <summary>
+ /// Storage buffer address and size information.
+ /// </summary>
+ struct SbDescriptor
+ {
+#pragma warning disable CS0649
+ public uint AddressLow;
+ public uint AddressHigh;
+ public int Size;
+ public int Padding;
+#pragma warning restore CS0649
+
+ public ulong PackAddress()
+ {
+ return AddressLow | ((ulong)AddressHigh << 32);
+ }
+ }
+}