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 **************************************************************************/
31 #include "u_format_zs.h"
35 * z32_unorm conversion functions
38 static inline uint16_t
39 z32_unorm_to_z16_unorm(uint32_t z
)
41 /* z * 0xffff / 0xffffffff */
45 static inline uint32_t
46 z16_unorm_to_z32_unorm(uint16_t z
)
48 /* z * 0xffffffff / 0xffff */
52 static inline uint32_t
53 z32_unorm_to_z24_unorm(uint32_t z
)
55 /* z * 0xffffff / 0xffffffff */
59 static inline uint32_t
60 z24_unorm_to_z32_unorm(uint32_t z
)
62 /* z * 0xffffffff / 0xffffff */
63 return (z
<< 8) | (z
>> 16);
68 * z32_float conversion functions
71 static inline uint16_t
72 z32_float_to_z16_unorm(float z
)
74 const float scale
= 0xffff;
75 return (uint16_t)(z
* scale
+ 0.5f
);
79 z16_unorm_to_z32_float(uint16_t z
)
81 const float scale
= 1.0 / 0xffff;
82 return (float)(z
* scale
);
85 static inline uint32_t
86 z32_float_to_z24_unorm(float z
)
88 const double scale
= 0xffffff;
89 return (uint32_t)(z
* scale
) & 0xffffff;
93 z24_unorm_to_z32_float(uint32_t z
)
95 const double scale
= 1.0 / 0xffffff;
96 return (float)(z
* scale
);
99 static inline uint32_t
100 z32_float_to_z32_unorm(float z
)
102 const double scale
= 0xffffffff;
103 return (uint32_t)(z
* scale
);
107 z32_unorm_to_z32_float(uint32_t z
)
109 const double scale
= 1.0 / 0xffffffff;
110 return (float)(z
* scale
);
115 util_format_s8_uint_unpack_s_8uint(uint8_t *dst_row
, unsigned dst_stride
,
116 const uint8_t *src_row
, unsigned src_stride
,
117 unsigned width
, unsigned height
)
120 for(y
= 0; y
< height
; ++y
) {
121 memcpy(dst_row
, src_row
, width
);
122 src_row
+= src_stride
/sizeof(*src_row
);
123 dst_row
+= dst_stride
/sizeof(*dst_row
);
128 util_format_s8_uint_pack_s_8uint(uint8_t *dst_row
, unsigned dst_stride
,
129 const uint8_t *src_row
, unsigned src_stride
,
130 unsigned width
, unsigned height
)
133 for(y
= 0; y
< height
; ++y
) {
134 memcpy(dst_row
, src_row
, width
);
135 src_row
+= src_stride
/sizeof(*src_row
);
136 dst_row
+= dst_stride
/sizeof(*dst_row
);
141 util_format_z16_unorm_unpack_z_float(float *dst_row
, unsigned dst_stride
,
142 const uint8_t *src_row
, unsigned src_stride
,
143 unsigned width
, unsigned height
)
146 for(y
= 0; y
< height
; ++y
) {
147 float *dst
= dst_row
;
148 const uint16_t *src
= (const uint16_t *)src_row
;
149 for(x
= 0; x
< width
; ++x
) {
150 uint16_t value
= util_cpu_to_le16(*src
++);
151 *dst
++ = z16_unorm_to_z32_float(value
);
153 src_row
+= src_stride
/sizeof(*src_row
);
154 dst_row
+= dst_stride
/sizeof(*dst_row
);
159 util_format_z16_unorm_pack_z_float(uint8_t *dst_row
, unsigned dst_stride
,
160 const float *src_row
, unsigned src_stride
,
161 unsigned width
, unsigned height
)
164 for(y
= 0; y
< height
; ++y
) {
165 const float *src
= src_row
;
166 uint16_t *dst
= (uint16_t *)dst_row
;
167 for(x
= 0; x
< width
; ++x
) {
169 value
= z32_float_to_z16_unorm(*src
++);
170 *dst
++ = util_le16_to_cpu(value
);
172 dst_row
+= dst_stride
/sizeof(*dst_row
);
173 src_row
+= src_stride
/sizeof(*src_row
);
178 util_format_z16_unorm_unpack_z_32unorm(uint32_t *dst_row
, unsigned dst_stride
,
179 const uint8_t *src_row
, unsigned src_stride
,
180 unsigned width
, unsigned height
)
183 for(y
= 0; y
< height
; ++y
) {
184 uint32_t *dst
= dst_row
;
185 const uint16_t *src
= (const uint16_t *)src_row
;
186 for(x
= 0; x
< width
; ++x
) {
187 uint16_t value
= util_cpu_to_le16(*src
++);
188 *dst
++ = z16_unorm_to_z32_unorm(value
);
190 src_row
+= src_stride
/sizeof(*src_row
);
191 dst_row
+= dst_stride
/sizeof(*dst_row
);
196 util_format_z16_unorm_pack_z_32unorm(uint8_t *dst_row
, unsigned dst_stride
,
197 const uint32_t *src_row
, unsigned src_stride
,
198 unsigned width
, unsigned height
)
201 for(y
= 0; y
< height
; ++y
) {
202 const uint32_t *src
= src_row
;
203 uint16_t *dst
= (uint16_t *)dst_row
;
204 for(x
= 0; x
< width
; ++x
) {
206 value
= z32_unorm_to_z16_unorm(*src
++);
207 *dst
++ = util_le16_to_cpu(value
);
209 dst_row
+= dst_stride
/sizeof(*dst_row
);
210 src_row
+= src_stride
/sizeof(*src_row
);
215 util_format_z32_unorm_unpack_z_float(float *dst_row
, unsigned dst_stride
,
216 const uint8_t *src_row
, unsigned src_stride
,
217 unsigned width
, unsigned height
)
220 for(y
= 0; y
< height
; ++y
) {
221 float *dst
= dst_row
;
222 const uint32_t *src
= (const uint32_t *)src_row
;
223 for(x
= 0; x
< width
; ++x
) {
224 uint32_t value
= util_cpu_to_le32(*src
++);
225 *dst
++ = z32_unorm_to_z32_float(value
);
227 src_row
+= src_stride
/sizeof(*src_row
);
228 dst_row
+= dst_stride
/sizeof(*dst_row
);
233 util_format_z32_unorm_pack_z_float(uint8_t *dst_row
, unsigned dst_stride
,
234 const float *src_row
, unsigned src_stride
,
235 unsigned width
, unsigned height
)
238 for(y
= 0; y
< height
; ++y
) {
239 const float *src
= src_row
;
240 uint32_t *dst
= (uint32_t *)dst_row
;
241 for(x
= 0; x
< width
; ++x
) {
243 value
= z32_float_to_z32_unorm(*src
++);
244 *dst
++ = util_le32_to_cpu(value
);
246 dst_row
+= dst_stride
/sizeof(*dst_row
);
247 src_row
+= src_stride
/sizeof(*src_row
);
252 util_format_z32_unorm_unpack_z_32unorm(uint32_t *dst_row
, unsigned dst_stride
,
253 const uint8_t *src_row
, unsigned src_stride
,
254 unsigned width
, unsigned height
)
257 for(y
= 0; y
< height
; ++y
) {
258 memcpy(dst_row
, src_row
, width
* 4);
259 src_row
+= src_stride
/sizeof(*src_row
);
260 dst_row
+= dst_stride
/sizeof(*dst_row
);
265 util_format_z32_unorm_pack_z_32unorm(uint8_t *dst_row
, unsigned dst_stride
,
266 const uint32_t *src_row
, unsigned src_stride
,
267 unsigned width
, unsigned height
)
270 for(y
= 0; y
< height
; ++y
) {
271 memcpy(dst_row
, src_row
, width
* 4);
272 src_row
+= src_stride
/sizeof(*src_row
);
273 dst_row
+= dst_stride
/sizeof(*dst_row
);
278 util_format_z32_float_unpack_z_float(float *dst_row
, unsigned dst_stride
,
279 const uint8_t *src_row
, unsigned src_stride
,
280 unsigned width
, unsigned height
)
283 for(y
= 0; y
< height
; ++y
) {
284 memcpy(dst_row
, src_row
, width
* 4);
285 src_row
+= src_stride
/sizeof(*src_row
);
286 dst_row
+= dst_stride
/sizeof(*dst_row
);
291 util_format_z32_float_pack_z_float(uint8_t *dst_row
, unsigned dst_stride
,
292 const float *src_row
, unsigned src_stride
,
293 unsigned width
, unsigned height
)
296 for(y
= 0; y
< height
; ++y
) {
297 memcpy(dst_row
, src_row
, width
* 4);
298 src_row
+= src_stride
/sizeof(*src_row
);
299 dst_row
+= dst_stride
/sizeof(*dst_row
);
304 util_format_z32_float_unpack_z_32unorm(uint32_t *dst_row
, unsigned dst_stride
,
305 const uint8_t *src_row
, unsigned src_stride
,
306 unsigned width
, unsigned height
)
309 for(y
= 0; y
< height
; ++y
) {
310 uint32_t *dst
= dst_row
;
311 const float *src
= (const float *)src_row
;
312 for(x
= 0; x
< width
; ++x
) {
313 *dst
++ = z32_float_to_z32_unorm(*src
++);
315 src_row
+= src_stride
/sizeof(*src_row
);
316 dst_row
+= dst_stride
/sizeof(*dst_row
);
321 util_format_z32_float_pack_z_32unorm(uint8_t *dst_row
, unsigned dst_stride
,
322 const uint32_t *src_row
, unsigned src_stride
,
323 unsigned width
, unsigned height
)
326 for(y
= 0; y
< height
; ++y
) {
327 const uint32_t *src
= src_row
;
328 float *dst
= (float *)dst_row
;
329 for(x
= 0; x
< width
; ++x
) {
330 *dst
++ = z32_unorm_to_z32_float(*src
++);
332 dst_row
+= dst_stride
/sizeof(*dst_row
);
333 src_row
+= src_stride
/sizeof(*src_row
);
338 util_format_z24_unorm_s8_uint_unpack_z_float(float *dst_row
, unsigned dst_stride
,
339 const uint8_t *src_row
, unsigned src_stride
,
340 unsigned width
, unsigned height
)
343 for(y
= 0; y
< height
; ++y
) {
344 float *dst
= dst_row
;
345 const uint32_t *src
= (const uint32_t *)src_row
;
346 for(x
= 0; x
< width
; ++x
) {
347 uint32_t value
= util_cpu_to_le32(*src
++);
348 *dst
++ = z24_unorm_to_z32_float(value
& 0xffffff);
350 src_row
+= src_stride
/sizeof(*src_row
);
351 dst_row
+= dst_stride
/sizeof(*dst_row
);
356 util_format_z24_unorm_s8_uint_pack_z_float(uint8_t *dst_row
, unsigned dst_stride
,
357 const float *src_row
, unsigned src_stride
,
358 unsigned width
, unsigned height
)
361 for(y
= 0; y
< height
; ++y
) {
362 const float *src
= src_row
;
363 uint32_t *dst
= (uint32_t *)dst_row
;
364 for(x
= 0; x
< width
; ++x
) {
365 uint32_t value
= util_le32_to_cpu(*dst
);
367 value
|= z32_float_to_z24_unorm(*src
++);
368 *dst
++ = util_cpu_to_le32(value
);
370 dst_row
+= dst_stride
/sizeof(*dst_row
);
371 src_row
+= src_stride
/sizeof(*src_row
);
376 util_format_z24_unorm_s8_uint_unpack_z_32unorm(uint32_t *dst_row
, unsigned dst_stride
,
377 const uint8_t *src_row
, unsigned src_stride
,
378 unsigned width
, unsigned height
)
381 for(y
= 0; y
< height
; ++y
) {
382 uint32_t *dst
= dst_row
;
383 const uint32_t *src
= (const uint32_t *)src_row
;
384 for(x
= 0; x
< width
; ++x
) {
385 uint32_t value
= util_cpu_to_le32(*src
++);
386 *dst
++ = z24_unorm_to_z32_unorm(value
& 0xffffff);
388 src_row
+= src_stride
/sizeof(*src_row
);
389 dst_row
+= dst_stride
/sizeof(*dst_row
);
394 util_format_z24_unorm_s8_uint_pack_z_32unorm(uint8_t *dst_row
, unsigned dst_stride
,
395 const uint32_t *src_row
, unsigned src_stride
,
396 unsigned width
, unsigned height
)
399 for(y
= 0; y
< height
; ++y
) {
400 const uint32_t *src
= src_row
;
401 uint32_t *dst
= (uint32_t *)dst_row
;
402 for(x
= 0; x
< width
; ++x
) {
403 uint32_t value
= util_le32_to_cpu(*dst
);
405 value
|= z32_unorm_to_z24_unorm(*src
++);
406 *dst
++ = util_cpu_to_le32(value
);
408 dst_row
+= dst_stride
/sizeof(*dst_row
);
409 src_row
+= src_stride
/sizeof(*src_row
);
414 util_format_z24_unorm_s8_uint_unpack_s_8uint(uint8_t *dst_row
, unsigned dst_stride
,
415 const uint8_t *src_row
, unsigned src_stride
,
416 unsigned width
, unsigned height
)
419 for(y
= 0; y
< height
; ++y
) {
420 uint8_t *dst
= dst_row
;
421 const uint32_t *src
= (const uint32_t *)src_row
;
422 for(x
= 0; x
< width
; ++x
) {
423 uint32_t value
= util_cpu_to_le32(*src
++);
424 *dst
++ = value
>> 24;
426 src_row
+= src_stride
/sizeof(*src_row
);
427 dst_row
+= dst_stride
/sizeof(*dst_row
);
432 util_format_z24_unorm_s8_uint_pack_s_8uint(uint8_t *dst_row
, unsigned dst_stride
,
433 const uint8_t *src_row
, unsigned src_stride
,
434 unsigned width
, unsigned height
)
437 for(y
= 0; y
< height
; ++y
) {
438 const uint8_t *src
= src_row
;
439 uint32_t *dst
= (uint32_t *)dst_row
;
440 for(x
= 0; x
< width
; ++x
) {
441 uint32_t value
= util_le32_to_cpu(*dst
);
443 value
|= *src
++ << 24;
444 *dst
++ = util_cpu_to_le32(value
);
446 dst_row
+= dst_stride
/sizeof(*dst_row
);
447 src_row
+= src_stride
/sizeof(*src_row
);
452 util_format_s8_uint_z24_unorm_unpack_z_float(float *dst_row
, unsigned dst_stride
,
453 const uint8_t *src_row
, unsigned src_stride
,
454 unsigned width
, unsigned height
)
457 for(y
= 0; y
< height
; ++y
) {
458 float *dst
= dst_row
;
459 const uint32_t *src
= (const uint32_t *)src_row
;
460 for(x
= 0; x
< width
; ++x
) {
461 uint32_t value
= util_cpu_to_le32(*src
++);
462 *dst
++ = z24_unorm_to_z32_float(value
>> 8);
464 src_row
+= src_stride
/sizeof(*src_row
);
465 dst_row
+= dst_stride
/sizeof(*dst_row
);
470 util_format_s8_uint_z24_unorm_pack_z_float(uint8_t *dst_row
, unsigned dst_stride
,
471 const float *src_row
, unsigned src_stride
,
472 unsigned width
, unsigned height
)
475 for(y
= 0; y
< height
; ++y
) {
476 const float *src
= src_row
;
477 uint32_t *dst
= (uint32_t *)dst_row
;
478 for(x
= 0; x
< width
; ++x
) {
479 uint32_t value
= util_le32_to_cpu(*dst
);
481 value
|= z32_float_to_z24_unorm(*src
++) << 8;
482 *dst
++ = util_cpu_to_le32(value
);
484 dst_row
+= dst_stride
/sizeof(*dst_row
);
485 src_row
+= src_stride
/sizeof(*src_row
);
490 util_format_s8_uint_z24_unorm_unpack_z_32unorm(uint32_t *dst_row
, unsigned dst_stride
,
491 const uint8_t *src_row
, unsigned src_stride
,
492 unsigned width
, unsigned height
)
495 for(y
= 0; y
< height
; ++y
) {
496 uint32_t *dst
= dst_row
;
497 const uint32_t *src
= (const uint32_t *)src_row
;
498 for(x
= 0; x
< width
; ++x
) {
499 uint32_t value
= util_cpu_to_le32(*src
++);
500 *dst
++ = z24_unorm_to_z32_unorm(value
>> 8);
502 src_row
+= src_stride
/sizeof(*src_row
);
503 dst_row
+= dst_stride
/sizeof(*dst_row
);
508 util_format_s8_uint_z24_unorm_pack_z_32unorm(uint8_t *dst_row
, unsigned dst_stride
,
509 const uint32_t *src_row
, unsigned src_stride
,
510 unsigned width
, unsigned height
)
513 for(y
= 0; y
< height
; ++y
) {
514 const uint32_t *src
= src_row
;
515 uint32_t *dst
= (uint32_t *)dst_row
;
516 for(x
= 0; x
< width
; ++x
) {
517 uint32_t value
= util_le32_to_cpu(*dst
);
519 value
|= *src
++ & 0xffffff00;
520 *dst
++ = util_cpu_to_le32(value
);
522 dst_row
+= dst_stride
/sizeof(*dst_row
);
523 src_row
+= src_stride
/sizeof(*src_row
);
528 util_format_s8_uint_z24_unorm_unpack_s_8uint(uint8_t *dst_row
, unsigned dst_stride
,
529 const uint8_t *src_row
, unsigned src_stride
,
530 unsigned width
, unsigned height
)
533 for(y
= 0; y
< height
; ++y
) {
534 uint8_t *dst
= dst_row
;
535 const uint32_t *src
= (const uint32_t *)src_row
;
536 for(x
= 0; x
< width
; ++x
) {
537 uint32_t value
= util_cpu_to_le32(*src
++);
538 *dst
++ = value
& 0xff;
540 src_row
+= src_stride
/sizeof(*src_row
);
541 dst_row
+= dst_stride
/sizeof(*dst_row
);
546 util_format_s8_uint_z24_unorm_pack_s_8uint(uint8_t *dst_row
, unsigned dst_stride
,
547 const uint8_t *src_row
, unsigned src_stride
,
548 unsigned width
, unsigned height
)
551 for(y
= 0; y
< height
; ++y
) {
552 const uint8_t *src
= src_row
;
553 uint32_t *dst
= (uint32_t *)dst_row
;
554 for(x
= 0; x
< width
; ++x
) {
555 uint32_t value
= util_le32_to_cpu(*dst
);
558 *dst
++ = util_cpu_to_le32(value
);
560 dst_row
+= dst_stride
/sizeof(*dst_row
);
561 src_row
+= src_stride
/sizeof(*src_row
);
566 util_format_z24x8_unorm_unpack_z_float(float *dst_row
, unsigned dst_stride
,
567 const uint8_t *src_row
, unsigned src_stride
,
568 unsigned width
, unsigned height
)
571 for(y
= 0; y
< height
; ++y
) {
572 float *dst
= dst_row
;
573 const uint32_t *src
= (const uint32_t *)src_row
;
574 for(x
= 0; x
< width
; ++x
) {
575 uint32_t value
= util_cpu_to_le32(*src
++);
576 *dst
++ = z24_unorm_to_z32_float(value
& 0xffffff);
578 src_row
+= src_stride
/sizeof(*src_row
);
579 dst_row
+= dst_stride
/sizeof(*dst_row
);
584 util_format_z24x8_unorm_pack_z_float(uint8_t *dst_row
, unsigned dst_stride
,
585 const float *src_row
, unsigned src_stride
,
586 unsigned width
, unsigned height
)
589 for(y
= 0; y
< height
; ++y
) {
590 const float *src
= src_row
;
591 uint32_t *dst
= (uint32_t *)dst_row
;
592 for(x
= 0; x
< width
; ++x
) {
594 value
= z32_float_to_z24_unorm(*src
++);
595 *dst
++ = util_le32_to_cpu(value
);
597 dst_row
+= dst_stride
/sizeof(*dst_row
);
598 src_row
+= src_stride
/sizeof(*src_row
);
603 util_format_z24x8_unorm_unpack_z_32unorm(uint32_t *dst_row
, unsigned dst_stride
,
604 const uint8_t *src_row
, unsigned src_stride
,
605 unsigned width
, unsigned height
)
608 for(y
= 0; y
< height
; ++y
) {
609 uint32_t *dst
= dst_row
;
610 const uint32_t *src
= (const uint32_t *)src_row
;
611 for(x
= 0; x
< width
; ++x
) {
612 uint32_t value
= util_cpu_to_le32(*src
++);
613 *dst
++ = z24_unorm_to_z32_unorm(value
& 0xffffff);
615 src_row
+= src_stride
/sizeof(*src_row
);
616 dst_row
+= dst_stride
/sizeof(*dst_row
);
621 util_format_z24x8_unorm_pack_z_32unorm(uint8_t *dst_row
, unsigned dst_stride
,
622 const uint32_t *src_row
, unsigned src_stride
,
623 unsigned width
, unsigned height
)
626 for(y
= 0; y
< height
; ++y
) {
627 const uint32_t *src
= src_row
;
628 uint32_t *dst
= (uint32_t *)dst_row
;
629 for(x
= 0; x
< width
; ++x
) {
631 value
= z32_unorm_to_z24_unorm(*src
++);
632 *dst
++ = util_cpu_to_le32(value
);
634 dst_row
+= dst_stride
/sizeof(*dst_row
);
635 src_row
+= src_stride
/sizeof(*src_row
);
640 util_format_x8z24_unorm_unpack_z_float(float *dst_row
, unsigned dst_stride
,
641 const uint8_t *src_row
, unsigned src_stride
,
642 unsigned width
, unsigned height
)
645 for(y
= 0; y
< height
; ++y
) {
646 float *dst
= dst_row
;
647 const uint32_t *src
= (uint32_t *)src_row
;
648 for(x
= 0; x
< width
; ++x
) {
649 uint32_t value
= util_cpu_to_le32(*src
++);
650 *dst
++ = z24_unorm_to_z32_float(value
>> 8);
652 src_row
+= src_stride
/sizeof(*src_row
);
653 dst_row
+= dst_stride
/sizeof(*dst_row
);
658 util_format_x8z24_unorm_pack_z_float(uint8_t *dst_row
, unsigned dst_stride
,
659 const float *src_row
, unsigned src_stride
,
660 unsigned width
, unsigned height
)
663 for(y
= 0; y
< height
; ++y
) {
664 const float *src
= src_row
;
665 uint32_t *dst
= (uint32_t *)dst_row
;
666 for(x
= 0; x
< width
; ++x
) {
668 value
= z32_float_to_z24_unorm(*src
++) << 8;
669 *dst
++ = util_cpu_to_le32(value
);
671 dst_row
+= dst_stride
/sizeof(*dst_row
);
672 src_row
+= src_stride
/sizeof(*src_row
);
677 util_format_x8z24_unorm_unpack_z_32unorm(uint32_t *dst_row
, unsigned dst_stride
,
678 const uint8_t *src_row
, unsigned src_stride
,
679 unsigned width
, unsigned height
)
682 for(y
= 0; y
< height
; ++y
) {
683 uint32_t *dst
= dst_row
;
684 const uint32_t *src
= (const uint32_t *)src_row
;
685 for(x
= 0; x
< width
; ++x
) {
686 uint32_t value
= util_cpu_to_le32(*src
++);
687 *dst
++ = z24_unorm_to_z32_unorm(value
>> 8);
689 src_row
+= src_stride
/sizeof(*src_row
);
690 dst_row
+= dst_stride
/sizeof(*dst_row
);
695 util_format_x8z24_unorm_pack_z_32unorm(uint8_t *dst_row
, unsigned dst_stride
,
696 const uint32_t *src_row
, unsigned src_stride
,
697 unsigned width
, unsigned height
)
700 for(y
= 0; y
< height
; ++y
) {
701 const uint32_t *src
= src_row
;
702 uint32_t *dst
= (uint32_t *)dst_row
;
703 for(x
= 0; x
< width
; ++x
) {
705 value
= z32_unorm_to_z24_unorm(*src
++) << 8;
706 *dst
++ = util_cpu_to_le32(value
);
708 dst_row
+= dst_stride
/sizeof(*dst_row
);
709 src_row
+= src_stride
/sizeof(*src_row
);
714 util_format_z32_float_s8x24_uint_unpack_z_float(float *dst_row
, unsigned dst_stride
,
715 const uint8_t *src_row
, unsigned src_stride
,
716 unsigned width
, unsigned height
)
719 for(y
= 0; y
< height
; ++y
) {
720 float *dst
= dst_row
;
721 const float *src
= (const float *)src_row
;
722 for(x
= 0; x
< width
; ++x
) {
727 src_row
+= src_stride
/sizeof(*src_row
);
728 dst_row
+= dst_stride
/sizeof(*dst_row
);
733 util_format_z32_float_s8x24_uint_pack_z_float(uint8_t *dst_row
, unsigned dst_stride
,
734 const float *src_row
, unsigned src_stride
,
735 unsigned width
, unsigned height
)
738 for(y
= 0; y
< height
; ++y
) {
739 const float *src
= src_row
;
740 float *dst
= (float *)dst_row
;
741 for(x
= 0; x
< width
; ++x
) {
746 dst_row
+= dst_stride
/sizeof(*dst_row
);
747 src_row
+= src_stride
/sizeof(*src_row
);
752 util_format_z32_float_s8x24_uint_unpack_z_32unorm(uint32_t *dst_row
, unsigned dst_stride
,
753 const uint8_t *src_row
, unsigned src_stride
,
754 unsigned width
, unsigned height
)
757 for(y
= 0; y
< height
; ++y
) {
758 uint32_t *dst
= dst_row
;
759 const float *src
= (const float *)src_row
;
760 for(x
= 0; x
< width
; ++x
) {
761 *dst
= z32_float_to_z32_unorm(*src
);
765 src_row
+= src_stride
/sizeof(*src_row
);
766 dst_row
+= dst_stride
/sizeof(*dst_row
);
771 util_format_z32_float_s8x24_uint_pack_z_32unorm(uint8_t *dst_row
, unsigned dst_stride
,
772 const uint32_t *src_row
, unsigned src_stride
,
773 unsigned width
, unsigned height
)
776 for(y
= 0; y
< height
; ++y
) {
777 const uint32_t *src
= src_row
;
778 float *dst
= (float *)dst_row
;
779 for(x
= 0; x
< width
; ++x
) {
780 *dst
++ = z32_unorm_to_z32_float(*src
++);
782 dst_row
+= dst_stride
/sizeof(*dst_row
);
783 src_row
+= src_stride
/sizeof(*src_row
);
788 util_format_z32_float_s8x24_uint_unpack_s_8uint(uint8_t *dst_row
, unsigned dst_stride
,
789 const uint8_t *src_row
, unsigned src_stride
,
790 unsigned width
, unsigned height
)
793 for(y
= 0; y
< height
; ++y
) {
794 uint8_t *dst
= dst_row
;
795 const uint8_t *src
= src_row
+ 4;
796 for(x
= 0; x
< width
; ++x
) {
801 src_row
+= src_stride
/sizeof(*src_row
);
802 dst_row
+= dst_stride
/sizeof(*dst_row
);
807 util_format_z32_float_s8x24_uint_pack_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 const uint8_t *src
= src_row
;
814 uint8_t *dst
= dst_row
+ 4;
815 for(x
= 0; x
< width
; ++x
) {
820 dst_row
+= dst_stride
/sizeof(*dst_row
);
821 src_row
+= src_stride
/sizeof(*src_row
);
827 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
)
829 util_format_z24_unorm_s8_uint_unpack_s_8uint(dst_row
, dst_stride
,
835 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
)
837 util_format_z24_unorm_s8_uint_pack_s_8uint(dst_row
, dst_stride
,
843 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
)
845 util_format_s8_uint_z24_unorm_unpack_s_8uint(dst_row
, dst_stride
,
851 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
)
853 util_format_s8_uint_z24_unorm_pack_s_8uint(dst_row
, dst_stride
,
859 util_format_x32_s8x24_uint_unpack_s_8uint(uint8_t *dst_row
, unsigned dst_stride
,
860 const uint8_t *src_row
, unsigned src_stride
,
861 unsigned width
, unsigned height
)
863 util_format_z32_float_s8x24_uint_unpack_s_8uint(dst_row
, dst_stride
,
870 util_format_x32_s8x24_uint_pack_s_8uint(uint8_t *dst_row
, unsigned dst_stride
,
871 const uint8_t *src_row
, unsigned src_stride
,
872 unsigned width
, unsigned height
)
874 util_format_z32_float_s8x24_uint_pack_s_8uint(dst_row
, dst_stride
,