1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
|
/*
* Copyright © 2022 Imagination Technologies Ltd.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef PVR_CSB_ENUM_HELPERS_H
#define PVR_CSB_ENUM_HELPERS_H
#include <stdint.h>
#include <vulkan/vulkan_core.h>
#include "pvr_csb.h"
#include "rogue/rogue.h"
#include "util/macros.h"
static const char *
pvr_cmd_stream_type_to_str(const enum pvr_cmd_stream_type stream_type)
{
switch (stream_type) {
case PVR_CMD_STREAM_TYPE_INVALID:
return "INVALID";
case PVR_CMD_STREAM_TYPE_GRAPHICS:
return "GRAPHICS";
case PVR_CMD_STREAM_TYPE_COMPUTE:
return "COMPUTE";
default:
return NULL;
}
}
/******************************************************************************
CR
******************************************************************************/
/* TODO: Use VkSampleCountFlagBits as param type? */
/* clang-format off */
static inline enum PVRX(CR_ISP_AA_MODE_TYPE)
pvr_cr_isp_aa_mode_type(uint32_t samples)
/* clang-format on */
{
switch (samples) {
case 1:
return PVRX(CR_ISP_AA_MODE_TYPE_AA_NONE);
case 2:
return PVRX(CR_ISP_AA_MODE_TYPE_AA_2X);
case 4:
return PVRX(CR_ISP_AA_MODE_TYPE_AA_4X);
case 8:
return PVRX(CR_ISP_AA_MODE_TYPE_AA_8X);
default:
unreachable("Unsupported number of samples");
}
}
/******************************************************************************
PDS
******************************************************************************/
/* clang-format off */
static inline enum PVRX(PDSINST_DOUTU_SAMPLE_RATE)
pvr_pdsinst_doutu_sample_rate_from_rogue(enum rogue_msaa_mode msaa_mode)
/* clang-format on */
{
switch (msaa_mode) {
case ROGUE_MSAA_MODE_PIXEL:
return PVRX(PDSINST_DOUTU_SAMPLE_RATE_INSTANCE);
case ROGUE_MSAA_MODE_SELECTIVE:
return PVRX(PDSINST_DOUTU_SAMPLE_RATE_SELECTIVE);
case ROGUE_MSAA_MODE_FULL:
return PVRX(PDSINST_DOUTU_SAMPLE_RATE_FULL);
default:
unreachable("Undefined MSAA mode.");
}
}
/******************************************************************************
PBESTATE
******************************************************************************/
enum pvr_pbe_source_start_pos {
PVR_PBE_STARTPOS_BIT0,
PVR_PBE_STARTPOS_BIT32,
PVR_PBE_STARTPOS_BIT64,
PVR_PBE_STARTPOS_BIT96,
/* The below values are available if has_eight_output_registers feature is
* enabled.
*/
PVR_PBE_STARTPOS_BIT128,
PVR_PBE_STARTPOS_BIT160,
PVR_PBE_STARTPOS_BIT192,
PVR_PBE_STARTPOS_BIT224,
};
static inline enum ROGUE_PBESTATE_SOURCE_POS
pvr_pbestate_source_pos(enum pvr_pbe_source_start_pos pos)
{
switch (pos) {
case PVR_PBE_STARTPOS_BIT0:
case PVR_PBE_STARTPOS_BIT128:
return ROGUE_PBESTATE_SOURCE_POS_START_BIT0;
case PVR_PBE_STARTPOS_BIT32:
case PVR_PBE_STARTPOS_BIT160:
return ROGUE_PBESTATE_SOURCE_POS_START_BIT32;
case PVR_PBE_STARTPOS_BIT64:
case PVR_PBE_STARTPOS_BIT192:
return ROGUE_PBESTATE_SOURCE_POS_START_BIT64;
case PVR_PBE_STARTPOS_BIT96:
case PVR_PBE_STARTPOS_BIT224:
return ROGUE_PBESTATE_SOURCE_POS_START_BIT96;
default:
unreachable("Undefined PBE source pos.");
}
}
/******************************************************************************
TA
******************************************************************************/
static inline enum PVRX(TA_CMPMODE) pvr_ta_cmpmode(VkCompareOp op)
{
/* enum values are identical, so we can just cast the input directly. */
return (enum PVRX(TA_CMPMODE))op;
}
static inline enum PVRX(TA_ISPB_STENCILOP) pvr_ta_stencilop(VkStencilOp op)
{
/* enum values are identical, so we can just cast the input directly. */
return (enum PVRX(TA_ISPB_STENCILOP))op;
}
/* clang-format off */
static inline enum PVRX(TA_OBJTYPE)
pvr_ta_objtype(VkPrimitiveTopology topology)
/* clang-format on */
{
switch (topology) {
case VK_PRIMITIVE_TOPOLOGY_POINT_LIST:
return PVRX(TA_OBJTYPE_SPRITE_01UV);
case VK_PRIMITIVE_TOPOLOGY_LINE_LIST:
case VK_PRIMITIVE_TOPOLOGY_LINE_STRIP:
case VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY:
case VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY:
return PVRX(TA_OBJTYPE_LINE);
case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST:
case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP:
case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN:
case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY:
case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY:
return PVRX(TA_OBJTYPE_TRIANGLE);
default:
unreachable("Invalid topology.");
return 0;
}
}
/******************************************************************************
TEXSTATE
******************************************************************************/
static inline enum PVRX(TEXSTATE_CMP_MODE) pvr_texstate_cmpmode(VkCompareOp op)
{
/* enum values are identical, so we can just cast the input directly. */
return (enum PVRX(TEXSTATE_CMP_MODE))op;
}
/******************************************************************************
VDMCTRL
******************************************************************************/
/* clang-format off */
static inline uint32_t
pvr_vdmctrl_index_size_nr_bytes(enum PVRX(VDMCTRL_INDEX_SIZE) index_size)
/* clang-format on */
{
switch (index_size) {
case PVRX(VDMCTRL_INDEX_SIZE_B8):
return 1;
case PVRX(VDMCTRL_INDEX_SIZE_B16):
return 2;
case PVRX(VDMCTRL_INDEX_SIZE_B32):
return 4;
default:
return 0;
}
}
#endif /* PVR_CSB_ENUM_HELPERS_H */
|