1b8e80941Smrg/*
2b8e80941Smrg * Mesa 3-D graphics library
3b8e80941Smrg *
4b8e80941Smrg * Copyright (c) 2011 VMware, Inc.
5b8e80941Smrg * Copyright (c) 2014 Intel Corporation.
6b8e80941Smrg *
7b8e80941Smrg * Permission is hereby granted, free of charge, to any person obtaining a
8b8e80941Smrg * copy of this software and associated documentation files (the "Software"),
9b8e80941Smrg * to deal in the Software without restriction, including without limitation
10b8e80941Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11b8e80941Smrg * and/or sell copies of the Software, and to permit persons to whom the
12b8e80941Smrg * Software is furnished to do so, subject to the following conditions:
13b8e80941Smrg *
14b8e80941Smrg * The above copyright notice and this permission notice shall be included
15b8e80941Smrg * in all copies or substantial portions of the Software.
16b8e80941Smrg *
17b8e80941Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18b8e80941Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19b8e80941Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
20b8e80941Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21b8e80941Smrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22b8e80941Smrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23b8e80941Smrg * OTHER DEALINGS IN THE SOFTWARE.
24b8e80941Smrg */
25b8e80941Smrg
26b8e80941Smrg
27b8e80941Smrg/**
28b8e80941Smrg * Color, depth, stencil packing functions.
29b8e80941Smrg * Used to pack basic color, depth and stencil formats to specific
30b8e80941Smrg * hardware formats.
31b8e80941Smrg *
32b8e80941Smrg * There are both per-pixel and per-row packing functions:
33b8e80941Smrg * - The former will be used by swrast to write values to the color, depth,
34b8e80941Smrg *   stencil buffers when drawing points, lines and masked spans.
35b8e80941Smrg * - The later will be used for image-oriented functions like glDrawPixels,
36b8e80941Smrg *   glAccum, and glTexImage.
37b8e80941Smrg */
38b8e80941Smrg
39b8e80941Smrg#include <stdint.h>
40b8e80941Smrg
41b8e80941Smrg#include "config.h"
42b8e80941Smrg#include "errors.h"
43b8e80941Smrg#include "format_pack.h"
44b8e80941Smrg#include "format_utils.h"
45b8e80941Smrg#include "macros.h"
46b8e80941Smrg#include "util/format_rgb9e5.h"
47b8e80941Smrg#include "util/format_r11g11b10f.h"
48b8e80941Smrg#include "util/format_srgb.h"
49b8e80941Smrg
50b8e80941Smrg#define UNPACK(SRC, OFFSET, BITS) (((SRC) >> (OFFSET)) & MAX_UINT(BITS))
51b8e80941Smrg#define PACK(SRC, OFFSET, BITS) (((SRC) & MAX_UINT(BITS)) << (OFFSET))
52b8e80941Smrg
53b8e80941Smrg
54b8e80941Smrg
55b8e80941Smrg/* ubyte packing functions */
56b8e80941Smrg
57b8e80941Smrg
58b8e80941Smrgstatic inline void
59b8e80941Smrgpack_ubyte_a8b8g8r8_unorm(const GLubyte src[4], void *dst)
60b8e80941Smrg{
61b8e80941Smrg
62b8e80941Smrg
63b8e80941Smrg      uint8_t a =
64b8e80941Smrg            _mesa_unorm_to_unorm(src[3], 8, 8);
65b8e80941Smrg
66b8e80941Smrg
67b8e80941Smrg      uint8_t b =
68b8e80941Smrg            _mesa_unorm_to_unorm(src[2], 8, 8);
69b8e80941Smrg
70b8e80941Smrg
71b8e80941Smrg      uint8_t g =
72b8e80941Smrg            _mesa_unorm_to_unorm(src[1], 8, 8);
73b8e80941Smrg
74b8e80941Smrg
75b8e80941Smrg      uint8_t r =
76b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 8);
77b8e80941Smrg
78b8e80941Smrg      uint32_t d = 0;
79b8e80941Smrg         d |= PACK(a, 0, 8);
80b8e80941Smrg         d |= PACK(b, 8, 8);
81b8e80941Smrg         d |= PACK(g, 16, 8);
82b8e80941Smrg         d |= PACK(r, 24, 8);
83b8e80941Smrg      (*(uint32_t *)dst) = d;
84b8e80941Smrg}
85b8e80941Smrg
86b8e80941Smrgstatic inline void
87b8e80941Smrgpack_ubyte_x8b8g8r8_unorm(const GLubyte src[4], void *dst)
88b8e80941Smrg{
89b8e80941Smrg
90b8e80941Smrg
91b8e80941Smrg
92b8e80941Smrg      uint8_t b =
93b8e80941Smrg            _mesa_unorm_to_unorm(src[2], 8, 8);
94b8e80941Smrg
95b8e80941Smrg
96b8e80941Smrg      uint8_t g =
97b8e80941Smrg            _mesa_unorm_to_unorm(src[1], 8, 8);
98b8e80941Smrg
99b8e80941Smrg
100b8e80941Smrg      uint8_t r =
101b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 8);
102b8e80941Smrg
103b8e80941Smrg      uint32_t d = 0;
104b8e80941Smrg                     d |= PACK(b, 8, 8);
105b8e80941Smrg         d |= PACK(g, 16, 8);
106b8e80941Smrg         d |= PACK(r, 24, 8);
107b8e80941Smrg      (*(uint32_t *)dst) = d;
108b8e80941Smrg}
109b8e80941Smrg
110b8e80941Smrgstatic inline void
111b8e80941Smrgpack_ubyte_r8g8b8a8_unorm(const GLubyte src[4], void *dst)
112b8e80941Smrg{
113b8e80941Smrg
114b8e80941Smrg
115b8e80941Smrg      uint8_t r =
116b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 8);
117b8e80941Smrg
118b8e80941Smrg
119b8e80941Smrg      uint8_t g =
120b8e80941Smrg            _mesa_unorm_to_unorm(src[1], 8, 8);
121b8e80941Smrg
122b8e80941Smrg
123b8e80941Smrg      uint8_t b =
124b8e80941Smrg            _mesa_unorm_to_unorm(src[2], 8, 8);
125b8e80941Smrg
126b8e80941Smrg
127b8e80941Smrg      uint8_t a =
128b8e80941Smrg            _mesa_unorm_to_unorm(src[3], 8, 8);
129b8e80941Smrg
130b8e80941Smrg      uint32_t d = 0;
131b8e80941Smrg         d |= PACK(r, 0, 8);
132b8e80941Smrg         d |= PACK(g, 8, 8);
133b8e80941Smrg         d |= PACK(b, 16, 8);
134b8e80941Smrg         d |= PACK(a, 24, 8);
135b8e80941Smrg      (*(uint32_t *)dst) = d;
136b8e80941Smrg}
137b8e80941Smrg
138b8e80941Smrgstatic inline void
139b8e80941Smrgpack_ubyte_r8g8b8x8_unorm(const GLubyte src[4], void *dst)
140b8e80941Smrg{
141b8e80941Smrg
142b8e80941Smrg
143b8e80941Smrg      uint8_t r =
144b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 8);
145b8e80941Smrg
146b8e80941Smrg
147b8e80941Smrg      uint8_t g =
148b8e80941Smrg            _mesa_unorm_to_unorm(src[1], 8, 8);
149b8e80941Smrg
150b8e80941Smrg
151b8e80941Smrg      uint8_t b =
152b8e80941Smrg            _mesa_unorm_to_unorm(src[2], 8, 8);
153b8e80941Smrg
154b8e80941Smrg
155b8e80941Smrg      uint32_t d = 0;
156b8e80941Smrg         d |= PACK(r, 0, 8);
157b8e80941Smrg         d |= PACK(g, 8, 8);
158b8e80941Smrg         d |= PACK(b, 16, 8);
159b8e80941Smrg                  (*(uint32_t *)dst) = d;
160b8e80941Smrg}
161b8e80941Smrg
162b8e80941Smrgstatic inline void
163b8e80941Smrgpack_ubyte_b8g8r8a8_unorm(const GLubyte src[4], void *dst)
164b8e80941Smrg{
165b8e80941Smrg
166b8e80941Smrg
167b8e80941Smrg      uint8_t b =
168b8e80941Smrg            _mesa_unorm_to_unorm(src[2], 8, 8);
169b8e80941Smrg
170b8e80941Smrg
171b8e80941Smrg      uint8_t g =
172b8e80941Smrg            _mesa_unorm_to_unorm(src[1], 8, 8);
173b8e80941Smrg
174b8e80941Smrg
175b8e80941Smrg      uint8_t r =
176b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 8);
177b8e80941Smrg
178b8e80941Smrg
179b8e80941Smrg      uint8_t a =
180b8e80941Smrg            _mesa_unorm_to_unorm(src[3], 8, 8);
181b8e80941Smrg
182b8e80941Smrg      uint32_t d = 0;
183b8e80941Smrg         d |= PACK(b, 0, 8);
184b8e80941Smrg         d |= PACK(g, 8, 8);
185b8e80941Smrg         d |= PACK(r, 16, 8);
186b8e80941Smrg         d |= PACK(a, 24, 8);
187b8e80941Smrg      (*(uint32_t *)dst) = d;
188b8e80941Smrg}
189b8e80941Smrg
190b8e80941Smrgstatic inline void
191b8e80941Smrgpack_ubyte_b8g8r8x8_unorm(const GLubyte src[4], void *dst)
192b8e80941Smrg{
193b8e80941Smrg
194b8e80941Smrg
195b8e80941Smrg      uint8_t b =
196b8e80941Smrg            _mesa_unorm_to_unorm(src[2], 8, 8);
197b8e80941Smrg
198b8e80941Smrg
199b8e80941Smrg      uint8_t g =
200b8e80941Smrg            _mesa_unorm_to_unorm(src[1], 8, 8);
201b8e80941Smrg
202b8e80941Smrg
203b8e80941Smrg      uint8_t r =
204b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 8);
205b8e80941Smrg
206b8e80941Smrg
207b8e80941Smrg      uint32_t d = 0;
208b8e80941Smrg         d |= PACK(b, 0, 8);
209b8e80941Smrg         d |= PACK(g, 8, 8);
210b8e80941Smrg         d |= PACK(r, 16, 8);
211b8e80941Smrg                  (*(uint32_t *)dst) = d;
212b8e80941Smrg}
213b8e80941Smrg
214b8e80941Smrgstatic inline void
215b8e80941Smrgpack_ubyte_a8r8g8b8_unorm(const GLubyte src[4], void *dst)
216b8e80941Smrg{
217b8e80941Smrg
218b8e80941Smrg
219b8e80941Smrg      uint8_t a =
220b8e80941Smrg            _mesa_unorm_to_unorm(src[3], 8, 8);
221b8e80941Smrg
222b8e80941Smrg
223b8e80941Smrg      uint8_t r =
224b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 8);
225b8e80941Smrg
226b8e80941Smrg
227b8e80941Smrg      uint8_t g =
228b8e80941Smrg            _mesa_unorm_to_unorm(src[1], 8, 8);
229b8e80941Smrg
230b8e80941Smrg
231b8e80941Smrg      uint8_t b =
232b8e80941Smrg            _mesa_unorm_to_unorm(src[2], 8, 8);
233b8e80941Smrg
234b8e80941Smrg      uint32_t d = 0;
235b8e80941Smrg         d |= PACK(a, 0, 8);
236b8e80941Smrg         d |= PACK(r, 8, 8);
237b8e80941Smrg         d |= PACK(g, 16, 8);
238b8e80941Smrg         d |= PACK(b, 24, 8);
239b8e80941Smrg      (*(uint32_t *)dst) = d;
240b8e80941Smrg}
241b8e80941Smrg
242b8e80941Smrgstatic inline void
243b8e80941Smrgpack_ubyte_x8r8g8b8_unorm(const GLubyte src[4], void *dst)
244b8e80941Smrg{
245b8e80941Smrg
246b8e80941Smrg
247b8e80941Smrg
248b8e80941Smrg      uint8_t r =
249b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 8);
250b8e80941Smrg
251b8e80941Smrg
252b8e80941Smrg      uint8_t g =
253b8e80941Smrg            _mesa_unorm_to_unorm(src[1], 8, 8);
254b8e80941Smrg
255b8e80941Smrg
256b8e80941Smrg      uint8_t b =
257b8e80941Smrg            _mesa_unorm_to_unorm(src[2], 8, 8);
258b8e80941Smrg
259b8e80941Smrg      uint32_t d = 0;
260b8e80941Smrg                     d |= PACK(r, 8, 8);
261b8e80941Smrg         d |= PACK(g, 16, 8);
262b8e80941Smrg         d |= PACK(b, 24, 8);
263b8e80941Smrg      (*(uint32_t *)dst) = d;
264b8e80941Smrg}
265b8e80941Smrg
266b8e80941Smrgstatic inline void
267b8e80941Smrgpack_ubyte_l16a16_unorm(const GLubyte src[4], void *dst)
268b8e80941Smrg{
269b8e80941Smrg
270b8e80941Smrg
271b8e80941Smrg      uint16_t l =
272b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 16);
273b8e80941Smrg
274b8e80941Smrg
275b8e80941Smrg      uint16_t a =
276b8e80941Smrg            _mesa_unorm_to_unorm(src[3], 8, 16);
277b8e80941Smrg
278b8e80941Smrg      uint32_t d = 0;
279b8e80941Smrg         d |= PACK(l, 0, 16);
280b8e80941Smrg         d |= PACK(a, 16, 16);
281b8e80941Smrg      (*(uint32_t *)dst) = d;
282b8e80941Smrg}
283b8e80941Smrg
284b8e80941Smrgstatic inline void
285b8e80941Smrgpack_ubyte_a16l16_unorm(const GLubyte src[4], void *dst)
286b8e80941Smrg{
287b8e80941Smrg
288b8e80941Smrg
289b8e80941Smrg      uint16_t a =
290b8e80941Smrg            _mesa_unorm_to_unorm(src[3], 8, 16);
291b8e80941Smrg
292b8e80941Smrg
293b8e80941Smrg      uint16_t l =
294b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 16);
295b8e80941Smrg
296b8e80941Smrg      uint32_t d = 0;
297b8e80941Smrg         d |= PACK(a, 0, 16);
298b8e80941Smrg         d |= PACK(l, 16, 16);
299b8e80941Smrg      (*(uint32_t *)dst) = d;
300b8e80941Smrg}
301b8e80941Smrg
302b8e80941Smrgstatic inline void
303b8e80941Smrgpack_ubyte_b5g6r5_unorm(const GLubyte src[4], void *dst)
304b8e80941Smrg{
305b8e80941Smrg
306b8e80941Smrg
307b8e80941Smrg      uint8_t b =
308b8e80941Smrg            _mesa_unorm_to_unorm(src[2], 8, 5);
309b8e80941Smrg
310b8e80941Smrg
311b8e80941Smrg      uint8_t g =
312b8e80941Smrg            _mesa_unorm_to_unorm(src[1], 8, 6);
313b8e80941Smrg
314b8e80941Smrg
315b8e80941Smrg      uint8_t r =
316b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 5);
317b8e80941Smrg
318b8e80941Smrg      uint16_t d = 0;
319b8e80941Smrg         d |= PACK(b, 0, 5);
320b8e80941Smrg         d |= PACK(g, 5, 6);
321b8e80941Smrg         d |= PACK(r, 11, 5);
322b8e80941Smrg      (*(uint16_t *)dst) = d;
323b8e80941Smrg}
324b8e80941Smrg
325b8e80941Smrgstatic inline void
326b8e80941Smrgpack_ubyte_r5g6b5_unorm(const GLubyte src[4], void *dst)
327b8e80941Smrg{
328b8e80941Smrg
329b8e80941Smrg
330b8e80941Smrg      uint8_t r =
331b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 5);
332b8e80941Smrg
333b8e80941Smrg
334b8e80941Smrg      uint8_t g =
335b8e80941Smrg            _mesa_unorm_to_unorm(src[1], 8, 6);
336b8e80941Smrg
337b8e80941Smrg
338b8e80941Smrg      uint8_t b =
339b8e80941Smrg            _mesa_unorm_to_unorm(src[2], 8, 5);
340b8e80941Smrg
341b8e80941Smrg      uint16_t d = 0;
342b8e80941Smrg         d |= PACK(r, 0, 5);
343b8e80941Smrg         d |= PACK(g, 5, 6);
344b8e80941Smrg         d |= PACK(b, 11, 5);
345b8e80941Smrg      (*(uint16_t *)dst) = d;
346b8e80941Smrg}
347b8e80941Smrg
348b8e80941Smrgstatic inline void
349b8e80941Smrgpack_ubyte_b4g4r4a4_unorm(const GLubyte src[4], void *dst)
350b8e80941Smrg{
351b8e80941Smrg
352b8e80941Smrg
353b8e80941Smrg      uint8_t b =
354b8e80941Smrg            _mesa_unorm_to_unorm(src[2], 8, 4);
355b8e80941Smrg
356b8e80941Smrg
357b8e80941Smrg      uint8_t g =
358b8e80941Smrg            _mesa_unorm_to_unorm(src[1], 8, 4);
359b8e80941Smrg
360b8e80941Smrg
361b8e80941Smrg      uint8_t r =
362b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 4);
363b8e80941Smrg
364b8e80941Smrg
365b8e80941Smrg      uint8_t a =
366b8e80941Smrg            _mesa_unorm_to_unorm(src[3], 8, 4);
367b8e80941Smrg
368b8e80941Smrg      uint16_t d = 0;
369b8e80941Smrg         d |= PACK(b, 0, 4);
370b8e80941Smrg         d |= PACK(g, 4, 4);
371b8e80941Smrg         d |= PACK(r, 8, 4);
372b8e80941Smrg         d |= PACK(a, 12, 4);
373b8e80941Smrg      (*(uint16_t *)dst) = d;
374b8e80941Smrg}
375b8e80941Smrg
376b8e80941Smrgstatic inline void
377b8e80941Smrgpack_ubyte_b4g4r4x4_unorm(const GLubyte src[4], void *dst)
378b8e80941Smrg{
379b8e80941Smrg
380b8e80941Smrg
381b8e80941Smrg      uint8_t b =
382b8e80941Smrg            _mesa_unorm_to_unorm(src[2], 8, 4);
383b8e80941Smrg
384b8e80941Smrg
385b8e80941Smrg      uint8_t g =
386b8e80941Smrg            _mesa_unorm_to_unorm(src[1], 8, 4);
387b8e80941Smrg
388b8e80941Smrg
389b8e80941Smrg      uint8_t r =
390b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 4);
391b8e80941Smrg
392b8e80941Smrg
393b8e80941Smrg      uint16_t d = 0;
394b8e80941Smrg         d |= PACK(b, 0, 4);
395b8e80941Smrg         d |= PACK(g, 4, 4);
396b8e80941Smrg         d |= PACK(r, 8, 4);
397b8e80941Smrg                  (*(uint16_t *)dst) = d;
398b8e80941Smrg}
399b8e80941Smrg
400b8e80941Smrgstatic inline void
401b8e80941Smrgpack_ubyte_a4r4g4b4_unorm(const GLubyte src[4], void *dst)
402b8e80941Smrg{
403b8e80941Smrg
404b8e80941Smrg
405b8e80941Smrg      uint8_t a =
406b8e80941Smrg            _mesa_unorm_to_unorm(src[3], 8, 4);
407b8e80941Smrg
408b8e80941Smrg
409b8e80941Smrg      uint8_t r =
410b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 4);
411b8e80941Smrg
412b8e80941Smrg
413b8e80941Smrg      uint8_t g =
414b8e80941Smrg            _mesa_unorm_to_unorm(src[1], 8, 4);
415b8e80941Smrg
416b8e80941Smrg
417b8e80941Smrg      uint8_t b =
418b8e80941Smrg            _mesa_unorm_to_unorm(src[2], 8, 4);
419b8e80941Smrg
420b8e80941Smrg      uint16_t d = 0;
421b8e80941Smrg         d |= PACK(a, 0, 4);
422b8e80941Smrg         d |= PACK(r, 4, 4);
423b8e80941Smrg         d |= PACK(g, 8, 4);
424b8e80941Smrg         d |= PACK(b, 12, 4);
425b8e80941Smrg      (*(uint16_t *)dst) = d;
426b8e80941Smrg}
427b8e80941Smrg
428b8e80941Smrgstatic inline void
429b8e80941Smrgpack_ubyte_a1b5g5r5_unorm(const GLubyte src[4], void *dst)
430b8e80941Smrg{
431b8e80941Smrg
432b8e80941Smrg
433b8e80941Smrg      uint8_t a =
434b8e80941Smrg            _mesa_unorm_to_unorm(src[3], 8, 1);
435b8e80941Smrg
436b8e80941Smrg
437b8e80941Smrg      uint8_t b =
438b8e80941Smrg            _mesa_unorm_to_unorm(src[2], 8, 5);
439b8e80941Smrg
440b8e80941Smrg
441b8e80941Smrg      uint8_t g =
442b8e80941Smrg            _mesa_unorm_to_unorm(src[1], 8, 5);
443b8e80941Smrg
444b8e80941Smrg
445b8e80941Smrg      uint8_t r =
446b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 5);
447b8e80941Smrg
448b8e80941Smrg      uint16_t d = 0;
449b8e80941Smrg         d |= PACK(a, 0, 1);
450b8e80941Smrg         d |= PACK(b, 1, 5);
451b8e80941Smrg         d |= PACK(g, 6, 5);
452b8e80941Smrg         d |= PACK(r, 11, 5);
453b8e80941Smrg      (*(uint16_t *)dst) = d;
454b8e80941Smrg}
455b8e80941Smrg
456b8e80941Smrgstatic inline void
457b8e80941Smrgpack_ubyte_x1b5g5r5_unorm(const GLubyte src[4], void *dst)
458b8e80941Smrg{
459b8e80941Smrg
460b8e80941Smrg
461b8e80941Smrg
462b8e80941Smrg      uint8_t b =
463b8e80941Smrg            _mesa_unorm_to_unorm(src[2], 8, 5);
464b8e80941Smrg
465b8e80941Smrg
466b8e80941Smrg      uint8_t g =
467b8e80941Smrg            _mesa_unorm_to_unorm(src[1], 8, 5);
468b8e80941Smrg
469b8e80941Smrg
470b8e80941Smrg      uint8_t r =
471b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 5);
472b8e80941Smrg
473b8e80941Smrg      uint16_t d = 0;
474b8e80941Smrg                     d |= PACK(b, 1, 5);
475b8e80941Smrg         d |= PACK(g, 6, 5);
476b8e80941Smrg         d |= PACK(r, 11, 5);
477b8e80941Smrg      (*(uint16_t *)dst) = d;
478b8e80941Smrg}
479b8e80941Smrg
480b8e80941Smrgstatic inline void
481b8e80941Smrgpack_ubyte_b5g5r5a1_unorm(const GLubyte src[4], void *dst)
482b8e80941Smrg{
483b8e80941Smrg
484b8e80941Smrg
485b8e80941Smrg      uint8_t b =
486b8e80941Smrg            _mesa_unorm_to_unorm(src[2], 8, 5);
487b8e80941Smrg
488b8e80941Smrg
489b8e80941Smrg      uint8_t g =
490b8e80941Smrg            _mesa_unorm_to_unorm(src[1], 8, 5);
491b8e80941Smrg
492b8e80941Smrg
493b8e80941Smrg      uint8_t r =
494b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 5);
495b8e80941Smrg
496b8e80941Smrg
497b8e80941Smrg      uint8_t a =
498b8e80941Smrg            _mesa_unorm_to_unorm(src[3], 8, 1);
499b8e80941Smrg
500b8e80941Smrg      uint16_t d = 0;
501b8e80941Smrg         d |= PACK(b, 0, 5);
502b8e80941Smrg         d |= PACK(g, 5, 5);
503b8e80941Smrg         d |= PACK(r, 10, 5);
504b8e80941Smrg         d |= PACK(a, 15, 1);
505b8e80941Smrg      (*(uint16_t *)dst) = d;
506b8e80941Smrg}
507b8e80941Smrg
508b8e80941Smrgstatic inline void
509b8e80941Smrgpack_ubyte_b5g5r5x1_unorm(const GLubyte src[4], void *dst)
510b8e80941Smrg{
511b8e80941Smrg
512b8e80941Smrg
513b8e80941Smrg      uint8_t b =
514b8e80941Smrg            _mesa_unorm_to_unorm(src[2], 8, 5);
515b8e80941Smrg
516b8e80941Smrg
517b8e80941Smrg      uint8_t g =
518b8e80941Smrg            _mesa_unorm_to_unorm(src[1], 8, 5);
519b8e80941Smrg
520b8e80941Smrg
521b8e80941Smrg      uint8_t r =
522b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 5);
523b8e80941Smrg
524b8e80941Smrg
525b8e80941Smrg      uint16_t d = 0;
526b8e80941Smrg         d |= PACK(b, 0, 5);
527b8e80941Smrg         d |= PACK(g, 5, 5);
528b8e80941Smrg         d |= PACK(r, 10, 5);
529b8e80941Smrg                  (*(uint16_t *)dst) = d;
530b8e80941Smrg}
531b8e80941Smrg
532b8e80941Smrgstatic inline void
533b8e80941Smrgpack_ubyte_a1r5g5b5_unorm(const GLubyte src[4], void *dst)
534b8e80941Smrg{
535b8e80941Smrg
536b8e80941Smrg
537b8e80941Smrg      uint8_t a =
538b8e80941Smrg            _mesa_unorm_to_unorm(src[3], 8, 1);
539b8e80941Smrg
540b8e80941Smrg
541b8e80941Smrg      uint8_t r =
542b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 5);
543b8e80941Smrg
544b8e80941Smrg
545b8e80941Smrg      uint8_t g =
546b8e80941Smrg            _mesa_unorm_to_unorm(src[1], 8, 5);
547b8e80941Smrg
548b8e80941Smrg
549b8e80941Smrg      uint8_t b =
550b8e80941Smrg            _mesa_unorm_to_unorm(src[2], 8, 5);
551b8e80941Smrg
552b8e80941Smrg      uint16_t d = 0;
553b8e80941Smrg         d |= PACK(a, 0, 1);
554b8e80941Smrg         d |= PACK(r, 1, 5);
555b8e80941Smrg         d |= PACK(g, 6, 5);
556b8e80941Smrg         d |= PACK(b, 11, 5);
557b8e80941Smrg      (*(uint16_t *)dst) = d;
558b8e80941Smrg}
559b8e80941Smrg
560b8e80941Smrgstatic inline void
561b8e80941Smrgpack_ubyte_l8a8_unorm(const GLubyte src[4], void *dst)
562b8e80941Smrg{
563b8e80941Smrg
564b8e80941Smrg
565b8e80941Smrg      uint8_t l =
566b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 8);
567b8e80941Smrg
568b8e80941Smrg
569b8e80941Smrg      uint8_t a =
570b8e80941Smrg            _mesa_unorm_to_unorm(src[3], 8, 8);
571b8e80941Smrg
572b8e80941Smrg      uint16_t d = 0;
573b8e80941Smrg         d |= PACK(l, 0, 8);
574b8e80941Smrg         d |= PACK(a, 8, 8);
575b8e80941Smrg      (*(uint16_t *)dst) = d;
576b8e80941Smrg}
577b8e80941Smrg
578b8e80941Smrgstatic inline void
579b8e80941Smrgpack_ubyte_a8l8_unorm(const GLubyte src[4], void *dst)
580b8e80941Smrg{
581b8e80941Smrg
582b8e80941Smrg
583b8e80941Smrg      uint8_t a =
584b8e80941Smrg            _mesa_unorm_to_unorm(src[3], 8, 8);
585b8e80941Smrg
586b8e80941Smrg
587b8e80941Smrg      uint8_t l =
588b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 8);
589b8e80941Smrg
590b8e80941Smrg      uint16_t d = 0;
591b8e80941Smrg         d |= PACK(a, 0, 8);
592b8e80941Smrg         d |= PACK(l, 8, 8);
593b8e80941Smrg      (*(uint16_t *)dst) = d;
594b8e80941Smrg}
595b8e80941Smrg
596b8e80941Smrgstatic inline void
597b8e80941Smrgpack_ubyte_r8g8_unorm(const GLubyte src[4], void *dst)
598b8e80941Smrg{
599b8e80941Smrg
600b8e80941Smrg
601b8e80941Smrg      uint8_t r =
602b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 8);
603b8e80941Smrg
604b8e80941Smrg
605b8e80941Smrg      uint8_t g =
606b8e80941Smrg            _mesa_unorm_to_unorm(src[1], 8, 8);
607b8e80941Smrg
608b8e80941Smrg      uint16_t d = 0;
609b8e80941Smrg         d |= PACK(r, 0, 8);
610b8e80941Smrg         d |= PACK(g, 8, 8);
611b8e80941Smrg      (*(uint16_t *)dst) = d;
612b8e80941Smrg}
613b8e80941Smrg
614b8e80941Smrgstatic inline void
615b8e80941Smrgpack_ubyte_g8r8_unorm(const GLubyte src[4], void *dst)
616b8e80941Smrg{
617b8e80941Smrg
618b8e80941Smrg
619b8e80941Smrg      uint8_t g =
620b8e80941Smrg            _mesa_unorm_to_unorm(src[1], 8, 8);
621b8e80941Smrg
622b8e80941Smrg
623b8e80941Smrg      uint8_t r =
624b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 8);
625b8e80941Smrg
626b8e80941Smrg      uint16_t d = 0;
627b8e80941Smrg         d |= PACK(g, 0, 8);
628b8e80941Smrg         d |= PACK(r, 8, 8);
629b8e80941Smrg      (*(uint16_t *)dst) = d;
630b8e80941Smrg}
631b8e80941Smrg
632b8e80941Smrgstatic inline void
633b8e80941Smrgpack_ubyte_l4a4_unorm(const GLubyte src[4], void *dst)
634b8e80941Smrg{
635b8e80941Smrg
636b8e80941Smrg
637b8e80941Smrg      uint8_t l =
638b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 4);
639b8e80941Smrg
640b8e80941Smrg
641b8e80941Smrg      uint8_t a =
642b8e80941Smrg            _mesa_unorm_to_unorm(src[3], 8, 4);
643b8e80941Smrg
644b8e80941Smrg      uint8_t d = 0;
645b8e80941Smrg         d |= PACK(l, 0, 4);
646b8e80941Smrg         d |= PACK(a, 4, 4);
647b8e80941Smrg      (*(uint8_t *)dst) = d;
648b8e80941Smrg}
649b8e80941Smrg
650b8e80941Smrgstatic inline void
651b8e80941Smrgpack_ubyte_b2g3r3_unorm(const GLubyte src[4], void *dst)
652b8e80941Smrg{
653b8e80941Smrg
654b8e80941Smrg
655b8e80941Smrg      uint8_t b =
656b8e80941Smrg            _mesa_unorm_to_unorm(src[2], 8, 2);
657b8e80941Smrg
658b8e80941Smrg
659b8e80941Smrg      uint8_t g =
660b8e80941Smrg            _mesa_unorm_to_unorm(src[1], 8, 3);
661b8e80941Smrg
662b8e80941Smrg
663b8e80941Smrg      uint8_t r =
664b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 3);
665b8e80941Smrg
666b8e80941Smrg      uint8_t d = 0;
667b8e80941Smrg         d |= PACK(b, 0, 2);
668b8e80941Smrg         d |= PACK(g, 2, 3);
669b8e80941Smrg         d |= PACK(r, 5, 3);
670b8e80941Smrg      (*(uint8_t *)dst) = d;
671b8e80941Smrg}
672b8e80941Smrg
673b8e80941Smrgstatic inline void
674b8e80941Smrgpack_ubyte_r16g16_unorm(const GLubyte src[4], void *dst)
675b8e80941Smrg{
676b8e80941Smrg
677b8e80941Smrg
678b8e80941Smrg      uint16_t r =
679b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 16);
680b8e80941Smrg
681b8e80941Smrg
682b8e80941Smrg      uint16_t g =
683b8e80941Smrg            _mesa_unorm_to_unorm(src[1], 8, 16);
684b8e80941Smrg
685b8e80941Smrg      uint32_t d = 0;
686b8e80941Smrg         d |= PACK(r, 0, 16);
687b8e80941Smrg         d |= PACK(g, 16, 16);
688b8e80941Smrg      (*(uint32_t *)dst) = d;
689b8e80941Smrg}
690b8e80941Smrg
691b8e80941Smrgstatic inline void
692b8e80941Smrgpack_ubyte_g16r16_unorm(const GLubyte src[4], void *dst)
693b8e80941Smrg{
694b8e80941Smrg
695b8e80941Smrg
696b8e80941Smrg      uint16_t g =
697b8e80941Smrg            _mesa_unorm_to_unorm(src[1], 8, 16);
698b8e80941Smrg
699b8e80941Smrg
700b8e80941Smrg      uint16_t r =
701b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 16);
702b8e80941Smrg
703b8e80941Smrg      uint32_t d = 0;
704b8e80941Smrg         d |= PACK(g, 0, 16);
705b8e80941Smrg         d |= PACK(r, 16, 16);
706b8e80941Smrg      (*(uint32_t *)dst) = d;
707b8e80941Smrg}
708b8e80941Smrg
709b8e80941Smrgstatic inline void
710b8e80941Smrgpack_ubyte_b10g10r10a2_unorm(const GLubyte src[4], void *dst)
711b8e80941Smrg{
712b8e80941Smrg
713b8e80941Smrg
714b8e80941Smrg      uint16_t b =
715b8e80941Smrg            _mesa_unorm_to_unorm(src[2], 8, 10);
716b8e80941Smrg
717b8e80941Smrg
718b8e80941Smrg      uint16_t g =
719b8e80941Smrg            _mesa_unorm_to_unorm(src[1], 8, 10);
720b8e80941Smrg
721b8e80941Smrg
722b8e80941Smrg      uint16_t r =
723b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 10);
724b8e80941Smrg
725b8e80941Smrg
726b8e80941Smrg      uint8_t a =
727b8e80941Smrg            _mesa_unorm_to_unorm(src[3], 8, 2);
728b8e80941Smrg
729b8e80941Smrg      uint32_t d = 0;
730b8e80941Smrg         d |= PACK(b, 0, 10);
731b8e80941Smrg         d |= PACK(g, 10, 10);
732b8e80941Smrg         d |= PACK(r, 20, 10);
733b8e80941Smrg         d |= PACK(a, 30, 2);
734b8e80941Smrg      (*(uint32_t *)dst) = d;
735b8e80941Smrg}
736b8e80941Smrg
737b8e80941Smrgstatic inline void
738b8e80941Smrgpack_ubyte_b10g10r10x2_unorm(const GLubyte src[4], void *dst)
739b8e80941Smrg{
740b8e80941Smrg
741b8e80941Smrg
742b8e80941Smrg      uint16_t b =
743b8e80941Smrg            _mesa_unorm_to_unorm(src[2], 8, 10);
744b8e80941Smrg
745b8e80941Smrg
746b8e80941Smrg      uint16_t g =
747b8e80941Smrg            _mesa_unorm_to_unorm(src[1], 8, 10);
748b8e80941Smrg
749b8e80941Smrg
750b8e80941Smrg      uint16_t r =
751b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 10);
752b8e80941Smrg
753b8e80941Smrg
754b8e80941Smrg      uint32_t d = 0;
755b8e80941Smrg         d |= PACK(b, 0, 10);
756b8e80941Smrg         d |= PACK(g, 10, 10);
757b8e80941Smrg         d |= PACK(r, 20, 10);
758b8e80941Smrg                  (*(uint32_t *)dst) = d;
759b8e80941Smrg}
760b8e80941Smrg
761b8e80941Smrgstatic inline void
762b8e80941Smrgpack_ubyte_r10g10b10a2_unorm(const GLubyte src[4], void *dst)
763b8e80941Smrg{
764b8e80941Smrg
765b8e80941Smrg
766b8e80941Smrg      uint16_t r =
767b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 10);
768b8e80941Smrg
769b8e80941Smrg
770b8e80941Smrg      uint16_t g =
771b8e80941Smrg            _mesa_unorm_to_unorm(src[1], 8, 10);
772b8e80941Smrg
773b8e80941Smrg
774b8e80941Smrg      uint16_t b =
775b8e80941Smrg            _mesa_unorm_to_unorm(src[2], 8, 10);
776b8e80941Smrg
777b8e80941Smrg
778b8e80941Smrg      uint8_t a =
779b8e80941Smrg            _mesa_unorm_to_unorm(src[3], 8, 2);
780b8e80941Smrg
781b8e80941Smrg      uint32_t d = 0;
782b8e80941Smrg         d |= PACK(r, 0, 10);
783b8e80941Smrg         d |= PACK(g, 10, 10);
784b8e80941Smrg         d |= PACK(b, 20, 10);
785b8e80941Smrg         d |= PACK(a, 30, 2);
786b8e80941Smrg      (*(uint32_t *)dst) = d;
787b8e80941Smrg}
788b8e80941Smrg
789b8e80941Smrgstatic inline void
790b8e80941Smrgpack_ubyte_r10g10b10x2_unorm(const GLubyte src[4], void *dst)
791b8e80941Smrg{
792b8e80941Smrg
793b8e80941Smrg
794b8e80941Smrg      uint16_t r =
795b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 10);
796b8e80941Smrg
797b8e80941Smrg
798b8e80941Smrg      uint16_t g =
799b8e80941Smrg            _mesa_unorm_to_unorm(src[1], 8, 10);
800b8e80941Smrg
801b8e80941Smrg
802b8e80941Smrg      uint16_t b =
803b8e80941Smrg            _mesa_unorm_to_unorm(src[2], 8, 10);
804b8e80941Smrg
805b8e80941Smrg
806b8e80941Smrg      uint32_t d = 0;
807b8e80941Smrg         d |= PACK(r, 0, 10);
808b8e80941Smrg         d |= PACK(g, 10, 10);
809b8e80941Smrg         d |= PACK(b, 20, 10);
810b8e80941Smrg                  (*(uint32_t *)dst) = d;
811b8e80941Smrg}
812b8e80941Smrg
813b8e80941Smrgstatic inline void
814b8e80941Smrgpack_ubyte_r3g3b2_unorm(const GLubyte src[4], void *dst)
815b8e80941Smrg{
816b8e80941Smrg
817b8e80941Smrg
818b8e80941Smrg      uint8_t r =
819b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 3);
820b8e80941Smrg
821b8e80941Smrg
822b8e80941Smrg      uint8_t g =
823b8e80941Smrg            _mesa_unorm_to_unorm(src[1], 8, 3);
824b8e80941Smrg
825b8e80941Smrg
826b8e80941Smrg      uint8_t b =
827b8e80941Smrg            _mesa_unorm_to_unorm(src[2], 8, 2);
828b8e80941Smrg
829b8e80941Smrg      uint8_t d = 0;
830b8e80941Smrg         d |= PACK(r, 0, 3);
831b8e80941Smrg         d |= PACK(g, 3, 3);
832b8e80941Smrg         d |= PACK(b, 6, 2);
833b8e80941Smrg      (*(uint8_t *)dst) = d;
834b8e80941Smrg}
835b8e80941Smrg
836b8e80941Smrgstatic inline void
837b8e80941Smrgpack_ubyte_a4b4g4r4_unorm(const GLubyte src[4], void *dst)
838b8e80941Smrg{
839b8e80941Smrg
840b8e80941Smrg
841b8e80941Smrg      uint8_t a =
842b8e80941Smrg            _mesa_unorm_to_unorm(src[3], 8, 4);
843b8e80941Smrg
844b8e80941Smrg
845b8e80941Smrg      uint8_t b =
846b8e80941Smrg            _mesa_unorm_to_unorm(src[2], 8, 4);
847b8e80941Smrg
848b8e80941Smrg
849b8e80941Smrg      uint8_t g =
850b8e80941Smrg            _mesa_unorm_to_unorm(src[1], 8, 4);
851b8e80941Smrg
852b8e80941Smrg
853b8e80941Smrg      uint8_t r =
854b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 4);
855b8e80941Smrg
856b8e80941Smrg      uint16_t d = 0;
857b8e80941Smrg         d |= PACK(a, 0, 4);
858b8e80941Smrg         d |= PACK(b, 4, 4);
859b8e80941Smrg         d |= PACK(g, 8, 4);
860b8e80941Smrg         d |= PACK(r, 12, 4);
861b8e80941Smrg      (*(uint16_t *)dst) = d;
862b8e80941Smrg}
863b8e80941Smrg
864b8e80941Smrgstatic inline void
865b8e80941Smrgpack_ubyte_r4g4b4a4_unorm(const GLubyte src[4], void *dst)
866b8e80941Smrg{
867b8e80941Smrg
868b8e80941Smrg
869b8e80941Smrg      uint8_t r =
870b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 4);
871b8e80941Smrg
872b8e80941Smrg
873b8e80941Smrg      uint8_t g =
874b8e80941Smrg            _mesa_unorm_to_unorm(src[1], 8, 4);
875b8e80941Smrg
876b8e80941Smrg
877b8e80941Smrg      uint8_t b =
878b8e80941Smrg            _mesa_unorm_to_unorm(src[2], 8, 4);
879b8e80941Smrg
880b8e80941Smrg
881b8e80941Smrg      uint8_t a =
882b8e80941Smrg            _mesa_unorm_to_unorm(src[3], 8, 4);
883b8e80941Smrg
884b8e80941Smrg      uint16_t d = 0;
885b8e80941Smrg         d |= PACK(r, 0, 4);
886b8e80941Smrg         d |= PACK(g, 4, 4);
887b8e80941Smrg         d |= PACK(b, 8, 4);
888b8e80941Smrg         d |= PACK(a, 12, 4);
889b8e80941Smrg      (*(uint16_t *)dst) = d;
890b8e80941Smrg}
891b8e80941Smrg
892b8e80941Smrgstatic inline void
893b8e80941Smrgpack_ubyte_r5g5b5a1_unorm(const GLubyte src[4], void *dst)
894b8e80941Smrg{
895b8e80941Smrg
896b8e80941Smrg
897b8e80941Smrg      uint8_t r =
898b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 5);
899b8e80941Smrg
900b8e80941Smrg
901b8e80941Smrg      uint8_t g =
902b8e80941Smrg            _mesa_unorm_to_unorm(src[1], 8, 5);
903b8e80941Smrg
904b8e80941Smrg
905b8e80941Smrg      uint8_t b =
906b8e80941Smrg            _mesa_unorm_to_unorm(src[2], 8, 5);
907b8e80941Smrg
908b8e80941Smrg
909b8e80941Smrg      uint8_t a =
910b8e80941Smrg            _mesa_unorm_to_unorm(src[3], 8, 1);
911b8e80941Smrg
912b8e80941Smrg      uint16_t d = 0;
913b8e80941Smrg         d |= PACK(r, 0, 5);
914b8e80941Smrg         d |= PACK(g, 5, 5);
915b8e80941Smrg         d |= PACK(b, 10, 5);
916b8e80941Smrg         d |= PACK(a, 15, 1);
917b8e80941Smrg      (*(uint16_t *)dst) = d;
918b8e80941Smrg}
919b8e80941Smrg
920b8e80941Smrgstatic inline void
921b8e80941Smrgpack_ubyte_a2b10g10r10_unorm(const GLubyte src[4], void *dst)
922b8e80941Smrg{
923b8e80941Smrg
924b8e80941Smrg
925b8e80941Smrg      uint8_t a =
926b8e80941Smrg            _mesa_unorm_to_unorm(src[3], 8, 2);
927b8e80941Smrg
928b8e80941Smrg
929b8e80941Smrg      uint16_t b =
930b8e80941Smrg            _mesa_unorm_to_unorm(src[2], 8, 10);
931b8e80941Smrg
932b8e80941Smrg
933b8e80941Smrg      uint16_t g =
934b8e80941Smrg            _mesa_unorm_to_unorm(src[1], 8, 10);
935b8e80941Smrg
936b8e80941Smrg
937b8e80941Smrg      uint16_t r =
938b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 10);
939b8e80941Smrg
940b8e80941Smrg      uint32_t d = 0;
941b8e80941Smrg         d |= PACK(a, 0, 2);
942b8e80941Smrg         d |= PACK(b, 2, 10);
943b8e80941Smrg         d |= PACK(g, 12, 10);
944b8e80941Smrg         d |= PACK(r, 22, 10);
945b8e80941Smrg      (*(uint32_t *)dst) = d;
946b8e80941Smrg}
947b8e80941Smrg
948b8e80941Smrgstatic inline void
949b8e80941Smrgpack_ubyte_a2r10g10b10_unorm(const GLubyte src[4], void *dst)
950b8e80941Smrg{
951b8e80941Smrg
952b8e80941Smrg
953b8e80941Smrg      uint8_t a =
954b8e80941Smrg            _mesa_unorm_to_unorm(src[3], 8, 2);
955b8e80941Smrg
956b8e80941Smrg
957b8e80941Smrg      uint16_t r =
958b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 10);
959b8e80941Smrg
960b8e80941Smrg
961b8e80941Smrg      uint16_t g =
962b8e80941Smrg            _mesa_unorm_to_unorm(src[1], 8, 10);
963b8e80941Smrg
964b8e80941Smrg
965b8e80941Smrg      uint16_t b =
966b8e80941Smrg            _mesa_unorm_to_unorm(src[2], 8, 10);
967b8e80941Smrg
968b8e80941Smrg      uint32_t d = 0;
969b8e80941Smrg         d |= PACK(a, 0, 2);
970b8e80941Smrg         d |= PACK(r, 2, 10);
971b8e80941Smrg         d |= PACK(g, 12, 10);
972b8e80941Smrg         d |= PACK(b, 22, 10);
973b8e80941Smrg      (*(uint32_t *)dst) = d;
974b8e80941Smrg}
975b8e80941Smrg
976b8e80941Smrgstatic inline void
977b8e80941Smrgpack_ubyte_a_unorm8(const GLubyte src[4], void *dst)
978b8e80941Smrg{
979b8e80941Smrg
980b8e80941Smrg
981b8e80941Smrg      uint8_t a =
982b8e80941Smrg            _mesa_unorm_to_unorm(src[3], 8, 8);
983b8e80941Smrg
984b8e80941Smrg      uint8_t *d = (uint8_t *)dst;
985b8e80941Smrg         d[0] = a;
986b8e80941Smrg}
987b8e80941Smrg
988b8e80941Smrgstatic inline void
989b8e80941Smrgpack_ubyte_a_unorm16(const GLubyte src[4], void *dst)
990b8e80941Smrg{
991b8e80941Smrg
992b8e80941Smrg
993b8e80941Smrg      uint16_t a =
994b8e80941Smrg            _mesa_unorm_to_unorm(src[3], 8, 16);
995b8e80941Smrg
996b8e80941Smrg      uint16_t *d = (uint16_t *)dst;
997b8e80941Smrg         d[0] = a;
998b8e80941Smrg}
999b8e80941Smrg
1000b8e80941Smrgstatic inline void
1001b8e80941Smrgpack_ubyte_l_unorm8(const GLubyte src[4], void *dst)
1002b8e80941Smrg{
1003b8e80941Smrg
1004b8e80941Smrg
1005b8e80941Smrg      uint8_t l =
1006b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 8);
1007b8e80941Smrg
1008b8e80941Smrg      uint8_t *d = (uint8_t *)dst;
1009b8e80941Smrg         d[0] = l;
1010b8e80941Smrg}
1011b8e80941Smrg
1012b8e80941Smrgstatic inline void
1013b8e80941Smrgpack_ubyte_l_unorm16(const GLubyte src[4], void *dst)
1014b8e80941Smrg{
1015b8e80941Smrg
1016b8e80941Smrg
1017b8e80941Smrg      uint16_t l =
1018b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 16);
1019b8e80941Smrg
1020b8e80941Smrg      uint16_t *d = (uint16_t *)dst;
1021b8e80941Smrg         d[0] = l;
1022b8e80941Smrg}
1023b8e80941Smrg
1024b8e80941Smrgstatic inline void
1025b8e80941Smrgpack_ubyte_i_unorm8(const GLubyte src[4], void *dst)
1026b8e80941Smrg{
1027b8e80941Smrg
1028b8e80941Smrg
1029b8e80941Smrg      uint8_t i =
1030b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 8);
1031b8e80941Smrg
1032b8e80941Smrg      uint8_t *d = (uint8_t *)dst;
1033b8e80941Smrg         d[0] = i;
1034b8e80941Smrg}
1035b8e80941Smrg
1036b8e80941Smrgstatic inline void
1037b8e80941Smrgpack_ubyte_i_unorm16(const GLubyte src[4], void *dst)
1038b8e80941Smrg{
1039b8e80941Smrg
1040b8e80941Smrg
1041b8e80941Smrg      uint16_t i =
1042b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 16);
1043b8e80941Smrg
1044b8e80941Smrg      uint16_t *d = (uint16_t *)dst;
1045b8e80941Smrg         d[0] = i;
1046b8e80941Smrg}
1047b8e80941Smrg
1048b8e80941Smrgstatic inline void
1049b8e80941Smrgpack_ubyte_r_unorm8(const GLubyte src[4], void *dst)
1050b8e80941Smrg{
1051b8e80941Smrg
1052b8e80941Smrg
1053b8e80941Smrg      uint8_t r =
1054b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 8);
1055b8e80941Smrg
1056b8e80941Smrg      uint8_t *d = (uint8_t *)dst;
1057b8e80941Smrg         d[0] = r;
1058b8e80941Smrg}
1059b8e80941Smrg
1060b8e80941Smrgstatic inline void
1061b8e80941Smrgpack_ubyte_r_unorm16(const GLubyte src[4], void *dst)
1062b8e80941Smrg{
1063b8e80941Smrg
1064b8e80941Smrg
1065b8e80941Smrg      uint16_t r =
1066b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 16);
1067b8e80941Smrg
1068b8e80941Smrg      uint16_t *d = (uint16_t *)dst;
1069b8e80941Smrg         d[0] = r;
1070b8e80941Smrg}
1071b8e80941Smrg
1072b8e80941Smrgstatic inline void
1073b8e80941Smrgpack_ubyte_bgr_unorm8(const GLubyte src[4], void *dst)
1074b8e80941Smrg{
1075b8e80941Smrg
1076b8e80941Smrg
1077b8e80941Smrg      uint8_t b =
1078b8e80941Smrg            _mesa_unorm_to_unorm(src[2], 8, 8);
1079b8e80941Smrg
1080b8e80941Smrg
1081b8e80941Smrg      uint8_t g =
1082b8e80941Smrg            _mesa_unorm_to_unorm(src[1], 8, 8);
1083b8e80941Smrg
1084b8e80941Smrg
1085b8e80941Smrg      uint8_t r =
1086b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 8);
1087b8e80941Smrg
1088b8e80941Smrg      uint8_t *d = (uint8_t *)dst;
1089b8e80941Smrg         d[0] = b;
1090b8e80941Smrg         d[1] = g;
1091b8e80941Smrg         d[2] = r;
1092b8e80941Smrg}
1093b8e80941Smrg
1094b8e80941Smrgstatic inline void
1095b8e80941Smrgpack_ubyte_rgb_unorm8(const GLubyte src[4], void *dst)
1096b8e80941Smrg{
1097b8e80941Smrg
1098b8e80941Smrg
1099b8e80941Smrg      uint8_t r =
1100b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 8);
1101b8e80941Smrg
1102b8e80941Smrg
1103b8e80941Smrg      uint8_t g =
1104b8e80941Smrg            _mesa_unorm_to_unorm(src[1], 8, 8);
1105b8e80941Smrg
1106b8e80941Smrg
1107b8e80941Smrg      uint8_t b =
1108b8e80941Smrg            _mesa_unorm_to_unorm(src[2], 8, 8);
1109b8e80941Smrg
1110b8e80941Smrg      uint8_t *d = (uint8_t *)dst;
1111b8e80941Smrg         d[0] = r;
1112b8e80941Smrg         d[1] = g;
1113b8e80941Smrg         d[2] = b;
1114b8e80941Smrg}
1115b8e80941Smrg
1116b8e80941Smrgstatic inline void
1117b8e80941Smrgpack_ubyte_rgba_unorm16(const GLubyte src[4], void *dst)
1118b8e80941Smrg{
1119b8e80941Smrg
1120b8e80941Smrg
1121b8e80941Smrg      uint16_t r =
1122b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 16);
1123b8e80941Smrg
1124b8e80941Smrg
1125b8e80941Smrg      uint16_t g =
1126b8e80941Smrg            _mesa_unorm_to_unorm(src[1], 8, 16);
1127b8e80941Smrg
1128b8e80941Smrg
1129b8e80941Smrg      uint16_t b =
1130b8e80941Smrg            _mesa_unorm_to_unorm(src[2], 8, 16);
1131b8e80941Smrg
1132b8e80941Smrg
1133b8e80941Smrg      uint16_t a =
1134b8e80941Smrg            _mesa_unorm_to_unorm(src[3], 8, 16);
1135b8e80941Smrg
1136b8e80941Smrg      uint16_t *d = (uint16_t *)dst;
1137b8e80941Smrg         d[0] = r;
1138b8e80941Smrg         d[1] = g;
1139b8e80941Smrg         d[2] = b;
1140b8e80941Smrg         d[3] = a;
1141b8e80941Smrg}
1142b8e80941Smrg
1143b8e80941Smrgstatic inline void
1144b8e80941Smrgpack_ubyte_rgbx_unorm16(const GLubyte src[4], void *dst)
1145b8e80941Smrg{
1146b8e80941Smrg
1147b8e80941Smrg
1148b8e80941Smrg      uint16_t r =
1149b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 16);
1150b8e80941Smrg
1151b8e80941Smrg
1152b8e80941Smrg      uint16_t g =
1153b8e80941Smrg            _mesa_unorm_to_unorm(src[1], 8, 16);
1154b8e80941Smrg
1155b8e80941Smrg
1156b8e80941Smrg      uint16_t b =
1157b8e80941Smrg            _mesa_unorm_to_unorm(src[2], 8, 16);
1158b8e80941Smrg
1159b8e80941Smrg
1160b8e80941Smrg      uint16_t *d = (uint16_t *)dst;
1161b8e80941Smrg         d[0] = r;
1162b8e80941Smrg         d[1] = g;
1163b8e80941Smrg         d[2] = b;
1164b8e80941Smrg            }
1165b8e80941Smrg
1166b8e80941Smrgstatic inline void
1167b8e80941Smrgpack_ubyte_a8b8g8r8_snorm(const GLubyte src[4], void *dst)
1168b8e80941Smrg{
1169b8e80941Smrg
1170b8e80941Smrg
1171b8e80941Smrg      int8_t a =
1172b8e80941Smrg         _mesa_unorm_to_snorm(src[3], 8, 8);
1173b8e80941Smrg
1174b8e80941Smrg
1175b8e80941Smrg      int8_t b =
1176b8e80941Smrg         _mesa_unorm_to_snorm(src[2], 8, 8);
1177b8e80941Smrg
1178b8e80941Smrg
1179b8e80941Smrg      int8_t g =
1180b8e80941Smrg         _mesa_unorm_to_snorm(src[1], 8, 8);
1181b8e80941Smrg
1182b8e80941Smrg
1183b8e80941Smrg      int8_t r =
1184b8e80941Smrg         _mesa_unorm_to_snorm(src[0], 8, 8);
1185b8e80941Smrg
1186b8e80941Smrg      uint32_t d = 0;
1187b8e80941Smrg         d |= PACK(a, 0, 8);
1188b8e80941Smrg         d |= PACK(b, 8, 8);
1189b8e80941Smrg         d |= PACK(g, 16, 8);
1190b8e80941Smrg         d |= PACK(r, 24, 8);
1191b8e80941Smrg      (*(uint32_t *)dst) = d;
1192b8e80941Smrg}
1193b8e80941Smrg
1194b8e80941Smrgstatic inline void
1195b8e80941Smrgpack_ubyte_x8b8g8r8_snorm(const GLubyte src[4], void *dst)
1196b8e80941Smrg{
1197b8e80941Smrg
1198b8e80941Smrg
1199b8e80941Smrg
1200b8e80941Smrg      int8_t b =
1201b8e80941Smrg         _mesa_unorm_to_snorm(src[2], 8, 8);
1202b8e80941Smrg
1203b8e80941Smrg
1204b8e80941Smrg      int8_t g =
1205b8e80941Smrg         _mesa_unorm_to_snorm(src[1], 8, 8);
1206b8e80941Smrg
1207b8e80941Smrg
1208b8e80941Smrg      int8_t r =
1209b8e80941Smrg         _mesa_unorm_to_snorm(src[0], 8, 8);
1210b8e80941Smrg
1211b8e80941Smrg      uint32_t d = 0;
1212b8e80941Smrg                     d |= PACK(b, 8, 8);
1213b8e80941Smrg         d |= PACK(g, 16, 8);
1214b8e80941Smrg         d |= PACK(r, 24, 8);
1215b8e80941Smrg      (*(uint32_t *)dst) = d;
1216b8e80941Smrg}
1217b8e80941Smrg
1218b8e80941Smrgstatic inline void
1219b8e80941Smrgpack_ubyte_r8g8b8a8_snorm(const GLubyte src[4], void *dst)
1220b8e80941Smrg{
1221b8e80941Smrg
1222b8e80941Smrg
1223b8e80941Smrg      int8_t r =
1224b8e80941Smrg         _mesa_unorm_to_snorm(src[0], 8, 8);
1225b8e80941Smrg
1226b8e80941Smrg
1227b8e80941Smrg      int8_t g =
1228b8e80941Smrg         _mesa_unorm_to_snorm(src[1], 8, 8);
1229b8e80941Smrg
1230b8e80941Smrg
1231b8e80941Smrg      int8_t b =
1232b8e80941Smrg         _mesa_unorm_to_snorm(src[2], 8, 8);
1233b8e80941Smrg
1234b8e80941Smrg
1235b8e80941Smrg      int8_t a =
1236b8e80941Smrg         _mesa_unorm_to_snorm(src[3], 8, 8);
1237b8e80941Smrg
1238b8e80941Smrg      uint32_t d = 0;
1239b8e80941Smrg         d |= PACK(r, 0, 8);
1240b8e80941Smrg         d |= PACK(g, 8, 8);
1241b8e80941Smrg         d |= PACK(b, 16, 8);
1242b8e80941Smrg         d |= PACK(a, 24, 8);
1243b8e80941Smrg      (*(uint32_t *)dst) = d;
1244b8e80941Smrg}
1245b8e80941Smrg
1246b8e80941Smrgstatic inline void
1247b8e80941Smrgpack_ubyte_r8g8b8x8_snorm(const GLubyte src[4], void *dst)
1248b8e80941Smrg{
1249b8e80941Smrg
1250b8e80941Smrg
1251b8e80941Smrg      int8_t r =
1252b8e80941Smrg         _mesa_unorm_to_snorm(src[0], 8, 8);
1253b8e80941Smrg
1254b8e80941Smrg
1255b8e80941Smrg      int8_t g =
1256b8e80941Smrg         _mesa_unorm_to_snorm(src[1], 8, 8);
1257b8e80941Smrg
1258b8e80941Smrg
1259b8e80941Smrg      int8_t b =
1260b8e80941Smrg         _mesa_unorm_to_snorm(src[2], 8, 8);
1261b8e80941Smrg
1262b8e80941Smrg
1263b8e80941Smrg      uint32_t d = 0;
1264b8e80941Smrg         d |= PACK(r, 0, 8);
1265b8e80941Smrg         d |= PACK(g, 8, 8);
1266b8e80941Smrg         d |= PACK(b, 16, 8);
1267b8e80941Smrg                  (*(uint32_t *)dst) = d;
1268b8e80941Smrg}
1269b8e80941Smrg
1270b8e80941Smrgstatic inline void
1271b8e80941Smrgpack_ubyte_r16g16_snorm(const GLubyte src[4], void *dst)
1272b8e80941Smrg{
1273b8e80941Smrg
1274b8e80941Smrg
1275b8e80941Smrg      int16_t r =
1276b8e80941Smrg         _mesa_unorm_to_snorm(src[0], 8, 16);
1277b8e80941Smrg
1278b8e80941Smrg
1279b8e80941Smrg      int16_t g =
1280b8e80941Smrg         _mesa_unorm_to_snorm(src[1], 8, 16);
1281b8e80941Smrg
1282b8e80941Smrg      uint32_t d = 0;
1283b8e80941Smrg         d |= PACK(r, 0, 16);
1284b8e80941Smrg         d |= PACK(g, 16, 16);
1285b8e80941Smrg      (*(uint32_t *)dst) = d;
1286b8e80941Smrg}
1287b8e80941Smrg
1288b8e80941Smrgstatic inline void
1289b8e80941Smrgpack_ubyte_g16r16_snorm(const GLubyte src[4], void *dst)
1290b8e80941Smrg{
1291b8e80941Smrg
1292b8e80941Smrg
1293b8e80941Smrg      int16_t g =
1294b8e80941Smrg         _mesa_unorm_to_snorm(src[1], 8, 16);
1295b8e80941Smrg
1296b8e80941Smrg
1297b8e80941Smrg      int16_t r =
1298b8e80941Smrg         _mesa_unorm_to_snorm(src[0], 8, 16);
1299b8e80941Smrg
1300b8e80941Smrg      uint32_t d = 0;
1301b8e80941Smrg         d |= PACK(g, 0, 16);
1302b8e80941Smrg         d |= PACK(r, 16, 16);
1303b8e80941Smrg      (*(uint32_t *)dst) = d;
1304b8e80941Smrg}
1305b8e80941Smrg
1306b8e80941Smrgstatic inline void
1307b8e80941Smrgpack_ubyte_r8g8_snorm(const GLubyte src[4], void *dst)
1308b8e80941Smrg{
1309b8e80941Smrg
1310b8e80941Smrg
1311b8e80941Smrg      int8_t r =
1312b8e80941Smrg         _mesa_unorm_to_snorm(src[0], 8, 8);
1313b8e80941Smrg
1314b8e80941Smrg
1315b8e80941Smrg      int8_t g =
1316b8e80941Smrg         _mesa_unorm_to_snorm(src[1], 8, 8);
1317b8e80941Smrg
1318b8e80941Smrg      uint16_t d = 0;
1319b8e80941Smrg         d |= PACK(r, 0, 8);
1320b8e80941Smrg         d |= PACK(g, 8, 8);
1321b8e80941Smrg      (*(uint16_t *)dst) = d;
1322b8e80941Smrg}
1323b8e80941Smrg
1324b8e80941Smrgstatic inline void
1325b8e80941Smrgpack_ubyte_g8r8_snorm(const GLubyte src[4], void *dst)
1326b8e80941Smrg{
1327b8e80941Smrg
1328b8e80941Smrg
1329b8e80941Smrg      int8_t g =
1330b8e80941Smrg         _mesa_unorm_to_snorm(src[1], 8, 8);
1331b8e80941Smrg
1332b8e80941Smrg
1333b8e80941Smrg      int8_t r =
1334b8e80941Smrg         _mesa_unorm_to_snorm(src[0], 8, 8);
1335b8e80941Smrg
1336b8e80941Smrg      uint16_t d = 0;
1337b8e80941Smrg         d |= PACK(g, 0, 8);
1338b8e80941Smrg         d |= PACK(r, 8, 8);
1339b8e80941Smrg      (*(uint16_t *)dst) = d;
1340b8e80941Smrg}
1341b8e80941Smrg
1342b8e80941Smrgstatic inline void
1343b8e80941Smrgpack_ubyte_l8a8_snorm(const GLubyte src[4], void *dst)
1344b8e80941Smrg{
1345b8e80941Smrg
1346b8e80941Smrg
1347b8e80941Smrg      int8_t l =
1348b8e80941Smrg         _mesa_unorm_to_snorm(src[0], 8, 8);
1349b8e80941Smrg
1350b8e80941Smrg
1351b8e80941Smrg      int8_t a =
1352b8e80941Smrg         _mesa_unorm_to_snorm(src[3], 8, 8);
1353b8e80941Smrg
1354b8e80941Smrg      uint16_t d = 0;
1355b8e80941Smrg         d |= PACK(l, 0, 8);
1356b8e80941Smrg         d |= PACK(a, 8, 8);
1357b8e80941Smrg      (*(uint16_t *)dst) = d;
1358b8e80941Smrg}
1359b8e80941Smrg
1360b8e80941Smrgstatic inline void
1361b8e80941Smrgpack_ubyte_a8l8_snorm(const GLubyte src[4], void *dst)
1362b8e80941Smrg{
1363b8e80941Smrg
1364b8e80941Smrg
1365b8e80941Smrg      int8_t a =
1366b8e80941Smrg         _mesa_unorm_to_snorm(src[3], 8, 8);
1367b8e80941Smrg
1368b8e80941Smrg
1369b8e80941Smrg      int8_t l =
1370b8e80941Smrg         _mesa_unorm_to_snorm(src[0], 8, 8);
1371b8e80941Smrg
1372b8e80941Smrg      uint16_t d = 0;
1373b8e80941Smrg         d |= PACK(a, 0, 8);
1374b8e80941Smrg         d |= PACK(l, 8, 8);
1375b8e80941Smrg      (*(uint16_t *)dst) = d;
1376b8e80941Smrg}
1377b8e80941Smrg
1378b8e80941Smrgstatic inline void
1379b8e80941Smrgpack_ubyte_a_snorm8(const GLubyte src[4], void *dst)
1380b8e80941Smrg{
1381b8e80941Smrg
1382b8e80941Smrg
1383b8e80941Smrg      int8_t a =
1384b8e80941Smrg         _mesa_unorm_to_snorm(src[3], 8, 8);
1385b8e80941Smrg
1386b8e80941Smrg      int8_t *d = (int8_t *)dst;
1387b8e80941Smrg         d[0] = a;
1388b8e80941Smrg}
1389b8e80941Smrg
1390b8e80941Smrgstatic inline void
1391b8e80941Smrgpack_ubyte_a_snorm16(const GLubyte src[4], void *dst)
1392b8e80941Smrg{
1393b8e80941Smrg
1394b8e80941Smrg
1395b8e80941Smrg      int16_t a =
1396b8e80941Smrg         _mesa_unorm_to_snorm(src[3], 8, 16);
1397b8e80941Smrg
1398b8e80941Smrg      int16_t *d = (int16_t *)dst;
1399b8e80941Smrg         d[0] = a;
1400b8e80941Smrg}
1401b8e80941Smrg
1402b8e80941Smrgstatic inline void
1403b8e80941Smrgpack_ubyte_l_snorm8(const GLubyte src[4], void *dst)
1404b8e80941Smrg{
1405b8e80941Smrg
1406b8e80941Smrg
1407b8e80941Smrg      int8_t l =
1408b8e80941Smrg         _mesa_unorm_to_snorm(src[0], 8, 8);
1409b8e80941Smrg
1410b8e80941Smrg      int8_t *d = (int8_t *)dst;
1411b8e80941Smrg         d[0] = l;
1412b8e80941Smrg}
1413b8e80941Smrg
1414b8e80941Smrgstatic inline void
1415b8e80941Smrgpack_ubyte_l_snorm16(const GLubyte src[4], void *dst)
1416b8e80941Smrg{
1417b8e80941Smrg
1418b8e80941Smrg
1419b8e80941Smrg      int16_t l =
1420b8e80941Smrg         _mesa_unorm_to_snorm(src[0], 8, 16);
1421b8e80941Smrg
1422b8e80941Smrg      int16_t *d = (int16_t *)dst;
1423b8e80941Smrg         d[0] = l;
1424b8e80941Smrg}
1425b8e80941Smrg
1426b8e80941Smrgstatic inline void
1427b8e80941Smrgpack_ubyte_i_snorm8(const GLubyte src[4], void *dst)
1428b8e80941Smrg{
1429b8e80941Smrg
1430b8e80941Smrg
1431b8e80941Smrg      int8_t i =
1432b8e80941Smrg         _mesa_unorm_to_snorm(src[0], 8, 8);
1433b8e80941Smrg
1434b8e80941Smrg      int8_t *d = (int8_t *)dst;
1435b8e80941Smrg         d[0] = i;
1436b8e80941Smrg}
1437b8e80941Smrg
1438b8e80941Smrgstatic inline void
1439b8e80941Smrgpack_ubyte_i_snorm16(const GLubyte src[4], void *dst)
1440b8e80941Smrg{
1441b8e80941Smrg
1442b8e80941Smrg
1443b8e80941Smrg      int16_t i =
1444b8e80941Smrg         _mesa_unorm_to_snorm(src[0], 8, 16);
1445b8e80941Smrg
1446b8e80941Smrg      int16_t *d = (int16_t *)dst;
1447b8e80941Smrg         d[0] = i;
1448b8e80941Smrg}
1449b8e80941Smrg
1450b8e80941Smrgstatic inline void
1451b8e80941Smrgpack_ubyte_r_snorm8(const GLubyte src[4], void *dst)
1452b8e80941Smrg{
1453b8e80941Smrg
1454b8e80941Smrg
1455b8e80941Smrg      int8_t r =
1456b8e80941Smrg         _mesa_unorm_to_snorm(src[0], 8, 8);
1457b8e80941Smrg
1458b8e80941Smrg      int8_t *d = (int8_t *)dst;
1459b8e80941Smrg         d[0] = r;
1460b8e80941Smrg}
1461b8e80941Smrg
1462b8e80941Smrgstatic inline void
1463b8e80941Smrgpack_ubyte_r_snorm16(const GLubyte src[4], void *dst)
1464b8e80941Smrg{
1465b8e80941Smrg
1466b8e80941Smrg
1467b8e80941Smrg      int16_t r =
1468b8e80941Smrg         _mesa_unorm_to_snorm(src[0], 8, 16);
1469b8e80941Smrg
1470b8e80941Smrg      int16_t *d = (int16_t *)dst;
1471b8e80941Smrg         d[0] = r;
1472b8e80941Smrg}
1473b8e80941Smrg
1474b8e80941Smrgstatic inline void
1475b8e80941Smrgpack_ubyte_la_snorm16(const GLubyte src[4], void *dst)
1476b8e80941Smrg{
1477b8e80941Smrg
1478b8e80941Smrg
1479b8e80941Smrg      int16_t l =
1480b8e80941Smrg         _mesa_unorm_to_snorm(src[0], 8, 16);
1481b8e80941Smrg
1482b8e80941Smrg
1483b8e80941Smrg      int16_t a =
1484b8e80941Smrg         _mesa_unorm_to_snorm(src[3], 8, 16);
1485b8e80941Smrg
1486b8e80941Smrg      int16_t *d = (int16_t *)dst;
1487b8e80941Smrg         d[0] = l;
1488b8e80941Smrg         d[1] = a;
1489b8e80941Smrg}
1490b8e80941Smrg
1491b8e80941Smrgstatic inline void
1492b8e80941Smrgpack_ubyte_rgb_snorm16(const GLubyte src[4], void *dst)
1493b8e80941Smrg{
1494b8e80941Smrg
1495b8e80941Smrg
1496b8e80941Smrg      int16_t r =
1497b8e80941Smrg         _mesa_unorm_to_snorm(src[0], 8, 16);
1498b8e80941Smrg
1499b8e80941Smrg
1500b8e80941Smrg      int16_t g =
1501b8e80941Smrg         _mesa_unorm_to_snorm(src[1], 8, 16);
1502b8e80941Smrg
1503b8e80941Smrg
1504b8e80941Smrg      int16_t b =
1505b8e80941Smrg         _mesa_unorm_to_snorm(src[2], 8, 16);
1506b8e80941Smrg
1507b8e80941Smrg      int16_t *d = (int16_t *)dst;
1508b8e80941Smrg         d[0] = r;
1509b8e80941Smrg         d[1] = g;
1510b8e80941Smrg         d[2] = b;
1511b8e80941Smrg}
1512b8e80941Smrg
1513b8e80941Smrgstatic inline void
1514b8e80941Smrgpack_ubyte_rgba_snorm16(const GLubyte src[4], void *dst)
1515b8e80941Smrg{
1516b8e80941Smrg
1517b8e80941Smrg
1518b8e80941Smrg      int16_t r =
1519b8e80941Smrg         _mesa_unorm_to_snorm(src[0], 8, 16);
1520b8e80941Smrg
1521b8e80941Smrg
1522b8e80941Smrg      int16_t g =
1523b8e80941Smrg         _mesa_unorm_to_snorm(src[1], 8, 16);
1524b8e80941Smrg
1525b8e80941Smrg
1526b8e80941Smrg      int16_t b =
1527b8e80941Smrg         _mesa_unorm_to_snorm(src[2], 8, 16);
1528b8e80941Smrg
1529b8e80941Smrg
1530b8e80941Smrg      int16_t a =
1531b8e80941Smrg         _mesa_unorm_to_snorm(src[3], 8, 16);
1532b8e80941Smrg
1533b8e80941Smrg      int16_t *d = (int16_t *)dst;
1534b8e80941Smrg         d[0] = r;
1535b8e80941Smrg         d[1] = g;
1536b8e80941Smrg         d[2] = b;
1537b8e80941Smrg         d[3] = a;
1538b8e80941Smrg}
1539b8e80941Smrg
1540b8e80941Smrgstatic inline void
1541b8e80941Smrgpack_ubyte_rgbx_snorm16(const GLubyte src[4], void *dst)
1542b8e80941Smrg{
1543b8e80941Smrg
1544b8e80941Smrg
1545b8e80941Smrg      int16_t r =
1546b8e80941Smrg         _mesa_unorm_to_snorm(src[0], 8, 16);
1547b8e80941Smrg
1548b8e80941Smrg
1549b8e80941Smrg      int16_t g =
1550b8e80941Smrg         _mesa_unorm_to_snorm(src[1], 8, 16);
1551b8e80941Smrg
1552b8e80941Smrg
1553b8e80941Smrg      int16_t b =
1554b8e80941Smrg         _mesa_unorm_to_snorm(src[2], 8, 16);
1555b8e80941Smrg
1556b8e80941Smrg
1557b8e80941Smrg      int16_t *d = (int16_t *)dst;
1558b8e80941Smrg         d[0] = r;
1559b8e80941Smrg         d[1] = g;
1560b8e80941Smrg         d[2] = b;
1561b8e80941Smrg            }
1562b8e80941Smrg
1563b8e80941Smrgstatic inline void
1564b8e80941Smrgpack_ubyte_a8b8g8r8_srgb(const GLubyte src[4], void *dst)
1565b8e80941Smrg{
1566b8e80941Smrg
1567b8e80941Smrg
1568b8e80941Smrg      uint8_t a =
1569b8e80941Smrg            _mesa_unorm_to_unorm(src[3], 8, 8);
1570b8e80941Smrg
1571b8e80941Smrg
1572b8e80941Smrg      uint8_t b =
1573b8e80941Smrg
1574b8e80941Smrg            util_format_linear_to_srgb_8unorm(src[2]);
1575b8e80941Smrg
1576b8e80941Smrg
1577b8e80941Smrg      uint8_t g =
1578b8e80941Smrg
1579b8e80941Smrg            util_format_linear_to_srgb_8unorm(src[1]);
1580b8e80941Smrg
1581b8e80941Smrg
1582b8e80941Smrg      uint8_t r =
1583b8e80941Smrg
1584b8e80941Smrg            util_format_linear_to_srgb_8unorm(src[0]);
1585b8e80941Smrg
1586b8e80941Smrg      uint32_t d = 0;
1587b8e80941Smrg         d |= PACK(a, 0, 8);
1588b8e80941Smrg         d |= PACK(b, 8, 8);
1589b8e80941Smrg         d |= PACK(g, 16, 8);
1590b8e80941Smrg         d |= PACK(r, 24, 8);
1591b8e80941Smrg      (*(uint32_t *)dst) = d;
1592b8e80941Smrg}
1593b8e80941Smrg
1594b8e80941Smrgstatic inline void
1595b8e80941Smrgpack_ubyte_b8g8r8a8_srgb(const GLubyte src[4], void *dst)
1596b8e80941Smrg{
1597b8e80941Smrg
1598b8e80941Smrg
1599b8e80941Smrg      uint8_t b =
1600b8e80941Smrg
1601b8e80941Smrg            util_format_linear_to_srgb_8unorm(src[2]);
1602b8e80941Smrg
1603b8e80941Smrg
1604b8e80941Smrg      uint8_t g =
1605b8e80941Smrg
1606b8e80941Smrg            util_format_linear_to_srgb_8unorm(src[1]);
1607b8e80941Smrg
1608b8e80941Smrg
1609b8e80941Smrg      uint8_t r =
1610b8e80941Smrg
1611b8e80941Smrg            util_format_linear_to_srgb_8unorm(src[0]);
1612b8e80941Smrg
1613b8e80941Smrg
1614b8e80941Smrg      uint8_t a =
1615b8e80941Smrg            _mesa_unorm_to_unorm(src[3], 8, 8);
1616b8e80941Smrg
1617b8e80941Smrg      uint32_t d = 0;
1618b8e80941Smrg         d |= PACK(b, 0, 8);
1619b8e80941Smrg         d |= PACK(g, 8, 8);
1620b8e80941Smrg         d |= PACK(r, 16, 8);
1621b8e80941Smrg         d |= PACK(a, 24, 8);
1622b8e80941Smrg      (*(uint32_t *)dst) = d;
1623b8e80941Smrg}
1624b8e80941Smrg
1625b8e80941Smrgstatic inline void
1626b8e80941Smrgpack_ubyte_a8r8g8b8_srgb(const GLubyte src[4], void *dst)
1627b8e80941Smrg{
1628b8e80941Smrg
1629b8e80941Smrg
1630b8e80941Smrg      uint8_t a =
1631b8e80941Smrg            _mesa_unorm_to_unorm(src[3], 8, 8);
1632b8e80941Smrg
1633b8e80941Smrg
1634b8e80941Smrg      uint8_t r =
1635b8e80941Smrg
1636b8e80941Smrg            util_format_linear_to_srgb_8unorm(src[0]);
1637b8e80941Smrg
1638b8e80941Smrg
1639b8e80941Smrg      uint8_t g =
1640b8e80941Smrg
1641b8e80941Smrg            util_format_linear_to_srgb_8unorm(src[1]);
1642b8e80941Smrg
1643b8e80941Smrg
1644b8e80941Smrg      uint8_t b =
1645b8e80941Smrg
1646b8e80941Smrg            util_format_linear_to_srgb_8unorm(src[2]);
1647b8e80941Smrg
1648b8e80941Smrg      uint32_t d = 0;
1649b8e80941Smrg         d |= PACK(a, 0, 8);
1650b8e80941Smrg         d |= PACK(r, 8, 8);
1651b8e80941Smrg         d |= PACK(g, 16, 8);
1652b8e80941Smrg         d |= PACK(b, 24, 8);
1653b8e80941Smrg      (*(uint32_t *)dst) = d;
1654b8e80941Smrg}
1655b8e80941Smrg
1656b8e80941Smrgstatic inline void
1657b8e80941Smrgpack_ubyte_b8g8r8x8_srgb(const GLubyte src[4], void *dst)
1658b8e80941Smrg{
1659b8e80941Smrg
1660b8e80941Smrg
1661b8e80941Smrg      uint8_t b =
1662b8e80941Smrg
1663b8e80941Smrg            util_format_linear_to_srgb_8unorm(src[2]);
1664b8e80941Smrg
1665b8e80941Smrg
1666b8e80941Smrg      uint8_t g =
1667b8e80941Smrg
1668b8e80941Smrg            util_format_linear_to_srgb_8unorm(src[1]);
1669b8e80941Smrg
1670b8e80941Smrg
1671b8e80941Smrg      uint8_t r =
1672b8e80941Smrg
1673b8e80941Smrg            util_format_linear_to_srgb_8unorm(src[0]);
1674b8e80941Smrg
1675b8e80941Smrg
1676b8e80941Smrg      uint32_t d = 0;
1677b8e80941Smrg         d |= PACK(b, 0, 8);
1678b8e80941Smrg         d |= PACK(g, 8, 8);
1679b8e80941Smrg         d |= PACK(r, 16, 8);
1680b8e80941Smrg                  (*(uint32_t *)dst) = d;
1681b8e80941Smrg}
1682b8e80941Smrg
1683b8e80941Smrgstatic inline void
1684b8e80941Smrgpack_ubyte_x8r8g8b8_srgb(const GLubyte src[4], void *dst)
1685b8e80941Smrg{
1686b8e80941Smrg
1687b8e80941Smrg
1688b8e80941Smrg
1689b8e80941Smrg      uint8_t r =
1690b8e80941Smrg
1691b8e80941Smrg            util_format_linear_to_srgb_8unorm(src[0]);
1692b8e80941Smrg
1693b8e80941Smrg
1694b8e80941Smrg      uint8_t g =
1695b8e80941Smrg
1696b8e80941Smrg            util_format_linear_to_srgb_8unorm(src[1]);
1697b8e80941Smrg
1698b8e80941Smrg
1699b8e80941Smrg      uint8_t b =
1700b8e80941Smrg
1701b8e80941Smrg            util_format_linear_to_srgb_8unorm(src[2]);
1702b8e80941Smrg
1703b8e80941Smrg      uint32_t d = 0;
1704b8e80941Smrg                     d |= PACK(r, 8, 8);
1705b8e80941Smrg         d |= PACK(g, 16, 8);
1706b8e80941Smrg         d |= PACK(b, 24, 8);
1707b8e80941Smrg      (*(uint32_t *)dst) = d;
1708b8e80941Smrg}
1709b8e80941Smrg
1710b8e80941Smrgstatic inline void
1711b8e80941Smrgpack_ubyte_r8g8b8a8_srgb(const GLubyte src[4], void *dst)
1712b8e80941Smrg{
1713b8e80941Smrg
1714b8e80941Smrg
1715b8e80941Smrg      uint8_t r =
1716b8e80941Smrg
1717b8e80941Smrg            util_format_linear_to_srgb_8unorm(src[0]);
1718b8e80941Smrg
1719b8e80941Smrg
1720b8e80941Smrg      uint8_t g =
1721b8e80941Smrg
1722b8e80941Smrg            util_format_linear_to_srgb_8unorm(src[1]);
1723b8e80941Smrg
1724b8e80941Smrg
1725b8e80941Smrg      uint8_t b =
1726b8e80941Smrg
1727b8e80941Smrg            util_format_linear_to_srgb_8unorm(src[2]);
1728b8e80941Smrg
1729b8e80941Smrg
1730b8e80941Smrg      uint8_t a =
1731b8e80941Smrg            _mesa_unorm_to_unorm(src[3], 8, 8);
1732b8e80941Smrg
1733b8e80941Smrg      uint32_t d = 0;
1734b8e80941Smrg         d |= PACK(r, 0, 8);
1735b8e80941Smrg         d |= PACK(g, 8, 8);
1736b8e80941Smrg         d |= PACK(b, 16, 8);
1737b8e80941Smrg         d |= PACK(a, 24, 8);
1738b8e80941Smrg      (*(uint32_t *)dst) = d;
1739b8e80941Smrg}
1740b8e80941Smrg
1741b8e80941Smrgstatic inline void
1742b8e80941Smrgpack_ubyte_r8g8b8x8_srgb(const GLubyte src[4], void *dst)
1743b8e80941Smrg{
1744b8e80941Smrg
1745b8e80941Smrg
1746b8e80941Smrg      uint8_t r =
1747b8e80941Smrg
1748b8e80941Smrg            util_format_linear_to_srgb_8unorm(src[0]);
1749b8e80941Smrg
1750b8e80941Smrg
1751b8e80941Smrg      uint8_t g =
1752b8e80941Smrg
1753b8e80941Smrg            util_format_linear_to_srgb_8unorm(src[1]);
1754b8e80941Smrg
1755b8e80941Smrg
1756b8e80941Smrg      uint8_t b =
1757b8e80941Smrg
1758b8e80941Smrg            util_format_linear_to_srgb_8unorm(src[2]);
1759b8e80941Smrg
1760b8e80941Smrg
1761b8e80941Smrg      uint32_t d = 0;
1762b8e80941Smrg         d |= PACK(r, 0, 8);
1763b8e80941Smrg         d |= PACK(g, 8, 8);
1764b8e80941Smrg         d |= PACK(b, 16, 8);
1765b8e80941Smrg                  (*(uint32_t *)dst) = d;
1766b8e80941Smrg}
1767b8e80941Smrg
1768b8e80941Smrgstatic inline void
1769b8e80941Smrgpack_ubyte_x8b8g8r8_srgb(const GLubyte src[4], void *dst)
1770b8e80941Smrg{
1771b8e80941Smrg
1772b8e80941Smrg
1773b8e80941Smrg
1774b8e80941Smrg      uint8_t b =
1775b8e80941Smrg
1776b8e80941Smrg            util_format_linear_to_srgb_8unorm(src[2]);
1777b8e80941Smrg
1778b8e80941Smrg
1779b8e80941Smrg      uint8_t g =
1780b8e80941Smrg
1781b8e80941Smrg            util_format_linear_to_srgb_8unorm(src[1]);
1782b8e80941Smrg
1783b8e80941Smrg
1784b8e80941Smrg      uint8_t r =
1785b8e80941Smrg
1786b8e80941Smrg            util_format_linear_to_srgb_8unorm(src[0]);
1787b8e80941Smrg
1788b8e80941Smrg      uint32_t d = 0;
1789b8e80941Smrg                     d |= PACK(b, 8, 8);
1790b8e80941Smrg         d |= PACK(g, 16, 8);
1791b8e80941Smrg         d |= PACK(r, 24, 8);
1792b8e80941Smrg      (*(uint32_t *)dst) = d;
1793b8e80941Smrg}
1794b8e80941Smrg
1795b8e80941Smrgstatic inline void
1796b8e80941Smrgpack_ubyte_l8a8_srgb(const GLubyte src[4], void *dst)
1797b8e80941Smrg{
1798b8e80941Smrg
1799b8e80941Smrg
1800b8e80941Smrg      uint8_t l =
1801b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 8);
1802b8e80941Smrg
1803b8e80941Smrg
1804b8e80941Smrg      uint8_t a =
1805b8e80941Smrg            _mesa_unorm_to_unorm(src[3], 8, 8);
1806b8e80941Smrg
1807b8e80941Smrg      uint16_t d = 0;
1808b8e80941Smrg         d |= PACK(l, 0, 8);
1809b8e80941Smrg         d |= PACK(a, 8, 8);
1810b8e80941Smrg      (*(uint16_t *)dst) = d;
1811b8e80941Smrg}
1812b8e80941Smrg
1813b8e80941Smrgstatic inline void
1814b8e80941Smrgpack_ubyte_a8l8_srgb(const GLubyte src[4], void *dst)
1815b8e80941Smrg{
1816b8e80941Smrg
1817b8e80941Smrg
1818b8e80941Smrg      uint8_t a =
1819b8e80941Smrg            _mesa_unorm_to_unorm(src[3], 8, 8);
1820b8e80941Smrg
1821b8e80941Smrg
1822b8e80941Smrg      uint8_t l =
1823b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 8);
1824b8e80941Smrg
1825b8e80941Smrg      uint16_t d = 0;
1826b8e80941Smrg         d |= PACK(a, 0, 8);
1827b8e80941Smrg         d |= PACK(l, 8, 8);
1828b8e80941Smrg      (*(uint16_t *)dst) = d;
1829b8e80941Smrg}
1830b8e80941Smrg
1831b8e80941Smrgstatic inline void
1832b8e80941Smrgpack_ubyte_r_srgb8(const GLubyte src[4], void *dst)
1833b8e80941Smrg{
1834b8e80941Smrg
1835b8e80941Smrg
1836b8e80941Smrg      uint8_t r =
1837b8e80941Smrg
1838b8e80941Smrg            util_format_linear_to_srgb_8unorm(src[0]);
1839b8e80941Smrg
1840b8e80941Smrg      uint8_t *d = (uint8_t *)dst;
1841b8e80941Smrg         d[0] = r;
1842b8e80941Smrg}
1843b8e80941Smrg
1844b8e80941Smrgstatic inline void
1845b8e80941Smrgpack_ubyte_l_srgb8(const GLubyte src[4], void *dst)
1846b8e80941Smrg{
1847b8e80941Smrg
1848b8e80941Smrg
1849b8e80941Smrg      uint8_t l =
1850b8e80941Smrg            _mesa_unorm_to_unorm(src[0], 8, 8);
1851b8e80941Smrg
1852b8e80941Smrg      uint8_t *d = (uint8_t *)dst;
1853b8e80941Smrg         d[0] = l;
1854b8e80941Smrg}
1855b8e80941Smrg
1856b8e80941Smrgstatic inline void
1857b8e80941Smrgpack_ubyte_bgr_srgb8(const GLubyte src[4], void *dst)
1858b8e80941Smrg{
1859b8e80941Smrg
1860b8e80941Smrg
1861b8e80941Smrg      uint8_t b =
1862b8e80941Smrg
1863b8e80941Smrg            util_format_linear_to_srgb_8unorm(src[2]);
1864b8e80941Smrg
1865b8e80941Smrg
1866b8e80941Smrg      uint8_t g =
1867b8e80941Smrg
1868b8e80941Smrg            util_format_linear_to_srgb_8unorm(src[1]);
1869b8e80941Smrg
1870b8e80941Smrg
1871b8e80941Smrg      uint8_t r =
1872b8e80941Smrg
1873b8e80941Smrg            util_format_linear_to_srgb_8unorm(src[0]);
1874b8e80941Smrg
1875b8e80941Smrg      uint8_t *d = (uint8_t *)dst;
1876b8e80941Smrg         d[0] = b;
1877b8e80941Smrg         d[1] = g;
1878b8e80941Smrg         d[2] = r;
1879b8e80941Smrg}
1880b8e80941Smrg
1881b8e80941Smrgstatic inline void
1882b8e80941Smrgpack_ubyte_a_float16(const GLubyte src[4], void *dst)
1883b8e80941Smrg{
1884b8e80941Smrg
1885b8e80941Smrg
1886b8e80941Smrg      uint16_t a =
1887b8e80941Smrg            _mesa_unorm_to_half(src[3], 8);
1888b8e80941Smrg
1889b8e80941Smrg      uint16_t *d = (uint16_t *)dst;
1890b8e80941Smrg         d[0] = a;
1891b8e80941Smrg}
1892b8e80941Smrg
1893b8e80941Smrgstatic inline void
1894b8e80941Smrgpack_ubyte_a_float32(const GLubyte src[4], void *dst)
1895b8e80941Smrg{
1896b8e80941Smrg
1897b8e80941Smrg
1898b8e80941Smrg      float a =
1899b8e80941Smrg            _mesa_unorm_to_float(src[3], 8);
1900b8e80941Smrg
1901b8e80941Smrg      float *d = (float *)dst;
1902b8e80941Smrg         d[0] = a;
1903b8e80941Smrg}
1904b8e80941Smrg
1905b8e80941Smrgstatic inline void
1906b8e80941Smrgpack_ubyte_l_float16(const GLubyte src[4], void *dst)
1907b8e80941Smrg{
1908b8e80941Smrg
1909b8e80941Smrg
1910b8e80941Smrg      uint16_t l =
1911b8e80941Smrg            _mesa_unorm_to_half(src[0], 8);
1912b8e80941Smrg
1913b8e80941Smrg      uint16_t *d = (uint16_t *)dst;
1914b8e80941Smrg         d[0] = l;
1915b8e80941Smrg}
1916b8e80941Smrg
1917b8e80941Smrgstatic inline void
1918b8e80941Smrgpack_ubyte_l_float32(const GLubyte src[4], void *dst)
1919b8e80941Smrg{
1920b8e80941Smrg
1921b8e80941Smrg
1922b8e80941Smrg      float l =
1923b8e80941Smrg            _mesa_unorm_to_float(src[0], 8);
1924b8e80941Smrg
1925b8e80941Smrg      float *d = (float *)dst;
1926b8e80941Smrg         d[0] = l;
1927b8e80941Smrg}
1928b8e80941Smrg
1929b8e80941Smrgstatic inline void
1930b8e80941Smrgpack_ubyte_la_float16(const GLubyte src[4], void *dst)
1931b8e80941Smrg{
1932b8e80941Smrg
1933b8e80941Smrg
1934b8e80941Smrg      uint16_t l =
1935b8e80941Smrg            _mesa_unorm_to_half(src[0], 8);
1936b8e80941Smrg
1937b8e80941Smrg
1938b8e80941Smrg      uint16_t a =
1939b8e80941Smrg            _mesa_unorm_to_half(src[3], 8);
1940b8e80941Smrg
1941b8e80941Smrg      uint16_t *d = (uint16_t *)dst;
1942b8e80941Smrg         d[0] = l;
1943b8e80941Smrg         d[1] = a;
1944b8e80941Smrg}
1945b8e80941Smrg
1946b8e80941Smrgstatic inline void
1947b8e80941Smrgpack_ubyte_la_float32(const GLubyte src[4], void *dst)
1948b8e80941Smrg{
1949b8e80941Smrg
1950b8e80941Smrg
1951b8e80941Smrg      float l =
1952b8e80941Smrg            _mesa_unorm_to_float(src[0], 8);
1953b8e80941Smrg
1954b8e80941Smrg
1955b8e80941Smrg      float a =
1956b8e80941Smrg            _mesa_unorm_to_float(src[3], 8);
1957b8e80941Smrg
1958b8e80941Smrg      float *d = (float *)dst;
1959b8e80941Smrg         d[0] = l;
1960b8e80941Smrg         d[1] = a;
1961b8e80941Smrg}
1962b8e80941Smrg
1963b8e80941Smrgstatic inline void
1964b8e80941Smrgpack_ubyte_i_float16(const GLubyte src[4], void *dst)
1965b8e80941Smrg{
1966b8e80941Smrg
1967b8e80941Smrg
1968b8e80941Smrg      uint16_t i =
1969b8e80941Smrg            _mesa_unorm_to_half(src[0], 8);
1970b8e80941Smrg
1971b8e80941Smrg      uint16_t *d = (uint16_t *)dst;
1972b8e80941Smrg         d[0] = i;
1973b8e80941Smrg}
1974b8e80941Smrg
1975b8e80941Smrgstatic inline void
1976b8e80941Smrgpack_ubyte_i_float32(const GLubyte src[4], void *dst)
1977b8e80941Smrg{
1978b8e80941Smrg
1979b8e80941Smrg
1980b8e80941Smrg      float i =
1981b8e80941Smrg            _mesa_unorm_to_float(src[0], 8);
1982b8e80941Smrg
1983b8e80941Smrg      float *d = (float *)dst;
1984b8e80941Smrg         d[0] = i;
1985b8e80941Smrg}
1986b8e80941Smrg
1987b8e80941Smrgstatic inline void
1988b8e80941Smrgpack_ubyte_r_float16(const GLubyte src[4], void *dst)
1989b8e80941Smrg{
1990b8e80941Smrg
1991b8e80941Smrg
1992b8e80941Smrg      uint16_t r =
1993b8e80941Smrg            _mesa_unorm_to_half(src[0], 8);
1994b8e80941Smrg
1995b8e80941Smrg      uint16_t *d = (uint16_t *)dst;
1996b8e80941Smrg         d[0] = r;
1997b8e80941Smrg}
1998b8e80941Smrg
1999b8e80941Smrgstatic inline void
2000b8e80941Smrgpack_ubyte_r_float32(const GLubyte src[4], void *dst)
2001b8e80941Smrg{
2002b8e80941Smrg
2003b8e80941Smrg
2004b8e80941Smrg      float r =
2005b8e80941Smrg            _mesa_unorm_to_float(src[0], 8);
2006b8e80941Smrg
2007b8e80941Smrg      float *d = (float *)dst;
2008b8e80941Smrg         d[0] = r;
2009b8e80941Smrg}
2010b8e80941Smrg
2011b8e80941Smrgstatic inline void
2012b8e80941Smrgpack_ubyte_rg_float16(const GLubyte src[4], void *dst)
2013b8e80941Smrg{
2014b8e80941Smrg
2015b8e80941Smrg
2016b8e80941Smrg      uint16_t r =
2017b8e80941Smrg            _mesa_unorm_to_half(src[0], 8);
2018b8e80941Smrg
2019b8e80941Smrg
2020b8e80941Smrg      uint16_t g =
2021b8e80941Smrg            _mesa_unorm_to_half(src[1], 8);
2022b8e80941Smrg
2023b8e80941Smrg      uint16_t *d = (uint16_t *)dst;
2024b8e80941Smrg         d[0] = r;
2025b8e80941Smrg         d[1] = g;
2026b8e80941Smrg}
2027b8e80941Smrg
2028b8e80941Smrgstatic inline void
2029b8e80941Smrgpack_ubyte_rg_float32(const GLubyte src[4], void *dst)
2030b8e80941Smrg{
2031b8e80941Smrg
2032b8e80941Smrg
2033b8e80941Smrg      float r =
2034b8e80941Smrg            _mesa_unorm_to_float(src[0], 8);
2035b8e80941Smrg
2036b8e80941Smrg
2037b8e80941Smrg      float g =
2038b8e80941Smrg            _mesa_unorm_to_float(src[1], 8);
2039b8e80941Smrg
2040b8e80941Smrg      float *d = (float *)dst;
2041b8e80941Smrg         d[0] = r;
2042b8e80941Smrg         d[1] = g;
2043b8e80941Smrg}
2044b8e80941Smrg
2045b8e80941Smrgstatic inline void
2046b8e80941Smrgpack_ubyte_rgb_float16(const GLubyte src[4], void *dst)
2047b8e80941Smrg{
2048b8e80941Smrg
2049b8e80941Smrg
2050b8e80941Smrg      uint16_t r =
2051b8e80941Smrg            _mesa_unorm_to_half(src[0], 8);
2052b8e80941Smrg
2053b8e80941Smrg
2054b8e80941Smrg      uint16_t g =
2055b8e80941Smrg            _mesa_unorm_to_half(src[1], 8);
2056b8e80941Smrg
2057b8e80941Smrg
2058b8e80941Smrg      uint16_t b =
2059b8e80941Smrg            _mesa_unorm_to_half(src[2], 8);
2060b8e80941Smrg
2061b8e80941Smrg      uint16_t *d = (uint16_t *)dst;
2062b8e80941Smrg         d[0] = r;
2063b8e80941Smrg         d[1] = g;
2064b8e80941Smrg         d[2] = b;
2065b8e80941Smrg}
2066b8e80941Smrg
2067b8e80941Smrgstatic inline void
2068b8e80941Smrgpack_ubyte_rgb_float32(const GLubyte src[4], void *dst)
2069b8e80941Smrg{
2070b8e80941Smrg
2071b8e80941Smrg
2072b8e80941Smrg      float r =
2073b8e80941Smrg            _mesa_unorm_to_float(src[0], 8);
2074b8e80941Smrg
2075b8e80941Smrg
2076b8e80941Smrg      float g =
2077b8e80941Smrg            _mesa_unorm_to_float(src[1], 8);
2078b8e80941Smrg
2079b8e80941Smrg
2080b8e80941Smrg      float b =
2081b8e80941Smrg            _mesa_unorm_to_float(src[2], 8);
2082b8e80941Smrg
2083b8e80941Smrg      float *d = (float *)dst;
2084b8e80941Smrg         d[0] = r;
2085b8e80941Smrg         d[1] = g;
2086b8e80941Smrg         d[2] = b;
2087b8e80941Smrg}
2088b8e80941Smrg
2089b8e80941Smrgstatic inline void
2090b8e80941Smrgpack_ubyte_rgba_float16(const GLubyte src[4], void *dst)
2091b8e80941Smrg{
2092b8e80941Smrg
2093b8e80941Smrg
2094b8e80941Smrg      uint16_t r =
2095b8e80941Smrg            _mesa_unorm_to_half(src[0], 8);
2096b8e80941Smrg
2097b8e80941Smrg
2098b8e80941Smrg      uint16_t g =
2099b8e80941Smrg            _mesa_unorm_to_half(src[1], 8);
2100b8e80941Smrg
2101b8e80941Smrg
2102b8e80941Smrg      uint16_t b =
2103b8e80941Smrg            _mesa_unorm_to_half(src[2], 8);
2104b8e80941Smrg
2105b8e80941Smrg
2106b8e80941Smrg      uint16_t a =
2107b8e80941Smrg            _mesa_unorm_to_half(src[3], 8);
2108b8e80941Smrg
2109b8e80941Smrg      uint16_t *d = (uint16_t *)dst;
2110b8e80941Smrg         d[0] = r;
2111b8e80941Smrg         d[1] = g;
2112b8e80941Smrg         d[2] = b;
2113b8e80941Smrg         d[3] = a;
2114b8e80941Smrg}
2115b8e80941Smrg
2116b8e80941Smrgstatic inline void
2117b8e80941Smrgpack_ubyte_rgba_float32(const GLubyte src[4], void *dst)
2118b8e80941Smrg{
2119b8e80941Smrg
2120b8e80941Smrg
2121b8e80941Smrg      float r =
2122b8e80941Smrg            _mesa_unorm_to_float(src[0], 8);
2123b8e80941Smrg
2124b8e80941Smrg
2125b8e80941Smrg      float g =
2126b8e80941Smrg            _mesa_unorm_to_float(src[1], 8);
2127b8e80941Smrg
2128b8e80941Smrg
2129b8e80941Smrg      float b =
2130b8e80941Smrg            _mesa_unorm_to_float(src[2], 8);
2131b8e80941Smrg
2132b8e80941Smrg
2133b8e80941Smrg      float a =
2134b8e80941Smrg            _mesa_unorm_to_float(src[3], 8);
2135b8e80941Smrg
2136b8e80941Smrg      float *d = (float *)dst;
2137b8e80941Smrg         d[0] = r;
2138b8e80941Smrg         d[1] = g;
2139b8e80941Smrg         d[2] = b;
2140b8e80941Smrg         d[3] = a;
2141b8e80941Smrg}
2142b8e80941Smrg
2143b8e80941Smrgstatic inline void
2144b8e80941Smrgpack_ubyte_rgbx_float16(const GLubyte src[4], void *dst)
2145b8e80941Smrg{
2146b8e80941Smrg
2147b8e80941Smrg
2148b8e80941Smrg      uint16_t r =
2149b8e80941Smrg            _mesa_unorm_to_half(src[0], 8);
2150b8e80941Smrg
2151b8e80941Smrg
2152b8e80941Smrg      uint16_t g =
2153b8e80941Smrg            _mesa_unorm_to_half(src[1], 8);
2154b8e80941Smrg
2155b8e80941Smrg
2156b8e80941Smrg      uint16_t b =
2157b8e80941Smrg            _mesa_unorm_to_half(src[2], 8);
2158b8e80941Smrg
2159b8e80941Smrg
2160b8e80941Smrg      uint16_t *d = (uint16_t *)dst;
2161b8e80941Smrg         d[0] = r;
2162b8e80941Smrg         d[1] = g;
2163b8e80941Smrg         d[2] = b;
2164b8e80941Smrg            }
2165b8e80941Smrg
2166b8e80941Smrgstatic inline void
2167b8e80941Smrgpack_ubyte_rgbx_float32(const GLubyte src[4], void *dst)
2168b8e80941Smrg{
2169b8e80941Smrg
2170b8e80941Smrg
2171b8e80941Smrg      float r =
2172b8e80941Smrg            _mesa_unorm_to_float(src[0], 8);
2173b8e80941Smrg
2174b8e80941Smrg
2175b8e80941Smrg      float g =
2176b8e80941Smrg            _mesa_unorm_to_float(src[1], 8);
2177b8e80941Smrg
2178b8e80941Smrg
2179b8e80941Smrg      float b =
2180b8e80941Smrg            _mesa_unorm_to_float(src[2], 8);
2181b8e80941Smrg
2182b8e80941Smrg
2183b8e80941Smrg      float *d = (float *)dst;
2184b8e80941Smrg         d[0] = r;
2185b8e80941Smrg         d[1] = g;
2186b8e80941Smrg         d[2] = b;
2187b8e80941Smrg            }
2188b8e80941Smrg
2189b8e80941Smrgstatic inline void
2190b8e80941Smrgpack_ubyte_a8b8g8r8_uint(const GLubyte src[4], void *dst)
2191b8e80941Smrg{
2192b8e80941Smrg
2193b8e80941Smrg
2194b8e80941Smrg      uint8_t a =
2195b8e80941Smrg              _mesa_unsigned_to_unsigned(src[3], 8);
2196b8e80941Smrg
2197b8e80941Smrg
2198b8e80941Smrg      uint8_t b =
2199b8e80941Smrg              _mesa_unsigned_to_unsigned(src[2], 8);
2200b8e80941Smrg
2201b8e80941Smrg
2202b8e80941Smrg      uint8_t g =
2203b8e80941Smrg              _mesa_unsigned_to_unsigned(src[1], 8);
2204b8e80941Smrg
2205b8e80941Smrg
2206b8e80941Smrg      uint8_t r =
2207b8e80941Smrg              _mesa_unsigned_to_unsigned(src[0], 8);
2208b8e80941Smrg
2209b8e80941Smrg      uint32_t d = 0;
2210b8e80941Smrg         d |= PACK(a, 0, 8);
2211b8e80941Smrg         d |= PACK(b, 8, 8);
2212b8e80941Smrg         d |= PACK(g, 16, 8);
2213b8e80941Smrg         d |= PACK(r, 24, 8);
2214b8e80941Smrg      (*(uint32_t *)dst) = d;
2215b8e80941Smrg}
2216b8e80941Smrg
2217b8e80941Smrgstatic inline void
2218b8e80941Smrgpack_ubyte_a8r8g8b8_uint(const GLubyte src[4], void *dst)
2219b8e80941Smrg{
2220b8e80941Smrg
2221b8e80941Smrg
2222b8e80941Smrg      uint8_t a =
2223b8e80941Smrg              _mesa_unsigned_to_unsigned(src[3], 8);
2224b8e80941Smrg
2225b8e80941Smrg
2226b8e80941Smrg      uint8_t r =
2227b8e80941Smrg              _mesa_unsigned_to_unsigned(src[0], 8);
2228b8e80941Smrg
2229b8e80941Smrg
2230b8e80941Smrg      uint8_t g =
2231b8e80941Smrg              _mesa_unsigned_to_unsigned(src[1], 8);
2232b8e80941Smrg
2233b8e80941Smrg
2234b8e80941Smrg      uint8_t b =
2235b8e80941Smrg              _mesa_unsigned_to_unsigned(src[2], 8);
2236b8e80941Smrg
2237b8e80941Smrg      uint32_t d = 0;
2238b8e80941Smrg         d |= PACK(a, 0, 8);
2239b8e80941Smrg         d |= PACK(r, 8, 8);
2240b8e80941Smrg         d |= PACK(g, 16, 8);
2241b8e80941Smrg         d |= PACK(b, 24, 8);
2242b8e80941Smrg      (*(uint32_t *)dst) = d;
2243b8e80941Smrg}
2244b8e80941Smrg
2245b8e80941Smrgstatic inline void
2246b8e80941Smrgpack_ubyte_r8g8b8a8_uint(const GLubyte src[4], void *dst)
2247b8e80941Smrg{
2248b8e80941Smrg
2249b8e80941Smrg
2250b8e80941Smrg      uint8_t r =
2251b8e80941Smrg              _mesa_unsigned_to_unsigned(src[0], 8);
2252b8e80941Smrg
2253b8e80941Smrg
2254b8e80941Smrg      uint8_t g =
2255b8e80941Smrg              _mesa_unsigned_to_unsigned(src[1], 8);
2256b8e80941Smrg
2257b8e80941Smrg
2258b8e80941Smrg      uint8_t b =
2259b8e80941Smrg              _mesa_unsigned_to_unsigned(src[2], 8);
2260b8e80941Smrg
2261b8e80941Smrg
2262b8e80941Smrg      uint8_t a =
2263b8e80941Smrg              _mesa_unsigned_to_unsigned(src[3], 8);
2264b8e80941Smrg
2265b8e80941Smrg      uint32_t d = 0;
2266b8e80941Smrg         d |= PACK(r, 0, 8);
2267b8e80941Smrg         d |= PACK(g, 8, 8);
2268b8e80941Smrg         d |= PACK(b, 16, 8);
2269b8e80941Smrg         d |= PACK(a, 24, 8);
2270b8e80941Smrg      (*(uint32_t *)dst) = d;
2271b8e80941Smrg}
2272b8e80941Smrg
2273b8e80941Smrgstatic inline void
2274b8e80941Smrgpack_ubyte_b8g8r8a8_uint(const GLubyte src[4], void *dst)
2275b8e80941Smrg{
2276b8e80941Smrg
2277b8e80941Smrg
2278b8e80941Smrg      uint8_t b =
2279b8e80941Smrg              _mesa_unsigned_to_unsigned(src[2], 8);
2280b8e80941Smrg
2281b8e80941Smrg
2282b8e80941Smrg      uint8_t g =
2283b8e80941Smrg              _mesa_unsigned_to_unsigned(src[1], 8);
2284b8e80941Smrg
2285b8e80941Smrg
2286b8e80941Smrg      uint8_t r =
2287b8e80941Smrg              _mesa_unsigned_to_unsigned(src[0], 8);
2288b8e80941Smrg
2289b8e80941Smrg
2290b8e80941Smrg      uint8_t a =
2291b8e80941Smrg              _mesa_unsigned_to_unsigned(src[3], 8);
2292b8e80941Smrg
2293b8e80941Smrg      uint32_t d = 0;
2294b8e80941Smrg         d |= PACK(b, 0, 8);
2295b8e80941Smrg         d |= PACK(g, 8, 8);
2296b8e80941Smrg         d |= PACK(r, 16, 8);
2297b8e80941Smrg         d |= PACK(a, 24, 8);
2298b8e80941Smrg      (*(uint32_t *)dst) = d;
2299b8e80941Smrg}
2300b8e80941Smrg
2301b8e80941Smrgstatic inline void
2302b8e80941Smrgpack_ubyte_b10g10r10a2_uint(const GLubyte src[4], void *dst)
2303b8e80941Smrg{
2304b8e80941Smrg
2305b8e80941Smrg
2306b8e80941Smrg      uint16_t b =
2307b8e80941Smrg              _mesa_unsigned_to_unsigned(src[2], 10);
2308b8e80941Smrg
2309b8e80941Smrg
2310b8e80941Smrg      uint16_t g =
2311b8e80941Smrg              _mesa_unsigned_to_unsigned(src[1], 10);
2312b8e80941Smrg
2313b8e80941Smrg
2314b8e80941Smrg      uint16_t r =
2315b8e80941Smrg              _mesa_unsigned_to_unsigned(src[0], 10);
2316b8e80941Smrg
2317b8e80941Smrg
2318b8e80941Smrg      uint8_t a =
2319b8e80941Smrg              _mesa_unsigned_to_unsigned(src[3], 2);
2320b8e80941Smrg
2321b8e80941Smrg      uint32_t d = 0;
2322b8e80941Smrg         d |= PACK(b, 0, 10);
2323b8e80941Smrg         d |= PACK(g, 10, 10);
2324b8e80941Smrg         d |= PACK(r, 20, 10);
2325b8e80941Smrg         d |= PACK(a, 30, 2);
2326b8e80941Smrg      (*(uint32_t *)dst) = d;
2327b8e80941Smrg}
2328b8e80941Smrg
2329b8e80941Smrgstatic inline void
2330b8e80941Smrgpack_ubyte_r10g10b10a2_uint(const GLubyte src[4], void *dst)
2331b8e80941Smrg{
2332b8e80941Smrg
2333b8e80941Smrg
2334b8e80941Smrg      uint16_t r =
2335b8e80941Smrg              _mesa_unsigned_to_unsigned(src[0], 10);
2336b8e80941Smrg
2337b8e80941Smrg
2338b8e80941Smrg      uint16_t g =
2339b8e80941Smrg              _mesa_unsigned_to_unsigned(src[1], 10);
2340b8e80941Smrg
2341b8e80941Smrg
2342b8e80941Smrg      uint16_t b =
2343b8e80941Smrg              _mesa_unsigned_to_unsigned(src[2], 10);
2344b8e80941Smrg
2345b8e80941Smrg
2346b8e80941Smrg      uint8_t a =
2347b8e80941Smrg              _mesa_unsigned_to_unsigned(src[3], 2);
2348b8e80941Smrg
2349b8e80941Smrg      uint32_t d = 0;
2350b8e80941Smrg         d |= PACK(r, 0, 10);
2351b8e80941Smrg         d |= PACK(g, 10, 10);
2352b8e80941Smrg         d |= PACK(b, 20, 10);
2353b8e80941Smrg         d |= PACK(a, 30, 2);
2354b8e80941Smrg      (*(uint32_t *)dst) = d;
2355b8e80941Smrg}
2356b8e80941Smrg
2357b8e80941Smrgstatic inline void
2358b8e80941Smrgpack_ubyte_a2b10g10r10_uint(const GLubyte src[4], void *dst)
2359b8e80941Smrg{
2360b8e80941Smrg
2361b8e80941Smrg
2362b8e80941Smrg      uint8_t a =
2363b8e80941Smrg              _mesa_unsigned_to_unsigned(src[3], 2);
2364b8e80941Smrg
2365b8e80941Smrg
2366b8e80941Smrg      uint16_t b =
2367b8e80941Smrg              _mesa_unsigned_to_unsigned(src[2], 10);
2368b8e80941Smrg
2369b8e80941Smrg
2370b8e80941Smrg      uint16_t g =
2371b8e80941Smrg              _mesa_unsigned_to_unsigned(src[1], 10);
2372b8e80941Smrg
2373b8e80941Smrg
2374b8e80941Smrg      uint16_t r =
2375b8e80941Smrg              _mesa_unsigned_to_unsigned(src[0], 10);
2376b8e80941Smrg
2377b8e80941Smrg      uint32_t d = 0;
2378b8e80941Smrg         d |= PACK(a, 0, 2);
2379b8e80941Smrg         d |= PACK(b, 2, 10);
2380b8e80941Smrg         d |= PACK(g, 12, 10);
2381b8e80941Smrg         d |= PACK(r, 22, 10);
2382b8e80941Smrg      (*(uint32_t *)dst) = d;
2383b8e80941Smrg}
2384b8e80941Smrg
2385b8e80941Smrgstatic inline void
2386b8e80941Smrgpack_ubyte_a2r10g10b10_uint(const GLubyte src[4], void *dst)
2387b8e80941Smrg{
2388b8e80941Smrg
2389b8e80941Smrg
2390b8e80941Smrg      uint8_t a =
2391b8e80941Smrg              _mesa_unsigned_to_unsigned(src[3], 2);
2392b8e80941Smrg
2393b8e80941Smrg
2394b8e80941Smrg      uint16_t r =
2395b8e80941Smrg              _mesa_unsigned_to_unsigned(src[0], 10);
2396b8e80941Smrg
2397b8e80941Smrg
2398b8e80941Smrg      uint16_t g =
2399b8e80941Smrg              _mesa_unsigned_to_unsigned(src[1], 10);
2400b8e80941Smrg
2401b8e80941Smrg
2402b8e80941Smrg      uint16_t b =
2403b8e80941Smrg              _mesa_unsigned_to_unsigned(src[2], 10);
2404b8e80941Smrg
2405b8e80941Smrg      uint32_t d = 0;
2406b8e80941Smrg         d |= PACK(a, 0, 2);
2407b8e80941Smrg         d |= PACK(r, 2, 10);
2408b8e80941Smrg         d |= PACK(g, 12, 10);
2409b8e80941Smrg         d |= PACK(b, 22, 10);
2410b8e80941Smrg      (*(uint32_t *)dst) = d;
2411b8e80941Smrg}
2412b8e80941Smrg
2413b8e80941Smrgstatic inline void
2414b8e80941Smrgpack_ubyte_b5g6r5_uint(const GLubyte src[4], void *dst)
2415b8e80941Smrg{
2416b8e80941Smrg
2417b8e80941Smrg
2418b8e80941Smrg      uint8_t b =
2419b8e80941Smrg              _mesa_unsigned_to_unsigned(src[2], 5);
2420b8e80941Smrg
2421b8e80941Smrg
2422b8e80941Smrg      uint8_t g =
2423b8e80941Smrg              _mesa_unsigned_to_unsigned(src[1], 6);
2424b8e80941Smrg
2425b8e80941Smrg
2426b8e80941Smrg      uint8_t r =
2427b8e80941Smrg              _mesa_unsigned_to_unsigned(src[0], 5);
2428b8e80941Smrg
2429b8e80941Smrg      uint16_t d = 0;
2430b8e80941Smrg         d |= PACK(b, 0, 5);
2431b8e80941Smrg         d |= PACK(g, 5, 6);
2432b8e80941Smrg         d |= PACK(r, 11, 5);
2433b8e80941Smrg      (*(uint16_t *)dst) = d;
2434b8e80941Smrg}
2435b8e80941Smrg
2436b8e80941Smrgstatic inline void
2437b8e80941Smrgpack_ubyte_r5g6b5_uint(const GLubyte src[4], void *dst)
2438b8e80941Smrg{
2439b8e80941Smrg
2440b8e80941Smrg
2441b8e80941Smrg      uint8_t r =
2442b8e80941Smrg              _mesa_unsigned_to_unsigned(src[0], 5);
2443b8e80941Smrg
2444b8e80941Smrg
2445b8e80941Smrg      uint8_t g =
2446b8e80941Smrg              _mesa_unsigned_to_unsigned(src[1], 6);
2447b8e80941Smrg
2448b8e80941Smrg
2449b8e80941Smrg      uint8_t b =
2450b8e80941Smrg              _mesa_unsigned_to_unsigned(src[2], 5);
2451b8e80941Smrg
2452b8e80941Smrg      uint16_t d = 0;
2453b8e80941Smrg         d |= PACK(r, 0, 5);
2454b8e80941Smrg         d |= PACK(g, 5, 6);
2455b8e80941Smrg         d |= PACK(b, 11, 5);
2456b8e80941Smrg      (*(uint16_t *)dst) = d;
2457b8e80941Smrg}
2458b8e80941Smrg
2459b8e80941Smrgstatic inline void
2460b8e80941Smrgpack_ubyte_b2g3r3_uint(const GLubyte src[4], void *dst)
2461b8e80941Smrg{
2462b8e80941Smrg
2463b8e80941Smrg
2464b8e80941Smrg      uint8_t b =
2465b8e80941Smrg              _mesa_unsigned_to_unsigned(src[2], 2);
2466b8e80941Smrg
2467b8e80941Smrg
2468b8e80941Smrg      uint8_t g =
2469b8e80941Smrg              _mesa_unsigned_to_unsigned(src[1], 3);
2470b8e80941Smrg
2471b8e80941Smrg
2472b8e80941Smrg      uint8_t r =
2473b8e80941Smrg              _mesa_unsigned_to_unsigned(src[0], 3);
2474b8e80941Smrg
2475b8e80941Smrg      uint8_t d = 0;
2476b8e80941Smrg         d |= PACK(b, 0, 2);
2477b8e80941Smrg         d |= PACK(g, 2, 3);
2478b8e80941Smrg         d |= PACK(r, 5, 3);
2479b8e80941Smrg      (*(uint8_t *)dst) = d;
2480b8e80941Smrg}
2481b8e80941Smrg
2482b8e80941Smrgstatic inline void
2483b8e80941Smrgpack_ubyte_r3g3b2_uint(const GLubyte src[4], void *dst)
2484b8e80941Smrg{
2485b8e80941Smrg
2486b8e80941Smrg
2487b8e80941Smrg      uint8_t r =
2488b8e80941Smrg              _mesa_unsigned_to_unsigned(src[0], 3);
2489b8e80941Smrg
2490b8e80941Smrg
2491b8e80941Smrg      uint8_t g =
2492b8e80941Smrg              _mesa_unsigned_to_unsigned(src[1], 3);
2493b8e80941Smrg
2494b8e80941Smrg
2495b8e80941Smrg      uint8_t b =
2496b8e80941Smrg              _mesa_unsigned_to_unsigned(src[2], 2);
2497b8e80941Smrg
2498b8e80941Smrg      uint8_t d = 0;
2499b8e80941Smrg         d |= PACK(r, 0, 3);
2500b8e80941Smrg         d |= PACK(g, 3, 3);
2501b8e80941Smrg         d |= PACK(b, 6, 2);
2502b8e80941Smrg      (*(uint8_t *)dst) = d;
2503b8e80941Smrg}
2504b8e80941Smrg
2505b8e80941Smrgstatic inline void
2506b8e80941Smrgpack_ubyte_a4b4g4r4_uint(const GLubyte src[4], void *dst)
2507b8e80941Smrg{
2508b8e80941Smrg
2509b8e80941Smrg
2510b8e80941Smrg      uint8_t a =
2511b8e80941Smrg              _mesa_unsigned_to_unsigned(src[3], 4);
2512b8e80941Smrg
2513b8e80941Smrg
2514b8e80941Smrg      uint8_t b =
2515b8e80941Smrg              _mesa_unsigned_to_unsigned(src[2], 4);
2516b8e80941Smrg
2517b8e80941Smrg
2518b8e80941Smrg      uint8_t g =
2519b8e80941Smrg              _mesa_unsigned_to_unsigned(src[1], 4);
2520b8e80941Smrg
2521b8e80941Smrg
2522b8e80941Smrg      uint8_t r =
2523b8e80941Smrg              _mesa_unsigned_to_unsigned(src[0], 4);
2524b8e80941Smrg
2525b8e80941Smrg      uint16_t d = 0;
2526b8e80941Smrg         d |= PACK(a, 0, 4);
2527b8e80941Smrg         d |= PACK(b, 4, 4);
2528b8e80941Smrg         d |= PACK(g, 8, 4);
2529b8e80941Smrg         d |= PACK(r, 12, 4);
2530b8e80941Smrg      (*(uint16_t *)dst) = d;
2531b8e80941Smrg}
2532b8e80941Smrg
2533b8e80941Smrgstatic inline void
2534b8e80941Smrgpack_ubyte_r4g4b4a4_uint(const GLubyte src[4], void *dst)
2535b8e80941Smrg{
2536b8e80941Smrg
2537b8e80941Smrg
2538b8e80941Smrg      uint8_t r =
2539b8e80941Smrg              _mesa_unsigned_to_unsigned(src[0], 4);
2540b8e80941Smrg
2541b8e80941Smrg
2542b8e80941Smrg      uint8_t g =
2543b8e80941Smrg              _mesa_unsigned_to_unsigned(src[1], 4);
2544b8e80941Smrg
2545b8e80941Smrg
2546b8e80941Smrg      uint8_t b =
2547b8e80941Smrg              _mesa_unsigned_to_unsigned(src[2], 4);
2548b8e80941Smrg
2549b8e80941Smrg
2550b8e80941Smrg      uint8_t a =
2551b8e80941Smrg              _mesa_unsigned_to_unsigned(src[3], 4);
2552b8e80941Smrg
2553b8e80941Smrg      uint16_t d = 0;
2554b8e80941Smrg         d |= PACK(r, 0, 4);
2555b8e80941Smrg         d |= PACK(g, 4, 4);
2556b8e80941Smrg         d |= PACK(b, 8, 4);
2557b8e80941Smrg         d |= PACK(a, 12, 4);
2558b8e80941Smrg      (*(uint16_t *)dst) = d;
2559b8e80941Smrg}
2560b8e80941Smrg
2561b8e80941Smrgstatic inline void
2562b8e80941Smrgpack_ubyte_b4g4r4a4_uint(const GLubyte src[4], void *dst)
2563b8e80941Smrg{
2564b8e80941Smrg
2565b8e80941Smrg
2566b8e80941Smrg      uint8_t b =
2567b8e80941Smrg              _mesa_unsigned_to_unsigned(src[2], 4);
2568b8e80941Smrg
2569b8e80941Smrg
2570b8e80941Smrg      uint8_t g =
2571b8e80941Smrg              _mesa_unsigned_to_unsigned(src[1], 4);
2572b8e80941Smrg
2573b8e80941Smrg
2574b8e80941Smrg      uint8_t r =
2575b8e80941Smrg              _mesa_unsigned_to_unsigned(src[0], 4);
2576b8e80941Smrg
2577b8e80941Smrg
2578b8e80941Smrg      uint8_t a =
2579b8e80941Smrg              _mesa_unsigned_to_unsigned(src[3], 4);
2580b8e80941Smrg
2581b8e80941Smrg      uint16_t d = 0;
2582b8e80941Smrg         d |= PACK(b, 0, 4);
2583b8e80941Smrg         d |= PACK(g, 4, 4);
2584b8e80941Smrg         d |= PACK(r, 8, 4);
2585b8e80941Smrg         d |= PACK(a, 12, 4);
2586b8e80941Smrg      (*(uint16_t *)dst) = d;
2587b8e80941Smrg}
2588b8e80941Smrg
2589b8e80941Smrgstatic inline void
2590b8e80941Smrgpack_ubyte_a4r4g4b4_uint(const GLubyte src[4], void *dst)
2591b8e80941Smrg{
2592b8e80941Smrg
2593b8e80941Smrg
2594b8e80941Smrg      uint8_t a =
2595b8e80941Smrg              _mesa_unsigned_to_unsigned(src[3], 4);
2596b8e80941Smrg
2597b8e80941Smrg
2598b8e80941Smrg      uint8_t r =
2599b8e80941Smrg              _mesa_unsigned_to_unsigned(src[0], 4);
2600b8e80941Smrg
2601b8e80941Smrg
2602b8e80941Smrg      uint8_t g =
2603b8e80941Smrg              _mesa_unsigned_to_unsigned(src[1], 4);
2604b8e80941Smrg
2605b8e80941Smrg
2606b8e80941Smrg      uint8_t b =
2607b8e80941Smrg              _mesa_unsigned_to_unsigned(src[2], 4);
2608b8e80941Smrg
2609b8e80941Smrg      uint16_t d = 0;
2610b8e80941Smrg         d |= PACK(a, 0, 4);
2611b8e80941Smrg         d |= PACK(r, 4, 4);
2612b8e80941Smrg         d |= PACK(g, 8, 4);
2613b8e80941Smrg         d |= PACK(b, 12, 4);
2614b8e80941Smrg      (*(uint16_t *)dst) = d;
2615b8e80941Smrg}
2616b8e80941Smrg
2617b8e80941Smrgstatic inline void
2618b8e80941Smrgpack_ubyte_a1b5g5r5_uint(const GLubyte src[4], void *dst)
2619b8e80941Smrg{
2620b8e80941Smrg
2621b8e80941Smrg
2622b8e80941Smrg      uint8_t a =
2623b8e80941Smrg              _mesa_unsigned_to_unsigned(src[3], 1);
2624b8e80941Smrg
2625b8e80941Smrg
2626b8e80941Smrg      uint8_t b =
2627b8e80941Smrg              _mesa_unsigned_to_unsigned(src[2], 5);
2628b8e80941Smrg
2629b8e80941Smrg
2630b8e80941Smrg      uint8_t g =
2631b8e80941Smrg              _mesa_unsigned_to_unsigned(src[1], 5);
2632b8e80941Smrg
2633b8e80941Smrg
2634b8e80941Smrg      uint8_t r =
2635b8e80941Smrg              _mesa_unsigned_to_unsigned(src[0], 5);
2636b8e80941Smrg
2637b8e80941Smrg      uint16_t d = 0;
2638b8e80941Smrg         d |= PACK(a, 0, 1);
2639b8e80941Smrg         d |= PACK(b, 1, 5);
2640b8e80941Smrg         d |= PACK(g, 6, 5);
2641b8e80941Smrg         d |= PACK(r, 11, 5);
2642b8e80941Smrg      (*(uint16_t *)dst) = d;
2643b8e80941Smrg}
2644b8e80941Smrg
2645b8e80941Smrgstatic inline void
2646b8e80941Smrgpack_ubyte_b5g5r5a1_uint(const GLubyte src[4], void *dst)
2647b8e80941Smrg{
2648b8e80941Smrg
2649b8e80941Smrg
2650b8e80941Smrg      uint8_t b =
2651b8e80941Smrg              _mesa_unsigned_to_unsigned(src[2], 5);
2652b8e80941Smrg
2653b8e80941Smrg
2654b8e80941Smrg      uint8_t g =
2655b8e80941Smrg              _mesa_unsigned_to_unsigned(src[1], 5);
2656b8e80941Smrg
2657b8e80941Smrg
2658b8e80941Smrg      uint8_t r =
2659b8e80941Smrg              _mesa_unsigned_to_unsigned(src[0], 5);
2660b8e80941Smrg
2661b8e80941Smrg
2662b8e80941Smrg      uint8_t a =
2663b8e80941Smrg              _mesa_unsigned_to_unsigned(src[3], 1);
2664b8e80941Smrg
2665b8e80941Smrg      uint16_t d = 0;
2666b8e80941Smrg         d |= PACK(b, 0, 5);
2667b8e80941Smrg         d |= PACK(g, 5, 5);
2668b8e80941Smrg         d |= PACK(r, 10, 5);
2669b8e80941Smrg         d |= PACK(a, 15, 1);
2670b8e80941Smrg      (*(uint16_t *)dst) = d;
2671b8e80941Smrg}
2672b8e80941Smrg
2673b8e80941Smrgstatic inline void
2674b8e80941Smrgpack_ubyte_a1r5g5b5_uint(const GLubyte src[4], void *dst)
2675b8e80941Smrg{
2676b8e80941Smrg
2677b8e80941Smrg
2678b8e80941Smrg      uint8_t a =
2679b8e80941Smrg              _mesa_unsigned_to_unsigned(src[3], 1);
2680b8e80941Smrg
2681b8e80941Smrg
2682b8e80941Smrg      uint8_t r =
2683b8e80941Smrg              _mesa_unsigned_to_unsigned(src[0], 5);
2684b8e80941Smrg
2685b8e80941Smrg
2686b8e80941Smrg      uint8_t g =
2687b8e80941Smrg              _mesa_unsigned_to_unsigned(src[1], 5);
2688b8e80941Smrg
2689b8e80941Smrg
2690b8e80941Smrg      uint8_t b =
2691b8e80941Smrg              _mesa_unsigned_to_unsigned(src[2], 5);
2692b8e80941Smrg
2693b8e80941Smrg      uint16_t d = 0;
2694b8e80941Smrg         d |= PACK(a, 0, 1);
2695b8e80941Smrg         d |= PACK(r, 1, 5);
2696b8e80941Smrg         d |= PACK(g, 6, 5);
2697b8e80941Smrg         d |= PACK(b, 11, 5);
2698b8e80941Smrg      (*(uint16_t *)dst) = d;
2699b8e80941Smrg}
2700b8e80941Smrg
2701b8e80941Smrgstatic inline void
2702b8e80941Smrgpack_ubyte_r5g5b5a1_uint(const GLubyte src[4], void *dst)
2703b8e80941Smrg{
2704b8e80941Smrg
2705b8e80941Smrg
2706b8e80941Smrg      uint8_t r =
2707b8e80941Smrg              _mesa_unsigned_to_unsigned(src[0], 5);
2708b8e80941Smrg
2709b8e80941Smrg
2710b8e80941Smrg      uint8_t g =
2711b8e80941Smrg              _mesa_unsigned_to_unsigned(src[1], 5);
2712b8e80941Smrg
2713b8e80941Smrg
2714b8e80941Smrg      uint8_t b =
2715b8e80941Smrg              _mesa_unsigned_to_unsigned(src[2], 5);
2716b8e80941Smrg
2717b8e80941Smrg
2718b8e80941Smrg      uint8_t a =
2719b8e80941Smrg              _mesa_unsigned_to_unsigned(src[3], 1);
2720b8e80941Smrg
2721b8e80941Smrg      uint16_t d = 0;
2722b8e80941Smrg         d |= PACK(r, 0, 5);
2723b8e80941Smrg         d |= PACK(g, 5, 5);
2724b8e80941Smrg         d |= PACK(b, 10, 5);
2725b8e80941Smrg         d |= PACK(a, 15, 1);
2726b8e80941Smrg      (*(uint16_t *)dst) = d;
2727b8e80941Smrg}
2728b8e80941Smrg
2729b8e80941Smrgstatic inline void
2730b8e80941Smrgpack_ubyte_a_uint8(const GLubyte src[4], void *dst)
2731b8e80941Smrg{
2732b8e80941Smrg
2733b8e80941Smrg
2734b8e80941Smrg      uint8_t a =
2735b8e80941Smrg              _mesa_unsigned_to_unsigned(src[3], 8);
2736b8e80941Smrg
2737b8e80941Smrg      uint8_t *d = (uint8_t *)dst;
2738b8e80941Smrg         d[0] = a;
2739b8e80941Smrg}
2740b8e80941Smrg
2741b8e80941Smrgstatic inline void
2742b8e80941Smrgpack_ubyte_a_uint16(const GLubyte src[4], void *dst)
2743b8e80941Smrg{
2744b8e80941Smrg
2745b8e80941Smrg
2746b8e80941Smrg      uint16_t a =
2747b8e80941Smrg              _mesa_unsigned_to_unsigned(src[3], 16);
2748b8e80941Smrg
2749b8e80941Smrg      uint16_t *d = (uint16_t *)dst;
2750b8e80941Smrg         d[0] = a;
2751b8e80941Smrg}
2752b8e80941Smrg
2753b8e80941Smrgstatic inline void
2754b8e80941Smrgpack_ubyte_a_uint32(const GLubyte src[4], void *dst)
2755b8e80941Smrg{
2756b8e80941Smrg
2757b8e80941Smrg
2758b8e80941Smrg      uint32_t a =
2759b8e80941Smrg              _mesa_unsigned_to_unsigned(src[3], 32);
2760b8e80941Smrg
2761b8e80941Smrg      uint32_t *d = (uint32_t *)dst;
2762b8e80941Smrg         d[0] = a;
2763b8e80941Smrg}
2764b8e80941Smrg
2765b8e80941Smrgstatic inline void
2766b8e80941Smrgpack_ubyte_a_sint8(const GLubyte src[4], void *dst)
2767b8e80941Smrg{
2768b8e80941Smrg
2769b8e80941Smrg
2770b8e80941Smrg      int8_t a =
2771b8e80941Smrg              _mesa_unsigned_to_signed(src[3], 8);
2772b8e80941Smrg
2773b8e80941Smrg      int8_t *d = (int8_t *)dst;
2774b8e80941Smrg         d[0] = a;
2775b8e80941Smrg}
2776b8e80941Smrg
2777b8e80941Smrgstatic inline void
2778b8e80941Smrgpack_ubyte_a_sint16(const GLubyte src[4], void *dst)
2779b8e80941Smrg{
2780b8e80941Smrg
2781b8e80941Smrg
2782b8e80941Smrg      int16_t a =
2783b8e80941Smrg              _mesa_unsigned_to_signed(src[3], 16);
2784b8e80941Smrg
2785b8e80941Smrg      int16_t *d = (int16_t *)dst;
2786b8e80941Smrg         d[0] = a;
2787b8e80941Smrg}
2788b8e80941Smrg
2789b8e80941Smrgstatic inline void
2790b8e80941Smrgpack_ubyte_a_sint32(const GLubyte src[4], void *dst)
2791b8e80941Smrg{
2792b8e80941Smrg
2793b8e80941Smrg
2794b8e80941Smrg      int32_t a =
2795b8e80941Smrg              _mesa_unsigned_to_signed(src[3], 32);
2796b8e80941Smrg
2797b8e80941Smrg      int32_t *d = (int32_t *)dst;
2798b8e80941Smrg         d[0] = a;
2799b8e80941Smrg}
2800b8e80941Smrg
2801b8e80941Smrgstatic inline void
2802b8e80941Smrgpack_ubyte_i_uint8(const GLubyte src[4], void *dst)
2803b8e80941Smrg{
2804b8e80941Smrg
2805b8e80941Smrg
2806b8e80941Smrg      uint8_t i =
2807b8e80941Smrg              _mesa_unsigned_to_unsigned(src[0], 8);
2808b8e80941Smrg
2809b8e80941Smrg      uint8_t *d = (uint8_t *)dst;
2810b8e80941Smrg         d[0] = i;
2811b8e80941Smrg}
2812b8e80941Smrg
2813b8e80941Smrgstatic inline void
2814b8e80941Smrgpack_ubyte_i_uint16(const GLubyte src[4], void *dst)
2815b8e80941Smrg{
2816b8e80941Smrg
2817b8e80941Smrg
2818b8e80941Smrg      uint16_t i =
2819b8e80941Smrg              _mesa_unsigned_to_unsigned(src[0], 16);
2820b8e80941Smrg
2821b8e80941Smrg      uint16_t *d = (uint16_t *)dst;
2822b8e80941Smrg         d[0] = i;
2823b8e80941Smrg}
2824b8e80941Smrg
2825b8e80941Smrgstatic inline void
2826b8e80941Smrgpack_ubyte_i_uint32(const GLubyte src[4], void *dst)
2827b8e80941Smrg{
2828b8e80941Smrg
2829b8e80941Smrg
2830b8e80941Smrg      uint32_t i =
2831b8e80941Smrg              _mesa_unsigned_to_unsigned(src[0], 32);
2832b8e80941Smrg
2833b8e80941Smrg      uint32_t *d = (uint32_t *)dst;
2834b8e80941Smrg         d[0] = i;
2835b8e80941Smrg}
2836b8e80941Smrg
2837b8e80941Smrgstatic inline void
2838b8e80941Smrgpack_ubyte_i_sint8(const GLubyte src[4], void *dst)
2839b8e80941Smrg{
2840b8e80941Smrg
2841b8e80941Smrg
2842b8e80941Smrg      int8_t i =
2843b8e80941Smrg              _mesa_unsigned_to_signed(src[0], 8);
2844b8e80941Smrg
2845b8e80941Smrg      int8_t *d = (int8_t *)dst;
2846b8e80941Smrg         d[0] = i;
2847b8e80941Smrg}
2848b8e80941Smrg
2849b8e80941Smrgstatic inline void
2850b8e80941Smrgpack_ubyte_i_sint16(const GLubyte src[4], void *dst)
2851b8e80941Smrg{
2852b8e80941Smrg
2853b8e80941Smrg
2854b8e80941Smrg      int16_t i =
2855b8e80941Smrg              _mesa_unsigned_to_signed(src[0], 16);
2856b8e80941Smrg
2857b8e80941Smrg      int16_t *d = (int16_t *)dst;
2858b8e80941Smrg         d[0] = i;
2859b8e80941Smrg}
2860b8e80941Smrg
2861b8e80941Smrgstatic inline void
2862b8e80941Smrgpack_ubyte_i_sint32(const GLubyte src[4], void *dst)
2863b8e80941Smrg{
2864b8e80941Smrg
2865b8e80941Smrg
2866b8e80941Smrg      int32_t i =
2867b8e80941Smrg              _mesa_unsigned_to_signed(src[0], 32);
2868b8e80941Smrg
2869b8e80941Smrg      int32_t *d = (int32_t *)dst;
2870b8e80941Smrg         d[0] = i;
2871b8e80941Smrg}
2872b8e80941Smrg
2873b8e80941Smrgstatic inline void
2874b8e80941Smrgpack_ubyte_l_uint8(const GLubyte src[4], void *dst)
2875b8e80941Smrg{
2876b8e80941Smrg
2877b8e80941Smrg
2878b8e80941Smrg      uint8_t l =
2879b8e80941Smrg              _mesa_unsigned_to_unsigned(src[0], 8);
2880b8e80941Smrg
2881b8e80941Smrg      uint8_t *d = (uint8_t *)dst;
2882b8e80941Smrg         d[0] = l;
2883b8e80941Smrg}
2884b8e80941Smrg
2885b8e80941Smrgstatic inline void
2886b8e80941Smrgpack_ubyte_l_uint16(const GLubyte src[4], void *dst)
2887b8e80941Smrg{
2888b8e80941Smrg
2889b8e80941Smrg
2890b8e80941Smrg      uint16_t l =
2891b8e80941Smrg              _mesa_unsigned_to_unsigned(src[0], 16);
2892b8e80941Smrg
2893b8e80941Smrg      uint16_t *d = (uint16_t *)dst;
2894b8e80941Smrg         d[0] = l;
2895b8e80941Smrg}
2896b8e80941Smrg
2897b8e80941Smrgstatic inline void
2898b8e80941Smrgpack_ubyte_l_uint32(const GLubyte src[4], void *dst)
2899b8e80941Smrg{
2900b8e80941Smrg
2901b8e80941Smrg
2902b8e80941Smrg      uint32_t l =
2903b8e80941Smrg              _mesa_unsigned_to_unsigned(src[0], 32);
2904b8e80941Smrg
2905b8e80941Smrg      uint32_t *d = (uint32_t *)dst;
2906b8e80941Smrg         d[0] = l;
2907b8e80941Smrg}
2908b8e80941Smrg
2909b8e80941Smrgstatic inline void
2910b8e80941Smrgpack_ubyte_l_sint8(const GLubyte src[4], void *dst)
2911b8e80941Smrg{
2912b8e80941Smrg
2913b8e80941Smrg
2914b8e80941Smrg      int8_t l =
2915b8e80941Smrg              _mesa_unsigned_to_signed(src[0], 8);
2916b8e80941Smrg
2917b8e80941Smrg      int8_t *d = (int8_t *)dst;
2918b8e80941Smrg         d[0] = l;
2919b8e80941Smrg}
2920b8e80941Smrg
2921b8e80941Smrgstatic inline void
2922b8e80941Smrgpack_ubyte_l_sint16(const GLubyte src[4], void *dst)
2923b8e80941Smrg{
2924b8e80941Smrg
2925b8e80941Smrg
2926b8e80941Smrg      int16_t l =
2927b8e80941Smrg              _mesa_unsigned_to_signed(src[0], 16);
2928b8e80941Smrg
2929b8e80941Smrg      int16_t *d = (int16_t *)dst;
2930b8e80941Smrg         d[0] = l;
2931b8e80941Smrg}
2932b8e80941Smrg
2933b8e80941Smrgstatic inline void
2934b8e80941Smrgpack_ubyte_l_sint32(const GLubyte src[4], void *dst)
2935b8e80941Smrg{
2936b8e80941Smrg
2937b8e80941Smrg
2938b8e80941Smrg      int32_t l =
2939b8e80941Smrg              _mesa_unsigned_to_signed(src[0], 32);
2940b8e80941Smrg
2941b8e80941Smrg      int32_t *d = (int32_t *)dst;
2942b8e80941Smrg         d[0] = l;
2943b8e80941Smrg}
2944b8e80941Smrg
2945b8e80941Smrgstatic inline void
2946b8e80941Smrgpack_ubyte_la_uint8(const GLubyte src[4], void *dst)
2947b8e80941Smrg{
2948b8e80941Smrg
2949b8e80941Smrg
2950b8e80941Smrg      uint8_t l =
2951b8e80941Smrg              _mesa_unsigned_to_unsigned(src[0], 8);
2952b8e80941Smrg
2953b8e80941Smrg
2954b8e80941Smrg      uint8_t a =
2955b8e80941Smrg              _mesa_unsigned_to_unsigned(src[3], 8);
2956b8e80941Smrg
2957b8e80941Smrg      uint8_t *d = (uint8_t *)dst;
2958b8e80941Smrg         d[0] = l;
2959b8e80941Smrg         d[1] = a;
2960b8e80941Smrg}
2961b8e80941Smrg
2962b8e80941Smrgstatic inline void
2963b8e80941Smrgpack_ubyte_la_uint16(const GLubyte src[4], void *dst)
2964b8e80941Smrg{
2965b8e80941Smrg
2966b8e80941Smrg
2967b8e80941Smrg      uint16_t l =
2968b8e80941Smrg              _mesa_unsigned_to_unsigned(src[0], 16);
2969b8e80941Smrg
2970b8e80941Smrg
2971b8e80941Smrg      uint16_t a =
2972b8e80941Smrg              _mesa_unsigned_to_unsigned(src[3], 16);
2973b8e80941Smrg
2974b8e80941Smrg      uint16_t *d = (uint16_t *)dst;
2975b8e80941Smrg         d[0] = l;
2976b8e80941Smrg         d[1] = a;
2977b8e80941Smrg}
2978b8e80941Smrg
2979b8e80941Smrgstatic inline void
2980b8e80941Smrgpack_ubyte_la_uint32(const GLubyte src[4], void *dst)
2981b8e80941Smrg{
2982b8e80941Smrg
2983b8e80941Smrg
2984b8e80941Smrg      uint32_t l =
2985b8e80941Smrg              _mesa_unsigned_to_unsigned(src[0], 32);
2986b8e80941Smrg
2987b8e80941Smrg
2988b8e80941Smrg      uint32_t a =
2989b8e80941Smrg              _mesa_unsigned_to_unsigned(src[3], 32);
2990b8e80941Smrg
2991b8e80941Smrg      uint32_t *d = (uint32_t *)dst;
2992b8e80941Smrg         d[0] = l;
2993b8e80941Smrg         d[1] = a;
2994b8e80941Smrg}
2995b8e80941Smrg
2996b8e80941Smrgstatic inline void
2997b8e80941Smrgpack_ubyte_la_sint8(const GLubyte src[4], void *dst)
2998b8e80941Smrg{
2999b8e80941Smrg
3000b8e80941Smrg
3001b8e80941Smrg      int8_t l =
3002b8e80941Smrg              _mesa_unsigned_to_signed(src[0], 8);
3003b8e80941Smrg
3004b8e80941Smrg
3005b8e80941Smrg      int8_t a =
3006b8e80941Smrg              _mesa_unsigned_to_signed(src[3], 8);
3007b8e80941Smrg
3008b8e80941Smrg      int8_t *d = (int8_t *)dst;
3009b8e80941Smrg         d[0] = l;
3010b8e80941Smrg         d[1] = a;
3011b8e80941Smrg}
3012b8e80941Smrg
3013b8e80941Smrgstatic inline void
3014b8e80941Smrgpack_ubyte_la_sint16(const GLubyte src[4], void *dst)
3015b8e80941Smrg{
3016b8e80941Smrg
3017b8e80941Smrg
3018b8e80941Smrg      int16_t l =
3019b8e80941Smrg              _mesa_unsigned_to_signed(src[0], 16);
3020b8e80941Smrg
3021b8e80941Smrg
3022b8e80941Smrg      int16_t a =
3023b8e80941Smrg              _mesa_unsigned_to_signed(src[3], 16);
3024b8e80941Smrg
3025b8e80941Smrg      int16_t *d = (int16_t *)dst;
3026b8e80941Smrg         d[0] = l;
3027b8e80941Smrg         d[1] = a;
3028b8e80941Smrg}
3029b8e80941Smrg
3030b8e80941Smrgstatic inline void
3031b8e80941Smrgpack_ubyte_la_sint32(const GLubyte src[4], void *dst)
3032b8e80941Smrg{
3033b8e80941Smrg
3034b8e80941Smrg
3035b8e80941Smrg      int32_t l =
3036b8e80941Smrg              _mesa_unsigned_to_signed(src[0], 32);
3037b8e80941Smrg
3038b8e80941Smrg
3039b8e80941Smrg      int32_t a =
3040b8e80941Smrg              _mesa_unsigned_to_signed(src[3], 32);
3041b8e80941Smrg
3042b8e80941Smrg      int32_t *d = (int32_t *)dst;
3043b8e80941Smrg         d[0] = l;
3044b8e80941Smrg         d[1] = a;
3045b8e80941Smrg}
3046b8e80941Smrg
3047b8e80941Smrgstatic inline void
3048b8e80941Smrgpack_ubyte_r_uint8(const GLubyte src[4], void *dst)
3049b8e80941Smrg{
3050b8e80941Smrg
3051b8e80941Smrg
3052b8e80941Smrg      uint8_t r =
3053b8e80941Smrg              _mesa_unsigned_to_unsigned(src[0], 8);
3054b8e80941Smrg
3055b8e80941Smrg      uint8_t *d = (uint8_t *)dst;
3056b8e80941Smrg         d[0] = r;
3057b8e80941Smrg}
3058b8e80941Smrg
3059b8e80941Smrgstatic inline void
3060b8e80941Smrgpack_ubyte_r_uint16(const GLubyte src[4], void *dst)
3061b8e80941Smrg{
3062b8e80941Smrg
3063b8e80941Smrg
3064b8e80941Smrg      uint16_t r =
3065b8e80941Smrg              _mesa_unsigned_to_unsigned(src[0], 16);
3066b8e80941Smrg
3067b8e80941Smrg      uint16_t *d = (uint16_t *)dst;
3068b8e80941Smrg         d[0] = r;
3069b8e80941Smrg}
3070b8e80941Smrg
3071b8e80941Smrgstatic inline void
3072b8e80941Smrgpack_ubyte_r_uint32(const GLubyte src[4], void *dst)
3073b8e80941Smrg{
3074b8e80941Smrg
3075b8e80941Smrg
3076b8e80941Smrg      uint32_t r =
3077b8e80941Smrg              _mesa_unsigned_to_unsigned(src[0], 32);
3078b8e80941Smrg
3079b8e80941Smrg      uint32_t *d = (uint32_t *)dst;
3080b8e80941Smrg         d[0] = r;
3081b8e80941Smrg}
3082b8e80941Smrg
3083b8e80941Smrgstatic inline void
3084b8e80941Smrgpack_ubyte_r_sint8(const GLubyte src[4], void *dst)
3085b8e80941Smrg{
3086b8e80941Smrg
3087b8e80941Smrg
3088b8e80941Smrg      int8_t r =
3089b8e80941Smrg              _mesa_unsigned_to_signed(src[0], 8);
3090b8e80941Smrg
3091b8e80941Smrg      int8_t *d = (int8_t *)dst;
3092b8e80941Smrg         d[0] = r;
3093b8e80941Smrg}
3094b8e80941Smrg
3095b8e80941Smrgstatic inline void
3096b8e80941Smrgpack_ubyte_r_sint16(const GLubyte src[4], void *dst)
3097b8e80941Smrg{
3098b8e80941Smrg
3099b8e80941Smrg
3100b8e80941Smrg      int16_t r =
3101b8e80941Smrg              _mesa_unsigned_to_signed(src[0], 16);
3102b8e80941Smrg
3103b8e80941Smrg      int16_t *d = (int16_t *)dst;
3104b8e80941Smrg         d[0] = r;
3105b8e80941Smrg}
3106b8e80941Smrg
3107b8e80941Smrgstatic inline void
3108b8e80941Smrgpack_ubyte_r_sint32(const GLubyte src[4], void *dst)
3109b8e80941Smrg{
3110b8e80941Smrg
3111b8e80941Smrg
3112b8e80941Smrg      int32_t r =
3113b8e80941Smrg              _mesa_unsigned_to_signed(src[0], 32);
3114b8e80941Smrg
3115b8e80941Smrg      int32_t *d = (int32_t *)dst;
3116b8e80941Smrg         d[0] = r;
3117b8e80941Smrg}
3118b8e80941Smrg
3119b8e80941Smrgstatic inline void
3120b8e80941Smrgpack_ubyte_rg_uint8(const GLubyte src[4], void *dst)
3121b8e80941Smrg{
3122b8e80941Smrg
3123b8e80941Smrg
3124b8e80941Smrg      uint8_t r =
3125b8e80941Smrg              _mesa_unsigned_to_unsigned(src[0], 8);
3126b8e80941Smrg
3127b8e80941Smrg
3128b8e80941Smrg      uint8_t g =
3129b8e80941Smrg              _mesa_unsigned_to_unsigned(src[1], 8);
3130b8e80941Smrg
3131b8e80941Smrg      uint8_t *d = (uint8_t *)dst;
3132b8e80941Smrg         d[0] = r;
3133b8e80941Smrg         d[1] = g;
3134b8e80941Smrg}
3135b8e80941Smrg
3136b8e80941Smrgstatic inline void
3137b8e80941Smrgpack_ubyte_rg_uint16(const GLubyte src[4], void *dst)
3138b8e80941Smrg{
3139b8e80941Smrg
3140b8e80941Smrg
3141b8e80941Smrg      uint16_t r =
3142b8e80941Smrg              _mesa_unsigned_to_unsigned(src[0], 16);
3143b8e80941Smrg
3144b8e80941Smrg
3145b8e80941Smrg      uint16_t g =
3146b8e80941Smrg              _mesa_unsigned_to_unsigned(src[1], 16);
3147b8e80941Smrg
3148b8e80941Smrg      uint16_t *d = (uint16_t *)dst;
3149b8e80941Smrg         d[0] = r;
3150b8e80941Smrg         d[1] = g;
3151b8e80941Smrg}
3152b8e80941Smrg
3153b8e80941Smrgstatic inline void
3154b8e80941Smrgpack_ubyte_rg_uint32(const GLubyte src[4], void *dst)
3155b8e80941Smrg{
3156b8e80941Smrg
3157b8e80941Smrg
3158b8e80941Smrg      uint32_t r =
3159b8e80941Smrg              _mesa_unsigned_to_unsigned(src[0], 32);
3160b8e80941Smrg
3161b8e80941Smrg
3162b8e80941Smrg      uint32_t g =
3163b8e80941Smrg              _mesa_unsigned_to_unsigned(src[1], 32);
3164b8e80941Smrg
3165b8e80941Smrg      uint32_t *d = (uint32_t *)dst;
3166b8e80941Smrg         d[0] = r;
3167b8e80941Smrg         d[1] = g;
3168b8e80941Smrg}
3169b8e80941Smrg
3170b8e80941Smrgstatic inline void
3171b8e80941Smrgpack_ubyte_rg_sint8(const GLubyte src[4], void *dst)
3172b8e80941Smrg{
3173b8e80941Smrg
3174b8e80941Smrg
3175b8e80941Smrg      int8_t r =
3176b8e80941Smrg              _mesa_unsigned_to_signed(src[0], 8);
3177b8e80941Smrg
3178b8e80941Smrg
3179b8e80941Smrg      int8_t g =
3180b8e80941Smrg              _mesa_unsigned_to_signed(src[1], 8);
3181b8e80941Smrg
3182b8e80941Smrg      int8_t *d = (int8_t *)dst;
3183b8e80941Smrg         d[0] = r;
3184b8e80941Smrg         d[1] = g;
3185b8e80941Smrg}
3186b8e80941Smrg
3187b8e80941Smrgstatic inline void
3188b8e80941Smrgpack_ubyte_rg_sint16(const GLubyte src[4], void *dst)
3189b8e80941Smrg{
3190b8e80941Smrg
3191b8e80941Smrg
3192b8e80941Smrg      int16_t r =
3193b8e80941Smrg              _mesa_unsigned_to_signed(src[0], 16);
3194b8e80941Smrg
3195b8e80941Smrg
3196b8e80941Smrg      int16_t g =
3197b8e80941Smrg              _mesa_unsigned_to_signed(src[1], 16);
3198b8e80941Smrg
3199b8e80941Smrg      int16_t *d = (int16_t *)dst;
3200b8e80941Smrg         d[0] = r;
3201b8e80941Smrg         d[1] = g;
3202b8e80941Smrg}
3203b8e80941Smrg
3204b8e80941Smrgstatic inline void
3205b8e80941Smrgpack_ubyte_rg_sint32(const GLubyte src[4], void *dst)
3206b8e80941Smrg{
3207b8e80941Smrg
3208b8e80941Smrg
3209b8e80941Smrg      int32_t r =
3210b8e80941Smrg              _mesa_unsigned_to_signed(src[0], 32);
3211b8e80941Smrg
3212b8e80941Smrg
3213b8e80941Smrg      int32_t g =
3214b8e80941Smrg              _mesa_unsigned_to_signed(src[1], 32);
3215b8e80941Smrg
3216b8e80941Smrg      int32_t *d = (int32_t *)dst;
3217b8e80941Smrg         d[0] = r;
3218b8e80941Smrg         d[1] = g;
3219b8e80941Smrg}
3220b8e80941Smrg
3221b8e80941Smrgstatic inline void
3222b8e80941Smrgpack_ubyte_rgb_uint8(const GLubyte src[4], void *dst)
3223b8e80941Smrg{
3224b8e80941Smrg
3225b8e80941Smrg
3226b8e80941Smrg      uint8_t r =
3227b8e80941Smrg              _mesa_unsigned_to_unsigned(src[0], 8);
3228b8e80941Smrg
3229b8e80941Smrg
3230b8e80941Smrg      uint8_t g =
3231b8e80941Smrg              _mesa_unsigned_to_unsigned(src[1], 8);
3232b8e80941Smrg
3233b8e80941Smrg
3234b8e80941Smrg      uint8_t b =
3235b8e80941Smrg              _mesa_unsigned_to_unsigned(src[2], 8);
3236b8e80941Smrg
3237b8e80941Smrg      uint8_t *d = (uint8_t *)dst;
3238b8e80941Smrg         d[0] = r;
3239b8e80941Smrg         d[1] = g;
3240b8e80941Smrg         d[2] = b;
3241b8e80941Smrg}
3242b8e80941Smrg
3243b8e80941Smrgstatic inline void
3244b8e80941Smrgpack_ubyte_rgb_uint16(const GLubyte src[4], void *dst)
3245b8e80941Smrg{
3246b8e80941Smrg
3247b8e80941Smrg
3248b8e80941Smrg      uint16_t r =
3249b8e80941Smrg              _mesa_unsigned_to_unsigned(src[0], 16);
3250b8e80941Smrg
3251b8e80941Smrg
3252b8e80941Smrg      uint16_t g =
3253b8e80941Smrg              _mesa_unsigned_to_unsigned(src[1], 16);
3254b8e80941Smrg
3255b8e80941Smrg
3256b8e80941Smrg      uint16_t b =
3257b8e80941Smrg              _mesa_unsigned_to_unsigned(src[2], 16);
3258b8e80941Smrg
3259b8e80941Smrg      uint16_t *d = (uint16_t *)dst;
3260b8e80941Smrg         d[0] = r;
3261b8e80941Smrg         d[1] = g;
3262b8e80941Smrg         d[2] = b;
3263b8e80941Smrg}
3264b8e80941Smrg
3265b8e80941Smrgstatic inline void
3266b8e80941Smrgpack_ubyte_rgb_uint32(const GLubyte src[4], void *dst)
3267b8e80941Smrg{
3268b8e80941Smrg
3269b8e80941Smrg
3270b8e80941Smrg      uint32_t r =
3271b8e80941Smrg              _mesa_unsigned_to_unsigned(src[0], 32);
3272b8e80941Smrg
3273b8e80941Smrg
3274b8e80941Smrg      uint32_t g =
3275b8e80941Smrg              _mesa_unsigned_to_unsigned(src[1], 32);
3276b8e80941Smrg
3277b8e80941Smrg
3278b8e80941Smrg      uint32_t b =
3279b8e80941Smrg              _mesa_unsigned_to_unsigned(src[2], 32);
3280b8e80941Smrg
3281b8e80941Smrg      uint32_t *d = (uint32_t *)dst;
3282b8e80941Smrg         d[0] = r;
3283b8e80941Smrg         d[1] = g;
3284b8e80941Smrg         d[2] = b;
3285b8e80941Smrg}
3286b8e80941Smrg
3287b8e80941Smrgstatic inline void
3288b8e80941Smrgpack_ubyte_rgb_sint8(const GLubyte src[4], void *dst)
3289b8e80941Smrg{
3290b8e80941Smrg
3291b8e80941Smrg
3292b8e80941Smrg      int8_t r =
3293b8e80941Smrg              _mesa_unsigned_to_signed(src[0], 8);
3294b8e80941Smrg
3295b8e80941Smrg
3296b8e80941Smrg      int8_t g =
3297b8e80941Smrg              _mesa_unsigned_to_signed(src[1], 8);
3298b8e80941Smrg
3299b8e80941Smrg
3300b8e80941Smrg      int8_t b =
3301b8e80941Smrg              _mesa_unsigned_to_signed(src[2], 8);
3302b8e80941Smrg
3303b8e80941Smrg      int8_t *d = (int8_t *)dst;
3304b8e80941Smrg         d[0] = r;
3305b8e80941Smrg         d[1] = g;
3306b8e80941Smrg         d[2] = b;
3307b8e80941Smrg}
3308b8e80941Smrg
3309b8e80941Smrgstatic inline void
3310b8e80941Smrgpack_ubyte_rgb_sint16(const GLubyte src[4], void *dst)
3311b8e80941Smrg{
3312b8e80941Smrg
3313b8e80941Smrg
3314b8e80941Smrg      int16_t r =
3315b8e80941Smrg              _mesa_unsigned_to_signed(src[0], 16);
3316b8e80941Smrg
3317b8e80941Smrg
3318b8e80941Smrg      int16_t g =
3319b8e80941Smrg              _mesa_unsigned_to_signed(src[1], 16);
3320b8e80941Smrg
3321b8e80941Smrg
3322b8e80941Smrg      int16_t b =
3323b8e80941Smrg              _mesa_unsigned_to_signed(src[2], 16);
3324b8e80941Smrg
3325b8e80941Smrg      int16_t *d = (int16_t *)dst;
3326b8e80941Smrg         d[0] = r;
3327b8e80941Smrg         d[1] = g;
3328b8e80941Smrg         d[2] = b;
3329b8e80941Smrg}
3330b8e80941Smrg
3331b8e80941Smrgstatic inline void
3332b8e80941Smrgpack_ubyte_rgb_sint32(const GLubyte src[4], void *dst)
3333b8e80941Smrg{
3334b8e80941Smrg
3335b8e80941Smrg
3336b8e80941Smrg      int32_t r =
3337b8e80941Smrg              _mesa_unsigned_to_signed(src[0], 32);
3338b8e80941Smrg
3339b8e80941Smrg
3340b8e80941Smrg      int32_t g =
3341b8e80941Smrg              _mesa_unsigned_to_signed(src[1], 32);
3342b8e80941Smrg
3343b8e80941Smrg
3344b8e80941Smrg      int32_t b =
3345b8e80941Smrg              _mesa_unsigned_to_signed(src[2], 32);
3346b8e80941Smrg
3347b8e80941Smrg      int32_t *d = (int32_t *)dst;
3348b8e80941Smrg         d[0] = r;
3349b8e80941Smrg         d[1] = g;
3350b8e80941Smrg         d[2] = b;
3351b8e80941Smrg}
3352b8e80941Smrg
3353b8e80941Smrgstatic inline void
3354b8e80941Smrgpack_ubyte_rgba_uint8(const GLubyte src[4], void *dst)
3355b8e80941Smrg{
3356b8e80941Smrg
3357b8e80941Smrg
3358b8e80941Smrg      uint8_t r =
3359b8e80941Smrg              _mesa_unsigned_to_unsigned(src[0], 8);
3360b8e80941Smrg
3361b8e80941Smrg
3362b8e80941Smrg      uint8_t g =
3363b8e80941Smrg              _mesa_unsigned_to_unsigned(src[1], 8);
3364b8e80941Smrg
3365b8e80941Smrg
3366b8e80941Smrg      uint8_t b =
3367b8e80941Smrg              _mesa_unsigned_to_unsigned(src[2], 8);
3368b8e80941Smrg
3369b8e80941Smrg
3370b8e80941Smrg      uint8_t a =
3371b8e80941Smrg              _mesa_unsigned_to_unsigned(src[3], 8);
3372b8e80941Smrg
3373b8e80941Smrg      uint8_t *d = (uint8_t *)dst;
3374b8e80941Smrg         d[0] = r;
3375b8e80941Smrg         d[1] = g;
3376b8e80941Smrg         d[2] = b;
3377b8e80941Smrg         d[3] = a;
3378b8e80941Smrg}
3379b8e80941Smrg
3380b8e80941Smrgstatic inline void
3381b8e80941Smrgpack_ubyte_rgba_uint16(const GLubyte src[4], void *dst)
3382b8e80941Smrg{
3383b8e80941Smrg
3384b8e80941Smrg
3385b8e80941Smrg      uint16_t r =
3386b8e80941Smrg              _mesa_unsigned_to_unsigned(src[0], 16);
3387b8e80941Smrg
3388b8e80941Smrg
3389b8e80941Smrg      uint16_t g =
3390b8e80941Smrg              _mesa_unsigned_to_unsigned(src[1], 16);
3391b8e80941Smrg
3392b8e80941Smrg
3393b8e80941Smrg      uint16_t b =
3394b8e80941Smrg              _mesa_unsigned_to_unsigned(src[2], 16);
3395b8e80941Smrg
3396b8e80941Smrg
3397b8e80941Smrg      uint16_t a =
3398b8e80941Smrg              _mesa_unsigned_to_unsigned(src[3], 16);
3399b8e80941Smrg
3400b8e80941Smrg      uint16_t *d = (uint16_t *)dst;
3401b8e80941Smrg         d[0] = r;
3402b8e80941Smrg         d[1] = g;
3403b8e80941Smrg         d[2] = b;
3404b8e80941Smrg         d[3] = a;
3405b8e80941Smrg}
3406b8e80941Smrg
3407b8e80941Smrgstatic inline void
3408b8e80941Smrgpack_ubyte_rgba_uint32(const GLubyte src[4], void *dst)
3409b8e80941Smrg{
3410b8e80941Smrg
3411b8e80941Smrg
3412b8e80941Smrg      uint32_t r =
3413b8e80941Smrg              _mesa_unsigned_to_unsigned(src[0], 32);
3414b8e80941Smrg
3415b8e80941Smrg
3416b8e80941Smrg      uint32_t g =
3417b8e80941Smrg              _mesa_unsigned_to_unsigned(src[1], 32);
3418b8e80941Smrg
3419b8e80941Smrg
3420b8e80941Smrg      uint32_t b =
3421b8e80941Smrg              _mesa_unsigned_to_unsigned(src[2], 32);
3422b8e80941Smrg
3423b8e80941Smrg
3424b8e80941Smrg      uint32_t a =
3425b8e80941Smrg              _mesa_unsigned_to_unsigned(src[3], 32);
3426b8e80941Smrg
3427b8e80941Smrg      uint32_t *d = (uint32_t *)dst;
3428b8e80941Smrg         d[0] = r;
3429b8e80941Smrg         d[1] = g;
3430b8e80941Smrg         d[2] = b;
3431b8e80941Smrg         d[3] = a;
3432b8e80941Smrg}
3433b8e80941Smrg
3434b8e80941Smrgstatic inline void
3435b8e80941Smrgpack_ubyte_rgba_sint8(const GLubyte src[4], void *dst)
3436b8e80941Smrg{
3437b8e80941Smrg
3438b8e80941Smrg
3439b8e80941Smrg      int8_t r =
3440b8e80941Smrg              _mesa_unsigned_to_signed(src[0], 8);
3441b8e80941Smrg
3442b8e80941Smrg
3443b8e80941Smrg      int8_t g =
3444b8e80941Smrg              _mesa_unsigned_to_signed(src[1], 8);
3445b8e80941Smrg
3446b8e80941Smrg
3447b8e80941Smrg      int8_t b =
3448b8e80941Smrg              _mesa_unsigned_to_signed(src[2], 8);
3449b8e80941Smrg
3450b8e80941Smrg
3451b8e80941Smrg      int8_t a =
3452b8e80941Smrg              _mesa_unsigned_to_signed(src[3], 8);
3453b8e80941Smrg
3454b8e80941Smrg      int8_t *d = (int8_t *)dst;
3455b8e80941Smrg         d[0] = r;
3456b8e80941Smrg         d[1] = g;
3457b8e80941Smrg         d[2] = b;
3458b8e80941Smrg         d[3] = a;
3459b8e80941Smrg}
3460b8e80941Smrg
3461b8e80941Smrgstatic inline void
3462b8e80941Smrgpack_ubyte_rgba_sint16(const GLubyte src[4], void *dst)
3463b8e80941Smrg{
3464b8e80941Smrg
3465b8e80941Smrg
3466b8e80941Smrg      int16_t r =
3467b8e80941Smrg              _mesa_unsigned_to_signed(src[0], 16);
3468b8e80941Smrg
3469b8e80941Smrg
3470b8e80941Smrg      int16_t g =
3471b8e80941Smrg              _mesa_unsigned_to_signed(src[1], 16);
3472b8e80941Smrg
3473b8e80941Smrg
3474b8e80941Smrg      int16_t b =
3475b8e80941Smrg              _mesa_unsigned_to_signed(src[2], 16);
3476b8e80941Smrg
3477b8e80941Smrg
3478b8e80941Smrg      int16_t a =
3479b8e80941Smrg              _mesa_unsigned_to_signed(src[3], 16);
3480b8e80941Smrg
3481b8e80941Smrg      int16_t *d = (int16_t *)dst;
3482b8e80941Smrg         d[0] = r;
3483b8e80941Smrg         d[1] = g;
3484b8e80941Smrg         d[2] = b;
3485b8e80941Smrg         d[3] = a;
3486b8e80941Smrg}
3487b8e80941Smrg
3488b8e80941Smrgstatic inline void
3489b8e80941Smrgpack_ubyte_rgba_sint32(const GLubyte src[4], void *dst)
3490b8e80941Smrg{
3491b8e80941Smrg
3492b8e80941Smrg
3493b8e80941Smrg      int32_t r =
3494b8e80941Smrg              _mesa_unsigned_to_signed(src[0], 32);
3495b8e80941Smrg
3496b8e80941Smrg
3497b8e80941Smrg      int32_t g =
3498b8e80941Smrg              _mesa_unsigned_to_signed(src[1], 32);
3499b8e80941Smrg
3500b8e80941Smrg
3501b8e80941Smrg      int32_t b =
3502b8e80941Smrg              _mesa_unsigned_to_signed(src[2], 32);
3503b8e80941Smrg
3504b8e80941Smrg
3505b8e80941Smrg      int32_t a =
3506b8e80941Smrg              _mesa_unsigned_to_signed(src[3], 32);
3507b8e80941Smrg
3508b8e80941Smrg      int32_t *d = (int32_t *)dst;
3509b8e80941Smrg         d[0] = r;
3510b8e80941Smrg         d[1] = g;
3511b8e80941Smrg         d[2] = b;
3512b8e80941Smrg         d[3] = a;
3513b8e80941Smrg}
3514b8e80941Smrg
3515b8e80941Smrgstatic inline void
3516b8e80941Smrgpack_ubyte_rgbx_uint8(const GLubyte src[4], void *dst)
3517b8e80941Smrg{
3518b8e80941Smrg
3519b8e80941Smrg
3520b8e80941Smrg      uint8_t r =
3521b8e80941Smrg              _mesa_unsigned_to_unsigned(src[0], 8);
3522b8e80941Smrg
3523b8e80941Smrg
3524b8e80941Smrg      uint8_t g =
3525b8e80941Smrg              _mesa_unsigned_to_unsigned(src[1], 8);
3526b8e80941Smrg
3527b8e80941Smrg
3528b8e80941Smrg      uint8_t b =
3529b8e80941Smrg              _mesa_unsigned_to_unsigned(src[2], 8);
3530b8e80941Smrg
3531b8e80941Smrg
3532b8e80941Smrg      uint8_t *d = (uint8_t *)dst;
3533b8e80941Smrg         d[0] = r;
3534b8e80941Smrg         d[1] = g;
3535b8e80941Smrg         d[2] = b;
3536b8e80941Smrg            }
3537b8e80941Smrg
3538b8e80941Smrgstatic inline void
3539b8e80941Smrgpack_ubyte_rgbx_uint16(const GLubyte src[4], void *dst)
3540b8e80941Smrg{
3541b8e80941Smrg
3542b8e80941Smrg
3543b8e80941Smrg      uint16_t r =
3544b8e80941Smrg              _mesa_unsigned_to_unsigned(src[0], 16);
3545b8e80941Smrg
3546b8e80941Smrg
3547b8e80941Smrg      uint16_t g =
3548b8e80941Smrg              _mesa_unsigned_to_unsigned(src[1], 16);
3549b8e80941Smrg
3550b8e80941Smrg
3551b8e80941Smrg      uint16_t b =
3552b8e80941Smrg              _mesa_unsigned_to_unsigned(src[2], 16);
3553b8e80941Smrg
3554b8e80941Smrg
3555b8e80941Smrg      uint16_t *d = (uint16_t *)dst;
3556b8e80941Smrg         d[0] = r;
3557b8e80941Smrg         d[1] = g;
3558b8e80941Smrg         d[2] = b;
3559b8e80941Smrg            }
3560b8e80941Smrg
3561b8e80941Smrgstatic inline void
3562b8e80941Smrgpack_ubyte_rgbx_uint32(const GLubyte src[4], void *dst)
3563b8e80941Smrg{
3564b8e80941Smrg
3565b8e80941Smrg
3566b8e80941Smrg      uint32_t r =
3567b8e80941Smrg              _mesa_unsigned_to_unsigned(src[0], 32);
3568b8e80941Smrg
3569b8e80941Smrg
3570b8e80941Smrg      uint32_t g =
3571b8e80941Smrg              _mesa_unsigned_to_unsigned(src[1], 32);
3572b8e80941Smrg
3573b8e80941Smrg
3574b8e80941Smrg      uint32_t b =
3575b8e80941Smrg              _mesa_unsigned_to_unsigned(src[2], 32);
3576b8e80941Smrg
3577b8e80941Smrg
3578b8e80941Smrg      uint32_t *d = (uint32_t *)dst;
3579b8e80941Smrg         d[0] = r;
3580b8e80941Smrg         d[1] = g;
3581b8e80941Smrg         d[2] = b;
3582b8e80941Smrg            }
3583b8e80941Smrg
3584b8e80941Smrgstatic inline void
3585b8e80941Smrgpack_ubyte_rgbx_sint8(const GLubyte src[4], void *dst)
3586b8e80941Smrg{
3587b8e80941Smrg
3588b8e80941Smrg
3589b8e80941Smrg      int8_t r =
3590b8e80941Smrg              _mesa_unsigned_to_signed(src[0], 8);
3591b8e80941Smrg
3592b8e80941Smrg
3593b8e80941Smrg      int8_t g =
3594b8e80941Smrg              _mesa_unsigned_to_signed(src[1], 8);
3595b8e80941Smrg
3596b8e80941Smrg
3597b8e80941Smrg      int8_t b =
3598b8e80941Smrg              _mesa_unsigned_to_signed(src[2], 8);
3599b8e80941Smrg
3600b8e80941Smrg
3601b8e80941Smrg      int8_t *d = (int8_t *)dst;
3602b8e80941Smrg         d[0] = r;
3603b8e80941Smrg         d[1] = g;
3604b8e80941Smrg         d[2] = b;
3605b8e80941Smrg            }
3606b8e80941Smrg
3607b8e80941Smrgstatic inline void
3608b8e80941Smrgpack_ubyte_rgbx_sint16(const GLubyte src[4], void *dst)
3609b8e80941Smrg{
3610b8e80941Smrg
3611b8e80941Smrg
3612b8e80941Smrg      int16_t r =
3613b8e80941Smrg              _mesa_unsigned_to_signed(src[0], 16);
3614b8e80941Smrg
3615b8e80941Smrg
3616b8e80941Smrg      int16_t g =
3617b8e80941Smrg              _mesa_unsigned_to_signed(src[1], 16);
3618b8e80941Smrg
3619b8e80941Smrg
3620b8e80941Smrg      int16_t b =
3621b8e80941Smrg              _mesa_unsigned_to_signed(src[2], 16);
3622b8e80941Smrg
3623b8e80941Smrg
3624b8e80941Smrg      int16_t *d = (int16_t *)dst;
3625b8e80941Smrg         d[0] = r;
3626b8e80941Smrg         d[1] = g;
3627b8e80941Smrg         d[2] = b;
3628b8e80941Smrg            }
3629b8e80941Smrg
3630b8e80941Smrgstatic inline void
3631b8e80941Smrgpack_ubyte_rgbx_sint32(const GLubyte src[4], void *dst)
3632b8e80941Smrg{
3633b8e80941Smrg
3634b8e80941Smrg
3635b8e80941Smrg      int32_t r =
3636b8e80941Smrg              _mesa_unsigned_to_signed(src[0], 32);
3637b8e80941Smrg
3638b8e80941Smrg
3639b8e80941Smrg      int32_t g =
3640b8e80941Smrg              _mesa_unsigned_to_signed(src[1], 32);
3641b8e80941Smrg
3642b8e80941Smrg
3643b8e80941Smrg      int32_t b =
3644b8e80941Smrg              _mesa_unsigned_to_signed(src[2], 32);
3645b8e80941Smrg
3646b8e80941Smrg
3647b8e80941Smrg      int32_t *d = (int32_t *)dst;
3648b8e80941Smrg         d[0] = r;
3649b8e80941Smrg         d[1] = g;
3650b8e80941Smrg         d[2] = b;
3651b8e80941Smrg            }
3652b8e80941Smrg
3653b8e80941Smrgstatic inline void
3654b8e80941Smrgpack_ubyte_r9g9b9e5_float(const GLubyte src[4], void *dst)
3655b8e80941Smrg{
3656b8e80941Smrg   GLuint *d = (GLuint *) dst;
3657b8e80941Smrg   GLfloat rgb[3];
3658b8e80941Smrg   rgb[0] = _mesa_unorm_to_float(src[RCOMP], 8);
3659b8e80941Smrg   rgb[1] = _mesa_unorm_to_float(src[GCOMP], 8);
3660b8e80941Smrg   rgb[2] = _mesa_unorm_to_float(src[BCOMP], 8);
3661b8e80941Smrg   *d = float3_to_rgb9e5(rgb);
3662b8e80941Smrg}
3663b8e80941Smrg
3664b8e80941Smrgstatic inline void
3665b8e80941Smrgpack_ubyte_r11g11b10_float(const GLubyte src[4], void *dst)
3666b8e80941Smrg{
3667b8e80941Smrg   GLuint *d = (GLuint *) dst;
3668b8e80941Smrg   GLfloat rgb[3];
3669b8e80941Smrg   rgb[0] = _mesa_unorm_to_float(src[RCOMP], 8);
3670b8e80941Smrg   rgb[1] = _mesa_unorm_to_float(src[GCOMP], 8);
3671b8e80941Smrg   rgb[2] = _mesa_unorm_to_float(src[BCOMP], 8);
3672b8e80941Smrg   *d = float3_to_r11g11b10f(rgb);
3673b8e80941Smrg}
3674b8e80941Smrg
3675b8e80941Smrg/* uint packing functions */
3676b8e80941Smrg
3677b8e80941Smrg
3678b8e80941Smrgstatic inline void
3679b8e80941Smrgpack_uint_a8b8g8r8_uint(const GLuint src[4], void *dst)
3680b8e80941Smrg{
3681b8e80941Smrg
3682b8e80941Smrg
3683b8e80941Smrg      uint8_t a =
3684b8e80941Smrg         _mesa_unsigned_to_unsigned(src[3], 8);
3685b8e80941Smrg
3686b8e80941Smrg
3687b8e80941Smrg      uint8_t b =
3688b8e80941Smrg         _mesa_unsigned_to_unsigned(src[2], 8);
3689b8e80941Smrg
3690b8e80941Smrg
3691b8e80941Smrg      uint8_t g =
3692b8e80941Smrg         _mesa_unsigned_to_unsigned(src[1], 8);
3693b8e80941Smrg
3694b8e80941Smrg
3695b8e80941Smrg      uint8_t r =
3696b8e80941Smrg         _mesa_unsigned_to_unsigned(src[0], 8);
3697b8e80941Smrg
3698b8e80941Smrg      uint32_t d = 0;
3699b8e80941Smrg         d |= PACK(a, 0, 8);
3700b8e80941Smrg         d |= PACK(b, 8, 8);
3701b8e80941Smrg         d |= PACK(g, 16, 8);
3702b8e80941Smrg         d |= PACK(r, 24, 8);
3703b8e80941Smrg      (*(uint32_t *)dst) = d;
3704b8e80941Smrg}
3705b8e80941Smrg
3706b8e80941Smrgstatic inline void
3707b8e80941Smrgpack_uint_a8r8g8b8_uint(const GLuint src[4], void *dst)
3708b8e80941Smrg{
3709b8e80941Smrg
3710b8e80941Smrg
3711b8e80941Smrg      uint8_t a =
3712b8e80941Smrg         _mesa_unsigned_to_unsigned(src[3], 8);
3713b8e80941Smrg
3714b8e80941Smrg
3715b8e80941Smrg      uint8_t r =
3716b8e80941Smrg         _mesa_unsigned_to_unsigned(src[0], 8);
3717b8e80941Smrg
3718b8e80941Smrg
3719b8e80941Smrg      uint8_t g =
3720b8e80941Smrg         _mesa_unsigned_to_unsigned(src[1], 8);
3721b8e80941Smrg
3722b8e80941Smrg
3723b8e80941Smrg      uint8_t b =
3724b8e80941Smrg         _mesa_unsigned_to_unsigned(src[2], 8);
3725b8e80941Smrg
3726b8e80941Smrg      uint32_t d = 0;
3727b8e80941Smrg         d |= PACK(a, 0, 8);
3728b8e80941Smrg         d |= PACK(r, 8, 8);
3729b8e80941Smrg         d |= PACK(g, 16, 8);
3730b8e80941Smrg         d |= PACK(b, 24, 8);
3731b8e80941Smrg      (*(uint32_t *)dst) = d;
3732b8e80941Smrg}
3733b8e80941Smrg
3734b8e80941Smrgstatic inline void
3735b8e80941Smrgpack_uint_r8g8b8a8_uint(const GLuint src[4], void *dst)
3736b8e80941Smrg{
3737b8e80941Smrg
3738b8e80941Smrg
3739b8e80941Smrg      uint8_t r =
3740b8e80941Smrg         _mesa_unsigned_to_unsigned(src[0], 8);
3741b8e80941Smrg
3742b8e80941Smrg
3743b8e80941Smrg      uint8_t g =
3744b8e80941Smrg         _mesa_unsigned_to_unsigned(src[1], 8);
3745b8e80941Smrg
3746b8e80941Smrg
3747b8e80941Smrg      uint8_t b =
3748b8e80941Smrg         _mesa_unsigned_to_unsigned(src[2], 8);
3749b8e80941Smrg
3750b8e80941Smrg
3751b8e80941Smrg      uint8_t a =
3752b8e80941Smrg         _mesa_unsigned_to_unsigned(src[3], 8);
3753b8e80941Smrg
3754b8e80941Smrg      uint32_t d = 0;
3755b8e80941Smrg         d |= PACK(r, 0, 8);
3756b8e80941Smrg         d |= PACK(g, 8, 8);
3757b8e80941Smrg         d |= PACK(b, 16, 8);
3758b8e80941Smrg         d |= PACK(a, 24, 8);
3759b8e80941Smrg      (*(uint32_t *)dst) = d;
3760b8e80941Smrg}
3761b8e80941Smrg
3762b8e80941Smrgstatic inline void
3763b8e80941Smrgpack_uint_b8g8r8a8_uint(const GLuint src[4], void *dst)
3764b8e80941Smrg{
3765b8e80941Smrg
3766b8e80941Smrg
3767b8e80941Smrg      uint8_t b =
3768b8e80941Smrg         _mesa_unsigned_to_unsigned(src[2], 8);
3769b8e80941Smrg
3770b8e80941Smrg
3771b8e80941Smrg      uint8_t g =
3772b8e80941Smrg         _mesa_unsigned_to_unsigned(src[1], 8);
3773b8e80941Smrg
3774b8e80941Smrg
3775b8e80941Smrg      uint8_t r =
3776b8e80941Smrg         _mesa_unsigned_to_unsigned(src[0], 8);
3777b8e80941Smrg
3778b8e80941Smrg
3779b8e80941Smrg      uint8_t a =
3780b8e80941Smrg         _mesa_unsigned_to_unsigned(src[3], 8);
3781b8e80941Smrg
3782b8e80941Smrg      uint32_t d = 0;
3783b8e80941Smrg         d |= PACK(b, 0, 8);
3784b8e80941Smrg         d |= PACK(g, 8, 8);
3785b8e80941Smrg         d |= PACK(r, 16, 8);
3786b8e80941Smrg         d |= PACK(a, 24, 8);
3787b8e80941Smrg      (*(uint32_t *)dst) = d;
3788b8e80941Smrg}
3789b8e80941Smrg
3790b8e80941Smrgstatic inline void
3791b8e80941Smrgpack_uint_b10g10r10a2_uint(const GLuint src[4], void *dst)
3792b8e80941Smrg{
3793b8e80941Smrg
3794b8e80941Smrg
3795b8e80941Smrg      uint16_t b =
3796b8e80941Smrg         _mesa_unsigned_to_unsigned(src[2], 10);
3797b8e80941Smrg
3798b8e80941Smrg
3799b8e80941Smrg      uint16_t g =
3800b8e80941Smrg         _mesa_unsigned_to_unsigned(src[1], 10);
3801b8e80941Smrg
3802b8e80941Smrg
3803b8e80941Smrg      uint16_t r =
3804b8e80941Smrg         _mesa_unsigned_to_unsigned(src[0], 10);
3805b8e80941Smrg
3806b8e80941Smrg
3807b8e80941Smrg      uint8_t a =
3808b8e80941Smrg         _mesa_unsigned_to_unsigned(src[3], 2);
3809b8e80941Smrg
3810b8e80941Smrg      uint32_t d = 0;
3811b8e80941Smrg         d |= PACK(b, 0, 10);
3812b8e80941Smrg         d |= PACK(g, 10, 10);
3813b8e80941Smrg         d |= PACK(r, 20, 10);
3814b8e80941Smrg         d |= PACK(a, 30, 2);
3815b8e80941Smrg      (*(uint32_t *)dst) = d;
3816b8e80941Smrg}
3817b8e80941Smrg
3818b8e80941Smrgstatic inline void
3819b8e80941Smrgpack_uint_r10g10b10a2_uint(const GLuint src[4], void *dst)
3820b8e80941Smrg{
3821b8e80941Smrg
3822b8e80941Smrg
3823b8e80941Smrg      uint16_t r =
3824b8e80941Smrg         _mesa_unsigned_to_unsigned(src[0], 10);
3825b8e80941Smrg
3826b8e80941Smrg
3827b8e80941Smrg      uint16_t g =
3828b8e80941Smrg         _mesa_unsigned_to_unsigned(src[1], 10);
3829b8e80941Smrg
3830b8e80941Smrg
3831b8e80941Smrg      uint16_t b =
3832b8e80941Smrg         _mesa_unsigned_to_unsigned(src[2], 10);
3833b8e80941Smrg
3834b8e80941Smrg
3835b8e80941Smrg      uint8_t a =
3836b8e80941Smrg         _mesa_unsigned_to_unsigned(src[3], 2);
3837b8e80941Smrg
3838b8e80941Smrg      uint32_t d = 0;
3839b8e80941Smrg         d |= PACK(r, 0, 10);
3840b8e80941Smrg         d |= PACK(g, 10, 10);
3841b8e80941Smrg         d |= PACK(b, 20, 10);
3842b8e80941Smrg         d |= PACK(a, 30, 2);
3843b8e80941Smrg      (*(uint32_t *)dst) = d;
3844b8e80941Smrg}
3845b8e80941Smrg
3846b8e80941Smrgstatic inline void
3847b8e80941Smrgpack_uint_a2b10g10r10_uint(const GLuint src[4], void *dst)
3848b8e80941Smrg{
3849b8e80941Smrg
3850b8e80941Smrg
3851b8e80941Smrg      uint8_t a =
3852b8e80941Smrg         _mesa_unsigned_to_unsigned(src[3], 2);
3853b8e80941Smrg
3854b8e80941Smrg
3855b8e80941Smrg      uint16_t b =
3856b8e80941Smrg         _mesa_unsigned_to_unsigned(src[2], 10);
3857b8e80941Smrg
3858b8e80941Smrg
3859b8e80941Smrg      uint16_t g =
3860b8e80941Smrg         _mesa_unsigned_to_unsigned(src[1], 10);
3861b8e80941Smrg
3862b8e80941Smrg
3863b8e80941Smrg      uint16_t r =
3864b8e80941Smrg         _mesa_unsigned_to_unsigned(src[0], 10);
3865b8e80941Smrg
3866b8e80941Smrg      uint32_t d = 0;
3867b8e80941Smrg         d |= PACK(a, 0, 2);
3868b8e80941Smrg         d |= PACK(b, 2, 10);
3869b8e80941Smrg         d |= PACK(g, 12, 10);
3870b8e80941Smrg         d |= PACK(r, 22, 10);
3871b8e80941Smrg      (*(uint32_t *)dst) = d;
3872b8e80941Smrg}
3873b8e80941Smrg
3874b8e80941Smrgstatic inline void
3875b8e80941Smrgpack_uint_a2r10g10b10_uint(const GLuint src[4], void *dst)
3876b8e80941Smrg{
3877b8e80941Smrg
3878b8e80941Smrg
3879b8e80941Smrg      uint8_t a =
3880b8e80941Smrg         _mesa_unsigned_to_unsigned(src[3], 2);
3881b8e80941Smrg
3882b8e80941Smrg
3883b8e80941Smrg      uint16_t r =
3884b8e80941Smrg         _mesa_unsigned_to_unsigned(src[0], 10);
3885b8e80941Smrg
3886b8e80941Smrg
3887b8e80941Smrg      uint16_t g =
3888b8e80941Smrg         _mesa_unsigned_to_unsigned(src[1], 10);
3889b8e80941Smrg
3890b8e80941Smrg
3891b8e80941Smrg      uint16_t b =
3892b8e80941Smrg         _mesa_unsigned_to_unsigned(src[2], 10);
3893b8e80941Smrg
3894b8e80941Smrg      uint32_t d = 0;
3895b8e80941Smrg         d |= PACK(a, 0, 2);
3896b8e80941Smrg         d |= PACK(r, 2, 10);
3897b8e80941Smrg         d |= PACK(g, 12, 10);
3898b8e80941Smrg         d |= PACK(b, 22, 10);
3899b8e80941Smrg      (*(uint32_t *)dst) = d;
3900b8e80941Smrg}
3901b8e80941Smrg
3902b8e80941Smrgstatic inline void
3903b8e80941Smrgpack_uint_b5g6r5_uint(const GLuint src[4], void *dst)
3904b8e80941Smrg{
3905b8e80941Smrg
3906b8e80941Smrg
3907b8e80941Smrg      uint8_t b =
3908b8e80941Smrg         _mesa_unsigned_to_unsigned(src[2], 5);
3909b8e80941Smrg
3910b8e80941Smrg
3911b8e80941Smrg      uint8_t g =
3912b8e80941Smrg         _mesa_unsigned_to_unsigned(src[1], 6);
3913b8e80941Smrg
3914b8e80941Smrg
3915b8e80941Smrg      uint8_t r =
3916b8e80941Smrg         _mesa_unsigned_to_unsigned(src[0], 5);
3917b8e80941Smrg
3918b8e80941Smrg      uint16_t d = 0;
3919b8e80941Smrg         d |= PACK(b, 0, 5);
3920b8e80941Smrg         d |= PACK(g, 5, 6);
3921b8e80941Smrg         d |= PACK(r, 11, 5);
3922b8e80941Smrg      (*(uint16_t *)dst) = d;
3923b8e80941Smrg}
3924b8e80941Smrg
3925b8e80941Smrgstatic inline void
3926b8e80941Smrgpack_uint_r5g6b5_uint(const GLuint src[4], void *dst)
3927b8e80941Smrg{
3928b8e80941Smrg
3929b8e80941Smrg
3930b8e80941Smrg      uint8_t r =
3931b8e80941Smrg         _mesa_unsigned_to_unsigned(src[0], 5);
3932b8e80941Smrg
3933b8e80941Smrg
3934b8e80941Smrg      uint8_t g =
3935b8e80941Smrg         _mesa_unsigned_to_unsigned(src[1], 6);
3936b8e80941Smrg
3937b8e80941Smrg
3938b8e80941Smrg      uint8_t b =
3939b8e80941Smrg         _mesa_unsigned_to_unsigned(src[2], 5);
3940b8e80941Smrg
3941b8e80941Smrg      uint16_t d = 0;
3942b8e80941Smrg         d |= PACK(r, 0, 5);
3943b8e80941Smrg         d |= PACK(g, 5, 6);
3944b8e80941Smrg         d |= PACK(b, 11, 5);
3945b8e80941Smrg      (*(uint16_t *)dst) = d;
3946b8e80941Smrg}
3947b8e80941Smrg
3948b8e80941Smrgstatic inline void
3949b8e80941Smrgpack_uint_b2g3r3_uint(const GLuint src[4], void *dst)
3950b8e80941Smrg{
3951b8e80941Smrg
3952b8e80941Smrg
3953b8e80941Smrg      uint8_t b =
3954b8e80941Smrg         _mesa_unsigned_to_unsigned(src[2], 2);
3955b8e80941Smrg
3956b8e80941Smrg
3957b8e80941Smrg      uint8_t g =
3958b8e80941Smrg         _mesa_unsigned_to_unsigned(src[1], 3);
3959b8e80941Smrg
3960b8e80941Smrg
3961b8e80941Smrg      uint8_t r =
3962b8e80941Smrg         _mesa_unsigned_to_unsigned(src[0], 3);
3963b8e80941Smrg
3964b8e80941Smrg      uint8_t d = 0;
3965b8e80941Smrg         d |= PACK(b, 0, 2);
3966b8e80941Smrg         d |= PACK(g, 2, 3);
3967b8e80941Smrg         d |= PACK(r, 5, 3);
3968b8e80941Smrg      (*(uint8_t *)dst) = d;
3969b8e80941Smrg}
3970b8e80941Smrg
3971b8e80941Smrgstatic inline void
3972b8e80941Smrgpack_uint_r3g3b2_uint(const GLuint src[4], void *dst)
3973b8e80941Smrg{
3974b8e80941Smrg
3975b8e80941Smrg
3976b8e80941Smrg      uint8_t r =
3977b8e80941Smrg         _mesa_unsigned_to_unsigned(src[0], 3);
3978b8e80941Smrg
3979b8e80941Smrg
3980b8e80941Smrg      uint8_t g =
3981b8e80941Smrg         _mesa_unsigned_to_unsigned(src[1], 3);
3982b8e80941Smrg
3983b8e80941Smrg
3984b8e80941Smrg      uint8_t b =
3985b8e80941Smrg         _mesa_unsigned_to_unsigned(src[2], 2);
3986b8e80941Smrg
3987b8e80941Smrg      uint8_t d = 0;
3988b8e80941Smrg         d |= PACK(r, 0, 3);
3989b8e80941Smrg         d |= PACK(g, 3, 3);
3990b8e80941Smrg         d |= PACK(b, 6, 2);
3991b8e80941Smrg      (*(uint8_t *)dst) = d;
3992b8e80941Smrg}
3993b8e80941Smrg
3994b8e80941Smrgstatic inline void
3995b8e80941Smrgpack_uint_a4b4g4r4_uint(const GLuint src[4], void *dst)
3996b8e80941Smrg{
3997b8e80941Smrg
3998b8e80941Smrg
3999b8e80941Smrg      uint8_t a =
4000b8e80941Smrg         _mesa_unsigned_to_unsigned(src[3], 4);
4001b8e80941Smrg
4002b8e80941Smrg
4003b8e80941Smrg      uint8_t b =
4004b8e80941Smrg         _mesa_unsigned_to_unsigned(src[2], 4);
4005b8e80941Smrg
4006b8e80941Smrg
4007b8e80941Smrg      uint8_t g =
4008b8e80941Smrg         _mesa_unsigned_to_unsigned(src[1], 4);
4009b8e80941Smrg
4010b8e80941Smrg
4011b8e80941Smrg      uint8_t r =
4012b8e80941Smrg         _mesa_unsigned_to_unsigned(src[0], 4);
4013b8e80941Smrg
4014b8e80941Smrg      uint16_t d = 0;
4015b8e80941Smrg         d |= PACK(a, 0, 4);
4016b8e80941Smrg         d |= PACK(b, 4, 4);
4017b8e80941Smrg         d |= PACK(g, 8, 4);
4018b8e80941Smrg         d |= PACK(r, 12, 4);
4019b8e80941Smrg      (*(uint16_t *)dst) = d;
4020b8e80941Smrg}
4021b8e80941Smrg
4022b8e80941Smrgstatic inline void
4023b8e80941Smrgpack_uint_r4g4b4a4_uint(const GLuint src[4], void *dst)
4024b8e80941Smrg{
4025b8e80941Smrg
4026b8e80941Smrg
4027b8e80941Smrg      uint8_t r =
4028b8e80941Smrg         _mesa_unsigned_to_unsigned(src[0], 4);
4029b8e80941Smrg
4030b8e80941Smrg
4031b8e80941Smrg      uint8_t g =
4032b8e80941Smrg         _mesa_unsigned_to_unsigned(src[1], 4);
4033b8e80941Smrg
4034b8e80941Smrg
4035b8e80941Smrg      uint8_t b =
4036b8e80941Smrg         _mesa_unsigned_to_unsigned(src[2], 4);
4037b8e80941Smrg
4038b8e80941Smrg
4039b8e80941Smrg      uint8_t a =
4040b8e80941Smrg         _mesa_unsigned_to_unsigned(src[3], 4);
4041b8e80941Smrg
4042b8e80941Smrg      uint16_t d = 0;
4043b8e80941Smrg         d |= PACK(r, 0, 4);
4044b8e80941Smrg         d |= PACK(g, 4, 4);
4045b8e80941Smrg         d |= PACK(b, 8, 4);
4046b8e80941Smrg         d |= PACK(a, 12, 4);
4047b8e80941Smrg      (*(uint16_t *)dst) = d;
4048b8e80941Smrg}
4049b8e80941Smrg
4050b8e80941Smrgstatic inline void
4051b8e80941Smrgpack_uint_b4g4r4a4_uint(const GLuint src[4], void *dst)
4052b8e80941Smrg{
4053b8e80941Smrg
4054b8e80941Smrg
4055b8e80941Smrg      uint8_t b =
4056b8e80941Smrg         _mesa_unsigned_to_unsigned(src[2], 4);
4057b8e80941Smrg
4058b8e80941Smrg
4059b8e80941Smrg      uint8_t g =
4060b8e80941Smrg         _mesa_unsigned_to_unsigned(src[1], 4);
4061b8e80941Smrg
4062b8e80941Smrg
4063b8e80941Smrg      uint8_t r =
4064b8e80941Smrg         _mesa_unsigned_to_unsigned(src[0], 4);
4065b8e80941Smrg
4066b8e80941Smrg
4067b8e80941Smrg      uint8_t a =
4068b8e80941Smrg         _mesa_unsigned_to_unsigned(src[3], 4);
4069b8e80941Smrg
4070b8e80941Smrg      uint16_t d = 0;
4071b8e80941Smrg         d |= PACK(b, 0, 4);
4072b8e80941Smrg         d |= PACK(g, 4, 4);
4073b8e80941Smrg         d |= PACK(r, 8, 4);
4074b8e80941Smrg         d |= PACK(a, 12, 4);
4075b8e80941Smrg      (*(uint16_t *)dst) = d;
4076b8e80941Smrg}
4077b8e80941Smrg
4078b8e80941Smrgstatic inline void
4079b8e80941Smrgpack_uint_a4r4g4b4_uint(const GLuint src[4], void *dst)
4080b8e80941Smrg{
4081b8e80941Smrg
4082b8e80941Smrg
4083b8e80941Smrg      uint8_t a =
4084b8e80941Smrg         _mesa_unsigned_to_unsigned(src[3], 4);
4085b8e80941Smrg
4086b8e80941Smrg
4087b8e80941Smrg      uint8_t r =
4088b8e80941Smrg         _mesa_unsigned_to_unsigned(src[0], 4);
4089b8e80941Smrg
4090b8e80941Smrg
4091b8e80941Smrg      uint8_t g =
4092b8e80941Smrg         _mesa_unsigned_to_unsigned(src[1], 4);
4093b8e80941Smrg
4094b8e80941Smrg
4095b8e80941Smrg      uint8_t b =
4096b8e80941Smrg         _mesa_unsigned_to_unsigned(src[2], 4);
4097b8e80941Smrg
4098b8e80941Smrg      uint16_t d = 0;
4099b8e80941Smrg         d |= PACK(a, 0, 4);
4100b8e80941Smrg         d |= PACK(r, 4, 4);
4101b8e80941Smrg         d |= PACK(g, 8, 4);
4102b8e80941Smrg         d |= PACK(b, 12, 4);
4103b8e80941Smrg      (*(uint16_t *)dst) = d;
4104b8e80941Smrg}
4105b8e80941Smrg
4106b8e80941Smrgstatic inline void
4107b8e80941Smrgpack_uint_a1b5g5r5_uint(const GLuint src[4], void *dst)
4108b8e80941Smrg{
4109b8e80941Smrg
4110b8e80941Smrg
4111b8e80941Smrg      uint8_t a =
4112b8e80941Smrg         _mesa_unsigned_to_unsigned(src[3], 1);
4113b8e80941Smrg
4114b8e80941Smrg
4115b8e80941Smrg      uint8_t b =
4116b8e80941Smrg         _mesa_unsigned_to_unsigned(src[2], 5);
4117b8e80941Smrg
4118b8e80941Smrg
4119b8e80941Smrg      uint8_t g =
4120b8e80941Smrg         _mesa_unsigned_to_unsigned(src[1], 5);
4121b8e80941Smrg
4122b8e80941Smrg
4123b8e80941Smrg      uint8_t r =
4124b8e80941Smrg         _mesa_unsigned_to_unsigned(src[0], 5);
4125b8e80941Smrg
4126b8e80941Smrg      uint16_t d = 0;
4127b8e80941Smrg         d |= PACK(a, 0, 1);
4128b8e80941Smrg         d |= PACK(b, 1, 5);
4129b8e80941Smrg         d |= PACK(g, 6, 5);
4130b8e80941Smrg         d |= PACK(r, 11, 5);
4131b8e80941Smrg      (*(uint16_t *)dst) = d;
4132b8e80941Smrg}
4133b8e80941Smrg
4134b8e80941Smrgstatic inline void
4135b8e80941Smrgpack_uint_b5g5r5a1_uint(const GLuint src[4], void *dst)
4136b8e80941Smrg{
4137b8e80941Smrg
4138b8e80941Smrg
4139b8e80941Smrg      uint8_t b =
4140b8e80941Smrg         _mesa_unsigned_to_unsigned(src[2], 5);
4141b8e80941Smrg
4142b8e80941Smrg
4143b8e80941Smrg      uint8_t g =
4144b8e80941Smrg         _mesa_unsigned_to_unsigned(src[1], 5);
4145b8e80941Smrg
4146b8e80941Smrg
4147b8e80941Smrg      uint8_t r =
4148b8e80941Smrg         _mesa_unsigned_to_unsigned(src[0], 5);
4149b8e80941Smrg
4150b8e80941Smrg
4151b8e80941Smrg      uint8_t a =
4152b8e80941Smrg         _mesa_unsigned_to_unsigned(src[3], 1);
4153b8e80941Smrg
4154b8e80941Smrg      uint16_t d = 0;
4155b8e80941Smrg         d |= PACK(b, 0, 5);
4156b8e80941Smrg         d |= PACK(g, 5, 5);
4157b8e80941Smrg         d |= PACK(r, 10, 5);
4158b8e80941Smrg         d |= PACK(a, 15, 1);
4159b8e80941Smrg      (*(uint16_t *)dst) = d;
4160b8e80941Smrg}
4161b8e80941Smrg
4162b8e80941Smrgstatic inline void
4163b8e80941Smrgpack_uint_a1r5g5b5_uint(const GLuint src[4], void *dst)
4164b8e80941Smrg{
4165b8e80941Smrg
4166b8e80941Smrg
4167b8e80941Smrg      uint8_t a =
4168b8e80941Smrg         _mesa_unsigned_to_unsigned(src[3], 1);
4169b8e80941Smrg
4170b8e80941Smrg
4171b8e80941Smrg      uint8_t r =
4172b8e80941Smrg         _mesa_unsigned_to_unsigned(src[0], 5);
4173b8e80941Smrg
4174b8e80941Smrg
4175b8e80941Smrg      uint8_t g =
4176b8e80941Smrg         _mesa_unsigned_to_unsigned(src[1], 5);
4177b8e80941Smrg
4178b8e80941Smrg
4179b8e80941Smrg      uint8_t b =
4180b8e80941Smrg         _mesa_unsigned_to_unsigned(src[2], 5);
4181b8e80941Smrg
4182b8e80941Smrg      uint16_t d = 0;
4183b8e80941Smrg         d |= PACK(a, 0, 1);
4184b8e80941Smrg         d |= PACK(r, 1, 5);
4185b8e80941Smrg         d |= PACK(g, 6, 5);
4186b8e80941Smrg         d |= PACK(b, 11, 5);
4187b8e80941Smrg      (*(uint16_t *)dst) = d;
4188b8e80941Smrg}
4189b8e80941Smrg
4190b8e80941Smrgstatic inline void
4191b8e80941Smrgpack_uint_r5g5b5a1_uint(const GLuint src[4], void *dst)
4192b8e80941Smrg{
4193b8e80941Smrg
4194b8e80941Smrg
4195b8e80941Smrg      uint8_t r =
4196b8e80941Smrg         _mesa_unsigned_to_unsigned(src[0], 5);
4197b8e80941Smrg
4198b8e80941Smrg
4199b8e80941Smrg      uint8_t g =
4200b8e80941Smrg         _mesa_unsigned_to_unsigned(src[1], 5);
4201b8e80941Smrg
4202b8e80941Smrg
4203b8e80941Smrg      uint8_t b =
4204b8e80941Smrg         _mesa_unsigned_to_unsigned(src[2], 5);
4205b8e80941Smrg
4206b8e80941Smrg
4207b8e80941Smrg      uint8_t a =
4208b8e80941Smrg         _mesa_unsigned_to_unsigned(src[3], 1);
4209b8e80941Smrg
4210b8e80941Smrg      uint16_t d = 0;
4211b8e80941Smrg         d |= PACK(r, 0, 5);
4212b8e80941Smrg         d |= PACK(g, 5, 5);
4213b8e80941Smrg         d |= PACK(b, 10, 5);
4214b8e80941Smrg         d |= PACK(a, 15, 1);
4215b8e80941Smrg      (*(uint16_t *)dst) = d;
4216b8e80941Smrg}
4217b8e80941Smrg
4218b8e80941Smrgstatic inline void
4219b8e80941Smrgpack_uint_a_uint8(const GLuint src[4], void *dst)
4220b8e80941Smrg{
4221b8e80941Smrg
4222b8e80941Smrg
4223b8e80941Smrg      uint8_t a =
4224b8e80941Smrg         _mesa_unsigned_to_unsigned(src[3], 8);
4225b8e80941Smrg
4226b8e80941Smrg      uint8_t *d = (uint8_t *)dst;
4227b8e80941Smrg         d[0] = a;
4228b8e80941Smrg}
4229b8e80941Smrg
4230b8e80941Smrgstatic inline void
4231b8e80941Smrgpack_uint_a_uint16(const GLuint src[4], void *dst)
4232b8e80941Smrg{
4233b8e80941Smrg
4234b8e80941Smrg
4235b8e80941Smrg      uint16_t a =
4236b8e80941Smrg         _mesa_unsigned_to_unsigned(src[3], 16);
4237b8e80941Smrg
4238b8e80941Smrg      uint16_t *d = (uint16_t *)dst;
4239b8e80941Smrg         d[0] = a;
4240b8e80941Smrg}
4241b8e80941Smrg
4242b8e80941Smrgstatic inline void
4243b8e80941Smrgpack_uint_a_uint32(const GLuint src[4], void *dst)
4244b8e80941Smrg{
4245b8e80941Smrg
4246b8e80941Smrg
4247b8e80941Smrg      uint32_t a =
4248b8e80941Smrg         _mesa_unsigned_to_unsigned(src[3], 32);
4249b8e80941Smrg
4250b8e80941Smrg      uint32_t *d = (uint32_t *)dst;
4251b8e80941Smrg         d[0] = a;
4252b8e80941Smrg}
4253b8e80941Smrg
4254b8e80941Smrgstatic inline void
4255b8e80941Smrgpack_uint_a_sint8(const GLuint src[4], void *dst)
4256b8e80941Smrg{
4257b8e80941Smrg
4258b8e80941Smrg
4259b8e80941Smrg      int8_t a =
4260b8e80941Smrg         _mesa_signed_to_signed(src[3], 8);
4261b8e80941Smrg
4262b8e80941Smrg      int8_t *d = (int8_t *)dst;
4263b8e80941Smrg         d[0] = a;
4264b8e80941Smrg}
4265b8e80941Smrg
4266b8e80941Smrgstatic inline void
4267b8e80941Smrgpack_uint_a_sint16(const GLuint src[4], void *dst)
4268b8e80941Smrg{
4269b8e80941Smrg
4270b8e80941Smrg
4271b8e80941Smrg      int16_t a =
4272b8e80941Smrg         _mesa_signed_to_signed(src[3], 16);
4273b8e80941Smrg
4274b8e80941Smrg      int16_t *d = (int16_t *)dst;
4275b8e80941Smrg         d[0] = a;
4276b8e80941Smrg}
4277b8e80941Smrg
4278b8e80941Smrgstatic inline void
4279b8e80941Smrgpack_uint_a_sint32(const GLuint src[4], void *dst)
4280b8e80941Smrg{
4281b8e80941Smrg
4282b8e80941Smrg
4283b8e80941Smrg      int32_t a =
4284b8e80941Smrg         _mesa_signed_to_signed(src[3], 32);
4285b8e80941Smrg
4286b8e80941Smrg      int32_t *d = (int32_t *)dst;
4287b8e80941Smrg         d[0] = a;
4288b8e80941Smrg}
4289b8e80941Smrg
4290b8e80941Smrgstatic inline void
4291b8e80941Smrgpack_uint_i_uint8(const GLuint src[4], void *dst)
4292b8e80941Smrg{
4293b8e80941Smrg
4294b8e80941Smrg
4295b8e80941Smrg      uint8_t i =
4296b8e80941Smrg         _mesa_unsigned_to_unsigned(src[0], 8);
4297b8e80941Smrg
4298b8e80941Smrg      uint8_t *d = (uint8_t *)dst;
4299b8e80941Smrg         d[0] = i;
4300b8e80941Smrg}
4301b8e80941Smrg
4302b8e80941Smrgstatic inline void
4303b8e80941Smrgpack_uint_i_uint16(const GLuint src[4], void *dst)
4304b8e80941Smrg{
4305b8e80941Smrg
4306b8e80941Smrg
4307b8e80941Smrg      uint16_t i =
4308b8e80941Smrg         _mesa_unsigned_to_unsigned(src[0], 16);
4309b8e80941Smrg
4310b8e80941Smrg      uint16_t *d = (uint16_t *)dst;
4311b8e80941Smrg         d[0] = i;
4312b8e80941Smrg}
4313b8e80941Smrg
4314b8e80941Smrgstatic inline void
4315b8e80941Smrgpack_uint_i_uint32(const GLuint src[4], void *dst)
4316b8e80941Smrg{
4317b8e80941Smrg
4318b8e80941Smrg
4319b8e80941Smrg      uint32_t i =
4320b8e80941Smrg         _mesa_unsigned_to_unsigned(src[0], 32);
4321b8e80941Smrg
4322b8e80941Smrg      uint32_t *d = (uint32_t *)dst;
4323b8e80941Smrg         d[0] = i;
4324b8e80941Smrg}
4325b8e80941Smrg
4326b8e80941Smrgstatic inline void
4327b8e80941Smrgpack_uint_i_sint8(const GLuint src[4], void *dst)
4328b8e80941Smrg{
4329b8e80941Smrg
4330b8e80941Smrg
4331b8e80941Smrg      int8_t i =
4332b8e80941Smrg         _mesa_signed_to_signed(src[0], 8);
4333b8e80941Smrg
4334b8e80941Smrg      int8_t *d = (int8_t *)dst;
4335b8e80941Smrg         d[0] = i;
4336b8e80941Smrg}
4337b8e80941Smrg
4338b8e80941Smrgstatic inline void
4339b8e80941Smrgpack_uint_i_sint16(const GLuint src[4], void *dst)
4340b8e80941Smrg{
4341b8e80941Smrg
4342b8e80941Smrg
4343b8e80941Smrg      int16_t i =
4344b8e80941Smrg         _mesa_signed_to_signed(src[0], 16);
4345b8e80941Smrg
4346b8e80941Smrg      int16_t *d = (int16_t *)dst;
4347b8e80941Smrg         d[0] = i;
4348b8e80941Smrg}
4349b8e80941Smrg
4350b8e80941Smrgstatic inline void
4351b8e80941Smrgpack_uint_i_sint32(const GLuint src[4], void *dst)
4352b8e80941Smrg{
4353b8e80941Smrg
4354b8e80941Smrg
4355b8e80941Smrg      int32_t i =
4356b8e80941Smrg         _mesa_signed_to_signed(src[0], 32);
4357b8e80941Smrg
4358b8e80941Smrg      int32_t *d = (int32_t *)dst;
4359b8e80941Smrg         d[0] = i;
4360b8e80941Smrg}
4361b8e80941Smrg
4362b8e80941Smrgstatic inline void
4363b8e80941Smrgpack_uint_l_uint8(const GLuint src[4], void *dst)
4364b8e80941Smrg{
4365b8e80941Smrg
4366b8e80941Smrg
4367b8e80941Smrg      uint8_t l =
4368b8e80941Smrg         _mesa_unsigned_to_unsigned(src[0], 8);
4369b8e80941Smrg
4370b8e80941Smrg      uint8_t *d = (uint8_t *)dst;
4371b8e80941Smrg         d[0] = l;
4372b8e80941Smrg}
4373b8e80941Smrg
4374b8e80941Smrgstatic inline void
4375b8e80941Smrgpack_uint_l_uint16(const GLuint src[4], void *dst)
4376b8e80941Smrg{
4377b8e80941Smrg
4378b8e80941Smrg
4379b8e80941Smrg      uint16_t l =
4380b8e80941Smrg         _mesa_unsigned_to_unsigned(src[0], 16);
4381b8e80941Smrg
4382b8e80941Smrg      uint16_t *d = (uint16_t *)dst;
4383b8e80941Smrg         d[0] = l;
4384b8e80941Smrg}
4385b8e80941Smrg
4386b8e80941Smrgstatic inline void
4387b8e80941Smrgpack_uint_l_uint32(const GLuint src[4], void *dst)
4388b8e80941Smrg{
4389b8e80941Smrg
4390b8e80941Smrg
4391b8e80941Smrg      uint32_t l =
4392b8e80941Smrg         _mesa_unsigned_to_unsigned(src[0], 32);
4393b8e80941Smrg
4394b8e80941Smrg      uint32_t *d = (uint32_t *)dst;
4395b8e80941Smrg         d[0] = l;
4396b8e80941Smrg}
4397b8e80941Smrg
4398b8e80941Smrgstatic inline void
4399b8e80941Smrgpack_uint_l_sint8(const GLuint src[4], void *dst)
4400b8e80941Smrg{
4401b8e80941Smrg
4402b8e80941Smrg
4403b8e80941Smrg      int8_t l =
4404b8e80941Smrg         _mesa_signed_to_signed(src[0], 8);
4405b8e80941Smrg
4406b8e80941Smrg      int8_t *d = (int8_t *)dst;
4407b8e80941Smrg         d[0] = l;
4408b8e80941Smrg}
4409b8e80941Smrg
4410b8e80941Smrgstatic inline void
4411b8e80941Smrgpack_uint_l_sint16(const GLuint src[4], void *dst)
4412b8e80941Smrg{
4413b8e80941Smrg
4414b8e80941Smrg
4415b8e80941Smrg      int16_t l =
4416b8e80941Smrg         _mesa_signed_to_signed(src[0], 16);
4417b8e80941Smrg
4418b8e80941Smrg      int16_t *d = (int16_t *)dst;
4419b8e80941Smrg         d[0] = l;
4420b8e80941Smrg}
4421b8e80941Smrg
4422b8e80941Smrgstatic inline void
4423b8e80941Smrgpack_uint_l_sint32(const GLuint src[4], void *dst)
4424b8e80941Smrg{
4425b8e80941Smrg
4426b8e80941Smrg
4427b8e80941Smrg      int32_t l =
4428b8e80941Smrg         _mesa_signed_to_signed(src[0], 32);
4429b8e80941Smrg
4430b8e80941Smrg      int32_t *d = (int32_t *)dst;
4431b8e80941Smrg         d[0] = l;
4432b8e80941Smrg}
4433b8e80941Smrg
4434b8e80941Smrgstatic inline void
4435b8e80941Smrgpack_uint_la_uint8(const GLuint src[4], void *dst)
4436b8e80941Smrg{
4437b8e80941Smrg
4438b8e80941Smrg
4439b8e80941Smrg      uint8_t l =
4440b8e80941Smrg         _mesa_unsigned_to_unsigned(src[0], 8);
4441b8e80941Smrg
4442b8e80941Smrg
4443b8e80941Smrg      uint8_t a =
4444b8e80941Smrg         _mesa_unsigned_to_unsigned(src[3], 8);
4445b8e80941Smrg
4446b8e80941Smrg      uint8_t *d = (uint8_t *)dst;
4447b8e80941Smrg         d[0] = l;
4448b8e80941Smrg         d[1] = a;
4449b8e80941Smrg}
4450b8e80941Smrg
4451b8e80941Smrgstatic inline void
4452b8e80941Smrgpack_uint_la_uint16(const GLuint src[4], void *dst)
4453b8e80941Smrg{
4454b8e80941Smrg
4455b8e80941Smrg
4456b8e80941Smrg      uint16_t l =
4457b8e80941Smrg         _mesa_unsigned_to_unsigned(src[0], 16);
4458b8e80941Smrg
4459b8e80941Smrg
4460b8e80941Smrg      uint16_t a =
4461b8e80941Smrg         _mesa_unsigned_to_unsigned(src[3], 16);
4462b8e80941Smrg
4463b8e80941Smrg      uint16_t *d = (uint16_t *)dst;
4464b8e80941Smrg         d[0] = l;
4465b8e80941Smrg         d[1] = a;
4466b8e80941Smrg}
4467b8e80941Smrg
4468b8e80941Smrgstatic inline void
4469b8e80941Smrgpack_uint_la_uint32(const GLuint src[4], void *dst)
4470b8e80941Smrg{
4471b8e80941Smrg
4472b8e80941Smrg
4473b8e80941Smrg      uint32_t l =
4474b8e80941Smrg         _mesa_unsigned_to_unsigned(src[0], 32);
4475b8e80941Smrg
4476b8e80941Smrg
4477b8e80941Smrg      uint32_t a =
4478b8e80941Smrg         _mesa_unsigned_to_unsigned(src[3], 32);
4479b8e80941Smrg
4480b8e80941Smrg      uint32_t *d = (uint32_t *)dst;
4481b8e80941Smrg         d[0] = l;
4482b8e80941Smrg         d[1] = a;
4483b8e80941Smrg}
4484b8e80941Smrg
4485b8e80941Smrgstatic inline void
4486b8e80941Smrgpack_uint_la_sint8(const GLuint src[4], void *dst)
4487b8e80941Smrg{
4488b8e80941Smrg
4489b8e80941Smrg
4490b8e80941Smrg      int8_t l =
4491b8e80941Smrg         _mesa_signed_to_signed(src[0], 8);
4492b8e80941Smrg
4493b8e80941Smrg
4494b8e80941Smrg      int8_t a =
4495b8e80941Smrg         _mesa_signed_to_signed(src[3], 8);
4496b8e80941Smrg
4497b8e80941Smrg      int8_t *d = (int8_t *)dst;
4498b8e80941Smrg         d[0] = l;
4499b8e80941Smrg         d[1] = a;
4500b8e80941Smrg}
4501b8e80941Smrg
4502b8e80941Smrgstatic inline void
4503b8e80941Smrgpack_uint_la_sint16(const GLuint src[4], void *dst)
4504b8e80941Smrg{
4505b8e80941Smrg
4506b8e80941Smrg
4507b8e80941Smrg      int16_t l =
4508b8e80941Smrg         _mesa_signed_to_signed(src[0], 16);
4509b8e80941Smrg
4510b8e80941Smrg
4511b8e80941Smrg      int16_t a =
4512b8e80941Smrg         _mesa_signed_to_signed(src[3], 16);
4513b8e80941Smrg
4514b8e80941Smrg      int16_t *d = (int16_t *)dst;
4515b8e80941Smrg         d[0] = l;
4516b8e80941Smrg         d[1] = a;
4517b8e80941Smrg}
4518b8e80941Smrg
4519b8e80941Smrgstatic inline void
4520b8e80941Smrgpack_uint_la_sint32(const GLuint src[4], void *dst)
4521b8e80941Smrg{
4522b8e80941Smrg
4523b8e80941Smrg
4524b8e80941Smrg      int32_t l =
4525b8e80941Smrg         _mesa_signed_to_signed(src[0], 32);
4526b8e80941Smrg
4527b8e80941Smrg
4528b8e80941Smrg      int32_t a =
4529b8e80941Smrg         _mesa_signed_to_signed(src[3], 32);
4530b8e80941Smrg
4531b8e80941Smrg      int32_t *d = (int32_t *)dst;
4532b8e80941Smrg         d[0] = l;
4533b8e80941Smrg         d[1] = a;
4534b8e80941Smrg}
4535b8e80941Smrg
4536b8e80941Smrgstatic inline void
4537b8e80941Smrgpack_uint_r_uint8(const GLuint src[4], void *dst)
4538b8e80941Smrg{
4539b8e80941Smrg
4540b8e80941Smrg
4541b8e80941Smrg      uint8_t r =
4542b8e80941Smrg         _mesa_unsigned_to_unsigned(src[0], 8);
4543b8e80941Smrg
4544b8e80941Smrg      uint8_t *d = (uint8_t *)dst;
4545b8e80941Smrg         d[0] = r;
4546b8e80941Smrg}
4547b8e80941Smrg
4548b8e80941Smrgstatic inline void
4549b8e80941Smrgpack_uint_r_uint16(const GLuint src[4], void *dst)
4550b8e80941Smrg{
4551b8e80941Smrg
4552b8e80941Smrg
4553b8e80941Smrg      uint16_t r =
4554b8e80941Smrg         _mesa_unsigned_to_unsigned(src[0], 16);
4555b8e80941Smrg
4556b8e80941Smrg      uint16_t *d = (uint16_t *)dst;
4557b8e80941Smrg         d[0] = r;
4558b8e80941Smrg}
4559b8e80941Smrg
4560b8e80941Smrgstatic inline void
4561b8e80941Smrgpack_uint_r_uint32(const GLuint src[4], void *dst)
4562b8e80941Smrg{
4563b8e80941Smrg
4564b8e80941Smrg
4565b8e80941Smrg      uint32_t r =
4566b8e80941Smrg         _mesa_unsigned_to_unsigned(src[0], 32);
4567b8e80941Smrg
4568b8e80941Smrg      uint32_t *d = (uint32_t *)dst;
4569b8e80941Smrg         d[0] = r;
4570b8e80941Smrg}
4571b8e80941Smrg
4572b8e80941Smrgstatic inline void
4573b8e80941Smrgpack_uint_r_sint8(const GLuint src[4], void *dst)
4574b8e80941Smrg{
4575b8e80941Smrg
4576b8e80941Smrg
4577b8e80941Smrg      int8_t r =
4578b8e80941Smrg         _mesa_signed_to_signed(src[0], 8);
4579b8e80941Smrg
4580b8e80941Smrg      int8_t *d = (int8_t *)dst;
4581b8e80941Smrg         d[0] = r;
4582b8e80941Smrg}
4583b8e80941Smrg
4584b8e80941Smrgstatic inline void
4585b8e80941Smrgpack_uint_r_sint16(const GLuint src[4], void *dst)
4586b8e80941Smrg{
4587b8e80941Smrg
4588b8e80941Smrg
4589b8e80941Smrg      int16_t r =
4590b8e80941Smrg         _mesa_signed_to_signed(src[0], 16);
4591b8e80941Smrg
4592b8e80941Smrg      int16_t *d = (int16_t *)dst;
4593b8e80941Smrg         d[0] = r;
4594b8e80941Smrg}
4595b8e80941Smrg
4596b8e80941Smrgstatic inline void
4597b8e80941Smrgpack_uint_r_sint32(const GLuint src[4], void *dst)
4598b8e80941Smrg{
4599b8e80941Smrg
4600b8e80941Smrg
4601b8e80941Smrg      int32_t r =
4602b8e80941Smrg         _mesa_signed_to_signed(src[0], 32);
4603b8e80941Smrg
4604b8e80941Smrg      int32_t *d = (int32_t *)dst;
4605b8e80941Smrg         d[0] = r;
4606b8e80941Smrg}
4607b8e80941Smrg
4608b8e80941Smrgstatic inline void
4609b8e80941Smrgpack_uint_rg_uint8(const GLuint src[4], void *dst)
4610b8e80941Smrg{
4611b8e80941Smrg
4612b8e80941Smrg
4613b8e80941Smrg      uint8_t r =
4614b8e80941Smrg         _mesa_unsigned_to_unsigned(src[0], 8);
4615b8e80941Smrg
4616b8e80941Smrg
4617b8e80941Smrg      uint8_t g =
4618b8e80941Smrg         _mesa_unsigned_to_unsigned(src[1], 8);
4619b8e80941Smrg
4620b8e80941Smrg      uint8_t *d = (uint8_t *)dst;
4621b8e80941Smrg         d[0] = r;
4622b8e80941Smrg         d[1] = g;
4623b8e80941Smrg}
4624b8e80941Smrg
4625b8e80941Smrgstatic inline void
4626b8e80941Smrgpack_uint_rg_uint16(const GLuint src[4], void *dst)
4627b8e80941Smrg{
4628b8e80941Smrg
4629b8e80941Smrg
4630b8e80941Smrg      uint16_t r =
4631b8e80941Smrg         _mesa_unsigned_to_unsigned(src[0], 16);
4632b8e80941Smrg
4633b8e80941Smrg
4634b8e80941Smrg      uint16_t g =
4635b8e80941Smrg         _mesa_unsigned_to_unsigned(src[1], 16);
4636b8e80941Smrg
4637b8e80941Smrg      uint16_t *d = (uint16_t *)dst;
4638b8e80941Smrg         d[0] = r;
4639b8e80941Smrg         d[1] = g;
4640b8e80941Smrg}
4641b8e80941Smrg
4642b8e80941Smrgstatic inline void
4643b8e80941Smrgpack_uint_rg_uint32(const GLuint src[4], void *dst)
4644b8e80941Smrg{
4645b8e80941Smrg
4646b8e80941Smrg
4647b8e80941Smrg      uint32_t r =
4648b8e80941Smrg         _mesa_unsigned_to_unsigned(src[0], 32);
4649b8e80941Smrg
4650b8e80941Smrg
4651b8e80941Smrg      uint32_t g =
4652b8e80941Smrg         _mesa_unsigned_to_unsigned(src[1], 32);
4653b8e80941Smrg
4654b8e80941Smrg      uint32_t *d = (uint32_t *)dst;
4655b8e80941Smrg         d[0] = r;
4656b8e80941Smrg         d[1] = g;
4657b8e80941Smrg}
4658b8e80941Smrg
4659b8e80941Smrgstatic inline void
4660b8e80941Smrgpack_uint_rg_sint8(const GLuint src[4], void *dst)
4661b8e80941Smrg{
4662b8e80941Smrg
4663b8e80941Smrg
4664b8e80941Smrg      int8_t r =
4665b8e80941Smrg         _mesa_signed_to_signed(src[0], 8);
4666b8e80941Smrg
4667b8e80941Smrg
4668b8e80941Smrg      int8_t g =
4669b8e80941Smrg         _mesa_signed_to_signed(src[1], 8);
4670b8e80941Smrg
4671b8e80941Smrg      int8_t *d = (int8_t *)dst;
4672b8e80941Smrg         d[0] = r;
4673b8e80941Smrg         d[1] = g;
4674b8e80941Smrg}
4675b8e80941Smrg
4676b8e80941Smrgstatic inline void
4677b8e80941Smrgpack_uint_rg_sint16(const GLuint src[4], void *dst)
4678b8e80941Smrg{
4679b8e80941Smrg
4680b8e80941Smrg
4681b8e80941Smrg      int16_t r =
4682b8e80941Smrg         _mesa_signed_to_signed(src[0], 16);
4683b8e80941Smrg
4684b8e80941Smrg
4685b8e80941Smrg      int16_t g =
4686b8e80941Smrg         _mesa_signed_to_signed(src[1], 16);
4687b8e80941Smrg
4688b8e80941Smrg      int16_t *d = (int16_t *)dst;
4689b8e80941Smrg         d[0] = r;
4690b8e80941Smrg         d[1] = g;
4691b8e80941Smrg}
4692b8e80941Smrg
4693b8e80941Smrgstatic inline void
4694b8e80941Smrgpack_uint_rg_sint32(const GLuint src[4], void *dst)
4695b8e80941Smrg{
4696b8e80941Smrg
4697b8e80941Smrg
4698b8e80941Smrg      int32_t r =
4699b8e80941Smrg         _mesa_signed_to_signed(src[0], 32);
4700b8e80941Smrg
4701b8e80941Smrg
4702b8e80941Smrg      int32_t g =
4703b8e80941Smrg         _mesa_signed_to_signed(src[1], 32);
4704b8e80941Smrg
4705b8e80941Smrg      int32_t *d = (int32_t *)dst;
4706b8e80941Smrg         d[0] = r;
4707b8e80941Smrg         d[1] = g;
4708b8e80941Smrg}
4709b8e80941Smrg
4710b8e80941Smrgstatic inline void
4711b8e80941Smrgpack_uint_rgb_uint8(const GLuint src[4], void *dst)
4712b8e80941Smrg{
4713b8e80941Smrg
4714b8e80941Smrg
4715b8e80941Smrg      uint8_t r =
4716b8e80941Smrg         _mesa_unsigned_to_unsigned(src[0], 8);
4717b8e80941Smrg
4718b8e80941Smrg
4719b8e80941Smrg      uint8_t g =
4720b8e80941Smrg         _mesa_unsigned_to_unsigned(src[1], 8);
4721b8e80941Smrg
4722b8e80941Smrg
4723b8e80941Smrg      uint8_t b =
4724b8e80941Smrg         _mesa_unsigned_to_unsigned(src[2], 8);
4725b8e80941Smrg
4726b8e80941Smrg      uint8_t *d = (uint8_t *)dst;
4727b8e80941Smrg         d[0] = r;
4728b8e80941Smrg         d[1] = g;
4729b8e80941Smrg         d[2] = b;
4730b8e80941Smrg}
4731b8e80941Smrg
4732b8e80941Smrgstatic inline void
4733b8e80941Smrgpack_uint_rgb_uint16(const GLuint src[4], void *dst)
4734b8e80941Smrg{
4735b8e80941Smrg
4736b8e80941Smrg
4737b8e80941Smrg      uint16_t r =
4738b8e80941Smrg         _mesa_unsigned_to_unsigned(src[0], 16);
4739b8e80941Smrg
4740b8e80941Smrg
4741b8e80941Smrg      uint16_t g =
4742b8e80941Smrg         _mesa_unsigned_to_unsigned(src[1], 16);
4743b8e80941Smrg
4744b8e80941Smrg
4745b8e80941Smrg      uint16_t b =
4746b8e80941Smrg         _mesa_unsigned_to_unsigned(src[2], 16);
4747b8e80941Smrg
4748b8e80941Smrg      uint16_t *d = (uint16_t *)dst;
4749b8e80941Smrg         d[0] = r;
4750b8e80941Smrg         d[1] = g;
4751b8e80941Smrg         d[2] = b;
4752b8e80941Smrg}
4753b8e80941Smrg
4754b8e80941Smrgstatic inline void
4755b8e80941Smrgpack_uint_rgb_uint32(const GLuint src[4], void *dst)
4756b8e80941Smrg{
4757b8e80941Smrg
4758b8e80941Smrg
4759b8e80941Smrg      uint32_t r =
4760b8e80941Smrg         _mesa_unsigned_to_unsigned(src[0], 32);
4761b8e80941Smrg
4762b8e80941Smrg
4763b8e80941Smrg      uint32_t g =
4764b8e80941Smrg         _mesa_unsigned_to_unsigned(src[1], 32);
4765b8e80941Smrg
4766b8e80941Smrg
4767b8e80941Smrg      uint32_t b =
4768b8e80941Smrg         _mesa_unsigned_to_unsigned(src[2], 32);
4769b8e80941Smrg
4770b8e80941Smrg      uint32_t *d = (uint32_t *)dst;
4771b8e80941Smrg         d[0] = r;
4772b8e80941Smrg         d[1] = g;
4773b8e80941Smrg         d[2] = b;
4774b8e80941Smrg}
4775b8e80941Smrg
4776b8e80941Smrgstatic inline void
4777b8e80941Smrgpack_uint_rgb_sint8(const GLuint src[4], void *dst)
4778b8e80941Smrg{
4779b8e80941Smrg
4780b8e80941Smrg
4781b8e80941Smrg      int8_t r =
4782b8e80941Smrg         _mesa_signed_to_signed(src[0], 8);
4783b8e80941Smrg
4784b8e80941Smrg
4785b8e80941Smrg      int8_t g =
4786b8e80941Smrg         _mesa_signed_to_signed(src[1], 8);
4787b8e80941Smrg
4788b8e80941Smrg
4789b8e80941Smrg      int8_t b =
4790b8e80941Smrg         _mesa_signed_to_signed(src[2], 8);
4791b8e80941Smrg
4792b8e80941Smrg      int8_t *d = (int8_t *)dst;
4793b8e80941Smrg         d[0] = r;
4794b8e80941Smrg         d[1] = g;
4795b8e80941Smrg         d[2] = b;
4796b8e80941Smrg}
4797b8e80941Smrg
4798b8e80941Smrgstatic inline void
4799b8e80941Smrgpack_uint_rgb_sint16(const GLuint src[4], void *dst)
4800b8e80941Smrg{
4801b8e80941Smrg
4802b8e80941Smrg
4803b8e80941Smrg      int16_t r =
4804b8e80941Smrg         _mesa_signed_to_signed(src[0], 16);
4805b8e80941Smrg
4806b8e80941Smrg
4807b8e80941Smrg      int16_t g =
4808b8e80941Smrg         _mesa_signed_to_signed(src[1], 16);
4809b8e80941Smrg
4810b8e80941Smrg
4811b8e80941Smrg      int16_t b =
4812b8e80941Smrg         _mesa_signed_to_signed(src[2], 16);
4813b8e80941Smrg
4814b8e80941Smrg      int16_t *d = (int16_t *)dst;
4815b8e80941Smrg         d[0] = r;
4816b8e80941Smrg         d[1] = g;
4817b8e80941Smrg         d[2] = b;
4818b8e80941Smrg}
4819b8e80941Smrg
4820b8e80941Smrgstatic inline void
4821b8e80941Smrgpack_uint_rgb_sint32(const GLuint src[4], void *dst)
4822b8e80941Smrg{
4823b8e80941Smrg
4824b8e80941Smrg
4825b8e80941Smrg      int32_t r =
4826b8e80941Smrg         _mesa_signed_to_signed(src[0], 32);
4827b8e80941Smrg
4828b8e80941Smrg
4829b8e80941Smrg      int32_t g =
4830b8e80941Smrg         _mesa_signed_to_signed(src[1], 32);
4831b8e80941Smrg
4832b8e80941Smrg
4833b8e80941Smrg      int32_t b =
4834b8e80941Smrg         _mesa_signed_to_signed(src[2], 32);
4835b8e80941Smrg
4836b8e80941Smrg      int32_t *d = (int32_t *)dst;
4837b8e80941Smrg         d[0] = r;
4838b8e80941Smrg         d[1] = g;
4839b8e80941Smrg         d[2] = b;
4840b8e80941Smrg}
4841b8e80941Smrg
4842b8e80941Smrgstatic inline void
4843b8e80941Smrgpack_uint_rgba_uint8(const GLuint src[4], void *dst)
4844b8e80941Smrg{
4845b8e80941Smrg
4846b8e80941Smrg
4847b8e80941Smrg      uint8_t r =
4848b8e80941Smrg         _mesa_unsigned_to_unsigned(src[0], 8);
4849b8e80941Smrg
4850b8e80941Smrg
4851b8e80941Smrg      uint8_t g =
4852b8e80941Smrg         _mesa_unsigned_to_unsigned(src[1], 8);
4853b8e80941Smrg
4854b8e80941Smrg
4855b8e80941Smrg      uint8_t b =
4856b8e80941Smrg         _mesa_unsigned_to_unsigned(src[2], 8);
4857b8e80941Smrg
4858b8e80941Smrg
4859b8e80941Smrg      uint8_t a =
4860b8e80941Smrg         _mesa_unsigned_to_unsigned(src[3], 8);
4861b8e80941Smrg
4862b8e80941Smrg      uint8_t *d = (uint8_t *)dst;
4863b8e80941Smrg         d[0] = r;
4864b8e80941Smrg         d[1] = g;
4865b8e80941Smrg         d[2] = b;
4866b8e80941Smrg         d[3] = a;
4867b8e80941Smrg}
4868b8e80941Smrg
4869b8e80941Smrgstatic inline void
4870b8e80941Smrgpack_uint_rgba_uint16(const GLuint src[4], void *dst)
4871b8e80941Smrg{
4872b8e80941Smrg
4873b8e80941Smrg
4874b8e80941Smrg      uint16_t r =
4875b8e80941Smrg         _mesa_unsigned_to_unsigned(src[0], 16);
4876b8e80941Smrg
4877b8e80941Smrg
4878b8e80941Smrg      uint16_t g =
4879b8e80941Smrg         _mesa_unsigned_to_unsigned(src[1], 16);
4880b8e80941Smrg
4881b8e80941Smrg
4882b8e80941Smrg      uint16_t b =
4883b8e80941Smrg         _mesa_unsigned_to_unsigned(src[2], 16);
4884b8e80941Smrg
4885b8e80941Smrg
4886b8e80941Smrg      uint16_t a =
4887b8e80941Smrg         _mesa_unsigned_to_unsigned(src[3], 16);
4888b8e80941Smrg
4889b8e80941Smrg      uint16_t *d = (uint16_t *)dst;
4890b8e80941Smrg         d[0] = r;
4891b8e80941Smrg         d[1] = g;
4892b8e80941Smrg         d[2] = b;
4893b8e80941Smrg         d[3] = a;
4894b8e80941Smrg}
4895b8e80941Smrg
4896b8e80941Smrgstatic inline void
4897b8e80941Smrgpack_uint_rgba_uint32(const GLuint src[4], void *dst)
4898b8e80941Smrg{
4899b8e80941Smrg
4900b8e80941Smrg
4901b8e80941Smrg      uint32_t r =
4902b8e80941Smrg         _mesa_unsigned_to_unsigned(src[0], 32);
4903b8e80941Smrg
4904b8e80941Smrg
4905b8e80941Smrg      uint32_t g =
4906b8e80941Smrg         _mesa_unsigned_to_unsigned(src[1], 32);
4907b8e80941Smrg
4908b8e80941Smrg
4909b8e80941Smrg      uint32_t b =
4910b8e80941Smrg         _mesa_unsigned_to_unsigned(src[2], 32);
4911b8e80941Smrg
4912b8e80941Smrg
4913b8e80941Smrg      uint32_t a =
4914b8e80941Smrg         _mesa_unsigned_to_unsigned(src[3], 32);
4915b8e80941Smrg
4916b8e80941Smrg      uint32_t *d = (uint32_t *)dst;
4917b8e80941Smrg         d[0] = r;
4918b8e80941Smrg         d[1] = g;
4919b8e80941Smrg         d[2] = b;
4920b8e80941Smrg         d[3] = a;
4921b8e80941Smrg}
4922b8e80941Smrg
4923b8e80941Smrgstatic inline void
4924b8e80941Smrgpack_uint_rgba_sint8(const GLuint src[4], void *dst)
4925b8e80941Smrg{
4926b8e80941Smrg
4927b8e80941Smrg
4928b8e80941Smrg      int8_t r =
4929b8e80941Smrg         _mesa_signed_to_signed(src[0], 8);
4930b8e80941Smrg
4931b8e80941Smrg
4932b8e80941Smrg      int8_t g =
4933b8e80941Smrg         _mesa_signed_to_signed(src[1], 8);
4934b8e80941Smrg
4935b8e80941Smrg
4936b8e80941Smrg      int8_t b =
4937b8e80941Smrg         _mesa_signed_to_signed(src[2], 8);
4938b8e80941Smrg
4939b8e80941Smrg
4940b8e80941Smrg      int8_t a =
4941b8e80941Smrg         _mesa_signed_to_signed(src[3], 8);
4942b8e80941Smrg
4943b8e80941Smrg      int8_t *d = (int8_t *)dst;
4944b8e80941Smrg         d[0] = r;
4945b8e80941Smrg         d[1] = g;
4946b8e80941Smrg         d[2] = b;
4947b8e80941Smrg         d[3] = a;
4948b8e80941Smrg}
4949b8e80941Smrg
4950b8e80941Smrgstatic inline void
4951b8e80941Smrgpack_uint_rgba_sint16(const GLuint src[4], void *dst)
4952b8e80941Smrg{
4953b8e80941Smrg
4954b8e80941Smrg
4955b8e80941Smrg      int16_t r =
4956b8e80941Smrg         _mesa_signed_to_signed(src[0], 16);
4957b8e80941Smrg
4958b8e80941Smrg
4959b8e80941Smrg      int16_t g =
4960b8e80941Smrg         _mesa_signed_to_signed(src[1], 16);
4961b8e80941Smrg
4962b8e80941Smrg
4963b8e80941Smrg      int16_t b =
4964b8e80941Smrg         _mesa_signed_to_signed(src[2], 16);
4965b8e80941Smrg
4966b8e80941Smrg
4967b8e80941Smrg      int16_t a =
4968b8e80941Smrg         _mesa_signed_to_signed(src[3], 16);
4969b8e80941Smrg
4970b8e80941Smrg      int16_t *d = (int16_t *)dst;
4971b8e80941Smrg         d[0] = r;
4972b8e80941Smrg         d[1] = g;
4973b8e80941Smrg         d[2] = b;
4974b8e80941Smrg         d[3] = a;
4975b8e80941Smrg}
4976b8e80941Smrg
4977b8e80941Smrgstatic inline void
4978b8e80941Smrgpack_uint_rgba_sint32(const GLuint src[4], void *dst)
4979b8e80941Smrg{
4980b8e80941Smrg
4981b8e80941Smrg
4982b8e80941Smrg      int32_t r =
4983b8e80941Smrg         _mesa_signed_to_signed(src[0], 32);
4984b8e80941Smrg
4985b8e80941Smrg
4986b8e80941Smrg      int32_t g =
4987b8e80941Smrg         _mesa_signed_to_signed(src[1], 32);
4988b8e80941Smrg
4989b8e80941Smrg
4990b8e80941Smrg      int32_t b =
4991b8e80941Smrg         _mesa_signed_to_signed(src[2], 32);
4992b8e80941Smrg
4993b8e80941Smrg
4994b8e80941Smrg      int32_t a =
4995b8e80941Smrg         _mesa_signed_to_signed(src[3], 32);
4996b8e80941Smrg
4997b8e80941Smrg      int32_t *d = (int32_t *)dst;
4998b8e80941Smrg         d[0] = r;
4999b8e80941Smrg         d[1] = g;
5000b8e80941Smrg         d[2] = b;
5001b8e80941Smrg         d[3] = a;
5002b8e80941Smrg}
5003b8e80941Smrg
5004b8e80941Smrgstatic inline void
5005b8e80941Smrgpack_uint_rgbx_uint8(const GLuint src[4], void *dst)
5006b8e80941Smrg{
5007b8e80941Smrg
5008b8e80941Smrg
5009b8e80941Smrg      uint8_t r =
5010b8e80941Smrg         _mesa_unsigned_to_unsigned(src[0], 8);
5011b8e80941Smrg
5012b8e80941Smrg
5013b8e80941Smrg      uint8_t g =
5014b8e80941Smrg         _mesa_unsigned_to_unsigned(src[1], 8);
5015b8e80941Smrg
5016b8e80941Smrg
5017b8e80941Smrg      uint8_t b =
5018b8e80941Smrg         _mesa_unsigned_to_unsigned(src[2], 8);
5019b8e80941Smrg
5020b8e80941Smrg
5021b8e80941Smrg      uint8_t *d = (uint8_t *)dst;
5022b8e80941Smrg         d[0] = r;
5023b8e80941Smrg         d[1] = g;
5024b8e80941Smrg         d[2] = b;
5025b8e80941Smrg            }
5026b8e80941Smrg
5027b8e80941Smrgstatic inline void
5028b8e80941Smrgpack_uint_rgbx_uint16(const GLuint src[4], void *dst)
5029b8e80941Smrg{
5030b8e80941Smrg
5031b8e80941Smrg
5032b8e80941Smrg      uint16_t r =
5033b8e80941Smrg         _mesa_unsigned_to_unsigned(src[0], 16);
5034b8e80941Smrg
5035b8e80941Smrg
5036b8e80941Smrg      uint16_t g =
5037b8e80941Smrg         _mesa_unsigned_to_unsigned(src[1], 16);
5038b8e80941Smrg
5039b8e80941Smrg
5040b8e80941Smrg      uint16_t b =
5041b8e80941Smrg         _mesa_unsigned_to_unsigned(src[2], 16);
5042b8e80941Smrg
5043b8e80941Smrg
5044b8e80941Smrg      uint16_t *d = (uint16_t *)dst;
5045b8e80941Smrg         d[0] = r;
5046b8e80941Smrg         d[1] = g;
5047b8e80941Smrg         d[2] = b;
5048b8e80941Smrg            }
5049b8e80941Smrg
5050b8e80941Smrgstatic inline void
5051b8e80941Smrgpack_uint_rgbx_uint32(const GLuint src[4], void *dst)
5052b8e80941Smrg{
5053b8e80941Smrg
5054b8e80941Smrg
5055b8e80941Smrg      uint32_t r =
5056b8e80941Smrg         _mesa_unsigned_to_unsigned(src[0], 32);
5057b8e80941Smrg
5058b8e80941Smrg
5059b8e80941Smrg      uint32_t g =
5060b8e80941Smrg         _mesa_unsigned_to_unsigned(src[1], 32);
5061b8e80941Smrg
5062b8e80941Smrg
5063b8e80941Smrg      uint32_t b =
5064b8e80941Smrg         _mesa_unsigned_to_unsigned(src[2], 32);
5065b8e80941Smrg
5066b8e80941Smrg
5067b8e80941Smrg      uint32_t *d = (uint32_t *)dst;
5068b8e80941Smrg         d[0] = r;
5069b8e80941Smrg         d[1] = g;
5070b8e80941Smrg         d[2] = b;
5071b8e80941Smrg            }
5072b8e80941Smrg
5073b8e80941Smrgstatic inline void
5074b8e80941Smrgpack_uint_rgbx_sint8(const GLuint src[4], void *dst)
5075b8e80941Smrg{
5076b8e80941Smrg
5077b8e80941Smrg
5078b8e80941Smrg      int8_t r =
5079b8e80941Smrg         _mesa_signed_to_signed(src[0], 8);
5080b8e80941Smrg
5081b8e80941Smrg
5082b8e80941Smrg      int8_t g =
5083b8e80941Smrg         _mesa_signed_to_signed(src[1], 8);
5084b8e80941Smrg
5085b8e80941Smrg
5086b8e80941Smrg      int8_t b =
5087b8e80941Smrg         _mesa_signed_to_signed(src[2], 8);
5088b8e80941Smrg
5089b8e80941Smrg
5090b8e80941Smrg      int8_t *d = (int8_t *)dst;
5091b8e80941Smrg         d[0] = r;
5092b8e80941Smrg         d[1] = g;
5093b8e80941Smrg         d[2] = b;
5094b8e80941Smrg            }
5095b8e80941Smrg
5096b8e80941Smrgstatic inline void
5097b8e80941Smrgpack_uint_rgbx_sint16(const GLuint src[4], void *dst)
5098b8e80941Smrg{
5099b8e80941Smrg
5100b8e80941Smrg
5101b8e80941Smrg      int16_t r =
5102b8e80941Smrg         _mesa_signed_to_signed(src[0], 16);
5103b8e80941Smrg
5104b8e80941Smrg
5105b8e80941Smrg      int16_t g =
5106b8e80941Smrg         _mesa_signed_to_signed(src[1], 16);
5107b8e80941Smrg
5108b8e80941Smrg
5109b8e80941Smrg      int16_t b =
5110b8e80941Smrg         _mesa_signed_to_signed(src[2], 16);
5111b8e80941Smrg
5112b8e80941Smrg
5113b8e80941Smrg      int16_t *d = (int16_t *)dst;
5114b8e80941Smrg         d[0] = r;
5115b8e80941Smrg         d[1] = g;
5116b8e80941Smrg         d[2] = b;
5117b8e80941Smrg            }
5118b8e80941Smrg
5119b8e80941Smrgstatic inline void
5120b8e80941Smrgpack_uint_rgbx_sint32(const GLuint src[4], void *dst)
5121b8e80941Smrg{
5122b8e80941Smrg
5123b8e80941Smrg
5124b8e80941Smrg      int32_t r =
5125b8e80941Smrg         _mesa_signed_to_signed(src[0], 32);
5126b8e80941Smrg
5127b8e80941Smrg
5128b8e80941Smrg      int32_t g =
5129b8e80941Smrg         _mesa_signed_to_signed(src[1], 32);
5130b8e80941Smrg
5131b8e80941Smrg
5132b8e80941Smrg      int32_t b =
5133b8e80941Smrg         _mesa_signed_to_signed(src[2], 32);
5134b8e80941Smrg
5135b8e80941Smrg
5136b8e80941Smrg      int32_t *d = (int32_t *)dst;
5137b8e80941Smrg         d[0] = r;
5138b8e80941Smrg         d[1] = g;
5139b8e80941Smrg         d[2] = b;
5140b8e80941Smrg            }
5141b8e80941Smrg
5142b8e80941Smrg/* float packing functions */
5143b8e80941Smrg
5144b8e80941Smrg
5145b8e80941Smrgstatic inline void
5146b8e80941Smrgpack_float_a8b8g8r8_unorm(const GLfloat src[4], void *dst)
5147b8e80941Smrg{
5148b8e80941Smrg
5149b8e80941Smrg
5150b8e80941Smrg      uint8_t a =
5151b8e80941Smrg            _mesa_float_to_unorm(src[3], 8);
5152b8e80941Smrg
5153b8e80941Smrg
5154b8e80941Smrg      uint8_t b =
5155b8e80941Smrg            _mesa_float_to_unorm(src[2], 8);
5156b8e80941Smrg
5157b8e80941Smrg
5158b8e80941Smrg      uint8_t g =
5159b8e80941Smrg            _mesa_float_to_unorm(src[1], 8);
5160b8e80941Smrg
5161b8e80941Smrg
5162b8e80941Smrg      uint8_t r =
5163b8e80941Smrg            _mesa_float_to_unorm(src[0], 8);
5164b8e80941Smrg
5165b8e80941Smrg      uint32_t d = 0;
5166b8e80941Smrg         d |= PACK(a, 0, 8);
5167b8e80941Smrg         d |= PACK(b, 8, 8);
5168b8e80941Smrg         d |= PACK(g, 16, 8);
5169b8e80941Smrg         d |= PACK(r, 24, 8);
5170b8e80941Smrg      (*(uint32_t *)dst) = d;
5171b8e80941Smrg}
5172b8e80941Smrg
5173b8e80941Smrgstatic inline void
5174b8e80941Smrgpack_float_x8b8g8r8_unorm(const GLfloat src[4], void *dst)
5175b8e80941Smrg{
5176b8e80941Smrg
5177b8e80941Smrg
5178b8e80941Smrg
5179b8e80941Smrg      uint8_t b =
5180b8e80941Smrg            _mesa_float_to_unorm(src[2], 8);
5181b8e80941Smrg
5182b8e80941Smrg
5183b8e80941Smrg      uint8_t g =
5184b8e80941Smrg            _mesa_float_to_unorm(src[1], 8);
5185b8e80941Smrg
5186b8e80941Smrg
5187b8e80941Smrg      uint8_t r =
5188b8e80941Smrg            _mesa_float_to_unorm(src[0], 8);
5189b8e80941Smrg
5190b8e80941Smrg      uint32_t d = 0;
5191b8e80941Smrg                     d |= PACK(b, 8, 8);
5192b8e80941Smrg         d |= PACK(g, 16, 8);
5193b8e80941Smrg         d |= PACK(r, 24, 8);
5194b8e80941Smrg      (*(uint32_t *)dst) = d;
5195b8e80941Smrg}
5196b8e80941Smrg
5197b8e80941Smrgstatic inline void
5198b8e80941Smrgpack_float_r8g8b8a8_unorm(const GLfloat src[4], void *dst)
5199b8e80941Smrg{
5200b8e80941Smrg
5201b8e80941Smrg
5202b8e80941Smrg      uint8_t r =
5203b8e80941Smrg            _mesa_float_to_unorm(src[0], 8);
5204b8e80941Smrg
5205b8e80941Smrg
5206b8e80941Smrg      uint8_t g =
5207b8e80941Smrg            _mesa_float_to_unorm(src[1], 8);
5208b8e80941Smrg
5209b8e80941Smrg
5210b8e80941Smrg      uint8_t b =
5211b8e80941Smrg            _mesa_float_to_unorm(src[2], 8);
5212b8e80941Smrg
5213b8e80941Smrg
5214b8e80941Smrg      uint8_t a =
5215b8e80941Smrg            _mesa_float_to_unorm(src[3], 8);
5216b8e80941Smrg
5217b8e80941Smrg      uint32_t d = 0;
5218b8e80941Smrg         d |= PACK(r, 0, 8);
5219b8e80941Smrg         d |= PACK(g, 8, 8);
5220b8e80941Smrg         d |= PACK(b, 16, 8);
5221b8e80941Smrg         d |= PACK(a, 24, 8);
5222b8e80941Smrg      (*(uint32_t *)dst) = d;
5223b8e80941Smrg}
5224b8e80941Smrg
5225b8e80941Smrgstatic inline void
5226b8e80941Smrgpack_float_r8g8b8x8_unorm(const GLfloat src[4], void *dst)
5227b8e80941Smrg{
5228b8e80941Smrg
5229b8e80941Smrg
5230b8e80941Smrg      uint8_t r =
5231b8e80941Smrg            _mesa_float_to_unorm(src[0], 8);
5232b8e80941Smrg
5233b8e80941Smrg
5234b8e80941Smrg      uint8_t g =
5235b8e80941Smrg            _mesa_float_to_unorm(src[1], 8);
5236b8e80941Smrg
5237b8e80941Smrg
5238b8e80941Smrg      uint8_t b =
5239b8e80941Smrg            _mesa_float_to_unorm(src[2], 8);
5240b8e80941Smrg
5241b8e80941Smrg
5242b8e80941Smrg      uint32_t d = 0;
5243b8e80941Smrg         d |= PACK(r, 0, 8);
5244b8e80941Smrg         d |= PACK(g, 8, 8);
5245b8e80941Smrg         d |= PACK(b, 16, 8);
5246b8e80941Smrg                  (*(uint32_t *)dst) = d;
5247b8e80941Smrg}
5248b8e80941Smrg
5249b8e80941Smrgstatic inline void
5250b8e80941Smrgpack_float_b8g8r8a8_unorm(const GLfloat src[4], void *dst)
5251b8e80941Smrg{
5252b8e80941Smrg
5253b8e80941Smrg
5254b8e80941Smrg      uint8_t b =
5255b8e80941Smrg            _mesa_float_to_unorm(src[2], 8);
5256b8e80941Smrg
5257b8e80941Smrg
5258b8e80941Smrg      uint8_t g =
5259b8e80941Smrg            _mesa_float_to_unorm(src[1], 8);
5260b8e80941Smrg
5261b8e80941Smrg
5262b8e80941Smrg      uint8_t r =
5263b8e80941Smrg            _mesa_float_to_unorm(src[0], 8);
5264b8e80941Smrg
5265b8e80941Smrg
5266b8e80941Smrg      uint8_t a =
5267b8e80941Smrg            _mesa_float_to_unorm(src[3], 8);
5268b8e80941Smrg
5269b8e80941Smrg      uint32_t d = 0;
5270b8e80941Smrg         d |= PACK(b, 0, 8);
5271b8e80941Smrg         d |= PACK(g, 8, 8);
5272b8e80941Smrg         d |= PACK(r, 16, 8);
5273b8e80941Smrg         d |= PACK(a, 24, 8);
5274b8e80941Smrg      (*(uint32_t *)dst) = d;
5275b8e80941Smrg}
5276b8e80941Smrg
5277b8e80941Smrgstatic inline void
5278b8e80941Smrgpack_float_b8g8r8x8_unorm(const GLfloat src[4], void *dst)
5279b8e80941Smrg{
5280b8e80941Smrg
5281b8e80941Smrg
5282b8e80941Smrg      uint8_t b =
5283b8e80941Smrg            _mesa_float_to_unorm(src[2], 8);
5284b8e80941Smrg
5285b8e80941Smrg
5286b8e80941Smrg      uint8_t g =
5287b8e80941Smrg            _mesa_float_to_unorm(src[1], 8);
5288b8e80941Smrg
5289b8e80941Smrg
5290b8e80941Smrg      uint8_t r =
5291b8e80941Smrg            _mesa_float_to_unorm(src[0], 8);
5292b8e80941Smrg
5293b8e80941Smrg
5294b8e80941Smrg      uint32_t d = 0;
5295b8e80941Smrg         d |= PACK(b, 0, 8);
5296b8e80941Smrg         d |= PACK(g, 8, 8);
5297b8e80941Smrg         d |= PACK(r, 16, 8);
5298b8e80941Smrg                  (*(uint32_t *)dst) = d;
5299b8e80941Smrg}
5300b8e80941Smrg
5301b8e80941Smrgstatic inline void
5302b8e80941Smrgpack_float_a8r8g8b8_unorm(const GLfloat src[4], void *dst)
5303b8e80941Smrg{
5304b8e80941Smrg
5305b8e80941Smrg
5306b8e80941Smrg      uint8_t a =
5307b8e80941Smrg            _mesa_float_to_unorm(src[3], 8);
5308b8e80941Smrg
5309b8e80941Smrg
5310b8e80941Smrg      uint8_t r =
5311b8e80941Smrg            _mesa_float_to_unorm(src[0], 8);
5312b8e80941Smrg
5313b8e80941Smrg
5314b8e80941Smrg      uint8_t g =
5315b8e80941Smrg            _mesa_float_to_unorm(src[1], 8);
5316b8e80941Smrg
5317b8e80941Smrg
5318b8e80941Smrg      uint8_t b =
5319b8e80941Smrg            _mesa_float_to_unorm(src[2], 8);
5320b8e80941Smrg
5321b8e80941Smrg      uint32_t d = 0;
5322b8e80941Smrg         d |= PACK(a, 0, 8);
5323b8e80941Smrg         d |= PACK(r, 8, 8);
5324b8e80941Smrg         d |= PACK(g, 16, 8);
5325b8e80941Smrg         d |= PACK(b, 24, 8);
5326b8e80941Smrg      (*(uint32_t *)dst) = d;
5327b8e80941Smrg}
5328b8e80941Smrg
5329b8e80941Smrgstatic inline void
5330b8e80941Smrgpack_float_x8r8g8b8_unorm(const GLfloat src[4], void *dst)
5331b8e80941Smrg{
5332b8e80941Smrg
5333b8e80941Smrg
5334b8e80941Smrg
5335b8e80941Smrg      uint8_t r =
5336b8e80941Smrg            _mesa_float_to_unorm(src[0], 8);
5337b8e80941Smrg
5338b8e80941Smrg
5339b8e80941Smrg      uint8_t g =
5340b8e80941Smrg            _mesa_float_to_unorm(src[1], 8);
5341b8e80941Smrg
5342b8e80941Smrg
5343b8e80941Smrg      uint8_t b =
5344b8e80941Smrg            _mesa_float_to_unorm(src[2], 8);
5345b8e80941Smrg
5346b8e80941Smrg      uint32_t d = 0;
5347b8e80941Smrg                     d |= PACK(r, 8, 8);
5348b8e80941Smrg         d |= PACK(g, 16, 8);
5349b8e80941Smrg         d |= PACK(b, 24, 8);
5350b8e80941Smrg      (*(uint32_t *)dst) = d;
5351b8e80941Smrg}
5352b8e80941Smrg
5353b8e80941Smrgstatic inline void
5354b8e80941Smrgpack_float_l16a16_unorm(const GLfloat src[4], void *dst)
5355b8e80941Smrg{
5356b8e80941Smrg
5357b8e80941Smrg
5358b8e80941Smrg      uint16_t l =
5359b8e80941Smrg            _mesa_float_to_unorm(src[0], 16);
5360b8e80941Smrg
5361b8e80941Smrg
5362b8e80941Smrg      uint16_t a =
5363b8e80941Smrg            _mesa_float_to_unorm(src[3], 16);
5364b8e80941Smrg
5365b8e80941Smrg      uint32_t d = 0;
5366b8e80941Smrg         d |= PACK(l, 0, 16);
5367b8e80941Smrg         d |= PACK(a, 16, 16);
5368b8e80941Smrg      (*(uint32_t *)dst) = d;
5369b8e80941Smrg}
5370b8e80941Smrg
5371b8e80941Smrgstatic inline void
5372b8e80941Smrgpack_float_a16l16_unorm(const GLfloat src[4], void *dst)
5373b8e80941Smrg{
5374b8e80941Smrg
5375b8e80941Smrg
5376b8e80941Smrg      uint16_t a =
5377b8e80941Smrg            _mesa_float_to_unorm(src[3], 16);
5378b8e80941Smrg
5379b8e80941Smrg
5380b8e80941Smrg      uint16_t l =
5381b8e80941Smrg            _mesa_float_to_unorm(src[0], 16);
5382b8e80941Smrg
5383b8e80941Smrg      uint32_t d = 0;
5384b8e80941Smrg         d |= PACK(a, 0, 16);
5385b8e80941Smrg         d |= PACK(l, 16, 16);
5386b8e80941Smrg      (*(uint32_t *)dst) = d;
5387b8e80941Smrg}
5388b8e80941Smrg
5389b8e80941Smrgstatic inline void
5390b8e80941Smrgpack_float_b5g6r5_unorm(const GLfloat src[4], void *dst)
5391b8e80941Smrg{
5392b8e80941Smrg
5393b8e80941Smrg
5394b8e80941Smrg      uint8_t b =
5395b8e80941Smrg            _mesa_float_to_unorm(src[2], 5);
5396b8e80941Smrg
5397b8e80941Smrg
5398b8e80941Smrg      uint8_t g =
5399b8e80941Smrg            _mesa_float_to_unorm(src[1], 6);
5400b8e80941Smrg
5401b8e80941Smrg
5402b8e80941Smrg      uint8_t r =
5403b8e80941Smrg            _mesa_float_to_unorm(src[0], 5);
5404b8e80941Smrg
5405b8e80941Smrg      uint16_t d = 0;
5406b8e80941Smrg         d |= PACK(b, 0, 5);
5407b8e80941Smrg         d |= PACK(g, 5, 6);
5408b8e80941Smrg         d |= PACK(r, 11, 5);
5409b8e80941Smrg      (*(uint16_t *)dst) = d;
5410b8e80941Smrg}
5411b8e80941Smrg
5412b8e80941Smrgstatic inline void
5413b8e80941Smrgpack_float_r5g6b5_unorm(const GLfloat src[4], void *dst)
5414b8e80941Smrg{
5415b8e80941Smrg
5416b8e80941Smrg
5417b8e80941Smrg      uint8_t r =
5418b8e80941Smrg            _mesa_float_to_unorm(src[0], 5);
5419b8e80941Smrg
5420b8e80941Smrg
5421b8e80941Smrg      uint8_t g =
5422b8e80941Smrg            _mesa_float_to_unorm(src[1], 6);
5423b8e80941Smrg
5424b8e80941Smrg
5425b8e80941Smrg      uint8_t b =
5426b8e80941Smrg            _mesa_float_to_unorm(src[2], 5);
5427b8e80941Smrg
5428b8e80941Smrg      uint16_t d = 0;
5429b8e80941Smrg         d |= PACK(r, 0, 5);
5430b8e80941Smrg         d |= PACK(g, 5, 6);
5431b8e80941Smrg         d |= PACK(b, 11, 5);
5432b8e80941Smrg      (*(uint16_t *)dst) = d;
5433b8e80941Smrg}
5434b8e80941Smrg
5435b8e80941Smrgstatic inline void
5436b8e80941Smrgpack_float_b4g4r4a4_unorm(const GLfloat src[4], void *dst)
5437b8e80941Smrg{
5438b8e80941Smrg
5439b8e80941Smrg
5440b8e80941Smrg      uint8_t b =
5441b8e80941Smrg            _mesa_float_to_unorm(src[2], 4);
5442b8e80941Smrg
5443b8e80941Smrg
5444b8e80941Smrg      uint8_t g =
5445b8e80941Smrg            _mesa_float_to_unorm(src[1], 4);
5446b8e80941Smrg
5447b8e80941Smrg
5448b8e80941Smrg      uint8_t r =
5449b8e80941Smrg            _mesa_float_to_unorm(src[0], 4);
5450b8e80941Smrg
5451b8e80941Smrg
5452b8e80941Smrg      uint8_t a =
5453b8e80941Smrg            _mesa_float_to_unorm(src[3], 4);
5454b8e80941Smrg
5455b8e80941Smrg      uint16_t d = 0;
5456b8e80941Smrg         d |= PACK(b, 0, 4);
5457b8e80941Smrg         d |= PACK(g, 4, 4);
5458b8e80941Smrg         d |= PACK(r, 8, 4);
5459b8e80941Smrg         d |= PACK(a, 12, 4);
5460b8e80941Smrg      (*(uint16_t *)dst) = d;
5461b8e80941Smrg}
5462b8e80941Smrg
5463b8e80941Smrgstatic inline void
5464b8e80941Smrgpack_float_b4g4r4x4_unorm(const GLfloat src[4], void *dst)
5465b8e80941Smrg{
5466b8e80941Smrg
5467b8e80941Smrg
5468b8e80941Smrg      uint8_t b =
5469b8e80941Smrg            _mesa_float_to_unorm(src[2], 4);
5470b8e80941Smrg
5471b8e80941Smrg
5472b8e80941Smrg      uint8_t g =
5473b8e80941Smrg            _mesa_float_to_unorm(src[1], 4);
5474b8e80941Smrg
5475b8e80941Smrg
5476b8e80941Smrg      uint8_t r =
5477b8e80941Smrg            _mesa_float_to_unorm(src[0], 4);
5478b8e80941Smrg
5479b8e80941Smrg
5480b8e80941Smrg      uint16_t d = 0;
5481b8e80941Smrg         d |= PACK(b, 0, 4);
5482b8e80941Smrg         d |= PACK(g, 4, 4);
5483b8e80941Smrg         d |= PACK(r, 8, 4);
5484b8e80941Smrg                  (*(uint16_t *)dst) = d;
5485b8e80941Smrg}
5486b8e80941Smrg
5487b8e80941Smrgstatic inline void
5488b8e80941Smrgpack_float_a4r4g4b4_unorm(const GLfloat src[4], void *dst)
5489b8e80941Smrg{
5490b8e80941Smrg
5491b8e80941Smrg
5492b8e80941Smrg      uint8_t a =
5493b8e80941Smrg            _mesa_float_to_unorm(src[3], 4);
5494b8e80941Smrg
5495b8e80941Smrg
5496b8e80941Smrg      uint8_t r =
5497b8e80941Smrg            _mesa_float_to_unorm(src[0], 4);
5498b8e80941Smrg
5499b8e80941Smrg
5500b8e80941Smrg      uint8_t g =
5501b8e80941Smrg            _mesa_float_to_unorm(src[1], 4);
5502b8e80941Smrg
5503b8e80941Smrg
5504b8e80941Smrg      uint8_t b =
5505b8e80941Smrg            _mesa_float_to_unorm(src[2], 4);
5506b8e80941Smrg
5507b8e80941Smrg      uint16_t d = 0;
5508b8e80941Smrg         d |= PACK(a, 0, 4);
5509b8e80941Smrg         d |= PACK(r, 4, 4);
5510b8e80941Smrg         d |= PACK(g, 8, 4);
5511b8e80941Smrg         d |= PACK(b, 12, 4);
5512b8e80941Smrg      (*(uint16_t *)dst) = d;
5513b8e80941Smrg}
5514b8e80941Smrg
5515b8e80941Smrgstatic inline void
5516b8e80941Smrgpack_float_a1b5g5r5_unorm(const GLfloat src[4], void *dst)
5517b8e80941Smrg{
5518b8e80941Smrg
5519b8e80941Smrg
5520b8e80941Smrg      uint8_t a =
5521b8e80941Smrg            _mesa_float_to_unorm(src[3], 1);
5522b8e80941Smrg
5523b8e80941Smrg
5524b8e80941Smrg      uint8_t b =
5525b8e80941Smrg            _mesa_float_to_unorm(src[2], 5);
5526b8e80941Smrg
5527b8e80941Smrg
5528b8e80941Smrg      uint8_t g =
5529b8e80941Smrg            _mesa_float_to_unorm(src[1], 5);
5530b8e80941Smrg
5531b8e80941Smrg
5532b8e80941Smrg      uint8_t r =
5533b8e80941Smrg            _mesa_float_to_unorm(src[0], 5);
5534b8e80941Smrg
5535b8e80941Smrg      uint16_t d = 0;
5536b8e80941Smrg         d |= PACK(a, 0, 1);
5537b8e80941Smrg         d |= PACK(b, 1, 5);
5538b8e80941Smrg         d |= PACK(g, 6, 5);
5539b8e80941Smrg         d |= PACK(r, 11, 5);
5540b8e80941Smrg      (*(uint16_t *)dst) = d;
5541b8e80941Smrg}
5542b8e80941Smrg
5543b8e80941Smrgstatic inline void
5544b8e80941Smrgpack_float_x1b5g5r5_unorm(const GLfloat src[4], void *dst)
5545b8e80941Smrg{
5546b8e80941Smrg
5547b8e80941Smrg
5548b8e80941Smrg
5549b8e80941Smrg      uint8_t b =
5550b8e80941Smrg            _mesa_float_to_unorm(src[2], 5);
5551b8e80941Smrg
5552b8e80941Smrg
5553b8e80941Smrg      uint8_t g =
5554b8e80941Smrg            _mesa_float_to_unorm(src[1], 5);
5555b8e80941Smrg
5556b8e80941Smrg
5557b8e80941Smrg      uint8_t r =
5558b8e80941Smrg            _mesa_float_to_unorm(src[0], 5);
5559b8e80941Smrg
5560b8e80941Smrg      uint16_t d = 0;
5561b8e80941Smrg                     d |= PACK(b, 1, 5);
5562b8e80941Smrg         d |= PACK(g, 6, 5);
5563b8e80941Smrg         d |= PACK(r, 11, 5);
5564b8e80941Smrg      (*(uint16_t *)dst) = d;
5565b8e80941Smrg}
5566b8e80941Smrg
5567b8e80941Smrgstatic inline void
5568b8e80941Smrgpack_float_b5g5r5a1_unorm(const GLfloat src[4], void *dst)
5569b8e80941Smrg{
5570b8e80941Smrg
5571b8e80941Smrg
5572b8e80941Smrg      uint8_t b =
5573b8e80941Smrg            _mesa_float_to_unorm(src[2], 5);
5574b8e80941Smrg
5575b8e80941Smrg
5576b8e80941Smrg      uint8_t g =
5577b8e80941Smrg            _mesa_float_to_unorm(src[1], 5);
5578b8e80941Smrg
5579b8e80941Smrg
5580b8e80941Smrg      uint8_t r =
5581b8e80941Smrg            _mesa_float_to_unorm(src[0], 5);
5582b8e80941Smrg
5583b8e80941Smrg
5584b8e80941Smrg      uint8_t a =
5585b8e80941Smrg            _mesa_float_to_unorm(src[3], 1);
5586b8e80941Smrg
5587b8e80941Smrg      uint16_t d = 0;
5588b8e80941Smrg         d |= PACK(b, 0, 5);
5589b8e80941Smrg         d |= PACK(g, 5, 5);
5590b8e80941Smrg         d |= PACK(r, 10, 5);
5591b8e80941Smrg         d |= PACK(a, 15, 1);
5592b8e80941Smrg      (*(uint16_t *)dst) = d;
5593b8e80941Smrg}
5594b8e80941Smrg
5595b8e80941Smrgstatic inline void
5596b8e80941Smrgpack_float_b5g5r5x1_unorm(const GLfloat src[4], void *dst)
5597b8e80941Smrg{
5598b8e80941Smrg
5599b8e80941Smrg
5600b8e80941Smrg      uint8_t b =
5601b8e80941Smrg            _mesa_float_to_unorm(src[2], 5);
5602b8e80941Smrg
5603b8e80941Smrg
5604b8e80941Smrg      uint8_t g =
5605b8e80941Smrg            _mesa_float_to_unorm(src[1], 5);
5606b8e80941Smrg
5607b8e80941Smrg
5608b8e80941Smrg      uint8_t r =
5609b8e80941Smrg            _mesa_float_to_unorm(src[0], 5);
5610b8e80941Smrg
5611b8e80941Smrg
5612b8e80941Smrg      uint16_t d = 0;
5613b8e80941Smrg         d |= PACK(b, 0, 5);
5614b8e80941Smrg         d |= PACK(g, 5, 5);
5615b8e80941Smrg         d |= PACK(r, 10, 5);
5616b8e80941Smrg                  (*(uint16_t *)dst) = d;
5617b8e80941Smrg}
5618b8e80941Smrg
5619b8e80941Smrgstatic inline void
5620b8e80941Smrgpack_float_a1r5g5b5_unorm(const GLfloat src[4], void *dst)
5621b8e80941Smrg{
5622b8e80941Smrg
5623b8e80941Smrg
5624b8e80941Smrg      uint8_t a =
5625b8e80941Smrg            _mesa_float_to_unorm(src[3], 1);
5626b8e80941Smrg
5627b8e80941Smrg
5628b8e80941Smrg      uint8_t r =
5629b8e80941Smrg            _mesa_float_to_unorm(src[0], 5);
5630b8e80941Smrg
5631b8e80941Smrg
5632b8e80941Smrg      uint8_t g =
5633b8e80941Smrg            _mesa_float_to_unorm(src[1], 5);
5634b8e80941Smrg
5635b8e80941Smrg
5636b8e80941Smrg      uint8_t b =
5637b8e80941Smrg            _mesa_float_to_unorm(src[2], 5);
5638b8e80941Smrg
5639b8e80941Smrg      uint16_t d = 0;
5640b8e80941Smrg         d |= PACK(a, 0, 1);
5641b8e80941Smrg         d |= PACK(r, 1, 5);
5642b8e80941Smrg         d |= PACK(g, 6, 5);
5643b8e80941Smrg         d |= PACK(b, 11, 5);
5644b8e80941Smrg      (*(uint16_t *)dst) = d;
5645b8e80941Smrg}
5646b8e80941Smrg
5647b8e80941Smrgstatic inline void
5648b8e80941Smrgpack_float_l8a8_unorm(const GLfloat src[4], void *dst)
5649b8e80941Smrg{
5650b8e80941Smrg
5651b8e80941Smrg
5652b8e80941Smrg      uint8_t l =
5653b8e80941Smrg            _mesa_float_to_unorm(src[0], 8);
5654b8e80941Smrg
5655b8e80941Smrg
5656b8e80941Smrg      uint8_t a =
5657b8e80941Smrg            _mesa_float_to_unorm(src[3], 8);
5658b8e80941Smrg
5659b8e80941Smrg      uint16_t d = 0;
5660b8e80941Smrg         d |= PACK(l, 0, 8);
5661b8e80941Smrg         d |= PACK(a, 8, 8);
5662b8e80941Smrg      (*(uint16_t *)dst) = d;
5663b8e80941Smrg}
5664b8e80941Smrg
5665b8e80941Smrgstatic inline void
5666b8e80941Smrgpack_float_a8l8_unorm(const GLfloat src[4], void *dst)
5667b8e80941Smrg{
5668b8e80941Smrg
5669b8e80941Smrg
5670b8e80941Smrg      uint8_t a =
5671b8e80941Smrg            _mesa_float_to_unorm(src[3], 8);
5672b8e80941Smrg
5673b8e80941Smrg
5674b8e80941Smrg      uint8_t l =
5675b8e80941Smrg            _mesa_float_to_unorm(src[0], 8);
5676b8e80941Smrg
5677b8e80941Smrg      uint16_t d = 0;
5678b8e80941Smrg         d |= PACK(a, 0, 8);
5679b8e80941Smrg         d |= PACK(l, 8, 8);
5680b8e80941Smrg      (*(uint16_t *)dst) = d;
5681b8e80941Smrg}
5682b8e80941Smrg
5683b8e80941Smrgstatic inline void
5684b8e80941Smrgpack_float_r8g8_unorm(const GLfloat src[4], void *dst)
5685b8e80941Smrg{
5686b8e80941Smrg
5687b8e80941Smrg
5688b8e80941Smrg      uint8_t r =
5689b8e80941Smrg            _mesa_float_to_unorm(src[0], 8);
5690b8e80941Smrg
5691b8e80941Smrg
5692b8e80941Smrg      uint8_t g =
5693b8e80941Smrg            _mesa_float_to_unorm(src[1], 8);
5694b8e80941Smrg
5695b8e80941Smrg      uint16_t d = 0;
5696b8e80941Smrg         d |= PACK(r, 0, 8);
5697b8e80941Smrg         d |= PACK(g, 8, 8);
5698b8e80941Smrg      (*(uint16_t *)dst) = d;
5699b8e80941Smrg}
5700b8e80941Smrg
5701b8e80941Smrgstatic inline void
5702b8e80941Smrgpack_float_g8r8_unorm(const GLfloat src[4], void *dst)
5703b8e80941Smrg{
5704b8e80941Smrg
5705b8e80941Smrg
5706b8e80941Smrg      uint8_t g =
5707b8e80941Smrg            _mesa_float_to_unorm(src[1], 8);
5708b8e80941Smrg
5709b8e80941Smrg
5710b8e80941Smrg      uint8_t r =
5711b8e80941Smrg            _mesa_float_to_unorm(src[0], 8);
5712b8e80941Smrg
5713b8e80941Smrg      uint16_t d = 0;
5714b8e80941Smrg         d |= PACK(g, 0, 8);
5715b8e80941Smrg         d |= PACK(r, 8, 8);
5716b8e80941Smrg      (*(uint16_t *)dst) = d;
5717b8e80941Smrg}
5718b8e80941Smrg
5719b8e80941Smrgstatic inline void
5720b8e80941Smrgpack_float_l4a4_unorm(const GLfloat src[4], void *dst)
5721b8e80941Smrg{
5722b8e80941Smrg
5723b8e80941Smrg
5724b8e80941Smrg      uint8_t l =
5725b8e80941Smrg            _mesa_float_to_unorm(src[0], 4);
5726b8e80941Smrg
5727b8e80941Smrg
5728b8e80941Smrg      uint8_t a =
5729b8e80941Smrg            _mesa_float_to_unorm(src[3], 4);
5730b8e80941Smrg
5731b8e80941Smrg      uint8_t d = 0;
5732b8e80941Smrg         d |= PACK(l, 0, 4);
5733b8e80941Smrg         d |= PACK(a, 4, 4);
5734b8e80941Smrg      (*(uint8_t *)dst) = d;
5735b8e80941Smrg}
5736b8e80941Smrg
5737b8e80941Smrgstatic inline void
5738b8e80941Smrgpack_float_b2g3r3_unorm(const GLfloat src[4], void *dst)
5739b8e80941Smrg{
5740b8e80941Smrg
5741b8e80941Smrg
5742b8e80941Smrg      uint8_t b =
5743b8e80941Smrg            _mesa_float_to_unorm(src[2], 2);
5744b8e80941Smrg
5745b8e80941Smrg
5746b8e80941Smrg      uint8_t g =
5747b8e80941Smrg            _mesa_float_to_unorm(src[1], 3);
5748b8e80941Smrg
5749b8e80941Smrg
5750b8e80941Smrg      uint8_t r =
5751b8e80941Smrg            _mesa_float_to_unorm(src[0], 3);
5752b8e80941Smrg
5753b8e80941Smrg      uint8_t d = 0;
5754b8e80941Smrg         d |= PACK(b, 0, 2);
5755b8e80941Smrg         d |= PACK(g, 2, 3);
5756b8e80941Smrg         d |= PACK(r, 5, 3);
5757b8e80941Smrg      (*(uint8_t *)dst) = d;
5758b8e80941Smrg}
5759b8e80941Smrg
5760b8e80941Smrgstatic inline void
5761b8e80941Smrgpack_float_r16g16_unorm(const GLfloat src[4], void *dst)
5762b8e80941Smrg{
5763b8e80941Smrg
5764b8e80941Smrg
5765b8e80941Smrg      uint16_t r =
5766b8e80941Smrg            _mesa_float_to_unorm(src[0], 16);
5767b8e80941Smrg
5768b8e80941Smrg
5769b8e80941Smrg      uint16_t g =
5770b8e80941Smrg            _mesa_float_to_unorm(src[1], 16);
5771b8e80941Smrg
5772b8e80941Smrg      uint32_t d = 0;
5773b8e80941Smrg         d |= PACK(r, 0, 16);
5774b8e80941Smrg         d |= PACK(g, 16, 16);
5775b8e80941Smrg      (*(uint32_t *)dst) = d;
5776b8e80941Smrg}
5777b8e80941Smrg
5778b8e80941Smrgstatic inline void
5779b8e80941Smrgpack_float_g16r16_unorm(const GLfloat src[4], void *dst)
5780b8e80941Smrg{
5781b8e80941Smrg
5782b8e80941Smrg
5783b8e80941Smrg      uint16_t g =
5784b8e80941Smrg            _mesa_float_to_unorm(src[1], 16);
5785b8e80941Smrg
5786b8e80941Smrg
5787b8e80941Smrg      uint16_t r =
5788b8e80941Smrg            _mesa_float_to_unorm(src[0], 16);
5789b8e80941Smrg
5790b8e80941Smrg      uint32_t d = 0;
5791b8e80941Smrg         d |= PACK(g, 0, 16);
5792b8e80941Smrg         d |= PACK(r, 16, 16);
5793b8e80941Smrg      (*(uint32_t *)dst) = d;
5794b8e80941Smrg}
5795b8e80941Smrg
5796b8e80941Smrgstatic inline void
5797b8e80941Smrgpack_float_b10g10r10a2_unorm(const GLfloat src[4], void *dst)
5798b8e80941Smrg{
5799b8e80941Smrg
5800b8e80941Smrg
5801b8e80941Smrg      uint16_t b =
5802b8e80941Smrg            _mesa_float_to_unorm(src[2], 10);
5803b8e80941Smrg
5804b8e80941Smrg
5805b8e80941Smrg      uint16_t g =
5806b8e80941Smrg            _mesa_float_to_unorm(src[1], 10);
5807b8e80941Smrg
5808b8e80941Smrg
5809b8e80941Smrg      uint16_t r =
5810b8e80941Smrg            _mesa_float_to_unorm(src[0], 10);
5811b8e80941Smrg
5812b8e80941Smrg
5813b8e80941Smrg      uint8_t a =
5814b8e80941Smrg            _mesa_float_to_unorm(src[3], 2);
5815b8e80941Smrg
5816b8e80941Smrg      uint32_t d = 0;
5817b8e80941Smrg         d |= PACK(b, 0, 10);
5818b8e80941Smrg         d |= PACK(g, 10, 10);
5819b8e80941Smrg         d |= PACK(r, 20, 10);
5820b8e80941Smrg         d |= PACK(a, 30, 2);
5821b8e80941Smrg      (*(uint32_t *)dst) = d;
5822b8e80941Smrg}
5823b8e80941Smrg
5824b8e80941Smrgstatic inline void
5825b8e80941Smrgpack_float_b10g10r10x2_unorm(const GLfloat src[4], void *dst)
5826b8e80941Smrg{
5827b8e80941Smrg
5828b8e80941Smrg
5829b8e80941Smrg      uint16_t b =
5830b8e80941Smrg            _mesa_float_to_unorm(src[2], 10);
5831b8e80941Smrg
5832b8e80941Smrg
5833b8e80941Smrg      uint16_t g =
5834b8e80941Smrg            _mesa_float_to_unorm(src[1], 10);
5835b8e80941Smrg
5836b8e80941Smrg
5837b8e80941Smrg      uint16_t r =
5838b8e80941Smrg            _mesa_float_to_unorm(src[0], 10);
5839b8e80941Smrg
5840b8e80941Smrg
5841b8e80941Smrg      uint32_t d = 0;
5842b8e80941Smrg         d |= PACK(b, 0, 10);
5843b8e80941Smrg         d |= PACK(g, 10, 10);
5844b8e80941Smrg         d |= PACK(r, 20, 10);
5845b8e80941Smrg                  (*(uint32_t *)dst) = d;
5846b8e80941Smrg}
5847b8e80941Smrg
5848b8e80941Smrgstatic inline void
5849b8e80941Smrgpack_float_r10g10b10a2_unorm(const GLfloat src[4], void *dst)
5850b8e80941Smrg{
5851b8e80941Smrg
5852b8e80941Smrg
5853b8e80941Smrg      uint16_t r =
5854b8e80941Smrg            _mesa_float_to_unorm(src[0], 10);
5855b8e80941Smrg
5856b8e80941Smrg
5857b8e80941Smrg      uint16_t g =
5858b8e80941Smrg            _mesa_float_to_unorm(src[1], 10);
5859b8e80941Smrg
5860b8e80941Smrg
5861b8e80941Smrg      uint16_t b =
5862b8e80941Smrg            _mesa_float_to_unorm(src[2], 10);
5863b8e80941Smrg
5864b8e80941Smrg
5865b8e80941Smrg      uint8_t a =
5866b8e80941Smrg            _mesa_float_to_unorm(src[3], 2);
5867b8e80941Smrg
5868b8e80941Smrg      uint32_t d = 0;
5869b8e80941Smrg         d |= PACK(r, 0, 10);
5870b8e80941Smrg         d |= PACK(g, 10, 10);
5871b8e80941Smrg         d |= PACK(b, 20, 10);
5872b8e80941Smrg         d |= PACK(a, 30, 2);
5873b8e80941Smrg      (*(uint32_t *)dst) = d;
5874b8e80941Smrg}
5875b8e80941Smrg
5876b8e80941Smrgstatic inline void
5877b8e80941Smrgpack_float_r10g10b10x2_unorm(const GLfloat src[4], void *dst)
5878b8e80941Smrg{
5879b8e80941Smrg
5880b8e80941Smrg
5881b8e80941Smrg      uint16_t r =
5882b8e80941Smrg            _mesa_float_to_unorm(src[0], 10);
5883b8e80941Smrg
5884b8e80941Smrg
5885b8e80941Smrg      uint16_t g =
5886b8e80941Smrg            _mesa_float_to_unorm(src[1], 10);
5887b8e80941Smrg
5888b8e80941Smrg
5889b8e80941Smrg      uint16_t b =
5890b8e80941Smrg            _mesa_float_to_unorm(src[2], 10);
5891b8e80941Smrg
5892b8e80941Smrg
5893b8e80941Smrg      uint32_t d = 0;
5894b8e80941Smrg         d |= PACK(r, 0, 10);
5895b8e80941Smrg         d |= PACK(g, 10, 10);
5896b8e80941Smrg         d |= PACK(b, 20, 10);
5897b8e80941Smrg                  (*(uint32_t *)dst) = d;
5898b8e80941Smrg}
5899b8e80941Smrg
5900b8e80941Smrgstatic inline void
5901b8e80941Smrgpack_float_r3g3b2_unorm(const GLfloat src[4], void *dst)
5902b8e80941Smrg{
5903b8e80941Smrg
5904b8e80941Smrg
5905b8e80941Smrg      uint8_t r =
5906b8e80941Smrg            _mesa_float_to_unorm(src[0], 3);
5907b8e80941Smrg
5908b8e80941Smrg
5909b8e80941Smrg      uint8_t g =
5910b8e80941Smrg            _mesa_float_to_unorm(src[1], 3);
5911b8e80941Smrg
5912b8e80941Smrg
5913b8e80941Smrg      uint8_t b =
5914b8e80941Smrg            _mesa_float_to_unorm(src[2], 2);
5915b8e80941Smrg
5916b8e80941Smrg      uint8_t d = 0;
5917b8e80941Smrg         d |= PACK(r, 0, 3);
5918b8e80941Smrg         d |= PACK(g, 3, 3);
5919b8e80941Smrg         d |= PACK(b, 6, 2);
5920b8e80941Smrg      (*(uint8_t *)dst) = d;
5921b8e80941Smrg}
5922b8e80941Smrg
5923b8e80941Smrgstatic inline void
5924b8e80941Smrgpack_float_a4b4g4r4_unorm(const GLfloat src[4], void *dst)
5925b8e80941Smrg{
5926b8e80941Smrg
5927b8e80941Smrg
5928b8e80941Smrg      uint8_t a =
5929b8e80941Smrg            _mesa_float_to_unorm(src[3], 4);
5930b8e80941Smrg
5931b8e80941Smrg
5932b8e80941Smrg      uint8_t b =
5933b8e80941Smrg            _mesa_float_to_unorm(src[2], 4);
5934b8e80941Smrg
5935b8e80941Smrg
5936b8e80941Smrg      uint8_t g =
5937b8e80941Smrg            _mesa_float_to_unorm(src[1], 4);
5938b8e80941Smrg
5939b8e80941Smrg
5940b8e80941Smrg      uint8_t r =
5941b8e80941Smrg            _mesa_float_to_unorm(src[0], 4);
5942b8e80941Smrg
5943b8e80941Smrg      uint16_t d = 0;
5944b8e80941Smrg         d |= PACK(a, 0, 4);
5945b8e80941Smrg         d |= PACK(b, 4, 4);
5946b8e80941Smrg         d |= PACK(g, 8, 4);
5947b8e80941Smrg         d |= PACK(r, 12, 4);
5948b8e80941Smrg      (*(uint16_t *)dst) = d;
5949b8e80941Smrg}
5950b8e80941Smrg
5951b8e80941Smrgstatic inline void
5952b8e80941Smrgpack_float_r4g4b4a4_unorm(const GLfloat src[4], void *dst)
5953b8e80941Smrg{
5954b8e80941Smrg
5955b8e80941Smrg
5956b8e80941Smrg      uint8_t r =
5957b8e80941Smrg            _mesa_float_to_unorm(src[0], 4);
5958b8e80941Smrg
5959b8e80941Smrg
5960b8e80941Smrg      uint8_t g =
5961b8e80941Smrg            _mesa_float_to_unorm(src[1], 4);
5962b8e80941Smrg
5963b8e80941Smrg
5964b8e80941Smrg      uint8_t b =
5965b8e80941Smrg            _mesa_float_to_unorm(src[2], 4);
5966b8e80941Smrg
5967b8e80941Smrg
5968b8e80941Smrg      uint8_t a =
5969b8e80941Smrg            _mesa_float_to_unorm(src[3], 4);
5970b8e80941Smrg
5971b8e80941Smrg      uint16_t d = 0;
5972b8e80941Smrg         d |= PACK(r, 0, 4);
5973b8e80941Smrg         d |= PACK(g, 4, 4);
5974b8e80941Smrg         d |= PACK(b, 8, 4);
5975b8e80941Smrg         d |= PACK(a, 12, 4);
5976b8e80941Smrg      (*(uint16_t *)dst) = d;
5977b8e80941Smrg}
5978b8e80941Smrg
5979b8e80941Smrgstatic inline void
5980b8e80941Smrgpack_float_r5g5b5a1_unorm(const GLfloat src[4], void *dst)
5981b8e80941Smrg{
5982b8e80941Smrg
5983b8e80941Smrg
5984b8e80941Smrg      uint8_t r =
5985b8e80941Smrg            _mesa_float_to_unorm(src[0], 5);
5986b8e80941Smrg
5987b8e80941Smrg
5988b8e80941Smrg      uint8_t g =
5989b8e80941Smrg            _mesa_float_to_unorm(src[1], 5);
5990b8e80941Smrg
5991b8e80941Smrg
5992b8e80941Smrg      uint8_t b =
5993b8e80941Smrg            _mesa_float_to_unorm(src[2], 5);
5994b8e80941Smrg
5995b8e80941Smrg
5996b8e80941Smrg      uint8_t a =
5997b8e80941Smrg            _mesa_float_to_unorm(src[3], 1);
5998b8e80941Smrg
5999b8e80941Smrg      uint16_t d = 0;
6000b8e80941Smrg         d |= PACK(r, 0, 5);
6001b8e80941Smrg         d |= PACK(g, 5, 5);
6002b8e80941Smrg         d |= PACK(b, 10, 5);
6003b8e80941Smrg         d |= PACK(a, 15, 1);
6004b8e80941Smrg      (*(uint16_t *)dst) = d;
6005b8e80941Smrg}
6006b8e80941Smrg
6007b8e80941Smrgstatic inline void
6008b8e80941Smrgpack_float_a2b10g10r10_unorm(const GLfloat src[4], void *dst)
6009b8e80941Smrg{
6010b8e80941Smrg
6011b8e80941Smrg
6012b8e80941Smrg      uint8_t a =
6013b8e80941Smrg            _mesa_float_to_unorm(src[3], 2);
6014b8e80941Smrg
6015b8e80941Smrg
6016b8e80941Smrg      uint16_t b =
6017b8e80941Smrg            _mesa_float_to_unorm(src[2], 10);
6018b8e80941Smrg
6019b8e80941Smrg
6020b8e80941Smrg      uint16_t g =
6021b8e80941Smrg            _mesa_float_to_unorm(src[1], 10);
6022b8e80941Smrg
6023b8e80941Smrg
6024b8e80941Smrg      uint16_t r =
6025b8e80941Smrg            _mesa_float_to_unorm(src[0], 10);
6026b8e80941Smrg
6027b8e80941Smrg      uint32_t d = 0;
6028b8e80941Smrg         d |= PACK(a, 0, 2);
6029b8e80941Smrg         d |= PACK(b, 2, 10);
6030b8e80941Smrg         d |= PACK(g, 12, 10);
6031b8e80941Smrg         d |= PACK(r, 22, 10);
6032b8e80941Smrg      (*(uint32_t *)dst) = d;
6033b8e80941Smrg}
6034b8e80941Smrg
6035b8e80941Smrgstatic inline void
6036b8e80941Smrgpack_float_a2r10g10b10_unorm(const GLfloat src[4], void *dst)
6037b8e80941Smrg{
6038b8e80941Smrg
6039b8e80941Smrg
6040b8e80941Smrg      uint8_t a =
6041b8e80941Smrg            _mesa_float_to_unorm(src[3], 2);
6042b8e80941Smrg
6043b8e80941Smrg
6044b8e80941Smrg      uint16_t r =
6045b8e80941Smrg            _mesa_float_to_unorm(src[0], 10);
6046b8e80941Smrg
6047b8e80941Smrg
6048b8e80941Smrg      uint16_t g =
6049b8e80941Smrg            _mesa_float_to_unorm(src[1], 10);
6050b8e80941Smrg
6051b8e80941Smrg
6052b8e80941Smrg      uint16_t b =
6053b8e80941Smrg            _mesa_float_to_unorm(src[2], 10);
6054b8e80941Smrg
6055b8e80941Smrg      uint32_t d = 0;
6056b8e80941Smrg         d |= PACK(a, 0, 2);
6057b8e80941Smrg         d |= PACK(r, 2, 10);
6058b8e80941Smrg         d |= PACK(g, 12, 10);
6059b8e80941Smrg         d |= PACK(b, 22, 10);
6060b8e80941Smrg      (*(uint32_t *)dst) = d;
6061b8e80941Smrg}
6062b8e80941Smrg
6063b8e80941Smrgstatic inline void
6064b8e80941Smrgpack_float_a_unorm8(const GLfloat src[4], void *dst)
6065b8e80941Smrg{
6066b8e80941Smrg
6067b8e80941Smrg
6068b8e80941Smrg      uint8_t a =
6069b8e80941Smrg            _mesa_float_to_unorm(src[3], 8);
6070b8e80941Smrg
6071b8e80941Smrg      uint8_t *d = (uint8_t *)dst;
6072b8e80941Smrg         d[0] = a;
6073b8e80941Smrg}
6074b8e80941Smrg
6075b8e80941Smrgstatic inline void
6076b8e80941Smrgpack_float_a_unorm16(const GLfloat src[4], void *dst)
6077b8e80941Smrg{
6078b8e80941Smrg
6079b8e80941Smrg
6080b8e80941Smrg      uint16_t a =
6081b8e80941Smrg            _mesa_float_to_unorm(src[3], 16);
6082b8e80941Smrg
6083b8e80941Smrg      uint16_t *d = (uint16_t *)dst;
6084b8e80941Smrg         d[0] = a;
6085b8e80941Smrg}
6086b8e80941Smrg
6087b8e80941Smrgstatic inline void
6088b8e80941Smrgpack_float_l_unorm8(const GLfloat src[4], void *dst)
6089b8e80941Smrg{
6090b8e80941Smrg
6091b8e80941Smrg
6092b8e80941Smrg      uint8_t l =
6093b8e80941Smrg            _mesa_float_to_unorm(src[0], 8);
6094b8e80941Smrg
6095b8e80941Smrg      uint8_t *d = (uint8_t *)dst;
6096b8e80941Smrg         d[0] = l;
6097b8e80941Smrg}
6098b8e80941Smrg
6099b8e80941Smrgstatic inline void
6100b8e80941Smrgpack_float_l_unorm16(const GLfloat src[4], void *dst)
6101b8e80941Smrg{
6102b8e80941Smrg
6103b8e80941Smrg
6104b8e80941Smrg      uint16_t l =
6105b8e80941Smrg            _mesa_float_to_unorm(src[0], 16);
6106b8e80941Smrg
6107b8e80941Smrg      uint16_t *d = (uint16_t *)dst;
6108b8e80941Smrg         d[0] = l;
6109b8e80941Smrg}
6110b8e80941Smrg
6111b8e80941Smrgstatic inline void
6112b8e80941Smrgpack_float_i_unorm8(const GLfloat src[4], void *dst)
6113b8e80941Smrg{
6114b8e80941Smrg
6115b8e80941Smrg
6116b8e80941Smrg      uint8_t i =
6117b8e80941Smrg            _mesa_float_to_unorm(src[0], 8);
6118b8e80941Smrg
6119b8e80941Smrg      uint8_t *d = (uint8_t *)dst;
6120b8e80941Smrg         d[0] = i;
6121b8e80941Smrg}
6122b8e80941Smrg
6123b8e80941Smrgstatic inline void
6124b8e80941Smrgpack_float_i_unorm16(const GLfloat src[4], void *dst)
6125b8e80941Smrg{
6126b8e80941Smrg
6127b8e80941Smrg
6128b8e80941Smrg      uint16_t i =
6129b8e80941Smrg            _mesa_float_to_unorm(src[0], 16);
6130b8e80941Smrg
6131b8e80941Smrg      uint16_t *d = (uint16_t *)dst;
6132b8e80941Smrg         d[0] = i;
6133b8e80941Smrg}
6134b8e80941Smrg
6135b8e80941Smrgstatic inline void
6136b8e80941Smrgpack_float_r_unorm8(const GLfloat src[4], void *dst)
6137b8e80941Smrg{
6138b8e80941Smrg
6139b8e80941Smrg
6140b8e80941Smrg      uint8_t r =
6141b8e80941Smrg            _mesa_float_to_unorm(src[0], 8);
6142b8e80941Smrg
6143b8e80941Smrg      uint8_t *d = (uint8_t *)dst;
6144b8e80941Smrg         d[0] = r;
6145b8e80941Smrg}
6146b8e80941Smrg
6147b8e80941Smrgstatic inline void
6148b8e80941Smrgpack_float_r_unorm16(const GLfloat src[4], void *dst)
6149b8e80941Smrg{
6150b8e80941Smrg
6151b8e80941Smrg
6152b8e80941Smrg      uint16_t r =
6153b8e80941Smrg            _mesa_float_to_unorm(src[0], 16);
6154b8e80941Smrg
6155b8e80941Smrg      uint16_t *d = (uint16_t *)dst;
6156b8e80941Smrg         d[0] = r;
6157b8e80941Smrg}
6158b8e80941Smrg
6159b8e80941Smrgstatic inline void
6160b8e80941Smrgpack_float_bgr_unorm8(const GLfloat src[4], void *dst)
6161b8e80941Smrg{
6162b8e80941Smrg
6163b8e80941Smrg
6164b8e80941Smrg      uint8_t b =
6165b8e80941Smrg            _mesa_float_to_unorm(src[2], 8);
6166b8e80941Smrg
6167b8e80941Smrg
6168b8e80941Smrg      uint8_t g =
6169b8e80941Smrg            _mesa_float_to_unorm(src[1], 8);
6170b8e80941Smrg
6171b8e80941Smrg
6172b8e80941Smrg      uint8_t r =
6173b8e80941Smrg            _mesa_float_to_unorm(src[0], 8);
6174b8e80941Smrg
6175b8e80941Smrg      uint8_t *d = (uint8_t *)dst;
6176b8e80941Smrg         d[0] = b;
6177b8e80941Smrg         d[1] = g;
6178b8e80941Smrg         d[2] = r;
6179b8e80941Smrg}
6180b8e80941Smrg
6181b8e80941Smrgstatic inline void
6182b8e80941Smrgpack_float_rgb_unorm8(const GLfloat src[4], void *dst)
6183b8e80941Smrg{
6184b8e80941Smrg
6185b8e80941Smrg
6186b8e80941Smrg      uint8_t r =
6187b8e80941Smrg            _mesa_float_to_unorm(src[0], 8);
6188b8e80941Smrg
6189b8e80941Smrg
6190b8e80941Smrg      uint8_t g =
6191b8e80941Smrg            _mesa_float_to_unorm(src[1], 8);
6192b8e80941Smrg
6193b8e80941Smrg
6194b8e80941Smrg      uint8_t b =
6195b8e80941Smrg            _mesa_float_to_unorm(src[2], 8);
6196b8e80941Smrg
6197b8e80941Smrg      uint8_t *d = (uint8_t *)dst;
6198b8e80941Smrg         d[0] = r;
6199b8e80941Smrg         d[1] = g;
6200b8e80941Smrg         d[2] = b;
6201b8e80941Smrg}
6202b8e80941Smrg
6203b8e80941Smrgstatic inline void
6204b8e80941Smrgpack_float_rgba_unorm16(const GLfloat src[4], void *dst)
6205b8e80941Smrg{
6206b8e80941Smrg
6207b8e80941Smrg
6208b8e80941Smrg      uint16_t r =
6209b8e80941Smrg            _mesa_float_to_unorm(src[0], 16);
6210b8e80941Smrg
6211b8e80941Smrg
6212b8e80941Smrg      uint16_t g =
6213b8e80941Smrg            _mesa_float_to_unorm(src[1], 16);
6214b8e80941Smrg
6215b8e80941Smrg
6216b8e80941Smrg      uint16_t b =
6217b8e80941Smrg            _mesa_float_to_unorm(src[2], 16);
6218b8e80941Smrg
6219b8e80941Smrg
6220b8e80941Smrg      uint16_t a =
6221b8e80941Smrg            _mesa_float_to_unorm(src[3], 16);
6222b8e80941Smrg
6223b8e80941Smrg      uint16_t *d = (uint16_t *)dst;
6224b8e80941Smrg         d[0] = r;
6225b8e80941Smrg         d[1] = g;
6226b8e80941Smrg         d[2] = b;
6227b8e80941Smrg         d[3] = a;
6228b8e80941Smrg}
6229b8e80941Smrg
6230b8e80941Smrgstatic inline void
6231b8e80941Smrgpack_float_rgbx_unorm16(const GLfloat src[4], void *dst)
6232b8e80941Smrg{
6233b8e80941Smrg
6234b8e80941Smrg
6235b8e80941Smrg      uint16_t r =
6236b8e80941Smrg            _mesa_float_to_unorm(src[0], 16);
6237b8e80941Smrg
6238b8e80941Smrg
6239b8e80941Smrg      uint16_t g =
6240b8e80941Smrg            _mesa_float_to_unorm(src[1], 16);
6241b8e80941Smrg
6242b8e80941Smrg
6243b8e80941Smrg      uint16_t b =
6244b8e80941Smrg            _mesa_float_to_unorm(src[2], 16);
6245b8e80941Smrg
6246b8e80941Smrg
6247b8e80941Smrg      uint16_t *d = (uint16_t *)dst;
6248b8e80941Smrg         d[0] = r;
6249b8e80941Smrg         d[1] = g;
6250b8e80941Smrg         d[2] = b;
6251b8e80941Smrg            }
6252b8e80941Smrg
6253b8e80941Smrgstatic inline void
6254b8e80941Smrgpack_float_a8b8g8r8_snorm(const GLfloat src[4], void *dst)
6255b8e80941Smrg{
6256b8e80941Smrg
6257b8e80941Smrg
6258b8e80941Smrg      int8_t a =
6259b8e80941Smrg         _mesa_float_to_snorm(src[3], 8);
6260b8e80941Smrg
6261b8e80941Smrg
6262b8e80941Smrg      int8_t b =
6263b8e80941Smrg         _mesa_float_to_snorm(src[2], 8);
6264b8e80941Smrg
6265b8e80941Smrg
6266b8e80941Smrg      int8_t g =
6267b8e80941Smrg         _mesa_float_to_snorm(src[1], 8);
6268b8e80941Smrg
6269b8e80941Smrg
6270b8e80941Smrg      int8_t r =
6271b8e80941Smrg         _mesa_float_to_snorm(src[0], 8);
6272b8e80941Smrg
6273b8e80941Smrg      uint32_t d = 0;
6274b8e80941Smrg         d |= PACK(a, 0, 8);
6275b8e80941Smrg         d |= PACK(b, 8, 8);
6276b8e80941Smrg         d |= PACK(g, 16, 8);
6277b8e80941Smrg         d |= PACK(r, 24, 8);
6278b8e80941Smrg      (*(uint32_t *)dst) = d;
6279b8e80941Smrg}
6280b8e80941Smrg
6281b8e80941Smrgstatic inline void
6282b8e80941Smrgpack_float_x8b8g8r8_snorm(const GLfloat src[4], void *dst)
6283b8e80941Smrg{
6284b8e80941Smrg
6285b8e80941Smrg
6286b8e80941Smrg
6287b8e80941Smrg      int8_t b =
6288b8e80941Smrg         _mesa_float_to_snorm(src[2], 8);
6289b8e80941Smrg
6290b8e80941Smrg
6291b8e80941Smrg      int8_t g =
6292b8e80941Smrg         _mesa_float_to_snorm(src[1], 8);
6293b8e80941Smrg
6294b8e80941Smrg
6295b8e80941Smrg      int8_t r =
6296b8e80941Smrg         _mesa_float_to_snorm(src[0], 8);
6297b8e80941Smrg
6298b8e80941Smrg      uint32_t d = 0;
6299b8e80941Smrg                     d |= PACK(b, 8, 8);
6300b8e80941Smrg         d |= PACK(g, 16, 8);
6301b8e80941Smrg         d |= PACK(r, 24, 8);
6302b8e80941Smrg      (*(uint32_t *)dst) = d;
6303b8e80941Smrg}
6304b8e80941Smrg
6305b8e80941Smrgstatic inline void
6306b8e80941Smrgpack_float_r8g8b8a8_snorm(const GLfloat src[4], void *dst)
6307b8e80941Smrg{
6308b8e80941Smrg
6309b8e80941Smrg
6310b8e80941Smrg      int8_t r =
6311b8e80941Smrg         _mesa_float_to_snorm(src[0], 8);
6312b8e80941Smrg
6313b8e80941Smrg
6314b8e80941Smrg      int8_t g =
6315b8e80941Smrg         _mesa_float_to_snorm(src[1], 8);
6316b8e80941Smrg
6317b8e80941Smrg
6318b8e80941Smrg      int8_t b =
6319b8e80941Smrg         _mesa_float_to_snorm(src[2], 8);
6320b8e80941Smrg
6321b8e80941Smrg
6322b8e80941Smrg      int8_t a =
6323b8e80941Smrg         _mesa_float_to_snorm(src[3], 8);
6324b8e80941Smrg
6325b8e80941Smrg      uint32_t d = 0;
6326b8e80941Smrg         d |= PACK(r, 0, 8);
6327b8e80941Smrg         d |= PACK(g, 8, 8);
6328b8e80941Smrg         d |= PACK(b, 16, 8);
6329b8e80941Smrg         d |= PACK(a, 24, 8);
6330b8e80941Smrg      (*(uint32_t *)dst) = d;
6331b8e80941Smrg}
6332b8e80941Smrg
6333b8e80941Smrgstatic inline void
6334b8e80941Smrgpack_float_r8g8b8x8_snorm(const GLfloat src[4], void *dst)
6335b8e80941Smrg{
6336b8e80941Smrg
6337b8e80941Smrg
6338b8e80941Smrg      int8_t r =
6339b8e80941Smrg         _mesa_float_to_snorm(src[0], 8);
6340b8e80941Smrg
6341b8e80941Smrg
6342b8e80941Smrg      int8_t g =
6343b8e80941Smrg         _mesa_float_to_snorm(src[1], 8);
6344b8e80941Smrg
6345b8e80941Smrg
6346b8e80941Smrg      int8_t b =
6347b8e80941Smrg         _mesa_float_to_snorm(src[2], 8);
6348b8e80941Smrg
6349b8e80941Smrg
6350b8e80941Smrg      uint32_t d = 0;
6351b8e80941Smrg         d |= PACK(r, 0, 8);
6352b8e80941Smrg         d |= PACK(g, 8, 8);
6353b8e80941Smrg         d |= PACK(b, 16, 8);
6354b8e80941Smrg                  (*(uint32_t *)dst) = d;
6355b8e80941Smrg}
6356b8e80941Smrg
6357b8e80941Smrgstatic inline void
6358b8e80941Smrgpack_float_r16g16_snorm(const GLfloat src[4], void *dst)
6359b8e80941Smrg{
6360b8e80941Smrg
6361b8e80941Smrg
6362b8e80941Smrg      int16_t r =
6363b8e80941Smrg         _mesa_float_to_snorm(src[0], 16);
6364b8e80941Smrg
6365b8e80941Smrg
6366b8e80941Smrg      int16_t g =
6367b8e80941Smrg         _mesa_float_to_snorm(src[1], 16);
6368b8e80941Smrg
6369b8e80941Smrg      uint32_t d = 0;
6370b8e80941Smrg         d |= PACK(r, 0, 16);
6371b8e80941Smrg         d |= PACK(g, 16, 16);
6372b8e80941Smrg      (*(uint32_t *)dst) = d;
6373b8e80941Smrg}
6374b8e80941Smrg
6375b8e80941Smrgstatic inline void
6376b8e80941Smrgpack_float_g16r16_snorm(const GLfloat src[4], void *dst)
6377b8e80941Smrg{
6378b8e80941Smrg
6379b8e80941Smrg
6380b8e80941Smrg      int16_t g =
6381b8e80941Smrg         _mesa_float_to_snorm(src[1], 16);
6382b8e80941Smrg
6383b8e80941Smrg
6384b8e80941Smrg      int16_t r =
6385b8e80941Smrg         _mesa_float_to_snorm(src[0], 16);
6386b8e80941Smrg
6387b8e80941Smrg      uint32_t d = 0;
6388b8e80941Smrg         d |= PACK(g, 0, 16);
6389b8e80941Smrg         d |= PACK(r, 16, 16);
6390b8e80941Smrg      (*(uint32_t *)dst) = d;
6391b8e80941Smrg}
6392b8e80941Smrg
6393b8e80941Smrgstatic inline void
6394b8e80941Smrgpack_float_r8g8_snorm(const GLfloat src[4], void *dst)
6395b8e80941Smrg{
6396b8e80941Smrg
6397b8e80941Smrg
6398b8e80941Smrg      int8_t r =
6399b8e80941Smrg         _mesa_float_to_snorm(src[0], 8);
6400b8e80941Smrg
6401b8e80941Smrg
6402b8e80941Smrg      int8_t g =
6403b8e80941Smrg         _mesa_float_to_snorm(src[1], 8);
6404b8e80941Smrg
6405b8e80941Smrg      uint16_t d = 0;
6406b8e80941Smrg         d |= PACK(r, 0, 8);
6407b8e80941Smrg         d |= PACK(g, 8, 8);
6408b8e80941Smrg      (*(uint16_t *)dst) = d;
6409b8e80941Smrg}
6410b8e80941Smrg
6411b8e80941Smrgstatic inline void
6412b8e80941Smrgpack_float_g8r8_snorm(const GLfloat src[4], void *dst)
6413b8e80941Smrg{
6414b8e80941Smrg
6415b8e80941Smrg
6416b8e80941Smrg      int8_t g =
6417b8e80941Smrg         _mesa_float_to_snorm(src[1], 8);
6418b8e80941Smrg
6419b8e80941Smrg
6420b8e80941Smrg      int8_t r =
6421b8e80941Smrg         _mesa_float_to_snorm(src[0], 8);
6422b8e80941Smrg
6423b8e80941Smrg      uint16_t d = 0;
6424b8e80941Smrg         d |= PACK(g, 0, 8);
6425b8e80941Smrg         d |= PACK(r, 8, 8);
6426b8e80941Smrg      (*(uint16_t *)dst) = d;
6427b8e80941Smrg}
6428b8e80941Smrg
6429b8e80941Smrgstatic inline void
6430b8e80941Smrgpack_float_l8a8_snorm(const GLfloat src[4], void *dst)
6431b8e80941Smrg{
6432b8e80941Smrg
6433b8e80941Smrg
6434b8e80941Smrg      int8_t l =
6435b8e80941Smrg         _mesa_float_to_snorm(src[0], 8);
6436b8e80941Smrg
6437b8e80941Smrg
6438b8e80941Smrg      int8_t a =
6439b8e80941Smrg         _mesa_float_to_snorm(src[3], 8);
6440b8e80941Smrg
6441b8e80941Smrg      uint16_t d = 0;
6442b8e80941Smrg         d |= PACK(l, 0, 8);
6443b8e80941Smrg         d |= PACK(a, 8, 8);
6444b8e80941Smrg      (*(uint16_t *)dst) = d;
6445b8e80941Smrg}
6446b8e80941Smrg
6447b8e80941Smrgstatic inline void
6448b8e80941Smrgpack_float_a8l8_snorm(const GLfloat src[4], void *dst)
6449b8e80941Smrg{
6450b8e80941Smrg
6451b8e80941Smrg
6452b8e80941Smrg      int8_t a =
6453b8e80941Smrg         _mesa_float_to_snorm(src[3], 8);
6454b8e80941Smrg
6455b8e80941Smrg
6456b8e80941Smrg      int8_t l =
6457b8e80941Smrg         _mesa_float_to_snorm(src[0], 8);
6458b8e80941Smrg
6459b8e80941Smrg      uint16_t d = 0;
6460b8e80941Smrg         d |= PACK(a, 0, 8);
6461b8e80941Smrg         d |= PACK(l, 8, 8);
6462b8e80941Smrg      (*(uint16_t *)dst) = d;
6463b8e80941Smrg}
6464b8e80941Smrg
6465b8e80941Smrgstatic inline void
6466b8e80941Smrgpack_float_a_snorm8(const GLfloat src[4], void *dst)
6467b8e80941Smrg{
6468b8e80941Smrg
6469b8e80941Smrg
6470b8e80941Smrg      int8_t a =
6471b8e80941Smrg         _mesa_float_to_snorm(src[3], 8);
6472b8e80941Smrg
6473b8e80941Smrg      int8_t *d = (int8_t *)dst;
6474b8e80941Smrg         d[0] = a;
6475b8e80941Smrg}
6476b8e80941Smrg
6477b8e80941Smrgstatic inline void
6478b8e80941Smrgpack_float_a_snorm16(const GLfloat src[4], void *dst)
6479b8e80941Smrg{
6480b8e80941Smrg
6481b8e80941Smrg
6482b8e80941Smrg      int16_t a =
6483b8e80941Smrg         _mesa_float_to_snorm(src[3], 16);
6484b8e80941Smrg
6485b8e80941Smrg      int16_t *d = (int16_t *)dst;
6486b8e80941Smrg         d[0] = a;
6487b8e80941Smrg}
6488b8e80941Smrg
6489b8e80941Smrgstatic inline void
6490b8e80941Smrgpack_float_l_snorm8(const GLfloat src[4], void *dst)
6491b8e80941Smrg{
6492b8e80941Smrg
6493b8e80941Smrg
6494b8e80941Smrg      int8_t l =
6495b8e80941Smrg         _mesa_float_to_snorm(src[0], 8);
6496b8e80941Smrg
6497b8e80941Smrg      int8_t *d = (int8_t *)dst;
6498b8e80941Smrg         d[0] = l;
6499b8e80941Smrg}
6500b8e80941Smrg
6501b8e80941Smrgstatic inline void
6502b8e80941Smrgpack_float_l_snorm16(const GLfloat src[4], void *dst)
6503b8e80941Smrg{
6504b8e80941Smrg
6505b8e80941Smrg
6506b8e80941Smrg      int16_t l =
6507b8e80941Smrg         _mesa_float_to_snorm(src[0], 16);
6508b8e80941Smrg
6509b8e80941Smrg      int16_t *d = (int16_t *)dst;
6510b8e80941Smrg         d[0] = l;
6511b8e80941Smrg}
6512b8e80941Smrg
6513b8e80941Smrgstatic inline void
6514b8e80941Smrgpack_float_i_snorm8(const GLfloat src[4], void *dst)
6515b8e80941Smrg{
6516b8e80941Smrg
6517b8e80941Smrg
6518b8e80941Smrg      int8_t i =
6519b8e80941Smrg         _mesa_float_to_snorm(src[0], 8);
6520b8e80941Smrg
6521b8e80941Smrg      int8_t *d = (int8_t *)dst;
6522b8e80941Smrg         d[0] = i;
6523b8e80941Smrg}
6524b8e80941Smrg
6525b8e80941Smrgstatic inline void
6526b8e80941Smrgpack_float_i_snorm16(const GLfloat src[4], void *dst)
6527b8e80941Smrg{
6528b8e80941Smrg
6529b8e80941Smrg
6530b8e80941Smrg      int16_t i =
6531b8e80941Smrg         _mesa_float_to_snorm(src[0], 16);
6532b8e80941Smrg
6533b8e80941Smrg      int16_t *d = (int16_t *)dst;
6534b8e80941Smrg         d[0] = i;
6535b8e80941Smrg}
6536b8e80941Smrg
6537b8e80941Smrgstatic inline void
6538b8e80941Smrgpack_float_r_snorm8(const GLfloat src[4], void *dst)
6539b8e80941Smrg{
6540b8e80941Smrg
6541b8e80941Smrg
6542b8e80941Smrg      int8_t r =
6543b8e80941Smrg         _mesa_float_to_snorm(src[0], 8);
6544b8e80941Smrg
6545b8e80941Smrg      int8_t *d = (int8_t *)dst;
6546b8e80941Smrg         d[0] = r;
6547b8e80941Smrg}
6548b8e80941Smrg
6549b8e80941Smrgstatic inline void
6550b8e80941Smrgpack_float_r_snorm16(const GLfloat src[4], void *dst)
6551b8e80941Smrg{
6552b8e80941Smrg
6553b8e80941Smrg
6554b8e80941Smrg      int16_t r =
6555b8e80941Smrg         _mesa_float_to_snorm(src[0], 16);
6556b8e80941Smrg
6557b8e80941Smrg      int16_t *d = (int16_t *)dst;
6558b8e80941Smrg         d[0] = r;
6559b8e80941Smrg}
6560b8e80941Smrg
6561b8e80941Smrgstatic inline void
6562b8e80941Smrgpack_float_la_snorm16(const GLfloat src[4], void *dst)
6563b8e80941Smrg{
6564b8e80941Smrg
6565b8e80941Smrg
6566b8e80941Smrg      int16_t l =
6567b8e80941Smrg         _mesa_float_to_snorm(src[0], 16);
6568b8e80941Smrg
6569b8e80941Smrg
6570b8e80941Smrg      int16_t a =
6571b8e80941Smrg         _mesa_float_to_snorm(src[3], 16);
6572b8e80941Smrg
6573b8e80941Smrg      int16_t *d = (int16_t *)dst;
6574b8e80941Smrg         d[0] = l;
6575b8e80941Smrg         d[1] = a;
6576b8e80941Smrg}
6577b8e80941Smrg
6578b8e80941Smrgstatic inline void
6579b8e80941Smrgpack_float_rgb_snorm16(const GLfloat src[4], void *dst)
6580b8e80941Smrg{
6581b8e80941Smrg
6582b8e80941Smrg
6583b8e80941Smrg      int16_t r =
6584b8e80941Smrg         _mesa_float_to_snorm(src[0], 16);
6585b8e80941Smrg
6586b8e80941Smrg
6587b8e80941Smrg      int16_t g =
6588b8e80941Smrg         _mesa_float_to_snorm(src[1], 16);
6589b8e80941Smrg
6590b8e80941Smrg
6591b8e80941Smrg      int16_t b =
6592b8e80941Smrg         _mesa_float_to_snorm(src[2], 16);
6593b8e80941Smrg
6594b8e80941Smrg      int16_t *d = (int16_t *)dst;
6595b8e80941Smrg         d[0] = r;
6596b8e80941Smrg         d[1] = g;
6597b8e80941Smrg         d[2] = b;
6598b8e80941Smrg}
6599b8e80941Smrg
6600b8e80941Smrgstatic inline void
6601b8e80941Smrgpack_float_rgba_snorm16(const GLfloat src[4], void *dst)
6602b8e80941Smrg{
6603b8e80941Smrg
6604b8e80941Smrg
6605b8e80941Smrg      int16_t r =
6606b8e80941Smrg         _mesa_float_to_snorm(src[0], 16);
6607b8e80941Smrg
6608b8e80941Smrg
6609b8e80941Smrg      int16_t g =
6610b8e80941Smrg         _mesa_float_to_snorm(src[1], 16);
6611b8e80941Smrg
6612b8e80941Smrg
6613b8e80941Smrg      int16_t b =
6614b8e80941Smrg         _mesa_float_to_snorm(src[2], 16);
6615b8e80941Smrg
6616b8e80941Smrg
6617b8e80941Smrg      int16_t a =
6618b8e80941Smrg         _mesa_float_to_snorm(src[3], 16);
6619b8e80941Smrg
6620b8e80941Smrg      int16_t *d = (int16_t *)dst;
6621b8e80941Smrg         d[0] = r;
6622b8e80941Smrg         d[1] = g;
6623b8e80941Smrg         d[2] = b;
6624b8e80941Smrg         d[3] = a;
6625b8e80941Smrg}
6626b8e80941Smrg
6627b8e80941Smrgstatic inline void
6628b8e80941Smrgpack_float_rgbx_snorm16(const GLfloat src[4], void *dst)
6629b8e80941Smrg{
6630b8e80941Smrg
6631b8e80941Smrg
6632b8e80941Smrg      int16_t r =
6633b8e80941Smrg         _mesa_float_to_snorm(src[0], 16);
6634b8e80941Smrg
6635b8e80941Smrg
6636b8e80941Smrg      int16_t g =
6637b8e80941Smrg         _mesa_float_to_snorm(src[1], 16);
6638b8e80941Smrg
6639b8e80941Smrg
6640b8e80941Smrg      int16_t b =
6641b8e80941Smrg         _mesa_float_to_snorm(src[2], 16);
6642b8e80941Smrg
6643b8e80941Smrg
6644b8e80941Smrg      int16_t *d = (int16_t *)dst;
6645b8e80941Smrg         d[0] = r;
6646b8e80941Smrg         d[1] = g;
6647b8e80941Smrg         d[2] = b;
6648b8e80941Smrg            }
6649b8e80941Smrg
6650b8e80941Smrgstatic inline void
6651b8e80941Smrgpack_float_a8b8g8r8_srgb(const GLfloat src[4], void *dst)
6652b8e80941Smrg{
6653b8e80941Smrg
6654b8e80941Smrg
6655b8e80941Smrg      uint8_t a =
6656b8e80941Smrg            _mesa_float_to_unorm(src[3], 8);
6657b8e80941Smrg
6658b8e80941Smrg
6659b8e80941Smrg      uint8_t b =
6660b8e80941Smrg
6661b8e80941Smrg            util_format_linear_float_to_srgb_8unorm(src[2]);
6662b8e80941Smrg
6663b8e80941Smrg
6664b8e80941Smrg      uint8_t g =
6665b8e80941Smrg
6666b8e80941Smrg            util_format_linear_float_to_srgb_8unorm(src[1]);
6667b8e80941Smrg
6668b8e80941Smrg
6669b8e80941Smrg      uint8_t r =
6670b8e80941Smrg
6671b8e80941Smrg            util_format_linear_float_to_srgb_8unorm(src[0]);
6672b8e80941Smrg
6673b8e80941Smrg      uint32_t d = 0;
6674b8e80941Smrg         d |= PACK(a, 0, 8);
6675b8e80941Smrg         d |= PACK(b, 8, 8);
6676b8e80941Smrg         d |= PACK(g, 16, 8);
6677b8e80941Smrg         d |= PACK(r, 24, 8);
6678b8e80941Smrg      (*(uint32_t *)dst) = d;
6679b8e80941Smrg}
6680b8e80941Smrg
6681b8e80941Smrgstatic inline void
6682b8e80941Smrgpack_float_b8g8r8a8_srgb(const GLfloat src[4], void *dst)
6683b8e80941Smrg{
6684b8e80941Smrg
6685b8e80941Smrg
6686b8e80941Smrg      uint8_t b =
6687b8e80941Smrg
6688b8e80941Smrg            util_format_linear_float_to_srgb_8unorm(src[2]);
6689b8e80941Smrg
6690b8e80941Smrg
6691b8e80941Smrg      uint8_t g =
6692b8e80941Smrg
6693b8e80941Smrg            util_format_linear_float_to_srgb_8unorm(src[1]);
6694b8e80941Smrg
6695b8e80941Smrg
6696b8e80941Smrg      uint8_t r =
6697b8e80941Smrg
6698b8e80941Smrg            util_format_linear_float_to_srgb_8unorm(src[0]);
6699b8e80941Smrg
6700b8e80941Smrg
6701b8e80941Smrg      uint8_t a =
6702b8e80941Smrg            _mesa_float_to_unorm(src[3], 8);
6703b8e80941Smrg
6704b8e80941Smrg      uint32_t d = 0;
6705b8e80941Smrg         d |= PACK(b, 0, 8);
6706b8e80941Smrg         d |= PACK(g, 8, 8);
6707b8e80941Smrg         d |= PACK(r, 16, 8);
6708b8e80941Smrg         d |= PACK(a, 24, 8);
6709b8e80941Smrg      (*(uint32_t *)dst) = d;
6710b8e80941Smrg}
6711b8e80941Smrg
6712b8e80941Smrgstatic inline void
6713b8e80941Smrgpack_float_a8r8g8b8_srgb(const GLfloat src[4], void *dst)
6714b8e80941Smrg{
6715b8e80941Smrg
6716b8e80941Smrg
6717b8e80941Smrg      uint8_t a =
6718b8e80941Smrg            _mesa_float_to_unorm(src[3], 8);
6719b8e80941Smrg
6720b8e80941Smrg
6721b8e80941Smrg      uint8_t r =
6722b8e80941Smrg
6723b8e80941Smrg            util_format_linear_float_to_srgb_8unorm(src[0]);
6724b8e80941Smrg
6725b8e80941Smrg
6726b8e80941Smrg      uint8_t g =
6727b8e80941Smrg
6728b8e80941Smrg            util_format_linear_float_to_srgb_8unorm(src[1]);
6729b8e80941Smrg
6730b8e80941Smrg
6731b8e80941Smrg      uint8_t b =
6732b8e80941Smrg
6733b8e80941Smrg            util_format_linear_float_to_srgb_8unorm(src[2]);
6734b8e80941Smrg
6735b8e80941Smrg      uint32_t d = 0;
6736b8e80941Smrg         d |= PACK(a, 0, 8);
6737b8e80941Smrg         d |= PACK(r, 8, 8);
6738b8e80941Smrg         d |= PACK(g, 16, 8);
6739b8e80941Smrg         d |= PACK(b, 24, 8);
6740b8e80941Smrg      (*(uint32_t *)dst) = d;
6741b8e80941Smrg}
6742b8e80941Smrg
6743b8e80941Smrgstatic inline void
6744b8e80941Smrgpack_float_b8g8r8x8_srgb(const GLfloat src[4], void *dst)
6745b8e80941Smrg{
6746b8e80941Smrg
6747b8e80941Smrg
6748b8e80941Smrg      uint8_t b =
6749b8e80941Smrg
6750b8e80941Smrg            util_format_linear_float_to_srgb_8unorm(src[2]);
6751b8e80941Smrg
6752b8e80941Smrg
6753b8e80941Smrg      uint8_t g =
6754b8e80941Smrg
6755b8e80941Smrg            util_format_linear_float_to_srgb_8unorm(src[1]);
6756b8e80941Smrg
6757b8e80941Smrg
6758b8e80941Smrg      uint8_t r =
6759b8e80941Smrg
6760b8e80941Smrg            util_format_linear_float_to_srgb_8unorm(src[0]);
6761b8e80941Smrg
6762b8e80941Smrg
6763b8e80941Smrg      uint32_t d = 0;
6764b8e80941Smrg         d |= PACK(b, 0, 8);
6765b8e80941Smrg         d |= PACK(g, 8, 8);
6766b8e80941Smrg         d |= PACK(r, 16, 8);
6767b8e80941Smrg                  (*(uint32_t *)dst) = d;
6768b8e80941Smrg}
6769b8e80941Smrg
6770b8e80941Smrgstatic inline void
6771b8e80941Smrgpack_float_x8r8g8b8_srgb(const GLfloat src[4], void *dst)
6772b8e80941Smrg{
6773b8e80941Smrg
6774b8e80941Smrg
6775b8e80941Smrg
6776b8e80941Smrg      uint8_t r =
6777b8e80941Smrg
6778b8e80941Smrg            util_format_linear_float_to_srgb_8unorm(src[0]);
6779b8e80941Smrg
6780b8e80941Smrg
6781b8e80941Smrg      uint8_t g =
6782b8e80941Smrg
6783b8e80941Smrg            util_format_linear_float_to_srgb_8unorm(src[1]);
6784b8e80941Smrg
6785b8e80941Smrg
6786b8e80941Smrg      uint8_t b =
6787b8e80941Smrg
6788b8e80941Smrg            util_format_linear_float_to_srgb_8unorm(src[2]);
6789b8e80941Smrg
6790b8e80941Smrg      uint32_t d = 0;
6791b8e80941Smrg                     d |= PACK(r, 8, 8);
6792b8e80941Smrg         d |= PACK(g, 16, 8);
6793b8e80941Smrg         d |= PACK(b, 24, 8);
6794b8e80941Smrg      (*(uint32_t *)dst) = d;
6795b8e80941Smrg}
6796b8e80941Smrg
6797b8e80941Smrgstatic inline void
6798b8e80941Smrgpack_float_r8g8b8a8_srgb(const GLfloat src[4], void *dst)
6799b8e80941Smrg{
6800b8e80941Smrg
6801b8e80941Smrg
6802b8e80941Smrg      uint8_t r =
6803b8e80941Smrg
6804b8e80941Smrg            util_format_linear_float_to_srgb_8unorm(src[0]);
6805b8e80941Smrg
6806b8e80941Smrg
6807b8e80941Smrg      uint8_t g =
6808b8e80941Smrg
6809b8e80941Smrg            util_format_linear_float_to_srgb_8unorm(src[1]);
6810b8e80941Smrg
6811b8e80941Smrg
6812b8e80941Smrg      uint8_t b =
6813b8e80941Smrg
6814b8e80941Smrg            util_format_linear_float_to_srgb_8unorm(src[2]);
6815b8e80941Smrg
6816b8e80941Smrg
6817b8e80941Smrg      uint8_t a =
6818b8e80941Smrg            _mesa_float_to_unorm(src[3], 8);
6819b8e80941Smrg
6820b8e80941Smrg      uint32_t d = 0;
6821b8e80941Smrg         d |= PACK(r, 0, 8);
6822b8e80941Smrg         d |= PACK(g, 8, 8);
6823b8e80941Smrg         d |= PACK(b, 16, 8);
6824b8e80941Smrg         d |= PACK(a, 24, 8);
6825b8e80941Smrg      (*(uint32_t *)dst) = d;
6826b8e80941Smrg}
6827b8e80941Smrg
6828b8e80941Smrgstatic inline void
6829b8e80941Smrgpack_float_r8g8b8x8_srgb(const GLfloat src[4], void *dst)
6830b8e80941Smrg{
6831b8e80941Smrg
6832b8e80941Smrg
6833b8e80941Smrg      uint8_t r =
6834b8e80941Smrg
6835b8e80941Smrg            util_format_linear_float_to_srgb_8unorm(src[0]);
6836b8e80941Smrg
6837b8e80941Smrg
6838b8e80941Smrg      uint8_t g =
6839b8e80941Smrg
6840b8e80941Smrg            util_format_linear_float_to_srgb_8unorm(src[1]);
6841b8e80941Smrg
6842b8e80941Smrg
6843b8e80941Smrg      uint8_t b =
6844b8e80941Smrg
6845b8e80941Smrg            util_format_linear_float_to_srgb_8unorm(src[2]);
6846b8e80941Smrg
6847b8e80941Smrg
6848b8e80941Smrg      uint32_t d = 0;
6849b8e80941Smrg         d |= PACK(r, 0, 8);
6850b8e80941Smrg         d |= PACK(g, 8, 8);
6851b8e80941Smrg         d |= PACK(b, 16, 8);
6852b8e80941Smrg                  (*(uint32_t *)dst) = d;
6853b8e80941Smrg}
6854b8e80941Smrg
6855b8e80941Smrgstatic inline void
6856b8e80941Smrgpack_float_x8b8g8r8_srgb(const GLfloat src[4], void *dst)
6857b8e80941Smrg{
6858b8e80941Smrg
6859b8e80941Smrg
6860b8e80941Smrg
6861b8e80941Smrg      uint8_t b =
6862b8e80941Smrg
6863b8e80941Smrg            util_format_linear_float_to_srgb_8unorm(src[2]);
6864b8e80941Smrg
6865b8e80941Smrg
6866b8e80941Smrg      uint8_t g =
6867b8e80941Smrg
6868b8e80941Smrg            util_format_linear_float_to_srgb_8unorm(src[1]);
6869b8e80941Smrg
6870b8e80941Smrg
6871b8e80941Smrg      uint8_t r =
6872b8e80941Smrg
6873b8e80941Smrg            util_format_linear_float_to_srgb_8unorm(src[0]);
6874b8e80941Smrg
6875b8e80941Smrg      uint32_t d = 0;
6876b8e80941Smrg                     d |= PACK(b, 8, 8);
6877b8e80941Smrg         d |= PACK(g, 16, 8);
6878b8e80941Smrg         d |= PACK(r, 24, 8);
6879b8e80941Smrg      (*(uint32_t *)dst) = d;
6880b8e80941Smrg}
6881b8e80941Smrg
6882b8e80941Smrgstatic inline void
6883b8e80941Smrgpack_float_l8a8_srgb(const GLfloat src[4], void *dst)
6884b8e80941Smrg{
6885b8e80941Smrg
6886b8e80941Smrg
6887b8e80941Smrg      uint8_t l =
6888b8e80941Smrg            _mesa_float_to_unorm(src[0], 8);
6889b8e80941Smrg
6890b8e80941Smrg
6891b8e80941Smrg      uint8_t a =
6892b8e80941Smrg            _mesa_float_to_unorm(src[3], 8);
6893b8e80941Smrg
6894b8e80941Smrg      uint16_t d = 0;
6895b8e80941Smrg         d |= PACK(l, 0, 8);
6896b8e80941Smrg         d |= PACK(a, 8, 8);
6897b8e80941Smrg      (*(uint16_t *)dst) = d;
6898b8e80941Smrg}
6899b8e80941Smrg
6900b8e80941Smrgstatic inline void
6901b8e80941Smrgpack_float_a8l8_srgb(const GLfloat src[4], void *dst)
6902b8e80941Smrg{
6903b8e80941Smrg
6904b8e80941Smrg
6905b8e80941Smrg      uint8_t a =
6906b8e80941Smrg            _mesa_float_to_unorm(src[3], 8);
6907b8e80941Smrg
6908b8e80941Smrg
6909b8e80941Smrg      uint8_t l =
6910b8e80941Smrg            _mesa_float_to_unorm(src[0], 8);
6911b8e80941Smrg
6912b8e80941Smrg      uint16_t d = 0;
6913b8e80941Smrg         d |= PACK(a, 0, 8);
6914b8e80941Smrg         d |= PACK(l, 8, 8);
6915b8e80941Smrg      (*(uint16_t *)dst) = d;
6916b8e80941Smrg}
6917b8e80941Smrg
6918b8e80941Smrgstatic inline void
6919b8e80941Smrgpack_float_r_srgb8(const GLfloat src[4], void *dst)
6920b8e80941Smrg{
6921b8e80941Smrg
6922b8e80941Smrg
6923b8e80941Smrg      uint8_t r =
6924b8e80941Smrg
6925b8e80941Smrg            util_format_linear_float_to_srgb_8unorm(src[0]);
6926b8e80941Smrg
6927b8e80941Smrg      uint8_t *d = (uint8_t *)dst;
6928b8e80941Smrg         d[0] = r;
6929b8e80941Smrg}
6930b8e80941Smrg
6931b8e80941Smrgstatic inline void
6932b8e80941Smrgpack_float_l_srgb8(const GLfloat src[4], void *dst)
6933b8e80941Smrg{
6934b8e80941Smrg
6935b8e80941Smrg
6936b8e80941Smrg      uint8_t l =
6937b8e80941Smrg            _mesa_float_to_unorm(src[0], 8);
6938b8e80941Smrg
6939b8e80941Smrg      uint8_t *d = (uint8_t *)dst;
6940b8e80941Smrg         d[0] = l;
6941b8e80941Smrg}
6942b8e80941Smrg
6943b8e80941Smrgstatic inline void
6944b8e80941Smrgpack_float_bgr_srgb8(const GLfloat src[4], void *dst)
6945b8e80941Smrg{
6946b8e80941Smrg
6947b8e80941Smrg
6948b8e80941Smrg      uint8_t b =
6949b8e80941Smrg
6950b8e80941Smrg            util_format_linear_float_to_srgb_8unorm(src[2]);
6951b8e80941Smrg
6952b8e80941Smrg
6953b8e80941Smrg      uint8_t g =
6954b8e80941Smrg
6955b8e80941Smrg            util_format_linear_float_to_srgb_8unorm(src[1]);
6956b8e80941Smrg
6957b8e80941Smrg
6958b8e80941Smrg      uint8_t r =
6959b8e80941Smrg
6960b8e80941Smrg            util_format_linear_float_to_srgb_8unorm(src[0]);
6961b8e80941Smrg
6962b8e80941Smrg      uint8_t *d = (uint8_t *)dst;
6963b8e80941Smrg         d[0] = b;
6964b8e80941Smrg         d[1] = g;
6965b8e80941Smrg         d[2] = r;
6966b8e80941Smrg}
6967b8e80941Smrg
6968b8e80941Smrgstatic inline void
6969b8e80941Smrgpack_float_a_float16(const GLfloat src[4], void *dst)
6970b8e80941Smrg{
6971b8e80941Smrg
6972b8e80941Smrg
6973b8e80941Smrg      uint16_t a =
6974b8e80941Smrg            _mesa_float_to_half(src[3]);
6975b8e80941Smrg
6976b8e80941Smrg      uint16_t *d = (uint16_t *)dst;
6977b8e80941Smrg         d[0] = a;
6978b8e80941Smrg}
6979b8e80941Smrg
6980b8e80941Smrgstatic inline void
6981b8e80941Smrgpack_float_a_float32(const GLfloat src[4], void *dst)
6982b8e80941Smrg{
6983b8e80941Smrg
6984b8e80941Smrg
6985b8e80941Smrg      float a =
6986b8e80941Smrg            src[3];
6987b8e80941Smrg
6988b8e80941Smrg      float *d = (float *)dst;
6989b8e80941Smrg         d[0] = a;
6990b8e80941Smrg}
6991b8e80941Smrg
6992b8e80941Smrgstatic inline void
6993b8e80941Smrgpack_float_l_float16(const GLfloat src[4], void *dst)
6994b8e80941Smrg{
6995b8e80941Smrg
6996b8e80941Smrg
6997b8e80941Smrg      uint16_t l =
6998b8e80941Smrg            _mesa_float_to_half(src[0]);
6999b8e80941Smrg
7000b8e80941Smrg      uint16_t *d = (uint16_t *)dst;
7001b8e80941Smrg         d[0] = l;
7002b8e80941Smrg}
7003b8e80941Smrg
7004b8e80941Smrgstatic inline void
7005b8e80941Smrgpack_float_l_float32(const GLfloat src[4], void *dst)
7006b8e80941Smrg{
7007b8e80941Smrg
7008b8e80941Smrg
7009b8e80941Smrg      float l =
7010b8e80941Smrg            src[0];
7011b8e80941Smrg
7012b8e80941Smrg      float *d = (float *)dst;
7013b8e80941Smrg         d[0] = l;
7014b8e80941Smrg}
7015b8e80941Smrg
7016b8e80941Smrgstatic inline void
7017b8e80941Smrgpack_float_la_float16(const GLfloat src[4], void *dst)
7018b8e80941Smrg{
7019b8e80941Smrg
7020b8e80941Smrg
7021b8e80941Smrg      uint16_t l =
7022b8e80941Smrg            _mesa_float_to_half(src[0]);
7023b8e80941Smrg
7024b8e80941Smrg
7025b8e80941Smrg      uint16_t a =
7026b8e80941Smrg            _mesa_float_to_half(src[3]);
7027b8e80941Smrg
7028b8e80941Smrg      uint16_t *d = (uint16_t *)dst;
7029b8e80941Smrg         d[0] = l;
7030b8e80941Smrg         d[1] = a;
7031b8e80941Smrg}
7032b8e80941Smrg
7033b8e80941Smrgstatic inline void
7034b8e80941Smrgpack_float_la_float32(const GLfloat src[4], void *dst)
7035b8e80941Smrg{
7036b8e80941Smrg
7037b8e80941Smrg
7038b8e80941Smrg      float l =
7039b8e80941Smrg            src[0];
7040b8e80941Smrg
7041b8e80941Smrg
7042b8e80941Smrg      float a =
7043b8e80941Smrg            src[3];
7044b8e80941Smrg
7045b8e80941Smrg      float *d = (float *)dst;
7046b8e80941Smrg         d[0] = l;
7047b8e80941Smrg         d[1] = a;
7048b8e80941Smrg}
7049b8e80941Smrg
7050b8e80941Smrgstatic inline void
7051b8e80941Smrgpack_float_i_float16(const GLfloat src[4], void *dst)
7052b8e80941Smrg{
7053b8e80941Smrg
7054b8e80941Smrg
7055b8e80941Smrg      uint16_t i =
7056b8e80941Smrg            _mesa_float_to_half(src[0]);
7057b8e80941Smrg
7058b8e80941Smrg      uint16_t *d = (uint16_t *)dst;
7059b8e80941Smrg         d[0] = i;
7060b8e80941Smrg}
7061b8e80941Smrg
7062b8e80941Smrgstatic inline void
7063b8e80941Smrgpack_float_i_float32(const GLfloat src[4], void *dst)
7064b8e80941Smrg{
7065b8e80941Smrg
7066b8e80941Smrg
7067b8e80941Smrg      float i =
7068b8e80941Smrg            src[0];
7069b8e80941Smrg
7070b8e80941Smrg      float *d = (float *)dst;
7071b8e80941Smrg         d[0] = i;
7072b8e80941Smrg}
7073b8e80941Smrg
7074b8e80941Smrgstatic inline void
7075b8e80941Smrgpack_float_r_float16(const GLfloat src[4], void *dst)
7076b8e80941Smrg{
7077b8e80941Smrg
7078b8e80941Smrg
7079b8e80941Smrg      uint16_t r =
7080b8e80941Smrg            _mesa_float_to_half(src[0]);
7081b8e80941Smrg
7082b8e80941Smrg      uint16_t *d = (uint16_t *)dst;
7083b8e80941Smrg         d[0] = r;
7084b8e80941Smrg}
7085b8e80941Smrg
7086b8e80941Smrgstatic inline void
7087b8e80941Smrgpack_float_r_float32(const GLfloat src[4], void *dst)
7088b8e80941Smrg{
7089b8e80941Smrg
7090b8e80941Smrg
7091b8e80941Smrg      float r =
7092b8e80941Smrg            src[0];
7093b8e80941Smrg
7094b8e80941Smrg      float *d = (float *)dst;
7095b8e80941Smrg         d[0] = r;
7096b8e80941Smrg}
7097b8e80941Smrg
7098b8e80941Smrgstatic inline void
7099b8e80941Smrgpack_float_rg_float16(const GLfloat src[4], void *dst)
7100b8e80941Smrg{
7101b8e80941Smrg
7102b8e80941Smrg
7103b8e80941Smrg      uint16_t r =
7104b8e80941Smrg            _mesa_float_to_half(src[0]);
7105b8e80941Smrg
7106b8e80941Smrg
7107b8e80941Smrg      uint16_t g =
7108b8e80941Smrg            _mesa_float_to_half(src[1]);
7109b8e80941Smrg
7110b8e80941Smrg      uint16_t *d = (uint16_t *)dst;
7111b8e80941Smrg         d[0] = r;
7112b8e80941Smrg         d[1] = g;
7113b8e80941Smrg}
7114b8e80941Smrg
7115b8e80941Smrgstatic inline void
7116b8e80941Smrgpack_float_rg_float32(const GLfloat src[4], void *dst)
7117b8e80941Smrg{
7118b8e80941Smrg
7119b8e80941Smrg
7120b8e80941Smrg      float r =
7121b8e80941Smrg            src[0];
7122b8e80941Smrg
7123b8e80941Smrg
7124b8e80941Smrg      float g =
7125b8e80941Smrg            src[1];
7126b8e80941Smrg
7127b8e80941Smrg      float *d = (float *)dst;
7128b8e80941Smrg         d[0] = r;
7129b8e80941Smrg         d[1] = g;
7130b8e80941Smrg}
7131b8e80941Smrg
7132b8e80941Smrgstatic inline void
7133b8e80941Smrgpack_float_rgb_float16(const GLfloat src[4], void *dst)
7134b8e80941Smrg{
7135b8e80941Smrg
7136b8e80941Smrg
7137b8e80941Smrg      uint16_t r =
7138b8e80941Smrg            _mesa_float_to_half(src[0]);
7139b8e80941Smrg
7140b8e80941Smrg
7141b8e80941Smrg      uint16_t g =
7142b8e80941Smrg            _mesa_float_to_half(src[1]);
7143b8e80941Smrg
7144b8e80941Smrg
7145b8e80941Smrg      uint16_t b =
7146b8e80941Smrg            _mesa_float_to_half(src[2]);
7147b8e80941Smrg
7148b8e80941Smrg      uint16_t *d = (uint16_t *)dst;
7149b8e80941Smrg         d[0] = r;
7150b8e80941Smrg         d[1] = g;
7151b8e80941Smrg         d[2] = b;
7152b8e80941Smrg}
7153b8e80941Smrg
7154b8e80941Smrgstatic inline void
7155b8e80941Smrgpack_float_rgb_float32(const GLfloat src[4], void *dst)
7156b8e80941Smrg{
7157b8e80941Smrg
7158b8e80941Smrg
7159b8e80941Smrg      float r =
7160b8e80941Smrg            src[0];
7161b8e80941Smrg
7162b8e80941Smrg
7163b8e80941Smrg      float g =
7164b8e80941Smrg            src[1];
7165b8e80941Smrg
7166b8e80941Smrg
7167b8e80941Smrg      float b =
7168b8e80941Smrg            src[2];
7169b8e80941Smrg
7170b8e80941Smrg      float *d = (float *)dst;
7171b8e80941Smrg         d[0] = r;
7172b8e80941Smrg         d[1] = g;
7173b8e80941Smrg         d[2] = b;
7174b8e80941Smrg}
7175b8e80941Smrg
7176b8e80941Smrgstatic inline void
7177b8e80941Smrgpack_float_rgba_float16(const GLfloat src[4], void *dst)
7178b8e80941Smrg{
7179b8e80941Smrg
7180b8e80941Smrg
7181b8e80941Smrg      uint16_t r =
7182b8e80941Smrg            _mesa_float_to_half(src[0]);
7183b8e80941Smrg
7184b8e80941Smrg
7185b8e80941Smrg      uint16_t g =
7186b8e80941Smrg            _mesa_float_to_half(src[1]);
7187b8e80941Smrg
7188b8e80941Smrg
7189b8e80941Smrg      uint16_t b =
7190b8e80941Smrg            _mesa_float_to_half(src[2]);
7191b8e80941Smrg
7192b8e80941Smrg
7193b8e80941Smrg      uint16_t a =
7194b8e80941Smrg            _mesa_float_to_half(src[3]);
7195b8e80941Smrg
7196b8e80941Smrg      uint16_t *d = (uint16_t *)dst;
7197b8e80941Smrg         d[0] = r;
7198b8e80941Smrg         d[1] = g;
7199b8e80941Smrg         d[2] = b;
7200b8e80941Smrg         d[3] = a;
7201b8e80941Smrg}
7202b8e80941Smrg
7203b8e80941Smrgstatic inline void
7204b8e80941Smrgpack_float_rgba_float32(const GLfloat src[4], void *dst)
7205b8e80941Smrg{
7206b8e80941Smrg
7207b8e80941Smrg
7208b8e80941Smrg      float r =
7209b8e80941Smrg            src[0];
7210b8e80941Smrg
7211b8e80941Smrg
7212b8e80941Smrg      float g =
7213b8e80941Smrg            src[1];
7214b8e80941Smrg
7215b8e80941Smrg
7216b8e80941Smrg      float b =
7217b8e80941Smrg            src[2];
7218b8e80941Smrg
7219b8e80941Smrg
7220b8e80941Smrg      float a =
7221b8e80941Smrg            src[3];
7222b8e80941Smrg
7223b8e80941Smrg      float *d = (float *)dst;
7224b8e80941Smrg         d[0] = r;
7225b8e80941Smrg         d[1] = g;
7226b8e80941Smrg         d[2] = b;
7227b8e80941Smrg         d[3] = a;
7228b8e80941Smrg}
7229b8e80941Smrg
7230b8e80941Smrgstatic inline void
7231b8e80941Smrgpack_float_rgbx_float16(const GLfloat src[4], void *dst)
7232b8e80941Smrg{
7233b8e80941Smrg
7234b8e80941Smrg
7235b8e80941Smrg      uint16_t r =
7236b8e80941Smrg            _mesa_float_to_half(src[0]);
7237b8e80941Smrg
7238b8e80941Smrg
7239b8e80941Smrg      uint16_t g =
7240b8e80941Smrg            _mesa_float_to_half(src[1]);
7241b8e80941Smrg
7242b8e80941Smrg
7243b8e80941Smrg      uint16_t b =
7244b8e80941Smrg            _mesa_float_to_half(src[2]);
7245b8e80941Smrg
7246b8e80941Smrg
7247b8e80941Smrg      uint16_t *d = (uint16_t *)dst;
7248b8e80941Smrg         d[0] = r;
7249b8e80941Smrg         d[1] = g;
7250b8e80941Smrg         d[2] = b;
7251b8e80941Smrg            }
7252b8e80941Smrg
7253b8e80941Smrgstatic inline void
7254b8e80941Smrgpack_float_rgbx_float32(const GLfloat src[4], void *dst)
7255b8e80941Smrg{
7256b8e80941Smrg
7257b8e80941Smrg
7258b8e80941Smrg      float r =
7259b8e80941Smrg            src[0];
7260b8e80941Smrg
7261b8e80941Smrg
7262b8e80941Smrg      float g =
7263b8e80941Smrg            src[1];
7264b8e80941Smrg
7265b8e80941Smrg
7266b8e80941Smrg      float b =
7267b8e80941Smrg            src[2];
7268b8e80941Smrg
7269b8e80941Smrg
7270b8e80941Smrg      float *d = (float *)dst;
7271b8e80941Smrg         d[0] = r;
7272b8e80941Smrg         d[1] = g;
7273b8e80941Smrg         d[2] = b;
7274b8e80941Smrg            }
7275b8e80941Smrg
7276b8e80941Smrgstatic inline void
7277b8e80941Smrgpack_float_r9g9b9e5_float(const GLfloat src[4], void *dst)
7278b8e80941Smrg{
7279b8e80941Smrg   GLuint *d = (GLuint *) dst;
7280b8e80941Smrg   *d = float3_to_rgb9e5(src);
7281b8e80941Smrg}
7282b8e80941Smrg
7283b8e80941Smrgstatic inline void
7284b8e80941Smrgpack_float_r11g11b10_float(const GLfloat src[4], void *dst)
7285b8e80941Smrg{
7286b8e80941Smrg   GLuint *d = (GLuint *) dst;
7287b8e80941Smrg   *d = float3_to_r11g11b10f(src);
7288b8e80941Smrg}
7289b8e80941Smrg
7290b8e80941Smrg/**
7291b8e80941Smrg * Return a function that can pack a GLubyte rgba[4] color.
7292b8e80941Smrg */
7293b8e80941Smrggl_pack_ubyte_rgba_func
7294b8e80941Smrg_mesa_get_pack_ubyte_rgba_function(mesa_format format)
7295b8e80941Smrg{
7296b8e80941Smrg   switch (format) {
7297b8e80941Smrg
7298b8e80941Smrg   case MESA_FORMAT_A8B8G8R8_UNORM:
7299b8e80941Smrg      return pack_ubyte_a8b8g8r8_unorm;
7300b8e80941Smrg
7301b8e80941Smrg   case MESA_FORMAT_X8B8G8R8_UNORM:
7302b8e80941Smrg      return pack_ubyte_x8b8g8r8_unorm;
7303b8e80941Smrg
7304b8e80941Smrg   case MESA_FORMAT_R8G8B8A8_UNORM:
7305b8e80941Smrg      return pack_ubyte_r8g8b8a8_unorm;
7306b8e80941Smrg
7307b8e80941Smrg   case MESA_FORMAT_R8G8B8X8_UNORM:
7308b8e80941Smrg      return pack_ubyte_r8g8b8x8_unorm;
7309b8e80941Smrg
7310b8e80941Smrg   case MESA_FORMAT_B8G8R8A8_UNORM:
7311b8e80941Smrg      return pack_ubyte_b8g8r8a8_unorm;
7312b8e80941Smrg
7313b8e80941Smrg   case MESA_FORMAT_B8G8R8X8_UNORM:
7314b8e80941Smrg      return pack_ubyte_b8g8r8x8_unorm;
7315b8e80941Smrg
7316b8e80941Smrg   case MESA_FORMAT_A8R8G8B8_UNORM:
7317b8e80941Smrg      return pack_ubyte_a8r8g8b8_unorm;
7318b8e80941Smrg
7319b8e80941Smrg   case MESA_FORMAT_X8R8G8B8_UNORM:
7320b8e80941Smrg      return pack_ubyte_x8r8g8b8_unorm;
7321b8e80941Smrg
7322b8e80941Smrg   case MESA_FORMAT_L16A16_UNORM:
7323b8e80941Smrg      return pack_ubyte_l16a16_unorm;
7324b8e80941Smrg
7325b8e80941Smrg   case MESA_FORMAT_A16L16_UNORM:
7326b8e80941Smrg      return pack_ubyte_a16l16_unorm;
7327b8e80941Smrg
7328b8e80941Smrg   case MESA_FORMAT_B5G6R5_UNORM:
7329b8e80941Smrg      return pack_ubyte_b5g6r5_unorm;
7330b8e80941Smrg
7331b8e80941Smrg   case MESA_FORMAT_R5G6B5_UNORM:
7332b8e80941Smrg      return pack_ubyte_r5g6b5_unorm;
7333b8e80941Smrg
7334b8e80941Smrg   case MESA_FORMAT_B4G4R4A4_UNORM:
7335b8e80941Smrg      return pack_ubyte_b4g4r4a4_unorm;
7336b8e80941Smrg
7337b8e80941Smrg   case MESA_FORMAT_B4G4R4X4_UNORM:
7338b8e80941Smrg      return pack_ubyte_b4g4r4x4_unorm;
7339b8e80941Smrg
7340b8e80941Smrg   case MESA_FORMAT_A4R4G4B4_UNORM:
7341b8e80941Smrg      return pack_ubyte_a4r4g4b4_unorm;
7342b8e80941Smrg
7343b8e80941Smrg   case MESA_FORMAT_A1B5G5R5_UNORM:
7344b8e80941Smrg      return pack_ubyte_a1b5g5r5_unorm;
7345b8e80941Smrg
7346b8e80941Smrg   case MESA_FORMAT_X1B5G5R5_UNORM:
7347b8e80941Smrg      return pack_ubyte_x1b5g5r5_unorm;
7348b8e80941Smrg
7349b8e80941Smrg   case MESA_FORMAT_B5G5R5A1_UNORM:
7350b8e80941Smrg      return pack_ubyte_b5g5r5a1_unorm;
7351b8e80941Smrg
7352b8e80941Smrg   case MESA_FORMAT_B5G5R5X1_UNORM:
7353b8e80941Smrg      return pack_ubyte_b5g5r5x1_unorm;
7354b8e80941Smrg
7355b8e80941Smrg   case MESA_FORMAT_A1R5G5B5_UNORM:
7356b8e80941Smrg      return pack_ubyte_a1r5g5b5_unorm;
7357b8e80941Smrg
7358b8e80941Smrg   case MESA_FORMAT_L8A8_UNORM:
7359b8e80941Smrg      return pack_ubyte_l8a8_unorm;
7360b8e80941Smrg
7361b8e80941Smrg   case MESA_FORMAT_A8L8_UNORM:
7362b8e80941Smrg      return pack_ubyte_a8l8_unorm;
7363b8e80941Smrg
7364b8e80941Smrg   case MESA_FORMAT_R8G8_UNORM:
7365b8e80941Smrg      return pack_ubyte_r8g8_unorm;
7366b8e80941Smrg
7367b8e80941Smrg   case MESA_FORMAT_G8R8_UNORM:
7368b8e80941Smrg      return pack_ubyte_g8r8_unorm;
7369b8e80941Smrg
7370b8e80941Smrg   case MESA_FORMAT_L4A4_UNORM:
7371b8e80941Smrg      return pack_ubyte_l4a4_unorm;
7372b8e80941Smrg
7373b8e80941Smrg   case MESA_FORMAT_B2G3R3_UNORM:
7374b8e80941Smrg      return pack_ubyte_b2g3r3_unorm;
7375b8e80941Smrg
7376b8e80941Smrg   case MESA_FORMAT_R16G16_UNORM:
7377b8e80941Smrg      return pack_ubyte_r16g16_unorm;
7378b8e80941Smrg
7379b8e80941Smrg   case MESA_FORMAT_G16R16_UNORM:
7380b8e80941Smrg      return pack_ubyte_g16r16_unorm;
7381b8e80941Smrg
7382b8e80941Smrg   case MESA_FORMAT_B10G10R10A2_UNORM:
7383b8e80941Smrg      return pack_ubyte_b10g10r10a2_unorm;
7384b8e80941Smrg
7385b8e80941Smrg   case MESA_FORMAT_B10G10R10X2_UNORM:
7386b8e80941Smrg      return pack_ubyte_b10g10r10x2_unorm;
7387b8e80941Smrg
7388b8e80941Smrg   case MESA_FORMAT_R10G10B10A2_UNORM:
7389b8e80941Smrg      return pack_ubyte_r10g10b10a2_unorm;
7390b8e80941Smrg
7391b8e80941Smrg   case MESA_FORMAT_R10G10B10X2_UNORM:
7392b8e80941Smrg      return pack_ubyte_r10g10b10x2_unorm;
7393b8e80941Smrg
7394b8e80941Smrg   case MESA_FORMAT_R3G3B2_UNORM:
7395b8e80941Smrg      return pack_ubyte_r3g3b2_unorm;
7396b8e80941Smrg
7397b8e80941Smrg   case MESA_FORMAT_A4B4G4R4_UNORM:
7398b8e80941Smrg      return pack_ubyte_a4b4g4r4_unorm;
7399b8e80941Smrg
7400b8e80941Smrg   case MESA_FORMAT_R4G4B4A4_UNORM:
7401b8e80941Smrg      return pack_ubyte_r4g4b4a4_unorm;
7402b8e80941Smrg
7403b8e80941Smrg   case MESA_FORMAT_R5G5B5A1_UNORM:
7404b8e80941Smrg      return pack_ubyte_r5g5b5a1_unorm;
7405b8e80941Smrg
7406b8e80941Smrg   case MESA_FORMAT_A2B10G10R10_UNORM:
7407b8e80941Smrg      return pack_ubyte_a2b10g10r10_unorm;
7408b8e80941Smrg
7409b8e80941Smrg   case MESA_FORMAT_A2R10G10B10_UNORM:
7410b8e80941Smrg      return pack_ubyte_a2r10g10b10_unorm;
7411b8e80941Smrg
7412b8e80941Smrg   case MESA_FORMAT_A_UNORM8:
7413b8e80941Smrg      return pack_ubyte_a_unorm8;
7414b8e80941Smrg
7415b8e80941Smrg   case MESA_FORMAT_A_UNORM16:
7416b8e80941Smrg      return pack_ubyte_a_unorm16;
7417b8e80941Smrg
7418b8e80941Smrg   case MESA_FORMAT_L_UNORM8:
7419b8e80941Smrg      return pack_ubyte_l_unorm8;
7420b8e80941Smrg
7421b8e80941Smrg   case MESA_FORMAT_L_UNORM16:
7422b8e80941Smrg      return pack_ubyte_l_unorm16;
7423b8e80941Smrg
7424b8e80941Smrg   case MESA_FORMAT_I_UNORM8:
7425b8e80941Smrg      return pack_ubyte_i_unorm8;
7426b8e80941Smrg
7427b8e80941Smrg   case MESA_FORMAT_I_UNORM16:
7428b8e80941Smrg      return pack_ubyte_i_unorm16;
7429b8e80941Smrg
7430b8e80941Smrg   case MESA_FORMAT_R_UNORM8:
7431b8e80941Smrg      return pack_ubyte_r_unorm8;
7432b8e80941Smrg
7433b8e80941Smrg   case MESA_FORMAT_R_UNORM16:
7434b8e80941Smrg      return pack_ubyte_r_unorm16;
7435b8e80941Smrg
7436b8e80941Smrg   case MESA_FORMAT_BGR_UNORM8:
7437b8e80941Smrg      return pack_ubyte_bgr_unorm8;
7438b8e80941Smrg
7439b8e80941Smrg   case MESA_FORMAT_RGB_UNORM8:
7440b8e80941Smrg      return pack_ubyte_rgb_unorm8;
7441b8e80941Smrg
7442b8e80941Smrg   case MESA_FORMAT_RGBA_UNORM16:
7443b8e80941Smrg      return pack_ubyte_rgba_unorm16;
7444b8e80941Smrg
7445b8e80941Smrg   case MESA_FORMAT_RGBX_UNORM16:
7446b8e80941Smrg      return pack_ubyte_rgbx_unorm16;
7447b8e80941Smrg
7448b8e80941Smrg   case MESA_FORMAT_A8B8G8R8_SNORM:
7449b8e80941Smrg      return pack_ubyte_a8b8g8r8_snorm;
7450b8e80941Smrg
7451b8e80941Smrg   case MESA_FORMAT_X8B8G8R8_SNORM:
7452b8e80941Smrg      return pack_ubyte_x8b8g8r8_snorm;
7453b8e80941Smrg
7454b8e80941Smrg   case MESA_FORMAT_R8G8B8A8_SNORM:
7455b8e80941Smrg      return pack_ubyte_r8g8b8a8_snorm;
7456b8e80941Smrg
7457b8e80941Smrg   case MESA_FORMAT_R8G8B8X8_SNORM:
7458b8e80941Smrg      return pack_ubyte_r8g8b8x8_snorm;
7459b8e80941Smrg
7460b8e80941Smrg   case MESA_FORMAT_R16G16_SNORM:
7461b8e80941Smrg      return pack_ubyte_r16g16_snorm;
7462b8e80941Smrg
7463b8e80941Smrg   case MESA_FORMAT_G16R16_SNORM:
7464b8e80941Smrg      return pack_ubyte_g16r16_snorm;
7465b8e80941Smrg
7466b8e80941Smrg   case MESA_FORMAT_R8G8_SNORM:
7467b8e80941Smrg      return pack_ubyte_r8g8_snorm;
7468b8e80941Smrg
7469b8e80941Smrg   case MESA_FORMAT_G8R8_SNORM:
7470b8e80941Smrg      return pack_ubyte_g8r8_snorm;
7471b8e80941Smrg
7472b8e80941Smrg   case MESA_FORMAT_L8A8_SNORM:
7473b8e80941Smrg      return pack_ubyte_l8a8_snorm;
7474b8e80941Smrg
7475b8e80941Smrg   case MESA_FORMAT_A8L8_SNORM:
7476b8e80941Smrg      return pack_ubyte_a8l8_snorm;
7477b8e80941Smrg
7478b8e80941Smrg   case MESA_FORMAT_A_SNORM8:
7479b8e80941Smrg      return pack_ubyte_a_snorm8;
7480b8e80941Smrg
7481b8e80941Smrg   case MESA_FORMAT_A_SNORM16:
7482b8e80941Smrg      return pack_ubyte_a_snorm16;
7483b8e80941Smrg
7484b8e80941Smrg   case MESA_FORMAT_L_SNORM8:
7485b8e80941Smrg      return pack_ubyte_l_snorm8;
7486b8e80941Smrg
7487b8e80941Smrg   case MESA_FORMAT_L_SNORM16:
7488b8e80941Smrg      return pack_ubyte_l_snorm16;
7489b8e80941Smrg
7490b8e80941Smrg   case MESA_FORMAT_I_SNORM8:
7491b8e80941Smrg      return pack_ubyte_i_snorm8;
7492b8e80941Smrg
7493b8e80941Smrg   case MESA_FORMAT_I_SNORM16:
7494b8e80941Smrg      return pack_ubyte_i_snorm16;
7495b8e80941Smrg
7496b8e80941Smrg   case MESA_FORMAT_R_SNORM8:
7497b8e80941Smrg      return pack_ubyte_r_snorm8;
7498b8e80941Smrg
7499b8e80941Smrg   case MESA_FORMAT_R_SNORM16:
7500b8e80941Smrg      return pack_ubyte_r_snorm16;
7501b8e80941Smrg
7502b8e80941Smrg   case MESA_FORMAT_LA_SNORM16:
7503b8e80941Smrg      return pack_ubyte_la_snorm16;
7504b8e80941Smrg
7505b8e80941Smrg   case MESA_FORMAT_RGB_SNORM16:
7506b8e80941Smrg      return pack_ubyte_rgb_snorm16;
7507b8e80941Smrg
7508b8e80941Smrg   case MESA_FORMAT_RGBA_SNORM16:
7509b8e80941Smrg      return pack_ubyte_rgba_snorm16;
7510b8e80941Smrg
7511b8e80941Smrg   case MESA_FORMAT_RGBX_SNORM16:
7512b8e80941Smrg      return pack_ubyte_rgbx_snorm16;
7513b8e80941Smrg
7514b8e80941Smrg   case MESA_FORMAT_A8B8G8R8_SRGB:
7515b8e80941Smrg      return pack_ubyte_a8b8g8r8_srgb;
7516b8e80941Smrg
7517b8e80941Smrg   case MESA_FORMAT_B8G8R8A8_SRGB:
7518b8e80941Smrg      return pack_ubyte_b8g8r8a8_srgb;
7519b8e80941Smrg
7520b8e80941Smrg   case MESA_FORMAT_A8R8G8B8_SRGB:
7521b8e80941Smrg      return pack_ubyte_a8r8g8b8_srgb;
7522b8e80941Smrg
7523b8e80941Smrg   case MESA_FORMAT_B8G8R8X8_SRGB:
7524b8e80941Smrg      return pack_ubyte_b8g8r8x8_srgb;
7525b8e80941Smrg
7526b8e80941Smrg   case MESA_FORMAT_X8R8G8B8_SRGB:
7527b8e80941Smrg      return pack_ubyte_x8r8g8b8_srgb;
7528b8e80941Smrg
7529b8e80941Smrg   case MESA_FORMAT_R8G8B8A8_SRGB:
7530b8e80941Smrg      return pack_ubyte_r8g8b8a8_srgb;
7531b8e80941Smrg
7532b8e80941Smrg   case MESA_FORMAT_R8G8B8X8_SRGB:
7533b8e80941Smrg      return pack_ubyte_r8g8b8x8_srgb;
7534b8e80941Smrg
7535b8e80941Smrg   case MESA_FORMAT_X8B8G8R8_SRGB:
7536b8e80941Smrg      return pack_ubyte_x8b8g8r8_srgb;
7537b8e80941Smrg
7538b8e80941Smrg   case MESA_FORMAT_L8A8_SRGB:
7539b8e80941Smrg      return pack_ubyte_l8a8_srgb;
7540b8e80941Smrg
7541b8e80941Smrg   case MESA_FORMAT_A8L8_SRGB:
7542b8e80941Smrg      return pack_ubyte_a8l8_srgb;
7543b8e80941Smrg
7544b8e80941Smrg   case MESA_FORMAT_R_SRGB8:
7545b8e80941Smrg      return pack_ubyte_r_srgb8;
7546b8e80941Smrg
7547b8e80941Smrg   case MESA_FORMAT_L_SRGB8:
7548b8e80941Smrg      return pack_ubyte_l_srgb8;
7549b8e80941Smrg
7550b8e80941Smrg   case MESA_FORMAT_BGR_SRGB8:
7551b8e80941Smrg      return pack_ubyte_bgr_srgb8;
7552b8e80941Smrg
7553b8e80941Smrg   case MESA_FORMAT_R9G9B9E5_FLOAT:
7554b8e80941Smrg      return pack_ubyte_r9g9b9e5_float;
7555b8e80941Smrg
7556b8e80941Smrg   case MESA_FORMAT_R11G11B10_FLOAT:
7557b8e80941Smrg      return pack_ubyte_r11g11b10_float;
7558b8e80941Smrg
7559b8e80941Smrg   case MESA_FORMAT_A_FLOAT16:
7560b8e80941Smrg      return pack_ubyte_a_float16;
7561b8e80941Smrg
7562b8e80941Smrg   case MESA_FORMAT_A_FLOAT32:
7563b8e80941Smrg      return pack_ubyte_a_float32;
7564b8e80941Smrg
7565b8e80941Smrg   case MESA_FORMAT_L_FLOAT16:
7566b8e80941Smrg      return pack_ubyte_l_float16;
7567b8e80941Smrg
7568b8e80941Smrg   case MESA_FORMAT_L_FLOAT32:
7569b8e80941Smrg      return pack_ubyte_l_float32;
7570b8e80941Smrg
7571b8e80941Smrg   case MESA_FORMAT_LA_FLOAT16:
7572b8e80941Smrg      return pack_ubyte_la_float16;
7573b8e80941Smrg
7574b8e80941Smrg   case MESA_FORMAT_LA_FLOAT32:
7575b8e80941Smrg      return pack_ubyte_la_float32;
7576b8e80941Smrg
7577b8e80941Smrg   case MESA_FORMAT_I_FLOAT16:
7578b8e80941Smrg      return pack_ubyte_i_float16;
7579b8e80941Smrg
7580b8e80941Smrg   case MESA_FORMAT_I_FLOAT32:
7581b8e80941Smrg      return pack_ubyte_i_float32;
7582b8e80941Smrg
7583b8e80941Smrg   case MESA_FORMAT_R_FLOAT16:
7584b8e80941Smrg      return pack_ubyte_r_float16;
7585b8e80941Smrg
7586b8e80941Smrg   case MESA_FORMAT_R_FLOAT32:
7587b8e80941Smrg      return pack_ubyte_r_float32;
7588b8e80941Smrg
7589b8e80941Smrg   case MESA_FORMAT_RG_FLOAT16:
7590b8e80941Smrg      return pack_ubyte_rg_float16;
7591b8e80941Smrg
7592b8e80941Smrg   case MESA_FORMAT_RG_FLOAT32:
7593b8e80941Smrg      return pack_ubyte_rg_float32;
7594b8e80941Smrg
7595b8e80941Smrg   case MESA_FORMAT_RGB_FLOAT16:
7596b8e80941Smrg      return pack_ubyte_rgb_float16;
7597b8e80941Smrg
7598b8e80941Smrg   case MESA_FORMAT_RGB_FLOAT32:
7599b8e80941Smrg      return pack_ubyte_rgb_float32;
7600b8e80941Smrg
7601b8e80941Smrg   case MESA_FORMAT_RGBA_FLOAT16:
7602b8e80941Smrg      return pack_ubyte_rgba_float16;
7603b8e80941Smrg
7604b8e80941Smrg   case MESA_FORMAT_RGBA_FLOAT32:
7605b8e80941Smrg      return pack_ubyte_rgba_float32;
7606b8e80941Smrg
7607b8e80941Smrg   case MESA_FORMAT_RGBX_FLOAT16:
7608b8e80941Smrg      return pack_ubyte_rgbx_float16;
7609b8e80941Smrg
7610b8e80941Smrg   case MESA_FORMAT_RGBX_FLOAT32:
7611b8e80941Smrg      return pack_ubyte_rgbx_float32;
7612b8e80941Smrg
7613b8e80941Smrg   case MESA_FORMAT_A8B8G8R8_UINT:
7614b8e80941Smrg      return pack_ubyte_a8b8g8r8_uint;
7615b8e80941Smrg
7616b8e80941Smrg   case MESA_FORMAT_A8R8G8B8_UINT:
7617b8e80941Smrg      return pack_ubyte_a8r8g8b8_uint;
7618b8e80941Smrg
7619b8e80941Smrg   case MESA_FORMAT_R8G8B8A8_UINT:
7620b8e80941Smrg      return pack_ubyte_r8g8b8a8_uint;
7621b8e80941Smrg
7622b8e80941Smrg   case MESA_FORMAT_B8G8R8A8_UINT:
7623b8e80941Smrg      return pack_ubyte_b8g8r8a8_uint;
7624b8e80941Smrg
7625b8e80941Smrg   case MESA_FORMAT_B10G10R10A2_UINT:
7626b8e80941Smrg      return pack_ubyte_b10g10r10a2_uint;
7627b8e80941Smrg
7628b8e80941Smrg   case MESA_FORMAT_R10G10B10A2_UINT:
7629b8e80941Smrg      return pack_ubyte_r10g10b10a2_uint;
7630b8e80941Smrg
7631b8e80941Smrg   case MESA_FORMAT_A2B10G10R10_UINT:
7632b8e80941Smrg      return pack_ubyte_a2b10g10r10_uint;
7633b8e80941Smrg
7634b8e80941Smrg   case MESA_FORMAT_A2R10G10B10_UINT:
7635b8e80941Smrg      return pack_ubyte_a2r10g10b10_uint;
7636b8e80941Smrg
7637b8e80941Smrg   case MESA_FORMAT_B5G6R5_UINT:
7638b8e80941Smrg      return pack_ubyte_b5g6r5_uint;
7639b8e80941Smrg
7640b8e80941Smrg   case MESA_FORMAT_R5G6B5_UINT:
7641b8e80941Smrg      return pack_ubyte_r5g6b5_uint;
7642b8e80941Smrg
7643b8e80941Smrg   case MESA_FORMAT_B2G3R3_UINT:
7644b8e80941Smrg      return pack_ubyte_b2g3r3_uint;
7645b8e80941Smrg
7646b8e80941Smrg   case MESA_FORMAT_R3G3B2_UINT:
7647b8e80941Smrg      return pack_ubyte_r3g3b2_uint;
7648b8e80941Smrg
7649b8e80941Smrg   case MESA_FORMAT_A4B4G4R4_UINT:
7650b8e80941Smrg      return pack_ubyte_a4b4g4r4_uint;
7651b8e80941Smrg
7652b8e80941Smrg   case MESA_FORMAT_R4G4B4A4_UINT:
7653b8e80941Smrg      return pack_ubyte_r4g4b4a4_uint;
7654b8e80941Smrg
7655b8e80941Smrg   case MESA_FORMAT_B4G4R4A4_UINT:
7656b8e80941Smrg      return pack_ubyte_b4g4r4a4_uint;
7657b8e80941Smrg
7658b8e80941Smrg   case MESA_FORMAT_A4R4G4B4_UINT:
7659b8e80941Smrg      return pack_ubyte_a4r4g4b4_uint;
7660b8e80941Smrg
7661b8e80941Smrg   case MESA_FORMAT_A1B5G5R5_UINT:
7662b8e80941Smrg      return pack_ubyte_a1b5g5r5_uint;
7663b8e80941Smrg
7664b8e80941Smrg   case MESA_FORMAT_B5G5R5A1_UINT:
7665b8e80941Smrg      return pack_ubyte_b5g5r5a1_uint;
7666b8e80941Smrg
7667b8e80941Smrg   case MESA_FORMAT_A1R5G5B5_UINT:
7668b8e80941Smrg      return pack_ubyte_a1r5g5b5_uint;
7669b8e80941Smrg
7670b8e80941Smrg   case MESA_FORMAT_R5G5B5A1_UINT:
7671b8e80941Smrg      return pack_ubyte_r5g5b5a1_uint;
7672b8e80941Smrg
7673b8e80941Smrg   case MESA_FORMAT_A_UINT8:
7674b8e80941Smrg      return pack_ubyte_a_uint8;
7675b8e80941Smrg
7676b8e80941Smrg   case MESA_FORMAT_A_UINT16:
7677b8e80941Smrg      return pack_ubyte_a_uint16;
7678b8e80941Smrg
7679b8e80941Smrg   case MESA_FORMAT_A_UINT32:
7680b8e80941Smrg      return pack_ubyte_a_uint32;
7681b8e80941Smrg
7682b8e80941Smrg   case MESA_FORMAT_A_SINT8:
7683b8e80941Smrg      return pack_ubyte_a_sint8;
7684b8e80941Smrg
7685b8e80941Smrg   case MESA_FORMAT_A_SINT16:
7686b8e80941Smrg      return pack_ubyte_a_sint16;
7687b8e80941Smrg
7688b8e80941Smrg   case MESA_FORMAT_A_SINT32:
7689b8e80941Smrg      return pack_ubyte_a_sint32;
7690b8e80941Smrg
7691b8e80941Smrg   case MESA_FORMAT_I_UINT8:
7692b8e80941Smrg      return pack_ubyte_i_uint8;
7693b8e80941Smrg
7694b8e80941Smrg   case MESA_FORMAT_I_UINT16:
7695b8e80941Smrg      return pack_ubyte_i_uint16;
7696b8e80941Smrg
7697b8e80941Smrg   case MESA_FORMAT_I_UINT32:
7698b8e80941Smrg      return pack_ubyte_i_uint32;
7699b8e80941Smrg
7700b8e80941Smrg   case MESA_FORMAT_I_SINT8:
7701b8e80941Smrg      return pack_ubyte_i_sint8;
7702b8e80941Smrg
7703b8e80941Smrg   case MESA_FORMAT_I_SINT16:
7704b8e80941Smrg      return pack_ubyte_i_sint16;
7705b8e80941Smrg
7706b8e80941Smrg   case MESA_FORMAT_I_SINT32:
7707b8e80941Smrg      return pack_ubyte_i_sint32;
7708b8e80941Smrg
7709b8e80941Smrg   case MESA_FORMAT_L_UINT8:
7710b8e80941Smrg      return pack_ubyte_l_uint8;
7711b8e80941Smrg
7712b8e80941Smrg   case MESA_FORMAT_L_UINT16:
7713b8e80941Smrg      return pack_ubyte_l_uint16;
7714b8e80941Smrg
7715b8e80941Smrg   case MESA_FORMAT_L_UINT32:
7716b8e80941Smrg      return pack_ubyte_l_uint32;
7717b8e80941Smrg
7718b8e80941Smrg   case MESA_FORMAT_L_SINT8:
7719b8e80941Smrg      return pack_ubyte_l_sint8;
7720b8e80941Smrg
7721b8e80941Smrg   case MESA_FORMAT_L_SINT16:
7722b8e80941Smrg      return pack_ubyte_l_sint16;
7723b8e80941Smrg
7724b8e80941Smrg   case MESA_FORMAT_L_SINT32:
7725b8e80941Smrg      return pack_ubyte_l_sint32;
7726b8e80941Smrg
7727b8e80941Smrg   case MESA_FORMAT_LA_UINT8:
7728b8e80941Smrg      return pack_ubyte_la_uint8;
7729b8e80941Smrg
7730b8e80941Smrg   case MESA_FORMAT_LA_UINT16:
7731b8e80941Smrg      return pack_ubyte_la_uint16;
7732b8e80941Smrg
7733b8e80941Smrg   case MESA_FORMAT_LA_UINT32:
7734b8e80941Smrg      return pack_ubyte_la_uint32;
7735b8e80941Smrg
7736b8e80941Smrg   case MESA_FORMAT_LA_SINT8:
7737b8e80941Smrg      return pack_ubyte_la_sint8;
7738b8e80941Smrg
7739b8e80941Smrg   case MESA_FORMAT_LA_SINT16:
7740b8e80941Smrg      return pack_ubyte_la_sint16;
7741b8e80941Smrg
7742b8e80941Smrg   case MESA_FORMAT_LA_SINT32:
7743b8e80941Smrg      return pack_ubyte_la_sint32;
7744b8e80941Smrg
7745b8e80941Smrg   case MESA_FORMAT_R_UINT8:
7746b8e80941Smrg      return pack_ubyte_r_uint8;
7747b8e80941Smrg
7748b8e80941Smrg   case MESA_FORMAT_R_UINT16:
7749b8e80941Smrg      return pack_ubyte_r_uint16;
7750b8e80941Smrg
7751b8e80941Smrg   case MESA_FORMAT_R_UINT32:
7752b8e80941Smrg      return pack_ubyte_r_uint32;
7753b8e80941Smrg
7754b8e80941Smrg   case MESA_FORMAT_R_SINT8:
7755b8e80941Smrg      return pack_ubyte_r_sint8;
7756b8e80941Smrg
7757b8e80941Smrg   case MESA_FORMAT_R_SINT16:
7758b8e80941Smrg      return pack_ubyte_r_sint16;
7759b8e80941Smrg
7760b8e80941Smrg   case MESA_FORMAT_R_SINT32:
7761b8e80941Smrg      return pack_ubyte_r_sint32;
7762b8e80941Smrg
7763b8e80941Smrg   case MESA_FORMAT_RG_UINT8:
7764b8e80941Smrg      return pack_ubyte_rg_uint8;
7765b8e80941Smrg
7766b8e80941Smrg   case MESA_FORMAT_RG_UINT16:
7767b8e80941Smrg      return pack_ubyte_rg_uint16;
7768b8e80941Smrg
7769b8e80941Smrg   case MESA_FORMAT_RG_UINT32:
7770b8e80941Smrg      return pack_ubyte_rg_uint32;
7771b8e80941Smrg
7772b8e80941Smrg   case MESA_FORMAT_RG_SINT8:
7773b8e80941Smrg      return pack_ubyte_rg_sint8;
7774b8e80941Smrg
7775b8e80941Smrg   case MESA_FORMAT_RG_SINT16:
7776b8e80941Smrg      return pack_ubyte_rg_sint16;
7777b8e80941Smrg
7778b8e80941Smrg   case MESA_FORMAT_RG_SINT32:
7779b8e80941Smrg      return pack_ubyte_rg_sint32;
7780b8e80941Smrg
7781b8e80941Smrg   case MESA_FORMAT_RGB_UINT8:
7782b8e80941Smrg      return pack_ubyte_rgb_uint8;
7783b8e80941Smrg
7784b8e80941Smrg   case MESA_FORMAT_RGB_UINT16:
7785b8e80941Smrg      return pack_ubyte_rgb_uint16;
7786b8e80941Smrg
7787b8e80941Smrg   case MESA_FORMAT_RGB_UINT32:
7788b8e80941Smrg      return pack_ubyte_rgb_uint32;
7789b8e80941Smrg
7790b8e80941Smrg   case MESA_FORMAT_RGB_SINT8:
7791b8e80941Smrg      return pack_ubyte_rgb_sint8;
7792b8e80941Smrg
7793b8e80941Smrg   case MESA_FORMAT_RGB_SINT16:
7794b8e80941Smrg      return pack_ubyte_rgb_sint16;
7795b8e80941Smrg
7796b8e80941Smrg   case MESA_FORMAT_RGB_SINT32:
7797b8e80941Smrg      return pack_ubyte_rgb_sint32;
7798b8e80941Smrg
7799b8e80941Smrg   case MESA_FORMAT_RGBA_UINT8:
7800b8e80941Smrg      return pack_ubyte_rgba_uint8;
7801b8e80941Smrg
7802b8e80941Smrg   case MESA_FORMAT_RGBA_UINT16:
7803b8e80941Smrg      return pack_ubyte_rgba_uint16;
7804b8e80941Smrg
7805b8e80941Smrg   case MESA_FORMAT_RGBA_UINT32:
7806b8e80941Smrg      return pack_ubyte_rgba_uint32;
7807b8e80941Smrg
7808b8e80941Smrg   case MESA_FORMAT_RGBA_SINT8:
7809b8e80941Smrg      return pack_ubyte_rgba_sint8;
7810b8e80941Smrg
7811b8e80941Smrg   case MESA_FORMAT_RGBA_SINT16:
7812b8e80941Smrg      return pack_ubyte_rgba_sint16;
7813b8e80941Smrg
7814b8e80941Smrg   case MESA_FORMAT_RGBA_SINT32:
7815b8e80941Smrg      return pack_ubyte_rgba_sint32;
7816b8e80941Smrg
7817b8e80941Smrg   case MESA_FORMAT_RGBX_UINT8:
7818b8e80941Smrg      return pack_ubyte_rgbx_uint8;
7819b8e80941Smrg
7820b8e80941Smrg   case MESA_FORMAT_RGBX_UINT16:
7821b8e80941Smrg      return pack_ubyte_rgbx_uint16;
7822b8e80941Smrg
7823b8e80941Smrg   case MESA_FORMAT_RGBX_UINT32:
7824b8e80941Smrg      return pack_ubyte_rgbx_uint32;
7825b8e80941Smrg
7826b8e80941Smrg   case MESA_FORMAT_RGBX_SINT8:
7827b8e80941Smrg      return pack_ubyte_rgbx_sint8;
7828b8e80941Smrg
7829b8e80941Smrg   case MESA_FORMAT_RGBX_SINT16:
7830b8e80941Smrg      return pack_ubyte_rgbx_sint16;
7831b8e80941Smrg
7832b8e80941Smrg   case MESA_FORMAT_RGBX_SINT32:
7833b8e80941Smrg      return pack_ubyte_rgbx_sint32;
7834b8e80941Smrg                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           default:
7835b8e80941Smrg      return NULL;
7836b8e80941Smrg   }
7837b8e80941Smrg}
7838b8e80941Smrg
7839b8e80941Smrg/**
7840b8e80941Smrg * Return a function that can pack a GLfloat rgba[4] color.
7841b8e80941Smrg */
7842b8e80941Smrggl_pack_float_rgba_func
7843b8e80941Smrg_mesa_get_pack_float_rgba_function(mesa_format format)
7844b8e80941Smrg{
7845b8e80941Smrg   switch (format) {
7846b8e80941Smrg
7847b8e80941Smrg   case MESA_FORMAT_A8B8G8R8_UNORM:
7848b8e80941Smrg      return pack_float_a8b8g8r8_unorm;
7849b8e80941Smrg
7850b8e80941Smrg   case MESA_FORMAT_X8B8G8R8_UNORM:
7851b8e80941Smrg      return pack_float_x8b8g8r8_unorm;
7852b8e80941Smrg
7853b8e80941Smrg   case MESA_FORMAT_R8G8B8A8_UNORM:
7854b8e80941Smrg      return pack_float_r8g8b8a8_unorm;
7855b8e80941Smrg
7856b8e80941Smrg   case MESA_FORMAT_R8G8B8X8_UNORM:
7857b8e80941Smrg      return pack_float_r8g8b8x8_unorm;
7858b8e80941Smrg
7859b8e80941Smrg   case MESA_FORMAT_B8G8R8A8_UNORM:
7860b8e80941Smrg      return pack_float_b8g8r8a8_unorm;
7861b8e80941Smrg
7862b8e80941Smrg   case MESA_FORMAT_B8G8R8X8_UNORM:
7863b8e80941Smrg      return pack_float_b8g8r8x8_unorm;
7864b8e80941Smrg
7865b8e80941Smrg   case MESA_FORMAT_A8R8G8B8_UNORM:
7866b8e80941Smrg      return pack_float_a8r8g8b8_unorm;
7867b8e80941Smrg
7868b8e80941Smrg   case MESA_FORMAT_X8R8G8B8_UNORM:
7869b8e80941Smrg      return pack_float_x8r8g8b8_unorm;
7870b8e80941Smrg
7871b8e80941Smrg   case MESA_FORMAT_L16A16_UNORM:
7872b8e80941Smrg      return pack_float_l16a16_unorm;
7873b8e80941Smrg
7874b8e80941Smrg   case MESA_FORMAT_A16L16_UNORM:
7875b8e80941Smrg      return pack_float_a16l16_unorm;
7876b8e80941Smrg
7877b8e80941Smrg   case MESA_FORMAT_B5G6R5_UNORM:
7878b8e80941Smrg      return pack_float_b5g6r5_unorm;
7879b8e80941Smrg
7880b8e80941Smrg   case MESA_FORMAT_R5G6B5_UNORM:
7881b8e80941Smrg      return pack_float_r5g6b5_unorm;
7882b8e80941Smrg
7883b8e80941Smrg   case MESA_FORMAT_B4G4R4A4_UNORM:
7884b8e80941Smrg      return pack_float_b4g4r4a4_unorm;
7885b8e80941Smrg
7886b8e80941Smrg   case MESA_FORMAT_B4G4R4X4_UNORM:
7887b8e80941Smrg      return pack_float_b4g4r4x4_unorm;
7888b8e80941Smrg
7889b8e80941Smrg   case MESA_FORMAT_A4R4G4B4_UNORM:
7890b8e80941Smrg      return pack_float_a4r4g4b4_unorm;
7891b8e80941Smrg
7892b8e80941Smrg   case MESA_FORMAT_A1B5G5R5_UNORM:
7893b8e80941Smrg      return pack_float_a1b5g5r5_unorm;
7894b8e80941Smrg
7895b8e80941Smrg   case MESA_FORMAT_X1B5G5R5_UNORM:
7896b8e80941Smrg      return pack_float_x1b5g5r5_unorm;
7897b8e80941Smrg
7898b8e80941Smrg   case MESA_FORMAT_B5G5R5A1_UNORM:
7899b8e80941Smrg      return pack_float_b5g5r5a1_unorm;
7900b8e80941Smrg
7901b8e80941Smrg   case MESA_FORMAT_B5G5R5X1_UNORM:
7902b8e80941Smrg      return pack_float_b5g5r5x1_unorm;
7903b8e80941Smrg
7904b8e80941Smrg   case MESA_FORMAT_A1R5G5B5_UNORM:
7905b8e80941Smrg      return pack_float_a1r5g5b5_unorm;
7906b8e80941Smrg
7907b8e80941Smrg   case MESA_FORMAT_L8A8_UNORM:
7908b8e80941Smrg      return pack_float_l8a8_unorm;
7909b8e80941Smrg
7910b8e80941Smrg   case MESA_FORMAT_A8L8_UNORM:
7911b8e80941Smrg      return pack_float_a8l8_unorm;
7912b8e80941Smrg
7913b8e80941Smrg   case MESA_FORMAT_R8G8_UNORM:
7914b8e80941Smrg      return pack_float_r8g8_unorm;
7915b8e80941Smrg
7916b8e80941Smrg   case MESA_FORMAT_G8R8_UNORM:
7917b8e80941Smrg      return pack_float_g8r8_unorm;
7918b8e80941Smrg
7919b8e80941Smrg   case MESA_FORMAT_L4A4_UNORM:
7920b8e80941Smrg      return pack_float_l4a4_unorm;
7921b8e80941Smrg
7922b8e80941Smrg   case MESA_FORMAT_B2G3R3_UNORM:
7923b8e80941Smrg      return pack_float_b2g3r3_unorm;
7924b8e80941Smrg
7925b8e80941Smrg   case MESA_FORMAT_R16G16_UNORM:
7926b8e80941Smrg      return pack_float_r16g16_unorm;
7927b8e80941Smrg
7928b8e80941Smrg   case MESA_FORMAT_G16R16_UNORM:
7929b8e80941Smrg      return pack_float_g16r16_unorm;
7930b8e80941Smrg
7931b8e80941Smrg   case MESA_FORMAT_B10G10R10A2_UNORM:
7932b8e80941Smrg      return pack_float_b10g10r10a2_unorm;
7933b8e80941Smrg
7934b8e80941Smrg   case MESA_FORMAT_B10G10R10X2_UNORM:
7935b8e80941Smrg      return pack_float_b10g10r10x2_unorm;
7936b8e80941Smrg
7937b8e80941Smrg   case MESA_FORMAT_R10G10B10A2_UNORM:
7938b8e80941Smrg      return pack_float_r10g10b10a2_unorm;
7939b8e80941Smrg
7940b8e80941Smrg   case MESA_FORMAT_R10G10B10X2_UNORM:
7941b8e80941Smrg      return pack_float_r10g10b10x2_unorm;
7942b8e80941Smrg
7943b8e80941Smrg   case MESA_FORMAT_R3G3B2_UNORM:
7944b8e80941Smrg      return pack_float_r3g3b2_unorm;
7945b8e80941Smrg
7946b8e80941Smrg   case MESA_FORMAT_A4B4G4R4_UNORM:
7947b8e80941Smrg      return pack_float_a4b4g4r4_unorm;
7948b8e80941Smrg
7949b8e80941Smrg   case MESA_FORMAT_R4G4B4A4_UNORM:
7950b8e80941Smrg      return pack_float_r4g4b4a4_unorm;
7951b8e80941Smrg
7952b8e80941Smrg   case MESA_FORMAT_R5G5B5A1_UNORM:
7953b8e80941Smrg      return pack_float_r5g5b5a1_unorm;
7954b8e80941Smrg
7955b8e80941Smrg   case MESA_FORMAT_A2B10G10R10_UNORM:
7956b8e80941Smrg      return pack_float_a2b10g10r10_unorm;
7957b8e80941Smrg
7958b8e80941Smrg   case MESA_FORMAT_A2R10G10B10_UNORM:
7959b8e80941Smrg      return pack_float_a2r10g10b10_unorm;
7960b8e80941Smrg
7961b8e80941Smrg   case MESA_FORMAT_A_UNORM8:
7962b8e80941Smrg      return pack_float_a_unorm8;
7963b8e80941Smrg
7964b8e80941Smrg   case MESA_FORMAT_A_UNORM16:
7965b8e80941Smrg      return pack_float_a_unorm16;
7966b8e80941Smrg
7967b8e80941Smrg   case MESA_FORMAT_L_UNORM8:
7968b8e80941Smrg      return pack_float_l_unorm8;
7969b8e80941Smrg
7970b8e80941Smrg   case MESA_FORMAT_L_UNORM16:
7971b8e80941Smrg      return pack_float_l_unorm16;
7972b8e80941Smrg
7973b8e80941Smrg   case MESA_FORMAT_I_UNORM8:
7974b8e80941Smrg      return pack_float_i_unorm8;
7975b8e80941Smrg
7976b8e80941Smrg   case MESA_FORMAT_I_UNORM16:
7977b8e80941Smrg      return pack_float_i_unorm16;
7978b8e80941Smrg
7979b8e80941Smrg   case MESA_FORMAT_R_UNORM8:
7980b8e80941Smrg      return pack_float_r_unorm8;
7981b8e80941Smrg
7982b8e80941Smrg   case MESA_FORMAT_R_UNORM16:
7983b8e80941Smrg      return pack_float_r_unorm16;
7984b8e80941Smrg
7985b8e80941Smrg   case MESA_FORMAT_BGR_UNORM8:
7986b8e80941Smrg      return pack_float_bgr_unorm8;
7987b8e80941Smrg
7988b8e80941Smrg   case MESA_FORMAT_RGB_UNORM8:
7989b8e80941Smrg      return pack_float_rgb_unorm8;
7990b8e80941Smrg
7991b8e80941Smrg   case MESA_FORMAT_RGBA_UNORM16:
7992b8e80941Smrg      return pack_float_rgba_unorm16;
7993b8e80941Smrg
7994b8e80941Smrg   case MESA_FORMAT_RGBX_UNORM16:
7995b8e80941Smrg      return pack_float_rgbx_unorm16;
7996b8e80941Smrg
7997b8e80941Smrg   case MESA_FORMAT_A8B8G8R8_SNORM:
7998b8e80941Smrg      return pack_float_a8b8g8r8_snorm;
7999b8e80941Smrg
8000b8e80941Smrg   case MESA_FORMAT_X8B8G8R8_SNORM:
8001b8e80941Smrg      return pack_float_x8b8g8r8_snorm;
8002b8e80941Smrg
8003b8e80941Smrg   case MESA_FORMAT_R8G8B8A8_SNORM:
8004b8e80941Smrg      return pack_float_r8g8b8a8_snorm;
8005b8e80941Smrg
8006b8e80941Smrg   case MESA_FORMAT_R8G8B8X8_SNORM:
8007b8e80941Smrg      return pack_float_r8g8b8x8_snorm;
8008b8e80941Smrg
8009b8e80941Smrg   case MESA_FORMAT_R16G16_SNORM:
8010b8e80941Smrg      return pack_float_r16g16_snorm;
8011b8e80941Smrg
8012b8e80941Smrg   case MESA_FORMAT_G16R16_SNORM:
8013b8e80941Smrg      return pack_float_g16r16_snorm;
8014b8e80941Smrg
8015b8e80941Smrg   case MESA_FORMAT_R8G8_SNORM:
8016b8e80941Smrg      return pack_float_r8g8_snorm;
8017b8e80941Smrg
8018b8e80941Smrg   case MESA_FORMAT_G8R8_SNORM:
8019b8e80941Smrg      return pack_float_g8r8_snorm;
8020b8e80941Smrg
8021b8e80941Smrg   case MESA_FORMAT_L8A8_SNORM:
8022b8e80941Smrg      return pack_float_l8a8_snorm;
8023b8e80941Smrg
8024b8e80941Smrg   case MESA_FORMAT_A8L8_SNORM:
8025b8e80941Smrg      return pack_float_a8l8_snorm;
8026b8e80941Smrg
8027b8e80941Smrg   case MESA_FORMAT_A_SNORM8:
8028b8e80941Smrg      return pack_float_a_snorm8;
8029b8e80941Smrg
8030b8e80941Smrg   case MESA_FORMAT_A_SNORM16:
8031b8e80941Smrg      return pack_float_a_snorm16;
8032b8e80941Smrg
8033b8e80941Smrg   case MESA_FORMAT_L_SNORM8:
8034b8e80941Smrg      return pack_float_l_snorm8;
8035b8e80941Smrg
8036b8e80941Smrg   case MESA_FORMAT_L_SNORM16:
8037b8e80941Smrg      return pack_float_l_snorm16;
8038b8e80941Smrg
8039b8e80941Smrg   case MESA_FORMAT_I_SNORM8:
8040b8e80941Smrg      return pack_float_i_snorm8;
8041b8e80941Smrg
8042b8e80941Smrg   case MESA_FORMAT_I_SNORM16:
8043b8e80941Smrg      return pack_float_i_snorm16;
8044b8e80941Smrg
8045b8e80941Smrg   case MESA_FORMAT_R_SNORM8:
8046b8e80941Smrg      return pack_float_r_snorm8;
8047b8e80941Smrg
8048b8e80941Smrg   case MESA_FORMAT_R_SNORM16:
8049b8e80941Smrg      return pack_float_r_snorm16;
8050b8e80941Smrg
8051b8e80941Smrg   case MESA_FORMAT_LA_SNORM16:
8052b8e80941Smrg      return pack_float_la_snorm16;
8053b8e80941Smrg
8054b8e80941Smrg   case MESA_FORMAT_RGB_SNORM16:
8055b8e80941Smrg      return pack_float_rgb_snorm16;
8056b8e80941Smrg
8057b8e80941Smrg   case MESA_FORMAT_RGBA_SNORM16:
8058b8e80941Smrg      return pack_float_rgba_snorm16;
8059b8e80941Smrg
8060b8e80941Smrg   case MESA_FORMAT_RGBX_SNORM16:
8061b8e80941Smrg      return pack_float_rgbx_snorm16;
8062b8e80941Smrg
8063b8e80941Smrg   case MESA_FORMAT_A8B8G8R8_SRGB:
8064b8e80941Smrg      return pack_float_a8b8g8r8_srgb;
8065b8e80941Smrg
8066b8e80941Smrg   case MESA_FORMAT_B8G8R8A8_SRGB:
8067b8e80941Smrg      return pack_float_b8g8r8a8_srgb;
8068b8e80941Smrg
8069b8e80941Smrg   case MESA_FORMAT_A8R8G8B8_SRGB:
8070b8e80941Smrg      return pack_float_a8r8g8b8_srgb;
8071b8e80941Smrg
8072b8e80941Smrg   case MESA_FORMAT_B8G8R8X8_SRGB:
8073b8e80941Smrg      return pack_float_b8g8r8x8_srgb;
8074b8e80941Smrg
8075b8e80941Smrg   case MESA_FORMAT_X8R8G8B8_SRGB:
8076b8e80941Smrg      return pack_float_x8r8g8b8_srgb;
8077b8e80941Smrg
8078b8e80941Smrg   case MESA_FORMAT_R8G8B8A8_SRGB:
8079b8e80941Smrg      return pack_float_r8g8b8a8_srgb;
8080b8e80941Smrg
8081b8e80941Smrg   case MESA_FORMAT_R8G8B8X8_SRGB:
8082b8e80941Smrg      return pack_float_r8g8b8x8_srgb;
8083b8e80941Smrg
8084b8e80941Smrg   case MESA_FORMAT_X8B8G8R8_SRGB:
8085b8e80941Smrg      return pack_float_x8b8g8r8_srgb;
8086b8e80941Smrg
8087b8e80941Smrg   case MESA_FORMAT_L8A8_SRGB:
8088b8e80941Smrg      return pack_float_l8a8_srgb;
8089b8e80941Smrg
8090b8e80941Smrg   case MESA_FORMAT_A8L8_SRGB:
8091b8e80941Smrg      return pack_float_a8l8_srgb;
8092b8e80941Smrg
8093b8e80941Smrg   case MESA_FORMAT_R_SRGB8:
8094b8e80941Smrg      return pack_float_r_srgb8;
8095b8e80941Smrg
8096b8e80941Smrg   case MESA_FORMAT_L_SRGB8:
8097b8e80941Smrg      return pack_float_l_srgb8;
8098b8e80941Smrg
8099b8e80941Smrg   case MESA_FORMAT_BGR_SRGB8:
8100b8e80941Smrg      return pack_float_bgr_srgb8;
8101b8e80941Smrg
8102b8e80941Smrg   case MESA_FORMAT_R9G9B9E5_FLOAT:
8103b8e80941Smrg      return pack_float_r9g9b9e5_float;
8104b8e80941Smrg
8105b8e80941Smrg   case MESA_FORMAT_R11G11B10_FLOAT:
8106b8e80941Smrg      return pack_float_r11g11b10_float;
8107b8e80941Smrg
8108b8e80941Smrg   case MESA_FORMAT_A_FLOAT16:
8109b8e80941Smrg      return pack_float_a_float16;
8110b8e80941Smrg
8111b8e80941Smrg   case MESA_FORMAT_A_FLOAT32:
8112b8e80941Smrg      return pack_float_a_float32;
8113b8e80941Smrg
8114b8e80941Smrg   case MESA_FORMAT_L_FLOAT16:
8115b8e80941Smrg      return pack_float_l_float16;
8116b8e80941Smrg
8117b8e80941Smrg   case MESA_FORMAT_L_FLOAT32:
8118b8e80941Smrg      return pack_float_l_float32;
8119b8e80941Smrg
8120b8e80941Smrg   case MESA_FORMAT_LA_FLOAT16:
8121b8e80941Smrg      return pack_float_la_float16;
8122b8e80941Smrg
8123b8e80941Smrg   case MESA_FORMAT_LA_FLOAT32:
8124b8e80941Smrg      return pack_float_la_float32;
8125b8e80941Smrg
8126b8e80941Smrg   case MESA_FORMAT_I_FLOAT16:
8127b8e80941Smrg      return pack_float_i_float16;
8128b8e80941Smrg
8129b8e80941Smrg   case MESA_FORMAT_I_FLOAT32:
8130b8e80941Smrg      return pack_float_i_float32;
8131b8e80941Smrg
8132b8e80941Smrg   case MESA_FORMAT_R_FLOAT16:
8133b8e80941Smrg      return pack_float_r_float16;
8134b8e80941Smrg
8135b8e80941Smrg   case MESA_FORMAT_R_FLOAT32:
8136b8e80941Smrg      return pack_float_r_float32;
8137b8e80941Smrg
8138b8e80941Smrg   case MESA_FORMAT_RG_FLOAT16:
8139b8e80941Smrg      return pack_float_rg_float16;
8140b8e80941Smrg
8141b8e80941Smrg   case MESA_FORMAT_RG_FLOAT32:
8142b8e80941Smrg      return pack_float_rg_float32;
8143b8e80941Smrg
8144b8e80941Smrg   case MESA_FORMAT_RGB_FLOAT16:
8145b8e80941Smrg      return pack_float_rgb_float16;
8146b8e80941Smrg
8147b8e80941Smrg   case MESA_FORMAT_RGB_FLOAT32:
8148b8e80941Smrg      return pack_float_rgb_float32;
8149b8e80941Smrg
8150b8e80941Smrg   case MESA_FORMAT_RGBA_FLOAT16:
8151b8e80941Smrg      return pack_float_rgba_float16;
8152b8e80941Smrg
8153b8e80941Smrg   case MESA_FORMAT_RGBA_FLOAT32:
8154b8e80941Smrg      return pack_float_rgba_float32;
8155b8e80941Smrg
8156b8e80941Smrg   case MESA_FORMAT_RGBX_FLOAT16:
8157b8e80941Smrg      return pack_float_rgbx_float16;
8158b8e80941Smrg
8159b8e80941Smrg   case MESA_FORMAT_RGBX_FLOAT32:
8160b8e80941Smrg      return pack_float_rgbx_float32;
8161b8e80941Smrg                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       default:
8162b8e80941Smrg      return NULL;
8163b8e80941Smrg   }
8164b8e80941Smrg}
8165b8e80941Smrg
8166b8e80941Smrg/**
8167b8e80941Smrg * Pack a row of GLubyte rgba[4] values to the destination.
8168b8e80941Smrg */
8169b8e80941Smrgvoid
8170b8e80941Smrg_mesa_pack_ubyte_rgba_row(mesa_format format, GLuint n,
8171b8e80941Smrg                          const GLubyte src[][4], void *dst)
8172b8e80941Smrg{
8173b8e80941Smrg   GLuint i;
8174b8e80941Smrg   GLubyte *d = dst;
8175b8e80941Smrg
8176b8e80941Smrg   switch (format) {
8177b8e80941Smrg
8178b8e80941Smrg   case MESA_FORMAT_A8B8G8R8_UNORM:
8179b8e80941Smrg      for (i = 0; i < n; ++i) {
8180b8e80941Smrg         pack_ubyte_a8b8g8r8_unorm(src[i], d);
8181b8e80941Smrg         d += 4;
8182b8e80941Smrg      }
8183b8e80941Smrg      break;
8184b8e80941Smrg
8185b8e80941Smrg   case MESA_FORMAT_X8B8G8R8_UNORM:
8186b8e80941Smrg      for (i = 0; i < n; ++i) {
8187b8e80941Smrg         pack_ubyte_x8b8g8r8_unorm(src[i], d);
8188b8e80941Smrg         d += 4;
8189b8e80941Smrg      }
8190b8e80941Smrg      break;
8191b8e80941Smrg
8192b8e80941Smrg   case MESA_FORMAT_R8G8B8A8_UNORM:
8193b8e80941Smrg      for (i = 0; i < n; ++i) {
8194b8e80941Smrg         pack_ubyte_r8g8b8a8_unorm(src[i], d);
8195b8e80941Smrg         d += 4;
8196b8e80941Smrg      }
8197b8e80941Smrg      break;
8198b8e80941Smrg
8199b8e80941Smrg   case MESA_FORMAT_R8G8B8X8_UNORM:
8200b8e80941Smrg      for (i = 0; i < n; ++i) {
8201b8e80941Smrg         pack_ubyte_r8g8b8x8_unorm(src[i], d);
8202b8e80941Smrg         d += 4;
8203b8e80941Smrg      }
8204b8e80941Smrg      break;
8205b8e80941Smrg
8206b8e80941Smrg   case MESA_FORMAT_B8G8R8A8_UNORM:
8207b8e80941Smrg      for (i = 0; i < n; ++i) {
8208b8e80941Smrg         pack_ubyte_b8g8r8a8_unorm(src[i], d);
8209b8e80941Smrg         d += 4;
8210b8e80941Smrg      }
8211b8e80941Smrg      break;
8212b8e80941Smrg
8213b8e80941Smrg   case MESA_FORMAT_B8G8R8X8_UNORM:
8214b8e80941Smrg      for (i = 0; i < n; ++i) {
8215b8e80941Smrg         pack_ubyte_b8g8r8x8_unorm(src[i], d);
8216b8e80941Smrg         d += 4;
8217b8e80941Smrg      }
8218b8e80941Smrg      break;
8219b8e80941Smrg
8220b8e80941Smrg   case MESA_FORMAT_A8R8G8B8_UNORM:
8221b8e80941Smrg      for (i = 0; i < n; ++i) {
8222b8e80941Smrg         pack_ubyte_a8r8g8b8_unorm(src[i], d);
8223b8e80941Smrg         d += 4;
8224b8e80941Smrg      }
8225b8e80941Smrg      break;
8226b8e80941Smrg
8227b8e80941Smrg   case MESA_FORMAT_X8R8G8B8_UNORM:
8228b8e80941Smrg      for (i = 0; i < n; ++i) {
8229b8e80941Smrg         pack_ubyte_x8r8g8b8_unorm(src[i], d);
8230b8e80941Smrg         d += 4;
8231b8e80941Smrg      }
8232b8e80941Smrg      break;
8233b8e80941Smrg
8234b8e80941Smrg   case MESA_FORMAT_L16A16_UNORM:
8235b8e80941Smrg      for (i = 0; i < n; ++i) {
8236b8e80941Smrg         pack_ubyte_l16a16_unorm(src[i], d);
8237b8e80941Smrg         d += 4;
8238b8e80941Smrg      }
8239b8e80941Smrg      break;
8240b8e80941Smrg
8241b8e80941Smrg   case MESA_FORMAT_A16L16_UNORM:
8242b8e80941Smrg      for (i = 0; i < n; ++i) {
8243b8e80941Smrg         pack_ubyte_a16l16_unorm(src[i], d);
8244b8e80941Smrg         d += 4;
8245b8e80941Smrg      }
8246b8e80941Smrg      break;
8247b8e80941Smrg
8248b8e80941Smrg   case MESA_FORMAT_B5G6R5_UNORM:
8249b8e80941Smrg      for (i = 0; i < n; ++i) {
8250b8e80941Smrg         pack_ubyte_b5g6r5_unorm(src[i], d);
8251b8e80941Smrg         d += 2;
8252b8e80941Smrg      }
8253b8e80941Smrg      break;
8254b8e80941Smrg
8255b8e80941Smrg   case MESA_FORMAT_R5G6B5_UNORM:
8256b8e80941Smrg      for (i = 0; i < n; ++i) {
8257b8e80941Smrg         pack_ubyte_r5g6b5_unorm(src[i], d);
8258b8e80941Smrg         d += 2;
8259b8e80941Smrg      }
8260b8e80941Smrg      break;
8261b8e80941Smrg
8262b8e80941Smrg   case MESA_FORMAT_B4G4R4A4_UNORM:
8263b8e80941Smrg      for (i = 0; i < n; ++i) {
8264b8e80941Smrg         pack_ubyte_b4g4r4a4_unorm(src[i], d);
8265b8e80941Smrg         d += 2;
8266b8e80941Smrg      }
8267b8e80941Smrg      break;
8268b8e80941Smrg
8269b8e80941Smrg   case MESA_FORMAT_B4G4R4X4_UNORM:
8270b8e80941Smrg      for (i = 0; i < n; ++i) {
8271b8e80941Smrg         pack_ubyte_b4g4r4x4_unorm(src[i], d);
8272b8e80941Smrg         d += 2;
8273b8e80941Smrg      }
8274b8e80941Smrg      break;
8275b8e80941Smrg
8276b8e80941Smrg   case MESA_FORMAT_A4R4G4B4_UNORM:
8277b8e80941Smrg      for (i = 0; i < n; ++i) {
8278b8e80941Smrg         pack_ubyte_a4r4g4b4_unorm(src[i], d);
8279b8e80941Smrg         d += 2;
8280b8e80941Smrg      }
8281b8e80941Smrg      break;
8282b8e80941Smrg
8283b8e80941Smrg   case MESA_FORMAT_A1B5G5R5_UNORM:
8284b8e80941Smrg      for (i = 0; i < n; ++i) {
8285b8e80941Smrg         pack_ubyte_a1b5g5r5_unorm(src[i], d);
8286b8e80941Smrg         d += 2;
8287b8e80941Smrg      }
8288b8e80941Smrg      break;
8289b8e80941Smrg
8290b8e80941Smrg   case MESA_FORMAT_X1B5G5R5_UNORM:
8291b8e80941Smrg      for (i = 0; i < n; ++i) {
8292b8e80941Smrg         pack_ubyte_x1b5g5r5_unorm(src[i], d);
8293b8e80941Smrg         d += 2;
8294b8e80941Smrg      }
8295b8e80941Smrg      break;
8296b8e80941Smrg
8297b8e80941Smrg   case MESA_FORMAT_B5G5R5A1_UNORM:
8298b8e80941Smrg      for (i = 0; i < n; ++i) {
8299b8e80941Smrg         pack_ubyte_b5g5r5a1_unorm(src[i], d);
8300b8e80941Smrg         d += 2;
8301b8e80941Smrg      }
8302b8e80941Smrg      break;
8303b8e80941Smrg
8304b8e80941Smrg   case MESA_FORMAT_B5G5R5X1_UNORM:
8305b8e80941Smrg      for (i = 0; i < n; ++i) {
8306b8e80941Smrg         pack_ubyte_b5g5r5x1_unorm(src[i], d);
8307b8e80941Smrg         d += 2;
8308b8e80941Smrg      }
8309b8e80941Smrg      break;
8310b8e80941Smrg
8311b8e80941Smrg   case MESA_FORMAT_A1R5G5B5_UNORM:
8312b8e80941Smrg      for (i = 0; i < n; ++i) {
8313b8e80941Smrg         pack_ubyte_a1r5g5b5_unorm(src[i], d);
8314b8e80941Smrg         d += 2;
8315b8e80941Smrg      }
8316b8e80941Smrg      break;
8317b8e80941Smrg
8318b8e80941Smrg   case MESA_FORMAT_L8A8_UNORM:
8319b8e80941Smrg      for (i = 0; i < n; ++i) {
8320b8e80941Smrg         pack_ubyte_l8a8_unorm(src[i], d);
8321b8e80941Smrg         d += 2;
8322b8e80941Smrg      }
8323b8e80941Smrg      break;
8324b8e80941Smrg
8325b8e80941Smrg   case MESA_FORMAT_A8L8_UNORM:
8326b8e80941Smrg      for (i = 0; i < n; ++i) {
8327b8e80941Smrg         pack_ubyte_a8l8_unorm(src[i], d);
8328b8e80941Smrg         d += 2;
8329b8e80941Smrg      }
8330b8e80941Smrg      break;
8331b8e80941Smrg
8332b8e80941Smrg   case MESA_FORMAT_R8G8_UNORM:
8333b8e80941Smrg      for (i = 0; i < n; ++i) {
8334b8e80941Smrg         pack_ubyte_r8g8_unorm(src[i], d);
8335b8e80941Smrg         d += 2;
8336b8e80941Smrg      }
8337b8e80941Smrg      break;
8338b8e80941Smrg
8339b8e80941Smrg   case MESA_FORMAT_G8R8_UNORM:
8340b8e80941Smrg      for (i = 0; i < n; ++i) {
8341b8e80941Smrg         pack_ubyte_g8r8_unorm(src[i], d);
8342b8e80941Smrg         d += 2;
8343b8e80941Smrg      }
8344b8e80941Smrg      break;
8345b8e80941Smrg
8346b8e80941Smrg   case MESA_FORMAT_L4A4_UNORM:
8347b8e80941Smrg      for (i = 0; i < n; ++i) {
8348b8e80941Smrg         pack_ubyte_l4a4_unorm(src[i], d);
8349b8e80941Smrg         d += 1;
8350b8e80941Smrg      }
8351b8e80941Smrg      break;
8352b8e80941Smrg
8353b8e80941Smrg   case MESA_FORMAT_B2G3R3_UNORM:
8354b8e80941Smrg      for (i = 0; i < n; ++i) {
8355b8e80941Smrg         pack_ubyte_b2g3r3_unorm(src[i], d);
8356b8e80941Smrg         d += 1;
8357b8e80941Smrg      }
8358b8e80941Smrg      break;
8359b8e80941Smrg
8360b8e80941Smrg   case MESA_FORMAT_R16G16_UNORM:
8361b8e80941Smrg      for (i = 0; i < n; ++i) {
8362b8e80941Smrg         pack_ubyte_r16g16_unorm(src[i], d);
8363b8e80941Smrg         d += 4;
8364b8e80941Smrg      }
8365b8e80941Smrg      break;
8366b8e80941Smrg
8367b8e80941Smrg   case MESA_FORMAT_G16R16_UNORM:
8368b8e80941Smrg      for (i = 0; i < n; ++i) {
8369b8e80941Smrg         pack_ubyte_g16r16_unorm(src[i], d);
8370b8e80941Smrg         d += 4;
8371b8e80941Smrg      }
8372b8e80941Smrg      break;
8373b8e80941Smrg
8374b8e80941Smrg   case MESA_FORMAT_B10G10R10A2_UNORM:
8375b8e80941Smrg      for (i = 0; i < n; ++i) {
8376b8e80941Smrg         pack_ubyte_b10g10r10a2_unorm(src[i], d);
8377b8e80941Smrg         d += 4;
8378b8e80941Smrg      }
8379b8e80941Smrg      break;
8380b8e80941Smrg
8381b8e80941Smrg   case MESA_FORMAT_B10G10R10X2_UNORM:
8382b8e80941Smrg      for (i = 0; i < n; ++i) {
8383b8e80941Smrg         pack_ubyte_b10g10r10x2_unorm(src[i], d);
8384b8e80941Smrg         d += 4;
8385b8e80941Smrg      }
8386b8e80941Smrg      break;
8387b8e80941Smrg
8388b8e80941Smrg   case MESA_FORMAT_R10G10B10A2_UNORM:
8389b8e80941Smrg      for (i = 0; i < n; ++i) {
8390b8e80941Smrg         pack_ubyte_r10g10b10a2_unorm(src[i], d);
8391b8e80941Smrg         d += 4;
8392b8e80941Smrg      }
8393b8e80941Smrg      break;
8394b8e80941Smrg
8395b8e80941Smrg   case MESA_FORMAT_R10G10B10X2_UNORM:
8396b8e80941Smrg      for (i = 0; i < n; ++i) {
8397b8e80941Smrg         pack_ubyte_r10g10b10x2_unorm(src[i], d);
8398b8e80941Smrg         d += 4;
8399b8e80941Smrg      }
8400b8e80941Smrg      break;
8401b8e80941Smrg
8402b8e80941Smrg   case MESA_FORMAT_R3G3B2_UNORM:
8403b8e80941Smrg      for (i = 0; i < n; ++i) {
8404b8e80941Smrg         pack_ubyte_r3g3b2_unorm(src[i], d);
8405b8e80941Smrg         d += 1;
8406b8e80941Smrg      }
8407b8e80941Smrg      break;
8408b8e80941Smrg
8409b8e80941Smrg   case MESA_FORMAT_A4B4G4R4_UNORM:
8410b8e80941Smrg      for (i = 0; i < n; ++i) {
8411b8e80941Smrg         pack_ubyte_a4b4g4r4_unorm(src[i], d);
8412b8e80941Smrg         d += 2;
8413b8e80941Smrg      }
8414b8e80941Smrg      break;
8415b8e80941Smrg
8416b8e80941Smrg   case MESA_FORMAT_R4G4B4A4_UNORM:
8417b8e80941Smrg      for (i = 0; i < n; ++i) {
8418b8e80941Smrg         pack_ubyte_r4g4b4a4_unorm(src[i], d);
8419b8e80941Smrg         d += 2;
8420b8e80941Smrg      }
8421b8e80941Smrg      break;
8422b8e80941Smrg
8423b8e80941Smrg   case MESA_FORMAT_R5G5B5A1_UNORM:
8424b8e80941Smrg      for (i = 0; i < n; ++i) {
8425b8e80941Smrg         pack_ubyte_r5g5b5a1_unorm(src[i], d);
8426b8e80941Smrg         d += 2;
8427b8e80941Smrg      }
8428b8e80941Smrg      break;
8429b8e80941Smrg
8430b8e80941Smrg   case MESA_FORMAT_A2B10G10R10_UNORM:
8431b8e80941Smrg      for (i = 0; i < n; ++i) {
8432b8e80941Smrg         pack_ubyte_a2b10g10r10_unorm(src[i], d);
8433b8e80941Smrg         d += 4;
8434b8e80941Smrg      }
8435b8e80941Smrg      break;
8436b8e80941Smrg
8437b8e80941Smrg   case MESA_FORMAT_A2R10G10B10_UNORM:
8438b8e80941Smrg      for (i = 0; i < n; ++i) {
8439b8e80941Smrg         pack_ubyte_a2r10g10b10_unorm(src[i], d);
8440b8e80941Smrg         d += 4;
8441b8e80941Smrg      }
8442b8e80941Smrg      break;
8443b8e80941Smrg
8444b8e80941Smrg   case MESA_FORMAT_A_UNORM8:
8445b8e80941Smrg      for (i = 0; i < n; ++i) {
8446b8e80941Smrg         pack_ubyte_a_unorm8(src[i], d);
8447b8e80941Smrg         d += 1;
8448b8e80941Smrg      }
8449b8e80941Smrg      break;
8450b8e80941Smrg
8451b8e80941Smrg   case MESA_FORMAT_A_UNORM16:
8452b8e80941Smrg      for (i = 0; i < n; ++i) {
8453b8e80941Smrg         pack_ubyte_a_unorm16(src[i], d);
8454b8e80941Smrg         d += 2;
8455b8e80941Smrg      }
8456b8e80941Smrg      break;
8457b8e80941Smrg
8458b8e80941Smrg   case MESA_FORMAT_L_UNORM8:
8459b8e80941Smrg      for (i = 0; i < n; ++i) {
8460b8e80941Smrg         pack_ubyte_l_unorm8(src[i], d);
8461b8e80941Smrg         d += 1;
8462b8e80941Smrg      }
8463b8e80941Smrg      break;
8464b8e80941Smrg
8465b8e80941Smrg   case MESA_FORMAT_L_UNORM16:
8466b8e80941Smrg      for (i = 0; i < n; ++i) {
8467b8e80941Smrg         pack_ubyte_l_unorm16(src[i], d);
8468b8e80941Smrg         d += 2;
8469b8e80941Smrg      }
8470b8e80941Smrg      break;
8471b8e80941Smrg
8472b8e80941Smrg   case MESA_FORMAT_I_UNORM8:
8473b8e80941Smrg      for (i = 0; i < n; ++i) {
8474b8e80941Smrg         pack_ubyte_i_unorm8(src[i], d);
8475b8e80941Smrg         d += 1;
8476b8e80941Smrg      }
8477b8e80941Smrg      break;
8478b8e80941Smrg
8479b8e80941Smrg   case MESA_FORMAT_I_UNORM16:
8480b8e80941Smrg      for (i = 0; i < n; ++i) {
8481b8e80941Smrg         pack_ubyte_i_unorm16(src[i], d);
8482b8e80941Smrg         d += 2;
8483b8e80941Smrg      }
8484b8e80941Smrg      break;
8485b8e80941Smrg
8486b8e80941Smrg   case MESA_FORMAT_R_UNORM8:
8487b8e80941Smrg      for (i = 0; i < n; ++i) {
8488b8e80941Smrg         pack_ubyte_r_unorm8(src[i], d);
8489b8e80941Smrg         d += 1;
8490b8e80941Smrg      }
8491b8e80941Smrg      break;
8492b8e80941Smrg
8493b8e80941Smrg   case MESA_FORMAT_R_UNORM16:
8494b8e80941Smrg      for (i = 0; i < n; ++i) {
8495b8e80941Smrg         pack_ubyte_r_unorm16(src[i], d);
8496b8e80941Smrg         d += 2;
8497b8e80941Smrg      }
8498b8e80941Smrg      break;
8499b8e80941Smrg
8500b8e80941Smrg   case MESA_FORMAT_BGR_UNORM8:
8501b8e80941Smrg      for (i = 0; i < n; ++i) {
8502b8e80941Smrg         pack_ubyte_bgr_unorm8(src[i], d);
8503b8e80941Smrg         d += 3;
8504b8e80941Smrg      }
8505b8e80941Smrg      break;
8506b8e80941Smrg
8507b8e80941Smrg   case MESA_FORMAT_RGB_UNORM8:
8508b8e80941Smrg      for (i = 0; i < n; ++i) {
8509b8e80941Smrg         pack_ubyte_rgb_unorm8(src[i], d);
8510b8e80941Smrg         d += 3;
8511b8e80941Smrg      }
8512b8e80941Smrg      break;
8513b8e80941Smrg
8514b8e80941Smrg   case MESA_FORMAT_RGBA_UNORM16:
8515b8e80941Smrg      for (i = 0; i < n; ++i) {
8516b8e80941Smrg         pack_ubyte_rgba_unorm16(src[i], d);
8517b8e80941Smrg         d += 8;
8518b8e80941Smrg      }
8519b8e80941Smrg      break;
8520b8e80941Smrg
8521b8e80941Smrg   case MESA_FORMAT_RGBX_UNORM16:
8522b8e80941Smrg      for (i = 0; i < n; ++i) {
8523b8e80941Smrg         pack_ubyte_rgbx_unorm16(src[i], d);
8524b8e80941Smrg         d += 8;
8525b8e80941Smrg      }
8526b8e80941Smrg      break;
8527b8e80941Smrg
8528b8e80941Smrg   case MESA_FORMAT_A8B8G8R8_SNORM:
8529b8e80941Smrg      for (i = 0; i < n; ++i) {
8530b8e80941Smrg         pack_ubyte_a8b8g8r8_snorm(src[i], d);
8531b8e80941Smrg         d += 4;
8532b8e80941Smrg      }
8533b8e80941Smrg      break;
8534b8e80941Smrg
8535b8e80941Smrg   case MESA_FORMAT_X8B8G8R8_SNORM:
8536b8e80941Smrg      for (i = 0; i < n; ++i) {
8537b8e80941Smrg         pack_ubyte_x8b8g8r8_snorm(src[i], d);
8538b8e80941Smrg         d += 4;
8539b8e80941Smrg      }
8540b8e80941Smrg      break;
8541b8e80941Smrg
8542b8e80941Smrg   case MESA_FORMAT_R8G8B8A8_SNORM:
8543b8e80941Smrg      for (i = 0; i < n; ++i) {
8544b8e80941Smrg         pack_ubyte_r8g8b8a8_snorm(src[i], d);
8545b8e80941Smrg         d += 4;
8546b8e80941Smrg      }
8547b8e80941Smrg      break;
8548b8e80941Smrg
8549b8e80941Smrg   case MESA_FORMAT_R8G8B8X8_SNORM:
8550b8e80941Smrg      for (i = 0; i < n; ++i) {
8551b8e80941Smrg         pack_ubyte_r8g8b8x8_snorm(src[i], d);
8552b8e80941Smrg         d += 4;
8553b8e80941Smrg      }
8554b8e80941Smrg      break;
8555b8e80941Smrg
8556b8e80941Smrg   case MESA_FORMAT_R16G16_SNORM:
8557b8e80941Smrg      for (i = 0; i < n; ++i) {
8558b8e80941Smrg         pack_ubyte_r16g16_snorm(src[i], d);
8559b8e80941Smrg         d += 4;
8560b8e80941Smrg      }
8561b8e80941Smrg      break;
8562b8e80941Smrg
8563b8e80941Smrg   case MESA_FORMAT_G16R16_SNORM:
8564b8e80941Smrg      for (i = 0; i < n; ++i) {
8565b8e80941Smrg         pack_ubyte_g16r16_snorm(src[i], d);
8566b8e80941Smrg         d += 4;
8567b8e80941Smrg      }
8568b8e80941Smrg      break;
8569b8e80941Smrg
8570b8e80941Smrg   case MESA_FORMAT_R8G8_SNORM:
8571b8e80941Smrg      for (i = 0; i < n; ++i) {
8572b8e80941Smrg         pack_ubyte_r8g8_snorm(src[i], d);
8573b8e80941Smrg         d += 2;
8574b8e80941Smrg      }
8575b8e80941Smrg      break;
8576b8e80941Smrg
8577b8e80941Smrg   case MESA_FORMAT_G8R8_SNORM:
8578b8e80941Smrg      for (i = 0; i < n; ++i) {
8579b8e80941Smrg         pack_ubyte_g8r8_snorm(src[i], d);
8580b8e80941Smrg         d += 2;
8581b8e80941Smrg      }
8582b8e80941Smrg      break;
8583b8e80941Smrg
8584b8e80941Smrg   case MESA_FORMAT_L8A8_SNORM:
8585b8e80941Smrg      for (i = 0; i < n; ++i) {
8586b8e80941Smrg         pack_ubyte_l8a8_snorm(src[i], d);
8587b8e80941Smrg         d += 2;
8588b8e80941Smrg      }
8589b8e80941Smrg      break;
8590b8e80941Smrg
8591b8e80941Smrg   case MESA_FORMAT_A8L8_SNORM:
8592b8e80941Smrg      for (i = 0; i < n; ++i) {
8593b8e80941Smrg         pack_ubyte_a8l8_snorm(src[i], d);
8594b8e80941Smrg         d += 2;
8595b8e80941Smrg      }
8596b8e80941Smrg      break;
8597b8e80941Smrg
8598b8e80941Smrg   case MESA_FORMAT_A_SNORM8:
8599b8e80941Smrg      for (i = 0; i < n; ++i) {
8600b8e80941Smrg         pack_ubyte_a_snorm8(src[i], d);
8601b8e80941Smrg         d += 1;
8602b8e80941Smrg      }
8603b8e80941Smrg      break;
8604b8e80941Smrg
8605b8e80941Smrg   case MESA_FORMAT_A_SNORM16:
8606b8e80941Smrg      for (i = 0; i < n; ++i) {
8607b8e80941Smrg         pack_ubyte_a_snorm16(src[i], d);
8608b8e80941Smrg         d += 2;
8609b8e80941Smrg      }
8610b8e80941Smrg      break;
8611b8e80941Smrg
8612b8e80941Smrg   case MESA_FORMAT_L_SNORM8:
8613b8e80941Smrg      for (i = 0; i < n; ++i) {
8614b8e80941Smrg         pack_ubyte_l_snorm8(src[i], d);
8615b8e80941Smrg         d += 1;
8616b8e80941Smrg      }
8617b8e80941Smrg      break;
8618b8e80941Smrg
8619b8e80941Smrg   case MESA_FORMAT_L_SNORM16:
8620b8e80941Smrg      for (i = 0; i < n; ++i) {
8621b8e80941Smrg         pack_ubyte_l_snorm16(src[i], d);
8622b8e80941Smrg         d += 2;
8623b8e80941Smrg      }
8624b8e80941Smrg      break;
8625b8e80941Smrg
8626b8e80941Smrg   case MESA_FORMAT_I_SNORM8:
8627b8e80941Smrg      for (i = 0; i < n; ++i) {
8628b8e80941Smrg         pack_ubyte_i_snorm8(src[i], d);
8629b8e80941Smrg         d += 1;
8630b8e80941Smrg      }
8631b8e80941Smrg      break;
8632b8e80941Smrg
8633b8e80941Smrg   case MESA_FORMAT_I_SNORM16:
8634b8e80941Smrg      for (i = 0; i < n; ++i) {
8635b8e80941Smrg         pack_ubyte_i_snorm16(src[i], d);
8636b8e80941Smrg         d += 2;
8637b8e80941Smrg      }
8638b8e80941Smrg      break;
8639b8e80941Smrg
8640b8e80941Smrg   case MESA_FORMAT_R_SNORM8:
8641b8e80941Smrg      for (i = 0; i < n; ++i) {
8642b8e80941Smrg         pack_ubyte_r_snorm8(src[i], d);
8643b8e80941Smrg         d += 1;
8644b8e80941Smrg      }
8645b8e80941Smrg      break;
8646b8e80941Smrg
8647b8e80941Smrg   case MESA_FORMAT_R_SNORM16:
8648b8e80941Smrg      for (i = 0; i < n; ++i) {
8649b8e80941Smrg         pack_ubyte_r_snorm16(src[i], d);
8650b8e80941Smrg         d += 2;
8651b8e80941Smrg      }
8652b8e80941Smrg      break;
8653b8e80941Smrg
8654b8e80941Smrg   case MESA_FORMAT_LA_SNORM16:
8655b8e80941Smrg      for (i = 0; i < n; ++i) {
8656b8e80941Smrg         pack_ubyte_la_snorm16(src[i], d);
8657b8e80941Smrg         d += 4;
8658b8e80941Smrg      }
8659b8e80941Smrg      break;
8660b8e80941Smrg
8661b8e80941Smrg   case MESA_FORMAT_RGB_SNORM16:
8662b8e80941Smrg      for (i = 0; i < n; ++i) {
8663b8e80941Smrg         pack_ubyte_rgb_snorm16(src[i], d);
8664b8e80941Smrg         d += 6;
8665b8e80941Smrg      }
8666b8e80941Smrg      break;
8667b8e80941Smrg
8668b8e80941Smrg   case MESA_FORMAT_RGBA_SNORM16:
8669b8e80941Smrg      for (i = 0; i < n; ++i) {
8670b8e80941Smrg         pack_ubyte_rgba_snorm16(src[i], d);
8671b8e80941Smrg         d += 8;
8672b8e80941Smrg      }
8673b8e80941Smrg      break;
8674b8e80941Smrg
8675b8e80941Smrg   case MESA_FORMAT_RGBX_SNORM16:
8676b8e80941Smrg      for (i = 0; i < n; ++i) {
8677b8e80941Smrg         pack_ubyte_rgbx_snorm16(src[i], d);
8678b8e80941Smrg         d += 8;
8679b8e80941Smrg      }
8680b8e80941Smrg      break;
8681b8e80941Smrg
8682b8e80941Smrg   case MESA_FORMAT_A8B8G8R8_SRGB:
8683b8e80941Smrg      for (i = 0; i < n; ++i) {
8684b8e80941Smrg         pack_ubyte_a8b8g8r8_srgb(src[i], d);
8685b8e80941Smrg         d += 4;
8686b8e80941Smrg      }
8687b8e80941Smrg      break;
8688b8e80941Smrg
8689b8e80941Smrg   case MESA_FORMAT_B8G8R8A8_SRGB:
8690b8e80941Smrg      for (i = 0; i < n; ++i) {
8691b8e80941Smrg         pack_ubyte_b8g8r8a8_srgb(src[i], d);
8692b8e80941Smrg         d += 4;
8693b8e80941Smrg      }
8694b8e80941Smrg      break;
8695b8e80941Smrg
8696b8e80941Smrg   case MESA_FORMAT_A8R8G8B8_SRGB:
8697b8e80941Smrg      for (i = 0; i < n; ++i) {
8698b8e80941Smrg         pack_ubyte_a8r8g8b8_srgb(src[i], d);
8699b8e80941Smrg         d += 4;
8700b8e80941Smrg      }
8701b8e80941Smrg      break;
8702b8e80941Smrg
8703b8e80941Smrg   case MESA_FORMAT_B8G8R8X8_SRGB:
8704b8e80941Smrg      for (i = 0; i < n; ++i) {
8705b8e80941Smrg         pack_ubyte_b8g8r8x8_srgb(src[i], d);
8706b8e80941Smrg         d += 4;
8707b8e80941Smrg      }
8708b8e80941Smrg      break;
8709b8e80941Smrg
8710b8e80941Smrg   case MESA_FORMAT_X8R8G8B8_SRGB:
8711b8e80941Smrg      for (i = 0; i < n; ++i) {
8712b8e80941Smrg         pack_ubyte_x8r8g8b8_srgb(src[i], d);
8713b8e80941Smrg         d += 4;
8714b8e80941Smrg      }
8715b8e80941Smrg      break;
8716b8e80941Smrg
8717b8e80941Smrg   case MESA_FORMAT_R8G8B8A8_SRGB:
8718b8e80941Smrg      for (i = 0; i < n; ++i) {
8719b8e80941Smrg         pack_ubyte_r8g8b8a8_srgb(src[i], d);
8720b8e80941Smrg         d += 4;
8721b8e80941Smrg      }
8722b8e80941Smrg      break;
8723b8e80941Smrg
8724b8e80941Smrg   case MESA_FORMAT_R8G8B8X8_SRGB:
8725b8e80941Smrg      for (i = 0; i < n; ++i) {
8726b8e80941Smrg         pack_ubyte_r8g8b8x8_srgb(src[i], d);
8727b8e80941Smrg         d += 4;
8728b8e80941Smrg      }
8729b8e80941Smrg      break;
8730b8e80941Smrg
8731b8e80941Smrg   case MESA_FORMAT_X8B8G8R8_SRGB:
8732b8e80941Smrg      for (i = 0; i < n; ++i) {
8733b8e80941Smrg         pack_ubyte_x8b8g8r8_srgb(src[i], d);
8734b8e80941Smrg         d += 4;
8735b8e80941Smrg      }
8736b8e80941Smrg      break;
8737b8e80941Smrg
8738b8e80941Smrg   case MESA_FORMAT_L8A8_SRGB:
8739b8e80941Smrg      for (i = 0; i < n; ++i) {
8740b8e80941Smrg         pack_ubyte_l8a8_srgb(src[i], d);
8741b8e80941Smrg         d += 2;
8742b8e80941Smrg      }
8743b8e80941Smrg      break;
8744b8e80941Smrg
8745b8e80941Smrg   case MESA_FORMAT_A8L8_SRGB:
8746b8e80941Smrg      for (i = 0; i < n; ++i) {
8747b8e80941Smrg         pack_ubyte_a8l8_srgb(src[i], d);
8748b8e80941Smrg         d += 2;
8749b8e80941Smrg      }
8750b8e80941Smrg      break;
8751b8e80941Smrg
8752b8e80941Smrg   case MESA_FORMAT_R_SRGB8:
8753b8e80941Smrg      for (i = 0; i < n; ++i) {
8754b8e80941Smrg         pack_ubyte_r_srgb8(src[i], d);
8755b8e80941Smrg         d += 1;
8756b8e80941Smrg      }
8757b8e80941Smrg      break;
8758b8e80941Smrg
8759b8e80941Smrg   case MESA_FORMAT_L_SRGB8:
8760b8e80941Smrg      for (i = 0; i < n; ++i) {
8761b8e80941Smrg         pack_ubyte_l_srgb8(src[i], d);
8762b8e80941Smrg         d += 1;
8763b8e80941Smrg      }
8764b8e80941Smrg      break;
8765b8e80941Smrg
8766b8e80941Smrg   case MESA_FORMAT_BGR_SRGB8:
8767b8e80941Smrg      for (i = 0; i < n; ++i) {
8768b8e80941Smrg         pack_ubyte_bgr_srgb8(src[i], d);
8769b8e80941Smrg         d += 3;
8770b8e80941Smrg      }
8771b8e80941Smrg      break;
8772b8e80941Smrg
8773b8e80941Smrg   case MESA_FORMAT_R9G9B9E5_FLOAT:
8774b8e80941Smrg      for (i = 0; i < n; ++i) {
8775b8e80941Smrg         pack_ubyte_r9g9b9e5_float(src[i], d);
8776b8e80941Smrg         d += 4;
8777b8e80941Smrg      }
8778b8e80941Smrg      break;
8779b8e80941Smrg
8780b8e80941Smrg   case MESA_FORMAT_R11G11B10_FLOAT:
8781b8e80941Smrg      for (i = 0; i < n; ++i) {
8782b8e80941Smrg         pack_ubyte_r11g11b10_float(src[i], d);
8783b8e80941Smrg         d += 4;
8784b8e80941Smrg      }
8785b8e80941Smrg      break;
8786b8e80941Smrg
8787b8e80941Smrg   case MESA_FORMAT_A_FLOAT16:
8788b8e80941Smrg      for (i = 0; i < n; ++i) {
8789b8e80941Smrg         pack_ubyte_a_float16(src[i], d);
8790b8e80941Smrg         d += 2;
8791b8e80941Smrg      }
8792b8e80941Smrg      break;
8793b8e80941Smrg
8794b8e80941Smrg   case MESA_FORMAT_A_FLOAT32:
8795b8e80941Smrg      for (i = 0; i < n; ++i) {
8796b8e80941Smrg         pack_ubyte_a_float32(src[i], d);
8797b8e80941Smrg         d += 4;
8798b8e80941Smrg      }
8799b8e80941Smrg      break;
8800b8e80941Smrg
8801b8e80941Smrg   case MESA_FORMAT_L_FLOAT16:
8802b8e80941Smrg      for (i = 0; i < n; ++i) {
8803b8e80941Smrg         pack_ubyte_l_float16(src[i], d);
8804b8e80941Smrg         d += 2;
8805b8e80941Smrg      }
8806b8e80941Smrg      break;
8807b8e80941Smrg
8808b8e80941Smrg   case MESA_FORMAT_L_FLOAT32:
8809b8e80941Smrg      for (i = 0; i < n; ++i) {
8810b8e80941Smrg         pack_ubyte_l_float32(src[i], d);
8811b8e80941Smrg         d += 4;
8812b8e80941Smrg      }
8813b8e80941Smrg      break;
8814b8e80941Smrg
8815b8e80941Smrg   case MESA_FORMAT_LA_FLOAT16:
8816b8e80941Smrg      for (i = 0; i < n; ++i) {
8817b8e80941Smrg         pack_ubyte_la_float16(src[i], d);
8818b8e80941Smrg         d += 4;
8819b8e80941Smrg      }
8820b8e80941Smrg      break;
8821b8e80941Smrg
8822b8e80941Smrg   case MESA_FORMAT_LA_FLOAT32:
8823b8e80941Smrg      for (i = 0; i < n; ++i) {
8824b8e80941Smrg         pack_ubyte_la_float32(src[i], d);
8825b8e80941Smrg         d += 8;
8826b8e80941Smrg      }
8827b8e80941Smrg      break;
8828b8e80941Smrg
8829b8e80941Smrg   case MESA_FORMAT_I_FLOAT16:
8830b8e80941Smrg      for (i = 0; i < n; ++i) {
8831b8e80941Smrg         pack_ubyte_i_float16(src[i], d);
8832b8e80941Smrg         d += 2;
8833b8e80941Smrg      }
8834b8e80941Smrg      break;
8835b8e80941Smrg
8836b8e80941Smrg   case MESA_FORMAT_I_FLOAT32:
8837b8e80941Smrg      for (i = 0; i < n; ++i) {
8838b8e80941Smrg         pack_ubyte_i_float32(src[i], d);
8839b8e80941Smrg         d += 4;
8840b8e80941Smrg      }
8841b8e80941Smrg      break;
8842b8e80941Smrg
8843b8e80941Smrg   case MESA_FORMAT_R_FLOAT16:
8844b8e80941Smrg      for (i = 0; i < n; ++i) {
8845b8e80941Smrg         pack_ubyte_r_float16(src[i], d);
8846b8e80941Smrg         d += 2;
8847b8e80941Smrg      }
8848b8e80941Smrg      break;
8849b8e80941Smrg
8850b8e80941Smrg   case MESA_FORMAT_R_FLOAT32:
8851b8e80941Smrg      for (i = 0; i < n; ++i) {
8852b8e80941Smrg         pack_ubyte_r_float32(src[i], d);
8853b8e80941Smrg         d += 4;
8854b8e80941Smrg      }
8855b8e80941Smrg      break;
8856b8e80941Smrg
8857b8e80941Smrg   case MESA_FORMAT_RG_FLOAT16:
8858b8e80941Smrg      for (i = 0; i < n; ++i) {
8859b8e80941Smrg         pack_ubyte_rg_float16(src[i], d);
8860b8e80941Smrg         d += 4;
8861b8e80941Smrg      }
8862b8e80941Smrg      break;
8863b8e80941Smrg
8864b8e80941Smrg   case MESA_FORMAT_RG_FLOAT32:
8865b8e80941Smrg      for (i = 0; i < n; ++i) {
8866b8e80941Smrg         pack_ubyte_rg_float32(src[i], d);
8867b8e80941Smrg         d += 8;
8868b8e80941Smrg      }
8869b8e80941Smrg      break;
8870b8e80941Smrg
8871b8e80941Smrg   case MESA_FORMAT_RGB_FLOAT16:
8872b8e80941Smrg      for (i = 0; i < n; ++i) {
8873b8e80941Smrg         pack_ubyte_rgb_float16(src[i], d);
8874b8e80941Smrg         d += 6;
8875b8e80941Smrg      }
8876b8e80941Smrg      break;
8877b8e80941Smrg
8878b8e80941Smrg   case MESA_FORMAT_RGB_FLOAT32:
8879b8e80941Smrg      for (i = 0; i < n; ++i) {
8880b8e80941Smrg         pack_ubyte_rgb_float32(src[i], d);
8881b8e80941Smrg         d += 12;
8882b8e80941Smrg      }
8883b8e80941Smrg      break;
8884b8e80941Smrg
8885b8e80941Smrg   case MESA_FORMAT_RGBA_FLOAT16:
8886b8e80941Smrg      for (i = 0; i < n; ++i) {
8887b8e80941Smrg         pack_ubyte_rgba_float16(src[i], d);
8888b8e80941Smrg         d += 8;
8889b8e80941Smrg      }
8890b8e80941Smrg      break;
8891b8e80941Smrg
8892b8e80941Smrg   case MESA_FORMAT_RGBA_FLOAT32:
8893b8e80941Smrg      for (i = 0; i < n; ++i) {
8894b8e80941Smrg         pack_ubyte_rgba_float32(src[i], d);
8895b8e80941Smrg         d += 16;
8896b8e80941Smrg      }
8897b8e80941Smrg      break;
8898b8e80941Smrg
8899b8e80941Smrg   case MESA_FORMAT_RGBX_FLOAT16:
8900b8e80941Smrg      for (i = 0; i < n; ++i) {
8901b8e80941Smrg         pack_ubyte_rgbx_float16(src[i], d);
8902b8e80941Smrg         d += 8;
8903b8e80941Smrg      }
8904b8e80941Smrg      break;
8905b8e80941Smrg
8906b8e80941Smrg   case MESA_FORMAT_RGBX_FLOAT32:
8907b8e80941Smrg      for (i = 0; i < n; ++i) {
8908b8e80941Smrg         pack_ubyte_rgbx_float32(src[i], d);
8909b8e80941Smrg         d += 16;
8910b8e80941Smrg      }
8911b8e80941Smrg      break;
8912b8e80941Smrg
8913b8e80941Smrg   case MESA_FORMAT_A8B8G8R8_UINT:
8914b8e80941Smrg      for (i = 0; i < n; ++i) {
8915b8e80941Smrg         pack_ubyte_a8b8g8r8_uint(src[i], d);
8916b8e80941Smrg         d += 4;
8917b8e80941Smrg      }
8918b8e80941Smrg      break;
8919b8e80941Smrg
8920b8e80941Smrg   case MESA_FORMAT_A8R8G8B8_UINT:
8921b8e80941Smrg      for (i = 0; i < n; ++i) {
8922b8e80941Smrg         pack_ubyte_a8r8g8b8_uint(src[i], d);
8923b8e80941Smrg         d += 4;
8924b8e80941Smrg      }
8925b8e80941Smrg      break;
8926b8e80941Smrg
8927b8e80941Smrg   case MESA_FORMAT_R8G8B8A8_UINT:
8928b8e80941Smrg      for (i = 0; i < n; ++i) {
8929b8e80941Smrg         pack_ubyte_r8g8b8a8_uint(src[i], d);
8930b8e80941Smrg         d += 4;
8931b8e80941Smrg      }
8932b8e80941Smrg      break;
8933b8e80941Smrg
8934b8e80941Smrg   case MESA_FORMAT_B8G8R8A8_UINT:
8935b8e80941Smrg      for (i = 0; i < n; ++i) {
8936b8e80941Smrg         pack_ubyte_b8g8r8a8_uint(src[i], d);
8937b8e80941Smrg         d += 4;
8938b8e80941Smrg      }
8939b8e80941Smrg      break;
8940b8e80941Smrg
8941b8e80941Smrg   case MESA_FORMAT_B10G10R10A2_UINT:
8942b8e80941Smrg      for (i = 0; i < n; ++i) {
8943b8e80941Smrg         pack_ubyte_b10g10r10a2_uint(src[i], d);
8944b8e80941Smrg         d += 4;
8945b8e80941Smrg      }
8946b8e80941Smrg      break;
8947b8e80941Smrg
8948b8e80941Smrg   case MESA_FORMAT_R10G10B10A2_UINT:
8949b8e80941Smrg      for (i = 0; i < n; ++i) {
8950b8e80941Smrg         pack_ubyte_r10g10b10a2_uint(src[i], d);
8951b8e80941Smrg         d += 4;
8952b8e80941Smrg      }
8953b8e80941Smrg      break;
8954b8e80941Smrg
8955b8e80941Smrg   case MESA_FORMAT_A2B10G10R10_UINT:
8956b8e80941Smrg      for (i = 0; i < n; ++i) {
8957b8e80941Smrg         pack_ubyte_a2b10g10r10_uint(src[i], d);
8958b8e80941Smrg         d += 4;
8959b8e80941Smrg      }
8960b8e80941Smrg      break;
8961b8e80941Smrg
8962b8e80941Smrg   case MESA_FORMAT_A2R10G10B10_UINT:
8963b8e80941Smrg      for (i = 0; i < n; ++i) {
8964b8e80941Smrg         pack_ubyte_a2r10g10b10_uint(src[i], d);
8965b8e80941Smrg         d += 4;
8966b8e80941Smrg      }
8967b8e80941Smrg      break;
8968b8e80941Smrg
8969b8e80941Smrg   case MESA_FORMAT_B5G6R5_UINT:
8970b8e80941Smrg      for (i = 0; i < n; ++i) {
8971b8e80941Smrg         pack_ubyte_b5g6r5_uint(src[i], d);
8972b8e80941Smrg         d += 2;
8973b8e80941Smrg      }
8974b8e80941Smrg      break;
8975b8e80941Smrg
8976b8e80941Smrg   case MESA_FORMAT_R5G6B5_UINT:
8977b8e80941Smrg      for (i = 0; i < n; ++i) {
8978b8e80941Smrg         pack_ubyte_r5g6b5_uint(src[i], d);
8979b8e80941Smrg         d += 2;
8980b8e80941Smrg      }
8981b8e80941Smrg      break;
8982b8e80941Smrg
8983b8e80941Smrg   case MESA_FORMAT_B2G3R3_UINT:
8984b8e80941Smrg      for (i = 0; i < n; ++i) {
8985b8e80941Smrg         pack_ubyte_b2g3r3_uint(src[i], d);
8986b8e80941Smrg         d += 1;
8987b8e80941Smrg      }
8988b8e80941Smrg      break;
8989b8e80941Smrg
8990b8e80941Smrg   case MESA_FORMAT_R3G3B2_UINT:
8991b8e80941Smrg      for (i = 0; i < n; ++i) {
8992b8e80941Smrg         pack_ubyte_r3g3b2_uint(src[i], d);
8993b8e80941Smrg         d += 1;
8994b8e80941Smrg      }
8995b8e80941Smrg      break;
8996b8e80941Smrg
8997b8e80941Smrg   case MESA_FORMAT_A4B4G4R4_UINT:
8998b8e80941Smrg      for (i = 0; i < n; ++i) {
8999b8e80941Smrg         pack_ubyte_a4b4g4r4_uint(src[i], d);
9000b8e80941Smrg         d += 2;
9001b8e80941Smrg      }
9002b8e80941Smrg      break;
9003b8e80941Smrg
9004b8e80941Smrg   case MESA_FORMAT_R4G4B4A4_UINT:
9005b8e80941Smrg      for (i = 0; i < n; ++i) {
9006b8e80941Smrg         pack_ubyte_r4g4b4a4_uint(src[i], d);
9007b8e80941Smrg         d += 2;
9008b8e80941Smrg      }
9009b8e80941Smrg      break;
9010b8e80941Smrg
9011b8e80941Smrg   case MESA_FORMAT_B4G4R4A4_UINT:
9012b8e80941Smrg      for (i = 0; i < n; ++i) {
9013b8e80941Smrg         pack_ubyte_b4g4r4a4_uint(src[i], d);
9014b8e80941Smrg         d += 2;
9015b8e80941Smrg      }
9016b8e80941Smrg      break;
9017b8e80941Smrg
9018b8e80941Smrg   case MESA_FORMAT_A4R4G4B4_UINT:
9019b8e80941Smrg      for (i = 0; i < n; ++i) {
9020b8e80941Smrg         pack_ubyte_a4r4g4b4_uint(src[i], d);
9021b8e80941Smrg         d += 2;
9022b8e80941Smrg      }
9023b8e80941Smrg      break;
9024b8e80941Smrg
9025b8e80941Smrg   case MESA_FORMAT_A1B5G5R5_UINT:
9026b8e80941Smrg      for (i = 0; i < n; ++i) {
9027b8e80941Smrg         pack_ubyte_a1b5g5r5_uint(src[i], d);
9028b8e80941Smrg         d += 2;
9029b8e80941Smrg      }
9030b8e80941Smrg      break;
9031b8e80941Smrg
9032b8e80941Smrg   case MESA_FORMAT_B5G5R5A1_UINT:
9033b8e80941Smrg      for (i = 0; i < n; ++i) {
9034b8e80941Smrg         pack_ubyte_b5g5r5a1_uint(src[i], d);
9035b8e80941Smrg         d += 2;
9036b8e80941Smrg      }
9037b8e80941Smrg      break;
9038b8e80941Smrg
9039b8e80941Smrg   case MESA_FORMAT_A1R5G5B5_UINT:
9040b8e80941Smrg      for (i = 0; i < n; ++i) {
9041b8e80941Smrg         pack_ubyte_a1r5g5b5_uint(src[i], d);
9042b8e80941Smrg         d += 2;
9043b8e80941Smrg      }
9044b8e80941Smrg      break;
9045b8e80941Smrg
9046b8e80941Smrg   case MESA_FORMAT_R5G5B5A1_UINT:
9047b8e80941Smrg      for (i = 0; i < n; ++i) {
9048b8e80941Smrg         pack_ubyte_r5g5b5a1_uint(src[i], d);
9049b8e80941Smrg         d += 2;
9050b8e80941Smrg      }
9051b8e80941Smrg      break;
9052b8e80941Smrg
9053b8e80941Smrg   case MESA_FORMAT_A_UINT8:
9054b8e80941Smrg      for (i = 0; i < n; ++i) {
9055b8e80941Smrg         pack_ubyte_a_uint8(src[i], d);
9056b8e80941Smrg         d += 1;
9057b8e80941Smrg      }
9058b8e80941Smrg      break;
9059b8e80941Smrg
9060b8e80941Smrg   case MESA_FORMAT_A_UINT16:
9061b8e80941Smrg      for (i = 0; i < n; ++i) {
9062b8e80941Smrg         pack_ubyte_a_uint16(src[i], d);
9063b8e80941Smrg         d += 2;
9064b8e80941Smrg      }
9065b8e80941Smrg      break;
9066b8e80941Smrg
9067b8e80941Smrg   case MESA_FORMAT_A_UINT32:
9068b8e80941Smrg      for (i = 0; i < n; ++i) {
9069b8e80941Smrg         pack_ubyte_a_uint32(src[i], d);
9070b8e80941Smrg         d += 4;
9071b8e80941Smrg      }
9072b8e80941Smrg      break;
9073b8e80941Smrg
9074b8e80941Smrg   case MESA_FORMAT_A_SINT8:
9075b8e80941Smrg      for (i = 0; i < n; ++i) {
9076b8e80941Smrg         pack_ubyte_a_sint8(src[i], d);
9077b8e80941Smrg         d += 1;
9078b8e80941Smrg      }
9079b8e80941Smrg      break;
9080b8e80941Smrg
9081b8e80941Smrg   case MESA_FORMAT_A_SINT16:
9082b8e80941Smrg      for (i = 0; i < n; ++i) {
9083b8e80941Smrg         pack_ubyte_a_sint16(src[i], d);
9084b8e80941Smrg         d += 2;
9085b8e80941Smrg      }
9086b8e80941Smrg      break;
9087b8e80941Smrg
9088b8e80941Smrg   case MESA_FORMAT_A_SINT32:
9089b8e80941Smrg      for (i = 0; i < n; ++i) {
9090b8e80941Smrg         pack_ubyte_a_sint32(src[i], d);
9091b8e80941Smrg         d += 4;
9092b8e80941Smrg      }
9093b8e80941Smrg      break;
9094b8e80941Smrg
9095b8e80941Smrg   case MESA_FORMAT_I_UINT8:
9096b8e80941Smrg      for (i = 0; i < n; ++i) {
9097b8e80941Smrg         pack_ubyte_i_uint8(src[i], d);
9098b8e80941Smrg         d += 1;
9099b8e80941Smrg      }
9100b8e80941Smrg      break;
9101b8e80941Smrg
9102b8e80941Smrg   case MESA_FORMAT_I_UINT16:
9103b8e80941Smrg      for (i = 0; i < n; ++i) {
9104b8e80941Smrg         pack_ubyte_i_uint16(src[i], d);
9105b8e80941Smrg         d += 2;
9106b8e80941Smrg      }
9107b8e80941Smrg      break;
9108b8e80941Smrg
9109b8e80941Smrg   case MESA_FORMAT_I_UINT32:
9110b8e80941Smrg      for (i = 0; i < n; ++i) {
9111b8e80941Smrg         pack_ubyte_i_uint32(src[i], d);
9112b8e80941Smrg         d += 4;
9113b8e80941Smrg      }
9114b8e80941Smrg      break;
9115b8e80941Smrg
9116b8e80941Smrg   case MESA_FORMAT_I_SINT8:
9117b8e80941Smrg      for (i = 0; i < n; ++i) {
9118b8e80941Smrg         pack_ubyte_i_sint8(src[i], d);
9119b8e80941Smrg         d += 1;
9120b8e80941Smrg      }
9121b8e80941Smrg      break;
9122b8e80941Smrg
9123b8e80941Smrg   case MESA_FORMAT_I_SINT16:
9124b8e80941Smrg      for (i = 0; i < n; ++i) {
9125b8e80941Smrg         pack_ubyte_i_sint16(src[i], d);
9126b8e80941Smrg         d += 2;
9127b8e80941Smrg      }
9128b8e80941Smrg      break;
9129b8e80941Smrg
9130b8e80941Smrg   case MESA_FORMAT_I_SINT32:
9131b8e80941Smrg      for (i = 0; i < n; ++i) {
9132b8e80941Smrg         pack_ubyte_i_sint32(src[i], d);
9133b8e80941Smrg         d += 4;
9134b8e80941Smrg      }
9135b8e80941Smrg      break;
9136b8e80941Smrg
9137b8e80941Smrg   case MESA_FORMAT_L_UINT8:
9138b8e80941Smrg      for (i = 0; i < n; ++i) {
9139b8e80941Smrg         pack_ubyte_l_uint8(src[i], d);
9140b8e80941Smrg         d += 1;
9141b8e80941Smrg      }
9142b8e80941Smrg      break;
9143b8e80941Smrg
9144b8e80941Smrg   case MESA_FORMAT_L_UINT16:
9145b8e80941Smrg      for (i = 0; i < n; ++i) {
9146b8e80941Smrg         pack_ubyte_l_uint16(src[i], d);
9147b8e80941Smrg         d += 2;
9148b8e80941Smrg      }
9149b8e80941Smrg      break;
9150b8e80941Smrg
9151b8e80941Smrg   case MESA_FORMAT_L_UINT32:
9152b8e80941Smrg      for (i = 0; i < n; ++i) {
9153b8e80941Smrg         pack_ubyte_l_uint32(src[i], d);
9154b8e80941Smrg         d += 4;
9155b8e80941Smrg      }
9156b8e80941Smrg      break;
9157b8e80941Smrg
9158b8e80941Smrg   case MESA_FORMAT_L_SINT8:
9159b8e80941Smrg      for (i = 0; i < n; ++i) {
9160b8e80941Smrg         pack_ubyte_l_sint8(src[i], d);
9161b8e80941Smrg         d += 1;
9162b8e80941Smrg      }
9163b8e80941Smrg      break;
9164b8e80941Smrg
9165b8e80941Smrg   case MESA_FORMAT_L_SINT16:
9166b8e80941Smrg      for (i = 0; i < n; ++i) {
9167b8e80941Smrg         pack_ubyte_l_sint16(src[i], d);
9168b8e80941Smrg         d += 2;
9169b8e80941Smrg      }
9170b8e80941Smrg      break;
9171b8e80941Smrg
9172b8e80941Smrg   case MESA_FORMAT_L_SINT32:
9173b8e80941Smrg      for (i = 0; i < n; ++i) {
9174b8e80941Smrg         pack_ubyte_l_sint32(src[i], d);
9175b8e80941Smrg         d += 4;
9176b8e80941Smrg      }
9177b8e80941Smrg      break;
9178b8e80941Smrg
9179b8e80941Smrg   case MESA_FORMAT_LA_UINT8:
9180b8e80941Smrg      for (i = 0; i < n; ++i) {
9181b8e80941Smrg         pack_ubyte_la_uint8(src[i], d);
9182b8e80941Smrg         d += 2;
9183b8e80941Smrg      }
9184b8e80941Smrg      break;
9185b8e80941Smrg
9186b8e80941Smrg   case MESA_FORMAT_LA_UINT16:
9187b8e80941Smrg      for (i = 0; i < n; ++i) {
9188b8e80941Smrg         pack_ubyte_la_uint16(src[i], d);
9189b8e80941Smrg         d += 4;
9190b8e80941Smrg      }
9191b8e80941Smrg      break;
9192b8e80941Smrg
9193b8e80941Smrg   case MESA_FORMAT_LA_UINT32:
9194b8e80941Smrg      for (i = 0; i < n; ++i) {
9195b8e80941Smrg         pack_ubyte_la_uint32(src[i], d);
9196b8e80941Smrg         d += 8;
9197b8e80941Smrg      }
9198b8e80941Smrg      break;
9199b8e80941Smrg
9200b8e80941Smrg   case MESA_FORMAT_LA_SINT8:
9201b8e80941Smrg      for (i = 0; i < n; ++i) {
9202b8e80941Smrg         pack_ubyte_la_sint8(src[i], d);
9203b8e80941Smrg         d += 2;
9204b8e80941Smrg      }
9205b8e80941Smrg      break;
9206b8e80941Smrg
9207b8e80941Smrg   case MESA_FORMAT_LA_SINT16:
9208b8e80941Smrg      for (i = 0; i < n; ++i) {
9209b8e80941Smrg         pack_ubyte_la_sint16(src[i], d);
9210b8e80941Smrg         d += 4;
9211b8e80941Smrg      }
9212b8e80941Smrg      break;
9213b8e80941Smrg
9214b8e80941Smrg   case MESA_FORMAT_LA_SINT32:
9215b8e80941Smrg      for (i = 0; i < n; ++i) {
9216b8e80941Smrg         pack_ubyte_la_sint32(src[i], d);
9217b8e80941Smrg         d += 8;
9218b8e80941Smrg      }
9219b8e80941Smrg      break;
9220b8e80941Smrg
9221b8e80941Smrg   case MESA_FORMAT_R_UINT8:
9222b8e80941Smrg      for (i = 0; i < n; ++i) {
9223b8e80941Smrg         pack_ubyte_r_uint8(src[i], d);
9224b8e80941Smrg         d += 1;
9225b8e80941Smrg      }
9226b8e80941Smrg      break;
9227b8e80941Smrg
9228b8e80941Smrg   case MESA_FORMAT_R_UINT16:
9229b8e80941Smrg      for (i = 0; i < n; ++i) {
9230b8e80941Smrg         pack_ubyte_r_uint16(src[i], d);
9231b8e80941Smrg         d += 2;
9232b8e80941Smrg      }
9233b8e80941Smrg      break;
9234b8e80941Smrg
9235b8e80941Smrg   case MESA_FORMAT_R_UINT32:
9236b8e80941Smrg      for (i = 0; i < n; ++i) {
9237b8e80941Smrg         pack_ubyte_r_uint32(src[i], d);
9238b8e80941Smrg         d += 4;
9239b8e80941Smrg      }
9240b8e80941Smrg      break;
9241b8e80941Smrg
9242b8e80941Smrg   case MESA_FORMAT_R_SINT8:
9243b8e80941Smrg      for (i = 0; i < n; ++i) {
9244b8e80941Smrg         pack_ubyte_r_sint8(src[i], d);
9245b8e80941Smrg         d += 1;
9246b8e80941Smrg      }
9247b8e80941Smrg      break;
9248b8e80941Smrg
9249b8e80941Smrg   case MESA_FORMAT_R_SINT16:
9250b8e80941Smrg      for (i = 0; i < n; ++i) {
9251b8e80941Smrg         pack_ubyte_r_sint16(src[i], d);
9252b8e80941Smrg         d += 2;
9253b8e80941Smrg      }
9254b8e80941Smrg      break;
9255b8e80941Smrg
9256b8e80941Smrg   case MESA_FORMAT_R_SINT32:
9257b8e80941Smrg      for (i = 0; i < n; ++i) {
9258b8e80941Smrg         pack_ubyte_r_sint32(src[i], d);
9259b8e80941Smrg         d += 4;
9260b8e80941Smrg      }
9261b8e80941Smrg      break;
9262b8e80941Smrg
9263b8e80941Smrg   case MESA_FORMAT_RG_UINT8:
9264b8e80941Smrg      for (i = 0; i < n; ++i) {
9265b8e80941Smrg         pack_ubyte_rg_uint8(src[i], d);
9266b8e80941Smrg         d += 2;
9267b8e80941Smrg      }
9268b8e80941Smrg      break;
9269b8e80941Smrg
9270b8e80941Smrg   case MESA_FORMAT_RG_UINT16:
9271b8e80941Smrg      for (i = 0; i < n; ++i) {
9272b8e80941Smrg         pack_ubyte_rg_uint16(src[i], d);
9273b8e80941Smrg         d += 4;
9274b8e80941Smrg      }
9275b8e80941Smrg      break;
9276b8e80941Smrg
9277b8e80941Smrg   case MESA_FORMAT_RG_UINT32:
9278b8e80941Smrg      for (i = 0; i < n; ++i) {
9279b8e80941Smrg         pack_ubyte_rg_uint32(src[i], d);
9280b8e80941Smrg         d += 8;
9281b8e80941Smrg      }
9282b8e80941Smrg      break;
9283b8e80941Smrg
9284b8e80941Smrg   case MESA_FORMAT_RG_SINT8:
9285b8e80941Smrg      for (i = 0; i < n; ++i) {
9286b8e80941Smrg         pack_ubyte_rg_sint8(src[i], d);
9287b8e80941Smrg         d += 2;
9288b8e80941Smrg      }
9289b8e80941Smrg      break;
9290b8e80941Smrg
9291b8e80941Smrg   case MESA_FORMAT_RG_SINT16:
9292b8e80941Smrg      for (i = 0; i < n; ++i) {
9293b8e80941Smrg         pack_ubyte_rg_sint16(src[i], d);
9294b8e80941Smrg         d += 4;
9295b8e80941Smrg      }
9296b8e80941Smrg      break;
9297b8e80941Smrg
9298b8e80941Smrg   case MESA_FORMAT_RG_SINT32:
9299b8e80941Smrg      for (i = 0; i < n; ++i) {
9300b8e80941Smrg         pack_ubyte_rg_sint32(src[i], d);
9301b8e80941Smrg         d += 8;
9302b8e80941Smrg      }
9303b8e80941Smrg      break;
9304b8e80941Smrg
9305b8e80941Smrg   case MESA_FORMAT_RGB_UINT8:
9306b8e80941Smrg      for (i = 0; i < n; ++i) {
9307b8e80941Smrg         pack_ubyte_rgb_uint8(src[i], d);
9308b8e80941Smrg         d += 3;
9309b8e80941Smrg      }
9310b8e80941Smrg      break;
9311b8e80941Smrg
9312b8e80941Smrg   case MESA_FORMAT_RGB_UINT16:
9313b8e80941Smrg      for (i = 0; i < n; ++i) {
9314b8e80941Smrg         pack_ubyte_rgb_uint16(src[i], d);
9315b8e80941Smrg         d += 6;
9316b8e80941Smrg      }
9317b8e80941Smrg      break;
9318b8e80941Smrg
9319b8e80941Smrg   case MESA_FORMAT_RGB_UINT32:
9320b8e80941Smrg      for (i = 0; i < n; ++i) {
9321b8e80941Smrg         pack_ubyte_rgb_uint32(src[i], d);
9322b8e80941Smrg         d += 12;
9323b8e80941Smrg      }
9324b8e80941Smrg      break;
9325b8e80941Smrg
9326b8e80941Smrg   case MESA_FORMAT_RGB_SINT8:
9327b8e80941Smrg      for (i = 0; i < n; ++i) {
9328b8e80941Smrg         pack_ubyte_rgb_sint8(src[i], d);
9329b8e80941Smrg         d += 3;
9330b8e80941Smrg      }
9331b8e80941Smrg      break;
9332b8e80941Smrg
9333b8e80941Smrg   case MESA_FORMAT_RGB_SINT16:
9334b8e80941Smrg      for (i = 0; i < n; ++i) {
9335b8e80941Smrg         pack_ubyte_rgb_sint16(src[i], d);
9336b8e80941Smrg         d += 6;
9337b8e80941Smrg      }
9338b8e80941Smrg      break;
9339b8e80941Smrg
9340b8e80941Smrg   case MESA_FORMAT_RGB_SINT32:
9341b8e80941Smrg      for (i = 0; i < n; ++i) {
9342b8e80941Smrg         pack_ubyte_rgb_sint32(src[i], d);
9343b8e80941Smrg         d += 12;
9344b8e80941Smrg      }
9345b8e80941Smrg      break;
9346b8e80941Smrg
9347b8e80941Smrg   case MESA_FORMAT_RGBA_UINT8:
9348b8e80941Smrg      for (i = 0; i < n; ++i) {
9349b8e80941Smrg         pack_ubyte_rgba_uint8(src[i], d);
9350b8e80941Smrg         d += 4;
9351b8e80941Smrg      }
9352b8e80941Smrg      break;
9353b8e80941Smrg
9354b8e80941Smrg   case MESA_FORMAT_RGBA_UINT16:
9355b8e80941Smrg      for (i = 0; i < n; ++i) {
9356b8e80941Smrg         pack_ubyte_rgba_uint16(src[i], d);
9357b8e80941Smrg         d += 8;
9358b8e80941Smrg      }
9359b8e80941Smrg      break;
9360b8e80941Smrg
9361b8e80941Smrg   case MESA_FORMAT_RGBA_UINT32:
9362b8e80941Smrg      for (i = 0; i < n; ++i) {
9363b8e80941Smrg         pack_ubyte_rgba_uint32(src[i], d);
9364b8e80941Smrg         d += 16;
9365b8e80941Smrg      }
9366b8e80941Smrg      break;
9367b8e80941Smrg
9368b8e80941Smrg   case MESA_FORMAT_RGBA_SINT8:
9369b8e80941Smrg      for (i = 0; i < n; ++i) {
9370b8e80941Smrg         pack_ubyte_rgba_sint8(src[i], d);
9371b8e80941Smrg         d += 4;
9372b8e80941Smrg      }
9373b8e80941Smrg      break;
9374b8e80941Smrg
9375b8e80941Smrg   case MESA_FORMAT_RGBA_SINT16:
9376b8e80941Smrg      for (i = 0; i < n; ++i) {
9377b8e80941Smrg         pack_ubyte_rgba_sint16(src[i], d);
9378b8e80941Smrg         d += 8;
9379b8e80941Smrg      }
9380b8e80941Smrg      break;
9381b8e80941Smrg
9382b8e80941Smrg   case MESA_FORMAT_RGBA_SINT32:
9383b8e80941Smrg      for (i = 0; i < n; ++i) {
9384b8e80941Smrg         pack_ubyte_rgba_sint32(src[i], d);
9385b8e80941Smrg         d += 16;
9386b8e80941Smrg      }
9387b8e80941Smrg      break;
9388b8e80941Smrg
9389b8e80941Smrg   case MESA_FORMAT_RGBX_UINT8:
9390b8e80941Smrg      for (i = 0; i < n; ++i) {
9391b8e80941Smrg         pack_ubyte_rgbx_uint8(src[i], d);
9392b8e80941Smrg         d += 4;
9393b8e80941Smrg      }
9394b8e80941Smrg      break;
9395b8e80941Smrg
9396b8e80941Smrg   case MESA_FORMAT_RGBX_UINT16:
9397b8e80941Smrg      for (i = 0; i < n; ++i) {
9398b8e80941Smrg         pack_ubyte_rgbx_uint16(src[i], d);
9399b8e80941Smrg         d += 8;
9400b8e80941Smrg      }
9401b8e80941Smrg      break;
9402b8e80941Smrg
9403b8e80941Smrg   case MESA_FORMAT_RGBX_UINT32:
9404b8e80941Smrg      for (i = 0; i < n; ++i) {
9405b8e80941Smrg         pack_ubyte_rgbx_uint32(src[i], d);
9406b8e80941Smrg         d += 16;
9407b8e80941Smrg      }
9408b8e80941Smrg      break;
9409b8e80941Smrg
9410b8e80941Smrg   case MESA_FORMAT_RGBX_SINT8:
9411b8e80941Smrg      for (i = 0; i < n; ++i) {
9412b8e80941Smrg         pack_ubyte_rgbx_sint8(src[i], d);
9413b8e80941Smrg         d += 4;
9414b8e80941Smrg      }
9415b8e80941Smrg      break;
9416b8e80941Smrg
9417b8e80941Smrg   case MESA_FORMAT_RGBX_SINT16:
9418b8e80941Smrg      for (i = 0; i < n; ++i) {
9419b8e80941Smrg         pack_ubyte_rgbx_sint16(src[i], d);
9420b8e80941Smrg         d += 8;
9421b8e80941Smrg      }
9422b8e80941Smrg      break;
9423b8e80941Smrg
9424b8e80941Smrg   case MESA_FORMAT_RGBX_SINT32:
9425b8e80941Smrg      for (i = 0; i < n; ++i) {
9426b8e80941Smrg         pack_ubyte_rgbx_sint32(src[i], d);
9427b8e80941Smrg         d += 16;
9428b8e80941Smrg      }
9429b8e80941Smrg      break;
9430b8e80941Smrg                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           default:
9431b8e80941Smrg      assert(!"Invalid format");
9432b8e80941Smrg   }
9433b8e80941Smrg}
9434b8e80941Smrg
9435b8e80941Smrg/**
9436b8e80941Smrg * Pack a row of GLuint rgba[4] values to the destination.
9437b8e80941Smrg */
9438b8e80941Smrgvoid
9439b8e80941Smrg_mesa_pack_uint_rgba_row(mesa_format format, GLuint n,
9440b8e80941Smrg                          const GLuint src[][4], void *dst)
9441b8e80941Smrg{
9442b8e80941Smrg   GLuint i;
9443b8e80941Smrg   GLubyte *d = dst;
9444b8e80941Smrg
9445b8e80941Smrg   switch (format) {
9446b8e80941Smrg
9447b8e80941Smrg   case MESA_FORMAT_A8B8G8R8_UINT:
9448b8e80941Smrg      for (i = 0; i < n; ++i) {
9449b8e80941Smrg         pack_uint_a8b8g8r8_uint(src[i], d);
9450b8e80941Smrg         d += 4;
9451b8e80941Smrg      }
9452b8e80941Smrg      break;
9453b8e80941Smrg
9454b8e80941Smrg   case MESA_FORMAT_A8R8G8B8_UINT:
9455b8e80941Smrg      for (i = 0; i < n; ++i) {
9456b8e80941Smrg         pack_uint_a8r8g8b8_uint(src[i], d);
9457b8e80941Smrg         d += 4;
9458b8e80941Smrg      }
9459b8e80941Smrg      break;
9460b8e80941Smrg
9461b8e80941Smrg   case MESA_FORMAT_R8G8B8A8_UINT:
9462b8e80941Smrg      for (i = 0; i < n; ++i) {
9463b8e80941Smrg         pack_uint_r8g8b8a8_uint(src[i], d);
9464b8e80941Smrg         d += 4;
9465b8e80941Smrg      }
9466b8e80941Smrg      break;
9467b8e80941Smrg
9468b8e80941Smrg   case MESA_FORMAT_B8G8R8A8_UINT:
9469b8e80941Smrg      for (i = 0; i < n; ++i) {
9470b8e80941Smrg         pack_uint_b8g8r8a8_uint(src[i], d);
9471b8e80941Smrg         d += 4;
9472b8e80941Smrg      }
9473b8e80941Smrg      break;
9474b8e80941Smrg
9475b8e80941Smrg   case MESA_FORMAT_B10G10R10A2_UINT:
9476b8e80941Smrg      for (i = 0; i < n; ++i) {
9477b8e80941Smrg         pack_uint_b10g10r10a2_uint(src[i], d);
9478b8e80941Smrg         d += 4;
9479b8e80941Smrg      }
9480b8e80941Smrg      break;
9481b8e80941Smrg
9482b8e80941Smrg   case MESA_FORMAT_R10G10B10A2_UINT:
9483b8e80941Smrg      for (i = 0; i < n; ++i) {
9484b8e80941Smrg         pack_uint_r10g10b10a2_uint(src[i], d);
9485b8e80941Smrg         d += 4;
9486b8e80941Smrg      }
9487b8e80941Smrg      break;
9488b8e80941Smrg
9489b8e80941Smrg   case MESA_FORMAT_A2B10G10R10_UINT:
9490b8e80941Smrg      for (i = 0; i < n; ++i) {
9491b8e80941Smrg         pack_uint_a2b10g10r10_uint(src[i], d);
9492b8e80941Smrg         d += 4;
9493b8e80941Smrg      }
9494b8e80941Smrg      break;
9495b8e80941Smrg
9496b8e80941Smrg   case MESA_FORMAT_A2R10G10B10_UINT:
9497b8e80941Smrg      for (i = 0; i < n; ++i) {
9498b8e80941Smrg         pack_uint_a2r10g10b10_uint(src[i], d);
9499b8e80941Smrg         d += 4;
9500b8e80941Smrg      }
9501b8e80941Smrg      break;
9502b8e80941Smrg
9503b8e80941Smrg   case MESA_FORMAT_B5G6R5_UINT:
9504b8e80941Smrg      for (i = 0; i < n; ++i) {
9505b8e80941Smrg         pack_uint_b5g6r5_uint(src[i], d);
9506b8e80941Smrg         d += 2;
9507b8e80941Smrg      }
9508b8e80941Smrg      break;
9509b8e80941Smrg
9510b8e80941Smrg   case MESA_FORMAT_R5G6B5_UINT:
9511b8e80941Smrg      for (i = 0; i < n; ++i) {
9512b8e80941Smrg         pack_uint_r5g6b5_uint(src[i], d);
9513b8e80941Smrg         d += 2;
9514b8e80941Smrg      }
9515b8e80941Smrg      break;
9516b8e80941Smrg
9517b8e80941Smrg   case MESA_FORMAT_B2G3R3_UINT:
9518b8e80941Smrg      for (i = 0; i < n; ++i) {
9519b8e80941Smrg         pack_uint_b2g3r3_uint(src[i], d);
9520b8e80941Smrg         d += 1;
9521b8e80941Smrg      }
9522b8e80941Smrg      break;
9523b8e80941Smrg
9524b8e80941Smrg   case MESA_FORMAT_R3G3B2_UINT:
9525b8e80941Smrg      for (i = 0; i < n; ++i) {
9526b8e80941Smrg         pack_uint_r3g3b2_uint(src[i], d);
9527b8e80941Smrg         d += 1;
9528b8e80941Smrg      }
9529b8e80941Smrg      break;
9530b8e80941Smrg
9531b8e80941Smrg   case MESA_FORMAT_A4B4G4R4_UINT:
9532b8e80941Smrg      for (i = 0; i < n; ++i) {
9533b8e80941Smrg         pack_uint_a4b4g4r4_uint(src[i], d);
9534b8e80941Smrg         d += 2;
9535b8e80941Smrg      }
9536b8e80941Smrg      break;
9537b8e80941Smrg
9538b8e80941Smrg   case MESA_FORMAT_R4G4B4A4_UINT:
9539b8e80941Smrg      for (i = 0; i < n; ++i) {
9540b8e80941Smrg         pack_uint_r4g4b4a4_uint(src[i], d);
9541b8e80941Smrg         d += 2;
9542b8e80941Smrg      }
9543b8e80941Smrg      break;
9544b8e80941Smrg
9545b8e80941Smrg   case MESA_FORMAT_B4G4R4A4_UINT:
9546b8e80941Smrg      for (i = 0; i < n; ++i) {
9547b8e80941Smrg         pack_uint_b4g4r4a4_uint(src[i], d);
9548b8e80941Smrg         d += 2;
9549b8e80941Smrg      }
9550b8e80941Smrg      break;
9551b8e80941Smrg
9552b8e80941Smrg   case MESA_FORMAT_A4R4G4B4_UINT:
9553b8e80941Smrg      for (i = 0; i < n; ++i) {
9554b8e80941Smrg         pack_uint_a4r4g4b4_uint(src[i], d);
9555b8e80941Smrg         d += 2;
9556b8e80941Smrg      }
9557b8e80941Smrg      break;
9558b8e80941Smrg
9559b8e80941Smrg   case MESA_FORMAT_A1B5G5R5_UINT:
9560b8e80941Smrg      for (i = 0; i < n; ++i) {
9561b8e80941Smrg         pack_uint_a1b5g5r5_uint(src[i], d);
9562b8e80941Smrg         d += 2;
9563b8e80941Smrg      }
9564b8e80941Smrg      break;
9565b8e80941Smrg
9566b8e80941Smrg   case MESA_FORMAT_B5G5R5A1_UINT:
9567b8e80941Smrg      for (i = 0; i < n; ++i) {
9568b8e80941Smrg         pack_uint_b5g5r5a1_uint(src[i], d);
9569b8e80941Smrg         d += 2;
9570b8e80941Smrg      }
9571b8e80941Smrg      break;
9572b8e80941Smrg
9573b8e80941Smrg   case MESA_FORMAT_A1R5G5B5_UINT:
9574b8e80941Smrg      for (i = 0; i < n; ++i) {
9575b8e80941Smrg         pack_uint_a1r5g5b5_uint(src[i], d);
9576b8e80941Smrg         d += 2;
9577b8e80941Smrg      }
9578b8e80941Smrg      break;
9579b8e80941Smrg
9580b8e80941Smrg   case MESA_FORMAT_R5G5B5A1_UINT:
9581b8e80941Smrg      for (i = 0; i < n; ++i) {
9582b8e80941Smrg         pack_uint_r5g5b5a1_uint(src[i], d);
9583b8e80941Smrg         d += 2;
9584b8e80941Smrg      }
9585b8e80941Smrg      break;
9586b8e80941Smrg
9587b8e80941Smrg   case MESA_FORMAT_A_UINT8:
9588b8e80941Smrg      for (i = 0; i < n; ++i) {
9589b8e80941Smrg         pack_uint_a_uint8(src[i], d);
9590b8e80941Smrg         d += 1;
9591b8e80941Smrg      }
9592b8e80941Smrg      break;
9593b8e80941Smrg
9594b8e80941Smrg   case MESA_FORMAT_A_UINT16:
9595b8e80941Smrg      for (i = 0; i < n; ++i) {
9596b8e80941Smrg         pack_uint_a_uint16(src[i], d);
9597b8e80941Smrg         d += 2;
9598b8e80941Smrg      }
9599b8e80941Smrg      break;
9600b8e80941Smrg
9601b8e80941Smrg   case MESA_FORMAT_A_UINT32:
9602b8e80941Smrg      for (i = 0; i < n; ++i) {
9603b8e80941Smrg         pack_uint_a_uint32(src[i], d);
9604b8e80941Smrg         d += 4;
9605b8e80941Smrg      }
9606b8e80941Smrg      break;
9607b8e80941Smrg
9608b8e80941Smrg   case MESA_FORMAT_A_SINT8:
9609b8e80941Smrg      for (i = 0; i < n; ++i) {
9610b8e80941Smrg         pack_uint_a_sint8(src[i], d);
9611b8e80941Smrg         d += 1;
9612b8e80941Smrg      }
9613b8e80941Smrg      break;
9614b8e80941Smrg
9615b8e80941Smrg   case MESA_FORMAT_A_SINT16:
9616b8e80941Smrg      for (i = 0; i < n; ++i) {
9617b8e80941Smrg         pack_uint_a_sint16(src[i], d);
9618b8e80941Smrg         d += 2;
9619b8e80941Smrg      }
9620b8e80941Smrg      break;
9621b8e80941Smrg
9622b8e80941Smrg   case MESA_FORMAT_A_SINT32:
9623b8e80941Smrg      for (i = 0; i < n; ++i) {
9624b8e80941Smrg         pack_uint_a_sint32(src[i], d);
9625b8e80941Smrg         d += 4;
9626b8e80941Smrg      }
9627b8e80941Smrg      break;
9628b8e80941Smrg
9629b8e80941Smrg   case MESA_FORMAT_I_UINT8:
9630b8e80941Smrg      for (i = 0; i < n; ++i) {
9631b8e80941Smrg         pack_uint_i_uint8(src[i], d);
9632b8e80941Smrg         d += 1;
9633b8e80941Smrg      }
9634b8e80941Smrg      break;
9635b8e80941Smrg
9636b8e80941Smrg   case MESA_FORMAT_I_UINT16:
9637b8e80941Smrg      for (i = 0; i < n; ++i) {
9638b8e80941Smrg         pack_uint_i_uint16(src[i], d);
9639b8e80941Smrg         d += 2;
9640b8e80941Smrg      }
9641b8e80941Smrg      break;
9642b8e80941Smrg
9643b8e80941Smrg   case MESA_FORMAT_I_UINT32:
9644b8e80941Smrg      for (i = 0; i < n; ++i) {
9645b8e80941Smrg         pack_uint_i_uint32(src[i], d);
9646b8e80941Smrg         d += 4;
9647b8e80941Smrg      }
9648b8e80941Smrg      break;
9649b8e80941Smrg
9650b8e80941Smrg   case MESA_FORMAT_I_SINT8:
9651b8e80941Smrg      for (i = 0; i < n; ++i) {
9652b8e80941Smrg         pack_uint_i_sint8(src[i], d);
9653b8e80941Smrg         d += 1;
9654b8e80941Smrg      }
9655b8e80941Smrg      break;
9656b8e80941Smrg
9657b8e80941Smrg   case MESA_FORMAT_I_SINT16:
9658b8e80941Smrg      for (i = 0; i < n; ++i) {
9659b8e80941Smrg         pack_uint_i_sint16(src[i], d);
9660b8e80941Smrg         d += 2;
9661b8e80941Smrg      }
9662b8e80941Smrg      break;
9663b8e80941Smrg
9664b8e80941Smrg   case MESA_FORMAT_I_SINT32:
9665b8e80941Smrg      for (i = 0; i < n; ++i) {
9666b8e80941Smrg         pack_uint_i_sint32(src[i], d);
9667b8e80941Smrg         d += 4;
9668b8e80941Smrg      }
9669b8e80941Smrg      break;
9670b8e80941Smrg
9671b8e80941Smrg   case MESA_FORMAT_L_UINT8:
9672b8e80941Smrg      for (i = 0; i < n; ++i) {
9673b8e80941Smrg         pack_uint_l_uint8(src[i], d);
9674b8e80941Smrg         d += 1;
9675b8e80941Smrg      }
9676b8e80941Smrg      break;
9677b8e80941Smrg
9678b8e80941Smrg   case MESA_FORMAT_L_UINT16:
9679b8e80941Smrg      for (i = 0; i < n; ++i) {
9680b8e80941Smrg         pack_uint_l_uint16(src[i], d);
9681b8e80941Smrg         d += 2;
9682b8e80941Smrg      }
9683b8e80941Smrg      break;
9684b8e80941Smrg
9685b8e80941Smrg   case MESA_FORMAT_L_UINT32:
9686b8e80941Smrg      for (i = 0; i < n; ++i) {
9687b8e80941Smrg         pack_uint_l_uint32(src[i], d);
9688b8e80941Smrg         d += 4;
9689b8e80941Smrg      }
9690b8e80941Smrg      break;
9691b8e80941Smrg
9692b8e80941Smrg   case MESA_FORMAT_L_SINT8:
9693b8e80941Smrg      for (i = 0; i < n; ++i) {
9694b8e80941Smrg         pack_uint_l_sint8(src[i], d);
9695b8e80941Smrg         d += 1;
9696b8e80941Smrg      }
9697b8e80941Smrg      break;
9698b8e80941Smrg
9699b8e80941Smrg   case MESA_FORMAT_L_SINT16:
9700b8e80941Smrg      for (i = 0; i < n; ++i) {
9701b8e80941Smrg         pack_uint_l_sint16(src[i], d);
9702b8e80941Smrg         d += 2;
9703b8e80941Smrg      }
9704b8e80941Smrg      break;
9705b8e80941Smrg
9706b8e80941Smrg   case MESA_FORMAT_L_SINT32:
9707b8e80941Smrg      for (i = 0; i < n; ++i) {
9708b8e80941Smrg         pack_uint_l_sint32(src[i], d);
9709b8e80941Smrg         d += 4;
9710b8e80941Smrg      }
9711b8e80941Smrg      break;
9712b8e80941Smrg
9713b8e80941Smrg   case MESA_FORMAT_LA_UINT8:
9714b8e80941Smrg      for (i = 0; i < n; ++i) {
9715b8e80941Smrg         pack_uint_la_uint8(src[i], d);
9716b8e80941Smrg         d += 2;
9717b8e80941Smrg      }
9718b8e80941Smrg      break;
9719b8e80941Smrg
9720b8e80941Smrg   case MESA_FORMAT_LA_UINT16:
9721b8e80941Smrg      for (i = 0; i < n; ++i) {
9722b8e80941Smrg         pack_uint_la_uint16(src[i], d);
9723b8e80941Smrg         d += 4;
9724b8e80941Smrg      }
9725b8e80941Smrg      break;
9726b8e80941Smrg
9727b8e80941Smrg   case MESA_FORMAT_LA_UINT32:
9728b8e80941Smrg      for (i = 0; i < n; ++i) {
9729b8e80941Smrg         pack_uint_la_uint32(src[i], d);
9730b8e80941Smrg         d += 8;
9731b8e80941Smrg      }
9732b8e80941Smrg      break;
9733b8e80941Smrg
9734b8e80941Smrg   case MESA_FORMAT_LA_SINT8:
9735b8e80941Smrg      for (i = 0; i < n; ++i) {
9736b8e80941Smrg         pack_uint_la_sint8(src[i], d);
9737b8e80941Smrg         d += 2;
9738b8e80941Smrg      }
9739b8e80941Smrg      break;
9740b8e80941Smrg
9741b8e80941Smrg   case MESA_FORMAT_LA_SINT16:
9742b8e80941Smrg      for (i = 0; i < n; ++i) {
9743b8e80941Smrg         pack_uint_la_sint16(src[i], d);
9744b8e80941Smrg         d += 4;
9745b8e80941Smrg      }
9746b8e80941Smrg      break;
9747b8e80941Smrg
9748b8e80941Smrg   case MESA_FORMAT_LA_SINT32:
9749b8e80941Smrg      for (i = 0; i < n; ++i) {
9750b8e80941Smrg         pack_uint_la_sint32(src[i], d);
9751b8e80941Smrg         d += 8;
9752b8e80941Smrg      }
9753b8e80941Smrg      break;
9754b8e80941Smrg
9755b8e80941Smrg   case MESA_FORMAT_R_UINT8:
9756b8e80941Smrg      for (i = 0; i < n; ++i) {
9757b8e80941Smrg         pack_uint_r_uint8(src[i], d);
9758b8e80941Smrg         d += 1;
9759b8e80941Smrg      }
9760b8e80941Smrg      break;
9761b8e80941Smrg
9762b8e80941Smrg   case MESA_FORMAT_R_UINT16:
9763b8e80941Smrg      for (i = 0; i < n; ++i) {
9764b8e80941Smrg         pack_uint_r_uint16(src[i], d);
9765b8e80941Smrg         d += 2;
9766b8e80941Smrg      }
9767b8e80941Smrg      break;
9768b8e80941Smrg
9769b8e80941Smrg   case MESA_FORMAT_R_UINT32:
9770b8e80941Smrg      for (i = 0; i < n; ++i) {
9771b8e80941Smrg         pack_uint_r_uint32(src[i], d);
9772b8e80941Smrg         d += 4;
9773b8e80941Smrg      }
9774b8e80941Smrg      break;
9775b8e80941Smrg
9776b8e80941Smrg   case MESA_FORMAT_R_SINT8:
9777b8e80941Smrg      for (i = 0; i < n; ++i) {
9778b8e80941Smrg         pack_uint_r_sint8(src[i], d);
9779b8e80941Smrg         d += 1;
9780b8e80941Smrg      }
9781b8e80941Smrg      break;
9782b8e80941Smrg
9783b8e80941Smrg   case MESA_FORMAT_R_SINT16:
9784b8e80941Smrg      for (i = 0; i < n; ++i) {
9785b8e80941Smrg         pack_uint_r_sint16(src[i], d);
9786b8e80941Smrg         d += 2;
9787b8e80941Smrg      }
9788b8e80941Smrg      break;
9789b8e80941Smrg
9790b8e80941Smrg   case MESA_FORMAT_R_SINT32:
9791b8e80941Smrg      for (i = 0; i < n; ++i) {
9792b8e80941Smrg         pack_uint_r_sint32(src[i], d);
9793b8e80941Smrg         d += 4;
9794b8e80941Smrg      }
9795b8e80941Smrg      break;
9796b8e80941Smrg
9797b8e80941Smrg   case MESA_FORMAT_RG_UINT8:
9798b8e80941Smrg      for (i = 0; i < n; ++i) {
9799b8e80941Smrg         pack_uint_rg_uint8(src[i], d);
9800b8e80941Smrg         d += 2;
9801b8e80941Smrg      }
9802b8e80941Smrg      break;
9803b8e80941Smrg
9804b8e80941Smrg   case MESA_FORMAT_RG_UINT16:
9805b8e80941Smrg      for (i = 0; i < n; ++i) {
9806b8e80941Smrg         pack_uint_rg_uint16(src[i], d);
9807b8e80941Smrg         d += 4;
9808b8e80941Smrg      }
9809b8e80941Smrg      break;
9810b8e80941Smrg
9811b8e80941Smrg   case MESA_FORMAT_RG_UINT32:
9812b8e80941Smrg      for (i = 0; i < n; ++i) {
9813b8e80941Smrg         pack_uint_rg_uint32(src[i], d);
9814b8e80941Smrg         d += 8;
9815b8e80941Smrg      }
9816b8e80941Smrg      break;
9817b8e80941Smrg
9818b8e80941Smrg   case MESA_FORMAT_RG_SINT8:
9819b8e80941Smrg      for (i = 0; i < n; ++i) {
9820b8e80941Smrg         pack_uint_rg_sint8(src[i], d);
9821b8e80941Smrg         d += 2;
9822b8e80941Smrg      }
9823b8e80941Smrg      break;
9824b8e80941Smrg
9825b8e80941Smrg   case MESA_FORMAT_RG_SINT16:
9826b8e80941Smrg      for (i = 0; i < n; ++i) {
9827b8e80941Smrg         pack_uint_rg_sint16(src[i], d);
9828b8e80941Smrg         d += 4;
9829b8e80941Smrg      }
9830b8e80941Smrg      break;
9831b8e80941Smrg
9832b8e80941Smrg   case MESA_FORMAT_RG_SINT32:
9833b8e80941Smrg      for (i = 0; i < n; ++i) {
9834b8e80941Smrg         pack_uint_rg_sint32(src[i], d);
9835b8e80941Smrg         d += 8;
9836b8e80941Smrg      }
9837b8e80941Smrg      break;
9838b8e80941Smrg
9839b8e80941Smrg   case MESA_FORMAT_RGB_UINT8:
9840b8e80941Smrg      for (i = 0; i < n; ++i) {
9841b8e80941Smrg         pack_uint_rgb_uint8(src[i], d);
9842b8e80941Smrg         d += 3;
9843b8e80941Smrg      }
9844b8e80941Smrg      break;
9845b8e80941Smrg
9846b8e80941Smrg   case MESA_FORMAT_RGB_UINT16:
9847b8e80941Smrg      for (i = 0; i < n; ++i) {
9848b8e80941Smrg         pack_uint_rgb_uint16(src[i], d);
9849b8e80941Smrg         d += 6;
9850b8e80941Smrg      }
9851b8e80941Smrg      break;
9852b8e80941Smrg
9853b8e80941Smrg   case MESA_FORMAT_RGB_UINT32:
9854b8e80941Smrg      for (i = 0; i < n; ++i) {
9855b8e80941Smrg         pack_uint_rgb_uint32(src[i], d);
9856b8e80941Smrg         d += 12;
9857b8e80941Smrg      }
9858b8e80941Smrg      break;
9859b8e80941Smrg
9860b8e80941Smrg   case MESA_FORMAT_RGB_SINT8:
9861b8e80941Smrg      for (i = 0; i < n; ++i) {
9862b8e80941Smrg         pack_uint_rgb_sint8(src[i], d);
9863b8e80941Smrg         d += 3;
9864b8e80941Smrg      }
9865b8e80941Smrg      break;
9866b8e80941Smrg
9867b8e80941Smrg   case MESA_FORMAT_RGB_SINT16:
9868b8e80941Smrg      for (i = 0; i < n; ++i) {
9869b8e80941Smrg         pack_uint_rgb_sint16(src[i], d);
9870b8e80941Smrg         d += 6;
9871b8e80941Smrg      }
9872b8e80941Smrg      break;
9873b8e80941Smrg
9874b8e80941Smrg   case MESA_FORMAT_RGB_SINT32:
9875b8e80941Smrg      for (i = 0; i < n; ++i) {
9876b8e80941Smrg         pack_uint_rgb_sint32(src[i], d);
9877b8e80941Smrg         d += 12;
9878b8e80941Smrg      }
9879b8e80941Smrg      break;
9880b8e80941Smrg
9881b8e80941Smrg   case MESA_FORMAT_RGBA_UINT8:
9882b8e80941Smrg      for (i = 0; i < n; ++i) {
9883b8e80941Smrg         pack_uint_rgba_uint8(src[i], d);
9884b8e80941Smrg         d += 4;
9885b8e80941Smrg      }
9886b8e80941Smrg      break;
9887b8e80941Smrg
9888b8e80941Smrg   case MESA_FORMAT_RGBA_UINT16:
9889b8e80941Smrg      for (i = 0; i < n; ++i) {
9890b8e80941Smrg         pack_uint_rgba_uint16(src[i], d);
9891b8e80941Smrg         d += 8;
9892b8e80941Smrg      }
9893b8e80941Smrg      break;
9894b8e80941Smrg
9895b8e80941Smrg   case MESA_FORMAT_RGBA_UINT32:
9896b8e80941Smrg      for (i = 0; i < n; ++i) {
9897b8e80941Smrg         pack_uint_rgba_uint32(src[i], d);
9898b8e80941Smrg         d += 16;
9899b8e80941Smrg      }
9900b8e80941Smrg      break;
9901b8e80941Smrg
9902b8e80941Smrg   case MESA_FORMAT_RGBA_SINT8:
9903b8e80941Smrg      for (i = 0; i < n; ++i) {
9904b8e80941Smrg         pack_uint_rgba_sint8(src[i], d);
9905b8e80941Smrg         d += 4;
9906b8e80941Smrg      }
9907b8e80941Smrg      break;
9908b8e80941Smrg
9909b8e80941Smrg   case MESA_FORMAT_RGBA_SINT16:
9910b8e80941Smrg      for (i = 0; i < n; ++i) {
9911b8e80941Smrg         pack_uint_rgba_sint16(src[i], d);
9912b8e80941Smrg         d += 8;
9913b8e80941Smrg      }
9914b8e80941Smrg      break;
9915b8e80941Smrg
9916b8e80941Smrg   case MESA_FORMAT_RGBA_SINT32:
9917b8e80941Smrg      for (i = 0; i < n; ++i) {
9918b8e80941Smrg         pack_uint_rgba_sint32(src[i], d);
9919b8e80941Smrg         d += 16;
9920b8e80941Smrg      }
9921b8e80941Smrg      break;
9922b8e80941Smrg
9923b8e80941Smrg   case MESA_FORMAT_RGBX_UINT8:
9924b8e80941Smrg      for (i = 0; i < n; ++i) {
9925b8e80941Smrg         pack_uint_rgbx_uint8(src[i], d);
9926b8e80941Smrg         d += 4;
9927b8e80941Smrg      }
9928b8e80941Smrg      break;
9929b8e80941Smrg
9930b8e80941Smrg   case MESA_FORMAT_RGBX_UINT16:
9931b8e80941Smrg      for (i = 0; i < n; ++i) {
9932b8e80941Smrg         pack_uint_rgbx_uint16(src[i], d);
9933b8e80941Smrg         d += 8;
9934b8e80941Smrg      }
9935b8e80941Smrg      break;
9936b8e80941Smrg
9937b8e80941Smrg   case MESA_FORMAT_RGBX_UINT32:
9938b8e80941Smrg      for (i = 0; i < n; ++i) {
9939b8e80941Smrg         pack_uint_rgbx_uint32(src[i], d);
9940b8e80941Smrg         d += 16;
9941b8e80941Smrg      }
9942b8e80941Smrg      break;
9943b8e80941Smrg
9944b8e80941Smrg   case MESA_FORMAT_RGBX_SINT8:
9945b8e80941Smrg      for (i = 0; i < n; ++i) {
9946b8e80941Smrg         pack_uint_rgbx_sint8(src[i], d);
9947b8e80941Smrg         d += 4;
9948b8e80941Smrg      }
9949b8e80941Smrg      break;
9950b8e80941Smrg
9951b8e80941Smrg   case MESA_FORMAT_RGBX_SINT16:
9952b8e80941Smrg      for (i = 0; i < n; ++i) {
9953b8e80941Smrg         pack_uint_rgbx_sint16(src[i], d);
9954b8e80941Smrg         d += 8;
9955b8e80941Smrg      }
9956b8e80941Smrg      break;
9957b8e80941Smrg
9958b8e80941Smrg   case MESA_FORMAT_RGBX_SINT32:
9959b8e80941Smrg      for (i = 0; i < n; ++i) {
9960b8e80941Smrg         pack_uint_rgbx_sint32(src[i], d);
9961b8e80941Smrg         d += 16;
9962b8e80941Smrg      }
9963b8e80941Smrg      break;
9964b8e80941Smrg                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           default:
9965b8e80941Smrg      assert(!"Invalid format");
9966b8e80941Smrg   }
9967b8e80941Smrg}
9968b8e80941Smrg
9969b8e80941Smrg/**
9970b8e80941Smrg * Pack a row of GLfloat rgba[4] values to the destination.
9971b8e80941Smrg */
9972b8e80941Smrgvoid
9973b8e80941Smrg_mesa_pack_float_rgba_row(mesa_format format, GLuint n,
9974b8e80941Smrg                          const GLfloat src[][4], void *dst)
9975b8e80941Smrg{
9976b8e80941Smrg   GLuint i;
9977b8e80941Smrg   GLubyte *d = dst;
9978b8e80941Smrg
9979b8e80941Smrg   switch (format) {
9980b8e80941Smrg
9981b8e80941Smrg   case MESA_FORMAT_A8B8G8R8_UNORM:
9982b8e80941Smrg      for (i = 0; i < n; ++i) {
9983b8e80941Smrg         pack_float_a8b8g8r8_unorm(src[i], d);
9984b8e80941Smrg         d += 4;
9985b8e80941Smrg      }
9986b8e80941Smrg      break;
9987b8e80941Smrg
9988b8e80941Smrg   case MESA_FORMAT_X8B8G8R8_UNORM:
9989b8e80941Smrg      for (i = 0; i < n; ++i) {
9990b8e80941Smrg         pack_float_x8b8g8r8_unorm(src[i], d);
9991b8e80941Smrg         d += 4;
9992b8e80941Smrg      }
9993b8e80941Smrg      break;
9994b8e80941Smrg
9995b8e80941Smrg   case MESA_FORMAT_R8G8B8A8_UNORM:
9996b8e80941Smrg      for (i = 0; i < n; ++i) {
9997b8e80941Smrg         pack_float_r8g8b8a8_unorm(src[i], d);
9998b8e80941Smrg         d += 4;
9999b8e80941Smrg      }
10000b8e80941Smrg      break;
10001b8e80941Smrg
10002b8e80941Smrg   case MESA_FORMAT_R8G8B8X8_UNORM:
10003b8e80941Smrg      for (i = 0; i < n; ++i) {
10004b8e80941Smrg         pack_float_r8g8b8x8_unorm(src[i], d);
10005b8e80941Smrg         d += 4;
10006b8e80941Smrg      }
10007b8e80941Smrg      break;
10008b8e80941Smrg
10009b8e80941Smrg   case MESA_FORMAT_B8G8R8A8_UNORM:
10010b8e80941Smrg      for (i = 0; i < n; ++i) {
10011b8e80941Smrg         pack_float_b8g8r8a8_unorm(src[i], d);
10012b8e80941Smrg         d += 4;
10013b8e80941Smrg      }
10014b8e80941Smrg      break;
10015b8e80941Smrg
10016b8e80941Smrg   case MESA_FORMAT_B8G8R8X8_UNORM:
10017b8e80941Smrg      for (i = 0; i < n; ++i) {
10018b8e80941Smrg         pack_float_b8g8r8x8_unorm(src[i], d);
10019b8e80941Smrg         d += 4;
10020b8e80941Smrg      }
10021b8e80941Smrg      break;
10022b8e80941Smrg
10023b8e80941Smrg   case MESA_FORMAT_A8R8G8B8_UNORM:
10024b8e80941Smrg      for (i = 0; i < n; ++i) {
10025b8e80941Smrg         pack_float_a8r8g8b8_unorm(src[i], d);
10026b8e80941Smrg         d += 4;
10027b8e80941Smrg      }
10028b8e80941Smrg      break;
10029b8e80941Smrg
10030b8e80941Smrg   case MESA_FORMAT_X8R8G8B8_UNORM:
10031b8e80941Smrg      for (i = 0; i < n; ++i) {
10032b8e80941Smrg         pack_float_x8r8g8b8_unorm(src[i], d);
10033b8e80941Smrg         d += 4;
10034b8e80941Smrg      }
10035b8e80941Smrg      break;
10036b8e80941Smrg
10037b8e80941Smrg   case MESA_FORMAT_L16A16_UNORM:
10038b8e80941Smrg      for (i = 0; i < n; ++i) {
10039b8e80941Smrg         pack_float_l16a16_unorm(src[i], d);
10040b8e80941Smrg         d += 4;
10041b8e80941Smrg      }
10042b8e80941Smrg      break;
10043b8e80941Smrg
10044b8e80941Smrg   case MESA_FORMAT_A16L16_UNORM:
10045b8e80941Smrg      for (i = 0; i < n; ++i) {
10046b8e80941Smrg         pack_float_a16l16_unorm(src[i], d);
10047b8e80941Smrg         d += 4;
10048b8e80941Smrg      }
10049b8e80941Smrg      break;
10050b8e80941Smrg
10051b8e80941Smrg   case MESA_FORMAT_B5G6R5_UNORM:
10052b8e80941Smrg      for (i = 0; i < n; ++i) {
10053b8e80941Smrg         pack_float_b5g6r5_unorm(src[i], d);
10054b8e80941Smrg         d += 2;
10055b8e80941Smrg      }
10056b8e80941Smrg      break;
10057b8e80941Smrg
10058b8e80941Smrg   case MESA_FORMAT_R5G6B5_UNORM:
10059b8e80941Smrg      for (i = 0; i < n; ++i) {
10060b8e80941Smrg         pack_float_r5g6b5_unorm(src[i], d);
10061b8e80941Smrg         d += 2;
10062b8e80941Smrg      }
10063b8e80941Smrg      break;
10064b8e80941Smrg
10065b8e80941Smrg   case MESA_FORMAT_B4G4R4A4_UNORM:
10066b8e80941Smrg      for (i = 0; i < n; ++i) {
10067b8e80941Smrg         pack_float_b4g4r4a4_unorm(src[i], d);
10068b8e80941Smrg         d += 2;
10069b8e80941Smrg      }
10070b8e80941Smrg      break;
10071b8e80941Smrg
10072b8e80941Smrg   case MESA_FORMAT_B4G4R4X4_UNORM:
10073b8e80941Smrg      for (i = 0; i < n; ++i) {
10074b8e80941Smrg         pack_float_b4g4r4x4_unorm(src[i], d);
10075b8e80941Smrg         d += 2;
10076b8e80941Smrg      }
10077b8e80941Smrg      break;
10078b8e80941Smrg
10079b8e80941Smrg   case MESA_FORMAT_A4R4G4B4_UNORM:
10080b8e80941Smrg      for (i = 0; i < n; ++i) {
10081b8e80941Smrg         pack_float_a4r4g4b4_unorm(src[i], d);
10082b8e80941Smrg         d += 2;
10083b8e80941Smrg      }
10084b8e80941Smrg      break;
10085b8e80941Smrg
10086b8e80941Smrg   case MESA_FORMAT_A1B5G5R5_UNORM:
10087b8e80941Smrg      for (i = 0; i < n; ++i) {
10088b8e80941Smrg         pack_float_a1b5g5r5_unorm(src[i], d);
10089b8e80941Smrg         d += 2;
10090b8e80941Smrg      }
10091b8e80941Smrg      break;
10092b8e80941Smrg
10093b8e80941Smrg   case MESA_FORMAT_X1B5G5R5_UNORM:
10094b8e80941Smrg      for (i = 0; i < n; ++i) {
10095b8e80941Smrg         pack_float_x1b5g5r5_unorm(src[i], d);
10096b8e80941Smrg         d += 2;
10097b8e80941Smrg      }
10098b8e80941Smrg      break;
10099b8e80941Smrg
10100b8e80941Smrg   case MESA_FORMAT_B5G5R5A1_UNORM:
10101b8e80941Smrg      for (i = 0; i < n; ++i) {
10102b8e80941Smrg         pack_float_b5g5r5a1_unorm(src[i], d);
10103b8e80941Smrg         d += 2;
10104b8e80941Smrg      }
10105b8e80941Smrg      break;
10106b8e80941Smrg
10107b8e80941Smrg   case MESA_FORMAT_B5G5R5X1_UNORM:
10108b8e80941Smrg      for (i = 0; i < n; ++i) {
10109b8e80941Smrg         pack_float_b5g5r5x1_unorm(src[i], d);
10110b8e80941Smrg         d += 2;
10111b8e80941Smrg      }
10112b8e80941Smrg      break;
10113b8e80941Smrg
10114b8e80941Smrg   case MESA_FORMAT_A1R5G5B5_UNORM:
10115b8e80941Smrg      for (i = 0; i < n; ++i) {
10116b8e80941Smrg         pack_float_a1r5g5b5_unorm(src[i], d);
10117b8e80941Smrg         d += 2;
10118b8e80941Smrg      }
10119b8e80941Smrg      break;
10120b8e80941Smrg
10121b8e80941Smrg   case MESA_FORMAT_L8A8_UNORM:
10122b8e80941Smrg      for (i = 0; i < n; ++i) {
10123b8e80941Smrg         pack_float_l8a8_unorm(src[i], d);
10124b8e80941Smrg         d += 2;
10125b8e80941Smrg      }
10126b8e80941Smrg      break;
10127b8e80941Smrg
10128b8e80941Smrg   case MESA_FORMAT_A8L8_UNORM:
10129b8e80941Smrg      for (i = 0; i < n; ++i) {
10130b8e80941Smrg         pack_float_a8l8_unorm(src[i], d);
10131b8e80941Smrg         d += 2;
10132b8e80941Smrg      }
10133b8e80941Smrg      break;
10134b8e80941Smrg
10135b8e80941Smrg   case MESA_FORMAT_R8G8_UNORM:
10136b8e80941Smrg      for (i = 0; i < n; ++i) {
10137b8e80941Smrg         pack_float_r8g8_unorm(src[i], d);
10138b8e80941Smrg         d += 2;
10139b8e80941Smrg      }
10140b8e80941Smrg      break;
10141b8e80941Smrg
10142b8e80941Smrg   case MESA_FORMAT_G8R8_UNORM:
10143b8e80941Smrg      for (i = 0; i < n; ++i) {
10144b8e80941Smrg         pack_float_g8r8_unorm(src[i], d);
10145b8e80941Smrg         d += 2;
10146b8e80941Smrg      }
10147b8e80941Smrg      break;
10148b8e80941Smrg
10149b8e80941Smrg   case MESA_FORMAT_L4A4_UNORM:
10150b8e80941Smrg      for (i = 0; i < n; ++i) {
10151b8e80941Smrg         pack_float_l4a4_unorm(src[i], d);
10152b8e80941Smrg         d += 1;
10153b8e80941Smrg      }
10154b8e80941Smrg      break;
10155b8e80941Smrg
10156b8e80941Smrg   case MESA_FORMAT_B2G3R3_UNORM:
10157b8e80941Smrg      for (i = 0; i < n; ++i) {
10158b8e80941Smrg         pack_float_b2g3r3_unorm(src[i], d);
10159b8e80941Smrg         d += 1;
10160b8e80941Smrg      }
10161b8e80941Smrg      break;
10162b8e80941Smrg
10163b8e80941Smrg   case MESA_FORMAT_R16G16_UNORM:
10164b8e80941Smrg      for (i = 0; i < n; ++i) {
10165b8e80941Smrg         pack_float_r16g16_unorm(src[i], d);
10166b8e80941Smrg         d += 4;
10167b8e80941Smrg      }
10168b8e80941Smrg      break;
10169b8e80941Smrg
10170b8e80941Smrg   case MESA_FORMAT_G16R16_UNORM:
10171b8e80941Smrg      for (i = 0; i < n; ++i) {
10172b8e80941Smrg         pack_float_g16r16_unorm(src[i], d);
10173b8e80941Smrg         d += 4;
10174b8e80941Smrg      }
10175b8e80941Smrg      break;
10176b8e80941Smrg
10177b8e80941Smrg   case MESA_FORMAT_B10G10R10A2_UNORM:
10178b8e80941Smrg      for (i = 0; i < n; ++i) {
10179b8e80941Smrg         pack_float_b10g10r10a2_unorm(src[i], d);
10180b8e80941Smrg         d += 4;
10181b8e80941Smrg      }
10182b8e80941Smrg      break;
10183b8e80941Smrg
10184b8e80941Smrg   case MESA_FORMAT_B10G10R10X2_UNORM:
10185b8e80941Smrg      for (i = 0; i < n; ++i) {
10186b8e80941Smrg         pack_float_b10g10r10x2_unorm(src[i], d);
10187b8e80941Smrg         d += 4;
10188b8e80941Smrg      }
10189b8e80941Smrg      break;
10190b8e80941Smrg
10191b8e80941Smrg   case MESA_FORMAT_R10G10B10A2_UNORM:
10192b8e80941Smrg      for (i = 0; i < n; ++i) {
10193b8e80941Smrg         pack_float_r10g10b10a2_unorm(src[i], d);
10194b8e80941Smrg         d += 4;
10195b8e80941Smrg      }
10196b8e80941Smrg      break;
10197b8e80941Smrg
10198b8e80941Smrg   case MESA_FORMAT_R10G10B10X2_UNORM:
10199b8e80941Smrg      for (i = 0; i < n; ++i) {
10200b8e80941Smrg         pack_float_r10g10b10x2_unorm(src[i], d);
10201b8e80941Smrg         d += 4;
10202b8e80941Smrg      }
10203b8e80941Smrg      break;
10204b8e80941Smrg
10205b8e80941Smrg   case MESA_FORMAT_R3G3B2_UNORM:
10206b8e80941Smrg      for (i = 0; i < n; ++i) {
10207b8e80941Smrg         pack_float_r3g3b2_unorm(src[i], d);
10208b8e80941Smrg         d += 1;
10209b8e80941Smrg      }
10210b8e80941Smrg      break;
10211b8e80941Smrg
10212b8e80941Smrg   case MESA_FORMAT_A4B4G4R4_UNORM:
10213b8e80941Smrg      for (i = 0; i < n; ++i) {
10214b8e80941Smrg         pack_float_a4b4g4r4_unorm(src[i], d);
10215b8e80941Smrg         d += 2;
10216b8e80941Smrg      }
10217b8e80941Smrg      break;
10218b8e80941Smrg
10219b8e80941Smrg   case MESA_FORMAT_R4G4B4A4_UNORM:
10220b8e80941Smrg      for (i = 0; i < n; ++i) {
10221b8e80941Smrg         pack_float_r4g4b4a4_unorm(src[i], d);
10222b8e80941Smrg         d += 2;
10223b8e80941Smrg      }
10224b8e80941Smrg      break;
10225b8e80941Smrg
10226b8e80941Smrg   case MESA_FORMAT_R5G5B5A1_UNORM:
10227b8e80941Smrg      for (i = 0; i < n; ++i) {
10228b8e80941Smrg         pack_float_r5g5b5a1_unorm(src[i], d);
10229b8e80941Smrg         d += 2;
10230b8e80941Smrg      }
10231b8e80941Smrg      break;
10232b8e80941Smrg
10233b8e80941Smrg   case MESA_FORMAT_A2B10G10R10_UNORM:
10234b8e80941Smrg      for (i = 0; i < n; ++i) {
10235b8e80941Smrg         pack_float_a2b10g10r10_unorm(src[i], d);
10236b8e80941Smrg         d += 4;
10237b8e80941Smrg      }
10238b8e80941Smrg      break;
10239b8e80941Smrg
10240b8e80941Smrg   case MESA_FORMAT_A2R10G10B10_UNORM:
10241b8e80941Smrg      for (i = 0; i < n; ++i) {
10242b8e80941Smrg         pack_float_a2r10g10b10_unorm(src[i], d);
10243b8e80941Smrg         d += 4;
10244b8e80941Smrg      }
10245b8e80941Smrg      break;
10246b8e80941Smrg
10247b8e80941Smrg   case MESA_FORMAT_A_UNORM8:
10248b8e80941Smrg      for (i = 0; i < n; ++i) {
10249b8e80941Smrg         pack_float_a_unorm8(src[i], d);
10250b8e80941Smrg         d += 1;
10251b8e80941Smrg      }
10252b8e80941Smrg      break;
10253b8e80941Smrg
10254b8e80941Smrg   case MESA_FORMAT_A_UNORM16:
10255b8e80941Smrg      for (i = 0; i < n; ++i) {
10256b8e80941Smrg         pack_float_a_unorm16(src[i], d);
10257b8e80941Smrg         d += 2;
10258b8e80941Smrg      }
10259b8e80941Smrg      break;
10260b8e80941Smrg
10261b8e80941Smrg   case MESA_FORMAT_L_UNORM8:
10262b8e80941Smrg      for (i = 0; i < n; ++i) {
10263b8e80941Smrg         pack_float_l_unorm8(src[i], d);
10264b8e80941Smrg         d += 1;
10265b8e80941Smrg      }
10266b8e80941Smrg      break;
10267b8e80941Smrg
10268b8e80941Smrg   case MESA_FORMAT_L_UNORM16:
10269b8e80941Smrg      for (i = 0; i < n; ++i) {
10270b8e80941Smrg         pack_float_l_unorm16(src[i], d);
10271b8e80941Smrg         d += 2;
10272b8e80941Smrg      }
10273b8e80941Smrg      break;
10274b8e80941Smrg
10275b8e80941Smrg   case MESA_FORMAT_I_UNORM8:
10276b8e80941Smrg      for (i = 0; i < n; ++i) {
10277b8e80941Smrg         pack_float_i_unorm8(src[i], d);
10278b8e80941Smrg         d += 1;
10279b8e80941Smrg      }
10280b8e80941Smrg      break;
10281b8e80941Smrg
10282b8e80941Smrg   case MESA_FORMAT_I_UNORM16:
10283b8e80941Smrg      for (i = 0; i < n; ++i) {
10284b8e80941Smrg         pack_float_i_unorm16(src[i], d);
10285b8e80941Smrg         d += 2;
10286b8e80941Smrg      }
10287b8e80941Smrg      break;
10288b8e80941Smrg
10289b8e80941Smrg   case MESA_FORMAT_R_UNORM8:
10290b8e80941Smrg      for (i = 0; i < n; ++i) {
10291b8e80941Smrg         pack_float_r_unorm8(src[i], d);
10292b8e80941Smrg         d += 1;
10293b8e80941Smrg      }
10294b8e80941Smrg      break;
10295b8e80941Smrg
10296b8e80941Smrg   case MESA_FORMAT_R_UNORM16:
10297b8e80941Smrg      for (i = 0; i < n; ++i) {
10298b8e80941Smrg         pack_float_r_unorm16(src[i], d);
10299b8e80941Smrg         d += 2;
10300b8e80941Smrg      }
10301b8e80941Smrg      break;
10302b8e80941Smrg
10303b8e80941Smrg   case MESA_FORMAT_BGR_UNORM8:
10304b8e80941Smrg      for (i = 0; i < n; ++i) {
10305b8e80941Smrg         pack_float_bgr_unorm8(src[i], d);
10306b8e80941Smrg         d += 3;
10307b8e80941Smrg      }
10308b8e80941Smrg      break;
10309b8e80941Smrg
10310b8e80941Smrg   case MESA_FORMAT_RGB_UNORM8:
10311b8e80941Smrg      for (i = 0; i < n; ++i) {
10312b8e80941Smrg         pack_float_rgb_unorm8(src[i], d);
10313b8e80941Smrg         d += 3;
10314b8e80941Smrg      }
10315b8e80941Smrg      break;
10316b8e80941Smrg
10317b8e80941Smrg   case MESA_FORMAT_RGBA_UNORM16:
10318b8e80941Smrg      for (i = 0; i < n; ++i) {
10319b8e80941Smrg         pack_float_rgba_unorm16(src[i], d);
10320b8e80941Smrg         d += 8;
10321b8e80941Smrg      }
10322b8e80941Smrg      break;
10323b8e80941Smrg
10324b8e80941Smrg   case MESA_FORMAT_RGBX_UNORM16:
10325b8e80941Smrg      for (i = 0; i < n; ++i) {
10326b8e80941Smrg         pack_float_rgbx_unorm16(src[i], d);
10327b8e80941Smrg         d += 8;
10328b8e80941Smrg      }
10329b8e80941Smrg      break;
10330b8e80941Smrg
10331b8e80941Smrg   case MESA_FORMAT_A8B8G8R8_SNORM:
10332b8e80941Smrg      for (i = 0; i < n; ++i) {
10333b8e80941Smrg         pack_float_a8b8g8r8_snorm(src[i], d);
10334b8e80941Smrg         d += 4;
10335b8e80941Smrg      }
10336b8e80941Smrg      break;
10337b8e80941Smrg
10338b8e80941Smrg   case MESA_FORMAT_X8B8G8R8_SNORM:
10339b8e80941Smrg      for (i = 0; i < n; ++i) {
10340b8e80941Smrg         pack_float_x8b8g8r8_snorm(src[i], d);
10341b8e80941Smrg         d += 4;
10342b8e80941Smrg      }
10343b8e80941Smrg      break;
10344b8e80941Smrg
10345b8e80941Smrg   case MESA_FORMAT_R8G8B8A8_SNORM:
10346b8e80941Smrg      for (i = 0; i < n; ++i) {
10347b8e80941Smrg         pack_float_r8g8b8a8_snorm(src[i], d);
10348b8e80941Smrg         d += 4;
10349b8e80941Smrg      }
10350b8e80941Smrg      break;
10351b8e80941Smrg
10352b8e80941Smrg   case MESA_FORMAT_R8G8B8X8_SNORM:
10353b8e80941Smrg      for (i = 0; i < n; ++i) {
10354b8e80941Smrg         pack_float_r8g8b8x8_snorm(src[i], d);
10355b8e80941Smrg         d += 4;
10356b8e80941Smrg      }
10357b8e80941Smrg      break;
10358b8e80941Smrg
10359b8e80941Smrg   case MESA_FORMAT_R16G16_SNORM:
10360b8e80941Smrg      for (i = 0; i < n; ++i) {
10361b8e80941Smrg         pack_float_r16g16_snorm(src[i], d);
10362b8e80941Smrg         d += 4;
10363b8e80941Smrg      }
10364b8e80941Smrg      break;
10365b8e80941Smrg
10366b8e80941Smrg   case MESA_FORMAT_G16R16_SNORM:
10367b8e80941Smrg      for (i = 0; i < n; ++i) {
10368b8e80941Smrg         pack_float_g16r16_snorm(src[i], d);
10369b8e80941Smrg         d += 4;
10370b8e80941Smrg      }
10371b8e80941Smrg      break;
10372b8e80941Smrg
10373b8e80941Smrg   case MESA_FORMAT_R8G8_SNORM:
10374b8e80941Smrg      for (i = 0; i < n; ++i) {
10375b8e80941Smrg         pack_float_r8g8_snorm(src[i], d);
10376b8e80941Smrg         d += 2;
10377b8e80941Smrg      }
10378b8e80941Smrg      break;
10379b8e80941Smrg
10380b8e80941Smrg   case MESA_FORMAT_G8R8_SNORM:
10381b8e80941Smrg      for (i = 0; i < n; ++i) {
10382b8e80941Smrg         pack_float_g8r8_snorm(src[i], d);
10383b8e80941Smrg         d += 2;
10384b8e80941Smrg      }
10385b8e80941Smrg      break;
10386b8e80941Smrg
10387b8e80941Smrg   case MESA_FORMAT_L8A8_SNORM:
10388b8e80941Smrg      for (i = 0; i < n; ++i) {
10389b8e80941Smrg         pack_float_l8a8_snorm(src[i], d);
10390b8e80941Smrg         d += 2;
10391b8e80941Smrg      }
10392b8e80941Smrg      break;
10393b8e80941Smrg
10394b8e80941Smrg   case MESA_FORMAT_A8L8_SNORM:
10395b8e80941Smrg      for (i = 0; i < n; ++i) {
10396b8e80941Smrg         pack_float_a8l8_snorm(src[i], d);
10397b8e80941Smrg         d += 2;
10398b8e80941Smrg      }
10399b8e80941Smrg      break;
10400b8e80941Smrg
10401b8e80941Smrg   case MESA_FORMAT_A_SNORM8:
10402b8e80941Smrg      for (i = 0; i < n; ++i) {
10403b8e80941Smrg         pack_float_a_snorm8(src[i], d);
10404b8e80941Smrg         d += 1;
10405b8e80941Smrg      }
10406b8e80941Smrg      break;
10407b8e80941Smrg
10408b8e80941Smrg   case MESA_FORMAT_A_SNORM16:
10409b8e80941Smrg      for (i = 0; i < n; ++i) {
10410b8e80941Smrg         pack_float_a_snorm16(src[i], d);
10411b8e80941Smrg         d += 2;
10412b8e80941Smrg      }
10413b8e80941Smrg      break;
10414b8e80941Smrg
10415b8e80941Smrg   case MESA_FORMAT_L_SNORM8:
10416b8e80941Smrg      for (i = 0; i < n; ++i) {
10417b8e80941Smrg         pack_float_l_snorm8(src[i], d);
10418b8e80941Smrg         d += 1;
10419b8e80941Smrg      }
10420b8e80941Smrg      break;
10421b8e80941Smrg
10422b8e80941Smrg   case MESA_FORMAT_L_SNORM16:
10423b8e80941Smrg      for (i = 0; i < n; ++i) {
10424b8e80941Smrg         pack_float_l_snorm16(src[i], d);
10425b8e80941Smrg         d += 2;
10426b8e80941Smrg      }
10427b8e80941Smrg      break;
10428b8e80941Smrg
10429b8e80941Smrg   case MESA_FORMAT_I_SNORM8:
10430b8e80941Smrg      for (i = 0; i < n; ++i) {
10431b8e80941Smrg         pack_float_i_snorm8(src[i], d);
10432b8e80941Smrg         d += 1;
10433b8e80941Smrg      }
10434b8e80941Smrg      break;
10435b8e80941Smrg
10436b8e80941Smrg   case MESA_FORMAT_I_SNORM16:
10437b8e80941Smrg      for (i = 0; i < n; ++i) {
10438b8e80941Smrg         pack_float_i_snorm16(src[i], d);
10439b8e80941Smrg         d += 2;
10440b8e80941Smrg      }
10441b8e80941Smrg      break;
10442b8e80941Smrg
10443b8e80941Smrg   case MESA_FORMAT_R_SNORM8:
10444b8e80941Smrg      for (i = 0; i < n; ++i) {
10445b8e80941Smrg         pack_float_r_snorm8(src[i], d);
10446b8e80941Smrg         d += 1;
10447b8e80941Smrg      }
10448b8e80941Smrg      break;
10449b8e80941Smrg
10450b8e80941Smrg   case MESA_FORMAT_R_SNORM16:
10451b8e80941Smrg      for (i = 0; i < n; ++i) {
10452b8e80941Smrg         pack_float_r_snorm16(src[i], d);
10453b8e80941Smrg         d += 2;
10454b8e80941Smrg      }
10455b8e80941Smrg      break;
10456b8e80941Smrg
10457b8e80941Smrg   case MESA_FORMAT_LA_SNORM16:
10458b8e80941Smrg      for (i = 0; i < n; ++i) {
10459b8e80941Smrg         pack_float_la_snorm16(src[i], d);
10460b8e80941Smrg         d += 4;
10461b8e80941Smrg      }
10462b8e80941Smrg      break;
10463b8e80941Smrg
10464b8e80941Smrg   case MESA_FORMAT_RGB_SNORM16:
10465b8e80941Smrg      for (i = 0; i < n; ++i) {
10466b8e80941Smrg         pack_float_rgb_snorm16(src[i], d);
10467b8e80941Smrg         d += 6;
10468b8e80941Smrg      }
10469b8e80941Smrg      break;
10470b8e80941Smrg
10471b8e80941Smrg   case MESA_FORMAT_RGBA_SNORM16:
10472b8e80941Smrg      for (i = 0; i < n; ++i) {
10473b8e80941Smrg         pack_float_rgba_snorm16(src[i], d);
10474b8e80941Smrg         d += 8;
10475b8e80941Smrg      }
10476b8e80941Smrg      break;
10477b8e80941Smrg
10478b8e80941Smrg   case MESA_FORMAT_RGBX_SNORM16:
10479b8e80941Smrg      for (i = 0; i < n; ++i) {
10480b8e80941Smrg         pack_float_rgbx_snorm16(src[i], d);
10481b8e80941Smrg         d += 8;
10482b8e80941Smrg      }
10483b8e80941Smrg      break;
10484b8e80941Smrg
10485b8e80941Smrg   case MESA_FORMAT_A8B8G8R8_SRGB:
10486b8e80941Smrg      for (i = 0; i < n; ++i) {
10487b8e80941Smrg         pack_float_a8b8g8r8_srgb(src[i], d);
10488b8e80941Smrg         d += 4;
10489b8e80941Smrg      }
10490b8e80941Smrg      break;
10491b8e80941Smrg
10492b8e80941Smrg   case MESA_FORMAT_B8G8R8A8_SRGB:
10493b8e80941Smrg      for (i = 0; i < n; ++i) {
10494b8e80941Smrg         pack_float_b8g8r8a8_srgb(src[i], d);
10495b8e80941Smrg         d += 4;
10496b8e80941Smrg      }
10497b8e80941Smrg      break;
10498b8e80941Smrg
10499b8e80941Smrg   case MESA_FORMAT_A8R8G8B8_SRGB:
10500b8e80941Smrg      for (i = 0; i < n; ++i) {
10501b8e80941Smrg         pack_float_a8r8g8b8_srgb(src[i], d);
10502b8e80941Smrg         d += 4;
10503b8e80941Smrg      }
10504b8e80941Smrg      break;
10505b8e80941Smrg
10506b8e80941Smrg   case MESA_FORMAT_B8G8R8X8_SRGB:
10507b8e80941Smrg      for (i = 0; i < n; ++i) {
10508b8e80941Smrg         pack_float_b8g8r8x8_srgb(src[i], d);
10509b8e80941Smrg         d += 4;
10510b8e80941Smrg      }
10511b8e80941Smrg      break;
10512b8e80941Smrg
10513b8e80941Smrg   case MESA_FORMAT_X8R8G8B8_SRGB:
10514b8e80941Smrg      for (i = 0; i < n; ++i) {
10515b8e80941Smrg         pack_float_x8r8g8b8_srgb(src[i], d);
10516b8e80941Smrg         d += 4;
10517b8e80941Smrg      }
10518b8e80941Smrg      break;
10519b8e80941Smrg
10520b8e80941Smrg   case MESA_FORMAT_R8G8B8A8_SRGB:
10521b8e80941Smrg      for (i = 0; i < n; ++i) {
10522b8e80941Smrg         pack_float_r8g8b8a8_srgb(src[i], d);
10523b8e80941Smrg         d += 4;
10524b8e80941Smrg      }
10525b8e80941Smrg      break;
10526b8e80941Smrg
10527b8e80941Smrg   case MESA_FORMAT_R8G8B8X8_SRGB:
10528b8e80941Smrg      for (i = 0; i < n; ++i) {
10529b8e80941Smrg         pack_float_r8g8b8x8_srgb(src[i], d);
10530b8e80941Smrg         d += 4;
10531b8e80941Smrg      }
10532b8e80941Smrg      break;
10533b8e80941Smrg
10534b8e80941Smrg   case MESA_FORMAT_X8B8G8R8_SRGB:
10535b8e80941Smrg      for (i = 0; i < n; ++i) {
10536b8e80941Smrg         pack_float_x8b8g8r8_srgb(src[i], d);
10537b8e80941Smrg         d += 4;
10538b8e80941Smrg      }
10539b8e80941Smrg      break;
10540b8e80941Smrg
10541b8e80941Smrg   case MESA_FORMAT_L8A8_SRGB:
10542b8e80941Smrg      for (i = 0; i < n; ++i) {
10543b8e80941Smrg         pack_float_l8a8_srgb(src[i], d);
10544b8e80941Smrg         d += 2;
10545b8e80941Smrg      }
10546b8e80941Smrg      break;
10547b8e80941Smrg
10548b8e80941Smrg   case MESA_FORMAT_A8L8_SRGB:
10549b8e80941Smrg      for (i = 0; i < n; ++i) {
10550b8e80941Smrg         pack_float_a8l8_srgb(src[i], d);
10551b8e80941Smrg         d += 2;
10552b8e80941Smrg      }
10553b8e80941Smrg      break;
10554b8e80941Smrg
10555b8e80941Smrg   case MESA_FORMAT_R_SRGB8:
10556b8e80941Smrg      for (i = 0; i < n; ++i) {
10557b8e80941Smrg         pack_float_r_srgb8(src[i], d);
10558b8e80941Smrg         d += 1;
10559b8e80941Smrg      }
10560b8e80941Smrg      break;
10561b8e80941Smrg
10562b8e80941Smrg   case MESA_FORMAT_L_SRGB8:
10563b8e80941Smrg      for (i = 0; i < n; ++i) {
10564b8e80941Smrg         pack_float_l_srgb8(src[i], d);
10565b8e80941Smrg         d += 1;
10566b8e80941Smrg      }
10567b8e80941Smrg      break;
10568b8e80941Smrg
10569b8e80941Smrg   case MESA_FORMAT_BGR_SRGB8:
10570b8e80941Smrg      for (i = 0; i < n; ++i) {
10571b8e80941Smrg         pack_float_bgr_srgb8(src[i], d);
10572b8e80941Smrg         d += 3;
10573b8e80941Smrg      }
10574b8e80941Smrg      break;
10575b8e80941Smrg
10576b8e80941Smrg   case MESA_FORMAT_R9G9B9E5_FLOAT:
10577b8e80941Smrg      for (i = 0; i < n; ++i) {
10578b8e80941Smrg         pack_float_r9g9b9e5_float(src[i], d);
10579b8e80941Smrg         d += 4;
10580b8e80941Smrg      }
10581b8e80941Smrg      break;
10582b8e80941Smrg
10583b8e80941Smrg   case MESA_FORMAT_R11G11B10_FLOAT:
10584b8e80941Smrg      for (i = 0; i < n; ++i) {
10585b8e80941Smrg         pack_float_r11g11b10_float(src[i], d);
10586b8e80941Smrg         d += 4;
10587b8e80941Smrg      }
10588b8e80941Smrg      break;
10589b8e80941Smrg
10590b8e80941Smrg   case MESA_FORMAT_A_FLOAT16:
10591b8e80941Smrg      for (i = 0; i < n; ++i) {
10592b8e80941Smrg         pack_float_a_float16(src[i], d);
10593b8e80941Smrg         d += 2;
10594b8e80941Smrg      }
10595b8e80941Smrg      break;
10596b8e80941Smrg
10597b8e80941Smrg   case MESA_FORMAT_A_FLOAT32:
10598b8e80941Smrg      for (i = 0; i < n; ++i) {
10599b8e80941Smrg         pack_float_a_float32(src[i], d);
10600b8e80941Smrg         d += 4;
10601b8e80941Smrg      }
10602b8e80941Smrg      break;
10603b8e80941Smrg
10604b8e80941Smrg   case MESA_FORMAT_L_FLOAT16:
10605b8e80941Smrg      for (i = 0; i < n; ++i) {
10606b8e80941Smrg         pack_float_l_float16(src[i], d);
10607b8e80941Smrg         d += 2;
10608b8e80941Smrg      }
10609b8e80941Smrg      break;
10610b8e80941Smrg
10611b8e80941Smrg   case MESA_FORMAT_L_FLOAT32:
10612b8e80941Smrg      for (i = 0; i < n; ++i) {
10613b8e80941Smrg         pack_float_l_float32(src[i], d);
10614b8e80941Smrg         d += 4;
10615b8e80941Smrg      }
10616b8e80941Smrg      break;
10617b8e80941Smrg
10618b8e80941Smrg   case MESA_FORMAT_LA_FLOAT16:
10619b8e80941Smrg      for (i = 0; i < n; ++i) {
10620b8e80941Smrg         pack_float_la_float16(src[i], d);
10621b8e80941Smrg         d += 4;
10622b8e80941Smrg      }
10623b8e80941Smrg      break;
10624b8e80941Smrg
10625b8e80941Smrg   case MESA_FORMAT_LA_FLOAT32:
10626b8e80941Smrg      for (i = 0; i < n; ++i) {
10627b8e80941Smrg         pack_float_la_float32(src[i], d);
10628b8e80941Smrg         d += 8;
10629b8e80941Smrg      }
10630b8e80941Smrg      break;
10631b8e80941Smrg
10632b8e80941Smrg   case MESA_FORMAT_I_FLOAT16:
10633b8e80941Smrg      for (i = 0; i < n; ++i) {
10634b8e80941Smrg         pack_float_i_float16(src[i], d);
10635b8e80941Smrg         d += 2;
10636b8e80941Smrg      }
10637b8e80941Smrg      break;
10638b8e80941Smrg
10639b8e80941Smrg   case MESA_FORMAT_I_FLOAT32:
10640b8e80941Smrg      for (i = 0; i < n; ++i) {
10641b8e80941Smrg         pack_float_i_float32(src[i], d);
10642b8e80941Smrg         d += 4;
10643b8e80941Smrg      }
10644b8e80941Smrg      break;
10645b8e80941Smrg
10646b8e80941Smrg   case MESA_FORMAT_R_FLOAT16:
10647b8e80941Smrg      for (i = 0; i < n; ++i) {
10648b8e80941Smrg         pack_float_r_float16(src[i], d);
10649b8e80941Smrg         d += 2;
10650b8e80941Smrg      }
10651b8e80941Smrg      break;
10652b8e80941Smrg
10653b8e80941Smrg   case MESA_FORMAT_R_FLOAT32:
10654b8e80941Smrg      for (i = 0; i < n; ++i) {
10655b8e80941Smrg         pack_float_r_float32(src[i], d);
10656b8e80941Smrg         d += 4;
10657b8e80941Smrg      }
10658b8e80941Smrg      break;
10659b8e80941Smrg
10660b8e80941Smrg   case MESA_FORMAT_RG_FLOAT16:
10661b8e80941Smrg      for (i = 0; i < n; ++i) {
10662b8e80941Smrg         pack_float_rg_float16(src[i], d);
10663b8e80941Smrg         d += 4;
10664b8e80941Smrg      }
10665b8e80941Smrg      break;
10666b8e80941Smrg
10667b8e80941Smrg   case MESA_FORMAT_RG_FLOAT32:
10668b8e80941Smrg      for (i = 0; i < n; ++i) {
10669b8e80941Smrg         pack_float_rg_float32(src[i], d);
10670b8e80941Smrg         d += 8;
10671b8e80941Smrg      }
10672b8e80941Smrg      break;
10673b8e80941Smrg
10674b8e80941Smrg   case MESA_FORMAT_RGB_FLOAT16:
10675b8e80941Smrg      for (i = 0; i < n; ++i) {
10676b8e80941Smrg         pack_float_rgb_float16(src[i], d);
10677b8e80941Smrg         d += 6;
10678b8e80941Smrg      }
10679b8e80941Smrg      break;
10680b8e80941Smrg
10681b8e80941Smrg   case MESA_FORMAT_RGB_FLOAT32:
10682b8e80941Smrg      for (i = 0; i < n; ++i) {
10683b8e80941Smrg         pack_float_rgb_float32(src[i], d);
10684b8e80941Smrg         d += 12;
10685b8e80941Smrg      }
10686b8e80941Smrg      break;
10687b8e80941Smrg
10688b8e80941Smrg   case MESA_FORMAT_RGBA_FLOAT16:
10689b8e80941Smrg      for (i = 0; i < n; ++i) {
10690b8e80941Smrg         pack_float_rgba_float16(src[i], d);
10691b8e80941Smrg         d += 8;
10692b8e80941Smrg      }
10693b8e80941Smrg      break;
10694b8e80941Smrg
10695b8e80941Smrg   case MESA_FORMAT_RGBA_FLOAT32:
10696b8e80941Smrg      for (i = 0; i < n; ++i) {
10697b8e80941Smrg         pack_float_rgba_float32(src[i], d);
10698b8e80941Smrg         d += 16;
10699b8e80941Smrg      }
10700b8e80941Smrg      break;
10701b8e80941Smrg
10702b8e80941Smrg   case MESA_FORMAT_RGBX_FLOAT16:
10703b8e80941Smrg      for (i = 0; i < n; ++i) {
10704b8e80941Smrg         pack_float_rgbx_float16(src[i], d);
10705b8e80941Smrg         d += 8;
10706b8e80941Smrg      }
10707b8e80941Smrg      break;
10708b8e80941Smrg
10709b8e80941Smrg   case MESA_FORMAT_RGBX_FLOAT32:
10710b8e80941Smrg      for (i = 0; i < n; ++i) {
10711b8e80941Smrg         pack_float_rgbx_float32(src[i], d);
10712b8e80941Smrg         d += 16;
10713b8e80941Smrg      }
10714b8e80941Smrg      break;
10715b8e80941Smrg                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       default:
10716b8e80941Smrg      assert(!"Invalid format");
10717b8e80941Smrg   }
10718b8e80941Smrg}
10719b8e80941Smrg
10720b8e80941Smrg/**
10721b8e80941Smrg * Pack a 2D image of ubyte RGBA pixels in the given format.
10722b8e80941Smrg * \param srcRowStride  source image row stride in bytes
10723b8e80941Smrg * \param dstRowStride  destination image row stride in bytes
10724b8e80941Smrg */
10725b8e80941Smrgvoid
10726b8e80941Smrg_mesa_pack_ubyte_rgba_rect(mesa_format format, GLuint width, GLuint height,
10727b8e80941Smrg                           const GLubyte *src, GLint srcRowStride,
10728b8e80941Smrg                           void *dst, GLint dstRowStride)
10729b8e80941Smrg{
10730b8e80941Smrg   GLubyte *dstUB = dst;
10731b8e80941Smrg   GLuint i;
10732b8e80941Smrg
10733b8e80941Smrg   if (srcRowStride == width * 4 * sizeof(GLubyte) &&
10734b8e80941Smrg       dstRowStride == _mesa_format_row_stride(format, width)) {
10735b8e80941Smrg      /* do whole image at once */
10736b8e80941Smrg      _mesa_pack_ubyte_rgba_row(format, width * height,
10737b8e80941Smrg                                (const GLubyte (*)[4]) src, dst);
10738b8e80941Smrg   }
10739b8e80941Smrg   else {
10740b8e80941Smrg      /* row by row */
10741b8e80941Smrg      for (i = 0; i < height; i++) {
10742b8e80941Smrg         _mesa_pack_ubyte_rgba_row(format, width,
10743b8e80941Smrg                                   (const GLubyte (*)[4]) src, dstUB);
10744b8e80941Smrg         src += srcRowStride;
10745b8e80941Smrg         dstUB += dstRowStride;
10746b8e80941Smrg      }
10747b8e80941Smrg   }
10748b8e80941Smrg}
10749b8e80941Smrg
10750b8e80941Smrg
10751b8e80941Smrg/** Helper struct for MESA_FORMAT_Z32_FLOAT_S8X24_UINT */
10752b8e80941Smrgstruct z32f_x24s8
10753b8e80941Smrg{
10754b8e80941Smrg   float z;
10755b8e80941Smrg   uint32_t x24s8;
10756b8e80941Smrg};
10757b8e80941Smrg
10758b8e80941Smrg
10759b8e80941Smrg/**
10760b8e80941Smrg ** Pack float Z pixels
10761b8e80941Smrg **/
10762b8e80941Smrg
10763b8e80941Smrgstatic void
10764b8e80941Smrgpack_float_S8_UINT_Z24_UNORM(const GLfloat *src, void *dst)
10765b8e80941Smrg{
10766b8e80941Smrg   /* don't disturb the stencil values */
10767b8e80941Smrg   GLuint *d = ((GLuint *) dst);
10768b8e80941Smrg   const GLdouble scale = (GLdouble) 0xffffff;
10769b8e80941Smrg   GLuint s = *d & 0xff;
10770b8e80941Smrg   GLuint z = (GLuint) (*src * scale);
10771b8e80941Smrg   assert(z <= 0xffffff);
10772b8e80941Smrg   *d = (z << 8) | s;
10773b8e80941Smrg}
10774b8e80941Smrg
10775b8e80941Smrgstatic void
10776b8e80941Smrgpack_float_Z24_UNORM_S8_UINT(const GLfloat *src, void *dst)
10777b8e80941Smrg{
10778b8e80941Smrg   /* don't disturb the stencil values */
10779b8e80941Smrg   GLuint *d = ((GLuint *) dst);
10780b8e80941Smrg   const GLdouble scale = (GLdouble) 0xffffff;
10781b8e80941Smrg   GLuint s = *d & 0xff000000;
10782b8e80941Smrg   GLuint z = (GLuint) (*src * scale);
10783b8e80941Smrg   assert(z <= 0xffffff);
10784b8e80941Smrg   *d = s | z;
10785b8e80941Smrg}
10786b8e80941Smrg
10787b8e80941Smrgstatic void
10788b8e80941Smrgpack_float_Z_UNORM16(const GLfloat *src, void *dst)
10789b8e80941Smrg{
10790b8e80941Smrg   GLushort *d = ((GLushort *) dst);
10791b8e80941Smrg   const GLfloat scale = (GLfloat) 0xffff;
10792b8e80941Smrg   *d = (GLushort) (*src * scale);
10793b8e80941Smrg}
10794b8e80941Smrg
10795b8e80941Smrgstatic void
10796b8e80941Smrgpack_float_Z_UNORM32(const GLfloat *src, void *dst)
10797b8e80941Smrg{
10798b8e80941Smrg   GLuint *d = ((GLuint *) dst);
10799b8e80941Smrg   const GLdouble scale = (GLdouble) 0xffffffff;
10800b8e80941Smrg   *d = (GLuint) (*src * scale);
10801b8e80941Smrg}
10802b8e80941Smrg
10803b8e80941Smrg/**
10804b8e80941Smrg ** Pack float to Z_FLOAT32 or Z_FLOAT32_X24S8.
10805b8e80941Smrg **/
10806b8e80941Smrg
10807b8e80941Smrgstatic void
10808b8e80941Smrgpack_float_Z_FLOAT32(const GLfloat *src, void *dst)
10809b8e80941Smrg{
10810b8e80941Smrg   GLfloat *d = (GLfloat *) dst;
10811b8e80941Smrg   *d = *src;
10812b8e80941Smrg}
10813b8e80941Smrg
10814b8e80941Smrggl_pack_float_z_func
10815b8e80941Smrg_mesa_get_pack_float_z_func(mesa_format format)
10816b8e80941Smrg{
10817b8e80941Smrg   switch (format) {
10818b8e80941Smrg   case MESA_FORMAT_S8_UINT_Z24_UNORM:
10819b8e80941Smrg   case MESA_FORMAT_X8_UINT_Z24_UNORM:
10820b8e80941Smrg      return pack_float_S8_UINT_Z24_UNORM;
10821b8e80941Smrg   case MESA_FORMAT_Z24_UNORM_S8_UINT:
10822b8e80941Smrg   case MESA_FORMAT_Z24_UNORM_X8_UINT:
10823b8e80941Smrg      return pack_float_Z24_UNORM_S8_UINT;
10824b8e80941Smrg   case MESA_FORMAT_Z_UNORM16:
10825b8e80941Smrg      return pack_float_Z_UNORM16;
10826b8e80941Smrg   case MESA_FORMAT_Z_UNORM32:
10827b8e80941Smrg      return pack_float_Z_UNORM32;
10828b8e80941Smrg   case MESA_FORMAT_Z_FLOAT32:
10829b8e80941Smrg   case MESA_FORMAT_Z32_FLOAT_S8X24_UINT:
10830b8e80941Smrg      return pack_float_Z_FLOAT32;
10831b8e80941Smrg   default:
10832b8e80941Smrg      _mesa_problem(NULL,
10833b8e80941Smrg                    "unexpected format in _mesa_get_pack_float_z_func()");
10834b8e80941Smrg      return NULL;
10835b8e80941Smrg   }
10836b8e80941Smrg}
10837b8e80941Smrg
10838b8e80941Smrg
10839b8e80941Smrg
10840b8e80941Smrg/**
10841b8e80941Smrg ** Pack uint Z pixels.  The incoming src value is always in
10842b8e80941Smrg ** the range [0, 2^32-1].
10843b8e80941Smrg **/
10844b8e80941Smrg
10845b8e80941Smrgstatic void
10846b8e80941Smrgpack_uint_S8_UINT_Z24_UNORM(const GLuint *src, void *dst)
10847b8e80941Smrg{
10848b8e80941Smrg   /* don't disturb the stencil values */
10849b8e80941Smrg   GLuint *d = ((GLuint *) dst);
10850b8e80941Smrg   GLuint s = *d & 0xff;
10851b8e80941Smrg   GLuint z = *src & 0xffffff00;
10852b8e80941Smrg   *d = z | s;
10853b8e80941Smrg}
10854b8e80941Smrg
10855b8e80941Smrgstatic void
10856b8e80941Smrgpack_uint_Z24_UNORM_S8_UINT(const GLuint *src, void *dst)
10857b8e80941Smrg{
10858b8e80941Smrg   /* don't disturb the stencil values */
10859b8e80941Smrg   GLuint *d = ((GLuint *) dst);
10860b8e80941Smrg   GLuint s = *d & 0xff000000;
10861b8e80941Smrg   GLuint z = *src >> 8;
10862b8e80941Smrg   *d = s | z;
10863b8e80941Smrg}
10864b8e80941Smrg
10865b8e80941Smrgstatic void
10866b8e80941Smrgpack_uint_Z_UNORM16(const GLuint *src, void *dst)
10867b8e80941Smrg{
10868b8e80941Smrg   GLushort *d = ((GLushort *) dst);
10869b8e80941Smrg   *d = *src >> 16;
10870b8e80941Smrg}
10871b8e80941Smrg
10872b8e80941Smrgstatic void
10873b8e80941Smrgpack_uint_Z_UNORM32(const GLuint *src, void *dst)
10874b8e80941Smrg{
10875b8e80941Smrg   GLuint *d = ((GLuint *) dst);
10876b8e80941Smrg   *d = *src;
10877b8e80941Smrg}
10878b8e80941Smrg
10879b8e80941Smrg/**
10880b8e80941Smrg ** Pack uint to Z_FLOAT32 or Z_FLOAT32_X24S8.
10881b8e80941Smrg **/
10882b8e80941Smrg
10883b8e80941Smrgstatic void
10884b8e80941Smrgpack_uint_Z_FLOAT32(const GLuint *src, void *dst)
10885b8e80941Smrg{
10886b8e80941Smrg   GLfloat *d = ((GLfloat *) dst);
10887b8e80941Smrg   const GLdouble scale = 1.0 / (GLdouble) 0xffffffff;
10888b8e80941Smrg   *d = (GLfloat) (*src * scale);
10889b8e80941Smrg   assert(*d >= 0.0f);
10890b8e80941Smrg   assert(*d <= 1.0f);
10891b8e80941Smrg}
10892b8e80941Smrg
10893b8e80941Smrggl_pack_uint_z_func
10894b8e80941Smrg_mesa_get_pack_uint_z_func(mesa_format format)
10895b8e80941Smrg{
10896b8e80941Smrg   switch (format) {
10897b8e80941Smrg   case MESA_FORMAT_S8_UINT_Z24_UNORM:
10898b8e80941Smrg   case MESA_FORMAT_X8_UINT_Z24_UNORM:
10899b8e80941Smrg      return pack_uint_S8_UINT_Z24_UNORM;
10900b8e80941Smrg   case MESA_FORMAT_Z24_UNORM_S8_UINT:
10901b8e80941Smrg   case MESA_FORMAT_Z24_UNORM_X8_UINT:
10902b8e80941Smrg      return pack_uint_Z24_UNORM_S8_UINT;
10903b8e80941Smrg   case MESA_FORMAT_Z_UNORM16:
10904b8e80941Smrg      return pack_uint_Z_UNORM16;
10905b8e80941Smrg   case MESA_FORMAT_Z_UNORM32:
10906b8e80941Smrg      return pack_uint_Z_UNORM32;
10907b8e80941Smrg   case MESA_FORMAT_Z_FLOAT32:
10908b8e80941Smrg   case MESA_FORMAT_Z32_FLOAT_S8X24_UINT:
10909b8e80941Smrg      return pack_uint_Z_FLOAT32;
10910b8e80941Smrg   default:
10911b8e80941Smrg      _mesa_problem(NULL, "unexpected format in _mesa_get_pack_uint_z_func()");
10912b8e80941Smrg      return NULL;
10913b8e80941Smrg   }
10914b8e80941Smrg}
10915b8e80941Smrg
10916b8e80941Smrg
10917b8e80941Smrg/**
10918b8e80941Smrg ** Pack ubyte stencil pixels
10919b8e80941Smrg **/
10920b8e80941Smrg
10921b8e80941Smrgstatic void
10922b8e80941Smrgpack_ubyte_stencil_Z24_S8(const GLubyte *src, void *dst)
10923b8e80941Smrg{
10924b8e80941Smrg   /* don't disturb the Z values */
10925b8e80941Smrg   GLuint *d = ((GLuint *) dst);
10926b8e80941Smrg   GLuint s = *src;
10927b8e80941Smrg   GLuint z = *d & 0xffffff00;
10928b8e80941Smrg   *d = z | s;
10929b8e80941Smrg}
10930b8e80941Smrg
10931b8e80941Smrgstatic void
10932b8e80941Smrgpack_ubyte_stencil_S8_Z24(const GLubyte *src, void *dst)
10933b8e80941Smrg{
10934b8e80941Smrg   /* don't disturb the Z values */
10935b8e80941Smrg   GLuint *d = ((GLuint *) dst);
10936b8e80941Smrg   GLuint s = *src << 24;
10937b8e80941Smrg   GLuint z = *d & 0xffffff;
10938b8e80941Smrg   *d = s | z;
10939b8e80941Smrg}
10940b8e80941Smrg
10941b8e80941Smrgstatic void
10942b8e80941Smrgpack_ubyte_stencil_S8(const GLubyte *src, void *dst)
10943b8e80941Smrg{
10944b8e80941Smrg   GLubyte *d = (GLubyte *) dst;
10945b8e80941Smrg   *d = *src;
10946b8e80941Smrg}
10947b8e80941Smrg
10948b8e80941Smrgstatic void
10949b8e80941Smrgpack_ubyte_stencil_Z32_FLOAT_X24S8(const GLubyte *src, void *dst)
10950b8e80941Smrg{
10951b8e80941Smrg   GLfloat *d = ((GLfloat *) dst);
10952b8e80941Smrg   d[1] = *src;
10953b8e80941Smrg}
10954b8e80941Smrg
10955b8e80941Smrg
10956b8e80941Smrggl_pack_ubyte_stencil_func
10957b8e80941Smrg_mesa_get_pack_ubyte_stencil_func(mesa_format format)
10958b8e80941Smrg{
10959b8e80941Smrg   switch (format) {
10960b8e80941Smrg   case MESA_FORMAT_S8_UINT_Z24_UNORM:
10961b8e80941Smrg      return pack_ubyte_stencil_Z24_S8;
10962b8e80941Smrg   case MESA_FORMAT_Z24_UNORM_S8_UINT:
10963b8e80941Smrg      return pack_ubyte_stencil_S8_Z24;
10964b8e80941Smrg   case MESA_FORMAT_S_UINT8:
10965b8e80941Smrg      return pack_ubyte_stencil_S8;
10966b8e80941Smrg   case MESA_FORMAT_Z32_FLOAT_S8X24_UINT:
10967b8e80941Smrg      return pack_ubyte_stencil_Z32_FLOAT_X24S8;
10968b8e80941Smrg   default:
10969b8e80941Smrg      _mesa_problem(NULL,
10970b8e80941Smrg                    "unexpected format in _mesa_pack_ubyte_stencil_func()");
10971b8e80941Smrg      return NULL;
10972b8e80941Smrg   }
10973b8e80941Smrg}
10974b8e80941Smrg
10975b8e80941Smrg
10976b8e80941Smrg
10977b8e80941Smrgvoid
10978b8e80941Smrg_mesa_pack_float_z_row(mesa_format format, GLuint n,
10979b8e80941Smrg                       const GLfloat *src, void *dst)
10980b8e80941Smrg{
10981b8e80941Smrg   switch (format) {
10982b8e80941Smrg   case MESA_FORMAT_S8_UINT_Z24_UNORM:
10983b8e80941Smrg   case MESA_FORMAT_X8_UINT_Z24_UNORM:
10984b8e80941Smrg      {
10985b8e80941Smrg         /* don't disturb the stencil values */
10986b8e80941Smrg         GLuint *d = ((GLuint *) dst);
10987b8e80941Smrg         const GLdouble scale = (GLdouble) 0xffffff;
10988b8e80941Smrg         GLuint i;
10989b8e80941Smrg         for (i = 0; i < n; i++) {
10990b8e80941Smrg            GLuint s = d[i] & 0xff;
10991b8e80941Smrg            GLuint z = (GLuint) (src[i] * scale);
10992b8e80941Smrg            assert(z <= 0xffffff);
10993b8e80941Smrg            d[i] = (z << 8) | s;
10994b8e80941Smrg         }
10995b8e80941Smrg      }
10996b8e80941Smrg      break;
10997b8e80941Smrg   case MESA_FORMAT_Z24_UNORM_S8_UINT:
10998b8e80941Smrg   case MESA_FORMAT_Z24_UNORM_X8_UINT:
10999b8e80941Smrg      {
11000b8e80941Smrg         /* don't disturb the stencil values */
11001b8e80941Smrg         GLuint *d = ((GLuint *) dst);
11002b8e80941Smrg         const GLdouble scale = (GLdouble) 0xffffff;
11003b8e80941Smrg         GLuint i;
11004b8e80941Smrg         for (i = 0; i < n; i++) {
11005b8e80941Smrg            GLuint s = d[i] & 0xff000000;
11006b8e80941Smrg            GLuint z = (GLuint) (src[i] * scale);
11007b8e80941Smrg            assert(z <= 0xffffff);
11008b8e80941Smrg            d[i] = s | z;
11009b8e80941Smrg         }
11010b8e80941Smrg      }
11011b8e80941Smrg      break;
11012b8e80941Smrg   case MESA_FORMAT_Z_UNORM16:
11013b8e80941Smrg      {
11014b8e80941Smrg         GLushort *d = ((GLushort *) dst);
11015b8e80941Smrg         const GLfloat scale = (GLfloat) 0xffff;
11016b8e80941Smrg         GLuint i;
11017b8e80941Smrg         for (i = 0; i < n; i++) {
11018b8e80941Smrg            d[i] = (GLushort) (src[i] * scale);
11019b8e80941Smrg         }
11020b8e80941Smrg      }
11021b8e80941Smrg      break;
11022b8e80941Smrg   case MESA_FORMAT_Z_UNORM32:
11023b8e80941Smrg      {
11024b8e80941Smrg         GLuint *d = ((GLuint *) dst);
11025b8e80941Smrg         const GLdouble scale = (GLdouble) 0xffffffff;
11026b8e80941Smrg         GLuint i;
11027b8e80941Smrg         for (i = 0; i < n; i++) {
11028b8e80941Smrg            d[i] = (GLuint) (src[i] * scale);
11029b8e80941Smrg         }
11030b8e80941Smrg      }
11031b8e80941Smrg      break;
11032b8e80941Smrg   case MESA_FORMAT_Z_FLOAT32:
11033b8e80941Smrg      memcpy(dst, src, n * sizeof(GLfloat));
11034b8e80941Smrg      break;
11035b8e80941Smrg   case MESA_FORMAT_Z32_FLOAT_S8X24_UINT:
11036b8e80941Smrg      {
11037b8e80941Smrg         struct z32f_x24s8 *d = (struct z32f_x24s8 *) dst;
11038b8e80941Smrg         GLuint i;
11039b8e80941Smrg         for (i = 0; i < n; i++) {
11040b8e80941Smrg            d[i].z = src[i];
11041b8e80941Smrg         }
11042b8e80941Smrg      }
11043b8e80941Smrg      break;
11044b8e80941Smrg   default:
11045b8e80941Smrg      _mesa_problem(NULL, "unexpected format in _mesa_pack_float_z_row()");
11046b8e80941Smrg   }
11047b8e80941Smrg}
11048b8e80941Smrg
11049b8e80941Smrg
11050b8e80941Smrg/**
11051b8e80941Smrg * The incoming Z values are always in the range [0, 0xffffffff].
11052b8e80941Smrg */
11053b8e80941Smrgvoid
11054b8e80941Smrg_mesa_pack_uint_z_row(mesa_format format, GLuint n,
11055b8e80941Smrg                      const GLuint *src, void *dst)
11056b8e80941Smrg{
11057b8e80941Smrg   switch (format) {
11058b8e80941Smrg   case MESA_FORMAT_S8_UINT_Z24_UNORM:
11059b8e80941Smrg   case MESA_FORMAT_X8_UINT_Z24_UNORM:
11060b8e80941Smrg      {
11061b8e80941Smrg         /* don't disturb the stencil values */
11062b8e80941Smrg         GLuint *d = ((GLuint *) dst);
11063b8e80941Smrg         GLuint i;
11064b8e80941Smrg         for (i = 0; i < n; i++) {
11065b8e80941Smrg            GLuint s = d[i] & 0xff;
11066b8e80941Smrg            GLuint z = src[i] & 0xffffff00;
11067b8e80941Smrg            d[i] = z | s;
11068b8e80941Smrg         }
11069b8e80941Smrg      }
11070b8e80941Smrg      break;
11071b8e80941Smrg   case MESA_FORMAT_Z24_UNORM_S8_UINT:
11072b8e80941Smrg   case MESA_FORMAT_Z24_UNORM_X8_UINT:
11073b8e80941Smrg      {
11074b8e80941Smrg         /* don't disturb the stencil values */
11075b8e80941Smrg         GLuint *d = ((GLuint *) dst);
11076b8e80941Smrg         GLuint i;
11077b8e80941Smrg         for (i = 0; i < n; i++) {
11078b8e80941Smrg            GLuint s = d[i] & 0xff000000;
11079b8e80941Smrg            GLuint z = src[i] >> 8;
11080b8e80941Smrg            d[i] = s | z;
11081b8e80941Smrg         }
11082b8e80941Smrg      }
11083b8e80941Smrg      break;
11084b8e80941Smrg   case MESA_FORMAT_Z_UNORM16:
11085b8e80941Smrg      {
11086b8e80941Smrg         GLushort *d = ((GLushort *) dst);
11087b8e80941Smrg         GLuint i;
11088b8e80941Smrg         for (i = 0; i < n; i++) {
11089b8e80941Smrg            d[i] = src[i] >> 16;
11090b8e80941Smrg         }
11091b8e80941Smrg      }
11092b8e80941Smrg      break;
11093b8e80941Smrg   case MESA_FORMAT_Z_UNORM32:
11094b8e80941Smrg      memcpy(dst, src, n * sizeof(GLfloat));
11095b8e80941Smrg      break;
11096b8e80941Smrg   case MESA_FORMAT_Z_FLOAT32:
11097b8e80941Smrg      {
11098b8e80941Smrg         GLuint *d = ((GLuint *) dst);
11099b8e80941Smrg         const GLdouble scale = 1.0 / (GLdouble) 0xffffffff;
11100b8e80941Smrg         GLuint i;
11101b8e80941Smrg         for (i = 0; i < n; i++) {
11102b8e80941Smrg            d[i] = (GLuint) (src[i] * scale);
11103b8e80941Smrg            assert(d[i] >= 0.0f);
11104b8e80941Smrg            assert(d[i] <= 1.0f);
11105b8e80941Smrg         }
11106b8e80941Smrg      }
11107b8e80941Smrg      break;
11108b8e80941Smrg   case MESA_FORMAT_Z32_FLOAT_S8X24_UINT:
11109b8e80941Smrg      {
11110b8e80941Smrg         struct z32f_x24s8 *d = (struct z32f_x24s8 *) dst;
11111b8e80941Smrg         const GLdouble scale = 1.0 / (GLdouble) 0xffffffff;
11112b8e80941Smrg         GLuint i;
11113b8e80941Smrg         for (i = 0; i < n; i++) {
11114b8e80941Smrg            d[i].z = (GLfloat) (src[i] * scale);
11115b8e80941Smrg            assert(d[i].z >= 0.0f);
11116b8e80941Smrg            assert(d[i].z <= 1.0f);
11117b8e80941Smrg         }
11118b8e80941Smrg      }
11119b8e80941Smrg      break;
11120b8e80941Smrg   default:
11121b8e80941Smrg      _mesa_problem(NULL, "unexpected format in _mesa_pack_uint_z_row()");
11122b8e80941Smrg   }
11123b8e80941Smrg}
11124b8e80941Smrg
11125b8e80941Smrg
11126b8e80941Smrgvoid
11127b8e80941Smrg_mesa_pack_ubyte_stencil_row(mesa_format format, GLuint n,
11128b8e80941Smrg                             const GLubyte *src, void *dst)
11129b8e80941Smrg{
11130b8e80941Smrg   switch (format) {
11131b8e80941Smrg   case MESA_FORMAT_S8_UINT_Z24_UNORM:
11132b8e80941Smrg      {
11133b8e80941Smrg         /* don't disturb the Z values */
11134b8e80941Smrg         GLuint *d = ((GLuint *) dst);
11135b8e80941Smrg         GLuint i;
11136b8e80941Smrg         for (i = 0; i < n; i++) {
11137b8e80941Smrg            GLuint s = src[i];
11138b8e80941Smrg            GLuint z = d[i] & 0xffffff00;
11139b8e80941Smrg            d[i] = z | s;
11140b8e80941Smrg         }
11141b8e80941Smrg      }
11142b8e80941Smrg      break;
11143b8e80941Smrg   case MESA_FORMAT_Z24_UNORM_S8_UINT:
11144b8e80941Smrg      {
11145b8e80941Smrg         /* don't disturb the Z values */
11146b8e80941Smrg         GLuint *d = ((GLuint *) dst);
11147b8e80941Smrg         GLuint i;
11148b8e80941Smrg         for (i = 0; i < n; i++) {
11149b8e80941Smrg            GLuint s = src[i] << 24;
11150b8e80941Smrg            GLuint z = d[i] & 0xffffff;
11151b8e80941Smrg            d[i] = s | z;
11152b8e80941Smrg         }
11153b8e80941Smrg      }
11154b8e80941Smrg      break;
11155b8e80941Smrg   case MESA_FORMAT_S_UINT8:
11156b8e80941Smrg      memcpy(dst, src, n * sizeof(GLubyte));
11157b8e80941Smrg      break;
11158b8e80941Smrg   case MESA_FORMAT_Z32_FLOAT_S8X24_UINT:
11159b8e80941Smrg      {
11160b8e80941Smrg         struct z32f_x24s8 *d = (struct z32f_x24s8 *) dst;
11161b8e80941Smrg         GLuint i;
11162b8e80941Smrg         for (i = 0; i < n; i++) {
11163b8e80941Smrg            d[i].x24s8 = src[i];
11164b8e80941Smrg         }
11165b8e80941Smrg      }
11166b8e80941Smrg      break;
11167b8e80941Smrg   default:
11168b8e80941Smrg      _mesa_problem(NULL, "unexpected format in _mesa_pack_ubyte_stencil_row()");
11169b8e80941Smrg   }
11170b8e80941Smrg}
11171b8e80941Smrg
11172b8e80941Smrg
11173b8e80941Smrg/**
11174b8e80941Smrg * Incoming Z/stencil values are always in uint_24_8 format.
11175b8e80941Smrg */
11176b8e80941Smrgvoid
11177b8e80941Smrg_mesa_pack_uint_24_8_depth_stencil_row(mesa_format format, GLuint n,
11178b8e80941Smrg                                       const GLuint *src, void *dst)
11179b8e80941Smrg{
11180b8e80941Smrg   switch (format) {
11181b8e80941Smrg   case MESA_FORMAT_S8_UINT_Z24_UNORM:
11182b8e80941Smrg      memcpy(dst, src, n * sizeof(GLuint));
11183b8e80941Smrg      break;
11184b8e80941Smrg   case MESA_FORMAT_Z24_UNORM_S8_UINT:
11185b8e80941Smrg      {
11186b8e80941Smrg         GLuint *d = ((GLuint *) dst);
11187b8e80941Smrg         GLuint i;
11188b8e80941Smrg         for (i = 0; i < n; i++) {
11189b8e80941Smrg            GLuint s = src[i] << 24;
11190b8e80941Smrg            GLuint z = src[i] >> 8;
11191b8e80941Smrg            d[i] = s | z;
11192b8e80941Smrg         }
11193b8e80941Smrg      }
11194b8e80941Smrg      break;
11195b8e80941Smrg   case MESA_FORMAT_Z32_FLOAT_S8X24_UINT:
11196b8e80941Smrg      {
11197b8e80941Smrg         const GLdouble scale = 1.0 / (GLdouble) 0xffffff;
11198b8e80941Smrg         struct z32f_x24s8 *d = (struct z32f_x24s8 *) dst;
11199b8e80941Smrg         GLuint i;
11200b8e80941Smrg         for (i = 0; i < n; i++) {
11201b8e80941Smrg            GLfloat z = (GLfloat) ((src[i] >> 8) * scale);
11202b8e80941Smrg            d[i].z = z;
11203b8e80941Smrg            d[i].x24s8 = src[i];
11204b8e80941Smrg         }
11205b8e80941Smrg      }
11206b8e80941Smrg      break;
11207b8e80941Smrg   default:
11208b8e80941Smrg      _mesa_problem(NULL, "bad format %s in _mesa_pack_ubyte_s_row",
11209b8e80941Smrg                    _mesa_get_format_name(format));
11210b8e80941Smrg      return;
11211b8e80941Smrg   }
11212b8e80941Smrg}
11213b8e80941Smrg
11214b8e80941Smrg
11215b8e80941Smrg
11216b8e80941Smrg/**
11217b8e80941Smrg * Convert a boolean color mask to a packed color where each channel of
11218b8e80941Smrg * the packed value at dst will be 0 or ~0 depending on the colorMask.
11219b8e80941Smrg */
11220b8e80941Smrgvoid
11221b8e80941Smrg_mesa_pack_colormask(mesa_format format, const GLubyte colorMask[4], void *dst)
11222b8e80941Smrg{
11223b8e80941Smrg   GLfloat maskColor[4];
11224b8e80941Smrg
11225b8e80941Smrg   switch (_mesa_get_format_datatype(format)) {
11226b8e80941Smrg   case GL_UNSIGNED_NORMALIZED:
11227b8e80941Smrg      /* simple: 1.0 will convert to ~0 in the right bit positions */
11228b8e80941Smrg      maskColor[0] = colorMask[0] ? 1.0f : 0.0f;
11229b8e80941Smrg      maskColor[1] = colorMask[1] ? 1.0f : 0.0f;
11230b8e80941Smrg      maskColor[2] = colorMask[2] ? 1.0f : 0.0f;
11231b8e80941Smrg      maskColor[3] = colorMask[3] ? 1.0f : 0.0f;
11232b8e80941Smrg      _mesa_pack_float_rgba_row(format, 1,
11233b8e80941Smrg                                (const GLfloat (*)[4]) maskColor, dst);
11234b8e80941Smrg      break;
11235b8e80941Smrg   case GL_SIGNED_NORMALIZED:
11236b8e80941Smrg   case GL_FLOAT:
11237b8e80941Smrg      /* These formats are harder because it's hard to know the floating
11238b8e80941Smrg       * point values that will convert to ~0 for each color channel's bits.
11239b8e80941Smrg       * This solution just generates a non-zero value for each color channel
11240b8e80941Smrg       * then fixes up the non-zero values to be ~0.
11241b8e80941Smrg       * Note: we'll need to add special case code if we ever have to deal
11242b8e80941Smrg       * with formats with unequal color channel sizes, like R11_G11_B10.
11243b8e80941Smrg       * We issue a warning below for channel sizes other than 8,16,32.
11244b8e80941Smrg       */
11245b8e80941Smrg      {
11246b8e80941Smrg         GLuint bits = _mesa_get_format_max_bits(format); /* bits per chan */
11247b8e80941Smrg         GLuint bytes = _mesa_get_format_bytes(format);
11248b8e80941Smrg         GLuint i;
11249b8e80941Smrg
11250b8e80941Smrg         /* this should put non-zero values into the channels of dst */
11251b8e80941Smrg         maskColor[0] = colorMask[0] ? -1.0f : 0.0f;
11252b8e80941Smrg         maskColor[1] = colorMask[1] ? -1.0f : 0.0f;
11253b8e80941Smrg         maskColor[2] = colorMask[2] ? -1.0f : 0.0f;
11254b8e80941Smrg         maskColor[3] = colorMask[3] ? -1.0f : 0.0f;
11255b8e80941Smrg         _mesa_pack_float_rgba_row(format, 1,
11256b8e80941Smrg                                   (const GLfloat (*)[4]) maskColor, dst);
11257b8e80941Smrg
11258b8e80941Smrg         /* fix-up the dst channels by converting non-zero values to ~0 */
11259b8e80941Smrg         if (bits == 8) {
11260b8e80941Smrg            GLubyte *d = (GLubyte *) dst;
11261b8e80941Smrg            for (i = 0; i < bytes; i++) {
11262b8e80941Smrg               d[i] = d[i] ? 0xff : 0x0;
11263b8e80941Smrg            }
11264b8e80941Smrg         }
11265b8e80941Smrg         else if (bits == 16) {
11266b8e80941Smrg            GLushort *d = (GLushort *) dst;
11267b8e80941Smrg            for (i = 0; i < bytes / 2; i++) {
11268b8e80941Smrg               d[i] = d[i] ? 0xffff : 0x0;
11269b8e80941Smrg            }
11270b8e80941Smrg         }
11271b8e80941Smrg         else if (bits == 32) {
11272b8e80941Smrg            GLuint *d = (GLuint *) dst;
11273b8e80941Smrg            for (i = 0; i < bytes / 4; i++) {
11274b8e80941Smrg               d[i] = d[i] ? 0xffffffffU : 0x0;
11275b8e80941Smrg            }
11276b8e80941Smrg         }
11277b8e80941Smrg         else {
11278b8e80941Smrg            _mesa_problem(NULL, "unexpected size in _mesa_pack_colormask()");
11279b8e80941Smrg            return;
11280b8e80941Smrg         }
11281b8e80941Smrg      }
11282b8e80941Smrg      break;
11283b8e80941Smrg   default:
11284b8e80941Smrg      _mesa_problem(NULL, "unexpected format data type in gen_color_mask()");
11285b8e80941Smrg      return;
11286b8e80941Smrg   }
11287b8e80941Smrg}
11288b8e80941Smrg
11289