summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/vdpau/device.c
diff options
context:
space:
mode:
authorChristian König <[email protected]>2014-08-13 20:21:06 +0200
committerChristian König <[email protected]>2014-08-26 17:56:57 +0200
commitb73c20759fe1b4a96296bed58637f5ded7c9155c (patch)
tree80eaecaeab0748286fd093e376b4b279b95b70ed /src/gallium/state_trackers/vdpau/device.c
parente3c251071b0c9396c3ec76d1cf943c60ae297281 (diff)
st/vdpau: fix vlVdpOutputSurfaceRender(Output|Bitmap)Surface
Correctly handle that the source_surface is only optional. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=80561 Signed-off-by: Christian König <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]> Cc: [email protected]
Diffstat (limited to 'src/gallium/state_trackers/vdpau/device.c')
-rw-r--r--src/gallium/state_trackers/vdpau/device.c43
1 files changed, 42 insertions, 1 deletions
diff --git a/src/gallium/state_trackers/vdpau/device.c b/src/gallium/state_trackers/vdpau/device.c
index 9c5ec60da4a..efc1fdeb190 100644
--- a/src/gallium/state_trackers/vdpau/device.c
+++ b/src/gallium/state_trackers/vdpau/device.c
@@ -42,6 +42,8 @@ vdp_imp_device_create_x11(Display *display, int screen, VdpDevice *device,
VdpGetProcAddress **get_proc_address)
{
struct pipe_screen *pscreen;
+ struct pipe_resource *res, res_tmpl;
+ struct pipe_sampler_view sv_tmpl;
vlVdpDevice *dev = NULL;
VdpStatus ret;
@@ -79,6 +81,43 @@ vdp_imp_device_create_x11(Display *display, int screen, VdpDevice *device,
goto no_context;
}
+ memset(&res_tmpl, 0, sizeof(res_tmpl));
+
+ res_tmpl.target = PIPE_TEXTURE_2D;
+ res_tmpl.format = PIPE_FORMAT_R8G8B8A8_UNORM;
+ res_tmpl.width0 = 1;
+ res_tmpl.height0 = 1;
+ res_tmpl.depth0 = 1;
+ res_tmpl.array_size = 1;
+ res_tmpl.bind = PIPE_BIND_SAMPLER_VIEW;
+ res_tmpl.usage = PIPE_USAGE_DEFAULT;
+
+ if (!CheckSurfaceParams(pscreen, &res_tmpl)) {
+ ret = VDP_STATUS_NO_IMPLEMENTATION;
+ goto no_resource;
+ }
+
+ res = pscreen->resource_create(pscreen, &res_tmpl);
+ if (!res) {
+ ret = VDP_STATUS_RESOURCES;
+ goto no_resource;
+ }
+
+ memset(&sv_tmpl, 0, sizeof(sv_tmpl));
+ u_sampler_view_default_template(&sv_tmpl, res, res->format);
+
+ sv_tmpl.swizzle_r = PIPE_SWIZZLE_ONE;
+ sv_tmpl.swizzle_g = PIPE_SWIZZLE_ONE;
+ sv_tmpl.swizzle_b = PIPE_SWIZZLE_ONE;
+ sv_tmpl.swizzle_a = PIPE_SWIZZLE_ONE;
+
+ dev->dummy_sv = dev->context->create_sampler_view(dev->context, res, &sv_tmpl);
+ pipe_resource_reference(&res, NULL);
+ if (!dev->dummy_sv) {
+ ret = VDP_STATUS_RESOURCES;
+ goto no_resource;
+ }
+
*device = vlAddDataHTAB(dev);
if (*device == 0) {
ret = VDP_STATUS_ERROR;
@@ -93,8 +132,9 @@ vdp_imp_device_create_x11(Display *display, int screen, VdpDevice *device,
return VDP_STATUS_OK;
no_handle:
+ pipe_sampler_view_reference(&dev->dummy_sv, NULL);
+no_resource:
dev->context->destroy(dev->context);
- /* Destroy vscreen */
no_context:
vl_screen_destroy(dev->vscreen);
no_vscreen:
@@ -185,6 +225,7 @@ vlVdpDeviceFree(vlVdpDevice *dev)
{
pipe_mutex_destroy(dev->mutex);
vl_compositor_cleanup(&dev->compositor);
+ pipe_sampler_view_reference(&dev->dummy_sv, NULL);
dev->context->destroy(dev->context);
vl_screen_destroy(dev->vscreen);
FREE(dev);