ddce95601a6ee97d86faa076498d552a7e55aa45
[mesa.git] / src / gallium / auxiliary / util / u_format.c
1 /**************************************************************************
2 *
3 * Copyright 2010 VMware, Inc.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28 /**
29 * @file
30 * Pixel format accessor functions.
31 *
32 * @author Jose Fonseca <jfonseca@vmware.com>
33 */
34
35 #include "u_math.h"
36 #include "u_memory.h"
37 #include "u_rect.h"
38 #include "u_format.h"
39 #include "u_format_s3tc.h"
40
41 #include "pipe/p_defines.h"
42
43
44 boolean
45 util_format_is_float(enum pipe_format format)
46 {
47 const struct util_format_description *desc = util_format_description(format);
48 unsigned i;
49
50 assert(desc);
51 if (!desc) {
52 return FALSE;
53 }
54
55 i = util_format_get_first_non_void_channel(format);
56 if (i == -1) {
57 return FALSE;
58 }
59
60 return desc->channel[i].type == UTIL_FORMAT_TYPE_FLOAT ? TRUE : FALSE;
61 }
62
63
64 /** Test if the format contains RGB, but not alpha */
65 boolean
66 util_format_is_rgb_no_alpha(enum pipe_format format)
67 {
68 const struct util_format_description *desc =
69 util_format_description(format);
70
71 if ((desc->colorspace == UTIL_FORMAT_COLORSPACE_RGB ||
72 desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB) &&
73 desc->swizzle[3] == UTIL_FORMAT_SWIZZLE_1) {
74 return TRUE;
75 }
76 return FALSE;
77 }
78
79
80 boolean
81 util_format_is_luminance(enum pipe_format format)
82 {
83 const struct util_format_description *desc =
84 util_format_description(format);
85
86 if ((desc->colorspace == UTIL_FORMAT_COLORSPACE_RGB ||
87 desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB) &&
88 desc->swizzle[0] == UTIL_FORMAT_SWIZZLE_X &&
89 desc->swizzle[1] == UTIL_FORMAT_SWIZZLE_X &&
90 desc->swizzle[2] == UTIL_FORMAT_SWIZZLE_X &&
91 desc->swizzle[3] == UTIL_FORMAT_SWIZZLE_1) {
92 return TRUE;
93 }
94 return FALSE;
95 }
96
97 boolean
98 util_format_is_pure_integer(enum pipe_format format)
99 {
100 const struct util_format_description *desc = util_format_description(format);
101 int i;
102
103 /* Find the first non-void channel. */
104 i = util_format_get_first_non_void_channel(format);
105 if (i == -1)
106 return FALSE;
107
108 return desc->channel[i].pure_integer ? TRUE : FALSE;
109 }
110
111 boolean
112 util_format_is_pure_sint(enum pipe_format format)
113 {
114 const struct util_format_description *desc = util_format_description(format);
115 int i;
116
117 i = util_format_get_first_non_void_channel(format);
118 if (i == -1)
119 return FALSE;
120
121 return (desc->channel[i].type == UTIL_FORMAT_TYPE_SIGNED && desc->channel[i].pure_integer) ? TRUE : FALSE;
122 }
123
124 boolean
125 util_format_is_pure_uint(enum pipe_format format)
126 {
127 const struct util_format_description *desc = util_format_description(format);
128 int i;
129
130 i = util_format_get_first_non_void_channel(format);
131 if (i == -1)
132 return FALSE;
133
134 return (desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED && desc->channel[i].pure_integer) ? TRUE : FALSE;
135 }
136
137 boolean
138 util_format_is_array(const struct util_format_description *desc)
139 {
140 unsigned chan;
141
142 if (desc->layout != UTIL_FORMAT_LAYOUT_PLAIN ||
143 desc->colorspace != UTIL_FORMAT_COLORSPACE_RGB ||
144 desc->block.width != 1 ||
145 desc->block.height != 1) {
146 return FALSE;
147 }
148
149 for (chan = 0; chan < desc->nr_channels; ++chan) {
150 if (desc->channel[chan].size != desc->channel[0].size)
151 return FALSE;
152
153 if (desc->channel[chan].type == UTIL_FORMAT_TYPE_VOID && (chan + 1) == desc->nr_channels)
154 continue;
155
156 if (desc->channel[chan].type != desc->channel[0].type)
157 return FALSE;
158
159 if (desc->channel[chan].normalized != desc->channel[0].normalized)
160 return FALSE;
161
162 if (desc->channel[chan].pure_integer != desc->channel[0].pure_integer)
163 return FALSE;
164 }
165
166 if (desc->nr_channels == 4) {
167 if (desc->swizzle[3] < 3)
168 return FALSE;
169 } else {
170 for (chan = 0; chan < desc->nr_channels; ++chan) {
171 if (desc->swizzle[chan] != chan)
172 return FALSE;
173 }
174 }
175
176 return TRUE;
177 }
178
179 boolean
180 util_format_is_luminance_alpha(enum pipe_format format)
181 {
182 const struct util_format_description *desc =
183 util_format_description(format);
184
185 if ((desc->colorspace == UTIL_FORMAT_COLORSPACE_RGB ||
186 desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB) &&
187 desc->swizzle[0] == UTIL_FORMAT_SWIZZLE_X &&
188 desc->swizzle[1] == UTIL_FORMAT_SWIZZLE_X &&
189 desc->swizzle[2] == UTIL_FORMAT_SWIZZLE_X &&
190 desc->swizzle[3] == UTIL_FORMAT_SWIZZLE_Y) {
191 return TRUE;
192 }
193 return FALSE;
194 }
195
196
197 boolean
198 util_format_is_intensity(enum pipe_format format)
199 {
200 const struct util_format_description *desc =
201 util_format_description(format);
202
203 if ((desc->colorspace == UTIL_FORMAT_COLORSPACE_RGB ||
204 desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB) &&
205 desc->swizzle[0] == UTIL_FORMAT_SWIZZLE_X &&
206 desc->swizzle[1] == UTIL_FORMAT_SWIZZLE_X &&
207 desc->swizzle[2] == UTIL_FORMAT_SWIZZLE_X &&
208 desc->swizzle[3] == UTIL_FORMAT_SWIZZLE_X) {
209 return TRUE;
210 }
211 return FALSE;
212 }
213
214
215 boolean
216 util_format_is_supported(enum pipe_format format, unsigned bind)
217 {
218 if (util_format_is_s3tc(format) && !util_format_s3tc_enabled) {
219 return FALSE;
220 }
221
222 #ifndef TEXTURE_FLOAT_ENABLED
223 if ((bind & PIPE_BIND_RENDER_TARGET) &&
224 format != PIPE_FORMAT_R9G9B9E5_FLOAT &&
225 format != PIPE_FORMAT_R11G11B10_FLOAT &&
226 util_format_is_float(format)) {
227 return FALSE;
228 }
229 #endif
230
231 return TRUE;
232 }
233
234
235 void
236 util_format_read_4f(enum pipe_format format,
237 float *dst, unsigned dst_stride,
238 const void *src, unsigned src_stride,
239 unsigned x, unsigned y, unsigned w, unsigned h)
240 {
241 const struct util_format_description *format_desc;
242 const uint8_t *src_row;
243 float *dst_row;
244
245 format_desc = util_format_description(format);
246
247 assert(x % format_desc->block.width == 0);
248 assert(y % format_desc->block.height == 0);
249
250 src_row = (const uint8_t *)src + y*src_stride + x*(format_desc->block.bits/8);
251 dst_row = dst;
252
253 format_desc->unpack_rgba_float(dst_row, dst_stride, src_row, src_stride, w, h);
254 }
255
256
257 void
258 util_format_write_4f(enum pipe_format format,
259 const float *src, unsigned src_stride,
260 void *dst, unsigned dst_stride,
261 unsigned x, unsigned y, unsigned w, unsigned h)
262 {
263 const struct util_format_description *format_desc;
264 uint8_t *dst_row;
265 const float *src_row;
266
267 format_desc = util_format_description(format);
268
269 assert(x % format_desc->block.width == 0);
270 assert(y % format_desc->block.height == 0);
271
272 dst_row = (uint8_t *)dst + y*dst_stride + x*(format_desc->block.bits/8);
273 src_row = src;
274
275 format_desc->pack_rgba_float(dst_row, dst_stride, src_row, src_stride, w, h);
276 }
277
278
279 void
280 util_format_read_4ub(enum pipe_format format, uint8_t *dst, unsigned dst_stride, const void *src, unsigned src_stride, unsigned x, unsigned y, unsigned w, unsigned h)
281 {
282 const struct util_format_description *format_desc;
283 const uint8_t *src_row;
284 uint8_t *dst_row;
285
286 format_desc = util_format_description(format);
287
288 assert(x % format_desc->block.width == 0);
289 assert(y % format_desc->block.height == 0);
290
291 src_row = (const uint8_t *)src + y*src_stride + x*(format_desc->block.bits/8);
292 dst_row = dst;
293
294 format_desc->unpack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride, w, h);
295 }
296
297
298 void
299 util_format_write_4ub(enum pipe_format format, const uint8_t *src, unsigned src_stride, void *dst, unsigned dst_stride, unsigned x, unsigned y, unsigned w, unsigned h)
300 {
301 const struct util_format_description *format_desc;
302 uint8_t *dst_row;
303 const uint8_t *src_row;
304
305 format_desc = util_format_description(format);
306
307 assert(x % format_desc->block.width == 0);
308 assert(y % format_desc->block.height == 0);
309
310 dst_row = (uint8_t *)dst + y*dst_stride + x*(format_desc->block.bits/8);
311 src_row = src;
312
313 format_desc->pack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride, w, h);
314 }
315
316 void
317 util_format_read_4ui(enum pipe_format format,
318 unsigned *dst, unsigned dst_stride,
319 const void *src, unsigned src_stride,
320 unsigned x, unsigned y, unsigned w, unsigned h)
321 {
322 const struct util_format_description *format_desc;
323 const uint8_t *src_row;
324 unsigned *dst_row;
325
326 format_desc = util_format_description(format);
327
328 assert(x % format_desc->block.width == 0);
329 assert(y % format_desc->block.height == 0);
330
331 src_row = (const uint8_t *)src + y*src_stride + x*(format_desc->block.bits/8);
332 dst_row = dst;
333
334 format_desc->unpack_rgba_uint(dst_row, dst_stride, src_row, src_stride, w, h);
335 }
336
337 void
338 util_format_write_4ui(enum pipe_format format,
339 const unsigned int *src, unsigned src_stride,
340 void *dst, unsigned dst_stride,
341 unsigned x, unsigned y, unsigned w, unsigned h)
342 {
343 const struct util_format_description *format_desc;
344 uint8_t *dst_row;
345 const unsigned *src_row;
346
347 format_desc = util_format_description(format);
348
349 assert(x % format_desc->block.width == 0);
350 assert(y % format_desc->block.height == 0);
351
352 dst_row = (uint8_t *)dst + y*dst_stride + x*(format_desc->block.bits/8);
353 src_row = src;
354
355 format_desc->pack_rgba_uint(dst_row, dst_stride, src_row, src_stride, w, h);
356 }
357
358 void
359 util_format_read_4i(enum pipe_format format,
360 int *dst, unsigned dst_stride,
361 const void *src, unsigned src_stride,
362 unsigned x, unsigned y, unsigned w, unsigned h)
363 {
364 const struct util_format_description *format_desc;
365 const uint8_t *src_row;
366 int *dst_row;
367
368 format_desc = util_format_description(format);
369
370 assert(x % format_desc->block.width == 0);
371 assert(y % format_desc->block.height == 0);
372
373 src_row = (const uint8_t *)src + y*src_stride + x*(format_desc->block.bits/8);
374 dst_row = dst;
375
376 format_desc->unpack_rgba_sint(dst_row, dst_stride, src_row, src_stride, w, h);
377 }
378
379 void
380 util_format_write_4i(enum pipe_format format,
381 const int *src, unsigned src_stride,
382 void *dst, unsigned dst_stride,
383 unsigned x, unsigned y, unsigned w, unsigned h)
384 {
385 const struct util_format_description *format_desc;
386 uint8_t *dst_row;
387 const int *src_row;
388
389 format_desc = util_format_description(format);
390
391 assert(x % format_desc->block.width == 0);
392 assert(y % format_desc->block.height == 0);
393
394 dst_row = (uint8_t *)dst + y*dst_stride + x*(format_desc->block.bits/8);
395 src_row = src;
396
397 format_desc->pack_rgba_sint(dst_row, dst_stride, src_row, src_stride, w, h);
398 }
399
400 boolean
401 util_is_format_compatible(const struct util_format_description *src_desc,
402 const struct util_format_description *dst_desc)
403 {
404 unsigned chan;
405
406 if (src_desc->format == dst_desc->format) {
407 return TRUE;
408 }
409
410 if (src_desc->layout != UTIL_FORMAT_LAYOUT_PLAIN ||
411 dst_desc->layout != UTIL_FORMAT_LAYOUT_PLAIN) {
412 return FALSE;
413 }
414
415 if (src_desc->block.bits != dst_desc->block.bits ||
416 src_desc->nr_channels != dst_desc->nr_channels ||
417 src_desc->colorspace != dst_desc->colorspace) {
418 return FALSE;
419 }
420
421 for (chan = 0; chan < 4; ++chan) {
422 if (src_desc->channel[chan].size !=
423 dst_desc->channel[chan].size) {
424 return FALSE;
425 }
426 }
427
428 for (chan = 0; chan < 4; ++chan) {
429 enum util_format_swizzle swizzle = dst_desc->swizzle[chan];
430
431 if (swizzle < 4) {
432 if (src_desc->swizzle[chan] != swizzle) {
433 return FALSE;
434 }
435 if ((src_desc->channel[swizzle].type !=
436 dst_desc->channel[swizzle].type) ||
437 (src_desc->channel[swizzle].normalized !=
438 dst_desc->channel[swizzle].normalized)) {
439 return FALSE;
440 }
441 }
442 }
443
444 return TRUE;
445 }
446
447
448 boolean
449 util_format_fits_8unorm(const struct util_format_description *format_desc)
450 {
451 unsigned chan;
452
453 /*
454 * After linearized sRGB values require more than 8bits.
455 */
456
457 if (format_desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB) {
458 return FALSE;
459 }
460
461 switch (format_desc->layout) {
462
463 case UTIL_FORMAT_LAYOUT_S3TC:
464 /*
465 * These are straight forward.
466 */
467 return TRUE;
468 case UTIL_FORMAT_LAYOUT_RGTC:
469 if (format_desc->format == PIPE_FORMAT_RGTC1_SNORM ||
470 format_desc->format == PIPE_FORMAT_RGTC2_SNORM ||
471 format_desc->format == PIPE_FORMAT_LATC1_SNORM ||
472 format_desc->format == PIPE_FORMAT_LATC2_SNORM)
473 return FALSE;
474 return TRUE;
475
476 case UTIL_FORMAT_LAYOUT_PLAIN:
477 /*
478 * For these we can find a generic rule.
479 */
480
481 for (chan = 0; chan < format_desc->nr_channels; ++chan) {
482 switch (format_desc->channel[chan].type) {
483 case UTIL_FORMAT_TYPE_VOID:
484 break;
485 case UTIL_FORMAT_TYPE_UNSIGNED:
486 if (!format_desc->channel[chan].normalized ||
487 format_desc->channel[chan].size > 8) {
488 return FALSE;
489 }
490 break;
491 default:
492 return FALSE;
493 }
494 }
495 return TRUE;
496
497 default:
498 /*
499 * Handle all others on a case by case basis.
500 */
501
502 switch (format_desc->format) {
503 case PIPE_FORMAT_R1_UNORM:
504 case PIPE_FORMAT_UYVY:
505 case PIPE_FORMAT_YUYV:
506 case PIPE_FORMAT_R8G8_B8G8_UNORM:
507 case PIPE_FORMAT_G8R8_G8B8_UNORM:
508 return TRUE;
509
510 default:
511 return FALSE;
512 }
513 }
514 }
515
516
517 void
518 util_format_translate(enum pipe_format dst_format,
519 void *dst, unsigned dst_stride,
520 unsigned dst_x, unsigned dst_y,
521 enum pipe_format src_format,
522 const void *src, unsigned src_stride,
523 unsigned src_x, unsigned src_y,
524 unsigned width, unsigned height)
525 {
526 const struct util_format_description *dst_format_desc;
527 const struct util_format_description *src_format_desc;
528 uint8_t *dst_row;
529 const uint8_t *src_row;
530 unsigned x_step, y_step;
531 unsigned dst_step;
532 unsigned src_step;
533
534 dst_format_desc = util_format_description(dst_format);
535 src_format_desc = util_format_description(src_format);
536
537 if (util_is_format_compatible(src_format_desc, dst_format_desc)) {
538 /*
539 * Trivial case.
540 */
541
542 util_copy_rect(dst, dst_format, dst_stride, dst_x, dst_y,
543 width, height, src, (int)src_stride,
544 src_x, src_y);
545 return;
546 }
547
548 assert(dst_x % dst_format_desc->block.width == 0);
549 assert(dst_y % dst_format_desc->block.height == 0);
550 assert(src_x % src_format_desc->block.width == 0);
551 assert(src_y % src_format_desc->block.height == 0);
552
553 dst_row = (uint8_t *)dst + dst_y*dst_stride + dst_x*(dst_format_desc->block.bits/8);
554 src_row = (const uint8_t *)src + src_y*src_stride + src_x*(src_format_desc->block.bits/8);
555
556 /*
557 * This works because all pixel formats have pixel blocks with power of two
558 * sizes.
559 */
560
561 y_step = MAX2(dst_format_desc->block.height, src_format_desc->block.height);
562 x_step = MAX2(dst_format_desc->block.width, src_format_desc->block.width);
563 assert(y_step % dst_format_desc->block.height == 0);
564 assert(y_step % src_format_desc->block.height == 0);
565
566 dst_step = y_step / dst_format_desc->block.height * dst_stride;
567 src_step = y_step / src_format_desc->block.height * src_stride;
568
569 /*
570 * TODO: double formats will loose precision
571 * TODO: Add a special case for formats that are mere swizzles of each other
572 */
573
574 if (src_format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS ||
575 dst_format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS) {
576 float *tmp_z = NULL;
577 uint8_t *tmp_s = NULL;
578
579 assert(x_step == 1);
580 assert(y_step == 1);
581
582 if (src_format_desc->unpack_z_float &&
583 dst_format_desc->pack_z_float) {
584 tmp_z = MALLOC(width * sizeof *tmp_z);
585 }
586
587 if (src_format_desc->unpack_s_8uint &&
588 dst_format_desc->pack_s_8uint) {
589 tmp_s = MALLOC(width * sizeof *tmp_s);
590 }
591
592 while (height--) {
593 if (tmp_z) {
594 src_format_desc->unpack_z_float(tmp_z, 0, src_row, src_stride, width, 1);
595 dst_format_desc->pack_z_float(dst_row, dst_stride, tmp_z, 0, width, 1);
596 }
597
598 if (tmp_s) {
599 src_format_desc->unpack_s_8uint(tmp_s, 0, src_row, src_stride, width, 1);
600 dst_format_desc->pack_s_8uint(dst_row, dst_stride, tmp_s, 0, width, 1);
601 }
602
603 dst_row += dst_step;
604 src_row += src_step;
605 }
606
607 FREE(tmp_s);
608
609 FREE(tmp_z);
610
611 return;
612 }
613
614 if (util_format_fits_8unorm(src_format_desc) ||
615 util_format_fits_8unorm(dst_format_desc)) {
616 unsigned tmp_stride;
617 uint8_t *tmp_row;
618
619 tmp_stride = MAX2(width, x_step) * 4 * sizeof *tmp_row;
620 tmp_row = MALLOC(y_step * tmp_stride);
621 if (!tmp_row)
622 return;
623
624 while (height >= y_step) {
625 src_format_desc->unpack_rgba_8unorm(tmp_row, tmp_stride, src_row, src_stride, width, y_step);
626 dst_format_desc->pack_rgba_8unorm(dst_row, dst_stride, tmp_row, tmp_stride, width, y_step);
627
628 dst_row += dst_step;
629 src_row += src_step;
630 height -= y_step;
631 }
632
633 if (height) {
634 src_format_desc->unpack_rgba_8unorm(tmp_row, tmp_stride, src_row, src_stride, width, height);
635 dst_format_desc->pack_rgba_8unorm(dst_row, dst_stride, tmp_row, tmp_stride, width, height);
636 }
637
638 FREE(tmp_row);
639 }
640 else {
641 unsigned tmp_stride;
642 float *tmp_row;
643
644 tmp_stride = MAX2(width, x_step) * 4 * sizeof *tmp_row;
645 tmp_row = MALLOC(y_step * tmp_stride);
646 if (!tmp_row)
647 return;
648
649 while (height >= y_step) {
650 src_format_desc->unpack_rgba_float(tmp_row, tmp_stride, src_row, src_stride, width, y_step);
651 dst_format_desc->pack_rgba_float(dst_row, dst_stride, tmp_row, tmp_stride, width, y_step);
652
653 dst_row += dst_step;
654 src_row += src_step;
655 height -= y_step;
656 }
657
658 if (height) {
659 src_format_desc->unpack_rgba_float(tmp_row, tmp_stride, src_row, src_stride, width, height);
660 dst_format_desc->pack_rgba_float(dst_row, dst_stride, tmp_row, tmp_stride, width, height);
661 }
662
663 FREE(tmp_row);
664 }
665 }
666
667 void util_format_compose_swizzles(const unsigned char swz1[4],
668 const unsigned char swz2[4],
669 unsigned char dst[4])
670 {
671 unsigned i;
672
673 for (i = 0; i < 4; i++) {
674 dst[i] = swz2[i] <= UTIL_FORMAT_SWIZZLE_W ?
675 swz1[swz2[i]] : swz2[i];
676 }
677 }
678
679 void util_format_swizzle_4f(float *dst, const float *src,
680 const unsigned char swz[4])
681 {
682 unsigned i;
683
684 for (i = 0; i < 4; i++) {
685 if (swz[i] <= UTIL_FORMAT_SWIZZLE_W)
686 dst[i] = src[swz[i]];
687 else if (swz[i] == UTIL_FORMAT_SWIZZLE_0)
688 dst[i] = 0;
689 else if (swz[i] == UTIL_FORMAT_SWIZZLE_1)
690 dst[i] = 1;
691 }
692 }
693
694 void util_format_unswizzle_4f(float *dst, const float *src,
695 const unsigned char swz[4])
696 {
697 unsigned i;
698
699 for (i = 0; i < 4; i++) {
700 switch (swz[i]) {
701 case UTIL_FORMAT_SWIZZLE_X:
702 dst[0] = src[i];
703 break;
704 case UTIL_FORMAT_SWIZZLE_Y:
705 dst[1] = src[i];
706 break;
707 case UTIL_FORMAT_SWIZZLE_Z:
708 dst[2] = src[i];
709 break;
710 case UTIL_FORMAT_SWIZZLE_W:
711 dst[3] = src[i];
712 break;
713 }
714 }
715 }