From 1448e829e86981e6144410ba6a3d0f16357fb2b3 Mon Sep 17 00:00:00 2001 From: Christian König Date: Wed, 15 Feb 2012 17:20:50 +0100 Subject: vl: rework winsys interface MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Throw out all the old and now unneeded stuff. Signed-off-by: Christian König --- src/gallium/winsys/g3dvl/dri/dri_winsys.c | 137 ++++++++--------------------- src/gallium/winsys/g3dvl/vl_winsys.h | 17 +--- src/gallium/winsys/g3dvl/xlib/xsp_winsys.c | 85 +++--------------- 3 files changed, 54 insertions(+), 185 deletions(-) (limited to 'src/gallium/winsys/g3dvl') diff --git a/src/gallium/winsys/g3dvl/dri/dri_winsys.c b/src/gallium/winsys/g3dvl/dri/dri_winsys.c index 1875d49e139..904a6d796fc 100644 --- a/src/gallium/winsys/g3dvl/dri/dri_winsys.c +++ b/src/gallium/winsys/g3dvl/dri/dri_winsys.c @@ -54,69 +54,13 @@ struct vl_dri_screen Drawable last_seen_drawable; }; -static struct pipe_surface* -vl_dri2_get_front(struct vl_context *vctx, Drawable drawable) -{ - int w, h; - unsigned int attachments[1] = {DRI2BufferFrontLeft}; - int count; - DRI2Buffer *dri2_front; - struct pipe_resource *front_tex; - struct pipe_surface *front_surf = NULL; - - assert(vctx); - - struct vl_dri_screen *vl_dri_scrn = (struct vl_dri_screen*)vctx->vscreen; - assert(vl_dri_scrn); - - dri2_front = DRI2GetBuffers(vl_dri_scrn->display, drawable, &w, &h, - attachments, 1, &count); - - assert(count == 1); - - if (dri2_front) { - struct winsys_handle dri2_front_handle = - { - .type = DRM_API_HANDLE_TYPE_SHARED, - .handle = dri2_front->name, - .stride = dri2_front->pitch - }; - struct pipe_resource template; - struct pipe_surface surf_template; - - memset(&template, 0, sizeof(struct pipe_resource)); - template.target = PIPE_TEXTURE_2D; - template.format = PIPE_FORMAT_B8G8R8X8_UNORM; - template.last_level = 0; - template.width0 = w; - template.height0 = h; - template.depth0 = 1; - template.usage = PIPE_USAGE_STATIC; - template.bind = PIPE_BIND_RENDER_TARGET; - template.flags = 0; - - front_tex = vl_dri_scrn->base.pscreen->resource_from_handle(vl_dri_scrn->base.pscreen, &template, &dri2_front_handle); - if (front_tex) { - memset(&surf_template, 0, sizeof(surf_template)); - surf_template.format = front_tex->format; - surf_template.usage = PIPE_BIND_RENDER_TARGET; - front_surf = vctx->pipe->create_surface(vctx->pipe, front_tex, &surf_template); - } - pipe_resource_reference(&front_tex, NULL); - Xfree(dri2_front); - } - - return front_surf; -} - static void vl_dri2_flush_frontbuffer(struct pipe_screen *screen, struct pipe_resource *resource, unsigned level, unsigned layer, void *context_private) { - struct vl_context *vl_dri_ctx = (struct vl_context*)context_private; - struct vl_dri_screen *vl_dri_scrn = (struct vl_dri_screen*)vl_dri_ctx->vscreen; + struct vl_dri_screen *vl_dri_scrn = (struct vl_dri_screen*)context_private; XserverRegion region; assert(screen); @@ -129,12 +73,16 @@ vl_dri2_flush_frontbuffer(struct pipe_screen *screen, XFixesDestroyRegion(vl_dri_scrn->display, region); } -struct pipe_surface* -vl_drawable_surface_get(struct vl_context *vctx, Drawable drawable) +struct pipe_resource* +vl_screen_texture_from_drawable(struct vl_screen *vscreen, Drawable drawable) { - assert(vctx); + struct vl_dri_screen *vl_dri_scrn = (struct vl_dri_screen*)vscreen; + unsigned int attachments[1] = {DRI2BufferFrontLeft}; + struct winsys_handle dri2_front_handle; + struct pipe_resource template, *tex; + DRI2Buffer *dri2_front; + int w, h, count; - struct vl_dri_screen *vl_dri_scrn = (struct vl_dri_screen*)vctx->vscreen; assert(vl_dri_scrn); if (vl_dri_scrn->last_seen_drawable != drawable) { @@ -148,13 +96,39 @@ vl_drawable_surface_get(struct vl_context *vctx, Drawable drawable) vl_dri_scrn->last_seen_drawable = drawable; } - return vl_dri2_get_front(vctx, drawable); + dri2_front = DRI2GetBuffers(vl_dri_scrn->display, drawable, &w, &h, attachments, 1, &count); + + assert(count == 1); + + if (!dri2_front) + return NULL; + + memset(&dri2_front_handle, 0, sizeof(dri2_front_handle)); + dri2_front_handle.type = DRM_API_HANDLE_TYPE_SHARED; + dri2_front_handle.handle = dri2_front->name; + dri2_front_handle.stride = dri2_front->pitch; + + memset(&template, 0, sizeof(template)); + template.target = PIPE_TEXTURE_2D; + template.format = PIPE_FORMAT_B8G8R8X8_UNORM; + template.last_level = 0; + template.width0 = w; + template.height0 = h; + template.depth0 = 1; + template.usage = PIPE_USAGE_STATIC; + template.bind = PIPE_BIND_RENDER_TARGET; + template.flags = 0; + + tex = vl_dri_scrn->base.pscreen->resource_from_handle(vl_dri_scrn->base.pscreen, &template, &dri2_front_handle); + Xfree(dri2_front); + + return tex; } void* -vl_contextprivate_get(struct vl_context *vctx, struct pipe_surface *displaytarget) +vl_screen_get_private(struct vl_screen *vscreen) { - return vctx; + return vscreen; } static unsigned drawable_hash(void *key) @@ -237,38 +211,3 @@ void vl_screen_destroy(struct vl_screen *vscreen) vl_dri_scrn->base.pscreen->destroy(vl_dri_scrn->base.pscreen); FREE(vl_dri_scrn); } - -struct vl_context* -vl_video_create(struct vl_screen *vscreen) -{ - struct vl_context *vl_dri_ctx; - - vl_dri_ctx = CALLOC_STRUCT(vl_context); - if (!vl_dri_ctx) - goto no_struct; - - vl_dri_ctx->vscreen = vscreen; - vl_dri_ctx->pipe = vscreen->pscreen->context_create(vscreen->pscreen, vl_dri_ctx); - if (!vl_dri_ctx->pipe) { - debug_printf("[G3DVL] No video support found on %s/%s.\n", - vscreen->pscreen->get_vendor(vscreen->pscreen), - vscreen->pscreen->get_name(vscreen->pscreen)); - goto no_pipe; - } - - return vl_dri_ctx; - -no_pipe: - FREE(vl_dri_ctx); - -no_struct: - return NULL; -} - -void vl_video_destroy(struct vl_context *vctx) -{ - assert(vctx); - - vctx->pipe->destroy(vctx->pipe); - FREE(vctx); -} diff --git a/src/gallium/winsys/g3dvl/vl_winsys.h b/src/gallium/winsys/g3dvl/vl_winsys.h index 2782e513880..3e7d771db2f 100644 --- a/src/gallium/winsys/g3dvl/vl_winsys.h +++ b/src/gallium/winsys/g3dvl/vl_winsys.h @@ -40,26 +40,15 @@ struct vl_screen struct pipe_screen *pscreen; }; -struct vl_context -{ - struct vl_screen *vscreen; - struct pipe_context *pipe; -}; - struct vl_screen* vl_screen_create(Display *display, int screen); void vl_screen_destroy(struct vl_screen *vscreen); -struct vl_context* -vl_video_create(struct vl_screen *vscreen); - -void vl_video_destroy(struct vl_context *vctx); - -struct pipe_surface* -vl_drawable_surface_get(struct vl_context *vctx, Drawable drawable); +struct pipe_resource* +vl_screen_texture_from_drawable(struct vl_screen *vscreen, Drawable drawable); void* -vl_contextprivate_get(struct vl_context *vctx, struct pipe_surface *drawable_surface); +vl_screen_get_private(struct vl_screen *vscreen); #endif diff --git a/src/gallium/winsys/g3dvl/xlib/xsp_winsys.c b/src/gallium/winsys/g3dvl/xlib/xsp_winsys.c index c0c7cdea737..2ff5ef19580 100644 --- a/src/gallium/winsys/g3dvl/xlib/xsp_winsys.c +++ b/src/gallium/winsys/g3dvl/xlib/xsp_winsys.c @@ -31,8 +31,6 @@ #include "util/u_format.h" #include "util/u_inlines.h" -#include - #include "state_tracker/xlib_sw_winsys.h" #include "softpipe/sp_public.h" @@ -45,21 +43,19 @@ struct vl_xsp_screen int screen; Visual visual; struct xlib_drawable xdraw; - struct pipe_surface *drawable_surface; + struct pipe_resource *tex; }; -struct pipe_surface* -vl_drawable_surface_get(struct vl_context *vctx, Drawable drawable) +struct pipe_resource* +vl_screen_texture_from_drawable(struct vl_screen *vscreen, Drawable drawable) { - struct vl_screen *vscreen = vctx->vscreen; struct vl_xsp_screen *xsp_screen = (struct vl_xsp_screen*)vscreen; Window root; int x, y; unsigned int width, height; unsigned int border_width; unsigned int depth; - struct pipe_resource templat, *drawable_tex; - struct pipe_surface surf_template, *drawable_surface = NULL; + struct pipe_resource templat; assert(vscreen); assert(drawable != None); @@ -69,14 +65,11 @@ vl_drawable_surface_get(struct vl_context *vctx, Drawable drawable) xsp_screen->xdraw.drawable = drawable; - if (xsp_screen->drawable_surface) { - if (xsp_screen->drawable_surface->width == width && - xsp_screen->drawable_surface->height == height) { - pipe_surface_reference(&drawable_surface, xsp_screen->drawable_surface); - return drawable_surface; - } + if (xsp_screen->tex) { + if (xsp_screen->tex->width0 == width && xsp_screen->tex->height0 == height) + return xsp_screen->tex; else - pipe_surface_reference(&xsp_screen->drawable_surface, NULL); + pipe_resource_reference(&xsp_screen->tex, NULL); } memset(&templat, 0, sizeof(struct pipe_resource)); @@ -91,37 +84,17 @@ vl_drawable_surface_get(struct vl_context *vctx, Drawable drawable) templat.bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_DISPLAY_TARGET; templat.flags = 0; - drawable_tex = vscreen->pscreen->resource_create(vscreen->pscreen, &templat); - if (!drawable_tex) - return NULL; - - memset(&surf_template, 0, sizeof(surf_template)); - surf_template.format = templat.format; - surf_template.usage = PIPE_BIND_RENDER_TARGET; - xsp_screen->drawable_surface = vctx->pipe->create_surface(vctx->pipe, drawable_tex, - &surf_template); - pipe_resource_reference(&drawable_tex, NULL); - - if (!xsp_screen->drawable_surface) - return NULL; - - pipe_surface_reference(&drawable_surface, xsp_screen->drawable_surface); - xsp_screen->xdraw.depth = 24/*util_format_get_blocksizebits(templat.format) / util_format_get_blockwidth(templat.format)*/; - return drawable_surface; + xsp_screen->tex = vscreen->pscreen->resource_create(vscreen->pscreen, &templat); + return xsp_screen->tex; } void* -vl_contextprivate_get(struct vl_context *vctx, struct pipe_surface *drawable_surface) +vl_screen_get_private(struct vl_screen *vscreen) { - struct vl_xsp_screen *xsp_screen = (struct vl_xsp_screen*)vctx->vscreen; - - assert(vctx); - assert(drawable_surface); - assert(xsp_screen->drawable_surface == drawable_surface); - + struct vl_xsp_screen *xsp_screen = (struct vl_xsp_screen*)vscreen; return &xsp_screen->xdraw; } @@ -163,39 +136,7 @@ void vl_screen_destroy(struct vl_screen *vscreen) assert(vscreen); - pipe_surface_reference(&xsp_screen->drawable_surface, NULL); + pipe_resource_reference(&xsp_screen->tex, NULL); vscreen->pscreen->destroy(vscreen->pscreen); FREE(vscreen); } - -struct vl_context* -vl_video_create(struct vl_screen *vscreen) -{ - struct pipe_context *pipe; - struct vl_context *vctx; - - assert(vscreen); - - pipe = vscreen->pscreen->context_create(vscreen->pscreen, NULL); - if (!pipe) - return NULL; - - vctx = CALLOC_STRUCT(vl_context); - if (!vctx) { - pipe->destroy(pipe); - return NULL; - } - - vctx->pipe = pipe; - vctx->vscreen = vscreen; - - return vctx; -} - -void vl_video_destroy(struct vl_context *vctx) -{ - assert(vctx); - - vctx->pipe->destroy(vctx->pipe); - FREE(vctx); -} -- cgit v1.2.3