Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/intel/isl/isl_drm.c
4547 views
1
/*
2
* Copyright 2017 Intel Corporation
3
*
4
* Permission is hereby granted, free of charge, to any person obtaining a
5
* copy of this software and associated documentation files (the "Software"),
6
* to deal in the Software without restriction, including without limitation
7
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8
* and/or sell copies of the Software, and to permit persons to whom the
9
* Software is furnished to do so, subject to the following conditions:
10
*
11
* The above copyright notice and this permission notice (including the next
12
* paragraph) shall be included in all copies or substantial portions of the
13
* Software.
14
*
15
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21
* IN THE SOFTWARE.
22
*/
23
24
#include <assert.h>
25
#include <stdlib.h>
26
27
#include "drm-uapi/drm_fourcc.h"
28
#include "drm-uapi/i915_drm.h"
29
30
#include "isl.h"
31
#include "dev/intel_device_info.h"
32
#include "dev/intel_debug.h"
33
34
uint32_t
35
isl_tiling_to_i915_tiling(enum isl_tiling tiling)
36
{
37
switch (tiling) {
38
case ISL_TILING_LINEAR:
39
return I915_TILING_NONE;
40
41
case ISL_TILING_X:
42
return I915_TILING_X;
43
44
case ISL_TILING_Y0:
45
case ISL_TILING_HIZ:
46
case ISL_TILING_CCS:
47
return I915_TILING_Y;
48
49
case ISL_TILING_W:
50
case ISL_TILING_Yf:
51
case ISL_TILING_Ys:
52
case ISL_TILING_GFX12_CCS:
53
return I915_TILING_NONE;
54
}
55
56
unreachable("Invalid ISL tiling");
57
}
58
59
enum isl_tiling
60
isl_tiling_from_i915_tiling(uint32_t tiling)
61
{
62
switch (tiling) {
63
case I915_TILING_NONE:
64
return ISL_TILING_LINEAR;
65
66
case I915_TILING_X:
67
return ISL_TILING_X;
68
69
case I915_TILING_Y:
70
return ISL_TILING_Y0;
71
}
72
73
unreachable("Invalid i915 tiling");
74
}
75
76
/** Sentinel is DRM_FORMAT_MOD_INVALID. */
77
const struct isl_drm_modifier_info
78
isl_drm_modifier_info_list[] = {
79
{
80
.modifier = DRM_FORMAT_MOD_NONE,
81
.name = "DRM_FORMAT_MOD_NONE",
82
.tiling = ISL_TILING_LINEAR,
83
},
84
{
85
.modifier = I915_FORMAT_MOD_X_TILED,
86
.name = "I915_FORMAT_MOD_X_TILED",
87
.tiling = ISL_TILING_X,
88
},
89
{
90
.modifier = I915_FORMAT_MOD_Y_TILED,
91
.name = "I915_FORMAT_MOD_Y_TILED",
92
.tiling = ISL_TILING_Y0,
93
},
94
{
95
.modifier = I915_FORMAT_MOD_Y_TILED_CCS,
96
.name = "I915_FORMAT_MOD_Y_TILED_CCS",
97
.tiling = ISL_TILING_Y0,
98
.aux_usage = ISL_AUX_USAGE_CCS_E,
99
.supports_clear_color = false,
100
},
101
{
102
.modifier = I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS,
103
.name = "I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS",
104
.tiling = ISL_TILING_Y0,
105
.aux_usage = ISL_AUX_USAGE_GFX12_CCS_E,
106
.supports_clear_color = false,
107
},
108
{
109
.modifier = I915_FORMAT_MOD_Y_TILED_GEN12_MC_CCS,
110
.name = "I915_FORMAT_MOD_Y_TILED_GEN12_MC_CCS",
111
.tiling = ISL_TILING_Y0,
112
.aux_usage = ISL_AUX_USAGE_MC,
113
.supports_clear_color = false,
114
},
115
{
116
.modifier = I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS_CC,
117
.name = "I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS_CC",
118
.tiling = ISL_TILING_Y0,
119
.aux_usage = ISL_AUX_USAGE_GFX12_CCS_E,
120
.supports_clear_color = true,
121
},
122
{
123
.modifier = DRM_FORMAT_MOD_INVALID,
124
},
125
};
126
127
const struct isl_drm_modifier_info *
128
isl_drm_modifier_get_info(uint64_t modifier)
129
{
130
isl_drm_modifier_info_for_each(info) {
131
if (info->modifier == modifier)
132
return info;
133
}
134
135
return NULL;
136
}
137
138
uint32_t
139
isl_drm_modifier_get_score(const struct intel_device_info *devinfo,
140
uint64_t modifier)
141
{
142
/* FINISHME: Add gfx12 modifiers */
143
switch (modifier) {
144
default:
145
return 0;
146
case DRM_FORMAT_MOD_LINEAR:
147
return 1;
148
case I915_FORMAT_MOD_X_TILED:
149
return 2;
150
case I915_FORMAT_MOD_Y_TILED:
151
return 3;
152
case I915_FORMAT_MOD_Y_TILED_CCS:
153
/* Gfx12's CCS layout differs from Gfx9-11. */
154
if (devinfo->ver >= 12)
155
return 0;
156
157
if (INTEL_DEBUG & DEBUG_NO_RBC)
158
return 0;
159
160
return 4;
161
}
162
}
163
164