Now the loaders don't have to switch on dri2/dri3/swrast.
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20069>
*/
#define MESA_INTERFACE_VERSION_STRING PACKAGE_VERSION MESA_GIT_SHA1
const char *version_string;
+
+ /* Screen creation function regardless of DRI2, image, or swrast backend.
+ * (Nothing uses the old __DRI_CORE screen create).
+ *
+ * If not associated with a DRM fd (non-swkms swrast), the fd argument should
+ * be -1.
+ */
+ __DRIcreateNewScreen2Func createNewScreen;
};
#endif /* MESA_INTERFACE_H */
{
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
- if (dri2_dpy->image_driver) {
- dri2_dpy->dri_screen =
- dri2_dpy->image_driver->createNewScreen2(0, dri2_dpy->fd,
- dri2_dpy->loader_extensions,
- dri2_dpy->driver_extensions,
- &dri2_dpy->driver_configs,
- disp);
- } else if (dri2_dpy->dri2) {
- dri2_dpy->dri_screen =
- dri2_dpy->dri2->createNewScreen2(0, dri2_dpy->fd,
- dri2_dpy->loader_extensions,
- dri2_dpy->driver_extensions,
- &dri2_dpy->driver_configs, disp);
- } else {
- assert(dri2_dpy->swrast);
- dri2_dpy->dri_screen =
- dri2_dpy->swrast->createNewScreen2(0, dri2_dpy->loader_extensions,
- dri2_dpy->driver_extensions,
- &dri2_dpy->driver_configs, disp);
- }
+ int screen_fd = dri2_dpy->swrast ? -1 : dri2_dpy->fd;
+ dri2_dpy->dri_screen = dri2_dpy->mesa->createNewScreen(0, screen_fd,
+ dri2_dpy->loader_extensions,
+ dri2_dpy->driver_extensions,
+ &dri2_dpy->driver_configs,
+ disp);
if (dri2_dpy->dri_screen == NULL) {
_eglLog(_EGL_WARNING, "egl: failed to create dri2 screen");
static const struct __DRImesaCoreExtensionRec mesaCoreExtension = {
.base = { __DRI_MESA, 1 },
.version_string = MESA_INTERFACE_VERSION_STRING,
+ .createNewScreen = driCreateNewScreen2,
};
/* This is the table of extensions that the loader will dlsym() for. */
* It's used to create global state for the driver across contexts on the same
* Display.
*/
-static __DRIscreen *
+__DRIscreen *
driCreateNewScreen2(int scrn, int fd,
const __DRIextension **loader_extensions,
const __DRIextension **driver_extensions,
#define __DRIVER_CONTEXT_ATTRIB_NO_ERROR (1 << 3)
#define __DRIVER_CONTEXT_ATTRIB_PROTECTED (1 << 4)
+__DRIscreen *
+driCreateNewScreen2(int scrn, int fd,
+ const __DRIextension **loader_extensions,
+ const __DRIextension **driver_extensions,
+ const __DRIconfig ***driver_configs, void *data);
+
extern uint32_t
driGLFormatToImageFormat(mesa_format format);
static const struct __DRImesaCoreExtensionRec mesaCoreExtension = {
.base = { __DRI_MESA, 1 },
.version_string = MESA_INTERFACE_VERSION_STRING,
+ .createNewScreen = driCreateNewScreen2,
};
/* This is the table of extensions that the loader will dlsym() for. */
static const struct __DRImesaCoreExtensionRec mesaCoreExtension = {
.base = { __DRI_MESA, 1 },
.version_string = MESA_INTERFACE_VERSION_STRING,
+ .createNewScreen = driCreateNewScreen2,
};
const __DRIextension *galliumvk_driver_extensions[] = {
}
dri->loader_extensions = gbm_dri_screen_extensions;
+ dri->screen = dri->mesa->createNewScreen(0, swrast ? -1 : dri->base.v0.fd,
+ dri->loader_extensions,
+ dri->driver_extensions,
+ &dri->driver_configs, dri);
+ if (dri->screen == NULL)
+ return -1;
if (!swrast) {
- dri->screen = dri->dri2->createNewScreen2(0, dri->base.v0.fd,
- dri->loader_extensions,
- dri->driver_extensions,
- &dri->driver_configs, dri);
- if (dri->screen == NULL)
- return -1;
-
extensions = dri->core->getExtensions(dri->screen);
if (!loader_bind_extensions(dri, dri_core_extensions,
ARRAY_SIZE(dri_core_extensions),
ret = -1;
goto free_screen;
}
- } else {
- dri->screen = dri->swrast->createNewScreen2(0, dri->loader_extensions,
- dri->driver_extensions,
- &dri->driver_configs, dri);
- if (dri->screen == NULL)
- return -1;
}
dri->lookup_image = NULL;