panfrost: Preliminary work for cubemaps
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Wed, 27 Mar 2019 04:37:26 +0000 (04:37 +0000)
committerAlyssa Rosenzweig <alyssa@rosenzweig.io>
Sun, 31 Mar 2019 02:36:37 +0000 (02:36 +0000)
Again, not yet functional, but this sets up the memory management for
cube maps.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
src/gallium/drivers/panfrost/pan_context.c
src/gallium/drivers/panfrost/pan_resource.c
src/gallium/drivers/panfrost/pan_resource.h

index 8fed527..43e0a62 100644 (file)
@@ -1907,9 +1907,6 @@ panfrost_create_sampler_view(
          * (data) itself. So, we serialise the descriptor here and cache it for
          * later. */
 
-        /* TODO: Other types of textures */
-        assert(template->target == PIPE_TEXTURE_2D);
-
         /* Make sure it's something with which we're familiar */
         assert(bytes_per_pixel >= 1 && bytes_per_pixel <= 4);
 
index 9e663e5..a1285f2 100644 (file)
@@ -218,7 +218,10 @@ panfrost_setup_slices(const struct pipe_resource *tmpl, struct panfrost_bo *bo)
                 height = u_minify(height, 1);
         }
 
-        bo->size = ALIGN(offset, 4096);
+        assert(tmpl->array_size);
+
+        bo->cubemap_stride = ALIGN(offset, 64);
+        bo->size = ALIGN(bo->cubemap_stride * tmpl->array_size, 4096);
 }
 
 static struct panfrost_bo *
@@ -286,6 +289,7 @@ panfrost_resource_create(struct pipe_screen *screen,
                 case PIPE_TEXTURE_1D:
                 case PIPE_TEXTURE_2D:
                 case PIPE_TEXTURE_3D:
+                case PIPE_TEXTURE_CUBE:
                 case PIPE_TEXTURE_RECT:
                         break;
                 default:
@@ -388,7 +392,6 @@ panfrost_transfer_map(struct pipe_context *pctx,
         transfer->base.box = *box;
         transfer->base.stride = bo->slices[level].stride;
         transfer->base.layer_stride = bytes_per_pixel * resource->width0; /* TODO: Cubemaps */
-        assert(!transfer->base.box.z);
 
         pipe_resource_reference(&transfer->base.resource, resource);
 
@@ -417,6 +420,7 @@ panfrost_transfer_map(struct pipe_context *pctx,
         } else {
                 return bo->cpu
                         + bo->slices[level].offset
+                        + transfer->base.box.z * bo->cubemap_stride
                         + transfer->base.box.y * bo->slices[level].stride
                         + transfer->base.box.x * bytes_per_pixel;
         }
index 3e076b8..a1315ab 100644 (file)
@@ -53,9 +53,12 @@ struct panfrost_bo {
         /* GPU address for the object */
         mali_ptr gpu;
 
-        /* Size of the entire tree */
+        /* Size of all entire trees */
         size_t size;
 
+        /* Distance from tree to tree */
+        unsigned cubemap_stride;
+
         /* Set if this bo was imported rather than allocated */
         bool imported;