<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
  <title>Environment Variables</title>
  <link rel="stylesheet" type="text/css" href="mesa.css">
</head>
<body>

<div class="header">
  <h1>The Mesa 3D Graphics Library</h1>
</div>

<iframe src="contents.html"></iframe>
<div class="content">

<h1>Environment Variables</h1>

<p>
Normally, no environment variables need to be set.  Most of the environment
variables used by Mesa/Gallium are for debugging purposes, but they can
sometimes be useful for debugging end-user issues.
</p>


<h2>LibGL environment variables</h2>

<ul>
<li>LIBGL_DEBUG - If defined debug information will be printed to stderr.
   If set to 'verbose' additional information will be printed.
<li>LIBGL_DRIVERS_PATH - colon-separated list of paths to search for DRI drivers
<li>LIBGL_ALWAYS_INDIRECT - forces an indirect rendering context/connection.
<li>LIBGL_ALWAYS_SOFTWARE - if set, always use software rendering
<li>LIBGL_NO_DRAWARRAYS - if set do not use DrawArrays GLX protocol (for debugging)
<li>LIBGL_SHOW_FPS - print framerate to stdout based on the number of glXSwapBuffers
    calls per second.
<li>LIBGL_DRI3_DISABLE - disable DRI3 if set (the value does not matter)
</ul>



<h2>Core Mesa environment variables</h2>

<ul>
<li>MESA_NO_ASM - if set, disables all assembly language optimizations
<li>MESA_NO_MMX - if set, disables Intel MMX optimizations
<li>MESA_NO_3DNOW - if set, disables AMD 3DNow! optimizations
<li>MESA_NO_SSE - if set, disables Intel SSE optimizations
<li>MESA_DEBUG - if set, error messages are printed to stderr.  For example,
   if the application generates a GL_INVALID_ENUM error, a corresponding error
   message indicating where the error occurred, and possibly why, will be
   printed to stderr.<br>

   For release builds, MESA_DEBUG defaults to off (no debug output).

   MESA_DEBUG accepts the following comma-separated list of named
   flags, which adds extra behaviour to just set MESA_DEBUG=1:
   <ul>
     <li>silent - turn off debug messages. Only useful for debug builds.</li>
     <li>flush - flush after each drawing command</li>
     <li>incomplete_tex - extra debug messages when a texture is incomplete</li>
     <li>incomplete_fbo - extra debug messages when a fbo is incomplete</li>
     <li>context - create a debug context (see GLX_CONTEXT_DEBUG_BIT_ARB) and
         print error and performance messages to stderr (or MESA_LOG_FILE).</li>
   </ul>
<li>MESA_LOG_FILE - specifies a file name for logging all errors, warnings,
etc., rather than stderr
<li>MESA_TEX_PROG - if set, implement conventional texture env modes with
fragment programs (intended for developers only)
<li>MESA_TNL_PROG - if set, implement conventional vertex transformation
operations with vertex programs (intended for developers only).
Setting this variable automatically sets the MESA_TEX_PROG variable as well.
<li>MESA_EXTENSION_OVERRIDE - can be used to enable/disable extensions.
A value such as "GL_EXT_foo -GL_EXT_bar" will enable the GL_EXT_foo extension
and disable the GL_EXT_bar extension.
<li>MESA_EXTENSION_MAX_YEAR - The GL_EXTENSIONS string returned by Mesa is sorted
by extension year.
If this variable is set to year X, only extensions defined on or before year
X will be reported.
This is to work-around a bug in some games where the extension string is
copied into a fixed-size buffer without truncating.
If the extension string is too long, the buffer overrun can cause the game
to crash.
This is a work-around for that.
<li>MESA_GL_VERSION_OVERRIDE - changes the value returned by
glGetString(GL_VERSION) and possibly the GL API type.
<ul>
<li> The format should be MAJOR.MINOR[FC]
<li> FC is an optional suffix that indicates a forward compatible context.
This is only valid for versions &gt;= 3.0.
<li> GL versions &lt; 3.0 are set to a compatibility (non-Core) profile
<li> GL versions = 3.0, see below
<li> GL versions &gt; 3.0 are set to a Core profile
<li> Examples: 2.1, 3.0, 3.0FC, 3.1, 3.1FC
<ul>
<li> 2.1 - select a compatibility (non-Core) profile with GL version 2.1
<li> 3.0 - select a compatibility (non-Core) profile with GL version 3.0
<li> 3.0FC - select a Core+Forward Compatible profile with GL version 3.0
<li> 3.1 - select a Core profile with GL version 3.1
<li> 3.1FC - select a Core+Forward Compatible profile with GL version 3.1
</ul>
<li> Mesa may not really implement all the features of the given version.
(for developers only)
</ul>
<li>MESA_GLES_VERSION_OVERRIDE - changes the value returned by
glGetString(GL_VERSION) for OpenGL ES.
<ul>
<li> The format should be MAJOR.MINOR
<li> Examples: 2.0, 3.0, 3.1
<li> Mesa may not really implement all the features of the given version.
(for developers only)
</ul>
<li>MESA_GLSL_VERSION_OVERRIDE - changes the value returned by
glGetString(GL_SHADING_LANGUAGE_VERSION). Valid values are integers, such as
"130".  Mesa will not really implement all the features of the given language version
if it's higher than what's normally reported. (for developers only)
<li>MESA_GLSL_CACHE_DISABLE - if set, disables the GLSL shader cache
<li>MESA_GLSL_CACHE_MAX_SIZE - if set, determines the maximum size of
the on-disk cache of compiled GLSL programs. Should be set to a number
optionally followed by 'K', 'M', or 'G' to specify a size in
kilobytes, megabytes, or gigabytes. By default, gigabytes will be
assumed. And if unset, a maxium size of 1GB will be used.
<li>MESA_GLSL_CACHE_DIR - if set, determines the directory to be used
for the on-disk cache of compiled GLSL programs. If this variable is
not set, then the cache will be stored in $XDG_CACHE_HOME/mesa (if
that variable is set), or else within .cache/mesa within the user's
home directory.
<li>MESA_GLSL - <a href="shading.html#envvars">shading language compiler options</a>
<li>MESA_NO_MINMAX_CACHE - when set, the minmax index cache is globally disabled.
</ul>


<h2>Mesa Xlib driver environment variables</h2>

<p>
The following are only applicable to the Mesa Xlib software driver.
See the <a href="xlibdriver.html">Xlib software driver page</a> for details.
</p>
<ul>
<li>MESA_RGB_VISUAL - specifies the X visual and depth for RGB mode
<li>MESA_CI_VISUAL - specifies the X visual and depth for CI mode
<li>MESA_BACK_BUFFER - specifies how to implement the back color buffer,
    either "pixmap" or "ximage"
<li>MESA_GAMMA - gamma correction coefficients for red, green, blue channels
<li>MESA_XSYNC - enable synchronous X behavior (for debugging only)
<li>MESA_GLX_FORCE_CI - if set, force GLX to treat 8bpp visuals as CI visuals
<li>MESA_GLX_FORCE_ALPHA - if set, forces RGB windows to have an alpha channel.
<li>MESA_GLX_DEPTH_BITS - specifies default number of bits for depth buffer.
<li>MESA_GLX_ALPHA_BITS - specifies default number of bits for alpha channel.
</ul>


<h2>i945/i965 driver environment variables (non-Gallium)</h2>

<ul>
<li>INTEL_NO_HW - if set to 1, prevents batches from being submitted to the hardware.
   This is useful for debugging hangs, etc.</li>
<li>INTEL_DEBUG - a comma-separated list of named flags, which do various things:
<ul>
   <li>tex - emit messages about textures.</li>
   <li>state - emit messages about state flag tracking</li>
   <li>blit - emit messages about blit operations</li>
   <li>miptree - emit messages about miptrees</li>
   <li>perf - emit messages about performance issues</li>
   <li>perfmon - emit messages about AMD_performance_monitor</li>
   <li>bat - emit batch information</li>
   <li>pix - emit messages about pixel operations</li>
   <li>buf - emit messages about buffer objects</li>
   <li>fbo - emit messages about framebuffers</li>
   <li>fs - dump shader assembly for fragment shaders</li>
   <li>gs - dump shader assembly for geometry shaders</li>
   <li>sync - after sending each batch, emit a message and wait for that batch to finish rendering</li>
   <li>prim - emit messages about drawing primitives</li>
   <li>vert - emit messages about vertex assembly</li>
   <li>dri - emit messages about the DRI interface</li>
   <li>sf - emit messages about the strips &amp; fans unit (for old gens, includes the SF program)</li>
   <li>stats - enable statistics counters. you probably actually want perfmon or intel_gpu_top instead.</li>
   <li>urb - emit messages about URB setup</li>
   <li>vs - dump shader assembly for vertex shaders</li>
   <li>clip - emit messages about the clip unit (for old gens, includes the CLIP program)</li>
   <li>aub - dump batches into an AUB trace for use with simulation tools</li>
   <li>shader_time - record how much GPU time is spent in each shader</li>
   <li>no16 - suppress generation of 16-wide fragment shaders. useful for debugging broken shaders</li>
   <li>blorp - emit messages about the blorp operations (blits &amp; clears)</li>
   <li>nodualobj - suppress generation of dual-object geometry shader code</li>
   <li>optimizer - dump shader assembly to files at each optimization pass and iteration that make progress</li>
   <li>ann - annotate IR in assembly dumps</li>
   <li>no8 - don't generate SIMD8 fragment shader</li>
   <li>vec4 - force vec4 mode in vertex shader</li>
   <li>spill_fs - force spilling of all registers in the scalar backend (useful to debug spilling code)</li>
   <li>spill_vec4 - force spilling of all registers in the vec4 backend (useful to debug spilling code)</li>
   <li>cs - dump shader assembly for compute shaders</li>
   <li>hex - print instruction hex dump with the disassembly</li>
   <li>nocompact - disable instruction compaction</li>
   <li>tcs - dump shader assembly for tessellation control shaders</li>
   <li>tes - dump shader assembly for tessellation evaluation shaders</li>
   <li>l3 - emit messages about the new L3 state during transitions</li>
   <li>do32 - generate compute shader SIMD32 programs even if workgroup size doesn't exceed the SIMD16 limit</li>
   <li>norbc - disable single sampled render buffer compression</li>
</ul>
<li>INTEL_PRECISE_TRIG - if set to 1, true or yes, then the driver prefers
   accuracy over performance in trig functions.</li>
</ul>


<h2>Radeon driver environment variables (radeon, r200, and r300g)</h2>

<ul>
<li>RADEON_NO_TCL - if set, disable hardware-accelerated Transform/Clip/Lighting.
</ul>


<h2>EGL environment variables</h2>

<p>
Mesa EGL supports different sets of environment variables.  See the
<a href="egl.html">Mesa EGL</a> page for the details.
</p>


<h2>Gallium environment variables</h2>

<ul>
<li>GALLIUM_HUD - draws various information on the screen, like framerate,
    cpu load, driver statistics, performance counters, etc.
    Set GALLIUM_HUD=help and run e.g. glxgears for more info.
<li>GALLIUM_HUD_PERIOD - sets the hud update rate in seconds (float). Use zero
    to update every frame. The default period is 1/2 second.
<li>GALLIUM_HUD_VISIBLE - control default visibility, defaults to true.
<li>GALLIUM_HUD_TOGGLE_SIGNAL - toggle visibility via user specified signal.
    Especially useful to toggle hud at specific points of application and
    disable for unencumbered viewing the rest of the time. For example, set
    GALLIUM_HUD_VISIBLE to false and GALLIUM_HUD_TOGGLE_SIGNAL to 10 (SIGUSR1).
    Use kill -10 <pid> to toggle the hud as desired.
<li>GALLIUM_HUD_DUMP_DIR - specifies a directory for writing the displayed
    hud values into files.
<li>GALLIUM_DRIVER - useful in combination with LIBGL_ALWAYS_SOFTWARE=1 for
    choosing one of the software renderers "softpipe", "llvmpipe" or "swr".
<li>GALLIUM_LOG_FILE - specifies a file for logging all errors, warnings, etc.
    rather than stderr.
<li>GALLIUM_PRINT_OPTIONS - if non-zero, print all the Gallium environment
    variables which are used, and their current values.
<li>GALLIUM_DUMP_CPU - if non-zero, print information about the CPU on start-up
<li>TGSI_PRINT_SANITY - if set, do extra sanity checking on TGSI shaders and
    print any errors to stderr.
<LI>DRAW_FSE - ???
<LI>DRAW_NO_FSE - ???
<li>DRAW_USE_LLVM - if set to zero, the draw module will not use LLVM to execute
    shaders, vertex fetch, etc.
<li>ST_DEBUG - controls debug output from the Mesa/Gallium state tracker.
Setting to "tgsi", for example, will print all the TGSI shaders.
See src/mesa/state_tracker/st_debug.c for other options.
</ul>

<h3>Clover state tracker environment variables</h3>

<ul>
<li>CLOVER_EXTRA_BUILD_OPTIONS - allows specifying additional compiler and linker
    options. Specified options are appended after the options set by the OpenCL
    program in clBuildProgram.
<li>CLOVER_EXTRA_COMPILE_OPTIONS - allows specifying additional compiler
    options. Specified options are appended after the options set by the OpenCL
    program in clCompileProgram.
<li>CLOVER_EXTRA_LINK_OPTIONS - allows specifying additional linker
    options. Specified options are appended after the options set by the OpenCL
    program in clLinkProgram.
</ul>


<h3>Softpipe driver environment variables</h3>
<ul>
<li>SOFTPIPE_DUMP_FS - if set, the softpipe driver will print fragment shaders
    to stderr
<li>SOFTPIPE_DUMP_GS - if set, the softpipe driver will print geometry shaders
    to stderr
<li>SOFTPIPE_NO_RAST - if set, rasterization is no-op'd.  For profiling purposes.
<li>SOFTPIPE_USE_LLVM - if set, the softpipe driver will try to use LLVM JIT for
    vertex shading processing.
</ul>


<h3>LLVMpipe driver environment variables</h3>
<ul>
<li>LP_NO_RAST - if set LLVMpipe will no-op rasterization
<li>LP_DEBUG - a comma-separated list of debug options is accepted.  See the
    source code for details.
<li>LP_PERF - a comma-separated list of options to selectively no-op various
    parts of the driver.  See the source code for details.
<li>LP_NUM_THREADS - an integer indicating how many threads to use for rendering.
    Zero turns off threading completely.  The default value is the number of CPU
    cores present.
</ul>

<h3>VMware SVGA driver environment variables</h3>
<ul>
<li>SVGA_FORCE_SWTNL - force use of software vertex transformation
<li>SVGA_NO_SWTNL - don't allow software vertex transformation fallbacks
(will often result in incorrect rendering).
<li>SVGA_DEBUG - for dumping shaders, constant buffers, etc.  See the code
for details.
<li>See the driver code for other, lesser-used variables.
</ul>


<h3>VA-API state tracker environment variables</h3>
<ul>
<li>VAAPI_MPEG4_ENABLED - enable MPEG4 for VA-API, disabled by default.
</ul>


<h3>VC4 driver environment variables</h3>
<ul>
<li>VC4_DEBUG - a comma-separated list of named flags, which do various things:
<ul>
   <li>cl - dump command list during creation</li>
   <li>qpu - dump generated QPU instructions</li>
   <li>qir - dump QPU IR during program compile</li>
   <li>nir - dump NIR during program compile</li>
   <li>tgsi - dump TGSI during program compile</li>
   <li>shaderdb - dump program compile information for shader-db analysis</li>
   <li>perf - print during performance-related events</li>
   <li>norast - skip actual hardware execution of commands</li>
   <li>always_flush - flush after each draw call</li>
   <li>always_sync - wait for finish after each flush</li>
   <li>dump - write a GPU command stream trace file (VC4 simulator only)</li>
</ul>
</ul>


<p>
Other Gallium drivers have their own environment variables.  These may change
frequently so the source code should be consulted for details.
</p>

</div>
</body>
</html>