vc4: When asked to sample from a raster texture, make a shadow tiled copy.
authorEric Anholt <eric@anholt.net>
Wed, 8 Apr 2015 19:49:24 +0000 (12:49 -0700)
committerEric Anholt <eric@anholt.net>
Tue, 14 Apr 2015 05:34:06 +0000 (22:34 -0700)
So, it turns out my simulator doesn't *quite* match the hardware.  And the
errata about raster textures tells you most of what's wrong, but there's
still stuff wrong after that.  Instead, if we're asked to sample from
raster, we'll just blit it to a tiled temporary.

Raster textures should only be screen scanout, and word is that it's
faster to copy to tiled using the tiling engine first than to texture from
an entire raster texture, anyway.

src/gallium/drivers/vc4/vc4_state.c

index 332f310824166bfd878114e04f7d7b6fd734e1a1..df75b6ec81b3c35c35c9e07c3fea2791aac07f03 100644 (file)
@@ -516,6 +516,7 @@ vc4_create_sampler_view(struct pipe_context *pctx, struct pipe_resource *prsc,
                         const struct pipe_sampler_view *cso)
 {
         struct pipe_sampler_view *so = malloc(sizeof(*so));
+        struct vc4_resource *rsc = vc4_resource(prsc);
 
         if (!so)
                 return NULL;
@@ -527,8 +528,12 @@ vc4_create_sampler_view(struct pipe_context *pctx, struct pipe_resource *prsc,
         /* There is no hardware level clamping, and the start address of a
          * texture may be misaligned, so in that case we have to copy to a
          * temporary.
+         *
+         * Also, Raspberry Pi doesn't support sampling from raster textures,
+         * so we also have to copy to a temporary then.
          */
-        if (so->u.tex.first_level) {
+        if (so->u.tex.first_level ||
+            rsc->vc4_format == VC4_TEXTURE_TYPE_RGBA32R) {
                 struct vc4_resource *shadow_parent = vc4_resource(prsc);
                 struct pipe_resource tmpl = shadow_parent->base.b;
                 struct vc4_resource *clone;
@@ -574,8 +579,10 @@ vc4_set_sampler_views(struct pipe_context *pctx, unsigned shader,
 
         for (i = 0; i < nr; i++) {
                 if (views[i]) {
+                        struct vc4_resource *rsc =
+                                vc4_resource(views[i]->texture);
                         new_nr = i + 1;
-                        if (views[i]->u.tex.first_level != 0)
+                        if (rsc->shadow_parent)
                                 vc4_update_shadow_baselevel_texture(pctx, views[i]);
                 }
                 pipe_sampler_view_reference(&stage_tex->textures[i], views[i]);