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 "errors.h"
42b8e80941Smrg#include "format_unpack.h"
43b8e80941Smrg#include "format_utils.h"
44b8e80941Smrg#include "macros.h"
45b8e80941Smrg#include "util/format_rgb9e5.h"
46b8e80941Smrg#include "util/format_r11g11b10f.h"
47b8e80941Smrg#include "util/format_srgb.h"
48b8e80941Smrg
49b8e80941Smrg#define UNPACK(SRC, OFFSET, BITS) (((SRC) >> (OFFSET)) & MAX_UINT(BITS))
50b8e80941Smrg
51b8e80941Smrg
52b8e80941Smrg
53b8e80941Smrg/* float unpacking functions */
54b8e80941Smrg
55b8e80941Smrg
56b8e80941Smrgstatic inline void
57b8e80941Smrgunpack_float_a8b8g8r8_unorm(const void *void_src, GLfloat dst[4])
58b8e80941Smrg{
59b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
60b8e80941Smrg            uint8_t a = UNPACK(*src, 0, 8);
61b8e80941Smrg            uint8_t b = UNPACK(*src, 8, 8);
62b8e80941Smrg            uint8_t g = UNPACK(*src, 16, 8);
63b8e80941Smrg            uint8_t r = UNPACK(*src, 24, 8);
64b8e80941Smrg
65b8e80941Smrg
66b8e80941Smrg
67b8e80941Smrg               dst[0] = _mesa_unorm_to_float(r, 8);
68b8e80941Smrg
69b8e80941Smrg
70b8e80941Smrg               dst[1] = _mesa_unorm_to_float(g, 8);
71b8e80941Smrg
72b8e80941Smrg
73b8e80941Smrg               dst[2] = _mesa_unorm_to_float(b, 8);
74b8e80941Smrg
75b8e80941Smrg
76b8e80941Smrg               dst[3] = _mesa_unorm_to_float(a, 8);
77b8e80941Smrg}
78b8e80941Smrg
79b8e80941Smrgstatic inline void
80b8e80941Smrgunpack_float_x8b8g8r8_unorm(const void *void_src, GLfloat dst[4])
81b8e80941Smrg{
82b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
83b8e80941Smrg            uint8_t b = UNPACK(*src, 8, 8);
84b8e80941Smrg            uint8_t g = UNPACK(*src, 16, 8);
85b8e80941Smrg            uint8_t r = UNPACK(*src, 24, 8);
86b8e80941Smrg
87b8e80941Smrg
88b8e80941Smrg
89b8e80941Smrg               dst[0] = _mesa_unorm_to_float(r, 8);
90b8e80941Smrg
91b8e80941Smrg
92b8e80941Smrg               dst[1] = _mesa_unorm_to_float(g, 8);
93b8e80941Smrg
94b8e80941Smrg
95b8e80941Smrg               dst[2] = _mesa_unorm_to_float(b, 8);
96b8e80941Smrg
97b8e80941Smrg         dst[3] = 1.0f;
98b8e80941Smrg}
99b8e80941Smrg
100b8e80941Smrgstatic inline void
101b8e80941Smrgunpack_float_r8g8b8a8_unorm(const void *void_src, GLfloat dst[4])
102b8e80941Smrg{
103b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
104b8e80941Smrg            uint8_t r = UNPACK(*src, 0, 8);
105b8e80941Smrg            uint8_t g = UNPACK(*src, 8, 8);
106b8e80941Smrg            uint8_t b = UNPACK(*src, 16, 8);
107b8e80941Smrg            uint8_t a = UNPACK(*src, 24, 8);
108b8e80941Smrg
109b8e80941Smrg
110b8e80941Smrg
111b8e80941Smrg               dst[0] = _mesa_unorm_to_float(r, 8);
112b8e80941Smrg
113b8e80941Smrg
114b8e80941Smrg               dst[1] = _mesa_unorm_to_float(g, 8);
115b8e80941Smrg
116b8e80941Smrg
117b8e80941Smrg               dst[2] = _mesa_unorm_to_float(b, 8);
118b8e80941Smrg
119b8e80941Smrg
120b8e80941Smrg               dst[3] = _mesa_unorm_to_float(a, 8);
121b8e80941Smrg}
122b8e80941Smrg
123b8e80941Smrgstatic inline void
124b8e80941Smrgunpack_float_r8g8b8x8_unorm(const void *void_src, GLfloat dst[4])
125b8e80941Smrg{
126b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
127b8e80941Smrg            uint8_t r = UNPACK(*src, 0, 8);
128b8e80941Smrg            uint8_t g = UNPACK(*src, 8, 8);
129b8e80941Smrg            uint8_t b = UNPACK(*src, 16, 8);
130b8e80941Smrg
131b8e80941Smrg
132b8e80941Smrg
133b8e80941Smrg               dst[0] = _mesa_unorm_to_float(r, 8);
134b8e80941Smrg
135b8e80941Smrg
136b8e80941Smrg               dst[1] = _mesa_unorm_to_float(g, 8);
137b8e80941Smrg
138b8e80941Smrg
139b8e80941Smrg               dst[2] = _mesa_unorm_to_float(b, 8);
140b8e80941Smrg
141b8e80941Smrg         dst[3] = 1.0f;
142b8e80941Smrg}
143b8e80941Smrg
144b8e80941Smrgstatic inline void
145b8e80941Smrgunpack_float_b8g8r8a8_unorm(const void *void_src, GLfloat dst[4])
146b8e80941Smrg{
147b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
148b8e80941Smrg            uint8_t b = UNPACK(*src, 0, 8);
149b8e80941Smrg            uint8_t g = UNPACK(*src, 8, 8);
150b8e80941Smrg            uint8_t r = UNPACK(*src, 16, 8);
151b8e80941Smrg            uint8_t a = UNPACK(*src, 24, 8);
152b8e80941Smrg
153b8e80941Smrg
154b8e80941Smrg
155b8e80941Smrg               dst[0] = _mesa_unorm_to_float(r, 8);
156b8e80941Smrg
157b8e80941Smrg
158b8e80941Smrg               dst[1] = _mesa_unorm_to_float(g, 8);
159b8e80941Smrg
160b8e80941Smrg
161b8e80941Smrg               dst[2] = _mesa_unorm_to_float(b, 8);
162b8e80941Smrg
163b8e80941Smrg
164b8e80941Smrg               dst[3] = _mesa_unorm_to_float(a, 8);
165b8e80941Smrg}
166b8e80941Smrg
167b8e80941Smrgstatic inline void
168b8e80941Smrgunpack_float_b8g8r8x8_unorm(const void *void_src, GLfloat dst[4])
169b8e80941Smrg{
170b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
171b8e80941Smrg            uint8_t b = UNPACK(*src, 0, 8);
172b8e80941Smrg            uint8_t g = UNPACK(*src, 8, 8);
173b8e80941Smrg            uint8_t r = UNPACK(*src, 16, 8);
174b8e80941Smrg
175b8e80941Smrg
176b8e80941Smrg
177b8e80941Smrg               dst[0] = _mesa_unorm_to_float(r, 8);
178b8e80941Smrg
179b8e80941Smrg
180b8e80941Smrg               dst[1] = _mesa_unorm_to_float(g, 8);
181b8e80941Smrg
182b8e80941Smrg
183b8e80941Smrg               dst[2] = _mesa_unorm_to_float(b, 8);
184b8e80941Smrg
185b8e80941Smrg         dst[3] = 1.0f;
186b8e80941Smrg}
187b8e80941Smrg
188b8e80941Smrgstatic inline void
189b8e80941Smrgunpack_float_a8r8g8b8_unorm(const void *void_src, GLfloat dst[4])
190b8e80941Smrg{
191b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
192b8e80941Smrg            uint8_t a = UNPACK(*src, 0, 8);
193b8e80941Smrg            uint8_t r = UNPACK(*src, 8, 8);
194b8e80941Smrg            uint8_t g = UNPACK(*src, 16, 8);
195b8e80941Smrg            uint8_t b = UNPACK(*src, 24, 8);
196b8e80941Smrg
197b8e80941Smrg
198b8e80941Smrg
199b8e80941Smrg               dst[0] = _mesa_unorm_to_float(r, 8);
200b8e80941Smrg
201b8e80941Smrg
202b8e80941Smrg               dst[1] = _mesa_unorm_to_float(g, 8);
203b8e80941Smrg
204b8e80941Smrg
205b8e80941Smrg               dst[2] = _mesa_unorm_to_float(b, 8);
206b8e80941Smrg
207b8e80941Smrg
208b8e80941Smrg               dst[3] = _mesa_unorm_to_float(a, 8);
209b8e80941Smrg}
210b8e80941Smrg
211b8e80941Smrgstatic inline void
212b8e80941Smrgunpack_float_x8r8g8b8_unorm(const void *void_src, GLfloat dst[4])
213b8e80941Smrg{
214b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
215b8e80941Smrg            uint8_t r = UNPACK(*src, 8, 8);
216b8e80941Smrg            uint8_t g = UNPACK(*src, 16, 8);
217b8e80941Smrg            uint8_t b = UNPACK(*src, 24, 8);
218b8e80941Smrg
219b8e80941Smrg
220b8e80941Smrg
221b8e80941Smrg               dst[0] = _mesa_unorm_to_float(r, 8);
222b8e80941Smrg
223b8e80941Smrg
224b8e80941Smrg               dst[1] = _mesa_unorm_to_float(g, 8);
225b8e80941Smrg
226b8e80941Smrg
227b8e80941Smrg               dst[2] = _mesa_unorm_to_float(b, 8);
228b8e80941Smrg
229b8e80941Smrg         dst[3] = 1.0f;
230b8e80941Smrg}
231b8e80941Smrg
232b8e80941Smrgstatic inline void
233b8e80941Smrgunpack_float_l16a16_unorm(const void *void_src, GLfloat dst[4])
234b8e80941Smrg{
235b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
236b8e80941Smrg            uint16_t l = UNPACK(*src, 0, 16);
237b8e80941Smrg            uint16_t a = UNPACK(*src, 16, 16);
238b8e80941Smrg
239b8e80941Smrg
240b8e80941Smrg
241b8e80941Smrg               dst[0] = _mesa_unorm_to_float(l, 16);
242b8e80941Smrg
243b8e80941Smrg
244b8e80941Smrg               dst[1] = _mesa_unorm_to_float(l, 16);
245b8e80941Smrg
246b8e80941Smrg
247b8e80941Smrg               dst[2] = _mesa_unorm_to_float(l, 16);
248b8e80941Smrg
249b8e80941Smrg
250b8e80941Smrg               dst[3] = _mesa_unorm_to_float(a, 16);
251b8e80941Smrg}
252b8e80941Smrg
253b8e80941Smrgstatic inline void
254b8e80941Smrgunpack_float_a16l16_unorm(const void *void_src, GLfloat dst[4])
255b8e80941Smrg{
256b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
257b8e80941Smrg            uint16_t a = UNPACK(*src, 0, 16);
258b8e80941Smrg            uint16_t l = UNPACK(*src, 16, 16);
259b8e80941Smrg
260b8e80941Smrg
261b8e80941Smrg
262b8e80941Smrg               dst[0] = _mesa_unorm_to_float(l, 16);
263b8e80941Smrg
264b8e80941Smrg
265b8e80941Smrg               dst[1] = _mesa_unorm_to_float(l, 16);
266b8e80941Smrg
267b8e80941Smrg
268b8e80941Smrg               dst[2] = _mesa_unorm_to_float(l, 16);
269b8e80941Smrg
270b8e80941Smrg
271b8e80941Smrg               dst[3] = _mesa_unorm_to_float(a, 16);
272b8e80941Smrg}
273b8e80941Smrg
274b8e80941Smrgstatic inline void
275b8e80941Smrgunpack_float_b5g6r5_unorm(const void *void_src, GLfloat dst[4])
276b8e80941Smrg{
277b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
278b8e80941Smrg            uint8_t b = UNPACK(*src, 0, 5);
279b8e80941Smrg            uint8_t g = UNPACK(*src, 5, 6);
280b8e80941Smrg            uint8_t r = UNPACK(*src, 11, 5);
281b8e80941Smrg
282b8e80941Smrg
283b8e80941Smrg
284b8e80941Smrg               dst[0] = _mesa_unorm_to_float(r, 5);
285b8e80941Smrg
286b8e80941Smrg
287b8e80941Smrg               dst[1] = _mesa_unorm_to_float(g, 6);
288b8e80941Smrg
289b8e80941Smrg
290b8e80941Smrg               dst[2] = _mesa_unorm_to_float(b, 5);
291b8e80941Smrg
292b8e80941Smrg         dst[3] = 1.0f;
293b8e80941Smrg}
294b8e80941Smrg
295b8e80941Smrgstatic inline void
296b8e80941Smrgunpack_float_r5g6b5_unorm(const void *void_src, GLfloat dst[4])
297b8e80941Smrg{
298b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
299b8e80941Smrg            uint8_t r = UNPACK(*src, 0, 5);
300b8e80941Smrg            uint8_t g = UNPACK(*src, 5, 6);
301b8e80941Smrg            uint8_t b = UNPACK(*src, 11, 5);
302b8e80941Smrg
303b8e80941Smrg
304b8e80941Smrg
305b8e80941Smrg               dst[0] = _mesa_unorm_to_float(r, 5);
306b8e80941Smrg
307b8e80941Smrg
308b8e80941Smrg               dst[1] = _mesa_unorm_to_float(g, 6);
309b8e80941Smrg
310b8e80941Smrg
311b8e80941Smrg               dst[2] = _mesa_unorm_to_float(b, 5);
312b8e80941Smrg
313b8e80941Smrg         dst[3] = 1.0f;
314b8e80941Smrg}
315b8e80941Smrg
316b8e80941Smrgstatic inline void
317b8e80941Smrgunpack_float_b4g4r4a4_unorm(const void *void_src, GLfloat dst[4])
318b8e80941Smrg{
319b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
320b8e80941Smrg            uint8_t b = UNPACK(*src, 0, 4);
321b8e80941Smrg            uint8_t g = UNPACK(*src, 4, 4);
322b8e80941Smrg            uint8_t r = UNPACK(*src, 8, 4);
323b8e80941Smrg            uint8_t a = UNPACK(*src, 12, 4);
324b8e80941Smrg
325b8e80941Smrg
326b8e80941Smrg
327b8e80941Smrg               dst[0] = _mesa_unorm_to_float(r, 4);
328b8e80941Smrg
329b8e80941Smrg
330b8e80941Smrg               dst[1] = _mesa_unorm_to_float(g, 4);
331b8e80941Smrg
332b8e80941Smrg
333b8e80941Smrg               dst[2] = _mesa_unorm_to_float(b, 4);
334b8e80941Smrg
335b8e80941Smrg
336b8e80941Smrg               dst[3] = _mesa_unorm_to_float(a, 4);
337b8e80941Smrg}
338b8e80941Smrg
339b8e80941Smrgstatic inline void
340b8e80941Smrgunpack_float_b4g4r4x4_unorm(const void *void_src, GLfloat dst[4])
341b8e80941Smrg{
342b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
343b8e80941Smrg            uint8_t b = UNPACK(*src, 0, 4);
344b8e80941Smrg            uint8_t g = UNPACK(*src, 4, 4);
345b8e80941Smrg            uint8_t r = UNPACK(*src, 8, 4);
346b8e80941Smrg
347b8e80941Smrg
348b8e80941Smrg
349b8e80941Smrg               dst[0] = _mesa_unorm_to_float(r, 4);
350b8e80941Smrg
351b8e80941Smrg
352b8e80941Smrg               dst[1] = _mesa_unorm_to_float(g, 4);
353b8e80941Smrg
354b8e80941Smrg
355b8e80941Smrg               dst[2] = _mesa_unorm_to_float(b, 4);
356b8e80941Smrg
357b8e80941Smrg         dst[3] = 1.0f;
358b8e80941Smrg}
359b8e80941Smrg
360b8e80941Smrgstatic inline void
361b8e80941Smrgunpack_float_a4r4g4b4_unorm(const void *void_src, GLfloat dst[4])
362b8e80941Smrg{
363b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
364b8e80941Smrg            uint8_t a = UNPACK(*src, 0, 4);
365b8e80941Smrg            uint8_t r = UNPACK(*src, 4, 4);
366b8e80941Smrg            uint8_t g = UNPACK(*src, 8, 4);
367b8e80941Smrg            uint8_t b = UNPACK(*src, 12, 4);
368b8e80941Smrg
369b8e80941Smrg
370b8e80941Smrg
371b8e80941Smrg               dst[0] = _mesa_unorm_to_float(r, 4);
372b8e80941Smrg
373b8e80941Smrg
374b8e80941Smrg               dst[1] = _mesa_unorm_to_float(g, 4);
375b8e80941Smrg
376b8e80941Smrg
377b8e80941Smrg               dst[2] = _mesa_unorm_to_float(b, 4);
378b8e80941Smrg
379b8e80941Smrg
380b8e80941Smrg               dst[3] = _mesa_unorm_to_float(a, 4);
381b8e80941Smrg}
382b8e80941Smrg
383b8e80941Smrgstatic inline void
384b8e80941Smrgunpack_float_a1b5g5r5_unorm(const void *void_src, GLfloat dst[4])
385b8e80941Smrg{
386b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
387b8e80941Smrg            uint8_t a = UNPACK(*src, 0, 1);
388b8e80941Smrg            uint8_t b = UNPACK(*src, 1, 5);
389b8e80941Smrg            uint8_t g = UNPACK(*src, 6, 5);
390b8e80941Smrg            uint8_t r = UNPACK(*src, 11, 5);
391b8e80941Smrg
392b8e80941Smrg
393b8e80941Smrg
394b8e80941Smrg               dst[0] = _mesa_unorm_to_float(r, 5);
395b8e80941Smrg
396b8e80941Smrg
397b8e80941Smrg               dst[1] = _mesa_unorm_to_float(g, 5);
398b8e80941Smrg
399b8e80941Smrg
400b8e80941Smrg               dst[2] = _mesa_unorm_to_float(b, 5);
401b8e80941Smrg
402b8e80941Smrg
403b8e80941Smrg               dst[3] = _mesa_unorm_to_float(a, 1);
404b8e80941Smrg}
405b8e80941Smrg
406b8e80941Smrgstatic inline void
407b8e80941Smrgunpack_float_x1b5g5r5_unorm(const void *void_src, GLfloat dst[4])
408b8e80941Smrg{
409b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
410b8e80941Smrg            uint8_t b = UNPACK(*src, 1, 5);
411b8e80941Smrg            uint8_t g = UNPACK(*src, 6, 5);
412b8e80941Smrg            uint8_t r = UNPACK(*src, 11, 5);
413b8e80941Smrg
414b8e80941Smrg
415b8e80941Smrg
416b8e80941Smrg               dst[0] = _mesa_unorm_to_float(r, 5);
417b8e80941Smrg
418b8e80941Smrg
419b8e80941Smrg               dst[1] = _mesa_unorm_to_float(g, 5);
420b8e80941Smrg
421b8e80941Smrg
422b8e80941Smrg               dst[2] = _mesa_unorm_to_float(b, 5);
423b8e80941Smrg
424b8e80941Smrg         dst[3] = 1.0f;
425b8e80941Smrg}
426b8e80941Smrg
427b8e80941Smrgstatic inline void
428b8e80941Smrgunpack_float_b5g5r5a1_unorm(const void *void_src, GLfloat dst[4])
429b8e80941Smrg{
430b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
431b8e80941Smrg            uint8_t b = UNPACK(*src, 0, 5);
432b8e80941Smrg            uint8_t g = UNPACK(*src, 5, 5);
433b8e80941Smrg            uint8_t r = UNPACK(*src, 10, 5);
434b8e80941Smrg            uint8_t a = UNPACK(*src, 15, 1);
435b8e80941Smrg
436b8e80941Smrg
437b8e80941Smrg
438b8e80941Smrg               dst[0] = _mesa_unorm_to_float(r, 5);
439b8e80941Smrg
440b8e80941Smrg
441b8e80941Smrg               dst[1] = _mesa_unorm_to_float(g, 5);
442b8e80941Smrg
443b8e80941Smrg
444b8e80941Smrg               dst[2] = _mesa_unorm_to_float(b, 5);
445b8e80941Smrg
446b8e80941Smrg
447b8e80941Smrg               dst[3] = _mesa_unorm_to_float(a, 1);
448b8e80941Smrg}
449b8e80941Smrg
450b8e80941Smrgstatic inline void
451b8e80941Smrgunpack_float_b5g5r5x1_unorm(const void *void_src, GLfloat dst[4])
452b8e80941Smrg{
453b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
454b8e80941Smrg            uint8_t b = UNPACK(*src, 0, 5);
455b8e80941Smrg            uint8_t g = UNPACK(*src, 5, 5);
456b8e80941Smrg            uint8_t r = UNPACK(*src, 10, 5);
457b8e80941Smrg
458b8e80941Smrg
459b8e80941Smrg
460b8e80941Smrg               dst[0] = _mesa_unorm_to_float(r, 5);
461b8e80941Smrg
462b8e80941Smrg
463b8e80941Smrg               dst[1] = _mesa_unorm_to_float(g, 5);
464b8e80941Smrg
465b8e80941Smrg
466b8e80941Smrg               dst[2] = _mesa_unorm_to_float(b, 5);
467b8e80941Smrg
468b8e80941Smrg         dst[3] = 1.0f;
469b8e80941Smrg}
470b8e80941Smrg
471b8e80941Smrgstatic inline void
472b8e80941Smrgunpack_float_a1r5g5b5_unorm(const void *void_src, GLfloat dst[4])
473b8e80941Smrg{
474b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
475b8e80941Smrg            uint8_t a = UNPACK(*src, 0, 1);
476b8e80941Smrg            uint8_t r = UNPACK(*src, 1, 5);
477b8e80941Smrg            uint8_t g = UNPACK(*src, 6, 5);
478b8e80941Smrg            uint8_t b = UNPACK(*src, 11, 5);
479b8e80941Smrg
480b8e80941Smrg
481b8e80941Smrg
482b8e80941Smrg               dst[0] = _mesa_unorm_to_float(r, 5);
483b8e80941Smrg
484b8e80941Smrg
485b8e80941Smrg               dst[1] = _mesa_unorm_to_float(g, 5);
486b8e80941Smrg
487b8e80941Smrg
488b8e80941Smrg               dst[2] = _mesa_unorm_to_float(b, 5);
489b8e80941Smrg
490b8e80941Smrg
491b8e80941Smrg               dst[3] = _mesa_unorm_to_float(a, 1);
492b8e80941Smrg}
493b8e80941Smrg
494b8e80941Smrgstatic inline void
495b8e80941Smrgunpack_float_l8a8_unorm(const void *void_src, GLfloat dst[4])
496b8e80941Smrg{
497b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
498b8e80941Smrg            uint8_t l = UNPACK(*src, 0, 8);
499b8e80941Smrg            uint8_t a = UNPACK(*src, 8, 8);
500b8e80941Smrg
501b8e80941Smrg
502b8e80941Smrg
503b8e80941Smrg               dst[0] = _mesa_unorm_to_float(l, 8);
504b8e80941Smrg
505b8e80941Smrg
506b8e80941Smrg               dst[1] = _mesa_unorm_to_float(l, 8);
507b8e80941Smrg
508b8e80941Smrg
509b8e80941Smrg               dst[2] = _mesa_unorm_to_float(l, 8);
510b8e80941Smrg
511b8e80941Smrg
512b8e80941Smrg               dst[3] = _mesa_unorm_to_float(a, 8);
513b8e80941Smrg}
514b8e80941Smrg
515b8e80941Smrgstatic inline void
516b8e80941Smrgunpack_float_a8l8_unorm(const void *void_src, GLfloat dst[4])
517b8e80941Smrg{
518b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
519b8e80941Smrg            uint8_t a = UNPACK(*src, 0, 8);
520b8e80941Smrg            uint8_t l = UNPACK(*src, 8, 8);
521b8e80941Smrg
522b8e80941Smrg
523b8e80941Smrg
524b8e80941Smrg               dst[0] = _mesa_unorm_to_float(l, 8);
525b8e80941Smrg
526b8e80941Smrg
527b8e80941Smrg               dst[1] = _mesa_unorm_to_float(l, 8);
528b8e80941Smrg
529b8e80941Smrg
530b8e80941Smrg               dst[2] = _mesa_unorm_to_float(l, 8);
531b8e80941Smrg
532b8e80941Smrg
533b8e80941Smrg               dst[3] = _mesa_unorm_to_float(a, 8);
534b8e80941Smrg}
535b8e80941Smrg
536b8e80941Smrgstatic inline void
537b8e80941Smrgunpack_float_r8g8_unorm(const void *void_src, GLfloat dst[4])
538b8e80941Smrg{
539b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
540b8e80941Smrg            uint8_t r = UNPACK(*src, 0, 8);
541b8e80941Smrg            uint8_t g = UNPACK(*src, 8, 8);
542b8e80941Smrg
543b8e80941Smrg
544b8e80941Smrg
545b8e80941Smrg               dst[0] = _mesa_unorm_to_float(r, 8);
546b8e80941Smrg
547b8e80941Smrg
548b8e80941Smrg               dst[1] = _mesa_unorm_to_float(g, 8);
549b8e80941Smrg
550b8e80941Smrg         dst[2] = 0.0f;
551b8e80941Smrg
552b8e80941Smrg         dst[3] = 1.0f;
553b8e80941Smrg}
554b8e80941Smrg
555b8e80941Smrgstatic inline void
556b8e80941Smrgunpack_float_g8r8_unorm(const void *void_src, GLfloat dst[4])
557b8e80941Smrg{
558b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
559b8e80941Smrg            uint8_t g = UNPACK(*src, 0, 8);
560b8e80941Smrg            uint8_t r = UNPACK(*src, 8, 8);
561b8e80941Smrg
562b8e80941Smrg
563b8e80941Smrg
564b8e80941Smrg               dst[0] = _mesa_unorm_to_float(r, 8);
565b8e80941Smrg
566b8e80941Smrg
567b8e80941Smrg               dst[1] = _mesa_unorm_to_float(g, 8);
568b8e80941Smrg
569b8e80941Smrg         dst[2] = 0.0f;
570b8e80941Smrg
571b8e80941Smrg         dst[3] = 1.0f;
572b8e80941Smrg}
573b8e80941Smrg
574b8e80941Smrgstatic inline void
575b8e80941Smrgunpack_float_l4a4_unorm(const void *void_src, GLfloat dst[4])
576b8e80941Smrg{
577b8e80941Smrg   uint8_t *src = (uint8_t *)void_src;
578b8e80941Smrg            uint8_t l = UNPACK(*src, 0, 4);
579b8e80941Smrg            uint8_t a = UNPACK(*src, 4, 4);
580b8e80941Smrg
581b8e80941Smrg
582b8e80941Smrg
583b8e80941Smrg               dst[0] = _mesa_unorm_to_float(l, 4);
584b8e80941Smrg
585b8e80941Smrg
586b8e80941Smrg               dst[1] = _mesa_unorm_to_float(l, 4);
587b8e80941Smrg
588b8e80941Smrg
589b8e80941Smrg               dst[2] = _mesa_unorm_to_float(l, 4);
590b8e80941Smrg
591b8e80941Smrg
592b8e80941Smrg               dst[3] = _mesa_unorm_to_float(a, 4);
593b8e80941Smrg}
594b8e80941Smrg
595b8e80941Smrgstatic inline void
596b8e80941Smrgunpack_float_b2g3r3_unorm(const void *void_src, GLfloat dst[4])
597b8e80941Smrg{
598b8e80941Smrg   uint8_t *src = (uint8_t *)void_src;
599b8e80941Smrg            uint8_t b = UNPACK(*src, 0, 2);
600b8e80941Smrg            uint8_t g = UNPACK(*src, 2, 3);
601b8e80941Smrg            uint8_t r = UNPACK(*src, 5, 3);
602b8e80941Smrg
603b8e80941Smrg
604b8e80941Smrg
605b8e80941Smrg               dst[0] = _mesa_unorm_to_float(r, 3);
606b8e80941Smrg
607b8e80941Smrg
608b8e80941Smrg               dst[1] = _mesa_unorm_to_float(g, 3);
609b8e80941Smrg
610b8e80941Smrg
611b8e80941Smrg               dst[2] = _mesa_unorm_to_float(b, 2);
612b8e80941Smrg
613b8e80941Smrg         dst[3] = 1.0f;
614b8e80941Smrg}
615b8e80941Smrg
616b8e80941Smrgstatic inline void
617b8e80941Smrgunpack_float_r16g16_unorm(const void *void_src, GLfloat dst[4])
618b8e80941Smrg{
619b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
620b8e80941Smrg            uint16_t r = UNPACK(*src, 0, 16);
621b8e80941Smrg            uint16_t g = UNPACK(*src, 16, 16);
622b8e80941Smrg
623b8e80941Smrg
624b8e80941Smrg
625b8e80941Smrg               dst[0] = _mesa_unorm_to_float(r, 16);
626b8e80941Smrg
627b8e80941Smrg
628b8e80941Smrg               dst[1] = _mesa_unorm_to_float(g, 16);
629b8e80941Smrg
630b8e80941Smrg         dst[2] = 0.0f;
631b8e80941Smrg
632b8e80941Smrg         dst[3] = 1.0f;
633b8e80941Smrg}
634b8e80941Smrg
635b8e80941Smrgstatic inline void
636b8e80941Smrgunpack_float_g16r16_unorm(const void *void_src, GLfloat dst[4])
637b8e80941Smrg{
638b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
639b8e80941Smrg            uint16_t g = UNPACK(*src, 0, 16);
640b8e80941Smrg            uint16_t r = UNPACK(*src, 16, 16);
641b8e80941Smrg
642b8e80941Smrg
643b8e80941Smrg
644b8e80941Smrg               dst[0] = _mesa_unorm_to_float(r, 16);
645b8e80941Smrg
646b8e80941Smrg
647b8e80941Smrg               dst[1] = _mesa_unorm_to_float(g, 16);
648b8e80941Smrg
649b8e80941Smrg         dst[2] = 0.0f;
650b8e80941Smrg
651b8e80941Smrg         dst[3] = 1.0f;
652b8e80941Smrg}
653b8e80941Smrg
654b8e80941Smrgstatic inline void
655b8e80941Smrgunpack_float_b10g10r10a2_unorm(const void *void_src, GLfloat dst[4])
656b8e80941Smrg{
657b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
658b8e80941Smrg            uint16_t b = UNPACK(*src, 0, 10);
659b8e80941Smrg            uint16_t g = UNPACK(*src, 10, 10);
660b8e80941Smrg            uint16_t r = UNPACK(*src, 20, 10);
661b8e80941Smrg            uint8_t a = UNPACK(*src, 30, 2);
662b8e80941Smrg
663b8e80941Smrg
664b8e80941Smrg
665b8e80941Smrg               dst[0] = _mesa_unorm_to_float(r, 10);
666b8e80941Smrg
667b8e80941Smrg
668b8e80941Smrg               dst[1] = _mesa_unorm_to_float(g, 10);
669b8e80941Smrg
670b8e80941Smrg
671b8e80941Smrg               dst[2] = _mesa_unorm_to_float(b, 10);
672b8e80941Smrg
673b8e80941Smrg
674b8e80941Smrg               dst[3] = _mesa_unorm_to_float(a, 2);
675b8e80941Smrg}
676b8e80941Smrg
677b8e80941Smrgstatic inline void
678b8e80941Smrgunpack_float_b10g10r10x2_unorm(const void *void_src, GLfloat dst[4])
679b8e80941Smrg{
680b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
681b8e80941Smrg            uint16_t b = UNPACK(*src, 0, 10);
682b8e80941Smrg            uint16_t g = UNPACK(*src, 10, 10);
683b8e80941Smrg            uint16_t r = UNPACK(*src, 20, 10);
684b8e80941Smrg
685b8e80941Smrg
686b8e80941Smrg
687b8e80941Smrg               dst[0] = _mesa_unorm_to_float(r, 10);
688b8e80941Smrg
689b8e80941Smrg
690b8e80941Smrg               dst[1] = _mesa_unorm_to_float(g, 10);
691b8e80941Smrg
692b8e80941Smrg
693b8e80941Smrg               dst[2] = _mesa_unorm_to_float(b, 10);
694b8e80941Smrg
695b8e80941Smrg         dst[3] = 1.0f;
696b8e80941Smrg}
697b8e80941Smrg
698b8e80941Smrgstatic inline void
699b8e80941Smrgunpack_float_r10g10b10a2_unorm(const void *void_src, GLfloat dst[4])
700b8e80941Smrg{
701b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
702b8e80941Smrg            uint16_t r = UNPACK(*src, 0, 10);
703b8e80941Smrg            uint16_t g = UNPACK(*src, 10, 10);
704b8e80941Smrg            uint16_t b = UNPACK(*src, 20, 10);
705b8e80941Smrg            uint8_t a = UNPACK(*src, 30, 2);
706b8e80941Smrg
707b8e80941Smrg
708b8e80941Smrg
709b8e80941Smrg               dst[0] = _mesa_unorm_to_float(r, 10);
710b8e80941Smrg
711b8e80941Smrg
712b8e80941Smrg               dst[1] = _mesa_unorm_to_float(g, 10);
713b8e80941Smrg
714b8e80941Smrg
715b8e80941Smrg               dst[2] = _mesa_unorm_to_float(b, 10);
716b8e80941Smrg
717b8e80941Smrg
718b8e80941Smrg               dst[3] = _mesa_unorm_to_float(a, 2);
719b8e80941Smrg}
720b8e80941Smrg
721b8e80941Smrgstatic inline void
722b8e80941Smrgunpack_float_r10g10b10x2_unorm(const void *void_src, GLfloat dst[4])
723b8e80941Smrg{
724b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
725b8e80941Smrg            uint16_t r = UNPACK(*src, 0, 10);
726b8e80941Smrg            uint16_t g = UNPACK(*src, 10, 10);
727b8e80941Smrg            uint16_t b = UNPACK(*src, 20, 10);
728b8e80941Smrg
729b8e80941Smrg
730b8e80941Smrg
731b8e80941Smrg               dst[0] = _mesa_unorm_to_float(r, 10);
732b8e80941Smrg
733b8e80941Smrg
734b8e80941Smrg               dst[1] = _mesa_unorm_to_float(g, 10);
735b8e80941Smrg
736b8e80941Smrg
737b8e80941Smrg               dst[2] = _mesa_unorm_to_float(b, 10);
738b8e80941Smrg
739b8e80941Smrg         dst[3] = 1.0f;
740b8e80941Smrg}
741b8e80941Smrg
742b8e80941Smrgstatic inline void
743b8e80941Smrgunpack_float_r3g3b2_unorm(const void *void_src, GLfloat dst[4])
744b8e80941Smrg{
745b8e80941Smrg   uint8_t *src = (uint8_t *)void_src;
746b8e80941Smrg            uint8_t r = UNPACK(*src, 0, 3);
747b8e80941Smrg            uint8_t g = UNPACK(*src, 3, 3);
748b8e80941Smrg            uint8_t b = UNPACK(*src, 6, 2);
749b8e80941Smrg
750b8e80941Smrg
751b8e80941Smrg
752b8e80941Smrg               dst[0] = _mesa_unorm_to_float(r, 3);
753b8e80941Smrg
754b8e80941Smrg
755b8e80941Smrg               dst[1] = _mesa_unorm_to_float(g, 3);
756b8e80941Smrg
757b8e80941Smrg
758b8e80941Smrg               dst[2] = _mesa_unorm_to_float(b, 2);
759b8e80941Smrg
760b8e80941Smrg         dst[3] = 1.0f;
761b8e80941Smrg}
762b8e80941Smrg
763b8e80941Smrgstatic inline void
764b8e80941Smrgunpack_float_a4b4g4r4_unorm(const void *void_src, GLfloat dst[4])
765b8e80941Smrg{
766b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
767b8e80941Smrg            uint8_t a = UNPACK(*src, 0, 4);
768b8e80941Smrg            uint8_t b = UNPACK(*src, 4, 4);
769b8e80941Smrg            uint8_t g = UNPACK(*src, 8, 4);
770b8e80941Smrg            uint8_t r = UNPACK(*src, 12, 4);
771b8e80941Smrg
772b8e80941Smrg
773b8e80941Smrg
774b8e80941Smrg               dst[0] = _mesa_unorm_to_float(r, 4);
775b8e80941Smrg
776b8e80941Smrg
777b8e80941Smrg               dst[1] = _mesa_unorm_to_float(g, 4);
778b8e80941Smrg
779b8e80941Smrg
780b8e80941Smrg               dst[2] = _mesa_unorm_to_float(b, 4);
781b8e80941Smrg
782b8e80941Smrg
783b8e80941Smrg               dst[3] = _mesa_unorm_to_float(a, 4);
784b8e80941Smrg}
785b8e80941Smrg
786b8e80941Smrgstatic inline void
787b8e80941Smrgunpack_float_r4g4b4a4_unorm(const void *void_src, GLfloat dst[4])
788b8e80941Smrg{
789b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
790b8e80941Smrg            uint8_t r = UNPACK(*src, 0, 4);
791b8e80941Smrg            uint8_t g = UNPACK(*src, 4, 4);
792b8e80941Smrg            uint8_t b = UNPACK(*src, 8, 4);
793b8e80941Smrg            uint8_t a = UNPACK(*src, 12, 4);
794b8e80941Smrg
795b8e80941Smrg
796b8e80941Smrg
797b8e80941Smrg               dst[0] = _mesa_unorm_to_float(r, 4);
798b8e80941Smrg
799b8e80941Smrg
800b8e80941Smrg               dst[1] = _mesa_unorm_to_float(g, 4);
801b8e80941Smrg
802b8e80941Smrg
803b8e80941Smrg               dst[2] = _mesa_unorm_to_float(b, 4);
804b8e80941Smrg
805b8e80941Smrg
806b8e80941Smrg               dst[3] = _mesa_unorm_to_float(a, 4);
807b8e80941Smrg}
808b8e80941Smrg
809b8e80941Smrgstatic inline void
810b8e80941Smrgunpack_float_r5g5b5a1_unorm(const void *void_src, GLfloat dst[4])
811b8e80941Smrg{
812b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
813b8e80941Smrg            uint8_t r = UNPACK(*src, 0, 5);
814b8e80941Smrg            uint8_t g = UNPACK(*src, 5, 5);
815b8e80941Smrg            uint8_t b = UNPACK(*src, 10, 5);
816b8e80941Smrg            uint8_t a = UNPACK(*src, 15, 1);
817b8e80941Smrg
818b8e80941Smrg
819b8e80941Smrg
820b8e80941Smrg               dst[0] = _mesa_unorm_to_float(r, 5);
821b8e80941Smrg
822b8e80941Smrg
823b8e80941Smrg               dst[1] = _mesa_unorm_to_float(g, 5);
824b8e80941Smrg
825b8e80941Smrg
826b8e80941Smrg               dst[2] = _mesa_unorm_to_float(b, 5);
827b8e80941Smrg
828b8e80941Smrg
829b8e80941Smrg               dst[3] = _mesa_unorm_to_float(a, 1);
830b8e80941Smrg}
831b8e80941Smrg
832b8e80941Smrgstatic inline void
833b8e80941Smrgunpack_float_a2b10g10r10_unorm(const void *void_src, GLfloat dst[4])
834b8e80941Smrg{
835b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
836b8e80941Smrg            uint8_t a = UNPACK(*src, 0, 2);
837b8e80941Smrg            uint16_t b = UNPACK(*src, 2, 10);
838b8e80941Smrg            uint16_t g = UNPACK(*src, 12, 10);
839b8e80941Smrg            uint16_t r = UNPACK(*src, 22, 10);
840b8e80941Smrg
841b8e80941Smrg
842b8e80941Smrg
843b8e80941Smrg               dst[0] = _mesa_unorm_to_float(r, 10);
844b8e80941Smrg
845b8e80941Smrg
846b8e80941Smrg               dst[1] = _mesa_unorm_to_float(g, 10);
847b8e80941Smrg
848b8e80941Smrg
849b8e80941Smrg               dst[2] = _mesa_unorm_to_float(b, 10);
850b8e80941Smrg
851b8e80941Smrg
852b8e80941Smrg               dst[3] = _mesa_unorm_to_float(a, 2);
853b8e80941Smrg}
854b8e80941Smrg
855b8e80941Smrgstatic inline void
856b8e80941Smrgunpack_float_a2r10g10b10_unorm(const void *void_src, GLfloat dst[4])
857b8e80941Smrg{
858b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
859b8e80941Smrg            uint8_t a = UNPACK(*src, 0, 2);
860b8e80941Smrg            uint16_t r = UNPACK(*src, 2, 10);
861b8e80941Smrg            uint16_t g = UNPACK(*src, 12, 10);
862b8e80941Smrg            uint16_t b = UNPACK(*src, 22, 10);
863b8e80941Smrg
864b8e80941Smrg
865b8e80941Smrg
866b8e80941Smrg               dst[0] = _mesa_unorm_to_float(r, 10);
867b8e80941Smrg
868b8e80941Smrg
869b8e80941Smrg               dst[1] = _mesa_unorm_to_float(g, 10);
870b8e80941Smrg
871b8e80941Smrg
872b8e80941Smrg               dst[2] = _mesa_unorm_to_float(b, 10);
873b8e80941Smrg
874b8e80941Smrg
875b8e80941Smrg               dst[3] = _mesa_unorm_to_float(a, 2);
876b8e80941Smrg}
877b8e80941Smrg
878b8e80941Smrgstatic inline void
879b8e80941Smrgunpack_float_a_unorm8(const void *void_src, GLfloat dst[4])
880b8e80941Smrg{
881b8e80941Smrg   uint8_t *src = (uint8_t *)void_src;
882b8e80941Smrg            uint8_t a = src[0];
883b8e80941Smrg
884b8e80941Smrg
885b8e80941Smrg         dst[0] = 0.0f;
886b8e80941Smrg
887b8e80941Smrg         dst[1] = 0.0f;
888b8e80941Smrg
889b8e80941Smrg         dst[2] = 0.0f;
890b8e80941Smrg
891b8e80941Smrg
892b8e80941Smrg               dst[3] = _mesa_unorm_to_float(a, 8);
893b8e80941Smrg}
894b8e80941Smrg
895b8e80941Smrgstatic inline void
896b8e80941Smrgunpack_float_a_unorm16(const void *void_src, GLfloat dst[4])
897b8e80941Smrg{
898b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
899b8e80941Smrg            uint16_t a = src[0];
900b8e80941Smrg
901b8e80941Smrg
902b8e80941Smrg         dst[0] = 0.0f;
903b8e80941Smrg
904b8e80941Smrg         dst[1] = 0.0f;
905b8e80941Smrg
906b8e80941Smrg         dst[2] = 0.0f;
907b8e80941Smrg
908b8e80941Smrg
909b8e80941Smrg               dst[3] = _mesa_unorm_to_float(a, 16);
910b8e80941Smrg}
911b8e80941Smrg
912b8e80941Smrgstatic inline void
913b8e80941Smrgunpack_float_l_unorm8(const void *void_src, GLfloat dst[4])
914b8e80941Smrg{
915b8e80941Smrg   uint8_t *src = (uint8_t *)void_src;
916b8e80941Smrg            uint8_t l = src[0];
917b8e80941Smrg
918b8e80941Smrg
919b8e80941Smrg
920b8e80941Smrg               dst[0] = _mesa_unorm_to_float(l, 8);
921b8e80941Smrg
922b8e80941Smrg
923b8e80941Smrg               dst[1] = _mesa_unorm_to_float(l, 8);
924b8e80941Smrg
925b8e80941Smrg
926b8e80941Smrg               dst[2] = _mesa_unorm_to_float(l, 8);
927b8e80941Smrg
928b8e80941Smrg         dst[3] = 1.0f;
929b8e80941Smrg}
930b8e80941Smrg
931b8e80941Smrgstatic inline void
932b8e80941Smrgunpack_float_l_unorm16(const void *void_src, GLfloat dst[4])
933b8e80941Smrg{
934b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
935b8e80941Smrg            uint16_t l = src[0];
936b8e80941Smrg
937b8e80941Smrg
938b8e80941Smrg
939b8e80941Smrg               dst[0] = _mesa_unorm_to_float(l, 16);
940b8e80941Smrg
941b8e80941Smrg
942b8e80941Smrg               dst[1] = _mesa_unorm_to_float(l, 16);
943b8e80941Smrg
944b8e80941Smrg
945b8e80941Smrg               dst[2] = _mesa_unorm_to_float(l, 16);
946b8e80941Smrg
947b8e80941Smrg         dst[3] = 1.0f;
948b8e80941Smrg}
949b8e80941Smrg
950b8e80941Smrgstatic inline void
951b8e80941Smrgunpack_float_i_unorm8(const void *void_src, GLfloat dst[4])
952b8e80941Smrg{
953b8e80941Smrg   uint8_t *src = (uint8_t *)void_src;
954b8e80941Smrg            uint8_t i = src[0];
955b8e80941Smrg
956b8e80941Smrg
957b8e80941Smrg
958b8e80941Smrg               dst[0] = _mesa_unorm_to_float(i, 8);
959b8e80941Smrg
960b8e80941Smrg
961b8e80941Smrg               dst[1] = _mesa_unorm_to_float(i, 8);
962b8e80941Smrg
963b8e80941Smrg
964b8e80941Smrg               dst[2] = _mesa_unorm_to_float(i, 8);
965b8e80941Smrg
966b8e80941Smrg
967b8e80941Smrg               dst[3] = _mesa_unorm_to_float(i, 8);
968b8e80941Smrg}
969b8e80941Smrg
970b8e80941Smrgstatic inline void
971b8e80941Smrgunpack_float_i_unorm16(const void *void_src, GLfloat dst[4])
972b8e80941Smrg{
973b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
974b8e80941Smrg            uint16_t i = src[0];
975b8e80941Smrg
976b8e80941Smrg
977b8e80941Smrg
978b8e80941Smrg               dst[0] = _mesa_unorm_to_float(i, 16);
979b8e80941Smrg
980b8e80941Smrg
981b8e80941Smrg               dst[1] = _mesa_unorm_to_float(i, 16);
982b8e80941Smrg
983b8e80941Smrg
984b8e80941Smrg               dst[2] = _mesa_unorm_to_float(i, 16);
985b8e80941Smrg
986b8e80941Smrg
987b8e80941Smrg               dst[3] = _mesa_unorm_to_float(i, 16);
988b8e80941Smrg}
989b8e80941Smrg
990b8e80941Smrgstatic inline void
991b8e80941Smrgunpack_float_r_unorm8(const void *void_src, GLfloat dst[4])
992b8e80941Smrg{
993b8e80941Smrg   uint8_t *src = (uint8_t *)void_src;
994b8e80941Smrg            uint8_t r = src[0];
995b8e80941Smrg
996b8e80941Smrg
997b8e80941Smrg
998b8e80941Smrg               dst[0] = _mesa_unorm_to_float(r, 8);
999b8e80941Smrg
1000b8e80941Smrg         dst[1] = 0.0f;
1001b8e80941Smrg
1002b8e80941Smrg         dst[2] = 0.0f;
1003b8e80941Smrg
1004b8e80941Smrg         dst[3] = 1.0f;
1005b8e80941Smrg}
1006b8e80941Smrg
1007b8e80941Smrgstatic inline void
1008b8e80941Smrgunpack_float_r_unorm16(const void *void_src, GLfloat dst[4])
1009b8e80941Smrg{
1010b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
1011b8e80941Smrg            uint16_t r = src[0];
1012b8e80941Smrg
1013b8e80941Smrg
1014b8e80941Smrg
1015b8e80941Smrg               dst[0] = _mesa_unorm_to_float(r, 16);
1016b8e80941Smrg
1017b8e80941Smrg         dst[1] = 0.0f;
1018b8e80941Smrg
1019b8e80941Smrg         dst[2] = 0.0f;
1020b8e80941Smrg
1021b8e80941Smrg         dst[3] = 1.0f;
1022b8e80941Smrg}
1023b8e80941Smrg
1024b8e80941Smrgstatic inline void
1025b8e80941Smrgunpack_float_bgr_unorm8(const void *void_src, GLfloat dst[4])
1026b8e80941Smrg{
1027b8e80941Smrg   uint8_t *src = (uint8_t *)void_src;
1028b8e80941Smrg            uint8_t b = src[0];
1029b8e80941Smrg            uint8_t g = src[1];
1030b8e80941Smrg            uint8_t r = src[2];
1031b8e80941Smrg
1032b8e80941Smrg
1033b8e80941Smrg
1034b8e80941Smrg               dst[0] = _mesa_unorm_to_float(r, 8);
1035b8e80941Smrg
1036b8e80941Smrg
1037b8e80941Smrg               dst[1] = _mesa_unorm_to_float(g, 8);
1038b8e80941Smrg
1039b8e80941Smrg
1040b8e80941Smrg               dst[2] = _mesa_unorm_to_float(b, 8);
1041b8e80941Smrg
1042b8e80941Smrg         dst[3] = 1.0f;
1043b8e80941Smrg}
1044b8e80941Smrg
1045b8e80941Smrgstatic inline void
1046b8e80941Smrgunpack_float_rgb_unorm8(const void *void_src, GLfloat dst[4])
1047b8e80941Smrg{
1048b8e80941Smrg   uint8_t *src = (uint8_t *)void_src;
1049b8e80941Smrg            uint8_t r = src[0];
1050b8e80941Smrg            uint8_t g = src[1];
1051b8e80941Smrg            uint8_t b = src[2];
1052b8e80941Smrg
1053b8e80941Smrg
1054b8e80941Smrg
1055b8e80941Smrg               dst[0] = _mesa_unorm_to_float(r, 8);
1056b8e80941Smrg
1057b8e80941Smrg
1058b8e80941Smrg               dst[1] = _mesa_unorm_to_float(g, 8);
1059b8e80941Smrg
1060b8e80941Smrg
1061b8e80941Smrg               dst[2] = _mesa_unorm_to_float(b, 8);
1062b8e80941Smrg
1063b8e80941Smrg         dst[3] = 1.0f;
1064b8e80941Smrg}
1065b8e80941Smrg
1066b8e80941Smrgstatic inline void
1067b8e80941Smrgunpack_float_rgba_unorm16(const void *void_src, GLfloat dst[4])
1068b8e80941Smrg{
1069b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
1070b8e80941Smrg            uint16_t r = src[0];
1071b8e80941Smrg            uint16_t g = src[1];
1072b8e80941Smrg            uint16_t b = src[2];
1073b8e80941Smrg            uint16_t a = src[3];
1074b8e80941Smrg
1075b8e80941Smrg
1076b8e80941Smrg
1077b8e80941Smrg               dst[0] = _mesa_unorm_to_float(r, 16);
1078b8e80941Smrg
1079b8e80941Smrg
1080b8e80941Smrg               dst[1] = _mesa_unorm_to_float(g, 16);
1081b8e80941Smrg
1082b8e80941Smrg
1083b8e80941Smrg               dst[2] = _mesa_unorm_to_float(b, 16);
1084b8e80941Smrg
1085b8e80941Smrg
1086b8e80941Smrg               dst[3] = _mesa_unorm_to_float(a, 16);
1087b8e80941Smrg}
1088b8e80941Smrg
1089b8e80941Smrgstatic inline void
1090b8e80941Smrgunpack_float_rgbx_unorm16(const void *void_src, GLfloat dst[4])
1091b8e80941Smrg{
1092b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
1093b8e80941Smrg            uint16_t r = src[0];
1094b8e80941Smrg            uint16_t g = src[1];
1095b8e80941Smrg            uint16_t b = src[2];
1096b8e80941Smrg
1097b8e80941Smrg
1098b8e80941Smrg
1099b8e80941Smrg               dst[0] = _mesa_unorm_to_float(r, 16);
1100b8e80941Smrg
1101b8e80941Smrg
1102b8e80941Smrg               dst[1] = _mesa_unorm_to_float(g, 16);
1103b8e80941Smrg
1104b8e80941Smrg
1105b8e80941Smrg               dst[2] = _mesa_unorm_to_float(b, 16);
1106b8e80941Smrg
1107b8e80941Smrg         dst[3] = 1.0f;
1108b8e80941Smrg}
1109b8e80941Smrg
1110b8e80941Smrgstatic inline void
1111b8e80941Smrgunpack_float_a8b8g8r8_snorm(const void *void_src, GLfloat dst[4])
1112b8e80941Smrg{
1113b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
1114b8e80941Smrg            int8_t a = UNPACK(*src, 0, 8);
1115b8e80941Smrg            int8_t b = UNPACK(*src, 8, 8);
1116b8e80941Smrg            int8_t g = UNPACK(*src, 16, 8);
1117b8e80941Smrg            int8_t r = UNPACK(*src, 24, 8);
1118b8e80941Smrg
1119b8e80941Smrg
1120b8e80941Smrg
1121b8e80941Smrg            dst[0] = _mesa_snorm_to_float(r, 8);
1122b8e80941Smrg
1123b8e80941Smrg
1124b8e80941Smrg            dst[1] = _mesa_snorm_to_float(g, 8);
1125b8e80941Smrg
1126b8e80941Smrg
1127b8e80941Smrg            dst[2] = _mesa_snorm_to_float(b, 8);
1128b8e80941Smrg
1129b8e80941Smrg
1130b8e80941Smrg            dst[3] = _mesa_snorm_to_float(a, 8);
1131b8e80941Smrg}
1132b8e80941Smrg
1133b8e80941Smrgstatic inline void
1134b8e80941Smrgunpack_float_x8b8g8r8_snorm(const void *void_src, GLfloat dst[4])
1135b8e80941Smrg{
1136b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
1137b8e80941Smrg            int8_t b = UNPACK(*src, 8, 8);
1138b8e80941Smrg            int8_t g = UNPACK(*src, 16, 8);
1139b8e80941Smrg            int8_t r = UNPACK(*src, 24, 8);
1140b8e80941Smrg
1141b8e80941Smrg
1142b8e80941Smrg
1143b8e80941Smrg            dst[0] = _mesa_snorm_to_float(r, 8);
1144b8e80941Smrg
1145b8e80941Smrg
1146b8e80941Smrg            dst[1] = _mesa_snorm_to_float(g, 8);
1147b8e80941Smrg
1148b8e80941Smrg
1149b8e80941Smrg            dst[2] = _mesa_snorm_to_float(b, 8);
1150b8e80941Smrg
1151b8e80941Smrg         dst[3] = 1.0f;
1152b8e80941Smrg}
1153b8e80941Smrg
1154b8e80941Smrgstatic inline void
1155b8e80941Smrgunpack_float_r8g8b8a8_snorm(const void *void_src, GLfloat dst[4])
1156b8e80941Smrg{
1157b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
1158b8e80941Smrg            int8_t r = UNPACK(*src, 0, 8);
1159b8e80941Smrg            int8_t g = UNPACK(*src, 8, 8);
1160b8e80941Smrg            int8_t b = UNPACK(*src, 16, 8);
1161b8e80941Smrg            int8_t a = UNPACK(*src, 24, 8);
1162b8e80941Smrg
1163b8e80941Smrg
1164b8e80941Smrg
1165b8e80941Smrg            dst[0] = _mesa_snorm_to_float(r, 8);
1166b8e80941Smrg
1167b8e80941Smrg
1168b8e80941Smrg            dst[1] = _mesa_snorm_to_float(g, 8);
1169b8e80941Smrg
1170b8e80941Smrg
1171b8e80941Smrg            dst[2] = _mesa_snorm_to_float(b, 8);
1172b8e80941Smrg
1173b8e80941Smrg
1174b8e80941Smrg            dst[3] = _mesa_snorm_to_float(a, 8);
1175b8e80941Smrg}
1176b8e80941Smrg
1177b8e80941Smrgstatic inline void
1178b8e80941Smrgunpack_float_r8g8b8x8_snorm(const void *void_src, GLfloat dst[4])
1179b8e80941Smrg{
1180b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
1181b8e80941Smrg            int8_t r = UNPACK(*src, 0, 8);
1182b8e80941Smrg            int8_t g = UNPACK(*src, 8, 8);
1183b8e80941Smrg            int8_t b = UNPACK(*src, 16, 8);
1184b8e80941Smrg
1185b8e80941Smrg
1186b8e80941Smrg
1187b8e80941Smrg            dst[0] = _mesa_snorm_to_float(r, 8);
1188b8e80941Smrg
1189b8e80941Smrg
1190b8e80941Smrg            dst[1] = _mesa_snorm_to_float(g, 8);
1191b8e80941Smrg
1192b8e80941Smrg
1193b8e80941Smrg            dst[2] = _mesa_snorm_to_float(b, 8);
1194b8e80941Smrg
1195b8e80941Smrg         dst[3] = 1.0f;
1196b8e80941Smrg}
1197b8e80941Smrg
1198b8e80941Smrgstatic inline void
1199b8e80941Smrgunpack_float_r16g16_snorm(const void *void_src, GLfloat dst[4])
1200b8e80941Smrg{
1201b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
1202b8e80941Smrg            int16_t r = UNPACK(*src, 0, 16);
1203b8e80941Smrg            int16_t g = UNPACK(*src, 16, 16);
1204b8e80941Smrg
1205b8e80941Smrg
1206b8e80941Smrg
1207b8e80941Smrg            dst[0] = _mesa_snorm_to_float(r, 16);
1208b8e80941Smrg
1209b8e80941Smrg
1210b8e80941Smrg            dst[1] = _mesa_snorm_to_float(g, 16);
1211b8e80941Smrg
1212b8e80941Smrg         dst[2] = 0.0f;
1213b8e80941Smrg
1214b8e80941Smrg         dst[3] = 1.0f;
1215b8e80941Smrg}
1216b8e80941Smrg
1217b8e80941Smrgstatic inline void
1218b8e80941Smrgunpack_float_g16r16_snorm(const void *void_src, GLfloat dst[4])
1219b8e80941Smrg{
1220b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
1221b8e80941Smrg            int16_t g = UNPACK(*src, 0, 16);
1222b8e80941Smrg            int16_t r = UNPACK(*src, 16, 16);
1223b8e80941Smrg
1224b8e80941Smrg
1225b8e80941Smrg
1226b8e80941Smrg            dst[0] = _mesa_snorm_to_float(r, 16);
1227b8e80941Smrg
1228b8e80941Smrg
1229b8e80941Smrg            dst[1] = _mesa_snorm_to_float(g, 16);
1230b8e80941Smrg
1231b8e80941Smrg         dst[2] = 0.0f;
1232b8e80941Smrg
1233b8e80941Smrg         dst[3] = 1.0f;
1234b8e80941Smrg}
1235b8e80941Smrg
1236b8e80941Smrgstatic inline void
1237b8e80941Smrgunpack_float_r8g8_snorm(const void *void_src, GLfloat dst[4])
1238b8e80941Smrg{
1239b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
1240b8e80941Smrg            int8_t r = UNPACK(*src, 0, 8);
1241b8e80941Smrg            int8_t g = UNPACK(*src, 8, 8);
1242b8e80941Smrg
1243b8e80941Smrg
1244b8e80941Smrg
1245b8e80941Smrg            dst[0] = _mesa_snorm_to_float(r, 8);
1246b8e80941Smrg
1247b8e80941Smrg
1248b8e80941Smrg            dst[1] = _mesa_snorm_to_float(g, 8);
1249b8e80941Smrg
1250b8e80941Smrg         dst[2] = 0.0f;
1251b8e80941Smrg
1252b8e80941Smrg         dst[3] = 1.0f;
1253b8e80941Smrg}
1254b8e80941Smrg
1255b8e80941Smrgstatic inline void
1256b8e80941Smrgunpack_float_g8r8_snorm(const void *void_src, GLfloat dst[4])
1257b8e80941Smrg{
1258b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
1259b8e80941Smrg            int8_t g = UNPACK(*src, 0, 8);
1260b8e80941Smrg            int8_t r = UNPACK(*src, 8, 8);
1261b8e80941Smrg
1262b8e80941Smrg
1263b8e80941Smrg
1264b8e80941Smrg            dst[0] = _mesa_snorm_to_float(r, 8);
1265b8e80941Smrg
1266b8e80941Smrg
1267b8e80941Smrg            dst[1] = _mesa_snorm_to_float(g, 8);
1268b8e80941Smrg
1269b8e80941Smrg         dst[2] = 0.0f;
1270b8e80941Smrg
1271b8e80941Smrg         dst[3] = 1.0f;
1272b8e80941Smrg}
1273b8e80941Smrg
1274b8e80941Smrgstatic inline void
1275b8e80941Smrgunpack_float_l8a8_snorm(const void *void_src, GLfloat dst[4])
1276b8e80941Smrg{
1277b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
1278b8e80941Smrg            int8_t l = UNPACK(*src, 0, 8);
1279b8e80941Smrg            int8_t a = UNPACK(*src, 8, 8);
1280b8e80941Smrg
1281b8e80941Smrg
1282b8e80941Smrg
1283b8e80941Smrg            dst[0] = _mesa_snorm_to_float(l, 8);
1284b8e80941Smrg
1285b8e80941Smrg
1286b8e80941Smrg            dst[1] = _mesa_snorm_to_float(l, 8);
1287b8e80941Smrg
1288b8e80941Smrg
1289b8e80941Smrg            dst[2] = _mesa_snorm_to_float(l, 8);
1290b8e80941Smrg
1291b8e80941Smrg
1292b8e80941Smrg            dst[3] = _mesa_snorm_to_float(a, 8);
1293b8e80941Smrg}
1294b8e80941Smrg
1295b8e80941Smrgstatic inline void
1296b8e80941Smrgunpack_float_a8l8_snorm(const void *void_src, GLfloat dst[4])
1297b8e80941Smrg{
1298b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
1299b8e80941Smrg            int8_t a = UNPACK(*src, 0, 8);
1300b8e80941Smrg            int8_t l = UNPACK(*src, 8, 8);
1301b8e80941Smrg
1302b8e80941Smrg
1303b8e80941Smrg
1304b8e80941Smrg            dst[0] = _mesa_snorm_to_float(l, 8);
1305b8e80941Smrg
1306b8e80941Smrg
1307b8e80941Smrg            dst[1] = _mesa_snorm_to_float(l, 8);
1308b8e80941Smrg
1309b8e80941Smrg
1310b8e80941Smrg            dst[2] = _mesa_snorm_to_float(l, 8);
1311b8e80941Smrg
1312b8e80941Smrg
1313b8e80941Smrg            dst[3] = _mesa_snorm_to_float(a, 8);
1314b8e80941Smrg}
1315b8e80941Smrg
1316b8e80941Smrgstatic inline void
1317b8e80941Smrgunpack_float_a_snorm8(const void *void_src, GLfloat dst[4])
1318b8e80941Smrg{
1319b8e80941Smrg   int8_t *src = (int8_t *)void_src;
1320b8e80941Smrg            int8_t a = src[0];
1321b8e80941Smrg
1322b8e80941Smrg
1323b8e80941Smrg         dst[0] = 0.0f;
1324b8e80941Smrg
1325b8e80941Smrg         dst[1] = 0.0f;
1326b8e80941Smrg
1327b8e80941Smrg         dst[2] = 0.0f;
1328b8e80941Smrg
1329b8e80941Smrg
1330b8e80941Smrg            dst[3] = _mesa_snorm_to_float(a, 8);
1331b8e80941Smrg}
1332b8e80941Smrg
1333b8e80941Smrgstatic inline void
1334b8e80941Smrgunpack_float_a_snorm16(const void *void_src, GLfloat dst[4])
1335b8e80941Smrg{
1336b8e80941Smrg   int16_t *src = (int16_t *)void_src;
1337b8e80941Smrg            int16_t a = src[0];
1338b8e80941Smrg
1339b8e80941Smrg
1340b8e80941Smrg         dst[0] = 0.0f;
1341b8e80941Smrg
1342b8e80941Smrg         dst[1] = 0.0f;
1343b8e80941Smrg
1344b8e80941Smrg         dst[2] = 0.0f;
1345b8e80941Smrg
1346b8e80941Smrg
1347b8e80941Smrg            dst[3] = _mesa_snorm_to_float(a, 16);
1348b8e80941Smrg}
1349b8e80941Smrg
1350b8e80941Smrgstatic inline void
1351b8e80941Smrgunpack_float_l_snorm8(const void *void_src, GLfloat dst[4])
1352b8e80941Smrg{
1353b8e80941Smrg   int8_t *src = (int8_t *)void_src;
1354b8e80941Smrg            int8_t l = src[0];
1355b8e80941Smrg
1356b8e80941Smrg
1357b8e80941Smrg
1358b8e80941Smrg            dst[0] = _mesa_snorm_to_float(l, 8);
1359b8e80941Smrg
1360b8e80941Smrg
1361b8e80941Smrg            dst[1] = _mesa_snorm_to_float(l, 8);
1362b8e80941Smrg
1363b8e80941Smrg
1364b8e80941Smrg            dst[2] = _mesa_snorm_to_float(l, 8);
1365b8e80941Smrg
1366b8e80941Smrg         dst[3] = 1.0f;
1367b8e80941Smrg}
1368b8e80941Smrg
1369b8e80941Smrgstatic inline void
1370b8e80941Smrgunpack_float_l_snorm16(const void *void_src, GLfloat dst[4])
1371b8e80941Smrg{
1372b8e80941Smrg   int16_t *src = (int16_t *)void_src;
1373b8e80941Smrg            int16_t l = src[0];
1374b8e80941Smrg
1375b8e80941Smrg
1376b8e80941Smrg
1377b8e80941Smrg            dst[0] = _mesa_snorm_to_float(l, 16);
1378b8e80941Smrg
1379b8e80941Smrg
1380b8e80941Smrg            dst[1] = _mesa_snorm_to_float(l, 16);
1381b8e80941Smrg
1382b8e80941Smrg
1383b8e80941Smrg            dst[2] = _mesa_snorm_to_float(l, 16);
1384b8e80941Smrg
1385b8e80941Smrg         dst[3] = 1.0f;
1386b8e80941Smrg}
1387b8e80941Smrg
1388b8e80941Smrgstatic inline void
1389b8e80941Smrgunpack_float_i_snorm8(const void *void_src, GLfloat dst[4])
1390b8e80941Smrg{
1391b8e80941Smrg   int8_t *src = (int8_t *)void_src;
1392b8e80941Smrg            int8_t i = src[0];
1393b8e80941Smrg
1394b8e80941Smrg
1395b8e80941Smrg
1396b8e80941Smrg            dst[0] = _mesa_snorm_to_float(i, 8);
1397b8e80941Smrg
1398b8e80941Smrg
1399b8e80941Smrg            dst[1] = _mesa_snorm_to_float(i, 8);
1400b8e80941Smrg
1401b8e80941Smrg
1402b8e80941Smrg            dst[2] = _mesa_snorm_to_float(i, 8);
1403b8e80941Smrg
1404b8e80941Smrg
1405b8e80941Smrg            dst[3] = _mesa_snorm_to_float(i, 8);
1406b8e80941Smrg}
1407b8e80941Smrg
1408b8e80941Smrgstatic inline void
1409b8e80941Smrgunpack_float_i_snorm16(const void *void_src, GLfloat dst[4])
1410b8e80941Smrg{
1411b8e80941Smrg   int16_t *src = (int16_t *)void_src;
1412b8e80941Smrg            int16_t i = src[0];
1413b8e80941Smrg
1414b8e80941Smrg
1415b8e80941Smrg
1416b8e80941Smrg            dst[0] = _mesa_snorm_to_float(i, 16);
1417b8e80941Smrg
1418b8e80941Smrg
1419b8e80941Smrg            dst[1] = _mesa_snorm_to_float(i, 16);
1420b8e80941Smrg
1421b8e80941Smrg
1422b8e80941Smrg            dst[2] = _mesa_snorm_to_float(i, 16);
1423b8e80941Smrg
1424b8e80941Smrg
1425b8e80941Smrg            dst[3] = _mesa_snorm_to_float(i, 16);
1426b8e80941Smrg}
1427b8e80941Smrg
1428b8e80941Smrgstatic inline void
1429b8e80941Smrgunpack_float_r_snorm8(const void *void_src, GLfloat dst[4])
1430b8e80941Smrg{
1431b8e80941Smrg   int8_t *src = (int8_t *)void_src;
1432b8e80941Smrg            int8_t r = src[0];
1433b8e80941Smrg
1434b8e80941Smrg
1435b8e80941Smrg
1436b8e80941Smrg            dst[0] = _mesa_snorm_to_float(r, 8);
1437b8e80941Smrg
1438b8e80941Smrg         dst[1] = 0.0f;
1439b8e80941Smrg
1440b8e80941Smrg         dst[2] = 0.0f;
1441b8e80941Smrg
1442b8e80941Smrg         dst[3] = 1.0f;
1443b8e80941Smrg}
1444b8e80941Smrg
1445b8e80941Smrgstatic inline void
1446b8e80941Smrgunpack_float_r_snorm16(const void *void_src, GLfloat dst[4])
1447b8e80941Smrg{
1448b8e80941Smrg   int16_t *src = (int16_t *)void_src;
1449b8e80941Smrg            int16_t r = src[0];
1450b8e80941Smrg
1451b8e80941Smrg
1452b8e80941Smrg
1453b8e80941Smrg            dst[0] = _mesa_snorm_to_float(r, 16);
1454b8e80941Smrg
1455b8e80941Smrg         dst[1] = 0.0f;
1456b8e80941Smrg
1457b8e80941Smrg         dst[2] = 0.0f;
1458b8e80941Smrg
1459b8e80941Smrg         dst[3] = 1.0f;
1460b8e80941Smrg}
1461b8e80941Smrg
1462b8e80941Smrgstatic inline void
1463b8e80941Smrgunpack_float_la_snorm16(const void *void_src, GLfloat dst[4])
1464b8e80941Smrg{
1465b8e80941Smrg   int16_t *src = (int16_t *)void_src;
1466b8e80941Smrg            int16_t l = src[0];
1467b8e80941Smrg            int16_t a = src[1];
1468b8e80941Smrg
1469b8e80941Smrg
1470b8e80941Smrg
1471b8e80941Smrg            dst[0] = _mesa_snorm_to_float(l, 16);
1472b8e80941Smrg
1473b8e80941Smrg
1474b8e80941Smrg            dst[1] = _mesa_snorm_to_float(l, 16);
1475b8e80941Smrg
1476b8e80941Smrg
1477b8e80941Smrg            dst[2] = _mesa_snorm_to_float(l, 16);
1478b8e80941Smrg
1479b8e80941Smrg
1480b8e80941Smrg            dst[3] = _mesa_snorm_to_float(a, 16);
1481b8e80941Smrg}
1482b8e80941Smrg
1483b8e80941Smrgstatic inline void
1484b8e80941Smrgunpack_float_rgb_snorm16(const void *void_src, GLfloat dst[4])
1485b8e80941Smrg{
1486b8e80941Smrg   int16_t *src = (int16_t *)void_src;
1487b8e80941Smrg            int16_t r = src[0];
1488b8e80941Smrg            int16_t g = src[1];
1489b8e80941Smrg            int16_t b = src[2];
1490b8e80941Smrg
1491b8e80941Smrg
1492b8e80941Smrg
1493b8e80941Smrg            dst[0] = _mesa_snorm_to_float(r, 16);
1494b8e80941Smrg
1495b8e80941Smrg
1496b8e80941Smrg            dst[1] = _mesa_snorm_to_float(g, 16);
1497b8e80941Smrg
1498b8e80941Smrg
1499b8e80941Smrg            dst[2] = _mesa_snorm_to_float(b, 16);
1500b8e80941Smrg
1501b8e80941Smrg         dst[3] = 1.0f;
1502b8e80941Smrg}
1503b8e80941Smrg
1504b8e80941Smrgstatic inline void
1505b8e80941Smrgunpack_float_rgba_snorm16(const void *void_src, GLfloat dst[4])
1506b8e80941Smrg{
1507b8e80941Smrg   int16_t *src = (int16_t *)void_src;
1508b8e80941Smrg            int16_t r = src[0];
1509b8e80941Smrg            int16_t g = src[1];
1510b8e80941Smrg            int16_t b = src[2];
1511b8e80941Smrg            int16_t a = src[3];
1512b8e80941Smrg
1513b8e80941Smrg
1514b8e80941Smrg
1515b8e80941Smrg            dst[0] = _mesa_snorm_to_float(r, 16);
1516b8e80941Smrg
1517b8e80941Smrg
1518b8e80941Smrg            dst[1] = _mesa_snorm_to_float(g, 16);
1519b8e80941Smrg
1520b8e80941Smrg
1521b8e80941Smrg            dst[2] = _mesa_snorm_to_float(b, 16);
1522b8e80941Smrg
1523b8e80941Smrg
1524b8e80941Smrg            dst[3] = _mesa_snorm_to_float(a, 16);
1525b8e80941Smrg}
1526b8e80941Smrg
1527b8e80941Smrgstatic inline void
1528b8e80941Smrgunpack_float_rgbx_snorm16(const void *void_src, GLfloat dst[4])
1529b8e80941Smrg{
1530b8e80941Smrg   int16_t *src = (int16_t *)void_src;
1531b8e80941Smrg            int16_t r = src[0];
1532b8e80941Smrg            int16_t g = src[1];
1533b8e80941Smrg            int16_t b = src[2];
1534b8e80941Smrg
1535b8e80941Smrg
1536b8e80941Smrg
1537b8e80941Smrg            dst[0] = _mesa_snorm_to_float(r, 16);
1538b8e80941Smrg
1539b8e80941Smrg
1540b8e80941Smrg            dst[1] = _mesa_snorm_to_float(g, 16);
1541b8e80941Smrg
1542b8e80941Smrg
1543b8e80941Smrg            dst[2] = _mesa_snorm_to_float(b, 16);
1544b8e80941Smrg
1545b8e80941Smrg         dst[3] = 1.0f;
1546b8e80941Smrg}
1547b8e80941Smrg
1548b8e80941Smrgstatic inline void
1549b8e80941Smrgunpack_float_a8b8g8r8_srgb(const void *void_src, GLfloat dst[4])
1550b8e80941Smrg{
1551b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
1552b8e80941Smrg            uint8_t a = UNPACK(*src, 0, 8);
1553b8e80941Smrg            uint8_t b = UNPACK(*src, 8, 8);
1554b8e80941Smrg            uint8_t g = UNPACK(*src, 16, 8);
1555b8e80941Smrg            uint8_t r = UNPACK(*src, 24, 8);
1556b8e80941Smrg
1557b8e80941Smrg
1558b8e80941Smrg
1559b8e80941Smrg
1560b8e80941Smrg               dst[0] = util_format_srgb_8unorm_to_linear_float(r);
1561b8e80941Smrg
1562b8e80941Smrg
1563b8e80941Smrg
1564b8e80941Smrg               dst[1] = util_format_srgb_8unorm_to_linear_float(g);
1565b8e80941Smrg
1566b8e80941Smrg
1567b8e80941Smrg
1568b8e80941Smrg               dst[2] = util_format_srgb_8unorm_to_linear_float(b);
1569b8e80941Smrg
1570b8e80941Smrg
1571b8e80941Smrg               dst[3] = _mesa_unorm_to_float(a, 8);
1572b8e80941Smrg}
1573b8e80941Smrg
1574b8e80941Smrgstatic inline void
1575b8e80941Smrgunpack_float_b8g8r8a8_srgb(const void *void_src, GLfloat dst[4])
1576b8e80941Smrg{
1577b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
1578b8e80941Smrg            uint8_t b = UNPACK(*src, 0, 8);
1579b8e80941Smrg            uint8_t g = UNPACK(*src, 8, 8);
1580b8e80941Smrg            uint8_t r = UNPACK(*src, 16, 8);
1581b8e80941Smrg            uint8_t a = UNPACK(*src, 24, 8);
1582b8e80941Smrg
1583b8e80941Smrg
1584b8e80941Smrg
1585b8e80941Smrg
1586b8e80941Smrg               dst[0] = util_format_srgb_8unorm_to_linear_float(r);
1587b8e80941Smrg
1588b8e80941Smrg
1589b8e80941Smrg
1590b8e80941Smrg               dst[1] = util_format_srgb_8unorm_to_linear_float(g);
1591b8e80941Smrg
1592b8e80941Smrg
1593b8e80941Smrg
1594b8e80941Smrg               dst[2] = util_format_srgb_8unorm_to_linear_float(b);
1595b8e80941Smrg
1596b8e80941Smrg
1597b8e80941Smrg               dst[3] = _mesa_unorm_to_float(a, 8);
1598b8e80941Smrg}
1599b8e80941Smrg
1600b8e80941Smrgstatic inline void
1601b8e80941Smrgunpack_float_a8r8g8b8_srgb(const void *void_src, GLfloat dst[4])
1602b8e80941Smrg{
1603b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
1604b8e80941Smrg            uint8_t a = UNPACK(*src, 0, 8);
1605b8e80941Smrg            uint8_t r = UNPACK(*src, 8, 8);
1606b8e80941Smrg            uint8_t g = UNPACK(*src, 16, 8);
1607b8e80941Smrg            uint8_t b = UNPACK(*src, 24, 8);
1608b8e80941Smrg
1609b8e80941Smrg
1610b8e80941Smrg
1611b8e80941Smrg
1612b8e80941Smrg               dst[0] = util_format_srgb_8unorm_to_linear_float(r);
1613b8e80941Smrg
1614b8e80941Smrg
1615b8e80941Smrg
1616b8e80941Smrg               dst[1] = util_format_srgb_8unorm_to_linear_float(g);
1617b8e80941Smrg
1618b8e80941Smrg
1619b8e80941Smrg
1620b8e80941Smrg               dst[2] = util_format_srgb_8unorm_to_linear_float(b);
1621b8e80941Smrg
1622b8e80941Smrg
1623b8e80941Smrg               dst[3] = _mesa_unorm_to_float(a, 8);
1624b8e80941Smrg}
1625b8e80941Smrg
1626b8e80941Smrgstatic inline void
1627b8e80941Smrgunpack_float_b8g8r8x8_srgb(const void *void_src, GLfloat dst[4])
1628b8e80941Smrg{
1629b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
1630b8e80941Smrg            uint8_t b = UNPACK(*src, 0, 8);
1631b8e80941Smrg            uint8_t g = UNPACK(*src, 8, 8);
1632b8e80941Smrg            uint8_t r = UNPACK(*src, 16, 8);
1633b8e80941Smrg
1634b8e80941Smrg
1635b8e80941Smrg
1636b8e80941Smrg
1637b8e80941Smrg               dst[0] = util_format_srgb_8unorm_to_linear_float(r);
1638b8e80941Smrg
1639b8e80941Smrg
1640b8e80941Smrg
1641b8e80941Smrg               dst[1] = util_format_srgb_8unorm_to_linear_float(g);
1642b8e80941Smrg
1643b8e80941Smrg
1644b8e80941Smrg
1645b8e80941Smrg               dst[2] = util_format_srgb_8unorm_to_linear_float(b);
1646b8e80941Smrg
1647b8e80941Smrg         dst[3] = 1.0f;
1648b8e80941Smrg}
1649b8e80941Smrg
1650b8e80941Smrgstatic inline void
1651b8e80941Smrgunpack_float_x8r8g8b8_srgb(const void *void_src, GLfloat dst[4])
1652b8e80941Smrg{
1653b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
1654b8e80941Smrg            uint8_t r = UNPACK(*src, 8, 8);
1655b8e80941Smrg            uint8_t g = UNPACK(*src, 16, 8);
1656b8e80941Smrg            uint8_t b = UNPACK(*src, 24, 8);
1657b8e80941Smrg
1658b8e80941Smrg
1659b8e80941Smrg
1660b8e80941Smrg
1661b8e80941Smrg               dst[0] = util_format_srgb_8unorm_to_linear_float(r);
1662b8e80941Smrg
1663b8e80941Smrg
1664b8e80941Smrg
1665b8e80941Smrg               dst[1] = util_format_srgb_8unorm_to_linear_float(g);
1666b8e80941Smrg
1667b8e80941Smrg
1668b8e80941Smrg
1669b8e80941Smrg               dst[2] = util_format_srgb_8unorm_to_linear_float(b);
1670b8e80941Smrg
1671b8e80941Smrg         dst[3] = 1.0f;
1672b8e80941Smrg}
1673b8e80941Smrg
1674b8e80941Smrgstatic inline void
1675b8e80941Smrgunpack_float_r8g8b8a8_srgb(const void *void_src, GLfloat dst[4])
1676b8e80941Smrg{
1677b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
1678b8e80941Smrg            uint8_t r = UNPACK(*src, 0, 8);
1679b8e80941Smrg            uint8_t g = UNPACK(*src, 8, 8);
1680b8e80941Smrg            uint8_t b = UNPACK(*src, 16, 8);
1681b8e80941Smrg            uint8_t a = UNPACK(*src, 24, 8);
1682b8e80941Smrg
1683b8e80941Smrg
1684b8e80941Smrg
1685b8e80941Smrg
1686b8e80941Smrg               dst[0] = util_format_srgb_8unorm_to_linear_float(r);
1687b8e80941Smrg
1688b8e80941Smrg
1689b8e80941Smrg
1690b8e80941Smrg               dst[1] = util_format_srgb_8unorm_to_linear_float(g);
1691b8e80941Smrg
1692b8e80941Smrg
1693b8e80941Smrg
1694b8e80941Smrg               dst[2] = util_format_srgb_8unorm_to_linear_float(b);
1695b8e80941Smrg
1696b8e80941Smrg
1697b8e80941Smrg               dst[3] = _mesa_unorm_to_float(a, 8);
1698b8e80941Smrg}
1699b8e80941Smrg
1700b8e80941Smrgstatic inline void
1701b8e80941Smrgunpack_float_r8g8b8x8_srgb(const void *void_src, GLfloat dst[4])
1702b8e80941Smrg{
1703b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
1704b8e80941Smrg            uint8_t r = UNPACK(*src, 0, 8);
1705b8e80941Smrg            uint8_t g = UNPACK(*src, 8, 8);
1706b8e80941Smrg            uint8_t b = UNPACK(*src, 16, 8);
1707b8e80941Smrg
1708b8e80941Smrg
1709b8e80941Smrg
1710b8e80941Smrg
1711b8e80941Smrg               dst[0] = util_format_srgb_8unorm_to_linear_float(r);
1712b8e80941Smrg
1713b8e80941Smrg
1714b8e80941Smrg
1715b8e80941Smrg               dst[1] = util_format_srgb_8unorm_to_linear_float(g);
1716b8e80941Smrg
1717b8e80941Smrg
1718b8e80941Smrg
1719b8e80941Smrg               dst[2] = util_format_srgb_8unorm_to_linear_float(b);
1720b8e80941Smrg
1721b8e80941Smrg         dst[3] = 1.0f;
1722b8e80941Smrg}
1723b8e80941Smrg
1724b8e80941Smrgstatic inline void
1725b8e80941Smrgunpack_float_x8b8g8r8_srgb(const void *void_src, GLfloat dst[4])
1726b8e80941Smrg{
1727b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
1728b8e80941Smrg            uint8_t b = UNPACK(*src, 8, 8);
1729b8e80941Smrg            uint8_t g = UNPACK(*src, 16, 8);
1730b8e80941Smrg            uint8_t r = UNPACK(*src, 24, 8);
1731b8e80941Smrg
1732b8e80941Smrg
1733b8e80941Smrg
1734b8e80941Smrg
1735b8e80941Smrg               dst[0] = util_format_srgb_8unorm_to_linear_float(r);
1736b8e80941Smrg
1737b8e80941Smrg
1738b8e80941Smrg
1739b8e80941Smrg               dst[1] = util_format_srgb_8unorm_to_linear_float(g);
1740b8e80941Smrg
1741b8e80941Smrg
1742b8e80941Smrg
1743b8e80941Smrg               dst[2] = util_format_srgb_8unorm_to_linear_float(b);
1744b8e80941Smrg
1745b8e80941Smrg         dst[3] = 1.0f;
1746b8e80941Smrg}
1747b8e80941Smrg
1748b8e80941Smrgstatic inline void
1749b8e80941Smrgunpack_float_l8a8_srgb(const void *void_src, GLfloat dst[4])
1750b8e80941Smrg{
1751b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
1752b8e80941Smrg            uint8_t l = UNPACK(*src, 0, 8);
1753b8e80941Smrg            uint8_t a = UNPACK(*src, 8, 8);
1754b8e80941Smrg
1755b8e80941Smrg
1756b8e80941Smrg
1757b8e80941Smrg               dst[0] = _mesa_unorm_to_float(l, 8);
1758b8e80941Smrg
1759b8e80941Smrg
1760b8e80941Smrg               dst[1] = _mesa_unorm_to_float(l, 8);
1761b8e80941Smrg
1762b8e80941Smrg
1763b8e80941Smrg               dst[2] = _mesa_unorm_to_float(l, 8);
1764b8e80941Smrg
1765b8e80941Smrg
1766b8e80941Smrg               dst[3] = _mesa_unorm_to_float(a, 8);
1767b8e80941Smrg}
1768b8e80941Smrg
1769b8e80941Smrgstatic inline void
1770b8e80941Smrgunpack_float_a8l8_srgb(const void *void_src, GLfloat dst[4])
1771b8e80941Smrg{
1772b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
1773b8e80941Smrg            uint8_t a = UNPACK(*src, 0, 8);
1774b8e80941Smrg            uint8_t l = UNPACK(*src, 8, 8);
1775b8e80941Smrg
1776b8e80941Smrg
1777b8e80941Smrg
1778b8e80941Smrg               dst[0] = _mesa_unorm_to_float(l, 8);
1779b8e80941Smrg
1780b8e80941Smrg
1781b8e80941Smrg               dst[1] = _mesa_unorm_to_float(l, 8);
1782b8e80941Smrg
1783b8e80941Smrg
1784b8e80941Smrg               dst[2] = _mesa_unorm_to_float(l, 8);
1785b8e80941Smrg
1786b8e80941Smrg
1787b8e80941Smrg               dst[3] = _mesa_unorm_to_float(a, 8);
1788b8e80941Smrg}
1789b8e80941Smrg
1790b8e80941Smrgstatic inline void
1791b8e80941Smrgunpack_float_r_srgb8(const void *void_src, GLfloat dst[4])
1792b8e80941Smrg{
1793b8e80941Smrg   uint8_t *src = (uint8_t *)void_src;
1794b8e80941Smrg            uint8_t r = src[0];
1795b8e80941Smrg
1796b8e80941Smrg
1797b8e80941Smrg
1798b8e80941Smrg
1799b8e80941Smrg               dst[0] = util_format_srgb_8unorm_to_linear_float(r);
1800b8e80941Smrg
1801b8e80941Smrg         dst[1] = 0.0f;
1802b8e80941Smrg
1803b8e80941Smrg         dst[2] = 0.0f;
1804b8e80941Smrg
1805b8e80941Smrg         dst[3] = 1.0f;
1806b8e80941Smrg}
1807b8e80941Smrg
1808b8e80941Smrgstatic inline void
1809b8e80941Smrgunpack_float_l_srgb8(const void *void_src, GLfloat dst[4])
1810b8e80941Smrg{
1811b8e80941Smrg   uint8_t *src = (uint8_t *)void_src;
1812b8e80941Smrg            uint8_t l = src[0];
1813b8e80941Smrg
1814b8e80941Smrg
1815b8e80941Smrg
1816b8e80941Smrg               dst[0] = _mesa_unorm_to_float(l, 8);
1817b8e80941Smrg
1818b8e80941Smrg
1819b8e80941Smrg               dst[1] = _mesa_unorm_to_float(l, 8);
1820b8e80941Smrg
1821b8e80941Smrg
1822b8e80941Smrg               dst[2] = _mesa_unorm_to_float(l, 8);
1823b8e80941Smrg
1824b8e80941Smrg         dst[3] = 1.0f;
1825b8e80941Smrg}
1826b8e80941Smrg
1827b8e80941Smrgstatic inline void
1828b8e80941Smrgunpack_float_bgr_srgb8(const void *void_src, GLfloat dst[4])
1829b8e80941Smrg{
1830b8e80941Smrg   uint8_t *src = (uint8_t *)void_src;
1831b8e80941Smrg            uint8_t b = src[0];
1832b8e80941Smrg            uint8_t g = src[1];
1833b8e80941Smrg            uint8_t r = src[2];
1834b8e80941Smrg
1835b8e80941Smrg
1836b8e80941Smrg
1837b8e80941Smrg
1838b8e80941Smrg               dst[0] = util_format_srgb_8unorm_to_linear_float(r);
1839b8e80941Smrg
1840b8e80941Smrg
1841b8e80941Smrg
1842b8e80941Smrg               dst[1] = util_format_srgb_8unorm_to_linear_float(g);
1843b8e80941Smrg
1844b8e80941Smrg
1845b8e80941Smrg
1846b8e80941Smrg               dst[2] = util_format_srgb_8unorm_to_linear_float(b);
1847b8e80941Smrg
1848b8e80941Smrg         dst[3] = 1.0f;
1849b8e80941Smrg}
1850b8e80941Smrg
1851b8e80941Smrgstatic inline void
1852b8e80941Smrgunpack_float_a_float16(const void *void_src, GLfloat dst[4])
1853b8e80941Smrg{
1854b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
1855b8e80941Smrg            uint16_t a = src[0];
1856b8e80941Smrg
1857b8e80941Smrg
1858b8e80941Smrg         dst[0] = 0.0f;
1859b8e80941Smrg
1860b8e80941Smrg         dst[1] = 0.0f;
1861b8e80941Smrg
1862b8e80941Smrg         dst[2] = 0.0f;
1863b8e80941Smrg
1864b8e80941Smrg
1865b8e80941Smrg               dst[3] = _mesa_half_to_float(a);
1866b8e80941Smrg}
1867b8e80941Smrg
1868b8e80941Smrgstatic inline void
1869b8e80941Smrgunpack_float_a_float32(const void *void_src, GLfloat dst[4])
1870b8e80941Smrg{
1871b8e80941Smrg   float *src = (float *)void_src;
1872b8e80941Smrg            float a = src[0];
1873b8e80941Smrg
1874b8e80941Smrg
1875b8e80941Smrg         dst[0] = 0.0f;
1876b8e80941Smrg
1877b8e80941Smrg         dst[1] = 0.0f;
1878b8e80941Smrg
1879b8e80941Smrg         dst[2] = 0.0f;
1880b8e80941Smrg
1881b8e80941Smrg
1882b8e80941Smrg               dst[3] = a;
1883b8e80941Smrg}
1884b8e80941Smrg
1885b8e80941Smrgstatic inline void
1886b8e80941Smrgunpack_float_l_float16(const void *void_src, GLfloat dst[4])
1887b8e80941Smrg{
1888b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
1889b8e80941Smrg            uint16_t l = src[0];
1890b8e80941Smrg
1891b8e80941Smrg
1892b8e80941Smrg
1893b8e80941Smrg               dst[0] = _mesa_half_to_float(l);
1894b8e80941Smrg
1895b8e80941Smrg
1896b8e80941Smrg               dst[1] = _mesa_half_to_float(l);
1897b8e80941Smrg
1898b8e80941Smrg
1899b8e80941Smrg               dst[2] = _mesa_half_to_float(l);
1900b8e80941Smrg
1901b8e80941Smrg         dst[3] = 1.0f;
1902b8e80941Smrg}
1903b8e80941Smrg
1904b8e80941Smrgstatic inline void
1905b8e80941Smrgunpack_float_l_float32(const void *void_src, GLfloat dst[4])
1906b8e80941Smrg{
1907b8e80941Smrg   float *src = (float *)void_src;
1908b8e80941Smrg            float l = src[0];
1909b8e80941Smrg
1910b8e80941Smrg
1911b8e80941Smrg
1912b8e80941Smrg               dst[0] = l;
1913b8e80941Smrg
1914b8e80941Smrg
1915b8e80941Smrg               dst[1] = l;
1916b8e80941Smrg
1917b8e80941Smrg
1918b8e80941Smrg               dst[2] = l;
1919b8e80941Smrg
1920b8e80941Smrg         dst[3] = 1.0f;
1921b8e80941Smrg}
1922b8e80941Smrg
1923b8e80941Smrgstatic inline void
1924b8e80941Smrgunpack_float_la_float16(const void *void_src, GLfloat dst[4])
1925b8e80941Smrg{
1926b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
1927b8e80941Smrg            uint16_t l = src[0];
1928b8e80941Smrg            uint16_t a = src[1];
1929b8e80941Smrg
1930b8e80941Smrg
1931b8e80941Smrg
1932b8e80941Smrg               dst[0] = _mesa_half_to_float(l);
1933b8e80941Smrg
1934b8e80941Smrg
1935b8e80941Smrg               dst[1] = _mesa_half_to_float(l);
1936b8e80941Smrg
1937b8e80941Smrg
1938b8e80941Smrg               dst[2] = _mesa_half_to_float(l);
1939b8e80941Smrg
1940b8e80941Smrg
1941b8e80941Smrg               dst[3] = _mesa_half_to_float(a);
1942b8e80941Smrg}
1943b8e80941Smrg
1944b8e80941Smrgstatic inline void
1945b8e80941Smrgunpack_float_la_float32(const void *void_src, GLfloat dst[4])
1946b8e80941Smrg{
1947b8e80941Smrg   float *src = (float *)void_src;
1948b8e80941Smrg            float l = src[0];
1949b8e80941Smrg            float a = src[1];
1950b8e80941Smrg
1951b8e80941Smrg
1952b8e80941Smrg
1953b8e80941Smrg               dst[0] = l;
1954b8e80941Smrg
1955b8e80941Smrg
1956b8e80941Smrg               dst[1] = l;
1957b8e80941Smrg
1958b8e80941Smrg
1959b8e80941Smrg               dst[2] = l;
1960b8e80941Smrg
1961b8e80941Smrg
1962b8e80941Smrg               dst[3] = a;
1963b8e80941Smrg}
1964b8e80941Smrg
1965b8e80941Smrgstatic inline void
1966b8e80941Smrgunpack_float_i_float16(const void *void_src, GLfloat dst[4])
1967b8e80941Smrg{
1968b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
1969b8e80941Smrg            uint16_t i = src[0];
1970b8e80941Smrg
1971b8e80941Smrg
1972b8e80941Smrg
1973b8e80941Smrg               dst[0] = _mesa_half_to_float(i);
1974b8e80941Smrg
1975b8e80941Smrg
1976b8e80941Smrg               dst[1] = _mesa_half_to_float(i);
1977b8e80941Smrg
1978b8e80941Smrg
1979b8e80941Smrg               dst[2] = _mesa_half_to_float(i);
1980b8e80941Smrg
1981b8e80941Smrg
1982b8e80941Smrg               dst[3] = _mesa_half_to_float(i);
1983b8e80941Smrg}
1984b8e80941Smrg
1985b8e80941Smrgstatic inline void
1986b8e80941Smrgunpack_float_i_float32(const void *void_src, GLfloat dst[4])
1987b8e80941Smrg{
1988b8e80941Smrg   float *src = (float *)void_src;
1989b8e80941Smrg            float i = src[0];
1990b8e80941Smrg
1991b8e80941Smrg
1992b8e80941Smrg
1993b8e80941Smrg               dst[0] = i;
1994b8e80941Smrg
1995b8e80941Smrg
1996b8e80941Smrg               dst[1] = i;
1997b8e80941Smrg
1998b8e80941Smrg
1999b8e80941Smrg               dst[2] = i;
2000b8e80941Smrg
2001b8e80941Smrg
2002b8e80941Smrg               dst[3] = i;
2003b8e80941Smrg}
2004b8e80941Smrg
2005b8e80941Smrgstatic inline void
2006b8e80941Smrgunpack_float_r_float16(const void *void_src, GLfloat dst[4])
2007b8e80941Smrg{
2008b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
2009b8e80941Smrg            uint16_t r = src[0];
2010b8e80941Smrg
2011b8e80941Smrg
2012b8e80941Smrg
2013b8e80941Smrg               dst[0] = _mesa_half_to_float(r);
2014b8e80941Smrg
2015b8e80941Smrg         dst[1] = 0.0f;
2016b8e80941Smrg
2017b8e80941Smrg         dst[2] = 0.0f;
2018b8e80941Smrg
2019b8e80941Smrg         dst[3] = 1.0f;
2020b8e80941Smrg}
2021b8e80941Smrg
2022b8e80941Smrgstatic inline void
2023b8e80941Smrgunpack_float_r_float32(const void *void_src, GLfloat dst[4])
2024b8e80941Smrg{
2025b8e80941Smrg   float *src = (float *)void_src;
2026b8e80941Smrg            float r = src[0];
2027b8e80941Smrg
2028b8e80941Smrg
2029b8e80941Smrg
2030b8e80941Smrg               dst[0] = r;
2031b8e80941Smrg
2032b8e80941Smrg         dst[1] = 0.0f;
2033b8e80941Smrg
2034b8e80941Smrg         dst[2] = 0.0f;
2035b8e80941Smrg
2036b8e80941Smrg         dst[3] = 1.0f;
2037b8e80941Smrg}
2038b8e80941Smrg
2039b8e80941Smrgstatic inline void
2040b8e80941Smrgunpack_float_rg_float16(const void *void_src, GLfloat dst[4])
2041b8e80941Smrg{
2042b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
2043b8e80941Smrg            uint16_t r = src[0];
2044b8e80941Smrg            uint16_t g = src[1];
2045b8e80941Smrg
2046b8e80941Smrg
2047b8e80941Smrg
2048b8e80941Smrg               dst[0] = _mesa_half_to_float(r);
2049b8e80941Smrg
2050b8e80941Smrg
2051b8e80941Smrg               dst[1] = _mesa_half_to_float(g);
2052b8e80941Smrg
2053b8e80941Smrg         dst[2] = 0.0f;
2054b8e80941Smrg
2055b8e80941Smrg         dst[3] = 1.0f;
2056b8e80941Smrg}
2057b8e80941Smrg
2058b8e80941Smrgstatic inline void
2059b8e80941Smrgunpack_float_rg_float32(const void *void_src, GLfloat dst[4])
2060b8e80941Smrg{
2061b8e80941Smrg   float *src = (float *)void_src;
2062b8e80941Smrg            float r = src[0];
2063b8e80941Smrg            float g = src[1];
2064b8e80941Smrg
2065b8e80941Smrg
2066b8e80941Smrg
2067b8e80941Smrg               dst[0] = r;
2068b8e80941Smrg
2069b8e80941Smrg
2070b8e80941Smrg               dst[1] = g;
2071b8e80941Smrg
2072b8e80941Smrg         dst[2] = 0.0f;
2073b8e80941Smrg
2074b8e80941Smrg         dst[3] = 1.0f;
2075b8e80941Smrg}
2076b8e80941Smrg
2077b8e80941Smrgstatic inline void
2078b8e80941Smrgunpack_float_rgb_float16(const void *void_src, GLfloat dst[4])
2079b8e80941Smrg{
2080b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
2081b8e80941Smrg            uint16_t r = src[0];
2082b8e80941Smrg            uint16_t g = src[1];
2083b8e80941Smrg            uint16_t b = src[2];
2084b8e80941Smrg
2085b8e80941Smrg
2086b8e80941Smrg
2087b8e80941Smrg               dst[0] = _mesa_half_to_float(r);
2088b8e80941Smrg
2089b8e80941Smrg
2090b8e80941Smrg               dst[1] = _mesa_half_to_float(g);
2091b8e80941Smrg
2092b8e80941Smrg
2093b8e80941Smrg               dst[2] = _mesa_half_to_float(b);
2094b8e80941Smrg
2095b8e80941Smrg         dst[3] = 1.0f;
2096b8e80941Smrg}
2097b8e80941Smrg
2098b8e80941Smrgstatic inline void
2099b8e80941Smrgunpack_float_rgb_float32(const void *void_src, GLfloat dst[4])
2100b8e80941Smrg{
2101b8e80941Smrg   float *src = (float *)void_src;
2102b8e80941Smrg            float r = src[0];
2103b8e80941Smrg            float g = src[1];
2104b8e80941Smrg            float b = src[2];
2105b8e80941Smrg
2106b8e80941Smrg
2107b8e80941Smrg
2108b8e80941Smrg               dst[0] = r;
2109b8e80941Smrg
2110b8e80941Smrg
2111b8e80941Smrg               dst[1] = g;
2112b8e80941Smrg
2113b8e80941Smrg
2114b8e80941Smrg               dst[2] = b;
2115b8e80941Smrg
2116b8e80941Smrg         dst[3] = 1.0f;
2117b8e80941Smrg}
2118b8e80941Smrg
2119b8e80941Smrgstatic inline void
2120b8e80941Smrgunpack_float_rgba_float16(const void *void_src, GLfloat dst[4])
2121b8e80941Smrg{
2122b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
2123b8e80941Smrg            uint16_t r = src[0];
2124b8e80941Smrg            uint16_t g = src[1];
2125b8e80941Smrg            uint16_t b = src[2];
2126b8e80941Smrg            uint16_t a = src[3];
2127b8e80941Smrg
2128b8e80941Smrg
2129b8e80941Smrg
2130b8e80941Smrg               dst[0] = _mesa_half_to_float(r);
2131b8e80941Smrg
2132b8e80941Smrg
2133b8e80941Smrg               dst[1] = _mesa_half_to_float(g);
2134b8e80941Smrg
2135b8e80941Smrg
2136b8e80941Smrg               dst[2] = _mesa_half_to_float(b);
2137b8e80941Smrg
2138b8e80941Smrg
2139b8e80941Smrg               dst[3] = _mesa_half_to_float(a);
2140b8e80941Smrg}
2141b8e80941Smrg
2142b8e80941Smrgstatic inline void
2143b8e80941Smrgunpack_float_rgba_float32(const void *void_src, GLfloat dst[4])
2144b8e80941Smrg{
2145b8e80941Smrg   float *src = (float *)void_src;
2146b8e80941Smrg            float r = src[0];
2147b8e80941Smrg            float g = src[1];
2148b8e80941Smrg            float b = src[2];
2149b8e80941Smrg            float a = src[3];
2150b8e80941Smrg
2151b8e80941Smrg
2152b8e80941Smrg
2153b8e80941Smrg               dst[0] = r;
2154b8e80941Smrg
2155b8e80941Smrg
2156b8e80941Smrg               dst[1] = g;
2157b8e80941Smrg
2158b8e80941Smrg
2159b8e80941Smrg               dst[2] = b;
2160b8e80941Smrg
2161b8e80941Smrg
2162b8e80941Smrg               dst[3] = a;
2163b8e80941Smrg}
2164b8e80941Smrg
2165b8e80941Smrgstatic inline void
2166b8e80941Smrgunpack_float_rgbx_float16(const void *void_src, GLfloat dst[4])
2167b8e80941Smrg{
2168b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
2169b8e80941Smrg            uint16_t r = src[0];
2170b8e80941Smrg            uint16_t g = src[1];
2171b8e80941Smrg            uint16_t b = src[2];
2172b8e80941Smrg
2173b8e80941Smrg
2174b8e80941Smrg
2175b8e80941Smrg               dst[0] = _mesa_half_to_float(r);
2176b8e80941Smrg
2177b8e80941Smrg
2178b8e80941Smrg               dst[1] = _mesa_half_to_float(g);
2179b8e80941Smrg
2180b8e80941Smrg
2181b8e80941Smrg               dst[2] = _mesa_half_to_float(b);
2182b8e80941Smrg
2183b8e80941Smrg         dst[3] = 1.0f;
2184b8e80941Smrg}
2185b8e80941Smrg
2186b8e80941Smrgstatic inline void
2187b8e80941Smrgunpack_float_rgbx_float32(const void *void_src, GLfloat dst[4])
2188b8e80941Smrg{
2189b8e80941Smrg   float *src = (float *)void_src;
2190b8e80941Smrg            float r = src[0];
2191b8e80941Smrg            float g = src[1];
2192b8e80941Smrg            float b = src[2];
2193b8e80941Smrg
2194b8e80941Smrg
2195b8e80941Smrg
2196b8e80941Smrg               dst[0] = r;
2197b8e80941Smrg
2198b8e80941Smrg
2199b8e80941Smrg               dst[1] = g;
2200b8e80941Smrg
2201b8e80941Smrg
2202b8e80941Smrg               dst[2] = b;
2203b8e80941Smrg
2204b8e80941Smrg         dst[3] = 1.0f;
2205b8e80941Smrg}
2206b8e80941Smrg
2207b8e80941Smrgstatic void
2208b8e80941Smrgunpack_float_r9g9b9e5_float(const void *src, GLfloat dst[4])
2209b8e80941Smrg{
2210b8e80941Smrg   rgb9e5_to_float3(*(const GLuint *)src, dst);
2211b8e80941Smrg   dst[3] = 1.0f;
2212b8e80941Smrg}
2213b8e80941Smrg
2214b8e80941Smrgstatic void
2215b8e80941Smrgunpack_float_r11g11b10_float(const void *src, GLfloat dst[4])
2216b8e80941Smrg{
2217b8e80941Smrg   r11g11b10f_to_float3(*(const GLuint *)src, dst);
2218b8e80941Smrg   dst[3] = 1.0f;
2219b8e80941Smrg}
2220b8e80941Smrg
2221b8e80941Smrgstatic void
2222b8e80941Smrgunpack_float_ycbcr(const void *src, GLfloat dst[][4], GLuint n)
2223b8e80941Smrg{
2224b8e80941Smrg   GLuint i;
2225b8e80941Smrg   for (i = 0; i < n; i++) {
2226b8e80941Smrg      const GLushort *src0 = ((const GLushort *) src) + i * 2; /* even */
2227b8e80941Smrg      const GLushort *src1 = src0 + 1;         /* odd */
2228b8e80941Smrg      const GLubyte y0 = (*src0 >> 8) & 0xff;  /* luminance */
2229b8e80941Smrg      const GLubyte cb = *src0 & 0xff;         /* chroma U */
2230b8e80941Smrg      const GLubyte y1 = (*src1 >> 8) & 0xff;  /* luminance */
2231b8e80941Smrg      const GLubyte cr = *src1 & 0xff;         /* chroma V */
2232b8e80941Smrg      const GLubyte y = (i & 1) ? y1 : y0;     /* choose even/odd luminance */
2233b8e80941Smrg      GLfloat r = 1.164F * (y - 16) + 1.596F * (cr - 128);
2234b8e80941Smrg      GLfloat g = 1.164F * (y - 16) - 0.813F * (cr - 128) - 0.391F * (cb - 128);
2235b8e80941Smrg      GLfloat b = 1.164F * (y - 16) + 2.018F * (cb - 128);
2236b8e80941Smrg      r *= (1.0F / 255.0F);
2237b8e80941Smrg      g *= (1.0F / 255.0F);
2238b8e80941Smrg      b *= (1.0F / 255.0F);
2239b8e80941Smrg      dst[i][0] = CLAMP(r, 0.0F, 1.0F);
2240b8e80941Smrg      dst[i][1] = CLAMP(g, 0.0F, 1.0F);
2241b8e80941Smrg      dst[i][2] = CLAMP(b, 0.0F, 1.0F);
2242b8e80941Smrg      dst[i][3] = 1.0F;
2243b8e80941Smrg   }
2244b8e80941Smrg}
2245b8e80941Smrg
2246b8e80941Smrgstatic void
2247b8e80941Smrgunpack_float_ycbcr_rev(const void *src, GLfloat dst[][4], GLuint n)
2248b8e80941Smrg{
2249b8e80941Smrg   GLuint i;
2250b8e80941Smrg   for (i = 0; i < n; i++) {
2251b8e80941Smrg      const GLushort *src0 = ((const GLushort *) src) + i * 2; /* even */
2252b8e80941Smrg      const GLushort *src1 = src0 + 1;         /* odd */
2253b8e80941Smrg      const GLubyte y0 = *src0 & 0xff;         /* luminance */
2254b8e80941Smrg      const GLubyte cr = (*src0 >> 8) & 0xff;  /* chroma V */
2255b8e80941Smrg      const GLubyte y1 = *src1 & 0xff;         /* luminance */
2256b8e80941Smrg      const GLubyte cb = (*src1 >> 8) & 0xff;  /* chroma U */
2257b8e80941Smrg      const GLubyte y = (i & 1) ? y1 : y0;     /* choose even/odd luminance */
2258b8e80941Smrg      GLfloat r = 1.164F * (y - 16) + 1.596F * (cr - 128);
2259b8e80941Smrg      GLfloat g = 1.164F * (y - 16) - 0.813F * (cr - 128) - 0.391F * (cb - 128);
2260b8e80941Smrg      GLfloat b = 1.164F * (y - 16) + 2.018F * (cb - 128);
2261b8e80941Smrg      r *= (1.0F / 255.0F);
2262b8e80941Smrg      g *= (1.0F / 255.0F);
2263b8e80941Smrg      b *= (1.0F / 255.0F);
2264b8e80941Smrg      dst[i][0] = CLAMP(r, 0.0F, 1.0F);
2265b8e80941Smrg      dst[i][1] = CLAMP(g, 0.0F, 1.0F);
2266b8e80941Smrg      dst[i][2] = CLAMP(b, 0.0F, 1.0F);
2267b8e80941Smrg      dst[i][3] = 1.0F;
2268b8e80941Smrg   }
2269b8e80941Smrg}
2270b8e80941Smrg
2271b8e80941Smrg/* ubyte packing functions */
2272b8e80941Smrg
2273b8e80941Smrg
2274b8e80941Smrgstatic inline void
2275b8e80941Smrgunpack_ubyte_a8b8g8r8_unorm(const void *void_src, GLubyte dst[4])
2276b8e80941Smrg{
2277b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
2278b8e80941Smrg            uint8_t a = UNPACK(*src, 0, 8);
2279b8e80941Smrg            uint8_t b = UNPACK(*src, 8, 8);
2280b8e80941Smrg            uint8_t g = UNPACK(*src, 16, 8);
2281b8e80941Smrg            uint8_t r = UNPACK(*src, 24, 8);
2282b8e80941Smrg
2283b8e80941Smrg
2284b8e80941Smrg
2285b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(r, 8, 8);
2286b8e80941Smrg
2287b8e80941Smrg
2288b8e80941Smrg               dst[1] = _mesa_unorm_to_unorm(g, 8, 8);
2289b8e80941Smrg
2290b8e80941Smrg
2291b8e80941Smrg               dst[2] = _mesa_unorm_to_unorm(b, 8, 8);
2292b8e80941Smrg
2293b8e80941Smrg
2294b8e80941Smrg               dst[3] = _mesa_unorm_to_unorm(a, 8, 8);
2295b8e80941Smrg}
2296b8e80941Smrg
2297b8e80941Smrgstatic inline void
2298b8e80941Smrgunpack_ubyte_x8b8g8r8_unorm(const void *void_src, GLubyte dst[4])
2299b8e80941Smrg{
2300b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
2301b8e80941Smrg            uint8_t b = UNPACK(*src, 8, 8);
2302b8e80941Smrg            uint8_t g = UNPACK(*src, 16, 8);
2303b8e80941Smrg            uint8_t r = UNPACK(*src, 24, 8);
2304b8e80941Smrg
2305b8e80941Smrg
2306b8e80941Smrg
2307b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(r, 8, 8);
2308b8e80941Smrg
2309b8e80941Smrg
2310b8e80941Smrg               dst[1] = _mesa_unorm_to_unorm(g, 8, 8);
2311b8e80941Smrg
2312b8e80941Smrg
2313b8e80941Smrg               dst[2] = _mesa_unorm_to_unorm(b, 8, 8);
2314b8e80941Smrg
2315b8e80941Smrg         dst[3] = 255;
2316b8e80941Smrg}
2317b8e80941Smrg
2318b8e80941Smrgstatic inline void
2319b8e80941Smrgunpack_ubyte_r8g8b8a8_unorm(const void *void_src, GLubyte dst[4])
2320b8e80941Smrg{
2321b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
2322b8e80941Smrg            uint8_t r = UNPACK(*src, 0, 8);
2323b8e80941Smrg            uint8_t g = UNPACK(*src, 8, 8);
2324b8e80941Smrg            uint8_t b = UNPACK(*src, 16, 8);
2325b8e80941Smrg            uint8_t a = UNPACK(*src, 24, 8);
2326b8e80941Smrg
2327b8e80941Smrg
2328b8e80941Smrg
2329b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(r, 8, 8);
2330b8e80941Smrg
2331b8e80941Smrg
2332b8e80941Smrg               dst[1] = _mesa_unorm_to_unorm(g, 8, 8);
2333b8e80941Smrg
2334b8e80941Smrg
2335b8e80941Smrg               dst[2] = _mesa_unorm_to_unorm(b, 8, 8);
2336b8e80941Smrg
2337b8e80941Smrg
2338b8e80941Smrg               dst[3] = _mesa_unorm_to_unorm(a, 8, 8);
2339b8e80941Smrg}
2340b8e80941Smrg
2341b8e80941Smrgstatic inline void
2342b8e80941Smrgunpack_ubyte_r8g8b8x8_unorm(const void *void_src, GLubyte dst[4])
2343b8e80941Smrg{
2344b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
2345b8e80941Smrg            uint8_t r = UNPACK(*src, 0, 8);
2346b8e80941Smrg            uint8_t g = UNPACK(*src, 8, 8);
2347b8e80941Smrg            uint8_t b = UNPACK(*src, 16, 8);
2348b8e80941Smrg
2349b8e80941Smrg
2350b8e80941Smrg
2351b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(r, 8, 8);
2352b8e80941Smrg
2353b8e80941Smrg
2354b8e80941Smrg               dst[1] = _mesa_unorm_to_unorm(g, 8, 8);
2355b8e80941Smrg
2356b8e80941Smrg
2357b8e80941Smrg               dst[2] = _mesa_unorm_to_unorm(b, 8, 8);
2358b8e80941Smrg
2359b8e80941Smrg         dst[3] = 255;
2360b8e80941Smrg}
2361b8e80941Smrg
2362b8e80941Smrgstatic inline void
2363b8e80941Smrgunpack_ubyte_b8g8r8a8_unorm(const void *void_src, GLubyte dst[4])
2364b8e80941Smrg{
2365b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
2366b8e80941Smrg            uint8_t b = UNPACK(*src, 0, 8);
2367b8e80941Smrg            uint8_t g = UNPACK(*src, 8, 8);
2368b8e80941Smrg            uint8_t r = UNPACK(*src, 16, 8);
2369b8e80941Smrg            uint8_t a = UNPACK(*src, 24, 8);
2370b8e80941Smrg
2371b8e80941Smrg
2372b8e80941Smrg
2373b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(r, 8, 8);
2374b8e80941Smrg
2375b8e80941Smrg
2376b8e80941Smrg               dst[1] = _mesa_unorm_to_unorm(g, 8, 8);
2377b8e80941Smrg
2378b8e80941Smrg
2379b8e80941Smrg               dst[2] = _mesa_unorm_to_unorm(b, 8, 8);
2380b8e80941Smrg
2381b8e80941Smrg
2382b8e80941Smrg               dst[3] = _mesa_unorm_to_unorm(a, 8, 8);
2383b8e80941Smrg}
2384b8e80941Smrg
2385b8e80941Smrgstatic inline void
2386b8e80941Smrgunpack_ubyte_b8g8r8x8_unorm(const void *void_src, GLubyte dst[4])
2387b8e80941Smrg{
2388b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
2389b8e80941Smrg            uint8_t b = UNPACK(*src, 0, 8);
2390b8e80941Smrg            uint8_t g = UNPACK(*src, 8, 8);
2391b8e80941Smrg            uint8_t r = UNPACK(*src, 16, 8);
2392b8e80941Smrg
2393b8e80941Smrg
2394b8e80941Smrg
2395b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(r, 8, 8);
2396b8e80941Smrg
2397b8e80941Smrg
2398b8e80941Smrg               dst[1] = _mesa_unorm_to_unorm(g, 8, 8);
2399b8e80941Smrg
2400b8e80941Smrg
2401b8e80941Smrg               dst[2] = _mesa_unorm_to_unorm(b, 8, 8);
2402b8e80941Smrg
2403b8e80941Smrg         dst[3] = 255;
2404b8e80941Smrg}
2405b8e80941Smrg
2406b8e80941Smrgstatic inline void
2407b8e80941Smrgunpack_ubyte_a8r8g8b8_unorm(const void *void_src, GLubyte dst[4])
2408b8e80941Smrg{
2409b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
2410b8e80941Smrg            uint8_t a = UNPACK(*src, 0, 8);
2411b8e80941Smrg            uint8_t r = UNPACK(*src, 8, 8);
2412b8e80941Smrg            uint8_t g = UNPACK(*src, 16, 8);
2413b8e80941Smrg            uint8_t b = UNPACK(*src, 24, 8);
2414b8e80941Smrg
2415b8e80941Smrg
2416b8e80941Smrg
2417b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(r, 8, 8);
2418b8e80941Smrg
2419b8e80941Smrg
2420b8e80941Smrg               dst[1] = _mesa_unorm_to_unorm(g, 8, 8);
2421b8e80941Smrg
2422b8e80941Smrg
2423b8e80941Smrg               dst[2] = _mesa_unorm_to_unorm(b, 8, 8);
2424b8e80941Smrg
2425b8e80941Smrg
2426b8e80941Smrg               dst[3] = _mesa_unorm_to_unorm(a, 8, 8);
2427b8e80941Smrg}
2428b8e80941Smrg
2429b8e80941Smrgstatic inline void
2430b8e80941Smrgunpack_ubyte_x8r8g8b8_unorm(const void *void_src, GLubyte dst[4])
2431b8e80941Smrg{
2432b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
2433b8e80941Smrg            uint8_t r = UNPACK(*src, 8, 8);
2434b8e80941Smrg            uint8_t g = UNPACK(*src, 16, 8);
2435b8e80941Smrg            uint8_t b = UNPACK(*src, 24, 8);
2436b8e80941Smrg
2437b8e80941Smrg
2438b8e80941Smrg
2439b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(r, 8, 8);
2440b8e80941Smrg
2441b8e80941Smrg
2442b8e80941Smrg               dst[1] = _mesa_unorm_to_unorm(g, 8, 8);
2443b8e80941Smrg
2444b8e80941Smrg
2445b8e80941Smrg               dst[2] = _mesa_unorm_to_unorm(b, 8, 8);
2446b8e80941Smrg
2447b8e80941Smrg         dst[3] = 255;
2448b8e80941Smrg}
2449b8e80941Smrg
2450b8e80941Smrgstatic inline void
2451b8e80941Smrgunpack_ubyte_l16a16_unorm(const void *void_src, GLubyte dst[4])
2452b8e80941Smrg{
2453b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
2454b8e80941Smrg            uint16_t l = UNPACK(*src, 0, 16);
2455b8e80941Smrg            uint16_t a = UNPACK(*src, 16, 16);
2456b8e80941Smrg
2457b8e80941Smrg
2458b8e80941Smrg
2459b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(l, 16, 8);
2460b8e80941Smrg
2461b8e80941Smrg
2462b8e80941Smrg               dst[1] = _mesa_unorm_to_unorm(l, 16, 8);
2463b8e80941Smrg
2464b8e80941Smrg
2465b8e80941Smrg               dst[2] = _mesa_unorm_to_unorm(l, 16, 8);
2466b8e80941Smrg
2467b8e80941Smrg
2468b8e80941Smrg               dst[3] = _mesa_unorm_to_unorm(a, 16, 8);
2469b8e80941Smrg}
2470b8e80941Smrg
2471b8e80941Smrgstatic inline void
2472b8e80941Smrgunpack_ubyte_a16l16_unorm(const void *void_src, GLubyte dst[4])
2473b8e80941Smrg{
2474b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
2475b8e80941Smrg            uint16_t a = UNPACK(*src, 0, 16);
2476b8e80941Smrg            uint16_t l = UNPACK(*src, 16, 16);
2477b8e80941Smrg
2478b8e80941Smrg
2479b8e80941Smrg
2480b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(l, 16, 8);
2481b8e80941Smrg
2482b8e80941Smrg
2483b8e80941Smrg               dst[1] = _mesa_unorm_to_unorm(l, 16, 8);
2484b8e80941Smrg
2485b8e80941Smrg
2486b8e80941Smrg               dst[2] = _mesa_unorm_to_unorm(l, 16, 8);
2487b8e80941Smrg
2488b8e80941Smrg
2489b8e80941Smrg               dst[3] = _mesa_unorm_to_unorm(a, 16, 8);
2490b8e80941Smrg}
2491b8e80941Smrg
2492b8e80941Smrgstatic inline void
2493b8e80941Smrgunpack_ubyte_b5g6r5_unorm(const void *void_src, GLubyte dst[4])
2494b8e80941Smrg{
2495b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
2496b8e80941Smrg            uint8_t b = UNPACK(*src, 0, 5);
2497b8e80941Smrg            uint8_t g = UNPACK(*src, 5, 6);
2498b8e80941Smrg            uint8_t r = UNPACK(*src, 11, 5);
2499b8e80941Smrg
2500b8e80941Smrg
2501b8e80941Smrg
2502b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(r, 5, 8);
2503b8e80941Smrg
2504b8e80941Smrg
2505b8e80941Smrg               dst[1] = _mesa_unorm_to_unorm(g, 6, 8);
2506b8e80941Smrg
2507b8e80941Smrg
2508b8e80941Smrg               dst[2] = _mesa_unorm_to_unorm(b, 5, 8);
2509b8e80941Smrg
2510b8e80941Smrg         dst[3] = 255;
2511b8e80941Smrg}
2512b8e80941Smrg
2513b8e80941Smrgstatic inline void
2514b8e80941Smrgunpack_ubyte_r5g6b5_unorm(const void *void_src, GLubyte dst[4])
2515b8e80941Smrg{
2516b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
2517b8e80941Smrg            uint8_t r = UNPACK(*src, 0, 5);
2518b8e80941Smrg            uint8_t g = UNPACK(*src, 5, 6);
2519b8e80941Smrg            uint8_t b = UNPACK(*src, 11, 5);
2520b8e80941Smrg
2521b8e80941Smrg
2522b8e80941Smrg
2523b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(r, 5, 8);
2524b8e80941Smrg
2525b8e80941Smrg
2526b8e80941Smrg               dst[1] = _mesa_unorm_to_unorm(g, 6, 8);
2527b8e80941Smrg
2528b8e80941Smrg
2529b8e80941Smrg               dst[2] = _mesa_unorm_to_unorm(b, 5, 8);
2530b8e80941Smrg
2531b8e80941Smrg         dst[3] = 255;
2532b8e80941Smrg}
2533b8e80941Smrg
2534b8e80941Smrgstatic inline void
2535b8e80941Smrgunpack_ubyte_b4g4r4a4_unorm(const void *void_src, GLubyte dst[4])
2536b8e80941Smrg{
2537b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
2538b8e80941Smrg            uint8_t b = UNPACK(*src, 0, 4);
2539b8e80941Smrg            uint8_t g = UNPACK(*src, 4, 4);
2540b8e80941Smrg            uint8_t r = UNPACK(*src, 8, 4);
2541b8e80941Smrg            uint8_t a = UNPACK(*src, 12, 4);
2542b8e80941Smrg
2543b8e80941Smrg
2544b8e80941Smrg
2545b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(r, 4, 8);
2546b8e80941Smrg
2547b8e80941Smrg
2548b8e80941Smrg               dst[1] = _mesa_unorm_to_unorm(g, 4, 8);
2549b8e80941Smrg
2550b8e80941Smrg
2551b8e80941Smrg               dst[2] = _mesa_unorm_to_unorm(b, 4, 8);
2552b8e80941Smrg
2553b8e80941Smrg
2554b8e80941Smrg               dst[3] = _mesa_unorm_to_unorm(a, 4, 8);
2555b8e80941Smrg}
2556b8e80941Smrg
2557b8e80941Smrgstatic inline void
2558b8e80941Smrgunpack_ubyte_b4g4r4x4_unorm(const void *void_src, GLubyte dst[4])
2559b8e80941Smrg{
2560b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
2561b8e80941Smrg            uint8_t b = UNPACK(*src, 0, 4);
2562b8e80941Smrg            uint8_t g = UNPACK(*src, 4, 4);
2563b8e80941Smrg            uint8_t r = UNPACK(*src, 8, 4);
2564b8e80941Smrg
2565b8e80941Smrg
2566b8e80941Smrg
2567b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(r, 4, 8);
2568b8e80941Smrg
2569b8e80941Smrg
2570b8e80941Smrg               dst[1] = _mesa_unorm_to_unorm(g, 4, 8);
2571b8e80941Smrg
2572b8e80941Smrg
2573b8e80941Smrg               dst[2] = _mesa_unorm_to_unorm(b, 4, 8);
2574b8e80941Smrg
2575b8e80941Smrg         dst[3] = 255;
2576b8e80941Smrg}
2577b8e80941Smrg
2578b8e80941Smrgstatic inline void
2579b8e80941Smrgunpack_ubyte_a4r4g4b4_unorm(const void *void_src, GLubyte dst[4])
2580b8e80941Smrg{
2581b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
2582b8e80941Smrg            uint8_t a = UNPACK(*src, 0, 4);
2583b8e80941Smrg            uint8_t r = UNPACK(*src, 4, 4);
2584b8e80941Smrg            uint8_t g = UNPACK(*src, 8, 4);
2585b8e80941Smrg            uint8_t b = UNPACK(*src, 12, 4);
2586b8e80941Smrg
2587b8e80941Smrg
2588b8e80941Smrg
2589b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(r, 4, 8);
2590b8e80941Smrg
2591b8e80941Smrg
2592b8e80941Smrg               dst[1] = _mesa_unorm_to_unorm(g, 4, 8);
2593b8e80941Smrg
2594b8e80941Smrg
2595b8e80941Smrg               dst[2] = _mesa_unorm_to_unorm(b, 4, 8);
2596b8e80941Smrg
2597b8e80941Smrg
2598b8e80941Smrg               dst[3] = _mesa_unorm_to_unorm(a, 4, 8);
2599b8e80941Smrg}
2600b8e80941Smrg
2601b8e80941Smrgstatic inline void
2602b8e80941Smrgunpack_ubyte_a1b5g5r5_unorm(const void *void_src, GLubyte dst[4])
2603b8e80941Smrg{
2604b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
2605b8e80941Smrg            uint8_t a = UNPACK(*src, 0, 1);
2606b8e80941Smrg            uint8_t b = UNPACK(*src, 1, 5);
2607b8e80941Smrg            uint8_t g = UNPACK(*src, 6, 5);
2608b8e80941Smrg            uint8_t r = UNPACK(*src, 11, 5);
2609b8e80941Smrg
2610b8e80941Smrg
2611b8e80941Smrg
2612b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(r, 5, 8);
2613b8e80941Smrg
2614b8e80941Smrg
2615b8e80941Smrg               dst[1] = _mesa_unorm_to_unorm(g, 5, 8);
2616b8e80941Smrg
2617b8e80941Smrg
2618b8e80941Smrg               dst[2] = _mesa_unorm_to_unorm(b, 5, 8);
2619b8e80941Smrg
2620b8e80941Smrg
2621b8e80941Smrg               dst[3] = _mesa_unorm_to_unorm(a, 1, 8);
2622b8e80941Smrg}
2623b8e80941Smrg
2624b8e80941Smrgstatic inline void
2625b8e80941Smrgunpack_ubyte_x1b5g5r5_unorm(const void *void_src, GLubyte dst[4])
2626b8e80941Smrg{
2627b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
2628b8e80941Smrg            uint8_t b = UNPACK(*src, 1, 5);
2629b8e80941Smrg            uint8_t g = UNPACK(*src, 6, 5);
2630b8e80941Smrg            uint8_t r = UNPACK(*src, 11, 5);
2631b8e80941Smrg
2632b8e80941Smrg
2633b8e80941Smrg
2634b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(r, 5, 8);
2635b8e80941Smrg
2636b8e80941Smrg
2637b8e80941Smrg               dst[1] = _mesa_unorm_to_unorm(g, 5, 8);
2638b8e80941Smrg
2639b8e80941Smrg
2640b8e80941Smrg               dst[2] = _mesa_unorm_to_unorm(b, 5, 8);
2641b8e80941Smrg
2642b8e80941Smrg         dst[3] = 255;
2643b8e80941Smrg}
2644b8e80941Smrg
2645b8e80941Smrgstatic inline void
2646b8e80941Smrgunpack_ubyte_b5g5r5a1_unorm(const void *void_src, GLubyte dst[4])
2647b8e80941Smrg{
2648b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
2649b8e80941Smrg            uint8_t b = UNPACK(*src, 0, 5);
2650b8e80941Smrg            uint8_t g = UNPACK(*src, 5, 5);
2651b8e80941Smrg            uint8_t r = UNPACK(*src, 10, 5);
2652b8e80941Smrg            uint8_t a = UNPACK(*src, 15, 1);
2653b8e80941Smrg
2654b8e80941Smrg
2655b8e80941Smrg
2656b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(r, 5, 8);
2657b8e80941Smrg
2658b8e80941Smrg
2659b8e80941Smrg               dst[1] = _mesa_unorm_to_unorm(g, 5, 8);
2660b8e80941Smrg
2661b8e80941Smrg
2662b8e80941Smrg               dst[2] = _mesa_unorm_to_unorm(b, 5, 8);
2663b8e80941Smrg
2664b8e80941Smrg
2665b8e80941Smrg               dst[3] = _mesa_unorm_to_unorm(a, 1, 8);
2666b8e80941Smrg}
2667b8e80941Smrg
2668b8e80941Smrgstatic inline void
2669b8e80941Smrgunpack_ubyte_b5g5r5x1_unorm(const void *void_src, GLubyte dst[4])
2670b8e80941Smrg{
2671b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
2672b8e80941Smrg            uint8_t b = UNPACK(*src, 0, 5);
2673b8e80941Smrg            uint8_t g = UNPACK(*src, 5, 5);
2674b8e80941Smrg            uint8_t r = UNPACK(*src, 10, 5);
2675b8e80941Smrg
2676b8e80941Smrg
2677b8e80941Smrg
2678b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(r, 5, 8);
2679b8e80941Smrg
2680b8e80941Smrg
2681b8e80941Smrg               dst[1] = _mesa_unorm_to_unorm(g, 5, 8);
2682b8e80941Smrg
2683b8e80941Smrg
2684b8e80941Smrg               dst[2] = _mesa_unorm_to_unorm(b, 5, 8);
2685b8e80941Smrg
2686b8e80941Smrg         dst[3] = 255;
2687b8e80941Smrg}
2688b8e80941Smrg
2689b8e80941Smrgstatic inline void
2690b8e80941Smrgunpack_ubyte_a1r5g5b5_unorm(const void *void_src, GLubyte dst[4])
2691b8e80941Smrg{
2692b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
2693b8e80941Smrg            uint8_t a = UNPACK(*src, 0, 1);
2694b8e80941Smrg            uint8_t r = UNPACK(*src, 1, 5);
2695b8e80941Smrg            uint8_t g = UNPACK(*src, 6, 5);
2696b8e80941Smrg            uint8_t b = UNPACK(*src, 11, 5);
2697b8e80941Smrg
2698b8e80941Smrg
2699b8e80941Smrg
2700b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(r, 5, 8);
2701b8e80941Smrg
2702b8e80941Smrg
2703b8e80941Smrg               dst[1] = _mesa_unorm_to_unorm(g, 5, 8);
2704b8e80941Smrg
2705b8e80941Smrg
2706b8e80941Smrg               dst[2] = _mesa_unorm_to_unorm(b, 5, 8);
2707b8e80941Smrg
2708b8e80941Smrg
2709b8e80941Smrg               dst[3] = _mesa_unorm_to_unorm(a, 1, 8);
2710b8e80941Smrg}
2711b8e80941Smrg
2712b8e80941Smrgstatic inline void
2713b8e80941Smrgunpack_ubyte_l8a8_unorm(const void *void_src, GLubyte dst[4])
2714b8e80941Smrg{
2715b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
2716b8e80941Smrg            uint8_t l = UNPACK(*src, 0, 8);
2717b8e80941Smrg            uint8_t a = UNPACK(*src, 8, 8);
2718b8e80941Smrg
2719b8e80941Smrg
2720b8e80941Smrg
2721b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(l, 8, 8);
2722b8e80941Smrg
2723b8e80941Smrg
2724b8e80941Smrg               dst[1] = _mesa_unorm_to_unorm(l, 8, 8);
2725b8e80941Smrg
2726b8e80941Smrg
2727b8e80941Smrg               dst[2] = _mesa_unorm_to_unorm(l, 8, 8);
2728b8e80941Smrg
2729b8e80941Smrg
2730b8e80941Smrg               dst[3] = _mesa_unorm_to_unorm(a, 8, 8);
2731b8e80941Smrg}
2732b8e80941Smrg
2733b8e80941Smrgstatic inline void
2734b8e80941Smrgunpack_ubyte_a8l8_unorm(const void *void_src, GLubyte dst[4])
2735b8e80941Smrg{
2736b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
2737b8e80941Smrg            uint8_t a = UNPACK(*src, 0, 8);
2738b8e80941Smrg            uint8_t l = UNPACK(*src, 8, 8);
2739b8e80941Smrg
2740b8e80941Smrg
2741b8e80941Smrg
2742b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(l, 8, 8);
2743b8e80941Smrg
2744b8e80941Smrg
2745b8e80941Smrg               dst[1] = _mesa_unorm_to_unorm(l, 8, 8);
2746b8e80941Smrg
2747b8e80941Smrg
2748b8e80941Smrg               dst[2] = _mesa_unorm_to_unorm(l, 8, 8);
2749b8e80941Smrg
2750b8e80941Smrg
2751b8e80941Smrg               dst[3] = _mesa_unorm_to_unorm(a, 8, 8);
2752b8e80941Smrg}
2753b8e80941Smrg
2754b8e80941Smrgstatic inline void
2755b8e80941Smrgunpack_ubyte_r8g8_unorm(const void *void_src, GLubyte dst[4])
2756b8e80941Smrg{
2757b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
2758b8e80941Smrg            uint8_t r = UNPACK(*src, 0, 8);
2759b8e80941Smrg            uint8_t g = UNPACK(*src, 8, 8);
2760b8e80941Smrg
2761b8e80941Smrg
2762b8e80941Smrg
2763b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(r, 8, 8);
2764b8e80941Smrg
2765b8e80941Smrg
2766b8e80941Smrg               dst[1] = _mesa_unorm_to_unorm(g, 8, 8);
2767b8e80941Smrg
2768b8e80941Smrg         dst[2] = 0;
2769b8e80941Smrg
2770b8e80941Smrg         dst[3] = 255;
2771b8e80941Smrg}
2772b8e80941Smrg
2773b8e80941Smrgstatic inline void
2774b8e80941Smrgunpack_ubyte_g8r8_unorm(const void *void_src, GLubyte dst[4])
2775b8e80941Smrg{
2776b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
2777b8e80941Smrg            uint8_t g = UNPACK(*src, 0, 8);
2778b8e80941Smrg            uint8_t r = UNPACK(*src, 8, 8);
2779b8e80941Smrg
2780b8e80941Smrg
2781b8e80941Smrg
2782b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(r, 8, 8);
2783b8e80941Smrg
2784b8e80941Smrg
2785b8e80941Smrg               dst[1] = _mesa_unorm_to_unorm(g, 8, 8);
2786b8e80941Smrg
2787b8e80941Smrg         dst[2] = 0;
2788b8e80941Smrg
2789b8e80941Smrg         dst[3] = 255;
2790b8e80941Smrg}
2791b8e80941Smrg
2792b8e80941Smrgstatic inline void
2793b8e80941Smrgunpack_ubyte_l4a4_unorm(const void *void_src, GLubyte dst[4])
2794b8e80941Smrg{
2795b8e80941Smrg   uint8_t *src = (uint8_t *)void_src;
2796b8e80941Smrg            uint8_t l = UNPACK(*src, 0, 4);
2797b8e80941Smrg            uint8_t a = UNPACK(*src, 4, 4);
2798b8e80941Smrg
2799b8e80941Smrg
2800b8e80941Smrg
2801b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(l, 4, 8);
2802b8e80941Smrg
2803b8e80941Smrg
2804b8e80941Smrg               dst[1] = _mesa_unorm_to_unorm(l, 4, 8);
2805b8e80941Smrg
2806b8e80941Smrg
2807b8e80941Smrg               dst[2] = _mesa_unorm_to_unorm(l, 4, 8);
2808b8e80941Smrg
2809b8e80941Smrg
2810b8e80941Smrg               dst[3] = _mesa_unorm_to_unorm(a, 4, 8);
2811b8e80941Smrg}
2812b8e80941Smrg
2813b8e80941Smrgstatic inline void
2814b8e80941Smrgunpack_ubyte_b2g3r3_unorm(const void *void_src, GLubyte dst[4])
2815b8e80941Smrg{
2816b8e80941Smrg   uint8_t *src = (uint8_t *)void_src;
2817b8e80941Smrg            uint8_t b = UNPACK(*src, 0, 2);
2818b8e80941Smrg            uint8_t g = UNPACK(*src, 2, 3);
2819b8e80941Smrg            uint8_t r = UNPACK(*src, 5, 3);
2820b8e80941Smrg
2821b8e80941Smrg
2822b8e80941Smrg
2823b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(r, 3, 8);
2824b8e80941Smrg
2825b8e80941Smrg
2826b8e80941Smrg               dst[1] = _mesa_unorm_to_unorm(g, 3, 8);
2827b8e80941Smrg
2828b8e80941Smrg
2829b8e80941Smrg               dst[2] = _mesa_unorm_to_unorm(b, 2, 8);
2830b8e80941Smrg
2831b8e80941Smrg         dst[3] = 255;
2832b8e80941Smrg}
2833b8e80941Smrg
2834b8e80941Smrgstatic inline void
2835b8e80941Smrgunpack_ubyte_r16g16_unorm(const void *void_src, GLubyte dst[4])
2836b8e80941Smrg{
2837b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
2838b8e80941Smrg            uint16_t r = UNPACK(*src, 0, 16);
2839b8e80941Smrg            uint16_t g = UNPACK(*src, 16, 16);
2840b8e80941Smrg
2841b8e80941Smrg
2842b8e80941Smrg
2843b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(r, 16, 8);
2844b8e80941Smrg
2845b8e80941Smrg
2846b8e80941Smrg               dst[1] = _mesa_unorm_to_unorm(g, 16, 8);
2847b8e80941Smrg
2848b8e80941Smrg         dst[2] = 0;
2849b8e80941Smrg
2850b8e80941Smrg         dst[3] = 255;
2851b8e80941Smrg}
2852b8e80941Smrg
2853b8e80941Smrgstatic inline void
2854b8e80941Smrgunpack_ubyte_g16r16_unorm(const void *void_src, GLubyte dst[4])
2855b8e80941Smrg{
2856b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
2857b8e80941Smrg            uint16_t g = UNPACK(*src, 0, 16);
2858b8e80941Smrg            uint16_t r = UNPACK(*src, 16, 16);
2859b8e80941Smrg
2860b8e80941Smrg
2861b8e80941Smrg
2862b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(r, 16, 8);
2863b8e80941Smrg
2864b8e80941Smrg
2865b8e80941Smrg               dst[1] = _mesa_unorm_to_unorm(g, 16, 8);
2866b8e80941Smrg
2867b8e80941Smrg         dst[2] = 0;
2868b8e80941Smrg
2869b8e80941Smrg         dst[3] = 255;
2870b8e80941Smrg}
2871b8e80941Smrg
2872b8e80941Smrgstatic inline void
2873b8e80941Smrgunpack_ubyte_b10g10r10a2_unorm(const void *void_src, GLubyte dst[4])
2874b8e80941Smrg{
2875b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
2876b8e80941Smrg            uint16_t b = UNPACK(*src, 0, 10);
2877b8e80941Smrg            uint16_t g = UNPACK(*src, 10, 10);
2878b8e80941Smrg            uint16_t r = UNPACK(*src, 20, 10);
2879b8e80941Smrg            uint8_t a = UNPACK(*src, 30, 2);
2880b8e80941Smrg
2881b8e80941Smrg
2882b8e80941Smrg
2883b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(r, 10, 8);
2884b8e80941Smrg
2885b8e80941Smrg
2886b8e80941Smrg               dst[1] = _mesa_unorm_to_unorm(g, 10, 8);
2887b8e80941Smrg
2888b8e80941Smrg
2889b8e80941Smrg               dst[2] = _mesa_unorm_to_unorm(b, 10, 8);
2890b8e80941Smrg
2891b8e80941Smrg
2892b8e80941Smrg               dst[3] = _mesa_unorm_to_unorm(a, 2, 8);
2893b8e80941Smrg}
2894b8e80941Smrg
2895b8e80941Smrgstatic inline void
2896b8e80941Smrgunpack_ubyte_b10g10r10x2_unorm(const void *void_src, GLubyte dst[4])
2897b8e80941Smrg{
2898b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
2899b8e80941Smrg            uint16_t b = UNPACK(*src, 0, 10);
2900b8e80941Smrg            uint16_t g = UNPACK(*src, 10, 10);
2901b8e80941Smrg            uint16_t r = UNPACK(*src, 20, 10);
2902b8e80941Smrg
2903b8e80941Smrg
2904b8e80941Smrg
2905b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(r, 10, 8);
2906b8e80941Smrg
2907b8e80941Smrg
2908b8e80941Smrg               dst[1] = _mesa_unorm_to_unorm(g, 10, 8);
2909b8e80941Smrg
2910b8e80941Smrg
2911b8e80941Smrg               dst[2] = _mesa_unorm_to_unorm(b, 10, 8);
2912b8e80941Smrg
2913b8e80941Smrg         dst[3] = 255;
2914b8e80941Smrg}
2915b8e80941Smrg
2916b8e80941Smrgstatic inline void
2917b8e80941Smrgunpack_ubyte_r10g10b10a2_unorm(const void *void_src, GLubyte dst[4])
2918b8e80941Smrg{
2919b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
2920b8e80941Smrg            uint16_t r = UNPACK(*src, 0, 10);
2921b8e80941Smrg            uint16_t g = UNPACK(*src, 10, 10);
2922b8e80941Smrg            uint16_t b = UNPACK(*src, 20, 10);
2923b8e80941Smrg            uint8_t a = UNPACK(*src, 30, 2);
2924b8e80941Smrg
2925b8e80941Smrg
2926b8e80941Smrg
2927b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(r, 10, 8);
2928b8e80941Smrg
2929b8e80941Smrg
2930b8e80941Smrg               dst[1] = _mesa_unorm_to_unorm(g, 10, 8);
2931b8e80941Smrg
2932b8e80941Smrg
2933b8e80941Smrg               dst[2] = _mesa_unorm_to_unorm(b, 10, 8);
2934b8e80941Smrg
2935b8e80941Smrg
2936b8e80941Smrg               dst[3] = _mesa_unorm_to_unorm(a, 2, 8);
2937b8e80941Smrg}
2938b8e80941Smrg
2939b8e80941Smrgstatic inline void
2940b8e80941Smrgunpack_ubyte_r10g10b10x2_unorm(const void *void_src, GLubyte dst[4])
2941b8e80941Smrg{
2942b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
2943b8e80941Smrg            uint16_t r = UNPACK(*src, 0, 10);
2944b8e80941Smrg            uint16_t g = UNPACK(*src, 10, 10);
2945b8e80941Smrg            uint16_t b = UNPACK(*src, 20, 10);
2946b8e80941Smrg
2947b8e80941Smrg
2948b8e80941Smrg
2949b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(r, 10, 8);
2950b8e80941Smrg
2951b8e80941Smrg
2952b8e80941Smrg               dst[1] = _mesa_unorm_to_unorm(g, 10, 8);
2953b8e80941Smrg
2954b8e80941Smrg
2955b8e80941Smrg               dst[2] = _mesa_unorm_to_unorm(b, 10, 8);
2956b8e80941Smrg
2957b8e80941Smrg         dst[3] = 255;
2958b8e80941Smrg}
2959b8e80941Smrg
2960b8e80941Smrgstatic inline void
2961b8e80941Smrgunpack_ubyte_r3g3b2_unorm(const void *void_src, GLubyte dst[4])
2962b8e80941Smrg{
2963b8e80941Smrg   uint8_t *src = (uint8_t *)void_src;
2964b8e80941Smrg            uint8_t r = UNPACK(*src, 0, 3);
2965b8e80941Smrg            uint8_t g = UNPACK(*src, 3, 3);
2966b8e80941Smrg            uint8_t b = UNPACK(*src, 6, 2);
2967b8e80941Smrg
2968b8e80941Smrg
2969b8e80941Smrg
2970b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(r, 3, 8);
2971b8e80941Smrg
2972b8e80941Smrg
2973b8e80941Smrg               dst[1] = _mesa_unorm_to_unorm(g, 3, 8);
2974b8e80941Smrg
2975b8e80941Smrg
2976b8e80941Smrg               dst[2] = _mesa_unorm_to_unorm(b, 2, 8);
2977b8e80941Smrg
2978b8e80941Smrg         dst[3] = 255;
2979b8e80941Smrg}
2980b8e80941Smrg
2981b8e80941Smrgstatic inline void
2982b8e80941Smrgunpack_ubyte_a4b4g4r4_unorm(const void *void_src, GLubyte dst[4])
2983b8e80941Smrg{
2984b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
2985b8e80941Smrg            uint8_t a = UNPACK(*src, 0, 4);
2986b8e80941Smrg            uint8_t b = UNPACK(*src, 4, 4);
2987b8e80941Smrg            uint8_t g = UNPACK(*src, 8, 4);
2988b8e80941Smrg            uint8_t r = UNPACK(*src, 12, 4);
2989b8e80941Smrg
2990b8e80941Smrg
2991b8e80941Smrg
2992b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(r, 4, 8);
2993b8e80941Smrg
2994b8e80941Smrg
2995b8e80941Smrg               dst[1] = _mesa_unorm_to_unorm(g, 4, 8);
2996b8e80941Smrg
2997b8e80941Smrg
2998b8e80941Smrg               dst[2] = _mesa_unorm_to_unorm(b, 4, 8);
2999b8e80941Smrg
3000b8e80941Smrg
3001b8e80941Smrg               dst[3] = _mesa_unorm_to_unorm(a, 4, 8);
3002b8e80941Smrg}
3003b8e80941Smrg
3004b8e80941Smrgstatic inline void
3005b8e80941Smrgunpack_ubyte_r4g4b4a4_unorm(const void *void_src, GLubyte dst[4])
3006b8e80941Smrg{
3007b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
3008b8e80941Smrg            uint8_t r = UNPACK(*src, 0, 4);
3009b8e80941Smrg            uint8_t g = UNPACK(*src, 4, 4);
3010b8e80941Smrg            uint8_t b = UNPACK(*src, 8, 4);
3011b8e80941Smrg            uint8_t a = UNPACK(*src, 12, 4);
3012b8e80941Smrg
3013b8e80941Smrg
3014b8e80941Smrg
3015b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(r, 4, 8);
3016b8e80941Smrg
3017b8e80941Smrg
3018b8e80941Smrg               dst[1] = _mesa_unorm_to_unorm(g, 4, 8);
3019b8e80941Smrg
3020b8e80941Smrg
3021b8e80941Smrg               dst[2] = _mesa_unorm_to_unorm(b, 4, 8);
3022b8e80941Smrg
3023b8e80941Smrg
3024b8e80941Smrg               dst[3] = _mesa_unorm_to_unorm(a, 4, 8);
3025b8e80941Smrg}
3026b8e80941Smrg
3027b8e80941Smrgstatic inline void
3028b8e80941Smrgunpack_ubyte_r5g5b5a1_unorm(const void *void_src, GLubyte dst[4])
3029b8e80941Smrg{
3030b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
3031b8e80941Smrg            uint8_t r = UNPACK(*src, 0, 5);
3032b8e80941Smrg            uint8_t g = UNPACK(*src, 5, 5);
3033b8e80941Smrg            uint8_t b = UNPACK(*src, 10, 5);
3034b8e80941Smrg            uint8_t a = UNPACK(*src, 15, 1);
3035b8e80941Smrg
3036b8e80941Smrg
3037b8e80941Smrg
3038b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(r, 5, 8);
3039b8e80941Smrg
3040b8e80941Smrg
3041b8e80941Smrg               dst[1] = _mesa_unorm_to_unorm(g, 5, 8);
3042b8e80941Smrg
3043b8e80941Smrg
3044b8e80941Smrg               dst[2] = _mesa_unorm_to_unorm(b, 5, 8);
3045b8e80941Smrg
3046b8e80941Smrg
3047b8e80941Smrg               dst[3] = _mesa_unorm_to_unorm(a, 1, 8);
3048b8e80941Smrg}
3049b8e80941Smrg
3050b8e80941Smrgstatic inline void
3051b8e80941Smrgunpack_ubyte_a2b10g10r10_unorm(const void *void_src, GLubyte dst[4])
3052b8e80941Smrg{
3053b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
3054b8e80941Smrg            uint8_t a = UNPACK(*src, 0, 2);
3055b8e80941Smrg            uint16_t b = UNPACK(*src, 2, 10);
3056b8e80941Smrg            uint16_t g = UNPACK(*src, 12, 10);
3057b8e80941Smrg            uint16_t r = UNPACK(*src, 22, 10);
3058b8e80941Smrg
3059b8e80941Smrg
3060b8e80941Smrg
3061b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(r, 10, 8);
3062b8e80941Smrg
3063b8e80941Smrg
3064b8e80941Smrg               dst[1] = _mesa_unorm_to_unorm(g, 10, 8);
3065b8e80941Smrg
3066b8e80941Smrg
3067b8e80941Smrg               dst[2] = _mesa_unorm_to_unorm(b, 10, 8);
3068b8e80941Smrg
3069b8e80941Smrg
3070b8e80941Smrg               dst[3] = _mesa_unorm_to_unorm(a, 2, 8);
3071b8e80941Smrg}
3072b8e80941Smrg
3073b8e80941Smrgstatic inline void
3074b8e80941Smrgunpack_ubyte_a2r10g10b10_unorm(const void *void_src, GLubyte dst[4])
3075b8e80941Smrg{
3076b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
3077b8e80941Smrg            uint8_t a = UNPACK(*src, 0, 2);
3078b8e80941Smrg            uint16_t r = UNPACK(*src, 2, 10);
3079b8e80941Smrg            uint16_t g = UNPACK(*src, 12, 10);
3080b8e80941Smrg            uint16_t b = UNPACK(*src, 22, 10);
3081b8e80941Smrg
3082b8e80941Smrg
3083b8e80941Smrg
3084b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(r, 10, 8);
3085b8e80941Smrg
3086b8e80941Smrg
3087b8e80941Smrg               dst[1] = _mesa_unorm_to_unorm(g, 10, 8);
3088b8e80941Smrg
3089b8e80941Smrg
3090b8e80941Smrg               dst[2] = _mesa_unorm_to_unorm(b, 10, 8);
3091b8e80941Smrg
3092b8e80941Smrg
3093b8e80941Smrg               dst[3] = _mesa_unorm_to_unorm(a, 2, 8);
3094b8e80941Smrg}
3095b8e80941Smrg
3096b8e80941Smrgstatic inline void
3097b8e80941Smrgunpack_ubyte_a_unorm8(const void *void_src, GLubyte dst[4])
3098b8e80941Smrg{
3099b8e80941Smrg   uint8_t *src = (uint8_t *)void_src;
3100b8e80941Smrg            uint8_t a = src[0];
3101b8e80941Smrg
3102b8e80941Smrg
3103b8e80941Smrg         dst[0] = 0;
3104b8e80941Smrg
3105b8e80941Smrg         dst[1] = 0;
3106b8e80941Smrg
3107b8e80941Smrg         dst[2] = 0;
3108b8e80941Smrg
3109b8e80941Smrg
3110b8e80941Smrg               dst[3] = _mesa_unorm_to_unorm(a, 8, 8);
3111b8e80941Smrg}
3112b8e80941Smrg
3113b8e80941Smrgstatic inline void
3114b8e80941Smrgunpack_ubyte_a_unorm16(const void *void_src, GLubyte dst[4])
3115b8e80941Smrg{
3116b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
3117b8e80941Smrg            uint16_t a = src[0];
3118b8e80941Smrg
3119b8e80941Smrg
3120b8e80941Smrg         dst[0] = 0;
3121b8e80941Smrg
3122b8e80941Smrg         dst[1] = 0;
3123b8e80941Smrg
3124b8e80941Smrg         dst[2] = 0;
3125b8e80941Smrg
3126b8e80941Smrg
3127b8e80941Smrg               dst[3] = _mesa_unorm_to_unorm(a, 16, 8);
3128b8e80941Smrg}
3129b8e80941Smrg
3130b8e80941Smrgstatic inline void
3131b8e80941Smrgunpack_ubyte_l_unorm8(const void *void_src, GLubyte dst[4])
3132b8e80941Smrg{
3133b8e80941Smrg   uint8_t *src = (uint8_t *)void_src;
3134b8e80941Smrg            uint8_t l = src[0];
3135b8e80941Smrg
3136b8e80941Smrg
3137b8e80941Smrg
3138b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(l, 8, 8);
3139b8e80941Smrg
3140b8e80941Smrg
3141b8e80941Smrg               dst[1] = _mesa_unorm_to_unorm(l, 8, 8);
3142b8e80941Smrg
3143b8e80941Smrg
3144b8e80941Smrg               dst[2] = _mesa_unorm_to_unorm(l, 8, 8);
3145b8e80941Smrg
3146b8e80941Smrg         dst[3] = 255;
3147b8e80941Smrg}
3148b8e80941Smrg
3149b8e80941Smrgstatic inline void
3150b8e80941Smrgunpack_ubyte_l_unorm16(const void *void_src, GLubyte dst[4])
3151b8e80941Smrg{
3152b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
3153b8e80941Smrg            uint16_t l = src[0];
3154b8e80941Smrg
3155b8e80941Smrg
3156b8e80941Smrg
3157b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(l, 16, 8);
3158b8e80941Smrg
3159b8e80941Smrg
3160b8e80941Smrg               dst[1] = _mesa_unorm_to_unorm(l, 16, 8);
3161b8e80941Smrg
3162b8e80941Smrg
3163b8e80941Smrg               dst[2] = _mesa_unorm_to_unorm(l, 16, 8);
3164b8e80941Smrg
3165b8e80941Smrg         dst[3] = 255;
3166b8e80941Smrg}
3167b8e80941Smrg
3168b8e80941Smrgstatic inline void
3169b8e80941Smrgunpack_ubyte_i_unorm8(const void *void_src, GLubyte dst[4])
3170b8e80941Smrg{
3171b8e80941Smrg   uint8_t *src = (uint8_t *)void_src;
3172b8e80941Smrg            uint8_t i = src[0];
3173b8e80941Smrg
3174b8e80941Smrg
3175b8e80941Smrg
3176b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(i, 8, 8);
3177b8e80941Smrg
3178b8e80941Smrg
3179b8e80941Smrg               dst[1] = _mesa_unorm_to_unorm(i, 8, 8);
3180b8e80941Smrg
3181b8e80941Smrg
3182b8e80941Smrg               dst[2] = _mesa_unorm_to_unorm(i, 8, 8);
3183b8e80941Smrg
3184b8e80941Smrg
3185b8e80941Smrg               dst[3] = _mesa_unorm_to_unorm(i, 8, 8);
3186b8e80941Smrg}
3187b8e80941Smrg
3188b8e80941Smrgstatic inline void
3189b8e80941Smrgunpack_ubyte_i_unorm16(const void *void_src, GLubyte dst[4])
3190b8e80941Smrg{
3191b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
3192b8e80941Smrg            uint16_t i = src[0];
3193b8e80941Smrg
3194b8e80941Smrg
3195b8e80941Smrg
3196b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(i, 16, 8);
3197b8e80941Smrg
3198b8e80941Smrg
3199b8e80941Smrg               dst[1] = _mesa_unorm_to_unorm(i, 16, 8);
3200b8e80941Smrg
3201b8e80941Smrg
3202b8e80941Smrg               dst[2] = _mesa_unorm_to_unorm(i, 16, 8);
3203b8e80941Smrg
3204b8e80941Smrg
3205b8e80941Smrg               dst[3] = _mesa_unorm_to_unorm(i, 16, 8);
3206b8e80941Smrg}
3207b8e80941Smrg
3208b8e80941Smrgstatic inline void
3209b8e80941Smrgunpack_ubyte_r_unorm8(const void *void_src, GLubyte dst[4])
3210b8e80941Smrg{
3211b8e80941Smrg   uint8_t *src = (uint8_t *)void_src;
3212b8e80941Smrg            uint8_t r = src[0];
3213b8e80941Smrg
3214b8e80941Smrg
3215b8e80941Smrg
3216b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(r, 8, 8);
3217b8e80941Smrg
3218b8e80941Smrg         dst[1] = 0;
3219b8e80941Smrg
3220b8e80941Smrg         dst[2] = 0;
3221b8e80941Smrg
3222b8e80941Smrg         dst[3] = 255;
3223b8e80941Smrg}
3224b8e80941Smrg
3225b8e80941Smrgstatic inline void
3226b8e80941Smrgunpack_ubyte_r_unorm16(const void *void_src, GLubyte dst[4])
3227b8e80941Smrg{
3228b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
3229b8e80941Smrg            uint16_t r = src[0];
3230b8e80941Smrg
3231b8e80941Smrg
3232b8e80941Smrg
3233b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(r, 16, 8);
3234b8e80941Smrg
3235b8e80941Smrg         dst[1] = 0;
3236b8e80941Smrg
3237b8e80941Smrg         dst[2] = 0;
3238b8e80941Smrg
3239b8e80941Smrg         dst[3] = 255;
3240b8e80941Smrg}
3241b8e80941Smrg
3242b8e80941Smrgstatic inline void
3243b8e80941Smrgunpack_ubyte_bgr_unorm8(const void *void_src, GLubyte dst[4])
3244b8e80941Smrg{
3245b8e80941Smrg   uint8_t *src = (uint8_t *)void_src;
3246b8e80941Smrg            uint8_t b = src[0];
3247b8e80941Smrg            uint8_t g = src[1];
3248b8e80941Smrg            uint8_t r = src[2];
3249b8e80941Smrg
3250b8e80941Smrg
3251b8e80941Smrg
3252b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(r, 8, 8);
3253b8e80941Smrg
3254b8e80941Smrg
3255b8e80941Smrg               dst[1] = _mesa_unorm_to_unorm(g, 8, 8);
3256b8e80941Smrg
3257b8e80941Smrg
3258b8e80941Smrg               dst[2] = _mesa_unorm_to_unorm(b, 8, 8);
3259b8e80941Smrg
3260b8e80941Smrg         dst[3] = 255;
3261b8e80941Smrg}
3262b8e80941Smrg
3263b8e80941Smrgstatic inline void
3264b8e80941Smrgunpack_ubyte_rgb_unorm8(const void *void_src, GLubyte dst[4])
3265b8e80941Smrg{
3266b8e80941Smrg   uint8_t *src = (uint8_t *)void_src;
3267b8e80941Smrg            uint8_t r = src[0];
3268b8e80941Smrg            uint8_t g = src[1];
3269b8e80941Smrg            uint8_t b = src[2];
3270b8e80941Smrg
3271b8e80941Smrg
3272b8e80941Smrg
3273b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(r, 8, 8);
3274b8e80941Smrg
3275b8e80941Smrg
3276b8e80941Smrg               dst[1] = _mesa_unorm_to_unorm(g, 8, 8);
3277b8e80941Smrg
3278b8e80941Smrg
3279b8e80941Smrg               dst[2] = _mesa_unorm_to_unorm(b, 8, 8);
3280b8e80941Smrg
3281b8e80941Smrg         dst[3] = 255;
3282b8e80941Smrg}
3283b8e80941Smrg
3284b8e80941Smrgstatic inline void
3285b8e80941Smrgunpack_ubyte_rgba_unorm16(const void *void_src, GLubyte dst[4])
3286b8e80941Smrg{
3287b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
3288b8e80941Smrg            uint16_t r = src[0];
3289b8e80941Smrg            uint16_t g = src[1];
3290b8e80941Smrg            uint16_t b = src[2];
3291b8e80941Smrg            uint16_t a = src[3];
3292b8e80941Smrg
3293b8e80941Smrg
3294b8e80941Smrg
3295b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(r, 16, 8);
3296b8e80941Smrg
3297b8e80941Smrg
3298b8e80941Smrg               dst[1] = _mesa_unorm_to_unorm(g, 16, 8);
3299b8e80941Smrg
3300b8e80941Smrg
3301b8e80941Smrg               dst[2] = _mesa_unorm_to_unorm(b, 16, 8);
3302b8e80941Smrg
3303b8e80941Smrg
3304b8e80941Smrg               dst[3] = _mesa_unorm_to_unorm(a, 16, 8);
3305b8e80941Smrg}
3306b8e80941Smrg
3307b8e80941Smrgstatic inline void
3308b8e80941Smrgunpack_ubyte_rgbx_unorm16(const void *void_src, GLubyte dst[4])
3309b8e80941Smrg{
3310b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
3311b8e80941Smrg            uint16_t r = src[0];
3312b8e80941Smrg            uint16_t g = src[1];
3313b8e80941Smrg            uint16_t b = src[2];
3314b8e80941Smrg
3315b8e80941Smrg
3316b8e80941Smrg
3317b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(r, 16, 8);
3318b8e80941Smrg
3319b8e80941Smrg
3320b8e80941Smrg               dst[1] = _mesa_unorm_to_unorm(g, 16, 8);
3321b8e80941Smrg
3322b8e80941Smrg
3323b8e80941Smrg               dst[2] = _mesa_unorm_to_unorm(b, 16, 8);
3324b8e80941Smrg
3325b8e80941Smrg         dst[3] = 255;
3326b8e80941Smrg}
3327b8e80941Smrg
3328b8e80941Smrgstatic inline void
3329b8e80941Smrgunpack_ubyte_a8b8g8r8_snorm(const void *void_src, GLubyte dst[4])
3330b8e80941Smrg{
3331b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
3332b8e80941Smrg            int8_t a = UNPACK(*src, 0, 8);
3333b8e80941Smrg            int8_t b = UNPACK(*src, 8, 8);
3334b8e80941Smrg            int8_t g = UNPACK(*src, 16, 8);
3335b8e80941Smrg            int8_t r = UNPACK(*src, 24, 8);
3336b8e80941Smrg
3337b8e80941Smrg
3338b8e80941Smrg
3339b8e80941Smrg            dst[0] = _mesa_snorm_to_unorm(r, 8, 8);
3340b8e80941Smrg
3341b8e80941Smrg
3342b8e80941Smrg            dst[1] = _mesa_snorm_to_unorm(g, 8, 8);
3343b8e80941Smrg
3344b8e80941Smrg
3345b8e80941Smrg            dst[2] = _mesa_snorm_to_unorm(b, 8, 8);
3346b8e80941Smrg
3347b8e80941Smrg
3348b8e80941Smrg            dst[3] = _mesa_snorm_to_unorm(a, 8, 8);
3349b8e80941Smrg}
3350b8e80941Smrg
3351b8e80941Smrgstatic inline void
3352b8e80941Smrgunpack_ubyte_x8b8g8r8_snorm(const void *void_src, GLubyte dst[4])
3353b8e80941Smrg{
3354b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
3355b8e80941Smrg            int8_t b = UNPACK(*src, 8, 8);
3356b8e80941Smrg            int8_t g = UNPACK(*src, 16, 8);
3357b8e80941Smrg            int8_t r = UNPACK(*src, 24, 8);
3358b8e80941Smrg
3359b8e80941Smrg
3360b8e80941Smrg
3361b8e80941Smrg            dst[0] = _mesa_snorm_to_unorm(r, 8, 8);
3362b8e80941Smrg
3363b8e80941Smrg
3364b8e80941Smrg            dst[1] = _mesa_snorm_to_unorm(g, 8, 8);
3365b8e80941Smrg
3366b8e80941Smrg
3367b8e80941Smrg            dst[2] = _mesa_snorm_to_unorm(b, 8, 8);
3368b8e80941Smrg
3369b8e80941Smrg         dst[3] = 255;
3370b8e80941Smrg}
3371b8e80941Smrg
3372b8e80941Smrgstatic inline void
3373b8e80941Smrgunpack_ubyte_r8g8b8a8_snorm(const void *void_src, GLubyte dst[4])
3374b8e80941Smrg{
3375b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
3376b8e80941Smrg            int8_t r = UNPACK(*src, 0, 8);
3377b8e80941Smrg            int8_t g = UNPACK(*src, 8, 8);
3378b8e80941Smrg            int8_t b = UNPACK(*src, 16, 8);
3379b8e80941Smrg            int8_t a = UNPACK(*src, 24, 8);
3380b8e80941Smrg
3381b8e80941Smrg
3382b8e80941Smrg
3383b8e80941Smrg            dst[0] = _mesa_snorm_to_unorm(r, 8, 8);
3384b8e80941Smrg
3385b8e80941Smrg
3386b8e80941Smrg            dst[1] = _mesa_snorm_to_unorm(g, 8, 8);
3387b8e80941Smrg
3388b8e80941Smrg
3389b8e80941Smrg            dst[2] = _mesa_snorm_to_unorm(b, 8, 8);
3390b8e80941Smrg
3391b8e80941Smrg
3392b8e80941Smrg            dst[3] = _mesa_snorm_to_unorm(a, 8, 8);
3393b8e80941Smrg}
3394b8e80941Smrg
3395b8e80941Smrgstatic inline void
3396b8e80941Smrgunpack_ubyte_r8g8b8x8_snorm(const void *void_src, GLubyte dst[4])
3397b8e80941Smrg{
3398b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
3399b8e80941Smrg            int8_t r = UNPACK(*src, 0, 8);
3400b8e80941Smrg            int8_t g = UNPACK(*src, 8, 8);
3401b8e80941Smrg            int8_t b = UNPACK(*src, 16, 8);
3402b8e80941Smrg
3403b8e80941Smrg
3404b8e80941Smrg
3405b8e80941Smrg            dst[0] = _mesa_snorm_to_unorm(r, 8, 8);
3406b8e80941Smrg
3407b8e80941Smrg
3408b8e80941Smrg            dst[1] = _mesa_snorm_to_unorm(g, 8, 8);
3409b8e80941Smrg
3410b8e80941Smrg
3411b8e80941Smrg            dst[2] = _mesa_snorm_to_unorm(b, 8, 8);
3412b8e80941Smrg
3413b8e80941Smrg         dst[3] = 255;
3414b8e80941Smrg}
3415b8e80941Smrg
3416b8e80941Smrgstatic inline void
3417b8e80941Smrgunpack_ubyte_r16g16_snorm(const void *void_src, GLubyte dst[4])
3418b8e80941Smrg{
3419b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
3420b8e80941Smrg            int16_t r = UNPACK(*src, 0, 16);
3421b8e80941Smrg            int16_t g = UNPACK(*src, 16, 16);
3422b8e80941Smrg
3423b8e80941Smrg
3424b8e80941Smrg
3425b8e80941Smrg            dst[0] = _mesa_snorm_to_unorm(r, 16, 8);
3426b8e80941Smrg
3427b8e80941Smrg
3428b8e80941Smrg            dst[1] = _mesa_snorm_to_unorm(g, 16, 8);
3429b8e80941Smrg
3430b8e80941Smrg         dst[2] = 0;
3431b8e80941Smrg
3432b8e80941Smrg         dst[3] = 255;
3433b8e80941Smrg}
3434b8e80941Smrg
3435b8e80941Smrgstatic inline void
3436b8e80941Smrgunpack_ubyte_g16r16_snorm(const void *void_src, GLubyte dst[4])
3437b8e80941Smrg{
3438b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
3439b8e80941Smrg            int16_t g = UNPACK(*src, 0, 16);
3440b8e80941Smrg            int16_t r = UNPACK(*src, 16, 16);
3441b8e80941Smrg
3442b8e80941Smrg
3443b8e80941Smrg
3444b8e80941Smrg            dst[0] = _mesa_snorm_to_unorm(r, 16, 8);
3445b8e80941Smrg
3446b8e80941Smrg
3447b8e80941Smrg            dst[1] = _mesa_snorm_to_unorm(g, 16, 8);
3448b8e80941Smrg
3449b8e80941Smrg         dst[2] = 0;
3450b8e80941Smrg
3451b8e80941Smrg         dst[3] = 255;
3452b8e80941Smrg}
3453b8e80941Smrg
3454b8e80941Smrgstatic inline void
3455b8e80941Smrgunpack_ubyte_r8g8_snorm(const void *void_src, GLubyte dst[4])
3456b8e80941Smrg{
3457b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
3458b8e80941Smrg            int8_t r = UNPACK(*src, 0, 8);
3459b8e80941Smrg            int8_t g = UNPACK(*src, 8, 8);
3460b8e80941Smrg
3461b8e80941Smrg
3462b8e80941Smrg
3463b8e80941Smrg            dst[0] = _mesa_snorm_to_unorm(r, 8, 8);
3464b8e80941Smrg
3465b8e80941Smrg
3466b8e80941Smrg            dst[1] = _mesa_snorm_to_unorm(g, 8, 8);
3467b8e80941Smrg
3468b8e80941Smrg         dst[2] = 0;
3469b8e80941Smrg
3470b8e80941Smrg         dst[3] = 255;
3471b8e80941Smrg}
3472b8e80941Smrg
3473b8e80941Smrgstatic inline void
3474b8e80941Smrgunpack_ubyte_g8r8_snorm(const void *void_src, GLubyte dst[4])
3475b8e80941Smrg{
3476b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
3477b8e80941Smrg            int8_t g = UNPACK(*src, 0, 8);
3478b8e80941Smrg            int8_t r = UNPACK(*src, 8, 8);
3479b8e80941Smrg
3480b8e80941Smrg
3481b8e80941Smrg
3482b8e80941Smrg            dst[0] = _mesa_snorm_to_unorm(r, 8, 8);
3483b8e80941Smrg
3484b8e80941Smrg
3485b8e80941Smrg            dst[1] = _mesa_snorm_to_unorm(g, 8, 8);
3486b8e80941Smrg
3487b8e80941Smrg         dst[2] = 0;
3488b8e80941Smrg
3489b8e80941Smrg         dst[3] = 255;
3490b8e80941Smrg}
3491b8e80941Smrg
3492b8e80941Smrgstatic inline void
3493b8e80941Smrgunpack_ubyte_l8a8_snorm(const void *void_src, GLubyte dst[4])
3494b8e80941Smrg{
3495b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
3496b8e80941Smrg            int8_t l = UNPACK(*src, 0, 8);
3497b8e80941Smrg            int8_t a = UNPACK(*src, 8, 8);
3498b8e80941Smrg
3499b8e80941Smrg
3500b8e80941Smrg
3501b8e80941Smrg            dst[0] = _mesa_snorm_to_unorm(l, 8, 8);
3502b8e80941Smrg
3503b8e80941Smrg
3504b8e80941Smrg            dst[1] = _mesa_snorm_to_unorm(l, 8, 8);
3505b8e80941Smrg
3506b8e80941Smrg
3507b8e80941Smrg            dst[2] = _mesa_snorm_to_unorm(l, 8, 8);
3508b8e80941Smrg
3509b8e80941Smrg
3510b8e80941Smrg            dst[3] = _mesa_snorm_to_unorm(a, 8, 8);
3511b8e80941Smrg}
3512b8e80941Smrg
3513b8e80941Smrgstatic inline void
3514b8e80941Smrgunpack_ubyte_a8l8_snorm(const void *void_src, GLubyte dst[4])
3515b8e80941Smrg{
3516b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
3517b8e80941Smrg            int8_t a = UNPACK(*src, 0, 8);
3518b8e80941Smrg            int8_t l = UNPACK(*src, 8, 8);
3519b8e80941Smrg
3520b8e80941Smrg
3521b8e80941Smrg
3522b8e80941Smrg            dst[0] = _mesa_snorm_to_unorm(l, 8, 8);
3523b8e80941Smrg
3524b8e80941Smrg
3525b8e80941Smrg            dst[1] = _mesa_snorm_to_unorm(l, 8, 8);
3526b8e80941Smrg
3527b8e80941Smrg
3528b8e80941Smrg            dst[2] = _mesa_snorm_to_unorm(l, 8, 8);
3529b8e80941Smrg
3530b8e80941Smrg
3531b8e80941Smrg            dst[3] = _mesa_snorm_to_unorm(a, 8, 8);
3532b8e80941Smrg}
3533b8e80941Smrg
3534b8e80941Smrgstatic inline void
3535b8e80941Smrgunpack_ubyte_a_snorm8(const void *void_src, GLubyte dst[4])
3536b8e80941Smrg{
3537b8e80941Smrg   int8_t *src = (int8_t *)void_src;
3538b8e80941Smrg            int8_t a = src[0];
3539b8e80941Smrg
3540b8e80941Smrg
3541b8e80941Smrg         dst[0] = 0;
3542b8e80941Smrg
3543b8e80941Smrg         dst[1] = 0;
3544b8e80941Smrg
3545b8e80941Smrg         dst[2] = 0;
3546b8e80941Smrg
3547b8e80941Smrg
3548b8e80941Smrg            dst[3] = _mesa_snorm_to_unorm(a, 8, 8);
3549b8e80941Smrg}
3550b8e80941Smrg
3551b8e80941Smrgstatic inline void
3552b8e80941Smrgunpack_ubyte_a_snorm16(const void *void_src, GLubyte dst[4])
3553b8e80941Smrg{
3554b8e80941Smrg   int16_t *src = (int16_t *)void_src;
3555b8e80941Smrg            int16_t a = src[0];
3556b8e80941Smrg
3557b8e80941Smrg
3558b8e80941Smrg         dst[0] = 0;
3559b8e80941Smrg
3560b8e80941Smrg         dst[1] = 0;
3561b8e80941Smrg
3562b8e80941Smrg         dst[2] = 0;
3563b8e80941Smrg
3564b8e80941Smrg
3565b8e80941Smrg            dst[3] = _mesa_snorm_to_unorm(a, 16, 8);
3566b8e80941Smrg}
3567b8e80941Smrg
3568b8e80941Smrgstatic inline void
3569b8e80941Smrgunpack_ubyte_l_snorm8(const void *void_src, GLubyte dst[4])
3570b8e80941Smrg{
3571b8e80941Smrg   int8_t *src = (int8_t *)void_src;
3572b8e80941Smrg            int8_t l = src[0];
3573b8e80941Smrg
3574b8e80941Smrg
3575b8e80941Smrg
3576b8e80941Smrg            dst[0] = _mesa_snorm_to_unorm(l, 8, 8);
3577b8e80941Smrg
3578b8e80941Smrg
3579b8e80941Smrg            dst[1] = _mesa_snorm_to_unorm(l, 8, 8);
3580b8e80941Smrg
3581b8e80941Smrg
3582b8e80941Smrg            dst[2] = _mesa_snorm_to_unorm(l, 8, 8);
3583b8e80941Smrg
3584b8e80941Smrg         dst[3] = 255;
3585b8e80941Smrg}
3586b8e80941Smrg
3587b8e80941Smrgstatic inline void
3588b8e80941Smrgunpack_ubyte_l_snorm16(const void *void_src, GLubyte dst[4])
3589b8e80941Smrg{
3590b8e80941Smrg   int16_t *src = (int16_t *)void_src;
3591b8e80941Smrg            int16_t l = src[0];
3592b8e80941Smrg
3593b8e80941Smrg
3594b8e80941Smrg
3595b8e80941Smrg            dst[0] = _mesa_snorm_to_unorm(l, 16, 8);
3596b8e80941Smrg
3597b8e80941Smrg
3598b8e80941Smrg            dst[1] = _mesa_snorm_to_unorm(l, 16, 8);
3599b8e80941Smrg
3600b8e80941Smrg
3601b8e80941Smrg            dst[2] = _mesa_snorm_to_unorm(l, 16, 8);
3602b8e80941Smrg
3603b8e80941Smrg         dst[3] = 255;
3604b8e80941Smrg}
3605b8e80941Smrg
3606b8e80941Smrgstatic inline void
3607b8e80941Smrgunpack_ubyte_i_snorm8(const void *void_src, GLubyte dst[4])
3608b8e80941Smrg{
3609b8e80941Smrg   int8_t *src = (int8_t *)void_src;
3610b8e80941Smrg            int8_t i = src[0];
3611b8e80941Smrg
3612b8e80941Smrg
3613b8e80941Smrg
3614b8e80941Smrg            dst[0] = _mesa_snorm_to_unorm(i, 8, 8);
3615b8e80941Smrg
3616b8e80941Smrg
3617b8e80941Smrg            dst[1] = _mesa_snorm_to_unorm(i, 8, 8);
3618b8e80941Smrg
3619b8e80941Smrg
3620b8e80941Smrg            dst[2] = _mesa_snorm_to_unorm(i, 8, 8);
3621b8e80941Smrg
3622b8e80941Smrg
3623b8e80941Smrg            dst[3] = _mesa_snorm_to_unorm(i, 8, 8);
3624b8e80941Smrg}
3625b8e80941Smrg
3626b8e80941Smrgstatic inline void
3627b8e80941Smrgunpack_ubyte_i_snorm16(const void *void_src, GLubyte dst[4])
3628b8e80941Smrg{
3629b8e80941Smrg   int16_t *src = (int16_t *)void_src;
3630b8e80941Smrg            int16_t i = src[0];
3631b8e80941Smrg
3632b8e80941Smrg
3633b8e80941Smrg
3634b8e80941Smrg            dst[0] = _mesa_snorm_to_unorm(i, 16, 8);
3635b8e80941Smrg
3636b8e80941Smrg
3637b8e80941Smrg            dst[1] = _mesa_snorm_to_unorm(i, 16, 8);
3638b8e80941Smrg
3639b8e80941Smrg
3640b8e80941Smrg            dst[2] = _mesa_snorm_to_unorm(i, 16, 8);
3641b8e80941Smrg
3642b8e80941Smrg
3643b8e80941Smrg            dst[3] = _mesa_snorm_to_unorm(i, 16, 8);
3644b8e80941Smrg}
3645b8e80941Smrg
3646b8e80941Smrgstatic inline void
3647b8e80941Smrgunpack_ubyte_r_snorm8(const void *void_src, GLubyte dst[4])
3648b8e80941Smrg{
3649b8e80941Smrg   int8_t *src = (int8_t *)void_src;
3650b8e80941Smrg            int8_t r = src[0];
3651b8e80941Smrg
3652b8e80941Smrg
3653b8e80941Smrg
3654b8e80941Smrg            dst[0] = _mesa_snorm_to_unorm(r, 8, 8);
3655b8e80941Smrg
3656b8e80941Smrg         dst[1] = 0;
3657b8e80941Smrg
3658b8e80941Smrg         dst[2] = 0;
3659b8e80941Smrg
3660b8e80941Smrg         dst[3] = 255;
3661b8e80941Smrg}
3662b8e80941Smrg
3663b8e80941Smrgstatic inline void
3664b8e80941Smrgunpack_ubyte_r_snorm16(const void *void_src, GLubyte dst[4])
3665b8e80941Smrg{
3666b8e80941Smrg   int16_t *src = (int16_t *)void_src;
3667b8e80941Smrg            int16_t r = src[0];
3668b8e80941Smrg
3669b8e80941Smrg
3670b8e80941Smrg
3671b8e80941Smrg            dst[0] = _mesa_snorm_to_unorm(r, 16, 8);
3672b8e80941Smrg
3673b8e80941Smrg         dst[1] = 0;
3674b8e80941Smrg
3675b8e80941Smrg         dst[2] = 0;
3676b8e80941Smrg
3677b8e80941Smrg         dst[3] = 255;
3678b8e80941Smrg}
3679b8e80941Smrg
3680b8e80941Smrgstatic inline void
3681b8e80941Smrgunpack_ubyte_la_snorm16(const void *void_src, GLubyte dst[4])
3682b8e80941Smrg{
3683b8e80941Smrg   int16_t *src = (int16_t *)void_src;
3684b8e80941Smrg            int16_t l = src[0];
3685b8e80941Smrg            int16_t a = src[1];
3686b8e80941Smrg
3687b8e80941Smrg
3688b8e80941Smrg
3689b8e80941Smrg            dst[0] = _mesa_snorm_to_unorm(l, 16, 8);
3690b8e80941Smrg
3691b8e80941Smrg
3692b8e80941Smrg            dst[1] = _mesa_snorm_to_unorm(l, 16, 8);
3693b8e80941Smrg
3694b8e80941Smrg
3695b8e80941Smrg            dst[2] = _mesa_snorm_to_unorm(l, 16, 8);
3696b8e80941Smrg
3697b8e80941Smrg
3698b8e80941Smrg            dst[3] = _mesa_snorm_to_unorm(a, 16, 8);
3699b8e80941Smrg}
3700b8e80941Smrg
3701b8e80941Smrgstatic inline void
3702b8e80941Smrgunpack_ubyte_rgb_snorm16(const void *void_src, GLubyte dst[4])
3703b8e80941Smrg{
3704b8e80941Smrg   int16_t *src = (int16_t *)void_src;
3705b8e80941Smrg            int16_t r = src[0];
3706b8e80941Smrg            int16_t g = src[1];
3707b8e80941Smrg            int16_t b = src[2];
3708b8e80941Smrg
3709b8e80941Smrg
3710b8e80941Smrg
3711b8e80941Smrg            dst[0] = _mesa_snorm_to_unorm(r, 16, 8);
3712b8e80941Smrg
3713b8e80941Smrg
3714b8e80941Smrg            dst[1] = _mesa_snorm_to_unorm(g, 16, 8);
3715b8e80941Smrg
3716b8e80941Smrg
3717b8e80941Smrg            dst[2] = _mesa_snorm_to_unorm(b, 16, 8);
3718b8e80941Smrg
3719b8e80941Smrg         dst[3] = 255;
3720b8e80941Smrg}
3721b8e80941Smrg
3722b8e80941Smrgstatic inline void
3723b8e80941Smrgunpack_ubyte_rgba_snorm16(const void *void_src, GLubyte dst[4])
3724b8e80941Smrg{
3725b8e80941Smrg   int16_t *src = (int16_t *)void_src;
3726b8e80941Smrg            int16_t r = src[0];
3727b8e80941Smrg            int16_t g = src[1];
3728b8e80941Smrg            int16_t b = src[2];
3729b8e80941Smrg            int16_t a = src[3];
3730b8e80941Smrg
3731b8e80941Smrg
3732b8e80941Smrg
3733b8e80941Smrg            dst[0] = _mesa_snorm_to_unorm(r, 16, 8);
3734b8e80941Smrg
3735b8e80941Smrg
3736b8e80941Smrg            dst[1] = _mesa_snorm_to_unorm(g, 16, 8);
3737b8e80941Smrg
3738b8e80941Smrg
3739b8e80941Smrg            dst[2] = _mesa_snorm_to_unorm(b, 16, 8);
3740b8e80941Smrg
3741b8e80941Smrg
3742b8e80941Smrg            dst[3] = _mesa_snorm_to_unorm(a, 16, 8);
3743b8e80941Smrg}
3744b8e80941Smrg
3745b8e80941Smrgstatic inline void
3746b8e80941Smrgunpack_ubyte_rgbx_snorm16(const void *void_src, GLubyte dst[4])
3747b8e80941Smrg{
3748b8e80941Smrg   int16_t *src = (int16_t *)void_src;
3749b8e80941Smrg            int16_t r = src[0];
3750b8e80941Smrg            int16_t g = src[1];
3751b8e80941Smrg            int16_t b = src[2];
3752b8e80941Smrg
3753b8e80941Smrg
3754b8e80941Smrg
3755b8e80941Smrg            dst[0] = _mesa_snorm_to_unorm(r, 16, 8);
3756b8e80941Smrg
3757b8e80941Smrg
3758b8e80941Smrg            dst[1] = _mesa_snorm_to_unorm(g, 16, 8);
3759b8e80941Smrg
3760b8e80941Smrg
3761b8e80941Smrg            dst[2] = _mesa_snorm_to_unorm(b, 16, 8);
3762b8e80941Smrg
3763b8e80941Smrg         dst[3] = 255;
3764b8e80941Smrg}
3765b8e80941Smrg
3766b8e80941Smrgstatic inline void
3767b8e80941Smrgunpack_ubyte_a8b8g8r8_srgb(const void *void_src, GLubyte dst[4])
3768b8e80941Smrg{
3769b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
3770b8e80941Smrg            uint8_t a = UNPACK(*src, 0, 8);
3771b8e80941Smrg            uint8_t b = UNPACK(*src, 8, 8);
3772b8e80941Smrg            uint8_t g = UNPACK(*src, 16, 8);
3773b8e80941Smrg            uint8_t r = UNPACK(*src, 24, 8);
3774b8e80941Smrg
3775b8e80941Smrg
3776b8e80941Smrg
3777b8e80941Smrg
3778b8e80941Smrg               dst[0] = util_format_srgb_to_linear_8unorm(r);
3779b8e80941Smrg
3780b8e80941Smrg
3781b8e80941Smrg
3782b8e80941Smrg               dst[1] = util_format_srgb_to_linear_8unorm(g);
3783b8e80941Smrg
3784b8e80941Smrg
3785b8e80941Smrg
3786b8e80941Smrg               dst[2] = util_format_srgb_to_linear_8unorm(b);
3787b8e80941Smrg
3788b8e80941Smrg
3789b8e80941Smrg               dst[3] = _mesa_unorm_to_unorm(a, 8, 8);
3790b8e80941Smrg}
3791b8e80941Smrg
3792b8e80941Smrgstatic inline void
3793b8e80941Smrgunpack_ubyte_b8g8r8a8_srgb(const void *void_src, GLubyte dst[4])
3794b8e80941Smrg{
3795b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
3796b8e80941Smrg            uint8_t b = UNPACK(*src, 0, 8);
3797b8e80941Smrg            uint8_t g = UNPACK(*src, 8, 8);
3798b8e80941Smrg            uint8_t r = UNPACK(*src, 16, 8);
3799b8e80941Smrg            uint8_t a = UNPACK(*src, 24, 8);
3800b8e80941Smrg
3801b8e80941Smrg
3802b8e80941Smrg
3803b8e80941Smrg
3804b8e80941Smrg               dst[0] = util_format_srgb_to_linear_8unorm(r);
3805b8e80941Smrg
3806b8e80941Smrg
3807b8e80941Smrg
3808b8e80941Smrg               dst[1] = util_format_srgb_to_linear_8unorm(g);
3809b8e80941Smrg
3810b8e80941Smrg
3811b8e80941Smrg
3812b8e80941Smrg               dst[2] = util_format_srgb_to_linear_8unorm(b);
3813b8e80941Smrg
3814b8e80941Smrg
3815b8e80941Smrg               dst[3] = _mesa_unorm_to_unorm(a, 8, 8);
3816b8e80941Smrg}
3817b8e80941Smrg
3818b8e80941Smrgstatic inline void
3819b8e80941Smrgunpack_ubyte_a8r8g8b8_srgb(const void *void_src, GLubyte dst[4])
3820b8e80941Smrg{
3821b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
3822b8e80941Smrg            uint8_t a = UNPACK(*src, 0, 8);
3823b8e80941Smrg            uint8_t r = UNPACK(*src, 8, 8);
3824b8e80941Smrg            uint8_t g = UNPACK(*src, 16, 8);
3825b8e80941Smrg            uint8_t b = UNPACK(*src, 24, 8);
3826b8e80941Smrg
3827b8e80941Smrg
3828b8e80941Smrg
3829b8e80941Smrg
3830b8e80941Smrg               dst[0] = util_format_srgb_to_linear_8unorm(r);
3831b8e80941Smrg
3832b8e80941Smrg
3833b8e80941Smrg
3834b8e80941Smrg               dst[1] = util_format_srgb_to_linear_8unorm(g);
3835b8e80941Smrg
3836b8e80941Smrg
3837b8e80941Smrg
3838b8e80941Smrg               dst[2] = util_format_srgb_to_linear_8unorm(b);
3839b8e80941Smrg
3840b8e80941Smrg
3841b8e80941Smrg               dst[3] = _mesa_unorm_to_unorm(a, 8, 8);
3842b8e80941Smrg}
3843b8e80941Smrg
3844b8e80941Smrgstatic inline void
3845b8e80941Smrgunpack_ubyte_b8g8r8x8_srgb(const void *void_src, GLubyte dst[4])
3846b8e80941Smrg{
3847b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
3848b8e80941Smrg            uint8_t b = UNPACK(*src, 0, 8);
3849b8e80941Smrg            uint8_t g = UNPACK(*src, 8, 8);
3850b8e80941Smrg            uint8_t r = UNPACK(*src, 16, 8);
3851b8e80941Smrg
3852b8e80941Smrg
3853b8e80941Smrg
3854b8e80941Smrg
3855b8e80941Smrg               dst[0] = util_format_srgb_to_linear_8unorm(r);
3856b8e80941Smrg
3857b8e80941Smrg
3858b8e80941Smrg
3859b8e80941Smrg               dst[1] = util_format_srgb_to_linear_8unorm(g);
3860b8e80941Smrg
3861b8e80941Smrg
3862b8e80941Smrg
3863b8e80941Smrg               dst[2] = util_format_srgb_to_linear_8unorm(b);
3864b8e80941Smrg
3865b8e80941Smrg         dst[3] = 255;
3866b8e80941Smrg}
3867b8e80941Smrg
3868b8e80941Smrgstatic inline void
3869b8e80941Smrgunpack_ubyte_x8r8g8b8_srgb(const void *void_src, GLubyte dst[4])
3870b8e80941Smrg{
3871b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
3872b8e80941Smrg            uint8_t r = UNPACK(*src, 8, 8);
3873b8e80941Smrg            uint8_t g = UNPACK(*src, 16, 8);
3874b8e80941Smrg            uint8_t b = UNPACK(*src, 24, 8);
3875b8e80941Smrg
3876b8e80941Smrg
3877b8e80941Smrg
3878b8e80941Smrg
3879b8e80941Smrg               dst[0] = util_format_srgb_to_linear_8unorm(r);
3880b8e80941Smrg
3881b8e80941Smrg
3882b8e80941Smrg
3883b8e80941Smrg               dst[1] = util_format_srgb_to_linear_8unorm(g);
3884b8e80941Smrg
3885b8e80941Smrg
3886b8e80941Smrg
3887b8e80941Smrg               dst[2] = util_format_srgb_to_linear_8unorm(b);
3888b8e80941Smrg
3889b8e80941Smrg         dst[3] = 255;
3890b8e80941Smrg}
3891b8e80941Smrg
3892b8e80941Smrgstatic inline void
3893b8e80941Smrgunpack_ubyte_r8g8b8a8_srgb(const void *void_src, GLubyte dst[4])
3894b8e80941Smrg{
3895b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
3896b8e80941Smrg            uint8_t r = UNPACK(*src, 0, 8);
3897b8e80941Smrg            uint8_t g = UNPACK(*src, 8, 8);
3898b8e80941Smrg            uint8_t b = UNPACK(*src, 16, 8);
3899b8e80941Smrg            uint8_t a = UNPACK(*src, 24, 8);
3900b8e80941Smrg
3901b8e80941Smrg
3902b8e80941Smrg
3903b8e80941Smrg
3904b8e80941Smrg               dst[0] = util_format_srgb_to_linear_8unorm(r);
3905b8e80941Smrg
3906b8e80941Smrg
3907b8e80941Smrg
3908b8e80941Smrg               dst[1] = util_format_srgb_to_linear_8unorm(g);
3909b8e80941Smrg
3910b8e80941Smrg
3911b8e80941Smrg
3912b8e80941Smrg               dst[2] = util_format_srgb_to_linear_8unorm(b);
3913b8e80941Smrg
3914b8e80941Smrg
3915b8e80941Smrg               dst[3] = _mesa_unorm_to_unorm(a, 8, 8);
3916b8e80941Smrg}
3917b8e80941Smrg
3918b8e80941Smrgstatic inline void
3919b8e80941Smrgunpack_ubyte_r8g8b8x8_srgb(const void *void_src, GLubyte dst[4])
3920b8e80941Smrg{
3921b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
3922b8e80941Smrg            uint8_t r = UNPACK(*src, 0, 8);
3923b8e80941Smrg            uint8_t g = UNPACK(*src, 8, 8);
3924b8e80941Smrg            uint8_t b = UNPACK(*src, 16, 8);
3925b8e80941Smrg
3926b8e80941Smrg
3927b8e80941Smrg
3928b8e80941Smrg
3929b8e80941Smrg               dst[0] = util_format_srgb_to_linear_8unorm(r);
3930b8e80941Smrg
3931b8e80941Smrg
3932b8e80941Smrg
3933b8e80941Smrg               dst[1] = util_format_srgb_to_linear_8unorm(g);
3934b8e80941Smrg
3935b8e80941Smrg
3936b8e80941Smrg
3937b8e80941Smrg               dst[2] = util_format_srgb_to_linear_8unorm(b);
3938b8e80941Smrg
3939b8e80941Smrg         dst[3] = 255;
3940b8e80941Smrg}
3941b8e80941Smrg
3942b8e80941Smrgstatic inline void
3943b8e80941Smrgunpack_ubyte_x8b8g8r8_srgb(const void *void_src, GLubyte dst[4])
3944b8e80941Smrg{
3945b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
3946b8e80941Smrg            uint8_t b = UNPACK(*src, 8, 8);
3947b8e80941Smrg            uint8_t g = UNPACK(*src, 16, 8);
3948b8e80941Smrg            uint8_t r = UNPACK(*src, 24, 8);
3949b8e80941Smrg
3950b8e80941Smrg
3951b8e80941Smrg
3952b8e80941Smrg
3953b8e80941Smrg               dst[0] = util_format_srgb_to_linear_8unorm(r);
3954b8e80941Smrg
3955b8e80941Smrg
3956b8e80941Smrg
3957b8e80941Smrg               dst[1] = util_format_srgb_to_linear_8unorm(g);
3958b8e80941Smrg
3959b8e80941Smrg
3960b8e80941Smrg
3961b8e80941Smrg               dst[2] = util_format_srgb_to_linear_8unorm(b);
3962b8e80941Smrg
3963b8e80941Smrg         dst[3] = 255;
3964b8e80941Smrg}
3965b8e80941Smrg
3966b8e80941Smrgstatic inline void
3967b8e80941Smrgunpack_ubyte_l8a8_srgb(const void *void_src, GLubyte dst[4])
3968b8e80941Smrg{
3969b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
3970b8e80941Smrg            uint8_t l = UNPACK(*src, 0, 8);
3971b8e80941Smrg            uint8_t a = UNPACK(*src, 8, 8);
3972b8e80941Smrg
3973b8e80941Smrg
3974b8e80941Smrg
3975b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(l, 8, 8);
3976b8e80941Smrg
3977b8e80941Smrg
3978b8e80941Smrg               dst[1] = _mesa_unorm_to_unorm(l, 8, 8);
3979b8e80941Smrg
3980b8e80941Smrg
3981b8e80941Smrg               dst[2] = _mesa_unorm_to_unorm(l, 8, 8);
3982b8e80941Smrg
3983b8e80941Smrg
3984b8e80941Smrg               dst[3] = _mesa_unorm_to_unorm(a, 8, 8);
3985b8e80941Smrg}
3986b8e80941Smrg
3987b8e80941Smrgstatic inline void
3988b8e80941Smrgunpack_ubyte_a8l8_srgb(const void *void_src, GLubyte dst[4])
3989b8e80941Smrg{
3990b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
3991b8e80941Smrg            uint8_t a = UNPACK(*src, 0, 8);
3992b8e80941Smrg            uint8_t l = UNPACK(*src, 8, 8);
3993b8e80941Smrg
3994b8e80941Smrg
3995b8e80941Smrg
3996b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(l, 8, 8);
3997b8e80941Smrg
3998b8e80941Smrg
3999b8e80941Smrg               dst[1] = _mesa_unorm_to_unorm(l, 8, 8);
4000b8e80941Smrg
4001b8e80941Smrg
4002b8e80941Smrg               dst[2] = _mesa_unorm_to_unorm(l, 8, 8);
4003b8e80941Smrg
4004b8e80941Smrg
4005b8e80941Smrg               dst[3] = _mesa_unorm_to_unorm(a, 8, 8);
4006b8e80941Smrg}
4007b8e80941Smrg
4008b8e80941Smrgstatic inline void
4009b8e80941Smrgunpack_ubyte_r_srgb8(const void *void_src, GLubyte dst[4])
4010b8e80941Smrg{
4011b8e80941Smrg   uint8_t *src = (uint8_t *)void_src;
4012b8e80941Smrg            uint8_t r = src[0];
4013b8e80941Smrg
4014b8e80941Smrg
4015b8e80941Smrg
4016b8e80941Smrg
4017b8e80941Smrg               dst[0] = util_format_srgb_to_linear_8unorm(r);
4018b8e80941Smrg
4019b8e80941Smrg         dst[1] = 0;
4020b8e80941Smrg
4021b8e80941Smrg         dst[2] = 0;
4022b8e80941Smrg
4023b8e80941Smrg         dst[3] = 255;
4024b8e80941Smrg}
4025b8e80941Smrg
4026b8e80941Smrgstatic inline void
4027b8e80941Smrgunpack_ubyte_l_srgb8(const void *void_src, GLubyte dst[4])
4028b8e80941Smrg{
4029b8e80941Smrg   uint8_t *src = (uint8_t *)void_src;
4030b8e80941Smrg            uint8_t l = src[0];
4031b8e80941Smrg
4032b8e80941Smrg
4033b8e80941Smrg
4034b8e80941Smrg               dst[0] = _mesa_unorm_to_unorm(l, 8, 8);
4035b8e80941Smrg
4036b8e80941Smrg
4037b8e80941Smrg               dst[1] = _mesa_unorm_to_unorm(l, 8, 8);
4038b8e80941Smrg
4039b8e80941Smrg
4040b8e80941Smrg               dst[2] = _mesa_unorm_to_unorm(l, 8, 8);
4041b8e80941Smrg
4042b8e80941Smrg         dst[3] = 255;
4043b8e80941Smrg}
4044b8e80941Smrg
4045b8e80941Smrgstatic inline void
4046b8e80941Smrgunpack_ubyte_bgr_srgb8(const void *void_src, GLubyte dst[4])
4047b8e80941Smrg{
4048b8e80941Smrg   uint8_t *src = (uint8_t *)void_src;
4049b8e80941Smrg            uint8_t b = src[0];
4050b8e80941Smrg            uint8_t g = src[1];
4051b8e80941Smrg            uint8_t r = src[2];
4052b8e80941Smrg
4053b8e80941Smrg
4054b8e80941Smrg
4055b8e80941Smrg
4056b8e80941Smrg               dst[0] = util_format_srgb_to_linear_8unorm(r);
4057b8e80941Smrg
4058b8e80941Smrg
4059b8e80941Smrg
4060b8e80941Smrg               dst[1] = util_format_srgb_to_linear_8unorm(g);
4061b8e80941Smrg
4062b8e80941Smrg
4063b8e80941Smrg
4064b8e80941Smrg               dst[2] = util_format_srgb_to_linear_8unorm(b);
4065b8e80941Smrg
4066b8e80941Smrg         dst[3] = 255;
4067b8e80941Smrg}
4068b8e80941Smrg
4069b8e80941Smrg/* integer packing functions */
4070b8e80941Smrg
4071b8e80941Smrg
4072b8e80941Smrgstatic inline void
4073b8e80941Smrgunpack_int_a8b8g8r8_uint(const void *void_src, GLuint dst[4])
4074b8e80941Smrg{
4075b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
4076b8e80941Smrg            uint8_t a = UNPACK(*src, 0, 8);
4077b8e80941Smrg            uint8_t b = UNPACK(*src, 8, 8);
4078b8e80941Smrg            uint8_t g = UNPACK(*src, 16, 8);
4079b8e80941Smrg            uint8_t r = UNPACK(*src, 24, 8);
4080b8e80941Smrg
4081b8e80941Smrg
4082b8e80941Smrg         dst[0] = r;
4083b8e80941Smrg
4084b8e80941Smrg         dst[1] = g;
4085b8e80941Smrg
4086b8e80941Smrg         dst[2] = b;
4087b8e80941Smrg
4088b8e80941Smrg         dst[3] = a;
4089b8e80941Smrg}
4090b8e80941Smrg
4091b8e80941Smrgstatic inline void
4092b8e80941Smrgunpack_int_a8r8g8b8_uint(const void *void_src, GLuint dst[4])
4093b8e80941Smrg{
4094b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
4095b8e80941Smrg            uint8_t a = UNPACK(*src, 0, 8);
4096b8e80941Smrg            uint8_t r = UNPACK(*src, 8, 8);
4097b8e80941Smrg            uint8_t g = UNPACK(*src, 16, 8);
4098b8e80941Smrg            uint8_t b = UNPACK(*src, 24, 8);
4099b8e80941Smrg
4100b8e80941Smrg
4101b8e80941Smrg         dst[0] = r;
4102b8e80941Smrg
4103b8e80941Smrg         dst[1] = g;
4104b8e80941Smrg
4105b8e80941Smrg         dst[2] = b;
4106b8e80941Smrg
4107b8e80941Smrg         dst[3] = a;
4108b8e80941Smrg}
4109b8e80941Smrg
4110b8e80941Smrgstatic inline void
4111b8e80941Smrgunpack_int_r8g8b8a8_uint(const void *void_src, GLuint dst[4])
4112b8e80941Smrg{
4113b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
4114b8e80941Smrg            uint8_t r = UNPACK(*src, 0, 8);
4115b8e80941Smrg            uint8_t g = UNPACK(*src, 8, 8);
4116b8e80941Smrg            uint8_t b = UNPACK(*src, 16, 8);
4117b8e80941Smrg            uint8_t a = UNPACK(*src, 24, 8);
4118b8e80941Smrg
4119b8e80941Smrg
4120b8e80941Smrg         dst[0] = r;
4121b8e80941Smrg
4122b8e80941Smrg         dst[1] = g;
4123b8e80941Smrg
4124b8e80941Smrg         dst[2] = b;
4125b8e80941Smrg
4126b8e80941Smrg         dst[3] = a;
4127b8e80941Smrg}
4128b8e80941Smrg
4129b8e80941Smrgstatic inline void
4130b8e80941Smrgunpack_int_b8g8r8a8_uint(const void *void_src, GLuint dst[4])
4131b8e80941Smrg{
4132b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
4133b8e80941Smrg            uint8_t b = UNPACK(*src, 0, 8);
4134b8e80941Smrg            uint8_t g = UNPACK(*src, 8, 8);
4135b8e80941Smrg            uint8_t r = UNPACK(*src, 16, 8);
4136b8e80941Smrg            uint8_t a = UNPACK(*src, 24, 8);
4137b8e80941Smrg
4138b8e80941Smrg
4139b8e80941Smrg         dst[0] = r;
4140b8e80941Smrg
4141b8e80941Smrg         dst[1] = g;
4142b8e80941Smrg
4143b8e80941Smrg         dst[2] = b;
4144b8e80941Smrg
4145b8e80941Smrg         dst[3] = a;
4146b8e80941Smrg}
4147b8e80941Smrg
4148b8e80941Smrgstatic inline void
4149b8e80941Smrgunpack_int_b10g10r10a2_uint(const void *void_src, GLuint dst[4])
4150b8e80941Smrg{
4151b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
4152b8e80941Smrg            uint16_t b = UNPACK(*src, 0, 10);
4153b8e80941Smrg            uint16_t g = UNPACK(*src, 10, 10);
4154b8e80941Smrg            uint16_t r = UNPACK(*src, 20, 10);
4155b8e80941Smrg            uint8_t a = UNPACK(*src, 30, 2);
4156b8e80941Smrg
4157b8e80941Smrg
4158b8e80941Smrg         dst[0] = r;
4159b8e80941Smrg
4160b8e80941Smrg         dst[1] = g;
4161b8e80941Smrg
4162b8e80941Smrg         dst[2] = b;
4163b8e80941Smrg
4164b8e80941Smrg         dst[3] = a;
4165b8e80941Smrg}
4166b8e80941Smrg
4167b8e80941Smrgstatic inline void
4168b8e80941Smrgunpack_int_r10g10b10a2_uint(const void *void_src, GLuint dst[4])
4169b8e80941Smrg{
4170b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
4171b8e80941Smrg            uint16_t r = UNPACK(*src, 0, 10);
4172b8e80941Smrg            uint16_t g = UNPACK(*src, 10, 10);
4173b8e80941Smrg            uint16_t b = UNPACK(*src, 20, 10);
4174b8e80941Smrg            uint8_t a = UNPACK(*src, 30, 2);
4175b8e80941Smrg
4176b8e80941Smrg
4177b8e80941Smrg         dst[0] = r;
4178b8e80941Smrg
4179b8e80941Smrg         dst[1] = g;
4180b8e80941Smrg
4181b8e80941Smrg         dst[2] = b;
4182b8e80941Smrg
4183b8e80941Smrg         dst[3] = a;
4184b8e80941Smrg}
4185b8e80941Smrg
4186b8e80941Smrgstatic inline void
4187b8e80941Smrgunpack_int_a2b10g10r10_uint(const void *void_src, GLuint dst[4])
4188b8e80941Smrg{
4189b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
4190b8e80941Smrg            uint8_t a = UNPACK(*src, 0, 2);
4191b8e80941Smrg            uint16_t b = UNPACK(*src, 2, 10);
4192b8e80941Smrg            uint16_t g = UNPACK(*src, 12, 10);
4193b8e80941Smrg            uint16_t r = UNPACK(*src, 22, 10);
4194b8e80941Smrg
4195b8e80941Smrg
4196b8e80941Smrg         dst[0] = r;
4197b8e80941Smrg
4198b8e80941Smrg         dst[1] = g;
4199b8e80941Smrg
4200b8e80941Smrg         dst[2] = b;
4201b8e80941Smrg
4202b8e80941Smrg         dst[3] = a;
4203b8e80941Smrg}
4204b8e80941Smrg
4205b8e80941Smrgstatic inline void
4206b8e80941Smrgunpack_int_a2r10g10b10_uint(const void *void_src, GLuint dst[4])
4207b8e80941Smrg{
4208b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
4209b8e80941Smrg            uint8_t a = UNPACK(*src, 0, 2);
4210b8e80941Smrg            uint16_t r = UNPACK(*src, 2, 10);
4211b8e80941Smrg            uint16_t g = UNPACK(*src, 12, 10);
4212b8e80941Smrg            uint16_t b = UNPACK(*src, 22, 10);
4213b8e80941Smrg
4214b8e80941Smrg
4215b8e80941Smrg         dst[0] = r;
4216b8e80941Smrg
4217b8e80941Smrg         dst[1] = g;
4218b8e80941Smrg
4219b8e80941Smrg         dst[2] = b;
4220b8e80941Smrg
4221b8e80941Smrg         dst[3] = a;
4222b8e80941Smrg}
4223b8e80941Smrg
4224b8e80941Smrgstatic inline void
4225b8e80941Smrgunpack_int_b5g6r5_uint(const void *void_src, GLuint dst[4])
4226b8e80941Smrg{
4227b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
4228b8e80941Smrg            uint8_t b = UNPACK(*src, 0, 5);
4229b8e80941Smrg            uint8_t g = UNPACK(*src, 5, 6);
4230b8e80941Smrg            uint8_t r = UNPACK(*src, 11, 5);
4231b8e80941Smrg
4232b8e80941Smrg
4233b8e80941Smrg         dst[0] = r;
4234b8e80941Smrg
4235b8e80941Smrg         dst[1] = g;
4236b8e80941Smrg
4237b8e80941Smrg         dst[2] = b;
4238b8e80941Smrg
4239b8e80941Smrg         dst[3] = 1;
4240b8e80941Smrg}
4241b8e80941Smrg
4242b8e80941Smrgstatic inline void
4243b8e80941Smrgunpack_int_r5g6b5_uint(const void *void_src, GLuint dst[4])
4244b8e80941Smrg{
4245b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
4246b8e80941Smrg            uint8_t r = UNPACK(*src, 0, 5);
4247b8e80941Smrg            uint8_t g = UNPACK(*src, 5, 6);
4248b8e80941Smrg            uint8_t b = UNPACK(*src, 11, 5);
4249b8e80941Smrg
4250b8e80941Smrg
4251b8e80941Smrg         dst[0] = r;
4252b8e80941Smrg
4253b8e80941Smrg         dst[1] = g;
4254b8e80941Smrg
4255b8e80941Smrg         dst[2] = b;
4256b8e80941Smrg
4257b8e80941Smrg         dst[3] = 1;
4258b8e80941Smrg}
4259b8e80941Smrg
4260b8e80941Smrgstatic inline void
4261b8e80941Smrgunpack_int_b2g3r3_uint(const void *void_src, GLuint dst[4])
4262b8e80941Smrg{
4263b8e80941Smrg   uint8_t *src = (uint8_t *)void_src;
4264b8e80941Smrg            uint8_t b = UNPACK(*src, 0, 2);
4265b8e80941Smrg            uint8_t g = UNPACK(*src, 2, 3);
4266b8e80941Smrg            uint8_t r = UNPACK(*src, 5, 3);
4267b8e80941Smrg
4268b8e80941Smrg
4269b8e80941Smrg         dst[0] = r;
4270b8e80941Smrg
4271b8e80941Smrg         dst[1] = g;
4272b8e80941Smrg
4273b8e80941Smrg         dst[2] = b;
4274b8e80941Smrg
4275b8e80941Smrg         dst[3] = 1;
4276b8e80941Smrg}
4277b8e80941Smrg
4278b8e80941Smrgstatic inline void
4279b8e80941Smrgunpack_int_r3g3b2_uint(const void *void_src, GLuint dst[4])
4280b8e80941Smrg{
4281b8e80941Smrg   uint8_t *src = (uint8_t *)void_src;
4282b8e80941Smrg            uint8_t r = UNPACK(*src, 0, 3);
4283b8e80941Smrg            uint8_t g = UNPACK(*src, 3, 3);
4284b8e80941Smrg            uint8_t b = UNPACK(*src, 6, 2);
4285b8e80941Smrg
4286b8e80941Smrg
4287b8e80941Smrg         dst[0] = r;
4288b8e80941Smrg
4289b8e80941Smrg         dst[1] = g;
4290b8e80941Smrg
4291b8e80941Smrg         dst[2] = b;
4292b8e80941Smrg
4293b8e80941Smrg         dst[3] = 1;
4294b8e80941Smrg}
4295b8e80941Smrg
4296b8e80941Smrgstatic inline void
4297b8e80941Smrgunpack_int_a4b4g4r4_uint(const void *void_src, GLuint dst[4])
4298b8e80941Smrg{
4299b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
4300b8e80941Smrg            uint8_t a = UNPACK(*src, 0, 4);
4301b8e80941Smrg            uint8_t b = UNPACK(*src, 4, 4);
4302b8e80941Smrg            uint8_t g = UNPACK(*src, 8, 4);
4303b8e80941Smrg            uint8_t r = UNPACK(*src, 12, 4);
4304b8e80941Smrg
4305b8e80941Smrg
4306b8e80941Smrg         dst[0] = r;
4307b8e80941Smrg
4308b8e80941Smrg         dst[1] = g;
4309b8e80941Smrg
4310b8e80941Smrg         dst[2] = b;
4311b8e80941Smrg
4312b8e80941Smrg         dst[3] = a;
4313b8e80941Smrg}
4314b8e80941Smrg
4315b8e80941Smrgstatic inline void
4316b8e80941Smrgunpack_int_r4g4b4a4_uint(const void *void_src, GLuint dst[4])
4317b8e80941Smrg{
4318b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
4319b8e80941Smrg            uint8_t r = UNPACK(*src, 0, 4);
4320b8e80941Smrg            uint8_t g = UNPACK(*src, 4, 4);
4321b8e80941Smrg            uint8_t b = UNPACK(*src, 8, 4);
4322b8e80941Smrg            uint8_t a = UNPACK(*src, 12, 4);
4323b8e80941Smrg
4324b8e80941Smrg
4325b8e80941Smrg         dst[0] = r;
4326b8e80941Smrg
4327b8e80941Smrg         dst[1] = g;
4328b8e80941Smrg
4329b8e80941Smrg         dst[2] = b;
4330b8e80941Smrg
4331b8e80941Smrg         dst[3] = a;
4332b8e80941Smrg}
4333b8e80941Smrg
4334b8e80941Smrgstatic inline void
4335b8e80941Smrgunpack_int_b4g4r4a4_uint(const void *void_src, GLuint dst[4])
4336b8e80941Smrg{
4337b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
4338b8e80941Smrg            uint8_t b = UNPACK(*src, 0, 4);
4339b8e80941Smrg            uint8_t g = UNPACK(*src, 4, 4);
4340b8e80941Smrg            uint8_t r = UNPACK(*src, 8, 4);
4341b8e80941Smrg            uint8_t a = UNPACK(*src, 12, 4);
4342b8e80941Smrg
4343b8e80941Smrg
4344b8e80941Smrg         dst[0] = r;
4345b8e80941Smrg
4346b8e80941Smrg         dst[1] = g;
4347b8e80941Smrg
4348b8e80941Smrg         dst[2] = b;
4349b8e80941Smrg
4350b8e80941Smrg         dst[3] = a;
4351b8e80941Smrg}
4352b8e80941Smrg
4353b8e80941Smrgstatic inline void
4354b8e80941Smrgunpack_int_a4r4g4b4_uint(const void *void_src, GLuint dst[4])
4355b8e80941Smrg{
4356b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
4357b8e80941Smrg            uint8_t a = UNPACK(*src, 0, 4);
4358b8e80941Smrg            uint8_t r = UNPACK(*src, 4, 4);
4359b8e80941Smrg            uint8_t g = UNPACK(*src, 8, 4);
4360b8e80941Smrg            uint8_t b = UNPACK(*src, 12, 4);
4361b8e80941Smrg
4362b8e80941Smrg
4363b8e80941Smrg         dst[0] = r;
4364b8e80941Smrg
4365b8e80941Smrg         dst[1] = g;
4366b8e80941Smrg
4367b8e80941Smrg         dst[2] = b;
4368b8e80941Smrg
4369b8e80941Smrg         dst[3] = a;
4370b8e80941Smrg}
4371b8e80941Smrg
4372b8e80941Smrgstatic inline void
4373b8e80941Smrgunpack_int_a1b5g5r5_uint(const void *void_src, GLuint dst[4])
4374b8e80941Smrg{
4375b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
4376b8e80941Smrg            uint8_t a = UNPACK(*src, 0, 1);
4377b8e80941Smrg            uint8_t b = UNPACK(*src, 1, 5);
4378b8e80941Smrg            uint8_t g = UNPACK(*src, 6, 5);
4379b8e80941Smrg            uint8_t r = UNPACK(*src, 11, 5);
4380b8e80941Smrg
4381b8e80941Smrg
4382b8e80941Smrg         dst[0] = r;
4383b8e80941Smrg
4384b8e80941Smrg         dst[1] = g;
4385b8e80941Smrg
4386b8e80941Smrg         dst[2] = b;
4387b8e80941Smrg
4388b8e80941Smrg         dst[3] = a;
4389b8e80941Smrg}
4390b8e80941Smrg
4391b8e80941Smrgstatic inline void
4392b8e80941Smrgunpack_int_b5g5r5a1_uint(const void *void_src, GLuint dst[4])
4393b8e80941Smrg{
4394b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
4395b8e80941Smrg            uint8_t b = UNPACK(*src, 0, 5);
4396b8e80941Smrg            uint8_t g = UNPACK(*src, 5, 5);
4397b8e80941Smrg            uint8_t r = UNPACK(*src, 10, 5);
4398b8e80941Smrg            uint8_t a = UNPACK(*src, 15, 1);
4399b8e80941Smrg
4400b8e80941Smrg
4401b8e80941Smrg         dst[0] = r;
4402b8e80941Smrg
4403b8e80941Smrg         dst[1] = g;
4404b8e80941Smrg
4405b8e80941Smrg         dst[2] = b;
4406b8e80941Smrg
4407b8e80941Smrg         dst[3] = a;
4408b8e80941Smrg}
4409b8e80941Smrg
4410b8e80941Smrgstatic inline void
4411b8e80941Smrgunpack_int_a1r5g5b5_uint(const void *void_src, GLuint dst[4])
4412b8e80941Smrg{
4413b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
4414b8e80941Smrg            uint8_t a = UNPACK(*src, 0, 1);
4415b8e80941Smrg            uint8_t r = UNPACK(*src, 1, 5);
4416b8e80941Smrg            uint8_t g = UNPACK(*src, 6, 5);
4417b8e80941Smrg            uint8_t b = UNPACK(*src, 11, 5);
4418b8e80941Smrg
4419b8e80941Smrg
4420b8e80941Smrg         dst[0] = r;
4421b8e80941Smrg
4422b8e80941Smrg         dst[1] = g;
4423b8e80941Smrg
4424b8e80941Smrg         dst[2] = b;
4425b8e80941Smrg
4426b8e80941Smrg         dst[3] = a;
4427b8e80941Smrg}
4428b8e80941Smrg
4429b8e80941Smrgstatic inline void
4430b8e80941Smrgunpack_int_r5g5b5a1_uint(const void *void_src, GLuint dst[4])
4431b8e80941Smrg{
4432b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
4433b8e80941Smrg            uint8_t r = UNPACK(*src, 0, 5);
4434b8e80941Smrg            uint8_t g = UNPACK(*src, 5, 5);
4435b8e80941Smrg            uint8_t b = UNPACK(*src, 10, 5);
4436b8e80941Smrg            uint8_t a = UNPACK(*src, 15, 1);
4437b8e80941Smrg
4438b8e80941Smrg
4439b8e80941Smrg         dst[0] = r;
4440b8e80941Smrg
4441b8e80941Smrg         dst[1] = g;
4442b8e80941Smrg
4443b8e80941Smrg         dst[2] = b;
4444b8e80941Smrg
4445b8e80941Smrg         dst[3] = a;
4446b8e80941Smrg}
4447b8e80941Smrg
4448b8e80941Smrgstatic inline void
4449b8e80941Smrgunpack_int_a_uint8(const void *void_src, GLuint dst[4])
4450b8e80941Smrg{
4451b8e80941Smrg   uint8_t *src = (uint8_t *)void_src;
4452b8e80941Smrg            uint8_t a = src[0];
4453b8e80941Smrg
4454b8e80941Smrg
4455b8e80941Smrg         dst[0] = 0;
4456b8e80941Smrg
4457b8e80941Smrg         dst[1] = 0;
4458b8e80941Smrg
4459b8e80941Smrg         dst[2] = 0;
4460b8e80941Smrg
4461b8e80941Smrg         dst[3] = a;
4462b8e80941Smrg}
4463b8e80941Smrg
4464b8e80941Smrgstatic inline void
4465b8e80941Smrgunpack_int_a_uint16(const void *void_src, GLuint dst[4])
4466b8e80941Smrg{
4467b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
4468b8e80941Smrg            uint16_t a = src[0];
4469b8e80941Smrg
4470b8e80941Smrg
4471b8e80941Smrg         dst[0] = 0;
4472b8e80941Smrg
4473b8e80941Smrg         dst[1] = 0;
4474b8e80941Smrg
4475b8e80941Smrg         dst[2] = 0;
4476b8e80941Smrg
4477b8e80941Smrg         dst[3] = a;
4478b8e80941Smrg}
4479b8e80941Smrg
4480b8e80941Smrgstatic inline void
4481b8e80941Smrgunpack_int_a_uint32(const void *void_src, GLuint dst[4])
4482b8e80941Smrg{
4483b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
4484b8e80941Smrg            uint32_t a = src[0];
4485b8e80941Smrg
4486b8e80941Smrg
4487b8e80941Smrg         dst[0] = 0;
4488b8e80941Smrg
4489b8e80941Smrg         dst[1] = 0;
4490b8e80941Smrg
4491b8e80941Smrg         dst[2] = 0;
4492b8e80941Smrg
4493b8e80941Smrg         dst[3] = a;
4494b8e80941Smrg}
4495b8e80941Smrg
4496b8e80941Smrgstatic inline void
4497b8e80941Smrgunpack_int_a_sint8(const void *void_src, GLuint dst[4])
4498b8e80941Smrg{
4499b8e80941Smrg   int8_t *src = (int8_t *)void_src;
4500b8e80941Smrg            int8_t a = src[0];
4501b8e80941Smrg
4502b8e80941Smrg
4503b8e80941Smrg         dst[0] = 0;
4504b8e80941Smrg
4505b8e80941Smrg         dst[1] = 0;
4506b8e80941Smrg
4507b8e80941Smrg         dst[2] = 0;
4508b8e80941Smrg
4509b8e80941Smrg         dst[3] = a;
4510b8e80941Smrg}
4511b8e80941Smrg
4512b8e80941Smrgstatic inline void
4513b8e80941Smrgunpack_int_a_sint16(const void *void_src, GLuint dst[4])
4514b8e80941Smrg{
4515b8e80941Smrg   int16_t *src = (int16_t *)void_src;
4516b8e80941Smrg            int16_t a = src[0];
4517b8e80941Smrg
4518b8e80941Smrg
4519b8e80941Smrg         dst[0] = 0;
4520b8e80941Smrg
4521b8e80941Smrg         dst[1] = 0;
4522b8e80941Smrg
4523b8e80941Smrg         dst[2] = 0;
4524b8e80941Smrg
4525b8e80941Smrg         dst[3] = a;
4526b8e80941Smrg}
4527b8e80941Smrg
4528b8e80941Smrgstatic inline void
4529b8e80941Smrgunpack_int_a_sint32(const void *void_src, GLuint dst[4])
4530b8e80941Smrg{
4531b8e80941Smrg   int32_t *src = (int32_t *)void_src;
4532b8e80941Smrg            int32_t a = src[0];
4533b8e80941Smrg
4534b8e80941Smrg
4535b8e80941Smrg         dst[0] = 0;
4536b8e80941Smrg
4537b8e80941Smrg         dst[1] = 0;
4538b8e80941Smrg
4539b8e80941Smrg         dst[2] = 0;
4540b8e80941Smrg
4541b8e80941Smrg         dst[3] = a;
4542b8e80941Smrg}
4543b8e80941Smrg
4544b8e80941Smrgstatic inline void
4545b8e80941Smrgunpack_int_i_uint8(const void *void_src, GLuint dst[4])
4546b8e80941Smrg{
4547b8e80941Smrg   uint8_t *src = (uint8_t *)void_src;
4548b8e80941Smrg            uint8_t i = src[0];
4549b8e80941Smrg
4550b8e80941Smrg
4551b8e80941Smrg         dst[0] = i;
4552b8e80941Smrg
4553b8e80941Smrg         dst[1] = i;
4554b8e80941Smrg
4555b8e80941Smrg         dst[2] = i;
4556b8e80941Smrg
4557b8e80941Smrg         dst[3] = i;
4558b8e80941Smrg}
4559b8e80941Smrg
4560b8e80941Smrgstatic inline void
4561b8e80941Smrgunpack_int_i_uint16(const void *void_src, GLuint dst[4])
4562b8e80941Smrg{
4563b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
4564b8e80941Smrg            uint16_t i = src[0];
4565b8e80941Smrg
4566b8e80941Smrg
4567b8e80941Smrg         dst[0] = i;
4568b8e80941Smrg
4569b8e80941Smrg         dst[1] = i;
4570b8e80941Smrg
4571b8e80941Smrg         dst[2] = i;
4572b8e80941Smrg
4573b8e80941Smrg         dst[3] = i;
4574b8e80941Smrg}
4575b8e80941Smrg
4576b8e80941Smrgstatic inline void
4577b8e80941Smrgunpack_int_i_uint32(const void *void_src, GLuint dst[4])
4578b8e80941Smrg{
4579b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
4580b8e80941Smrg            uint32_t i = src[0];
4581b8e80941Smrg
4582b8e80941Smrg
4583b8e80941Smrg         dst[0] = i;
4584b8e80941Smrg
4585b8e80941Smrg         dst[1] = i;
4586b8e80941Smrg
4587b8e80941Smrg         dst[2] = i;
4588b8e80941Smrg
4589b8e80941Smrg         dst[3] = i;
4590b8e80941Smrg}
4591b8e80941Smrg
4592b8e80941Smrgstatic inline void
4593b8e80941Smrgunpack_int_i_sint8(const void *void_src, GLuint dst[4])
4594b8e80941Smrg{
4595b8e80941Smrg   int8_t *src = (int8_t *)void_src;
4596b8e80941Smrg            int8_t i = src[0];
4597b8e80941Smrg
4598b8e80941Smrg
4599b8e80941Smrg         dst[0] = i;
4600b8e80941Smrg
4601b8e80941Smrg         dst[1] = i;
4602b8e80941Smrg
4603b8e80941Smrg         dst[2] = i;
4604b8e80941Smrg
4605b8e80941Smrg         dst[3] = i;
4606b8e80941Smrg}
4607b8e80941Smrg
4608b8e80941Smrgstatic inline void
4609b8e80941Smrgunpack_int_i_sint16(const void *void_src, GLuint dst[4])
4610b8e80941Smrg{
4611b8e80941Smrg   int16_t *src = (int16_t *)void_src;
4612b8e80941Smrg            int16_t i = src[0];
4613b8e80941Smrg
4614b8e80941Smrg
4615b8e80941Smrg         dst[0] = i;
4616b8e80941Smrg
4617b8e80941Smrg         dst[1] = i;
4618b8e80941Smrg
4619b8e80941Smrg         dst[2] = i;
4620b8e80941Smrg
4621b8e80941Smrg         dst[3] = i;
4622b8e80941Smrg}
4623b8e80941Smrg
4624b8e80941Smrgstatic inline void
4625b8e80941Smrgunpack_int_i_sint32(const void *void_src, GLuint dst[4])
4626b8e80941Smrg{
4627b8e80941Smrg   int32_t *src = (int32_t *)void_src;
4628b8e80941Smrg            int32_t i = src[0];
4629b8e80941Smrg
4630b8e80941Smrg
4631b8e80941Smrg         dst[0] = i;
4632b8e80941Smrg
4633b8e80941Smrg         dst[1] = i;
4634b8e80941Smrg
4635b8e80941Smrg         dst[2] = i;
4636b8e80941Smrg
4637b8e80941Smrg         dst[3] = i;
4638b8e80941Smrg}
4639b8e80941Smrg
4640b8e80941Smrgstatic inline void
4641b8e80941Smrgunpack_int_l_uint8(const void *void_src, GLuint dst[4])
4642b8e80941Smrg{
4643b8e80941Smrg   uint8_t *src = (uint8_t *)void_src;
4644b8e80941Smrg            uint8_t l = src[0];
4645b8e80941Smrg
4646b8e80941Smrg
4647b8e80941Smrg         dst[0] = l;
4648b8e80941Smrg
4649b8e80941Smrg         dst[1] = l;
4650b8e80941Smrg
4651b8e80941Smrg         dst[2] = l;
4652b8e80941Smrg
4653b8e80941Smrg         dst[3] = 1;
4654b8e80941Smrg}
4655b8e80941Smrg
4656b8e80941Smrgstatic inline void
4657b8e80941Smrgunpack_int_l_uint16(const void *void_src, GLuint dst[4])
4658b8e80941Smrg{
4659b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
4660b8e80941Smrg            uint16_t l = src[0];
4661b8e80941Smrg
4662b8e80941Smrg
4663b8e80941Smrg         dst[0] = l;
4664b8e80941Smrg
4665b8e80941Smrg         dst[1] = l;
4666b8e80941Smrg
4667b8e80941Smrg         dst[2] = l;
4668b8e80941Smrg
4669b8e80941Smrg         dst[3] = 1;
4670b8e80941Smrg}
4671b8e80941Smrg
4672b8e80941Smrgstatic inline void
4673b8e80941Smrgunpack_int_l_uint32(const void *void_src, GLuint dst[4])
4674b8e80941Smrg{
4675b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
4676b8e80941Smrg            uint32_t l = src[0];
4677b8e80941Smrg
4678b8e80941Smrg
4679b8e80941Smrg         dst[0] = l;
4680b8e80941Smrg
4681b8e80941Smrg         dst[1] = l;
4682b8e80941Smrg
4683b8e80941Smrg         dst[2] = l;
4684b8e80941Smrg
4685b8e80941Smrg         dst[3] = 1;
4686b8e80941Smrg}
4687b8e80941Smrg
4688b8e80941Smrgstatic inline void
4689b8e80941Smrgunpack_int_l_sint8(const void *void_src, GLuint dst[4])
4690b8e80941Smrg{
4691b8e80941Smrg   int8_t *src = (int8_t *)void_src;
4692b8e80941Smrg            int8_t l = src[0];
4693b8e80941Smrg
4694b8e80941Smrg
4695b8e80941Smrg         dst[0] = l;
4696b8e80941Smrg
4697b8e80941Smrg         dst[1] = l;
4698b8e80941Smrg
4699b8e80941Smrg         dst[2] = l;
4700b8e80941Smrg
4701b8e80941Smrg         dst[3] = 1;
4702b8e80941Smrg}
4703b8e80941Smrg
4704b8e80941Smrgstatic inline void
4705b8e80941Smrgunpack_int_l_sint16(const void *void_src, GLuint dst[4])
4706b8e80941Smrg{
4707b8e80941Smrg   int16_t *src = (int16_t *)void_src;
4708b8e80941Smrg            int16_t l = src[0];
4709b8e80941Smrg
4710b8e80941Smrg
4711b8e80941Smrg         dst[0] = l;
4712b8e80941Smrg
4713b8e80941Smrg         dst[1] = l;
4714b8e80941Smrg
4715b8e80941Smrg         dst[2] = l;
4716b8e80941Smrg
4717b8e80941Smrg         dst[3] = 1;
4718b8e80941Smrg}
4719b8e80941Smrg
4720b8e80941Smrgstatic inline void
4721b8e80941Smrgunpack_int_l_sint32(const void *void_src, GLuint dst[4])
4722b8e80941Smrg{
4723b8e80941Smrg   int32_t *src = (int32_t *)void_src;
4724b8e80941Smrg            int32_t l = src[0];
4725b8e80941Smrg
4726b8e80941Smrg
4727b8e80941Smrg         dst[0] = l;
4728b8e80941Smrg
4729b8e80941Smrg         dst[1] = l;
4730b8e80941Smrg
4731b8e80941Smrg         dst[2] = l;
4732b8e80941Smrg
4733b8e80941Smrg         dst[3] = 1;
4734b8e80941Smrg}
4735b8e80941Smrg
4736b8e80941Smrgstatic inline void
4737b8e80941Smrgunpack_int_la_uint8(const void *void_src, GLuint dst[4])
4738b8e80941Smrg{
4739b8e80941Smrg   uint8_t *src = (uint8_t *)void_src;
4740b8e80941Smrg            uint8_t l = src[0];
4741b8e80941Smrg            uint8_t a = src[1];
4742b8e80941Smrg
4743b8e80941Smrg
4744b8e80941Smrg         dst[0] = l;
4745b8e80941Smrg
4746b8e80941Smrg         dst[1] = l;
4747b8e80941Smrg
4748b8e80941Smrg         dst[2] = l;
4749b8e80941Smrg
4750b8e80941Smrg         dst[3] = a;
4751b8e80941Smrg}
4752b8e80941Smrg
4753b8e80941Smrgstatic inline void
4754b8e80941Smrgunpack_int_la_uint16(const void *void_src, GLuint dst[4])
4755b8e80941Smrg{
4756b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
4757b8e80941Smrg            uint16_t l = src[0];
4758b8e80941Smrg            uint16_t a = src[1];
4759b8e80941Smrg
4760b8e80941Smrg
4761b8e80941Smrg         dst[0] = l;
4762b8e80941Smrg
4763b8e80941Smrg         dst[1] = l;
4764b8e80941Smrg
4765b8e80941Smrg         dst[2] = l;
4766b8e80941Smrg
4767b8e80941Smrg         dst[3] = a;
4768b8e80941Smrg}
4769b8e80941Smrg
4770b8e80941Smrgstatic inline void
4771b8e80941Smrgunpack_int_la_uint32(const void *void_src, GLuint dst[4])
4772b8e80941Smrg{
4773b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
4774b8e80941Smrg            uint32_t l = src[0];
4775b8e80941Smrg            uint32_t a = src[1];
4776b8e80941Smrg
4777b8e80941Smrg
4778b8e80941Smrg         dst[0] = l;
4779b8e80941Smrg
4780b8e80941Smrg         dst[1] = l;
4781b8e80941Smrg
4782b8e80941Smrg         dst[2] = l;
4783b8e80941Smrg
4784b8e80941Smrg         dst[3] = a;
4785b8e80941Smrg}
4786b8e80941Smrg
4787b8e80941Smrgstatic inline void
4788b8e80941Smrgunpack_int_la_sint8(const void *void_src, GLuint dst[4])
4789b8e80941Smrg{
4790b8e80941Smrg   int8_t *src = (int8_t *)void_src;
4791b8e80941Smrg            int8_t l = src[0];
4792b8e80941Smrg            int8_t a = src[1];
4793b8e80941Smrg
4794b8e80941Smrg
4795b8e80941Smrg         dst[0] = l;
4796b8e80941Smrg
4797b8e80941Smrg         dst[1] = l;
4798b8e80941Smrg
4799b8e80941Smrg         dst[2] = l;
4800b8e80941Smrg
4801b8e80941Smrg         dst[3] = a;
4802b8e80941Smrg}
4803b8e80941Smrg
4804b8e80941Smrgstatic inline void
4805b8e80941Smrgunpack_int_la_sint16(const void *void_src, GLuint dst[4])
4806b8e80941Smrg{
4807b8e80941Smrg   int16_t *src = (int16_t *)void_src;
4808b8e80941Smrg            int16_t l = src[0];
4809b8e80941Smrg            int16_t a = src[1];
4810b8e80941Smrg
4811b8e80941Smrg
4812b8e80941Smrg         dst[0] = l;
4813b8e80941Smrg
4814b8e80941Smrg         dst[1] = l;
4815b8e80941Smrg
4816b8e80941Smrg         dst[2] = l;
4817b8e80941Smrg
4818b8e80941Smrg         dst[3] = a;
4819b8e80941Smrg}
4820b8e80941Smrg
4821b8e80941Smrgstatic inline void
4822b8e80941Smrgunpack_int_la_sint32(const void *void_src, GLuint dst[4])
4823b8e80941Smrg{
4824b8e80941Smrg   int32_t *src = (int32_t *)void_src;
4825b8e80941Smrg            int32_t l = src[0];
4826b8e80941Smrg            int32_t a = src[1];
4827b8e80941Smrg
4828b8e80941Smrg
4829b8e80941Smrg         dst[0] = l;
4830b8e80941Smrg
4831b8e80941Smrg         dst[1] = l;
4832b8e80941Smrg
4833b8e80941Smrg         dst[2] = l;
4834b8e80941Smrg
4835b8e80941Smrg         dst[3] = a;
4836b8e80941Smrg}
4837b8e80941Smrg
4838b8e80941Smrgstatic inline void
4839b8e80941Smrgunpack_int_r_uint8(const void *void_src, GLuint dst[4])
4840b8e80941Smrg{
4841b8e80941Smrg   uint8_t *src = (uint8_t *)void_src;
4842b8e80941Smrg            uint8_t r = src[0];
4843b8e80941Smrg
4844b8e80941Smrg
4845b8e80941Smrg         dst[0] = r;
4846b8e80941Smrg
4847b8e80941Smrg         dst[1] = 0;
4848b8e80941Smrg
4849b8e80941Smrg         dst[2] = 0;
4850b8e80941Smrg
4851b8e80941Smrg         dst[3] = 1;
4852b8e80941Smrg}
4853b8e80941Smrg
4854b8e80941Smrgstatic inline void
4855b8e80941Smrgunpack_int_r_uint16(const void *void_src, GLuint dst[4])
4856b8e80941Smrg{
4857b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
4858b8e80941Smrg            uint16_t r = src[0];
4859b8e80941Smrg
4860b8e80941Smrg
4861b8e80941Smrg         dst[0] = r;
4862b8e80941Smrg
4863b8e80941Smrg         dst[1] = 0;
4864b8e80941Smrg
4865b8e80941Smrg         dst[2] = 0;
4866b8e80941Smrg
4867b8e80941Smrg         dst[3] = 1;
4868b8e80941Smrg}
4869b8e80941Smrg
4870b8e80941Smrgstatic inline void
4871b8e80941Smrgunpack_int_r_uint32(const void *void_src, GLuint dst[4])
4872b8e80941Smrg{
4873b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
4874b8e80941Smrg            uint32_t r = src[0];
4875b8e80941Smrg
4876b8e80941Smrg
4877b8e80941Smrg         dst[0] = r;
4878b8e80941Smrg
4879b8e80941Smrg         dst[1] = 0;
4880b8e80941Smrg
4881b8e80941Smrg         dst[2] = 0;
4882b8e80941Smrg
4883b8e80941Smrg         dst[3] = 1;
4884b8e80941Smrg}
4885b8e80941Smrg
4886b8e80941Smrgstatic inline void
4887b8e80941Smrgunpack_int_r_sint8(const void *void_src, GLuint dst[4])
4888b8e80941Smrg{
4889b8e80941Smrg   int8_t *src = (int8_t *)void_src;
4890b8e80941Smrg            int8_t r = src[0];
4891b8e80941Smrg
4892b8e80941Smrg
4893b8e80941Smrg         dst[0] = r;
4894b8e80941Smrg
4895b8e80941Smrg         dst[1] = 0;
4896b8e80941Smrg
4897b8e80941Smrg         dst[2] = 0;
4898b8e80941Smrg
4899b8e80941Smrg         dst[3] = 1;
4900b8e80941Smrg}
4901b8e80941Smrg
4902b8e80941Smrgstatic inline void
4903b8e80941Smrgunpack_int_r_sint16(const void *void_src, GLuint dst[4])
4904b8e80941Smrg{
4905b8e80941Smrg   int16_t *src = (int16_t *)void_src;
4906b8e80941Smrg            int16_t r = src[0];
4907b8e80941Smrg
4908b8e80941Smrg
4909b8e80941Smrg         dst[0] = r;
4910b8e80941Smrg
4911b8e80941Smrg         dst[1] = 0;
4912b8e80941Smrg
4913b8e80941Smrg         dst[2] = 0;
4914b8e80941Smrg
4915b8e80941Smrg         dst[3] = 1;
4916b8e80941Smrg}
4917b8e80941Smrg
4918b8e80941Smrgstatic inline void
4919b8e80941Smrgunpack_int_r_sint32(const void *void_src, GLuint dst[4])
4920b8e80941Smrg{
4921b8e80941Smrg   int32_t *src = (int32_t *)void_src;
4922b8e80941Smrg            int32_t r = src[0];
4923b8e80941Smrg
4924b8e80941Smrg
4925b8e80941Smrg         dst[0] = r;
4926b8e80941Smrg
4927b8e80941Smrg         dst[1] = 0;
4928b8e80941Smrg
4929b8e80941Smrg         dst[2] = 0;
4930b8e80941Smrg
4931b8e80941Smrg         dst[3] = 1;
4932b8e80941Smrg}
4933b8e80941Smrg
4934b8e80941Smrgstatic inline void
4935b8e80941Smrgunpack_int_rg_uint8(const void *void_src, GLuint dst[4])
4936b8e80941Smrg{
4937b8e80941Smrg   uint8_t *src = (uint8_t *)void_src;
4938b8e80941Smrg            uint8_t r = src[0];
4939b8e80941Smrg            uint8_t g = src[1];
4940b8e80941Smrg
4941b8e80941Smrg
4942b8e80941Smrg         dst[0] = r;
4943b8e80941Smrg
4944b8e80941Smrg         dst[1] = g;
4945b8e80941Smrg
4946b8e80941Smrg         dst[2] = 0;
4947b8e80941Smrg
4948b8e80941Smrg         dst[3] = 1;
4949b8e80941Smrg}
4950b8e80941Smrg
4951b8e80941Smrgstatic inline void
4952b8e80941Smrgunpack_int_rg_uint16(const void *void_src, GLuint dst[4])
4953b8e80941Smrg{
4954b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
4955b8e80941Smrg            uint16_t r = src[0];
4956b8e80941Smrg            uint16_t g = src[1];
4957b8e80941Smrg
4958b8e80941Smrg
4959b8e80941Smrg         dst[0] = r;
4960b8e80941Smrg
4961b8e80941Smrg         dst[1] = g;
4962b8e80941Smrg
4963b8e80941Smrg         dst[2] = 0;
4964b8e80941Smrg
4965b8e80941Smrg         dst[3] = 1;
4966b8e80941Smrg}
4967b8e80941Smrg
4968b8e80941Smrgstatic inline void
4969b8e80941Smrgunpack_int_rg_uint32(const void *void_src, GLuint dst[4])
4970b8e80941Smrg{
4971b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
4972b8e80941Smrg            uint32_t r = src[0];
4973b8e80941Smrg            uint32_t g = src[1];
4974b8e80941Smrg
4975b8e80941Smrg
4976b8e80941Smrg         dst[0] = r;
4977b8e80941Smrg
4978b8e80941Smrg         dst[1] = g;
4979b8e80941Smrg
4980b8e80941Smrg         dst[2] = 0;
4981b8e80941Smrg
4982b8e80941Smrg         dst[3] = 1;
4983b8e80941Smrg}
4984b8e80941Smrg
4985b8e80941Smrgstatic inline void
4986b8e80941Smrgunpack_int_rg_sint8(const void *void_src, GLuint dst[4])
4987b8e80941Smrg{
4988b8e80941Smrg   int8_t *src = (int8_t *)void_src;
4989b8e80941Smrg            int8_t r = src[0];
4990b8e80941Smrg            int8_t g = src[1];
4991b8e80941Smrg
4992b8e80941Smrg
4993b8e80941Smrg         dst[0] = r;
4994b8e80941Smrg
4995b8e80941Smrg         dst[1] = g;
4996b8e80941Smrg
4997b8e80941Smrg         dst[2] = 0;
4998b8e80941Smrg
4999b8e80941Smrg         dst[3] = 1;
5000b8e80941Smrg}
5001b8e80941Smrg
5002b8e80941Smrgstatic inline void
5003b8e80941Smrgunpack_int_rg_sint16(const void *void_src, GLuint dst[4])
5004b8e80941Smrg{
5005b8e80941Smrg   int16_t *src = (int16_t *)void_src;
5006b8e80941Smrg            int16_t r = src[0];
5007b8e80941Smrg            int16_t g = src[1];
5008b8e80941Smrg
5009b8e80941Smrg
5010b8e80941Smrg         dst[0] = r;
5011b8e80941Smrg
5012b8e80941Smrg         dst[1] = g;
5013b8e80941Smrg
5014b8e80941Smrg         dst[2] = 0;
5015b8e80941Smrg
5016b8e80941Smrg         dst[3] = 1;
5017b8e80941Smrg}
5018b8e80941Smrg
5019b8e80941Smrgstatic inline void
5020b8e80941Smrgunpack_int_rg_sint32(const void *void_src, GLuint dst[4])
5021b8e80941Smrg{
5022b8e80941Smrg   int32_t *src = (int32_t *)void_src;
5023b8e80941Smrg            int32_t r = src[0];
5024b8e80941Smrg            int32_t g = src[1];
5025b8e80941Smrg
5026b8e80941Smrg
5027b8e80941Smrg         dst[0] = r;
5028b8e80941Smrg
5029b8e80941Smrg         dst[1] = g;
5030b8e80941Smrg
5031b8e80941Smrg         dst[2] = 0;
5032b8e80941Smrg
5033b8e80941Smrg         dst[3] = 1;
5034b8e80941Smrg}
5035b8e80941Smrg
5036b8e80941Smrgstatic inline void
5037b8e80941Smrgunpack_int_rgb_uint8(const void *void_src, GLuint dst[4])
5038b8e80941Smrg{
5039b8e80941Smrg   uint8_t *src = (uint8_t *)void_src;
5040b8e80941Smrg            uint8_t r = src[0];
5041b8e80941Smrg            uint8_t g = src[1];
5042b8e80941Smrg            uint8_t b = src[2];
5043b8e80941Smrg
5044b8e80941Smrg
5045b8e80941Smrg         dst[0] = r;
5046b8e80941Smrg
5047b8e80941Smrg         dst[1] = g;
5048b8e80941Smrg
5049b8e80941Smrg         dst[2] = b;
5050b8e80941Smrg
5051b8e80941Smrg         dst[3] = 1;
5052b8e80941Smrg}
5053b8e80941Smrg
5054b8e80941Smrgstatic inline void
5055b8e80941Smrgunpack_int_rgb_uint16(const void *void_src, GLuint dst[4])
5056b8e80941Smrg{
5057b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
5058b8e80941Smrg            uint16_t r = src[0];
5059b8e80941Smrg            uint16_t g = src[1];
5060b8e80941Smrg            uint16_t b = src[2];
5061b8e80941Smrg
5062b8e80941Smrg
5063b8e80941Smrg         dst[0] = r;
5064b8e80941Smrg
5065b8e80941Smrg         dst[1] = g;
5066b8e80941Smrg
5067b8e80941Smrg         dst[2] = b;
5068b8e80941Smrg
5069b8e80941Smrg         dst[3] = 1;
5070b8e80941Smrg}
5071b8e80941Smrg
5072b8e80941Smrgstatic inline void
5073b8e80941Smrgunpack_int_rgb_uint32(const void *void_src, GLuint dst[4])
5074b8e80941Smrg{
5075b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
5076b8e80941Smrg            uint32_t r = src[0];
5077b8e80941Smrg            uint32_t g = src[1];
5078b8e80941Smrg            uint32_t b = src[2];
5079b8e80941Smrg
5080b8e80941Smrg
5081b8e80941Smrg         dst[0] = r;
5082b8e80941Smrg
5083b8e80941Smrg         dst[1] = g;
5084b8e80941Smrg
5085b8e80941Smrg         dst[2] = b;
5086b8e80941Smrg
5087b8e80941Smrg         dst[3] = 1;
5088b8e80941Smrg}
5089b8e80941Smrg
5090b8e80941Smrgstatic inline void
5091b8e80941Smrgunpack_int_rgb_sint8(const void *void_src, GLuint dst[4])
5092b8e80941Smrg{
5093b8e80941Smrg   int8_t *src = (int8_t *)void_src;
5094b8e80941Smrg            int8_t r = src[0];
5095b8e80941Smrg            int8_t g = src[1];
5096b8e80941Smrg            int8_t b = src[2];
5097b8e80941Smrg
5098b8e80941Smrg
5099b8e80941Smrg         dst[0] = r;
5100b8e80941Smrg
5101b8e80941Smrg         dst[1] = g;
5102b8e80941Smrg
5103b8e80941Smrg         dst[2] = b;
5104b8e80941Smrg
5105b8e80941Smrg         dst[3] = 1;
5106b8e80941Smrg}
5107b8e80941Smrg
5108b8e80941Smrgstatic inline void
5109b8e80941Smrgunpack_int_rgb_sint16(const void *void_src, GLuint dst[4])
5110b8e80941Smrg{
5111b8e80941Smrg   int16_t *src = (int16_t *)void_src;
5112b8e80941Smrg            int16_t r = src[0];
5113b8e80941Smrg            int16_t g = src[1];
5114b8e80941Smrg            int16_t b = src[2];
5115b8e80941Smrg
5116b8e80941Smrg
5117b8e80941Smrg         dst[0] = r;
5118b8e80941Smrg
5119b8e80941Smrg         dst[1] = g;
5120b8e80941Smrg
5121b8e80941Smrg         dst[2] = b;
5122b8e80941Smrg
5123b8e80941Smrg         dst[3] = 1;
5124b8e80941Smrg}
5125b8e80941Smrg
5126b8e80941Smrgstatic inline void
5127b8e80941Smrgunpack_int_rgb_sint32(const void *void_src, GLuint dst[4])
5128b8e80941Smrg{
5129b8e80941Smrg   int32_t *src = (int32_t *)void_src;
5130b8e80941Smrg            int32_t r = src[0];
5131b8e80941Smrg            int32_t g = src[1];
5132b8e80941Smrg            int32_t b = src[2];
5133b8e80941Smrg
5134b8e80941Smrg
5135b8e80941Smrg         dst[0] = r;
5136b8e80941Smrg
5137b8e80941Smrg         dst[1] = g;
5138b8e80941Smrg
5139b8e80941Smrg         dst[2] = b;
5140b8e80941Smrg
5141b8e80941Smrg         dst[3] = 1;
5142b8e80941Smrg}
5143b8e80941Smrg
5144b8e80941Smrgstatic inline void
5145b8e80941Smrgunpack_int_rgba_uint8(const void *void_src, GLuint dst[4])
5146b8e80941Smrg{
5147b8e80941Smrg   uint8_t *src = (uint8_t *)void_src;
5148b8e80941Smrg            uint8_t r = src[0];
5149b8e80941Smrg            uint8_t g = src[1];
5150b8e80941Smrg            uint8_t b = src[2];
5151b8e80941Smrg            uint8_t a = src[3];
5152b8e80941Smrg
5153b8e80941Smrg
5154b8e80941Smrg         dst[0] = r;
5155b8e80941Smrg
5156b8e80941Smrg         dst[1] = g;
5157b8e80941Smrg
5158b8e80941Smrg         dst[2] = b;
5159b8e80941Smrg
5160b8e80941Smrg         dst[3] = a;
5161b8e80941Smrg}
5162b8e80941Smrg
5163b8e80941Smrgstatic inline void
5164b8e80941Smrgunpack_int_rgba_uint16(const void *void_src, GLuint dst[4])
5165b8e80941Smrg{
5166b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
5167b8e80941Smrg            uint16_t r = src[0];
5168b8e80941Smrg            uint16_t g = src[1];
5169b8e80941Smrg            uint16_t b = src[2];
5170b8e80941Smrg            uint16_t a = src[3];
5171b8e80941Smrg
5172b8e80941Smrg
5173b8e80941Smrg         dst[0] = r;
5174b8e80941Smrg
5175b8e80941Smrg         dst[1] = g;
5176b8e80941Smrg
5177b8e80941Smrg         dst[2] = b;
5178b8e80941Smrg
5179b8e80941Smrg         dst[3] = a;
5180b8e80941Smrg}
5181b8e80941Smrg
5182b8e80941Smrgstatic inline void
5183b8e80941Smrgunpack_int_rgba_uint32(const void *void_src, GLuint dst[4])
5184b8e80941Smrg{
5185b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
5186b8e80941Smrg            uint32_t r = src[0];
5187b8e80941Smrg            uint32_t g = src[1];
5188b8e80941Smrg            uint32_t b = src[2];
5189b8e80941Smrg            uint32_t a = src[3];
5190b8e80941Smrg
5191b8e80941Smrg
5192b8e80941Smrg         dst[0] = r;
5193b8e80941Smrg
5194b8e80941Smrg         dst[1] = g;
5195b8e80941Smrg
5196b8e80941Smrg         dst[2] = b;
5197b8e80941Smrg
5198b8e80941Smrg         dst[3] = a;
5199b8e80941Smrg}
5200b8e80941Smrg
5201b8e80941Smrgstatic inline void
5202b8e80941Smrgunpack_int_rgba_sint8(const void *void_src, GLuint dst[4])
5203b8e80941Smrg{
5204b8e80941Smrg   int8_t *src = (int8_t *)void_src;
5205b8e80941Smrg            int8_t r = src[0];
5206b8e80941Smrg            int8_t g = src[1];
5207b8e80941Smrg            int8_t b = src[2];
5208b8e80941Smrg            int8_t a = src[3];
5209b8e80941Smrg
5210b8e80941Smrg
5211b8e80941Smrg         dst[0] = r;
5212b8e80941Smrg
5213b8e80941Smrg         dst[1] = g;
5214b8e80941Smrg
5215b8e80941Smrg         dst[2] = b;
5216b8e80941Smrg
5217b8e80941Smrg         dst[3] = a;
5218b8e80941Smrg}
5219b8e80941Smrg
5220b8e80941Smrgstatic inline void
5221b8e80941Smrgunpack_int_rgba_sint16(const void *void_src, GLuint dst[4])
5222b8e80941Smrg{
5223b8e80941Smrg   int16_t *src = (int16_t *)void_src;
5224b8e80941Smrg            int16_t r = src[0];
5225b8e80941Smrg            int16_t g = src[1];
5226b8e80941Smrg            int16_t b = src[2];
5227b8e80941Smrg            int16_t a = src[3];
5228b8e80941Smrg
5229b8e80941Smrg
5230b8e80941Smrg         dst[0] = r;
5231b8e80941Smrg
5232b8e80941Smrg         dst[1] = g;
5233b8e80941Smrg
5234b8e80941Smrg         dst[2] = b;
5235b8e80941Smrg
5236b8e80941Smrg         dst[3] = a;
5237b8e80941Smrg}
5238b8e80941Smrg
5239b8e80941Smrgstatic inline void
5240b8e80941Smrgunpack_int_rgba_sint32(const void *void_src, GLuint dst[4])
5241b8e80941Smrg{
5242b8e80941Smrg   int32_t *src = (int32_t *)void_src;
5243b8e80941Smrg            int32_t r = src[0];
5244b8e80941Smrg            int32_t g = src[1];
5245b8e80941Smrg            int32_t b = src[2];
5246b8e80941Smrg            int32_t a = src[3];
5247b8e80941Smrg
5248b8e80941Smrg
5249b8e80941Smrg         dst[0] = r;
5250b8e80941Smrg
5251b8e80941Smrg         dst[1] = g;
5252b8e80941Smrg
5253b8e80941Smrg         dst[2] = b;
5254b8e80941Smrg
5255b8e80941Smrg         dst[3] = a;
5256b8e80941Smrg}
5257b8e80941Smrg
5258b8e80941Smrgstatic inline void
5259b8e80941Smrgunpack_int_rgbx_uint8(const void *void_src, GLuint dst[4])
5260b8e80941Smrg{
5261b8e80941Smrg   uint8_t *src = (uint8_t *)void_src;
5262b8e80941Smrg            uint8_t r = src[0];
5263b8e80941Smrg            uint8_t g = src[1];
5264b8e80941Smrg            uint8_t b = src[2];
5265b8e80941Smrg
5266b8e80941Smrg
5267b8e80941Smrg         dst[0] = r;
5268b8e80941Smrg
5269b8e80941Smrg         dst[1] = g;
5270b8e80941Smrg
5271b8e80941Smrg         dst[2] = b;
5272b8e80941Smrg
5273b8e80941Smrg         dst[3] = 1;
5274b8e80941Smrg}
5275b8e80941Smrg
5276b8e80941Smrgstatic inline void
5277b8e80941Smrgunpack_int_rgbx_uint16(const void *void_src, GLuint dst[4])
5278b8e80941Smrg{
5279b8e80941Smrg   uint16_t *src = (uint16_t *)void_src;
5280b8e80941Smrg            uint16_t r = src[0];
5281b8e80941Smrg            uint16_t g = src[1];
5282b8e80941Smrg            uint16_t b = src[2];
5283b8e80941Smrg
5284b8e80941Smrg
5285b8e80941Smrg         dst[0] = r;
5286b8e80941Smrg
5287b8e80941Smrg         dst[1] = g;
5288b8e80941Smrg
5289b8e80941Smrg         dst[2] = b;
5290b8e80941Smrg
5291b8e80941Smrg         dst[3] = 1;
5292b8e80941Smrg}
5293b8e80941Smrg
5294b8e80941Smrgstatic inline void
5295b8e80941Smrgunpack_int_rgbx_uint32(const void *void_src, GLuint dst[4])
5296b8e80941Smrg{
5297b8e80941Smrg   uint32_t *src = (uint32_t *)void_src;
5298b8e80941Smrg            uint32_t r = src[0];
5299b8e80941Smrg            uint32_t g = src[1];
5300b8e80941Smrg            uint32_t b = src[2];
5301b8e80941Smrg
5302b8e80941Smrg
5303b8e80941Smrg         dst[0] = r;
5304b8e80941Smrg
5305b8e80941Smrg         dst[1] = g;
5306b8e80941Smrg
5307b8e80941Smrg         dst[2] = b;
5308b8e80941Smrg
5309b8e80941Smrg         dst[3] = 1;
5310b8e80941Smrg}
5311b8e80941Smrg
5312b8e80941Smrgstatic inline void
5313b8e80941Smrgunpack_int_rgbx_sint8(const void *void_src, GLuint dst[4])
5314b8e80941Smrg{
5315b8e80941Smrg   int8_t *src = (int8_t *)void_src;
5316b8e80941Smrg            int8_t r = src[0];
5317b8e80941Smrg            int8_t g = src[1];
5318b8e80941Smrg            int8_t b = src[2];
5319b8e80941Smrg
5320b8e80941Smrg
5321b8e80941Smrg         dst[0] = r;
5322b8e80941Smrg
5323b8e80941Smrg         dst[1] = g;
5324b8e80941Smrg
5325b8e80941Smrg         dst[2] = b;
5326b8e80941Smrg
5327b8e80941Smrg         dst[3] = 1;
5328b8e80941Smrg}
5329b8e80941Smrg
5330b8e80941Smrgstatic inline void
5331b8e80941Smrgunpack_int_rgbx_sint16(const void *void_src, GLuint dst[4])
5332b8e80941Smrg{
5333b8e80941Smrg   int16_t *src = (int16_t *)void_src;
5334b8e80941Smrg            int16_t r = src[0];
5335b8e80941Smrg            int16_t g = src[1];
5336b8e80941Smrg            int16_t b = src[2];
5337b8e80941Smrg
5338b8e80941Smrg
5339b8e80941Smrg         dst[0] = r;
5340b8e80941Smrg
5341b8e80941Smrg         dst[1] = g;
5342b8e80941Smrg
5343b8e80941Smrg         dst[2] = b;
5344b8e80941Smrg
5345b8e80941Smrg         dst[3] = 1;
5346b8e80941Smrg}
5347b8e80941Smrg
5348b8e80941Smrgstatic inline void
5349b8e80941Smrgunpack_int_rgbx_sint32(const void *void_src, GLuint dst[4])
5350b8e80941Smrg{
5351b8e80941Smrg   int32_t *src = (int32_t *)void_src;
5352b8e80941Smrg            int32_t r = src[0];
5353b8e80941Smrg            int32_t g = src[1];
5354b8e80941Smrg            int32_t b = src[2];
5355b8e80941Smrg
5356b8e80941Smrg
5357b8e80941Smrg         dst[0] = r;
5358b8e80941Smrg
5359b8e80941Smrg         dst[1] = g;
5360b8e80941Smrg
5361b8e80941Smrg         dst[2] = b;
5362b8e80941Smrg
5363b8e80941Smrg         dst[3] = 1;
5364b8e80941Smrg}
5365b8e80941Smrg
5366b8e80941Smrg
5367b8e80941Smrgvoid
5368b8e80941Smrg_mesa_unpack_rgba_row(mesa_format format, GLuint n,
5369b8e80941Smrg                      const void *src, GLfloat dst[][4])
5370b8e80941Smrg{
5371b8e80941Smrg   GLubyte *s = (GLubyte *)src;
5372b8e80941Smrg   GLuint i;
5373b8e80941Smrg
5374b8e80941Smrg   switch (format) {
5375b8e80941Smrg   case MESA_FORMAT_A8B8G8R8_UNORM:
5376b8e80941Smrg      for (i = 0; i < n; ++i) {
5377b8e80941Smrg         unpack_float_a8b8g8r8_unorm(s, dst[i]);
5378b8e80941Smrg         s += 4;
5379b8e80941Smrg      }
5380b8e80941Smrg      break;
5381b8e80941Smrg   case MESA_FORMAT_X8B8G8R8_UNORM:
5382b8e80941Smrg      for (i = 0; i < n; ++i) {
5383b8e80941Smrg         unpack_float_x8b8g8r8_unorm(s, dst[i]);
5384b8e80941Smrg         s += 4;
5385b8e80941Smrg      }
5386b8e80941Smrg      break;
5387b8e80941Smrg   case MESA_FORMAT_R8G8B8A8_UNORM:
5388b8e80941Smrg      for (i = 0; i < n; ++i) {
5389b8e80941Smrg         unpack_float_r8g8b8a8_unorm(s, dst[i]);
5390b8e80941Smrg         s += 4;
5391b8e80941Smrg      }
5392b8e80941Smrg      break;
5393b8e80941Smrg   case MESA_FORMAT_R8G8B8X8_UNORM:
5394b8e80941Smrg      for (i = 0; i < n; ++i) {
5395b8e80941Smrg         unpack_float_r8g8b8x8_unorm(s, dst[i]);
5396b8e80941Smrg         s += 4;
5397b8e80941Smrg      }
5398b8e80941Smrg      break;
5399b8e80941Smrg   case MESA_FORMAT_B8G8R8A8_UNORM:
5400b8e80941Smrg      for (i = 0; i < n; ++i) {
5401b8e80941Smrg         unpack_float_b8g8r8a8_unorm(s, dst[i]);
5402b8e80941Smrg         s += 4;
5403b8e80941Smrg      }
5404b8e80941Smrg      break;
5405b8e80941Smrg   case MESA_FORMAT_B8G8R8X8_UNORM:
5406b8e80941Smrg      for (i = 0; i < n; ++i) {
5407b8e80941Smrg         unpack_float_b8g8r8x8_unorm(s, dst[i]);
5408b8e80941Smrg         s += 4;
5409b8e80941Smrg      }
5410b8e80941Smrg      break;
5411b8e80941Smrg   case MESA_FORMAT_A8R8G8B8_UNORM:
5412b8e80941Smrg      for (i = 0; i < n; ++i) {
5413b8e80941Smrg         unpack_float_a8r8g8b8_unorm(s, dst[i]);
5414b8e80941Smrg         s += 4;
5415b8e80941Smrg      }
5416b8e80941Smrg      break;
5417b8e80941Smrg   case MESA_FORMAT_X8R8G8B8_UNORM:
5418b8e80941Smrg      for (i = 0; i < n; ++i) {
5419b8e80941Smrg         unpack_float_x8r8g8b8_unorm(s, dst[i]);
5420b8e80941Smrg         s += 4;
5421b8e80941Smrg      }
5422b8e80941Smrg      break;
5423b8e80941Smrg   case MESA_FORMAT_L16A16_UNORM:
5424b8e80941Smrg      for (i = 0; i < n; ++i) {
5425b8e80941Smrg         unpack_float_l16a16_unorm(s, dst[i]);
5426b8e80941Smrg         s += 4;
5427b8e80941Smrg      }
5428b8e80941Smrg      break;
5429b8e80941Smrg   case MESA_FORMAT_A16L16_UNORM:
5430b8e80941Smrg      for (i = 0; i < n; ++i) {
5431b8e80941Smrg         unpack_float_a16l16_unorm(s, dst[i]);
5432b8e80941Smrg         s += 4;
5433b8e80941Smrg      }
5434b8e80941Smrg      break;
5435b8e80941Smrg   case MESA_FORMAT_B5G6R5_UNORM:
5436b8e80941Smrg      for (i = 0; i < n; ++i) {
5437b8e80941Smrg         unpack_float_b5g6r5_unorm(s, dst[i]);
5438b8e80941Smrg         s += 2;
5439b8e80941Smrg      }
5440b8e80941Smrg      break;
5441b8e80941Smrg   case MESA_FORMAT_R5G6B5_UNORM:
5442b8e80941Smrg      for (i = 0; i < n; ++i) {
5443b8e80941Smrg         unpack_float_r5g6b5_unorm(s, dst[i]);
5444b8e80941Smrg         s += 2;
5445b8e80941Smrg      }
5446b8e80941Smrg      break;
5447b8e80941Smrg   case MESA_FORMAT_B4G4R4A4_UNORM:
5448b8e80941Smrg      for (i = 0; i < n; ++i) {
5449b8e80941Smrg         unpack_float_b4g4r4a4_unorm(s, dst[i]);
5450b8e80941Smrg         s += 2;
5451b8e80941Smrg      }
5452b8e80941Smrg      break;
5453b8e80941Smrg   case MESA_FORMAT_B4G4R4X4_UNORM:
5454b8e80941Smrg      for (i = 0; i < n; ++i) {
5455b8e80941Smrg         unpack_float_b4g4r4x4_unorm(s, dst[i]);
5456b8e80941Smrg         s += 2;
5457b8e80941Smrg      }
5458b8e80941Smrg      break;
5459b8e80941Smrg   case MESA_FORMAT_A4R4G4B4_UNORM:
5460b8e80941Smrg      for (i = 0; i < n; ++i) {
5461b8e80941Smrg         unpack_float_a4r4g4b4_unorm(s, dst[i]);
5462b8e80941Smrg         s += 2;
5463b8e80941Smrg      }
5464b8e80941Smrg      break;
5465b8e80941Smrg   case MESA_FORMAT_A1B5G5R5_UNORM:
5466b8e80941Smrg      for (i = 0; i < n; ++i) {
5467b8e80941Smrg         unpack_float_a1b5g5r5_unorm(s, dst[i]);
5468b8e80941Smrg         s += 2;
5469b8e80941Smrg      }
5470b8e80941Smrg      break;
5471b8e80941Smrg   case MESA_FORMAT_X1B5G5R5_UNORM:
5472b8e80941Smrg      for (i = 0; i < n; ++i) {
5473b8e80941Smrg         unpack_float_x1b5g5r5_unorm(s, dst[i]);
5474b8e80941Smrg         s += 2;
5475b8e80941Smrg      }
5476b8e80941Smrg      break;
5477b8e80941Smrg   case MESA_FORMAT_B5G5R5A1_UNORM:
5478b8e80941Smrg      for (i = 0; i < n; ++i) {
5479b8e80941Smrg         unpack_float_b5g5r5a1_unorm(s, dst[i]);
5480b8e80941Smrg         s += 2;
5481b8e80941Smrg      }
5482b8e80941Smrg      break;
5483b8e80941Smrg   case MESA_FORMAT_B5G5R5X1_UNORM:
5484b8e80941Smrg      for (i = 0; i < n; ++i) {
5485b8e80941Smrg         unpack_float_b5g5r5x1_unorm(s, dst[i]);
5486b8e80941Smrg         s += 2;
5487b8e80941Smrg      }
5488b8e80941Smrg      break;
5489b8e80941Smrg   case MESA_FORMAT_A1R5G5B5_UNORM:
5490b8e80941Smrg      for (i = 0; i < n; ++i) {
5491b8e80941Smrg         unpack_float_a1r5g5b5_unorm(s, dst[i]);
5492b8e80941Smrg         s += 2;
5493b8e80941Smrg      }
5494b8e80941Smrg      break;
5495b8e80941Smrg   case MESA_FORMAT_L8A8_UNORM:
5496b8e80941Smrg      for (i = 0; i < n; ++i) {
5497b8e80941Smrg         unpack_float_l8a8_unorm(s, dst[i]);
5498b8e80941Smrg         s += 2;
5499b8e80941Smrg      }
5500b8e80941Smrg      break;
5501b8e80941Smrg   case MESA_FORMAT_A8L8_UNORM:
5502b8e80941Smrg      for (i = 0; i < n; ++i) {
5503b8e80941Smrg         unpack_float_a8l8_unorm(s, dst[i]);
5504b8e80941Smrg         s += 2;
5505b8e80941Smrg      }
5506b8e80941Smrg      break;
5507b8e80941Smrg   case MESA_FORMAT_R8G8_UNORM:
5508b8e80941Smrg      for (i = 0; i < n; ++i) {
5509b8e80941Smrg         unpack_float_r8g8_unorm(s, dst[i]);
5510b8e80941Smrg         s += 2;
5511b8e80941Smrg      }
5512b8e80941Smrg      break;
5513b8e80941Smrg   case MESA_FORMAT_G8R8_UNORM:
5514b8e80941Smrg      for (i = 0; i < n; ++i) {
5515b8e80941Smrg         unpack_float_g8r8_unorm(s, dst[i]);
5516b8e80941Smrg         s += 2;
5517b8e80941Smrg      }
5518b8e80941Smrg      break;
5519b8e80941Smrg   case MESA_FORMAT_L4A4_UNORM:
5520b8e80941Smrg      for (i = 0; i < n; ++i) {
5521b8e80941Smrg         unpack_float_l4a4_unorm(s, dst[i]);
5522b8e80941Smrg         s += 1;
5523b8e80941Smrg      }
5524b8e80941Smrg      break;
5525b8e80941Smrg   case MESA_FORMAT_B2G3R3_UNORM:
5526b8e80941Smrg      for (i = 0; i < n; ++i) {
5527b8e80941Smrg         unpack_float_b2g3r3_unorm(s, dst[i]);
5528b8e80941Smrg         s += 1;
5529b8e80941Smrg      }
5530b8e80941Smrg      break;
5531b8e80941Smrg   case MESA_FORMAT_R16G16_UNORM:
5532b8e80941Smrg      for (i = 0; i < n; ++i) {
5533b8e80941Smrg         unpack_float_r16g16_unorm(s, dst[i]);
5534b8e80941Smrg         s += 4;
5535b8e80941Smrg      }
5536b8e80941Smrg      break;
5537b8e80941Smrg   case MESA_FORMAT_G16R16_UNORM:
5538b8e80941Smrg      for (i = 0; i < n; ++i) {
5539b8e80941Smrg         unpack_float_g16r16_unorm(s, dst[i]);
5540b8e80941Smrg         s += 4;
5541b8e80941Smrg      }
5542b8e80941Smrg      break;
5543b8e80941Smrg   case MESA_FORMAT_B10G10R10A2_UNORM:
5544b8e80941Smrg      for (i = 0; i < n; ++i) {
5545b8e80941Smrg         unpack_float_b10g10r10a2_unorm(s, dst[i]);
5546b8e80941Smrg         s += 4;
5547b8e80941Smrg      }
5548b8e80941Smrg      break;
5549b8e80941Smrg   case MESA_FORMAT_B10G10R10X2_UNORM:
5550b8e80941Smrg      for (i = 0; i < n; ++i) {
5551b8e80941Smrg         unpack_float_b10g10r10x2_unorm(s, dst[i]);
5552b8e80941Smrg         s += 4;
5553b8e80941Smrg      }
5554b8e80941Smrg      break;
5555b8e80941Smrg   case MESA_FORMAT_R10G10B10A2_UNORM:
5556b8e80941Smrg      for (i = 0; i < n; ++i) {
5557b8e80941Smrg         unpack_float_r10g10b10a2_unorm(s, dst[i]);
5558b8e80941Smrg         s += 4;
5559b8e80941Smrg      }
5560b8e80941Smrg      break;
5561b8e80941Smrg   case MESA_FORMAT_R10G10B10X2_UNORM:
5562b8e80941Smrg      for (i = 0; i < n; ++i) {
5563b8e80941Smrg         unpack_float_r10g10b10x2_unorm(s, dst[i]);
5564b8e80941Smrg         s += 4;
5565b8e80941Smrg      }
5566b8e80941Smrg      break;
5567b8e80941Smrg   case MESA_FORMAT_R3G3B2_UNORM:
5568b8e80941Smrg      for (i = 0; i < n; ++i) {
5569b8e80941Smrg         unpack_float_r3g3b2_unorm(s, dst[i]);
5570b8e80941Smrg         s += 1;
5571b8e80941Smrg      }
5572b8e80941Smrg      break;
5573b8e80941Smrg   case MESA_FORMAT_A4B4G4R4_UNORM:
5574b8e80941Smrg      for (i = 0; i < n; ++i) {
5575b8e80941Smrg         unpack_float_a4b4g4r4_unorm(s, dst[i]);
5576b8e80941Smrg         s += 2;
5577b8e80941Smrg      }
5578b8e80941Smrg      break;
5579b8e80941Smrg   case MESA_FORMAT_R4G4B4A4_UNORM:
5580b8e80941Smrg      for (i = 0; i < n; ++i) {
5581b8e80941Smrg         unpack_float_r4g4b4a4_unorm(s, dst[i]);
5582b8e80941Smrg         s += 2;
5583b8e80941Smrg      }
5584b8e80941Smrg      break;
5585b8e80941Smrg   case MESA_FORMAT_R5G5B5A1_UNORM:
5586b8e80941Smrg      for (i = 0; i < n; ++i) {
5587b8e80941Smrg         unpack_float_r5g5b5a1_unorm(s, dst[i]);
5588b8e80941Smrg         s += 2;
5589b8e80941Smrg      }
5590b8e80941Smrg      break;
5591b8e80941Smrg   case MESA_FORMAT_A2B10G10R10_UNORM:
5592b8e80941Smrg      for (i = 0; i < n; ++i) {
5593b8e80941Smrg         unpack_float_a2b10g10r10_unorm(s, dst[i]);
5594b8e80941Smrg         s += 4;
5595b8e80941Smrg      }
5596b8e80941Smrg      break;
5597b8e80941Smrg   case MESA_FORMAT_A2R10G10B10_UNORM:
5598b8e80941Smrg      for (i = 0; i < n; ++i) {
5599b8e80941Smrg         unpack_float_a2r10g10b10_unorm(s, dst[i]);
5600b8e80941Smrg         s += 4;
5601b8e80941Smrg      }
5602b8e80941Smrg      break;
5603b8e80941Smrg   case MESA_FORMAT_A_UNORM8:
5604b8e80941Smrg      for (i = 0; i < n; ++i) {
5605b8e80941Smrg         unpack_float_a_unorm8(s, dst[i]);
5606b8e80941Smrg         s += 1;
5607b8e80941Smrg      }
5608b8e80941Smrg      break;
5609b8e80941Smrg   case MESA_FORMAT_A_UNORM16:
5610b8e80941Smrg      for (i = 0; i < n; ++i) {
5611b8e80941Smrg         unpack_float_a_unorm16(s, dst[i]);
5612b8e80941Smrg         s += 2;
5613b8e80941Smrg      }
5614b8e80941Smrg      break;
5615b8e80941Smrg   case MESA_FORMAT_L_UNORM8:
5616b8e80941Smrg      for (i = 0; i < n; ++i) {
5617b8e80941Smrg         unpack_float_l_unorm8(s, dst[i]);
5618b8e80941Smrg         s += 1;
5619b8e80941Smrg      }
5620b8e80941Smrg      break;
5621b8e80941Smrg   case MESA_FORMAT_L_UNORM16:
5622b8e80941Smrg      for (i = 0; i < n; ++i) {
5623b8e80941Smrg         unpack_float_l_unorm16(s, dst[i]);
5624b8e80941Smrg         s += 2;
5625b8e80941Smrg      }
5626b8e80941Smrg      break;
5627b8e80941Smrg   case MESA_FORMAT_I_UNORM8:
5628b8e80941Smrg      for (i = 0; i < n; ++i) {
5629b8e80941Smrg         unpack_float_i_unorm8(s, dst[i]);
5630b8e80941Smrg         s += 1;
5631b8e80941Smrg      }
5632b8e80941Smrg      break;
5633b8e80941Smrg   case MESA_FORMAT_I_UNORM16:
5634b8e80941Smrg      for (i = 0; i < n; ++i) {
5635b8e80941Smrg         unpack_float_i_unorm16(s, dst[i]);
5636b8e80941Smrg         s += 2;
5637b8e80941Smrg      }
5638b8e80941Smrg      break;
5639b8e80941Smrg   case MESA_FORMAT_R_UNORM8:
5640b8e80941Smrg      for (i = 0; i < n; ++i) {
5641b8e80941Smrg         unpack_float_r_unorm8(s, dst[i]);
5642b8e80941Smrg         s += 1;
5643b8e80941Smrg      }
5644b8e80941Smrg      break;
5645b8e80941Smrg   case MESA_FORMAT_R_UNORM16:
5646b8e80941Smrg      for (i = 0; i < n; ++i) {
5647b8e80941Smrg         unpack_float_r_unorm16(s, dst[i]);
5648b8e80941Smrg         s += 2;
5649b8e80941Smrg      }
5650b8e80941Smrg      break;
5651b8e80941Smrg   case MESA_FORMAT_BGR_UNORM8:
5652b8e80941Smrg      for (i = 0; i < n; ++i) {
5653b8e80941Smrg         unpack_float_bgr_unorm8(s, dst[i]);
5654b8e80941Smrg         s += 3;
5655b8e80941Smrg      }
5656b8e80941Smrg      break;
5657b8e80941Smrg   case MESA_FORMAT_RGB_UNORM8:
5658b8e80941Smrg      for (i = 0; i < n; ++i) {
5659b8e80941Smrg         unpack_float_rgb_unorm8(s, dst[i]);
5660b8e80941Smrg         s += 3;
5661b8e80941Smrg      }
5662b8e80941Smrg      break;
5663b8e80941Smrg   case MESA_FORMAT_RGBA_UNORM16:
5664b8e80941Smrg      for (i = 0; i < n; ++i) {
5665b8e80941Smrg         unpack_float_rgba_unorm16(s, dst[i]);
5666b8e80941Smrg         s += 8;
5667b8e80941Smrg      }
5668b8e80941Smrg      break;
5669b8e80941Smrg   case MESA_FORMAT_RGBX_UNORM16:
5670b8e80941Smrg      for (i = 0; i < n; ++i) {
5671b8e80941Smrg         unpack_float_rgbx_unorm16(s, dst[i]);
5672b8e80941Smrg         s += 8;
5673b8e80941Smrg      }
5674b8e80941Smrg      break;
5675b8e80941Smrg   case MESA_FORMAT_A8B8G8R8_SNORM:
5676b8e80941Smrg      for (i = 0; i < n; ++i) {
5677b8e80941Smrg         unpack_float_a8b8g8r8_snorm(s, dst[i]);
5678b8e80941Smrg         s += 4;
5679b8e80941Smrg      }
5680b8e80941Smrg      break;
5681b8e80941Smrg   case MESA_FORMAT_X8B8G8R8_SNORM:
5682b8e80941Smrg      for (i = 0; i < n; ++i) {
5683b8e80941Smrg         unpack_float_x8b8g8r8_snorm(s, dst[i]);
5684b8e80941Smrg         s += 4;
5685b8e80941Smrg      }
5686b8e80941Smrg      break;
5687b8e80941Smrg   case MESA_FORMAT_R8G8B8A8_SNORM:
5688b8e80941Smrg      for (i = 0; i < n; ++i) {
5689b8e80941Smrg         unpack_float_r8g8b8a8_snorm(s, dst[i]);
5690b8e80941Smrg         s += 4;
5691b8e80941Smrg      }
5692b8e80941Smrg      break;
5693b8e80941Smrg   case MESA_FORMAT_R8G8B8X8_SNORM:
5694b8e80941Smrg      for (i = 0; i < n; ++i) {
5695b8e80941Smrg         unpack_float_r8g8b8x8_snorm(s, dst[i]);
5696b8e80941Smrg         s += 4;
5697b8e80941Smrg      }
5698b8e80941Smrg      break;
5699b8e80941Smrg   case MESA_FORMAT_R16G16_SNORM:
5700b8e80941Smrg      for (i = 0; i < n; ++i) {
5701b8e80941Smrg         unpack_float_r16g16_snorm(s, dst[i]);
5702b8e80941Smrg         s += 4;
5703b8e80941Smrg      }
5704b8e80941Smrg      break;
5705b8e80941Smrg   case MESA_FORMAT_G16R16_SNORM:
5706b8e80941Smrg      for (i = 0; i < n; ++i) {
5707b8e80941Smrg         unpack_float_g16r16_snorm(s, dst[i]);
5708b8e80941Smrg         s += 4;
5709b8e80941Smrg      }
5710b8e80941Smrg      break;
5711b8e80941Smrg   case MESA_FORMAT_R8G8_SNORM:
5712b8e80941Smrg      for (i = 0; i < n; ++i) {
5713b8e80941Smrg         unpack_float_r8g8_snorm(s, dst[i]);
5714b8e80941Smrg         s += 2;
5715b8e80941Smrg      }
5716b8e80941Smrg      break;
5717b8e80941Smrg   case MESA_FORMAT_G8R8_SNORM:
5718b8e80941Smrg      for (i = 0; i < n; ++i) {
5719b8e80941Smrg         unpack_float_g8r8_snorm(s, dst[i]);
5720b8e80941Smrg         s += 2;
5721b8e80941Smrg      }
5722b8e80941Smrg      break;
5723b8e80941Smrg   case MESA_FORMAT_L8A8_SNORM:
5724b8e80941Smrg      for (i = 0; i < n; ++i) {
5725b8e80941Smrg         unpack_float_l8a8_snorm(s, dst[i]);
5726b8e80941Smrg         s += 2;
5727b8e80941Smrg      }
5728b8e80941Smrg      break;
5729b8e80941Smrg   case MESA_FORMAT_A8L8_SNORM:
5730b8e80941Smrg      for (i = 0; i < n; ++i) {
5731b8e80941Smrg         unpack_float_a8l8_snorm(s, dst[i]);
5732b8e80941Smrg         s += 2;
5733b8e80941Smrg      }
5734b8e80941Smrg      break;
5735b8e80941Smrg   case MESA_FORMAT_A_SNORM8:
5736b8e80941Smrg      for (i = 0; i < n; ++i) {
5737b8e80941Smrg         unpack_float_a_snorm8(s, dst[i]);
5738b8e80941Smrg         s += 1;
5739b8e80941Smrg      }
5740b8e80941Smrg      break;
5741b8e80941Smrg   case MESA_FORMAT_A_SNORM16:
5742b8e80941Smrg      for (i = 0; i < n; ++i) {
5743b8e80941Smrg         unpack_float_a_snorm16(s, dst[i]);
5744b8e80941Smrg         s += 2;
5745b8e80941Smrg      }
5746b8e80941Smrg      break;
5747b8e80941Smrg   case MESA_FORMAT_L_SNORM8:
5748b8e80941Smrg      for (i = 0; i < n; ++i) {
5749b8e80941Smrg         unpack_float_l_snorm8(s, dst[i]);
5750b8e80941Smrg         s += 1;
5751b8e80941Smrg      }
5752b8e80941Smrg      break;
5753b8e80941Smrg   case MESA_FORMAT_L_SNORM16:
5754b8e80941Smrg      for (i = 0; i < n; ++i) {
5755b8e80941Smrg         unpack_float_l_snorm16(s, dst[i]);
5756b8e80941Smrg         s += 2;
5757b8e80941Smrg      }
5758b8e80941Smrg      break;
5759b8e80941Smrg   case MESA_FORMAT_I_SNORM8:
5760b8e80941Smrg      for (i = 0; i < n; ++i) {
5761b8e80941Smrg         unpack_float_i_snorm8(s, dst[i]);
5762b8e80941Smrg         s += 1;
5763b8e80941Smrg      }
5764b8e80941Smrg      break;
5765b8e80941Smrg   case MESA_FORMAT_I_SNORM16:
5766b8e80941Smrg      for (i = 0; i < n; ++i) {
5767b8e80941Smrg         unpack_float_i_snorm16(s, dst[i]);
5768b8e80941Smrg         s += 2;
5769b8e80941Smrg      }
5770b8e80941Smrg      break;
5771b8e80941Smrg   case MESA_FORMAT_R_SNORM8:
5772b8e80941Smrg      for (i = 0; i < n; ++i) {
5773b8e80941Smrg         unpack_float_r_snorm8(s, dst[i]);
5774b8e80941Smrg         s += 1;
5775b8e80941Smrg      }
5776b8e80941Smrg      break;
5777b8e80941Smrg   case MESA_FORMAT_R_SNORM16:
5778b8e80941Smrg      for (i = 0; i < n; ++i) {
5779b8e80941Smrg         unpack_float_r_snorm16(s, dst[i]);
5780b8e80941Smrg         s += 2;
5781b8e80941Smrg      }
5782b8e80941Smrg      break;
5783b8e80941Smrg   case MESA_FORMAT_LA_SNORM16:
5784b8e80941Smrg      for (i = 0; i < n; ++i) {
5785b8e80941Smrg         unpack_float_la_snorm16(s, dst[i]);
5786b8e80941Smrg         s += 4;
5787b8e80941Smrg      }
5788b8e80941Smrg      break;
5789b8e80941Smrg   case MESA_FORMAT_RGB_SNORM16:
5790b8e80941Smrg      for (i = 0; i < n; ++i) {
5791b8e80941Smrg         unpack_float_rgb_snorm16(s, dst[i]);
5792b8e80941Smrg         s += 6;
5793b8e80941Smrg      }
5794b8e80941Smrg      break;
5795b8e80941Smrg   case MESA_FORMAT_RGBA_SNORM16:
5796b8e80941Smrg      for (i = 0; i < n; ++i) {
5797b8e80941Smrg         unpack_float_rgba_snorm16(s, dst[i]);
5798b8e80941Smrg         s += 8;
5799b8e80941Smrg      }
5800b8e80941Smrg      break;
5801b8e80941Smrg   case MESA_FORMAT_RGBX_SNORM16:
5802b8e80941Smrg      for (i = 0; i < n; ++i) {
5803b8e80941Smrg         unpack_float_rgbx_snorm16(s, dst[i]);
5804b8e80941Smrg         s += 8;
5805b8e80941Smrg      }
5806b8e80941Smrg      break;
5807b8e80941Smrg   case MESA_FORMAT_A8B8G8R8_SRGB:
5808b8e80941Smrg      for (i = 0; i < n; ++i) {
5809b8e80941Smrg         unpack_float_a8b8g8r8_srgb(s, dst[i]);
5810b8e80941Smrg         s += 4;
5811b8e80941Smrg      }
5812b8e80941Smrg      break;
5813b8e80941Smrg   case MESA_FORMAT_B8G8R8A8_SRGB:
5814b8e80941Smrg      for (i = 0; i < n; ++i) {
5815b8e80941Smrg         unpack_float_b8g8r8a8_srgb(s, dst[i]);
5816b8e80941Smrg         s += 4;
5817b8e80941Smrg      }
5818b8e80941Smrg      break;
5819b8e80941Smrg   case MESA_FORMAT_A8R8G8B8_SRGB:
5820b8e80941Smrg      for (i = 0; i < n; ++i) {
5821b8e80941Smrg         unpack_float_a8r8g8b8_srgb(s, dst[i]);
5822b8e80941Smrg         s += 4;
5823b8e80941Smrg      }
5824b8e80941Smrg      break;
5825b8e80941Smrg   case MESA_FORMAT_B8G8R8X8_SRGB:
5826b8e80941Smrg      for (i = 0; i < n; ++i) {
5827b8e80941Smrg         unpack_float_b8g8r8x8_srgb(s, dst[i]);
5828b8e80941Smrg         s += 4;
5829b8e80941Smrg      }
5830b8e80941Smrg      break;
5831b8e80941Smrg   case MESA_FORMAT_X8R8G8B8_SRGB:
5832b8e80941Smrg      for (i = 0; i < n; ++i) {
5833b8e80941Smrg         unpack_float_x8r8g8b8_srgb(s, dst[i]);
5834b8e80941Smrg         s += 4;
5835b8e80941Smrg      }
5836b8e80941Smrg      break;
5837b8e80941Smrg   case MESA_FORMAT_R8G8B8A8_SRGB:
5838b8e80941Smrg      for (i = 0; i < n; ++i) {
5839b8e80941Smrg         unpack_float_r8g8b8a8_srgb(s, dst[i]);
5840b8e80941Smrg         s += 4;
5841b8e80941Smrg      }
5842b8e80941Smrg      break;
5843b8e80941Smrg   case MESA_FORMAT_R8G8B8X8_SRGB:
5844b8e80941Smrg      for (i = 0; i < n; ++i) {
5845b8e80941Smrg         unpack_float_r8g8b8x8_srgb(s, dst[i]);
5846b8e80941Smrg         s += 4;
5847b8e80941Smrg      }
5848b8e80941Smrg      break;
5849b8e80941Smrg   case MESA_FORMAT_X8B8G8R8_SRGB:
5850b8e80941Smrg      for (i = 0; i < n; ++i) {
5851b8e80941Smrg         unpack_float_x8b8g8r8_srgb(s, dst[i]);
5852b8e80941Smrg         s += 4;
5853b8e80941Smrg      }
5854b8e80941Smrg      break;
5855b8e80941Smrg   case MESA_FORMAT_L8A8_SRGB:
5856b8e80941Smrg      for (i = 0; i < n; ++i) {
5857b8e80941Smrg         unpack_float_l8a8_srgb(s, dst[i]);
5858b8e80941Smrg         s += 2;
5859b8e80941Smrg      }
5860b8e80941Smrg      break;
5861b8e80941Smrg   case MESA_FORMAT_A8L8_SRGB:
5862b8e80941Smrg      for (i = 0; i < n; ++i) {
5863b8e80941Smrg         unpack_float_a8l8_srgb(s, dst[i]);
5864b8e80941Smrg         s += 2;
5865b8e80941Smrg      }
5866b8e80941Smrg      break;
5867b8e80941Smrg   case MESA_FORMAT_R_SRGB8:
5868b8e80941Smrg      for (i = 0; i < n; ++i) {
5869b8e80941Smrg         unpack_float_r_srgb8(s, dst[i]);
5870b8e80941Smrg         s += 1;
5871b8e80941Smrg      }
5872b8e80941Smrg      break;
5873b8e80941Smrg   case MESA_FORMAT_L_SRGB8:
5874b8e80941Smrg      for (i = 0; i < n; ++i) {
5875b8e80941Smrg         unpack_float_l_srgb8(s, dst[i]);
5876b8e80941Smrg         s += 1;
5877b8e80941Smrg      }
5878b8e80941Smrg      break;
5879b8e80941Smrg   case MESA_FORMAT_BGR_SRGB8:
5880b8e80941Smrg      for (i = 0; i < n; ++i) {
5881b8e80941Smrg         unpack_float_bgr_srgb8(s, dst[i]);
5882b8e80941Smrg         s += 3;
5883b8e80941Smrg      }
5884b8e80941Smrg      break;
5885b8e80941Smrg   case MESA_FORMAT_R9G9B9E5_FLOAT:
5886b8e80941Smrg      for (i = 0; i < n; ++i) {
5887b8e80941Smrg         unpack_float_r9g9b9e5_float(s, dst[i]);
5888b8e80941Smrg         s += 4;
5889b8e80941Smrg      }
5890b8e80941Smrg      break;
5891b8e80941Smrg   case MESA_FORMAT_R11G11B10_FLOAT:
5892b8e80941Smrg      for (i = 0; i < n; ++i) {
5893b8e80941Smrg         unpack_float_r11g11b10_float(s, dst[i]);
5894b8e80941Smrg         s += 4;
5895b8e80941Smrg      }
5896b8e80941Smrg      break;
5897b8e80941Smrg   case MESA_FORMAT_A_FLOAT16:
5898b8e80941Smrg      for (i = 0; i < n; ++i) {
5899b8e80941Smrg         unpack_float_a_float16(s, dst[i]);
5900b8e80941Smrg         s += 2;
5901b8e80941Smrg      }
5902b8e80941Smrg      break;
5903b8e80941Smrg   case MESA_FORMAT_A_FLOAT32:
5904b8e80941Smrg      for (i = 0; i < n; ++i) {
5905b8e80941Smrg         unpack_float_a_float32(s, dst[i]);
5906b8e80941Smrg         s += 4;
5907b8e80941Smrg      }
5908b8e80941Smrg      break;
5909b8e80941Smrg   case MESA_FORMAT_L_FLOAT16:
5910b8e80941Smrg      for (i = 0; i < n; ++i) {
5911b8e80941Smrg         unpack_float_l_float16(s, dst[i]);
5912b8e80941Smrg         s += 2;
5913b8e80941Smrg      }
5914b8e80941Smrg      break;
5915b8e80941Smrg   case MESA_FORMAT_L_FLOAT32:
5916b8e80941Smrg      for (i = 0; i < n; ++i) {
5917b8e80941Smrg         unpack_float_l_float32(s, dst[i]);
5918b8e80941Smrg         s += 4;
5919b8e80941Smrg      }
5920b8e80941Smrg      break;
5921b8e80941Smrg   case MESA_FORMAT_LA_FLOAT16:
5922b8e80941Smrg      for (i = 0; i < n; ++i) {
5923b8e80941Smrg         unpack_float_la_float16(s, dst[i]);
5924b8e80941Smrg         s += 4;
5925b8e80941Smrg      }
5926b8e80941Smrg      break;
5927b8e80941Smrg   case MESA_FORMAT_LA_FLOAT32:
5928b8e80941Smrg      for (i = 0; i < n; ++i) {
5929b8e80941Smrg         unpack_float_la_float32(s, dst[i]);
5930b8e80941Smrg         s += 8;
5931b8e80941Smrg      }
5932b8e80941Smrg      break;
5933b8e80941Smrg   case MESA_FORMAT_I_FLOAT16:
5934b8e80941Smrg      for (i = 0; i < n; ++i) {
5935b8e80941Smrg         unpack_float_i_float16(s, dst[i]);
5936b8e80941Smrg         s += 2;
5937b8e80941Smrg      }
5938b8e80941Smrg      break;
5939b8e80941Smrg   case MESA_FORMAT_I_FLOAT32:
5940b8e80941Smrg      for (i = 0; i < n; ++i) {
5941b8e80941Smrg         unpack_float_i_float32(s, dst[i]);
5942b8e80941Smrg         s += 4;
5943b8e80941Smrg      }
5944b8e80941Smrg      break;
5945b8e80941Smrg   case MESA_FORMAT_R_FLOAT16:
5946b8e80941Smrg      for (i = 0; i < n; ++i) {
5947b8e80941Smrg         unpack_float_r_float16(s, dst[i]);
5948b8e80941Smrg         s += 2;
5949b8e80941Smrg      }
5950b8e80941Smrg      break;
5951b8e80941Smrg   case MESA_FORMAT_R_FLOAT32:
5952b8e80941Smrg      for (i = 0; i < n; ++i) {
5953b8e80941Smrg         unpack_float_r_float32(s, dst[i]);
5954b8e80941Smrg         s += 4;
5955b8e80941Smrg      }
5956b8e80941Smrg      break;
5957b8e80941Smrg   case MESA_FORMAT_RG_FLOAT16:
5958b8e80941Smrg      for (i = 0; i < n; ++i) {
5959b8e80941Smrg         unpack_float_rg_float16(s, dst[i]);
5960b8e80941Smrg         s += 4;
5961b8e80941Smrg      }
5962b8e80941Smrg      break;
5963b8e80941Smrg   case MESA_FORMAT_RG_FLOAT32:
5964b8e80941Smrg      for (i = 0; i < n; ++i) {
5965b8e80941Smrg         unpack_float_rg_float32(s, dst[i]);
5966b8e80941Smrg         s += 8;
5967b8e80941Smrg      }
5968b8e80941Smrg      break;
5969b8e80941Smrg   case MESA_FORMAT_RGB_FLOAT16:
5970b8e80941Smrg      for (i = 0; i < n; ++i) {
5971b8e80941Smrg         unpack_float_rgb_float16(s, dst[i]);
5972b8e80941Smrg         s += 6;
5973b8e80941Smrg      }
5974b8e80941Smrg      break;
5975b8e80941Smrg   case MESA_FORMAT_RGB_FLOAT32:
5976b8e80941Smrg      for (i = 0; i < n; ++i) {
5977b8e80941Smrg         unpack_float_rgb_float32(s, dst[i]);
5978b8e80941Smrg         s += 12;
5979b8e80941Smrg      }
5980b8e80941Smrg      break;
5981b8e80941Smrg   case MESA_FORMAT_RGBA_FLOAT16:
5982b8e80941Smrg      for (i = 0; i < n; ++i) {
5983b8e80941Smrg         unpack_float_rgba_float16(s, dst[i]);
5984b8e80941Smrg         s += 8;
5985b8e80941Smrg      }
5986b8e80941Smrg      break;
5987b8e80941Smrg   case MESA_FORMAT_RGBA_FLOAT32:
5988b8e80941Smrg      for (i = 0; i < n; ++i) {
5989b8e80941Smrg         unpack_float_rgba_float32(s, dst[i]);
5990b8e80941Smrg         s += 16;
5991b8e80941Smrg      }
5992b8e80941Smrg      break;
5993b8e80941Smrg   case MESA_FORMAT_RGBX_FLOAT16:
5994b8e80941Smrg      for (i = 0; i < n; ++i) {
5995b8e80941Smrg         unpack_float_rgbx_float16(s, dst[i]);
5996b8e80941Smrg         s += 8;
5997b8e80941Smrg      }
5998b8e80941Smrg      break;
5999b8e80941Smrg   case MESA_FORMAT_RGBX_FLOAT32:
6000b8e80941Smrg      for (i = 0; i < n; ++i) {
6001b8e80941Smrg         unpack_float_rgbx_float32(s, dst[i]);
6002b8e80941Smrg         s += 16;
6003b8e80941Smrg      }
6004b8e80941Smrg      break;
6005b8e80941Smrg                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       case MESA_FORMAT_YCBCR:
6006b8e80941Smrg      unpack_float_ycbcr(src, dst, n);
6007b8e80941Smrg      break;
6008b8e80941Smrg   case MESA_FORMAT_YCBCR_REV:
6009b8e80941Smrg      unpack_float_ycbcr_rev(src, dst, n);
6010b8e80941Smrg      break;
6011b8e80941Smrg   default:
6012b8e80941Smrg      _mesa_problem(NULL, "%s: bad format %s", __func__,
6013b8e80941Smrg                    _mesa_get_format_name(format));
6014b8e80941Smrg      return;
6015b8e80941Smrg   }
6016b8e80941Smrg}
6017b8e80941Smrg
6018b8e80941Smrgvoid
6019b8e80941Smrg_mesa_unpack_ubyte_rgba_row(mesa_format format, GLuint n,
6020b8e80941Smrg                            const void *src, GLubyte dst[][4])
6021b8e80941Smrg{
6022b8e80941Smrg   GLubyte *s = (GLubyte *)src;
6023b8e80941Smrg   GLuint i;
6024b8e80941Smrg
6025b8e80941Smrg   switch (format) {
6026b8e80941Smrg
6027b8e80941Smrg   case MESA_FORMAT_A8B8G8R8_UNORM:
6028b8e80941Smrg      for (i = 0; i < n; ++i) {
6029b8e80941Smrg         unpack_ubyte_a8b8g8r8_unorm(s, dst[i]);
6030b8e80941Smrg         s += 4;
6031b8e80941Smrg      }
6032b8e80941Smrg      break;
6033b8e80941Smrg
6034b8e80941Smrg   case MESA_FORMAT_X8B8G8R8_UNORM:
6035b8e80941Smrg      for (i = 0; i < n; ++i) {
6036b8e80941Smrg         unpack_ubyte_x8b8g8r8_unorm(s, dst[i]);
6037b8e80941Smrg         s += 4;
6038b8e80941Smrg      }
6039b8e80941Smrg      break;
6040b8e80941Smrg
6041b8e80941Smrg   case MESA_FORMAT_R8G8B8A8_UNORM:
6042b8e80941Smrg      for (i = 0; i < n; ++i) {
6043b8e80941Smrg         unpack_ubyte_r8g8b8a8_unorm(s, dst[i]);
6044b8e80941Smrg         s += 4;
6045b8e80941Smrg      }
6046b8e80941Smrg      break;
6047b8e80941Smrg
6048b8e80941Smrg   case MESA_FORMAT_R8G8B8X8_UNORM:
6049b8e80941Smrg      for (i = 0; i < n; ++i) {
6050b8e80941Smrg         unpack_ubyte_r8g8b8x8_unorm(s, dst[i]);
6051b8e80941Smrg         s += 4;
6052b8e80941Smrg      }
6053b8e80941Smrg      break;
6054b8e80941Smrg
6055b8e80941Smrg   case MESA_FORMAT_B8G8R8A8_UNORM:
6056b8e80941Smrg      for (i = 0; i < n; ++i) {
6057b8e80941Smrg         unpack_ubyte_b8g8r8a8_unorm(s, dst[i]);
6058b8e80941Smrg         s += 4;
6059b8e80941Smrg      }
6060b8e80941Smrg      break;
6061b8e80941Smrg
6062b8e80941Smrg   case MESA_FORMAT_B8G8R8X8_UNORM:
6063b8e80941Smrg      for (i = 0; i < n; ++i) {
6064b8e80941Smrg         unpack_ubyte_b8g8r8x8_unorm(s, dst[i]);
6065b8e80941Smrg         s += 4;
6066b8e80941Smrg      }
6067b8e80941Smrg      break;
6068b8e80941Smrg
6069b8e80941Smrg   case MESA_FORMAT_A8R8G8B8_UNORM:
6070b8e80941Smrg      for (i = 0; i < n; ++i) {
6071b8e80941Smrg         unpack_ubyte_a8r8g8b8_unorm(s, dst[i]);
6072b8e80941Smrg         s += 4;
6073b8e80941Smrg      }
6074b8e80941Smrg      break;
6075b8e80941Smrg
6076b8e80941Smrg   case MESA_FORMAT_X8R8G8B8_UNORM:
6077b8e80941Smrg      for (i = 0; i < n; ++i) {
6078b8e80941Smrg         unpack_ubyte_x8r8g8b8_unorm(s, dst[i]);
6079b8e80941Smrg         s += 4;
6080b8e80941Smrg      }
6081b8e80941Smrg      break;
6082b8e80941Smrg
6083b8e80941Smrg   case MESA_FORMAT_L16A16_UNORM:
6084b8e80941Smrg      for (i = 0; i < n; ++i) {
6085b8e80941Smrg         unpack_ubyte_l16a16_unorm(s, dst[i]);
6086b8e80941Smrg         s += 4;
6087b8e80941Smrg      }
6088b8e80941Smrg      break;
6089b8e80941Smrg
6090b8e80941Smrg   case MESA_FORMAT_A16L16_UNORM:
6091b8e80941Smrg      for (i = 0; i < n; ++i) {
6092b8e80941Smrg         unpack_ubyte_a16l16_unorm(s, dst[i]);
6093b8e80941Smrg         s += 4;
6094b8e80941Smrg      }
6095b8e80941Smrg      break;
6096b8e80941Smrg
6097b8e80941Smrg   case MESA_FORMAT_B5G6R5_UNORM:
6098b8e80941Smrg      for (i = 0; i < n; ++i) {
6099b8e80941Smrg         unpack_ubyte_b5g6r5_unorm(s, dst[i]);
6100b8e80941Smrg         s += 2;
6101b8e80941Smrg      }
6102b8e80941Smrg      break;
6103b8e80941Smrg
6104b8e80941Smrg   case MESA_FORMAT_R5G6B5_UNORM:
6105b8e80941Smrg      for (i = 0; i < n; ++i) {
6106b8e80941Smrg         unpack_ubyte_r5g6b5_unorm(s, dst[i]);
6107b8e80941Smrg         s += 2;
6108b8e80941Smrg      }
6109b8e80941Smrg      break;
6110b8e80941Smrg
6111b8e80941Smrg   case MESA_FORMAT_B4G4R4A4_UNORM:
6112b8e80941Smrg      for (i = 0; i < n; ++i) {
6113b8e80941Smrg         unpack_ubyte_b4g4r4a4_unorm(s, dst[i]);
6114b8e80941Smrg         s += 2;
6115b8e80941Smrg      }
6116b8e80941Smrg      break;
6117b8e80941Smrg
6118b8e80941Smrg   case MESA_FORMAT_B4G4R4X4_UNORM:
6119b8e80941Smrg      for (i = 0; i < n; ++i) {
6120b8e80941Smrg         unpack_ubyte_b4g4r4x4_unorm(s, dst[i]);
6121b8e80941Smrg         s += 2;
6122b8e80941Smrg      }
6123b8e80941Smrg      break;
6124b8e80941Smrg
6125b8e80941Smrg   case MESA_FORMAT_A4R4G4B4_UNORM:
6126b8e80941Smrg      for (i = 0; i < n; ++i) {
6127b8e80941Smrg         unpack_ubyte_a4r4g4b4_unorm(s, dst[i]);
6128b8e80941Smrg         s += 2;
6129b8e80941Smrg      }
6130b8e80941Smrg      break;
6131b8e80941Smrg
6132b8e80941Smrg   case MESA_FORMAT_A1B5G5R5_UNORM:
6133b8e80941Smrg      for (i = 0; i < n; ++i) {
6134b8e80941Smrg         unpack_ubyte_a1b5g5r5_unorm(s, dst[i]);
6135b8e80941Smrg         s += 2;
6136b8e80941Smrg      }
6137b8e80941Smrg      break;
6138b8e80941Smrg
6139b8e80941Smrg   case MESA_FORMAT_X1B5G5R5_UNORM:
6140b8e80941Smrg      for (i = 0; i < n; ++i) {
6141b8e80941Smrg         unpack_ubyte_x1b5g5r5_unorm(s, dst[i]);
6142b8e80941Smrg         s += 2;
6143b8e80941Smrg      }
6144b8e80941Smrg      break;
6145b8e80941Smrg
6146b8e80941Smrg   case MESA_FORMAT_B5G5R5A1_UNORM:
6147b8e80941Smrg      for (i = 0; i < n; ++i) {
6148b8e80941Smrg         unpack_ubyte_b5g5r5a1_unorm(s, dst[i]);
6149b8e80941Smrg         s += 2;
6150b8e80941Smrg      }
6151b8e80941Smrg      break;
6152b8e80941Smrg
6153b8e80941Smrg   case MESA_FORMAT_B5G5R5X1_UNORM:
6154b8e80941Smrg      for (i = 0; i < n; ++i) {
6155b8e80941Smrg         unpack_ubyte_b5g5r5x1_unorm(s, dst[i]);
6156b8e80941Smrg         s += 2;
6157b8e80941Smrg      }
6158b8e80941Smrg      break;
6159b8e80941Smrg
6160b8e80941Smrg   case MESA_FORMAT_A1R5G5B5_UNORM:
6161b8e80941Smrg      for (i = 0; i < n; ++i) {
6162b8e80941Smrg         unpack_ubyte_a1r5g5b5_unorm(s, dst[i]);
6163b8e80941Smrg         s += 2;
6164b8e80941Smrg      }
6165b8e80941Smrg      break;
6166b8e80941Smrg
6167b8e80941Smrg   case MESA_FORMAT_L8A8_UNORM:
6168b8e80941Smrg      for (i = 0; i < n; ++i) {
6169b8e80941Smrg         unpack_ubyte_l8a8_unorm(s, dst[i]);
6170b8e80941Smrg         s += 2;
6171b8e80941Smrg      }
6172b8e80941Smrg      break;
6173b8e80941Smrg
6174b8e80941Smrg   case MESA_FORMAT_A8L8_UNORM:
6175b8e80941Smrg      for (i = 0; i < n; ++i) {
6176b8e80941Smrg         unpack_ubyte_a8l8_unorm(s, dst[i]);
6177b8e80941Smrg         s += 2;
6178b8e80941Smrg      }
6179b8e80941Smrg      break;
6180b8e80941Smrg
6181b8e80941Smrg   case MESA_FORMAT_R8G8_UNORM:
6182b8e80941Smrg      for (i = 0; i < n; ++i) {
6183b8e80941Smrg         unpack_ubyte_r8g8_unorm(s, dst[i]);
6184b8e80941Smrg         s += 2;
6185b8e80941Smrg      }
6186b8e80941Smrg      break;
6187b8e80941Smrg
6188b8e80941Smrg   case MESA_FORMAT_G8R8_UNORM:
6189b8e80941Smrg      for (i = 0; i < n; ++i) {
6190b8e80941Smrg         unpack_ubyte_g8r8_unorm(s, dst[i]);
6191b8e80941Smrg         s += 2;
6192b8e80941Smrg      }
6193b8e80941Smrg      break;
6194b8e80941Smrg
6195b8e80941Smrg   case MESA_FORMAT_L4A4_UNORM:
6196b8e80941Smrg      for (i = 0; i < n; ++i) {
6197b8e80941Smrg         unpack_ubyte_l4a4_unorm(s, dst[i]);
6198b8e80941Smrg         s += 1;
6199b8e80941Smrg      }
6200b8e80941Smrg      break;
6201b8e80941Smrg
6202b8e80941Smrg   case MESA_FORMAT_B2G3R3_UNORM:
6203b8e80941Smrg      for (i = 0; i < n; ++i) {
6204b8e80941Smrg         unpack_ubyte_b2g3r3_unorm(s, dst[i]);
6205b8e80941Smrg         s += 1;
6206b8e80941Smrg      }
6207b8e80941Smrg      break;
6208b8e80941Smrg
6209b8e80941Smrg   case MESA_FORMAT_R16G16_UNORM:
6210b8e80941Smrg      for (i = 0; i < n; ++i) {
6211b8e80941Smrg         unpack_ubyte_r16g16_unorm(s, dst[i]);
6212b8e80941Smrg         s += 4;
6213b8e80941Smrg      }
6214b8e80941Smrg      break;
6215b8e80941Smrg
6216b8e80941Smrg   case MESA_FORMAT_G16R16_UNORM:
6217b8e80941Smrg      for (i = 0; i < n; ++i) {
6218b8e80941Smrg         unpack_ubyte_g16r16_unorm(s, dst[i]);
6219b8e80941Smrg         s += 4;
6220b8e80941Smrg      }
6221b8e80941Smrg      break;
6222b8e80941Smrg
6223b8e80941Smrg   case MESA_FORMAT_B10G10R10A2_UNORM:
6224b8e80941Smrg      for (i = 0; i < n; ++i) {
6225b8e80941Smrg         unpack_ubyte_b10g10r10a2_unorm(s, dst[i]);
6226b8e80941Smrg         s += 4;
6227b8e80941Smrg      }
6228b8e80941Smrg      break;
6229b8e80941Smrg
6230b8e80941Smrg   case MESA_FORMAT_B10G10R10X2_UNORM:
6231b8e80941Smrg      for (i = 0; i < n; ++i) {
6232b8e80941Smrg         unpack_ubyte_b10g10r10x2_unorm(s, dst[i]);
6233b8e80941Smrg         s += 4;
6234b8e80941Smrg      }
6235b8e80941Smrg      break;
6236b8e80941Smrg
6237b8e80941Smrg   case MESA_FORMAT_R10G10B10A2_UNORM:
6238b8e80941Smrg      for (i = 0; i < n; ++i) {
6239b8e80941Smrg         unpack_ubyte_r10g10b10a2_unorm(s, dst[i]);
6240b8e80941Smrg         s += 4;
6241b8e80941Smrg      }
6242b8e80941Smrg      break;
6243b8e80941Smrg
6244b8e80941Smrg   case MESA_FORMAT_R10G10B10X2_UNORM:
6245b8e80941Smrg      for (i = 0; i < n; ++i) {
6246b8e80941Smrg         unpack_ubyte_r10g10b10x2_unorm(s, dst[i]);
6247b8e80941Smrg         s += 4;
6248b8e80941Smrg      }
6249b8e80941Smrg      break;
6250b8e80941Smrg
6251b8e80941Smrg   case MESA_FORMAT_R3G3B2_UNORM:
6252b8e80941Smrg      for (i = 0; i < n; ++i) {
6253b8e80941Smrg         unpack_ubyte_r3g3b2_unorm(s, dst[i]);
6254b8e80941Smrg         s += 1;
6255b8e80941Smrg      }
6256b8e80941Smrg      break;
6257b8e80941Smrg
6258b8e80941Smrg   case MESA_FORMAT_A4B4G4R4_UNORM:
6259b8e80941Smrg      for (i = 0; i < n; ++i) {
6260b8e80941Smrg         unpack_ubyte_a4b4g4r4_unorm(s, dst[i]);
6261b8e80941Smrg         s += 2;
6262b8e80941Smrg      }
6263b8e80941Smrg      break;
6264b8e80941Smrg
6265b8e80941Smrg   case MESA_FORMAT_R4G4B4A4_UNORM:
6266b8e80941Smrg      for (i = 0; i < n; ++i) {
6267b8e80941Smrg         unpack_ubyte_r4g4b4a4_unorm(s, dst[i]);
6268b8e80941Smrg         s += 2;
6269b8e80941Smrg      }
6270b8e80941Smrg      break;
6271b8e80941Smrg
6272b8e80941Smrg   case MESA_FORMAT_R5G5B5A1_UNORM:
6273b8e80941Smrg      for (i = 0; i < n; ++i) {
6274b8e80941Smrg         unpack_ubyte_r5g5b5a1_unorm(s, dst[i]);
6275b8e80941Smrg         s += 2;
6276b8e80941Smrg      }
6277b8e80941Smrg      break;
6278b8e80941Smrg
6279b8e80941Smrg   case MESA_FORMAT_A2B10G10R10_UNORM:
6280b8e80941Smrg      for (i = 0; i < n; ++i) {
6281b8e80941Smrg         unpack_ubyte_a2b10g10r10_unorm(s, dst[i]);
6282b8e80941Smrg         s += 4;
6283b8e80941Smrg      }
6284b8e80941Smrg      break;
6285b8e80941Smrg
6286b8e80941Smrg   case MESA_FORMAT_A2R10G10B10_UNORM:
6287b8e80941Smrg      for (i = 0; i < n; ++i) {
6288b8e80941Smrg         unpack_ubyte_a2r10g10b10_unorm(s, dst[i]);
6289b8e80941Smrg         s += 4;
6290b8e80941Smrg      }
6291b8e80941Smrg      break;
6292b8e80941Smrg
6293b8e80941Smrg   case MESA_FORMAT_A_UNORM8:
6294b8e80941Smrg      for (i = 0; i < n; ++i) {
6295b8e80941Smrg         unpack_ubyte_a_unorm8(s, dst[i]);
6296b8e80941Smrg         s += 1;
6297b8e80941Smrg      }
6298b8e80941Smrg      break;
6299b8e80941Smrg
6300b8e80941Smrg   case MESA_FORMAT_A_UNORM16:
6301b8e80941Smrg      for (i = 0; i < n; ++i) {
6302b8e80941Smrg         unpack_ubyte_a_unorm16(s, dst[i]);
6303b8e80941Smrg         s += 2;
6304b8e80941Smrg      }
6305b8e80941Smrg      break;
6306b8e80941Smrg
6307b8e80941Smrg   case MESA_FORMAT_L_UNORM8:
6308b8e80941Smrg      for (i = 0; i < n; ++i) {
6309b8e80941Smrg         unpack_ubyte_l_unorm8(s, dst[i]);
6310b8e80941Smrg         s += 1;
6311b8e80941Smrg      }
6312b8e80941Smrg      break;
6313b8e80941Smrg
6314b8e80941Smrg   case MESA_FORMAT_L_UNORM16:
6315b8e80941Smrg      for (i = 0; i < n; ++i) {
6316b8e80941Smrg         unpack_ubyte_l_unorm16(s, dst[i]);
6317b8e80941Smrg         s += 2;
6318b8e80941Smrg      }
6319b8e80941Smrg      break;
6320b8e80941Smrg
6321b8e80941Smrg   case MESA_FORMAT_I_UNORM8:
6322b8e80941Smrg      for (i = 0; i < n; ++i) {
6323b8e80941Smrg         unpack_ubyte_i_unorm8(s, dst[i]);
6324b8e80941Smrg         s += 1;
6325b8e80941Smrg      }
6326b8e80941Smrg      break;
6327b8e80941Smrg
6328b8e80941Smrg   case MESA_FORMAT_I_UNORM16:
6329b8e80941Smrg      for (i = 0; i < n; ++i) {
6330b8e80941Smrg         unpack_ubyte_i_unorm16(s, dst[i]);
6331b8e80941Smrg         s += 2;
6332b8e80941Smrg      }
6333b8e80941Smrg      break;
6334b8e80941Smrg
6335b8e80941Smrg   case MESA_FORMAT_R_UNORM8:
6336b8e80941Smrg      for (i = 0; i < n; ++i) {
6337b8e80941Smrg         unpack_ubyte_r_unorm8(s, dst[i]);
6338b8e80941Smrg         s += 1;
6339b8e80941Smrg      }
6340b8e80941Smrg      break;
6341b8e80941Smrg
6342b8e80941Smrg   case MESA_FORMAT_R_UNORM16:
6343b8e80941Smrg      for (i = 0; i < n; ++i) {
6344b8e80941Smrg         unpack_ubyte_r_unorm16(s, dst[i]);
6345b8e80941Smrg         s += 2;
6346b8e80941Smrg      }
6347b8e80941Smrg      break;
6348b8e80941Smrg
6349b8e80941Smrg   case MESA_FORMAT_BGR_UNORM8:
6350b8e80941Smrg      for (i = 0; i < n; ++i) {
6351b8e80941Smrg         unpack_ubyte_bgr_unorm8(s, dst[i]);
6352b8e80941Smrg         s += 3;
6353b8e80941Smrg      }
6354b8e80941Smrg      break;
6355b8e80941Smrg
6356b8e80941Smrg   case MESA_FORMAT_RGB_UNORM8:
6357b8e80941Smrg      for (i = 0; i < n; ++i) {
6358b8e80941Smrg         unpack_ubyte_rgb_unorm8(s, dst[i]);
6359b8e80941Smrg         s += 3;
6360b8e80941Smrg      }
6361b8e80941Smrg      break;
6362b8e80941Smrg
6363b8e80941Smrg   case MESA_FORMAT_RGBA_UNORM16:
6364b8e80941Smrg      for (i = 0; i < n; ++i) {
6365b8e80941Smrg         unpack_ubyte_rgba_unorm16(s, dst[i]);
6366b8e80941Smrg         s += 8;
6367b8e80941Smrg      }
6368b8e80941Smrg      break;
6369b8e80941Smrg
6370b8e80941Smrg   case MESA_FORMAT_RGBX_UNORM16:
6371b8e80941Smrg      for (i = 0; i < n; ++i) {
6372b8e80941Smrg         unpack_ubyte_rgbx_unorm16(s, dst[i]);
6373b8e80941Smrg         s += 8;
6374b8e80941Smrg      }
6375b8e80941Smrg      break;
6376b8e80941Smrg
6377b8e80941Smrg   case MESA_FORMAT_A8B8G8R8_SNORM:
6378b8e80941Smrg      for (i = 0; i < n; ++i) {
6379b8e80941Smrg         unpack_ubyte_a8b8g8r8_snorm(s, dst[i]);
6380b8e80941Smrg         s += 4;
6381b8e80941Smrg      }
6382b8e80941Smrg      break;
6383b8e80941Smrg
6384b8e80941Smrg   case MESA_FORMAT_X8B8G8R8_SNORM:
6385b8e80941Smrg      for (i = 0; i < n; ++i) {
6386b8e80941Smrg         unpack_ubyte_x8b8g8r8_snorm(s, dst[i]);
6387b8e80941Smrg         s += 4;
6388b8e80941Smrg      }
6389b8e80941Smrg      break;
6390b8e80941Smrg
6391b8e80941Smrg   case MESA_FORMAT_R8G8B8A8_SNORM:
6392b8e80941Smrg      for (i = 0; i < n; ++i) {
6393b8e80941Smrg         unpack_ubyte_r8g8b8a8_snorm(s, dst[i]);
6394b8e80941Smrg         s += 4;
6395b8e80941Smrg      }
6396b8e80941Smrg      break;
6397b8e80941Smrg
6398b8e80941Smrg   case MESA_FORMAT_R8G8B8X8_SNORM:
6399b8e80941Smrg      for (i = 0; i < n; ++i) {
6400b8e80941Smrg         unpack_ubyte_r8g8b8x8_snorm(s, dst[i]);
6401b8e80941Smrg         s += 4;
6402b8e80941Smrg      }
6403b8e80941Smrg      break;
6404b8e80941Smrg
6405b8e80941Smrg   case MESA_FORMAT_R16G16_SNORM:
6406b8e80941Smrg      for (i = 0; i < n; ++i) {
6407b8e80941Smrg         unpack_ubyte_r16g16_snorm(s, dst[i]);
6408b8e80941Smrg         s += 4;
6409b8e80941Smrg      }
6410b8e80941Smrg      break;
6411b8e80941Smrg
6412b8e80941Smrg   case MESA_FORMAT_G16R16_SNORM:
6413b8e80941Smrg      for (i = 0; i < n; ++i) {
6414b8e80941Smrg         unpack_ubyte_g16r16_snorm(s, dst[i]);
6415b8e80941Smrg         s += 4;
6416b8e80941Smrg      }
6417b8e80941Smrg      break;
6418b8e80941Smrg
6419b8e80941Smrg   case MESA_FORMAT_R8G8_SNORM:
6420b8e80941Smrg      for (i = 0; i < n; ++i) {
6421b8e80941Smrg         unpack_ubyte_r8g8_snorm(s, dst[i]);
6422b8e80941Smrg         s += 2;
6423b8e80941Smrg      }
6424b8e80941Smrg      break;
6425b8e80941Smrg
6426b8e80941Smrg   case MESA_FORMAT_G8R8_SNORM:
6427b8e80941Smrg      for (i = 0; i < n; ++i) {
6428b8e80941Smrg         unpack_ubyte_g8r8_snorm(s, dst[i]);
6429b8e80941Smrg         s += 2;
6430b8e80941Smrg      }
6431b8e80941Smrg      break;
6432b8e80941Smrg
6433b8e80941Smrg   case MESA_FORMAT_L8A8_SNORM:
6434b8e80941Smrg      for (i = 0; i < n; ++i) {
6435b8e80941Smrg         unpack_ubyte_l8a8_snorm(s, dst[i]);
6436b8e80941Smrg         s += 2;
6437b8e80941Smrg      }
6438b8e80941Smrg      break;
6439b8e80941Smrg
6440b8e80941Smrg   case MESA_FORMAT_A8L8_SNORM:
6441b8e80941Smrg      for (i = 0; i < n; ++i) {
6442b8e80941Smrg         unpack_ubyte_a8l8_snorm(s, dst[i]);
6443b8e80941Smrg         s += 2;
6444b8e80941Smrg      }
6445b8e80941Smrg      break;
6446b8e80941Smrg
6447b8e80941Smrg   case MESA_FORMAT_A_SNORM8:
6448b8e80941Smrg      for (i = 0; i < n; ++i) {
6449b8e80941Smrg         unpack_ubyte_a_snorm8(s, dst[i]);
6450b8e80941Smrg         s += 1;
6451b8e80941Smrg      }
6452b8e80941Smrg      break;
6453b8e80941Smrg
6454b8e80941Smrg   case MESA_FORMAT_A_SNORM16:
6455b8e80941Smrg      for (i = 0; i < n; ++i) {
6456b8e80941Smrg         unpack_ubyte_a_snorm16(s, dst[i]);
6457b8e80941Smrg         s += 2;
6458b8e80941Smrg      }
6459b8e80941Smrg      break;
6460b8e80941Smrg
6461b8e80941Smrg   case MESA_FORMAT_L_SNORM8:
6462b8e80941Smrg      for (i = 0; i < n; ++i) {
6463b8e80941Smrg         unpack_ubyte_l_snorm8(s, dst[i]);
6464b8e80941Smrg         s += 1;
6465b8e80941Smrg      }
6466b8e80941Smrg      break;
6467b8e80941Smrg
6468b8e80941Smrg   case MESA_FORMAT_L_SNORM16:
6469b8e80941Smrg      for (i = 0; i < n; ++i) {
6470b8e80941Smrg         unpack_ubyte_l_snorm16(s, dst[i]);
6471b8e80941Smrg         s += 2;
6472b8e80941Smrg      }
6473b8e80941Smrg      break;
6474b8e80941Smrg
6475b8e80941Smrg   case MESA_FORMAT_I_SNORM8:
6476b8e80941Smrg      for (i = 0; i < n; ++i) {
6477b8e80941Smrg         unpack_ubyte_i_snorm8(s, dst[i]);
6478b8e80941Smrg         s += 1;
6479b8e80941Smrg      }
6480b8e80941Smrg      break;
6481b8e80941Smrg
6482b8e80941Smrg   case MESA_FORMAT_I_SNORM16:
6483b8e80941Smrg      for (i = 0; i < n; ++i) {
6484b8e80941Smrg         unpack_ubyte_i_snorm16(s, dst[i]);
6485b8e80941Smrg         s += 2;
6486b8e80941Smrg      }
6487b8e80941Smrg      break;
6488b8e80941Smrg
6489b8e80941Smrg   case MESA_FORMAT_R_SNORM8:
6490b8e80941Smrg      for (i = 0; i < n; ++i) {
6491b8e80941Smrg         unpack_ubyte_r_snorm8(s, dst[i]);
6492b8e80941Smrg         s += 1;
6493b8e80941Smrg      }
6494b8e80941Smrg      break;
6495b8e80941Smrg
6496b8e80941Smrg   case MESA_FORMAT_R_SNORM16:
6497b8e80941Smrg      for (i = 0; i < n; ++i) {
6498b8e80941Smrg         unpack_ubyte_r_snorm16(s, dst[i]);
6499b8e80941Smrg         s += 2;
6500b8e80941Smrg      }
6501b8e80941Smrg      break;
6502b8e80941Smrg
6503b8e80941Smrg   case MESA_FORMAT_LA_SNORM16:
6504b8e80941Smrg      for (i = 0; i < n; ++i) {
6505b8e80941Smrg         unpack_ubyte_la_snorm16(s, dst[i]);
6506b8e80941Smrg         s += 4;
6507b8e80941Smrg      }
6508b8e80941Smrg      break;
6509b8e80941Smrg
6510b8e80941Smrg   case MESA_FORMAT_RGB_SNORM16:
6511b8e80941Smrg      for (i = 0; i < n; ++i) {
6512b8e80941Smrg         unpack_ubyte_rgb_snorm16(s, dst[i]);
6513b8e80941Smrg         s += 6;
6514b8e80941Smrg      }
6515b8e80941Smrg      break;
6516b8e80941Smrg
6517b8e80941Smrg   case MESA_FORMAT_RGBA_SNORM16:
6518b8e80941Smrg      for (i = 0; i < n; ++i) {
6519b8e80941Smrg         unpack_ubyte_rgba_snorm16(s, dst[i]);
6520b8e80941Smrg         s += 8;
6521b8e80941Smrg      }
6522b8e80941Smrg      break;
6523b8e80941Smrg
6524b8e80941Smrg   case MESA_FORMAT_RGBX_SNORM16:
6525b8e80941Smrg      for (i = 0; i < n; ++i) {
6526b8e80941Smrg         unpack_ubyte_rgbx_snorm16(s, dst[i]);
6527b8e80941Smrg         s += 8;
6528b8e80941Smrg      }
6529b8e80941Smrg      break;
6530b8e80941Smrg
6531b8e80941Smrg   case MESA_FORMAT_A8B8G8R8_SRGB:
6532b8e80941Smrg      for (i = 0; i < n; ++i) {
6533b8e80941Smrg         unpack_ubyte_a8b8g8r8_srgb(s, dst[i]);
6534b8e80941Smrg         s += 4;
6535b8e80941Smrg      }
6536b8e80941Smrg      break;
6537b8e80941Smrg
6538b8e80941Smrg   case MESA_FORMAT_B8G8R8A8_SRGB:
6539b8e80941Smrg      for (i = 0; i < n; ++i) {
6540b8e80941Smrg         unpack_ubyte_b8g8r8a8_srgb(s, dst[i]);
6541b8e80941Smrg         s += 4;
6542b8e80941Smrg      }
6543b8e80941Smrg      break;
6544b8e80941Smrg
6545b8e80941Smrg   case MESA_FORMAT_A8R8G8B8_SRGB:
6546b8e80941Smrg      for (i = 0; i < n; ++i) {
6547b8e80941Smrg         unpack_ubyte_a8r8g8b8_srgb(s, dst[i]);
6548b8e80941Smrg         s += 4;
6549b8e80941Smrg      }
6550b8e80941Smrg      break;
6551b8e80941Smrg
6552b8e80941Smrg   case MESA_FORMAT_B8G8R8X8_SRGB:
6553b8e80941Smrg      for (i = 0; i < n; ++i) {
6554b8e80941Smrg         unpack_ubyte_b8g8r8x8_srgb(s, dst[i]);
6555b8e80941Smrg         s += 4;
6556b8e80941Smrg      }
6557b8e80941Smrg      break;
6558b8e80941Smrg
6559b8e80941Smrg   case MESA_FORMAT_X8R8G8B8_SRGB:
6560b8e80941Smrg      for (i = 0; i < n; ++i) {
6561b8e80941Smrg         unpack_ubyte_x8r8g8b8_srgb(s, dst[i]);
6562b8e80941Smrg         s += 4;
6563b8e80941Smrg      }
6564b8e80941Smrg      break;
6565b8e80941Smrg
6566b8e80941Smrg   case MESA_FORMAT_R8G8B8A8_SRGB:
6567b8e80941Smrg      for (i = 0; i < n; ++i) {
6568b8e80941Smrg         unpack_ubyte_r8g8b8a8_srgb(s, dst[i]);
6569b8e80941Smrg         s += 4;
6570b8e80941Smrg      }
6571b8e80941Smrg      break;
6572b8e80941Smrg
6573b8e80941Smrg   case MESA_FORMAT_R8G8B8X8_SRGB:
6574b8e80941Smrg      for (i = 0; i < n; ++i) {
6575b8e80941Smrg         unpack_ubyte_r8g8b8x8_srgb(s, dst[i]);
6576b8e80941Smrg         s += 4;
6577b8e80941Smrg      }
6578b8e80941Smrg      break;
6579b8e80941Smrg
6580b8e80941Smrg   case MESA_FORMAT_X8B8G8R8_SRGB:
6581b8e80941Smrg      for (i = 0; i < n; ++i) {
6582b8e80941Smrg         unpack_ubyte_x8b8g8r8_srgb(s, dst[i]);
6583b8e80941Smrg         s += 4;
6584b8e80941Smrg      }
6585b8e80941Smrg      break;
6586b8e80941Smrg
6587b8e80941Smrg   case MESA_FORMAT_L8A8_SRGB:
6588b8e80941Smrg      for (i = 0; i < n; ++i) {
6589b8e80941Smrg         unpack_ubyte_l8a8_srgb(s, dst[i]);
6590b8e80941Smrg         s += 2;
6591b8e80941Smrg      }
6592b8e80941Smrg      break;
6593b8e80941Smrg
6594b8e80941Smrg   case MESA_FORMAT_A8L8_SRGB:
6595b8e80941Smrg      for (i = 0; i < n; ++i) {
6596b8e80941Smrg         unpack_ubyte_a8l8_srgb(s, dst[i]);
6597b8e80941Smrg         s += 2;
6598b8e80941Smrg      }
6599b8e80941Smrg      break;
6600b8e80941Smrg
6601b8e80941Smrg   case MESA_FORMAT_R_SRGB8:
6602b8e80941Smrg      for (i = 0; i < n; ++i) {
6603b8e80941Smrg         unpack_ubyte_r_srgb8(s, dst[i]);
6604b8e80941Smrg         s += 1;
6605b8e80941Smrg      }
6606b8e80941Smrg      break;
6607b8e80941Smrg
6608b8e80941Smrg   case MESA_FORMAT_L_SRGB8:
6609b8e80941Smrg      for (i = 0; i < n; ++i) {
6610b8e80941Smrg         unpack_ubyte_l_srgb8(s, dst[i]);
6611b8e80941Smrg         s += 1;
6612b8e80941Smrg      }
6613b8e80941Smrg      break;
6614b8e80941Smrg
6615b8e80941Smrg   case MESA_FORMAT_BGR_SRGB8:
6616b8e80941Smrg      for (i = 0; i < n; ++i) {
6617b8e80941Smrg         unpack_ubyte_bgr_srgb8(s, dst[i]);
6618b8e80941Smrg         s += 3;
6619b8e80941Smrg      }
6620b8e80941Smrg      break;
6621b8e80941Smrg                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               default:
6622b8e80941Smrg      /* get float values, convert to ubyte */
6623b8e80941Smrg      {
6624b8e80941Smrg         GLfloat *tmp = malloc(n * 4 * sizeof(GLfloat));
6625b8e80941Smrg         if (tmp) {
6626b8e80941Smrg            GLuint i;
6627b8e80941Smrg            _mesa_unpack_rgba_row(format, n, src, (GLfloat (*)[4]) tmp);
6628b8e80941Smrg            for (i = 0; i < n; i++) {
6629b8e80941Smrg               dst[i][0] = _mesa_float_to_unorm(tmp[i*4+0], 8);
6630b8e80941Smrg               dst[i][1] = _mesa_float_to_unorm(tmp[i*4+1], 8);
6631b8e80941Smrg               dst[i][2] = _mesa_float_to_unorm(tmp[i*4+2], 8);
6632b8e80941Smrg               dst[i][3] = _mesa_float_to_unorm(tmp[i*4+3], 8);
6633b8e80941Smrg            }
6634b8e80941Smrg            free(tmp);
6635b8e80941Smrg         }
6636b8e80941Smrg      }
6637b8e80941Smrg      break;
6638b8e80941Smrg   }
6639b8e80941Smrg}
6640b8e80941Smrg
6641b8e80941Smrgvoid
6642b8e80941Smrg_mesa_unpack_uint_rgba_row(mesa_format format, GLuint n,
6643b8e80941Smrg                           const void *src, GLuint dst[][4])
6644b8e80941Smrg{
6645b8e80941Smrg   GLubyte *s = (GLubyte *)src;
6646b8e80941Smrg   GLuint i;
6647b8e80941Smrg
6648b8e80941Smrg   switch (format) {
6649b8e80941Smrg
6650b8e80941Smrg   case MESA_FORMAT_A8B8G8R8_UINT:
6651b8e80941Smrg      for (i = 0; i < n; ++i) {
6652b8e80941Smrg         unpack_int_a8b8g8r8_uint(s, dst[i]);
6653b8e80941Smrg         s += 4;
6654b8e80941Smrg      }
6655b8e80941Smrg      break;
6656b8e80941Smrg
6657b8e80941Smrg   case MESA_FORMAT_A8R8G8B8_UINT:
6658b8e80941Smrg      for (i = 0; i < n; ++i) {
6659b8e80941Smrg         unpack_int_a8r8g8b8_uint(s, dst[i]);
6660b8e80941Smrg         s += 4;
6661b8e80941Smrg      }
6662b8e80941Smrg      break;
6663b8e80941Smrg
6664b8e80941Smrg   case MESA_FORMAT_R8G8B8A8_UINT:
6665b8e80941Smrg      for (i = 0; i < n; ++i) {
6666b8e80941Smrg         unpack_int_r8g8b8a8_uint(s, dst[i]);
6667b8e80941Smrg         s += 4;
6668b8e80941Smrg      }
6669b8e80941Smrg      break;
6670b8e80941Smrg
6671b8e80941Smrg   case MESA_FORMAT_B8G8R8A8_UINT:
6672b8e80941Smrg      for (i = 0; i < n; ++i) {
6673b8e80941Smrg         unpack_int_b8g8r8a8_uint(s, dst[i]);
6674b8e80941Smrg         s += 4;
6675b8e80941Smrg      }
6676b8e80941Smrg      break;
6677b8e80941Smrg
6678b8e80941Smrg   case MESA_FORMAT_B10G10R10A2_UINT:
6679b8e80941Smrg      for (i = 0; i < n; ++i) {
6680b8e80941Smrg         unpack_int_b10g10r10a2_uint(s, dst[i]);
6681b8e80941Smrg         s += 4;
6682b8e80941Smrg      }
6683b8e80941Smrg      break;
6684b8e80941Smrg
6685b8e80941Smrg   case MESA_FORMAT_R10G10B10A2_UINT:
6686b8e80941Smrg      for (i = 0; i < n; ++i) {
6687b8e80941Smrg         unpack_int_r10g10b10a2_uint(s, dst[i]);
6688b8e80941Smrg         s += 4;
6689b8e80941Smrg      }
6690b8e80941Smrg      break;
6691b8e80941Smrg
6692b8e80941Smrg   case MESA_FORMAT_A2B10G10R10_UINT:
6693b8e80941Smrg      for (i = 0; i < n; ++i) {
6694b8e80941Smrg         unpack_int_a2b10g10r10_uint(s, dst[i]);
6695b8e80941Smrg         s += 4;
6696b8e80941Smrg      }
6697b8e80941Smrg      break;
6698b8e80941Smrg
6699b8e80941Smrg   case MESA_FORMAT_A2R10G10B10_UINT:
6700b8e80941Smrg      for (i = 0; i < n; ++i) {
6701b8e80941Smrg         unpack_int_a2r10g10b10_uint(s, dst[i]);
6702b8e80941Smrg         s += 4;
6703b8e80941Smrg      }
6704b8e80941Smrg      break;
6705b8e80941Smrg
6706b8e80941Smrg   case MESA_FORMAT_B5G6R5_UINT:
6707b8e80941Smrg      for (i = 0; i < n; ++i) {
6708b8e80941Smrg         unpack_int_b5g6r5_uint(s, dst[i]);
6709b8e80941Smrg         s += 2;
6710b8e80941Smrg      }
6711b8e80941Smrg      break;
6712b8e80941Smrg
6713b8e80941Smrg   case MESA_FORMAT_R5G6B5_UINT:
6714b8e80941Smrg      for (i = 0; i < n; ++i) {
6715b8e80941Smrg         unpack_int_r5g6b5_uint(s, dst[i]);
6716b8e80941Smrg         s += 2;
6717b8e80941Smrg      }
6718b8e80941Smrg      break;
6719b8e80941Smrg
6720b8e80941Smrg   case MESA_FORMAT_B2G3R3_UINT:
6721b8e80941Smrg      for (i = 0; i < n; ++i) {
6722b8e80941Smrg         unpack_int_b2g3r3_uint(s, dst[i]);
6723b8e80941Smrg         s += 1;
6724b8e80941Smrg      }
6725b8e80941Smrg      break;
6726b8e80941Smrg
6727b8e80941Smrg   case MESA_FORMAT_R3G3B2_UINT:
6728b8e80941Smrg      for (i = 0; i < n; ++i) {
6729b8e80941Smrg         unpack_int_r3g3b2_uint(s, dst[i]);
6730b8e80941Smrg         s += 1;
6731b8e80941Smrg      }
6732b8e80941Smrg      break;
6733b8e80941Smrg
6734b8e80941Smrg   case MESA_FORMAT_A4B4G4R4_UINT:
6735b8e80941Smrg      for (i = 0; i < n; ++i) {
6736b8e80941Smrg         unpack_int_a4b4g4r4_uint(s, dst[i]);
6737b8e80941Smrg         s += 2;
6738b8e80941Smrg      }
6739b8e80941Smrg      break;
6740b8e80941Smrg
6741b8e80941Smrg   case MESA_FORMAT_R4G4B4A4_UINT:
6742b8e80941Smrg      for (i = 0; i < n; ++i) {
6743b8e80941Smrg         unpack_int_r4g4b4a4_uint(s, dst[i]);
6744b8e80941Smrg         s += 2;
6745b8e80941Smrg      }
6746b8e80941Smrg      break;
6747b8e80941Smrg
6748b8e80941Smrg   case MESA_FORMAT_B4G4R4A4_UINT:
6749b8e80941Smrg      for (i = 0; i < n; ++i) {
6750b8e80941Smrg         unpack_int_b4g4r4a4_uint(s, dst[i]);
6751b8e80941Smrg         s += 2;
6752b8e80941Smrg      }
6753b8e80941Smrg      break;
6754b8e80941Smrg
6755b8e80941Smrg   case MESA_FORMAT_A4R4G4B4_UINT:
6756b8e80941Smrg      for (i = 0; i < n; ++i) {
6757b8e80941Smrg         unpack_int_a4r4g4b4_uint(s, dst[i]);
6758b8e80941Smrg         s += 2;
6759b8e80941Smrg      }
6760b8e80941Smrg      break;
6761b8e80941Smrg
6762b8e80941Smrg   case MESA_FORMAT_A1B5G5R5_UINT:
6763b8e80941Smrg      for (i = 0; i < n; ++i) {
6764b8e80941Smrg         unpack_int_a1b5g5r5_uint(s, dst[i]);
6765b8e80941Smrg         s += 2;
6766b8e80941Smrg      }
6767b8e80941Smrg      break;
6768b8e80941Smrg
6769b8e80941Smrg   case MESA_FORMAT_B5G5R5A1_UINT:
6770b8e80941Smrg      for (i = 0; i < n; ++i) {
6771b8e80941Smrg         unpack_int_b5g5r5a1_uint(s, dst[i]);
6772b8e80941Smrg         s += 2;
6773b8e80941Smrg      }
6774b8e80941Smrg      break;
6775b8e80941Smrg
6776b8e80941Smrg   case MESA_FORMAT_A1R5G5B5_UINT:
6777b8e80941Smrg      for (i = 0; i < n; ++i) {
6778b8e80941Smrg         unpack_int_a1r5g5b5_uint(s, dst[i]);
6779b8e80941Smrg         s += 2;
6780b8e80941Smrg      }
6781b8e80941Smrg      break;
6782b8e80941Smrg
6783b8e80941Smrg   case MESA_FORMAT_R5G5B5A1_UINT:
6784b8e80941Smrg      for (i = 0; i < n; ++i) {
6785b8e80941Smrg         unpack_int_r5g5b5a1_uint(s, dst[i]);
6786b8e80941Smrg         s += 2;
6787b8e80941Smrg      }
6788b8e80941Smrg      break;
6789b8e80941Smrg
6790b8e80941Smrg   case MESA_FORMAT_A_UINT8:
6791b8e80941Smrg      for (i = 0; i < n; ++i) {
6792b8e80941Smrg         unpack_int_a_uint8(s, dst[i]);
6793b8e80941Smrg         s += 1;
6794b8e80941Smrg      }
6795b8e80941Smrg      break;
6796b8e80941Smrg
6797b8e80941Smrg   case MESA_FORMAT_A_UINT16:
6798b8e80941Smrg      for (i = 0; i < n; ++i) {
6799b8e80941Smrg         unpack_int_a_uint16(s, dst[i]);
6800b8e80941Smrg         s += 2;
6801b8e80941Smrg      }
6802b8e80941Smrg      break;
6803b8e80941Smrg
6804b8e80941Smrg   case MESA_FORMAT_A_UINT32:
6805b8e80941Smrg      for (i = 0; i < n; ++i) {
6806b8e80941Smrg         unpack_int_a_uint32(s, dst[i]);
6807b8e80941Smrg         s += 4;
6808b8e80941Smrg      }
6809b8e80941Smrg      break;
6810b8e80941Smrg
6811b8e80941Smrg   case MESA_FORMAT_A_SINT8:
6812b8e80941Smrg      for (i = 0; i < n; ++i) {
6813b8e80941Smrg         unpack_int_a_sint8(s, dst[i]);
6814b8e80941Smrg         s += 1;
6815b8e80941Smrg      }
6816b8e80941Smrg      break;
6817b8e80941Smrg
6818b8e80941Smrg   case MESA_FORMAT_A_SINT16:
6819b8e80941Smrg      for (i = 0; i < n; ++i) {
6820b8e80941Smrg         unpack_int_a_sint16(s, dst[i]);
6821b8e80941Smrg         s += 2;
6822b8e80941Smrg      }
6823b8e80941Smrg      break;
6824b8e80941Smrg
6825b8e80941Smrg   case MESA_FORMAT_A_SINT32:
6826b8e80941Smrg      for (i = 0; i < n; ++i) {
6827b8e80941Smrg         unpack_int_a_sint32(s, dst[i]);
6828b8e80941Smrg         s += 4;
6829b8e80941Smrg      }
6830b8e80941Smrg      break;
6831b8e80941Smrg
6832b8e80941Smrg   case MESA_FORMAT_I_UINT8:
6833b8e80941Smrg      for (i = 0; i < n; ++i) {
6834b8e80941Smrg         unpack_int_i_uint8(s, dst[i]);
6835b8e80941Smrg         s += 1;
6836b8e80941Smrg      }
6837b8e80941Smrg      break;
6838b8e80941Smrg
6839b8e80941Smrg   case MESA_FORMAT_I_UINT16:
6840b8e80941Smrg      for (i = 0; i < n; ++i) {
6841b8e80941Smrg         unpack_int_i_uint16(s, dst[i]);
6842b8e80941Smrg         s += 2;
6843b8e80941Smrg      }
6844b8e80941Smrg      break;
6845b8e80941Smrg
6846b8e80941Smrg   case MESA_FORMAT_I_UINT32:
6847b8e80941Smrg      for (i = 0; i < n; ++i) {
6848b8e80941Smrg         unpack_int_i_uint32(s, dst[i]);
6849b8e80941Smrg         s += 4;
6850b8e80941Smrg      }
6851b8e80941Smrg      break;
6852b8e80941Smrg
6853b8e80941Smrg   case MESA_FORMAT_I_SINT8:
6854b8e80941Smrg      for (i = 0; i < n; ++i) {
6855b8e80941Smrg         unpack_int_i_sint8(s, dst[i]);
6856b8e80941Smrg         s += 1;
6857b8e80941Smrg      }
6858b8e80941Smrg      break;
6859b8e80941Smrg
6860b8e80941Smrg   case MESA_FORMAT_I_SINT16:
6861b8e80941Smrg      for (i = 0; i < n; ++i) {
6862b8e80941Smrg         unpack_int_i_sint16(s, dst[i]);
6863b8e80941Smrg         s += 2;
6864b8e80941Smrg      }
6865b8e80941Smrg      break;
6866b8e80941Smrg
6867b8e80941Smrg   case MESA_FORMAT_I_SINT32:
6868b8e80941Smrg      for (i = 0; i < n; ++i) {
6869b8e80941Smrg         unpack_int_i_sint32(s, dst[i]);
6870b8e80941Smrg         s += 4;
6871b8e80941Smrg      }
6872b8e80941Smrg      break;
6873b8e80941Smrg
6874b8e80941Smrg   case MESA_FORMAT_L_UINT8:
6875b8e80941Smrg      for (i = 0; i < n; ++i) {
6876b8e80941Smrg         unpack_int_l_uint8(s, dst[i]);
6877b8e80941Smrg         s += 1;
6878b8e80941Smrg      }
6879b8e80941Smrg      break;
6880b8e80941Smrg
6881b8e80941Smrg   case MESA_FORMAT_L_UINT16:
6882b8e80941Smrg      for (i = 0; i < n; ++i) {
6883b8e80941Smrg         unpack_int_l_uint16(s, dst[i]);
6884b8e80941Smrg         s += 2;
6885b8e80941Smrg      }
6886b8e80941Smrg      break;
6887b8e80941Smrg
6888b8e80941Smrg   case MESA_FORMAT_L_UINT32:
6889b8e80941Smrg      for (i = 0; i < n; ++i) {
6890b8e80941Smrg         unpack_int_l_uint32(s, dst[i]);
6891b8e80941Smrg         s += 4;
6892b8e80941Smrg      }
6893b8e80941Smrg      break;
6894b8e80941Smrg
6895b8e80941Smrg   case MESA_FORMAT_L_SINT8:
6896b8e80941Smrg      for (i = 0; i < n; ++i) {
6897b8e80941Smrg         unpack_int_l_sint8(s, dst[i]);
6898b8e80941Smrg         s += 1;
6899b8e80941Smrg      }
6900b8e80941Smrg      break;
6901b8e80941Smrg
6902b8e80941Smrg   case MESA_FORMAT_L_SINT16:
6903b8e80941Smrg      for (i = 0; i < n; ++i) {
6904b8e80941Smrg         unpack_int_l_sint16(s, dst[i]);
6905b8e80941Smrg         s += 2;
6906b8e80941Smrg      }
6907b8e80941Smrg      break;
6908b8e80941Smrg
6909b8e80941Smrg   case MESA_FORMAT_L_SINT32:
6910b8e80941Smrg      for (i = 0; i < n; ++i) {
6911b8e80941Smrg         unpack_int_l_sint32(s, dst[i]);
6912b8e80941Smrg         s += 4;
6913b8e80941Smrg      }
6914b8e80941Smrg      break;
6915b8e80941Smrg
6916b8e80941Smrg   case MESA_FORMAT_LA_UINT8:
6917b8e80941Smrg      for (i = 0; i < n; ++i) {
6918b8e80941Smrg         unpack_int_la_uint8(s, dst[i]);
6919b8e80941Smrg         s += 2;
6920b8e80941Smrg      }
6921b8e80941Smrg      break;
6922b8e80941Smrg
6923b8e80941Smrg   case MESA_FORMAT_LA_UINT16:
6924b8e80941Smrg      for (i = 0; i < n; ++i) {
6925b8e80941Smrg         unpack_int_la_uint16(s, dst[i]);
6926b8e80941Smrg         s += 4;
6927b8e80941Smrg      }
6928b8e80941Smrg      break;
6929b8e80941Smrg
6930b8e80941Smrg   case MESA_FORMAT_LA_UINT32:
6931b8e80941Smrg      for (i = 0; i < n; ++i) {
6932b8e80941Smrg         unpack_int_la_uint32(s, dst[i]);
6933b8e80941Smrg         s += 8;
6934b8e80941Smrg      }
6935b8e80941Smrg      break;
6936b8e80941Smrg
6937b8e80941Smrg   case MESA_FORMAT_LA_SINT8:
6938b8e80941Smrg      for (i = 0; i < n; ++i) {
6939b8e80941Smrg         unpack_int_la_sint8(s, dst[i]);
6940b8e80941Smrg         s += 2;
6941b8e80941Smrg      }
6942b8e80941Smrg      break;
6943b8e80941Smrg
6944b8e80941Smrg   case MESA_FORMAT_LA_SINT16:
6945b8e80941Smrg      for (i = 0; i < n; ++i) {
6946b8e80941Smrg         unpack_int_la_sint16(s, dst[i]);
6947b8e80941Smrg         s += 4;
6948b8e80941Smrg      }
6949b8e80941Smrg      break;
6950b8e80941Smrg
6951b8e80941Smrg   case MESA_FORMAT_LA_SINT32:
6952b8e80941Smrg      for (i = 0; i < n; ++i) {
6953b8e80941Smrg         unpack_int_la_sint32(s, dst[i]);
6954b8e80941Smrg         s += 8;
6955b8e80941Smrg      }
6956b8e80941Smrg      break;
6957b8e80941Smrg
6958b8e80941Smrg   case MESA_FORMAT_R_UINT8:
6959b8e80941Smrg      for (i = 0; i < n; ++i) {
6960b8e80941Smrg         unpack_int_r_uint8(s, dst[i]);
6961b8e80941Smrg         s += 1;
6962b8e80941Smrg      }
6963b8e80941Smrg      break;
6964b8e80941Smrg
6965b8e80941Smrg   case MESA_FORMAT_R_UINT16:
6966b8e80941Smrg      for (i = 0; i < n; ++i) {
6967b8e80941Smrg         unpack_int_r_uint16(s, dst[i]);
6968b8e80941Smrg         s += 2;
6969b8e80941Smrg      }
6970b8e80941Smrg      break;
6971b8e80941Smrg
6972b8e80941Smrg   case MESA_FORMAT_R_UINT32:
6973b8e80941Smrg      for (i = 0; i < n; ++i) {
6974b8e80941Smrg         unpack_int_r_uint32(s, dst[i]);
6975b8e80941Smrg         s += 4;
6976b8e80941Smrg      }
6977b8e80941Smrg      break;
6978b8e80941Smrg
6979b8e80941Smrg   case MESA_FORMAT_R_SINT8:
6980b8e80941Smrg      for (i = 0; i < n; ++i) {
6981b8e80941Smrg         unpack_int_r_sint8(s, dst[i]);
6982b8e80941Smrg         s += 1;
6983b8e80941Smrg      }
6984b8e80941Smrg      break;
6985b8e80941Smrg
6986b8e80941Smrg   case MESA_FORMAT_R_SINT16:
6987b8e80941Smrg      for (i = 0; i < n; ++i) {
6988b8e80941Smrg         unpack_int_r_sint16(s, dst[i]);
6989b8e80941Smrg         s += 2;
6990b8e80941Smrg      }
6991b8e80941Smrg      break;
6992b8e80941Smrg
6993b8e80941Smrg   case MESA_FORMAT_R_SINT32:
6994b8e80941Smrg      for (i = 0; i < n; ++i) {
6995b8e80941Smrg         unpack_int_r_sint32(s, dst[i]);
6996b8e80941Smrg         s += 4;
6997b8e80941Smrg      }
6998b8e80941Smrg      break;
6999b8e80941Smrg
7000b8e80941Smrg   case MESA_FORMAT_RG_UINT8:
7001b8e80941Smrg      for (i = 0; i < n; ++i) {
7002b8e80941Smrg         unpack_int_rg_uint8(s, dst[i]);
7003b8e80941Smrg         s += 2;
7004b8e80941Smrg      }
7005b8e80941Smrg      break;
7006b8e80941Smrg
7007b8e80941Smrg   case MESA_FORMAT_RG_UINT16:
7008b8e80941Smrg      for (i = 0; i < n; ++i) {
7009b8e80941Smrg         unpack_int_rg_uint16(s, dst[i]);
7010b8e80941Smrg         s += 4;
7011b8e80941Smrg      }
7012b8e80941Smrg      break;
7013b8e80941Smrg
7014b8e80941Smrg   case MESA_FORMAT_RG_UINT32:
7015b8e80941Smrg      for (i = 0; i < n; ++i) {
7016b8e80941Smrg         unpack_int_rg_uint32(s, dst[i]);
7017b8e80941Smrg         s += 8;
7018b8e80941Smrg      }
7019b8e80941Smrg      break;
7020b8e80941Smrg
7021b8e80941Smrg   case MESA_FORMAT_RG_SINT8:
7022b8e80941Smrg      for (i = 0; i < n; ++i) {
7023b8e80941Smrg         unpack_int_rg_sint8(s, dst[i]);
7024b8e80941Smrg         s += 2;
7025b8e80941Smrg      }
7026b8e80941Smrg      break;
7027b8e80941Smrg
7028b8e80941Smrg   case MESA_FORMAT_RG_SINT16:
7029b8e80941Smrg      for (i = 0; i < n; ++i) {
7030b8e80941Smrg         unpack_int_rg_sint16(s, dst[i]);
7031b8e80941Smrg         s += 4;
7032b8e80941Smrg      }
7033b8e80941Smrg      break;
7034b8e80941Smrg
7035b8e80941Smrg   case MESA_FORMAT_RG_SINT32:
7036b8e80941Smrg      for (i = 0; i < n; ++i) {
7037b8e80941Smrg         unpack_int_rg_sint32(s, dst[i]);
7038b8e80941Smrg         s += 8;
7039b8e80941Smrg      }
7040b8e80941Smrg      break;
7041b8e80941Smrg
7042b8e80941Smrg   case MESA_FORMAT_RGB_UINT8:
7043b8e80941Smrg      for (i = 0; i < n; ++i) {
7044b8e80941Smrg         unpack_int_rgb_uint8(s, dst[i]);
7045b8e80941Smrg         s += 3;
7046b8e80941Smrg      }
7047b8e80941Smrg      break;
7048b8e80941Smrg
7049b8e80941Smrg   case MESA_FORMAT_RGB_UINT16:
7050b8e80941Smrg      for (i = 0; i < n; ++i) {
7051b8e80941Smrg         unpack_int_rgb_uint16(s, dst[i]);
7052b8e80941Smrg         s += 6;
7053b8e80941Smrg      }
7054b8e80941Smrg      break;
7055b8e80941Smrg
7056b8e80941Smrg   case MESA_FORMAT_RGB_UINT32:
7057b8e80941Smrg      for (i = 0; i < n; ++i) {
7058b8e80941Smrg         unpack_int_rgb_uint32(s, dst[i]);
7059b8e80941Smrg         s += 12;
7060b8e80941Smrg      }
7061b8e80941Smrg      break;
7062b8e80941Smrg
7063b8e80941Smrg   case MESA_FORMAT_RGB_SINT8:
7064b8e80941Smrg      for (i = 0; i < n; ++i) {
7065b8e80941Smrg         unpack_int_rgb_sint8(s, dst[i]);
7066b8e80941Smrg         s += 3;
7067b8e80941Smrg      }
7068b8e80941Smrg      break;
7069b8e80941Smrg
7070b8e80941Smrg   case MESA_FORMAT_RGB_SINT16:
7071b8e80941Smrg      for (i = 0; i < n; ++i) {
7072b8e80941Smrg         unpack_int_rgb_sint16(s, dst[i]);
7073b8e80941Smrg         s += 6;
7074b8e80941Smrg      }
7075b8e80941Smrg      break;
7076b8e80941Smrg
7077b8e80941Smrg   case MESA_FORMAT_RGB_SINT32:
7078b8e80941Smrg      for (i = 0; i < n; ++i) {
7079b8e80941Smrg         unpack_int_rgb_sint32(s, dst[i]);
7080b8e80941Smrg         s += 12;
7081b8e80941Smrg      }
7082b8e80941Smrg      break;
7083b8e80941Smrg
7084b8e80941Smrg   case MESA_FORMAT_RGBA_UINT8:
7085b8e80941Smrg      for (i = 0; i < n; ++i) {
7086b8e80941Smrg         unpack_int_rgba_uint8(s, dst[i]);
7087b8e80941Smrg         s += 4;
7088b8e80941Smrg      }
7089b8e80941Smrg      break;
7090b8e80941Smrg
7091b8e80941Smrg   case MESA_FORMAT_RGBA_UINT16:
7092b8e80941Smrg      for (i = 0; i < n; ++i) {
7093b8e80941Smrg         unpack_int_rgba_uint16(s, dst[i]);
7094b8e80941Smrg         s += 8;
7095b8e80941Smrg      }
7096b8e80941Smrg      break;
7097b8e80941Smrg
7098b8e80941Smrg   case MESA_FORMAT_RGBA_UINT32:
7099b8e80941Smrg      for (i = 0; i < n; ++i) {
7100b8e80941Smrg         unpack_int_rgba_uint32(s, dst[i]);
7101b8e80941Smrg         s += 16;
7102b8e80941Smrg      }
7103b8e80941Smrg      break;
7104b8e80941Smrg
7105b8e80941Smrg   case MESA_FORMAT_RGBA_SINT8:
7106b8e80941Smrg      for (i = 0; i < n; ++i) {
7107b8e80941Smrg         unpack_int_rgba_sint8(s, dst[i]);
7108b8e80941Smrg         s += 4;
7109b8e80941Smrg      }
7110b8e80941Smrg      break;
7111b8e80941Smrg
7112b8e80941Smrg   case MESA_FORMAT_RGBA_SINT16:
7113b8e80941Smrg      for (i = 0; i < n; ++i) {
7114b8e80941Smrg         unpack_int_rgba_sint16(s, dst[i]);
7115b8e80941Smrg         s += 8;
7116b8e80941Smrg      }
7117b8e80941Smrg      break;
7118b8e80941Smrg
7119b8e80941Smrg   case MESA_FORMAT_RGBA_SINT32:
7120b8e80941Smrg      for (i = 0; i < n; ++i) {
7121b8e80941Smrg         unpack_int_rgba_sint32(s, dst[i]);
7122b8e80941Smrg         s += 16;
7123b8e80941Smrg      }
7124b8e80941Smrg      break;
7125b8e80941Smrg
7126b8e80941Smrg   case MESA_FORMAT_RGBX_UINT8:
7127b8e80941Smrg      for (i = 0; i < n; ++i) {
7128b8e80941Smrg         unpack_int_rgbx_uint8(s, dst[i]);
7129b8e80941Smrg         s += 4;
7130b8e80941Smrg      }
7131b8e80941Smrg      break;
7132b8e80941Smrg
7133b8e80941Smrg   case MESA_FORMAT_RGBX_UINT16:
7134b8e80941Smrg      for (i = 0; i < n; ++i) {
7135b8e80941Smrg         unpack_int_rgbx_uint16(s, dst[i]);
7136b8e80941Smrg         s += 8;
7137b8e80941Smrg      }
7138b8e80941Smrg      break;
7139b8e80941Smrg
7140b8e80941Smrg   case MESA_FORMAT_RGBX_UINT32:
7141b8e80941Smrg      for (i = 0; i < n; ++i) {
7142b8e80941Smrg         unpack_int_rgbx_uint32(s, dst[i]);
7143b8e80941Smrg         s += 16;
7144b8e80941Smrg      }
7145b8e80941Smrg      break;
7146b8e80941Smrg
7147b8e80941Smrg   case MESA_FORMAT_RGBX_SINT8:
7148b8e80941Smrg      for (i = 0; i < n; ++i) {
7149b8e80941Smrg         unpack_int_rgbx_sint8(s, dst[i]);
7150b8e80941Smrg         s += 4;
7151b8e80941Smrg      }
7152b8e80941Smrg      break;
7153b8e80941Smrg
7154b8e80941Smrg   case MESA_FORMAT_RGBX_SINT16:
7155b8e80941Smrg      for (i = 0; i < n; ++i) {
7156b8e80941Smrg         unpack_int_rgbx_sint16(s, dst[i]);
7157b8e80941Smrg         s += 8;
7158b8e80941Smrg      }
7159b8e80941Smrg      break;
7160b8e80941Smrg
7161b8e80941Smrg   case MESA_FORMAT_RGBX_SINT32:
7162b8e80941Smrg      for (i = 0; i < n; ++i) {
7163b8e80941Smrg         unpack_int_rgbx_sint32(s, dst[i]);
7164b8e80941Smrg         s += 16;
7165b8e80941Smrg      }
7166b8e80941Smrg      break;
7167b8e80941Smrg                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           default:
7168b8e80941Smrg      _mesa_problem(NULL, "%s: bad format %s", __func__,
7169b8e80941Smrg                    _mesa_get_format_name(format));
7170b8e80941Smrg      return;
7171b8e80941Smrg   }
7172b8e80941Smrg}
7173b8e80941Smrg
7174b8e80941Smrg/**
7175b8e80941Smrg * Unpack a 2D rect of pixels returning float RGBA colors.
7176b8e80941Smrg * \param format  the source image format
7177b8e80941Smrg * \param src  start address of the source image
7178b8e80941Smrg * \param srcRowStride  source image row stride in bytes
7179b8e80941Smrg * \param dst  start address of the dest image
7180b8e80941Smrg * \param dstRowStride  dest image row stride in bytes
7181b8e80941Smrg * \param x  source image start X pos
7182b8e80941Smrg * \param y  source image start Y pos
7183b8e80941Smrg * \param width  width of rect region to convert
7184b8e80941Smrg * \param height  height of rect region to convert
7185b8e80941Smrg */
7186b8e80941Smrgvoid
7187b8e80941Smrg_mesa_unpack_rgba_block(mesa_format format,
7188b8e80941Smrg                        const void *src, GLint srcRowStride,
7189b8e80941Smrg                        GLfloat dst[][4], GLint dstRowStride,
7190b8e80941Smrg                        GLuint x, GLuint y, GLuint width, GLuint height)
7191b8e80941Smrg{
7192b8e80941Smrg   const GLuint srcPixStride = _mesa_get_format_bytes(format);
7193b8e80941Smrg   const GLuint dstPixStride = 4 * sizeof(GLfloat);
7194b8e80941Smrg   const GLubyte *srcRow;
7195b8e80941Smrg   GLubyte *dstRow;
7196b8e80941Smrg   GLuint i;
7197b8e80941Smrg
7198b8e80941Smrg   /* XXX needs to be fixed for compressed formats */
7199b8e80941Smrg
7200b8e80941Smrg   srcRow = ((const GLubyte *) src) + srcRowStride * y + srcPixStride * x;
7201b8e80941Smrg   dstRow = ((GLubyte *) dst) + dstRowStride * y + dstPixStride * x;
7202b8e80941Smrg
7203b8e80941Smrg   for (i = 0; i < height; i++) {
7204b8e80941Smrg      _mesa_unpack_rgba_row(format, width, srcRow, (GLfloat (*)[4]) dstRow);
7205b8e80941Smrg
7206b8e80941Smrg      dstRow += dstRowStride;
7207b8e80941Smrg      srcRow += srcRowStride;
7208b8e80941Smrg   }
7209b8e80941Smrg}
7210b8e80941Smrg
7211b8e80941Smrg/** Helper struct for MESA_FORMAT_Z32_FLOAT_S8X24_UINT */
7212b8e80941Smrgstruct z32f_x24s8
7213b8e80941Smrg{
7214b8e80941Smrg   float z;
7215b8e80941Smrg   uint32_t x24s8;
7216b8e80941Smrg};
7217b8e80941Smrg
7218b8e80941Smrgtypedef void (*unpack_float_z_func)(GLuint n, const void *src, GLfloat *dst);
7219b8e80941Smrg
7220b8e80941Smrgstatic void
7221b8e80941Smrgunpack_float_z_X8_UINT_Z24_UNORM(GLuint n, const void *src, GLfloat *dst)
7222b8e80941Smrg{
7223b8e80941Smrg   /* only return Z, not stencil data */
7224b8e80941Smrg   const GLuint *s = ((const GLuint *) src);
7225b8e80941Smrg   const GLdouble scale = 1.0 / (GLdouble) 0xffffff;
7226b8e80941Smrg   GLuint i;
7227b8e80941Smrg   for (i = 0; i < n; i++) {
7228b8e80941Smrg      dst[i] = (GLfloat) ((s[i] >> 8) * scale);
7229b8e80941Smrg      assert(dst[i] >= 0.0F);
7230b8e80941Smrg      assert(dst[i] <= 1.0F);
7231b8e80941Smrg   }
7232b8e80941Smrg}
7233b8e80941Smrg
7234b8e80941Smrgstatic void
7235b8e80941Smrgunpack_float_z_Z24_UNORM_X8_UINT(GLuint n, const void *src, GLfloat *dst)
7236b8e80941Smrg{
7237b8e80941Smrg   /* only return Z, not stencil data */
7238b8e80941Smrg   const GLuint *s = ((const GLuint *) src);
7239b8e80941Smrg   const GLdouble scale = 1.0 / (GLdouble) 0xffffff;
7240b8e80941Smrg   GLuint i;
7241b8e80941Smrg   for (i = 0; i < n; i++) {
7242b8e80941Smrg      dst[i] = (GLfloat) ((s[i] & 0x00ffffff) * scale);
7243b8e80941Smrg      assert(dst[i] >= 0.0F);
7244b8e80941Smrg      assert(dst[i] <= 1.0F);
7245b8e80941Smrg   }
7246b8e80941Smrg}
7247b8e80941Smrg
7248b8e80941Smrgstatic void
7249b8e80941Smrgunpack_float_Z_UNORM16(GLuint n, const void *src, GLfloat *dst)
7250b8e80941Smrg{
7251b8e80941Smrg   const GLushort *s = ((const GLushort *) src);
7252b8e80941Smrg   GLuint i;
7253b8e80941Smrg   for (i = 0; i < n; i++) {
7254b8e80941Smrg      dst[i] = s[i] * (1.0F / 65535.0F);
7255b8e80941Smrg   }
7256b8e80941Smrg}
7257b8e80941Smrg
7258b8e80941Smrgstatic void
7259b8e80941Smrgunpack_float_Z_UNORM32(GLuint n, const void *src, GLfloat *dst)
7260b8e80941Smrg{
7261b8e80941Smrg   const GLuint *s = ((const GLuint *) src);
7262b8e80941Smrg   GLuint i;
7263b8e80941Smrg   for (i = 0; i < n; i++) {
7264b8e80941Smrg      dst[i] = s[i] * (1.0F / 0xffffffff);
7265b8e80941Smrg   }
7266b8e80941Smrg}
7267b8e80941Smrg
7268b8e80941Smrgstatic void
7269b8e80941Smrgunpack_float_Z_FLOAT32(GLuint n, const void *src, GLfloat *dst)
7270b8e80941Smrg{
7271b8e80941Smrg   memcpy(dst, src, n * sizeof(float));
7272b8e80941Smrg}
7273b8e80941Smrg
7274b8e80941Smrgstatic void
7275b8e80941Smrgunpack_float_z_Z32X24S8(GLuint n, const void *src, GLfloat *dst)
7276b8e80941Smrg{
7277b8e80941Smrg   const struct z32f_x24s8 *s = (const struct z32f_x24s8 *) src;
7278b8e80941Smrg   GLuint i;
7279b8e80941Smrg   for (i = 0; i < n; i++) {
7280b8e80941Smrg      dst[i] = s[i].z;
7281b8e80941Smrg   }
7282b8e80941Smrg}
7283b8e80941Smrg
7284b8e80941Smrg
7285b8e80941Smrg
7286b8e80941Smrg/**
7287b8e80941Smrg * Unpack Z values.
7288b8e80941Smrg * The returned values will always be in the range [0.0, 1.0].
7289b8e80941Smrg */
7290b8e80941Smrgvoid
7291b8e80941Smrg_mesa_unpack_float_z_row(mesa_format format, GLuint n,
7292b8e80941Smrg                         const void *src, GLfloat *dst)
7293b8e80941Smrg{
7294b8e80941Smrg   unpack_float_z_func unpack;
7295b8e80941Smrg
7296b8e80941Smrg   switch (format) {
7297b8e80941Smrg   case MESA_FORMAT_S8_UINT_Z24_UNORM:
7298b8e80941Smrg   case MESA_FORMAT_X8_UINT_Z24_UNORM:
7299b8e80941Smrg      unpack = unpack_float_z_X8_UINT_Z24_UNORM;
7300b8e80941Smrg      break;
7301b8e80941Smrg   case MESA_FORMAT_Z24_UNORM_S8_UINT:
7302b8e80941Smrg   case MESA_FORMAT_Z24_UNORM_X8_UINT:
7303b8e80941Smrg      unpack = unpack_float_z_Z24_UNORM_X8_UINT;
7304b8e80941Smrg      break;
7305b8e80941Smrg   case MESA_FORMAT_Z_UNORM16:
7306b8e80941Smrg      unpack = unpack_float_Z_UNORM16;
7307b8e80941Smrg      break;
7308b8e80941Smrg   case MESA_FORMAT_Z_UNORM32:
7309b8e80941Smrg      unpack = unpack_float_Z_UNORM32;
7310b8e80941Smrg      break;
7311b8e80941Smrg   case MESA_FORMAT_Z_FLOAT32:
7312b8e80941Smrg      unpack = unpack_float_Z_FLOAT32;
7313b8e80941Smrg      break;
7314b8e80941Smrg   case MESA_FORMAT_Z32_FLOAT_S8X24_UINT:
7315b8e80941Smrg      unpack = unpack_float_z_Z32X24S8;
7316b8e80941Smrg      break;
7317b8e80941Smrg   default:
7318b8e80941Smrg      _mesa_problem(NULL, "bad format %s in _mesa_unpack_float_z_row",
7319b8e80941Smrg                    _mesa_get_format_name(format));
7320b8e80941Smrg      return;
7321b8e80941Smrg   }
7322b8e80941Smrg
7323b8e80941Smrg   unpack(n, src, dst);
7324b8e80941Smrg}
7325b8e80941Smrg
7326b8e80941Smrg
7327b8e80941Smrg
7328b8e80941Smrgtypedef void (*unpack_uint_z_func)(const void *src, GLuint *dst, GLuint n);
7329b8e80941Smrg
7330b8e80941Smrgstatic void
7331b8e80941Smrgunpack_uint_z_X8_UINT_Z24_UNORM(const void *src, GLuint *dst, GLuint n)
7332b8e80941Smrg{
7333b8e80941Smrg   /* only return Z, not stencil data */
7334b8e80941Smrg   const GLuint *s = ((const GLuint *) src);
7335b8e80941Smrg   GLuint i;
7336b8e80941Smrg   for (i = 0; i < n; i++) {
7337b8e80941Smrg      dst[i] = (s[i] & 0xffffff00) | (s[i] >> 24);
7338b8e80941Smrg   }
7339b8e80941Smrg}
7340b8e80941Smrg
7341b8e80941Smrgstatic void
7342b8e80941Smrgunpack_uint_z_Z24_UNORM_X8_UINT(const void *src, GLuint *dst, GLuint n)
7343b8e80941Smrg{
7344b8e80941Smrg   /* only return Z, not stencil data */
7345b8e80941Smrg   const GLuint *s = ((const GLuint *) src);
7346b8e80941Smrg   GLuint i;
7347b8e80941Smrg   for (i = 0; i < n; i++) {
7348b8e80941Smrg      dst[i] = (s[i] << 8) | ((s[i] >> 16) & 0xff);
7349b8e80941Smrg   }
7350b8e80941Smrg}
7351b8e80941Smrg
7352b8e80941Smrgstatic void
7353b8e80941Smrgunpack_uint_Z_UNORM16(const void *src, GLuint *dst, GLuint n)
7354b8e80941Smrg{
7355b8e80941Smrg   const GLushort *s = ((const GLushort *)src);
7356b8e80941Smrg   GLuint i;
7357b8e80941Smrg   for (i = 0; i < n; i++) {
7358b8e80941Smrg      dst[i] = (s[i] << 16) | s[i];
7359b8e80941Smrg   }
7360b8e80941Smrg}
7361b8e80941Smrg
7362b8e80941Smrgstatic void
7363b8e80941Smrgunpack_uint_Z_UNORM32(const void *src, GLuint *dst, GLuint n)
7364b8e80941Smrg{
7365b8e80941Smrg   memcpy(dst, src, n * sizeof(GLuint));
7366b8e80941Smrg}
7367b8e80941Smrg
7368b8e80941Smrgstatic void
7369b8e80941Smrgunpack_uint_Z_FLOAT32(const void *src, GLuint *dst, GLuint n)
7370b8e80941Smrg{
7371b8e80941Smrg   const float *s = (const float *)src;
7372b8e80941Smrg   GLuint i;
7373b8e80941Smrg   for (i = 0; i < n; i++) {
7374b8e80941Smrg      dst[i] = FLOAT_TO_UINT(CLAMP(s[i], 0.0F, 1.0F));
7375b8e80941Smrg   }
7376b8e80941Smrg}
7377b8e80941Smrg
7378b8e80941Smrgstatic void
7379b8e80941Smrgunpack_uint_Z_FLOAT32_X24S8(const void *src, GLuint *dst, GLuint n)
7380b8e80941Smrg{
7381b8e80941Smrg   const struct z32f_x24s8 *s = (const struct z32f_x24s8 *) src;
7382b8e80941Smrg   GLuint i;
7383b8e80941Smrg
7384b8e80941Smrg   for (i = 0; i < n; i++) {
7385b8e80941Smrg      dst[i] = FLOAT_TO_UINT(CLAMP(s[i].z, 0.0F, 1.0F));
7386b8e80941Smrg   }
7387b8e80941Smrg}
7388b8e80941Smrg
7389b8e80941Smrg
7390b8e80941Smrg/**
7391b8e80941Smrg * Unpack Z values.
7392b8e80941Smrg * The returned values will always be in the range [0, 0xffffffff].
7393b8e80941Smrg */
7394b8e80941Smrgvoid
7395b8e80941Smrg_mesa_unpack_uint_z_row(mesa_format format, GLuint n,
7396b8e80941Smrg                        const void *src, GLuint *dst)
7397b8e80941Smrg{
7398b8e80941Smrg   unpack_uint_z_func unpack;
7399b8e80941Smrg   const GLubyte *srcPtr = (GLubyte *) src;
7400b8e80941Smrg
7401b8e80941Smrg   switch (format) {
7402b8e80941Smrg   case MESA_FORMAT_S8_UINT_Z24_UNORM:
7403b8e80941Smrg   case MESA_FORMAT_X8_UINT_Z24_UNORM:
7404b8e80941Smrg      unpack = unpack_uint_z_X8_UINT_Z24_UNORM;
7405b8e80941Smrg      break;
7406b8e80941Smrg   case MESA_FORMAT_Z24_UNORM_S8_UINT:
7407b8e80941Smrg   case MESA_FORMAT_Z24_UNORM_X8_UINT:
7408b8e80941Smrg      unpack = unpack_uint_z_Z24_UNORM_X8_UINT;
7409b8e80941Smrg      break;
7410b8e80941Smrg   case MESA_FORMAT_Z_UNORM16:
7411b8e80941Smrg      unpack = unpack_uint_Z_UNORM16;
7412b8e80941Smrg      break;
7413b8e80941Smrg   case MESA_FORMAT_Z_UNORM32:
7414b8e80941Smrg      unpack = unpack_uint_Z_UNORM32;
7415b8e80941Smrg      break;
7416b8e80941Smrg   case MESA_FORMAT_Z_FLOAT32:
7417b8e80941Smrg      unpack = unpack_uint_Z_FLOAT32;
7418b8e80941Smrg      break;
7419b8e80941Smrg   case MESA_FORMAT_Z32_FLOAT_S8X24_UINT:
7420b8e80941Smrg      unpack = unpack_uint_Z_FLOAT32_X24S8;
7421b8e80941Smrg      break;
7422b8e80941Smrg   default:
7423b8e80941Smrg      _mesa_problem(NULL, "bad format %s in _mesa_unpack_uint_z_row",
7424b8e80941Smrg                    _mesa_get_format_name(format));
7425b8e80941Smrg      return;
7426b8e80941Smrg   }
7427b8e80941Smrg
7428b8e80941Smrg   unpack(srcPtr, dst, n);
7429b8e80941Smrg}
7430b8e80941Smrg
7431b8e80941Smrg
7432b8e80941Smrgstatic void
7433b8e80941Smrgunpack_ubyte_s_S_UINT8(const void *src, GLubyte *dst, GLuint n)
7434b8e80941Smrg{
7435b8e80941Smrg   memcpy(dst, src, n);
7436b8e80941Smrg}
7437b8e80941Smrg
7438b8e80941Smrgstatic void
7439b8e80941Smrgunpack_ubyte_s_S8_UINT_Z24_UNORM(const void *src, GLubyte *dst, GLuint n)
7440b8e80941Smrg{
7441b8e80941Smrg   GLuint i;
7442b8e80941Smrg   const GLuint *src32 = src;
7443b8e80941Smrg
7444b8e80941Smrg   for (i = 0; i < n; i++)
7445b8e80941Smrg      dst[i] = src32[i] & 0xff;
7446b8e80941Smrg}
7447b8e80941Smrg
7448b8e80941Smrgstatic void
7449b8e80941Smrgunpack_ubyte_s_Z24_UNORM_S8_UINT(const void *src, GLubyte *dst, GLuint n)
7450b8e80941Smrg{
7451b8e80941Smrg   GLuint i;
7452b8e80941Smrg   const GLuint *src32 = src;
7453b8e80941Smrg
7454b8e80941Smrg   for (i = 0; i < n; i++)
7455b8e80941Smrg      dst[i] = src32[i] >> 24;
7456b8e80941Smrg}
7457b8e80941Smrg
7458b8e80941Smrgstatic void
7459b8e80941Smrgunpack_ubyte_s_Z32_FLOAT_S8X24_UINT(const void *src, GLubyte *dst, GLuint n)
7460b8e80941Smrg{
7461b8e80941Smrg   GLuint i;
7462b8e80941Smrg   const struct z32f_x24s8 *s = (const struct z32f_x24s8 *) src;
7463b8e80941Smrg
7464b8e80941Smrg   for (i = 0; i < n; i++)
7465b8e80941Smrg      dst[i] = s[i].x24s8 & 0xff;
7466b8e80941Smrg}
7467b8e80941Smrg
7468b8e80941Smrgvoid
7469b8e80941Smrg_mesa_unpack_ubyte_stencil_row(mesa_format format, GLuint n,
7470b8e80941Smrg			       const void *src, GLubyte *dst)
7471b8e80941Smrg{
7472b8e80941Smrg   switch (format) {
7473b8e80941Smrg   case MESA_FORMAT_S_UINT8:
7474b8e80941Smrg      unpack_ubyte_s_S_UINT8(src, dst, n);
7475b8e80941Smrg      break;
7476b8e80941Smrg   case MESA_FORMAT_S8_UINT_Z24_UNORM:
7477b8e80941Smrg      unpack_ubyte_s_S8_UINT_Z24_UNORM(src, dst, n);
7478b8e80941Smrg      break;
7479b8e80941Smrg   case MESA_FORMAT_Z24_UNORM_S8_UINT:
7480b8e80941Smrg      unpack_ubyte_s_Z24_UNORM_S8_UINT(src, dst, n);
7481b8e80941Smrg      break;
7482b8e80941Smrg   case MESA_FORMAT_Z32_FLOAT_S8X24_UINT:
7483b8e80941Smrg      unpack_ubyte_s_Z32_FLOAT_S8X24_UINT(src, dst, n);
7484b8e80941Smrg      break;
7485b8e80941Smrg   default:
7486b8e80941Smrg      _mesa_problem(NULL, "bad format %s in _mesa_unpack_ubyte_s_row",
7487b8e80941Smrg                    _mesa_get_format_name(format));
7488b8e80941Smrg      return;
7489b8e80941Smrg   }
7490b8e80941Smrg}
7491b8e80941Smrg
7492b8e80941Smrgstatic void
7493b8e80941Smrgunpack_uint_24_8_depth_stencil_Z24_UNORM_S8_UINT(const GLuint *src, GLuint *dst, GLuint n)
7494b8e80941Smrg{
7495b8e80941Smrg   GLuint i;
7496b8e80941Smrg
7497b8e80941Smrg   for (i = 0; i < n; i++) {
7498b8e80941Smrg      GLuint val = src[i];
7499b8e80941Smrg      dst[i] = val >> 24 | val << 8;
7500b8e80941Smrg   }
7501b8e80941Smrg}
7502b8e80941Smrg
7503b8e80941Smrgstatic void
7504b8e80941Smrgunpack_uint_24_8_depth_stencil_Z32_S8X24(const GLuint *src,
7505b8e80941Smrg                                         GLuint *dst, GLuint n)
7506b8e80941Smrg{
7507b8e80941Smrg   GLuint i;
7508b8e80941Smrg
7509b8e80941Smrg   for (i = 0; i < n; i++) {
7510b8e80941Smrg      /* 8 bytes per pixel (float + uint32) */
7511b8e80941Smrg      GLfloat zf = ((GLfloat *) src)[i * 2 + 0];
7512b8e80941Smrg      GLuint z24 = (GLuint) (zf * (GLfloat) 0xffffff);
7513b8e80941Smrg      GLuint s = src[i * 2 + 1] & 0xff;
7514b8e80941Smrg      dst[i] = (z24 << 8) | s;
7515b8e80941Smrg   }
7516b8e80941Smrg}
7517b8e80941Smrg
7518b8e80941Smrgstatic void
7519b8e80941Smrgunpack_uint_24_8_depth_stencil_S8_UINT_Z24_UNORM(const GLuint *src, GLuint *dst, GLuint n)
7520b8e80941Smrg{
7521b8e80941Smrg   memcpy(dst, src, n * 4);
7522b8e80941Smrg}
7523b8e80941Smrg
7524b8e80941Smrg/**
7525b8e80941Smrg * Unpack depth/stencil returning as GL_UNSIGNED_INT_24_8.
7526b8e80941Smrg * \param format  the source data format
7527b8e80941Smrg */
7528b8e80941Smrgvoid
7529b8e80941Smrg_mesa_unpack_uint_24_8_depth_stencil_row(mesa_format format, GLuint n,
7530b8e80941Smrg					 const void *src, GLuint *dst)
7531b8e80941Smrg{
7532b8e80941Smrg   switch (format) {
7533b8e80941Smrg   case MESA_FORMAT_S8_UINT_Z24_UNORM:
7534b8e80941Smrg      unpack_uint_24_8_depth_stencil_S8_UINT_Z24_UNORM(src, dst, n);
7535b8e80941Smrg      break;
7536b8e80941Smrg   case MESA_FORMAT_Z24_UNORM_S8_UINT:
7537b8e80941Smrg      unpack_uint_24_8_depth_stencil_Z24_UNORM_S8_UINT(src, dst, n);
7538b8e80941Smrg      break;
7539b8e80941Smrg   case MESA_FORMAT_Z32_FLOAT_S8X24_UINT:
7540b8e80941Smrg      unpack_uint_24_8_depth_stencil_Z32_S8X24(src, dst, n);
7541b8e80941Smrg      break;
7542b8e80941Smrg   default:
7543b8e80941Smrg      _mesa_problem(NULL,
7544b8e80941Smrg                    "bad format %s in _mesa_unpack_uint_24_8_depth_stencil_row",
7545b8e80941Smrg                    _mesa_get_format_name(format));
7546b8e80941Smrg      return;
7547b8e80941Smrg   }
7548b8e80941Smrg}
7549b8e80941Smrg
7550b8e80941Smrgstatic void
7551b8e80941Smrgunpack_float_32_uint_24_8_Z24_UNORM_S8_UINT(const GLuint *src,
7552b8e80941Smrg                                            GLuint *dst, GLuint n)
7553b8e80941Smrg{
7554b8e80941Smrg   GLuint i;
7555b8e80941Smrg   struct z32f_x24s8 *d = (struct z32f_x24s8 *) dst;
7556b8e80941Smrg   const GLdouble scale = 1.0 / (GLdouble) 0xffffff;
7557b8e80941Smrg
7558b8e80941Smrg   for (i = 0; i < n; i++) {
7559b8e80941Smrg      const GLuint z24 = src[i] & 0xffffff;
7560b8e80941Smrg      d[i].z = z24 * scale;
7561b8e80941Smrg      d[i].x24s8 = src[i] >> 24;
7562b8e80941Smrg      assert(d[i].z >= 0.0f);
7563b8e80941Smrg      assert(d[i].z <= 1.0f);
7564b8e80941Smrg   }
7565b8e80941Smrg}
7566b8e80941Smrg
7567b8e80941Smrgstatic void
7568b8e80941Smrgunpack_float_32_uint_24_8_Z32_FLOAT_S8X24_UINT(const GLuint *src,
7569b8e80941Smrg                                               GLuint *dst, GLuint n)
7570b8e80941Smrg{
7571b8e80941Smrg   memcpy(dst, src, n * sizeof(struct z32f_x24s8));
7572b8e80941Smrg}
7573b8e80941Smrg
7574b8e80941Smrgstatic void
7575b8e80941Smrgunpack_float_32_uint_24_8_S8_UINT_Z24_UNORM(const GLuint *src,
7576b8e80941Smrg                                            GLuint *dst, GLuint n)
7577b8e80941Smrg{
7578b8e80941Smrg   GLuint i;
7579b8e80941Smrg   struct z32f_x24s8 *d = (struct z32f_x24s8 *) dst;
7580b8e80941Smrg   const GLdouble scale = 1.0 / (GLdouble) 0xffffff;
7581b8e80941Smrg
7582b8e80941Smrg   for (i = 0; i < n; i++) {
7583b8e80941Smrg      const GLuint z24 = src[i] >> 8;
7584b8e80941Smrg      d[i].z = z24 * scale;
7585b8e80941Smrg      d[i].x24s8 = src[i] & 0xff;
7586b8e80941Smrg      assert(d[i].z >= 0.0f);
7587b8e80941Smrg      assert(d[i].z <= 1.0f);
7588b8e80941Smrg   }
7589b8e80941Smrg}
7590b8e80941Smrg
7591b8e80941Smrg/**
7592b8e80941Smrg * Unpack depth/stencil returning as GL_FLOAT_32_UNSIGNED_INT_24_8_REV.
7593b8e80941Smrg * \param format  the source data format
7594b8e80941Smrg *
7595b8e80941Smrg * In GL_FLOAT_32_UNSIGNED_INT_24_8_REV lower 4 bytes contain float
7596b8e80941Smrg * component and higher 4 bytes contain packed 24-bit and 8-bit
7597b8e80941Smrg * components.
7598b8e80941Smrg *
7599b8e80941Smrg *    31 30 29 28 ... 4 3 2 1 0    31 30 29 ... 9 8 7 6 5 ... 2 1 0
7600b8e80941Smrg *    +-------------------------+  +--------------------------------+
7601b8e80941Smrg *    |    Float Component      |  | Unused         | 8 bit stencil |
7602b8e80941Smrg *    +-------------------------+  +--------------------------------+
7603b8e80941Smrg *          lower 4 bytes                  higher 4 bytes
7604b8e80941Smrg */
7605b8e80941Smrgvoid
7606b8e80941Smrg_mesa_unpack_float_32_uint_24_8_depth_stencil_row(mesa_format format, GLuint n,
7607b8e80941Smrg			                          const void *src, GLuint *dst)
7608b8e80941Smrg{
7609b8e80941Smrg   switch (format) {
7610b8e80941Smrg   case MESA_FORMAT_S8_UINT_Z24_UNORM:
7611b8e80941Smrg      unpack_float_32_uint_24_8_S8_UINT_Z24_UNORM(src, dst, n);
7612b8e80941Smrg      break;
7613b8e80941Smrg   case MESA_FORMAT_Z24_UNORM_S8_UINT:
7614b8e80941Smrg      unpack_float_32_uint_24_8_Z24_UNORM_S8_UINT(src, dst, n);
7615b8e80941Smrg      break;
7616b8e80941Smrg   case MESA_FORMAT_Z32_FLOAT_S8X24_UINT:
7617b8e80941Smrg      unpack_float_32_uint_24_8_Z32_FLOAT_S8X24_UINT(src, dst, n);
7618b8e80941Smrg      break;
7619b8e80941Smrg   default:
7620b8e80941Smrg      _mesa_problem(NULL,
7621b8e80941Smrg                    "bad format %s in _mesa_unpack_uint_24_8_depth_stencil_row",
7622b8e80941Smrg                    _mesa_get_format_name(format));
7623b8e80941Smrg      return;
7624b8e80941Smrg   }
7625b8e80941Smrg}
7626b8e80941Smrg
7627b8e80941Smrg/**
7628b8e80941Smrg * Unpack depth/stencil
7629b8e80941Smrg * \param format  the source data format
7630b8e80941Smrg * \param type the destination data type
7631b8e80941Smrg */
7632b8e80941Smrgvoid
7633b8e80941Smrg_mesa_unpack_depth_stencil_row(mesa_format format, GLuint n,
7634b8e80941Smrg	                       const void *src, GLenum type,
7635b8e80941Smrg                               GLuint *dst)
7636b8e80941Smrg{
7637b8e80941Smrg   assert(type == GL_UNSIGNED_INT_24_8 ||
7638b8e80941Smrg          type == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
7639b8e80941Smrg
7640b8e80941Smrg   switch (type) {
7641b8e80941Smrg   case GL_UNSIGNED_INT_24_8:
7642b8e80941Smrg      _mesa_unpack_uint_24_8_depth_stencil_row(format, n, src, dst);
7643b8e80941Smrg      break;
7644b8e80941Smrg   case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
7645b8e80941Smrg      _mesa_unpack_float_32_uint_24_8_depth_stencil_row(format, n, src, dst);
7646b8e80941Smrg      break;
7647b8e80941Smrg   default:
7648b8e80941Smrg      _mesa_problem(NULL,
7649b8e80941Smrg                    "bad type 0x%x in _mesa_unpack_depth_stencil_row",
7650b8e80941Smrg                    type);
7651b8e80941Smrg      return;
7652b8e80941Smrg   }
7653b8e80941Smrg}
7654b8e80941Smrg
7655