gfxDebugEvent.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // 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
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _GFXDEBUGEVENT_H_
  23. #define _GFXDEBUGEVENT_H_
  24. #ifndef _GFXDEVICE_H_
  25. #include "gfx/gfxDevice.h"
  26. #endif
  27. /// See TorqueConfig.h to enable this.
  28. #ifdef TORQUE_ENABLE_GFXDEBUGEVENTS
  29. /// You shouldn't use this class directly... use the
  30. /// following macros:
  31. ///
  32. /// GFXDEBUGEVENT_START / GFXDEBUGEVENT_END
  33. /// GFXDEBUGEVENT_SCOPE
  34. ///
  35. class GFXDebugEventScope
  36. {
  37. public:
  38. GFXDebugEventScope( const char* name, const ColorI &color )
  39. {
  40. GFX->enterDebugEvent( color, name );
  41. }
  42. ~GFXDebugEventScope()
  43. {
  44. GFX->leaveDebugEvent();
  45. }
  46. };
  47. #define GFXDEBUGEVENT_START( name, color ) GFX->enterDebugEvent( color, #name )
  48. #define GFXDEBUGEVENT_END() GFX->leaveDebugEvent()
  49. #define GFXDEBUGEVENT_MARKER( name, color ) GFX->setDebugMarker( color, #name )
  50. ///
  51. /// Will add start/end GFX debug events around the
  52. /// current scope.
  53. ///
  54. /// @param name The unquoted name for the event.
  55. /// @param color A ColorI to associate with the event.
  56. ///
  57. #define GFXDEBUGEVENT_SCOPE( name, color ) GFXDebugEventScope GFXDebugEventScope##name##Obj( #name, color )
  58. #define GFXDEBUGEVENT_SCOPE_EX( name, color, desc ) GFXDebugEventScope GFXDebugEventScope##name##Obj( desc, color )
  59. #else // !TORQUE_ENABLE_GFXDEBUGEVENTS
  60. /// These are disabled in shipping builds or maybe you
  61. /// forgot to include "platform/platform.h" first?
  62. #define GFXDEBUGEVENT_START(n,c)
  63. #define GFXDEBUGEVENT_END()
  64. #define GFXDEBUGEVENT_MARKER(n,c)
  65. #define GFXDEBUGEVENT_SCOPE(n,c)
  66. #define GFXDEBUGEVENT_SCOPE_EX(n,c,d)
  67. #endif
  68. #endif // _GFXDEBUGEVENT_H_