1bf215546Sopenharmony_ci/**************************************************************************
2bf215546Sopenharmony_ci *
3bf215546Sopenharmony_ci * Copyright 2007 VMware, Inc.
4bf215546Sopenharmony_ci * All Rights Reserved.
5bf215546Sopenharmony_ci *
6bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
7bf215546Sopenharmony_ci * copy of this software and associated documentation files (the
8bf215546Sopenharmony_ci * "Software"), to deal in the Software without restriction, including
9bf215546Sopenharmony_ci * without limitation the rights to use, copy, modify, merge, publish,
10bf215546Sopenharmony_ci * distribute, sub license, and/or sell copies of the Software, and to
11bf215546Sopenharmony_ci * permit persons to whom the Software is furnished to do so, subject to
12bf215546Sopenharmony_ci * the following conditions:
13bf215546Sopenharmony_ci *
14bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the
15bf215546Sopenharmony_ci * next paragraph) shall be included in all copies or substantial portions
16bf215546Sopenharmony_ci * of the Software.
17bf215546Sopenharmony_ci *
18bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19bf215546Sopenharmony_ci * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20bf215546Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21bf215546Sopenharmony_ci * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22bf215546Sopenharmony_ci * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23bf215546Sopenharmony_ci * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24bf215546Sopenharmony_ci * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25bf215546Sopenharmony_ci *
26bf215546Sopenharmony_ci **************************************************************************/
27bf215546Sopenharmony_ci
28bf215546Sopenharmony_ci /*
29bf215546Sopenharmony_ci  * Authors:
30bf215546Sopenharmony_ci  *   Keith Whitwell <keithw@vmware.com>
31bf215546Sopenharmony_ci  */
32bf215546Sopenharmony_ci
33bf215546Sopenharmony_ci#include "util/u_memory.h"
34bf215546Sopenharmony_ci#include "util/format/u_format.h"
35bf215546Sopenharmony_ci#include "util/half_float.h"
36bf215546Sopenharmony_ci#include "util/u_math.h"
37bf215546Sopenharmony_ci#include "pipe/p_state.h"
38bf215546Sopenharmony_ci#include "translate.h"
39bf215546Sopenharmony_ci
40bf215546Sopenharmony_ci
41bf215546Sopenharmony_ci#define DRAW_DBG 0
42bf215546Sopenharmony_ci
43bf215546Sopenharmony_citypedef void (*emit_func)(const void *attrib, void *ptr);
44bf215546Sopenharmony_ci
45bf215546Sopenharmony_ci
46bf215546Sopenharmony_ci
47bf215546Sopenharmony_cistruct translate_generic {
48bf215546Sopenharmony_ci   struct translate translate;
49bf215546Sopenharmony_ci
50bf215546Sopenharmony_ci   struct {
51bf215546Sopenharmony_ci      enum translate_element_type type;
52bf215546Sopenharmony_ci
53bf215546Sopenharmony_ci      void (*fetch)(void *restrict dst, const uint8_t *restrict src,
54bf215546Sopenharmony_ci                    unsigned width);
55bf215546Sopenharmony_ci      unsigned buffer;
56bf215546Sopenharmony_ci      unsigned input_offset;
57bf215546Sopenharmony_ci      unsigned instance_divisor;
58bf215546Sopenharmony_ci
59bf215546Sopenharmony_ci      emit_func emit;
60bf215546Sopenharmony_ci      unsigned output_offset;
61bf215546Sopenharmony_ci
62bf215546Sopenharmony_ci      const uint8_t *input_ptr;
63bf215546Sopenharmony_ci      unsigned input_stride;
64bf215546Sopenharmony_ci      unsigned max_index;
65bf215546Sopenharmony_ci
66bf215546Sopenharmony_ci      /* this value is set to -1 if this is a normal element with
67bf215546Sopenharmony_ci       * output_format != input_format: in this case, u_format is used
68bf215546Sopenharmony_ci       * to do a full conversion
69bf215546Sopenharmony_ci       *
70bf215546Sopenharmony_ci       * this value is set to the format size in bytes if
71bf215546Sopenharmony_ci       * output_format == input_format or for 32-bit instance ids:
72bf215546Sopenharmony_ci       * in this case, memcpy is used to copy this amount of bytes
73bf215546Sopenharmony_ci       */
74bf215546Sopenharmony_ci      int copy_size;
75bf215546Sopenharmony_ci
76bf215546Sopenharmony_ci   } attrib[TRANSLATE_MAX_ATTRIBS];
77bf215546Sopenharmony_ci
78bf215546Sopenharmony_ci   unsigned nr_attrib;
79bf215546Sopenharmony_ci};
80bf215546Sopenharmony_ci
81bf215546Sopenharmony_ci
82bf215546Sopenharmony_cistatic struct translate_generic *
83bf215546Sopenharmony_citranslate_generic(struct translate *translate)
84bf215546Sopenharmony_ci{
85bf215546Sopenharmony_ci   return (struct translate_generic *)translate;
86bf215546Sopenharmony_ci}
87bf215546Sopenharmony_ci
88bf215546Sopenharmony_ci
89bf215546Sopenharmony_ci/**
90bf215546Sopenharmony_ci * Fetch a dword[4] vertex attribute from memory, doing format/type
91bf215546Sopenharmony_ci * conversion as needed.
92bf215546Sopenharmony_ci *
93bf215546Sopenharmony_ci * This is probably needed/dupliocated elsewhere, eg format
94bf215546Sopenharmony_ci * conversion, texture sampling etc.
95bf215546Sopenharmony_ci */
96bf215546Sopenharmony_ci#define ATTRIB(NAME, SZ, SRCTYPE, DSTTYPE, TO)  	\
97bf215546Sopenharmony_cistatic void						\
98bf215546Sopenharmony_ciemit_##NAME(const void *attrib, void *ptr)		\
99bf215546Sopenharmony_ci{  \
100bf215546Sopenharmony_ci   unsigned i;						\
101bf215546Sopenharmony_ci   SRCTYPE *in = (SRCTYPE *)attrib;                     \
102bf215546Sopenharmony_ci   DSTTYPE *out = (DSTTYPE *)ptr;			\
103bf215546Sopenharmony_ci							\
104bf215546Sopenharmony_ci   for (i = 0; i < SZ; i++) {				\
105bf215546Sopenharmony_ci      out[i] = TO(in[i]);				\
106bf215546Sopenharmony_ci   }							\
107bf215546Sopenharmony_ci}
108bf215546Sopenharmony_ci
109bf215546Sopenharmony_ci
110bf215546Sopenharmony_ci#define TO_64_FLOAT(x)   ((double) x)
111bf215546Sopenharmony_ci#define TO_32_FLOAT(x)   (x)
112bf215546Sopenharmony_ci#define TO_16_FLOAT(x)   _mesa_float_to_half(x)
113bf215546Sopenharmony_ci
114bf215546Sopenharmony_ci#define TO_8_USCALED(x)  ((unsigned char) x)
115bf215546Sopenharmony_ci#define TO_16_USCALED(x) ((unsigned short) x)
116bf215546Sopenharmony_ci#define TO_32_USCALED(x) ((unsigned int) x)
117bf215546Sopenharmony_ci
118bf215546Sopenharmony_ci#define TO_8_SSCALED(x)  ((char) x)
119bf215546Sopenharmony_ci#define TO_16_SSCALED(x) ((short) x)
120bf215546Sopenharmony_ci#define TO_32_SSCALED(x) ((int) x)
121bf215546Sopenharmony_ci
122bf215546Sopenharmony_ci#define TO_8_UNORM(x)    ((unsigned char) (x * 255.0f))
123bf215546Sopenharmony_ci#define TO_16_UNORM(x)   ((unsigned short) (x * 65535.0f))
124bf215546Sopenharmony_ci#define TO_32_UNORM(x)   ((unsigned int) (x * 4294967295.0f))
125bf215546Sopenharmony_ci
126bf215546Sopenharmony_ci#define TO_8_SNORM(x)    ((char) (x * 127.0f))
127bf215546Sopenharmony_ci#define TO_16_SNORM(x)   ((short) (x * 32767.0f))
128bf215546Sopenharmony_ci#define TO_32_SNORM(x)   ((int) (x * 2147483647.0f))
129bf215546Sopenharmony_ci
130bf215546Sopenharmony_ci#define TO_32_FIXED(x)   ((int) (x * 65536.0f))
131bf215546Sopenharmony_ci
132bf215546Sopenharmony_ci#define TO_INT(x)        (x)
133bf215546Sopenharmony_ci
134bf215546Sopenharmony_ci
135bf215546Sopenharmony_ciATTRIB(R64G64B64A64_FLOAT,   4, float, double, TO_64_FLOAT)
136bf215546Sopenharmony_ciATTRIB(R64G64B64_FLOAT,      3, float, double, TO_64_FLOAT)
137bf215546Sopenharmony_ciATTRIB(R64G64_FLOAT,         2, float, double, TO_64_FLOAT)
138bf215546Sopenharmony_ciATTRIB(R64_FLOAT,            1, float, double, TO_64_FLOAT)
139bf215546Sopenharmony_ci
140bf215546Sopenharmony_ciATTRIB(R32G32B32A32_FLOAT,   4, float, float, TO_32_FLOAT)
141bf215546Sopenharmony_ciATTRIB(R32G32B32_FLOAT,      3, float, float, TO_32_FLOAT)
142bf215546Sopenharmony_ciATTRIB(R32G32_FLOAT,         2, float, float, TO_32_FLOAT)
143bf215546Sopenharmony_ciATTRIB(R32_FLOAT,            1, float, float, TO_32_FLOAT)
144bf215546Sopenharmony_ci
145bf215546Sopenharmony_ciATTRIB(R16G16B16A16_FLOAT,   4, float, ushort, TO_16_FLOAT)
146bf215546Sopenharmony_ciATTRIB(R16G16B16_FLOAT,      3, float, ushort, TO_16_FLOAT)
147bf215546Sopenharmony_ciATTRIB(R16G16_FLOAT,         2, float, ushort, TO_16_FLOAT)
148bf215546Sopenharmony_ciATTRIB(R16_FLOAT,            1, float, ushort, TO_16_FLOAT)
149bf215546Sopenharmony_ci
150bf215546Sopenharmony_ciATTRIB(R32G32B32A32_USCALED, 4, float, unsigned, TO_32_USCALED)
151bf215546Sopenharmony_ciATTRIB(R32G32B32_USCALED,    3, float, unsigned, TO_32_USCALED)
152bf215546Sopenharmony_ciATTRIB(R32G32_USCALED,       2, float, unsigned, TO_32_USCALED)
153bf215546Sopenharmony_ciATTRIB(R32_USCALED,          1, float, unsigned, TO_32_USCALED)
154bf215546Sopenharmony_ci
155bf215546Sopenharmony_ciATTRIB(R32G32B32A32_SSCALED, 4, float, int, TO_32_SSCALED)
156bf215546Sopenharmony_ciATTRIB(R32G32B32_SSCALED,    3, float, int, TO_32_SSCALED)
157bf215546Sopenharmony_ciATTRIB(R32G32_SSCALED,       2, float, int, TO_32_SSCALED)
158bf215546Sopenharmony_ciATTRIB(R32_SSCALED,          1, float, int, TO_32_SSCALED)
159bf215546Sopenharmony_ci
160bf215546Sopenharmony_ciATTRIB(R32G32B32A32_UNORM, 4, float, unsigned, TO_32_UNORM)
161bf215546Sopenharmony_ciATTRIB(R32G32B32_UNORM,    3, float, unsigned, TO_32_UNORM)
162bf215546Sopenharmony_ciATTRIB(R32G32_UNORM,       2, float, unsigned, TO_32_UNORM)
163bf215546Sopenharmony_ciATTRIB(R32_UNORM,          1, float, unsigned, TO_32_UNORM)
164bf215546Sopenharmony_ci
165bf215546Sopenharmony_ciATTRIB(R32G32B32A32_SNORM, 4, float, int, TO_32_SNORM)
166bf215546Sopenharmony_ciATTRIB(R32G32B32_SNORM,    3, float, int, TO_32_SNORM)
167bf215546Sopenharmony_ciATTRIB(R32G32_SNORM,       2, float, int, TO_32_SNORM)
168bf215546Sopenharmony_ciATTRIB(R32_SNORM,          1, float, int, TO_32_SNORM)
169bf215546Sopenharmony_ci
170bf215546Sopenharmony_ciATTRIB(R16G16B16A16_USCALED, 4, float, ushort, TO_16_USCALED)
171bf215546Sopenharmony_ciATTRIB(R16G16B16_USCALED,    3, float, ushort, TO_16_USCALED)
172bf215546Sopenharmony_ciATTRIB(R16G16_USCALED,       2, float, ushort, TO_16_USCALED)
173bf215546Sopenharmony_ciATTRIB(R16_USCALED,          1, float, ushort, TO_16_USCALED)
174bf215546Sopenharmony_ci
175bf215546Sopenharmony_ciATTRIB(R16G16B16A16_SSCALED, 4, float, short, TO_16_SSCALED)
176bf215546Sopenharmony_ciATTRIB(R16G16B16_SSCALED,    3, float, short, TO_16_SSCALED)
177bf215546Sopenharmony_ciATTRIB(R16G16_SSCALED,       2, float, short, TO_16_SSCALED)
178bf215546Sopenharmony_ciATTRIB(R16_SSCALED,          1, float, short, TO_16_SSCALED)
179bf215546Sopenharmony_ci
180bf215546Sopenharmony_ciATTRIB(R16G16B16A16_UNORM, 4, float, ushort, TO_16_UNORM)
181bf215546Sopenharmony_ciATTRIB(R16G16B16_UNORM,    3, float, ushort, TO_16_UNORM)
182bf215546Sopenharmony_ciATTRIB(R16G16_UNORM,       2, float, ushort, TO_16_UNORM)
183bf215546Sopenharmony_ciATTRIB(R16_UNORM,          1, float, ushort, TO_16_UNORM)
184bf215546Sopenharmony_ci
185bf215546Sopenharmony_ciATTRIB(R16G16B16A16_SNORM, 4, float, short, TO_16_SNORM)
186bf215546Sopenharmony_ciATTRIB(R16G16B16_SNORM,    3, float, short, TO_16_SNORM)
187bf215546Sopenharmony_ciATTRIB(R16G16_SNORM,       2, float, short, TO_16_SNORM)
188bf215546Sopenharmony_ciATTRIB(R16_SNORM,          1, float, short, TO_16_SNORM)
189bf215546Sopenharmony_ci
190bf215546Sopenharmony_ciATTRIB(R8G8B8A8_USCALED,   4, float, ubyte, TO_8_USCALED)
191bf215546Sopenharmony_ciATTRIB(R8G8B8_USCALED,     3, float, ubyte, TO_8_USCALED)
192bf215546Sopenharmony_ciATTRIB(R8G8_USCALED,       2, float, ubyte, TO_8_USCALED)
193bf215546Sopenharmony_ciATTRIB(R8_USCALED,         1, float, ubyte, TO_8_USCALED)
194bf215546Sopenharmony_ci
195bf215546Sopenharmony_ciATTRIB(R8G8B8A8_SSCALED,  4, float, char, TO_8_SSCALED)
196bf215546Sopenharmony_ciATTRIB(R8G8B8_SSCALED,    3, float, char, TO_8_SSCALED)
197bf215546Sopenharmony_ciATTRIB(R8G8_SSCALED,      2, float, char, TO_8_SSCALED)
198bf215546Sopenharmony_ciATTRIB(R8_SSCALED,        1, float, char, TO_8_SSCALED)
199bf215546Sopenharmony_ci
200bf215546Sopenharmony_ciATTRIB(R8G8B8A8_UNORM,  4, float, ubyte, TO_8_UNORM)
201bf215546Sopenharmony_ciATTRIB(R8G8B8_UNORM,    3, float, ubyte, TO_8_UNORM)
202bf215546Sopenharmony_ciATTRIB(R8G8_UNORM,      2, float, ubyte, TO_8_UNORM)
203bf215546Sopenharmony_ciATTRIB(R8_UNORM,        1, float, ubyte, TO_8_UNORM)
204bf215546Sopenharmony_ci
205bf215546Sopenharmony_ciATTRIB(R8G8B8A8_SNORM,  4, float, char, TO_8_SNORM)
206bf215546Sopenharmony_ciATTRIB(R8G8B8_SNORM,    3, float, char, TO_8_SNORM)
207bf215546Sopenharmony_ciATTRIB(R8G8_SNORM,      2, float, char, TO_8_SNORM)
208bf215546Sopenharmony_ciATTRIB(R8_SNORM,        1, float, char, TO_8_SNORM)
209bf215546Sopenharmony_ci
210bf215546Sopenharmony_ciATTRIB(R32G32B32A32_UINT, 4, uint32_t, unsigned, TO_INT)
211bf215546Sopenharmony_ciATTRIB(R32G32B32_UINT,    3, uint32_t, unsigned, TO_INT)
212bf215546Sopenharmony_ciATTRIB(R32G32_UINT,       2, uint32_t, unsigned, TO_INT)
213bf215546Sopenharmony_ciATTRIB(R32_UINT,          1, uint32_t, unsigned, TO_INT)
214bf215546Sopenharmony_ci
215bf215546Sopenharmony_ciATTRIB(R16G16B16A16_UINT, 4, uint32_t, ushort, TO_INT)
216bf215546Sopenharmony_ciATTRIB(R16G16B16_UINT,    3, uint32_t, ushort, TO_INT)
217bf215546Sopenharmony_ciATTRIB(R16G16_UINT,       2, uint32_t, ushort, TO_INT)
218bf215546Sopenharmony_ciATTRIB(R16_UINT,          1, uint32_t, ushort, TO_INT)
219bf215546Sopenharmony_ci
220bf215546Sopenharmony_ciATTRIB(R8G8B8A8_UINT,   4, uint32_t, ubyte, TO_INT)
221bf215546Sopenharmony_ciATTRIB(R8G8B8_UINT,     3, uint32_t, ubyte, TO_INT)
222bf215546Sopenharmony_ciATTRIB(R8G8_UINT,       2, uint32_t, ubyte, TO_INT)
223bf215546Sopenharmony_ciATTRIB(R8_UINT,         1, uint32_t, ubyte, TO_INT)
224bf215546Sopenharmony_ci
225bf215546Sopenharmony_ciATTRIB(R32G32B32A32_SINT, 4, int32_t, int, TO_INT)
226bf215546Sopenharmony_ciATTRIB(R32G32B32_SINT,    3, int32_t, int, TO_INT)
227bf215546Sopenharmony_ciATTRIB(R32G32_SINT,       2, int32_t, int, TO_INT)
228bf215546Sopenharmony_ciATTRIB(R32_SINT,          1, int32_t, int, TO_INT)
229bf215546Sopenharmony_ci
230bf215546Sopenharmony_ciATTRIB(R16G16B16A16_SINT, 4, int32_t, short, TO_INT)
231bf215546Sopenharmony_ciATTRIB(R16G16B16_SINT,    3, int32_t, short, TO_INT)
232bf215546Sopenharmony_ciATTRIB(R16G16_SINT,       2, int32_t, short, TO_INT)
233bf215546Sopenharmony_ciATTRIB(R16_SINT,          1, int32_t, short, TO_INT)
234bf215546Sopenharmony_ci
235bf215546Sopenharmony_ciATTRIB(R8G8B8A8_SINT,   4, int32_t, char, TO_INT)
236bf215546Sopenharmony_ciATTRIB(R8G8B8_SINT,     3, int32_t, char, TO_INT)
237bf215546Sopenharmony_ciATTRIB(R8G8_SINT,       2, int32_t, char, TO_INT)
238bf215546Sopenharmony_ciATTRIB(R8_SINT,         1, int32_t, char, TO_INT)
239bf215546Sopenharmony_ci
240bf215546Sopenharmony_cistatic void
241bf215546Sopenharmony_ciemit_A8R8G8B8_UNORM(const void *attrib, void *ptr)
242bf215546Sopenharmony_ci{
243bf215546Sopenharmony_ci   float *in = (float *)attrib;
244bf215546Sopenharmony_ci   ubyte *out = (ubyte *)ptr;
245bf215546Sopenharmony_ci   out[0] = TO_8_UNORM(in[3]);
246bf215546Sopenharmony_ci   out[1] = TO_8_UNORM(in[0]);
247bf215546Sopenharmony_ci   out[2] = TO_8_UNORM(in[1]);
248bf215546Sopenharmony_ci   out[3] = TO_8_UNORM(in[2]);
249bf215546Sopenharmony_ci}
250bf215546Sopenharmony_ci
251bf215546Sopenharmony_cistatic void
252bf215546Sopenharmony_ciemit_B8G8R8A8_UNORM(const void *attrib, void *ptr)
253bf215546Sopenharmony_ci{
254bf215546Sopenharmony_ci   float *in = (float *)attrib;
255bf215546Sopenharmony_ci   ubyte *out = (ubyte *)ptr;
256bf215546Sopenharmony_ci   out[2] = TO_8_UNORM(in[0]);
257bf215546Sopenharmony_ci   out[1] = TO_8_UNORM(in[1]);
258bf215546Sopenharmony_ci   out[0] = TO_8_UNORM(in[2]);
259bf215546Sopenharmony_ci   out[3] = TO_8_UNORM(in[3]);
260bf215546Sopenharmony_ci}
261bf215546Sopenharmony_ci
262bf215546Sopenharmony_cistatic void
263bf215546Sopenharmony_ciemit_B10G10R10A2_UNORM(const void *attrib, void *ptr)
264bf215546Sopenharmony_ci{
265bf215546Sopenharmony_ci   float *src = (float *)ptr;
266bf215546Sopenharmony_ci   uint32_t value = 0;
267bf215546Sopenharmony_ci   value |= ((uint32_t)(CLAMP(src[2], 0, 1) * 0x3ff)) & 0x3ff;
268bf215546Sopenharmony_ci   value |= (((uint32_t)(CLAMP(src[1], 0, 1) * 0x3ff)) & 0x3ff) << 10;
269bf215546Sopenharmony_ci   value |= (((uint32_t)(CLAMP(src[0], 0, 1) * 0x3ff)) & 0x3ff) << 20;
270bf215546Sopenharmony_ci   value |= ((uint32_t)(CLAMP(src[3], 0, 1) * 0x3)) << 30;
271bf215546Sopenharmony_ci   *(uint32_t *)attrib = util_le32_to_cpu(value);
272bf215546Sopenharmony_ci}
273bf215546Sopenharmony_ci
274bf215546Sopenharmony_cistatic void
275bf215546Sopenharmony_ciemit_B10G10R10A2_USCALED(const void *attrib, void *ptr)
276bf215546Sopenharmony_ci{
277bf215546Sopenharmony_ci   float *src = (float *)ptr;
278bf215546Sopenharmony_ci   uint32_t value = 0;
279bf215546Sopenharmony_ci   value |= ((uint32_t)CLAMP(src[2], 0, 1023)) & 0x3ff;
280bf215546Sopenharmony_ci   value |= (((uint32_t)CLAMP(src[1], 0, 1023)) & 0x3ff) << 10;
281bf215546Sopenharmony_ci   value |= (((uint32_t)CLAMP(src[0], 0, 1023)) & 0x3ff) << 20;
282bf215546Sopenharmony_ci   value |= ((uint32_t)CLAMP(src[3], 0, 3)) << 30;
283bf215546Sopenharmony_ci   *(uint32_t *)attrib = util_le32_to_cpu(value);
284bf215546Sopenharmony_ci}
285bf215546Sopenharmony_ci
286bf215546Sopenharmony_cistatic void
287bf215546Sopenharmony_ciemit_B10G10R10A2_SNORM(const void *attrib, void *ptr)
288bf215546Sopenharmony_ci{
289bf215546Sopenharmony_ci   float *src = (float *)ptr;
290bf215546Sopenharmony_ci   uint32_t value = 0;
291bf215546Sopenharmony_ci   value |= (uint32_t)(((uint32_t)(CLAMP(src[2], -1, 1) * 0x1ff)) & 0x3ff) ;
292bf215546Sopenharmony_ci   value |= (uint32_t)((((uint32_t)(CLAMP(src[1], -1, 1) * 0x1ff)) & 0x3ff) << 10) ;
293bf215546Sopenharmony_ci   value |= (uint32_t)((((uint32_t)(CLAMP(src[0], -1, 1) * 0x1ff)) & 0x3ff) << 20) ;
294bf215546Sopenharmony_ci   value |= (uint32_t)(((uint32_t)(CLAMP(src[3], -1, 1) * 0x1)) << 30) ;
295bf215546Sopenharmony_ci   *(uint32_t *)attrib = util_le32_to_cpu(value);
296bf215546Sopenharmony_ci}
297bf215546Sopenharmony_ci
298bf215546Sopenharmony_cistatic void
299bf215546Sopenharmony_ciemit_B10G10R10A2_SSCALED(const void *attrib, void *ptr)
300bf215546Sopenharmony_ci{
301bf215546Sopenharmony_ci   float *src = (float *)ptr;
302bf215546Sopenharmony_ci   uint32_t value = 0;
303bf215546Sopenharmony_ci   value |= (uint32_t)(((uint32_t)CLAMP(src[2], -512, 511)) & 0x3ff) ;
304bf215546Sopenharmony_ci   value |= (uint32_t)((((uint32_t)CLAMP(src[1], -512, 511)) & 0x3ff) << 10) ;
305bf215546Sopenharmony_ci   value |= (uint32_t)((((uint32_t)CLAMP(src[0], -512, 511)) & 0x3ff) << 20) ;
306bf215546Sopenharmony_ci   value |= (uint32_t)(((uint32_t)CLAMP(src[3], -2, 1)) << 30) ;
307bf215546Sopenharmony_ci   *(uint32_t *)attrib = util_le32_to_cpu(value);
308bf215546Sopenharmony_ci}
309bf215546Sopenharmony_ci
310bf215546Sopenharmony_cistatic void
311bf215546Sopenharmony_ciemit_R10G10B10A2_UNORM(const void *attrib, void *ptr)
312bf215546Sopenharmony_ci{
313bf215546Sopenharmony_ci   float *src = (float *)ptr;
314bf215546Sopenharmony_ci   uint32_t value = 0;
315bf215546Sopenharmony_ci   value |= ((uint32_t)(CLAMP(src[0], 0, 1) * 0x3ff)) & 0x3ff;
316bf215546Sopenharmony_ci   value |= (((uint32_t)(CLAMP(src[1], 0, 1) * 0x3ff)) & 0x3ff) << 10;
317bf215546Sopenharmony_ci   value |= (((uint32_t)(CLAMP(src[2], 0, 1) * 0x3ff)) & 0x3ff) << 20;
318bf215546Sopenharmony_ci   value |= ((uint32_t)(CLAMP(src[3], 0, 1) * 0x3)) << 30;
319bf215546Sopenharmony_ci   *(uint32_t *)attrib = util_le32_to_cpu(value);
320bf215546Sopenharmony_ci}
321bf215546Sopenharmony_ci
322bf215546Sopenharmony_cistatic void
323bf215546Sopenharmony_ciemit_R10G10B10A2_USCALED(const void *attrib, void *ptr)
324bf215546Sopenharmony_ci{
325bf215546Sopenharmony_ci   float *src = (float *)ptr;
326bf215546Sopenharmony_ci   uint32_t value = 0;
327bf215546Sopenharmony_ci   value |= ((uint32_t)CLAMP(src[0], 0, 1023)) & 0x3ff;
328bf215546Sopenharmony_ci   value |= (((uint32_t)CLAMP(src[1], 0, 1023)) & 0x3ff) << 10;
329bf215546Sopenharmony_ci   value |= (((uint32_t)CLAMP(src[2], 0, 1023)) & 0x3ff) << 20;
330bf215546Sopenharmony_ci   value |= ((uint32_t)CLAMP(src[3], 0, 3)) << 30;
331bf215546Sopenharmony_ci   *(uint32_t *)attrib = util_le32_to_cpu(value);
332bf215546Sopenharmony_ci}
333bf215546Sopenharmony_ci
334bf215546Sopenharmony_cistatic void
335bf215546Sopenharmony_ciemit_R10G10B10A2_SNORM(const void *attrib, void *ptr)
336bf215546Sopenharmony_ci{
337bf215546Sopenharmony_ci   float *src = (float *)ptr;
338bf215546Sopenharmony_ci   uint32_t value = 0;
339bf215546Sopenharmony_ci   value |= (uint32_t)(((uint32_t)(CLAMP(src[0], -1, 1) * 0x1ff)) & 0x3ff) ;
340bf215546Sopenharmony_ci   value |= (uint32_t)((((uint32_t)(CLAMP(src[1], -1, 1) * 0x1ff)) & 0x3ff) << 10) ;
341bf215546Sopenharmony_ci   value |= (uint32_t)((((uint32_t)(CLAMP(src[2], -1, 1) * 0x1ff)) & 0x3ff) << 20) ;
342bf215546Sopenharmony_ci   value |= (uint32_t)(((uint32_t)(CLAMP(src[3], -1, 1) * 0x1)) << 30) ;
343bf215546Sopenharmony_ci   *(uint32_t *)attrib = util_le32_to_cpu(value);
344bf215546Sopenharmony_ci}
345bf215546Sopenharmony_ci
346bf215546Sopenharmony_cistatic void
347bf215546Sopenharmony_ciemit_R10G10B10A2_SSCALED(const void *attrib, void *ptr)
348bf215546Sopenharmony_ci{
349bf215546Sopenharmony_ci   float *src = (float *)ptr;
350bf215546Sopenharmony_ci   uint32_t value = 0;
351bf215546Sopenharmony_ci   value |= (uint32_t)(((uint32_t)CLAMP(src[0], -512, 511)) & 0x3ff) ;
352bf215546Sopenharmony_ci   value |= (uint32_t)((((uint32_t)CLAMP(src[1], -512, 511)) & 0x3ff) << 10) ;
353bf215546Sopenharmony_ci   value |= (uint32_t)((((uint32_t)CLAMP(src[2], -512, 511)) & 0x3ff) << 20) ;
354bf215546Sopenharmony_ci   value |= (uint32_t)(((uint32_t)CLAMP(src[3], -2, 1)) << 30) ;
355bf215546Sopenharmony_ci   *(uint32_t *)attrib = util_le32_to_cpu(value);
356bf215546Sopenharmony_ci}
357bf215546Sopenharmony_ci
358bf215546Sopenharmony_cistatic void
359bf215546Sopenharmony_ciemit_NULL(const void *attrib, void *ptr)
360bf215546Sopenharmony_ci{
361bf215546Sopenharmony_ci   /* do nothing is the only sensible option */
362bf215546Sopenharmony_ci}
363bf215546Sopenharmony_ci
364bf215546Sopenharmony_cistatic emit_func
365bf215546Sopenharmony_ciget_emit_func(enum pipe_format format)
366bf215546Sopenharmony_ci{
367bf215546Sopenharmony_ci   switch (format) {
368bf215546Sopenharmony_ci   case PIPE_FORMAT_R64_FLOAT:
369bf215546Sopenharmony_ci      return &emit_R64_FLOAT;
370bf215546Sopenharmony_ci   case PIPE_FORMAT_R64G64_FLOAT:
371bf215546Sopenharmony_ci      return &emit_R64G64_FLOAT;
372bf215546Sopenharmony_ci   case PIPE_FORMAT_R64G64B64_FLOAT:
373bf215546Sopenharmony_ci      return &emit_R64G64B64_FLOAT;
374bf215546Sopenharmony_ci   case PIPE_FORMAT_R64G64B64A64_FLOAT:
375bf215546Sopenharmony_ci      return &emit_R64G64B64A64_FLOAT;
376bf215546Sopenharmony_ci
377bf215546Sopenharmony_ci   case PIPE_FORMAT_R32_FLOAT:
378bf215546Sopenharmony_ci      return &emit_R32_FLOAT;
379bf215546Sopenharmony_ci   case PIPE_FORMAT_R32G32_FLOAT:
380bf215546Sopenharmony_ci      return &emit_R32G32_FLOAT;
381bf215546Sopenharmony_ci   case PIPE_FORMAT_R32G32B32_FLOAT:
382bf215546Sopenharmony_ci      return &emit_R32G32B32_FLOAT;
383bf215546Sopenharmony_ci   case PIPE_FORMAT_R32G32B32A32_FLOAT:
384bf215546Sopenharmony_ci      return &emit_R32G32B32A32_FLOAT;
385bf215546Sopenharmony_ci
386bf215546Sopenharmony_ci   case PIPE_FORMAT_R16_FLOAT:
387bf215546Sopenharmony_ci      return &emit_R16_FLOAT;
388bf215546Sopenharmony_ci   case PIPE_FORMAT_R16G16_FLOAT:
389bf215546Sopenharmony_ci      return &emit_R16G16_FLOAT;
390bf215546Sopenharmony_ci   case PIPE_FORMAT_R16G16B16_FLOAT:
391bf215546Sopenharmony_ci      return &emit_R16G16B16_FLOAT;
392bf215546Sopenharmony_ci   case PIPE_FORMAT_R16G16B16A16_FLOAT:
393bf215546Sopenharmony_ci      return &emit_R16G16B16A16_FLOAT;
394bf215546Sopenharmony_ci
395bf215546Sopenharmony_ci   case PIPE_FORMAT_R32_UNORM:
396bf215546Sopenharmony_ci      return &emit_R32_UNORM;
397bf215546Sopenharmony_ci   case PIPE_FORMAT_R32G32_UNORM:
398bf215546Sopenharmony_ci      return &emit_R32G32_UNORM;
399bf215546Sopenharmony_ci   case PIPE_FORMAT_R32G32B32_UNORM:
400bf215546Sopenharmony_ci      return &emit_R32G32B32_UNORM;
401bf215546Sopenharmony_ci   case PIPE_FORMAT_R32G32B32A32_UNORM:
402bf215546Sopenharmony_ci      return &emit_R32G32B32A32_UNORM;
403bf215546Sopenharmony_ci
404bf215546Sopenharmony_ci   case PIPE_FORMAT_R32_USCALED:
405bf215546Sopenharmony_ci      return &emit_R32_USCALED;
406bf215546Sopenharmony_ci   case PIPE_FORMAT_R32G32_USCALED:
407bf215546Sopenharmony_ci      return &emit_R32G32_USCALED;
408bf215546Sopenharmony_ci   case PIPE_FORMAT_R32G32B32_USCALED:
409bf215546Sopenharmony_ci      return &emit_R32G32B32_USCALED;
410bf215546Sopenharmony_ci   case PIPE_FORMAT_R32G32B32A32_USCALED:
411bf215546Sopenharmony_ci      return &emit_R32G32B32A32_USCALED;
412bf215546Sopenharmony_ci
413bf215546Sopenharmony_ci   case PIPE_FORMAT_R32_SNORM:
414bf215546Sopenharmony_ci      return &emit_R32_SNORM;
415bf215546Sopenharmony_ci   case PIPE_FORMAT_R32G32_SNORM:
416bf215546Sopenharmony_ci      return &emit_R32G32_SNORM;
417bf215546Sopenharmony_ci   case PIPE_FORMAT_R32G32B32_SNORM:
418bf215546Sopenharmony_ci      return &emit_R32G32B32_SNORM;
419bf215546Sopenharmony_ci   case PIPE_FORMAT_R32G32B32A32_SNORM:
420bf215546Sopenharmony_ci      return &emit_R32G32B32A32_SNORM;
421bf215546Sopenharmony_ci
422bf215546Sopenharmony_ci   case PIPE_FORMAT_R32_SSCALED:
423bf215546Sopenharmony_ci      return &emit_R32_SSCALED;
424bf215546Sopenharmony_ci   case PIPE_FORMAT_R32G32_SSCALED:
425bf215546Sopenharmony_ci      return &emit_R32G32_SSCALED;
426bf215546Sopenharmony_ci   case PIPE_FORMAT_R32G32B32_SSCALED:
427bf215546Sopenharmony_ci      return &emit_R32G32B32_SSCALED;
428bf215546Sopenharmony_ci   case PIPE_FORMAT_R32G32B32A32_SSCALED:
429bf215546Sopenharmony_ci      return &emit_R32G32B32A32_SSCALED;
430bf215546Sopenharmony_ci
431bf215546Sopenharmony_ci   case PIPE_FORMAT_R16_UNORM:
432bf215546Sopenharmony_ci      return &emit_R16_UNORM;
433bf215546Sopenharmony_ci   case PIPE_FORMAT_R16G16_UNORM:
434bf215546Sopenharmony_ci      return &emit_R16G16_UNORM;
435bf215546Sopenharmony_ci   case PIPE_FORMAT_R16G16B16_UNORM:
436bf215546Sopenharmony_ci      return &emit_R16G16B16_UNORM;
437bf215546Sopenharmony_ci   case PIPE_FORMAT_R16G16B16A16_UNORM:
438bf215546Sopenharmony_ci      return &emit_R16G16B16A16_UNORM;
439bf215546Sopenharmony_ci
440bf215546Sopenharmony_ci   case PIPE_FORMAT_R16_USCALED:
441bf215546Sopenharmony_ci      return &emit_R16_USCALED;
442bf215546Sopenharmony_ci   case PIPE_FORMAT_R16G16_USCALED:
443bf215546Sopenharmony_ci      return &emit_R16G16_USCALED;
444bf215546Sopenharmony_ci   case PIPE_FORMAT_R16G16B16_USCALED:
445bf215546Sopenharmony_ci      return &emit_R16G16B16_USCALED;
446bf215546Sopenharmony_ci   case PIPE_FORMAT_R16G16B16A16_USCALED:
447bf215546Sopenharmony_ci      return &emit_R16G16B16A16_USCALED;
448bf215546Sopenharmony_ci
449bf215546Sopenharmony_ci   case PIPE_FORMAT_R16_SNORM:
450bf215546Sopenharmony_ci      return &emit_R16_SNORM;
451bf215546Sopenharmony_ci   case PIPE_FORMAT_R16G16_SNORM:
452bf215546Sopenharmony_ci      return &emit_R16G16_SNORM;
453bf215546Sopenharmony_ci   case PIPE_FORMAT_R16G16B16_SNORM:
454bf215546Sopenharmony_ci      return &emit_R16G16B16_SNORM;
455bf215546Sopenharmony_ci   case PIPE_FORMAT_R16G16B16A16_SNORM:
456bf215546Sopenharmony_ci      return &emit_R16G16B16A16_SNORM;
457bf215546Sopenharmony_ci
458bf215546Sopenharmony_ci   case PIPE_FORMAT_R16_SSCALED:
459bf215546Sopenharmony_ci      return &emit_R16_SSCALED;
460bf215546Sopenharmony_ci   case PIPE_FORMAT_R16G16_SSCALED:
461bf215546Sopenharmony_ci      return &emit_R16G16_SSCALED;
462bf215546Sopenharmony_ci   case PIPE_FORMAT_R16G16B16_SSCALED:
463bf215546Sopenharmony_ci      return &emit_R16G16B16_SSCALED;
464bf215546Sopenharmony_ci   case PIPE_FORMAT_R16G16B16A16_SSCALED:
465bf215546Sopenharmony_ci      return &emit_R16G16B16A16_SSCALED;
466bf215546Sopenharmony_ci
467bf215546Sopenharmony_ci   case PIPE_FORMAT_R8_UNORM:
468bf215546Sopenharmony_ci      return &emit_R8_UNORM;
469bf215546Sopenharmony_ci   case PIPE_FORMAT_R8G8_UNORM:
470bf215546Sopenharmony_ci      return &emit_R8G8_UNORM;
471bf215546Sopenharmony_ci   case PIPE_FORMAT_R8G8B8_UNORM:
472bf215546Sopenharmony_ci      return &emit_R8G8B8_UNORM;
473bf215546Sopenharmony_ci   case PIPE_FORMAT_R8G8B8A8_UNORM:
474bf215546Sopenharmony_ci      return &emit_R8G8B8A8_UNORM;
475bf215546Sopenharmony_ci
476bf215546Sopenharmony_ci   case PIPE_FORMAT_R8_USCALED:
477bf215546Sopenharmony_ci      return &emit_R8_USCALED;
478bf215546Sopenharmony_ci   case PIPE_FORMAT_R8G8_USCALED:
479bf215546Sopenharmony_ci      return &emit_R8G8_USCALED;
480bf215546Sopenharmony_ci   case PIPE_FORMAT_R8G8B8_USCALED:
481bf215546Sopenharmony_ci      return &emit_R8G8B8_USCALED;
482bf215546Sopenharmony_ci   case PIPE_FORMAT_R8G8B8A8_USCALED:
483bf215546Sopenharmony_ci      return &emit_R8G8B8A8_USCALED;
484bf215546Sopenharmony_ci
485bf215546Sopenharmony_ci   case PIPE_FORMAT_R8_SNORM:
486bf215546Sopenharmony_ci      return &emit_R8_SNORM;
487bf215546Sopenharmony_ci   case PIPE_FORMAT_R8G8_SNORM:
488bf215546Sopenharmony_ci      return &emit_R8G8_SNORM;
489bf215546Sopenharmony_ci   case PIPE_FORMAT_R8G8B8_SNORM:
490bf215546Sopenharmony_ci      return &emit_R8G8B8_SNORM;
491bf215546Sopenharmony_ci   case PIPE_FORMAT_R8G8B8A8_SNORM:
492bf215546Sopenharmony_ci      return &emit_R8G8B8A8_SNORM;
493bf215546Sopenharmony_ci
494bf215546Sopenharmony_ci   case PIPE_FORMAT_R8_SSCALED:
495bf215546Sopenharmony_ci      return &emit_R8_SSCALED;
496bf215546Sopenharmony_ci   case PIPE_FORMAT_R8G8_SSCALED:
497bf215546Sopenharmony_ci      return &emit_R8G8_SSCALED;
498bf215546Sopenharmony_ci   case PIPE_FORMAT_R8G8B8_SSCALED:
499bf215546Sopenharmony_ci      return &emit_R8G8B8_SSCALED;
500bf215546Sopenharmony_ci   case PIPE_FORMAT_R8G8B8A8_SSCALED:
501bf215546Sopenharmony_ci      return &emit_R8G8B8A8_SSCALED;
502bf215546Sopenharmony_ci
503bf215546Sopenharmony_ci   case PIPE_FORMAT_B8G8R8A8_UNORM:
504bf215546Sopenharmony_ci      return &emit_B8G8R8A8_UNORM;
505bf215546Sopenharmony_ci
506bf215546Sopenharmony_ci   case PIPE_FORMAT_A8R8G8B8_UNORM:
507bf215546Sopenharmony_ci      return &emit_A8R8G8B8_UNORM;
508bf215546Sopenharmony_ci
509bf215546Sopenharmony_ci   case PIPE_FORMAT_R32_UINT:
510bf215546Sopenharmony_ci      return &emit_R32_UINT;
511bf215546Sopenharmony_ci   case PIPE_FORMAT_R32G32_UINT:
512bf215546Sopenharmony_ci      return &emit_R32G32_UINT;
513bf215546Sopenharmony_ci   case PIPE_FORMAT_R32G32B32_UINT:
514bf215546Sopenharmony_ci      return &emit_R32G32B32_UINT;
515bf215546Sopenharmony_ci   case PIPE_FORMAT_R32G32B32A32_UINT:
516bf215546Sopenharmony_ci      return &emit_R32G32B32A32_UINT;
517bf215546Sopenharmony_ci
518bf215546Sopenharmony_ci   case PIPE_FORMAT_R16_UINT:
519bf215546Sopenharmony_ci      return &emit_R16_UINT;
520bf215546Sopenharmony_ci   case PIPE_FORMAT_R16G16_UINT:
521bf215546Sopenharmony_ci      return &emit_R16G16_UINT;
522bf215546Sopenharmony_ci   case PIPE_FORMAT_R16G16B16_UINT:
523bf215546Sopenharmony_ci      return &emit_R16G16B16_UINT;
524bf215546Sopenharmony_ci   case PIPE_FORMAT_R16G16B16A16_UINT:
525bf215546Sopenharmony_ci      return &emit_R16G16B16A16_UINT;
526bf215546Sopenharmony_ci
527bf215546Sopenharmony_ci   case PIPE_FORMAT_R8_UINT:
528bf215546Sopenharmony_ci      return &emit_R8_UINT;
529bf215546Sopenharmony_ci   case PIPE_FORMAT_R8G8_UINT:
530bf215546Sopenharmony_ci      return &emit_R8G8_UINT;
531bf215546Sopenharmony_ci   case PIPE_FORMAT_R8G8B8_UINT:
532bf215546Sopenharmony_ci      return &emit_R8G8B8_UINT;
533bf215546Sopenharmony_ci   case PIPE_FORMAT_R8G8B8A8_UINT:
534bf215546Sopenharmony_ci      return &emit_R8G8B8A8_UINT;
535bf215546Sopenharmony_ci
536bf215546Sopenharmony_ci   case PIPE_FORMAT_R32_SINT:
537bf215546Sopenharmony_ci      return &emit_R32_SINT;
538bf215546Sopenharmony_ci   case PIPE_FORMAT_R32G32_SINT:
539bf215546Sopenharmony_ci      return &emit_R32G32_SINT;
540bf215546Sopenharmony_ci   case PIPE_FORMAT_R32G32B32_SINT:
541bf215546Sopenharmony_ci      return &emit_R32G32B32_SINT;
542bf215546Sopenharmony_ci   case PIPE_FORMAT_R32G32B32A32_SINT:
543bf215546Sopenharmony_ci      return &emit_R32G32B32A32_SINT;
544bf215546Sopenharmony_ci
545bf215546Sopenharmony_ci   case PIPE_FORMAT_R16_SINT:
546bf215546Sopenharmony_ci      return &emit_R16_SINT;
547bf215546Sopenharmony_ci   case PIPE_FORMAT_R16G16_SINT:
548bf215546Sopenharmony_ci      return &emit_R16G16_SINT;
549bf215546Sopenharmony_ci   case PIPE_FORMAT_R16G16B16_SINT:
550bf215546Sopenharmony_ci      return &emit_R16G16B16_SINT;
551bf215546Sopenharmony_ci   case PIPE_FORMAT_R16G16B16A16_SINT:
552bf215546Sopenharmony_ci      return &emit_R16G16B16A16_SINT;
553bf215546Sopenharmony_ci
554bf215546Sopenharmony_ci   case PIPE_FORMAT_R8_SINT:
555bf215546Sopenharmony_ci      return &emit_R8_SINT;
556bf215546Sopenharmony_ci   case PIPE_FORMAT_R8G8_SINT:
557bf215546Sopenharmony_ci      return &emit_R8G8_SINT;
558bf215546Sopenharmony_ci   case PIPE_FORMAT_R8G8B8_SINT:
559bf215546Sopenharmony_ci      return &emit_R8G8B8_SINT;
560bf215546Sopenharmony_ci   case PIPE_FORMAT_R8G8B8A8_SINT:
561bf215546Sopenharmony_ci      return &emit_R8G8B8A8_SINT;
562bf215546Sopenharmony_ci
563bf215546Sopenharmony_ci   case PIPE_FORMAT_B10G10R10A2_UNORM:
564bf215546Sopenharmony_ci      return &emit_B10G10R10A2_UNORM;
565bf215546Sopenharmony_ci   case PIPE_FORMAT_B10G10R10A2_USCALED:
566bf215546Sopenharmony_ci      return &emit_B10G10R10A2_USCALED;
567bf215546Sopenharmony_ci   case PIPE_FORMAT_B10G10R10A2_SNORM:
568bf215546Sopenharmony_ci      return &emit_B10G10R10A2_SNORM;
569bf215546Sopenharmony_ci   case PIPE_FORMAT_B10G10R10A2_SSCALED:
570bf215546Sopenharmony_ci      return &emit_B10G10R10A2_SSCALED;
571bf215546Sopenharmony_ci
572bf215546Sopenharmony_ci   case PIPE_FORMAT_R10G10B10A2_UNORM:
573bf215546Sopenharmony_ci      return &emit_R10G10B10A2_UNORM;
574bf215546Sopenharmony_ci   case PIPE_FORMAT_R10G10B10A2_USCALED:
575bf215546Sopenharmony_ci      return &emit_R10G10B10A2_USCALED;
576bf215546Sopenharmony_ci   case PIPE_FORMAT_R10G10B10A2_SNORM:
577bf215546Sopenharmony_ci      return &emit_R10G10B10A2_SNORM;
578bf215546Sopenharmony_ci   case PIPE_FORMAT_R10G10B10A2_SSCALED:
579bf215546Sopenharmony_ci      return &emit_R10G10B10A2_SSCALED;
580bf215546Sopenharmony_ci
581bf215546Sopenharmony_ci   default:
582bf215546Sopenharmony_ci      assert(0);
583bf215546Sopenharmony_ci      return &emit_NULL;
584bf215546Sopenharmony_ci   }
585bf215546Sopenharmony_ci}
586bf215546Sopenharmony_ci
587bf215546Sopenharmony_cistatic ALWAYS_INLINE void PIPE_CDECL
588bf215546Sopenharmony_cigeneric_run_one(struct translate_generic *tg,
589bf215546Sopenharmony_ci                unsigned elt,
590bf215546Sopenharmony_ci                unsigned start_instance,
591bf215546Sopenharmony_ci                unsigned instance_id,
592bf215546Sopenharmony_ci                void *vert)
593bf215546Sopenharmony_ci{
594bf215546Sopenharmony_ci   unsigned nr_attrs = tg->nr_attrib;
595bf215546Sopenharmony_ci   unsigned attr;
596bf215546Sopenharmony_ci
597bf215546Sopenharmony_ci   for (attr = 0; attr < nr_attrs; attr++) {
598bf215546Sopenharmony_ci      float data[4];
599bf215546Sopenharmony_ci      uint8_t *dst = (uint8_t *)vert + tg->attrib[attr].output_offset;
600bf215546Sopenharmony_ci
601bf215546Sopenharmony_ci      if (tg->attrib[attr].type == TRANSLATE_ELEMENT_NORMAL) {
602bf215546Sopenharmony_ci         const uint8_t *src;
603bf215546Sopenharmony_ci         unsigned index;
604bf215546Sopenharmony_ci         int copy_size;
605bf215546Sopenharmony_ci
606bf215546Sopenharmony_ci         if (tg->attrib[attr].instance_divisor) {
607bf215546Sopenharmony_ci            index = start_instance;
608bf215546Sopenharmony_ci            index += (instance_id  / tg->attrib[attr].instance_divisor);
609bf215546Sopenharmony_ci            /* XXX we need to clamp the index here too, but to a
610bf215546Sopenharmony_ci             * per-array max value, not the draw->pt.max_index value
611bf215546Sopenharmony_ci             * that's being given to us via translate->set_buffer().
612bf215546Sopenharmony_ci             */
613bf215546Sopenharmony_ci         }
614bf215546Sopenharmony_ci         else {
615bf215546Sopenharmony_ci            index = elt;
616bf215546Sopenharmony_ci            /* clamp to avoid going out of bounds */
617bf215546Sopenharmony_ci            index = MIN2(index, tg->attrib[attr].max_index);
618bf215546Sopenharmony_ci         }
619bf215546Sopenharmony_ci
620bf215546Sopenharmony_ci         src = tg->attrib[attr].input_ptr +
621bf215546Sopenharmony_ci               (ptrdiff_t)tg->attrib[attr].input_stride * index;
622bf215546Sopenharmony_ci
623bf215546Sopenharmony_ci         copy_size = tg->attrib[attr].copy_size;
624bf215546Sopenharmony_ci         if (likely(copy_size >= 0)) {
625bf215546Sopenharmony_ci            memcpy(dst, src, copy_size);
626bf215546Sopenharmony_ci         } else {
627bf215546Sopenharmony_ci            tg->attrib[attr].fetch(data, src, 1);
628bf215546Sopenharmony_ci
629bf215546Sopenharmony_ci            if (0)
630bf215546Sopenharmony_ci               debug_printf("Fetch linear attr %d  from %p  stride %d  index %d: "
631bf215546Sopenharmony_ci                         " %f, %f, %f, %f \n",
632bf215546Sopenharmony_ci                         attr,
633bf215546Sopenharmony_ci                         tg->attrib[attr].input_ptr,
634bf215546Sopenharmony_ci                         tg->attrib[attr].input_stride,
635bf215546Sopenharmony_ci                         index,
636bf215546Sopenharmony_ci                         data[0], data[1],data[2], data[3]);
637bf215546Sopenharmony_ci
638bf215546Sopenharmony_ci            tg->attrib[attr].emit(data, dst);
639bf215546Sopenharmony_ci         }
640bf215546Sopenharmony_ci      } else {
641bf215546Sopenharmony_ci         if (likely(tg->attrib[attr].copy_size >= 0)) {
642bf215546Sopenharmony_ci            memcpy(data, &instance_id, 4);
643bf215546Sopenharmony_ci         } else {
644bf215546Sopenharmony_ci            data[0] = (float)instance_id;
645bf215546Sopenharmony_ci            tg->attrib[attr].emit(data, dst);
646bf215546Sopenharmony_ci         }
647bf215546Sopenharmony_ci      }
648bf215546Sopenharmony_ci   }
649bf215546Sopenharmony_ci}
650bf215546Sopenharmony_ci
651bf215546Sopenharmony_ci/**
652bf215546Sopenharmony_ci * Fetch vertex attributes for 'count' vertices.
653bf215546Sopenharmony_ci */
654bf215546Sopenharmony_cistatic void PIPE_CDECL
655bf215546Sopenharmony_cigeneric_run_elts(struct translate *translate,
656bf215546Sopenharmony_ci                 const unsigned *elts,
657bf215546Sopenharmony_ci                 unsigned count,
658bf215546Sopenharmony_ci                 unsigned start_instance,
659bf215546Sopenharmony_ci                 unsigned instance_id,
660bf215546Sopenharmony_ci                 void *output_buffer)
661bf215546Sopenharmony_ci{
662bf215546Sopenharmony_ci   struct translate_generic *tg = translate_generic(translate);
663bf215546Sopenharmony_ci   char *vert = output_buffer;
664bf215546Sopenharmony_ci   unsigned i;
665bf215546Sopenharmony_ci
666bf215546Sopenharmony_ci   for (i = 0; i < count; i++) {
667bf215546Sopenharmony_ci      generic_run_one(tg, *elts++, start_instance, instance_id, vert);
668bf215546Sopenharmony_ci      vert += tg->translate.key.output_stride;
669bf215546Sopenharmony_ci   }
670bf215546Sopenharmony_ci}
671bf215546Sopenharmony_ci
672bf215546Sopenharmony_cistatic void PIPE_CDECL
673bf215546Sopenharmony_cigeneric_run_elts16(struct translate *translate,
674bf215546Sopenharmony_ci                   const uint16_t *elts,
675bf215546Sopenharmony_ci                   unsigned count,
676bf215546Sopenharmony_ci                   unsigned start_instance,
677bf215546Sopenharmony_ci                   unsigned instance_id,
678bf215546Sopenharmony_ci                   void *output_buffer)
679bf215546Sopenharmony_ci{
680bf215546Sopenharmony_ci   struct translate_generic *tg = translate_generic(translate);
681bf215546Sopenharmony_ci   char *vert = output_buffer;
682bf215546Sopenharmony_ci   unsigned i;
683bf215546Sopenharmony_ci
684bf215546Sopenharmony_ci   for (i = 0; i < count; i++) {
685bf215546Sopenharmony_ci      generic_run_one(tg, *elts++, start_instance, instance_id, vert);
686bf215546Sopenharmony_ci      vert += tg->translate.key.output_stride;
687bf215546Sopenharmony_ci   }
688bf215546Sopenharmony_ci}
689bf215546Sopenharmony_ci
690bf215546Sopenharmony_cistatic void PIPE_CDECL
691bf215546Sopenharmony_cigeneric_run_elts8(struct translate *translate,
692bf215546Sopenharmony_ci                  const uint8_t *elts,
693bf215546Sopenharmony_ci                  unsigned count,
694bf215546Sopenharmony_ci                  unsigned start_instance,
695bf215546Sopenharmony_ci                  unsigned instance_id,
696bf215546Sopenharmony_ci                  void *output_buffer)
697bf215546Sopenharmony_ci{
698bf215546Sopenharmony_ci   struct translate_generic *tg = translate_generic(translate);
699bf215546Sopenharmony_ci   char *vert = output_buffer;
700bf215546Sopenharmony_ci   unsigned i;
701bf215546Sopenharmony_ci
702bf215546Sopenharmony_ci   for (i = 0; i < count; i++) {
703bf215546Sopenharmony_ci      generic_run_one(tg, *elts++, start_instance, instance_id, vert);
704bf215546Sopenharmony_ci      vert += tg->translate.key.output_stride;
705bf215546Sopenharmony_ci   }
706bf215546Sopenharmony_ci}
707bf215546Sopenharmony_ci
708bf215546Sopenharmony_cistatic void PIPE_CDECL
709bf215546Sopenharmony_cigeneric_run(struct translate *translate,
710bf215546Sopenharmony_ci            unsigned start,
711bf215546Sopenharmony_ci            unsigned count,
712bf215546Sopenharmony_ci            unsigned start_instance,
713bf215546Sopenharmony_ci            unsigned instance_id,
714bf215546Sopenharmony_ci            void *output_buffer)
715bf215546Sopenharmony_ci{
716bf215546Sopenharmony_ci   struct translate_generic *tg = translate_generic(translate);
717bf215546Sopenharmony_ci   char *vert = output_buffer;
718bf215546Sopenharmony_ci   unsigned i;
719bf215546Sopenharmony_ci
720bf215546Sopenharmony_ci   for (i = 0; i < count; i++) {
721bf215546Sopenharmony_ci      generic_run_one(tg, start + i, start_instance, instance_id, vert);
722bf215546Sopenharmony_ci      vert += tg->translate.key.output_stride;
723bf215546Sopenharmony_ci   }
724bf215546Sopenharmony_ci}
725bf215546Sopenharmony_ci
726bf215546Sopenharmony_ci
727bf215546Sopenharmony_ci
728bf215546Sopenharmony_cistatic void
729bf215546Sopenharmony_cigeneric_set_buffer(struct translate *translate,
730bf215546Sopenharmony_ci                   unsigned buf,
731bf215546Sopenharmony_ci                   const void *ptr,
732bf215546Sopenharmony_ci                   unsigned stride,
733bf215546Sopenharmony_ci                   unsigned max_index)
734bf215546Sopenharmony_ci{
735bf215546Sopenharmony_ci   struct translate_generic *tg = translate_generic(translate);
736bf215546Sopenharmony_ci   unsigned i;
737bf215546Sopenharmony_ci
738bf215546Sopenharmony_ci   for (i = 0; i < tg->nr_attrib; i++) {
739bf215546Sopenharmony_ci      if (tg->attrib[i].buffer == buf) {
740bf215546Sopenharmony_ci         tg->attrib[i].input_ptr = ((const uint8_t *)ptr +
741bf215546Sopenharmony_ci                                    tg->attrib[i].input_offset);
742bf215546Sopenharmony_ci         tg->attrib[i].input_stride = stride;
743bf215546Sopenharmony_ci         tg->attrib[i].max_index = max_index;
744bf215546Sopenharmony_ci      }
745bf215546Sopenharmony_ci   }
746bf215546Sopenharmony_ci}
747bf215546Sopenharmony_ci
748bf215546Sopenharmony_ci
749bf215546Sopenharmony_cistatic void
750bf215546Sopenharmony_cigeneric_release(struct translate *translate)
751bf215546Sopenharmony_ci{
752bf215546Sopenharmony_ci   /* Refcount?
753bf215546Sopenharmony_ci    */
754bf215546Sopenharmony_ci   FREE(translate);
755bf215546Sopenharmony_ci}
756bf215546Sopenharmony_ci
757bf215546Sopenharmony_cistatic boolean
758bf215546Sopenharmony_ciis_legal_int_format_combo(const struct util_format_description *src,
759bf215546Sopenharmony_ci                          const struct util_format_description *dst)
760bf215546Sopenharmony_ci{
761bf215546Sopenharmony_ci   unsigned i;
762bf215546Sopenharmony_ci   unsigned nr = MIN2(src->nr_channels, dst->nr_channels);
763bf215546Sopenharmony_ci
764bf215546Sopenharmony_ci   for (i = 0; i < nr; i++) {
765bf215546Sopenharmony_ci      /* The signs must match. */
766bf215546Sopenharmony_ci      if (src->channel[i].type != dst->channel[i].type) {
767bf215546Sopenharmony_ci         return FALSE;
768bf215546Sopenharmony_ci      }
769bf215546Sopenharmony_ci
770bf215546Sopenharmony_ci      /* Integers must not lose precision at any point in the pipeline. */
771bf215546Sopenharmony_ci      if (src->channel[i].size > dst->channel[i].size) {
772bf215546Sopenharmony_ci         return FALSE;
773bf215546Sopenharmony_ci      }
774bf215546Sopenharmony_ci   }
775bf215546Sopenharmony_ci   return TRUE;
776bf215546Sopenharmony_ci}
777bf215546Sopenharmony_ci
778bf215546Sopenharmony_cistruct translate *
779bf215546Sopenharmony_citranslate_generic_create(const struct translate_key *key)
780bf215546Sopenharmony_ci{
781bf215546Sopenharmony_ci   struct translate_generic *tg = CALLOC_STRUCT(translate_generic);
782bf215546Sopenharmony_ci   unsigned i;
783bf215546Sopenharmony_ci
784bf215546Sopenharmony_ci   if (!tg)
785bf215546Sopenharmony_ci      return NULL;
786bf215546Sopenharmony_ci
787bf215546Sopenharmony_ci   assert(key->nr_elements <= TRANSLATE_MAX_ATTRIBS);
788bf215546Sopenharmony_ci
789bf215546Sopenharmony_ci   tg->translate.key = *key;
790bf215546Sopenharmony_ci   tg->translate.release = generic_release;
791bf215546Sopenharmony_ci   tg->translate.set_buffer = generic_set_buffer;
792bf215546Sopenharmony_ci   tg->translate.run_elts = generic_run_elts;
793bf215546Sopenharmony_ci   tg->translate.run_elts16 = generic_run_elts16;
794bf215546Sopenharmony_ci   tg->translate.run_elts8 = generic_run_elts8;
795bf215546Sopenharmony_ci   tg->translate.run = generic_run;
796bf215546Sopenharmony_ci
797bf215546Sopenharmony_ci   for (i = 0; i < key->nr_elements; i++) {
798bf215546Sopenharmony_ci      const struct util_format_description *format_desc =
799bf215546Sopenharmony_ci            util_format_description(key->element[i].input_format);
800bf215546Sopenharmony_ci      const struct util_format_unpack_description *unpack =
801bf215546Sopenharmony_ci         util_format_unpack_description(key->element[i].input_format);
802bf215546Sopenharmony_ci
803bf215546Sopenharmony_ci      tg->attrib[i].type = key->element[i].type;
804bf215546Sopenharmony_ci
805bf215546Sopenharmony_ci      if (format_desc->channel[0].pure_integer) {
806bf215546Sopenharmony_ci         const struct util_format_description *out_format_desc =
807bf215546Sopenharmony_ci               util_format_description(key->element[i].output_format);
808bf215546Sopenharmony_ci
809bf215546Sopenharmony_ci         if (!is_legal_int_format_combo(format_desc, out_format_desc)) {
810bf215546Sopenharmony_ci            FREE(tg);
811bf215546Sopenharmony_ci            return NULL;
812bf215546Sopenharmony_ci         }
813bf215546Sopenharmony_ci      }
814bf215546Sopenharmony_ci
815bf215546Sopenharmony_ci      tg->attrib[i].fetch = unpack->unpack_rgba;
816bf215546Sopenharmony_ci      tg->attrib[i].buffer = key->element[i].input_buffer;
817bf215546Sopenharmony_ci      tg->attrib[i].input_offset = key->element[i].input_offset;
818bf215546Sopenharmony_ci      tg->attrib[i].instance_divisor = key->element[i].instance_divisor;
819bf215546Sopenharmony_ci
820bf215546Sopenharmony_ci      tg->attrib[i].output_offset = key->element[i].output_offset;
821bf215546Sopenharmony_ci
822bf215546Sopenharmony_ci      tg->attrib[i].copy_size = -1;
823bf215546Sopenharmony_ci      if (tg->attrib[i].type == TRANSLATE_ELEMENT_INSTANCE_ID) {
824bf215546Sopenharmony_ci         if (key->element[i].output_format == PIPE_FORMAT_R32_USCALED
825bf215546Sopenharmony_ci             || key->element[i].output_format == PIPE_FORMAT_R32_SSCALED)
826bf215546Sopenharmony_ci            tg->attrib[i].copy_size = 4;
827bf215546Sopenharmony_ci      } else {
828bf215546Sopenharmony_ci         if (key->element[i].input_format == key->element[i].output_format
829bf215546Sopenharmony_ci             && format_desc->block.width == 1
830bf215546Sopenharmony_ci             && format_desc->block.height == 1
831bf215546Sopenharmony_ci             && !(format_desc->block.bits & 7))
832bf215546Sopenharmony_ci            tg->attrib[i].copy_size = format_desc->block.bits >> 3;
833bf215546Sopenharmony_ci      }
834bf215546Sopenharmony_ci
835bf215546Sopenharmony_ci      if (tg->attrib[i].copy_size < 0)
836bf215546Sopenharmony_ci         tg->attrib[i].emit = get_emit_func(key->element[i].output_format);
837bf215546Sopenharmony_ci      else
838bf215546Sopenharmony_ci         tg->attrib[i].emit  = NULL;
839bf215546Sopenharmony_ci   }
840bf215546Sopenharmony_ci
841bf215546Sopenharmony_ci   tg->nr_attrib = key->nr_elements;
842bf215546Sopenharmony_ci
843bf215546Sopenharmony_ci   return &tg->translate;
844bf215546Sopenharmony_ci}
845bf215546Sopenharmony_ci
846bf215546Sopenharmony_ciboolean
847bf215546Sopenharmony_citranslate_generic_is_output_format_supported(enum pipe_format format)
848bf215546Sopenharmony_ci{
849bf215546Sopenharmony_ci   switch(format) {
850bf215546Sopenharmony_ci   case PIPE_FORMAT_R64G64B64A64_FLOAT: return TRUE;
851bf215546Sopenharmony_ci   case PIPE_FORMAT_R64G64B64_FLOAT: return TRUE;
852bf215546Sopenharmony_ci   case PIPE_FORMAT_R64G64_FLOAT: return TRUE;
853bf215546Sopenharmony_ci   case PIPE_FORMAT_R64_FLOAT: return TRUE;
854bf215546Sopenharmony_ci
855bf215546Sopenharmony_ci   case PIPE_FORMAT_R32G32B32A32_FLOAT: return TRUE;
856bf215546Sopenharmony_ci   case PIPE_FORMAT_R32G32B32_FLOAT: return TRUE;
857bf215546Sopenharmony_ci   case PIPE_FORMAT_R32G32_FLOAT: return TRUE;
858bf215546Sopenharmony_ci   case PIPE_FORMAT_R32_FLOAT: return TRUE;
859bf215546Sopenharmony_ci
860bf215546Sopenharmony_ci   case PIPE_FORMAT_R16G16B16A16_FLOAT: return TRUE;
861bf215546Sopenharmony_ci   case PIPE_FORMAT_R16G16B16_FLOAT: return TRUE;
862bf215546Sopenharmony_ci   case PIPE_FORMAT_R16G16_FLOAT: return TRUE;
863bf215546Sopenharmony_ci   case PIPE_FORMAT_R16_FLOAT: return TRUE;
864bf215546Sopenharmony_ci
865bf215546Sopenharmony_ci   case PIPE_FORMAT_R32G32B32A32_USCALED: return TRUE;
866bf215546Sopenharmony_ci   case PIPE_FORMAT_R32G32B32_USCALED: return TRUE;
867bf215546Sopenharmony_ci   case PIPE_FORMAT_R32G32_USCALED: return TRUE;
868bf215546Sopenharmony_ci   case PIPE_FORMAT_R32_USCALED: return TRUE;
869bf215546Sopenharmony_ci
870bf215546Sopenharmony_ci   case PIPE_FORMAT_R32G32B32A32_SSCALED: return TRUE;
871bf215546Sopenharmony_ci   case PIPE_FORMAT_R32G32B32_SSCALED: return TRUE;
872bf215546Sopenharmony_ci   case PIPE_FORMAT_R32G32_SSCALED: return TRUE;
873bf215546Sopenharmony_ci   case PIPE_FORMAT_R32_SSCALED: return TRUE;
874bf215546Sopenharmony_ci
875bf215546Sopenharmony_ci   case PIPE_FORMAT_R32G32B32A32_UNORM: return TRUE;
876bf215546Sopenharmony_ci   case PIPE_FORMAT_R32G32B32_UNORM: return TRUE;
877bf215546Sopenharmony_ci   case PIPE_FORMAT_R32G32_UNORM: return TRUE;
878bf215546Sopenharmony_ci   case PIPE_FORMAT_R32_UNORM: return TRUE;
879bf215546Sopenharmony_ci
880bf215546Sopenharmony_ci   case PIPE_FORMAT_R32G32B32A32_SNORM: return TRUE;
881bf215546Sopenharmony_ci   case PIPE_FORMAT_R32G32B32_SNORM: return TRUE;
882bf215546Sopenharmony_ci   case PIPE_FORMAT_R32G32_SNORM: return TRUE;
883bf215546Sopenharmony_ci   case PIPE_FORMAT_R32_SNORM: return TRUE;
884bf215546Sopenharmony_ci
885bf215546Sopenharmony_ci   case PIPE_FORMAT_R16G16B16A16_USCALED: return TRUE;
886bf215546Sopenharmony_ci   case PIPE_FORMAT_R16G16B16_USCALED: return TRUE;
887bf215546Sopenharmony_ci   case PIPE_FORMAT_R16G16_USCALED: return TRUE;
888bf215546Sopenharmony_ci   case PIPE_FORMAT_R16_USCALED: return TRUE;
889bf215546Sopenharmony_ci
890bf215546Sopenharmony_ci   case PIPE_FORMAT_R16G16B16A16_SSCALED: return TRUE;
891bf215546Sopenharmony_ci   case PIPE_FORMAT_R16G16B16_SSCALED: return TRUE;
892bf215546Sopenharmony_ci   case PIPE_FORMAT_R16G16_SSCALED: return TRUE;
893bf215546Sopenharmony_ci   case PIPE_FORMAT_R16_SSCALED: return TRUE;
894bf215546Sopenharmony_ci
895bf215546Sopenharmony_ci   case PIPE_FORMAT_R16G16B16A16_UNORM: return TRUE;
896bf215546Sopenharmony_ci   case PIPE_FORMAT_R16G16B16_UNORM: return TRUE;
897bf215546Sopenharmony_ci   case PIPE_FORMAT_R16G16_UNORM: return TRUE;
898bf215546Sopenharmony_ci   case PIPE_FORMAT_R16_UNORM: return TRUE;
899bf215546Sopenharmony_ci
900bf215546Sopenharmony_ci   case PIPE_FORMAT_R16G16B16A16_SNORM: return TRUE;
901bf215546Sopenharmony_ci   case PIPE_FORMAT_R16G16B16_SNORM: return TRUE;
902bf215546Sopenharmony_ci   case PIPE_FORMAT_R16G16_SNORM: return TRUE;
903bf215546Sopenharmony_ci   case PIPE_FORMAT_R16_SNORM: return TRUE;
904bf215546Sopenharmony_ci
905bf215546Sopenharmony_ci   case PIPE_FORMAT_R8G8B8A8_USCALED: return TRUE;
906bf215546Sopenharmony_ci   case PIPE_FORMAT_R8G8B8_USCALED: return TRUE;
907bf215546Sopenharmony_ci   case PIPE_FORMAT_R8G8_USCALED: return TRUE;
908bf215546Sopenharmony_ci   case PIPE_FORMAT_R8_USCALED: return TRUE;
909bf215546Sopenharmony_ci
910bf215546Sopenharmony_ci   case PIPE_FORMAT_R8G8B8A8_SSCALED: return TRUE;
911bf215546Sopenharmony_ci   case PIPE_FORMAT_R8G8B8_SSCALED: return TRUE;
912bf215546Sopenharmony_ci   case PIPE_FORMAT_R8G8_SSCALED: return TRUE;
913bf215546Sopenharmony_ci   case PIPE_FORMAT_R8_SSCALED: return TRUE;
914bf215546Sopenharmony_ci
915bf215546Sopenharmony_ci   case PIPE_FORMAT_R8G8B8A8_UNORM: return TRUE;
916bf215546Sopenharmony_ci   case PIPE_FORMAT_R8G8B8_UNORM: return TRUE;
917bf215546Sopenharmony_ci   case PIPE_FORMAT_R8G8_UNORM: return TRUE;
918bf215546Sopenharmony_ci   case PIPE_FORMAT_R8_UNORM: return TRUE;
919bf215546Sopenharmony_ci
920bf215546Sopenharmony_ci   case PIPE_FORMAT_R8G8B8A8_SNORM: return TRUE;
921bf215546Sopenharmony_ci   case PIPE_FORMAT_R8G8B8_SNORM: return TRUE;
922bf215546Sopenharmony_ci   case PIPE_FORMAT_R8G8_SNORM: return TRUE;
923bf215546Sopenharmony_ci   case PIPE_FORMAT_R8_SNORM: return TRUE;
924bf215546Sopenharmony_ci
925bf215546Sopenharmony_ci   case PIPE_FORMAT_A8R8G8B8_UNORM: return TRUE;
926bf215546Sopenharmony_ci   case PIPE_FORMAT_B8G8R8A8_UNORM: return TRUE;
927bf215546Sopenharmony_ci
928bf215546Sopenharmony_ci   case PIPE_FORMAT_R32G32B32A32_UINT: return TRUE;
929bf215546Sopenharmony_ci   case PIPE_FORMAT_R32G32B32_UINT: return TRUE;
930bf215546Sopenharmony_ci   case PIPE_FORMAT_R32G32_UINT: return TRUE;
931bf215546Sopenharmony_ci   case PIPE_FORMAT_R32_UINT: return TRUE;
932bf215546Sopenharmony_ci
933bf215546Sopenharmony_ci   case PIPE_FORMAT_R16G16B16A16_UINT: return TRUE;
934bf215546Sopenharmony_ci   case PIPE_FORMAT_R16G16B16_UINT: return TRUE;
935bf215546Sopenharmony_ci   case PIPE_FORMAT_R16G16_UINT: return TRUE;
936bf215546Sopenharmony_ci   case PIPE_FORMAT_R16_UINT: return TRUE;
937bf215546Sopenharmony_ci
938bf215546Sopenharmony_ci   case PIPE_FORMAT_R8G8B8A8_UINT: return TRUE;
939bf215546Sopenharmony_ci   case PIPE_FORMAT_R8G8B8_UINT: return TRUE;
940bf215546Sopenharmony_ci   case PIPE_FORMAT_R8G8_UINT: return TRUE;
941bf215546Sopenharmony_ci   case PIPE_FORMAT_R8_UINT: return TRUE;
942bf215546Sopenharmony_ci
943bf215546Sopenharmony_ci   case PIPE_FORMAT_R32G32B32A32_SINT: return TRUE;
944bf215546Sopenharmony_ci   case PIPE_FORMAT_R32G32B32_SINT: return TRUE;
945bf215546Sopenharmony_ci   case PIPE_FORMAT_R32G32_SINT: return TRUE;
946bf215546Sopenharmony_ci   case PIPE_FORMAT_R32_SINT: return TRUE;
947bf215546Sopenharmony_ci
948bf215546Sopenharmony_ci   case PIPE_FORMAT_R16G16B16A16_SINT: return TRUE;
949bf215546Sopenharmony_ci   case PIPE_FORMAT_R16G16B16_SINT: return TRUE;
950bf215546Sopenharmony_ci   case PIPE_FORMAT_R16G16_SINT: return TRUE;
951bf215546Sopenharmony_ci   case PIPE_FORMAT_R16_SINT: return TRUE;
952bf215546Sopenharmony_ci
953bf215546Sopenharmony_ci   case PIPE_FORMAT_R8G8B8A8_SINT: return TRUE;
954bf215546Sopenharmony_ci   case PIPE_FORMAT_R8G8B8_SINT: return TRUE;
955bf215546Sopenharmony_ci   case PIPE_FORMAT_R8G8_SINT: return TRUE;
956bf215546Sopenharmony_ci   case PIPE_FORMAT_R8_SINT: return TRUE;
957bf215546Sopenharmony_ci
958bf215546Sopenharmony_ci   case PIPE_FORMAT_B10G10R10A2_UNORM: return TRUE;
959bf215546Sopenharmony_ci   case PIPE_FORMAT_B10G10R10A2_USCALED: return TRUE;
960bf215546Sopenharmony_ci   case PIPE_FORMAT_B10G10R10A2_SNORM: return TRUE;
961bf215546Sopenharmony_ci   case PIPE_FORMAT_B10G10R10A2_SSCALED: return TRUE;
962bf215546Sopenharmony_ci
963bf215546Sopenharmony_ci   case PIPE_FORMAT_R10G10B10A2_UNORM: return TRUE;
964bf215546Sopenharmony_ci   case PIPE_FORMAT_R10G10B10A2_USCALED: return TRUE;
965bf215546Sopenharmony_ci   case PIPE_FORMAT_R10G10B10A2_SNORM: return TRUE;
966bf215546Sopenharmony_ci   case PIPE_FORMAT_R10G10B10A2_SSCALED: return TRUE;
967bf215546Sopenharmony_ci
968bf215546Sopenharmony_ci   default: return FALSE;
969bf215546Sopenharmony_ci   }
970bf215546Sopenharmony_ci}
971