vc4: Update the shadow texture for public textures on every draw.
authorEric Anholt <eric@anholt.net>
Tue, 14 Apr 2015 18:31:11 +0000 (11:31 -0700)
committerEric Anholt <eric@anholt.net>
Wed, 15 Apr 2015 23:50:23 +0000 (16:50 -0700)
We don't know who else has written to it, so we'd better update it every
time.  This makes the gears spin in X again.

src/gallium/drivers/vc4/vc4_draw.c
src/gallium/drivers/vc4/vc4_resource.c
src/gallium/drivers/vc4/vc4_state.c

index 717eb8a..16418bf 100644 (file)
@@ -132,6 +132,20 @@ vc4_start_draw(struct vc4_context *vc4)
 }
 
 static void
+vc4_update_shadow_textures(struct pipe_context *pctx,
+                           struct vc4_texture_stateobj *stage_tex)
+{
+        for (int i = 0; i < stage_tex->num_textures; i++) {
+                struct pipe_sampler_view *view = stage_tex->textures[i];
+                if (!view)
+                        continue;
+                struct vc4_resource *rsc = vc4_resource(view->texture);
+                if (rsc->shadow_parent)
+                        vc4_update_shadow_baselevel_texture(pctx, view);
+        }
+}
+
+static void
 vc4_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info)
 {
         struct vc4_context *vc4 = vc4_context(pctx);
@@ -145,6 +159,10 @@ vc4_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info)
                 return;
         }
 
+        /* Before setting up the draw, do any fixup blits necessary. */
+        vc4_update_shadow_textures(pctx, &vc4->verttex);
+        vc4_update_shadow_textures(pctx, &vc4->fragtex);
+
         vc4_get_draw_cl_space(vc4);
 
         struct vc4_vertex_stateobj *vtx = vc4->vtx;
index 94bab99..3f180d5 100644 (file)
@@ -583,7 +583,7 @@ vc4_update_shadow_baselevel_texture(struct pipe_context *pctx,
         struct vc4_resource *orig = vc4_resource(shadow->shadow_parent);
         assert(orig);
 
-        if (shadow->writes == orig->writes)
+        if (shadow->writes == orig->writes && orig->bo->private)
                 return;
 
         perf_debug("Updating shadow texture due to %s\n",
index df75b6e..80e963e 100644 (file)
@@ -578,13 +578,8 @@ vc4_set_sampler_views(struct pipe_context *pctx, unsigned shader,
         vc4->dirty |= VC4_DIRTY_TEXSTATE;
 
         for (i = 0; i < nr; i++) {
-                if (views[i]) {
-                        struct vc4_resource *rsc =
-                                vc4_resource(views[i]->texture);
+                if (views[i])
                         new_nr = i + 1;
-                        if (rsc->shadow_parent)
-                                vc4_update_shadow_baselevel_texture(pctx, views[i]);
-                }
                 pipe_sampler_view_reference(&stage_tex->textures[i], views[i]);
                 stage_tex->dirty_samplers |= (1 << i);
         }