summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@redhat.com>2009-02-16 00:23:10 -0500
committerKristian Høgsberg <krh@redhat.com>2009-02-16 00:23:10 -0500
commit934c0eb09283a8124eea9dfab25936006f356cfe (patch)
treeb5f0cf8f4e03999e8cb3cc8fc53cda562f0c7898
parent421c05594338cc4a21d4cc8adbf3be2a98bb840e (diff)
Make DRI2 backend finally work.
-rw-r--r--eagle-internal.h4
-rw-r--r--eagle.c6
-rw-r--r--intel.c6
-rw-r--r--test/setup.c2
-rw-r--r--x11-dri2.c39
5 files changed, 36 insertions, 21 deletions
diff --git a/eagle-internal.h b/eagle-internal.h
index 98b3b8e..1aa2ee5 100644
--- a/eagle-internal.h
+++ b/eagle-internal.h
@@ -1,5 +1,5 @@
/*
- * Copyright © 2008 Kristian Høgsberg
+ * Copyright © 2008, 2009 Kristian Høgsberg
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
@@ -100,7 +100,7 @@ struct EagleBackend {
};
int eglInitDisplay(EGLDisplay display,
- struct udev_device *device, const char *driver);
+ const char *path, const char *driver);
void eglInitSurface(EGLSurface surface, EGLDisplay display, EGLConfig fbconfig,
int width, int height);
diff --git a/eagle.c b/eagle.c
index 5874e97..0c89432 100644
--- a/eagle.c
+++ b/eagle.c
@@ -1,5 +1,5 @@
/*
- * Copyright © 2008 Kristian Høgsberg
+ * Copyright © 2008, 2009 Kristian Høgsberg
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
@@ -162,18 +162,16 @@ eglLoadDriver(EGLDisplay display, const char *driverName)
int
eglInitDisplay(EGLDisplay display,
- struct udev_device *device, const char *driver)
+ const char *path, const char *driver)
{
const __DRIconfig **configs;
const __DRIextension **extensions;
- const char *path;
int i;
memset(display, 0, sizeof *display);
display->initialized = EGL_FALSE;
display->next_surface_id = 1;
- path = udev_device_get_devnode(device);
display->fd = open(path, O_RDWR);
if (display->fd < 0) {
fprintf(stderr,
diff --git a/intel.c b/intel.c
index 6f41448..9fb8fac 100644
--- a/intel.c
+++ b/intel.c
@@ -1,5 +1,5 @@
/*
- * Copyright © 2008 Kristian Høgsberg
+ * Copyright © 2008, 2009 Kristian Høgsberg
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
@@ -201,12 +201,14 @@ static EGLDisplay
intelCreateDisplay(struct udev_device *device, const char *driver)
{
EGLDisplay display;
+ const char *path;
display = malloc(sizeof *display);
if (display == NULL)
return NULL;
- if (eglInitDisplay(display, device, driver) < 0) {
+ path = udev_device_get_devnode(device);
+ if (eglInitDisplay(display, path, driver) < 0) {
free(display);
return NULL;
}
diff --git a/test/setup.c b/test/setup.c
index a16c504..55d1688 100644
--- a/test/setup.c
+++ b/test/setup.c
@@ -103,7 +103,7 @@ create_frontbuffer(EGLDisplay display, int *width, int *height, int *stride)
drmModeConnector *connector;
drmModeRes *resources;
drmModeEncoder *encoder;
- struct drm_mode_modeinfo *mode;
+ drmModeModeInfo *mode;
struct drm_i915_gem_create create;
struct drm_gem_flink flink;
unsigned int fb_id;
diff --git a/x11-dri2.c b/x11-dri2.c
index 0c6b4dd..78e589a 100644
--- a/x11-dri2.c
+++ b/x11-dri2.c
@@ -1,5 +1,5 @@
/*
- * Copyright © 2008 Kristian Høgsberg
+ * Copyright © 2008, 2009 Kristian Høgsberg
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
@@ -49,22 +49,35 @@ x11GetBuffers(EGLSurface surface, uint32_t *attachments, int count)
EGLDisplayX11 x11Display = (EGLDisplayX11) surface->display;
EGLSurfaceX11 x11Surface = (EGLSurfaceX11) surface;
DRI2Buffer *buffers;
- int i, outCount;
+ uint32_t x11Attachments[10];
+ int i, j, outCount;
+
+ /* Make sure we ask for a back buffer regardless of the config
+ * in use and remap the buffers so the dri driver renders to
+ * the back buffer in all cases. We should only do this for
+ * Windows */
+
+ for (i = 0, j = 0; i < count; i++, j++) {
+ if (i == 1 && attachments[i] != __DRI_BUFFER_BACK_LEFT)
+ x11Attachments[j++] = __DRI_BUFFER_BACK_LEFT;
+ x11Attachments[j] = attachments[i];
+ }
buffers = DRI2GetBuffers(x11Display->display,
x11Surface->drawable,
&surface->width,
&surface->height,
- attachments, count, &outCount);
+ x11Attachments, j, &outCount);
- for (i = 0; i < outCount; i++) {
- surface->buffers[i].attachment = buffers[i].attachment;
- surface->buffers[i].name = buffers[i].name;
- surface->buffers[i].pitch = buffers[i].pitch;
- surface->buffers[i].cpp = buffers[i].cpp;
+ for (j = j - i, i = 0; i < count; i++, j++) {
+ surface->buffers[i].attachment = buffers[j].attachment;
+ surface->buffers[i].name = buffers[j].name;
+ surface->buffers[i].pitch = buffers[j].pitch;
+ surface->buffers[i].cpp = buffers[j].cpp;
}
+ surface->buffers[0].attachment = __DRI_BUFFER_FRONT_LEFT;
- surface->count = outCount;
+ surface->count = count;
XFree(buffers);
}
@@ -83,7 +96,7 @@ x11SwapBuffers(EGLDisplay display, EGLSurface surface)
rect.height = surface->height;
region = XFixesCreateRegion(x11Display->display, &rect, 1);
DRI2CopyRegion(x11Display->display, x11Surface->drawable,
- region, DRI2BufferBackLeft, DRI2BufferFrontLeft);
+ region, DRI2BufferFrontLeft, DRI2BufferBackLeft);
XFixesDestroyRegion(x11Display->display, region);
return EGL_TRUE;
@@ -132,8 +145,7 @@ eglCreateDisplayX11(Display *display, Window root)
x11Display->errorBase = errorBase;
x11Display->display = display;
- /* Get ude*/
- if (eglInitDisplay(&x11Display->base, NULL, driverName) < 0) {
+ if (eglInitDisplay(&x11Display->base, deviceName, driverName) < 0) {
free(x11Display);
return NULL;
}
@@ -155,6 +167,7 @@ eglCreateSurfaceX11(EGLDisplay display, EGLConfig config,
Window window, int width, int height)
{
EGLSurfaceX11 x11Surface;
+ EGLDisplayX11 x11Display = (EGLDisplayX11) display;
x11Surface = malloc(sizeof *x11Surface);
if (x11Surface == NULL)
@@ -164,5 +177,7 @@ eglCreateSurfaceX11(EGLDisplay display, EGLConfig config,
eglInitSurface(&x11Surface->base, display, config, width, height);
+ DRI2CreateDrawable(x11Display->display, x11Surface->drawable);
+
return &x11Surface->base;
}