panfrost: Use get_texture_address for framebuffer computations
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Sat, 22 Jun 2019 00:23:49 +0000 (17:23 -0700)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Tue, 25 Jun 2019 20:39:17 +0000 (13:39 -0700)
Allows for sharing some code as well as theoretically allowing cubemap
rendering.

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

index c4ffea774d2f2014a34c6b4bca6f539dab22a379..a54e27612fce7a6442ba2f403fb9d7bf23d69366 100644 (file)
@@ -826,25 +826,6 @@ panfrost_upload_sampler_descriptors(struct panfrost_context *ctx)
         }
 }
 
-/* Computes the address to a texture at a particular slice */
-
-static mali_ptr
-panfrost_get_texture_address(
-                struct panfrost_resource *rsrc,
-                unsigned level, unsigned face)
-{
-        unsigned level_offset = rsrc->bo->slices[level].offset;
-        unsigned face_offset = face * rsrc->bo->cubemap_stride;
-
-        /* Lower-bit is set when sampling from colour AFBC */
-        bool is_afbc = rsrc->bo->layout == PAN_AFBC;
-        bool is_zs = rsrc->base.bind & PIPE_BIND_DEPTH_STENCIL;
-        unsigned afbc_bit = (is_afbc && !is_zs) ? 1 : 0;
-
-        return rsrc->bo->gpu + level_offset + face_offset + afbc_bit;
-
-}
-
 static mali_ptr
 panfrost_upload_tex(
                 struct panfrost_context *ctx,
index 0ebfecc12008f9d3a48a38a02616a2eaf6bbd341..e74a8e6229f511e5c12eb559db1eb28d8ff09762 100644 (file)
@@ -94,10 +94,10 @@ panfrost_mfbd_set_cbuf(
         struct panfrost_resource *rsrc = pan_resource(surf->texture);
 
         unsigned level = surf->u.tex.level;
-        assert(surf->u.tex.first_layer == 0);
-
+        unsigned first_layer = surf->u.tex.first_layer;
         int stride = rsrc->bo->slices[level].stride;
-        unsigned offset = rsrc->bo->slices[level].offset;
+
+        mali_ptr base = panfrost_get_texture_address(rsrc, level, first_layer);
 
         rt->format = panfrost_mfbd_format(surf);
 
@@ -105,16 +105,15 @@ panfrost_mfbd_set_cbuf(
 
         if (rsrc->bo->layout == PAN_LINEAR) {
                 rt->format.block = MALI_MFBD_BLOCK_LINEAR;
-                rt->framebuffer = rsrc->bo->gpu + offset;
+                rt->framebuffer = base;
                 rt->framebuffer_stride = stride / 16;
         } else if (rsrc->bo->layout == PAN_TILED) {
                 rt->format.block = MALI_MFBD_BLOCK_TILED;
-                rt->framebuffer = rsrc->bo->gpu + offset;
+                rt->framebuffer = base;
                 rt->framebuffer_stride = stride;
         } else if (rsrc->bo->layout == PAN_AFBC) {
                 rt->format.block = MALI_MFBD_BLOCK_AFBC;
 
-                mali_ptr base = rsrc->bo->gpu + offset;
                 unsigned header_size = rsrc->bo->slices[level].header_size;
 
                 rt->framebuffer = base + header_size;
index d8f1a9b521f4328771ef911d67cda7a89af3867d..beb5f72d2d86e7a1394c817f183e75b0a46b12a9 100644 (file)
@@ -718,6 +718,24 @@ panfrost_generate_mipmap(
         return blit_res;
 }
 
+/* Computes the address to a texture at a particular slice */
+
+mali_ptr
+panfrost_get_texture_address(
+                struct panfrost_resource *rsrc,
+                unsigned level, unsigned face)
+{
+        unsigned level_offset = rsrc->bo->slices[level].offset;
+        unsigned face_offset = face * rsrc->bo->cubemap_stride;
+
+        /* Lower-bit is set when sampling from colour AFBC */
+        bool is_afbc = rsrc->bo->layout == PAN_AFBC;
+        bool is_zs = rsrc->base.bind & PIPE_BIND_DEPTH_STENCIL;
+        unsigned afbc_bit = (is_afbc && !is_zs) ? 1 : 0;
+
+        return rsrc->bo->gpu + level_offset + face_offset + afbc_bit;
+}
+
 static void
 panfrost_resource_set_stencil(struct pipe_resource *prsrc,
                               struct pipe_resource *stencil)
index a0bb5e962d9d8eb176cb3be31883b8d9c5a35299..220492039a591e3ec667ff0c193df57cecda6e4c 100644 (file)
@@ -120,6 +120,11 @@ pan_transfer(struct pipe_transfer *p)
    return (struct panfrost_gtransfer *)p;
 }
 
+mali_ptr
+panfrost_get_texture_address(
+                struct panfrost_resource *rsrc,
+                unsigned level, unsigned face);
+
 void panfrost_resource_screen_init(struct panfrost_screen *screen);
 void panfrost_resource_screen_deinit(struct panfrost_screen *screen);