mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-10-31 22:25:21 -04:00
backend/drm: check buffer format for multi-GPU
Fixes on-screen corruption when displaying a fullscreen client
with an implicit modifier on the secondary GPU.
What happens here:
- Client allocates a buffer with an INVALID modifier on primary GPU.
- Compositor attempts to scan-out this buffer on an output connected
to secondary GPU.
- Buffer is imported to secondary GPU, and is interpreted as if it had
the secondary GPU's implicit tiling, even though it has the primary
GPU's implicit tiling.
We need to forbid cross-device imports with implicit modifiers.
The mgpu_formats list is stripped from any INVALID modifier so
checking that fixes the bug.
Using the mgpu_formats list has an additional benefit: the buffer
is rejected in the test commit if it doesn't have a format supported
by the multi-GPU renderer.
Requires this Mesa bugfix:
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31725
(cherry picked from commit c6dd5e3c2e)
This commit is contained in:
parent
86eaa44a3a
commit
bdc75d058b
1 changed files with 16 additions and 0 deletions
|
|
@ -803,6 +803,22 @@ static bool drm_connector_prepare(struct wlr_drm_connector_state *conn_state, bo
|
|||
return false;
|
||||
}
|
||||
|
||||
if ((state->committed & WLR_OUTPUT_STATE_BUFFER) && conn->backend->mgpu_renderer.wlr_rend) {
|
||||
struct wlr_dmabuf_attributes dmabuf;
|
||||
if (!wlr_buffer_get_dmabuf(state->buffer, &dmabuf)) {
|
||||
wlr_drm_conn_log(conn, WLR_DEBUG, "Buffer is not a DMA-BUF");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!wlr_drm_format_set_has(&conn->backend->mgpu_formats, dmabuf.format, dmabuf.modifier)) {
|
||||
wlr_drm_conn_log(conn, WLR_DEBUG,
|
||||
"Buffer format 0x%"PRIX32" with modifier 0x%"PRIX64" cannot be "
|
||||
"imported into multi-GPU renderer",
|
||||
dmabuf.format, dmabuf.modifier);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (test_only && conn->backend->parent) {
|
||||
// If we're running as a secondary GPU, we can't perform an atomic
|
||||
// commit without blitting a buffer.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue