{ __DRI2_FLUSH_CONTROL, 1, offsetof(struct dri2_egl_display, flush_control) },
{ __DRI2_BLOB, 1, offsetof(struct dri2_egl_display, blob) },
{ __DRI_MUTABLE_RENDER_BUFFER_DRIVER, 1, offsetof(struct dri2_egl_display, mutable_render_buffer) },
+ { __DRI_KOPPER, 1, offsetof(struct dri2_egl_display, kopper) },
{ NULL, 0, 0 }
};
struct dri2_egl_surface *dri2_surf,
void *loaderPrivate)
{
- __DRIcreateNewDrawableFunc createNewDrawable;
-
- if (dri2_dpy->image_driver)
- createNewDrawable = dri2_dpy->image_driver->createNewDrawable;
- else if (dri2_dpy->dri2)
- createNewDrawable = dri2_dpy->dri2->createNewDrawable;
- else if (dri2_dpy->swrast)
- createNewDrawable = dri2_dpy->swrast->createNewDrawable;
- else
- return _eglError(EGL_BAD_ALLOC, "no createNewDrawable");
+ if (dri2_dpy->kopper) {
+ dri2_surf->dri_drawable =
+ dri2_dpy->kopper->createNewDrawable(dri2_dpy->dri_screen, config, loaderPrivate,
+ dri2_surf->base.Type == EGL_PBUFFER_BIT ||
+ dri2_surf->base.Type == EGL_PIXMAP_BIT);
+ } else {
+ __DRIcreateNewDrawableFunc createNewDrawable;
+ if (dri2_dpy->image_driver)
+ createNewDrawable = dri2_dpy->image_driver->createNewDrawable;
+ else if (dri2_dpy->dri2)
+ createNewDrawable = dri2_dpy->dri2->createNewDrawable;
+ else if (dri2_dpy->swrast)
+ createNewDrawable = dri2_dpy->swrast->createNewDrawable;
+ else
+ return _eglError(EGL_BAD_ALLOC, "no createNewDrawable");
- dri2_surf->dri_drawable = createNewDrawable(dri2_dpy->dri_screen,
- config, loaderPrivate);
+ dri2_surf->dri_drawable = createNewDrawable(dri2_dpy->dri_screen,
+ config, loaderPrivate);
+ }
if (dri2_surf->dri_drawable == NULL)
return _eglError(EGL_BAD_ALLOC, "createNewDrawable");
#include <GL/gl.h>
#include <GL/internal/dri_interface.h>
+#include "kopper_interface.h"
#ifdef HAVE_DRM_PLATFORM
#include <gbm_driint.h>
const __DRIimageDriverExtension *image_driver;
const __DRIdri2Extension *dri2;
const __DRIswrastExtension *swrast;
+ const __DRIkopperExtension *kopper;
const __DRI2flushExtension *flush;
const __DRI2flushControlExtension *flush_control;
const __DRItexBufferExtension *tex_buffer;
#include "egl_dri2.h"
#include "loader.h"
+#include "kopper_interface.h"
#include "util/debug.h"
static __DRIimage*
.getCapability = device_get_capability,
};
+static const __DRIkopperLoaderExtension kopper_loader_extension = {
+ .base = { __DRI_KOPPER_LOADER, 1 },
+
+ .SetSurfaceCreateInfo = NULL,
+};
+
static const __DRIextension *image_loader_extensions[] = {
&image_loader_extension.base,
&image_lookup_extension.base,
&use_invalidate.base,
+ &kopper_loader_extension.base,
NULL,
};
&swrast_pbuffer_loader_extension.base,
&image_lookup_extension.base,
&use_invalidate.base,
+ &kopper_loader_extension.base,
NULL,
};
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
dri2_dpy->fd = -1;
- dri2_dpy->driver_name = strdup("swrast");
+ dri2_dpy->driver_name = strdup(disp->Options.Zink ? "zink" : "swrast");
if (!dri2_dpy->driver_name)
return false;
dri2_dpy->core = dri2_dpy->gbm_dri->core;
dri2_dpy->dri2 = dri2_dpy->gbm_dri->dri2;
dri2_dpy->swrast = dri2_dpy->gbm_dri->swrast;
+ dri2_dpy->kopper = dri2_dpy->gbm_dri->kopper;
dri2_dpy->driver_configs = dri2_dpy->gbm_dri->driver_configs;
dri2_dpy->gbm_dri->lookup_image = dri2_lookup_egl_image;
#include "egl_dri2.h"
#include "loader.h"
+#include "kopper_interface.h"
static __DRIimage*
surfaceless_alloc_image(struct dri2_egl_display *dri2_dpy,
}
}
+static const __DRIkopperLoaderExtension kopper_loader_extension = {
+ .base = { __DRI_KOPPER_LOADER, 1 },
+
+ .SetSurfaceCreateInfo = NULL,
+};
+
static const __DRIimageLoaderExtension image_loader_extension = {
.base = { __DRI_IMAGE_LOADER, 2 },
.getBuffers = surfaceless_image_get_buffers,
&image_lookup_extension.base,
&use_invalidate.base,
&background_callable_extension.base,
+ &kopper_loader_extension.base,
NULL,
};
&image_loader_extension.base,
&image_lookup_extension.base,
&use_invalidate.base,
+ &kopper_loader_extension.base,
NULL,
};
disp->Device = _eglAddDevice(dri2_dpy->fd, true);
assert(disp->Device);
- dri2_dpy->driver_name = strdup("swrast");
+ dri2_dpy->driver_name = strdup(disp->Options.Zink ? "zink" : "swrast");
if (!dri2_dpy->driver_name)
return false;
#include "util/u_vector.h"
#include "util/anon_file.h"
#include "eglglobals.h"
+#include "kopper_interface.h"
#include <wayland-egl-backend.h>
#include <wayland-client.h>
.putImage2 = dri2_wl_swrast_put_image2,
};
+static void
+kopperSetSurfaceCreateInfo(void *_draw, struct kopper_loader_info *out)
+{
+ struct dri2_egl_surface *dri2_surf = _draw;
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display(dri2_surf->base.Resource.Display);
+ VkWaylandSurfaceCreateInfoKHR *wlsci = &out->wl;
+
+ wlsci->sType = VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR;
+ wlsci->pNext = NULL;
+ wlsci->flags = 0;
+ wlsci->display = dri2_dpy->wl_dpy;
+ wlsci->surface = dri2_surf->wl_surface_wrapper;
+}
+
+static const __DRIkopperLoaderExtension kopper_loader_extension = {
+ .base = { __DRI_KOPPER_LOADER, 1 },
+
+ .SetSurfaceCreateInfo = kopperSetSurfaceCreateInfo,
+};
static const __DRIextension *swrast_loader_extensions[] = {
&swrast_loader_extension.base,
&image_lookup_extension.base,
+ &kopper_loader_extension.base,
NULL,
};
0, dri2_dpy->formats.num_formats))
goto cleanup;
- dri2_dpy->driver_name = strdup("swrast");
+ dri2_dpy->driver_name = strdup(disp->Options.Zink ? "zink" : "swrast");
if (!dri2_load_driver_swrast(disp))
goto cleanup;
#include "egl_dri2.h"
#include "loader.h"
+#include "kopper_interface.h"
#ifdef HAVE_DRI3
#include "platform_x11_dri3.h"
goto cleanup_pixmap;
}
- if (!dri2_create_drawable(dri2_dpy, config, dri2_surf, dri2_surf))
- goto cleanup_pixmap;
-
if (type != EGL_PBUFFER_BIT) {
cookie = xcb_get_geometry (dri2_dpy->conn, dri2_surf->drawable);
reply = xcb_get_geometry_reply (dri2_dpy->conn, cookie, &error);
free(reply);
}
+ if (!dri2_create_drawable(dri2_dpy, config, dri2_surf, dri2_surf))
+ goto cleanup_pixmap;
+
if (dri2_dpy->dri2) {
xcb_void_cookie_t cookie;
int conn_error;
.getImage = swrastGetImage,
};
+static void
+kopperSetSurfaceCreateInfo(void *_draw, struct kopper_loader_info *ci)
+{
+ struct dri2_egl_surface *dri2_surf = _draw;
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display(dri2_surf->base.Resource.Display);
+
+ if (dri2_surf->base.Type != EGL_WINDOW_BIT)
+ return;
+ ci->xcb.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR;
+ ci->xcb.pNext = NULL;
+ ci->xcb.flags = 0;
+ ci->xcb.connection = dri2_dpy->conn;
+ ci->xcb.window = dri2_surf->drawable;
+ ci->has_alpha = dri2_surf->depth == 32;
+}
+
+static const __DRIkopperLoaderExtension kopper_loader_extension = {
+ .base = { __DRI_KOPPER_LOADER, 1 },
+
+ .SetSurfaceCreateInfo = kopperSetSurfaceCreateInfo,
+};
+
static const __DRIextension *swrast_loader_extensions[] = {
&swrast_loader_extension.base,
&image_lookup_extension.base,
+ &kopper_loader_extension.base,
NULL,
};
return _eglError(EGL_BAD_ALLOC, msg);
}
+static void
+dri2_x11_setup_swap_interval(_EGLDisplay *disp)
+{
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+ int arbitrary_max_interval = 1000;
+
+ /* default behavior for no SwapBuffers support: no vblank syncing
+ * either.
+ */
+ dri2_dpy->min_swap_interval = 0;
+ dri2_dpy->max_swap_interval = 0;
+ dri2_dpy->default_swap_interval = 0;
+
+ if (!dri2_dpy->swap_available)
+ return;
+
+ /* If we do have swapbuffers, then we can support pretty much any swap
+ * interval.
+ */
+ dri2_setup_swap_interval(disp, arbitrary_max_interval);
+}
+
static EGLBoolean
dri2_initialize_x11_swrast(_EGLDisplay *disp)
{
* Every hardware driver_name is set using strdup. Doing the same in
* here will allow is to simply free the memory at dri2_terminate().
*/
- dri2_dpy->driver_name = strdup("swrast");
+ dri2_dpy->driver_name = strdup(disp->Options.Zink ? "zink" : "swrast");
if (!dri2_load_driver_swrast(disp))
goto cleanup;
dri2_setup_screen(disp);
+ if (disp->Options.Zink) {
+#ifdef HAVE_WAYLAND_PLATFORM
+ dri2_dpy->device_name = strdup("zink");
+#endif
+ dri2_x11_setup_swap_interval(disp);
+ if (!dri2_dpy->is_different_gpu)
+ disp->Extensions.KHR_image_pixmap = EGL_TRUE;
+ disp->Extensions.NOK_texture_from_pixmap = EGL_TRUE;
+ disp->Extensions.CHROMIUM_sync_control = EGL_TRUE;
+ disp->Extensions.EXT_buffer_age = EGL_TRUE;
+ disp->Extensions.EXT_swap_buffers_with_damage = EGL_TRUE;
+
+ //dri2_set_WL_bind_wayland_display(disp);
+ }
+
if (!dri2_x11_add_configs_for_visuals(dri2_dpy, disp, true))
goto cleanup;
return EGL_FALSE;
}
-static void
-dri2_x11_setup_swap_interval(_EGLDisplay *disp)
-{
- struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
- int arbitrary_max_interval = 1000;
-
- /* default behavior for no SwapBuffers support: no vblank syncing
- * either.
- */
- dri2_dpy->min_swap_interval = 0;
- dri2_dpy->max_swap_interval = 0;
- dri2_dpy->default_swap_interval = 0;
-
- if (!dri2_dpy->swap_available)
- return;
-
- /* If we do have swapbuffers, then we can support pretty much any swap
- * interval.
- */
- dri2_setup_swap_interval(disp, arbitrary_max_interval);
-}
-
#ifdef HAVE_DRI3
static const __DRIextension *dri3_image_loader_extensions[] = {
env_var_as_boolean("LIBGL_ALWAYS_SOFTWARE", false);
if (disp->Options.ForceSoftware)
_eglLog(_EGL_DEBUG, "Found 'LIBGL_ALWAYS_SOFTWARE' set, will use a CPU renderer");
+ else {
+ const char *env = getenv("MESA_LOADER_DRIVER_OVERRIDE");
+ disp->Options.Zink = env && !strcmp(env, "zink");
+ disp->Options.ForceSoftware |= disp->Options.Zink;
+ }
/**
* Initialize the display using the driver's function.
/* options that affect how the driver initializes the display */
struct {
+ EGLBoolean Zink; /**< Use kopper only */
EGLBoolean ForceSoftware; /**< Use software path only */
EGLAttrib *Attribs; /**< Platform-specific options */
int fd; /**< plaform device specific, local fd */
static struct dri_extension_match gbm_swrast_device_extensions[] = {
{ __DRI_CORE, 1, offsetof(struct gbm_dri_device, core), false },
{ __DRI_SWRAST, 1, offsetof(struct gbm_dri_device, swrast), false },
+ { __DRI_KOPPER, 1, offsetof(struct gbm_dri_device, kopper), true },
};
static bool
#include <GL/gl.h> /* dri_interface needs GL types */
#include "GL/internal/dri_interface.h"
+#include "kopper_interface.h"
struct gbm_dri_surface;
struct gbm_dri_bo;
const __DRI2fenceExtension *fence;
const __DRIimageExtension *image;
const __DRIswrastExtension *swrast;
+ const __DRIkopperExtension *kopper;
const __DRI2flushExtension *flush;
const __DRIconfig **driver_configs;