vc4: Keep a reference to BOs queued for rendering.
authorEric Anholt <eric@anholt.net>
Thu, 31 Jul 2014 19:19:29 +0000 (12:19 -0700)
committerEric Anholt <eric@anholt.net>
Mon, 11 Aug 2014 21:45:30 +0000 (14:45 -0700)
Otherwise, once we're not flushing at the end of every draw, we'll free
things like gallium resources, and free the backing GEM object, before
we've flushed the rendering using it to the kernel.

src/gallium/drivers/vc4/vc4_cl.c
src/gallium/drivers/vc4/vc4_context.c
src/gallium/drivers/vc4/vc4_context.h

index 5c660d8d7a81fcf1f06fb6bff3f7bfabeb3803e9..29b956e6e9a8bd0af294e1a4fd5673f59d3c1e8d 100644 (file)
@@ -61,10 +61,7 @@ vc4_gem_hindex(struct vc4_context *vc4, struct vc4_bo *bo)
         }
 
         cl_u32(&vc4->bo_handles, bo->handle);
-
-#ifdef USE_VC4_SIMULATOR
-        cl_ptr(&vc4->bo_pointers, bo);
-#endif
+        cl_ptr(&vc4->bo_pointers, vc4_bo_reference(bo));
 
         return hindex;
 }
index c69d620d6b64cce253729fb1d141efaf1f646765..6799e7ebf616b53c9a731f97f70d79c042f4ddc3 100644 (file)
@@ -226,9 +226,10 @@ vc4_flush(struct pipe_context *pctx)
         vc4_reset_cl(&vc4->shader_rec);
         vc4_reset_cl(&vc4->uniforms);
         vc4_reset_cl(&vc4->bo_handles);
-#ifdef USE_VC4_SIMULATOR
+        struct vc4_bo **referenced_bos = vc4->bo_pointers.base;
+        for (int i = 0; i < submit.bo_handle_count; i++)
+                vc4_bo_unreference(&referenced_bos[i]);
         vc4_reset_cl(&vc4->bo_pointers);
-#endif
         vc4->shader_rec_count = 0;
 
         vc4->needs_flush = false;
index 55746ea3b71a27e7e7619f7cb06434129c1ec314..85cdf41e4279da73f7e9042775285ad84e28b62e 100644 (file)
@@ -123,9 +123,7 @@ struct vc4_context {
         struct vc4_cl shader_rec;
         struct vc4_cl uniforms;
         struct vc4_cl bo_handles;
-#ifdef USE_VC4_SIMULATOR
         struct vc4_cl bo_pointers;
-#endif
         uint32_t shader_rec_count;
 
         struct vc4_bo *tile_alloc;