CommandBufferScoped.cs 1.2 KB

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