source-profiler.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /******************************************************************************
  2. Copyright (C) 2023 by Dennis Sädtler <[email protected]>
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. ******************************************************************************/
  14. #pragma once
  15. #include "obs.h"
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19. typedef struct profiler_result {
  20. /* Tick times in ns */
  21. uint64_t tick_avg;
  22. uint64_t tick_max;
  23. /* Average and max render times for CPU and GPU in ns */
  24. uint64_t render_avg;
  25. uint64_t render_max;
  26. uint64_t render_gpu_avg;
  27. uint64_t render_gpu_max;
  28. /* Average of the sum of all render passes in a frame in ns
  29. * (a source can be rendered more than once per frame). */
  30. uint64_t render_sum;
  31. uint64_t render_gpu_sum;
  32. /* FPS of submitted async input */
  33. double async_input;
  34. /* Actually rendered async frames */
  35. double async_rendered;
  36. /* Best and worst frame times of input/output in ns */
  37. uint64_t async_input_best;
  38. uint64_t async_input_worst;
  39. uint64_t async_rendered_best;
  40. uint64_t async_rendered_worst;
  41. } profiler_result_t;
  42. /* Enable/disable profiler (applied on next frame) */
  43. EXPORT void source_profiler_enable(bool enable);
  44. /* Enable/disable GPU profiling (applied on next frame) */
  45. EXPORT void source_profiler_gpu_enable(bool enable);
  46. /* Get latest profiling results for source (must be freed by user) */
  47. EXPORT profiler_result_t *source_profiler_get_result(obs_source_t *source);
  48. /* Update existing profiler results object for source */
  49. EXPORT bool source_profiler_fill_result(obs_source_t *source, profiler_result_t *result);
  50. #ifdef __cplusplus
  51. }
  52. #endif