mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2025-06-28 23:40:47 -07:00
Add a GetSpan method to the memory manager and use it on GPU (#877)
This commit is contained in:
@ -21,7 +21,7 @@ namespace Ryujinx.Graphics.Shader.Decoders
|
||||
_opActivators = new ConcurrentDictionary<Type, OpActivator>();
|
||||
}
|
||||
|
||||
public static Block[] Decode(Span<byte> code, ulong headerSize)
|
||||
public static Block[] Decode(ReadOnlySpan<byte> code, ulong headerSize)
|
||||
{
|
||||
List<Block> blocks = new List<Block>();
|
||||
|
||||
@ -214,10 +214,10 @@ namespace Ryujinx.Graphics.Shader.Decoders
|
||||
}
|
||||
|
||||
private static void FillBlock(
|
||||
Span<byte> code,
|
||||
Block block,
|
||||
ulong limitAddress,
|
||||
ulong startAddress)
|
||||
ReadOnlySpan<byte> code,
|
||||
Block block,
|
||||
ulong limitAddress,
|
||||
ulong startAddress)
|
||||
{
|
||||
ulong address = block.Address;
|
||||
|
||||
|
@ -76,9 +76,9 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||
public bool OmapSampleMask { get; }
|
||||
public bool OmapDepth { get; }
|
||||
|
||||
public ShaderHeader(Span<byte> code)
|
||||
public ShaderHeader(ReadOnlySpan<byte> code)
|
||||
{
|
||||
Span<int> header = MemoryMarshal.Cast<byte, int>(code);
|
||||
ReadOnlySpan<int> header = MemoryMarshal.Cast<byte, int>(code);
|
||||
|
||||
int commonWord0 = header[0];
|
||||
int commonWord1 = header[1];
|
||||
|
@ -14,7 +14,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||
{
|
||||
private const int HeaderSize = 0x50;
|
||||
|
||||
public static Span<byte> ExtractCode(Span<byte> code, bool compute, out int headerSize)
|
||||
public static ReadOnlySpan<byte> ExtractCode(ReadOnlySpan<byte> code, bool compute, out int headerSize)
|
||||
{
|
||||
headerSize = compute ? 0 : HeaderSize;
|
||||
|
||||
@ -38,14 +38,14 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||
return code.Slice(0, headerSize + (int)endAddress);
|
||||
}
|
||||
|
||||
public static ShaderProgram Translate(Span<byte> code, TranslatorCallbacks callbacks, TranslationFlags flags)
|
||||
public static ShaderProgram Translate(ReadOnlySpan<byte> code, TranslatorCallbacks callbacks, TranslationFlags flags)
|
||||
{
|
||||
Operation[] ops = DecodeShader(code, callbacks, flags, out ShaderConfig config, out int size);
|
||||
|
||||
return Translate(ops, config, size);
|
||||
}
|
||||
|
||||
public static ShaderProgram Translate(Span<byte> vpACode, Span<byte> vpBCode, TranslatorCallbacks callbacks, TranslationFlags flags)
|
||||
public static ShaderProgram Translate(ReadOnlySpan<byte> vpACode, ReadOnlySpan<byte> vpBCode, TranslatorCallbacks callbacks, TranslationFlags flags)
|
||||
{
|
||||
Operation[] vpAOps = DecodeShader(vpACode, callbacks, flags, out _, out _);
|
||||
Operation[] vpBOps = DecodeShader(vpBCode, callbacks, flags, out ShaderConfig config, out int sizeB);
|
||||
@ -88,7 +88,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||
}
|
||||
|
||||
private static Operation[] DecodeShader(
|
||||
Span<byte> code,
|
||||
ReadOnlySpan<byte> code,
|
||||
TranslatorCallbacks callbacks,
|
||||
TranslationFlags flags,
|
||||
out ShaderConfig config,
|
||||
|
Reference in New Issue
Block a user