MTLPerfQuery.h 968 B

1234567891011121314151617181920212223242526272829303132333435
  1. // Copyright 2022 Dolphin Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #include <condition_variable>
  5. #include <mutex>
  6. #include "VideoCommon/PerfQueryBase.h"
  7. namespace Metal
  8. {
  9. class PerfQuery final : public PerfQueryBase
  10. {
  11. public:
  12. void EnableQuery(PerfQueryGroup type) override;
  13. void DisableQuery(PerfQueryGroup type) override;
  14. void ResetQuery() override;
  15. u32 GetQueryResult(PerfQueryType type) override;
  16. void FlushResults() override;
  17. bool IsFlushed() const override;
  18. /// Notify PerfQuery of a new pending encoder
  19. /// One call to ReturnResults should be made for every call to IncCount
  20. void IncCount() { m_query_count.fetch_add(1, std::memory_order_relaxed); }
  21. /// May be called from any thread
  22. void ReturnResults(const u64* data, const PerfQueryGroup* groups, size_t count, u32 query_id);
  23. private:
  24. u32 m_current_query = 0;
  25. std::mutex m_results_mtx;
  26. std::condition_variable m_cv;
  27. };
  28. } // namespace Metal