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);
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_uscaled_unpack_s_8uscaled(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_uscaled_pack_s_8uscaled(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 = *src++;
151 #ifdef PIPE_ARCH_BIG_ENDIAN
152 value = util_bswap16(value);
154 *dst++ = z16_unorm_to_z32_float(value);
156 src_row += src_stride/sizeof(*src_row);
157 dst_row += dst_stride/sizeof(*dst_row);
162 util_format_z16_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride,
163 const float *src_row, unsigned src_stride,
164 unsigned width, unsigned height)
167 for(y = 0; y < height; ++y) {
168 const float *src = src_row;
169 uint16_t *dst = (uint16_t *)dst_row;
170 for(x = 0; x < width; ++x) {
172 value = z32_float_to_z16_unorm(*src++);
173 #ifdef PIPE_ARCH_BIG_ENDIAN
174 value = util_bswap16(value);
178 dst_row += dst_stride/sizeof(*dst_row);
179 src_row += src_stride/sizeof(*src_row);
184 util_format_z16_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride,
185 const uint8_t *src_row, unsigned src_stride,
186 unsigned width, unsigned height)
189 for(y = 0; y < height; ++y) {
190 uint32_t *dst = dst_row;
191 const uint16_t *src = (const uint16_t *)src_row;
192 for(x = 0; x < width; ++x) {
193 uint16_t value = *src++;
194 #ifdef PIPE_ARCH_BIG_ENDIAN
195 value = util_bswap16(value);
197 *dst++ = z16_unorm_to_z32_unorm(value);
199 src_row += src_stride/sizeof(*src_row);
200 dst_row += dst_stride/sizeof(*dst_row);
205 util_format_z16_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride,
206 const uint32_t *src_row, unsigned src_stride,
207 unsigned width, unsigned height)
210 for(y = 0; y < height; ++y) {
211 const uint32_t *src = src_row;
212 uint16_t *dst = (uint16_t *)dst_row;
213 for(x = 0; x < width; ++x) {
215 value = z32_unorm_to_z16_unorm(*src++);
216 #ifdef PIPE_ARCH_BIG_ENDIAN
217 value = util_bswap16(value);
221 dst_row += dst_stride/sizeof(*dst_row);
222 src_row += src_stride/sizeof(*src_row);
227 util_format_z32_unorm_unpack_z_float(float *dst_row, unsigned dst_stride,
228 const uint8_t *src_row, unsigned src_stride,
229 unsigned width, unsigned height)
232 for(y = 0; y < height; ++y) {
233 float *dst = dst_row;
234 const uint32_t *src = (const uint32_t *)src_row;
235 for(x = 0; x < width; ++x) {
236 uint32_t value = *src++;
237 #ifdef PIPE_ARCH_BIG_ENDIAN
238 value = util_bswap32(value);
240 *dst++ = z32_unorm_to_z32_float(value);
242 src_row += src_stride/sizeof(*src_row);
243 dst_row += dst_stride/sizeof(*dst_row);
248 util_format_z32_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride,
249 const float *src_row, unsigned src_stride,
250 unsigned width, unsigned height)
253 for(y = 0; y < height; ++y) {
254 const float *src = src_row;
255 uint32_t *dst = (uint32_t *)dst_row;
256 for(x = 0; x < width; ++x) {
258 value = z32_float_to_z32_unorm(*src++);
259 #ifdef PIPE_ARCH_BIG_ENDIAN
260 value = util_bswap32(value);
264 dst_row += dst_stride/sizeof(*dst_row);
265 src_row += src_stride/sizeof(*src_row);
270 util_format_z32_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride,
271 const uint8_t *src_row, unsigned src_stride,
272 unsigned width, unsigned height)
275 for(y = 0; y < height; ++y) {
276 memcpy(dst_row, src_row, width * 4);
277 src_row += src_stride/sizeof(*src_row);
278 dst_row += dst_stride/sizeof(*dst_row);
283 util_format_z32_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride,
284 const uint32_t *src_row, unsigned src_stride,
285 unsigned width, unsigned height)
288 for(y = 0; y < height; ++y) {
289 memcpy(dst_row, src_row, width * 4);
290 src_row += src_stride/sizeof(*src_row);
291 dst_row += dst_stride/sizeof(*dst_row);
296 util_format_z32_float_unpack_z_float(float *dst_row, unsigned dst_stride,
297 const uint8_t *src_row, unsigned src_stride,
298 unsigned width, unsigned height)
301 for(y = 0; y < height; ++y) {
302 memcpy(dst_row, src_row, width * 4);
303 src_row += src_stride/sizeof(*src_row);
304 dst_row += dst_stride/sizeof(*dst_row);
309 util_format_z32_float_pack_z_float(uint8_t *dst_row, unsigned dst_stride,
310 const float *src_row, unsigned src_stride,
311 unsigned width, unsigned height)
314 for(y = 0; y < height; ++y) {
315 memcpy(dst_row, src_row, width * 4);
316 src_row += src_stride/sizeof(*src_row);
317 dst_row += dst_stride/sizeof(*dst_row);
322 util_format_z32_float_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride,
323 const uint8_t *src_row, unsigned src_stride,
324 unsigned width, unsigned height)
327 for(y = 0; y < height; ++y) {
328 uint32_t *dst = dst_row;
329 const float *src = (const float *)src_row;
330 for(x = 0; x < width; ++x) {
331 *dst++ = z32_float_to_z32_unorm(*src++);
333 src_row += src_stride/sizeof(*src_row);
334 dst_row += dst_stride/sizeof(*dst_row);
339 util_format_z32_float_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride,
340 const uint32_t *src_row, unsigned src_stride,
341 unsigned width, unsigned height)
344 for(y = 0; y < height; ++y) {
345 const uint32_t *src = src_row;
346 float *dst = (float *)dst_row;
347 for(x = 0; x < width; ++x) {
348 *dst++ = z32_unorm_to_z32_float(*src++);
350 dst_row += dst_stride/sizeof(*dst_row);
351 src_row += src_stride/sizeof(*src_row);
356 util_format_z24_unorm_s8_uscaled_unpack_z_float(float *dst_row, unsigned dst_stride,
357 const uint8_t *src_row, unsigned src_stride,
358 unsigned width, unsigned height)
361 for(y = 0; y < height; ++y) {
362 float *dst = dst_row;
363 const uint32_t *src = (const uint32_t *)src_row;
364 for(x = 0; x < width; ++x) {
365 uint32_t value = *src++;
366 #ifdef PIPE_ARCH_BIG_ENDIAN
367 value = util_bswap32(value);
369 *dst++ = z24_unorm_to_z32_float(value & 0xffffff);
371 src_row += src_stride/sizeof(*src_row);
372 dst_row += dst_stride/sizeof(*dst_row);
377 util_format_z24_unorm_s8_uscaled_pack_z_float(uint8_t *dst_row, unsigned dst_stride,
378 const float *src_row, unsigned src_stride,
379 unsigned width, unsigned height)
382 for(y = 0; y < height; ++y) {
383 const float *src = src_row;
384 uint32_t *dst = (uint32_t *)dst_row;
385 for(x = 0; x < width; ++x) {
386 uint32_t value = *dst;
387 #ifdef PIPE_ARCH_BIG_ENDIAN
388 value = util_bswap32(value);
391 value |= z32_float_to_z24_unorm(*src++);
392 #ifdef PIPE_ARCH_BIG_ENDIAN
393 value = util_bswap32(value);
397 dst_row += dst_stride/sizeof(*dst_row);
398 src_row += src_stride/sizeof(*src_row);
403 util_format_z24_unorm_s8_uscaled_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride,
404 const uint8_t *src_row, unsigned src_stride,
405 unsigned width, unsigned height)
408 for(y = 0; y < height; ++y) {
409 uint32_t *dst = dst_row;
410 const uint32_t *src = (const uint32_t *)src_row;
411 for(x = 0; x < width; ++x) {
412 uint32_t value = *src++;
413 #ifdef PIPE_ARCH_BIG_ENDIAN
414 value = util_bswap32(value);
416 *dst++ = z24_unorm_to_z32_unorm(value & 0xffffff);
418 src_row += src_stride/sizeof(*src_row);
419 dst_row += dst_stride/sizeof(*dst_row);
424 util_format_z24_unorm_s8_uscaled_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride,
425 const uint32_t *src_row, unsigned src_stride,
426 unsigned width, unsigned height)
429 for(y = 0; y < height; ++y) {
430 const uint32_t *src = src_row;
431 uint32_t *dst = (uint32_t *)dst_row;
432 for(x = 0; x < width; ++x) {
433 uint32_t value= *dst;
434 #ifdef PIPE_ARCH_BIG_ENDIAN
435 value = util_bswap32(value);
438 value |= z32_unorm_to_z24_unorm(*src++);
439 #ifdef PIPE_ARCH_BIG_ENDIAN
440 value = util_bswap32(value);
444 dst_row += dst_stride/sizeof(*dst_row);
445 src_row += src_stride/sizeof(*src_row);
450 util_format_z24_unorm_s8_uscaled_unpack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride,
451 const uint8_t *src_row, unsigned src_stride,
452 unsigned width, unsigned height)
455 for(y = 0; y < height; ++y) {
456 uint8_t *dst = dst_row;
457 const uint32_t *src = (const uint32_t *)src_row;
458 for(x = 0; x < width; ++x) {
459 uint32_t value = *src++;
460 #ifdef PIPE_ARCH_BIG_ENDIAN
461 value = util_bswap32(value);
463 *dst++ = value >> 24;
465 src_row += src_stride/sizeof(*src_row);
466 dst_row += dst_stride/sizeof(*dst_row);
471 util_format_z24_unorm_s8_uscaled_pack_s_8uscaled(uint8_t *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 const uint8_t *src = src_row;
478 uint32_t *dst = (uint32_t *)dst_row;
479 for(x = 0; x < width; ++x) {
480 uint32_t value = *dst;
481 #ifdef PIPE_ARCH_BIG_ENDIAN
482 value = util_bswap32(value);
485 value |= *src++ << 24;
486 #ifdef PIPE_ARCH_BIG_ENDIAN
487 value = util_bswap32(value);
491 dst_row += dst_stride/sizeof(*dst_row);
492 src_row += src_stride/sizeof(*src_row);
497 util_format_s8_uscaled_z24_unorm_unpack_z_float(float *dst_row, unsigned dst_stride,
498 const uint8_t *src_row, unsigned src_stride,
499 unsigned width, unsigned height)
502 for(y = 0; y < height; ++y) {
503 float *dst = dst_row;
504 const uint32_t *src = (const uint32_t *)src_row;
505 for(x = 0; x < width; ++x) {
506 uint32_t value = *src++;
507 #ifdef PIPE_ARCH_BIG_ENDIAN
508 value = util_bswap32(value);
510 *dst++ = z24_unorm_to_z32_float(value >> 8);
512 src_row += src_stride/sizeof(*src_row);
513 dst_row += dst_stride/sizeof(*dst_row);
518 util_format_s8_uscaled_z24_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride,
519 const float *src_row, unsigned src_stride,
520 unsigned width, unsigned height)
523 for(y = 0; y < height; ++y) {
524 const float *src = src_row;
525 uint32_t *dst = (uint32_t *)dst_row;
526 for(x = 0; x < width; ++x) {
527 uint32_t value = *dst;
528 #ifdef PIPE_ARCH_BIG_ENDIAN
529 value = util_bswap32(value);
532 value |= z32_float_to_z24_unorm(*src++) << 8;
533 #ifdef PIPE_ARCH_BIG_ENDIAN
534 value = util_bswap32(value);
538 dst_row += dst_stride/sizeof(*dst_row);
539 src_row += src_stride/sizeof(*src_row);
544 util_format_s8_uscaled_z24_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride,
545 const uint8_t *src_row, unsigned src_stride,
546 unsigned width, unsigned height)
549 for(y = 0; y < height; ++y) {
550 uint32_t *dst = dst_row;
551 const uint32_t *src = (const uint32_t *)src_row;
552 for(x = 0; x < width; ++x) {
553 uint32_t value = *src++;
554 #ifdef PIPE_ARCH_BIG_ENDIAN
555 value = util_bswap32(value);
557 *dst++ = z24_unorm_to_z32_unorm(value >> 8);
559 src_row += src_stride/sizeof(*src_row);
560 dst_row += dst_stride/sizeof(*dst_row);
565 util_format_s8_uscaled_z24_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride,
566 const uint32_t *src_row, unsigned src_stride,
567 unsigned width, unsigned height)
570 for(y = 0; y < height; ++y) {
571 const uint32_t *src = src_row;
572 uint32_t *dst = (uint32_t *)dst_row;
573 for(x = 0; x < width; ++x) {
574 uint32_t value = *dst;
575 #ifdef PIPE_ARCH_BIG_ENDIAN
576 value = util_bswap32(value);
579 value |= *src++ & 0xffffff00;
580 #ifdef PIPE_ARCH_BIG_ENDIAN
581 value = util_bswap32(value);
585 dst_row += dst_stride/sizeof(*dst_row);
586 src_row += src_stride/sizeof(*src_row);
591 util_format_s8_uscaled_z24_unorm_unpack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride,
592 const uint8_t *src_row, unsigned src_stride,
593 unsigned width, unsigned height)
596 for(y = 0; y < height; ++y) {
597 uint8_t *dst = dst_row;
598 const uint32_t *src = (const uint32_t *)src_row;
599 for(x = 0; x < width; ++x) {
600 uint32_t value = *src++;
601 #ifdef PIPE_ARCH_BIG_ENDIAN
602 value = util_bswap32(value);
604 *dst++ = value & 0xff;
606 src_row += src_stride/sizeof(*src_row);
607 dst_row += dst_stride/sizeof(*dst_row);
612 util_format_s8_uscaled_z24_unorm_pack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride,
613 const uint8_t *src_row, unsigned src_stride,
614 unsigned width, unsigned height)
617 for(y = 0; y < height; ++y) {
618 const uint8_t *src = src_row;
619 uint32_t *dst = (uint32_t *)dst_row;
620 for(x = 0; x < width; ++x) {
621 uint32_t value = *dst;
622 #ifdef PIPE_ARCH_BIG_ENDIAN
623 value = util_bswap32(value);
627 #ifdef PIPE_ARCH_BIG_ENDIAN
628 value = util_bswap32(value);
632 dst_row += dst_stride/sizeof(*dst_row);
633 src_row += src_stride/sizeof(*src_row);
638 util_format_z24x8_unorm_unpack_z_float(float *dst_row, unsigned dst_stride,
639 const uint8_t *src_row, unsigned src_stride,
640 unsigned width, unsigned height)
643 for(y = 0; y < height; ++y) {
644 float *dst = dst_row;
645 const uint32_t *src = (const uint32_t *)src_row;
646 for(x = 0; x < width; ++x) {
647 uint32_t value = *src++;
648 #ifdef PIPE_ARCH_BIG_ENDIAN
649 value = util_bswap32(value);
651 *dst++ = z24_unorm_to_z32_float(value & 0xffffff);
653 src_row += src_stride/sizeof(*src_row);
654 dst_row += dst_stride/sizeof(*dst_row);
659 util_format_z24x8_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride,
660 const float *src_row, unsigned src_stride,
661 unsigned width, unsigned height)
664 for(y = 0; y < height; ++y) {
665 const float *src = src_row;
666 uint32_t *dst = (uint32_t *)dst_row;
667 for(x = 0; x < width; ++x) {
669 value = z32_float_to_z24_unorm(*src++);
670 #ifdef PIPE_ARCH_BIG_ENDIAN
671 value = util_bswap32(value);
675 dst_row += dst_stride/sizeof(*dst_row);
676 src_row += src_stride/sizeof(*src_row);
681 util_format_z24x8_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride,
682 const uint8_t *src_row, unsigned src_stride,
683 unsigned width, unsigned height)
686 for(y = 0; y < height; ++y) {
687 uint32_t *dst = dst_row;
688 const uint32_t *src = (const uint32_t *)src_row;
689 for(x = 0; x < width; ++x) {
690 uint32_t value = *src++;
691 #ifdef PIPE_ARCH_BIG_ENDIAN
692 value = util_bswap32(value);
694 *dst++ = z24_unorm_to_z32_unorm(value & 0xffffff);
696 src_row += src_stride/sizeof(*src_row);
697 dst_row += dst_stride/sizeof(*dst_row);
702 util_format_z24x8_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride,
703 const uint32_t *src_row, unsigned src_stride,
704 unsigned width, unsigned height)
707 for(y = 0; y < height; ++y) {
708 const uint32_t *src = src_row;
709 uint32_t *dst = (uint32_t *)dst_row;
710 for(x = 0; x < width; ++x) {
712 value = z32_unorm_to_z24_unorm(*src++);
713 #ifdef PIPE_ARCH_BIG_ENDIAN
714 value = util_bswap32(value);
718 dst_row += dst_stride/sizeof(*dst_row);
719 src_row += src_stride/sizeof(*src_row);
724 util_format_x8z24_unorm_unpack_z_float(float *dst_row, unsigned dst_stride,
725 const uint8_t *src_row, unsigned src_stride,
726 unsigned width, unsigned height)
729 for(y = 0; y < height; ++y) {
730 float *dst = dst_row;
731 const uint32_t *src = (uint32_t *)src_row;
732 for(x = 0; x < width; ++x) {
733 uint32_t value = *src++;
734 #ifdef PIPE_ARCH_BIG_ENDIAN
735 value = util_bswap32(value);
737 *dst++ = z24_unorm_to_z32_float(value >> 8);
739 src_row += src_stride/sizeof(*src_row);
740 dst_row += dst_stride/sizeof(*dst_row);
745 util_format_x8z24_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride,
746 const float *src_row, unsigned src_stride,
747 unsigned width, unsigned height)
750 for(y = 0; y < height; ++y) {
751 const float *src = src_row;
752 uint32_t *dst = (uint32_t *)dst_row;
753 for(x = 0; x < width; ++x) {
755 value = z32_float_to_z24_unorm(*src++) << 8;
756 #ifdef PIPE_ARCH_BIG_ENDIAN
757 value = util_bswap32(value);
761 dst_row += dst_stride/sizeof(*dst_row);
762 src_row += src_stride/sizeof(*src_row);
767 util_format_x8z24_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride,
768 const uint8_t *src_row, unsigned src_stride,
769 unsigned width, unsigned height)
772 for(y = 0; y < height; ++y) {
773 uint32_t *dst = dst_row;
774 const uint32_t *src = (const uint32_t *)src_row;
775 for(x = 0; x < width; ++x) {
776 uint32_t value = *src++;
777 #ifdef PIPE_ARCH_BIG_ENDIAN
778 value = util_bswap32(value);
780 *dst++ = z24_unorm_to_z32_unorm(value >> 8);
782 src_row += src_stride/sizeof(*src_row);
783 dst_row += dst_stride/sizeof(*dst_row);
788 util_format_x8z24_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride,
789 const uint32_t *src_row, unsigned src_stride,
790 unsigned width, unsigned height)
793 for(y = 0; y < height; ++y) {
794 const uint32_t *src = src_row;
795 uint32_t *dst = (uint32_t *)dst_row;
796 for(x = 0; x < width; ++x) {
798 value = z32_unorm_to_z24_unorm(*src++) << 8;
799 #ifdef PIPE_ARCH_BIG_ENDIAN
800 value = util_bswap32(value);
804 dst_row += dst_stride/sizeof(*dst_row);
805 src_row += src_stride/sizeof(*src_row);
810 util_format_z32_float_s8x24_uscaled_unpack_z_float(float *dst_row, unsigned dst_stride,
811 const uint8_t *src_row, unsigned src_stride,
812 unsigned width, unsigned height)
815 for(y = 0; y < height; ++y) {
816 float *dst = dst_row;
817 const float *src = (const float *)src_row;
818 for(x = 0; x < width; ++x) {
823 src_row += src_stride/sizeof(*src_row);
824 dst_row += dst_stride/sizeof(*dst_row);
829 util_format_z32_float_s8x24_uscaled_pack_z_float(uint8_t *dst_row, unsigned dst_stride,
830 const float *src_row, unsigned src_stride,
831 unsigned width, unsigned height)
834 for(y = 0; y < height; ++y) {
835 const float *src = src_row;
836 float *dst = (float *)dst_row;
837 for(x = 0; x < width; ++x) {
842 dst_row += dst_stride/sizeof(*dst_row);
843 src_row += src_stride/sizeof(*src_row);
848 util_format_z32_float_s8x24_uscaled_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride,
849 const uint8_t *src_row, unsigned src_stride,
850 unsigned width, unsigned height)
853 for(y = 0; y < height; ++y) {
854 uint32_t *dst = dst_row;
855 const float *src = (const float *)src_row;
856 for(x = 0; x < width; ++x) {
857 *dst = z32_float_to_z32_unorm(*src);
861 src_row += src_stride/sizeof(*src_row);
862 dst_row += dst_stride/sizeof(*dst_row);
867 util_format_z32_float_s8x24_uscaled_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride,
868 const uint32_t *src_row, unsigned src_stride,
869 unsigned width, unsigned height)
872 for(y = 0; y < height; ++y) {
873 const uint32_t *src = src_row;
874 float *dst = (float *)dst_row;
875 for(x = 0; x < width; ++x) {
876 *dst++ = z32_unorm_to_z32_float(*src++);
878 dst_row += dst_stride/sizeof(*dst_row);
879 src_row += src_stride/sizeof(*src_row);
884 util_format_z32_float_s8x24_uscaled_unpack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride,
885 const uint8_t *src_row, unsigned src_stride,
886 unsigned width, unsigned height)
889 for(y = 0; y < height; ++y) {
890 uint8_t *dst = dst_row;
891 const uint8_t *src = src_row + 4;
892 for(x = 0; x < width; ++x) {
897 src_row += src_stride/sizeof(*src_row);
898 dst_row += dst_stride/sizeof(*dst_row);
903 util_format_z32_float_s8x24_uscaled_pack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride,
904 const uint8_t *src_row, unsigned src_stride,
905 unsigned width, unsigned height)
908 for(y = 0; y < height; ++y) {
909 const uint8_t *src = src_row;
910 uint8_t *dst = dst_row + 4;
911 for(x = 0; x < width; ++x) {
916 dst_row += dst_stride/sizeof(*dst_row);
917 src_row += src_stride/sizeof(*src_row);
923 util_format_x24s8_uscaled_unpack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
925 util_format_z24_unorm_s8_uscaled_unpack_s_8uscaled(dst_row, dst_stride,
931 util_format_x24s8_uscaled_pack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
933 util_format_z24_unorm_s8_uscaled_pack_s_8uscaled(dst_row, dst_stride,
939 util_format_s8x24_uscaled_unpack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
941 util_format_s8_uscaled_z24_unorm_unpack_s_8uscaled(dst_row, dst_stride,
947 util_format_s8x24_uscaled_pack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
949 util_format_s8_uscaled_z24_unorm_pack_s_8uscaled(dst_row, dst_stride,
955 util_format_x32_s8x24_uscaled_unpack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride,
956 const uint8_t *src_row, unsigned src_stride,
957 unsigned width, unsigned height)
959 util_format_z32_float_s8x24_uscaled_unpack_s_8uscaled(dst_row, dst_stride,
966 util_format_x32_s8x24_uscaled_pack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride,
967 const uint8_t *src_row, unsigned src_stride,
968 unsigned width, unsigned height)
970 util_format_z32_float_s8x24_uscaled_pack_s_8uscaled(dst_row, dst_stride,