intel/compiler: Add id parameter to shader_perf_log callback
authorIan Romanick <ian.d.romanick@intel.com>
Thu, 29 Jul 2021 21:27:57 +0000 (14:27 -0700)
committerMarge Bot <eric+marge@anholt.net>
Sun, 1 Aug 2021 23:58:08 +0000 (23:58 +0000)
commit5ffbee84a4b9ccfb9ba1cb7d054590cf4030353d
treedb9cd474ea4ac898eb70bf889a10143d87bb1815
parent043c5bf966a276c02c536846f44a1335e082789c
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>
src/gallium/drivers/crocus/crocus_program.c
src/gallium/drivers/crocus/crocus_screen.c
src/gallium/drivers/iris/iris_program.c
src/gallium/drivers/iris/iris_screen.c
src/intel/compiler/brw_compiler.h
src/intel/compiler/brw_debug_recompile.c
src/intel/compiler/brw_fs.cpp
src/intel/compiler/brw_vec4.cpp
src/intel/vulkan/anv_device.c
src/mesa/drivers/dri/i965/brw_program.c
src/mesa/drivers/dri/i965/brw_screen.c