vc4: Avoid loading undefined (newly-allocated) FBO contents.
authorEric Anholt <eric@anholt.net>
Mon, 9 Nov 2015 17:12:20 +0000 (09:12 -0800)
committerEric Anholt <eric@anholt.net>
Tue, 10 Nov 2015 03:17:36 +0000 (19:17 -0800)
Since X has undefined contents in new pixmaps, it will allocate new
textures for an FBO and draw to them without an explicit clear.  For
VC4, it's much faster to emit a clear than the load of the actual
undefined memory contents, so just do that instead.

src/gallium/drivers/vc4/vc4_state.c

index 7317695b6521816a16f46c7595e74be833ce0a5b..a234ce53b20ce1b1a495b7fd626f9a4b43f286bc 100644 (file)
@@ -420,6 +420,23 @@ vc4_set_framebuffer_state(struct pipe_context *pctx,
         cso->width = framebuffer->width;
         cso->height = framebuffer->height;
 
+        /* If we're binding to uninitialized buffers, no need to load their
+         * contents before drawing..
+         */
+        if (cso->cbufs[0]) {
+                struct vc4_resource *rsc =
+                        vc4_resource(cso->cbufs[0]->texture);
+                if (!rsc->writes)
+                        vc4->cleared |= PIPE_CLEAR_COLOR0;
+        }
+
+        if (cso->zsbuf) {
+                struct vc4_resource *rsc =
+                        vc4_resource(cso->zsbuf->texture);
+                if (!rsc->writes)
+                        vc4->cleared |= PIPE_CLEAR_DEPTH | PIPE_CLEAR_STENCIL;
+        }
+
         /* Nonzero texture mipmap levels are laid out as if they were in
          * power-of-two-sized spaces.  The renderbuffer config infers its
          * stride from the width parameter, so we need to configure our