From 65bc56b5683283859c12944dee653d4a0a1088f5 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Fri, 21 Jun 2019 17:23:49 -0700 Subject: [PATCH] panfrost: Use get_texture_address for framebuffer computations Allows for sharing some code as well as theoretically allowing cubemap rendering. Signed-off-by: Alyssa Rosenzweig --- src/gallium/drivers/panfrost/pan_context.c | 19 ------------------- src/gallium/drivers/panfrost/pan_mfbd.c | 11 +++++------ src/gallium/drivers/panfrost/pan_resource.c | 18 ++++++++++++++++++ src/gallium/drivers/panfrost/pan_resource.h | 5 +++++ 4 files changed, 28 insertions(+), 25 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c index c4ffea774d2..a54e27612fc 100644 --- a/src/gallium/drivers/panfrost/pan_context.c +++ b/src/gallium/drivers/panfrost/pan_context.c @@ -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, diff --git a/src/gallium/drivers/panfrost/pan_mfbd.c b/src/gallium/drivers/panfrost/pan_mfbd.c index 0ebfecc1200..e74a8e6229f 100644 --- a/src/gallium/drivers/panfrost/pan_mfbd.c +++ b/src/gallium/drivers/panfrost/pan_mfbd.c @@ -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; diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c index d8f1a9b521f..beb5f72d2d8 100644 --- a/src/gallium/drivers/panfrost/pan_resource.c +++ b/src/gallium/drivers/panfrost/pan_resource.c @@ -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) diff --git a/src/gallium/drivers/panfrost/pan_resource.h b/src/gallium/drivers/panfrost/pan_resource.h index a0bb5e962d9..220492039a5 100644 --- a/src/gallium/drivers/panfrost/pan_resource.h +++ b/src/gallium/drivers/panfrost/pan_resource.h @@ -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); -- 2.30.2