- unsigned header_size = ALIGN(header_bytes, AFBC_CACHE_ALIGN);
-
- /* The stride is a normal stride, but aligned */
- unsigned unaligned_stride = aligned_width * bytes_per_pixel;
- unsigned stride = ALIGN(unaligned_stride, AFBC_CACHE_ALIGN);
-
- /* Compute the entire buffer size */
- unsigned body_size = stride * aligned_height;
- unsigned buffer_size = header_size + body_size;
-
- /* Allocate the AFBC slab itself, large enough to hold the above */
- panfrost_drm_allocate_slab(screen, &rsrc->bo->afbc_slab,
- ALIGN(buffer_size, 4096) / 4096,
- true, 0, 0, 0);
-
- /* Compressed textured reads use a tagged pointer to the metadata */
- rsrc->bo->layout = PAN_AFBC;
- rsrc->bo->gpu = rsrc->bo->afbc_slab.gpu | (ds ? 0 : 1);
- rsrc->bo->cpu = rsrc->bo->afbc_slab.cpu;
- rsrc->bo->gem_handle = rsrc->bo->afbc_slab.gem_handle;
- rsrc->bo->afbc_metadata_size = header_size;