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_snorm8(enum pipe_format format
)
175 const struct util_format_description
*desc
= util_format_description(format
);
181 i
= util_format_get_first_non_void_channel(format
);
185 return desc
->channel
[i
].type
== UTIL_FORMAT_TYPE_SIGNED
&&
186 !desc
->channel
[i
].pure_integer
&&
187 desc
->channel
[i
].normalized
&&
188 desc
->channel
[i
].size
== 8;
192 util_format_is_luminance_alpha(enum pipe_format format
)
194 const struct util_format_description
*desc
=
195 util_format_description(format
);
197 if ((desc
->colorspace
== UTIL_FORMAT_COLORSPACE_RGB
||
198 desc
->colorspace
== UTIL_FORMAT_COLORSPACE_SRGB
) &&
199 desc
->swizzle
[0] == UTIL_FORMAT_SWIZZLE_X
&&
200 desc
->swizzle
[1] == UTIL_FORMAT_SWIZZLE_X
&&
201 desc
->swizzle
[2] == UTIL_FORMAT_SWIZZLE_X
&&
202 desc
->swizzle
[3] == UTIL_FORMAT_SWIZZLE_Y
) {
210 util_format_is_intensity(enum pipe_format format
)
212 const struct util_format_description
*desc
=
213 util_format_description(format
);
215 if ((desc
->colorspace
== UTIL_FORMAT_COLORSPACE_RGB
||
216 desc
->colorspace
== UTIL_FORMAT_COLORSPACE_SRGB
) &&
217 desc
->swizzle
[0] == UTIL_FORMAT_SWIZZLE_X
&&
218 desc
->swizzle
[1] == UTIL_FORMAT_SWIZZLE_X
&&
219 desc
->swizzle
[2] == UTIL_FORMAT_SWIZZLE_X
&&
220 desc
->swizzle
[3] == UTIL_FORMAT_SWIZZLE_X
) {
227 util_format_is_subsampled_422(enum pipe_format format
)
229 const struct util_format_description
*desc
=
230 util_format_description(format
);
232 return desc
->layout
== UTIL_FORMAT_LAYOUT_SUBSAMPLED
&&
233 desc
->block
.width
== 2 &&
234 desc
->block
.height
== 1 &&
235 desc
->block
.bits
== 32;
239 util_format_is_supported(enum pipe_format format
, unsigned bind
)
241 if (util_format_is_s3tc(format
) && !util_format_s3tc_enabled
) {
245 #ifndef TEXTURE_FLOAT_ENABLED
246 if ((bind
& PIPE_BIND_RENDER_TARGET
) &&
247 format
!= PIPE_FORMAT_R9G9B9E5_FLOAT
&&
248 format
!= PIPE_FORMAT_R11G11B10_FLOAT
&&
249 util_format_is_float(format
)) {
259 * Calculates the MRD for the depth format. MRD is used in depth bias
260 * for UNORM and unbound depth buffers. When the depth buffer is floating
261 * point, the depth bias calculation does not use the MRD. However, the
262 * default MRD will be 1.0 / ((1 << 24) - 1).
265 util_get_depth_format_mrd(const struct util_format_description
*desc
)
268 * Depth buffer formats without a depth component OR scenarios
269 * without a bound depth buffer default to D24.
271 double mrd
= 1.0 / ((1 << 24) - 1);
272 unsigned depth_channel
;
277 * Some depth formats do not store the depth component in the first
278 * channel, detect the format and adjust the depth channel. Get the
279 * swizzled depth component channel.
281 depth_channel
= desc
->swizzle
[0];
283 if (desc
->channel
[depth_channel
].type
== UTIL_FORMAT_TYPE_UNSIGNED
&&
284 desc
->channel
[depth_channel
].normalized
) {
287 depth_bits
= desc
->channel
[depth_channel
].size
;
288 mrd
= 1.0 / ((1ULL << depth_bits
) - 1);
296 util_format_read_4f(enum pipe_format format
,
297 float *dst
, unsigned dst_stride
,
298 const void *src
, unsigned src_stride
,
299 unsigned x
, unsigned y
, unsigned w
, unsigned h
)
301 const struct util_format_description
*format_desc
;
302 const uint8_t *src_row
;
305 format_desc
= util_format_description(format
);
307 assert(x
% format_desc
->block
.width
== 0);
308 assert(y
% format_desc
->block
.height
== 0);
310 src_row
= (const uint8_t *)src
+ y
*src_stride
+ x
*(format_desc
->block
.bits
/8);
313 format_desc
->unpack_rgba_float(dst_row
, dst_stride
, src_row
, src_stride
, w
, h
);
318 util_format_write_4f(enum pipe_format format
,
319 const float *src
, unsigned src_stride
,
320 void *dst
, unsigned dst_stride
,
321 unsigned x
, unsigned y
, unsigned w
, unsigned h
)
323 const struct util_format_description
*format_desc
;
325 const float *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 dst_row
= (uint8_t *)dst
+ y
*dst_stride
+ x
*(format_desc
->block
.bits
/8);
335 format_desc
->pack_rgba_float(dst_row
, dst_stride
, src_row
, src_stride
, w
, h
);
340 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
)
342 const struct util_format_description
*format_desc
;
343 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 src_row
= (const uint8_t *)src
+ y
*src_stride
+ x
*(format_desc
->block
.bits
/8);
354 format_desc
->unpack_rgba_8unorm(dst_row
, dst_stride
, src_row
, src_stride
, w
, h
);
359 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
)
361 const struct util_format_description
*format_desc
;
363 const uint8_t *src_row
;
365 format_desc
= util_format_description(format
);
367 assert(x
% format_desc
->block
.width
== 0);
368 assert(y
% format_desc
->block
.height
== 0);
370 dst_row
= (uint8_t *)dst
+ y
*dst_stride
+ x
*(format_desc
->block
.bits
/8);
373 format_desc
->pack_rgba_8unorm(dst_row
, dst_stride
, src_row
, src_stride
, w
, h
);
377 util_format_read_4ui(enum pipe_format format
,
378 unsigned *dst
, unsigned dst_stride
,
379 const void *src
, unsigned src_stride
,
380 unsigned x
, unsigned y
, unsigned w
, unsigned h
)
382 const struct util_format_description
*format_desc
;
383 const uint8_t *src_row
;
386 format_desc
= util_format_description(format
);
388 assert(x
% format_desc
->block
.width
== 0);
389 assert(y
% format_desc
->block
.height
== 0);
391 src_row
= (const uint8_t *)src
+ y
*src_stride
+ x
*(format_desc
->block
.bits
/8);
394 format_desc
->unpack_rgba_uint(dst_row
, dst_stride
, src_row
, src_stride
, w
, h
);
398 util_format_write_4ui(enum pipe_format format
,
399 const unsigned int *src
, unsigned src_stride
,
400 void *dst
, unsigned dst_stride
,
401 unsigned x
, unsigned y
, unsigned w
, unsigned h
)
403 const struct util_format_description
*format_desc
;
405 const uint32_t *src_row
;
407 format_desc
= util_format_description(format
);
409 assert(x
% format_desc
->block
.width
== 0);
410 assert(y
% format_desc
->block
.height
== 0);
412 dst_row
= (uint8_t *)dst
+ y
*dst_stride
+ x
*(format_desc
->block
.bits
/8);
415 format_desc
->pack_rgba_uint(dst_row
, dst_stride
, src_row
, src_stride
, w
, h
);
419 util_format_read_4i(enum pipe_format format
,
420 int *dst
, unsigned dst_stride
,
421 const void *src
, unsigned src_stride
,
422 unsigned x
, unsigned y
, unsigned w
, unsigned h
)
424 const struct util_format_description
*format_desc
;
425 const uint8_t *src_row
;
428 format_desc
= util_format_description(format
);
430 assert(x
% format_desc
->block
.width
== 0);
431 assert(y
% format_desc
->block
.height
== 0);
433 src_row
= (const uint8_t *)src
+ y
*src_stride
+ x
*(format_desc
->block
.bits
/8);
436 format_desc
->unpack_rgba_sint(dst_row
, dst_stride
, src_row
, src_stride
, w
, h
);
440 util_format_write_4i(enum pipe_format format
,
441 const int *src
, unsigned src_stride
,
442 void *dst
, unsigned dst_stride
,
443 unsigned x
, unsigned y
, unsigned w
, unsigned h
)
445 const struct util_format_description
*format_desc
;
447 const int32_t *src_row
;
449 format_desc
= util_format_description(format
);
451 assert(x
% format_desc
->block
.width
== 0);
452 assert(y
% format_desc
->block
.height
== 0);
454 dst_row
= (uint8_t *)dst
+ y
*dst_stride
+ x
*(format_desc
->block
.bits
/8);
457 format_desc
->pack_rgba_sint(dst_row
, dst_stride
, src_row
, src_stride
, w
, h
);
461 util_is_format_compatible(const struct util_format_description
*src_desc
,
462 const struct util_format_description
*dst_desc
)
466 if (src_desc
->format
== dst_desc
->format
) {
470 if (src_desc
->layout
!= UTIL_FORMAT_LAYOUT_PLAIN
||
471 dst_desc
->layout
!= UTIL_FORMAT_LAYOUT_PLAIN
) {
475 if (src_desc
->block
.bits
!= dst_desc
->block
.bits
||
476 src_desc
->nr_channels
!= dst_desc
->nr_channels
||
477 src_desc
->colorspace
!= dst_desc
->colorspace
) {
481 for (chan
= 0; chan
< 4; ++chan
) {
482 if (src_desc
->channel
[chan
].size
!=
483 dst_desc
->channel
[chan
].size
) {
488 for (chan
= 0; chan
< 4; ++chan
) {
489 enum util_format_swizzle swizzle
= dst_desc
->swizzle
[chan
];
492 if (src_desc
->swizzle
[chan
] != swizzle
) {
495 if ((src_desc
->channel
[swizzle
].type
!=
496 dst_desc
->channel
[swizzle
].type
) ||
497 (src_desc
->channel
[swizzle
].normalized
!=
498 dst_desc
->channel
[swizzle
].normalized
)) {
509 util_format_fits_8unorm(const struct util_format_description
*format_desc
)
514 * After linearized sRGB values require more than 8bits.
517 if (format_desc
->colorspace
== UTIL_FORMAT_COLORSPACE_SRGB
) {
521 switch (format_desc
->layout
) {
523 case UTIL_FORMAT_LAYOUT_S3TC
:
525 * These are straight forward.
528 case UTIL_FORMAT_LAYOUT_RGTC
:
529 if (format_desc
->format
== PIPE_FORMAT_RGTC1_SNORM
||
530 format_desc
->format
== PIPE_FORMAT_RGTC2_SNORM
||
531 format_desc
->format
== PIPE_FORMAT_LATC1_SNORM
||
532 format_desc
->format
== PIPE_FORMAT_LATC2_SNORM
)
535 case UTIL_FORMAT_LAYOUT_BPTC
:
536 if (format_desc
->format
== PIPE_FORMAT_BPTC_RGBA_UNORM
)
540 case UTIL_FORMAT_LAYOUT_PLAIN
:
542 * For these we can find a generic rule.
545 for (chan
= 0; chan
< format_desc
->nr_channels
; ++chan
) {
546 switch (format_desc
->channel
[chan
].type
) {
547 case UTIL_FORMAT_TYPE_VOID
:
549 case UTIL_FORMAT_TYPE_UNSIGNED
:
550 if (!format_desc
->channel
[chan
].normalized
||
551 format_desc
->channel
[chan
].size
> 8) {
563 * Handle all others on a case by case basis.
566 switch (format_desc
->format
) {
567 case PIPE_FORMAT_R1_UNORM
:
568 case PIPE_FORMAT_UYVY
:
569 case PIPE_FORMAT_YUYV
:
570 case PIPE_FORMAT_R8G8_B8G8_UNORM
:
571 case PIPE_FORMAT_G8R8_G8B8_UNORM
:
582 util_format_translate(enum pipe_format dst_format
,
583 void *dst
, unsigned dst_stride
,
584 unsigned dst_x
, unsigned dst_y
,
585 enum pipe_format src_format
,
586 const void *src
, unsigned src_stride
,
587 unsigned src_x
, unsigned src_y
,
588 unsigned width
, unsigned height
)
590 const struct util_format_description
*dst_format_desc
;
591 const struct util_format_description
*src_format_desc
;
593 const uint8_t *src_row
;
594 unsigned x_step
, y_step
;
598 dst_format_desc
= util_format_description(dst_format
);
599 src_format_desc
= util_format_description(src_format
);
601 if (util_is_format_compatible(src_format_desc
, dst_format_desc
)) {
606 util_copy_rect(dst
, dst_format
, dst_stride
, dst_x
, dst_y
,
607 width
, height
, src
, (int)src_stride
,
612 assert(dst_x
% dst_format_desc
->block
.width
== 0);
613 assert(dst_y
% dst_format_desc
->block
.height
== 0);
614 assert(src_x
% src_format_desc
->block
.width
== 0);
615 assert(src_y
% src_format_desc
->block
.height
== 0);
617 dst_row
= (uint8_t *)dst
+ dst_y
*dst_stride
+ dst_x
*(dst_format_desc
->block
.bits
/8);
618 src_row
= (const uint8_t *)src
+ src_y
*src_stride
+ src_x
*(src_format_desc
->block
.bits
/8);
621 * This works because all pixel formats have pixel blocks with power of two
625 y_step
= MAX2(dst_format_desc
->block
.height
, src_format_desc
->block
.height
);
626 x_step
= MAX2(dst_format_desc
->block
.width
, src_format_desc
->block
.width
);
627 assert(y_step
% dst_format_desc
->block
.height
== 0);
628 assert(y_step
% src_format_desc
->block
.height
== 0);
630 dst_step
= y_step
/ dst_format_desc
->block
.height
* dst_stride
;
631 src_step
= y_step
/ src_format_desc
->block
.height
* src_stride
;
634 * TODO: double formats will loose precision
635 * TODO: Add a special case for formats that are mere swizzles of each other
638 if (src_format_desc
->colorspace
== UTIL_FORMAT_COLORSPACE_ZS
||
639 dst_format_desc
->colorspace
== UTIL_FORMAT_COLORSPACE_ZS
) {
641 uint8_t *tmp_s
= NULL
;
646 if (src_format_desc
->unpack_z_float
&&
647 dst_format_desc
->pack_z_float
) {
648 tmp_z
= MALLOC(width
* sizeof *tmp_z
);
651 if (src_format_desc
->unpack_s_8uint
&&
652 dst_format_desc
->pack_s_8uint
) {
653 tmp_s
= MALLOC(width
* sizeof *tmp_s
);
658 src_format_desc
->unpack_z_float(tmp_z
, 0, src_row
, src_stride
, width
, 1);
659 dst_format_desc
->pack_z_float(dst_row
, dst_stride
, tmp_z
, 0, width
, 1);
663 src_format_desc
->unpack_s_8uint(tmp_s
, 0, src_row
, src_stride
, width
, 1);
664 dst_format_desc
->pack_s_8uint(dst_row
, dst_stride
, tmp_s
, 0, width
, 1);
678 if (util_format_fits_8unorm(src_format_desc
) ||
679 util_format_fits_8unorm(dst_format_desc
)) {
683 if (!src_format_desc
->unpack_rgba_8unorm
||
684 !dst_format_desc
->pack_rgba_8unorm
) {
688 tmp_stride
= MAX2(width
, x_step
) * 4 * sizeof *tmp_row
;
689 tmp_row
= MALLOC(y_step
* tmp_stride
);
693 while (height
>= y_step
) {
694 src_format_desc
->unpack_rgba_8unorm(tmp_row
, tmp_stride
, src_row
, src_stride
, width
, y_step
);
695 dst_format_desc
->pack_rgba_8unorm(dst_row
, dst_stride
, tmp_row
, tmp_stride
, width
, y_step
);
703 src_format_desc
->unpack_rgba_8unorm(tmp_row
, tmp_stride
, src_row
, src_stride
, width
, height
);
704 dst_format_desc
->pack_rgba_8unorm(dst_row
, dst_stride
, tmp_row
, tmp_stride
, width
, height
);
713 if (!src_format_desc
->unpack_rgba_float
||
714 !dst_format_desc
->pack_rgba_float
) {
718 tmp_stride
= MAX2(width
, x_step
) * 4 * sizeof *tmp_row
;
719 tmp_row
= MALLOC(y_step
* tmp_stride
);
723 while (height
>= y_step
) {
724 src_format_desc
->unpack_rgba_float(tmp_row
, tmp_stride
, src_row
, src_stride
, width
, y_step
);
725 dst_format_desc
->pack_rgba_float(dst_row
, dst_stride
, tmp_row
, tmp_stride
, width
, y_step
);
733 src_format_desc
->unpack_rgba_float(tmp_row
, tmp_stride
, src_row
, src_stride
, width
, height
);
734 dst_format_desc
->pack_rgba_float(dst_row
, dst_stride
, tmp_row
, tmp_stride
, width
, height
);
742 void util_format_compose_swizzles(const unsigned char swz1
[4],
743 const unsigned char swz2
[4],
744 unsigned char dst
[4])
748 for (i
= 0; i
< 4; i
++) {
749 dst
[i
] = swz2
[i
] <= UTIL_FORMAT_SWIZZLE_W
?
750 swz1
[swz2
[i
]] : swz2
[i
];
754 void util_format_apply_color_swizzle(union pipe_color_union
*dst
,
755 const union pipe_color_union
*src
,
756 const unsigned char swz
[4],
757 const boolean is_integer
)
762 for (c
= 0; c
< 4; ++c
) {
764 case PIPE_SWIZZLE_RED
: dst
->ui
[c
] = src
->ui
[0]; break;
765 case PIPE_SWIZZLE_GREEN
: dst
->ui
[c
] = src
->ui
[1]; break;
766 case PIPE_SWIZZLE_BLUE
: dst
->ui
[c
] = src
->ui
[2]; break;
767 case PIPE_SWIZZLE_ALPHA
: dst
->ui
[c
] = src
->ui
[3]; break;
769 dst
->ui
[c
] = (swz
[c
] == PIPE_SWIZZLE_ONE
) ? 1 : 0;
774 for (c
= 0; c
< 4; ++c
) {
776 case PIPE_SWIZZLE_RED
: dst
->f
[c
] = src
->f
[0]; break;
777 case PIPE_SWIZZLE_GREEN
: dst
->f
[c
] = src
->f
[1]; break;
778 case PIPE_SWIZZLE_BLUE
: dst
->f
[c
] = src
->f
[2]; break;
779 case PIPE_SWIZZLE_ALPHA
: dst
->f
[c
] = src
->f
[3]; break;
781 dst
->f
[c
] = (swz
[c
] == PIPE_SWIZZLE_ONE
) ? 1.0f
: 0.0f
;
788 void util_format_swizzle_4f(float *dst
, const float *src
,
789 const unsigned char swz
[4])
793 for (i
= 0; i
< 4; i
++) {
794 if (swz
[i
] <= UTIL_FORMAT_SWIZZLE_W
)
795 dst
[i
] = src
[swz
[i
]];
796 else if (swz
[i
] == UTIL_FORMAT_SWIZZLE_0
)
798 else if (swz
[i
] == UTIL_FORMAT_SWIZZLE_1
)
803 void util_format_unswizzle_4f(float *dst
, const float *src
,
804 const unsigned char swz
[4])
808 for (i
= 0; i
< 4; i
++) {
810 case UTIL_FORMAT_SWIZZLE_X
:
813 case UTIL_FORMAT_SWIZZLE_Y
:
816 case UTIL_FORMAT_SWIZZLE_Z
:
819 case UTIL_FORMAT_SWIZZLE_W
: