glx: drop unnecessary pointer deref for function calls
[mesa.git] / src / glx / dri3_glx.c
index 71ecebbc16c5e6e2c1efbfc7a833064d4ddf69ce..a5cf0e3bf32c72b6649f0e72c6e532d7a627c124 100644 (file)
@@ -211,9 +211,9 @@ dri3_bind_context(struct glx_context *context, struct glx_context *old,
       return GLXBadContext;
 
    if (dri_draw)
-      (*psc->f->invalidate)(dri_draw);
+      psc->f->invalidate(dri_draw);
    if (dri_read && dri_read != dri_draw)
-      (*psc->f->invalidate)(dri_read);
+      psc->f->invalidate(dri_read);
 
    return Success;
 }
@@ -259,6 +259,10 @@ dri3_create_context_attribs(struct glx_screen *base,
                                  &reset, &release, error))
       goto error_exit;
 
+   if (!dri2_check_no_error(flags, shareList, major_ver, error)) {
+      goto error_exit;
+   }
+
    /* Check the renderType value */
    if (!validate_renderType_against_config(config_base, render_type))
        goto error_exit;
@@ -303,6 +307,9 @@ dri3_create_context_attribs(struct glx_screen *base,
        * GLX_CONTEXT_*_BIT values.
        */
       ctx_attribs[num_ctx_attribs++] = flags;
+
+      if (flags & __DRI_CTX_FLAG_NO_ERROR)
+         pcp->base.noError = GL_TRUE;
    }
 
    pcp->driContext =
@@ -357,10 +364,12 @@ dri3_create_drawable(struct glx_screen *base, XID xDrawable,
 {
    struct dri3_drawable *pdraw;
    struct dri3_screen *psc = (struct dri3_screen *) base;
-   const struct dri3_display *const pdp = (struct dri3_display *)
-      base->display->dri3Display;
    __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) config_base;
    bool has_multibuffer = false;
+#ifdef HAVE_DRI3_MODIFIERS
+   const struct dri3_display *const pdp = (struct dri3_display *)
+      base->display->dri3Display;
+#endif
 
    pdraw = calloc(1, sizeof(*pdraw));
    if (!pdraw)
@@ -371,9 +380,13 @@ dri3_create_drawable(struct glx_screen *base, XID xDrawable,
    pdraw->base.drawable = drawable;
    pdraw->base.psc = &psc->base;
 
+#ifdef HAVE_DRI3_MODIFIERS
    if ((psc->image && psc->image->base.version >= 15) &&
-       (pdp->dri3Major > 1 || (pdp->dri3Major == 1 && pdp->dri3Minor >= 2)))
+       (pdp->dri3Major > 1 || (pdp->dri3Major == 1 && pdp->dri3Minor >= 2)) &&
+       (pdp->presentMajor > 1 ||
+        (pdp->presentMajor == 1 && pdp->presentMinor >= 2)))
       has_multibuffer = true;
+#endif
 
    (void) __glXInitialize(psc->base.dpy);
 
@@ -489,7 +502,7 @@ dri3_flush_front_buffer(__DRIdrawable *driDrawable, void *loaderPrivate)
 
    loader_dri3_flush(draw, __DRI2_FLUSH_DRAWABLE, __DRI2_THROTTLE_FLUSHFRONT);
 
-   (*psc->f->invalidate)(driDrawable);
+   psc->f->invalidate(driDrawable);
    loader_dri3_wait_gl(draw);
 }
 
@@ -636,7 +649,6 @@ dri3_set_swap_interval(__GLXDRIdrawable *pdraw, int interval)
       break;
    }
 
-   priv->swap_interval = interval;
    loader_dri3_set_swap_interval(&priv->loader_drawable, interval);
 
    return 0;
@@ -653,7 +665,7 @@ dri3_get_swap_interval(__GLXDRIdrawable *pdraw)
 
    struct dri3_drawable *priv =  (struct dri3_drawable *) pdraw;
 
-  return priv->swap_interval;
+  return priv->loader_drawable.swap_interval;
 }
 
 static void
@@ -670,7 +682,7 @@ dri3_bind_tex_image(Display * dpy,
    if (pdraw != NULL) {
       psc = (struct dri3_screen *) base->psc;
 
-      (*psc->f->invalidate)(pdraw->loader_drawable.dri_drawable);
+      psc->f->invalidate(pdraw->loader_drawable.dri_drawable);
 
       XSync(dpy, false);
 
@@ -774,6 +786,10 @@ dri3_bind_extensions(struct dri3_screen *psc, struct glx_display * priv,
          __glXEnableDirectExtension(&psc->base,
                                     "GLX_ARB_create_context_robustness");
 
+      if (strcmp(extensions[i]->name, __DRI2_NO_ERROR) == 0)
+         __glXEnableDirectExtension(&psc->base,
+                                    "GLX_ARB_create_context_no_error");
+
       if (strcmp(extensions[i]->name, __DRI2_RENDERER_QUERY) == 0) {
          psc->rendererQuery = (__DRI2rendererQueryExtension *) extensions[i];
          __glXEnableDirectExtension(&psc->base, "GLX_MESA_query_renderer");
@@ -855,13 +871,7 @@ dri3_create_screen(int screen, struct glx_display * priv)
       goto handle_error;
    }
 
-   psc->driver = driOpenDriver(driverName);
-   if (psc->driver == NULL) {
-      ErrorMessageF("driver pointer missing\n");
-      goto handle_error;
-   }
-
-   extensions = driGetDriverExtensions(psc->driver, driverName);
+   extensions = driOpenDriver(driverName, &psc->driver);
    if (extensions == NULL)
       goto handle_error;
 
@@ -989,7 +999,7 @@ dri3_create_screen(int screen, struct glx_display * priv)
    return &psc->base;
 
 handle_error:
-   CriticalErrorMessageF("failed to load driver: %s\n", driverName);
+   CriticalErrorMessageF("failed to load driver: %s\n", driverName ? driverName : "(null)");
 
    if (configs)
        glx_config_destroy_list(configs);
@@ -1020,6 +1030,18 @@ dri3_destroy_display(__GLXDRIdisplay * dpy)
    free(dpy);
 }
 
+/* Only request versions of these protocols which we actually support. */
+#define DRI3_SUPPORTED_MAJOR 1
+#define PRESENT_SUPPORTED_MAJOR 1
+
+#ifdef HAVE_DRI3_MODIFIERS
+#define DRI3_SUPPORTED_MINOR 2
+#define PRESENT_SUPPORTED_MINOR 2
+#else
+#define PRESENT_SUPPORTED_MINOR 0
+#define DRI3_SUPPORTED_MINOR 0
+#endif
+
 /** dri3_create_display
  *
  * Allocate, initialize and return a __DRIdisplayPrivate object.
@@ -1051,13 +1073,11 @@ dri3_create_display(Display * dpy)
       return NULL;
 
    dri3_cookie = xcb_dri3_query_version(c,
-                                        XCB_DRI3_MAJOR_VERSION,
-                                        XCB_DRI3_MINOR_VERSION);
-
-
+                                        DRI3_SUPPORTED_MAJOR,
+                                        DRI3_SUPPORTED_MINOR);
    present_cookie = xcb_present_query_version(c,
-                                   XCB_PRESENT_MAJOR_VERSION,
-                                   XCB_PRESENT_MINOR_VERSION);
+                                              PRESENT_SUPPORTED_MAJOR,
+                                              PRESENT_SUPPORTED_MINOR);
 
    pdp = malloc(sizeof *pdp);
    if (pdp == NULL)