RDNA3 Vulkan project

This commit is contained in:
Evan Husted
2025-01-05 23:04:17 -06:00
parent a23d1d660e
commit 7ffc1f0d2f
119 changed files with 38581 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace Ryujinx.Graphics.Rdna3Vulkan
{
unsafe class NativeArray<T> : IDisposable where T : unmanaged
{
public T* Pointer { get; private set; }
public int Length { get; }
public ref T this[int index]
{
get => ref Pointer[Checked(index)];
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private int Checked(int index)
{
if ((uint)index >= (uint)Length)
{
throw new IndexOutOfRangeException();
}
return index;
}
public NativeArray(int length)
{
Pointer = (T*)Marshal.AllocHGlobal(checked(length * Unsafe.SizeOf<T>()));
Length = length;
}
public Span<T> AsSpan()
{
return new Span<T>(Pointer, Length);
}
public void Dispose()
{
if (Pointer != null)
{
Marshal.FreeHGlobal((nint)Pointer);
Pointer = null;
}
}
}
}