AkInstrument.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*******************************************************************************
  2. The content of this file includes portions of the AUDIOKINETIC Wwise Technology
  3. released in source code form as part of the SDK installer package.
  4. Commercial License Usage
  5. Licensees holding valid commercial licenses to the AUDIOKINETIC Wwise Technology
  6. may use this file in accordance with the end user license agreement provided
  7. with the software or, alternatively, in accordance with the terms contained in a
  8. written agreement between you and Audiokinetic Inc.
  9. Apache License Usage
  10. Alternatively, this file may be used under the Apache License, Version 2.0 (the
  11. "Apache License"); you may not use this file except in compliance with the
  12. Apache License. You may obtain a copy of the Apache License at
  13. http://www.apache.org/licenses/LICENSE-2.0.
  14. Unless required by applicable law or agreed to in writing, software distributed
  15. under the Apache License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
  16. OR CONDITIONS OF ANY KIND, either express or implied. See the Apache License for
  17. the specific language governing permissions and limitations under the License.
  18. Copyright (c) 2023 Audiokinetic Inc.
  19. *******************************************************************************/
  20. #pragma once
  21. #include <AK/SoundEngine/Common/AkCommonDefs.h>
  22. #include <AK/Tools/Common/AkAssert.h>
  23. namespace AK
  24. {
  25. namespace Instrument
  26. {
  27. #ifndef AK_OPTIMIZED
  28. AK_CALLBACK(void*, PushTimerFunc)(
  29. AkPluginID in_uPluginID,
  30. const char * in_pszZoneName
  31. );
  32. AK_CALLBACK(void, PopTimerFunc)(void* in_pToken);
  33. AK_CALLBACK(void, PostMarkerFunc)(
  34. AkPluginID in_uPluginID,
  35. const char* in_pszMarkerName
  36. );
  37. AK_CALLBACK(void, PostMetaMarkerFunc)(
  38. AkPluginID in_uPluginID,
  39. AkUInt32 in_uMetadata
  40. );
  41. extern AKSOUNDENGINE_API PushTimerFunc g_fnPushTimer;
  42. extern AKSOUNDENGINE_API PopTimerFunc g_fnPopTimer;
  43. extern AKSOUNDENGINE_API PostMarkerFunc g_fnPostMarker;
  44. extern AKSOUNDENGINE_API PostMetaMarkerFunc g_fnPostMetaMarker;
  45. class Scope
  46. {
  47. public:
  48. inline Scope(AkPluginID in_uPluginID, const char* in_pszZoneName)
  49. {
  50. m_pToken = g_fnPushTimer(in_uPluginID, in_pszZoneName);
  51. }
  52. inline ~Scope()
  53. {
  54. g_fnPopTimer(m_pToken);
  55. }
  56. private:
  57. void* m_pToken;
  58. };
  59. #endif
  60. }
  61. }
  62. #if !defined(AK_OPTIMIZED)
  63. #define AK_INSTRUMENT_BEGIN(_plugin_id_, _zone_name_) (AK::Instrument::g_fnPushTimer(_plugin_id_, _zone_name_))
  64. #define AK_INSTRUMENT_END(__token__) (AK::Instrument::g_fnPopTimer(__token__))
  65. #define AK_INSTRUMENT_MARKER(_plugin_id_, _marker_name_) (AK::Instrument::g_fnPostMarker(_plugin_id_, _marker_name_))
  66. #define AK_INSTRUMENT_MARKER_PROFILINGID(_profilingid_) (AK::Instrument::g_fnPostMarker(AKMAKECLASSID( AkPluginTypeNone, AKCOMPANYID_AUDIOKINETIC, _profilingid_ ), nullptr))
  67. #define AK_INSTRUMENT_METAMARKER(_plugin_id_, _metadata_) (AK::Instrument::g_fnPostMetaMarker(_plugin_id_, _metadata_))
  68. #define AK_INSTRUMENT_CONCAT_INNER(_base_, _counter_) _base_ ## _counter_
  69. #define AK_INSTRUMENT_CONCAT(_base_, _counter_) AK_INSTRUMENT_CONCAT_INNER(_base_, _counter_)
  70. #define AK_INSTRUMENT_SCOPE(_zone_name_) \
  71. AK::Instrument::Scope AK_INSTRUMENT_CONCAT(_akInstrumentScope_, __LINE__)(0, _zone_name_)
  72. #define AK_INSTRUMENT_SCOPE_ID(_plugin_id_, _zone_name_) \
  73. AK::Instrument::Scope AK_INSTRUMENT_CONCAT(_akInstrumentScope_, __LINE__)(_plugin_id_, _zone_name_)
  74. #define AK_INSTRUMENT_SCOPE_PROFILINGID(_profilingid_) \
  75. AK::Instrument::Scope AK_INSTRUMENT_CONCAT(_akInstrumentScope_, __LINE__)(AKMAKECLASSID( AkPluginTypeNone, AKCOMPANYID_AUDIOKINETIC, _profilingid_ ), nullptr)
  76. #define AK_INSTRUMENT_THREAD_START( _thread_name_ )
  77. #else // AK_OPTIMIZED
  78. #define AK_INSTRUMENT_BEGIN(_plugin_id_, _zone_name_) (void*)( 0 )
  79. #define AK_INSTRUMENT_END(__token__)
  80. #define AK_INSTRUMENT_MARKER(_plugin_id_, _zone_name_)
  81. #define AK_INSTRUMENT_MARKER_PROFILINGID(_profilingid_)
  82. #define AK_INSTRUMENT_METAMARKER(_plugin_id_, _metadata_)
  83. #define AK_INSTRUMENT_SCOPE( _zone_name_ )
  84. #define AK_INSTRUMENT_SCOPE_ID(_plugin_id_, _zone_name_)
  85. #define AK_INSTRUMENT_SCOPE_PROFILINGID(_plugin_id_)
  86. #define AK_INSTRUMENT_THREAD_START( _thread_name_ )
  87. #endif // AK_OPTIMIZED
  88. #ifndef AK_INSTRUMENT_BEGIN_C
  89. #define AK_INSTRUMENT_BEGIN_C(_plugin_id_, _color_, _zone_name_) AK_INSTRUMENT_BEGIN(_plugin_id_, _zone_name_)
  90. #endif