glamor_debug.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * Copyright © 2009 Intel Corporation
  3. * Copyright © 1998 Keith Packard
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining a
  6. * copy of this software and associated documentation files (the "Software"),
  7. * to deal in the Software without restriction, including without limitation
  8. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  9. * and/or sell copies of the Software, and to permit persons to whom the
  10. * Software is furnished to do so, subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice (including the next
  13. * paragraph) shall be included in all copies or substantial portions of the
  14. * Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  19. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  21. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  22. * IN THE SOFTWARE.
  23. *
  24. * Authors:
  25. * Zhigang Gong <zhigang.gong@gmail.com>
  26. *
  27. */
  28. #ifndef __GLAMOR_DEBUG_H__
  29. #define __GLAMOR_DEBUG_H__
  30. #define GLAMOR_DELAYED_STRING_MAX 64
  31. #define GLAMOR_DEBUG_NONE 0
  32. #define GLAMOR_DEBUG_UNIMPL 0
  33. #define GLAMOR_DEBUG_FALLBACK 1
  34. #define GLAMOR_DEBUG_TEXTURE_DOWNLOAD 2
  35. #define GLAMOR_DEBUG_TEXTURE_DYNAMIC_UPLOAD 3
  36. extern void
  37. AbortServer(void)
  38. _X_NORETURN;
  39. #define GLAMOR_PANIC(_format_, ...) \
  40. do { \
  41. LogMessageVerb(X_NONE, 0, "Glamor Fatal Error" \
  42. " at %32s line %d: " _format_ "\n", \
  43. __FUNCTION__, __LINE__, \
  44. ##__VA_ARGS__ ); \
  45. exit(1); \
  46. } while(0)
  47. #define __debug_output_message(_format_, _prefix_, ...) \
  48. LogMessageVerb(X_NONE, 0, \
  49. "%32s:\t" _format_ , \
  50. /*_prefix_,*/ \
  51. __FUNCTION__, \
  52. ##__VA_ARGS__)
  53. #define glamor_debug_output(_level_, _format_,...) \
  54. do { \
  55. if (glamor_debug_level >= _level_) \
  56. __debug_output_message(_format_, \
  57. "Glamor debug", \
  58. ##__VA_ARGS__); \
  59. } while(0)
  60. #define glamor_fallback(_format_,...) \
  61. do { \
  62. if (glamor_debug_level >= GLAMOR_DEBUG_FALLBACK) \
  63. __debug_output_message(_format_, \
  64. "Glamor fallback", \
  65. ##__VA_ARGS__);} while(0)
  66. #define glamor_delayed_fallback(_screen_, _format_,...) \
  67. do { \
  68. if (glamor_debug_level >= GLAMOR_DEBUG_FALLBACK) { \
  69. glamor_screen_private *_glamor_priv_; \
  70. _glamor_priv_ = glamor_get_screen_private(_screen_); \
  71. _glamor_priv_->delayed_fallback_pending = 1; \
  72. snprintf(_glamor_priv_->delayed_fallback_string, \
  73. GLAMOR_DELAYED_STRING_MAX, \
  74. "glamor delayed fallback: \t%s " _format_ , \
  75. __FUNCTION__, ##__VA_ARGS__); } } while(0)
  76. #define glamor_clear_delayed_fallbacks(_screen_) \
  77. do { \
  78. if (glamor_debug_level >= GLAMOR_DEBUG_FALLBACK) { \
  79. glamor_screen_private *_glamor_priv_; \
  80. _glamor_priv_ = glamor_get_screen_private(_screen_); \
  81. _glamor_priv_->delayed_fallback_pending = 0; } } while(0)
  82. #define glamor_report_delayed_fallbacks(_screen_) \
  83. do { \
  84. if (glamor_debug_level >= GLAMOR_DEBUG_FALLBACK) { \
  85. glamor_screen_private *_glamor_priv_; \
  86. _glamor_priv_ = glamor_get_screen_private(_screen_); \
  87. LogMessageVerb(X_INFO, 0, "%s", \
  88. _glamor_priv_->delayed_fallback_string); \
  89. _glamor_priv_->delayed_fallback_pending = 0; } } while(0)
  90. #define DEBUGF(str, ...) do {} while(0)
  91. //#define DEBUGF(str, ...) ErrorF(str, ##__VA_ARGS__)
  92. #define DEBUGRegionPrint(x) do {} while (0)
  93. //#define DEBUGRegionPrint RegionPrint
  94. #endif