Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit 5ea02f9

Browse files
committed
backend/drm: force linear layout for multi-GPU buffers
Some buffers need to be copied across GPUs. Such buffers need to be allocated with a format and modifier suitable for both the source and the destination. When explicit modifiers aren't supported, we were forcing the buffers to be allocated with a linear layout, because implicit modifiers aren't portable across GPUs. All is well with this case. When explicit modifiers are supported, we were advertising the whole list of destination modifiers, in the hope that the source might have some in common and might be able to allocate a buffer with a more optimized layout. This works well if the source supports explicit modifiers. However, if the source doesn't, then wlr_drm_format_intersect will fallback to implicit modifiers, and everything goes boom: the source uses a GPU-specific tiling and the destination interprets it as linear. To avoid this, just force linear unconditionally. We'll be able to revert this once we have a good way to indicate that an implicit modifier isn't supported in wlr_drm_format_set, see [1]. [1]: #2815 Closes: #3030 (cherry picked from commit d71ed63)
1 parent 3415e37 commit 5ea02f9

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

backend/drm/backend.c

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -249,21 +249,15 @@ struct wlr_backend *wlr_drm_backend_create(struct wl_display *display,
249249
goto error_event;
250250
}
251251

252+
// Force a linear layout. In case explicit modifiers aren't supported,
253+
// the meaning of implicit modifiers changes from one GPU to the other.
254+
// In case explicit modifiers are supported, we still have no guarantee
255+
// that the buffer producer will support these, so they might fallback
256+
// to implicit modifiers.
252257
for (size_t i = 0; i < texture_formats->len; i++) {
253258
const struct wlr_drm_format *fmt = texture_formats->formats[i];
254-
if (fmt->len == 0) {
255-
// Modifiers aren't supported. The implicit modifier changes
256-
// from a GPU to the other, so we can only accept linear
257-
// buffers
258-
wlr_drm_format_set_add(&drm->mgpu_formats, fmt->format,
259-
DRM_FORMAT_MOD_LINEAR);
260-
continue;
261-
}
262-
263-
for (size_t j = 0; j < fmt->len; j++) {
264-
wlr_drm_format_set_add(&drm->mgpu_formats, fmt->format,
265-
fmt->modifiers[j]);
266-
}
259+
wlr_drm_format_set_add(&drm->mgpu_formats, fmt->format,
260+
DRM_FORMAT_MOD_LINEAR);
267261
}
268262
}
269263

0 commit comments

Comments
 (0)