diff --git a/src/panfrost/lib/pan_layout.c b/src/panfrost/lib/pan_layout.c index 9d6cfd9a8bc..fecac97bc45 100644 --- a/src/panfrost/lib/pan_layout.c +++ b/src/panfrost/lib/pan_layout.c @@ -160,6 +160,12 @@ pan_image_layout_init( /* Arrays and cubemaps have the entire miptree duplicated */ layout->array_stride_B = ALIGN_POT(layout_constraints.offset_B - layout->slices[0].offset_B, 64); + + if (layout_constraints.array_align_B) { + layout->array_stride_B = + ALIGN_POT(layout->array_stride_B, layout_constraints.array_align_B); + } + if (use_explicit_layout) { layout->data_size_B = layout_constraints.offset_B - explicit_layout_constraints->offset_B; diff --git a/src/panfrost/lib/pan_layout.h b/src/panfrost/lib/pan_layout.h index 855395fb98a..0f707b395d4 100644 --- a/src/panfrost/lib/pan_layout.h +++ b/src/panfrost/lib/pan_layout.h @@ -132,9 +132,20 @@ struct pan_image_layout_constraints { */ uint64_t offset_B; + /* Minimal aligment for an array layer. Used to implement sparse residency. */ + uint32_t array_align_B; + /* Row pitch in bytes. Non-zero if layout is explicit. */ uint32_t wsi_row_pitch_B; + union { + struct { + /* Minimal alignment for a row of ordered blocks. Used to implement sparse + * residency. */ + uint32_t row_align_B; + } u_tiled; + }; + /* When true, AFBC/AFRC imports are stricter than they were when those * modifiers where introduced. */ bool strict; diff --git a/src/panfrost/lib/pan_mod.c b/src/panfrost/lib/pan_mod.c index 72285e495c9..f02f92196af 100644 --- a/src/panfrost/lib/pan_mod.c +++ b/src/panfrost/lib/pan_mod.c @@ -546,6 +546,12 @@ pan_mod_u_tiled_init_slice_layout( align_mask + 1); } + if (layout_constraints && layout_constraints->u_tiled.row_align_B) { + slayout->tiled_or_linear.row_stride_B = + ALIGN_POT(slayout->tiled_or_linear.row_stride_B, + layout_constraints->u_tiled.row_align_B); + } + uint64_t surf_stride_B = (uint64_t)slayout->tiled_or_linear.row_stride_B * DIV_ROUND_UP(mip_extent_el.height, tile_extent_el.height);