17ec681f3Smrg/*
27ec681f3Smrg * Copyright © 2014 Broadcom
37ec681f3Smrg *
47ec681f3Smrg * Permission is hereby granted, free of charge, to any person obtaining a
57ec681f3Smrg * copy of this software and associated documentation files (the "Software"),
67ec681f3Smrg * to deal in the Software without restriction, including without limitation
77ec681f3Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
87ec681f3Smrg * and/or sell copies of the Software, and to permit persons to whom the
97ec681f3Smrg * Software is furnished to do so, subject to the following conditions:
107ec681f3Smrg *
117ec681f3Smrg * The above copyright notice and this permission notice (including the next
127ec681f3Smrg * paragraph) shall be included in all copies or substantial portions of the
137ec681f3Smrg * Software.
147ec681f3Smrg *
157ec681f3Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
167ec681f3Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
177ec681f3Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
187ec681f3Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
197ec681f3Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
207ec681f3Smrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
217ec681f3Smrg * IN THE SOFTWARE.
227ec681f3Smrg */
237ec681f3Smrg
247ec681f3Smrg#ifndef V3D_TILING_H
257ec681f3Smrg#define V3D_TILING_H
267ec681f3Smrg
277ec681f3Smrg#include "util/u_box.h"
287ec681f3Smrg
297ec681f3Smrg/* A UIFblock is a 256-byte region of memory that's 256-byte aligned.  These
307ec681f3Smrg * will be grouped in 4x4 blocks (left-to-right, then top-to-bottom) in a 4KB
317ec681f3Smrg * page.  Those pages are then arranged left-to-right, top-to-bottom, to cover
327ec681f3Smrg * an image.
337ec681f3Smrg *
347ec681f3Smrg * The inside of a UIFblock, for packed pixels, will be split into 4 64-byte
357ec681f3Smrg * utiles.  Utiles may be 8x8 (8bpp), 8x4(16bpp) or 4x4 (32bpp).
367ec681f3Smrg */
377ec681f3Smrg
387ec681f3Smrg/**
397ec681f3Smrg * Tiling mode enum used for v3d_resource.c, which maps directly to the Memory
407ec681f3Smrg * Format field of render target and Z/Stencil config.
417ec681f3Smrg */
427ec681f3Smrgenum v3d_tiling_mode {
437ec681f3Smrg        /* Untiled resources.  Not valid as texture inputs. */
447ec681f3Smrg        V3D_TILING_RASTER,
457ec681f3Smrg
467ec681f3Smrg        /* Single line of u-tiles. */
477ec681f3Smrg        V3D_TILING_LINEARTILE,
487ec681f3Smrg
497ec681f3Smrg        /* Departure from standard 4-UIF block column format. */
507ec681f3Smrg        V3D_TILING_UBLINEAR_1_COLUMN,
517ec681f3Smrg
527ec681f3Smrg        /* Departure from standard 4-UIF block column format. */
537ec681f3Smrg        V3D_TILING_UBLINEAR_2_COLUMN,
547ec681f3Smrg
557ec681f3Smrg        /* Normal tiling format: grouped in 4x4 UIFblocks, each of which is
567ec681f3Smrg         * split 2x2 into utiles.
577ec681f3Smrg         */
587ec681f3Smrg        V3D_TILING_UIF_NO_XOR,
597ec681f3Smrg
607ec681f3Smrg        /* Normal tiling format: grouped in 4x4 UIFblocks, each of which is
617ec681f3Smrg         * split 2x2 into utiles.
627ec681f3Smrg         */
637ec681f3Smrg        V3D_TILING_UIF_XOR,
647ec681f3Smrg};
657ec681f3Smrg
667ec681f3Smrguint32_t v3d_utile_width(int cpp) ATTRIBUTE_CONST;
677ec681f3Smrguint32_t v3d_utile_height(int cpp) ATTRIBUTE_CONST;
687ec681f3Smrgbool v3d_size_is_lt(uint32_t width, uint32_t height, int cpp) ATTRIBUTE_CONST;
697ec681f3Smrgvoid v3d_load_tiled_image(void *dst, uint32_t dst_stride,
707ec681f3Smrg                          void *src, uint32_t src_stride,
717ec681f3Smrg                          enum v3d_tiling_mode tiling_format, int cpp,
727ec681f3Smrg                          uint32_t image_h,
737ec681f3Smrg                          const struct pipe_box *box);
747ec681f3Smrgvoid v3d_store_tiled_image(void *dst, uint32_t dst_stride,
757ec681f3Smrg                           void *src, uint32_t src_stride,
767ec681f3Smrg                           enum v3d_tiling_mode tiling_format, int cpp,
777ec681f3Smrg                           uint32_t image_h,
787ec681f3Smrg                           const struct pipe_box *box);
797ec681f3Smrg
807ec681f3Smrg#endif /* V3D_TILING_H */
81