st/vdpau: check surface params before creating surfaces
authorIlia Mirkin <imirkin@alum.mit.edu>
Sat, 18 Jan 2014 03:33:47 +0000 (22:33 -0500)
committerIlia Mirkin <imirkin@alum.mit.edu>
Mon, 20 Jan 2014 01:02:10 +0000 (20:02 -0500)
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Christian König <christian.koenig@amd.com>
src/gallium/state_trackers/vdpau/bitmap.c
src/gallium/state_trackers/vdpau/output.c
src/gallium/state_trackers/vdpau/vdpau_private.h

index 87def5042eb09adcdfbc2c30e932444bd551a281..335c224f70078e33471a14591f3a933a323d63eb 100644 (file)
@@ -80,6 +80,12 @@ vlVdpBitmapSurfaceCreate(VdpDevice device,
    res_tmpl.usage = frequently_accessed ? PIPE_USAGE_DYNAMIC : PIPE_USAGE_STATIC;
 
    pipe_mutex_lock(dev->mutex);
+
+   if (!CheckSurfaceParams(pipe->screen, &res_tmpl)) {
+      ret = VDP_STATUS_RESOURCES;
+      goto err_unlock;
+   }
+
    res = pipe->screen->resource_create(pipe->screen, &res_tmpl);
    if (!res) {
       ret = VDP_STATUS_RESOURCES;
index ecf15796df513d4a914de95d193c2a1d502cf532..59874cb096530d6d5709c4887a6d78aa6f1e1070 100644 (file)
@@ -83,6 +83,10 @@ vlVdpOutputSurfaceCreate(VdpDevice device,
    res_tmpl.usage = PIPE_USAGE_STATIC;
 
    pipe_mutex_lock(dev->mutex);
+
+   if (!CheckSurfaceParams(pipe->screen, &res_tmpl))
+      goto err_unlock;
+
    res = pipe->screen->resource_create(pipe->screen, &res_tmpl);
    if (!res)
       goto err_unlock;
@@ -319,6 +323,9 @@ vlVdpOutputSurfacePutBitsIndexed(VdpOutputSurface surface,
    pipe_mutex_lock(vlsurface->device->mutex);
    vlVdpResolveDelayedRendering(vlsurface->device, NULL, NULL);
 
+   if (!CheckSurfaceParams(context->screen, &res_tmpl))
+      goto error_resource;
+
    res = context->screen->resource_create(context->screen, &res_tmpl);
    if (!res)
       goto error_resource;
index 014a262c672e3c44615de79fcd4414a2a0ce003d..08afe60341f126f6c51e2588ed07cdff343833d3 100644 (file)
@@ -332,6 +332,14 @@ RectToPipeBox(const VdpRect *rect, struct pipe_resource *res)
    return box;
 }
 
+static inline bool
+CheckSurfaceParams(struct pipe_screen *screen,
+                   const struct pipe_resource *templ)
+{
+   return screen->is_format_supported(
+         screen, templ->format, templ->target, templ->nr_samples, templ->bind);
+}
+
 typedef struct
 {
    struct vl_screen *vscreen;