vc4: Make some assertions about how many flushes/EOFs the simulator sees.
authorEric Anholt <eric@anholt.net>
Fri, 17 Oct 2014 08:43:54 +0000 (09:43 +0100)
committerEric Anholt <eric@anholt.net>
Fri, 17 Oct 2014 12:13:43 +0000 (13:13 +0100)
This caught the previous commit's bug in the kernel validator.

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

index 2cdd77dd3016b26aff20af2d30362e7228626c1f..634a4b0a4217a36357a2dbd9f13e8b96273175ba 100644 (file)
@@ -43,7 +43,7 @@ struct vc4_cl {
 void vc4_init_cl(struct vc4_context *vc4, struct vc4_cl *cl);
 void vc4_grow_cl(struct vc4_cl *cl);
 void vc4_reset_cl(struct vc4_cl *cl);
-void vc4_dump_cl(struct vc4_cl *cl, bool is_render);
+void vc4_dump_cl(void *cl, uint32_t size, bool is_render);
 uint32_t vc4_gem_hindex(struct vc4_context *vc4, struct vc4_bo *bo);
 
 static inline void
index 40bcf011874570d131e2ce6be82bb2fc14b8f52f..a55c04fc144538954ecc98d10e34c059d9fd67b7 100644 (file)
@@ -83,12 +83,12 @@ static const struct packet_info {
 };
 
 void
-vc4_dump_cl(struct vc4_cl *cl, bool is_render)
+vc4_dump_cl(void *cl, uint32_t size, bool is_render)
 {
         uint32_t offset = 0, hw_offset = 0;
-        uint8_t *cmds = cl->base;
+        uint8_t *cmds = cl;
 
-        while (offset < cl->end - cl->base) {
+        while (offset < size) {
                 uint8_t header = cmds[offset];
 
                 if (header > ARRAY_SIZE(packet_info) ||
@@ -105,7 +105,7 @@ vc4_dump_cl(struct vc4_cl *cl, bool is_render)
                         header, p->name);
 
                 for (uint32_t i = 1; i < p->size; i++) {
-                        if (offset + i >= cl->end - cl->base) {
+                        if (offset + i >= size) {
                                 fprintf(stderr, "0x%08x 0x%08x: CL overflow!\n",
                                         offset + i, hw_offset + i);
                                 return;
index 7779c461c7660e69acf713284e7fe6b469ce4b1f..cc57486e1033ed9eba97f7a03eb6225390212edc 100644 (file)
@@ -273,9 +273,9 @@ vc4_flush(struct pipe_context *pctx)
 
         if (vc4_debug & VC4_DEBUG_CL) {
                 fprintf(stderr, "BCL:\n");
-                vc4_dump_cl(&vc4->bcl, false);
+                vc4_dump_cl(vc4->bcl.base, vc4->bcl.end - vc4->bcl.base, false);
                 fprintf(stderr, "RCL:\n");
-                vc4_dump_cl(&vc4->rcl, true);
+                vc4_dump_cl(vc4->rcl.base, vc4->rcl.end - vc4->rcl.base, true);
         }
 
         struct drm_vc4_submit_cl submit;
index 34262f5362c7733b7c146c07346e04c0f6f84468..1040ae8f5c43de577afa16ea05a9a13cbbd2c606 100644 (file)
@@ -108,6 +108,7 @@ vc4_simulator_unpin_bos(struct exec_info *exec)
 int
 vc4_simulator_flush(struct vc4_context *vc4, struct drm_vc4_submit_cl *args)
 {
+        struct vc4_screen *screen = vc4->screen;
         struct vc4_surface *csurf = vc4_surface(vc4->framebuffer.cbufs[0]);
         struct vc4_resource *ctex = csurf ? vc4_resource(csurf->base.texture) : NULL;
         uint32_t winsys_stride = ctex ? ctex->bo->simulator_winsys_stride : 0;
@@ -149,8 +150,24 @@ vc4_simulator_flush(struct vc4_context *vc4, struct drm_vc4_submit_cl *args)
         if (ret)
                 return ret;
 
-        simpenrose_do_binning(exec.ct0ca, exec.ct0ea);
-        simpenrose_do_rendering(exec.ct1ca, exec.ct1ea);
+        int bfc = simpenrose_do_binning(exec.ct0ca, exec.ct0ea);
+        if (bfc != 1) {
+                fprintf(stderr, "Binning returned %d flushes, should be 1.\n",
+                        bfc);
+                fprintf(stderr, "Relocated binning command list:\n");
+                vc4_dump_cl(screen->simulator_mem_base + exec.ct0ca,
+                            exec.ct0ea - exec.ct0ca, false);
+                abort();
+        }
+        int rfc = simpenrose_do_rendering(exec.ct1ca, exec.ct1ea);
+        if (rfc != 1) {
+                fprintf(stderr, "Rendering returned %d frames, should be 1.\n",
+                        rfc);
+                fprintf(stderr, "Relocated render command list:\n");
+                vc4_dump_cl(screen->simulator_mem_base + exec.ct1ca,
+                            exec.ct1ea - exec.ct1ca, true);
+                abort();
+        }
 
         ret = vc4_simulator_unpin_bos(&exec);
         if (ret)