vc4: Always unref the current job surfaces at job reset time.
authorEric Anholt <eric@anholt.net>
Wed, 7 Sep 2016 19:40:39 +0000 (12:40 -0700)
committerEric Anholt <eric@anholt.net>
Wed, 14 Sep 2016 05:08:03 +0000 (06:08 +0100)
Drops some tricky logic in vc4_flush() trying to update the pointers, and
fixes a broken lack of unref for MSAA surfaces at context destroy time.

src/gallium/drivers/vc4/vc4_blit.c
src/gallium/drivers/vc4/vc4_context.c
src/gallium/drivers/vc4/vc4_job.c

index c37354425b6eb98117c59e91907e53d73ad6582e..ee08ab8c0f30b1dc5e664f5c5eb6237036aab6d4 100644 (file)
@@ -132,15 +132,10 @@ vc4_tile_blit(struct pipe_context *pctx, const struct pipe_blit_info *info)
                 vc4_get_blit_surface(pctx, info->src.resource, info->src.level);
 
         pipe_surface_reference(&vc4->color_read, src_surf);
-        pipe_surface_reference(&vc4->color_write,
-                               dst_surf->texture->nr_samples > 1 ?
-                               NULL : dst_surf);
-        pipe_surface_reference(&vc4->msaa_color_write,
-                               dst_surf->texture->nr_samples > 1 ?
-                               dst_surf : NULL);
-        pipe_surface_reference(&vc4->zs_read, NULL);
-        pipe_surface_reference(&vc4->zs_write, NULL);
-        pipe_surface_reference(&vc4->msaa_zs_write, NULL);
+        if (dst_surf->texture->nr_samples > 1)
+                pipe_surface_reference(&vc4->color_write, dst_surf);
+        else
+                pipe_surface_reference(&vc4->msaa_color_write, dst_surf);
 
         vc4->draw_min_x = info->dst.box.x;
         vc4->draw_min_y = info->dst.box.y;
index e7f63d697354266b83c9c6c9ef892e320865a69f..6f50b97f44705ad02d642f6a7a30485c181cddc7 100644 (file)
@@ -45,43 +45,29 @@ vc4_flush(struct pipe_context *pctx)
         struct pipe_surface *zsbuf = vc4->framebuffer.zsbuf;
 
         if (cbuf && (vc4->resolve & PIPE_CLEAR_COLOR0)) {
-                pipe_surface_reference(&vc4->color_write,
-                                       cbuf->texture->nr_samples > 1 ?
-                                       NULL : cbuf);
-                pipe_surface_reference(&vc4->msaa_color_write,
-                                       cbuf->texture->nr_samples > 1 ?
-                                       cbuf : NULL);
+                if (cbuf->texture->nr_samples > 1) {
+                        pipe_surface_reference(&vc4->msaa_color_write, cbuf);
+                } else {
+                        pipe_surface_reference(&vc4->color_write, cbuf);
+                }
 
                 if (!(vc4->cleared & PIPE_CLEAR_COLOR0)) {
                         pipe_surface_reference(&vc4->color_read, cbuf);
-                } else {
-                        pipe_surface_reference(&vc4->color_read, NULL);
                 }
 
-        } else {
-                pipe_surface_reference(&vc4->color_write, NULL);
-                pipe_surface_reference(&vc4->color_read, NULL);
-                pipe_surface_reference(&vc4->msaa_color_write, NULL);
         }
 
         if (vc4->framebuffer.zsbuf &&
             (vc4->resolve & (PIPE_CLEAR_DEPTH | PIPE_CLEAR_STENCIL))) {
-                pipe_surface_reference(&vc4->zs_write,
-                                       zsbuf->texture->nr_samples > 1 ?
-                                       NULL : zsbuf);
-                pipe_surface_reference(&vc4->msaa_zs_write,
-                                       zsbuf->texture->nr_samples > 1 ?
-                                       zsbuf : NULL);
+                if (zsbuf->texture->nr_samples > 1) {
+                        pipe_surface_reference(&vc4->msaa_zs_write, zsbuf);
+                } else {
+                        pipe_surface_reference(&vc4->zs_write, zsbuf);
+                }
 
                 if (!(vc4->cleared & (PIPE_CLEAR_DEPTH | PIPE_CLEAR_STENCIL))) {
                         pipe_surface_reference(&vc4->zs_read, zsbuf);
-                } else {
-                        pipe_surface_reference(&vc4->zs_read, NULL);
                 }
-        } else {
-                pipe_surface_reference(&vc4->zs_write, NULL);
-                pipe_surface_reference(&vc4->zs_read, NULL);
-                pipe_surface_reference(&vc4->msaa_zs_write, NULL);
         }
 
         vc4_job_submit(vc4);
@@ -182,9 +168,6 @@ vc4_context_destroy(struct pipe_context *pctx)
         pipe_surface_reference(&vc4->framebuffer.cbufs[0], NULL);
         pipe_surface_reference(&vc4->framebuffer.zsbuf, NULL);
 
-        pipe_surface_reference(&vc4->color_write, NULL);
-        pipe_surface_reference(&vc4->color_read, NULL);
-
         vc4_program_fini(pctx);
 
         ralloc_free(vc4);
index e71f6f4cf9105ba7db8a7924e7776662f8c2c569..a95768958dbde5ead6c2096aab0893364d922ada 100644 (file)
@@ -70,6 +70,13 @@ vc4_job_reset(struct vc4_context *vc4)
         vc4->draw_min_y = ~0;
         vc4->draw_max_x = 0;
         vc4->draw_max_y = 0;
+
+        pipe_surface_reference(&vc4->color_write, NULL);
+        pipe_surface_reference(&vc4->color_read, NULL);
+        pipe_surface_reference(&vc4->msaa_color_write, NULL);
+        pipe_surface_reference(&vc4->zs_write, NULL);
+        pipe_surface_reference(&vc4->zs_read, NULL);
+        pipe_surface_reference(&vc4->msaa_zs_write, NULL);
 }
 
 static void