diff options
author | Christian König <[email protected]> | 2012-02-25 13:09:17 +0100 |
---|---|---|
committer | Christian König <[email protected]> | 2012-03-02 13:14:20 +0100 |
commit | 32c4381d4a0479b3d9bfe305ce701be6b5ac8e18 (patch) | |
tree | 4ec14c7027256c368702e1c605190aa740de4ad1 /src/gallium/state_trackers | |
parent | 834f515988ca894b3828a4929d36cafd349eade8 (diff) |
vl/compositor: split shaders and state
Signed-off-by: Christian König <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers')
-rw-r--r-- | src/gallium/state_trackers/vdpau/mixer.c | 35 | ||||
-rw-r--r-- | src/gallium/state_trackers/vdpau/output.c | 24 | ||||
-rw-r--r-- | src/gallium/state_trackers/vdpau/presentation.c | 18 | ||||
-rw-r--r-- | src/gallium/state_trackers/vdpau/vdpau_private.h | 5 | ||||
-rw-r--r-- | src/gallium/state_trackers/xvmc/attributes.c | 2 | ||||
-rw-r--r-- | src/gallium/state_trackers/xvmc/context.c | 14 | ||||
-rw-r--r-- | src/gallium/state_trackers/xvmc/surface.c | 13 | ||||
-rw-r--r-- | src/gallium/state_trackers/xvmc/xvmc_private.h | 1 |
8 files changed, 71 insertions, 41 deletions
diff --git a/src/gallium/state_trackers/vdpau/mixer.c b/src/gallium/state_trackers/vdpau/mixer.c index 082860888af..ac0ce86beeb 100644 --- a/src/gallium/state_trackers/vdpau/mixer.c +++ b/src/gallium/state_trackers/vdpau/mixer.c @@ -62,11 +62,11 @@ vlVdpVideoMixerCreate(VdpDevice device, return VDP_STATUS_RESOURCES; vmixer->device = dev; - vl_compositor_init(&vmixer->compositor, dev->context); + vl_compositor_init_state(&vmixer->cstate, 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)) - vl_compositor_set_csc_matrix(&vmixer->compositor, vmixer->csc); + vl_compositor_set_csc_matrix(&vmixer->cstate, vmixer->csc); *mixer = vlAddDataHTAB(vmixer); if (*mixer == 0) { @@ -148,8 +148,9 @@ vlVdpVideoMixerCreate(VdpDevice device, no_params: vlRemoveDataHTAB(*mixer); + no_handle: - vl_compositor_cleanup(&vmixer->compositor); + vl_compositor_cleanup_state(&vmixer->cstate); FREE(vmixer); return ret; } @@ -167,7 +168,7 @@ vlVdpVideoMixerDestroy(VdpVideoMixer mixer) return VDP_STATUS_INVALID_HANDLE; vlRemoveDataHTAB(mixer); - vl_compositor_cleanup(&vmixer->compositor); + vl_compositor_cleanup_state(&vmixer->cstate); if (vmixer->noise_reduction.filter) { vl_median_filter_cleanup(vmixer->noise_reduction.filter); @@ -211,10 +212,14 @@ VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer, vlVdpSurface *surf; vlVdpOutputSurface *dst; + struct vl_compositor *compositor; + vmixer = vlGetDataHTAB(mixer); if (!vmixer) return VDP_STATUS_INVALID_HANDLE; + compositor = &vmixer->device->compositor; + surf = vlGetDataHTAB(video_surface_current); if (!surf) return VDP_STATUS_INVALID_HANDLE; @@ -238,11 +243,11 @@ VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer, vlVdpOutputSurface *bg = vlGetDataHTAB(background_surface); if (!bg) return VDP_STATUS_INVALID_HANDLE; - vl_compositor_set_rgba_layer(&vmixer->compositor, layer++, bg->sampler_view, + vl_compositor_set_rgba_layer(&vmixer->cstate, compositor, layer++, bg->sampler_view, RectToPipe(background_source_rect, &src_rect), NULL); } - vl_compositor_clear_layers(&vmixer->compositor); + vl_compositor_clear_layers(&vmixer->cstate); switch (current_picture_structure) { case VDP_VIDEO_MIXER_PICTURE_STRUCTURE_TOP_FIELD: @@ -260,13 +265,11 @@ VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer, default: return VDP_STATUS_INVALID_VIDEO_MIXER_PICTURE_STRUCTURE; }; - vl_compositor_set_buffer_layer(&vmixer->compositor, layer++, surf->video_buffer, - RectToPipe(video_source_rect, &src_rect), NULL, - deinterlace); - vl_compositor_render(&vmixer->compositor, dst->surface, - RectToPipe(destination_video_rect, &dst_rect), - RectToPipe(destination_rect, &dst_clip), - &dst->dirty_area); + vl_compositor_set_buffer_layer(&vmixer->cstate, compositor, layer++, surf->video_buffer, + RectToPipe(video_source_rect, &src_rect), NULL, deinterlace); + vl_compositor_set_dst_area(&vmixer->cstate, RectToPipe(destination_video_rect, &dst_rect)); + vl_compositor_set_dst_clip(&vmixer->cstate, RectToPipe(destination_rect, &dst_clip)); + vl_compositor_render(&vmixer->cstate, compositor, dst->surface, &dst->dirty_area); /* applying the noise reduction after scaling is actually not very clever, but currently we should avoid to copy around the image @@ -544,7 +547,7 @@ vlVdpVideoMixerSetAttributeValues(VdpVideoMixer mixer, color.f[1] = background_color->green; color.f[2] = background_color->blue; color.f[3] = background_color->alpha; - vl_compositor_set_clear_color(&vmixer->compositor, &color); + vl_compositor_set_clear_color(&vmixer->cstate, &color); break; case VDP_VIDEO_MIXER_ATTRIBUTE_CSC_MATRIX: vdp_csc = attribute_values[i]; @@ -554,7 +557,7 @@ vlVdpVideoMixerSetAttributeValues(VdpVideoMixer mixer, else memcpy(vmixer->csc, vdp_csc, sizeof(float)*12); if (!debug_get_bool_option("G3DVL_NO_CSC", FALSE)) - vl_compositor_set_csc_matrix(&vmixer->compositor, vmixer->csc); + vl_compositor_set_csc_matrix(&vmixer->cstate, vmixer->csc); break; case VDP_VIDEO_MIXER_ATTRIBUTE_NOISE_REDUCTION_LEVEL: @@ -664,7 +667,7 @@ vlVdpVideoMixerGetAttributeValues(VdpVideoMixer mixer, for (i = 0; i < attribute_count; ++i) { switch (attributes[i]) { case VDP_VIDEO_MIXER_ATTRIBUTE_BACKGROUND_COLOR: - vl_compositor_get_clear_color(&vmixer->compositor, attribute_values[i]); + vl_compositor_get_clear_color(&vmixer->cstate, attribute_values[i]); break; case VDP_VIDEO_MIXER_ATTRIBUTE_CSC_MATRIX: vdp_csc = attribute_values[i]; diff --git a/src/gallium/state_trackers/vdpau/output.c b/src/gallium/state_trackers/vdpau/output.c index 5ccb153fabd..0583c52fe82 100644 --- a/src/gallium/state_trackers/vdpau/output.c +++ b/src/gallium/state_trackers/vdpau/output.c @@ -113,6 +113,7 @@ vlVdpOutputSurfaceCreate(VdpDevice device, pipe_resource_reference(&res, NULL); + vl_compositor_init_state(&vlsurface->cstate, pipe); vl_compositor_reset_dirty_area(&vlsurface->dirty_area); return VDP_STATUS_OK; @@ -132,6 +133,7 @@ vlVdpOutputSurfaceDestroy(VdpOutputSurface surface) pipe_surface_reference(&vlsurface->surface, NULL); pipe_sampler_view_reference(&vlsurface->sampler_view, NULL); + vl_compositor_cleanup_state(&vlsurface->cstate); vlRemoveDataHTAB(surface); FREE(vlsurface); @@ -202,6 +204,7 @@ vlVdpOutputSurfacePutBitsIndexed(VdpOutputSurface surface, vlVdpOutputSurface *vlsurface; struct pipe_context *context; struct vl_compositor *compositor; + struct vl_compositor_state *cstate; enum pipe_format index_format; enum pipe_format colortbl_format; @@ -219,6 +222,7 @@ vlVdpOutputSurfacePutBitsIndexed(VdpOutputSurface surface, context = vlsurface->device->context; compositor = &vlsurface->device->compositor; + cstate = &vlsurface->cstate; index_format = FormatIndexedToPipe(source_indexed_format); if (index_format == PIPE_FORMAT_NONE) @@ -304,10 +308,10 @@ vlVdpOutputSurfacePutBitsIndexed(VdpOutputSurface surface, if (!sv_tbl) goto error_resource; - vl_compositor_clear_layers(compositor); - vl_compositor_set_palette_layer(compositor, 0, sv_idx, sv_tbl, NULL, NULL, false); - vl_compositor_render(compositor, vlsurface->surface, - RectToPipe(destination_rect, &dst_rect), NULL, NULL); + vl_compositor_clear_layers(cstate); + vl_compositor_set_palette_layer(cstate, compositor, 0, sv_idx, sv_tbl, NULL, NULL, false); + vl_compositor_set_dst_area(cstate, RectToPipe(destination_rect, &dst_rect)); + vl_compositor_render(cstate, compositor, vlsurface->surface, NULL); pipe_sampler_view_reference(&sv_idx, NULL); pipe_sampler_view_reference(&sv_tbl, NULL); @@ -442,6 +446,7 @@ vlVdpOutputSurfaceRenderOutputSurface(VdpOutputSurface destination_surface, struct pipe_context *context; struct vl_compositor *compositor; + struct vl_compositor_state *cstate; struct pipe_video_rect src_rect; struct pipe_video_rect dst_rect; @@ -461,15 +466,16 @@ vlVdpOutputSurfaceRenderOutputSurface(VdpOutputSurface destination_surface, context = dst_vlsurface->device->context; compositor = &dst_vlsurface->device->compositor; + cstate = &dst_vlsurface->cstate; blend = BlenderToPipe(context, blend_state); - vl_compositor_clear_layers(compositor); - vl_compositor_set_layer_blend(compositor, 0, blend, false); - vl_compositor_set_rgba_layer(compositor, 0, src_vlsurface->sampler_view, + vl_compositor_clear_layers(cstate); + vl_compositor_set_layer_blend(cstate, 0, blend, false); + vl_compositor_set_rgba_layer(cstate, compositor, 0, src_vlsurface->sampler_view, RectToPipe(source_rect, &src_rect), NULL); - vl_compositor_render(compositor, dst_vlsurface->surface, - RectToPipe(destination_rect, &dst_rect), NULL, false); + vl_compositor_set_dst_area(cstate, RectToPipe(destination_rect, &dst_rect)); + vl_compositor_render(cstate, compositor, dst_vlsurface->surface, NULL); context->delete_blend_state(context, blend); diff --git a/src/gallium/state_trackers/vdpau/presentation.c b/src/gallium/state_trackers/vdpau/presentation.c index 37c5c695e4d..71447793f58 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)) { + if (!vl_compositor_init_state(&pq->cstate, dev->context)) { ret = VDP_STATUS_ERROR; goto no_compositor; } @@ -99,7 +99,7 @@ vlVdpPresentationQueueDestroy(VdpPresentationQueue presentation_queue) if (!pq) return VDP_STATUS_INVALID_HANDLE; - vl_compositor_cleanup(&pq->compositor); + vl_compositor_cleanup_state(&pq->cstate); vlRemoveDataHTAB(presentation_queue); FREE(pq); @@ -129,7 +129,7 @@ vlVdpPresentationQueueSetBackgroundColor(VdpPresentationQueue presentation_queue color.f[2] = background_color->blue; color.f[3] = background_color->alpha; - vl_compositor_set_clear_color(&pq->compositor, &color); + vl_compositor_set_clear_color(&pq->cstate, &color); return VDP_STATUS_OK; } @@ -151,7 +151,7 @@ vlVdpPresentationQueueGetBackgroundColor(VdpPresentationQueue presentation_queue if (!pq) return VDP_STATUS_INVALID_HANDLE; - vl_compositor_get_clear_color(&pq->compositor, &color); + vl_compositor_get_clear_color(&pq->cstate, &color); background_color->red = color.f[0]; background_color->green = color.f[1]; @@ -205,11 +205,14 @@ vlVdpPresentationQueueDisplay(VdpPresentationQueue presentation_queue, struct pipe_video_rect src_rect, dst_clip; struct u_rect *dirty_area; + struct vl_compositor *compositor; + pq = vlGetDataHTAB(presentation_queue); if (!pq) return VDP_STATUS_INVALID_HANDLE; pipe = pq->device->context; + compositor = &pq->device->compositor; tex = vl_screen_texture_from_drawable(pq->device->vscreen, pq->drawable); if (!tex) @@ -238,9 +241,10 @@ vlVdpPresentationQueueDisplay(VdpPresentationQueue presentation_queue, 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, surf_draw, NULL, &dst_clip, dirty_area); + vl_compositor_clear_layers(&pq->cstate); + vl_compositor_set_rgba_layer(&pq->cstate, compositor, 0, surf->sampler_view, &src_rect, NULL); + vl_compositor_set_dst_clip(&pq->cstate, &dst_clip); + vl_compositor_render(&pq->cstate, compositor, surf_draw, dirty_area); pipe->screen->flush_frontbuffer ( diff --git a/src/gallium/state_trackers/vdpau/vdpau_private.h b/src/gallium/state_trackers/vdpau/vdpau_private.h index 1645362444e..e74c68187d2 100644 --- a/src/gallium/state_trackers/vdpau/vdpau_private.h +++ b/src/gallium/state_trackers/vdpau/vdpau_private.h @@ -300,13 +300,13 @@ typedef struct { vlVdpDevice *device; Drawable drawable; - struct vl_compositor compositor; + struct vl_compositor_state cstate; } vlVdpPresentationQueue; typedef struct { vlVdpDevice *device; - struct vl_compositor compositor; + struct vl_compositor_state cstate; struct { bool supported, enabled; @@ -342,6 +342,7 @@ typedef struct struct pipe_surface *surface; struct pipe_sampler_view *sampler_view; struct pipe_fence_handle *fence; + struct vl_compositor_state cstate; struct u_rect dirty_area; } vlVdpOutputSurface; diff --git a/src/gallium/state_trackers/xvmc/attributes.c b/src/gallium/state_trackers/xvmc/attributes.c index d40a7b1e6f4..da7b6493ba8 100644 --- a/src/gallium/state_trackers/xvmc/attributes.c +++ b/src/gallium/state_trackers/xvmc/attributes.c @@ -110,7 +110,7 @@ Status XvMCSetAttribute(Display *dpy, XvMCContext *context, Atom attribute, int context_priv->color_standard, &context_priv->procamp, true, csc ); - vl_compositor_set_csc_matrix(&context_priv->compositor, csc); + vl_compositor_set_csc_matrix(&context_priv->cstate, csc); XVMC_MSG(XVMC_TRACE, "[XvMC] Set attribute %s to value %d.\n", attr, value); diff --git a/src/gallium/state_trackers/xvmc/context.c b/src/gallium/state_trackers/xvmc/context.c index f5751515672..c598cad7455 100644 --- a/src/gallium/state_trackers/xvmc/context.c +++ b/src/gallium/state_trackers/xvmc/context.c @@ -270,6 +270,17 @@ Status XvMCCreateContext(Display *dpy, XvPortID port, int surface_type_id, return BadAlloc; } + if (!vl_compositor_init_state(&context_priv->cstate, pipe)) { + XVMC_MSG(XVMC_ERR, "[XvMC] Could not create VL compositor state.\n"); + vl_compositor_cleanup(&context_priv->compositor); + context_priv->decoder->destroy(context_priv->decoder); + pipe->destroy(pipe); + vl_screen_destroy(vscreen); + FREE(context_priv); + return BadAlloc; + } + + context_priv->color_standard = debug_get_bool_option("G3DVL_NO_CSC", FALSE) ? VL_CSC_COLOR_STANDARD_IDENTITY : VL_CSC_COLOR_STANDARD_BT_601; @@ -280,7 +291,7 @@ Status XvMCCreateContext(Display *dpy, XvPortID port, int surface_type_id, context_priv->color_standard, &context_priv->procamp, true, csc ); - vl_compositor_set_csc_matrix(&context_priv->compositor, csc); + vl_compositor_set_csc_matrix(&context_priv->cstate, csc); context_priv->vscreen = vscreen; context_priv->pipe = pipe; @@ -316,6 +327,7 @@ Status XvMCDestroyContext(Display *dpy, XvMCContext *context) context_priv = context->privData; context_priv->decoder->destroy(context_priv->decoder); + vl_compositor_cleanup_state(&context_priv->cstate); vl_compositor_cleanup(&context_priv->compositor); context_priv->pipe->destroy(context_priv->pipe); vl_screen_destroy(context_priv->vscreen); diff --git a/src/gallium/state_trackers/xvmc/surface.c b/src/gallium/state_trackers/xvmc/surface.c index c6f6ef593b4..47853cf6924 100644 --- a/src/gallium/state_trackers/xvmc/surface.c +++ b/src/gallium/state_trackers/xvmc/surface.c @@ -349,6 +349,7 @@ Status XvMCPutSurface(Display *dpy, XvMCSurface *surface, Drawable drawable, struct pipe_context *pipe; struct vl_compositor *compositor; + struct vl_compositor_state *cstate; XvMCSurfacePrivate *surface_priv; XvMCContextPrivate *context_priv; @@ -379,6 +380,7 @@ Status XvMCPutSurface(Display *dpy, XvMCSurface *surface, Drawable drawable, subpicture_priv = surface_priv->subpicture ? surface_priv->subpicture->privData : NULL; pipe = context_priv->pipe; compositor = &context_priv->compositor; + cstate = &context_priv->cstate; tex = vl_screen_texture_from_drawable(context_priv->vscreen, drawable); dirty_area = vl_screen_get_dirty_area(context_priv->vscreen); @@ -407,8 +409,8 @@ Status XvMCPutSurface(Display *dpy, XvMCSurface *surface, Drawable drawable, context_priv->decoder->flush(context_priv->decoder); - vl_compositor_clear_layers(compositor); - vl_compositor_set_buffer_layer(compositor, 0, surface_priv->video_buffer, + vl_compositor_clear_layers(cstate); + vl_compositor_set_buffer_layer(cstate, compositor, 0, surface_priv->video_buffer, &src_rect, NULL, VL_COMPOSITOR_WEAVE); if (subpicture_priv) { @@ -417,10 +419,10 @@ Status XvMCPutSurface(Display *dpy, XvMCSurface *surface, Drawable drawable, assert(subpicture_priv->surface == surface); if (subpicture_priv->palette) - vl_compositor_set_palette_layer(compositor, 1, subpicture_priv->sampler, subpicture_priv->palette, + vl_compositor_set_palette_layer(cstate, compositor, 1, subpicture_priv->sampler, subpicture_priv->palette, &subpicture_priv->src_rect, &subpicture_priv->dst_rect, true); else - vl_compositor_set_rgba_layer(compositor, 1, subpicture_priv->sampler, + vl_compositor_set_rgba_layer(cstate, compositor, 1, subpicture_priv->sampler, &subpicture_priv->src_rect, &subpicture_priv->dst_rect); surface_priv->subpicture = NULL; @@ -430,7 +432,8 @@ Status XvMCPutSurface(Display *dpy, XvMCSurface *surface, Drawable drawable, // Workaround for r600g, there seems to be a bug in the fence refcounting code pipe->screen->fence_reference(pipe->screen, &surface_priv->fence, NULL); - vl_compositor_render(compositor, surf, &dst_rect, NULL, dirty_area); + vl_compositor_set_dst_area(cstate, &dst_rect); + vl_compositor_render(cstate, compositor, surf, dirty_area); pipe->flush(pipe, &surface_priv->fence); diff --git a/src/gallium/state_trackers/xvmc/xvmc_private.h b/src/gallium/state_trackers/xvmc/xvmc_private.h index 4117f5bf689..26f874ad87a 100644 --- a/src/gallium/state_trackers/xvmc/xvmc_private.h +++ b/src/gallium/state_trackers/xvmc/xvmc_private.h @@ -57,6 +57,7 @@ typedef struct enum VL_CSC_COLOR_STANDARD color_standard; struct vl_procamp procamp; struct vl_compositor compositor; + struct vl_compositor_state cstate; unsigned short subpicture_max_width; unsigned short subpicture_max_height; |