gallium/u_inlines: allow NULL src in util_copy_image_view
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Fri, 29 Apr 2016 21:06:13 +0000 (16:06 -0500)
committerNicolai Hähnle <nicolai.haehnle@amd.com>
Wed, 1 Jun 2016 20:37:12 +0000 (22:37 +0200)
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/auxiliary/util/u_inlines.h

index 90821b29de20f7027a405cb319aaf2d8791e51a2..207e2aa838f20eb4c86c71bdc3e769112192f576 100644 (file)
@@ -626,10 +626,17 @@ static inline void
 util_copy_image_view(struct pipe_image_view *dst,
                      const struct pipe_image_view *src)
 {
-   pipe_resource_reference(&dst->resource, src->resource);
-   dst->format = src->format;
-   dst->access = src->access;
-   dst->u = src->u;
+   if (src) {
+      pipe_resource_reference(&dst->resource, src->resource);
+      dst->format = src->format;
+      dst->access = src->access;
+      dst->u = src->u;
+   } else {
+      pipe_resource_reference(&dst->resource, NULL);
+      dst->format = PIPE_FORMAT_NONE;
+      dst->access = 0;
+      memset(&dst->u, 0, sizeof(dst->u));
+   }
 }
 
 static inline unsigned