Commit graph

19 commits

Author SHA1 Message Date
Yiwei Zhang
b7a64441ef minigbm: refactor driver helpers
1. frontends access the driver via drv.h only
2. the renamed drv_helpers and drv_array_helpers are for driver only
3. remove extern "C" from drv_helpers.h given not exposed to gralloc
4. remove all redundant includes for those helpers

BUG=b:199524294
TEST=CQ and gralloc builds on aosp

Change-Id: I3f4d33076a6a8161804f1b7c26950ff5496507e9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3195651
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olv@google.com>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2021-10-01 18:35:11 +00:00
Jason Macnak
d6666c8f7a virtgpu_virgl: implement backend get_max_texture_2d_size()
BUG=b:194426249
TEST=launch Cuttlefish w/ 2D mode
TEST=launch Cuttlefish w/ 3D mode

Change-Id: Ib96be2c783d47959a24f579a1ae99244f8afffdb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3194814
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2021-09-30 07:58:14 +00:00
Yiwei Zhang
afdf87dcd4 minigbm: add more error handling especially for oom
This change also fixes a potential prime_fd leak in mediatek backend.

BUG=b:201110412
TEST=CQ

Change-Id: Ia3e10c94b536f83ecfb6580666103fe654bbc616
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3188852
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olv@google.com>
2021-09-29 07:08:22 +00:00
Yiwei Zhang
9420ffe3db virtgpu_virgl: strip scanout if necessary in resolve_use_flags
For guest running 3d virtgpu_virgl atop 2d virtgpu_virgl as host gbm
backend. Common and required scanout capable formats on the guest side
will fail virgl_supports_combination_natively check, resulting in
advertising no scanout support to the guest.

This change adds the same logic to resolve_use_flags before checking
support or asking for allocation to accommodate accordingly. Then
whether to strip scanout use_flag can align with native support on those
guest side scanout capable formats.

Advertising scanout for NV12 needs to go through virgl_add_combination
as well for the native support check. This is fixed by this CL.

The logic to strip scanout needs to be scanout use_flag specific to
avoid accidentally stripping scanout when the format fails texture check
but later passes the emulation check because scanout has been stripped.
This is also fixed by this CL.

BUG=b:200969382
TEST=CQ and camera interop works

Change-Id: I9126773a1ee49d4cdaf1f7186612d5f4f5c6200e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3180981
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Lepton Wu <lepton@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2021-09-25 03:56:22 +00:00
Yiwei Zhang
f58616e0e3 gralloc0: resource_info to return the correct strides and offsets
When format plane is single, it's still possible for the host image
memory to have multiple planes for auxiliary planes for non-linear
modifiers.

Relying on the non-zero stride to retrieve the actual strides and
offsets info.

BUG=b:197899093
TEST=run Vulkan apps on zork-arc-r
TEST=run guest video/camera apps
TEST=CtsNativeHardwareTestCases and related CtsGraphicsTestCases

Change-Id: Id80f143de114bbe9252c40b46dcfb835085c754d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3120411
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2021-09-22 22:42:36 +00:00
Yiwei Zhang
c1413ea43a minigbm: conditionally fallback to strip scanout use_flag
Only 2d virtgpu backend needs to fallback here because virtio primary
plane only allows DRM_FORMAT_XRGB8888.

Most our platforms cannot display YV12 (except msm), thus the fallback
is required for the converted DRM_FORMAT_YVU420_ANDROID. For virgl
backend, additionally append a BO_USE_LINEAR as a replacement for the
hack inside compute_virgl_bind_flags.

BUG=b:199524294
TEST=CQ
TEST=gralloctest alloc_combinations
TEST=android.media.cts.VideoDecoderRotationTest

Change-Id: Ic87838ea2aae2b0abf87ed898ad75a3d7e556471
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3166775
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Auto-Submit: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2021-09-22 19:47:06 +00:00
Yiwei Zhang
9f390d92a4 minigbm: remove redundant drv param in resolve_format
BUG=b:199524294
TEST=build

Change-Id: I53eaa20847afc6e80ae957b746248468420c30b4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3174312
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Auto-Submit: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2021-09-22 19:47:05 +00:00
Yiwei Zhang
9fa17e787a virtgpu_virgl: advertise scanout support for NV12
Deprecating the allocation fallback for formats not supporting scanout
in virtgpu_virgl causes issue for camera interop where NV12 is a format
required by camera interop. Host drv backends already have such support.

BUG=b:199524294
TEST=camera apps working in arcvm

Change-Id: Ifa94695491ae9d172b147c51b8eeec8180a440f6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3140575
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2021-09-21 23:07:23 +00:00
Yiwei Zhang
35aa91b797 virtgpu_virgl: refactor format advertisement
Refactor DRM_FORMAT_ABGR2101010 and DRM_FORMAT_ABGR16161616F into
texture formats since BO_USE_TEXTURE_MASK covers BO_USE_SW_MASK.

Refactor to remove the redundant advertisement of DRM_FORMAT_NV12 and
DRM_FORMAT_NV21 in the 2d path as the formats are already inside
dumb_texture_source_formats, and BO_USE_TEXTURE_MASK is a superset of
BO_USE_SW_MASK and BO_USE_LINEAR.

BUG=b:199524294
TEST=build

Change-Id: I89e315d2870ecf974157dfaec69d0c50453727f8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3169570
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Auto-Submit: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2021-09-21 04:38:03 +00:00
David Stevens
c6df2b2a60 virtgpu: no YVU420_ANDROID blobs for SW access
Currently, there is no way to coordinate buffer metadata between the
host and guest for blobs, so blobs which the guest will access can only
be used if the format is fully defined. Android's YV12 format (which
resolves to YVU420_ANDROID) is sort of fully defined, but some backends
don't actually use metadata that matches what the virtgpu_virgl expects.
As such only use blobs for YVU420_ANDROID when no SW access is required
(which is probably never, but it's straightforward enough to treat the
format the same as NV12).

Android's specification for YV12 is complicated by the fact that it
actually has two slightly different requirements depending on the use
case. The format itself requires that its stride be aligned to 16 bytes.
However, if the format is used with the long deprecated camera v1 APIs,
the stride must be the smallest possible 16 byte aligned value. The
various minigbm backends fulfil the format's stride alignment
requirement, but none actually fulfil the old camera API requirement.
Since this doesn't seem to be causing any problems in practice, either
in CTS or in any known apps, let's just leave it as is.

BUG=b:193205558, b:192516923, b:187462083
TEST=android.media.cts.EncodeDecodeTest on zork-arc-r
TEST=android.media.cts.VideoDecoderRotationTest on zork-arc-r

Change-Id: I3567cb166ab1cc547defb328b1ae697b4c3f55fe
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3088673
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: David Stevens <stevensd@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
2021-08-13 01:33:08 +00:00
David Stevens
1b252e2ee2 minigbm/virtgpu: make all blobs cross device
ARCVM's wayland compositor typically handles scanout buffers, but it can
fall back to texture buffers when the format doesn't support scanout.
These buffers can still end up being sent over virtwl, so any blob
resources with Android HW_COMPOSITOR usage need to have the
VIRTGPU_BLOB_FLAG_USE_CROSS_DEVICE set. In particular, this affects
output of SW decoders, as such buffers have no other HW usage flags set.

The simplest solution is to set the cross device flag on all blobs. This
can be revisited later if we add wider support for blobs.

BUG=b:194691227
TEST=android.mediav2.cts.CodecDecoderSurfaceTest on 5.10-arcvm kernel

Change-Id: I9baf65096eb2cb1f7d1190a52765254d7b0a2356
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3068681
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: David Stevens <stevensd@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
2021-08-10 17:09:45 +00:00
Yiwei Zhang
d3a73ff06d minigbm: map BO_USE_FRONT_RENDERING to VIRGL_BIND_LINEAR
BO_USE_FRONT_RENDERING was added to the RENDER/TEXTURE/SW_MASK masks in
crrev/c/2800148. This patch just maps the BO_USE_FRONT_RENDERING usage
flag to silence the log spam of "Unhandled bo use flag: 10000".

TEST=no more log spam from this BO usage

Change-Id: I4d5d573d700a172ae4eb387a46e60a38394af859
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3012831
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: Rob Clark <robdclark@chromium.org>
Auto-Submit: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Rob Clark <robdclark@chromium.org>
2021-07-08 21:39:00 +00:00
Nataraj Deshpande
450e57635c virtgpu: Fix RGBA_1010102 unhandled format error
The commit fixes following errors in logs
Unhandled format:808665665
Skipping unsupported combination format:808665665

BUG=none.
TEST=Boot arcvm-r and check logcat.

Change-Id: I5a64f7f7d1924e7695f7dcb63b88beb2e59c231e
Signed-off-by: Nataraj Deshpande <nataraj.deshpande@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2998276
Reviewed-by: Jason Macnak <natsu@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2021-07-08 05:09:09 +00:00
Yiwei Zhang
bb9d4af452 minigbm: support GPU_DATA_BUFFER in gralloc virtgpu_virgl backend
VK_ANDROID_external_memory_android_hardware_buffer spec requires gralloc
to support AHARDWAREBUFFER_USAGE_GPU_DATA_BUFFER. This patch adds a new
BO_USE_GPU_DATA_BUFFER flag accordingly and maps the new flag to
VIRGL_BIND_LINEAR, which aligns with the workarounds carried by existing
implementations as well as still going through the blob resource path to
be correctly mappable at the guest side.

BUG=b:191591725
TEST=AHardwareBuffer_allocate with AHARDWAREBUFFER_USAGE_GPU_DATA_BUFFER
TEST=CtsNativeHardwareTestCases
TEST=dEQP-VK.api.external.memory.android_hardware_buffer.*

Change-Id: Ib0d9b1cb90e3b7ff614d556954b6abb9018c92a1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2974800
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2021-06-25 21:02:35 +00:00
Jason Macnak
2ce35775fd virtgpu: Support P010
Enable basic 10-bit YUV P010 buffer support for use
with camera and image readers.

This is upstreaming aosp/1576366

BUG=b:147711411
TEST=Camera CTS

Change-Id: Ieaeda7189b528ec603390ff1b2012f582c627eae
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2946769
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Jason Macnak <natsu@google.com>
Commit-Queue: Jason Macnak <natsu@google.com>
2021-06-16 18:48:17 +00:00
Jason Macnak
b505a50005 virtgpu: Support PixelFormat::RGBA_1010102
BUG=b:179501410
TEST=cts -m CtsMediaV2TestCases

Change-Id: I44c7e4b43ed24040bd3ae6fa9e2ffef93610b2d1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2946768
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Jason Macnak <natsu@google.com>
Commit-Queue: Jason Macnak <natsu@google.com>
2021-06-09 23:03:44 +00:00
Yiwei Zhang
a1e93fd6f1 minibgm: update GRALLOC_DRM_GET_BUFFER_INFO query
Vulkan on Android relis on VkImageDrmFormatModifierExplicitCreateInfoEXT
to import the gralloc allocated buffer, which requires buffer info of
the host storage.

BUG=b:186679287
TEST=venus wsi on arcvm and egl/gles
TEST=CtsNativeHardwareTestCases and related CtsGraphicsTestCases

Change-Id: I7ab0e80ab67a2daae9ea547a8d5abe9417af17d8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2862161
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2021-05-05 07:58:40 +00:00
Gurchetan Singh
bbde01e70c minigbm: virtgpu: random fixups
Run presubmit.sh and fix grammar.

BUG=b:173630595
TEST=CQ will test

Change-Id: I5ec51a83a6dcbb10cc1871d6fe46760afbcaacec
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2699362
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
2021-02-19 00:15:22 +00:00
Gurchetan Singh
73c141e48e minigbm: virtgpu/cross_domain: next generation virtgpu backend
This change provides a route to the host side "cross domain"
allocator, which is specialized for resource sharing across domain
boundaries.  It uses the upcoming CONTEXT_INIT ioctl to initialize
the backend when available, and multiple timelines to perform
metadata queries.

While it would be awesome to use the revolutionary Address Space
Graphics (ASG) algorithm for metadata queries, it would be
non-trivial to pull off in minigbm.

Key aspects of the cross-domain allocator are:

* Intelligently falls back to OpenGL texture allocation host-side
  when external memory is not available.  The fallback path is
  named "virgl", even though it encompasses gfxstream and 2D mode.
  More refactorings will be added in the future for further
  clarity.

* Uses host Vulkan or minigbm to perform metadata query, and uses
  a cache to minimize vmexits.

* No shadow memory.  Only zero-copy blobs will be supported if the
  blob is mappable.  Shareable blobs may be compressed or tiled if
  not mappable.

* A commitment to sharing code across Google projects and
  cross-platform GPU virtualization.

The main goal here is to enable faster interation/testing, so this
code is just a prototype.  It should be fine to merge via minigbm,
since the project has a very chill philosophy and even proudly
accepts code that doesn't make any sense (crrev.com/c/2583188)
[so long as existing users are not broken].

BUG=b:173630595
TEST=launch virtual machine with 2D mode
TEST=launch virtual machine with 3D mode

Change-Id: Ie33a46f19e5cdd82a2ac03bcf2351f4a8f294970
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2691716
Reviewed-by: Lingfeng Yang <lfy@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
2021-02-17 07:25:37 +00:00
Renamed from virtio_gpu.c (Browse further)