summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--eagle-internal.h7
-rw-r--r--eagle.c54
-rw-r--r--eagle.h26
-rw-r--r--intel.c204
-rw-r--r--test/Makefile.in4
-rw-r--r--test/gears.c46
-rw-r--r--test/setup.c108
-rw-r--r--test/setup.h4
-rw-r--r--test/texture.c7
-rw-r--r--x11-dri2.c1
10 files changed, 231 insertions, 230 deletions
diff --git a/eagle-internal.h b/eagle-internal.h
index 5d09e8e..6adc18d 100644
--- a/eagle-internal.h
+++ b/eagle-internal.h
@@ -57,7 +57,7 @@ struct EGLDisplay {
int width, height;
- __DRIcopyBufferExtension *copyBuffer;
+ __DRI2flushExtension *flush;
const struct EagleBackend *backend;
void *backendPrivate;
@@ -97,13 +97,8 @@ struct EagleBackend {
void (*getBuffers)(EGLSurface surface,
uint32_t *attachments,
int count);
- EGLBoolean (*swapBuffers)(EGLDisplay display,
- EGLSurface surface);
EGLBoolean (*destroySurface)(EGLDisplay display,
EGLSurface surface);
- EGLSurface (*createSurfaceForName)(EGLDisplay display, EGLConfig config,
- uint32_t name, uint32_t width,
- uint32_t height, uint32_t stride, const EGLint *attribList);
};
int eglInitDisplay(EGLDisplay display,
diff --git a/eagle.c b/eagle.c
index 06c0ce2..0c3cd06 100644
--- a/eagle.c
+++ b/eagle.c
@@ -202,10 +202,10 @@ eglInitDisplay(EGLDisplay display,
(__DRItexBufferExtension *) extensions[i];
}
- if (strcmp(extensions[i]->name, __DRI_COPY_BUFFER) == 0 &&
- extensions[i]->version >= __DRI_COPY_BUFFER_VERSION) {
- display->copyBuffer =
- (__DRIcopyBufferExtension *) extensions[i];
+ if (strcmp(extensions[i]->name, __DRI2_FLUSH) == 0 &&
+ extensions[i]->version >= 2) {
+ display->flush =
+ (__DRI2flushExtension *) extensions[i];
}
}
@@ -214,8 +214,8 @@ eglInitDisplay(EGLDisplay display,
goto fail;
}
- if (display->copyBuffer == NULL) {
- fprintf(stderr, "dri driver has no copyBuffer extension\n");
+ if (display->flush == NULL) {
+ fprintf(stderr, "dri driver has no flush extension\n");
goto fail;
}
@@ -564,15 +564,6 @@ eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config,
return EGL_NO_SURFACE;
}
-EAGLE_EXPORT EGLSurface
-eglCreateSurfaceForName(EGLDisplay display, EGLConfig config,
- uint32_t name, uint32_t width,
- uint32_t height, uint32_t stride, const EGLint *attribList)
-{
- return display->backend->createSurfaceForName(display, config, name,
- width, height, stride, attribList);
-}
-
EAGLE_EXPORT EGLBoolean
eglDestroySurface(EGLDisplay display, EGLSurface surface)
{
@@ -761,7 +752,7 @@ eglWaitNative(EGLint engine)
EAGLE_EXPORT EGLBoolean
eglSwapBuffers(EGLDisplay display, EGLSurface surface)
{
- return display->backend->swapBuffers(display, surface);
+ return EGL_FALSE; /* Sorry... */
}
EAGLE_EXPORT EGLBoolean
@@ -790,34 +781,3 @@ EAGLE_EXPORT void
{
return NULL;
}
-
-EAGLE_EXPORT EGLBoolean
-eglCopyNativeBuffers(EGLDisplay display,
- EGLSurface dst, GLenum dstBuffer, int32_t dst_x, int32_t dst_y,
- EGLSurface src, GLenum srcBuffer, int32_t x, int32_t y, int32_t width, int32_t height)
-{
- EGLContext context;
- __DRIbuffer *dstDRIBuffer;
- unsigned int attachments[1];
-
- context = eglGetCurrentContext();
-
- /* FIXME: glCopyPixels should work, but then we'll have to
- * call eglMakeCurrent to set up the src and dest surfaces
- * first. This seems cheaper, but maybe there's a better way
- * to accomplish this. */
-
- attachments[0] = __DRI_BUFFER_FRONT_LEFT;
- display->backend->getBuffers(src, attachments, 1);
-
- /* FIXME: Actually use dstBuffer and srcBuffer (eg
- * GL_FRONT_LEFT) to look up the buffers to use. */
-
- dstDRIBuffer = &dst->buffers[0];
-
- return display->copyBuffer->copyBuffer(context->driContext,
- dstDRIBuffer,
- dst_x, dst_y,
- src->driDrawable, __DRI_BUFFER_FRONT_LEFT,
- x, y, width, height);
-}
diff --git a/eagle.h b/eagle.h
index 45f0bfe..9c0b9a7 100644
--- a/eagle.h
+++ b/eagle.h
@@ -248,6 +248,13 @@ extern EGLSurface eglCreatePixmapSurface(EGLDisplay dpy,
EGLNativePixmapType pixmap,
const EGLint *attribList);
+extern EGLSurface eglCreateSurface(EGLDisplay display,
+ EGLConfig config,
+ uint32_t width,
+ uint32_t height,
+ uint32_t colorBufferCount,
+ const EGLint *attribList);
+
extern EGLSurface eglCreateSurfaceForName(EGLDisplay dpy,
EGLConfig config,
GLuint name,
@@ -255,18 +262,15 @@ extern EGLSurface eglCreateSurfaceForName(EGLDisplay dpy,
GLuint height,
GLuint stride,
const EGLint *attribList);
+extern EGLBoolean eglGetColorBuffer(EGLSurface surface,
+ uint32_t index,
+ uint32_t *name,
+ uint32_t *handle,
+ uint32_t *stride);
-extern EGLBoolean eglGetNativeBuffer(EGLSurface surface,
- GLenum buffer,
- uint32_t *name,
- uint32_t *handle,
- uint32_t *stride);
-
-extern EGLBoolean eglCopyNativeBuffers(EGLDisplay display,
- EGLSurface dst, GLenum dstBuffer,
- GLint dst_x, GLint dst_y,
- EGLSurface src, GLenum srcBuffer,
- GLint x, GLint y, GLint width, GLint height);
+extern EGLBoolean eglBindColorBuffer(EGLDisplay display,
+ EGLSurface surface,
+ uint32_t index);
extern void *eglReadBuffer(EGLDisplay display,
EGLSurface surface, GLenum buffer, GLuint *stride);
diff --git a/intel.c b/intel.c
index 74cb80f..d27ba05 100644
--- a/intel.c
+++ b/intel.c
@@ -37,10 +37,11 @@
typedef struct EGLSurfaceNative *EGLSurfaceNative;
struct EGLSurfaceNative {
struct EGLSurface base;
+ __DRIbuffer *current;
+ __DRIbuffer colorBuffers[2];
+ int colorBufferCount;
+ uint32_t colorBufferHandles[2];
uint32_t handles[10];
- EGLBoolean backBuffer;
- __DRIbuffer front;
- uint32_t frontHandle;
};
static inline uint32_t
@@ -179,8 +180,12 @@ intelGetBuffers(EGLSurface surface, unsigned int *attachments, int count)
{
EGLSurfaceNative nativeSurface = (EGLSurfaceNative) surface;
__DRIbuffer *buffer;
- struct drm_gem_open open_arg;
- int i, ret;
+ int i;
+
+ buffer = &surface->buffers[0];
+ buffer->pitch = nativeSurface->current->pitch;
+ buffer->name = nativeSurface->current->name;
+ buffer->cpp = nativeSurface->current->cpp;
if (count == surface->count)
return;
@@ -192,16 +197,10 @@ intelGetBuffers(EGLSurface surface, unsigned int *attachments, int count)
buffer = &surface->buffers[i];
buffer->attachment = attachments[i];
- if (buffer->attachment == __DRI_BUFFER_FRONT_LEFT &&
- nativeSurface->front.name != ~0 &&
- !nativeSurface->backBuffer) {
- buffer->name = nativeSurface->front.name;
- buffer->pitch = nativeSurface->front.pitch;
- buffer->cpp = 4;
- open_arg.name = buffer->name;
- ret = ioctl(surface->display->fd,
- DRM_IOCTL_GEM_OPEN, &open_arg);
- nativeSurface->handles[i] = open_arg.handle;
+ if (buffer->attachment == __DRI_BUFFER_FRONT_LEFT) {
+ buffer->pitch = nativeSurface->current->pitch;
+ buffer->name = nativeSurface->current->name;
+ buffer->cpp = nativeSurface->current->cpp;
continue;
}
@@ -229,6 +228,12 @@ intelDestroySurface(EGLDisplay display, EGLSurface surface)
struct drm_gem_close close;
int i;
+ for (i = 0; i < nativeSurface->colorBufferCount; i++) {
+ close.handle = nativeSurface->colorBufferHandles[i];
+ if (ioctl(surface->display->fd, DRM_IOCTL_GEM_CLOSE, &close) < 0)
+ fprintf(stderr, "close of bo %d failed\n", close.handle);
+ }
+
for (i = 0; i < surface->count; i++) {
close.handle = nativeSurface->handles[i];
if (ioctl(surface->display->fd, DRM_IOCTL_GEM_CLOSE, &close) < 0)
@@ -240,127 +245,134 @@ intelDestroySurface(EGLDisplay display, EGLSurface surface)
return EGL_TRUE;
}
-static EGLBoolean
-intelSwapBuffers(EGLDisplay display, EGLSurface surface)
+static const struct EagleBackend intelBackend = {
+ intelGetBuffers,
+ intelDestroySurface,
+};
+
+static EGLDisplay
+intelCreateDisplay(struct udev_device *device, const char *driver)
{
- EGLSurfaceNative nativeSurface = (EGLSurfaceNative) surface;
- EGLContext context;
+ EGLDisplay display;
+ const char *path;
- if (!nativeSurface->backBuffer)
- return EGL_TRUE;
+ display = malloc(sizeof *display);
+ if (display == NULL)
+ return NULL;
+
+ path = udev_device_get_devnode(device);
+ if (eglInitDisplay(display, path, driver) < 0) {
+ free(display);
+ return NULL;
+ }
- context = eglGetCurrentContext();
+ display->backend = &intelBackend;
- display->copyBuffer->copyBuffer(context->driContext,
- &nativeSurface->front,
- 0, 0,
- surface->driDrawable, __DRI_BUFFER_FRONT_LEFT,
- 0, 0,
- surface->width,
- surface->height);
+ return display;
+}
- glFlush();
+EGLDisplay
+i915CreateDisplay(struct udev_device *device)
+{
+ return intelCreateDisplay(device, "i915");
+}
- return EGL_TRUE;
+EGLDisplay
+i965CreateDisplay(struct udev_device *device)
+{
+ return intelCreateDisplay(device, "i965");
}
-static EGLSurface
-intelCreateSurfaceForName(EGLDisplay display, EGLConfig config,
- uint32_t name, uint32_t width,
- uint32_t height, uint32_t stride, const EGLint *attribList)
+EAGLE_EXPORT EGLSurface
+eglCreateSurface(EGLDisplay display, EGLConfig config,
+ uint32_t width, uint32_t height,
+ uint32_t colorBufferCount, const EGLint *attribList)
{
EGLSurfaceNative nativeSurface;
int i;
+ if (colorBufferCount < 1 || colorBufferCount > 2)
+ return NULL;
+
nativeSurface = malloc(sizeof *nativeSurface);
if (nativeSurface == NULL)
return NULL;
- nativeSurface->backBuffer = EGL_FALSE;
-
- nativeSurface->front.attachment = __DRI_BUFFER_FRONT_LEFT;
- if (name == 0) {
- nativeSurface->frontHandle =
+ nativeSurface->current = &nativeSurface->colorBuffers[0];
+ nativeSurface->colorBufferCount = colorBufferCount;
+ for (i = 0; i < colorBufferCount; i++) {
+ nativeSurface->colorBufferHandles[i] =
intelCreateBuffer(display->fd,
- width, height,
- &nativeSurface->front);
- } else {
- nativeSurface->front.name = name;
- nativeSurface->front.pitch = stride;
- nativeSurface->front.cpp = 4;
- nativeSurface->front.flags = 0;
- nativeSurface->frontHandle = 0;
+ width,
+ height,
+ &nativeSurface->colorBuffers[i]);
}
eglInitSurface(&nativeSurface->base, display, config, width, height);
- for (i = 0; attribList && attribList[i] != EGL_NONE; i += 2) {
- if (attribList[i] == EGL_RENDER_BUFFER &&
- attribList[i + 1] == EGL_BACK_BUFFER)
- nativeSurface->backBuffer = EGL_TRUE;
- }
-
return &nativeSurface->base;
}
-static const struct EagleBackend intelBackend = {
- intelGetBuffers,
- intelSwapBuffers,
- intelDestroySurface,
- intelCreateSurfaceForName
-};
-
-static EGLDisplay
-intelCreateDisplay(struct udev_device *device, const char *driver)
+EAGLE_EXPORT EGLSurface
+eglCreateSurfaceForName(EGLDisplay display, EGLConfig config,
+ uint32_t name, uint32_t width,
+ uint32_t height, uint32_t stride, const EGLint *attribList)
{
- EGLDisplay display;
- const char *path;
+ EGLSurfaceNative nativeSurface;
+ struct drm_gem_open open_arg;
+ int ret;
- display = malloc(sizeof *display);
- if (display == NULL)
+ nativeSurface = malloc(sizeof *nativeSurface);
+ if (nativeSurface == NULL)
return NULL;
-
- path = udev_device_get_devnode(device);
- if (eglInitDisplay(display, path, driver) < 0) {
- free(display);
+
+ nativeSurface->current = &nativeSurface->colorBuffers[0];
+ nativeSurface->colorBufferCount = 1;
+ nativeSurface->colorBuffers[0].attachment = __DRI_BUFFER_FRONT_LEFT;
+ nativeSurface->colorBuffers[0].name = name;
+ nativeSurface->colorBuffers[0].pitch = stride;
+ nativeSurface->colorBuffers[0].cpp = 4;
+ nativeSurface->colorBuffers[0].flags = 0;
+
+ open_arg.name = name;
+ ret = ioctl(display->fd, DRM_IOCTL_GEM_OPEN, &open_arg);
+ if (ret < 0) {
+ free(nativeSurface);
return NULL;
}
+ nativeSurface->colorBufferHandles[0] = open_arg.handle;
- display->backend = &intelBackend;
+ eglInitSurface(&nativeSurface->base, display, config, width, height);
- return display;
+ return &nativeSurface->base;
}
EAGLE_EXPORT EGLBoolean
-eglGetNativeBuffer(EGLSurface surface, GLenum buffer,
- uint32_t *name, uint32_t *handle, uint32_t *stride)
+eglGetColorBuffer(EGLSurface surface, uint32_t index,
+ uint32_t *name, uint32_t *handle, uint32_t *stride)
{
EGLSurfaceNative nativeSurface = (EGLSurfaceNative) surface;
- switch (buffer) {
- case GL_FRONT_LEFT:
- *name = nativeSurface->front.name;
- *handle = nativeSurface->frontHandle;
- *stride = nativeSurface->front.pitch;
- return EGL_TRUE;
- case GL_BACK_LEFT:
- *name = surface->buffers[0].name;
- *handle = nativeSurface->handles[0];
- *stride = surface->buffers[0].pitch;
- return EGL_TRUE;
- default:
+ if (index >= nativeSurface->colorBufferCount)
return EGL_FALSE;
- }
-}
-EGLDisplay
-i915CreateDisplay(struct udev_device *device)
-{
- return intelCreateDisplay(device, "i915");
+ *name = nativeSurface->colorBuffers[index].name;
+ *handle = nativeSurface->colorBufferHandles[index];
+ *stride = nativeSurface->colorBuffers[index].pitch;
+
+ return EGL_TRUE;
}
-EGLDisplay
-i965CreateDisplay(struct udev_device *device)
+EAGLE_EXPORT EGLBoolean
+eglBindColorBuffer(EGLDisplay display, EGLSurface surface, uint32_t index)
{
- return intelCreateDisplay(device, "i965");
+ EGLSurfaceNative nativeSurface = (EGLSurfaceNative) surface;
+
+ if (index >= nativeSurface->colorBufferCount)
+ return EGL_FALSE;
+
+ display->flush->flushInvalidate(surface->driDrawable);
+ nativeSurface->current = &nativeSurface->colorBuffers[index];
+
+ return EGL_TRUE;
}
diff --git a/test/Makefile.in b/test/Makefile.in
index 743d61f..cec3f3d 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -9,12 +9,12 @@ all : gears texture
gears_objs = gears.o setup.o
gears : ../libeagle.so $(gears_objs)
- gcc -o $@ -L.. -leagle -lm $(gears_objs)
+ gcc -o $@ -L.. -leagle $(LDLIBS) -lm $(gears_objs)
texture_objs = texture.o setup.o
texture : ../libeagle.so $(texture_objs)
- gcc -o $@ -L.. -leagle -lm $(texture_objs)
+ gcc -o $@ -L.. -leagle $(LDLIBS) -lm $(texture_objs)
clean :
rm -f *.o glapi/*.o libeagle.so test
diff --git a/test/gears.c b/test/gears.c
index 34da966..2083850 100644
--- a/test/gears.c
+++ b/test/gears.c
@@ -35,6 +35,7 @@
struct gears {
int width, height;
GLint gear1, gear2, gear3;
+ GLfloat angle;
};
static void
@@ -165,6 +166,8 @@ gears_create(int width, int height)
GLfloat h;
gears = malloc(sizeof *gears);
+ gears->angle = 0;
+
/* make the gears */
gears->gear1 = glGenLists(1);
glNewList(gears->gear1, GL_COMPILE);
@@ -246,38 +249,25 @@ gears_draw(struct gears *gears, GLfloat angle)
glFlush();
}
+static int init(struct state *state)
+{
+ state->data = gears_create(state->width, state->height);
+
+ return 0;
+}
+
static int render(struct state *state)
{
- struct pollfd p[1];
- GLfloat angle = 0.0;
- struct gears *gears;
- struct timeval before, now;
- int count, elapsed, slice = 300;
-
- gears = gears_create(state->width, state->height);
- p[0].fd = STDIN_FILENO;
- p[0].events = POLLIN;
- count = 0;
- gettimeofday(&before, NULL);
- while (1) {
- glClear(GL_COLOR_BUFFER_BIT);
- gears_draw(gears, angle);
- eglSwapBuffers(state->display, state->surface);
- angle += 0.4;
- count += 1;
- if (count == slice) {
- gettimeofday(&now, NULL);
- elapsed = (now.tv_sec - before.tv_sec) * 1000 +
- (now.tv_usec - before.tv_usec) / 1000;
- before = now;
- printf("%d frames in %d seconds: %f fps\n",
- slice, elapsed, (float) 1000 * slice / elapsed);
- count = 0;
- }
- }
+ struct gears *gears = state->data;
+
+ glClear(GL_COLOR_BUFFER_BIT);
+ gears_draw(gears, gears->angle);
+ gears->angle += 0.4;
+
+ return 0;
}
int main(int argc, char *argv[])
{
- return setup(argc, argv, render);
+ return setup(argc, argv, init, render);
}
diff --git a/test/setup.c b/test/setup.c
index 3fa0753..35070b5 100644
--- a/test/setup.c
+++ b/test/setup.c
@@ -7,9 +7,11 @@
#include "../eagle.h"
#include <sys/time.h>
#include <drm_mode.h>
+#include <xf86drm.h>
#include <xf86drmMode.h>
#include <sys/ioctl.h>
#include <i915_drm.h>
+#include <string.h>
#include "setup.h"
@@ -21,19 +23,6 @@ void die(const char *msg)
exit(EXIT_FAILURE);
}
-static void run(struct state *state, render_func_t render)
-{
- state->context = eglCreateContext(state->display, state->config, NULL, NULL);
- if (state->context == NULL)
- die("failed to create context\n");
-
- if (!eglMakeCurrent(state->display, state->surface, state->surface, state->context))
- die("failed to make context current\n");
-
- render(state);
- eglTerminate(state->display);
-}
-
static const EGLint config_attribs[] = {
EGL_DEPTH_SIZE, 24,
EGL_RED_SIZE, 8,
@@ -44,7 +33,7 @@ static const EGLint config_attribs[] = {
EGL_NONE
};
-static void run_dri2(int x, int y, int width, int height, render_func_t render)
+static void run_dri2(int x, int y, int width, int height, init_func_t init, render_func_t render)
{
EGLint major, minor;
Display *x11_display;
@@ -98,10 +87,30 @@ static void run_dri2(int x, int y, int width, int height, render_func_t render)
if (state.surface == NULL)
die("failed to create surface\n");
- run(&state, render);
+ state.context = eglCreateContext(state.display, state.config, NULL, NULL);
+ if (state.context == NULL)
+ die("failed to create context\n");
+
+ if (!eglMakeCurrent(state.display, state.surface, state.surface, state.context))
+ die("failed to make context current\n");
+
+ init(&state);
+
+ render(&state);
+
+ eglTerminate(state.display);
+}
+
+static void
+page_flip_handler(int fd, unsigned int frame,
+ unsigned int sec, unsigned int usec, void *data)
+{
+ int *done = data;
+
+ *done = 1;
}
-static void run_native(int x, int y, int width, int height, render_func_t render)
+static void run_native(int x, int y, int width, int height, init_func_t init, render_func_t render)
{
EGLint major, minor;
struct udev *udev;
@@ -111,11 +120,12 @@ static void run_native(int x, int y, int width, int height, render_func_t render
drmModeRes *resources;
drmModeEncoder *encoder;
drmModeModeInfo *mode;
- unsigned int fb_id;
- uint32_t name, handle, stride;
- int i, ret, fd;
- const static EGLint attribs[] =
- { EGL_RENDER_BUFFER, EGL_BACK_BUFFER, EGL_NONE };
+ int i, ret, fd, done;
+ drmEventContext evctx;
+ struct buffer {
+ unsigned int fb_id;
+ uint32_t name, handle, stride;
+ } b[2];
udev = udev_new();
device = udev_device_new_from_syspath(udev, "/sys/class/drm/card0");
@@ -170,37 +180,61 @@ static void run_native(int x, int y, int width, int height, render_func_t render
drmModeFreeEncoder(encoder);
}
- state.surface = eglCreateSurfaceForName(state.display, state.config,
- 0, mode->hdisplay, mode->vdisplay,
- 0, attribs);
- eglGetNativeBuffer(state.surface,
- GL_FRONT_LEFT, &name, &handle, &stride);
-
- ret = drmModeAddFB(fd, mode->hdisplay, mode->vdisplay,
- 32, 32, stride, handle, &fb_id);
- if (ret) {
- fprintf(stderr, "failed to add fb: %m\n");
- return;
+ state.surface = eglCreateSurface(state.display, state.config,
+ mode->hdisplay, mode->vdisplay, 2, NULL);
+ for (i = 0; i < 2; i++) {
+ eglGetColorBuffer(state.surface,
+ i, &b[i].name, &b[i].handle, &b[i].stride);
+
+ ret = drmModeAddFB(fd, mode->hdisplay, mode->vdisplay,
+ 32, 32, b[i].stride, b[i].handle, &b[i].fb_id);
+ if (ret) {
+ fprintf(stderr, "failed to add fb %d: %m\n", i);
+ return;
+ }
}
- ret = drmModeSetCrtc(fd, encoder->crtc_id, fb_id, 0, 0,
+ ret = drmModeSetCrtc(fd, encoder->crtc_id, b[1].fb_id, 0, 0,
&connector->connector_id, 1, mode);
if (ret) {
fprintf(stderr, "failed to set mode: %m\n");
return;
}
- run(&state, render);
+ state.context = eglCreateContext(state.display, state.config, NULL, NULL);
+ if (state.context == NULL)
+ die("failed to create context\n");
+
+ if (!eglMakeCurrent(state.display, state.surface, state.surface, state.context))
+ die("failed to make context current\n");
+
+ init(&state);
+
+ memset(&evctx, 0, sizeof evctx);
+ evctx.version = DRM_EVENT_CONTEXT_VERSION;
+ evctx.page_flip_handler = page_flip_handler;
+ i = 0;
+ while (1) {
+ render(&state);
+ eglBindColorBuffer(state.display, state.surface, i ^ 1);
+ drmModePageFlip(fd, encoder->crtc_id, b[i].fb_id, &done);
+ i ^= 1;
+ done = 0;
+ while (!done)
+ drmHandleEvent(fd, &evctx);
+ }
+
+ eglTerminate(state.display);
}
-int setup(int argc, char *argv[], render_func_t render)
+int setup(int argc, char *argv[], init_func_t init, render_func_t render)
{
const int x = 100, y = 100, width = 300, height = 300;
- run_dri2(x, y, width, height, render);
+ run_dri2(x, y, width, height, init, render);
fprintf(stderr, "open x11 display failed, trying drmfb\n");
- run_native(x, y, width, height, render);
+ run_native(x, y, width, height, init, render);
return 0;
}
diff --git a/test/setup.h b/test/setup.h
index fe453ad..ca949a3 100644
--- a/test/setup.h
+++ b/test/setup.h
@@ -10,10 +10,12 @@ struct state {
EGLContext context;
int width;
int height;
+ void *data;
};
+typedef int (*init_func_t)(struct state *state);
typedef int (*render_func_t)(struct state *state);
-int setup(int argc, char *argv[], render_func_t render);
+int setup(int argc, char *argv[], init_func_t init, render_func_t render);
#endif
diff --git a/test/texture.c b/test/texture.c
index 7d181d5..9cd1a8f 100644
--- a/test/texture.c
+++ b/test/texture.c
@@ -32,6 +32,11 @@
#include "../eagle.h"
#include "setup.h"
+static int init(struct state *state)
+{
+ return 0;
+}
+
static int render(struct state *state)
{
GLfloat vertices[12];
@@ -105,5 +110,5 @@ static int render(struct state *state)
int main(int argc, char *argv[])
{
- return setup(argc, argv, render);
+ return setup(argc, argv, init, render);
}
diff --git a/x11-dri2.c b/x11-dri2.c
index 78e589a..6321bd4 100644
--- a/x11-dri2.c
+++ b/x11-dri2.c
@@ -115,7 +115,6 @@ x11DestroySurface(EGLDisplay display, EGLSurface surface)
static const struct EagleBackend x11Backend = {
x11GetBuffers,
- x11SwapBuffers,
x11DestroySurface
};