intel/fs: add variable for output of debug backend optimizer
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Mon, 7 Aug 2023 14:06:49 +0000 (17:06 +0300)
committerMarge Bot <emma+marge@anholt.net>
Thu, 10 Aug 2023 06:39:57 +0000 (06:39 +0000)
It can be useful to compare 2 runs with different compiler changes.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24552>

docs/envvars.rst
src/intel/compiler/brw_fs.cpp

index 4dc615c..204637d 100644 (file)
@@ -713,6 +713,22 @@ Intel driver environment variables
    if set to 1, true or yes, then the driver prefers accuracy over
    performance in trig functions.
 
+.. envvar:: INTEL_SHADER_OPTIMIZER_PATH
+
+   if set, determines the directory to be used for overriding shader
+   assembly. The binaries with custom assembly should be placed in
+   this folder and have a name formatted as ``sha1_of_assembly.bin``.
+   The SHA-1 of a shader assembly is printed when assembly is dumped via
+   corresponding :envvar:`INTEL_DEBUG` flag (e.g. ``vs`` for vertex shader).
+   A binary could be generated from a dumped assembly by ``i965_asm``.
+   For :envvar:`INTEL_SHADER_ASM_READ_PATH` to work it is necessary to enable
+   dumping of corresponding shader stages via :envvar:`INTEL_DEBUG`.
+   It is advised to use ``nocompact`` flag of :envvar:`INTEL_DEBUG` when
+   dumping and overriding shader assemblies.
+   The success of assembly override would be signified by "Successfully
+   overrode shader with sha1 <SHA-1>" in stderr replacing the original
+   assembly.
+
 .. envvar:: INTEL_SHADER_ASM_READ_PATH
 
    if set, determines the directory to be used for overriding shader
index 8c981f0..188b60c 100644 (file)
@@ -6200,7 +6200,8 @@ fs_visitor::debug_optimizer(const char *pass_name,
       return;
 
    char *filename;
-   int ret = asprintf(&filename, "%s%d-%s-%02d-%02d-%s",
+   int ret = asprintf(&filename, "%s/%s%d-%s-%02d-%02d-%s",
+                      debug_get_option("INTEL_SHADER_OPTIMIZER_PATH", "./"),
                       stage_abbrev, dispatch_width, nir->info.name,
                       iteration, pass_num, pass_name);
    if (ret == -1)