2016-09-21 03:57:24 -07:00
|
|
|
/*
|
|
|
|
* Copyright 2016 Józef Kucia for CodeWeavers
|
|
|
|
*
|
2017-06-16 12:05:54 -07:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2016-09-21 03:57:24 -07:00
|
|
|
*
|
2017-06-16 12:05:54 -07:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2016-09-21 03:57:24 -07:00
|
|
|
*
|
2017-06-16 12:05:54 -07:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2016-09-21 03:57:24 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __VKD3D_DEBUG_H
|
|
|
|
#define __VKD3D_DEBUG_H
|
|
|
|
|
|
|
|
#include "vkd3d_common.h"
|
|
|
|
|
2018-04-16 03:16:21 -07:00
|
|
|
#include <stdarg.h>
|
2019-05-17 01:39:14 -07:00
|
|
|
#include <stdbool.h>
|
2019-04-30 05:33:49 -07:00
|
|
|
#include <stdint.h>
|
2018-04-16 03:16:21 -07:00
|
|
|
|
2019-04-04 04:01:32 -07:00
|
|
|
#ifdef VKD3D_NO_TRACE_MESSAGES
|
2019-04-26 03:37:01 -07:00
|
|
|
#define TRACE(args...) do { } while (0)
|
2019-05-06 05:47:43 -07:00
|
|
|
#define TRACE_ON() (false)
|
2019-04-04 04:01:32 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef VKD3D_NO_DEBUG_MESSAGES
|
2019-04-26 03:37:01 -07:00
|
|
|
#define WARN(args...) do { } while (0)
|
|
|
|
#define FIXME(args...) do { } while (0)
|
2019-04-04 04:01:32 -07:00
|
|
|
#endif
|
|
|
|
|
2016-09-21 03:57:24 -07:00
|
|
|
enum vkd3d_dbg_level
|
|
|
|
{
|
|
|
|
VKD3D_DBG_LEVEL_NONE,
|
|
|
|
VKD3D_DBG_LEVEL_ERR,
|
|
|
|
VKD3D_DBG_LEVEL_FIXME,
|
|
|
|
VKD3D_DBG_LEVEL_WARN,
|
|
|
|
VKD3D_DBG_LEVEL_TRACE,
|
|
|
|
};
|
|
|
|
|
2021-08-08 23:11:49 -07:00
|
|
|
enum vkd3d_dbg_level vkd3d_dbg_get_level(void);
|
2017-06-19 09:05:53 -07:00
|
|
|
|
2021-08-08 23:11:49 -07:00
|
|
|
void vkd3d_dbg_printf(enum vkd3d_dbg_level level, const char *function, const char *fmt, ...) VKD3D_PRINTF_FUNC(3, 4);
|
2022-06-01 17:01:00 -07:00
|
|
|
void vkd3d_dbg_set_log_callback(PFN_vkd3d_log callback);
|
2016-09-21 03:57:24 -07:00
|
|
|
|
2021-08-08 23:11:49 -07:00
|
|
|
const char *vkd3d_dbg_sprintf(const char *fmt, ...) VKD3D_PRINTF_FUNC(1, 2);
|
|
|
|
const char *vkd3d_dbg_vsprintf(const char *fmt, va_list args);
|
|
|
|
const char *debugstr_a(const char *str);
|
2021-10-06 08:11:48 -07:00
|
|
|
const char *debugstr_an(const char *str, size_t n);
|
2021-08-08 23:11:49 -07:00
|
|
|
const char *debugstr_w(const WCHAR *wstr, size_t wchar_size);
|
2016-09-21 03:57:24 -07:00
|
|
|
|
|
|
|
#define VKD3D_DBG_LOG(level) \
|
|
|
|
do { \
|
2016-10-10 02:22:50 -07:00
|
|
|
const enum vkd3d_dbg_level vkd3d_dbg_level = VKD3D_DBG_LEVEL_##level; \
|
2016-09-21 03:57:24 -07:00
|
|
|
VKD3D_DBG_PRINTF
|
|
|
|
|
2019-06-12 05:08:01 -07:00
|
|
|
#define VKD3D_DBG_LOG_ONCE(first_time_level, level) \
|
|
|
|
do { \
|
|
|
|
static bool vkd3d_dbg_next_time; \
|
|
|
|
const enum vkd3d_dbg_level vkd3d_dbg_level = vkd3d_dbg_next_time \
|
|
|
|
? VKD3D_DBG_LEVEL_##level : VKD3D_DBG_LEVEL_##first_time_level; \
|
|
|
|
vkd3d_dbg_next_time = true; \
|
|
|
|
VKD3D_DBG_PRINTF
|
|
|
|
|
2019-10-01 03:33:44 -07:00
|
|
|
#define VKD3D_DBG_PRINTF(...) \
|
|
|
|
vkd3d_dbg_printf(vkd3d_dbg_level, __FUNCTION__, __VA_ARGS__); } while (0)
|
2016-09-21 03:57:24 -07:00
|
|
|
|
2019-04-04 04:01:32 -07:00
|
|
|
#ifndef TRACE
|
2016-09-21 03:57:24 -07:00
|
|
|
#define TRACE VKD3D_DBG_LOG(TRACE)
|
2019-04-04 04:01:32 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef WARN
|
2016-09-21 03:57:24 -07:00
|
|
|
#define WARN VKD3D_DBG_LOG(WARN)
|
2019-04-04 04:01:32 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef FIXME
|
2016-09-21 03:57:24 -07:00
|
|
|
#define FIXME VKD3D_DBG_LOG(FIXME)
|
2019-04-04 04:01:32 -07:00
|
|
|
#endif
|
|
|
|
|
2016-09-21 03:57:24 -07:00
|
|
|
#define ERR VKD3D_DBG_LOG(ERR)
|
|
|
|
|
2019-05-06 05:47:43 -07:00
|
|
|
#ifndef TRACE_ON
|
2017-06-19 09:05:53 -07:00
|
|
|
#define TRACE_ON() (vkd3d_dbg_get_level() == VKD3D_DBG_LEVEL_TRACE)
|
2019-05-06 05:47:43 -07:00
|
|
|
#endif
|
2017-06-19 09:05:53 -07:00
|
|
|
|
2019-06-12 05:08:01 -07:00
|
|
|
#define FIXME_ONCE VKD3D_DBG_LOG_ONCE(FIXME, WARN)
|
|
|
|
|
2023-04-05 13:23:53 -07:00
|
|
|
#define VKD3D_DEBUG_ENV_NAME(name) const char *const vkd3d_dbg_env_name = name
|
2019-01-31 02:29:28 -08:00
|
|
|
|
2016-09-21 03:57:24 -07:00
|
|
|
static inline const char *debugstr_guid(const GUID *guid)
|
|
|
|
{
|
|
|
|
if (!guid)
|
|
|
|
return "(null)";
|
|
|
|
|
2016-09-28 00:42:49 -07:00
|
|
|
return vkd3d_dbg_sprintf("{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
|
|
|
|
(unsigned long)guid->Data1, guid->Data2, guid->Data3, guid->Data4[0],
|
|
|
|
guid->Data4[1], guid->Data4[2], guid->Data4[3], guid->Data4[4],
|
|
|
|
guid->Data4[5], guid->Data4[6], guid->Data4[7]);
|
2016-09-21 03:57:24 -07:00
|
|
|
}
|
|
|
|
|
2024-01-11 12:17:15 -08:00
|
|
|
static inline const char *debugstr_hresult(HRESULT hr)
|
|
|
|
{
|
|
|
|
switch (hr)
|
|
|
|
{
|
|
|
|
#define TO_STR(u) case u: return #u;
|
|
|
|
TO_STR(S_OK)
|
|
|
|
TO_STR(S_FALSE)
|
|
|
|
TO_STR(E_NOTIMPL)
|
|
|
|
TO_STR(E_NOINTERFACE)
|
|
|
|
TO_STR(E_POINTER)
|
|
|
|
TO_STR(E_ABORT)
|
|
|
|
TO_STR(E_FAIL)
|
|
|
|
TO_STR(E_OUTOFMEMORY)
|
|
|
|
TO_STR(E_INVALIDARG)
|
|
|
|
TO_STR(DXGI_ERROR_NOT_FOUND)
|
|
|
|
TO_STR(DXGI_ERROR_MORE_DATA)
|
|
|
|
TO_STR(DXGI_ERROR_UNSUPPORTED)
|
|
|
|
#undef TO_STR
|
|
|
|
default:
|
|
|
|
return vkd3d_dbg_sprintf("%#x", (int)hr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-08 23:11:49 -07:00
|
|
|
unsigned int vkd3d_env_var_as_uint(const char *name, unsigned int default_value);
|
2019-03-14 03:34:56 -07:00
|
|
|
|
2019-04-30 05:33:49 -07:00
|
|
|
struct vkd3d_debug_option
|
|
|
|
{
|
|
|
|
const char *name;
|
|
|
|
uint64_t flag;
|
|
|
|
};
|
|
|
|
|
2021-08-08 23:11:49 -07:00
|
|
|
bool vkd3d_debug_list_has_member(const char *string, const char *member);
|
2019-04-30 05:33:49 -07:00
|
|
|
uint64_t vkd3d_parse_debug_options(const char *string,
|
2021-08-08 23:11:49 -07:00
|
|
|
const struct vkd3d_debug_option *options, unsigned int option_count);
|
2022-09-15 12:07:40 -07:00
|
|
|
void vkd3d_set_thread_name(const char *name);
|
2019-04-30 05:33:49 -07:00
|
|
|
|
2016-09-21 03:57:24 -07:00
|
|
|
#endif /* __VKD3D_DEBUG_H */
|