diff options
author | George Sapountzis <[email protected]> | 2010-03-29 21:06:54 +0300 |
---|---|---|
committer | George Sapountzis <[email protected]> | 2010-03-29 21:06:54 +0300 |
commit | 625e024b186829f199458679921916971a5b00cb (patch) | |
tree | 880bb927cb786e9602a91aded97298452b6193a9 /src/gallium/state_trackers | |
parent | 6cc5fbd76b8994da8174c39f8eacb6605f4aa3b2 (diff) |
st/dri/sw: add drisw_api similarly to dri1_api
I am pretty sure that this is in gallium spirit, so commit. Thanks to Chia-I
for suggesting this.
Diffstat (limited to 'src/gallium/state_trackers')
-rw-r--r-- | src/gallium/state_trackers/dri/common/dri_st_api.c | 2 | ||||
-rw-r--r-- | src/gallium/state_trackers/dri/drm/dri1.c | 30 | ||||
-rw-r--r-- | src/gallium/state_trackers/dri/sw/drisw.c | 100 | ||||
-rw-r--r-- | src/gallium/state_trackers/dri/sw/drisw.h | 2 |
4 files changed, 53 insertions, 81 deletions
diff --git a/src/gallium/state_trackers/dri/common/dri_st_api.c b/src/gallium/state_trackers/dri/common/dri_st_api.c index 40b24b18e9f..7ba7ec383d8 100644 --- a/src/gallium/state_trackers/dri/common/dri_st_api.c +++ b/src/gallium/state_trackers/dri/common/dri_st_api.c @@ -80,7 +80,7 @@ dri_st_framebuffer_validate(struct st_framebuffer_iface *stfbi, } #else if (new_stamp) - drisw_update_drawable_info(drawable->dPriv); + drisw_update_drawable_info(drawable); drisw_allocate_textures(drawable, statt_mask); #endif diff --git a/src/gallium/state_trackers/dri/drm/dri1.c b/src/gallium/state_trackers/dri/drm/dri1.c index aad098bb301..9b5842ba2bf 100644 --- a/src/gallium/state_trackers/dri/drm/dri1.c +++ b/src/gallium/state_trackers/dri/drm/dri1.c @@ -404,6 +404,19 @@ dri1_allocate_textures(struct dri_drawable *drawable, drawable->old_h = height; } +/* + * Backend function for init_screen. + */ + +static const __DRIextension *dri1_screen_extensions[] = { + &driReadDrawableExtension, + &driCopySubBufferExtension.base, + &driSwapControlExtension.base, + &driFrameTrackingExtension.base, + &driMediaStreamCounterExtension.base, + NULL +}; + static void st_dri_lock(struct pipe_context *pipe) { @@ -442,21 +455,6 @@ static struct dri1_api_lock_funcs dri1_lf = { .clear_lost_lock = st_dri_clear_lost_lock }; -/* - * Backend function for init_screen. - */ - -static const __DRIextension *dri1_screen_extensions[] = { - &driReadDrawableExtension, - &driCopySubBufferExtension.base, - &driSwapControlExtension.base, - &driFrameTrackingExtension.base, - &driMediaStreamCounterExtension.base, - NULL -}; - -struct dri1_api *__dri1_api_hooks = NULL; - static INLINE void dri1_copy_version(struct dri1_api_version *dst, const struct __DRIversionRec *src) @@ -466,6 +464,8 @@ dri1_copy_version(struct dri1_api_version *dst, dst->patch_level = src->patch; } +struct dri1_api *__dri1_api_hooks = NULL; + const __DRIconfig ** dri1_init_screen(__DRIscreen * sPriv) { diff --git a/src/gallium/state_trackers/dri/sw/drisw.c b/src/gallium/state_trackers/dri/sw/drisw.c index b7eba63bcb9..b8256710972 100644 --- a/src/gallium/state_trackers/dri/sw/drisw.c +++ b/src/gallium/state_trackers/dri/sw/drisw.c @@ -28,37 +28,17 @@ /* TODO: * - * stride: - * - * The driver and the loaders (libGL, xserver/glx) compute the stride from the - * width independently. winsys has a workaround that works for softpipe but may - * explode for other drivers or platforms, rendering- or performance-wise. - * Solving this issue properly requires extending the DRISW loader extension, - * in order to make the stride available to the putImage callback. - * - * drisw_api: - * - * Define drisw_api similarly to dri1_api and use it to call the loader. This - * is predicated on support for calling the loader from the winsys, which has - * to grow for DRI2 as well. - * * xshm / texture_from_pixmap / EGLImage: * * Allow the loaders to use the XSHM extension. It probably requires callbacks - * for createImage/destroyImage similar to DRI2 getBuffers. Probably not worth - * it, given the scope of DRISW, unless it falls naturally from properly - * solving the other issues. - * - * fences: - * - * No fences are used, are they needed for llvmpipe / cell ? + * for createImage/destroyImage similar to DRI2 getBuffers. */ #include "util/u_format.h" #include "util/u_memory.h" #include "util/u_inlines.h" #include "pipe/p_context.h" -#include "state_tracker/drm_api.h" +#include "state_tracker/drisw_api.h" #include "dri_screen.h" #include "dri_context.h" @@ -80,60 +60,47 @@ get_drawable_info(__DRIdrawable *dPriv, int *w, int *h) dPriv->loaderPrivate); } -/* - * Set the width to 'stride / cpp'. PutImage seems to correctly clip the width - * to the actual width of the dst drawable. Even if this is not specified but - * an implementation detail, it is the correct thing to do, so rely on it. XXX - */ static INLINE void -put_image(__DRIdrawable *dPriv, void *data, unsigned width) +put_image(__DRIdrawable *dPriv, void *data, unsigned width, unsigned height) { __DRIscreen *sPriv = dPriv->driScreenPriv; const __DRIswrastLoaderExtension *loader = sPriv->swrast_loader; loader->putImage(dPriv, __DRI_SWRAST_IMAGE_OP_SWAP, - 0, 0, width, dPriv->h, + 0, 0, width, height, data, dPriv->loaderPrivate); } void -drisw_update_drawable_info(__DRIdrawable *dPriv) +drisw_update_drawable_info(struct dri_drawable *drawable) { + __DRIdrawable *dPriv = drawable->dPriv; + get_drawable_info(dPriv, &dPriv->w, &dPriv->h); } +static void +drisw_put_image(struct dri_drawable *drawable, + void *data, unsigned width, unsigned height) +{ + __DRIdrawable *dPriv = drawable->dPriv; + + put_image(dPriv, data, width, height); +} + static INLINE void drisw_present_texture(__DRIdrawable *dPriv, struct pipe_texture *ptex) { struct dri_drawable *drawable = dri_drawable(dPriv); struct dri_screen *screen = dri_screen(drawable->sPriv); - struct pipe_context *pipe; struct pipe_surface *psurf; - struct pipe_transfer *ptrans; - void *pmap; - unsigned width; - pipe = dri1_get_pipe_context(screen); psurf = dri1_get_pipe_surface(drawable, ptex); - if (!pipe || !psurf) + if (!psurf) return; - ptrans = pipe->get_tex_transfer(pipe, ptex, 0, 0, 0, - PIPE_TRANSFER_READ, - 0, 0, dPriv->w, dPriv->h); - - width = ptrans->stride / util_format_get_blocksize(ptex->format); - - pmap = pipe->transfer_map(pipe, ptrans); - - assert(pmap); - - put_image(dPriv, pmap, width); - - pipe->transfer_unmap(pipe, ptrans); - - pipe->tex_transfer_destroy(pipe, ptrans); + screen->pipe_screen->flush_frontbuffer(screen->pipe_screen, psurf, drawable); } static INLINE void @@ -163,38 +130,38 @@ drisw_copy_to_front(__DRIdrawable * dPriv, */ void -drisw_flush_frontbuffer(struct dri_drawable *drawable, - enum st_attachment_type statt) +drisw_swap_buffers(__DRIdrawable *dPriv) { struct dri_context *ctx = dri_get_current(); + struct dri_drawable *drawable = dri_drawable(dPriv); struct pipe_texture *ptex; if (!ctx) return; - ptex = drawable->textures[statt]; + ptex = drawable->textures[ST_ATTACHMENT_BACK_LEFT]; if (ptex) { - drisw_copy_to_front(ctx->dPriv, ptex); + ctx->st->flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); + + drisw_copy_to_front(dPriv, ptex); } } void -drisw_swap_buffers(__DRIdrawable *dPriv) +drisw_flush_frontbuffer(struct dri_drawable *drawable, + enum st_attachment_type statt) { struct dri_context *ctx = dri_get_current(); - struct dri_drawable *drawable = dri_drawable(dPriv); struct pipe_texture *ptex; if (!ctx) return; - ptex = drawable->textures[ST_ATTACHMENT_BACK_LEFT]; + ptex = drawable->textures[statt]; if (ptex) { - ctx->st->flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); - - drisw_copy_to_front(dPriv, ptex); + drisw_copy_to_front(ctx->dPriv, ptex); } } @@ -286,12 +253,16 @@ static const __DRIextension *drisw_screen_extensions[] = { NULL }; +static struct drisw_loader_funcs drisw_lf = { + .put_image = drisw_put_image +}; + const __DRIconfig ** drisw_init_screen(__DRIscreen * sPriv) { const __DRIconfig **configs; struct dri_screen *screen; - struct drm_create_screen_arg arg; + struct drisw_create_screen_arg arg; screen = CALLOC_STRUCT(dri_screen); if (!screen) @@ -304,9 +275,10 @@ drisw_init_screen(__DRIscreen * sPriv) sPriv->private = (void *)screen; sPriv->extensions = drisw_screen_extensions; - arg.mode = DRM_CREATE_DRISW; + arg.base.mode = DRM_CREATE_DRISW; + arg.lf = &drisw_lf; - configs = dri_init_screen_helper(screen, &arg, 32); + configs = dri_init_screen_helper(screen, &arg.base, 32); if (!configs) goto fail; diff --git a/src/gallium/state_trackers/dri/sw/drisw.h b/src/gallium/state_trackers/dri/sw/drisw.h index 2c0d5610fac..c0c874f7326 100644 --- a/src/gallium/state_trackers/dri/sw/drisw.h +++ b/src/gallium/state_trackers/dri/sw/drisw.h @@ -39,7 +39,7 @@ const __DRIconfig ** drisw_init_screen(__DRIscreen * sPriv); void -drisw_update_drawable_info(__DRIdrawable *dPriv); +drisw_update_drawable_info(struct dri_drawable *drawable); void drisw_flush_frontbuffer(struct dri_drawable *drawable, |