• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2016 Etnaviv Project
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, sub license,
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
12  * next paragraph) shall be included in all copies or substantial portions
13  * of the 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 NON-INFRINGEMENT. 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
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21  * DEALINGS IN THE SOFTWARE.
22  *
23  * Authors:
24  *    Christian Gmeiner <christian.gmeiner@gmail.com>
25  */
26 
27 #include "etnaviv_format.h"
28 
29 #include "hw/common_3d.xml.h"
30 #include "hw/state.xml.h"
31 #include "hw/state_3d.xml.h"
32 
33 #include "pipe/p_defines.h"
34 
35 /* Specifies the table of all the formats and their features. Also supplies
36  * the helpers that look up various data in those tables.
37  */
38 
39 struct etna_format {
40    unsigned vtx;
41    unsigned tex;
42    unsigned rs;
43    unsigned ts;
44    boolean present;
45    const unsigned char tex_swiz[4];
46 };
47 
48 #define RS_FORMAT_NONE ~0
49 
50 #define RS_FORMAT_MASK        0xf
51 #define RS_FORMAT(x)          ((x) & RS_FORMAT_MASK)
52 #define RS_FORMAT_RB_SWAP     0x10
53 
54 #define RS_FORMAT_X8B8G8R8    (RS_FORMAT_X8R8G8B8 | RS_FORMAT_RB_SWAP)
55 #define RS_FORMAT_A8B8G8R8    (RS_FORMAT_A8R8G8B8 | RS_FORMAT_RB_SWAP)
56 
57 #define TS_SAMPLER_FORMAT_NONE      ETNA_NO_MATCH
58 
59 #define SWIZ(x,y,z,w) {    \
60    PIPE_SWIZZLE_##x,       \
61    PIPE_SWIZZLE_##y,       \
62    PIPE_SWIZZLE_##z,       \
63    PIPE_SWIZZLE_##w        \
64 }
65 
66 /* vertex + texture */
67 #define VT(pipe, vtxfmt, texfmt, texswiz, rsfmt, tsfmt)          \
68    [PIPE_FORMAT_##pipe] = {                               \
69       .vtx = FE_DATA_TYPE_##vtxfmt, \
70       .tex = TEXTURE_FORMAT_##texfmt,                     \
71       .rs = RS_FORMAT_##rsfmt,                            \
72       .ts = TS_SAMPLER_FORMAT_##tsfmt,        \
73       .present = 1,                                       \
74       .tex_swiz = texswiz,                                \
75    }
76 
77 /* texture-only */
78 #define _T(pipe, fmt, swiz, rsfmt, tsfmt) \
79    [PIPE_FORMAT_##pipe] = {        \
80       .vtx = ETNA_NO_MATCH,        \
81       .tex = TEXTURE_FORMAT_##fmt, \
82       .rs = RS_FORMAT_##rsfmt,     \
83       .ts = TS_SAMPLER_FORMAT_##tsfmt,     \
84       .present = 1,                \
85       .tex_swiz = swiz,            \
86    }
87 
88 /* vertex-only */
89 #define V_(pipe, fmt, rsfmt)                           \
90    [PIPE_FORMAT_##pipe] = {                            \
91       .vtx = FE_DATA_TYPE_##fmt, \
92       .tex = ETNA_NO_MATCH,                            \
93       .rs = RS_FORMAT_##rsfmt,                         \
94       .present = 1,                                    \
95    }
96 
97 static struct etna_format formats[PIPE_FORMAT_COUNT] = {
98    /* 8-bit */
99    VT(R8_UNORM,   UNSIGNED_BYTE, L8, SWIZ(X, 0, 0, 1), NONE, NONE),
100    V_(R8_SNORM,   BYTE,          NONE),
101    V_(R8_UINT,    UNSIGNED_BYTE, NONE),
102    V_(R8_SINT,    BYTE,          NONE),
103    V_(R8_USCALED, UNSIGNED_BYTE, NONE),
104    V_(R8_SSCALED, BYTE,          NONE),
105 
106    _T(A8_UNORM, A8, SWIZ(X, Y, Z, W), NONE, NONE),
107    _T(L8_UNORM, L8, SWIZ(X, Y, Z, W), NONE, NONE),
108    _T(I8_UNORM, I8, SWIZ(X, Y, Z, W), NONE, NONE),
109 
110    /* 16-bit */
111    V_(R16_UNORM,   UNSIGNED_SHORT, NONE),
112    V_(R16_SNORM,   SHORT,          NONE),
113    V_(R16_UINT,    UNSIGNED_SHORT, NONE),
114    V_(R16_SINT,    SHORT,          NONE),
115    V_(R16_USCALED, UNSIGNED_SHORT, NONE),
116    V_(R16_SSCALED, SHORT,          NONE),
117    V_(R16_FLOAT,   HALF_FLOAT,     NONE),
118 
119    _T(B4G4R4A4_UNORM, A4R4G4B4, SWIZ(X, Y, Z, W), A4R4G4B4, A4R4G4B4),
120    _T(B4G4R4X4_UNORM, X4R4G4B4, SWIZ(X, Y, Z, W), X4R4G4B4, A4R4G4B4),
121 
122    _T(L8A8_UNORM, A8L8, SWIZ(X, Y, Z, W), NONE, NONE),
123 
124    _T(Z16_UNORM,      D16,      SWIZ(X, Y, Z, W), A4R4G4B4, D16),
125    _T(B5G6R5_UNORM,   R5G6B5,   SWIZ(X, Y, Z, W), R5G6B5, R5G6B5),
126    _T(B5G5R5A1_UNORM, A1R5G5B5, SWIZ(X, Y, Z, W), A1R5G5B5, A1R5G5B5),
127    _T(B5G5R5X1_UNORM, X1R5G5B5, SWIZ(X, Y, Z, W), X1R5G5B5, A1R5G5B5),
128 
129    VT(R8G8_UNORM,   UNSIGNED_BYTE,  EXT_G8R8 | EXT_FORMAT, SWIZ(X, Y, 0, 1), NONE, NONE),
130    V_(R8G8_SNORM,   BYTE,           NONE),
131    V_(R8G8_UINT,    UNSIGNED_BYTE,  NONE),
132    V_(R8G8_SINT,    BYTE,           NONE),
133    V_(R8G8_USCALED, UNSIGNED_BYTE,  NONE),
134    V_(R8G8_SSCALED, BYTE,           NONE),
135 
136    /* 24-bit */
137    V_(R8G8B8_UNORM,   UNSIGNED_BYTE, NONE),
138    V_(R8G8B8_SNORM,   BYTE,          NONE),
139    V_(R8G8B8_UINT,    UNSIGNED_BYTE, NONE),
140    V_(R8G8B8_SINT,    BYTE,          NONE),
141    V_(R8G8B8_USCALED, UNSIGNED_BYTE, NONE),
142    V_(R8G8B8_SSCALED, BYTE,          NONE),
143 
144    /* 32-bit */
145    V_(R32_UNORM,   UNSIGNED_INT, NONE),
146    V_(R32_SNORM,   INT,          NONE),
147    V_(R32_SINT,    INT,          NONE),
148    V_(R32_UINT,    UNSIGNED_INT, NONE),
149    V_(R32_USCALED, UNSIGNED_INT, NONE),
150    V_(R32_SSCALED, INT,          NONE),
151    V_(R32_FLOAT,   FLOAT,        NONE),
152    V_(R32_FIXED,   FIXED,        NONE),
153 
154    V_(R16G16_UNORM,   UNSIGNED_SHORT, NONE),
155    V_(R16G16_SNORM,   SHORT,          NONE),
156    V_(R16G16_UINT,    UNSIGNED_SHORT, NONE),
157    V_(R16G16_SINT,    SHORT,          NONE),
158    V_(R16G16_USCALED, UNSIGNED_SHORT, NONE),
159    V_(R16G16_SSCALED, SHORT,          NONE),
160    V_(R16G16_FLOAT,   HALF_FLOAT,     NONE),
161 
162    V_(A8B8G8R8_UNORM,   UNSIGNED_BYTE, NONE),
163 
164    VT(R8G8B8A8_UNORM,   UNSIGNED_BYTE, A8B8G8R8, SWIZ(X, Y, Z, W), A8B8G8R8, A8R8G8B8),
165    V_(R8G8B8A8_SNORM,   BYTE,          A8B8G8R8),
166    _T(R8G8B8X8_UNORM,   X8B8G8R8,      SWIZ(X, Y, Z, W), X8B8G8R8, X8R8G8B8),
167    V_(R8G8B8A8_UINT,    UNSIGNED_BYTE, A8B8G8R8),
168    V_(R8G8B8A8_SINT,    BYTE,          A8B8G8R8),
169    V_(R8G8B8A8_USCALED, UNSIGNED_BYTE, A8B8G8R8),
170    V_(R8G8B8A8_SSCALED, BYTE,          A8B8G8R8),
171 
172    _T(B8G8R8A8_UNORM, A8R8G8B8, SWIZ(X, Y, Z, W), A8R8G8B8, A8R8G8B8),
173    _T(B8G8R8X8_UNORM, X8R8G8B8, SWIZ(X, Y, Z, W), X8R8G8B8, X8R8G8B8),
174    _T(B8G8R8A8_SRGB,  A8R8G8B8, SWIZ(X, Y, Z, W), A8R8G8B8, A8R8G8B8),
175    _T(B8G8R8X8_SRGB,  X8R8G8B8, SWIZ(X, Y, Z, W), X8R8G8B8, X8R8G8B8),
176 
177    V_(R10G10B10A2_UNORM,   UNSIGNED_INT_10_10_10_2, NONE),
178    V_(R10G10B10A2_SNORM,   INT_10_10_10_2,          NONE),
179    V_(R10G10B10A2_USCALED, UNSIGNED_INT_10_10_10_2, NONE),
180    V_(R10G10B10A2_SSCALED, INT_10_10_10_2,          NONE),
181 
182    _T(X8Z24_UNORM,       D24X8, SWIZ(X, Y, Z, W), A8R8G8B8, D24X8),
183    _T(S8_UINT_Z24_UNORM, D24X8, SWIZ(X, Y, Z, W), A8R8G8B8, D24X8),
184 
185    /* 48-bit */
186    V_(R16G16B16_UNORM,   UNSIGNED_SHORT, NONE),
187    V_(R16G16B16_SNORM,   SHORT,          NONE),
188    V_(R16G16B16_UINT,    UNSIGNED_SHORT, NONE),
189    V_(R16G16B16_SINT,    SHORT,          NONE),
190    V_(R16G16B16_USCALED, UNSIGNED_SHORT, NONE),
191    V_(R16G16B16_SSCALED, SHORT,          NONE),
192    V_(R16G16B16_FLOAT,   HALF_FLOAT,     NONE),
193 
194    /* 64-bit */
195    V_(R16G16B16A16_UNORM,   UNSIGNED_SHORT, NONE),
196    V_(R16G16B16A16_SNORM,   SHORT,          NONE),
197    V_(R16G16B16A16_UINT,    UNSIGNED_SHORT, NONE),
198    V_(R16G16B16A16_SINT,    SHORT,          NONE),
199    V_(R16G16B16A16_USCALED, UNSIGNED_SHORT, NONE),
200    V_(R16G16B16A16_SSCALED, SHORT,          NONE),
201    V_(R16G16B16A16_FLOAT,   HALF_FLOAT,     NONE),
202 
203    V_(R32G32_UNORM,   UNSIGNED_INT, NONE),
204    V_(R32G32_SNORM,   INT,          NONE),
205    V_(R32G32_UINT,    UNSIGNED_INT, NONE),
206    V_(R32G32_SINT,    INT,          NONE),
207    V_(R32G32_USCALED, UNSIGNED_INT, NONE),
208    V_(R32G32_SSCALED, INT,          NONE),
209    V_(R32G32_FLOAT,   FLOAT,        NONE),
210    V_(R32G32_FIXED,   FIXED,        NONE),
211 
212    /* 96-bit */
213    V_(R32G32B32_UNORM,   UNSIGNED_INT, NONE),
214    V_(R32G32B32_SNORM,   INT,          NONE),
215    V_(R32G32B32_UINT,    UNSIGNED_INT, NONE),
216    V_(R32G32B32_SINT,    INT,          NONE),
217    V_(R32G32B32_USCALED, UNSIGNED_INT, NONE),
218    V_(R32G32B32_SSCALED, INT,          NONE),
219    V_(R32G32B32_FLOAT,   FLOAT,        NONE),
220    V_(R32G32B32_FIXED,   FIXED,        NONE),
221 
222    /* 128-bit */
223    V_(R32G32B32A32_UNORM,   UNSIGNED_INT, NONE),
224    V_(R32G32B32A32_SNORM,   INT,          NONE),
225    V_(R32G32B32A32_UINT,    UNSIGNED_INT, NONE),
226    V_(R32G32B32A32_SINT,    INT,          NONE),
227    V_(R32G32B32A32_USCALED, UNSIGNED_INT, NONE),
228    V_(R32G32B32A32_SSCALED, INT,          NONE),
229    V_(R32G32B32A32_FLOAT,   FLOAT,        NONE),
230    V_(R32G32B32A32_FIXED,   FIXED,        NONE),
231 
232    /* compressed */
233    _T(ETC1_RGB8, ETC1, SWIZ(X, Y, Z, W), NONE, NONE),
234 
235    _T(DXT1_RGB,  DXT1,      SWIZ(X, Y, Z, W), NONE, NONE),
236    _T(DXT1_SRGBA,DXT1,      SWIZ(X, Y, Z, W), NONE, NONE),
237    _T(DXT1_RGBA, DXT1,      SWIZ(X, Y, Z, W), NONE, NONE),
238    _T(DXT3_SRGBA,DXT2_DXT3, SWIZ(X, Y, Z, W), NONE, NONE),
239    _T(DXT3_RGBA, DXT2_DXT3, SWIZ(X, Y, Z, W), NONE, NONE),
240    _T(DXT5_SRGBA,DXT4_DXT5, SWIZ(X, Y, Z, W), NONE, NONE),
241    _T(DXT5_RGBA, DXT4_DXT5, SWIZ(X, Y, Z, W), NONE, NONE),
242 
243    _T(ETC2_RGB8,       EXT_NONE | EXT_FORMAT,                          SWIZ(X, Y, Z, W), NONE, NONE), /* Extd. format NONE doubles as ETC2_RGB8 */
244    _T(ETC2_SRGB8,      EXT_NONE | EXT_FORMAT,                          SWIZ(X, Y, Z, W), NONE, NONE),
245    _T(ETC2_RGB8A1,     EXT_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 | EXT_FORMAT, SWIZ(X, Y, Z, W), NONE, NONE),
246    _T(ETC2_SRGB8A1,    EXT_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 | EXT_FORMAT, SWIZ(X, Y, Z, W), NONE, NONE),
247    _T(ETC2_RGBA8,      EXT_RGBA8_ETC2_EAC | EXT_FORMAT,                SWIZ(X, Y, Z, W), NONE, NONE),
248    _T(ETC2_SRGBA8,     EXT_RGBA8_ETC2_EAC | EXT_FORMAT,                SWIZ(X, Y, Z, W), NONE, NONE),
249    _T(ETC2_R11_UNORM,  EXT_R11_EAC | EXT_FORMAT,                       SWIZ(X, Y, Z, W), NONE, NONE),
250    _T(ETC2_R11_SNORM,  EXT_SIGNED_R11_EAC | EXT_FORMAT,                SWIZ(X, Y, Z, W), NONE, NONE),
251    _T(ETC2_RG11_UNORM, EXT_RG11_EAC | EXT_FORMAT,                      SWIZ(X, Y, Z, W), NONE, NONE),
252    _T(ETC2_RG11_SNORM, EXT_SIGNED_RG11_EAC | EXT_FORMAT,               SWIZ(X, Y, Z, W), NONE, NONE),
253 
254    _T(ASTC_4x4,        ASTC_RGBA_4x4 | ASTC_FORMAT,                    SWIZ(X, Y, Z, W), NONE, NONE),
255    _T(ASTC_5x4,        ASTC_RGBA_5x4 | ASTC_FORMAT,                    SWIZ(X, Y, Z, W), NONE, NONE),
256    _T(ASTC_5x5,        ASTC_RGBA_5x5 | ASTC_FORMAT,                    SWIZ(X, Y, Z, W), NONE, NONE),
257    _T(ASTC_6x5,        ASTC_RGBA_6x5 | ASTC_FORMAT,                    SWIZ(X, Y, Z, W), NONE, NONE),
258    _T(ASTC_6x6,        ASTC_RGBA_6x6 | ASTC_FORMAT,                    SWIZ(X, Y, Z, W), NONE, NONE),
259    _T(ASTC_8x5,        ASTC_RGBA_8x5 | ASTC_FORMAT,                    SWIZ(X, Y, Z, W), NONE, NONE),
260    _T(ASTC_8x6,        ASTC_RGBA_8x6 | ASTC_FORMAT,                    SWIZ(X, Y, Z, W), NONE, NONE),
261    _T(ASTC_8x8,        ASTC_RGBA_8x8 | ASTC_FORMAT,                    SWIZ(X, Y, Z, W), NONE, NONE),
262    _T(ASTC_10x5,       ASTC_RGBA_10x5 | ASTC_FORMAT,                   SWIZ(X, Y, Z, W), NONE, NONE),
263    _T(ASTC_10x6,       ASTC_RGBA_10x6 | ASTC_FORMAT,                   SWIZ(X, Y, Z, W), NONE, NONE),
264    _T(ASTC_10x8,       ASTC_RGBA_10x8 | ASTC_FORMAT,                   SWIZ(X, Y, Z, W), NONE, NONE),
265    _T(ASTC_10x10,      ASTC_RGBA_10x10 | ASTC_FORMAT,                  SWIZ(X, Y, Z, W), NONE, NONE),
266    _T(ASTC_12x10,      ASTC_RGBA_12x10 | ASTC_FORMAT,                  SWIZ(X, Y, Z, W), NONE, NONE),
267    _T(ASTC_12x12,      ASTC_RGBA_12x12 | ASTC_FORMAT,                  SWIZ(X, Y, Z, W), NONE, NONE),
268 
269    _T(ASTC_4x4_SRGB,   ASTC_SRGB8_ALPHA8_4x4 | ASTC_FORMAT,            SWIZ(X, Y, Z, W), NONE, NONE),
270    _T(ASTC_5x4_SRGB,   ASTC_SRGB8_ALPHA8_5x4 | ASTC_FORMAT,            SWIZ(X, Y, Z, W), NONE, NONE),
271    _T(ASTC_5x5_SRGB,   ASTC_SRGB8_ALPHA8_5x5 | ASTC_FORMAT,            SWIZ(X, Y, Z, W), NONE, NONE),
272    _T(ASTC_6x5_SRGB,   ASTC_SRGB8_ALPHA8_6x5 | ASTC_FORMAT,            SWIZ(X, Y, Z, W), NONE, NONE),
273    _T(ASTC_6x6_SRGB,   ASTC_SRGB8_ALPHA8_6x6 | ASTC_FORMAT,            SWIZ(X, Y, Z, W), NONE, NONE),
274    _T(ASTC_8x5_SRGB,   ASTC_SRGB8_ALPHA8_8x5 | ASTC_FORMAT,            SWIZ(X, Y, Z, W), NONE, NONE),
275    _T(ASTC_8x6_SRGB,   ASTC_SRGB8_ALPHA8_8x6 | ASTC_FORMAT,            SWIZ(X, Y, Z, W), NONE, NONE),
276    _T(ASTC_8x8_SRGB,   ASTC_SRGB8_ALPHA8_8x8 | ASTC_FORMAT,            SWIZ(X, Y, Z, W), NONE, NONE),
277    _T(ASTC_10x5_SRGB,  ASTC_SRGB8_ALPHA8_10x5 | ASTC_FORMAT,           SWIZ(X, Y, Z, W), NONE, NONE),
278    _T(ASTC_10x6_SRGB,  ASTC_SRGB8_ALPHA8_10x6 | ASTC_FORMAT,           SWIZ(X, Y, Z, W), NONE, NONE),
279    _T(ASTC_10x8_SRGB,  ASTC_SRGB8_ALPHA8_10x8 | ASTC_FORMAT,           SWIZ(X, Y, Z, W), NONE, NONE),
280    _T(ASTC_10x10_SRGB, ASTC_SRGB8_ALPHA8_10x10 | ASTC_FORMAT,          SWIZ(X, Y, Z, W), NONE, NONE),
281    _T(ASTC_12x10_SRGB, ASTC_SRGB8_ALPHA8_12x10 | ASTC_FORMAT,          SWIZ(X, Y, Z, W), NONE, NONE),
282    _T(ASTC_12x12_SRGB, ASTC_SRGB8_ALPHA8_12x12 | ASTC_FORMAT,          SWIZ(X, Y, Z, W), NONE, NONE),
283 
284    /* YUV */
285    _T(YUYV, YUY2, SWIZ(X, Y, Z, W), YUY2, NONE),
286    _T(UYVY, UYVY, SWIZ(X, Y, Z, W), NONE, NONE),
287 };
288 
289 uint32_t
translate_texture_format(enum pipe_format fmt)290 translate_texture_format(enum pipe_format fmt)
291 {
292    if (!formats[fmt].present)
293       return ETNA_NO_MATCH;
294 
295    return formats[fmt].tex;
296 }
297 
298 bool
texture_format_needs_swiz(enum pipe_format fmt)299 texture_format_needs_swiz(enum pipe_format fmt)
300 {
301    static const unsigned char def[4] = SWIZ(X, Y, Z, W);
302    bool swiz = false;
303 
304    if (formats[fmt].present)
305       swiz = !!memcmp(def, formats[fmt].tex_swiz, sizeof(formats[fmt].tex_swiz));
306 
307    return swiz;
308 }
309 
310 uint32_t
get_texture_swiz(enum pipe_format fmt,unsigned swizzle_r,unsigned swizzle_g,unsigned swizzle_b,unsigned swizzle_a)311 get_texture_swiz(enum pipe_format fmt, unsigned swizzle_r,
312                  unsigned swizzle_g, unsigned swizzle_b, unsigned swizzle_a)
313 {
314    unsigned char swiz[4] = {
315       swizzle_r, swizzle_g, swizzle_b, swizzle_a,
316    }, rswiz[4];
317 
318    assert(formats[fmt].present);
319    util_format_compose_swizzles(formats[fmt].tex_swiz, swiz, rswiz);
320 
321    /* PIPE_SWIZZLE_ maps 1:1 to TEXTURE_SWIZZLE_ */
322    STATIC_ASSERT(PIPE_SWIZZLE_X == TEXTURE_SWIZZLE_RED);
323    STATIC_ASSERT(PIPE_SWIZZLE_Y == TEXTURE_SWIZZLE_GREEN);
324    STATIC_ASSERT(PIPE_SWIZZLE_Z == TEXTURE_SWIZZLE_BLUE);
325    STATIC_ASSERT(PIPE_SWIZZLE_W == TEXTURE_SWIZZLE_ALPHA);
326    STATIC_ASSERT(PIPE_SWIZZLE_0 == TEXTURE_SWIZZLE_ZERO);
327    STATIC_ASSERT(PIPE_SWIZZLE_1 == TEXTURE_SWIZZLE_ONE);
328 
329    return VIVS_TE_SAMPLER_CONFIG1_SWIZZLE_R(rswiz[0]) |
330           VIVS_TE_SAMPLER_CONFIG1_SWIZZLE_G(rswiz[1]) |
331           VIVS_TE_SAMPLER_CONFIG1_SWIZZLE_B(rswiz[2]) |
332           VIVS_TE_SAMPLER_CONFIG1_SWIZZLE_A(rswiz[3]);
333 }
334 
335 uint32_t
translate_rs_format(enum pipe_format fmt)336 translate_rs_format(enum pipe_format fmt)
337 {
338    if (!formats[fmt].present)
339       return ETNA_NO_MATCH;
340 
341    if (formats[fmt].rs == ETNA_NO_MATCH)
342       return ETNA_NO_MATCH;
343 
344    return RS_FORMAT(formats[fmt].rs);
345 }
346 
347 int
translate_rs_format_rb_swap(enum pipe_format fmt)348 translate_rs_format_rb_swap(enum pipe_format fmt)
349 {
350    assert(formats[fmt].present);
351 
352    return formats[fmt].rs & RS_FORMAT_RB_SWAP;
353 }
354 
355 /* Return type flags for vertex element format */
356 uint32_t
translate_vertex_format_type(enum pipe_format fmt)357 translate_vertex_format_type(enum pipe_format fmt)
358 {
359    if (!formats[fmt].present)
360       return ETNA_NO_MATCH;
361 
362    return formats[fmt].vtx;
363 }
364 
365 uint32_t
translate_ts_sampler_format(enum pipe_format fmt)366 translate_ts_sampler_format(enum pipe_format fmt)
367 {
368    if (!formats[fmt].present)
369       return ETNA_NO_MATCH;
370 
371    return formats[fmt].ts;
372 }
373