mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-09-13 09:16:14 -07:00
vkd3d-shader: Allow writing log output via a custom callback.
When using PE vkd3d through Wine, debug output may be swallowed by writing to Win32 stderr. Avoid this by providing a way to hook up vkd3d log output to Wine output. Signed-off-by: Zebediah Figura <zfigura@codeweavers.com> Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
6ff6cb4ed2
commit
174172887b
@ -47,6 +47,7 @@ enum vkd3d_dbg_level
|
||||
enum vkd3d_dbg_level vkd3d_dbg_get_level(void);
|
||||
|
||||
void vkd3d_dbg_printf(enum vkd3d_dbg_level level, const char *function, const char *fmt, ...) VKD3D_PRINTF_FUNC(3, 4);
|
||||
void vkd3d_dbg_set_log_callback(PFN_vkd3d_log callback);
|
||||
|
||||
const char *vkd3d_dbg_sprintf(const char *fmt, ...) VKD3D_PRINTF_FUNC(1, 2);
|
||||
const char *vkd3d_dbg_vsprintf(const char *fmt, va_list args);
|
||||
|
@ -1806,6 +1806,18 @@ VKD3D_SHADER_API void vkd3d_shader_free_shader_signature(struct vkd3d_shader_sig
|
||||
VKD3D_SHADER_API int vkd3d_shader_preprocess(const struct vkd3d_shader_compile_info *compile_info,
|
||||
struct vkd3d_shader_code *out, char **messages);
|
||||
|
||||
/**
|
||||
* Set a callback to be called when vkd3d-shader outputs debug logging.
|
||||
*
|
||||
* If NULL, or if this function has not been called, libvkd3d-shader will print
|
||||
* all enabled log output to stderr.
|
||||
*
|
||||
* \param callback Callback function to set.
|
||||
*
|
||||
* \since 1.4
|
||||
*/
|
||||
VKD3D_SHADER_API void vkd3d_shader_set_log_callback(PFN_vkd3d_log callback);
|
||||
|
||||
#endif /* VKD3D_SHADER_NO_PROTOTYPES */
|
||||
|
||||
/** Type of vkd3d_shader_get_version(). */
|
||||
@ -1859,6 +1871,9 @@ typedef void (*PFN_vkd3d_shader_free_shader_signature)(struct vkd3d_shader_signa
|
||||
typedef void (*PFN_vkd3d_shader_preprocess)(struct vkd3d_shader_compile_info *compile_info,
|
||||
struct vkd3d_shader_code *out, char **messages);
|
||||
|
||||
/** Type of vkd3d_shader_set_log_callback(). \since 1.4 */
|
||||
typedef void (*PFN_vkd3d_shader_set_log_callback)(PFN_vkd3d_log callback);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
@ -19,6 +19,8 @@
|
||||
#ifndef __VKD3D_TYPES_H
|
||||
#define __VKD3D_TYPES_H
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
@ -53,6 +55,8 @@ enum vkd3d_result
|
||||
VKD3D_FORCE_32_BIT_ENUM(VKD3D_RESULT),
|
||||
};
|
||||
|
||||
typedef void (*PFN_vkd3d_log)(const char *format, va_list args);
|
||||
|
||||
#ifdef _WIN32
|
||||
# define VKD3D_IMPORT __declspec(dllimport)
|
||||
# define VKD3D_EXPORT __declspec(dllexport)
|
||||
|
@ -68,6 +68,25 @@ enum vkd3d_dbg_level vkd3d_dbg_get_level(void)
|
||||
return level;
|
||||
}
|
||||
|
||||
static PFN_vkd3d_log log_callback;
|
||||
|
||||
static void vkd3d_dbg_voutput(const char *fmt, va_list args)
|
||||
{
|
||||
if (log_callback)
|
||||
log_callback(fmt, args);
|
||||
else
|
||||
vfprintf(stderr, fmt, args);
|
||||
}
|
||||
|
||||
static void vkd3d_dbg_output(const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_start(args, fmt);
|
||||
vkd3d_dbg_voutput(fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void vkd3d_dbg_printf(enum vkd3d_dbg_level level, const char *function, const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
@ -77,12 +96,17 @@ void vkd3d_dbg_printf(enum vkd3d_dbg_level level, const char *function, const ch
|
||||
|
||||
assert(level < ARRAY_SIZE(debug_level_names));
|
||||
|
||||
fprintf(stderr, "%s:%s: ", debug_level_names[level], function);
|
||||
vkd3d_dbg_output("%s:%s ", debug_level_names[level], function);
|
||||
va_start(args, fmt);
|
||||
vfprintf(stderr, fmt, args);
|
||||
vkd3d_dbg_voutput(fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void vkd3d_dbg_set_log_callback(PFN_vkd3d_log callback)
|
||||
{
|
||||
log_callback = callback;
|
||||
}
|
||||
|
||||
static char *get_buffer(void)
|
||||
{
|
||||
static char buffers[VKD3D_DEBUG_BUFFER_COUNT][VKD3D_DEBUG_BUFFER_SIZE];
|
||||
|
@ -17,6 +17,7 @@ global:
|
||||
vkd3d_shader_preprocess;
|
||||
vkd3d_shader_scan;
|
||||
vkd3d_shader_serialize_root_signature;
|
||||
vkd3d_shader_set_log_callback;
|
||||
|
||||
local: *;
|
||||
};
|
||||
|
@ -1550,3 +1550,8 @@ int vkd3d_shader_preprocess(const struct vkd3d_shader_compile_info *compile_info
|
||||
vkd3d_shader_message_context_cleanup(&message_context);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void vkd3d_shader_set_log_callback(PFN_vkd3d_log callback)
|
||||
{
|
||||
vkd3d_dbg_set_log_callback(callback);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user