Rewrite shader decoding stage (#2698)

* Rewrite shader decoding stage

* Fix P2R constant buffer encoding

* Fix PSET/PSETP

* PR feedback

* Log unimplemented shader instructions

* Implement NOP

* Remove using

* PR feedback
This commit is contained in:
gdkchan 2021-10-12 17:35:31 -03:00 committed by GitHub
parent 9ac9489b8a
commit a1b0fd1ba9
168 changed files with 12022 additions and 6388 deletions

View file

@ -60,14 +60,14 @@ namespace Ryujinx.Graphics.Gpu.Shader
}
/// <summary>
/// Reads data from GPU memory.
/// Gets a span of the specified memory location, containing shader code.
/// </summary>
/// <typeparam name="T">Type of the data to be read</typeparam>
/// <param name="address">GPU virtual address of the data</param>
/// <returns>Data at the memory location</returns>
public override T MemoryRead<T>(ulong address)
/// <param name="minimumSize">Minimum size that the returned span may have</param>
/// <returns>Span of the memory location</returns>
public override ReadOnlySpan<ulong> GetCode(ulong address, int minimumSize)
{
return MemoryMarshal.Cast<byte, T>(_data.Span.Slice((int)address))[0];
return MemoryMarshal.Cast<byte, ulong>(_data.Span.Slice((int)address));
}
/// <summary>

View file

@ -1,6 +1,8 @@
using Ryujinx.Common.Logging;
using Ryujinx.Graphics.GAL;
using Ryujinx.Graphics.Shader;
using System;
using System.Runtime.InteropServices;
namespace Ryujinx.Graphics.Gpu.Shader
{
@ -95,24 +97,15 @@ namespace Ryujinx.Graphics.Gpu.Shader
}
/// <summary>
/// Reads data from GPU memory.
/// Gets a span of the specified memory location, containing shader code.
/// </summary>
/// <typeparam name="T">Type of the data to be read</typeparam>
/// <param name="address">GPU virtual address of the data</param>
/// <returns>Data at the memory location</returns>
public override T MemoryRead<T>(ulong address)
/// <param name="minimumSize">Minimum size that the returned span may have</param>
/// <returns>Span of the memory location</returns>
public override ReadOnlySpan<ulong> GetCode(ulong address, int minimumSize)
{
return _channel.MemoryManager.Read<T>(address);
}
/// <summary>
/// Checks if a given memory address is mapped.
/// </summary>
/// <param name="address">GPU virtual address to be checked</param>
/// <returns>True if the address is mapped, false otherwise</returns>
public bool MemoryMapped(ulong address)
{
return _channel.MemoryManager.IsMapped(address);
int size = Math.Max(minimumSize, 0x1000 - (int)(address & 0xfff));
return MemoryMarshal.Cast<byte, ulong>(_channel.MemoryManager.GetSpan(address, size));
}
/// <summary>

View file

@ -40,7 +40,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
/// <summary>
/// Version of the codegen (to be changed when codegen or guest format change).
/// </summary>
private const ulong ShaderCodeGenVersion = 2646;
private const ulong ShaderCodeGenVersion = 2697;
// Progress reporting helpers
private volatile int _shaderCount;

View file

@ -1,6 +1,7 @@
using Ryujinx.Graphics.GAL;
using Ryujinx.Graphics.Gpu.Image;
using Ryujinx.Graphics.Shader;
using System;
namespace Ryujinx.Graphics.Gpu.Shader
{
@ -13,7 +14,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
_context = context;
}
public abstract T MemoryRead<T>(ulong address) where T : unmanaged;
public abstract ReadOnlySpan<ulong> GetCode(ulong address, int minimumSize);
public abstract ITextureDescriptor GetTextureDescriptor(int handle, int cbufSlot);