Path: blob/21.2-virgl/src/gallium/frontends/nine/nine_debug.h
4561 views
/*1* Copyright 2011 Joakim Sindholt <[email protected]>2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* on the rights to use, copy, modify, merge, publish, distribute, sub7* license, and/or sell copies of the Software, and to permit persons to whom8* the Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice (including the next11* paragraph) shall be included in all copies or substantial portions of the12* Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL17* THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,18* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR19* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE20* USE OR OTHER DEALINGS IN THE SOFTWARE. */2122#ifndef _NINE_DEBUG_H_23#define _NINE_DEBUG_H_2425#include "util/u_debug.h"26#include "pipe/p_compiler.h"2728void29_nine_debug_printf( unsigned long flag,30const char *func,31const char *fmt,32... ) _util_printf_format(3,4);3334#define ERR(fmt, ...) _nine_debug_printf(DBG_ERROR, __FUNCTION__, fmt, ## __VA_ARGS__)3536#if defined(DEBUG) || !defined(NDEBUG)37#define WARN(fmt, ...) _nine_debug_printf(DBG_WARN, __FUNCTION__, fmt, ## __VA_ARGS__)38#define WARN_ONCE(fmt, ...) \39do { \40static boolean once = TRUE; \41if (once) { \42once = FALSE; \43_nine_debug_printf(DBG_WARN, __FUNCTION__, fmt, ## __VA_ARGS__); \44} \45} while(0)46#else47#define WARN(fmt, ...) do {} while(0)48#define WARN_ONCE(fmt, ...) do {} while(0)49#endif5051#if defined(DEBUG) || !defined(NDEBUG)52#define DBG_FLAG(flag, fmt, ...) \53_nine_debug_printf(flag, __FUNCTION__, fmt, ## __VA_ARGS__)54#else55#define DBG_FLAG(flag, fmt, ...) do {} while(0)56#endif57#define DBG(fmt, ...) DBG_FLAG(DBG_CHANNEL, fmt, ## __VA_ARGS__)5859#define DBG_UNKNOWN (1<< 0)60#define DBG_ADAPTER (1<< 1)61#define DBG_OVERLAYEXTENSION (1<< 2)62#define DBG_AUTHENTICATEDCHANNEL (1<< 3)63#define DBG_BASETEXTURE (1<< 4)64#define DBG_CRYPTOSESSION (1<< 5)65#define DBG_CUBETEXTURE (1<< 6)66#define DBG_DEVICE (1<< 7)67#define DBG_DEVICEVIDEO (1<< 8)68#define DBG_INDEXBUFFER (1<< 9)69#define DBG_PIXELSHADER (1<<10)70#define DBG_QUERY (1<<11)71#define DBG_RESOURCE (1<<12)72#define DBG_STATEBLOCK (1<<13)73#define DBG_SURFACE (1<<14)74#define DBG_SWAPCHAIN (1<<15)75#define DBG_TEXTURE (1<<16)76#define DBG_VERTEXBUFFER (1<<17)77#define DBG_VERTEXDECLARATION (1<<18)78#define DBG_VERTEXSHADER (1<<19)79#define DBG_VOLUME (1<<20)80#define DBG_VOLUMETEXTURE (1<<21)81#define DBG_SHADER (1<<22)82#define DBG_FF (1<<23)83#define DBG_USER (1<<24)84#define DBG_ERROR (1<<25)85#define DBG_WARN (1<<26)86#define DBG_TID (1<<27)8788void89_nine_stub( const char *file,90const char *func,91unsigned line );9293#if defined(DEBUG) || !defined(NDEBUG)94#define STUB(ret) \95do { \96_nine_stub(__FILE__, __FUNCTION__, __LINE__); \97return ret; \98} while (0)99#else100#define STUB(ret) do { return ret; } while (0)101#endif102103/* the expression for this macro is equivalent of that to assert, however this104* macro is designed to be used in conditionals ala105* if (user_error(required condition)) { assertion failed }106* It also prints debug message if the assertion fails. */107#if defined(DEBUG) || !defined(NDEBUG)108#define user_error(x) \109(!(x) ? (DBG_FLAG(DBG_USER, "User assertion failed: `%s'\n", #x), TRUE) \110: FALSE)111#else112#define user_error(x) (!(x) ? TRUE : FALSE)113#endif114115#if defined(DEBUG) || !defined(NDEBUG)116#define user_warn(x) \117if ((x)) { DBG_FLAG(DBG_USER, "User warning: `%s'\n", #x); }118#else119#define user_warn(x) do {} while(0)120#endif121122/* nonfatal assert */123#define user_assert(x, r) \124do { \125if (user_error(x)) { \126return r; \127} \128} while (0)129130#define ret_err(x, r) \131do { \132ERR(x); \133return r; \134} while(0)135136#endif /* _NINE_DEBUG_H_ */137138139