Mesa (master): st/vdpau: check surface params before creating surfaces

Emil Velikov evelikov at kemper.freedesktop.org
Mon Jan 20 01:20:17 UTC 2014


Module: Mesa
Branch: master
Commit: f5788e042afbb93e693885e90609d552674f9bd2
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=f5788e042afbb93e693885e90609d552674f9bd2

Author: Ilia Mirkin <imirkin at alum.mit.edu>
Date:   Fri Jan 17 22:33:47 2014 -0500

st/vdpau: check surface params before creating surfaces

Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
Reviewed-by: Christian König <christian.koenig at amd.com>

---

 src/gallium/state_trackers/vdpau/bitmap.c        |    6 ++++++
 src/gallium/state_trackers/vdpau/output.c        |    7 +++++++
 src/gallium/state_trackers/vdpau/vdpau_private.h |    8 ++++++++
 3 files changed, 21 insertions(+)

diff --git a/src/gallium/state_trackers/vdpau/bitmap.c b/src/gallium/state_trackers/vdpau/bitmap.c
index 87def50..335c224 100644
--- a/src/gallium/state_trackers/vdpau/bitmap.c
+++ b/src/gallium/state_trackers/vdpau/bitmap.c
@@ -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;
diff --git a/src/gallium/state_trackers/vdpau/output.c b/src/gallium/state_trackers/vdpau/output.c
index ecf1579..59874cb 100644
--- a/src/gallium/state_trackers/vdpau/output.c
+++ b/src/gallium/state_trackers/vdpau/output.c
@@ -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;
diff --git a/src/gallium/state_trackers/vdpau/vdpau_private.h b/src/gallium/state_trackers/vdpau/vdpau_private.h
index 014a262..08afe60 100644
--- a/src/gallium/state_trackers/vdpau/vdpau_private.h
+++ b/src/gallium/state_trackers/vdpau/vdpau_private.h
@@ -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;




More information about the mesa-commit mailing list