Path: blob/21.2-virgl/src/gallium/frontends/d3d10umd/Debug.cpp
4565 views
#include "Debug.h"12#include <stdarg.h>3#include <stdio.h>456#ifdef DEBUG78unsigned st_debug = 0;910static const11struct debug_named_value st_debug_flags[] = {12{"oldtexops", ST_DEBUG_OLD_TEX_OPS, "oldtexops"},13{"tgsi", ST_DEBUG_TGSI, "tgsi"},14{NULL, 0, NULL},15};16void17st_debug_parse(void)18{19st_debug = debug_get_flags_option("ST_DEBUG", st_debug_flags, st_debug);20}2122#endif232425void26DebugPrintf(const char *format, ...)27{28char buf[4096];2930va_list ap;31va_start(ap, format);32vsnprintf(buf, sizeof buf, format, ap);33va_end(ap);3435OutputDebugStringA(buf);36}373839/**40* Produce a human readable message from HRESULT.41*42* @sa http://msdn.microsoft.com/en-us/library/ms679351(VS.85).aspx43*/44void45CheckHResult(HRESULT hr, const char *function, unsigned line)46{47if (FAILED(hr)) {48LPSTR lpMessageBuffer = NULL;4950FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER |51FORMAT_MESSAGE_FROM_SYSTEM,52NULL,53hr,54MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),55(LPSTR)&lpMessageBuffer,560,57NULL);5859DebugPrintf("%s: %u: 0x%08lX: %s", function, line, hr, lpMessageBuffer);6061LocalFree(lpMessageBuffer);62}63}646566void67AssertFail(const char *expr,68const char *file,69unsigned line,70const char *function)71{72DebugPrintf("%s:%u:%s: Assertion `%s' failed.\n", file, line, function, expr);73#if defined(__GNUC__)74__asm("int3");75#elif defined(_MSC_VER)76__debugbreak();77#else78DebugBreak();79#endif80}818283