Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/panfrost/lib/pan_format.h
4560 views
1
/*
2
* Copyright (C) 2008 VMware, Inc.
3
* Copyright (C) 2014 Broadcom
4
* Copyright (C) 2018-2019 Alyssa Rosenzweig
5
* Copyright (C) 2019-2020 Collabora, Ltd.
6
*
7
* Permission is hereby granted, free of charge, to any person obtaining a
8
* copy of this software and associated documentation files (the "Software"),
9
* to deal in the Software without restriction, including without limitation
10
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
11
* and/or sell copies of the Software, and to permit persons to whom the
12
* Software is furnished to do so, subject to the following conditions:
13
*
14
* The above copyright notice and this permission notice (including the next
15
* paragraph) shall be included in all copies or substantial portions of the
16
* Software.
17
*
18
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
* SOFTWARE.
25
*
26
*/
27
28
#ifndef __PAN_FORMAT_H
29
#define __PAN_FORMAT_H
30
31
#include "util/format/u_format.h"
32
33
/* Formats */
34
35
typedef uint32_t mali_pixel_format;
36
37
struct panfrost_format {
38
mali_pixel_format hw;
39
unsigned bind;
40
};
41
42
struct pan_blendable_format {
43
/* enum mali_color_buffer_internal_format */ uint16_t internal;
44
/* enum mali_mfbd_color_format */ uint16_t writeback;
45
mali_pixel_format bifrost;
46
};
47
48
extern const struct pan_blendable_format panfrost_blendable_formats_v6[PIPE_FORMAT_COUNT];
49
extern const struct pan_blendable_format panfrost_blendable_formats_v7[PIPE_FORMAT_COUNT];
50
extern const struct panfrost_format panfrost_pipe_format_v6[PIPE_FORMAT_COUNT];
51
extern const struct panfrost_format panfrost_pipe_format_v7[PIPE_FORMAT_COUNT];
52
53
/* Helpers to construct swizzles */
54
#ifndef PAN_PACK_H
55
/* Avoid the GenXML dependence */
56
57
enum mali_channel {
58
MALI_CHANNEL_R = 0,
59
MALI_CHANNEL_G = 1,
60
MALI_CHANNEL_B = 2,
61
MALI_CHANNEL_A = 3,
62
MALI_CHANNEL_0 = 4,
63
MALI_CHANNEL_1 = 5,
64
};
65
#endif
66
67
#define PAN_V6_SWIZZLE(R, G, B, A) ( \
68
((MALI_CHANNEL_ ## R) << 0) | \
69
((MALI_CHANNEL_ ## G) << 3) | \
70
((MALI_CHANNEL_ ## B) << 6) | \
71
((MALI_CHANNEL_ ## A) << 9))
72
73
static inline unsigned
74
panfrost_get_default_swizzle(unsigned components)
75
{
76
switch (components) {
77
case 1:
78
return PAN_V6_SWIZZLE(R, 0, 0, 1);
79
case 2:
80
return PAN_V6_SWIZZLE(R, G, 0, 1);
81
case 3:
82
return PAN_V6_SWIZZLE(R, G, B, 1);
83
case 4:
84
return PAN_V6_SWIZZLE(R, G, B, A);
85
default:
86
unreachable("Invalid number of components");
87
}
88
}
89
90
#endif
91
92