MemoryAllocation.cs 962 B

12345678910111213141516171819202122232425262728293031323334353637
  1. using Silk.NET.Vulkan;
  2. using System;
  3. namespace Ryujinx.Graphics.Vulkan
  4. {
  5. readonly struct MemoryAllocation : IDisposable
  6. {
  7. private readonly MemoryAllocatorBlockList _owner;
  8. private readonly MemoryAllocatorBlockList.Block _block;
  9. public DeviceMemory Memory { get; }
  10. public IntPtr HostPointer { get;}
  11. public ulong Offset { get; }
  12. public ulong Size { get; }
  13. public MemoryAllocation(
  14. MemoryAllocatorBlockList owner,
  15. MemoryAllocatorBlockList.Block block,
  16. DeviceMemory memory,
  17. IntPtr hostPointer,
  18. ulong offset,
  19. ulong size)
  20. {
  21. _owner = owner;
  22. _block = block;
  23. Memory = memory;
  24. HostPointer = hostPointer;
  25. Offset = offset;
  26. Size = size;
  27. }
  28. public void Dispose()
  29. {
  30. _owner.Free(_block, Offset, Size);
  31. }
  32. }
  33. }