diff options
author | Christian König <[email protected]> | 2012-02-15 17:20:50 +0100 |
---|---|---|
committer | Christian König <[email protected]> | 2012-02-25 12:14:14 +0100 |
commit | 1448e829e86981e6144410ba6a3d0f16357fb2b3 (patch) | |
tree | 18a95fc6ebab9afd59837d419f2e5ab96130624b /src | |
parent | b34c35a5243e0f4a23721891dbbccff8863b7d4c (diff) |
vl: rework winsys interface
Throw out all the old and now unneeded stuff.
Signed-off-by: Christian König <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/state_trackers/vdpau/decode.c | 2 | ||||
-rw-r--r-- | src/gallium/state_trackers/vdpau/device.c | 10 | ||||
-rw-r--r-- | src/gallium/state_trackers/vdpau/mixer.c | 8 | ||||
-rw-r--r-- | src/gallium/state_trackers/vdpau/output.c | 6 | ||||
-rw-r--r-- | src/gallium/state_trackers/vdpau/presentation.c | 41 | ||||
-rw-r--r-- | src/gallium/state_trackers/vdpau/surface.c | 4 | ||||
-rw-r--r-- | src/gallium/state_trackers/vdpau/vdpau_private.h | 2 | ||||
-rw-r--r-- | src/gallium/state_trackers/xorg/xvmc/context.c | 28 | ||||
-rw-r--r-- | src/gallium/state_trackers/xorg/xvmc/subpicture.c | 8 | ||||
-rw-r--r-- | src/gallium/state_trackers/xorg/xvmc/surface.c | 24 | ||||
-rw-r--r-- | src/gallium/state_trackers/xorg/xvmc/xvmc_private.h | 5 | ||||
-rw-r--r-- | src/gallium/winsys/g3dvl/dri/dri_winsys.c | 137 | ||||
-rw-r--r-- | src/gallium/winsys/g3dvl/vl_winsys.h | 17 | ||||
-rw-r--r-- | src/gallium/winsys/g3dvl/xlib/xsp_winsys.c | 85 |
14 files changed, 126 insertions, 251 deletions
diff --git a/src/gallium/state_trackers/vdpau/decode.c b/src/gallium/state_trackers/vdpau/decode.c index c45abb81799..64349a8bbce 100644 --- a/src/gallium/state_trackers/vdpau/decode.c +++ b/src/gallium/state_trackers/vdpau/decode.c @@ -65,7 +65,7 @@ vlVdpDecoderCreate(VdpDevice device, if (!dev) return VDP_STATUS_INVALID_HANDLE; - pipe = dev->context->pipe; + pipe = dev->context; screen = dev->vscreen->pscreen; supported = screen->get_video_param ( diff --git a/src/gallium/state_trackers/vdpau/device.c b/src/gallium/state_trackers/vdpau/device.c index 7b23863d120..f4a3dc04bfb 100644 --- a/src/gallium/state_trackers/vdpau/device.c +++ b/src/gallium/state_trackers/vdpau/device.c @@ -41,8 +41,9 @@ PUBLIC VdpStatus vdp_imp_device_create_x11(Display *display, int screen, VdpDevice *device, VdpGetProcAddress **get_proc_address) { - VdpStatus ret; + struct pipe_screen *pscreen; vlVdpDevice *dev = NULL; + VdpStatus ret; if (!(display && device && get_proc_address)) return VDP_STATUS_INVALID_POINTER; @@ -64,7 +65,8 @@ vdp_imp_device_create_x11(Display *display, int screen, VdpDevice *device, goto no_vscreen; } - dev->context = vl_video_create(dev->vscreen); + pscreen = dev->vscreen->pscreen; + dev->context = pscreen->context_create(pscreen, dev->vscreen); if (!dev->context) { ret = VDP_STATUS_RESOURCES; goto no_context; @@ -76,7 +78,7 @@ vdp_imp_device_create_x11(Display *display, int screen, VdpDevice *device, goto no_handle; } - vl_compositor_init(&dev->compositor, dev->context->pipe); + vl_compositor_init(&dev->compositor, dev->context); *get_proc_address = &vlVdpGetProcAddress; @@ -160,7 +162,7 @@ vlVdpDeviceDestroy(VdpDevice device) return VDP_STATUS_INVALID_HANDLE; vl_compositor_cleanup(&dev->compositor); - vl_video_destroy(dev->context); + dev->context->destroy(dev->context); vl_screen_destroy(dev->vscreen); FREE(dev); diff --git a/src/gallium/state_trackers/vdpau/mixer.c b/src/gallium/state_trackers/vdpau/mixer.c index df6750d5698..082860888af 100644 --- a/src/gallium/state_trackers/vdpau/mixer.c +++ b/src/gallium/state_trackers/vdpau/mixer.c @@ -62,7 +62,7 @@ vlVdpVideoMixerCreate(VdpDevice device, return VDP_STATUS_RESOURCES; vmixer->device = dev; - vl_compositor_init(&vmixer->compositor, dev->context->pipe); + vl_compositor_init(&vmixer->compositor, dev->context); vl_csc_get_matrix(VL_CSC_COLOR_STANDARD_BT_601, NULL, true, vmixer->csc); if (!debug_get_bool_option("G3DVL_NO_CSC", FALSE)) @@ -300,8 +300,7 @@ vlVdpVideoMixerUpdateNoiseReductionFilter(vlVdpVideoMixer *vmixer) /* and create a new filter as needed */ if (vmixer->noise_reduction. enabled && vmixer->noise_reduction.level > 0) { vmixer->noise_reduction.filter = MALLOC(sizeof(struct vl_median_filter)); - vl_median_filter_init(vmixer->noise_reduction.filter, - vmixer->device->context->pipe, + vl_median_filter_init(vmixer->noise_reduction.filter, vmixer->device->context, vmixer->video_width, vmixer->video_height, vmixer->noise_reduction.level + 1, VL_MEDIAN_FILTER_CROSS); @@ -347,8 +346,7 @@ vlVdpVideoMixerUpdateSharpnessFilter(vlVdpVideoMixer *vmixer) } vmixer->sharpness.filter = MALLOC(sizeof(struct vl_matrix_filter)); - vl_matrix_filter_init(vmixer->sharpness.filter, - vmixer->device->context->pipe, + vl_matrix_filter_init(vmixer->sharpness.filter, vmixer->device->context, vmixer->video_width, vmixer->video_height, 3, 3, matrix); } diff --git a/src/gallium/state_trackers/vdpau/output.c b/src/gallium/state_trackers/vdpau/output.c index 17ce0373dba..5ccb153fabd 100644 --- a/src/gallium/state_trackers/vdpau/output.c +++ b/src/gallium/state_trackers/vdpau/output.c @@ -58,7 +58,7 @@ vlVdpOutputSurfaceCreate(VdpDevice device, if (!dev) return VDP_STATUS_INVALID_HANDLE; - pipe = dev->context->pipe; + pipe = dev->context; if (!pipe) return VDP_STATUS_INVALID_HANDLE; @@ -217,7 +217,7 @@ vlVdpOutputSurfacePutBitsIndexed(VdpOutputSurface surface, if (!vlsurface) return VDP_STATUS_INVALID_HANDLE; - context = vlsurface->device->context->pipe; + context = vlsurface->device->context; compositor = &vlsurface->device->compositor; index_format = FormatIndexedToPipe(source_indexed_format); @@ -459,7 +459,7 @@ vlVdpOutputSurfaceRenderOutputSurface(VdpOutputSurface destination_surface, if (dst_vlsurface->device != src_vlsurface->device) return VDP_STATUS_HANDLE_DEVICE_MISMATCH; - context = dst_vlsurface->device->context->pipe; + context = dst_vlsurface->device->context; compositor = &dst_vlsurface->device->compositor; blend = BlenderToPipe(context, blend_state); diff --git a/src/gallium/state_trackers/vdpau/presentation.c b/src/gallium/state_trackers/vdpau/presentation.c index 13025d21156..e3ad03a2a51 100644 --- a/src/gallium/state_trackers/vdpau/presentation.c +++ b/src/gallium/state_trackers/vdpau/presentation.c @@ -68,7 +68,7 @@ vlVdpPresentationQueueCreate(VdpDevice device, pq->device = dev; pq->drawable = pqt->drawable; - if (!vl_compositor_init(&pq->compositor, dev->context->pipe)) { + if (!vl_compositor_init(&pq->compositor, dev->context)) { ret = VDP_STATUS_ERROR; goto no_compositor; } @@ -202,17 +202,25 @@ vlVdpPresentationQueueDisplay(VdpPresentationQueue presentation_queue, vlVdpOutputSurface *surf; struct pipe_context *pipe; - struct pipe_surface *drawable_surface; + struct pipe_resource *tex; + struct pipe_surface surf_templ, *surf_draw; struct pipe_video_rect src_rect, dst_clip; pq = vlGetDataHTAB(presentation_queue); if (!pq) return VDP_STATUS_INVALID_HANDLE; - drawable_surface = vl_drawable_surface_get(pq->device->context, pq->drawable); - if (!drawable_surface) + pipe = pq->device->context; + + tex = vl_screen_texture_from_drawable(pq->device->vscreen, pq->drawable); + if (!tex) return VDP_STATUS_INVALID_HANDLE; + memset(&surf_templ, 0, sizeof(surf_templ)); + surf_templ.format = tex->format; + surf_templ.usage = PIPE_BIND_RENDER_TARGET; + surf_draw = pipe->create_surface(pipe, tex, &surf_templ); + surf = vlGetDataHTAB(surface); if (!surf) return VDP_STATUS_INVALID_HANDLE; @@ -221,26 +229,22 @@ vlVdpPresentationQueueDisplay(VdpPresentationQueue presentation_queue, src_rect.x = 0; src_rect.y = 0; - src_rect.w = drawable_surface->width; - src_rect.h = drawable_surface->height; + src_rect.w = surf_draw->width; + src_rect.h = surf_draw->height; dst_clip.x = 0; dst_clip.y = 0; - dst_clip.w = clip_width ? clip_width : drawable_surface->width; - dst_clip.h = clip_height ? clip_height : drawable_surface->height; + dst_clip.w = clip_width ? clip_width : surf_draw->width; + dst_clip.h = clip_height ? clip_height : surf_draw->height; vl_compositor_clear_layers(&pq->compositor); vl_compositor_set_rgba_layer(&pq->compositor, 0, surf->sampler_view, &src_rect, NULL); - vl_compositor_render(&pq->compositor, drawable_surface, NULL, &dst_clip, &pq->dirty_area); - - pipe = pq->device->context->pipe; + vl_compositor_render(&pq->compositor, surf_draw, NULL, &dst_clip, &pq->dirty_area); pipe->screen->flush_frontbuffer ( - pipe->screen, - drawable_surface->texture, - 0, 0, - vl_contextprivate_get(pq->device->context, drawable_surface) + pipe->screen, tex, 0, 0, + vl_screen_get_private(pq->device->vscreen) ); pipe->screen->fence_reference(pipe->screen, &surf->fence, NULL); @@ -259,7 +263,8 @@ vlVdpPresentationQueueDisplay(VdpPresentationQueue presentation_queue, VDPAU_MSG(VDPAU_ERR, "[VDPAU] Dumping surface %d failed.\n", surface); } - pipe_surface_reference(&drawable_surface, NULL); + pipe_resource_reference(&tex, NULL); + pipe_surface_reference(&surf_draw, NULL); return VDP_STATUS_OK; } @@ -288,7 +293,7 @@ vlVdpPresentationQueueBlockUntilSurfaceIdle(VdpPresentationQueue presentation_qu return VDP_STATUS_INVALID_HANDLE; if (surf->fence) { - screen = pq->device->context->pipe->screen; + screen = pq->device->vscreen->pscreen; screen->fence_finish(screen, surf->fence, 0); } @@ -327,7 +332,7 @@ vlVdpPresentationQueueQuerySurfaceStatus(VdpPresentationQueue presentation_queue if (!surf->fence) { *status = VDP_PRESENTATION_QUEUE_STATUS_IDLE; } else { - screen = pq->device->context->pipe->screen; + screen = pq->device->vscreen->pscreen; if (screen->fence_signalled(screen, surf->fence)) { screen->fence_reference(screen, &surf->fence, NULL); *status = VDP_PRESENTATION_QUEUE_STATUS_VISIBLE; diff --git a/src/gallium/state_trackers/vdpau/surface.c b/src/gallium/state_trackers/vdpau/surface.c index a0ebe001aa8..04832426a10 100644 --- a/src/gallium/state_trackers/vdpau/surface.c +++ b/src/gallium/state_trackers/vdpau/surface.c @@ -71,7 +71,7 @@ vlVdpVideoSurfaceCreate(VdpDevice device, VdpChromaType chroma_type, } p_surf->device = dev; - pipe = dev->context->pipe; + pipe = dev->context; memset(&p_surf->templat, 0, sizeof(p_surf->templat)); p_surf->templat.buffer_format = pipe->screen->get_video_param @@ -204,7 +204,7 @@ vlVdpVideoSurfacePutBitsYCbCr(VdpVideoSurface surface, if (!p_surf) return VDP_STATUS_INVALID_HANDLE; - pipe = p_surf->device->context->pipe; + pipe = p_surf->device->context; if (!pipe) return VDP_STATUS_INVALID_HANDLE; diff --git a/src/gallium/state_trackers/vdpau/vdpau_private.h b/src/gallium/state_trackers/vdpau/vdpau_private.h index 35f0dc0d58a..e02744ffd41 100644 --- a/src/gallium/state_trackers/vdpau/vdpau_private.h +++ b/src/gallium/state_trackers/vdpau/vdpau_private.h @@ -286,7 +286,7 @@ RectToPipe(const VdpRect *src, struct pipe_video_rect *dst) typedef struct { struct vl_screen *vscreen; - struct vl_context *context; + struct pipe_context *context; struct vl_compositor compositor; } vlVdpDevice; diff --git a/src/gallium/state_trackers/xorg/xvmc/context.c b/src/gallium/state_trackers/xorg/xvmc/context.c index b11f10fe402..e9ba06ba909 100644 --- a/src/gallium/state_trackers/xorg/xvmc/context.c +++ b/src/gallium/state_trackers/xorg/xvmc/context.c @@ -190,7 +190,7 @@ Status XvMCCreateContext(Display *dpy, XvPortID port, int surface_type_id, unsigned short subpic_max_h = 0; Status ret; struct vl_screen *vscreen; - struct vl_context *vctx; + struct pipe_context *pipe; XvMCContextPrivate *context_priv; float csc[16]; @@ -236,18 +236,17 @@ Status XvMCCreateContext(Display *dpy, XvPortID port, int surface_type_id, return BadAlloc; } - vctx = vl_video_create(vscreen); - if (!vctx) { + pipe = vscreen->pscreen->context_create(vscreen->pscreen, vscreen); + if (!pipe) { XVMC_MSG(XVMC_ERR, "[XvMC] Could not create VL context.\n"); vl_screen_destroy(vscreen); FREE(context_priv); return BadAlloc; } - context_priv->decoder = vctx->pipe->create_video_decoder + context_priv->decoder = pipe->create_video_decoder ( - vctx->pipe, - ProfileToPipe(mc_type), + pipe, ProfileToPipe(mc_type), (mc_type & XVMC_IDCT) ? PIPE_VIDEO_ENTRYPOINT_IDCT : PIPE_VIDEO_ENTRYPOINT_MC, FormatToPipe(chroma_format), width, height, 2, @@ -256,16 +255,16 @@ Status XvMCCreateContext(Display *dpy, XvPortID port, int surface_type_id, if (!context_priv->decoder) { XVMC_MSG(XVMC_ERR, "[XvMC] Could not create VL decoder.\n"); - vl_video_destroy(vctx); + pipe->destroy(pipe); vl_screen_destroy(vscreen); FREE(context_priv); return BadAlloc; } - if (!vl_compositor_init(&context_priv->compositor, vctx->pipe)) { + if (!vl_compositor_init(&context_priv->compositor, pipe)) { XVMC_MSG(XVMC_ERR, "[XvMC] Could not create VL compositor.\n"); context_priv->decoder->destroy(context_priv->decoder); - vl_video_destroy(vctx); + pipe->destroy(pipe); vl_screen_destroy(vscreen); FREE(context_priv); return BadAlloc; @@ -283,7 +282,8 @@ Status XvMCCreateContext(Display *dpy, XvPortID port, int surface_type_id, ); vl_compositor_set_csc_matrix(&context_priv->compositor, csc); - context_priv->vctx = vctx; + context_priv->vscreen = vscreen; + context_priv->pipe = pipe; context_priv->subpicture_max_width = subpic_max_w; context_priv->subpicture_max_height = subpic_max_h; @@ -305,8 +305,6 @@ Status XvMCCreateContext(Display *dpy, XvPortID port, int surface_type_id, PUBLIC Status XvMCDestroyContext(Display *dpy, XvMCContext *context) { - struct vl_screen *vscreen; - struct vl_context *vctx; XvMCContextPrivate *context_priv; XVMC_MSG(XVMC_TRACE, "[XvMC] Destroying context %p.\n", context); @@ -317,13 +315,11 @@ Status XvMCDestroyContext(Display *dpy, XvMCContext *context) return XvMCBadContext; context_priv = context->privData; - vctx = context_priv->vctx; - vscreen = vctx->vscreen; pipe_surface_reference(&context_priv->drawable_surface, NULL); context_priv->decoder->destroy(context_priv->decoder); vl_compositor_cleanup(&context_priv->compositor); - vl_video_destroy(vctx); - vl_screen_destroy(vscreen); + context_priv->pipe->destroy(context_priv->pipe); + vl_screen_destroy(context_priv->vscreen); FREE(context_priv); context->privData = NULL; diff --git a/src/gallium/state_trackers/xorg/xvmc/subpicture.c b/src/gallium/state_trackers/xorg/xvmc/subpicture.c index c5aa0c35213..d6be28ea3cd 100644 --- a/src/gallium/state_trackers/xorg/xvmc/subpicture.c +++ b/src/gallium/state_trackers/xorg/xvmc/subpicture.c @@ -210,7 +210,7 @@ Status XvMCCreateSubpicture(Display *dpy, XvMCContext *context, XvMCSubpicture * return XvMCBadContext; context_priv = context->privData; - pipe = context_priv->vctx->pipe; + pipe = context_priv->pipe; if (!subpicture) return XvMCBadSubpicture; @@ -321,7 +321,7 @@ Status XvMCClearSubpicture(Display *dpy, XvMCSubpicture *subpicture, short x, sh subpicture_priv = subpicture->privData; context_priv = subpicture_priv->context->privData; - pipe = context_priv->vctx->pipe; + pipe = context_priv->pipe; dst = subpicture_priv->sampler; /* TODO: Assert clear rect is within bounds? Or clip? */ @@ -371,7 +371,7 @@ Status XvMCCompositeSubpicture(Display *dpy, XvMCSubpicture *subpicture, XvImage subpicture_priv = subpicture->privData; context_priv = subpicture_priv->context->privData; - pipe = context_priv->vctx->pipe; + pipe = context_priv->pipe; /* clipping should be done by upload_sampler and regardles what the documentation says image->pitches[0] doesn't seems to be in bytes, so don't use it */ @@ -421,7 +421,7 @@ Status XvMCSetSubpicturePalette(Display *dpy, XvMCSubpicture *subpicture, unsign subpicture_priv = subpicture->privData; context_priv = subpicture_priv->context->privData; - pipe = context_priv->vctx->pipe; + pipe = context_priv->pipe; dst_box.width = subpicture->num_palette_entries; diff --git a/src/gallium/state_trackers/xorg/xvmc/surface.c b/src/gallium/state_trackers/xorg/xvmc/surface.c index 7f7eeadcbc6..293e7ad22a4 100644 --- a/src/gallium/state_trackers/xorg/xvmc/surface.c +++ b/src/gallium/state_trackers/xorg/xvmc/surface.c @@ -168,7 +168,7 @@ Status XvMCCreateSurface(Display *dpy, XvMCContext *context, XvMCSurface *surfac return XvMCBadSurface; context_priv = context->privData; - pipe = context_priv->vctx->pipe; + pipe = context_priv->pipe; surface_priv = CALLOC(1, sizeof(XvMCSurfacePrivate)); if (!surface_priv) @@ -373,17 +373,25 @@ Status XvMCPutSurface(Display *dpy, XvMCSurface *surface, Drawable drawable, assert(srcy + srch - 1 < surface->height); subpicture_priv = surface_priv->subpicture ? surface_priv->subpicture->privData : NULL; - pipe = context_priv->vctx->pipe; + pipe = context_priv->pipe; compositor = &context_priv->compositor; if (!context_priv->drawable_surface || context_priv->dst_rect.x != dst_rect.x || context_priv->dst_rect.y != dst_rect.y || context_priv->dst_rect.w != dst_rect.w || context_priv->dst_rect.h != dst_rect.h) { + struct pipe_surface surf_templ; + struct pipe_resource *tex = vl_screen_texture_from_drawable( + context_priv->vscreen, drawable); + pipe_surface_reference(&context_priv->drawable_surface, NULL); - context_priv->drawable_surface = vl_drawable_surface_get(context_priv->vctx, drawable); - context_priv->dst_rect = dst_rect; + + memset(&surf_templ, 0, sizeof(surf_templ)); + surf_templ.format = tex->format; + surf_templ.usage = PIPE_BIND_RENDER_TARGET; + context_priv->drawable_surface = pipe->create_surface(pipe, tex, &surf_templ); vl_compositor_reset_dirty_area(&context_priv->dirty_area); + context_priv->dst_rect = dst_rect; } if (!context_priv->drawable_surface) @@ -436,10 +444,8 @@ Status XvMCPutSurface(Display *dpy, XvMCSurface *surface, Drawable drawable, pipe->screen->flush_frontbuffer ( - pipe->screen, - context_priv->drawable_surface->texture, - 0, 0, - vl_contextprivate_get(context_priv->vctx, context_priv->drawable_surface) + pipe->screen, context_priv->drawable_surface->texture, 0, 0, + vl_screen_get_private(context_priv->vscreen) ); if(dump_window == -1) { @@ -476,7 +482,7 @@ Status XvMCGetSurfaceStatus(Display *dpy, XvMCSurface *surface, int *status) surface_priv = surface->privData; context_priv = surface_priv->context->privData; - pipe = context_priv->vctx->pipe; + pipe = context_priv->pipe; *status = 0; diff --git a/src/gallium/state_trackers/xorg/xvmc/xvmc_private.h b/src/gallium/state_trackers/xorg/xvmc/xvmc_private.h index daddba5fe54..b9519a7e65d 100644 --- a/src/gallium/state_trackers/xorg/xvmc/xvmc_private.h +++ b/src/gallium/state_trackers/xorg/xvmc/xvmc_private.h @@ -43,8 +43,6 @@ #define BLOCK_SIZE_SAMPLES 64 #define BLOCK_SIZE_BYTES (BLOCK_SIZE_SAMPLES * 2) -struct vl_context; - struct pipe_video_decoder; struct pipe_video_buffer; @@ -53,7 +51,8 @@ struct pipe_fence_handle; typedef struct { - struct vl_context *vctx; + struct vl_screen *vscreen; + struct pipe_context *pipe; struct pipe_video_decoder *decoder; enum VL_CSC_COLOR_STANDARD color_standard; 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 <X11/Xlibint.h> - #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); -} |