intel: Use env_var_as_boolean for INTEL_NO_HW
authorNanley Chery <nanley.g.chery@intel.com>
Wed, 21 Jul 2021 21:37:04 +0000 (14:37 -0700)
committerMarge Bot <eric+marge@anholt.net>
Tue, 24 Aug 2021 00:12:47 +0000 (00:12 +0000)
The prior method of checking the result of getenv() for NULL would cause
the feature to be enabled for INTEL_NO_HW=0.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12007>

docs/envvars.rst
src/gallium/drivers/crocus/crocus_screen.c
src/gallium/drivers/iris/iris_screen.c
src/intel/vulkan/anv_device.c
src/mesa/drivers/dri/i915/intel_screen.c
src/mesa/drivers/dri/i965/brw_screen.c

index 598d452..34fe9f9 100644 (file)
@@ -236,8 +236,8 @@ i945/i965 driver environment variables (non-Gallium)
 ----------------------------------------------------
 
 :envvar:`INTEL_NO_HW`
-   if set to 1, prevents batches from being submitted to the hardware.
-   This is useful for debugging hangs, etc.
+   if set to 1, true or yes, prevents batches from being submitted to the
+   hardware. This is useful for debugging hangs, etc.
 :envvar:`INTEL_DEBUG`
    a comma-separated list of named flags, which do various things:
 
index 7a741e9..e91bd62 100644 (file)
@@ -762,8 +762,7 @@ crocus_screen_create(int fd, const struct pipe_screen_config *config)
 
    screen->aperture_bytes = get_aperture_size(fd);
 
-   if (getenv("INTEL_NO_HW") != NULL)
-      screen->no_hw = true;
+   screen->no_hw = env_var_as_boolean("INTEL_NO_HW", false);
 
    driParseConfigFiles(config->options, config->options_info, 0, "crocus",
                        NULL, NULL, NULL, 0, NULL, 0);
index 8ea97a2..f45b414 100644 (file)
@@ -831,8 +831,7 @@ iris_screen_create(int fd, const struct pipe_screen_config *config)
    screen->fd = iris_bufmgr_get_fd(screen->bufmgr);
    screen->winsys_fd = fd;
 
-   if (getenv("INTEL_NO_HW") != NULL)
-      screen->no_hw = true;
+   screen->no_hw = env_var_as_boolean("INTEL_NO_HW", false);
 
    screen->workaround_bo =
       iris_bo_alloc(screen->bufmgr, "workaround", 4096, 1,
index 3eb71ee..d60c03a 100644 (file)
@@ -812,9 +812,8 @@ anv_physical_device_try_create(struct anv_instance *instance,
 
    device->info = devinfo;
 
-   device->no_hw = device->info.no_hw;
-   if (getenv("INTEL_NO_HW") != NULL)
-      device->no_hw = true;
+   device->no_hw =
+      device->info.no_hw || env_var_as_boolean("INTEL_NO_HW", false);
 
    device->pci_info.domain = drm_device->businfo.pci->domain;
    device->pci_info.bus = drm_device->businfo.pci->bus;
index 6135357..5ac199c 100644 (file)
@@ -40,6 +40,7 @@
 #include "swrast/s_renderbuffer.h"
 
 #include "utils.h"
+#include "util/debug.h"
 #include "util/driconf.h"
 #include "util/u_memory.h"
 
@@ -1019,7 +1020,7 @@ intel_init_bufmgr(struct intel_screen *intelScreen)
 {
    __DRIscreen *spriv = intelScreen->driScrnPriv;
 
-   intelScreen->no_hw = getenv("INTEL_NO_HW") != NULL;
+   intelScreen->no_hw = env_var_as_boolean("INTEL_NO_HW", false);
 
    intelScreen->bufmgr = intel_bufmgr_gem_init(spriv->fd, BATCH_SZ);
    if (intelScreen->bufmgr == NULL) {
index 227d31d..8d03279 100644 (file)
@@ -1889,8 +1889,7 @@ brw_init_bufmgr(struct brw_screen *screen)
 {
    __DRIscreen *dri_screen = screen->driScrnPriv;
 
-   if (getenv("INTEL_NO_HW") != NULL)
-      screen->no_hw = true;
+   screen->no_hw = env_var_as_boolean("INTEL_NO_HW", false);
 
    bool bo_reuse = false;
    int bo_reuse_mode = driQueryOptioni(&screen->optionCache, "bo_reuse");