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 SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
18 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 * USE OR OTHER DEALINGS IN THE SOFTWARE.
22 * The above copyright notice and this permission notice (including the
23 * next paragraph) shall be included in all copies or substantial portions
26 **************************************************************************/
29 #include "u_format_zs.h"
30 #include "util/u_math.h"
34 * z32_unorm conversion functions
37 static inline uint16_t
38 z32_unorm_to_z16_unorm(uint32_t z
)
40 /* z * 0xffff / 0xffffffff */
44 static inline uint32_t
45 z16_unorm_to_z32_unorm(uint16_t z
)
47 /* z * 0xffffffff / 0xffff */
48 return ((uint32_t)z
<< 16) | z
;
51 static inline uint32_t
52 z32_unorm_to_z24_unorm(uint32_t z
)
54 /* z * 0xffffff / 0xffffffff */
58 static inline uint32_t
59 z24_unorm_to_z32_unorm(uint32_t z
)
61 /* z * 0xffffffff / 0xffffff */
62 return (z
<< 8) | (z
>> 16);
67 * z32_float conversion functions
70 static inline uint16_t
71 z32_float_to_z16_unorm(float z
)
73 const float scale
= 0xffff;
74 return (uint16_t)(z
* scale
+ 0.5f
);
78 z16_unorm_to_z32_float(uint16_t z
)
80 const float scale
= 1.0 / 0xffff;
81 return (float)(z
* scale
);
84 static inline uint32_t
85 z32_float_to_z24_unorm(float z
)
87 const double scale
= 0xffffff;
88 return (uint32_t)(z
* scale
) & 0xffffff;
92 z24_unorm_to_z32_float(uint32_t z
)
94 const double scale
= 1.0 / 0xffffff;
95 return (float)(z
* scale
);
98 static inline uint32_t
99 z32_float_to_z32_unorm(float z
)
101 const double scale
= 0xffffffff;
102 return (uint32_t)(z
* scale
);
106 z32_unorm_to_z32_float(uint32_t z
)
108 const double scale
= 1.0 / 0xffffffff;
109 return (float)(z
* scale
);
114 util_format_s8_uint_unpack_s_8uint(uint8_t *dst_row
, unsigned dst_stride
,
115 const uint8_t *src_row
, unsigned src_stride
,
116 unsigned width
, unsigned height
)
119 for(y
= 0; y
< height
; ++y
) {
120 memcpy(dst_row
, src_row
, width
);
121 src_row
+= src_stride
/sizeof(*src_row
);
122 dst_row
+= dst_stride
/sizeof(*dst_row
);
127 util_format_s8_uint_pack_s_8uint(uint8_t *dst_row
, unsigned dst_stride
,
128 const uint8_t *src_row
, unsigned src_stride
,
129 unsigned width
, unsigned height
)
132 for(y
= 0; y
< height
; ++y
) {
133 memcpy(dst_row
, src_row
, width
);
134 src_row
+= src_stride
/sizeof(*src_row
);
135 dst_row
+= dst_stride
/sizeof(*dst_row
);
140 util_format_z16_unorm_unpack_z_float(float *dst_row
, unsigned dst_stride
,
141 const uint8_t *src_row
, unsigned src_stride
,
142 unsigned width
, unsigned height
)
145 for(y
= 0; y
< height
; ++y
) {
146 float *dst
= dst_row
;
147 const uint16_t *src
= (const uint16_t *)src_row
;
148 for(x
= 0; x
< width
; ++x
) {
149 uint16_t value
= util_cpu_to_le16(*src
++);
150 *dst
++ = z16_unorm_to_z32_float(value
);
152 src_row
+= src_stride
/sizeof(*src_row
);
153 dst_row
+= dst_stride
/sizeof(*dst_row
);
158 util_format_z16_unorm_pack_z_float(uint8_t *dst_row
, unsigned dst_stride
,
159 const float *src_row
, unsigned src_stride
,
160 unsigned width
, unsigned height
)
163 for(y
= 0; y
< height
; ++y
) {
164 const float *src
= src_row
;
165 uint16_t *dst
= (uint16_t *)dst_row
;
166 for(x
= 0; x
< width
; ++x
) {
168 value
= z32_float_to_z16_unorm(*src
++);
169 *dst
++ = util_le16_to_cpu(value
);
171 dst_row
+= dst_stride
/sizeof(*dst_row
);
172 src_row
+= src_stride
/sizeof(*src_row
);
177 util_format_z16_unorm_unpack_z_32unorm(uint32_t *dst_row
, unsigned dst_stride
,
178 const uint8_t *src_row
, unsigned src_stride
,
179 unsigned width
, unsigned height
)
182 for(y
= 0; y
< height
; ++y
) {
183 uint32_t *dst
= dst_row
;
184 const uint16_t *src
= (const uint16_t *)src_row
;
185 for(x
= 0; x
< width
; ++x
) {
186 uint16_t value
= util_cpu_to_le16(*src
++);
187 *dst
++ = z16_unorm_to_z32_unorm(value
);
189 src_row
+= src_stride
/sizeof(*src_row
);
190 dst_row
+= dst_stride
/sizeof(*dst_row
);
195 util_format_z16_unorm_pack_z_32unorm(uint8_t *dst_row
, unsigned dst_stride
,
196 const uint32_t *src_row
, unsigned src_stride
,
197 unsigned width
, unsigned height
)
200 for(y
= 0; y
< height
; ++y
) {
201 const uint32_t *src
= src_row
;
202 uint16_t *dst
= (uint16_t *)dst_row
;
203 for(x
= 0; x
< width
; ++x
) {
205 value
= z32_unorm_to_z16_unorm(*src
++);
206 *dst
++ = util_le16_to_cpu(value
);
208 dst_row
+= dst_stride
/sizeof(*dst_row
);
209 src_row
+= src_stride
/sizeof(*src_row
);
214 util_format_z32_unorm_unpack_z_float(float *dst_row
, unsigned dst_stride
,
215 const uint8_t *src_row
, unsigned src_stride
,
216 unsigned width
, unsigned height
)
219 for(y
= 0; y
< height
; ++y
) {
220 float *dst
= dst_row
;
221 const uint32_t *src
= (const uint32_t *)src_row
;
222 for(x
= 0; x
< width
; ++x
) {
223 uint32_t value
= util_cpu_to_le32(*src
++);
224 *dst
++ = z32_unorm_to_z32_float(value
);
226 src_row
+= src_stride
/sizeof(*src_row
);
227 dst_row
+= dst_stride
/sizeof(*dst_row
);
232 util_format_z32_unorm_pack_z_float(uint8_t *dst_row
, unsigned dst_stride
,
233 const float *src_row
, unsigned src_stride
,
234 unsigned width
, unsigned height
)
237 for(y
= 0; y
< height
; ++y
) {
238 const float *src
= src_row
;
239 uint32_t *dst
= (uint32_t *)dst_row
;
240 for(x
= 0; x
< width
; ++x
) {
242 value
= z32_float_to_z32_unorm(*src
++);
243 *dst
++ = util_le32_to_cpu(value
);
245 dst_row
+= dst_stride
/sizeof(*dst_row
);
246 src_row
+= src_stride
/sizeof(*src_row
);
251 util_format_z32_unorm_unpack_z_32unorm(uint32_t *dst_row
, unsigned dst_stride
,
252 const uint8_t *src_row
, unsigned src_stride
,
253 unsigned width
, unsigned height
)
256 for(y
= 0; y
< height
; ++y
) {
257 memcpy(dst_row
, src_row
, width
* 4);
258 src_row
+= src_stride
/sizeof(*src_row
);
259 dst_row
+= dst_stride
/sizeof(*dst_row
);
264 util_format_z32_unorm_pack_z_32unorm(uint8_t *dst_row
, unsigned dst_stride
,
265 const uint32_t *src_row
, unsigned src_stride
,
266 unsigned width
, unsigned height
)
269 for(y
= 0; y
< height
; ++y
) {
270 memcpy(dst_row
, src_row
, width
* 4);
271 src_row
+= src_stride
/sizeof(*src_row
);
272 dst_row
+= dst_stride
/sizeof(*dst_row
);
277 util_format_z32_float_unpack_z_float(float *dst_row
, unsigned dst_stride
,
278 const uint8_t *src_row
, unsigned src_stride
,
279 unsigned width
, unsigned height
)
282 for(y
= 0; y
< height
; ++y
) {
283 memcpy(dst_row
, src_row
, width
* 4);
284 src_row
+= src_stride
/sizeof(*src_row
);
285 dst_row
+= dst_stride
/sizeof(*dst_row
);
290 util_format_z32_float_pack_z_float(uint8_t *dst_row
, unsigned dst_stride
,
291 const float *src_row
, unsigned src_stride
,
292 unsigned width
, unsigned height
)
295 for(y
= 0; y
< height
; ++y
) {
296 memcpy(dst_row
, src_row
, width
* 4);
297 src_row
+= src_stride
/sizeof(*src_row
);
298 dst_row
+= dst_stride
/sizeof(*dst_row
);
303 util_format_z32_float_unpack_z_32unorm(uint32_t *dst_row
, unsigned dst_stride
,
304 const uint8_t *src_row
, unsigned src_stride
,
305 unsigned width
, unsigned height
)
308 for(y
= 0; y
< height
; ++y
) {
309 uint32_t *dst
= dst_row
;
310 const float *src
= (const float *)src_row
;
311 for(x
= 0; x
< width
; ++x
) {
312 *dst
++ = z32_float_to_z32_unorm(*src
++);
314 src_row
+= src_stride
/sizeof(*src_row
);
315 dst_row
+= dst_stride
/sizeof(*dst_row
);
320 util_format_z32_float_pack_z_32unorm(uint8_t *dst_row
, unsigned dst_stride
,
321 const uint32_t *src_row
, unsigned src_stride
,
322 unsigned width
, unsigned height
)
325 for(y
= 0; y
< height
; ++y
) {
326 const uint32_t *src
= src_row
;
327 float *dst
= (float *)dst_row
;
328 for(x
= 0; x
< width
; ++x
) {
329 *dst
++ = z32_unorm_to_z32_float(*src
++);
331 dst_row
+= dst_stride
/sizeof(*dst_row
);
332 src_row
+= src_stride
/sizeof(*src_row
);
337 util_format_z24_unorm_s8_uint_unpack_z_float(float *dst_row
, unsigned dst_stride
,
338 const uint8_t *src_row
, unsigned src_stride
,
339 unsigned width
, unsigned height
)
342 for(y
= 0; y
< height
; ++y
) {
343 float *dst
= dst_row
;
344 const uint32_t *src
= (const uint32_t *)src_row
;
345 for(x
= 0; x
< width
; ++x
) {
346 uint32_t value
= util_cpu_to_le32(*src
++);
347 *dst
++ = z24_unorm_to_z32_float(value
& 0xffffff);
349 src_row
+= src_stride
/sizeof(*src_row
);
350 dst_row
+= dst_stride
/sizeof(*dst_row
);
355 util_format_z24_unorm_s8_uint_pack_z_float(uint8_t *dst_row
, unsigned dst_stride
,
356 const float *src_row
, unsigned src_stride
,
357 unsigned width
, unsigned height
)
360 for(y
= 0; y
< height
; ++y
) {
361 const float *src
= src_row
;
362 uint32_t *dst
= (uint32_t *)dst_row
;
363 for(x
= 0; x
< width
; ++x
) {
364 uint32_t value
= util_le32_to_cpu(*dst
);
366 value
|= z32_float_to_z24_unorm(*src
++);
367 *dst
++ = util_cpu_to_le32(value
);
369 dst_row
+= dst_stride
/sizeof(*dst_row
);
370 src_row
+= src_stride
/sizeof(*src_row
);
375 util_format_z24_unorm_s8_uint_unpack_z_32unorm(uint32_t *dst_row
, unsigned dst_stride
,
376 const uint8_t *src_row
, unsigned src_stride
,
377 unsigned width
, unsigned height
)
380 for(y
= 0; y
< height
; ++y
) {
381 uint32_t *dst
= dst_row
;
382 const uint32_t *src
= (const uint32_t *)src_row
;
383 for(x
= 0; x
< width
; ++x
) {
384 uint32_t value
= util_cpu_to_le32(*src
++);
385 *dst
++ = z24_unorm_to_z32_unorm(value
& 0xffffff);
387 src_row
+= src_stride
/sizeof(*src_row
);
388 dst_row
+= dst_stride
/sizeof(*dst_row
);
393 util_format_z24_unorm_s8_uint_pack_z_32unorm(uint8_t *dst_row
, unsigned dst_stride
,
394 const uint32_t *src_row
, unsigned src_stride
,
395 unsigned width
, unsigned height
)
398 for(y
= 0; y
< height
; ++y
) {
399 const uint32_t *src
= src_row
;
400 uint32_t *dst
= (uint32_t *)dst_row
;
401 for(x
= 0; x
< width
; ++x
) {
402 uint32_t value
= util_le32_to_cpu(*dst
);
404 value
|= z32_unorm_to_z24_unorm(*src
++);
405 *dst
++ = util_cpu_to_le32(value
);
407 dst_row
+= dst_stride
/sizeof(*dst_row
);
408 src_row
+= src_stride
/sizeof(*src_row
);
413 util_format_z24_unorm_s8_uint_unpack_s_8uint(uint8_t *dst_row
, unsigned dst_stride
,
414 const uint8_t *src_row
, unsigned src_stride
,
415 unsigned width
, unsigned height
)
418 for(y
= 0; y
< height
; ++y
) {
419 uint8_t *dst
= dst_row
;
420 const uint32_t *src
= (const uint32_t *)src_row
;
421 for(x
= 0; x
< width
; ++x
) {
422 uint32_t value
= util_cpu_to_le32(*src
++);
423 *dst
++ = value
>> 24;
425 src_row
+= src_stride
/sizeof(*src_row
);
426 dst_row
+= dst_stride
/sizeof(*dst_row
);
431 util_format_z24_unorm_s8_uint_pack_s_8uint(uint8_t *dst_row
, unsigned dst_stride
,
432 const uint8_t *src_row
, unsigned src_stride
,
433 unsigned width
, unsigned height
)
436 for(y
= 0; y
< height
; ++y
) {
437 const uint8_t *src
= src_row
;
438 uint32_t *dst
= (uint32_t *)dst_row
;
439 for(x
= 0; x
< width
; ++x
) {
440 uint32_t value
= util_le32_to_cpu(*dst
);
442 value
|= (uint32_t)*src
++ << 24;
443 *dst
++ = util_cpu_to_le32(value
);
445 dst_row
+= dst_stride
/sizeof(*dst_row
);
446 src_row
+= src_stride
/sizeof(*src_row
);
451 util_format_z24_unorm_s8_uint_pack_separate(uint8_t *dst_row
, unsigned dst_stride
,
452 const uint32_t *z_src_row
, unsigned z_src_stride
,
453 const uint8_t *s_src_row
, unsigned s_src_stride
,
454 unsigned width
, unsigned height
)
457 for (y
= 0; y
< height
; ++y
) {
458 const uint32_t *z_src
= z_src_row
;
459 const uint8_t *s_src
= s_src_row
;
460 uint32_t *dst
= (uint32_t *)dst_row
;
461 for (x
= 0; x
< width
; ++x
) {
462 *dst
++ = (*z_src
++ & 0x00ffffff) | ((uint32_t)*s_src
++ << 24);
464 dst_row
+= dst_stride
/ sizeof(*dst_row
);
465 z_src_row
+= z_src_stride
/ sizeof(*z_src_row
);
466 s_src_row
+= s_src_stride
/ sizeof(*s_src_row
);
471 util_format_s8_uint_z24_unorm_unpack_z_float(float *dst_row
, unsigned dst_stride
,
472 const uint8_t *src_row
, unsigned src_stride
,
473 unsigned width
, unsigned height
)
476 for(y
= 0; y
< height
; ++y
) {
477 float *dst
= dst_row
;
478 const uint32_t *src
= (const uint32_t *)src_row
;
479 for(x
= 0; x
< width
; ++x
) {
480 uint32_t value
= util_cpu_to_le32(*src
++);
481 *dst
++ = z24_unorm_to_z32_float(value
>> 8);
483 src_row
+= src_stride
/sizeof(*src_row
);
484 dst_row
+= dst_stride
/sizeof(*dst_row
);
489 util_format_s8_uint_z24_unorm_pack_z_float(uint8_t *dst_row
, unsigned dst_stride
,
490 const float *src_row
, unsigned src_stride
,
491 unsigned width
, unsigned height
)
494 for(y
= 0; y
< height
; ++y
) {
495 const float *src
= src_row
;
496 uint32_t *dst
= (uint32_t *)dst_row
;
497 for(x
= 0; x
< width
; ++x
) {
498 uint32_t value
= util_le32_to_cpu(*dst
);
500 value
|= z32_float_to_z24_unorm(*src
++) << 8;
501 *dst
++ = util_cpu_to_le32(value
);
503 dst_row
+= dst_stride
/sizeof(*dst_row
);
504 src_row
+= src_stride
/sizeof(*src_row
);
509 util_format_s8_uint_z24_unorm_unpack_z_32unorm(uint32_t *dst_row
, unsigned dst_stride
,
510 const uint8_t *src_row
, unsigned src_stride
,
511 unsigned width
, unsigned height
)
514 for(y
= 0; y
< height
; ++y
) {
515 uint32_t *dst
= dst_row
;
516 const uint32_t *src
= (const uint32_t *)src_row
;
517 for(x
= 0; x
< width
; ++x
) {
518 uint32_t value
= util_cpu_to_le32(*src
++);
519 *dst
++ = z24_unorm_to_z32_unorm(value
>> 8);
521 src_row
+= src_stride
/sizeof(*src_row
);
522 dst_row
+= dst_stride
/sizeof(*dst_row
);
527 util_format_s8_uint_z24_unorm_pack_z_32unorm(uint8_t *dst_row
, unsigned dst_stride
,
528 const uint32_t *src_row
, unsigned src_stride
,
529 unsigned width
, unsigned height
)
532 for(y
= 0; y
< height
; ++y
) {
533 const uint32_t *src
= src_row
;
534 uint32_t *dst
= (uint32_t *)dst_row
;
535 for(x
= 0; x
< width
; ++x
) {
536 uint32_t value
= util_le32_to_cpu(*dst
);
538 value
|= *src
++ & 0xffffff00;
539 *dst
++ = util_cpu_to_le32(value
);
541 dst_row
+= dst_stride
/sizeof(*dst_row
);
542 src_row
+= src_stride
/sizeof(*src_row
);
547 util_format_s8_uint_z24_unorm_unpack_s_8uint(uint8_t *dst_row
, unsigned dst_stride
,
548 const uint8_t *src_row
, unsigned src_stride
,
549 unsigned width
, unsigned height
)
552 for(y
= 0; y
< height
; ++y
) {
553 uint8_t *dst
= dst_row
;
554 const uint32_t *src
= (const uint32_t *)src_row
;
555 for(x
= 0; x
< width
; ++x
) {
556 uint32_t value
= util_cpu_to_le32(*src
++);
557 *dst
++ = value
& 0xff;
559 src_row
+= src_stride
/sizeof(*src_row
);
560 dst_row
+= dst_stride
/sizeof(*dst_row
);
565 util_format_s8_uint_z24_unorm_pack_s_8uint(uint8_t *dst_row
, unsigned dst_stride
,
566 const uint8_t *src_row
, unsigned src_stride
,
567 unsigned width
, unsigned height
)
570 for(y
= 0; y
< height
; ++y
) {
571 const uint8_t *src
= src_row
;
572 uint32_t *dst
= (uint32_t *)dst_row
;
573 for(x
= 0; x
< width
; ++x
) {
574 uint32_t value
= util_le32_to_cpu(*dst
);
577 *dst
++ = util_cpu_to_le32(value
);
579 dst_row
+= dst_stride
/sizeof(*dst_row
);
580 src_row
+= src_stride
/sizeof(*src_row
);
585 util_format_z24x8_unorm_unpack_z_float(float *dst_row
, unsigned dst_stride
,
586 const uint8_t *src_row
, unsigned src_stride
,
587 unsigned width
, unsigned height
)
590 for(y
= 0; y
< height
; ++y
) {
591 float *dst
= dst_row
;
592 const uint32_t *src
= (const uint32_t *)src_row
;
593 for(x
= 0; x
< width
; ++x
) {
594 uint32_t value
= util_cpu_to_le32(*src
++);
595 *dst
++ = z24_unorm_to_z32_float(value
& 0xffffff);
597 src_row
+= src_stride
/sizeof(*src_row
);
598 dst_row
+= dst_stride
/sizeof(*dst_row
);
603 util_format_z24x8_unorm_pack_z_float(uint8_t *dst_row
, unsigned dst_stride
,
604 const float *src_row
, unsigned src_stride
,
605 unsigned width
, unsigned height
)
608 for(y
= 0; y
< height
; ++y
) {
609 const float *src
= src_row
;
610 uint32_t *dst
= (uint32_t *)dst_row
;
611 for(x
= 0; x
< width
; ++x
) {
613 value
= z32_float_to_z24_unorm(*src
++);
614 *dst
++ = util_le32_to_cpu(value
);
616 dst_row
+= dst_stride
/sizeof(*dst_row
);
617 src_row
+= src_stride
/sizeof(*src_row
);
622 util_format_z24x8_unorm_unpack_z_32unorm(uint32_t *dst_row
, unsigned dst_stride
,
623 const uint8_t *src_row
, unsigned src_stride
,
624 unsigned width
, unsigned height
)
627 for(y
= 0; y
< height
; ++y
) {
628 uint32_t *dst
= dst_row
;
629 const uint32_t *src
= (const uint32_t *)src_row
;
630 for(x
= 0; x
< width
; ++x
) {
631 uint32_t value
= util_cpu_to_le32(*src
++);
632 *dst
++ = z24_unorm_to_z32_unorm(value
& 0xffffff);
634 src_row
+= src_stride
/sizeof(*src_row
);
635 dst_row
+= dst_stride
/sizeof(*dst_row
);
640 util_format_z24x8_unorm_pack_z_32unorm(uint8_t *dst_row
, unsigned dst_stride
,
641 const uint32_t *src_row
, unsigned src_stride
,
642 unsigned width
, unsigned height
)
645 for(y
= 0; y
< height
; ++y
) {
646 const uint32_t *src
= src_row
;
647 uint32_t *dst
= (uint32_t *)dst_row
;
648 for(x
= 0; x
< width
; ++x
) {
650 value
= z32_unorm_to_z24_unorm(*src
++);
651 *dst
++ = util_cpu_to_le32(value
);
653 dst_row
+= dst_stride
/sizeof(*dst_row
);
654 src_row
+= src_stride
/sizeof(*src_row
);
659 util_format_x8z24_unorm_unpack_z_float(float *dst_row
, unsigned dst_stride
,
660 const uint8_t *src_row
, unsigned src_stride
,
661 unsigned width
, unsigned height
)
664 for(y
= 0; y
< height
; ++y
) {
665 float *dst
= dst_row
;
666 const uint32_t *src
= (uint32_t *)src_row
;
667 for(x
= 0; x
< width
; ++x
) {
668 uint32_t value
= util_cpu_to_le32(*src
++);
669 *dst
++ = z24_unorm_to_z32_float(value
>> 8);
671 src_row
+= src_stride
/sizeof(*src_row
);
672 dst_row
+= dst_stride
/sizeof(*dst_row
);
677 util_format_x8z24_unorm_pack_z_float(uint8_t *dst_row
, unsigned dst_stride
,
678 const float *src_row
, unsigned src_stride
,
679 unsigned width
, unsigned height
)
682 for(y
= 0; y
< height
; ++y
) {
683 const float *src
= src_row
;
684 uint32_t *dst
= (uint32_t *)dst_row
;
685 for(x
= 0; x
< width
; ++x
) {
687 value
= z32_float_to_z24_unorm(*src
++) << 8;
688 *dst
++ = util_cpu_to_le32(value
);
690 dst_row
+= dst_stride
/sizeof(*dst_row
);
691 src_row
+= src_stride
/sizeof(*src_row
);
696 util_format_x8z24_unorm_unpack_z_32unorm(uint32_t *dst_row
, unsigned dst_stride
,
697 const uint8_t *src_row
, unsigned src_stride
,
698 unsigned width
, unsigned height
)
701 for(y
= 0; y
< height
; ++y
) {
702 uint32_t *dst
= dst_row
;
703 const uint32_t *src
= (const uint32_t *)src_row
;
704 for(x
= 0; x
< width
; ++x
) {
705 uint32_t value
= util_cpu_to_le32(*src
++);
706 *dst
++ = z24_unorm_to_z32_unorm(value
>> 8);
708 src_row
+= src_stride
/sizeof(*src_row
);
709 dst_row
+= dst_stride
/sizeof(*dst_row
);
714 util_format_x8z24_unorm_pack_z_32unorm(uint8_t *dst_row
, unsigned dst_stride
,
715 const uint32_t *src_row
, unsigned src_stride
,
716 unsigned width
, unsigned height
)
719 for(y
= 0; y
< height
; ++y
) {
720 const uint32_t *src
= src_row
;
721 uint32_t *dst
= (uint32_t *)dst_row
;
722 for(x
= 0; x
< width
; ++x
) {
724 value
= z32_unorm_to_z24_unorm(*src
++) << 8;
725 *dst
++ = util_cpu_to_le32(value
);
727 dst_row
+= dst_stride
/sizeof(*dst_row
);
728 src_row
+= src_stride
/sizeof(*src_row
);
733 util_format_z32_float_s8x24_uint_unpack_z_float(float *dst_row
, unsigned dst_stride
,
734 const uint8_t *src_row
, unsigned src_stride
,
735 unsigned width
, unsigned height
)
738 for(y
= 0; y
< height
; ++y
) {
739 float *dst
= dst_row
;
740 const float *src
= (const float *)src_row
;
741 for(x
= 0; x
< width
; ++x
) {
746 src_row
+= src_stride
/sizeof(*src_row
);
747 dst_row
+= dst_stride
/sizeof(*dst_row
);
752 util_format_z32_float_s8x24_uint_pack_z_float(uint8_t *dst_row
, unsigned dst_stride
,
753 const float *src_row
, unsigned src_stride
,
754 unsigned width
, unsigned height
)
757 for(y
= 0; y
< height
; ++y
) {
758 const float *src
= src_row
;
759 float *dst
= (float *)dst_row
;
760 for(x
= 0; x
< width
; ++x
) {
765 dst_row
+= dst_stride
/sizeof(*dst_row
);
766 src_row
+= src_stride
/sizeof(*src_row
);
771 util_format_z32_float_s8x24_uint_unpack_z_32unorm(uint32_t *dst_row
, unsigned dst_stride
,
772 const uint8_t *src_row
, unsigned src_stride
,
773 unsigned width
, unsigned height
)
776 for(y
= 0; y
< height
; ++y
) {
777 uint32_t *dst
= dst_row
;
778 const float *src
= (const float *)src_row
;
779 for(x
= 0; x
< width
; ++x
) {
780 *dst
= z32_float_to_z32_unorm(*src
);
784 src_row
+= src_stride
/sizeof(*src_row
);
785 dst_row
+= dst_stride
/sizeof(*dst_row
);
790 util_format_z32_float_s8x24_uint_pack_z_32unorm(uint8_t *dst_row
, unsigned dst_stride
,
791 const uint32_t *src_row
, unsigned src_stride
,
792 unsigned width
, unsigned height
)
795 for(y
= 0; y
< height
; ++y
) {
796 const uint32_t *src
= src_row
;
797 float *dst
= (float *)dst_row
;
798 for(x
= 0; x
< width
; ++x
) {
799 *dst
++ = z32_unorm_to_z32_float(*src
++);
801 dst_row
+= dst_stride
/sizeof(*dst_row
);
802 src_row
+= src_stride
/sizeof(*src_row
);
807 util_format_z32_float_s8x24_uint_unpack_s_8uint(uint8_t *dst_row
, unsigned dst_stride
,
808 const uint8_t *src_row
, unsigned src_stride
,
809 unsigned width
, unsigned height
)
812 for(y
= 0; y
< height
; ++y
) {
813 uint8_t *dst
= dst_row
;
814 const uint8_t *src
= src_row
+ 4;
815 for(x
= 0; x
< width
; ++x
) {
820 src_row
+= src_stride
/sizeof(*src_row
);
821 dst_row
+= dst_stride
/sizeof(*dst_row
);
826 util_format_z32_float_s8x24_uint_pack_s_8uint(uint8_t *dst_row
, unsigned dst_stride
,
827 const uint8_t *src_row
, unsigned src_stride
,
828 unsigned width
, unsigned height
)
831 for(y
= 0; y
< height
; ++y
) {
832 const uint8_t *src
= src_row
;
833 uint32_t *dst
= ((uint32_t *)dst_row
) + 1;
834 for(x
= 0; x
< width
; ++x
) {
835 *dst
= util_cpu_to_le32(*src
);
839 dst_row
+= dst_stride
/sizeof(*dst_row
);
840 src_row
+= src_stride
/sizeof(*src_row
);
846 util_format_x24s8_uint_unpack_s_8uint(uint8_t *dst_row
, unsigned dst_stride
, const uint8_t *src_row
, unsigned src_stride
, unsigned width
, unsigned height
)
848 util_format_z24_unorm_s8_uint_unpack_s_8uint(dst_row
, dst_stride
,
854 util_format_x24s8_uint_pack_s_8uint(uint8_t *dst_row
, unsigned dst_stride
, const uint8_t *src_row
, unsigned src_stride
, unsigned width
, unsigned height
)
856 util_format_z24_unorm_s8_uint_pack_s_8uint(dst_row
, dst_stride
,
862 util_format_s8x24_uint_unpack_s_8uint(uint8_t *dst_row
, unsigned dst_stride
, const uint8_t *src_row
, unsigned src_stride
, unsigned width
, unsigned height
)
864 util_format_s8_uint_z24_unorm_unpack_s_8uint(dst_row
, dst_stride
,
870 util_format_s8x24_uint_pack_s_8uint(uint8_t *dst_row
, unsigned dst_stride
, const uint8_t *src_row
, unsigned src_stride
, unsigned width
, unsigned height
)
872 util_format_s8_uint_z24_unorm_pack_s_8uint(dst_row
, dst_stride
,
878 util_format_x32_s8x24_uint_unpack_s_8uint(uint8_t *dst_row
, unsigned dst_stride
,
879 const uint8_t *src_row
, unsigned src_stride
,
880 unsigned width
, unsigned height
)
882 util_format_z32_float_s8x24_uint_unpack_s_8uint(dst_row
, dst_stride
,
889 util_format_x32_s8x24_uint_pack_s_8uint(uint8_t *dst_row
, unsigned dst_stride
,
890 const uint8_t *src_row
, unsigned src_stride
,
891 unsigned width
, unsigned height
)
893 util_format_z32_float_s8x24_uint_pack_s_8uint(dst_row
, dst_stride
,