summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Isorce <[email protected]>2015-10-30 11:42:45 +0000
committerChristian König <[email protected]>2015-10-30 13:19:47 +0100
commitd42029d2d9bc6b65ccf847dc9ba2e70b496d0299 (patch)
tree7b7ba19e345dda95e81472fb67722fa675add9be
parent87109e5f88131b78232e42c8fe246002867fb247 (diff)
st/va: do not destroy old buffer when new one failed
If formats are not the same vlVaPutImage re-creates the video buffer with the right format. But if the creation of this new video buffer fails then the surface looses its current buffer. Let's just destroy the previous buffer on success. Signed-off-by: Julien Isorce <[email protected]> Reviewed-by: Emil Velikov <[email protected]> Reviewed-by: Christian König <[email protected]>
-rw-r--r--src/gallium/state_trackers/va/image.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/gallium/state_trackers/va/image.c b/src/gallium/state_trackers/va/image.c
index 0d961b1f8a2..b0c720de107 100644
--- a/src/gallium/state_trackers/va/image.c
+++ b/src/gallium/state_trackers/va/image.c
@@ -346,13 +346,20 @@ vlVaPutImage(VADriverContextP ctx, VASurfaceID surface, VAImageID image,
if (format == PIPE_FORMAT_NONE)
return VA_STATUS_ERROR_OPERATION_FAILED;
- if (surf->buffer == NULL || format != surf->buffer->buffer_format) {
- if (surf->buffer)
- surf->buffer->destroy(surf->buffer);
+ if (format != surf->buffer->buffer_format) {
+ struct pipe_video_buffer *tmp_buf;
+ enum pipe_format old_surf_format = surf->templat.buffer_format;
+
surf->templat.buffer_format = format;
- surf->buffer = drv->pipe->create_video_buffer(drv->pipe, &surf->templat);
- if (!surf->buffer)
- return VA_STATUS_ERROR_ALLOCATION_FAILED;
+ tmp_buf = drv->pipe->create_video_buffer(drv->pipe, &surf->templat);
+
+ if (!tmp_buf) {
+ surf->templat.buffer_format = old_surf_format;
+ return VA_STATUS_ERROR_ALLOCATION_FAILED;
+ }
+
+ surf->buffer->destroy(surf->buffer);
+ surf->buffer = tmp_buf;
}
views = surf->buffer->get_sampler_view_planes(surf->buffer);