diff options
| author | gdkchan <gab.dark.100@gmail.com> | 2020-07-15 00:01:10 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-15 13:01:10 +1000 |
| commit | 788ca6a411762035a6a7a88100c4b582b47ee82d (patch) | |
| tree | d48bfb91aecaead2906ec2d390357546f8c0611f /Ryujinx.Graphics.Gpu/State | |
| parent | 16dafe63166d065f40b57a9b7cf8017a6ba0b1ef (diff) | |
Initial transform feedback support (#1370)
* Initial transform feedback support
* Some nits and fixes
* Update ReportCounterType and Write method
* Can't change shader or TFB bindings while TFB is active
* Fix geometry shader input names with new naming
Diffstat (limited to 'Ryujinx.Graphics.Gpu/State')
| -rw-r--r-- | Ryujinx.Graphics.Gpu/State/GpuState.cs | 19 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Gpu/State/GpuStateTable.cs | 54 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Gpu/State/MethodOffset.cs | 6 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Gpu/State/ReportCounterType.cs | 11 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Gpu/State/TfBufferState.cs | 18 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Gpu/State/TfState.cs | 15 |
6 files changed, 87 insertions, 36 deletions
diff --git a/Ryujinx.Graphics.Gpu/State/GpuState.cs b/Ryujinx.Graphics.Gpu/State/GpuState.cs index 264719b4..9e7d9492 100644 --- a/Ryujinx.Graphics.Gpu/State/GpuState.cs +++ b/Ryujinx.Graphics.Gpu/State/GpuState.cs @@ -346,7 +346,7 @@ namespace Ryujinx.Graphics.Gpu.State /// <param name="offset">Register offset</param> /// <param name="index">Index for indexed data</param> /// <returns>The data at the specified location</returns> - public T Get<T>(MethodOffset offset, int index) where T : struct + public T Get<T>(MethodOffset offset, int index) where T : unmanaged { Register register = _registers[(int)offset]; @@ -364,19 +364,30 @@ namespace Ryujinx.Graphics.Gpu.State /// <typeparam name="T">Type of the data</typeparam> /// <param name="offset">Register offset</param> /// <returns>The data at the specified location</returns> - public T Get<T>(MethodOffset offset) where T : struct + public T Get<T>(MethodOffset offset) where T : unmanaged { return MemoryMarshal.Cast<int, T>(_memory.AsSpan().Slice((int)offset))[0]; } /// <summary> + /// Gets a span of the data at a given register offset. + /// </summary> + /// <param name="offset">Register offset</param> + /// <param name="length">Length of the data in bytes</param> + /// <returns>The data at the specified location</returns> + public Span<byte> GetSpan(MethodOffset offset, int length) + { + return MemoryMarshal.Cast<int, byte>(_memory.AsSpan().Slice((int)offset)).Slice(0, length); + } + + /// <summary> /// Sets indexed data to a given register offset. /// </summary> /// <typeparam name="T">Type of the data</typeparam> /// <param name="offset">Register offset</param> /// <param name="index">Index for indexed data</param> /// <param name="data">The data to set</param> - public void Set<T>(MethodOffset offset, int index, T data) where T : struct + public void Set<T>(MethodOffset offset, int index, T data) where T : unmanaged { Register register = _registers[(int)offset]; @@ -394,7 +405,7 @@ namespace Ryujinx.Graphics.Gpu.State /// <typeparam name="T">Type of the data</typeparam> /// <param name="offset">Register offset</param> /// <param name="data">The data to set</param> - public void Set<T>(MethodOffset offset, T data) where T : struct + public void Set<T>(MethodOffset offset, T data) where T : unmanaged { ReadOnlySpan<int> intSpan = MemoryMarshal.Cast<T, int>(MemoryMarshal.CreateReadOnlySpan(ref data, 1)); intSpan.CopyTo(_memory.AsSpan().Slice((int)offset, intSpan.Length)); diff --git a/Ryujinx.Graphics.Gpu/State/GpuStateTable.cs b/Ryujinx.Graphics.Gpu/State/GpuStateTable.cs index 65df5f4e..acc0fe85 100644 --- a/Ryujinx.Graphics.Gpu/State/GpuStateTable.cs +++ b/Ryujinx.Graphics.Gpu/State/GpuStateTable.cs @@ -53,32 +53,34 @@ namespace Ryujinx.Graphics.Gpu.State /// </summary> public static TableItem[] Table = new TableItem[] { - new TableItem(MethodOffset.RtColorState, typeof(RtColorState), Constants.TotalRenderTargets), - new TableItem(MethodOffset.ViewportTransform, typeof(ViewportTransform), Constants.TotalViewports), - new TableItem(MethodOffset.ViewportExtents, typeof(ViewportExtents), Constants.TotalViewports), - new TableItem(MethodOffset.VertexBufferDrawState, typeof(VertexBufferDrawState), 1), - new TableItem(MethodOffset.DepthBiasState, typeof(DepthBiasState), 1), - new TableItem(MethodOffset.ScissorState, typeof(ScissorState), Constants.TotalViewports), - new TableItem(MethodOffset.StencilBackMasks, typeof(StencilBackMasks), 1), - new TableItem(MethodOffset.RtDepthStencilState, typeof(RtDepthStencilState), 1), - new TableItem(MethodOffset.VertexAttribState, typeof(VertexAttribState), 16), - new TableItem(MethodOffset.RtDepthStencilSize, typeof(Size3D), 1), - new TableItem(MethodOffset.BlendEnable, typeof(Boolean32), Constants.TotalRenderTargets), - new TableItem(MethodOffset.StencilTestState, typeof(StencilTestState), 1), - new TableItem(MethodOffset.SamplerPoolState, typeof(PoolState), 1), - new TableItem(MethodOffset.TexturePoolState, typeof(PoolState), 1), - new TableItem(MethodOffset.StencilBackTestState, typeof(StencilBackTestState), 1), - new TableItem(MethodOffset.ShaderBaseAddress, typeof(GpuVa), 1), - new TableItem(MethodOffset.PrimitiveRestartState, typeof(PrimitiveRestartState), 1), - new TableItem(MethodOffset.IndexBufferState, typeof(IndexBufferState), 1), - new TableItem(MethodOffset.VertexBufferInstanced, typeof(Boolean32), 16), - new TableItem(MethodOffset.FaceState, typeof(FaceState), 1), - new TableItem(MethodOffset.RtColorMask, typeof(RtColorMask), Constants.TotalRenderTargets), - new TableItem(MethodOffset.VertexBufferState, typeof(VertexBufferState), 16), - new TableItem(MethodOffset.BlendConstant, typeof(ColorF), 1), - new TableItem(MethodOffset.BlendState, typeof(BlendState), Constants.TotalRenderTargets), - new TableItem(MethodOffset.VertexBufferEndAddress, typeof(GpuVa), 16), - new TableItem(MethodOffset.ShaderState, typeof(ShaderState), 6), + new TableItem(MethodOffset.TfBufferState, typeof(TfBufferState), Constants.TotalTransformFeedbackBuffers), + new TableItem(MethodOffset.TfState, typeof(TfState), Constants.TotalTransformFeedbackBuffers), + new TableItem(MethodOffset.RtColorState, typeof(RtColorState), Constants.TotalRenderTargets), + new TableItem(MethodOffset.ViewportTransform, typeof(ViewportTransform), Constants.TotalViewports), + new TableItem(MethodOffset.ViewportExtents, typeof(ViewportExtents), Constants.TotalViewports), + new TableItem(MethodOffset.VertexBufferDrawState, typeof(VertexBufferDrawState), 1), + new TableItem(MethodOffset.DepthBiasState, typeof(DepthBiasState), 1), + new TableItem(MethodOffset.ScissorState, typeof(ScissorState), Constants.TotalViewports), + new TableItem(MethodOffset.StencilBackMasks, typeof(StencilBackMasks), 1), + new TableItem(MethodOffset.RtDepthStencilState, typeof(RtDepthStencilState), 1), + new TableItem(MethodOffset.VertexAttribState, typeof(VertexAttribState), Constants.TotalVertexAttribs), + new TableItem(MethodOffset.RtDepthStencilSize, typeof(Size3D), 1), + new TableItem(MethodOffset.BlendEnable, typeof(Boolean32), Constants.TotalRenderTargets), + new TableItem(MethodOffset.StencilTestState, typeof(StencilTestState), 1), + new TableItem(MethodOffset.SamplerPoolState, typeof(PoolState), 1), + new TableItem(MethodOffset.TexturePoolState, typeof(PoolState), 1), + new TableItem(MethodOffset.StencilBackTestState, typeof(StencilBackTestState), 1), + new TableItem(MethodOffset.ShaderBaseAddress, typeof(GpuVa), 1), + new TableItem(MethodOffset.PrimitiveRestartState, typeof(PrimitiveRestartState), 1), + new TableItem(MethodOffset.IndexBufferState, typeof(IndexBufferState), 1), + new TableItem(MethodOffset.VertexBufferInstanced, typeof(Boolean32), Constants.TotalVertexBuffers), + new TableItem(MethodOffset.FaceState, typeof(FaceState), 1), + new TableItem(MethodOffset.RtColorMask, typeof(RtColorMask), Constants.TotalRenderTargets), + new TableItem(MethodOffset.VertexBufferState, typeof(VertexBufferState), Constants.TotalVertexBuffers), + new TableItem(MethodOffset.BlendConstant, typeof(ColorF), 1), + new TableItem(MethodOffset.BlendState, typeof(BlendState), Constants.TotalRenderTargets), + new TableItem(MethodOffset.VertexBufferEndAddress, typeof(GpuVa), Constants.TotalVertexBuffers), + new TableItem(MethodOffset.ShaderState, typeof(ShaderState), Constants.ShaderStages + 1), }; } }
\ No newline at end of file diff --git a/Ryujinx.Graphics.Gpu/State/MethodOffset.cs b/Ryujinx.Graphics.Gpu/State/MethodOffset.cs index d7d5d903..b0eb6f32 100644 --- a/Ryujinx.Graphics.Gpu/State/MethodOffset.cs +++ b/Ryujinx.Graphics.Gpu/State/MethodOffset.cs @@ -28,10 +28,13 @@ namespace Ryujinx.Graphics.Gpu.State SyncpointAction = 0xb2, CopyBuffer = 0xc0, RasterizeEnable = 0xdf, + TfBufferState = 0xe0, CopyBufferParams = 0x100, + TfState = 0x1c0, CopyBufferSwizzle = 0x1c2, CopyBufferDstTexture = 0x1c3, CopyBufferSrcTexture = 0x1ca, + TfEnable = 0x1d1, RtColorState = 0x200, CopyTextureControl = 0x223, CopyRegion = 0x22c, @@ -116,6 +119,7 @@ namespace Ryujinx.Graphics.Gpu.State UniformBufferBindTessEvaluation = 0x914, UniformBufferBindGeometry = 0x91c, UniformBufferBindFragment = 0x924, - TextureBufferIndex = 0x982 + TextureBufferIndex = 0x982, + TfVaryingLocations = 0xa00 } }
\ No newline at end of file diff --git a/Ryujinx.Graphics.Gpu/State/ReportCounterType.cs b/Ryujinx.Graphics.Gpu/State/ReportCounterType.cs index cface55d..6bde2844 100644 --- a/Ryujinx.Graphics.Gpu/State/ReportCounterType.cs +++ b/Ryujinx.Graphics.Gpu/State/ReportCounterType.cs @@ -11,18 +11,19 @@ namespace Ryujinx.Graphics.Gpu.State VertexShaderInvocations = 5, GeometryShaderInvocations = 7, GeometryShaderPrimitives = 9, + ZcullStats0 = 0xa, TransformFeedbackPrimitivesWritten = 0xb, + ZcullStats1 = 0xc, + ZcullStats2 = 0xe, ClipperInputPrimitives = 0xf, + ZcullStats3 = 0x10, ClipperOutputPrimitives = 0x11, PrimitivesGenerated = 0x12, FragmentShaderInvocations = 0x13, SamplesPassed = 0x15, + TransformFeedbackOffset = 0x1a, TessControlShaderInvocations = 0x1b, TessEvaluationShaderInvocations = 0x1d, - TessEvaluationShaderPrimitives = 0x1f, - ZcullStats0 = 0x2a, - ZcullStats1 = 0x2c, - ZcullStats2 = 0x2e, - ZcullStats3 = 0x30 + TessEvaluationShaderPrimitives = 0x1f } }
\ No newline at end of file diff --git a/Ryujinx.Graphics.Gpu/State/TfBufferState.cs b/Ryujinx.Graphics.Gpu/State/TfBufferState.cs new file mode 100644 index 00000000..24dc0952 --- /dev/null +++ b/Ryujinx.Graphics.Gpu/State/TfBufferState.cs @@ -0,0 +1,18 @@ +namespace Ryujinx.Graphics.Gpu.State +{ + /// <summary> + /// Transform feedback buffer state. + /// </summary> + struct TfBufferState + { +#pragma warning disable CS0649 + public Boolean32 Enable; + public GpuVa Address; + public int Size; + public int Offset; + public uint Padding0; + public uint Padding1; + public uint Padding2; +#pragma warning restore CS0649 + } +} diff --git a/Ryujinx.Graphics.Gpu/State/TfState.cs b/Ryujinx.Graphics.Gpu/State/TfState.cs new file mode 100644 index 00000000..fb8b950b --- /dev/null +++ b/Ryujinx.Graphics.Gpu/State/TfState.cs @@ -0,0 +1,15 @@ +namespace Ryujinx.Graphics.Gpu.State +{ + /// <summary> + /// Transform feedback state. + /// </summary> + struct TfState + { +#pragma warning disable CS0649 + public int BufferIndex; + public int VaryingsCount; + public int Stride; + public uint Padding; +#pragma warning restore CS0649 + } +} |
