1af69d88dSmrg/*
2af69d88dSmrg * Mesa 3-D graphics library
3af69d88dSmrg *
4af69d88dSmrg * Copyright (c) 2011 VMware, Inc.
5af69d88dSmrg *
6af69d88dSmrg * Permission is hereby granted, free of charge, to any person obtaining a
7af69d88dSmrg * copy of this software and associated documentation files (the "Software"),
8af69d88dSmrg * to deal in the Software without restriction, including without limitation
9af69d88dSmrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10af69d88dSmrg * and/or sell copies of the Software, and to permit persons to whom the
11af69d88dSmrg * Software is furnished to do so, subject to the following conditions:
12af69d88dSmrg *
13af69d88dSmrg * The above copyright notice and this permission notice shall be included
14af69d88dSmrg * in all copies or substantial portions of the Software.
15af69d88dSmrg *
16af69d88dSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17af69d88dSmrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18af69d88dSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19af69d88dSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20af69d88dSmrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21af69d88dSmrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22af69d88dSmrg * OTHER DEALINGS IN THE SOFTWARE.
23af69d88dSmrg */
24af69d88dSmrg
25af69d88dSmrg
26af69d88dSmrg#ifndef FORMAT_PACK_H
27af69d88dSmrg#define FORMAT_PACK_H
28af69d88dSmrg
29af69d88dSmrg
307ec681f3Smrg#include "util/format/u_format.h"
31af69d88dSmrg#include "formats.h"
32af69d88dSmrg
337ec681f3Smrg#ifdef __cplusplus
347ec681f3Smrgextern "C" {
357ec681f3Smrg#endif
36af69d88dSmrg
377ec681f3Smrgstatic inline void
387ec681f3Smrg_mesa_pack_float_rgba_row(mesa_format format, uint32_t n,
397ec681f3Smrg                          const float src[][4], void *dst)
407ec681f3Smrg{
417ec681f3Smrg   util_format_pack_rgba(format, dst, src, n);
427ec681f3Smrg}
437ec681f3Smrg
447ec681f3Smrgstatic inline void
457ec681f3Smrg_mesa_pack_ubyte_rgba_row(mesa_format format, uint32_t n,
467ec681f3Smrg                          const uint8_t *src, void *dst)
477ec681f3Smrg{
487ec681f3Smrg   const struct util_format_pack_description *pack = util_format_pack_description(format);
497ec681f3Smrg   pack->pack_rgba_8unorm((uint8_t *)dst, 0, src, 0, n, 1);
507ec681f3Smrg}
517ec681f3Smrg
527ec681f3Smrgstatic inline void
537ec681f3Smrg_mesa_pack_uint_rgba_row(mesa_format format, uint32_t n,
547ec681f3Smrg                         const uint32_t src[][4], void *dst)
557ec681f3Smrg{
567ec681f3Smrg   util_format_pack_rgba(format, dst, src, n);
577ec681f3Smrg}
587ec681f3Smrg
597ec681f3Smrgstatic inline void
607ec681f3Smrg_mesa_pack_float_z_row(mesa_format format, uint32_t n,
617ec681f3Smrg                       const float *src, void *dst)
627ec681f3Smrg{
637ec681f3Smrg   util_format_pack_z_float(format, dst, src, n);
647ec681f3Smrg}
657ec681f3Smrg
667ec681f3Smrgstatic inline void
677ec681f3Smrg_mesa_pack_uint_z_row(mesa_format format, uint32_t n,
687ec681f3Smrg                      const uint32_t *src, void *dst)
697ec681f3Smrg{
707ec681f3Smrg   util_format_pack_z_32unorm(format, dst, src, n);
717ec681f3Smrg}
727ec681f3Smrg
737ec681f3Smrgstatic inline void
747ec681f3Smrg_mesa_pack_ubyte_stencil_row(mesa_format format, uint32_t n,
757ec681f3Smrg                             const uint8_t *src, void *dst)
767ec681f3Smrg{
777ec681f3Smrg   util_format_pack_s_8uint(format, dst, src, n);
787ec681f3Smrg}
797ec681f3Smrg
807ec681f3Smrg#ifdef __cplusplus
817ec681f3Smrg}
827ec681f3Smrg#endif
83af69d88dSmrg
84af69d88dSmrg#endif
85