gallium: fix build on uclibc system
[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_has_alpha(enum pipe_format format)
67 {
68 const struct util_format_description *desc =
69 util_format_description(format);
70
71 return (desc->colorspace == UTIL_FORMAT_COLORSPACE_RGB ||
72 desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB) &&
73 desc->swizzle[3] != UTIL_FORMAT_SWIZZLE_1;
74 }
75
76
77 boolean
78 util_format_is_luminance(enum pipe_format format)
79 {
80 const struct util_format_description *desc =
81 util_format_description(format);
82
83 if ((desc->colorspace == UTIL_FORMAT_COLORSPACE_RGB ||
84 desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB) &&
85 desc->swizzle[0] == UTIL_FORMAT_SWIZZLE_X &&
86 desc->swizzle[1] == UTIL_FORMAT_SWIZZLE_X &&
87 desc->swizzle[2] == UTIL_FORMAT_SWIZZLE_X &&
88 desc->swizzle[3] == UTIL_FORMAT_SWIZZLE_1) {
89 return TRUE;
90 }
91 return FALSE;
92 }
93
94 boolean
95 util_format_is_pure_integer(enum pipe_format format)
96 {
97 const struct util_format_description *desc = util_format_description(format);
98 int i;
99
100 /* Find the first non-void channel. */
101 i = util_format_get_first_non_void_channel(format);
102 if (i == -1)
103 return FALSE;
104
105 return desc->channel[i].pure_integer ? TRUE : FALSE;
106 }
107
108 boolean
109 util_format_is_pure_sint(enum pipe_format format)
110 {
111 const struct util_format_description *desc = util_format_description(format);
112 int i;
113
114 i = util_format_get_first_non_void_channel(format);
115 if (i == -1)
116 return FALSE;
117
118 return (desc->channel[i].type == UTIL_FORMAT_TYPE_SIGNED && desc->channel[i].pure_integer) ? TRUE : FALSE;
119 }
120
121 boolean
122 util_format_is_pure_uint(enum pipe_format format)
123 {
124 const struct util_format_description *desc = util_format_description(format);
125 int i;
126
127 i = util_format_get_first_non_void_channel(format);
128 if (i == -1)
129 return FALSE;
130
131 return (desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED && desc->channel[i].pure_integer) ? TRUE : FALSE;
132 }
133
134
135 boolean
136 util_format_is_luminance_alpha(enum pipe_format format)
137 {
138 const struct util_format_description *desc =
139 util_format_description(format);
140
141 if ((desc->colorspace == UTIL_FORMAT_COLORSPACE_RGB ||
142 desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB) &&
143 desc->swizzle[0] == UTIL_FORMAT_SWIZZLE_X &&
144 desc->swizzle[1] == UTIL_FORMAT_SWIZZLE_X &&
145 desc->swizzle[2] == UTIL_FORMAT_SWIZZLE_X &&
146 desc->swizzle[3] == UTIL_FORMAT_SWIZZLE_Y) {
147 return TRUE;
148 }
149 return FALSE;
150 }
151
152
153 boolean
154 util_format_is_intensity(enum pipe_format format)
155 {
156 const struct util_format_description *desc =
157 util_format_description(format);
158
159 if ((desc->colorspace == UTIL_FORMAT_COLORSPACE_RGB ||
160 desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB) &&
161 desc->swizzle[0] == UTIL_FORMAT_SWIZZLE_X &&
162 desc->swizzle[1] == UTIL_FORMAT_SWIZZLE_X &&
163 desc->swizzle[2] == UTIL_FORMAT_SWIZZLE_X &&
164 desc->swizzle[3] == UTIL_FORMAT_SWIZZLE_X) {
165 return TRUE;
166 }
167 return FALSE;
168 }
169
170
171 boolean
172 util_format_is_supported(enum pipe_format format, unsigned bind)
173 {
174 if (util_format_is_s3tc(format) && !util_format_s3tc_enabled) {
175 return FALSE;
176 }
177
178 #ifndef TEXTURE_FLOAT_ENABLED
179 if ((bind & PIPE_BIND_RENDER_TARGET) &&
180 format != PIPE_FORMAT_R9G9B9E5_FLOAT &&
181 format != PIPE_FORMAT_R11G11B10_FLOAT &&
182 util_format_is_float(format)) {
183 return FALSE;
184 }
185 #endif
186
187 return TRUE;
188 }
189
190
191 void
192 util_format_read_4f(enum pipe_format format,
193 float *dst, unsigned dst_stride,
194 const void *src, unsigned src_stride,
195 unsigned x, unsigned y, unsigned w, unsigned h)
196 {
197 const struct util_format_description *format_desc;
198 const uint8_t *src_row;
199 float *dst_row;
200
201 format_desc = util_format_description(format);
202
203 assert(x % format_desc->block.width == 0);
204 assert(y % format_desc->block.height == 0);
205
206 src_row = (const uint8_t *)src + y*src_stride + x*(format_desc->block.bits/8);
207 dst_row = dst;
208
209 format_desc->unpack_rgba_float(dst_row, dst_stride, src_row, src_stride, w, h);
210 }
211
212
213 void
214 util_format_write_4f(enum pipe_format format,
215 const float *src, unsigned src_stride,
216 void *dst, unsigned dst_stride,
217 unsigned x, unsigned y, unsigned w, unsigned h)
218 {
219 const struct util_format_description *format_desc;
220 uint8_t *dst_row;
221 const float *src_row;
222
223 format_desc = util_format_description(format);
224
225 assert(x % format_desc->block.width == 0);
226 assert(y % format_desc->block.height == 0);
227
228 dst_row = (uint8_t *)dst + y*dst_stride + x*(format_desc->block.bits/8);
229 src_row = src;
230
231 format_desc->pack_rgba_float(dst_row, dst_stride, src_row, src_stride, w, h);
232 }
233
234
235 void
236 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)
237 {
238 const struct util_format_description *format_desc;
239 const uint8_t *src_row;
240 uint8_t *dst_row;
241
242 format_desc = util_format_description(format);
243
244 assert(x % format_desc->block.width == 0);
245 assert(y % format_desc->block.height == 0);
246
247 src_row = (const uint8_t *)src + y*src_stride + x*(format_desc->block.bits/8);
248 dst_row = dst;
249
250 format_desc->unpack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride, w, h);
251 }
252
253
254 void
255 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)
256 {
257 const struct util_format_description *format_desc;
258 uint8_t *dst_row;
259 const uint8_t *src_row;
260
261 format_desc = util_format_description(format);
262
263 assert(x % format_desc->block.width == 0);
264 assert(y % format_desc->block.height == 0);
265
266 dst_row = (uint8_t *)dst + y*dst_stride + x*(format_desc->block.bits/8);
267 src_row = src;
268
269 format_desc->pack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride, w, h);
270 }
271
272 void
273 util_format_read_4ui(enum pipe_format format,
274 unsigned *dst, unsigned dst_stride,
275 const void *src, unsigned src_stride,
276 unsigned x, unsigned y, unsigned w, unsigned h)
277 {
278 const struct util_format_description *format_desc;
279 const uint8_t *src_row;
280 unsigned *dst_row;
281
282 format_desc = util_format_description(format);
283
284 assert(x % format_desc->block.width == 0);
285 assert(y % format_desc->block.height == 0);
286
287 src_row = (const uint8_t *)src + y*src_stride + x*(format_desc->block.bits/8);
288 dst_row = dst;
289
290 format_desc->unpack_rgba_uint(dst_row, dst_stride, src_row, src_stride, w, h);
291 }
292
293 void
294 util_format_write_4ui(enum pipe_format format,
295 const unsigned int *src, unsigned src_stride,
296 void *dst, unsigned dst_stride,
297 unsigned x, unsigned y, unsigned w, unsigned h)
298 {
299 const struct util_format_description *format_desc;
300 uint8_t *dst_row;
301 const unsigned *src_row;
302
303 format_desc = util_format_description(format);
304
305 assert(x % format_desc->block.width == 0);
306 assert(y % format_desc->block.height == 0);
307
308 dst_row = (uint8_t *)dst + y*dst_stride + x*(format_desc->block.bits/8);
309 src_row = src;
310
311 format_desc->pack_rgba_uint(dst_row, dst_stride, src_row, src_stride, w, h);
312 }
313
314 void
315 util_format_read_4i(enum pipe_format format,
316 int *dst, unsigned dst_stride,
317 const void *src, unsigned src_stride,
318 unsigned x, unsigned y, unsigned w, unsigned h)
319 {
320 const struct util_format_description *format_desc;
321 const uint8_t *src_row;
322 int *dst_row;
323
324 format_desc = util_format_description(format);
325
326 assert(x % format_desc->block.width == 0);
327 assert(y % format_desc->block.height == 0);
328
329 src_row = (const uint8_t *)src + y*src_stride + x*(format_desc->block.bits/8);
330 dst_row = dst;
331
332 format_desc->unpack_rgba_sint(dst_row, dst_stride, src_row, src_stride, w, h);
333 }
334
335 void
336 util_format_write_4i(enum pipe_format format,
337 const int *src, unsigned src_stride,
338 void *dst, unsigned dst_stride,
339 unsigned x, unsigned y, unsigned w, unsigned h)
340 {
341 const struct util_format_description *format_desc;
342 uint8_t *dst_row;
343 const int *src_row;
344
345 format_desc = util_format_description(format);
346
347 assert(x % format_desc->block.width == 0);
348 assert(y % format_desc->block.height == 0);
349
350 dst_row = (uint8_t *)dst + y*dst_stride + x*(format_desc->block.bits/8);
351 src_row = src;
352
353 format_desc->pack_rgba_sint(dst_row, dst_stride, src_row, src_stride, w, h);
354 }
355
356 boolean
357 util_is_format_compatible(const struct util_format_description *src_desc,
358 const struct util_format_description *dst_desc)
359 {
360 unsigned chan;
361
362 if (src_desc->format == dst_desc->format) {
363 return TRUE;
364 }
365
366 if (src_desc->layout != UTIL_FORMAT_LAYOUT_PLAIN ||
367 dst_desc->layout != UTIL_FORMAT_LAYOUT_PLAIN) {
368 return FALSE;
369 }
370
371 if (src_desc->block.bits != dst_desc->block.bits ||
372 src_desc->nr_channels != dst_desc->nr_channels ||
373 src_desc->colorspace != dst_desc->colorspace) {
374 return FALSE;
375 }
376
377 for (chan = 0; chan < 4; ++chan) {
378 if (src_desc->channel[chan].size !=
379 dst_desc->channel[chan].size) {
380 return FALSE;
381 }
382 }
383
384 for (chan = 0; chan < 4; ++chan) {
385 enum util_format_swizzle swizzle = dst_desc->swizzle[chan];
386
387 if (swizzle < 4) {
388 if (src_desc->swizzle[chan] != swizzle) {
389 return FALSE;
390 }
391 if ((src_desc->channel[swizzle].type !=
392 dst_desc->channel[swizzle].type) ||
393 (src_desc->channel[swizzle].normalized !=
394 dst_desc->channel[swizzle].normalized)) {
395 return FALSE;
396 }
397 }
398 }
399
400 return TRUE;
401 }
402
403
404 boolean
405 util_format_fits_8unorm(const struct util_format_description *format_desc)
406 {
407 unsigned chan;
408
409 /*
410 * After linearized sRGB values require more than 8bits.
411 */
412
413 if (format_desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB) {
414 return FALSE;
415 }
416
417 switch (format_desc->layout) {
418
419 case UTIL_FORMAT_LAYOUT_S3TC:
420 /*
421 * These are straight forward.
422 */
423 return TRUE;
424 case UTIL_FORMAT_LAYOUT_RGTC:
425 if (format_desc->format == PIPE_FORMAT_RGTC1_SNORM ||
426 format_desc->format == PIPE_FORMAT_RGTC2_SNORM ||
427 format_desc->format == PIPE_FORMAT_LATC1_SNORM ||
428 format_desc->format == PIPE_FORMAT_LATC2_SNORM)
429 return FALSE;
430 return TRUE;
431
432 case UTIL_FORMAT_LAYOUT_PLAIN:
433 /*
434 * For these we can find a generic rule.
435 */
436
437 for (chan = 0; chan < format_desc->nr_channels; ++chan) {
438 switch (format_desc->channel[chan].type) {
439 case UTIL_FORMAT_TYPE_VOID:
440 break;
441 case UTIL_FORMAT_TYPE_UNSIGNED:
442 if (!format_desc->channel[chan].normalized ||
443 format_desc->channel[chan].size > 8) {
444 return FALSE;
445 }
446 break;
447 default:
448 return FALSE;
449 }
450 }
451 return TRUE;
452
453 default:
454 /*
455 * Handle all others on a case by case basis.
456 */
457
458 switch (format_desc->format) {
459 case PIPE_FORMAT_R1_UNORM:
460 case PIPE_FORMAT_UYVY:
461 case PIPE_FORMAT_YUYV:
462 case PIPE_FORMAT_R8G8_B8G8_UNORM:
463 case PIPE_FORMAT_G8R8_G8B8_UNORM:
464 return TRUE;
465
466 default:
467 return FALSE;
468 }
469 }
470 }
471
472
473 void
474 util_format_translate(enum pipe_format dst_format,
475 void *dst, unsigned dst_stride,
476 unsigned dst_x, unsigned dst_y,
477 enum pipe_format src_format,
478 const void *src, unsigned src_stride,
479 unsigned src_x, unsigned src_y,
480 unsigned width, unsigned height)
481 {
482 const struct util_format_description *dst_format_desc;
483 const struct util_format_description *src_format_desc;
484 uint8_t *dst_row;
485 const uint8_t *src_row;
486 unsigned x_step, y_step;
487 unsigned dst_step;
488 unsigned src_step;
489
490 dst_format_desc = util_format_description(dst_format);
491 src_format_desc = util_format_description(src_format);
492
493 if (util_is_format_compatible(src_format_desc, dst_format_desc)) {
494 /*
495 * Trivial case.
496 */
497
498 util_copy_rect(dst, dst_format, dst_stride, dst_x, dst_y,
499 width, height, src, (int)src_stride,
500 src_x, src_y);
501 return;
502 }
503
504 assert(dst_x % dst_format_desc->block.width == 0);
505 assert(dst_y % dst_format_desc->block.height == 0);
506 assert(src_x % src_format_desc->block.width == 0);
507 assert(src_y % src_format_desc->block.height == 0);
508
509 dst_row = (uint8_t *)dst + dst_y*dst_stride + dst_x*(dst_format_desc->block.bits/8);
510 src_row = (const uint8_t *)src + src_y*src_stride + src_x*(src_format_desc->block.bits/8);
511
512 /*
513 * This works because all pixel formats have pixel blocks with power of two
514 * sizes.
515 */
516
517 y_step = MAX2(dst_format_desc->block.height, src_format_desc->block.height);
518 x_step = MAX2(dst_format_desc->block.width, src_format_desc->block.width);
519 assert(y_step % dst_format_desc->block.height == 0);
520 assert(y_step % src_format_desc->block.height == 0);
521
522 dst_step = y_step / dst_format_desc->block.height * dst_stride;
523 src_step = y_step / src_format_desc->block.height * src_stride;
524
525 /*
526 * TODO: double formats will loose precision
527 * TODO: Add a special case for formats that are mere swizzles of each other
528 */
529
530 if (src_format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS ||
531 dst_format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS) {
532 float *tmp_z = NULL;
533 uint8_t *tmp_s = NULL;
534
535 assert(x_step == 1);
536 assert(y_step == 1);
537
538 if (src_format_desc->unpack_z_float &&
539 dst_format_desc->pack_z_float) {
540 tmp_z = MALLOC(width * sizeof *tmp_z);
541 }
542
543 if (src_format_desc->unpack_s_8uint &&
544 dst_format_desc->pack_s_8uint) {
545 tmp_s = MALLOC(width * sizeof *tmp_s);
546 }
547
548 while (height--) {
549 if (tmp_z) {
550 src_format_desc->unpack_z_float(tmp_z, 0, src_row, src_stride, width, 1);
551 dst_format_desc->pack_z_float(dst_row, dst_stride, tmp_z, 0, width, 1);
552 }
553
554 if (tmp_s) {
555 src_format_desc->unpack_s_8uint(tmp_s, 0, src_row, src_stride, width, 1);
556 dst_format_desc->pack_s_8uint(dst_row, dst_stride, tmp_s, 0, width, 1);
557 }
558
559 dst_row += dst_step;
560 src_row += src_step;
561 }
562
563 FREE(tmp_s);
564
565 FREE(tmp_z);
566
567 return;
568 }
569
570 if (util_format_fits_8unorm(src_format_desc) ||
571 util_format_fits_8unorm(dst_format_desc)) {
572 unsigned tmp_stride;
573 uint8_t *tmp_row;
574
575 tmp_stride = MAX2(width, x_step) * 4 * sizeof *tmp_row;
576 tmp_row = MALLOC(y_step * tmp_stride);
577 if (!tmp_row)
578 return;
579
580 while (height >= y_step) {
581 src_format_desc->unpack_rgba_8unorm(tmp_row, tmp_stride, src_row, src_stride, width, y_step);
582 dst_format_desc->pack_rgba_8unorm(dst_row, dst_stride, tmp_row, tmp_stride, width, y_step);
583
584 dst_row += dst_step;
585 src_row += src_step;
586 height -= y_step;
587 }
588
589 if (height) {
590 src_format_desc->unpack_rgba_8unorm(tmp_row, tmp_stride, src_row, src_stride, width, height);
591 dst_format_desc->pack_rgba_8unorm(dst_row, dst_stride, tmp_row, tmp_stride, width, height);
592 }
593
594 FREE(tmp_row);
595 }
596 else {
597 unsigned tmp_stride;
598 float *tmp_row;
599
600 tmp_stride = MAX2(width, x_step) * 4 * sizeof *tmp_row;
601 tmp_row = MALLOC(y_step * tmp_stride);
602 if (!tmp_row)
603 return;
604
605 while (height >= y_step) {
606 src_format_desc->unpack_rgba_float(tmp_row, tmp_stride, src_row, src_stride, width, y_step);
607 dst_format_desc->pack_rgba_float(dst_row, dst_stride, tmp_row, tmp_stride, width, y_step);
608
609 dst_row += dst_step;
610 src_row += src_step;
611 height -= y_step;
612 }
613
614 if (height) {
615 src_format_desc->unpack_rgba_float(tmp_row, tmp_stride, src_row, src_stride, width, height);
616 dst_format_desc->pack_rgba_float(dst_row, dst_stride, tmp_row, tmp_stride, width, height);
617 }
618
619 FREE(tmp_row);
620 }
621 }
622
623 void util_format_compose_swizzles(const unsigned char swz1[4],
624 const unsigned char swz2[4],
625 unsigned char dst[4])
626 {
627 unsigned i;
628
629 for (i = 0; i < 4; i++) {
630 dst[i] = swz2[i] <= UTIL_FORMAT_SWIZZLE_W ?
631 swz1[swz2[i]] : swz2[i];
632 }
633 }
634
635 void util_format_apply_color_swizzle(union pipe_color_union *dst,
636 const union pipe_color_union *src,
637 const unsigned char swz[4],
638 const boolean is_integer)
639 {
640 unsigned c;
641
642 if (is_integer) {
643 for (c = 0; c < 4; ++c) {
644 switch (swz[c]) {
645 case PIPE_SWIZZLE_RED: dst->ui[c] = src->ui[0]; break;
646 case PIPE_SWIZZLE_GREEN: dst->ui[c] = src->ui[1]; break;
647 case PIPE_SWIZZLE_BLUE: dst->ui[c] = src->ui[2]; break;
648 case PIPE_SWIZZLE_ALPHA: dst->ui[c] = src->ui[3]; break;
649 default:
650 dst->ui[c] = (swz[c] == PIPE_SWIZZLE_ONE) ? 1 : 0;
651 break;
652 }
653 }
654 } else {
655 for (c = 0; c < 4; ++c) {
656 switch (swz[c]) {
657 case PIPE_SWIZZLE_RED: dst->f[c] = src->f[0]; break;
658 case PIPE_SWIZZLE_GREEN: dst->f[c] = src->f[1]; break;
659 case PIPE_SWIZZLE_BLUE: dst->f[c] = src->f[2]; break;
660 case PIPE_SWIZZLE_ALPHA: dst->f[c] = src->f[3]; break;
661 default:
662 dst->f[c] = (swz[c] == PIPE_SWIZZLE_ONE) ? 1.0f : 0.0f;
663 break;
664 }
665 }
666 }
667 }
668
669 void util_format_swizzle_4f(float *dst, const float *src,
670 const unsigned char swz[4])
671 {
672 unsigned i;
673
674 for (i = 0; i < 4; i++) {
675 if (swz[i] <= UTIL_FORMAT_SWIZZLE_W)
676 dst[i] = src[swz[i]];
677 else if (swz[i] == UTIL_FORMAT_SWIZZLE_0)
678 dst[i] = 0;
679 else if (swz[i] == UTIL_FORMAT_SWIZZLE_1)
680 dst[i] = 1;
681 }
682 }
683
684 void util_format_unswizzle_4f(float *dst, const float *src,
685 const unsigned char swz[4])
686 {
687 unsigned i;
688
689 for (i = 0; i < 4; i++) {
690 switch (swz[i]) {
691 case UTIL_FORMAT_SWIZZLE_X:
692 dst[0] = src[i];
693 break;
694 case UTIL_FORMAT_SWIZZLE_Y:
695 dst[1] = src[i];
696 break;
697 case UTIL_FORMAT_SWIZZLE_Z:
698 dst[2] = src[i];
699 break;
700 case UTIL_FORMAT_SWIZZLE_W:
701 dst[3] = src[i];
702 break;
703 }
704 }
705 }