CommandBufferScoped.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using SharpMetal.Metal;
  2. using System;
  3. using System.Runtime.Versioning;
  4. namespace Ryujinx.Graphics.Metal
  5. {
  6. [SupportedOSPlatform("macos")]
  7. readonly struct CommandBufferScoped : IDisposable
  8. {
  9. private readonly CommandBufferPool _pool;
  10. public MTLCommandBuffer CommandBuffer { get; }
  11. public CommandBufferEncoder Encoders { get; }
  12. public int CommandBufferIndex { get; }
  13. public CommandBufferScoped(CommandBufferPool pool, MTLCommandBuffer commandBuffer, CommandBufferEncoder encoders, int commandBufferIndex)
  14. {
  15. _pool = pool;
  16. CommandBuffer = commandBuffer;
  17. Encoders = encoders;
  18. CommandBufferIndex = commandBufferIndex;
  19. }
  20. public void AddDependant(IAuto dependant)
  21. {
  22. _pool.AddDependant(CommandBufferIndex, dependant);
  23. }
  24. public void AddWaitable(MultiFenceHolder waitable)
  25. {
  26. _pool.AddWaitable(CommandBufferIndex, waitable);
  27. }
  28. public FenceHolder GetFence()
  29. {
  30. return _pool.GetFence(CommandBufferIndex);
  31. }
  32. public void Dispose()
  33. {
  34. _pool?.Return(this);
  35. }
  36. }
  37. }