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 "util/format/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_z16_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
)
341 unreachable("z16_s8 packing/unpacking is not implemented.");
345 util_format_z16_unorm_s8_uint_pack_z_float(uint8_t *dst_row
, unsigned dst_stride
,
346 const float *src_row
, unsigned src_stride
,
347 unsigned width
, unsigned height
)
349 unreachable("z16_s8 packing/unpacking is not implemented.");
353 util_format_z16_unorm_s8_uint_unpack_z_32unorm(uint32_t *dst_row
, unsigned dst_stride
,
354 const uint8_t *src_row
, unsigned src_stride
,
355 unsigned width
, unsigned height
)
357 unreachable("z16_s8 packing/unpacking is not implemented.");
361 util_format_z16_unorm_s8_uint_pack_z_32unorm(uint8_t *dst_row
, unsigned dst_stride
,
362 const uint32_t *src_row
, unsigned src_stride
,
363 unsigned width
, unsigned height
)
365 unreachable("z16_s8 packing/unpacking is not implemented.");
369 util_format_z16_unorm_s8_uint_unpack_s_8uint(uint8_t *dst_row
, unsigned dst_stride
,
370 const uint8_t *src_row
, unsigned src_stride
,
371 unsigned width
, unsigned height
)
373 unreachable("z16_s8 packing/unpacking is not implemented.");
377 util_format_z16_unorm_s8_uint_pack_s_8uint(uint8_t *dst_row
, unsigned dst_stride
,
378 const uint8_t *src_row
, unsigned src_stride
,
379 unsigned width
, unsigned height
)
381 unreachable("z16_s8 packing/unpacking is not implemented.");
385 util_format_z24_unorm_s8_uint_unpack_z_float(float *dst_row
, unsigned dst_stride
,
386 const uint8_t *src_row
, unsigned src_stride
,
387 unsigned width
, unsigned height
)
390 for(y
= 0; y
< height
; ++y
) {
391 float *dst
= dst_row
;
392 const uint32_t *src
= (const uint32_t *)src_row
;
393 for(x
= 0; x
< width
; ++x
) {
394 uint32_t value
= util_cpu_to_le32(*src
++);
395 *dst
++ = z24_unorm_to_z32_float(value
& 0xffffff);
397 src_row
+= src_stride
/sizeof(*src_row
);
398 dst_row
+= dst_stride
/sizeof(*dst_row
);
403 util_format_z24_unorm_s8_uint_pack_z_float(uint8_t *dst_row
, unsigned dst_stride
,
404 const float *src_row
, unsigned src_stride
,
405 unsigned width
, unsigned height
)
408 for(y
= 0; y
< height
; ++y
) {
409 const float *src
= src_row
;
410 uint32_t *dst
= (uint32_t *)dst_row
;
411 for(x
= 0; x
< width
; ++x
) {
412 uint32_t value
= util_le32_to_cpu(*dst
);
414 value
|= z32_float_to_z24_unorm(*src
++);
415 *dst
++ = util_cpu_to_le32(value
);
417 dst_row
+= dst_stride
/sizeof(*dst_row
);
418 src_row
+= src_stride
/sizeof(*src_row
);
423 util_format_z24_unorm_s8_uint_unpack_z_32unorm(uint32_t *dst_row
, unsigned dst_stride
,
424 const uint8_t *src_row
, unsigned src_stride
,
425 unsigned width
, unsigned height
)
428 for(y
= 0; y
< height
; ++y
) {
429 uint32_t *dst
= dst_row
;
430 const uint32_t *src
= (const uint32_t *)src_row
;
431 for(x
= 0; x
< width
; ++x
) {
432 uint32_t value
= util_cpu_to_le32(*src
++);
433 *dst
++ = z24_unorm_to_z32_unorm(value
& 0xffffff);
435 src_row
+= src_stride
/sizeof(*src_row
);
436 dst_row
+= dst_stride
/sizeof(*dst_row
);
441 util_format_z24_unorm_s8_uint_pack_z_32unorm(uint8_t *dst_row
, unsigned dst_stride
,
442 const uint32_t *src_row
, unsigned src_stride
,
443 unsigned width
, unsigned height
)
446 for(y
= 0; y
< height
; ++y
) {
447 const uint32_t *src
= src_row
;
448 uint32_t *dst
= (uint32_t *)dst_row
;
449 for(x
= 0; x
< width
; ++x
) {
450 uint32_t value
= util_le32_to_cpu(*dst
);
452 value
|= z32_unorm_to_z24_unorm(*src
++);
453 *dst
++ = util_cpu_to_le32(value
);
455 dst_row
+= dst_stride
/sizeof(*dst_row
);
456 src_row
+= src_stride
/sizeof(*src_row
);
461 util_format_z24_unorm_s8_uint_unpack_s_8uint(uint8_t *dst_row
, unsigned dst_stride
,
462 const uint8_t *src_row
, unsigned src_stride
,
463 unsigned width
, unsigned height
)
466 for(y
= 0; y
< height
; ++y
) {
467 uint8_t *dst
= dst_row
;
468 const uint32_t *src
= (const uint32_t *)src_row
;
469 for(x
= 0; x
< width
; ++x
) {
470 uint32_t value
= util_cpu_to_le32(*src
++);
471 *dst
++ = value
>> 24;
473 src_row
+= src_stride
/sizeof(*src_row
);
474 dst_row
+= dst_stride
/sizeof(*dst_row
);
479 util_format_z24_unorm_s8_uint_pack_s_8uint(uint8_t *dst_row
, unsigned dst_stride
,
480 const uint8_t *src_row
, unsigned src_stride
,
481 unsigned width
, unsigned height
)
484 for(y
= 0; y
< height
; ++y
) {
485 const uint8_t *src
= src_row
;
486 uint32_t *dst
= (uint32_t *)dst_row
;
487 for(x
= 0; x
< width
; ++x
) {
488 uint32_t value
= util_le32_to_cpu(*dst
);
490 value
|= (uint32_t)*src
++ << 24;
491 *dst
++ = util_cpu_to_le32(value
);
493 dst_row
+= dst_stride
/sizeof(*dst_row
);
494 src_row
+= src_stride
/sizeof(*src_row
);
499 util_format_z24_unorm_s8_uint_pack_separate(uint8_t *dst_row
, unsigned dst_stride
,
500 const uint32_t *z_src_row
, unsigned z_src_stride
,
501 const uint8_t *s_src_row
, unsigned s_src_stride
,
502 unsigned width
, unsigned height
)
505 for (y
= 0; y
< height
; ++y
) {
506 const uint32_t *z_src
= z_src_row
;
507 const uint8_t *s_src
= s_src_row
;
508 uint32_t *dst
= (uint32_t *)dst_row
;
509 for (x
= 0; x
< width
; ++x
) {
510 *dst
++ = (*z_src
++ & 0x00ffffff) | ((uint32_t)*s_src
++ << 24);
512 dst_row
+= dst_stride
/ sizeof(*dst_row
);
513 z_src_row
+= z_src_stride
/ sizeof(*z_src_row
);
514 s_src_row
+= s_src_stride
/ sizeof(*s_src_row
);
519 util_format_s8_uint_z24_unorm_unpack_z_float(float *dst_row
, unsigned dst_stride
,
520 const uint8_t *src_row
, unsigned src_stride
,
521 unsigned width
, unsigned height
)
524 for(y
= 0; y
< height
; ++y
) {
525 float *dst
= dst_row
;
526 const uint32_t *src
= (const uint32_t *)src_row
;
527 for(x
= 0; x
< width
; ++x
) {
528 uint32_t value
= util_cpu_to_le32(*src
++);
529 *dst
++ = z24_unorm_to_z32_float(value
>> 8);
531 src_row
+= src_stride
/sizeof(*src_row
);
532 dst_row
+= dst_stride
/sizeof(*dst_row
);
537 util_format_s8_uint_z24_unorm_pack_z_float(uint8_t *dst_row
, unsigned dst_stride
,
538 const float *src_row
, unsigned src_stride
,
539 unsigned width
, unsigned height
)
542 for(y
= 0; y
< height
; ++y
) {
543 const float *src
= src_row
;
544 uint32_t *dst
= (uint32_t *)dst_row
;
545 for(x
= 0; x
< width
; ++x
) {
546 uint32_t value
= util_le32_to_cpu(*dst
);
548 value
|= z32_float_to_z24_unorm(*src
++) << 8;
549 *dst
++ = util_cpu_to_le32(value
);
551 dst_row
+= dst_stride
/sizeof(*dst_row
);
552 src_row
+= src_stride
/sizeof(*src_row
);
557 util_format_s8_uint_z24_unorm_unpack_z_32unorm(uint32_t *dst_row
, unsigned dst_stride
,
558 const uint8_t *src_row
, unsigned src_stride
,
559 unsigned width
, unsigned height
)
562 for(y
= 0; y
< height
; ++y
) {
563 uint32_t *dst
= dst_row
;
564 const uint32_t *src
= (const uint32_t *)src_row
;
565 for(x
= 0; x
< width
; ++x
) {
566 uint32_t value
= util_cpu_to_le32(*src
++);
567 *dst
++ = z24_unorm_to_z32_unorm(value
>> 8);
569 src_row
+= src_stride
/sizeof(*src_row
);
570 dst_row
+= dst_stride
/sizeof(*dst_row
);
575 util_format_s8_uint_z24_unorm_pack_z_32unorm(uint8_t *dst_row
, unsigned dst_stride
,
576 const uint32_t *src_row
, unsigned src_stride
,
577 unsigned width
, unsigned height
)
580 for(y
= 0; y
< height
; ++y
) {
581 const uint32_t *src
= src_row
;
582 uint32_t *dst
= (uint32_t *)dst_row
;
583 for(x
= 0; x
< width
; ++x
) {
584 uint32_t value
= util_le32_to_cpu(*dst
);
586 value
|= *src
++ & 0xffffff00;
587 *dst
++ = util_cpu_to_le32(value
);
589 dst_row
+= dst_stride
/sizeof(*dst_row
);
590 src_row
+= src_stride
/sizeof(*src_row
);
595 util_format_s8_uint_z24_unorm_unpack_s_8uint(uint8_t *dst_row
, unsigned dst_stride
,
596 const uint8_t *src_row
, unsigned src_stride
,
597 unsigned width
, unsigned height
)
600 for(y
= 0; y
< height
; ++y
) {
601 uint8_t *dst
= dst_row
;
602 const uint32_t *src
= (const uint32_t *)src_row
;
603 for(x
= 0; x
< width
; ++x
) {
604 uint32_t value
= util_cpu_to_le32(*src
++);
605 *dst
++ = value
& 0xff;
607 src_row
+= src_stride
/sizeof(*src_row
);
608 dst_row
+= dst_stride
/sizeof(*dst_row
);
613 util_format_s8_uint_z24_unorm_pack_s_8uint(uint8_t *dst_row
, unsigned dst_stride
,
614 const uint8_t *src_row
, unsigned src_stride
,
615 unsigned width
, unsigned height
)
618 for(y
= 0; y
< height
; ++y
) {
619 const uint8_t *src
= src_row
;
620 uint32_t *dst
= (uint32_t *)dst_row
;
621 for(x
= 0; x
< width
; ++x
) {
622 uint32_t value
= util_le32_to_cpu(*dst
);
625 *dst
++ = util_cpu_to_le32(value
);
627 dst_row
+= dst_stride
/sizeof(*dst_row
);
628 src_row
+= src_stride
/sizeof(*src_row
);
633 util_format_z24x8_unorm_unpack_z_float(float *dst_row
, unsigned dst_stride
,
634 const uint8_t *src_row
, unsigned src_stride
,
635 unsigned width
, unsigned height
)
638 for(y
= 0; y
< height
; ++y
) {
639 float *dst
= dst_row
;
640 const uint32_t *src
= (const uint32_t *)src_row
;
641 for(x
= 0; x
< width
; ++x
) {
642 uint32_t value
= util_cpu_to_le32(*src
++);
643 *dst
++ = z24_unorm_to_z32_float(value
& 0xffffff);
645 src_row
+= src_stride
/sizeof(*src_row
);
646 dst_row
+= dst_stride
/sizeof(*dst_row
);
651 util_format_z24x8_unorm_pack_z_float(uint8_t *dst_row
, unsigned dst_stride
,
652 const float *src_row
, unsigned src_stride
,
653 unsigned width
, unsigned height
)
656 for(y
= 0; y
< height
; ++y
) {
657 const float *src
= src_row
;
658 uint32_t *dst
= (uint32_t *)dst_row
;
659 for(x
= 0; x
< width
; ++x
) {
661 value
= z32_float_to_z24_unorm(*src
++);
662 *dst
++ = util_le32_to_cpu(value
);
664 dst_row
+= dst_stride
/sizeof(*dst_row
);
665 src_row
+= src_stride
/sizeof(*src_row
);
670 util_format_z24x8_unorm_unpack_z_32unorm(uint32_t *dst_row
, unsigned dst_stride
,
671 const uint8_t *src_row
, unsigned src_stride
,
672 unsigned width
, unsigned height
)
675 for(y
= 0; y
< height
; ++y
) {
676 uint32_t *dst
= dst_row
;
677 const uint32_t *src
= (const uint32_t *)src_row
;
678 for(x
= 0; x
< width
; ++x
) {
679 uint32_t value
= util_cpu_to_le32(*src
++);
680 *dst
++ = z24_unorm_to_z32_unorm(value
& 0xffffff);
682 src_row
+= src_stride
/sizeof(*src_row
);
683 dst_row
+= dst_stride
/sizeof(*dst_row
);
688 util_format_z24x8_unorm_pack_z_32unorm(uint8_t *dst_row
, unsigned dst_stride
,
689 const uint32_t *src_row
, unsigned src_stride
,
690 unsigned width
, unsigned height
)
693 for(y
= 0; y
< height
; ++y
) {
694 const uint32_t *src
= src_row
;
695 uint32_t *dst
= (uint32_t *)dst_row
;
696 for(x
= 0; x
< width
; ++x
) {
698 value
= z32_unorm_to_z24_unorm(*src
++);
699 *dst
++ = util_cpu_to_le32(value
);
701 dst_row
+= dst_stride
/sizeof(*dst_row
);
702 src_row
+= src_stride
/sizeof(*src_row
);
707 util_format_x8z24_unorm_unpack_z_float(float *dst_row
, unsigned dst_stride
,
708 const uint8_t *src_row
, unsigned src_stride
,
709 unsigned width
, unsigned height
)
712 for(y
= 0; y
< height
; ++y
) {
713 float *dst
= dst_row
;
714 const uint32_t *src
= (uint32_t *)src_row
;
715 for(x
= 0; x
< width
; ++x
) {
716 uint32_t value
= util_cpu_to_le32(*src
++);
717 *dst
++ = z24_unorm_to_z32_float(value
>> 8);
719 src_row
+= src_stride
/sizeof(*src_row
);
720 dst_row
+= dst_stride
/sizeof(*dst_row
);
725 util_format_x8z24_unorm_pack_z_float(uint8_t *dst_row
, unsigned dst_stride
,
726 const float *src_row
, unsigned src_stride
,
727 unsigned width
, unsigned height
)
730 for(y
= 0; y
< height
; ++y
) {
731 const float *src
= src_row
;
732 uint32_t *dst
= (uint32_t *)dst_row
;
733 for(x
= 0; x
< width
; ++x
) {
735 value
= z32_float_to_z24_unorm(*src
++) << 8;
736 *dst
++ = util_cpu_to_le32(value
);
738 dst_row
+= dst_stride
/sizeof(*dst_row
);
739 src_row
+= src_stride
/sizeof(*src_row
);
744 util_format_x8z24_unorm_unpack_z_32unorm(uint32_t *dst_row
, unsigned dst_stride
,
745 const uint8_t *src_row
, unsigned src_stride
,
746 unsigned width
, unsigned height
)
749 for(y
= 0; y
< height
; ++y
) {
750 uint32_t *dst
= dst_row
;
751 const uint32_t *src
= (const uint32_t *)src_row
;
752 for(x
= 0; x
< width
; ++x
) {
753 uint32_t value
= util_cpu_to_le32(*src
++);
754 *dst
++ = z24_unorm_to_z32_unorm(value
>> 8);
756 src_row
+= src_stride
/sizeof(*src_row
);
757 dst_row
+= dst_stride
/sizeof(*dst_row
);
762 util_format_x8z24_unorm_pack_z_32unorm(uint8_t *dst_row
, unsigned dst_stride
,
763 const uint32_t *src_row
, unsigned src_stride
,
764 unsigned width
, unsigned height
)
767 for(y
= 0; y
< height
; ++y
) {
768 const uint32_t *src
= src_row
;
769 uint32_t *dst
= (uint32_t *)dst_row
;
770 for(x
= 0; x
< width
; ++x
) {
772 value
= z32_unorm_to_z24_unorm(*src
++) << 8;
773 *dst
++ = util_cpu_to_le32(value
);
775 dst_row
+= dst_stride
/sizeof(*dst_row
);
776 src_row
+= src_stride
/sizeof(*src_row
);
781 util_format_z32_float_s8x24_uint_unpack_z_float(float *dst_row
, unsigned dst_stride
,
782 const uint8_t *src_row
, unsigned src_stride
,
783 unsigned width
, unsigned height
)
786 for(y
= 0; y
< height
; ++y
) {
787 float *dst
= dst_row
;
788 const float *src
= (const float *)src_row
;
789 for(x
= 0; x
< width
; ++x
) {
794 src_row
+= src_stride
/sizeof(*src_row
);
795 dst_row
+= dst_stride
/sizeof(*dst_row
);
800 util_format_z32_float_s8x24_uint_pack_z_float(uint8_t *dst_row
, unsigned dst_stride
,
801 const float *src_row
, unsigned src_stride
,
802 unsigned width
, unsigned height
)
805 for(y
= 0; y
< height
; ++y
) {
806 const float *src
= src_row
;
807 float *dst
= (float *)dst_row
;
808 for(x
= 0; x
< width
; ++x
) {
813 dst_row
+= dst_stride
/sizeof(*dst_row
);
814 src_row
+= src_stride
/sizeof(*src_row
);
819 util_format_z32_float_s8x24_uint_unpack_z_32unorm(uint32_t *dst_row
, unsigned dst_stride
,
820 const uint8_t *src_row
, unsigned src_stride
,
821 unsigned width
, unsigned height
)
824 for(y
= 0; y
< height
; ++y
) {
825 uint32_t *dst
= dst_row
;
826 const float *src
= (const float *)src_row
;
827 for(x
= 0; x
< width
; ++x
) {
828 *dst
= z32_float_to_z32_unorm(*src
);
832 src_row
+= src_stride
/sizeof(*src_row
);
833 dst_row
+= dst_stride
/sizeof(*dst_row
);
838 util_format_z32_float_s8x24_uint_pack_z_32unorm(uint8_t *dst_row
, unsigned dst_stride
,
839 const uint32_t *src_row
, unsigned src_stride
,
840 unsigned width
, unsigned height
)
843 for(y
= 0; y
< height
; ++y
) {
844 const uint32_t *src
= src_row
;
845 float *dst
= (float *)dst_row
;
846 for(x
= 0; x
< width
; ++x
) {
847 *dst
++ = z32_unorm_to_z32_float(*src
++);
849 dst_row
+= dst_stride
/sizeof(*dst_row
);
850 src_row
+= src_stride
/sizeof(*src_row
);
855 util_format_z32_float_s8x24_uint_unpack_s_8uint(uint8_t *dst_row
, unsigned dst_stride
,
856 const uint8_t *src_row
, unsigned src_stride
,
857 unsigned width
, unsigned height
)
860 for(y
= 0; y
< height
; ++y
) {
861 uint8_t *dst
= dst_row
;
862 const uint8_t *src
= src_row
+ 4;
863 for(x
= 0; x
< width
; ++x
) {
868 src_row
+= src_stride
/sizeof(*src_row
);
869 dst_row
+= dst_stride
/sizeof(*dst_row
);
874 util_format_z32_float_s8x24_uint_pack_s_8uint(uint8_t *dst_row
, unsigned dst_stride
,
875 const uint8_t *src_row
, unsigned src_stride
,
876 unsigned width
, unsigned height
)
879 for(y
= 0; y
< height
; ++y
) {
880 const uint8_t *src
= src_row
;
881 uint32_t *dst
= ((uint32_t *)dst_row
) + 1;
882 for(x
= 0; x
< width
; ++x
) {
883 *dst
= util_cpu_to_le32(*src
);
887 dst_row
+= dst_stride
/sizeof(*dst_row
);
888 src_row
+= src_stride
/sizeof(*src_row
);
894 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
)
896 util_format_z24_unorm_s8_uint_unpack_s_8uint(dst_row
, dst_stride
,
902 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
)
904 util_format_z24_unorm_s8_uint_pack_s_8uint(dst_row
, dst_stride
,
910 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
)
912 util_format_s8_uint_z24_unorm_unpack_s_8uint(dst_row
, dst_stride
,
918 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
)
920 util_format_s8_uint_z24_unorm_pack_s_8uint(dst_row
, dst_stride
,
926 util_format_x32_s8x24_uint_unpack_s_8uint(uint8_t *dst_row
, unsigned dst_stride
,
927 const uint8_t *src_row
, unsigned src_stride
,
928 unsigned width
, unsigned height
)
930 util_format_z32_float_s8x24_uint_unpack_s_8uint(dst_row
, dst_stride
,
937 util_format_x32_s8x24_uint_pack_s_8uint(uint8_t *dst_row
, unsigned dst_stride
,
938 const uint8_t *src_row
, unsigned src_stride
,
939 unsigned width
, unsigned height
)
941 util_format_z32_float_s8x24_uint_pack_s_8uint(dst_row
, dst_stride
,