diff options
author | Kristian Høgsberg <krh@redhat.com> | 2009-01-24 21:15:10 -0500 |
---|---|---|
committer | Kristian Høgsberg <krh@redhat.com> | 2009-01-26 23:02:38 -0500 |
commit | 6e2d81a9632a16db3a957cc63addb77b88159214 (patch) | |
tree | b0544ac30464b9ff840dcd1a1c9240846dd9dcae | |
parent | b518f7b307a8e421ef38c6f661147b64ee438771 (diff) |
Get r300 in better shape.
Still not there yet, trying to figure out how to get it running.
-rw-r--r-- | Makefile.in | 2 | ||||
-rw-r--r-- | configure.ac | 6 | ||||
-rw-r--r-- | eagle-internal.h | 4 | ||||
-rw-r--r-- | eagle.c | 9 | ||||
-rw-r--r-- | intel.c | 81 | ||||
-rw-r--r-- | radeon.c | 80 |
6 files changed, 108 insertions, 74 deletions
diff --git a/Makefile.in b/Makefile.in index 601763c..a236e39 100644 --- a/Makefile.in +++ b/Makefile.in @@ -13,7 +13,7 @@ radeon_objs = radeon.o objs = \ eagle.o \ - $(@DRIVER@_objs) \ + intel.o \ $(x11_dri2_objs) \ glapi/glapi.o \ glapi/dispatch.o \ diff --git a/configure.ac b/configure.ac index d91509a..6f8ce6f 100644 --- a/configure.ac +++ b/configure.ac @@ -11,11 +11,5 @@ if test $CC = gcc; then fi AC_SUBST(GCC_CFLAGS) -# FIXME: We should support both drivers and select at runtime, of course. -AC_ARG_WITH(driver, AS_HELP_STRING([--with-driver=[intel/radeon]], - [Driver to compile for]), - [DRIVER=$withval], [DRIVER=intel]) -AC_SUBST(DRIVER) - AC_CONFIG_FILES([Makefile eagle.pc]) AC_OUTPUT
\ No newline at end of file diff --git a/eagle-internal.h b/eagle-internal.h index 30d7642..98b3b8e 100644 --- a/eagle-internal.h +++ b/eagle-internal.h @@ -94,6 +94,9 @@ struct EagleBackend { 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, @@ -103,5 +106,6 @@ void eglInitSurface(EGLSurface surface, EGLDisplay display, EGLConfig fbconfig, EGLDisplay i915CreateDisplay(struct udev_device *device); EGLDisplay i965CreateDisplay(struct udev_device *device); +EGLDisplay r300CreateDisplay(struct udev_device *device); #endif @@ -533,6 +533,15 @@ eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, return EGL_NO_SURFACE; } +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); +} + EGLBoolean eglDestroySurface(EGLDisplay display, EGLSurface surface) { @@ -50,7 +50,7 @@ align_to(uint32_t value, uint32_t align) } static void -nativeGetBuffers(EGLSurface surface, unsigned int *attachments, int count) +intelGetBuffers(EGLSurface surface, unsigned int *attachments, int count) { EGLSurfaceNative nativeSurface = (EGLSurfaceNative) surface; struct drm_i915_gem_create create; @@ -114,7 +114,7 @@ nativeGetBuffers(EGLSurface surface, unsigned int *attachments, int count) } static EGLBoolean -nativeDestroySurface(EGLDisplay display, EGLSurface surface) +intelDestroySurface(EGLDisplay display, EGLSurface surface) { free(surface); @@ -122,7 +122,7 @@ nativeDestroySurface(EGLDisplay display, EGLSurface surface) } static EGLBoolean -nativeDRISwapBuffers(EGLDisplay display, EGLSurface surface) +intelSwapBuffers(EGLDisplay display, EGLSurface surface) { EGLSurfaceNative nativeSurface = (EGLSurfaceNative) surface; EGLContext context; @@ -148,10 +148,43 @@ nativeDRISwapBuffers(EGLDisplay display, EGLSurface surface) return EGL_TRUE; } -static const struct EagleBackend nativeDRIBackend = { - nativeGetBuffers, - nativeDRISwapBuffers, - nativeDestroySurface, +static EGLSurface +intelCreateSurfaceForName(EGLDisplay display, EGLConfig config, + uint32_t name, uint32_t width, + uint32_t height, uint32_t stride, const EGLint *attribList) +{ + EGLSurfaceNative nativeSurface; + int i; + + nativeSurface = malloc(sizeof *nativeSurface); + if (nativeSurface == NULL) + return NULL; + + nativeSurface->backBuffer = EGL_FALSE; + + nativeSurface->front.attachment = __DRI_BUFFER_FRONT_LEFT; + nativeSurface->front.name = name; + nativeSurface->front.pitch = stride; + nativeSurface->front.cpp = 4; + nativeSurface->front.flags = 0; + nativeSurface->frontHandle = 0; + + 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 @@ -168,7 +201,7 @@ intelCreateDisplay(struct udev_device *device, const char *driver) return NULL; } - display->backend = &nativeDRIBackend; + display->backend = &intelBackend; return display; } @@ -184,35 +217,3 @@ i965CreateDisplay(struct udev_device *device) { return intelCreateDisplay(device, "i965"); } - -EGLSurface -eglCreateSurfaceForName(EGLDisplay display, EGLConfig config, - uint32_t name, uint32_t width, - uint32_t height, uint32_t stride, const EGLint *attribList) -{ - EGLSurfaceNative nativeSurface; - int i; - - nativeSurface = malloc(sizeof *nativeSurface); - if (nativeSurface == NULL) - return NULL; - - nativeSurface->backBuffer = EGL_FALSE; - - nativeSurface->front.attachment = __DRI_BUFFER_FRONT_LEFT; - nativeSurface->front.name = name; - nativeSurface->front.pitch = stride; - nativeSurface->front.cpp = 4; - nativeSurface->front.flags = 0; - nativeSurface->frontHandle = 0; - - 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; -} @@ -33,13 +33,6 @@ #include <GL/gl.h> /* dri_interface.h uses some GL integer types... */ #include "eagle-internal.h" -typedef struct EGLDisplayNative *EGLDisplayNative; -struct EGLDisplayNative { - struct EGLDisplay base; - - __DRIcopyBufferExtension *copyBuffer; -}; - typedef struct EGLSurfaceNative *EGLSurfaceNative; struct EGLSurfaceNative { struct EGLSurface base; @@ -58,7 +51,7 @@ align_to(uint32_t value, uint32_t align) #define RADEON_ALIGNMENT 64 static void -nativeGetBuffers(EGLSurface surface, unsigned int *attachments, int count) +r300GetBuffers(EGLSurface surface, unsigned int *attachments, int count) { EGLSurfaceNative nativeSurface = (EGLSurfaceNative) surface; struct drm_radeon_gem_create create; @@ -127,37 +120,44 @@ nativeGetBuffers(EGLSurface surface, unsigned int *attachments, int count) } static EGLBoolean -nativeDestroySurface(EGLDisplay display, EGLSurface surface) +r300DestroySurface(EGLDisplay display, EGLSurface surface) { free(surface); return EGL_TRUE; } -EGLDisplay -eglCreateDisplayNative(const char *device, const char *driver) +static EGLBoolean +r300SwapBuffers(EGLDisplay display, EGLSurface surface) { - EGLDisplayNative nativeDisplay; + EGLSurfaceNative nativeSurface = (EGLSurfaceNative) surface; + EGLContext context; + __DRIbuffer *back; - nativeDisplay = malloc(sizeof *nativeDisplay); - if (nativeDisplay == NULL) - return NULL; - - if (eglInitDisplay(&nativeDisplay->base, device, driver) < 0) { - free(nativeDisplay); - return NULL; - } + if (!nativeSurface->backBuffer) + return EGL_TRUE; - if (nativeDisplay->base.backend == NULL) - return NULL; + context = eglGetCurrentContext(); + + back = &surface->buffers[0]; + + display->copyBuffer->copyBuffer(context->driContext, + &nativeSurface->front, + 0, 0, + back, + 0, 0, + surface->width, + surface->height); + + glFlush(); - return &nativeDisplay->base; + return EGL_TRUE; } -EGLSurface -eglCreateSurfaceForName(EGLDisplay display, EGLConfig config, - uint32_t name, uint32_t width, - uint32_t height, uint32_t stride, const EGLint *attribList) +static EGLSurface +r300CreateSurfaceForName(EGLDisplay display, EGLConfig config, + uint32_t name, uint32_t width, + uint32_t height, uint32_t stride, const EGLint *attribList) { EGLSurfaceNative nativeSurface; int i; @@ -185,3 +185,29 @@ eglCreateSurfaceForName(EGLDisplay display, EGLConfig config, return &nativeSurface->base; } + +static const struct EagleBackend r300Backend = { + r300GetBuffers, + r300SwapBuffers, + r300DestroySurface, + r300CreateSurfaceForName +}; + +EGLDisplay +r300CreateDisplay(struct udev_device *device) +{ + EGLDisplay display; + + display = malloc(sizeof *display); + if (display == NULL) + return NULL; + + if (eglInitDisplay(display, device, "r300") < 0) { + free(display); + return NULL; + } + + display->backend = &r300Backend; + + return display; +} |