From fd8cad3fd2ddcc07163586a0aff13b81dc9f4999 Mon Sep 17 00:00:00 2001 From: David Riley Date: Mon, 15 Apr 2019 19:11:55 -0700 Subject: [PATCH] devices: gpu: Fallback to using non-scanout buffer if minigbm allocation fails. Only allocate using minigbm if scanout bind is request (which can indicate that the buffer is to be shared until a proper virgl bind flag for shared is available), but if that fails because the format is not supported for scanout, retry the minigbm allocation with the scanout flag. BUG=chromium:945033 TEST=None Change-Id: Ib99bf01c8b9c2a98b1c0d1a8592d5f7c6e1aa859 Reviewed-on: https://chromium-review.googlesource.com/1569025 Commit-Ready: David Riley Tested-by: David Riley Tested-by: kokoro Reviewed-by: Tomasz Figa Reviewed-by: Zach Reizner --- devices/src/virtio/gpu/backend.rs | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/devices/src/virtio/gpu/backend.rs b/devices/src/virtio/gpu/backend.rs index 690c94df98..0359dd34de 100644 --- a/devices/src/virtio/gpu/backend.rs +++ b/devices/src/virtio/gpu/backend.rs @@ -770,11 +770,22 @@ impl Backend { ) { Ok(buffer) => buffer, Err(e) => { - error!( - "failed to create buffer for 3d resource {}: {}", - format, e - ); - return GpuResponse::ErrUnspec; + // Attempt to allocate the buffer without scanout flag. + match self.device.create_buffer( + width, + height, + Format::from(fourcc), + Flags::empty().use_rendering(true), + ) { + Ok(buffer) => buffer, + Err(e) => { + error!( + "failed to create buffer for 3d resource {}: {}", + format, e + ); + return GpuResponse::ErrUnspec; + } + } } };