• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2019 Collabora, Ltd.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21  * SOFTWARE.
22  *
23  * Authors:
24  *   Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
25  */
26 
27 #include <stdio.h>
28 #include "midgard_pack.h"
29 #include "pan_texture.h"
30 
31 /* Convenience */
32 
33 #define BFMT2(pipe, internal, writeback) \
34         [PIPE_FORMAT_##pipe] = { \
35                 MALI_COLOR_BUFFER_INTERNAL_FORMAT_## internal, \
36                 MALI_MFBD_COLOR_FORMAT_## writeback \
37         }
38 
39 #define BFMT(pipe, internal_and_writeback) \
40         BFMT2(pipe, internal_and_writeback, internal_and_writeback)
41 
42 static const struct pan_blendable_format panfrost_blendable_formats[PIPE_FORMAT_COUNT] = {
43         BFMT2(L8_UNORM, R8G8B8A8, R8),
44         BFMT2(L8A8_UNORM, R8G8B8A8, R8G8),
45         BFMT2(I8_UNORM, R8G8B8A8, R8),
46         BFMT2(A8_UNORM, R8G8B8A8, R8),
47         BFMT2(R8_UNORM, R8G8B8A8, R8),
48         BFMT2(R8G8_UNORM, R8G8B8A8, R8G8),
49         BFMT2(R8G8B8_UNORM, R8G8B8A8, R8G8B8),
50 
51         BFMT(B8G8R8A8_UNORM, R8G8B8A8),
52         BFMT(B8G8R8X8_UNORM, R8G8B8A8),
53         BFMT(A8R8G8B8_UNORM, R8G8B8A8),
54         BFMT(X8R8G8B8_UNORM, R8G8B8A8),
55         BFMT(A8B8G8R8_UNORM, R8G8B8A8),
56         BFMT(X8B8G8R8_UNORM, R8G8B8A8),
57         BFMT(R8G8B8X8_UNORM, R8G8B8A8),
58         BFMT(R8G8B8A8_UNORM, R8G8B8A8),
59 
60         BFMT2(B5G6R5_UNORM, R5G6B5A0, R5G6B5),
61 
62         BFMT(A4B4G4R4_UNORM, R4G4B4A4),
63         BFMT(B4G4R4A4_UNORM, R4G4B4A4),
64         BFMT(R4G4B4A4_UNORM, R4G4B4A4),
65 
66         BFMT(R10G10B10A2_UNORM, R10G10B10A2),
67         BFMT(B10G10R10A2_UNORM, R10G10B10A2),
68         BFMT(R10G10B10X2_UNORM, R10G10B10A2),
69         BFMT(B10G10R10X2_UNORM, R10G10B10A2),
70 
71         BFMT(B5G5R5A1_UNORM, R5G5B5A1),
72         BFMT(R5G5B5A1_UNORM, R5G5B5A1),
73         BFMT(B5G5R5X1_UNORM, R5G5B5A1),
74 };
75 
76 /* Accessor that is generic over linear/sRGB */
77 
78 struct pan_blendable_format
panfrost_blend_format(enum pipe_format format)79 panfrost_blend_format(enum pipe_format format)
80 {
81         return panfrost_blendable_formats[util_format_linear(format)];
82 }
83 
84 /* Convenience */
85 
86 #define _V PIPE_BIND_VERTEX_BUFFER
87 #define _T PIPE_BIND_SAMPLER_VIEW
88 #define _R PIPE_BIND_RENDER_TARGET
89 #define _Z PIPE_BIND_DEPTH_STENCIL
90 
91 #define FLAGS_V___ (_V)
92 #define FLAGS__T__ (_T)
93 #define FLAGS_VTR_ (_V | _T | _R)
94 #define FLAGS_VT__ (_V | _T)
95 #define FLAGS__T_Z (_T | _Z)
96 
97 #define V6_000R PAN_V6_SWIZZLE(0, 0, 0, R)
98 #define V6_A001 PAN_V6_SWIZZLE(A, 0, 0, 1)
99 #define V6_ABG1 PAN_V6_SWIZZLE(A, B, G, 1)
100 #define V6_ABGR PAN_V6_SWIZZLE(A, B, G, R)
101 #define V6_BGR1 PAN_V6_SWIZZLE(B, G, R, 1)
102 #define V6_BGRA PAN_V6_SWIZZLE(B, G, R, A)
103 #define V6_GBA1 PAN_V6_SWIZZLE(G, B, A, 1)
104 #define V6_GBAR PAN_V6_SWIZZLE(G, B, A, R)
105 #define V6_R000 PAN_V6_SWIZZLE(R, 0, 0, 0)
106 #define V6_R001 PAN_V6_SWIZZLE(R, 0, 0, 1)
107 #define V6_RG01 PAN_V6_SWIZZLE(R, G, 0, 1)
108 #define V6_RGB1 PAN_V6_SWIZZLE(R, G, B, 1)
109 #define V6_RGBA PAN_V6_SWIZZLE(R, G, B, A)
110 #define V6_RRR1 PAN_V6_SWIZZLE(R, R, R, 1)
111 #define V6_RRRG PAN_V6_SWIZZLE(R, R, R, G)
112 #define V6_RRRR PAN_V6_SWIZZLE(R, R, R, R)
113 
114 #define SRGB_L (0)
115 #define SRGB_S (1)
116 
117 #define PAN_V6(pipe, mali, swizzle, srgb, flags) \
118         [PIPE_FORMAT_ ## pipe] = { \
119             .hw = ( V6_ ## swizzle ) | \
120                 (( MALI_ ## mali ) << 12) | \
121                 ((( SRGB_ ## srgb)) << 20), \
122             .bind = FLAGS_ ## flags \
123         }
124 
125 #define PAN_V7(pipe, mali, swizzle, srgb, flags) \
126         [PIPE_FORMAT_ ## pipe] = { \
127             .hw = ( MALI_RGB_COMPONENT_ORDER_ ## swizzle ) | \
128                 (( MALI_ ## mali ) << 12) | \
129                 ((( SRGB_ ## srgb)) << 20), \
130             .bind = FLAGS_ ## flags \
131         }
132 
133 const struct panfrost_format panfrost_pipe_format_v6[PIPE_FORMAT_COUNT] = {
134         PAN_V6(ETC1_RGB8,               ETC2_RGB8,       RGB1, L, _T__),
135         PAN_V6(ETC2_RGB8,               ETC2_RGB8,       RGB1, L, _T__),
136         PAN_V6(ETC2_SRGB8,              ETC2_RGB8,       RGB1, S, _T__),
137         PAN_V6(ETC2_R11_UNORM,          ETC2_R11_UNORM,  R001, L, _T__),
138         PAN_V6(ETC2_RGBA8,              ETC2_RGBA8,      RGBA, L, _T__),
139         PAN_V6(ETC2_SRGBA8,             ETC2_RGBA8,      RGBA, S, _T__),
140         PAN_V6(ETC2_RG11_UNORM,         ETC2_RG11_UNORM, RG01, L, _T__),
141         PAN_V6(ETC2_R11_SNORM,          ETC2_R11_SNORM,  R001, L, _T__),
142         PAN_V6(ETC2_RG11_SNORM,         ETC2_RG11_SNORM, RG01, L, _T__),
143         PAN_V6(ETC2_RGB8A1,             ETC2_RGB8A1,     RGBA, L, _T__),
144         PAN_V6(ETC2_SRGB8A1,            ETC2_RGB8A1,     RGBA, S, _T__),
145         PAN_V6(DXT1_RGB,                BC1_UNORM,       RGB1, L, _T__),
146         PAN_V6(DXT1_RGBA,               BC1_UNORM,       RGBA, L, _T__),
147         PAN_V6(DXT1_SRGB,               BC1_UNORM,       RGB1, S, _T__),
148         PAN_V6(DXT1_SRGBA,              BC1_UNORM,       RGBA, S, _T__),
149         PAN_V6(DXT3_RGBA,               BC2_UNORM,       RGBA, L, _T__),
150         PAN_V6(DXT3_SRGBA,              BC2_UNORM,       RGBA, S, _T__),
151         PAN_V6(DXT5_RGBA,               BC3_UNORM,       RGBA, L, _T__),
152         PAN_V6(DXT5_SRGBA,              BC3_UNORM,       RGBA, S, _T__),
153         PAN_V6(RGTC1_UNORM,             BC4_UNORM,       R001, L, _T__),
154         PAN_V6(RGTC1_SNORM,             BC4_SNORM,       R001, L, _T__),
155         PAN_V6(RGTC2_UNORM,             BC5_UNORM,       RG01, L, _T__),
156         PAN_V6(RGTC2_SNORM,             BC5_SNORM,       RG01, L, _T__),
157         PAN_V6(BPTC_RGB_FLOAT,          BC6H_SF16,       RGB1, L, _T__),
158         PAN_V6(BPTC_RGB_UFLOAT,         BC6H_UF16,       RGB1, L, _T__),
159         PAN_V6(BPTC_RGBA_UNORM,         BC7_UNORM,       RGBA, L, _T__),
160         PAN_V6(BPTC_SRGBA,              BC7_UNORM,       RGBA, S, _T__),
161         PAN_V6(ASTC_4x4,                ASTC_2D_HDR,     RGBA, L, _T__),
162         PAN_V6(ASTC_5x4,                ASTC_2D_HDR,     RGBA, L, _T__),
163         PAN_V6(ASTC_5x5,                ASTC_2D_HDR,     RGBA, L, _T__),
164         PAN_V6(ASTC_6x5,                ASTC_2D_HDR,     RGBA, L, _T__),
165         PAN_V6(ASTC_6x6,                ASTC_2D_HDR,     RGBA, L, _T__),
166         PAN_V6(ASTC_8x5,                ASTC_2D_HDR,     RGBA, L, _T__),
167         PAN_V6(ASTC_8x6,                ASTC_2D_HDR,     RGBA, L, _T__),
168         PAN_V6(ASTC_8x8,                ASTC_2D_HDR,     RGBA, L, _T__),
169         PAN_V6(ASTC_10x5,               ASTC_2D_HDR,     RGBA, L, _T__),
170         PAN_V6(ASTC_10x6,               ASTC_2D_HDR,     RGBA, L, _T__),
171         PAN_V6(ASTC_10x8,               ASTC_2D_HDR,     RGBA, L, _T__),
172         PAN_V6(ASTC_10x10,              ASTC_2D_HDR,     RGBA, L, _T__),
173         PAN_V6(ASTC_12x10,              ASTC_2D_HDR,     RGBA, L, _T__),
174         PAN_V6(ASTC_12x12,              ASTC_2D_HDR,     RGBA, L, _T__),
175         PAN_V6(ASTC_4x4_SRGB,           ASTC_2D_LDR,     RGBA, S, _T__),
176         PAN_V6(ASTC_5x4_SRGB,           ASTC_2D_LDR,     RGBA, S, _T__),
177         PAN_V6(ASTC_5x5_SRGB,           ASTC_2D_LDR,     RGBA, S, _T__),
178         PAN_V6(ASTC_6x5_SRGB,           ASTC_2D_LDR,     RGBA, S, _T__),
179         PAN_V6(ASTC_6x6_SRGB,           ASTC_2D_LDR,     RGBA, S, _T__),
180         PAN_V6(ASTC_8x5_SRGB,           ASTC_2D_LDR,     RGBA, S, _T__),
181         PAN_V6(ASTC_8x6_SRGB,           ASTC_2D_LDR,     RGBA, S, _T__),
182         PAN_V6(ASTC_8x8_SRGB,           ASTC_2D_LDR,     RGBA, S, _T__),
183         PAN_V6(ASTC_10x5_SRGB,          ASTC_2D_LDR,     RGBA, S, _T__),
184         PAN_V6(ASTC_10x6_SRGB,          ASTC_2D_LDR,     RGBA, S, _T__),
185         PAN_V6(ASTC_10x8_SRGB,          ASTC_2D_LDR,     RGBA, S, _T__),
186         PAN_V6(ASTC_10x10_SRGB,         ASTC_2D_LDR,     RGBA, S, _T__),
187         PAN_V6(ASTC_12x10_SRGB,         ASTC_2D_LDR,     RGBA, S, _T__),
188         PAN_V6(ASTC_12x12_SRGB,         ASTC_2D_LDR,     RGBA, S, _T__),
189         PAN_V6(B5G6R5_UNORM,            RGB565,          BGR1, L, VTR_),
190         PAN_V6(B5G5R5X1_UNORM,          RGB5_A1_UNORM,   BGR1, L, VT__),
191         PAN_V6(R5G5B5A1_UNORM,          RGB5_A1_UNORM,   RGBA, L, VTR_),
192         PAN_V6(R10G10B10X2_UNORM,       RGB10_A2_UNORM,  RGB1, L, VTR_),
193         PAN_V6(B10G10R10X2_UNORM,       RGB10_A2_UNORM,  BGR1, L, VTR_),
194         PAN_V6(R10G10B10A2_UNORM,       RGB10_A2_UNORM,  RGBA, L, VTR_),
195         PAN_V6(B10G10R10A2_UNORM,       RGB10_A2_UNORM,  BGRA, L, VTR_),
196         PAN_V6(R10G10B10X2_SNORM,       RGB10_A2_SNORM,  RGB1, L, VT__),
197         PAN_V6(R10G10B10A2_SNORM,       RGB10_A2_SNORM,  RGBA, L, VT__),
198         PAN_V6(B10G10R10A2_SNORM,       RGB10_A2_SNORM,  BGRA, L, VT__),
199         PAN_V6(R10G10B10A2_UINT,        RGB10_A2UI,      RGBA, L, VTR_),
200         PAN_V6(B10G10R10A2_UINT,        RGB10_A2UI,      BGRA, L, VTR_),
201         PAN_V6(R10G10B10A2_USCALED,     RGB10_A2UI,      RGBA, L, VTR_),
202         PAN_V6(B10G10R10A2_USCALED,     RGB10_A2UI,      BGRA, L, VTR_),
203         PAN_V6(R10G10B10A2_SINT,        RGB10_A2I,       RGBA, L, VTR_),
204         PAN_V6(B10G10R10A2_SINT,        RGB10_A2I,       BGRA, L, VTR_),
205         PAN_V6(R10G10B10A2_SSCALED,     RGB10_A2I,       RGBA, L, VTR_),
206         PAN_V6(B10G10R10A2_SSCALED,     RGB10_A2I,       BGRA, L, VTR_),
207         PAN_V6(R8_SSCALED,              R8I,             R001, L, V___),
208         PAN_V6(R8G8_SSCALED,            RG8I,            RG01, L, V___),
209         PAN_V6(R8G8B8_SSCALED,          RGB8I,           RGB1, L, V___),
210         PAN_V6(B8G8R8_SSCALED,          RGB8I,           BGR1, L, V___),
211         PAN_V6(R8G8B8A8_SSCALED,        RGBA8I,          RGBA, L, V___),
212         PAN_V6(B8G8R8A8_SSCALED,        RGBA8I,          BGRA, L, V___),
213         PAN_V6(A8B8G8R8_SSCALED,        RGBA8I,          ABGR, L, V___),
214         PAN_V6(R8_USCALED,              R8UI,            R001, L, V___),
215         PAN_V6(R8G8_USCALED,            RG8UI,           RG01, L, V___),
216         PAN_V6(R8G8B8_USCALED,          RGB8UI,          RGB1, L, V___),
217         PAN_V6(B8G8R8_USCALED,          RGB8UI,          BGR1, L, V___),
218         PAN_V6(R8G8B8A8_USCALED,        RGBA8UI,         RGBA, L, V___),
219         PAN_V6(B8G8R8A8_USCALED,        RGBA8UI,         BGRA, L, V___),
220         PAN_V6(A8B8G8R8_USCALED,        RGBA8UI,         ABGR, L, V___),
221         PAN_V6(R16_USCALED,             R16UI,           R001, L, V___),
222         PAN_V6(R16G16_USCALED,          RG16UI,          RG01, L, V___),
223         PAN_V6(R16G16B16_USCALED,       RGB16UI,         RGB1, L, V___),
224         PAN_V6(R16G16B16A16_USCALED,    RGBA16UI,        RGBA, L, V___),
225         PAN_V6(R16_SSCALED,             R16I,            R001, L, V___),
226         PAN_V6(R16G16_SSCALED,          RG16I,           RG01, L, V___),
227         PAN_V6(R16G16B16_SSCALED,       RGB16I,          RGB1, L, V___),
228         PAN_V6(R16G16B16A16_SSCALED,    RGBA16I,         RGBA, L, V___),
229         PAN_V6(R32_USCALED,             R32UI,           R001, L, V___),
230         PAN_V6(R32G32_USCALED,          RG32UI,          RG01, L, V___),
231         PAN_V6(R32G32B32_USCALED,       RGB32UI,         RGB1, L, V___),
232         PAN_V6(R32G32B32A32_USCALED,    RGBA32UI,        RGBA, L, V___),
233         PAN_V6(R32_SSCALED,             R32I,            R001, L, V___),
234         PAN_V6(R32G32_SSCALED,          RG32I,           RG01, L, V___),
235         PAN_V6(R32G32B32_SSCALED,       RGB32I,          RGB1, L, V___),
236         PAN_V6(R32G32B32A32_SSCALED,    RGBA32I,         RGBA, L, V___),
237         PAN_V6(R3G3B2_UNORM,            RGB332_UNORM,    RGB1, L, VT__),
238         PAN_V6(Z16_UNORM,               R16_UNORM,       R000, L, _T_Z),
239         PAN_V6(Z24_UNORM_S8_UINT,       Z24X8_UNORM,     R000, L, _T_Z),
240         PAN_V6(Z24X8_UNORM,             Z24X8_UNORM,     R000, L, _T_Z),
241         PAN_V6(Z32_FLOAT,               R32F,            R000, L, _T_Z),
242         PAN_V6(Z32_FLOAT_S8X24_UINT,    R32F,            R000, L, _T_Z),
243         PAN_V6(X32_S8X24_UINT,          R32UI,           R001, L, _T__),
244         PAN_V6(X24S8_UINT,              RGBA8UI,         A001, L, _T_Z),
245         PAN_V6(S8_UINT,                 R8UI,            R001, L, _T__),
246         PAN_V6(R32_FIXED,               R32_FIXED,       R001, L, V___),
247         PAN_V6(R32G32_FIXED,            RG32_FIXED,      RG01, L, V___),
248         PAN_V6(R32G32B32_FIXED,         RGB32_FIXED,     RGB1, L, V___),
249         PAN_V6(R32G32B32A32_FIXED,      RGBA32_FIXED,    RGBA, L, V___),
250         PAN_V6(R11G11B10_FLOAT,         R11F_G11F_B10F,  RGB1, L, VTR_),
251         PAN_V6(R9G9B9E5_FLOAT,          R9F_G9F_B9F_E5F, RGB1, L, VT__),
252         PAN_V6(R8_SNORM,                R8_SNORM,        R001, L, VT__),
253         PAN_V6(R16_SNORM,               R16_SNORM,       R001, L, VT__),
254         PAN_V6(R32_SNORM,               R32_SNORM,       R001, L, VT__),
255         PAN_V6(R8G8_SNORM,              RG8_SNORM,       RG01, L, VT__),
256         PAN_V6(R16G16_SNORM,            RG16_SNORM,      RG01, L, VT__),
257         PAN_V6(R32G32_SNORM,            RG32_SNORM,      RG01, L, VT__),
258         PAN_V6(R8G8B8_SNORM,            RGB8_SNORM,      RGB1, L, VT__),
259         PAN_V6(R16G16B16_SNORM,         RGB16_SNORM,     RGB1, L, VT__),
260         PAN_V6(R32G32B32_SNORM,         RGB32_SNORM,     RGB1, L, VT__),
261         PAN_V6(R8G8B8A8_SNORM,          RGBA8_SNORM,     RGBA, L, VT__),
262         PAN_V6(R16G16B16A16_SNORM,      RGBA16_SNORM,    RGBA, L, VT__),
263         PAN_V6(R32G32B32A32_SNORM,      RGBA32_SNORM,    RGBA, L, VT__),
264         PAN_V6(A8_SINT,                 R8I,             000R, L, VTR_),
265         PAN_V6(I8_SINT,                 R8I,             RRRR, L, VTR_),
266         PAN_V6(L8_SINT,                 R8I,             RRR1, L, VTR_),
267         PAN_V6(A8_UINT,                 R8UI,            000R, L, VTR_),
268         PAN_V6(I8_UINT,                 R8UI,            RRRR, L, VTR_),
269         PAN_V6(L8_UINT,                 R8UI,            RRR1, L, VTR_),
270         PAN_V6(A16_SINT,                R16I,            000R, L, VTR_),
271         PAN_V6(I16_SINT,                R16I,            RRRR, L, VTR_),
272         PAN_V6(L16_SINT,                R16I,            RRR1, L, VTR_),
273         PAN_V6(A16_UINT,                R16UI,           000R, L, VTR_),
274         PAN_V6(I16_UINT,                R16UI,           RRRR, L, VTR_),
275         PAN_V6(L16_UINT,                R16UI,           RRR1, L, VTR_),
276         PAN_V6(A32_SINT,                R32I,            000R, L, VTR_),
277         PAN_V6(I32_SINT,                R32I,            RRRR, L, VTR_),
278         PAN_V6(L32_SINT,                R32I,            RRR1, L, VTR_),
279         PAN_V6(A32_UINT,                R32UI,           000R, L, VTR_),
280         PAN_V6(I32_UINT,                R32UI,           RRRR, L, VTR_),
281         PAN_V6(L32_UINT,                R32UI,           RRR1, L, VTR_),
282         PAN_V6(B8G8R8_UINT,             RGB8UI,          BGR1, L, VTR_),
283         PAN_V6(B8G8R8A8_UINT,           RGBA8UI,         BGRA, L, VTR_),
284         PAN_V6(B8G8R8_SINT,             RGB8I,           BGR1, L, VTR_),
285         PAN_V6(B8G8R8A8_SINT,           RGBA8I,          BGRA, L, VTR_),
286         PAN_V6(A8R8G8B8_UINT,           RGBA8UI,         GBAR, L, VTR_),
287         PAN_V6(A8B8G8R8_UINT,           RGBA8UI,         ABGR, L, VTR_),
288         PAN_V6(R8_UINT,                 R8UI,            R001, L, VTR_),
289         PAN_V6(R16_UINT,                R16UI,           R001, L, VTR_),
290         PAN_V6(R32_UINT,                R32UI,           R001, L, VTR_),
291         PAN_V6(R8G8_UINT,               RG8UI,           RG01, L, VTR_),
292         PAN_V6(R16G16_UINT,             RG16UI,          RG01, L, VTR_),
293         PAN_V6(R32G32_UINT,             RG32UI,          RG01, L, VTR_),
294         PAN_V6(R8G8B8_UINT,             RGB8UI,          RGB1, L, VTR_),
295         PAN_V6(R16G16B16_UINT,          RGB16UI,         RGB1, L, VTR_),
296         PAN_V6(R32G32B32_UINT,          RGB32UI,         RGB1, L, VTR_),
297         PAN_V6(R8G8B8A8_UINT,           RGBA8UI,         RGBA, L, VTR_),
298         PAN_V6(R16G16B16A16_UINT,       RGBA16UI,        RGBA, L, VTR_),
299         PAN_V6(R32G32B32A32_UINT,       RGBA32UI,        RGBA, L, VTR_),
300         PAN_V6(R32_FLOAT,               R32F,            R001, L, VTR_),
301         PAN_V6(R32G32_FLOAT,            RG32F,           RG01, L, VTR_),
302         PAN_V6(R32G32B32_FLOAT,         RGB32F,          RGB1, L, VTR_),
303         PAN_V6(R32G32B32A32_FLOAT,      RGBA32F,         RGBA, L, VTR_),
304         PAN_V6(R8_UNORM,                R8_UNORM,        R001, L, VTR_),
305         PAN_V6(R16_UNORM,               R16_UNORM,       R001, L, VTR_),
306         PAN_V6(R32_UNORM,               R32_UNORM,       R001, L, VTR_),
307         PAN_V6(R8G8_UNORM,              RG8_UNORM,       RG01, L, VTR_),
308         PAN_V6(R16G16_UNORM,            RG16_UNORM,      RG01, L, VTR_),
309         PAN_V6(R32G32_UNORM,            RG32_UNORM,      RG01, L, VTR_),
310         PAN_V6(R8G8B8_UNORM,            RGB8_UNORM,      RGB1, L, VTR_),
311         PAN_V6(R16G16B16_UNORM,         RGB16_UNORM,     RGB1, L, VTR_),
312         PAN_V6(R32G32B32_UNORM,         RGB32_UNORM,     RGB1, L, VTR_),
313         PAN_V6(R4G4B4A4_UNORM,          RGBA4_UNORM,     RGBA, L, VTR_),
314         PAN_V6(R16G16B16A16_UNORM,      RGBA16_UNORM,    RGBA, L, VTR_),
315         PAN_V6(R32G32B32A32_UNORM,      RGBA32_UNORM,    RGBA, L, VTR_),
316         PAN_V6(B8G8R8A8_UNORM,          RGBA8_UNORM,     BGRA, L, VTR_),
317         PAN_V6(B8G8R8X8_UNORM,          RGBA8_UNORM,     BGR1, L, VTR_),
318         PAN_V6(A8R8G8B8_UNORM,          RGBA8_UNORM,     GBAR, L, VTR_),
319         PAN_V6(X8R8G8B8_UNORM,          RGBA8_UNORM,     GBA1, L, VTR_),
320         PAN_V6(A8B8G8R8_UNORM,          RGBA8_UNORM,     ABGR, L, VTR_),
321         PAN_V6(X8B8G8R8_UNORM,          RGBA8_UNORM,     ABG1, L, VTR_),
322         PAN_V6(R8G8B8X8_UNORM,          RGBA8_UNORM,     RGB1, L, VTR_),
323         PAN_V6(R8G8B8A8_UNORM,          RGBA8_UNORM,     RGBA, L, VTR_),
324         PAN_V6(R8G8B8X8_SNORM,          RGBA8_SNORM,     RGB1, L, VT__),
325         PAN_V6(R8G8B8X8_SRGB,           RGBA8_UNORM,     RGB1, S, VTR_),
326         PAN_V6(R8G8B8X8_UINT,           RGBA8UI,         RGB1, L, VTR_),
327         PAN_V6(R8G8B8X8_SINT,           RGBA8I,          RGB1, L, VTR_),
328         PAN_V6(L8_UNORM,                R8_UNORM,        RRR1, L, VTR_),
329         PAN_V6(A8_UNORM,                R8_UNORM,        000R, L, VTR_),
330         PAN_V6(I8_UNORM,                R8_UNORM,        RRRR, L, VTR_),
331         PAN_V6(L8A8_UNORM,              RG8_UNORM,       RRRG, L, VTR_),
332         PAN_V6(L16_UNORM,               R16_UNORM,       RRR1, L, VTR_),
333         PAN_V6(A16_UNORM,               R16_UNORM,       000R, L, VTR_),
334         PAN_V6(I16_UNORM,               R16_UNORM,       RRRR, L, VTR_),
335         PAN_V6(L8_SNORM,                R8_SNORM,        RRR1, L, VT__),
336         PAN_V6(A8_SNORM,                R8_SNORM,        000R, L, VT__),
337         PAN_V6(I8_SNORM,                R8_SNORM,        RRRR, L, VT__),
338         PAN_V6(L16_SNORM,               R16_SNORM,       RRR1, L, VT__),
339         PAN_V6(A16_SNORM,               R16_SNORM,       000R, L, VT__),
340         PAN_V6(I16_SNORM,               R16_SNORM,       RRRR, L, VT__),
341         PAN_V6(L16_FLOAT,               R16F,            RRR1, L, VTR_),
342         PAN_V6(A16_FLOAT,               R16F,            000R, L, VTR_),
343         PAN_V6(I16_FLOAT,               RG16F,           RRRR, L, VTR_),
344         PAN_V6(L8_SRGB,                 R8_UNORM,        RRR1, S, VTR_),
345         PAN_V6(R8_SRGB,                 R8_UNORM,        R001, S, VTR_),
346         PAN_V6(L8A8_SRGB,               RG8_UNORM,       RRRG, S, VTR_),
347         PAN_V6(R8G8_SRGB,               RG8_UNORM,       RG01, S, VTR_),
348         PAN_V6(R8G8B8_SRGB,             RGB8_UNORM,      RGB1, S, VTR_),
349         PAN_V6(B8G8R8_SRGB,             RGB8_UNORM,      BGR1, S, VTR_),
350         PAN_V6(R8G8B8A8_SRGB,           RGBA8_UNORM,     RGBA, S, VTR_),
351         PAN_V6(A8B8G8R8_SRGB,           RGBA8_UNORM,     ABGR, S, VTR_),
352         PAN_V6(X8B8G8R8_SRGB,           RGBA8_UNORM,     ABG1, S, VTR_),
353         PAN_V6(B8G8R8A8_SRGB,           RGBA8_UNORM,     BGRA, S, VTR_),
354         PAN_V6(B8G8R8X8_SRGB,           RGBA8_UNORM,     BGR1, S, VTR_),
355         PAN_V6(A8R8G8B8_SRGB,           RGBA8_UNORM,     GBAR, S, VTR_),
356         PAN_V6(X8R8G8B8_SRGB,           RGBA8_UNORM,     GBA1, S, VTR_),
357         PAN_V6(R8_SINT,                 R8I,             R001, L, VTR_),
358         PAN_V6(R16_SINT,                R16I,            R001, L, VTR_),
359         PAN_V6(R32_SINT,                R32I,            R001, L, VTR_),
360         PAN_V6(R16_FLOAT,               R16F,            R001, L, VTR_),
361         PAN_V6(R8G8_SINT,               RG8I,            RG01, L, VTR_),
362         PAN_V6(R16G16_SINT,             RG16I,           RG01, L, VTR_),
363         PAN_V6(R32G32_SINT,             RG32I,           RG01, L, VTR_),
364         PAN_V6(R16G16_FLOAT,            RG16F,           RG01, L, VTR_),
365         PAN_V6(R8G8B8_SINT,             RGB8I,           RGB1, L, VTR_),
366         PAN_V6(R16G16B16_SINT,          RGB16I,          RGB1, L, VTR_),
367         PAN_V6(R32G32B32_SINT,          RGB32I,          RGB1, L, VTR_),
368         PAN_V6(R16G16B16_FLOAT,         RGB16F,          RGB1, L, VTR_),
369         PAN_V6(R8G8B8A8_SINT,           RGBA8I,          RGBA, L, VTR_),
370         PAN_V6(R16G16B16A16_SINT,       RGBA16I,         RGBA, L, VTR_),
371         PAN_V6(R32G32B32A32_SINT,       RGBA32I,         RGBA, L, VTR_),
372         PAN_V6(R16G16B16A16_FLOAT,      RGBA16F,         RGBA, L, VTR_),
373         PAN_V6(R16G16B16X16_UNORM,      RGBA16_UNORM,    RGB1, L, VTR_),
374         PAN_V6(R16G16B16X16_SNORM,      RGBA16_SNORM,    RGB1, L, VT__),
375         PAN_V6(R16G16B16X16_FLOAT,      RGBA16F,         RGB1, L, VTR_),
376         PAN_V6(R16G16B16X16_UINT,       RGBA16UI,        RGB1, L, VTR_),
377         PAN_V6(R16G16B16X16_SINT,       RGBA16I,         RGB1, L, VTR_),
378         PAN_V6(R32G32B32X32_FLOAT,      RGBA32F,         RGB1, L, VTR_),
379         PAN_V6(R32G32B32X32_UINT,       RGBA32UI,        RGB1, L, VTR_),
380         PAN_V6(R32G32B32X32_SINT,       RGBA32I,         RGB1, L, VTR_),
381 };
382 
383 const struct panfrost_format panfrost_pipe_format_v7[PIPE_FORMAT_COUNT] = {
384         PAN_V7(ETC1_RGB8,               ETC2_RGB8,       RGB1, L, _T__),
385         PAN_V7(ETC2_RGB8,               ETC2_RGB8,       RGB1, L, _T__),
386         PAN_V7(ETC2_SRGB8,              ETC2_RGB8,       RGB1, S, _T__),
387         PAN_V7(ETC2_R11_UNORM,          ETC2_R11_UNORM,  RGB1, L, _T__),
388         PAN_V7(ETC2_RGBA8,              ETC2_RGBA8,      RGBA, L, _T__),
389         PAN_V7(ETC2_SRGBA8,             ETC2_RGBA8,      RGBA, S, _T__),
390         PAN_V7(ETC2_RG11_UNORM,         ETC2_RG11_UNORM, RGB1, L, _T__),
391         PAN_V7(ETC2_R11_SNORM,          ETC2_R11_SNORM,  RGB1, L, _T__),
392         PAN_V7(ETC2_RG11_SNORM,         ETC2_RG11_SNORM, RGB1, L, _T__),
393         PAN_V7(ETC2_RGB8A1,             ETC2_RGB8A1,     RGBA, L, _T__),
394         PAN_V7(ETC2_SRGB8A1,            ETC2_RGB8A1,     RGBA, S, _T__),
395         PAN_V7(DXT1_RGB,                BC1_UNORM,       RGB1, L, _T__),
396         PAN_V7(DXT1_RGBA,               BC1_UNORM,       RGBA, L, _T__),
397         PAN_V7(DXT1_SRGB,               BC1_UNORM,       RGB1, S, _T__),
398         PAN_V7(DXT1_SRGBA,              BC1_UNORM,       RGBA, S, _T__),
399         PAN_V7(DXT3_RGBA,               BC2_UNORM,       RGBA, L, _T__),
400         PAN_V7(DXT3_SRGBA,              BC2_UNORM,       RGBA, S, _T__),
401         PAN_V7(DXT5_RGBA,               BC3_UNORM,       RGBA, L, _T__),
402         PAN_V7(DXT5_SRGBA,              BC3_UNORM,       RGBA, S, _T__),
403         PAN_V7(RGTC1_UNORM,             BC4_UNORM,       RGB1, L, _T__),
404         PAN_V7(RGTC1_SNORM,             BC4_SNORM,       RGB1, L, _T__),
405         PAN_V7(RGTC2_UNORM,             BC5_UNORM,       RGB1, L, _T__),
406         PAN_V7(RGTC2_SNORM,             BC5_SNORM,       RGB1, L, _T__),
407         PAN_V7(BPTC_RGB_FLOAT,          BC6H_SF16,       RGB1, L, _T__),
408         PAN_V7(BPTC_RGB_UFLOAT,         BC6H_UF16,       RGB1, L, _T__),
409         PAN_V7(BPTC_RGBA_UNORM,         BC7_UNORM,       RGBA, L, _T__),
410         PAN_V7(BPTC_SRGBA,              BC7_UNORM,       RGBA, S, _T__),
411         PAN_V7(ASTC_4x4,                ASTC_2D_HDR,     RGBA, L, _T__),
412         PAN_V7(ASTC_5x4,                ASTC_2D_HDR,     RGBA, L, _T__),
413         PAN_V7(ASTC_5x5,                ASTC_2D_HDR,     RGBA, L, _T__),
414         PAN_V7(ASTC_6x5,                ASTC_2D_HDR,     RGBA, L, _T__),
415         PAN_V7(ASTC_6x6,                ASTC_2D_HDR,     RGBA, L, _T__),
416         PAN_V7(ASTC_8x5,                ASTC_2D_HDR,     RGBA, L, _T__),
417         PAN_V7(ASTC_8x6,                ASTC_2D_HDR,     RGBA, L, _T__),
418         PAN_V7(ASTC_8x8,                ASTC_2D_HDR,     RGBA, L, _T__),
419         PAN_V7(ASTC_10x5,               ASTC_2D_HDR,     RGBA, L, _T__),
420         PAN_V7(ASTC_10x6,               ASTC_2D_HDR,     RGBA, L, _T__),
421         PAN_V7(ASTC_10x8,               ASTC_2D_HDR,     RGBA, L, _T__),
422         PAN_V7(ASTC_10x10,              ASTC_2D_HDR,     RGBA, L, _T__),
423         PAN_V7(ASTC_12x10,              ASTC_2D_HDR,     RGBA, L, _T__),
424         PAN_V7(ASTC_12x12,              ASTC_2D_HDR,     RGBA, L, _T__),
425         PAN_V7(ASTC_4x4_SRGB,           ASTC_2D_LDR,     RGBA, S, _T__),
426         PAN_V7(ASTC_5x4_SRGB,           ASTC_2D_LDR,     RGBA, S, _T__),
427         PAN_V7(ASTC_5x5_SRGB,           ASTC_2D_LDR,     RGBA, S, _T__),
428         PAN_V7(ASTC_6x5_SRGB,           ASTC_2D_LDR,     RGBA, S, _T__),
429         PAN_V7(ASTC_6x6_SRGB,           ASTC_2D_LDR,     RGBA, S, _T__),
430         PAN_V7(ASTC_8x5_SRGB,           ASTC_2D_LDR,     RGBA, S, _T__),
431         PAN_V7(ASTC_8x6_SRGB,           ASTC_2D_LDR,     RGBA, S, _T__),
432         PAN_V7(ASTC_8x8_SRGB,           ASTC_2D_LDR,     RGBA, S, _T__),
433         PAN_V7(ASTC_10x5_SRGB,          ASTC_2D_LDR,     RGBA, S, _T__),
434         PAN_V7(ASTC_10x6_SRGB,          ASTC_2D_LDR,     RGBA, S, _T__),
435         PAN_V7(ASTC_10x8_SRGB,          ASTC_2D_LDR,     RGBA, S, _T__),
436         PAN_V7(ASTC_10x10_SRGB,         ASTC_2D_LDR,     RGBA, S, _T__),
437         PAN_V7(ASTC_12x10_SRGB,         ASTC_2D_LDR,     RGBA, S, _T__),
438         PAN_V7(ASTC_12x12_SRGB,         ASTC_2D_LDR,     RGBA, S, _T__),
439         PAN_V7(B5G6R5_UNORM,            RGB565,          BGR1, L, VTR_),
440         PAN_V7(B5G5R5X1_UNORM,          RGB5_A1_UNORM,   BGR1, L, VT__),
441         PAN_V7(R5G5B5A1_UNORM,          RGB5_A1_UNORM,   RGBA, L, VTR_),
442         PAN_V7(R10G10B10X2_UNORM,       RGB10_A2_UNORM,  RGB1, L, VTR_),
443         PAN_V7(B10G10R10X2_UNORM,       RGB10_A2_UNORM,  BGR1, L, VTR_),
444         PAN_V7(R10G10B10A2_UNORM,       RGB10_A2_UNORM,  RGBA, L, VTR_),
445         PAN_V7(B10G10R10A2_UNORM,       RGB10_A2_UNORM,  BGRA, L, VTR_),
446         PAN_V7(R10G10B10X2_SNORM,       RGB10_A2_SNORM,  RGB1, L, VT__),
447         PAN_V7(R10G10B10A2_SNORM,       RGB10_A2_SNORM,  RGBA, L, VT__),
448         PAN_V7(B10G10R10A2_SNORM,       RGB10_A2_SNORM,  BGRA, L, VT__),
449         PAN_V7(R10G10B10A2_UINT,        RGB10_A2UI,      RGBA, L, VTR_),
450         PAN_V7(B10G10R10A2_UINT,        RGB10_A2UI,      BGRA, L, VTR_),
451         PAN_V7(R10G10B10A2_USCALED,     RGB10_A2UI,      RGBA, L, VTR_),
452         PAN_V7(B10G10R10A2_USCALED,     RGB10_A2UI,      BGRA, L, VTR_),
453         PAN_V7(R10G10B10A2_SINT,        RGB10_A2I,       RGBA, L, VTR_),
454         PAN_V7(B10G10R10A2_SINT,        RGB10_A2I,       BGRA, L, VTR_),
455         PAN_V7(R10G10B10A2_SSCALED,     RGB10_A2I,       RGBA, L, VTR_),
456         PAN_V7(B10G10R10A2_SSCALED,     RGB10_A2I,       BGRA, L, VTR_),
457         PAN_V7(R8_SSCALED,              R8I,             RGB1, L, V___),
458         PAN_V7(R8G8_SSCALED,            RG8I,            RGB1, L, V___),
459         PAN_V7(R8G8B8_SSCALED,          RGB8I,           RGB1, L, V___),
460         PAN_V7(B8G8R8_SSCALED,          RGB8I,           BGR1, L, V___),
461         PAN_V7(R8G8B8A8_SSCALED,        RGBA8I,          RGBA, L, V___),
462         PAN_V7(B8G8R8A8_SSCALED,        RGBA8I,          BGRA, L, V___),
463         PAN_V7(A8B8G8R8_SSCALED,        RGBA8I,          ABGR, L, V___),
464         PAN_V7(R8_USCALED,              R8UI,            RGB1, L, V___),
465         PAN_V7(R8G8_USCALED,            RG8UI,           RGB1, L, V___),
466         PAN_V7(R8G8B8_USCALED,          RGB8UI,          RGB1, L, V___),
467         PAN_V7(B8G8R8_USCALED,          RGB8UI,          BGR1, L, V___),
468         PAN_V7(R8G8B8A8_USCALED,        RGBA8UI,         RGBA, L, V___),
469         PAN_V7(B8G8R8A8_USCALED,        RGBA8UI,         BGRA, L, V___),
470         PAN_V7(A8B8G8R8_USCALED,        RGBA8UI,         ABGR, L, V___),
471         PAN_V7(R16_USCALED,             R16UI,           RGB1, L, V___),
472         PAN_V7(R16G16_USCALED,          RG16UI,          RGB1, L, V___),
473         PAN_V7(R16G16B16_USCALED,       RGB16UI,         RGB1, L, V___),
474         PAN_V7(R16G16B16A16_USCALED,    RGBA16UI,        RGBA, L, V___),
475         PAN_V7(R16_SSCALED,             R16I,            RGB1, L, V___),
476         PAN_V7(R16G16_SSCALED,          RG16I,           RGB1, L, V___),
477         PAN_V7(R16G16B16_SSCALED,       RGB16I,          RGB1, L, V___),
478         PAN_V7(R16G16B16A16_SSCALED,    RGBA16I,         RGBA, L, V___),
479         PAN_V7(R32_USCALED,             R32UI,           RGB1, L, V___),
480         PAN_V7(R32G32_USCALED,          RG32UI,          RGB1, L, V___),
481         PAN_V7(R32G32B32_USCALED,       RGB32UI,         RGB1, L, V___),
482         PAN_V7(R32G32B32A32_USCALED,    RGBA32UI,        RGBA, L, V___),
483         PAN_V7(R32_SSCALED,             R32I,            RGB1, L, V___),
484         PAN_V7(R32G32_SSCALED,          RG32I,           RGB1, L, V___),
485         PAN_V7(R32G32B32_SSCALED,       RGB32I,          RGB1, L, V___),
486         PAN_V7(R32G32B32A32_SSCALED,    RGBA32I,         RGBA, L, V___),
487         PAN_V7(R3G3B2_UNORM,            RGB332_UNORM,    RGB1, L, VT__),
488         PAN_V7(Z16_UNORM,               R16_UNORM,       RGBA, L, _T_Z),
489         PAN_V7(Z24_UNORM_S8_UINT,       Z24X8_UNORM,     RGBA, L, _T_Z),
490         PAN_V7(Z24X8_UNORM,             Z24X8_UNORM,     RGBA, L, _T_Z),
491         PAN_V7(Z32_FLOAT,               R32F,            RGBA, L, _T_Z),
492         PAN_V7(Z32_FLOAT_S8X24_UINT,    R32F,            RGBA, L, _T_Z),
493         PAN_V7(X32_S8X24_UINT,          S8X24,           GRBA, L, _T__),
494         PAN_V7(X24S8_UINT,              TILEBUFFER_NATIVE /* XXX: Deduplicate enum */, GRBA, L, _T_Z),
495         PAN_V7(S8_UINT,                 S8,              GRBA, L, _T__),
496         PAN_V7(R32_FIXED,               R32_FIXED,       RGB1, L, V___),
497         PAN_V7(R32G32_FIXED,            RG32_FIXED,      RGB1, L, V___),
498         PAN_V7(R32G32B32_FIXED,         RGB32_FIXED,     RGB1, L, V___),
499         PAN_V7(R32G32B32A32_FIXED,      RGBA32_FIXED,    RGBA, L, V___),
500         PAN_V7(R11G11B10_FLOAT,         R11F_G11F_B10F,  RGB1, L, VTR_),
501         PAN_V7(R9G9B9E5_FLOAT,          R9F_G9F_B9F_E5F, RGB1, L, VT__),
502         PAN_V7(R8_SNORM,                R8_SNORM,        RGB1, L, VT__),
503         PAN_V7(R16_SNORM,               R16_SNORM,       RGB1, L, VT__),
504         PAN_V7(R32_SNORM,               R32_SNORM,       RGB1, L, VT__),
505         PAN_V7(R8G8_SNORM,              RG8_SNORM,       RGB1, L, VT__),
506         PAN_V7(R16G16_SNORM,            RG16_SNORM,      RGB1, L, VT__),
507         PAN_V7(R32G32_SNORM,            RG32_SNORM,      RGB1, L, VT__),
508         PAN_V7(R8G8B8_SNORM,            RGB8_SNORM,      RGB1, L, VT__),
509         PAN_V7(R16G16B16_SNORM,         RGB16_SNORM,     RGB1, L, VT__),
510         PAN_V7(R32G32B32_SNORM,         RGB32_SNORM,     RGB1, L, VT__),
511         PAN_V7(R8G8B8A8_SNORM,          RGBA8_SNORM,     RGBA, L, VT__),
512         PAN_V7(R16G16B16A16_SNORM,      RGBA16_SNORM,    RGBA, L, VT__),
513         PAN_V7(R32G32B32A32_SNORM,      RGBA32_SNORM,    RGBA, L, VT__),
514         /* A8_SINT dropped on v7 */
515         PAN_V7(I8_SINT,                 R8I,             RRRR, L, VTR_),
516         PAN_V7(L8_SINT,                 R8I,             RRR1, L, VTR_),
517         /* A8_UINT dropped on v7 */
518         PAN_V7(I8_UINT,                 R8UI,            RRRR, L, VTR_),
519         PAN_V7(L8_UINT,                 R8UI,            RRR1, L, VTR_),
520         /* A16_SINT dropped on v7 */
521         PAN_V7(I16_SINT,                R16I,            RRRR, L, VTR_),
522         PAN_V7(L16_SINT,                R16I,            RRR1, L, VTR_),
523         /* A16_UINT dropped on v7 */
524         PAN_V7(I16_UINT,                R16UI,           RRRR, L, VTR_),
525         PAN_V7(L16_UINT,                R16UI,           RRR1, L, VTR_),
526         /* A32_SINT dropped on v7 */
527         PAN_V7(I32_SINT,                R32I,            RRRR, L, VTR_),
528         PAN_V7(L32_SINT,                R32I,            RRR1, L, VTR_),
529         /* A32_UINT dropped on v7 */
530         PAN_V7(I32_UINT,                R32UI,           RRRR, L, VTR_),
531         PAN_V7(L32_UINT,                R32UI,           RRR1, L, VTR_),
532         PAN_V7(B8G8R8_UINT,             RGB8UI,          BGR1, L, VTR_),
533         PAN_V7(B8G8R8A8_UINT,           RGBA8UI,         BGRA, L, VTR_),
534         PAN_V7(B8G8R8_SINT,             RGB8I,           BGR1, L, VTR_),
535         PAN_V7(B8G8R8A8_SINT,           RGBA8I,          BGRA, L, VTR_),
536         PAN_V7(A8R8G8B8_UINT,           RGBA8UI,         ARGB, L, VTR_),
537         PAN_V7(A8B8G8R8_UINT,           RGBA8UI,         ABGR, L, VTR_),
538         PAN_V7(R8_UINT,                 R8UI,            RGB1, L, VTR_),
539         PAN_V7(R16_UINT,                R16UI,           RGB1, L, VTR_),
540         PAN_V7(R32_UINT,                R32UI,           RGB1, L, VTR_),
541         PAN_V7(R8G8_UINT,               RG8UI,           RGB1, L, VTR_),
542         PAN_V7(R16G16_UINT,             RG16UI,          RGB1, L, VTR_),
543         PAN_V7(R32G32_UINT,             RG32UI,          RGB1, L, VTR_),
544         PAN_V7(R8G8B8_UINT,             RGB8UI,          RGB1, L, VTR_),
545         PAN_V7(R16G16B16_UINT,          RGB16UI,         RGB1, L, VTR_),
546         PAN_V7(R32G32B32_UINT,          RGB32UI,         RGB1, L, VTR_),
547         PAN_V7(R8G8B8A8_UINT,           RGBA8UI,         RGBA, L, VTR_),
548         PAN_V7(R16G16B16A16_UINT,       RGBA16UI,        RGBA, L, VTR_),
549         PAN_V7(R32G32B32A32_UINT,       RGBA32UI,        RGBA, L, VTR_),
550         PAN_V7(R32_FLOAT,               R32F,            RGB1, L, VTR_),
551         PAN_V7(R32G32_FLOAT,            RG32F,           RGB1, L, VTR_),
552         PAN_V7(R32G32B32_FLOAT,         RGB32F,          RGB1, L, VTR_),
553         PAN_V7(R32G32B32A32_FLOAT,      RGBA32F,         RGBA, L, VTR_),
554         PAN_V7(R8_UNORM,                R8_UNORM,        RGB1, L, VTR_),
555         PAN_V7(R16_UNORM,               R16_UNORM,       RGB1, L, VTR_),
556         PAN_V7(R32_UNORM,               R32_UNORM,       RGB1, L, VTR_),
557         PAN_V7(R8G8_UNORM,              RG8_UNORM,       RGB1, L, VTR_),
558         PAN_V7(R16G16_UNORM,            RG16_UNORM,      RGB1, L, VTR_),
559         PAN_V7(R32G32_UNORM,            RG32_UNORM,      RGB1, L, VTR_),
560         PAN_V7(R8G8B8_UNORM,            RGB8_UNORM,      RGB1, L, VTR_),
561         PAN_V7(R16G16B16_UNORM,         RGB16_UNORM,     RGB1, L, VTR_),
562         PAN_V7(R32G32B32_UNORM,         RGB32_UNORM,     RGB1, L, VTR_),
563         PAN_V7(R4G4B4A4_UNORM,          RGBA4_UNORM,     RGBA, L, VTR_),
564         PAN_V7(R16G16B16A16_UNORM,      RGBA16_UNORM,    RGBA, L, VTR_),
565         PAN_V7(R32G32B32A32_UNORM,      RGBA32_UNORM,    RGBA, L, VTR_),
566         PAN_V7(B8G8R8A8_UNORM,          RGBA8_UNORM,     BGRA, L, VTR_),
567         PAN_V7(B8G8R8X8_UNORM,          RGBA8_UNORM,     BGR1, L, VTR_),
568         PAN_V7(A8R8G8B8_UNORM,          RGBA8_UNORM,     ARGB, L, VTR_),
569         PAN_V7(X8R8G8B8_UNORM,          RGBA8_UNORM,     1RGB, L, VTR_),
570         PAN_V7(A8B8G8R8_UNORM,          RGBA8_UNORM,     ABGR, L, VTR_),
571         PAN_V7(X8B8G8R8_UNORM,          RGBA8_UNORM,     1BGR, L, VTR_),
572         PAN_V7(R8G8B8X8_UNORM,          RGBA8_UNORM,     RGB1, L, VTR_),
573         PAN_V7(R8G8B8A8_UNORM,          RGBA8_UNORM,     RGBA, L, VTR_),
574         PAN_V7(R8G8B8X8_SNORM,          RGBA8_SNORM,     RGB1, L, VT__),
575         PAN_V7(R8G8B8X8_SRGB,           RGBA8_UNORM,     RGB1, S, VTR_),
576         PAN_V7(R8G8B8X8_UINT,           RGBA8UI,         RGB1, L, VTR_),
577         PAN_V7(R8G8B8X8_SINT,           RGBA8I,          RGB1, L, VTR_),
578         PAN_V7(L8_UNORM,                R8_UNORM,        RRR1, L, VTR_),
579         PAN_V7(A8_UNORM,                A8_UNORM,        000A, L, VTR_),
580         PAN_V7(I8_UNORM,                R8_UNORM,        RRRR, L, VTR_),
581         PAN_V7(L8A8_UNORM,              R8A8_UNORM,      RRRA, L, VTR_),
582         PAN_V7(L16_UNORM,               R16_UNORM,       RRR1, L, VTR_),
583         /* A16_UNORM dropped on v7 */
584         PAN_V7(I16_UNORM,               R16_UNORM,       RRRR, L, VTR_),
585         PAN_V7(L8_SNORM,                R8_SNORM,        RRR1, L, VT__),
586         /* A8_SNORM dropped on v7 */
587         PAN_V7(I8_SNORM,                R8_SNORM,        RRRR, L, VT__),
588         PAN_V7(L16_SNORM,               R16_SNORM,       RRR1, L, VT__),
589         /* A16_SNORM dropped on v7 */
590         PAN_V7(I16_SNORM,               R16_SNORM,       RRRR, L, VT__),
591         PAN_V7(L16_FLOAT,               R16F,            RRR1, L, VTR_),
592         /* A16_FLOAT dropped on v7 */
593         PAN_V7(I16_FLOAT,               RG16F,           RRRR, L, VTR_),
594         PAN_V7(L8_SRGB,                 R8_UNORM,        RRR1, S, VTR_),
595         PAN_V7(R8_SRGB,                 R8_UNORM,        RGB1, S, VTR_),
596         PAN_V7(L8A8_SRGB,               R8A8_UNORM,      RRRA, S, VTR_),
597         PAN_V7(R8G8_SRGB,               RG8_UNORM,       RGB1, S, VTR_),
598         PAN_V7(R8G8B8_SRGB,             RGB8_UNORM,      RGB1, S, VTR_),
599         PAN_V7(B8G8R8_SRGB,             RGB8_UNORM,      BGR1, S, VTR_),
600         PAN_V7(R8G8B8A8_SRGB,           RGBA8_UNORM,     RGBA, S, VTR_),
601         PAN_V7(A8B8G8R8_SRGB,           RGBA8_UNORM,     ABGR, S, VTR_),
602         PAN_V7(X8B8G8R8_SRGB,           RGBA8_UNORM,     1BGR, S, VTR_),
603         PAN_V7(B8G8R8A8_SRGB,           RGBA8_UNORM,     BGRA, S, VTR_),
604         PAN_V7(B8G8R8X8_SRGB,           RGBA8_UNORM,     BGR1, S, VTR_),
605         PAN_V7(A8R8G8B8_SRGB,           RGBA8_UNORM,     ARGB, S, VTR_),
606         PAN_V7(X8R8G8B8_SRGB,           RGBA8_UNORM,     1RGB, S, VTR_),
607         PAN_V7(R8_SINT,                 R8I,             RGB1, L, VTR_),
608         PAN_V7(R16_SINT,                R16I,            RGB1, L, VTR_),
609         PAN_V7(R32_SINT,                R32I,            RGB1, L, VTR_),
610         PAN_V7(R16_FLOAT,               R16F,            RGB1, L, VTR_),
611         PAN_V7(R8G8_SINT,               RG8I,            RGB1, L, VTR_),
612         PAN_V7(R16G16_SINT,             RG16I,           RGB1, L, VTR_),
613         PAN_V7(R32G32_SINT,             RG32I,           RGB1, L, VTR_),
614         PAN_V7(R16G16_FLOAT,            RG16F,           RGB1, L, VTR_),
615         PAN_V7(R8G8B8_SINT,             RGB8I,           RGB1, L, VTR_),
616         PAN_V7(R16G16B16_SINT,          RGB16I,          RGB1, L, VTR_),
617         PAN_V7(R32G32B32_SINT,          RGB32I,          RGB1, L, VTR_),
618         PAN_V7(R16G16B16_FLOAT,         RGB16F,          RGB1, L, VTR_),
619         PAN_V7(R8G8B8A8_SINT,           RGBA8I,          RGBA, L, VTR_),
620         PAN_V7(R16G16B16A16_SINT,       RGBA16I,         RGBA, L, VTR_),
621         PAN_V7(R32G32B32A32_SINT,       RGBA32I,         RGBA, L, VTR_),
622         PAN_V7(R16G16B16A16_FLOAT,      RGBA16F,         RGBA, L, VTR_),
623         PAN_V7(R16G16B16X16_UNORM,      RGBA16_UNORM,    RGB1, L, VTR_),
624         PAN_V7(R16G16B16X16_SNORM,      RGBA16_SNORM,    RGB1, L, VT__),
625         PAN_V7(R16G16B16X16_FLOAT,      RGBA16F,         RGB1, L, VTR_),
626         PAN_V7(R16G16B16X16_UINT,       RGBA16UI,        RGB1, L, VTR_),
627         PAN_V7(R16G16B16X16_SINT,       RGBA16I,         RGB1, L, VTR_),
628         PAN_V7(R32G32B32X32_FLOAT,      RGBA32F,         RGB1, L, VTR_),
629         PAN_V7(R32G32B32X32_UINT,       RGBA32UI,        RGB1, L, VTR_),
630         PAN_V7(R32G32B32X32_SINT,       RGBA32I,         RGB1, L, VTR_),
631 };
632 
633 /* Translate a PIPE swizzle quad to a 12-bit Mali swizzle code. PIPE
634  * swizzles line up with Mali swizzles for the XYZW01, but PIPE swizzles have
635  * an additional "NONE" field that we have to mask out to zero. Additionally,
636  * PIPE swizzles are sparse but Mali swizzles are packed */
637 
638 unsigned
panfrost_translate_swizzle_4(const unsigned char swizzle[4])639 panfrost_translate_swizzle_4(const unsigned char swizzle[4])
640 {
641         unsigned out = 0;
642 
643         for (unsigned i = 0; i < 4; ++i) {
644                 unsigned translated = (swizzle[i] > PIPE_SWIZZLE_1) ? PIPE_SWIZZLE_0 : swizzle[i];
645                 out |= (translated << (3*i));
646         }
647 
648         return out;
649 }
650 
651 void
panfrost_invert_swizzle(const unsigned char * in,unsigned char * out)652 panfrost_invert_swizzle(const unsigned char *in, unsigned char *out)
653 {
654         /* First, default to all zeroes to prevent uninitialized junk */
655 
656         for (unsigned c = 0; c < 4; ++c)
657                 out[c] = PIPE_SWIZZLE_0;
658 
659         /* Now "do" what the swizzle says */
660 
661         for (unsigned c = 0; c < 4; ++c) {
662                 unsigned char i = in[c];
663 
664                 /* Who cares? */
665                 assert(PIPE_SWIZZLE_X == 0);
666                 if (i > PIPE_SWIZZLE_W)
667                         continue;
668 
669                 /* Invert */
670                 unsigned idx = i - PIPE_SWIZZLE_X;
671                 out[idx] = PIPE_SWIZZLE_X + c;
672         }
673 }
674 
675 enum mali_format
panfrost_format_to_bifrost_blend(const struct util_format_description * desc,bool dither)676 panfrost_format_to_bifrost_blend(const struct util_format_description *desc, bool dither)
677 {
678         struct pan_blendable_format fmt = panfrost_blend_format(desc->format);
679 
680         /* Formats requiring blend shaders are stored raw in the tilebuffer */
681         if (!fmt.internal)
682                 return desc->format;
683 
684         /* Else, pick the pixel format matching the tilebuffer format */
685         switch (fmt.internal) {
686         case MALI_COLOR_BUFFER_INTERNAL_FORMAT_R8G8B8A8:
687                 return MALI_RGBA8_TB;
688 
689         case MALI_COLOR_BUFFER_INTERNAL_FORMAT_R10G10B10A2:
690                 return MALI_RGB10_A2_TB;
691 
692         case MALI_COLOR_BUFFER_INTERNAL_FORMAT_R8G8B8A2:
693                 return dither ? MALI_RGB8_A2_AU : MALI_RGB8_A2_PU;
694 
695         case MALI_COLOR_BUFFER_INTERNAL_FORMAT_R4G4B4A4:
696                 return dither ? MALI_RGBA4_AU : MALI_RGBA4_PU;
697 
698         case MALI_COLOR_BUFFER_INTERNAL_FORMAT_R5G6B5A0:
699                 return dither ? MALI_R5G6B5_AU : MALI_R5G6B5_PU;
700 
701         case MALI_COLOR_BUFFER_INTERNAL_FORMAT_R5G5B5A1:
702                 return dither ? MALI_RGB5_A1_AU : MALI_RGB5_A1_PU;
703         default:
704                 unreachable("invalid internal blendable");
705         }
706 }
707 
708 enum mali_z_internal_format
panfrost_get_z_internal_format(enum pipe_format fmt)709 panfrost_get_z_internal_format(enum pipe_format fmt)
710 {
711          switch (fmt) {
712          case PIPE_FORMAT_Z16_UNORM:
713          case PIPE_FORMAT_Z16_UNORM_S8_UINT:
714                 return MALI_Z_INTERNAL_FORMAT_D16;
715          case PIPE_FORMAT_Z24_UNORM_S8_UINT:
716          case PIPE_FORMAT_Z24X8_UNORM:
717                 return MALI_Z_INTERNAL_FORMAT_D24;
718          case PIPE_FORMAT_Z32_FLOAT:
719          case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT:
720                 return MALI_Z_INTERNAL_FORMAT_D32;
721          default:
722                 unreachable("Unsupported depth/stencil format.");
723          }
724 }
725