From 81a686a714a39bc943c916352ab32642dfbe796c Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Wed, 27 Apr 2022 11:23:37 -0400 Subject: [PATCH] panfrost: Use row stride for explicit layouts Line strides don't make sense for linear images, so use row strides instead in the API. Then update the layout code accordingly. Note: we need to preserve the old UABI (bug for bug compatibility), so we still use legacy strides externally. But now we use row strides internally, which is better than using both everywhere. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/gallium/drivers/panfrost/pan_resource.c | 4 ++-- src/panfrost/lib/pan_layout.c | 12 ++++++------ src/panfrost/lib/pan_texture.h | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c index a6e77b6e117..53a89f3db8b 100644 --- a/src/gallium/drivers/panfrost/pan_resource.c +++ b/src/gallium/drivers/panfrost/pan_resource.c @@ -86,7 +86,7 @@ panfrost_resource_from_handle(struct pipe_screen *pscreen, PAN_IMAGE_CRC_OOB : PAN_IMAGE_CRC_NONE; struct pan_image_explicit_layout explicit_layout = { .offset = whandle->offset, - .line_stride = whandle->stride, + .row_stride = panfrost_from_legacy_stride(whandle->stride, templat->format, mod) }; rsc->image.layout = (struct pan_image_layout) { @@ -177,7 +177,7 @@ panfrost_resource_get_handle(struct pipe_screen *pscreen, return false; } - handle->stride = rsrc->image.layout.slices[0].line_stride; + handle->stride = panfrost_get_legacy_stride(&rsrc->image.layout, 0); handle->offset = rsrc->image.layout.slices[0].offset; return true; } diff --git a/src/panfrost/lib/pan_layout.c b/src/panfrost/lib/pan_layout.c index c53013c194d..e033dc2bf25 100644 --- a/src/panfrost/lib/pan_layout.c +++ b/src/panfrost/lib/pan_layout.c @@ -246,21 +246,21 @@ pan_image_layout_init(struct pan_image_layout *layout, slice->offset = offset; /* Compute the would-be stride */ - unsigned stride = bytes_per_pixel * effective_width; + unsigned row_stride = bytes_per_pixel * effective_width * block_size.height; if (explicit_layout) { /* Make sure the explicit stride is valid */ - if (explicit_layout->line_stride < stride) + if (explicit_layout->row_stride < row_stride) return false; - stride = explicit_layout->line_stride; + row_stride = explicit_layout->row_stride; } else if (linear) { /* Keep lines alignment on 64 byte for performance */ - stride = ALIGN_POT(stride, 64); + row_stride = ALIGN_POT(row_stride, 64); } - slice->line_stride = stride; - slice->row_stride = stride * block_size.height; + slice->line_stride = row_stride / block_size.height; + slice->row_stride = row_stride; unsigned slice_one_size = slice->line_stride * effective_height; diff --git a/src/panfrost/lib/pan_texture.h b/src/panfrost/lib/pan_texture.h index e9497f2c111..83d057f1bde 100644 --- a/src/panfrost/lib/pan_texture.h +++ b/src/panfrost/lib/pan_texture.h @@ -222,7 +222,7 @@ struct pan_scoreboard; struct pan_image_explicit_layout { unsigned offset; - unsigned line_stride; + unsigned row_stride; }; bool