sync_manager.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // MIT License
  2. //
  3. // Copyright (c) Ryujinx Team and Contributors
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
  6. // associated documentation files (the "Software"), to deal in the Software without restriction,
  7. // including without limitation the rights to use, copy, modify, merge, publish, distribute,
  8. // sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in all copies or
  12. // substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
  15. // NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  16. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  17. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  19. //
  20. #pragma once
  21. #include <mutex>
  22. #include <vector>
  23. #include "common/common_types.h"
  24. namespace Tegra {
  25. class GPU;
  26. struct SyncptIncr {
  27. u32 id;
  28. u32 class_id;
  29. u32 syncpt_id;
  30. bool complete;
  31. SyncptIncr(u32 id_, u32 class_id_, u32 syncpt_id_, bool done = false)
  32. : id(id_), class_id(class_id_), syncpt_id(syncpt_id_), complete(done) {}
  33. };
  34. class SyncptIncrManager {
  35. public:
  36. explicit SyncptIncrManager(GPU& gpu);
  37. ~SyncptIncrManager();
  38. /// Add syncpoint id and increment all
  39. void Increment(u32 id);
  40. /// Returns a handle to increment later
  41. u32 IncrementWhenDone(u32 class_id, u32 id);
  42. /// IncrememntAllDone, including handle
  43. void SignalDone(u32 handle);
  44. /// Increment all sequential pending increments that are already done.
  45. void IncrementAllDone();
  46. private:
  47. std::vector<SyncptIncr> increments;
  48. std::mutex increment_lock;
  49. u32 current_id{};
  50. GPU& gpu;
  51. };
  52. } // namespace Tegra