summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/i965
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2021-07-29 14:27:57 -0700
committerMarge Bot <eric+marge@anholt.net>2021-08-01 23:58:08 +0000
commit5ffbee84a4b9ccfb9ba1cb7d054590cf4030353d (patch)
treedb9cd474ea4ac898eb70bf889a10143d87bb1815 /src/mesa/drivers/dri/i965
parent043c5bf966a276c02c536846f44a1335e082789c (diff)
intel/compiler: Add id parameter to shader_perf_log callback
There are two problems with the current architecture. In OpenGL, the id is supposed to be a unique identifier for a particular log source. This is done so that applications can (theoretically) filter particular log messages. The debug callback infrastructure in Mesa assigns a uniqe value when a value of 0 is passed in. This causes the id to get set once to a unique value for each message. By passing a stack variable that is initialized to 0 on every call, every time the same message is logged, it will have a different id. This isn't great, but it's also not catastrophic. When threaded shader compiles are used, the id *pointer* is saved and dereferenced at a possibly much later time on a possibly different thread. This causes one thread to access the stack from a different thread... and that stack frame might not be valid any more. :( I have not observed any crashes related to this particular issue. Reviewed-by: Matt Turner <mattst88@gmail.com> Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12136>
Diffstat (limited to 'src/mesa/drivers/dri/i965')
-rw-r--r--src/mesa/drivers/dri/i965/brw_program.c4
-rw-r--r--src/mesa/drivers/dri/i965/brw_screen.c5
2 files changed, 4 insertions, 5 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_program.c b/src/mesa/drivers/dri/i965/brw_program.c
index 0265fd73ea0..4cf5172e16d 100644
--- a/src/mesa/drivers/dri/i965/brw_program.c
+++ b/src/mesa/drivers/dri/i965/brw_program.c
@@ -964,8 +964,8 @@ brw_debug_recompile(struct brw_context *brw,
const struct brw_compiler *compiler = brw->screen->compiler;
enum brw_cache_id cache_id = brw_stage_cache_id(stage);
- compiler->shader_perf_log(brw, "Recompiling %s shader for program %d\n",
- _mesa_shader_stage_to_string(stage), api_id);
+ brw_shader_perf_log(compiler, brw, "Recompiling %s shader for program %d\n",
+ _mesa_shader_stage_to_string(stage), api_id);
const void *old_key =
brw_find_previous_compile(&brw->cache, cache_id, key->program_string_id);
diff --git a/src/mesa/drivers/dri/i965/brw_screen.c b/src/mesa/drivers/dri/i965/brw_screen.c
index 20ca5c21451..4c5bc64a4a5 100644
--- a/src/mesa/drivers/dri/i965/brw_screen.c
+++ b/src/mesa/drivers/dri/i965/brw_screen.c
@@ -2486,7 +2486,7 @@ shader_debug_log_mesa(void *data, unsigned *msg_id, const char *fmt, ...)
}
static void
-shader_perf_log_mesa(void *data, const char *fmt, ...)
+shader_perf_log_mesa(void *data, unsigned *msg_id, const char *fmt, ...)
{
struct brw_context *brw = (struct brw_context *)data;
@@ -2501,8 +2501,7 @@ shader_perf_log_mesa(void *data, const char *fmt, ...)
}
if (brw->perf_debug) {
- GLuint msg_id = 0;
- _mesa_gl_vdebugf(&brw->ctx, &msg_id,
+ _mesa_gl_vdebugf(&brw->ctx, msg_id,
MESA_DEBUG_SOURCE_SHADER_COMPILER,
MESA_DEBUG_TYPE_PERFORMANCE,
MESA_DEBUG_SEVERITY_MEDIUM, fmt, args);