From ea6a52a1f8e7fd72b5506218c31e58088131f1f5 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sat, 24 Apr 2010 13:36:09 +0100 Subject: st/dri: Add hooks for framebuffer functions --- src/gallium/state_trackers/dri/drm/dri1.c | 49 ++++++++++++------------------- src/gallium/state_trackers/dri/drm/dri1.h | 8 ----- src/gallium/state_trackers/dri/drm/dri2.c | 6 ++-- src/gallium/state_trackers/dri/drm/dri2.h | 9 ------ 4 files changed, 22 insertions(+), 50 deletions(-) (limited to 'src/gallium/state_trackers/dri/drm') diff --git a/src/gallium/state_trackers/dri/drm/dri1.c b/src/gallium/state_trackers/dri/drm/dri1.c index e216e46a87e..0be5fb5d8da 100644 --- a/src/gallium/state_trackers/dri/drm/dri1.c +++ b/src/gallium/state_trackers/dri/drm/dri1.c @@ -253,7 +253,7 @@ dri1_copy_to_front(struct dri_context *ctx, * Backend functions for st_framebuffer interface and swap_buffers. */ -void +static void dri1_flush_frontbuffer(struct dri_drawable *draw, enum st_attachment_type statt) { @@ -342,9 +342,10 @@ dri1_copy_sub_buffer(__DRIdrawable * dPriv, int x, int y, int w, int h) * as they are requested. Unused attachments are not removed, not until the * framebuffer is resized or destroyed. */ -void +static void dri1_allocate_textures(struct dri_drawable *drawable, - unsigned mask) + const enum st_attachment_type *statts, + unsigned count) { struct dri_screen *screen = dri_screen(drawable->sPriv); struct pipe_resource templ; @@ -371,40 +372,24 @@ dri1_allocate_textures(struct dri_drawable *drawable, templ.depth0 = 1; templ.last_level = 0; - for (i = 0; i < ST_ATTACHMENT_COUNT; i++) { + for (i = 0; i < count; i++) { enum pipe_format format; - unsigned tex_usage; + unsigned bind; - /* the texture already exists or not requested */ - if (drawable->textures[i] || !(mask & (1 << i))) { + /* the texture already exists */ + if (drawable->textures[statts[i]]) continue; - } - switch (i) { - case ST_ATTACHMENT_FRONT_LEFT: - case ST_ATTACHMENT_BACK_LEFT: - case ST_ATTACHMENT_FRONT_RIGHT: - case ST_ATTACHMENT_BACK_RIGHT: - format = drawable->stvis.color_format; - tex_usage = PIPE_BIND_DISPLAY_TARGET | - PIPE_BIND_RENDER_TARGET; - break; - case ST_ATTACHMENT_DEPTH_STENCIL: - format = drawable->stvis.depth_stencil_format; - tex_usage = PIPE_BIND_DEPTH_STENCIL; - break; - default: - format = PIPE_FORMAT_NONE; - break; - } + dri_drawable_get_format(drawable, statts[i], &format, &bind); + + if (format == PIPE_FORMAT_NONE) + continue; - if (format != PIPE_FORMAT_NONE) { - templ.format = format; - templ.bind = tex_usage; + templ.format = format; + templ.bind = bind; - drawable->textures[i] = - screen->pipe_screen->resource_create(screen->pipe_screen, &templ); - } + drawable->textures[statts[i]] = + screen->pipe_screen->resource_create(screen->pipe_screen, &templ); } drawable->old_w = width; @@ -489,6 +474,8 @@ dri1_init_screen(__DRIscreen * sPriv) screen->sPriv = sPriv; screen->fd = sPriv->fd; screen->drmLock = (drmLock *) & sPriv->pSAREA->lock; + screen->allocate_textures = dri1_allocate_textures; + screen->flush_frontbuffer = dri1_flush_frontbuffer; sPriv->private = (void *)screen; sPriv->extensions = dri1_screen_extensions; diff --git a/src/gallium/state_trackers/dri/drm/dri1.h b/src/gallium/state_trackers/dri/drm/dri1.h index f7441f98abc..a50188b3682 100644 --- a/src/gallium/state_trackers/dri/drm/dri1.h +++ b/src/gallium/state_trackers/dri/drm/dri1.h @@ -43,14 +43,6 @@ extern struct dri1_api *__dri1_api_hooks; const __DRIconfig ** dri1_init_screen(__DRIscreen * sPriv); -void -dri1_flush_frontbuffer(struct dri_drawable *drawable, - enum st_attachment_type statt); - -void -dri1_allocate_textures(struct dri_drawable *drawable, - unsigned mask); - void dri1_swap_buffers(__DRIdrawable * dPriv); void diff --git a/src/gallium/state_trackers/dri/drm/dri2.c b/src/gallium/state_trackers/dri/drm/dri2.c index 0bf8c83f21f..fa296a874a2 100644 --- a/src/gallium/state_trackers/dri/drm/dri2.c +++ b/src/gallium/state_trackers/dri/drm/dri2.c @@ -346,7 +346,7 @@ dri2_drawable_process_buffers(struct dri_drawable *drawable, * Backend functions for st_framebuffer interface. */ -void +static void dri2_allocate_textures(struct dri_drawable *drawable, const enum st_attachment_type *statts, unsigned count) @@ -358,7 +358,7 @@ dri2_allocate_textures(struct dri_drawable *drawable, dri2_drawable_process_buffers(drawable, buffers, num_buffers); } -void +static void dri2_flush_frontbuffer(struct dri_drawable *drawable, enum st_attachment_type statt) { @@ -513,6 +513,8 @@ dri2_init_screen(__DRIscreen * sPriv) screen->sPriv = sPriv; screen->fd = sPriv->fd; screen->lookup_egl_image = dri2_lookup_egl_image; + screen->allocate_textures = dri2_allocate_textures; + screen->flush_frontbuffer = dri2_flush_frontbuffer; sPriv->private = (void *)screen; sPriv->extensions = dri_screen_extensions; diff --git a/src/gallium/state_trackers/dri/drm/dri2.h b/src/gallium/state_trackers/dri/drm/dri2.h index 379963431fb..07adfe4f6c5 100644 --- a/src/gallium/state_trackers/dri/drm/dri2.h +++ b/src/gallium/state_trackers/dri/drm/dri2.h @@ -34,13 +34,4 @@ const __DRIconfig ** dri2_init_screen(__DRIscreen * sPriv); -void -dri2_flush_frontbuffer(struct dri_drawable *drawable, - enum st_attachment_type statt); - -void -dri2_allocate_textures(struct dri_drawable *drawable, - const enum st_attachment_type *statts, - unsigned count); - #endif /* DRI2_H */ -- cgit v1.2.3