[Mesa-dev] [PATCH shader-db] Set more env-var's in run.c

Matt Turner mattst88 at gmail.com
Tue Dec 1 17:00:31 PST 2015


On Tue, Dec 1, 2015 at 4:40 PM, Rob Clark <robdclark at gmail.com> wrote:
> Simplify the instructions a bit by setting all the potentially needed
> environment variables in run.c itself.
>
> Made very trivially more complex by the fact that all of the gallium
> drivers are using u_debug stuff, so one env var contains potentially
> multiple flags.  We don't want to clobber any other flags that are set
> so we simply append.
> ---
>  README |  4 ++--
>  run.c  | 22 ++++++++++++++++++++--
>  2 files changed, 22 insertions(+), 4 deletions(-)
>
> diff --git a/README b/README
> index 5477bf5..06294c9 100644
> --- a/README
> +++ b/README
> @@ -37,7 +37,7 @@ to run.
>
>  === Running shaders ===
>
> -ST_DEBUG=precompile R600_DEBUG=ps,vs,gs,precompile ./run shaders -1 2> new-run
> +./run shaders -1 2> new-run
>
>  Note that a debug mesa build required (ie. --enable-debug)
>
> @@ -50,7 +50,7 @@ Note that a debug mesa build required (ie. --enable-debug)
>
>  === Running shaders ===
>
> -FD_MESA_DEBUG=shaderdb ST_DEBUG=precompile ./run -1 shaders 2> new-run
> +./run -1 shaders 2> new-run

Huh, I didn't realize freedreno support was a thing. Must have missed the patch.

>
>  Note that a debug mesa build required (ie. --enable-debug)

That's awful... at least for a lot of shaders. You're going to want to
run shader-db on optimized builds.

>
> diff --git a/run.c b/run.c
> index 73e468d..82d8c91 100644
> --- a/run.c
> +++ b/run.c
> @@ -23,13 +23,15 @@
>   * DEALINGS IN THE SOFTWARE.
>   */
>
> +/* for memmem(). The man page doesn't say __USE_GNU... */
> +/* also for asprintf() */
> +#define _GNU_SOURCE
> +
>  #include <time.h>
>  #include <stdio.h>
>  #include <fcntl.h>
>  #include <assert.h>
>  #include <signal.h>
> -/* for memmem(). The man page doesn't say __USE_GNU... */
> -#define __USE_GNU
>  #include <string.h>
>  #include <stdlib.h>
>  #include <unistd.h>
> @@ -292,6 +294,19 @@ void print_usage(const char *prog_name)
>              prog_name);
>  }
>
> +static void addenv(const char *name, const char *value)
> +{
> +    const char *orig = getenv(name);
> +    if (orig) {
> +        char *newval;
> +        asprintf(&newval, "%s,%s", orig, value);
> +        setenv(name, newval, 1);
> +        free(newval);
> +    } else {
> +        setenv(name, value, 1);
> +    }
> +}
> +
>  int
>  main(int argc, char **argv)
>  {
> @@ -340,6 +355,9 @@ main(int argc, char **argv)
>
>      setenv("allow_glsl_extension_directive_midshader", "true", 1);
>      setenv("shader_precompile", "true", 1);
> +    addenv("ST_DEBUG", "precompile");
> +    addenv("R600_DEBUG", "ps,vs,gs,precompile");
> +    addenv("FD_MESA_DEBUG", "shaderdb");

Other than allow_glsl_extension_directive_midshader, I don't think any
of these should really be necessary ideally. I think adding
shader_precompile was unnecessary since it's on by default.

The Radeon support is hacky and predates support for getting KHR_debug
messages through all the Gallium layers. I'd kinda rather leave those
envars in the README as a reminder to use KHR_debug. :)

And why isn't freedreno using KHR_debug?

I don't get it. I write this tool that allows parallel compilation and
everyone just hacks up their drivers (and now shader-db) enough to get
non-concurrent compilation.


More information about the mesa-dev mailing list