1 /**************************************************************************
3 * Copyright 2009-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 **************************************************************************/
33 #include "pipe/p_format.h"
34 #include "util/u_debug.h"
42 * Describe how to pack/unpack pixels into/from the prescribed format.
44 * XXX: This could be renamed to something like util_format_pack, or broke down
45 * in flags inside util_format_block that said exactly what we want.
47 enum util_format_layout
{
49 * Formats with util_format_block::width == util_format_block::height == 1
50 * that can be described as an ordinary data structure.
52 UTIL_FORMAT_LAYOUT_PLAIN
= 0,
55 * Formats with sub-sampled channels.
57 * This is for formats like YV12 where there is less than one sample per
60 UTIL_FORMAT_LAYOUT_SUBSAMPLED
= 3,
63 * S3 Texture Compression formats.
65 UTIL_FORMAT_LAYOUT_S3TC
= 4,
68 * Red-Green Texture Compression formats.
70 UTIL_FORMAT_LAYOUT_RGTC
= 5,
73 * Everything else that doesn't fit in any of the above layouts.
75 UTIL_FORMAT_LAYOUT_OTHER
= 6
79 struct util_format_block
81 /** Block width in pixels */
84 /** Block height in pixels */
87 /** Block size in bits */
92 enum util_format_type
{
93 UTIL_FORMAT_TYPE_VOID
= 0,
94 UTIL_FORMAT_TYPE_UNSIGNED
= 1,
95 UTIL_FORMAT_TYPE_SIGNED
= 2,
96 UTIL_FORMAT_TYPE_FIXED
= 3,
97 UTIL_FORMAT_TYPE_FLOAT
= 4
101 enum util_format_swizzle
{
102 UTIL_FORMAT_SWIZZLE_X
= 0,
103 UTIL_FORMAT_SWIZZLE_Y
= 1,
104 UTIL_FORMAT_SWIZZLE_Z
= 2,
105 UTIL_FORMAT_SWIZZLE_W
= 3,
106 UTIL_FORMAT_SWIZZLE_0
= 4,
107 UTIL_FORMAT_SWIZZLE_1
= 5,
108 UTIL_FORMAT_SWIZZLE_NONE
= 6,
109 UTIL_FORMAT_SWIZZLE_MAX
= 7 /**< Number of enums counter (must be last) */
113 enum util_format_colorspace
{
114 UTIL_FORMAT_COLORSPACE_RGB
= 0,
115 UTIL_FORMAT_COLORSPACE_SRGB
= 1,
116 UTIL_FORMAT_COLORSPACE_YUV
= 2,
117 UTIL_FORMAT_COLORSPACE_ZS
= 3
121 struct util_format_channel_description
123 unsigned type
:5; /**< UTIL_FORMAT_TYPE_x */
124 unsigned normalized
:1;
125 unsigned pure_integer
:1;
126 unsigned size
:9; /**< bits per channel */
130 struct util_format_description
132 enum pipe_format format
;
137 * Short name, striped of the prefix, lower case.
139 const char *short_name
;
142 * Pixel block dimensions.
144 struct util_format_block block
;
146 enum util_format_layout layout
;
149 * The number of channels.
151 unsigned nr_channels
:3;
154 * Whether all channels have the same number of (whole) bytes.
159 * Whether the pixel format can be described as a bitfield structure.
162 * - pixel depth must be 8, 16, or 32 bits;
163 * - all channels must be unsigned, signed, or void
165 unsigned is_bitmask
:1;
168 * Whether channels have mixed types (ignoring UTIL_FORMAT_TYPE_VOID).
173 * Input channel description.
175 * Only valid for UTIL_FORMAT_LAYOUT_PLAIN formats.
177 struct util_format_channel_description channel
[4];
180 * Output channel swizzle.
182 * The order is either:
186 * depending on the colorspace.
188 unsigned char swizzle
[4];
191 * Colorspace transformation.
193 enum util_format_colorspace colorspace
;
196 * Unpack pixel blocks to R8G8B8A8_UNORM.
197 * Note: strides are in bytes.
199 * Only defined for non-depth-stencil formats.
202 (*unpack_rgba_8unorm
)(uint8_t *dst
, unsigned dst_stride
,
203 const uint8_t *src
, unsigned src_stride
,
204 unsigned width
, unsigned height
);
207 * Pack pixel blocks from R8G8B8A8_UNORM.
208 * Note: strides are in bytes.
210 * Only defined for non-depth-stencil formats.
213 (*pack_rgba_8unorm
)(uint8_t *dst
, unsigned dst_stride
,
214 const uint8_t *src
, unsigned src_stride
,
215 unsigned width
, unsigned height
);
218 * Fetch a single pixel (i, j) from a block.
220 * XXX: Only defined for a very few select formats.
223 (*fetch_rgba_8unorm
)(uint8_t *dst
,
225 unsigned i
, unsigned j
);
228 * Unpack pixel blocks to R32G32B32A32_FLOAT.
229 * Note: strides are in bytes.
231 * Only defined for non-depth-stencil formats.
234 (*unpack_rgba_float
)(float *dst
, unsigned dst_stride
,
235 const uint8_t *src
, unsigned src_stride
,
236 unsigned width
, unsigned height
);
239 * Pack pixel blocks from R32G32B32A32_FLOAT.
240 * Note: strides are in bytes.
242 * Only defined for non-depth-stencil formats.
245 (*pack_rgba_float
)(uint8_t *dst
, unsigned dst_stride
,
246 const float *src
, unsigned src_stride
,
247 unsigned width
, unsigned height
);
250 * Fetch a single pixel (i, j) from a block.
252 * Only defined for non-depth-stencil formats.
255 (*fetch_rgba_float
)(float *dst
,
257 unsigned i
, unsigned j
);
260 * Unpack pixels to Z32_UNORM.
261 * Note: strides are in bytes.
263 * Only defined for depth formats.
266 (*unpack_z_32unorm
)(uint32_t *dst
, unsigned dst_stride
,
267 const uint8_t *src
, unsigned src_stride
,
268 unsigned width
, unsigned height
);
271 * Pack pixels from Z32_FLOAT.
272 * Note: strides are in bytes.
274 * Only defined for depth formats.
277 (*pack_z_32unorm
)(uint8_t *dst
, unsigned dst_stride
,
278 const uint32_t *src
, unsigned src_stride
,
279 unsigned width
, unsigned height
);
282 * Unpack pixels to Z32_FLOAT.
283 * Note: strides are in bytes.
285 * Only defined for depth formats.
288 (*unpack_z_float
)(float *dst
, unsigned dst_stride
,
289 const uint8_t *src
, unsigned src_stride
,
290 unsigned width
, unsigned height
);
293 * Pack pixels from Z32_FLOAT.
294 * Note: strides are in bytes.
296 * Only defined for depth formats.
299 (*pack_z_float
)(uint8_t *dst
, unsigned dst_stride
,
300 const float *src
, unsigned src_stride
,
301 unsigned width
, unsigned height
);
304 * Unpack pixels to S8_USCALED.
305 * Note: strides are in bytes.
307 * Only defined for stencil formats.
310 (*unpack_s_8uscaled
)(uint8_t *dst
, unsigned dst_stride
,
311 const uint8_t *src
, unsigned src_stride
,
312 unsigned width
, unsigned height
);
315 * Pack pixels from S8_USCALED.
316 * Note: strides are in bytes.
318 * Only defined for stencil formats.
321 (*pack_s_8uscaled
)(uint8_t *dst
, unsigned dst_stride
,
322 const uint8_t *src
, unsigned src_stride
,
323 unsigned width
, unsigned height
);
326 * Unpack pixel blocks to R32G32B32A32_UINT.
327 * Note: strides are in bytes.
329 * Only defined for INT formats.
332 (*unpack_rgba_uint
)(unsigned *dst
, unsigned dst_stride
,
333 const uint8_t *src
, unsigned src_stride
,
334 unsigned width
, unsigned height
);
337 (*pack_rgba_uint
)(uint8_t *dst
, unsigned dst_stride
,
338 const unsigned *src
, unsigned src_stride
,
339 unsigned width
, unsigned height
);
342 * Unpack pixel blocks to R32G32B32A32_SINT.
343 * Note: strides are in bytes.
345 * Only defined for INT formats.
348 (*unpack_rgba_sint
)(signed *dst
, unsigned dst_stride
,
349 const uint8_t *src
, unsigned src_stride
,
350 unsigned width
, unsigned height
);
353 (*pack_rgba_sint
)(uint8_t *dst
, unsigned dst_stride
,
354 const int *src
, unsigned src_stride
,
355 unsigned width
, unsigned height
);
359 extern const struct util_format_description
360 util_format_description_table
[];
363 const struct util_format_description
*
364 util_format_description(enum pipe_format format
);
368 * Format query functions.
371 static INLINE
const char *
372 util_format_name(enum pipe_format format
)
374 const struct util_format_description
*desc
= util_format_description(format
);
378 return "PIPE_FORMAT_???";
384 static INLINE
const char *
385 util_format_short_name(enum pipe_format format
)
387 const struct util_format_description
*desc
= util_format_description(format
);
394 return desc
->short_name
;
398 * Whether this format is plain, see UTIL_FORMAT_LAYOUT_PLAIN for more info.
400 static INLINE boolean
401 util_format_is_plain(enum pipe_format format
)
403 const struct util_format_description
*desc
= util_format_description(format
);
409 return desc
->layout
== UTIL_FORMAT_LAYOUT_PLAIN
? TRUE
: FALSE
;
412 static INLINE boolean
413 util_format_is_compressed(enum pipe_format format
)
415 const struct util_format_description
*desc
= util_format_description(format
);
422 switch (desc
->layout
) {
423 case UTIL_FORMAT_LAYOUT_S3TC
:
424 case UTIL_FORMAT_LAYOUT_RGTC
:
425 /* XXX add other formats in the future */
432 static INLINE boolean
433 util_format_is_s3tc(enum pipe_format format
)
435 const struct util_format_description
*desc
= util_format_description(format
);
442 return desc
->layout
== UTIL_FORMAT_LAYOUT_S3TC
? TRUE
: FALSE
;
445 static INLINE boolean
446 util_format_is_srgb(enum pipe_format format
)
448 const struct util_format_description
*desc
= util_format_description(format
);
449 return desc
->colorspace
== UTIL_FORMAT_COLORSPACE_SRGB
;
452 static INLINE boolean
453 util_format_has_depth(const struct util_format_description
*desc
)
455 return desc
->colorspace
== UTIL_FORMAT_COLORSPACE_ZS
&&
456 desc
->swizzle
[0] != UTIL_FORMAT_SWIZZLE_NONE
;
459 static INLINE boolean
460 util_format_has_stencil(const struct util_format_description
*desc
)
462 return desc
->colorspace
== UTIL_FORMAT_COLORSPACE_ZS
&&
463 desc
->swizzle
[1] != UTIL_FORMAT_SWIZZLE_NONE
;
466 static INLINE boolean
467 util_format_is_depth_or_stencil(enum pipe_format format
)
469 const struct util_format_description
*desc
= util_format_description(format
);
476 return util_format_has_depth(desc
) ||
477 util_format_has_stencil(desc
);
480 static INLINE boolean
481 util_format_is_depth_and_stencil(enum pipe_format format
)
483 const struct util_format_description
*desc
= util_format_description(format
);
490 return util_format_has_depth(desc
) &&
491 util_format_has_stencil(desc
);
496 * Give the RGBA colormask of the channels that can be represented in this
499 * That is, the channels whose values are preserved.
501 static INLINE
unsigned
502 util_format_colormask(const struct util_format_description
*desc
)
507 switch (desc
->colorspace
) {
508 case UTIL_FORMAT_COLORSPACE_RGB
:
509 case UTIL_FORMAT_COLORSPACE_SRGB
:
510 case UTIL_FORMAT_COLORSPACE_YUV
:
512 for (chan
= 0; chan
< 4; ++chan
) {
513 if (desc
->swizzle
[chan
] < 4) {
514 colormask
|= (1 << chan
);
518 case UTIL_FORMAT_COLORSPACE_ZS
:
528 util_format_is_float(enum pipe_format format
);
532 util_format_is_rgb_no_alpha(enum pipe_format format
);
536 util_format_is_luminance(enum pipe_format format
);
540 util_format_is_luminance_alpha(enum pipe_format format
);
544 util_format_is_intensity(enum pipe_format format
);
547 util_format_is_pure_integer(enum pipe_format format
);
550 util_format_is_pure_sint(enum pipe_format format
);
553 util_format_is_pure_uint(enum pipe_format format
);
556 * Whether the src format can be blitted to destation format with a simple
560 util_is_format_compatible(const struct util_format_description
*src_desc
,
561 const struct util_format_description
*dst_desc
);
564 * Whether the format is supported by Gallium for the given bindings.
565 * This covers S3TC textures and floating-point render targets.
568 util_format_is_supported(enum pipe_format format
, unsigned bind
);
571 * Whether this format is a rgab8 variant.
573 * That is, any format that matches the
575 * PIPE_FORMAT_?8?8?8?8_UNORM
577 static INLINE boolean
578 util_format_is_rgba8_variant(const struct util_format_description
*desc
)
582 if(desc
->block
.width
!= 1 ||
583 desc
->block
.height
!= 1 ||
584 desc
->block
.bits
!= 32)
587 for(chan
= 0; chan
< 4; ++chan
) {
588 if(desc
->channel
[chan
].type
!= UTIL_FORMAT_TYPE_UNSIGNED
&&
589 desc
->channel
[chan
].type
!= UTIL_FORMAT_TYPE_VOID
)
591 if(desc
->channel
[chan
].size
!= 8)
600 * Return total bits needed for the pixel format per block.
603 util_format_get_blocksizebits(enum pipe_format format
)
605 const struct util_format_description
*desc
= util_format_description(format
);
612 return desc
->block
.bits
;
616 * Return bytes per block (not pixel) for the given format.
619 util_format_get_blocksize(enum pipe_format format
)
621 uint bits
= util_format_get_blocksizebits(format
);
623 assert(bits
% 8 == 0);
629 util_format_get_blockwidth(enum pipe_format format
)
631 const struct util_format_description
*desc
= util_format_description(format
);
638 return desc
->block
.width
;
642 util_format_get_blockheight(enum pipe_format format
)
644 const struct util_format_description
*desc
= util_format_description(format
);
651 return desc
->block
.height
;
654 static INLINE
unsigned
655 util_format_get_nblocksx(enum pipe_format format
,
658 unsigned blockwidth
= util_format_get_blockwidth(format
);
659 return (x
+ blockwidth
- 1) / blockwidth
;
662 static INLINE
unsigned
663 util_format_get_nblocksy(enum pipe_format format
,
666 unsigned blockheight
= util_format_get_blockheight(format
);
667 return (y
+ blockheight
- 1) / blockheight
;
670 static INLINE
unsigned
671 util_format_get_nblocks(enum pipe_format format
,
675 return util_format_get_nblocksx(format
, width
) * util_format_get_nblocksy(format
, height
);
679 util_format_get_stride(enum pipe_format format
,
682 return util_format_get_nblocksx(format
, width
) * util_format_get_blocksize(format
);
686 util_format_get_2d_size(enum pipe_format format
,
690 return util_format_get_nblocksy(format
, height
) * stride
;
694 util_format_get_component_bits(enum pipe_format format
,
695 enum util_format_colorspace colorspace
,
698 const struct util_format_description
*desc
= util_format_description(format
);
699 enum util_format_colorspace desc_colorspace
;
706 assert(component
< 4);
708 /* Treat RGB and SRGB as equivalent. */
709 if (colorspace
== UTIL_FORMAT_COLORSPACE_SRGB
) {
710 colorspace
= UTIL_FORMAT_COLORSPACE_RGB
;
712 if (desc
->colorspace
== UTIL_FORMAT_COLORSPACE_SRGB
) {
713 desc_colorspace
= UTIL_FORMAT_COLORSPACE_RGB
;
715 desc_colorspace
= desc
->colorspace
;
718 if (desc_colorspace
!= colorspace
) {
722 switch (desc
->swizzle
[component
]) {
723 case UTIL_FORMAT_SWIZZLE_X
:
724 return desc
->channel
[0].size
;
725 case UTIL_FORMAT_SWIZZLE_Y
:
726 return desc
->channel
[1].size
;
727 case UTIL_FORMAT_SWIZZLE_Z
:
728 return desc
->channel
[2].size
;
729 case UTIL_FORMAT_SWIZZLE_W
:
730 return desc
->channel
[3].size
;
736 static INLINE boolean
737 util_format_has_alpha(enum pipe_format format
)
739 const struct util_format_description
*desc
= util_format_description(format
);
746 switch (desc
->colorspace
) {
747 case UTIL_FORMAT_COLORSPACE_RGB
:
748 case UTIL_FORMAT_COLORSPACE_SRGB
:
749 return desc
->swizzle
[3] != UTIL_FORMAT_SWIZZLE_1
;
750 case UTIL_FORMAT_COLORSPACE_YUV
:
752 case UTIL_FORMAT_COLORSPACE_ZS
:
761 * Given a linear RGB colorspace format, return the corresponding SRGB
762 * format, or PIPE_FORMAT_NONE if none.
764 static INLINE
enum pipe_format
765 util_format_srgb(enum pipe_format format
)
768 case PIPE_FORMAT_L8_UNORM
:
769 return PIPE_FORMAT_L8_SRGB
;
770 case PIPE_FORMAT_L8A8_UNORM
:
771 return PIPE_FORMAT_L8A8_SRGB
;
772 case PIPE_FORMAT_R8G8B8_UNORM
:
773 return PIPE_FORMAT_R8G8B8_SRGB
;
774 case PIPE_FORMAT_A8B8G8R8_UNORM
:
775 return PIPE_FORMAT_A8B8G8R8_SRGB
;
776 case PIPE_FORMAT_X8B8G8R8_UNORM
:
777 return PIPE_FORMAT_X8B8G8R8_SRGB
;
778 case PIPE_FORMAT_B8G8R8A8_UNORM
:
779 return PIPE_FORMAT_B8G8R8A8_SRGB
;
780 case PIPE_FORMAT_B8G8R8X8_UNORM
:
781 return PIPE_FORMAT_B8G8R8X8_SRGB
;
782 case PIPE_FORMAT_A8R8G8B8_UNORM
:
783 return PIPE_FORMAT_A8R8G8B8_SRGB
;
784 case PIPE_FORMAT_X8R8G8B8_UNORM
:
785 return PIPE_FORMAT_X8R8G8B8_SRGB
;
786 case PIPE_FORMAT_DXT1_RGB
:
787 return PIPE_FORMAT_DXT1_SRGB
;
788 case PIPE_FORMAT_DXT1_RGBA
:
789 return PIPE_FORMAT_DXT1_SRGBA
;
790 case PIPE_FORMAT_DXT3_RGBA
:
791 return PIPE_FORMAT_DXT3_SRGBA
;
792 case PIPE_FORMAT_DXT5_RGBA
:
793 return PIPE_FORMAT_DXT5_SRGBA
;
795 return PIPE_FORMAT_NONE
;
800 * Given an sRGB format, return the corresponding linear colorspace format.
801 * For non sRGB formats, return the format unchanged.
803 static INLINE
enum pipe_format
804 util_format_linear(enum pipe_format format
)
807 case PIPE_FORMAT_L8_SRGB
:
808 return PIPE_FORMAT_L8_UNORM
;
809 case PIPE_FORMAT_L8A8_SRGB
:
810 return PIPE_FORMAT_L8A8_UNORM
;
811 case PIPE_FORMAT_R8G8B8_SRGB
:
812 return PIPE_FORMAT_R8G8B8_UNORM
;
813 case PIPE_FORMAT_A8B8G8R8_SRGB
:
814 return PIPE_FORMAT_A8B8G8R8_UNORM
;
815 case PIPE_FORMAT_X8B8G8R8_SRGB
:
816 return PIPE_FORMAT_X8B8G8R8_UNORM
;
817 case PIPE_FORMAT_B8G8R8A8_SRGB
:
818 return PIPE_FORMAT_B8G8R8A8_UNORM
;
819 case PIPE_FORMAT_B8G8R8X8_SRGB
:
820 return PIPE_FORMAT_B8G8R8X8_UNORM
;
821 case PIPE_FORMAT_A8R8G8B8_SRGB
:
822 return PIPE_FORMAT_A8R8G8B8_UNORM
;
823 case PIPE_FORMAT_X8R8G8B8_SRGB
:
824 return PIPE_FORMAT_X8R8G8B8_UNORM
;
825 case PIPE_FORMAT_DXT1_SRGB
:
826 return PIPE_FORMAT_DXT1_RGB
;
827 case PIPE_FORMAT_DXT1_SRGBA
:
828 return PIPE_FORMAT_DXT1_RGBA
;
829 case PIPE_FORMAT_DXT3_SRGBA
:
830 return PIPE_FORMAT_DXT3_RGBA
;
831 case PIPE_FORMAT_DXT5_SRGBA
:
832 return PIPE_FORMAT_DXT5_RGBA
;
839 * Return the number of components stored.
840 * Formats with block size != 1x1 will always have 1 component (the block).
842 static INLINE
unsigned
843 util_format_get_nr_components(enum pipe_format format
)
845 const struct util_format_description
*desc
= util_format_description(format
);
846 return desc
->nr_channels
;
850 * Return the index of the first non-void channel
851 * -1 if no non-void channels
854 util_format_get_first_non_void_channel(enum pipe_format format
)
856 const struct util_format_description
*desc
= util_format_description(format
);
859 for (i
= 0; i
< 4; i
++)
860 if (desc
->channel
[i
].type
!= UTIL_FORMAT_TYPE_VOID
)
870 * Format access functions.
874 util_format_read_4f(enum pipe_format format
,
875 float *dst
, unsigned dst_stride
,
876 const void *src
, unsigned src_stride
,
877 unsigned x
, unsigned y
, unsigned w
, unsigned h
);
880 util_format_write_4f(enum pipe_format format
,
881 const float *src
, unsigned src_stride
,
882 void *dst
, unsigned dst_stride
,
883 unsigned x
, unsigned y
, unsigned w
, unsigned h
);
886 util_format_read_4ub(enum pipe_format format
,
887 uint8_t *dst
, unsigned dst_stride
,
888 const void *src
, unsigned src_stride
,
889 unsigned x
, unsigned y
, unsigned w
, unsigned h
);
892 util_format_write_4ub(enum pipe_format format
,
893 const uint8_t *src
, unsigned src_stride
,
894 void *dst
, unsigned dst_stride
,
895 unsigned x
, unsigned y
, unsigned w
, unsigned h
);
898 util_format_read_4ui(enum pipe_format format
,
899 unsigned *dst
, unsigned dst_stride
,
900 const void *src
, unsigned src_stride
,
901 unsigned x
, unsigned y
, unsigned w
, unsigned h
);
904 util_format_write_4ui(enum pipe_format format
,
905 const unsigned int *src
, unsigned src_stride
,
906 void *dst
, unsigned dst_stride
,
907 unsigned x
, unsigned y
, unsigned w
, unsigned h
);
910 util_format_read_4i(enum pipe_format format
,
911 int *dst
, unsigned dst_stride
,
912 const void *src
, unsigned src_stride
,
913 unsigned x
, unsigned y
, unsigned w
, unsigned h
);
916 util_format_write_4i(enum pipe_format format
,
917 const int *src
, unsigned src_stride
,
918 void *dst
, unsigned dst_stride
,
919 unsigned x
, unsigned y
, unsigned w
, unsigned h
);
922 * Generic format conversion;
926 util_format_fits_8unorm(const struct util_format_description
*format_desc
);
929 util_format_translate(enum pipe_format dst_format
,
930 void *dst
, unsigned dst_stride
,
931 unsigned dst_x
, unsigned dst_y
,
932 enum pipe_format src_format
,
933 const void *src
, unsigned src_stride
,
934 unsigned src_x
, unsigned src_y
,
935 unsigned width
, unsigned height
);
938 * Swizzle operations.
941 /* Compose two sets of swizzles.
942 * If V is a 4D vector and the function parameters represent functions that
943 * swizzle vector components, this holds:
944 * swz2(swz1(V)) = dst(V)
946 void util_format_compose_swizzles(const unsigned char swz1
[4],
947 const unsigned char swz2
[4],
948 unsigned char dst
[4]);
950 void util_format_swizzle_4f(float *dst
, const float *src
,
951 const unsigned char swz
[4]);
953 void util_format_unswizzle_4f(float *dst
, const float *src
,
954 const unsigned char swz
[4]);
960 #endif /* ! U_FORMAT_H */