From 162927e43cdb5d6c184a4064fbd0799012fc297e Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Tue, 4 Feb 2020 10:31:28 +0100 Subject: [PATCH] panfrost: Use size0 when calculating the offset to a depth level Previously, we were using cubemap_stride and sometimes overwriting other BOs such as shaders. Signed-off-by: Alyssa Rosenzweig Signed-off-by: Tomeu Vizoso Reviewed-by: Alyssa Rosenzweig Part-of: --- src/gallium/drivers/panfrost/pan_context.c | 3 +-- src/gallium/drivers/panfrost/pan_resource.c | 16 +++++++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c index 585fefa7066..169e5956c2f 100644 --- a/src/gallium/drivers/panfrost/pan_context.c +++ b/src/gallium/drivers/panfrost/pan_context.c @@ -589,9 +589,8 @@ panfrost_upload_tex( for (unsigned l = first_level; l <= last_level; ++l) { for (unsigned f = first_face; f <= last_face; ++f) { pointers_and_strides[idx++] = - panfrost_get_texture_address(rsrc, l, w*face_mult + f) + panfrost_get_texture_address(rsrc, l, w * face_mult + f) + afbc_bit + view->astc_stretch; - if (has_manual_stride) { pointers_and_strides[idx++] = rsrc->slices[l].stride; diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c index aac1e8cf19d..6d5c9ab5cbd 100644 --- a/src/gallium/drivers/panfrost/pan_resource.c +++ b/src/gallium/drivers/panfrost/pan_resource.c @@ -555,6 +555,15 @@ panfrost_resource_destroy(struct pipe_screen *screen, ralloc_free(rsrc); } +static unsigned +panfrost_get_layer_stride(struct panfrost_resource *rsrc, unsigned level) +{ + if (rsrc->base.target == PIPE_TEXTURE_3D) + return rsrc->slices[level].size0; + else + return rsrc->cubemap_stride; +} + static void * panfrost_transfer_map(struct pipe_context *pctx, struct pipe_resource *resource, @@ -679,10 +688,7 @@ panfrost_transfer_map(struct pipe_context *pctx, return transfer->map; } else { transfer->base.stride = rsrc->slices[level].stride; - if (resource->target == PIPE_TEXTURE_3D) - transfer->base.layer_stride = rsrc->slices[level].size0; - else - transfer->base.layer_stride = rsrc->cubemap_stride; + transfer->base.layer_stride = panfrost_get_layer_stride(rsrc, level); /* By mapping direct-write, we're implicitly already * initialized (maybe), so be conservative */ @@ -830,7 +836,7 @@ panfrost_get_texture_address( unsigned level, unsigned face) { unsigned level_offset = rsrc->slices[level].offset; - unsigned face_offset = face * rsrc->cubemap_stride; + unsigned face_offset = face * panfrost_get_layer_stride(rsrc, level); return rsrc->bo->gpu + level_offset + face_offset; } -- 2.30.2