From 303cbb45b558a2b94e6922252cf57d115ba60b82 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Tue, 30 Jun 2009 11:49:43 +0200 Subject: drm/st: Return drm_api struct from a function --- src/gallium/state_trackers/dri/dri_context.c | 2 +- src/gallium/state_trackers/dri/dri_drawable.c | 10 +++++++--- src/gallium/state_trackers/dri/dri_screen.c | 6 ++++-- src/gallium/state_trackers/dri/dri_screen.h | 1 + 4 files changed, 13 insertions(+), 6 deletions(-) (limited to 'src/gallium/state_trackers/dri') diff --git a/src/gallium/state_trackers/dri/dri_context.c b/src/gallium/state_trackers/dri/dri_context.c index 45eaec4ed3..6c617197ec 100644 --- a/src/gallium/state_trackers/dri/dri_context.c +++ b/src/gallium/state_trackers/dri/dri_context.c @@ -69,7 +69,7 @@ dri_create_context(const __GLcontextModes * visual, driParseConfigFiles(&ctx->optionCache, &screen->optionCache, sPriv->myNum, "dri"); - ctx->pipe = drm_api_hooks.create_context(screen->pipe_screen); + ctx->pipe = screen->api->create_context(screen->api, screen->pipe_screen); if (ctx->pipe == NULL) goto fail; diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c index 815055b15b..1d91fbb89f 100644 --- a/src/gallium/state_trackers/dri/dri_drawable.c +++ b/src/gallium/state_trackers/dri/dri_drawable.c @@ -53,7 +53,8 @@ dri_copy_to_front(__DRIdrawablePrivate * dPriv, } static struct pipe_surface * -dri_surface_from_handle(struct pipe_screen *screen, +dri_surface_from_handle(struct drm_api *api, + struct pipe_screen *screen, unsigned handle, enum pipe_format format, unsigned width, unsigned height, unsigned pitch) @@ -63,7 +64,7 @@ dri_surface_from_handle(struct pipe_screen *screen, struct pipe_texture templat; struct pipe_buffer *buf = NULL; - buf = drm_api_hooks.buffer_from_handle(screen, "dri2 buffer", handle); + buf = api->buffer_from_handle(api, screen, "dri2 buffer", handle); if (!buf) return NULL; @@ -100,12 +101,14 @@ dri_surface_from_handle(struct pipe_screen *screen, void dri_get_buffers(__DRIdrawablePrivate * dPriv) { + struct dri_drawable *drawable = dri_drawable(dPriv); struct pipe_surface *surface = NULL; struct pipe_screen *screen = dri_screen(drawable->sPriv)->pipe_screen; __DRIbuffer *buffers = NULL; __DRIscreen *dri_screen = drawable->sPriv; __DRIdrawable *dri_drawable = drawable->dPriv; + struct drm_api *api = ((struct dri_screen*)(dri_screen->private))->api; boolean have_depth = FALSE; int i, count; @@ -187,7 +190,8 @@ dri_get_buffers(__DRIdrawablePrivate * dPriv) have_depth = TRUE; } - surface = dri_surface_from_handle(screen, + surface = dri_surface_from_handle(api, + screen, buffers[i].name, format, dri_drawable->w, diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c index 98bf68ccba..5f78b7264a 100644 --- a/src/gallium/state_trackers/dri/dri_screen.c +++ b/src/gallium/state_trackers/dri/dri_screen.c @@ -199,6 +199,7 @@ dri_init_screen(__DRIscreenPrivate * sPriv) if (!screen) return NULL; + screen->api = drm_api_create(); screen->sPriv = sPriv; screen->fd = sPriv->fd; screen->drmLock = (drmLock *) & sPriv->pSAREA->lock; @@ -216,7 +217,7 @@ dri_init_screen(__DRIscreenPrivate * sPriv) dri_copy_version(&arg.drm_version, &sPriv->drm_version); arg.api = NULL; - screen->pipe_screen = drm_api_hooks.create_screen(screen->fd, &arg.base); + screen->pipe_screen = screen->api->create_screen(screen->api, screen->fd, &arg.base); if (!screen->pipe_screen || !arg.api) { debug_printf("%s: failed to create dri1 screen\n", __FUNCTION__); @@ -265,13 +266,14 @@ dri_init_screen2(__DRIscreenPrivate * sPriv) if (!screen) goto fail; + screen->api = drm_api_create(); screen->sPriv = sPriv; screen->fd = sPriv->fd; sPriv->private = (void *)screen; sPriv->extensions = dri_screen_extensions; arg.mode = DRM_CREATE_NORMAL; - screen->pipe_screen = drm_api_hooks.create_screen(screen->fd, &arg); + screen->pipe_screen = screen->api->create_screen(screen->api, screen->fd, &arg); if (!screen->pipe_screen) { debug_printf("%s: failed to create pipe_screen\n", __FUNCTION__); goto fail; diff --git a/src/gallium/state_trackers/dri/dri_screen.h b/src/gallium/state_trackers/dri/dri_screen.h index 090f9fee7c..f3335bb09f 100644 --- a/src/gallium/state_trackers/dri/dri_screen.h +++ b/src/gallium/state_trackers/dri/dri_screen.h @@ -60,6 +60,7 @@ struct dri_screen drmLock *drmLock; /* gallium */ + struct drm_api *api; struct pipe_winsys *pipe_winsys; struct pipe_screen *pipe_screen; boolean d_depth_bits_last; -- cgit v1.2.3