Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. /*
  2.  * Mesa 3-D graphics library
  3.  *
  4.  * Copyright (C) 2012-2013 LunarG, Inc.
  5.  *
  6.  * Permission is hereby granted, free of charge, to any person obtaining a
  7.  * copy of this software and associated documentation files (the "Software"),
  8.  * to deal in the Software without restriction, including without limitation
  9.  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  10.  * and/or sell copies of the Software, and to permit persons to whom the
  11.  * Software is furnished to do so, subject to the following conditions:
  12.  *
  13.  * The above copyright notice and this permission notice shall be included
  14.  * in all copies or substantial portions of the 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
  22.  * DEALINGS IN THE SOFTWARE.
  23.  *
  24.  * Authors:
  25.  *    Chia-I Wu <olv@lunarg.com>
  26.  */
  27.  
  28. #ifndef ILO_DEBUG_H
  29. #define ILO_DEBUG_H
  30.  
  31. #include "ilo_core.h"
  32.  
  33. /* enable debug flags affecting hot pathes only with debug builds */
  34. #ifdef DEBUG
  35. #define ILO_DEBUG_HOT 1
  36. #else
  37. #define ILO_DEBUG_HOT 0
  38. #endif
  39.  
  40. enum ilo_debug {
  41.    ILO_DEBUG_BATCH     = 1 << 0,
  42.    ILO_DEBUG_VS        = 1 << 1,
  43.    ILO_DEBUG_GS        = 1 << 2,
  44.    ILO_DEBUG_FS        = 1 << 3,
  45.    ILO_DEBUG_CS        = 1 << 4,
  46.    ILO_DEBUG_DRAW      = ILO_DEBUG_HOT << 5,
  47.    ILO_DEBUG_SUBMIT    = 1 << 6,
  48.    ILO_DEBUG_HANG      = 1 << 7,
  49.  
  50.    /* flags that affect the behaviors of the driver */
  51.    ILO_DEBUG_NOHW      = 1 << 20,
  52.    ILO_DEBUG_NOCACHE   = 1 << 21,
  53.    ILO_DEBUG_NOHIZ     = 1 << 22,
  54. };
  55.  
  56. extern int ilo_debug;
  57.  
  58. void
  59. ilo_debug_init(const char *name);
  60.  
  61. /**
  62.  * Print a message, for dumping or debugging.
  63.  */
  64. static inline void _util_printf_format(1, 2)
  65. ilo_printf(const char *format, ...)
  66. {
  67.    va_list ap;
  68.  
  69.    va_start(ap, format);
  70.    _debug_vprintf(format, ap);
  71.    va_end(ap);
  72. }
  73.  
  74. /**
  75.  * Print a critical error.
  76.  */
  77. static inline void _util_printf_format(1, 2)
  78. ilo_err(const char *format, ...)
  79. {
  80.    va_list ap;
  81.  
  82.    va_start(ap, format);
  83.    _debug_vprintf(format, ap);
  84.    va_end(ap);
  85. }
  86.  
  87. /**
  88.  * Print a warning, silenced for release builds.
  89.  */
  90. static inline void _util_printf_format(1, 2)
  91. ilo_warn(const char *format, ...)
  92. {
  93. #ifdef DEBUG
  94.    va_list ap;
  95.  
  96.    va_start(ap, format);
  97.    _debug_vprintf(format, ap);
  98.    va_end(ap);
  99. #else
  100. #endif
  101. }
  102.  
  103. #endif /* ILO_DEBUG_H */
  104.