-
Notifications
You must be signed in to change notification settings - Fork 5
/
0003-Revert-nouveau-Use-format-modifiers-in-buffer-alloca.patch
215 lines (197 loc) · 7.98 KB
/
0003-Revert-nouveau-Use-format-modifiers-in-buffer-alloca.patch
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
213
214
From 7c19437292c0da14bda555b3f55875eb8c0b2ed2 Mon Sep 17 00:00:00 2001
From: Karol Herbst <[email protected]>
Date: Thu, 16 Sep 2021 13:07:31 -0400
Subject: [PATCH 3/6] Revert "nouveau: Use format modifiers in buffer
allocation"
This reverts commit 129d83cac2accc4a66eae50c19ac245b864dc98c.
---
.../drivers/nouveau/nvc0/nvc0_miptree.c | 125 ++----------------
1 file changed, 8 insertions(+), 117 deletions(-)
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c b/src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c
index e0a9d48249f..8260a90f0d6 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c
@@ -184,7 +184,7 @@ nvc0_choose_tiled_storage_type(struct pipe_screen *pscreen,
static uint32_t
nvc0_mt_choose_storage_type(struct pipe_screen *pscreen,
- const struct nv50_miptree *mt,
+ struct nv50_miptree *mt,
bool compressed)
{
const unsigned ms = util_logbase2(mt->base.base.nr_samples);
@@ -249,7 +249,7 @@ nvc0_miptree_init_layout_video(struct nv50_miptree *mt)
}
static void
-nvc0_miptree_init_layout_tiled(struct nv50_miptree *mt, uint64_t modifier)
+nvc0_miptree_init_layout_tiled(struct nv50_miptree *mt)
{
struct pipe_resource *pt = &mt->base.base;
unsigned w, h, d, l;
@@ -266,9 +266,6 @@ nvc0_miptree_init_layout_tiled(struct nv50_miptree *mt, uint64_t modifier)
d = mt->layout_3d ? pt->depth0 : 1;
assert(!mt->ms_mode || !pt->last_level);
- assert(modifier == DRM_FORMAT_MOD_INVALID ||
- (!pt->last_level && !mt->layout_3d));
- assert(modifier != DRM_FORMAT_MOD_LINEAR);
for (l = 0; l <= pt->last_level; ++l) {
struct nv50_miptree_level *lvl = &mt->level[l];
@@ -278,16 +275,7 @@ nvc0_miptree_init_layout_tiled(struct nv50_miptree *mt, uint64_t modifier)
lvl->offset = mt->total_size;
- if (modifier != DRM_FORMAT_MOD_INVALID)
- /* Extract the log2(block height) field from the modifier and pack it
- * into tile_mode's y field. Other tile dimensions are always 1
- * (represented using 0 here) for 2D surfaces, and non-2D surfaces are
- * not supported by the current modifiers (asserted above). Note the
- * modifier must be validated prior to calling this function.
- */
- lvl->tile_mode = ((uint32_t)modifier & 0xf) << 4;
- else
- lvl->tile_mode = nvc0_tex_choose_tile_dims(nbx, nby, d, mt->layout_3d);
+ lvl->tile_mode = nvc0_tex_choose_tile_dims(nbx, nby, d, mt->layout_3d);
tsx = NVC0_TILE_SIZE_X(lvl->tile_mode); /* x is tile row pitch in bytes */
tsy = NVC0_TILE_SIZE_Y(lvl->tile_mode);
@@ -358,87 +346,6 @@ nvc0_miptree_get_handle(struct pipe_screen *pscreen,
return true;
}
-static uint64_t
-nvc0_miptree_select_best_modifier(struct pipe_screen *pscreen,
- const struct nv50_miptree *mt,
- const uint64_t *modifiers,
- unsigned int count)
-{
- /*
- * Supported block heights are 1,2,4,8,16,32, stored as log2() their
- * value. Reserve one slot for each, as well as the linear modifier.
- */
- uint64_t prio_supported_mods[] = {
- DRM_FORMAT_MOD_INVALID,
- DRM_FORMAT_MOD_INVALID,
- DRM_FORMAT_MOD_INVALID,
- DRM_FORMAT_MOD_INVALID,
- DRM_FORMAT_MOD_INVALID,
- DRM_FORMAT_MOD_INVALID,
- DRM_FORMAT_MOD_LINEAR,
- };
- const uint32_t uc_kind = nvc0_mt_choose_storage_type(pscreen, mt, false);
- int top_mod_slot = ARRAY_SIZE(prio_supported_mods);
- const uint32_t kind_gen = nvc0_get_kind_generation(pscreen);
- unsigned int i;
- int p;
-
- if (uc_kind != 0u) {
- const struct pipe_resource *pt = &mt->base.base;
- const unsigned nbx = util_format_get_nblocksx(pt->format, pt->width0);
- const unsigned nby = util_format_get_nblocksy(pt->format, pt->height0);
- const uint32_t lbh_preferred =
- NVC0_TILE_MODE_Y(nvc0_tex_choose_tile_dims(nbx, nby, 1u, false));
- uint32_t lbh = lbh_preferred;
- bool dec_lbh = true;
- const uint8_t s = nouveau_screen(pscreen)->tegra_sector_layout ? 0 : 1;
-
- for (i = 0; i < ARRAY_SIZE(prio_supported_mods) - 1; i++) {
- assert(lbh <= 5u);
- prio_supported_mods[i] =
- DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, s, kind_gen, uc_kind, lbh);
-
- /*
- * The preferred block height is the largest block size that doesn't
- * waste excessive space with unused padding bytes relative to the
- * height of the image. Construct the priority array such that
- * the preferred block height is highest priority, followed by
- * progressively smaller block sizes down to a block height of one,
- * followed by progressively larger (more wasteful) block sizes up
- * to 5.
- */
- if (lbh == 0u) {
- lbh = lbh_preferred + 1u;
- dec_lbh = false;
- } else if (dec_lbh) {
- lbh--;
- } else {
- lbh++;
- }
- }
- }
-
- assert(prio_supported_mods[ARRAY_SIZE(prio_supported_mods) - 1] ==
- DRM_FORMAT_MOD_LINEAR);
-
- for (i = 0u; i < count; i++) {
- for (p = 0; p < ARRAY_SIZE(prio_supported_mods); p++) {
- if (prio_supported_mods[p] != DRM_FORMAT_MOD_INVALID) {
- if (modifiers[i] == DRM_FORMAT_MOD_INVALID ||
- prio_supported_mods[p] == modifiers[i]) {
- if (top_mod_slot > p) top_mod_slot = p;
- break;
- }
- }
- }
- }
-
- if (top_mod_slot >= ARRAY_SIZE(prio_supported_mods))
- return DRM_FORMAT_MOD_INVALID;
-
- return prio_supported_mods[top_mod_slot];
-}
-
struct pipe_resource *
nvc0_miptree_create(struct pipe_screen *pscreen,
const struct pipe_resource *templ,
@@ -450,7 +360,6 @@ nvc0_miptree_create(struct pipe_screen *pscreen,
union nouveau_bo_config bo_config;
uint32_t bo_flags;
unsigned pitch_align;
- uint64_t modifier = DRM_FORMAT_MOD_INVALID;
if (!mt)
return NULL;
@@ -460,9 +369,6 @@ nvc0_miptree_create(struct pipe_screen *pscreen,
pt->screen = pscreen;
if (pt->usage == PIPE_USAGE_STAGING) {
- /* PIPE_USAGE_STAGING, and usage in general, should not be specified when
- * modifiers are used. */
- assert(count == 0);
switch (pt->target) {
case PIPE_TEXTURE_2D:
case PIPE_TEXTURE_RECT:
@@ -476,27 +382,13 @@ nvc0_miptree_create(struct pipe_screen *pscreen,
}
}
- if (pt->bind & PIPE_BIND_LINEAR)
+ if (count == 1 && modifiers[0] == DRM_FORMAT_MOD_LINEAR)
pt->flags |= NOUVEAU_RESOURCE_FLAG_LINEAR;
- if (count > 0) {
- modifier = nvc0_miptree_select_best_modifier(pscreen, mt,
- modifiers, count);
-
- if (modifier == DRM_FORMAT_MOD_INVALID) {
- FREE(mt);
- return NULL;
- }
+ if (pt->bind & PIPE_BIND_LINEAR)
+ pt->flags |= NOUVEAU_RESOURCE_FLAG_LINEAR;
- if (modifier == DRM_FORMAT_MOD_LINEAR) {
- pt->flags |= NOUVEAU_RESOURCE_FLAG_LINEAR;
- bo_config.nvc0.memtype = 0;
- } else {
- bo_config.nvc0.memtype = (modifier >> 12) & 0xff;
- }
- } else {
- bo_config.nvc0.memtype = nvc0_mt_choose_storage_type(pscreen, mt, compressed);
- }
+ bo_config.nvc0.memtype = nvc0_mt_choose_storage_type(pscreen, mt, compressed);
if (!nvc0_miptree_init_ms_mode(mt)) {
FREE(mt);
@@ -504,11 +396,10 @@ nvc0_miptree_create(struct pipe_screen *pscreen,
}
if (unlikely(pt->flags & NVC0_RESOURCE_FLAG_VIDEO)) {
- assert(modifier == DRM_FORMAT_MOD_INVALID);
nvc0_miptree_init_layout_video(mt);
} else
if (likely(bo_config.nvc0.memtype)) {
- nvc0_miptree_init_layout_tiled(mt, modifier);
+ nvc0_miptree_init_layout_tiled(mt);
} else {
/* When modifiers are supplied, usage is zero. TODO: detect the
* modifiers+cursor case. */
--
2.31.1