From 39c81dada01585a6030f03d215842a1a2ae87d86 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Wed, 14 Apr 2010 21:28:12 +0100 Subject: [PATCH] st/dri: Refactor init code a bit Reviewed-by: George Sapountzis --- src/gallium/state_trackers/dri/common/dri_screen.c | 4 ++-- src/gallium/state_trackers/dri/common/dri_screen.h | 2 +- src/gallium/state_trackers/dri/drm/dri1.c | 6 +++++- src/gallium/state_trackers/dri/drm/dri2.c | 7 ++++--- src/gallium/state_trackers/dri/sw/drisw.c | 8 ++++++-- 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/gallium/state_trackers/dri/common/dri_screen.c b/src/gallium/state_trackers/dri/common/dri_screen.c index 83616744ad0..4bfbc6e80b7 100644 --- a/src/gallium/state_trackers/dri/common/dri_screen.c +++ b/src/gallium/state_trackers/dri/common/dri_screen.c @@ -327,10 +327,10 @@ dri_destroy_screen(__DRIscreen * sPriv) const __DRIconfig ** dri_init_screen_helper(struct dri_screen *screen, - struct drm_create_screen_arg *arg, + struct pipe_screen *pscreen, unsigned pixel_bits) { - screen->pipe_screen = screen->api->create_screen(screen->api, screen->fd, arg); + screen->pipe_screen = pscreen; if (!screen->pipe_screen) { debug_printf("%s: failed to create pipe_screen\n", __FUNCTION__); return NULL; diff --git a/src/gallium/state_trackers/dri/common/dri_screen.h b/src/gallium/state_trackers/dri/common/dri_screen.h index e77bce17ae9..8ab7d439191 100644 --- a/src/gallium/state_trackers/dri/common/dri_screen.h +++ b/src/gallium/state_trackers/dri/common/dri_screen.h @@ -104,7 +104,7 @@ dri_fill_st_visual(struct st_visual *stvis, struct dri_screen *screen, const __DRIconfig ** dri_init_screen_helper(struct dri_screen *screen, - struct drm_create_screen_arg *arg, + struct pipe_screen *pscreen, unsigned pixel_bits); void diff --git a/src/gallium/state_trackers/dri/drm/dri1.c b/src/gallium/state_trackers/dri/drm/dri1.c index a6f40394b69..bdf251653d9 100644 --- a/src/gallium/state_trackers/dri/drm/dri1.c +++ b/src/gallium/state_trackers/dri/drm/dri1.c @@ -469,6 +469,7 @@ const __DRIconfig ** dri1_init_screen(__DRIscreen * sPriv) { const __DRIconfig **configs; + struct pipe_screen *pscreen; struct dri_screen *screen; struct dri1_create_screen_arg arg; @@ -500,7 +501,10 @@ dri1_init_screen(__DRIscreen * sPriv) * using. */ - configs = dri_init_screen_helper(screen, &arg.base, sPriv->fbBPP); + pscreen = screen->api->create_screen(screen->api, screen->fd, &arg.base); + /* dri_init_screen_helper checks pscreen for us */ + + configs = dri_init_screen_helper(screen, pscreen, sPriv->fbBPP); if (!configs) goto fail; diff --git a/src/gallium/state_trackers/dri/drm/dri2.c b/src/gallium/state_trackers/dri/drm/dri2.c index c6655847e9c..0d15b5c9b85 100644 --- a/src/gallium/state_trackers/dri/drm/dri2.c +++ b/src/gallium/state_trackers/dri/drm/dri2.c @@ -499,7 +499,7 @@ dri2_init_screen(__DRIscreen * sPriv) { const __DRIconfig **configs; struct dri_screen *screen; - struct drm_create_screen_arg arg; + struct pipe_screen *pscreen; screen = CALLOC_STRUCT(dri_screen); if (!screen) @@ -512,9 +512,10 @@ dri2_init_screen(__DRIscreen * sPriv) sPriv->private = (void *)screen; sPriv->extensions = dri_screen_extensions; - arg.mode = DRM_CREATE_NORMAL; + pscreen = screen->api->create_screen(screen->api, screen->fd, NULL); + /* dri_init_screen_helper checks pscreen for us */ - configs = dri_init_screen_helper(screen, &arg, 32); + configs = dri_init_screen_helper(screen, pscreen, 32); if (!configs) goto fail; diff --git a/src/gallium/state_trackers/dri/sw/drisw.c b/src/gallium/state_trackers/dri/sw/drisw.c index 9106f0d5eb4..7f7d737f558 100644 --- a/src/gallium/state_trackers/dri/sw/drisw.c +++ b/src/gallium/state_trackers/dri/sw/drisw.c @@ -261,13 +261,14 @@ drisw_init_screen(__DRIscreen * sPriv) { const __DRIconfig **configs; struct dri_screen *screen; + struct pipe_screen *pscreen; struct drisw_create_screen_arg arg; screen = CALLOC_STRUCT(dri_screen); if (!screen) return NULL; - screen->api = drm_api_create(); + screen->api = NULL; /* not needed */ screen->sPriv = sPriv; screen->fd = -1; @@ -277,7 +278,10 @@ drisw_init_screen(__DRIscreen * sPriv) arg.base.mode = DRM_CREATE_DRISW; arg.lf = &drisw_lf; - configs = dri_init_screen_helper(screen, &arg.base, 32); + pscreen = screen->api->create_screen(screen->api, screen->fd, &arg.base); + /* dri_init_screen_helper checks pscreen for us */ + + configs = dri_init_screen_helper(screen, pscreen, 32); if (!configs) goto fail; -- 2.30.2