2024-01-22 20:14:46 +00:00
|
|
|
using Ryujinx.Graphics.Device;
|
2020-07-12 03:07:01 +00:00
|
|
|
using System;
|
|
|
|
|
|
|
|
namespace Ryujinx.Graphics.Nvdec
|
|
|
|
{
|
|
|
|
static class MemoryExtensions
|
|
|
|
{
|
2024-01-22 20:14:46 +00:00
|
|
|
public static T DeviceRead<T>(this DeviceMemoryManager gmm, uint offset) where T : unmanaged
|
2020-07-12 03:07:01 +00:00
|
|
|
{
|
2024-01-22 20:14:46 +00:00
|
|
|
return gmm.Read<T>(ExtendOffset(offset));
|
2020-07-12 03:07:01 +00:00
|
|
|
}
|
|
|
|
|
2024-01-22 20:14:46 +00:00
|
|
|
public static ReadOnlySpan<byte> DeviceGetSpan(this DeviceMemoryManager gmm, uint offset, int size)
|
2020-07-12 03:07:01 +00:00
|
|
|
{
|
2024-01-22 20:14:46 +00:00
|
|
|
return gmm.GetSpan(ExtendOffset(offset), size);
|
2020-07-12 03:07:01 +00:00
|
|
|
}
|
|
|
|
|
2024-01-22 20:14:46 +00:00
|
|
|
public static void DeviceWrite(this DeviceMemoryManager gmm, uint offset, ReadOnlySpan<byte> data)
|
2020-07-12 03:07:01 +00:00
|
|
|
{
|
2024-01-22 20:14:46 +00:00
|
|
|
gmm.Write(ExtendOffset(offset), data);
|
2020-07-12 03:07:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static ulong ExtendOffset(uint offset)
|
|
|
|
{
|
|
|
|
return (ulong)offset << 8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|