i965: Set screen->cmd_parser_version to 0 if we can't write registers.
authorKenneth Graunke <kenneth@whitecape.org>
Fri, 3 Mar 2017 02:21:31 +0000 (18:21 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Mon, 20 Mar 2017 22:58:05 +0000 (15:58 -0700)
If we can't write registers, then the effective command parser version
is 0 - it may exist, but it's not usefully enabling anything.

See kernel commit 1ca3712ca3429a617ed6c5f87718e4f6fe4ae0c6 (in v4.8)
where the kernel starts doing this for us.  This makes us do more or
less the same thing on older kernels.

This should preserve a bit of sanity by allowing us to perform a
screen->cmd_parser_version > N check to determine that we really can
use the features promised by command parser version N.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
src/mesa/drivers/dri/i965/intel_screen.c

index 17e5a4692e565b8230cabc5a85fabd366e9504c9..838151bf25b63909b31f49b97c99c3ab2c8d092b 100644 (file)
@@ -1845,8 +1845,18 @@ __DRIconfig **intelInitScreen2(__DRIscreen *dri_screen)
     *   means that we can no longer use it as an indicator of the
     *   age of the kernel.
     */
-   if (intel_detect_pipelined_so(screen))
+   if (intel_get_param(screen, I915_PARAM_CMD_PARSER_VERSION,
+                       &screen->cmd_parser_version) < 0) {
+      /* Command parser does not exist - getparam is unrecognized */
+      screen->cmd_parser_version = 0;
+   }
+
+   if (!intel_detect_pipelined_so(screen)) {
+      /* We can't do anything, so the effective version is 0. */
+      screen->cmd_parser_version = 0;
+   } else {
       screen->kernel_features |= KERNEL_ALLOWS_SOL_OFFSET_WRITES;
+   }
 
    const char *force_msaa = getenv("INTEL_FORCE_MSAA");
    if (force_msaa) {
@@ -1879,11 +1889,6 @@ __DRIconfig **intelInitScreen2(__DRIscreen *dri_screen)
          (ret != -1 || errno != EINVAL);
    }
 
-   if (intel_get_param(screen, I915_PARAM_CMD_PARSER_VERSION,
-                       &screen->cmd_parser_version) < 0) {
-      screen->cmd_parser_version = 0;
-   }
-
    if (devinfo->gen >= 8 || screen->cmd_parser_version >= 2)
       screen->kernel_features |= KERNEL_ALLOWS_PREDICATE_WRITES;