1 /**************************************************************************
3 * Copyright 2010 VMware, Inc.
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:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
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.
26 **************************************************************************/
30 * Pixel format accessor functions.
32 * @author Jose Fonseca <jfonseca@vmware.com>
38 #include "u_format_s3tc.h"
39 #include "u_surface.h"
41 #include "pipe/p_defines.h"
45 util_format_is_float(enum pipe_format format
)
47 const struct util_format_description
*desc
= util_format_description(format
);
55 i
= util_format_get_first_non_void_channel(format
);
60 return desc
->channel
[i
].type
== UTIL_FORMAT_TYPE_FLOAT
? TRUE
: FALSE
;
64 /** Test if the format contains RGB, but not alpha */
66 util_format_has_alpha(enum pipe_format format
)
68 const struct util_format_description
*desc
=
69 util_format_description(format
);
71 return (desc
->colorspace
== UTIL_FORMAT_COLORSPACE_RGB
||
72 desc
->colorspace
== UTIL_FORMAT_COLORSPACE_SRGB
) &&
73 desc
->swizzle
[3] != UTIL_FORMAT_SWIZZLE_1
;
78 util_format_is_luminance(enum pipe_format format
)
80 const struct util_format_description
*desc
=
81 util_format_description(format
);
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
) {
95 util_format_is_alpha(enum pipe_format format
)
97 const struct util_format_description
*desc
=
98 util_format_description(format
);
100 if ((desc
->colorspace
== UTIL_FORMAT_COLORSPACE_RGB
||
101 desc
->colorspace
== UTIL_FORMAT_COLORSPACE_SRGB
) &&
102 desc
->swizzle
[0] == UTIL_FORMAT_SWIZZLE_0
&&
103 desc
->swizzle
[1] == UTIL_FORMAT_SWIZZLE_0
&&
104 desc
->swizzle
[2] == UTIL_FORMAT_SWIZZLE_0
&&
105 desc
->swizzle
[3] == UTIL_FORMAT_SWIZZLE_X
) {
112 util_format_is_pure_integer(enum pipe_format format
)
114 const struct util_format_description
*desc
= util_format_description(format
);
117 /* Find the first non-void channel. */
118 i
= util_format_get_first_non_void_channel(format
);
122 return desc
->channel
[i
].pure_integer
? TRUE
: FALSE
;
126 util_format_is_pure_sint(enum pipe_format format
)
128 const struct util_format_description
*desc
= util_format_description(format
);
131 i
= util_format_get_first_non_void_channel(format
);
135 return (desc
->channel
[i
].type
== UTIL_FORMAT_TYPE_SIGNED
&& desc
->channel
[i
].pure_integer
) ? TRUE
: FALSE
;
139 util_format_is_pure_uint(enum pipe_format format
)
141 const struct util_format_description
*desc
= util_format_description(format
);
144 i
= util_format_get_first_non_void_channel(format
);
148 return (desc
->channel
[i
].type
== UTIL_FORMAT_TYPE_UNSIGNED
&& desc
->channel
[i
].pure_integer
) ? TRUE
: FALSE
;
152 * Returns true if all non-void channels are normalized signed.
155 util_format_is_snorm(enum pipe_format format
)
157 const struct util_format_description
*desc
= util_format_description(format
);
163 i
= util_format_get_first_non_void_channel(format
);
167 return desc
->channel
[i
].type
== UTIL_FORMAT_TYPE_SIGNED
&&
168 !desc
->channel
[i
].pure_integer
&&
169 desc
->channel
[i
].normalized
;
173 util_format_is_luminance_alpha(enum pipe_format format
)
175 const struct util_format_description
*desc
=
176 util_format_description(format
);
178 if ((desc
->colorspace
== UTIL_FORMAT_COLORSPACE_RGB
||
179 desc
->colorspace
== UTIL_FORMAT_COLORSPACE_SRGB
) &&
180 desc
->swizzle
[0] == UTIL_FORMAT_SWIZZLE_X
&&
181 desc
->swizzle
[1] == UTIL_FORMAT_SWIZZLE_X
&&
182 desc
->swizzle
[2] == UTIL_FORMAT_SWIZZLE_X
&&
183 desc
->swizzle
[3] == UTIL_FORMAT_SWIZZLE_Y
) {
191 util_format_is_intensity(enum pipe_format format
)
193 const struct util_format_description
*desc
=
194 util_format_description(format
);
196 if ((desc
->colorspace
== UTIL_FORMAT_COLORSPACE_RGB
||
197 desc
->colorspace
== UTIL_FORMAT_COLORSPACE_SRGB
) &&
198 desc
->swizzle
[0] == UTIL_FORMAT_SWIZZLE_X
&&
199 desc
->swizzle
[1] == UTIL_FORMAT_SWIZZLE_X
&&
200 desc
->swizzle
[2] == UTIL_FORMAT_SWIZZLE_X
&&
201 desc
->swizzle
[3] == UTIL_FORMAT_SWIZZLE_X
) {
208 util_format_is_subsampled_422(enum pipe_format format
)
210 const struct util_format_description
*desc
=
211 util_format_description(format
);
213 return desc
->layout
== UTIL_FORMAT_LAYOUT_SUBSAMPLED
&&
214 desc
->block
.width
== 2 &&
215 desc
->block
.height
== 1 &&
216 desc
->block
.bits
== 32;
220 util_format_is_supported(enum pipe_format format
, unsigned bind
)
222 if (util_format_is_s3tc(format
) && !util_format_s3tc_enabled
) {
226 #ifndef TEXTURE_FLOAT_ENABLED
227 if ((bind
& PIPE_BIND_RENDER_TARGET
) &&
228 format
!= PIPE_FORMAT_R9G9B9E5_FLOAT
&&
229 format
!= PIPE_FORMAT_R11G11B10_FLOAT
&&
230 util_format_is_float(format
)) {
240 * Calculates the MRD for the depth format. MRD is used in depth bias
241 * for UNORM and unbound depth buffers. When the depth buffer is floating
242 * point, the depth bias calculation does not use the MRD. However, the
243 * default MRD will be 1.0 / ((1 << 24) - 1).
246 util_get_depth_format_mrd(const struct util_format_description
*desc
)
249 * Depth buffer formats without a depth component OR scenarios
250 * without a bound depth buffer default to D24.
252 double mrd
= 1.0 / ((1 << 24) - 1);
253 unsigned depth_channel
;
258 * Some depth formats do not store the depth component in the first
259 * channel, detect the format and adjust the depth channel. Get the
260 * swizzled depth component channel.
262 depth_channel
= desc
->swizzle
[0];
264 if (desc
->channel
[depth_channel
].type
== UTIL_FORMAT_TYPE_UNSIGNED
&&
265 desc
->channel
[depth_channel
].normalized
) {
268 depth_bits
= desc
->channel
[depth_channel
].size
;
269 mrd
= 1.0 / ((1ULL << depth_bits
) - 1);
277 util_format_read_4f(enum pipe_format format
,
278 float *dst
, unsigned dst_stride
,
279 const void *src
, unsigned src_stride
,
280 unsigned x
, unsigned y
, unsigned w
, unsigned h
)
282 const struct util_format_description
*format_desc
;
283 const uint8_t *src_row
;
286 format_desc
= util_format_description(format
);
288 assert(x
% format_desc
->block
.width
== 0);
289 assert(y
% format_desc
->block
.height
== 0);
291 src_row
= (const uint8_t *)src
+ y
*src_stride
+ x
*(format_desc
->block
.bits
/8);
294 format_desc
->unpack_rgba_float(dst_row
, dst_stride
, src_row
, src_stride
, w
, h
);
299 util_format_write_4f(enum pipe_format format
,
300 const float *src
, unsigned src_stride
,
301 void *dst
, unsigned dst_stride
,
302 unsigned x
, unsigned y
, unsigned w
, unsigned h
)
304 const struct util_format_description
*format_desc
;
306 const float *src_row
;
308 format_desc
= util_format_description(format
);
310 assert(x
% format_desc
->block
.width
== 0);
311 assert(y
% format_desc
->block
.height
== 0);
313 dst_row
= (uint8_t *)dst
+ y
*dst_stride
+ x
*(format_desc
->block
.bits
/8);
316 format_desc
->pack_rgba_float(dst_row
, dst_stride
, src_row
, src_stride
, w
, h
);
321 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
)
323 const struct util_format_description
*format_desc
;
324 const uint8_t *src_row
;
327 format_desc
= util_format_description(format
);
329 assert(x
% format_desc
->block
.width
== 0);
330 assert(y
% format_desc
->block
.height
== 0);
332 src_row
= (const uint8_t *)src
+ y
*src_stride
+ x
*(format_desc
->block
.bits
/8);
335 format_desc
->unpack_rgba_8unorm(dst_row
, dst_stride
, src_row
, src_stride
, w
, h
);
340 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
)
342 const struct util_format_description
*format_desc
;
344 const uint8_t *src_row
;
346 format_desc
= util_format_description(format
);
348 assert(x
% format_desc
->block
.width
== 0);
349 assert(y
% format_desc
->block
.height
== 0);
351 dst_row
= (uint8_t *)dst
+ y
*dst_stride
+ x
*(format_desc
->block
.bits
/8);
354 format_desc
->pack_rgba_8unorm(dst_row
, dst_stride
, src_row
, src_stride
, w
, h
);
358 util_format_read_4ui(enum pipe_format format
,
359 unsigned *dst
, unsigned dst_stride
,
360 const void *src
, unsigned src_stride
,
361 unsigned x
, unsigned y
, unsigned w
, unsigned h
)
363 const struct util_format_description
*format_desc
;
364 const uint8_t *src_row
;
367 format_desc
= util_format_description(format
);
369 assert(x
% format_desc
->block
.width
== 0);
370 assert(y
% format_desc
->block
.height
== 0);
372 src_row
= (const uint8_t *)src
+ y
*src_stride
+ x
*(format_desc
->block
.bits
/8);
375 format_desc
->unpack_rgba_uint(dst_row
, dst_stride
, src_row
, src_stride
, w
, h
);
379 util_format_write_4ui(enum pipe_format format
,
380 const unsigned int *src
, unsigned src_stride
,
381 void *dst
, unsigned dst_stride
,
382 unsigned x
, unsigned y
, unsigned w
, unsigned h
)
384 const struct util_format_description
*format_desc
;
386 const uint32_t *src_row
;
388 format_desc
= util_format_description(format
);
390 assert(x
% format_desc
->block
.width
== 0);
391 assert(y
% format_desc
->block
.height
== 0);
393 dst_row
= (uint8_t *)dst
+ y
*dst_stride
+ x
*(format_desc
->block
.bits
/8);
396 format_desc
->pack_rgba_uint(dst_row
, dst_stride
, src_row
, src_stride
, w
, h
);
400 util_format_read_4i(enum pipe_format format
,
401 int *dst
, unsigned dst_stride
,
402 const void *src
, unsigned src_stride
,
403 unsigned x
, unsigned y
, unsigned w
, unsigned h
)
405 const struct util_format_description
*format_desc
;
406 const uint8_t *src_row
;
409 format_desc
= util_format_description(format
);
411 assert(x
% format_desc
->block
.width
== 0);
412 assert(y
% format_desc
->block
.height
== 0);
414 src_row
= (const uint8_t *)src
+ y
*src_stride
+ x
*(format_desc
->block
.bits
/8);
417 format_desc
->unpack_rgba_sint(dst_row
, dst_stride
, src_row
, src_stride
, w
, h
);
421 util_format_write_4i(enum pipe_format format
,
422 const int *src
, unsigned src_stride
,
423 void *dst
, unsigned dst_stride
,
424 unsigned x
, unsigned y
, unsigned w
, unsigned h
)
426 const struct util_format_description
*format_desc
;
428 const int32_t *src_row
;
430 format_desc
= util_format_description(format
);
432 assert(x
% format_desc
->block
.width
== 0);
433 assert(y
% format_desc
->block
.height
== 0);
435 dst_row
= (uint8_t *)dst
+ y
*dst_stride
+ x
*(format_desc
->block
.bits
/8);
438 format_desc
->pack_rgba_sint(dst_row
, dst_stride
, src_row
, src_stride
, w
, h
);
442 util_is_format_compatible(const struct util_format_description
*src_desc
,
443 const struct util_format_description
*dst_desc
)
447 if (src_desc
->format
== dst_desc
->format
) {
451 if (src_desc
->layout
!= UTIL_FORMAT_LAYOUT_PLAIN
||
452 dst_desc
->layout
!= UTIL_FORMAT_LAYOUT_PLAIN
) {
456 if (src_desc
->block
.bits
!= dst_desc
->block
.bits
||
457 src_desc
->nr_channels
!= dst_desc
->nr_channels
||
458 src_desc
->colorspace
!= dst_desc
->colorspace
) {
462 for (chan
= 0; chan
< 4; ++chan
) {
463 if (src_desc
->channel
[chan
].size
!=
464 dst_desc
->channel
[chan
].size
) {
469 for (chan
= 0; chan
< 4; ++chan
) {
470 enum util_format_swizzle swizzle
= dst_desc
->swizzle
[chan
];
473 if (src_desc
->swizzle
[chan
] != swizzle
) {
476 if ((src_desc
->channel
[swizzle
].type
!=
477 dst_desc
->channel
[swizzle
].type
) ||
478 (src_desc
->channel
[swizzle
].normalized
!=
479 dst_desc
->channel
[swizzle
].normalized
)) {
490 util_format_fits_8unorm(const struct util_format_description
*format_desc
)
495 * After linearized sRGB values require more than 8bits.
498 if (format_desc
->colorspace
== UTIL_FORMAT_COLORSPACE_SRGB
) {
502 switch (format_desc
->layout
) {
504 case UTIL_FORMAT_LAYOUT_S3TC
:
506 * These are straight forward.
509 case UTIL_FORMAT_LAYOUT_RGTC
:
510 if (format_desc
->format
== PIPE_FORMAT_RGTC1_SNORM
||
511 format_desc
->format
== PIPE_FORMAT_RGTC2_SNORM
||
512 format_desc
->format
== PIPE_FORMAT_LATC1_SNORM
||
513 format_desc
->format
== PIPE_FORMAT_LATC2_SNORM
)
516 case UTIL_FORMAT_LAYOUT_BPTC
:
517 if (format_desc
->format
== PIPE_FORMAT_BPTC_RGBA_UNORM
)
521 case UTIL_FORMAT_LAYOUT_PLAIN
:
523 * For these we can find a generic rule.
526 for (chan
= 0; chan
< format_desc
->nr_channels
; ++chan
) {
527 switch (format_desc
->channel
[chan
].type
) {
528 case UTIL_FORMAT_TYPE_VOID
:
530 case UTIL_FORMAT_TYPE_UNSIGNED
:
531 if (!format_desc
->channel
[chan
].normalized
||
532 format_desc
->channel
[chan
].size
> 8) {
544 * Handle all others on a case by case basis.
547 switch (format_desc
->format
) {
548 case PIPE_FORMAT_R1_UNORM
:
549 case PIPE_FORMAT_UYVY
:
550 case PIPE_FORMAT_YUYV
:
551 case PIPE_FORMAT_R8G8_B8G8_UNORM
:
552 case PIPE_FORMAT_G8R8_G8B8_UNORM
:
563 util_format_translate(enum pipe_format dst_format
,
564 void *dst
, unsigned dst_stride
,
565 unsigned dst_x
, unsigned dst_y
,
566 enum pipe_format src_format
,
567 const void *src
, unsigned src_stride
,
568 unsigned src_x
, unsigned src_y
,
569 unsigned width
, unsigned height
)
571 const struct util_format_description
*dst_format_desc
;
572 const struct util_format_description
*src_format_desc
;
574 const uint8_t *src_row
;
575 unsigned x_step
, y_step
;
579 dst_format_desc
= util_format_description(dst_format
);
580 src_format_desc
= util_format_description(src_format
);
582 if (util_is_format_compatible(src_format_desc
, dst_format_desc
)) {
587 util_copy_rect(dst
, dst_format
, dst_stride
, dst_x
, dst_y
,
588 width
, height
, src
, (int)src_stride
,
593 assert(dst_x
% dst_format_desc
->block
.width
== 0);
594 assert(dst_y
% dst_format_desc
->block
.height
== 0);
595 assert(src_x
% src_format_desc
->block
.width
== 0);
596 assert(src_y
% src_format_desc
->block
.height
== 0);
598 dst_row
= (uint8_t *)dst
+ dst_y
*dst_stride
+ dst_x
*(dst_format_desc
->block
.bits
/8);
599 src_row
= (const uint8_t *)src
+ src_y
*src_stride
+ src_x
*(src_format_desc
->block
.bits
/8);
602 * This works because all pixel formats have pixel blocks with power of two
606 y_step
= MAX2(dst_format_desc
->block
.height
, src_format_desc
->block
.height
);
607 x_step
= MAX2(dst_format_desc
->block
.width
, src_format_desc
->block
.width
);
608 assert(y_step
% dst_format_desc
->block
.height
== 0);
609 assert(y_step
% src_format_desc
->block
.height
== 0);
611 dst_step
= y_step
/ dst_format_desc
->block
.height
* dst_stride
;
612 src_step
= y_step
/ src_format_desc
->block
.height
* src_stride
;
615 * TODO: double formats will loose precision
616 * TODO: Add a special case for formats that are mere swizzles of each other
619 if (src_format_desc
->colorspace
== UTIL_FORMAT_COLORSPACE_ZS
||
620 dst_format_desc
->colorspace
== UTIL_FORMAT_COLORSPACE_ZS
) {
622 uint8_t *tmp_s
= NULL
;
627 if (src_format_desc
->unpack_z_float
&&
628 dst_format_desc
->pack_z_float
) {
629 tmp_z
= MALLOC(width
* sizeof *tmp_z
);
632 if (src_format_desc
->unpack_s_8uint
&&
633 dst_format_desc
->pack_s_8uint
) {
634 tmp_s
= MALLOC(width
* sizeof *tmp_s
);
639 src_format_desc
->unpack_z_float(tmp_z
, 0, src_row
, src_stride
, width
, 1);
640 dst_format_desc
->pack_z_float(dst_row
, dst_stride
, tmp_z
, 0, width
, 1);
644 src_format_desc
->unpack_s_8uint(tmp_s
, 0, src_row
, src_stride
, width
, 1);
645 dst_format_desc
->pack_s_8uint(dst_row
, dst_stride
, tmp_s
, 0, width
, 1);
659 if (util_format_fits_8unorm(src_format_desc
) ||
660 util_format_fits_8unorm(dst_format_desc
)) {
664 if (!src_format_desc
->unpack_rgba_8unorm
||
665 !dst_format_desc
->pack_rgba_8unorm
) {
669 tmp_stride
= MAX2(width
, x_step
) * 4 * sizeof *tmp_row
;
670 tmp_row
= MALLOC(y_step
* tmp_stride
);
674 while (height
>= y_step
) {
675 src_format_desc
->unpack_rgba_8unorm(tmp_row
, tmp_stride
, src_row
, src_stride
, width
, y_step
);
676 dst_format_desc
->pack_rgba_8unorm(dst_row
, dst_stride
, tmp_row
, tmp_stride
, width
, y_step
);
684 src_format_desc
->unpack_rgba_8unorm(tmp_row
, tmp_stride
, src_row
, src_stride
, width
, height
);
685 dst_format_desc
->pack_rgba_8unorm(dst_row
, dst_stride
, tmp_row
, tmp_stride
, width
, height
);
694 if (!src_format_desc
->unpack_rgba_float
||
695 !dst_format_desc
->pack_rgba_float
) {
699 tmp_stride
= MAX2(width
, x_step
) * 4 * sizeof *tmp_row
;
700 tmp_row
= MALLOC(y_step
* tmp_stride
);
704 while (height
>= y_step
) {
705 src_format_desc
->unpack_rgba_float(tmp_row
, tmp_stride
, src_row
, src_stride
, width
, y_step
);
706 dst_format_desc
->pack_rgba_float(dst_row
, dst_stride
, tmp_row
, tmp_stride
, width
, y_step
);
714 src_format_desc
->unpack_rgba_float(tmp_row
, tmp_stride
, src_row
, src_stride
, width
, height
);
715 dst_format_desc
->pack_rgba_float(dst_row
, dst_stride
, tmp_row
, tmp_stride
, width
, height
);
723 void util_format_compose_swizzles(const unsigned char swz1
[4],
724 const unsigned char swz2
[4],
725 unsigned char dst
[4])
729 for (i
= 0; i
< 4; i
++) {
730 dst
[i
] = swz2
[i
] <= UTIL_FORMAT_SWIZZLE_W
?
731 swz1
[swz2
[i
]] : swz2
[i
];
735 void util_format_apply_color_swizzle(union pipe_color_union
*dst
,
736 const union pipe_color_union
*src
,
737 const unsigned char swz
[4],
738 const boolean is_integer
)
743 for (c
= 0; c
< 4; ++c
) {
745 case PIPE_SWIZZLE_RED
: dst
->ui
[c
] = src
->ui
[0]; break;
746 case PIPE_SWIZZLE_GREEN
: dst
->ui
[c
] = src
->ui
[1]; break;
747 case PIPE_SWIZZLE_BLUE
: dst
->ui
[c
] = src
->ui
[2]; break;
748 case PIPE_SWIZZLE_ALPHA
: dst
->ui
[c
] = src
->ui
[3]; break;
750 dst
->ui
[c
] = (swz
[c
] == PIPE_SWIZZLE_ONE
) ? 1 : 0;
755 for (c
= 0; c
< 4; ++c
) {
757 case PIPE_SWIZZLE_RED
: dst
->f
[c
] = src
->f
[0]; break;
758 case PIPE_SWIZZLE_GREEN
: dst
->f
[c
] = src
->f
[1]; break;
759 case PIPE_SWIZZLE_BLUE
: dst
->f
[c
] = src
->f
[2]; break;
760 case PIPE_SWIZZLE_ALPHA
: dst
->f
[c
] = src
->f
[3]; break;
762 dst
->f
[c
] = (swz
[c
] == PIPE_SWIZZLE_ONE
) ? 1.0f
: 0.0f
;
769 void util_format_swizzle_4f(float *dst
, const float *src
,
770 const unsigned char swz
[4])
774 for (i
= 0; i
< 4; i
++) {
775 if (swz
[i
] <= UTIL_FORMAT_SWIZZLE_W
)
776 dst
[i
] = src
[swz
[i
]];
777 else if (swz
[i
] == UTIL_FORMAT_SWIZZLE_0
)
779 else if (swz
[i
] == UTIL_FORMAT_SWIZZLE_1
)
784 void util_format_unswizzle_4f(float *dst
, const float *src
,
785 const unsigned char swz
[4])
789 for (i
= 0; i
< 4; i
++) {
791 case UTIL_FORMAT_SWIZZLE_X
:
794 case UTIL_FORMAT_SWIZZLE_Y
:
797 case UTIL_FORMAT_SWIZZLE_Z
:
800 case UTIL_FORMAT_SWIZZLE_W
: