Merge branch 'anv-mesa-log-DEBUG_SHADERS_LINENO' into 'main'

anv: Convert DEBUG_SHADERS_LINENO logging to use mesa_log

See merge request mesa/mesa!38216
This commit is contained in:
Christian Gmeiner 2025-12-29 11:37:53 +01:00
commit bcfbbb8518
3 changed files with 89 additions and 3 deletions

View file

@ -89,9 +89,14 @@ upload_blorp_shader(struct blorp_batch *batch, uint32_t stage,
if (INTEL_DEBUG(DEBUG_SHADERS_LINENO)) {
/* shader hash is zero in this context */
if (!intel_shader_dump_filter) {
brw_disassemble_with_lineno(&device->physical->compiler->isa,
stage, -1, 0, kernel, 0,
bin->kernel.offset, stderr);
FILE *out = mesa_log_file_streami();
if (out) {
brw_disassemble_with_lineno(&device->physical->compiler->isa,
stage, -1, 0, kernel, 0,
bin->kernel.offset, out);
fclose(out);
}
}
}

View file

@ -554,3 +554,77 @@ _mesa_log_multiline(enum mesa_log_level level, const char *tag, const char *line
mesa_log_stream_flush(&tmp, 0);
free(tmp.msg);
}
#if DETECT_OS_LINUX && !DETECT_OS_ANDROID
/* glibc-based Linux (has fopencookie) */
static ssize_t
log_stream_write_cookie(void *cookie, const char *buf, size_t size)
{
mesa_log_stream_printf(cookie, "%.*s", (int)size, buf);
return size;
}
static int
log_stream_close_cookie(void *cookie)
{
mesa_log_stream_destroy(cookie);
return 0;
}
FILE *
mesa_log_stream_to_file(struct log_stream *stream)
{
if (!stream)
return NULL;
static const cookie_io_functions_t funcs = {
.read = NULL,
.write = log_stream_write_cookie,
.seek = NULL,
.close = log_stream_close_cookie
};
return fopencookie(stream, "w", funcs);
}
#elif DETECT_OS_ANDROID || DETECT_OS_APPLE || DETECT_OS_BSD
/* BSD-style (has funopen) */
static int
log_stream_write_func(void *cookie, const char *buf, int size)
{
mesa_log_stream_printf(cookie, "%.*s", size, buf);
return size;
}
static int
log_stream_close_func(void *cookie)
{
mesa_log_stream_destroy(cookie);
return 0;
}
FILE *
mesa_log_stream_to_file(struct log_stream *stream)
{
if (!stream)
return NULL;
return funopen(stream,
NULL, /* read */
log_stream_write_func, /* write */
NULL, /* seek */
log_stream_close_func); /* close */
}
#else
/* Unsupported platform */
FILE *
mesa_log_stream_to_file(struct log_stream *stream)
{
(void)stream;
return NULL;
}
#endif

View file

@ -129,6 +129,13 @@ static inline void PRINTFLIKE(1, 2)
__mesa_log_use_args(UNUSED const char *format, ...) { }
#endif
FILE *
mesa_log_stream_to_file(struct log_stream *stream);
#define mesa_log_file_streame() mesa_log_stream_to_file(mesa_log_streame())
#define mesa_log_file_streamw() mesa_log_stream_to_file(mesa_log_streamw())
#define mesa_log_file_streami() mesa_log_stream_to_file(mesa_log_streami())
#ifdef __cplusplus
}
#endif