PerfQueryBase.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // Copyright 2012 Dolphin Emulator Project
  2. // Licensed under GPLv2+
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include "Common/CommonTypes.h"
  6. enum PerfQueryType
  7. {
  8. PQ_ZCOMP_INPUT_ZCOMPLOC = 0,
  9. PQ_ZCOMP_OUTPUT_ZCOMPLOC,
  10. PQ_ZCOMP_INPUT,
  11. PQ_ZCOMP_OUTPUT,
  12. PQ_BLEND_INPUT,
  13. PQ_EFB_COPY_CLOCKS,
  14. PQ_NUM_MEMBERS
  15. };
  16. enum PerfQueryGroup
  17. {
  18. PQG_ZCOMP_ZCOMPLOC,
  19. PQG_ZCOMP,
  20. PQG_EFB_COPY_CLOCKS,
  21. PQG_NUM_MEMBERS,
  22. };
  23. class PerfQueryBase
  24. {
  25. public:
  26. PerfQueryBase()
  27. : m_query_count(0)
  28. {
  29. }
  30. virtual ~PerfQueryBase() {}
  31. // Checks if performance queries are enabled in the gameini configuration.
  32. // NOTE: Called from CPU+GPU thread
  33. static bool ShouldEmulate();
  34. // Begin querying the specified value for the following host GPU commands
  35. virtual void EnableQuery(PerfQueryGroup type) {}
  36. // Stop querying the specified value for the following host GPU commands
  37. virtual void DisableQuery(PerfQueryGroup type) {}
  38. // Reset query counters to zero and drop any pending queries
  39. virtual void ResetQuery() {}
  40. // Return the measured value for the specified query type
  41. // NOTE: Called from CPU thread
  42. virtual u32 GetQueryResult(PerfQueryType type) { return 0; }
  43. // Request the value of any pending queries - causes a pipeline flush and thus should be used carefully!
  44. virtual void FlushResults() {}
  45. // True if there are no further pending query results
  46. // NOTE: Called from CPU thread
  47. virtual bool IsFlushed() const { return true; }
  48. protected:
  49. // TODO: sloppy
  50. volatile u32 m_query_count;
  51. volatile u32 m_results[PQG_NUM_MEMBERS];
  52. };
  53. extern PerfQueryBase* g_perf_query;