1 /**************************************************************************
2  *
3  * Copyright 2019 Collabora, Ltd.
4  * All Rights Reserved.
5  *
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:
13  *
14  * The above copyright notice and this permission notice (including the
15  * next paragraph) shall be included in all copies or substantial portions
16  * of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21  * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25  *
26  **************************************************************************/
27 
28 #ifndef PAN_UTIL_H
29 #define PAN_UTIL_H
30 
31 #include <stdint.h>
32 #include <stdbool.h>
33 #include "util/format/u_format.h"
34 
35 #define PAN_DBG_PERF            0x0001
36 #define PAN_DBG_TRACE           0x0002
37 #define PAN_DBG_DEQP            0x0004
38 #define PAN_DBG_DIRTY           0x0008
39 #define PAN_DBG_SYNC            0x0010
40 #define PAN_DBG_PRECOMPILE      0x0020
41 #define PAN_DBG_NOFP16          0x0040
42 #define PAN_DBG_NO_CRC          0x0080
43 #define PAN_DBG_GL3             0x0100
44 #define PAN_DBG_NO_AFBC         0x0200
45 #define PAN_DBG_MSAA16          0x0400
46 #define PAN_DBG_INDIRECT        0x0800
47 #define PAN_DBG_LINEAR          0x1000
48 #define PAN_DBG_NO_CACHE        0x2000
49 #define PAN_DBG_DUMP            0x4000
50 
51 struct panfrost_device;
52 
53 unsigned
54 panfrost_translate_swizzle_4(const unsigned char swizzle[4]);
55 
56 void
57 panfrost_invert_swizzle(const unsigned char *in, unsigned char *out);
58 
59 unsigned
60 panfrost_format_to_bifrost_blend(const struct panfrost_device *dev,
61                                  enum pipe_format format,
62                                  bool dithered);
63 
64 void
65 pan_pack_color(uint32_t *packed, const union pipe_color_union *color,
66                enum pipe_format format, bool dithered);
67 
68 /* Get the last blend shader, for an erratum workaround on v5 */
69 
70 static inline uint64_t
panfrost_last_nonnull(uint64_t * ptrs,unsigned count)71 panfrost_last_nonnull(uint64_t *ptrs, unsigned count)
72 {
73         for (signed i = ((signed) count - 1); i >= 0; --i) {
74                 if (ptrs[i])
75                         return ptrs[i];
76         }
77 
78         return 0;
79 }
80 
81 #endif /* PAN_UTIL_H */
82