Commit graph

72 commits

Author SHA1 Message Date
Roman Stratiienko
4f7758ffa1 minigbm: Use dmabuf inode as unique buffer id instead of handle
Handle has some limits and can't be used as unique buffer ID on systems
where display controller can scanout from CMA but GPU can work with both
CMA and VRAM.

Such systems have DRM/KMS and DRM/GPU drivers separated.
GBM frontend is always expecting handle for DRM/KMS driver.
In such system any attempt of importing the buffer with more
than 1 contiguous chunk into DRM/KMS driver will fail.

Using dma-buf inode as unique buffer ID is a common practice for
a last several years starting from [this kernel patch][1].

[1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ed63bb1d1f8469586006a9ca63c42344401aa2ab
Change-Id: Ic3a69010d5da2f866a2252fc7e9eb29d67f8e1ed
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
2026-07-16 00:53:22 -04:00
Yiwei Zhang
6f379aae87 UPSTREAM: virtgpu_virgl: default to enable blob mem for compatible cases
All of virgl, venus and gfxstream have long been able to handle the
limited blob mem usage in the legacy backend.

BUG=b:327668289
TEST=AHB cts passing with Venus on Cuttlefish on ANV

Change-Id: Ie6a26c2e5e74faac6f8db060ffcfbb2364610d41
2025-06-30 22:58:00 +00:00
Andrew Wolfers
e714ab660b Merge "virtio: Add USE_CURSOR buffer padding" into main 2025-06-30 06:47:43 -07:00
Andrew Wolfers
34fcb9cbe2 virtio: Add USE_CURSOR buffer padding
This change modifies buffer allocation to include necessary padding
for buffers with the BO_USE_CURSOR flag. This behavior mirrors
identical logic in the i915, xe, and mtk implementations.

Bug: b/426503691
Change-Id: Ic572a970dcde0606fa9ec5844c57d3136c5d0b84
(cherry picked from commit f13b0faac8501a3bf3eb90f2fd07107728576876)
2025-06-27 17:20:40 +00:00
Mike Frysinger
bc47e98159 UPSTREAM: presubmit: switch to cros format
Rather than use `clang-format` from $PATH (which changes between devs),
use `cros format` which has a pinned version for all people.

Add *.cpp to the include list as not all C++ files use *.cc.

Then run format on the files to fix latent issues.

BUG=None
TEST=./presubmit.sh

Change-Id: I28e167d454a7b089bb79e932b7265fa87e4c331f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/6475964
Commit-Queue: Mike Frysinger <vapier@chromium.org>
Tested-by: Ryan Neph <ryanneph@google.com>
Tested-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Dominik Behr <dbehr@chromium.org>

Bug: None
Test: lunch brya-trunk_staging-userdebug && m libminigbm_gralloc
Change-Id: I23022dbb536ade53951fe61014c5056e114f4bbc
2025-06-24 17:37:57 -07:00
Jason Macnak
8956e04c7f Revert^2 "Merge remote-tracking branch 'aosp/upstream-main'"
8a3215bf53

Change-Id: I299a95b80910f102a652cbd577838ddfc65fdbc6
2024-10-16 19:19:47 +00:00
Jason Macnak
8a3215bf53 Revert "Merge remote-tracking branch 'aosp/upstream-main'"
Revert submission 3308804

Reason for revert: b/373667975

Reverted changes: /q/submissionid:3308804

Change-Id: Ieb4e87d2bdcd975f5aa231c8e05f1053963c6c6e
2024-10-15 20:15:13 +00:00
Jason Macnak
93d9ee4352 Merge remote-tracking branch 'aosp/upstream-main'
... to pull in https://crrev.com/c/5913519.

Bug: b/320202326
Bug: b/309244873
Test: CI
Change-Id: I353d0c39c44f600d6070a9796f4fd4b824f1848a
2024-10-11 12:30:00 -07:00
Dorinda Bassey
a2a049d9f5 Initialize emulated_metadata fields to avoid uninitialized warnings
Set `emulated_metadata` fields to default values (0) to prevent
potential usage of uninitialized variables in `virtgpu_virgl.c`.
This fix ensures that the compilation doesn't fail due to warnings
being treated as errors when using strict compiler flags.

Change-Id: I2508168c095896c7fd492830ffb6ff3564dc2733
Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/5782849
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Dominik Behr <dbehr@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2024-08-27 00:06:40 +00:00
Jason Macnak
197d810946 Merge remote-tracking branch 'aosp/upstream-main'
... to pull in https://crrev.com/c/5722608 for depth format support
handling on CF.

Bug: b/352091996
Test: dEQP test cases on Cuttlefish
Change-Id: Ie99042b2d35df70401efa0133b3ccfc370a9a97a
2024-08-01 09:20:50 -07:00
Jean-Francois Thibert
71ca6afaef Add format filtering for virgl gfxstream
Bug=b:352091996
Test=Ran CTS deqp test cases with cuttlefish

Change-Id: Ie6af00d39abfd19b8070b8df9349d05c80b324c2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/5722608
Reviewed-by: Dominik Behr <dbehr@chromium.org>
Commit-Queue: Jean-François Thibert <jfthibert@google.com>
Reviewed-by: Jason Macnak <natsu@google.com>
Tested-by: Jean-François Thibert <jfthibert@google.com>
2024-08-01 15:42:33 +00:00
Jean-François Thibert
fd19358a25 Revert^2 "Merge upstream-main into main"
This reverts commit b7a9a2b7d5.

Reason for revert: Crash resolved by Ieb07b5bbc206f07f69e4afba921149f49d6fe8c4
Bug: 349870098

Change-Id: I49848f6e7311c1f44e6c988cb42107ed79da3a6b
2024-07-03 18:21:13 +00:00
Jason Macnak
b7a9a2b7d5 Revert "Merge upstream-main into main"
This reverts commit 018f7ff8fa.

Reason for revert: b/349870098

Change-Id: I942c713e4f7a24881b7ea3cff30df13a2b4a7c9c
2024-06-27 21:40:26 +00:00
Jean-Francois Thibert
018f7ff8fa Merge upstream-main into main
This includes changes I63a5352e, Ia34b7d3a, I2685813f and I07e60729

mediatek: Add MT8196
minigbm: Reduce allocation size for MT2T allocations
minigbm: #define MINIGBM_HAS_GBM_BO_GET_MAP_INFO
Add depth buffer support for virtgpu virgl

Change-Id: I125c0b751f86b217a6ffbf7ec3fd2a1ddf848461
2024-06-26 13:21:44 -04:00
Jean-Francois Thibert
6158bc1fdc Add depth buffer support for virtgpu virgl
Bug: b:347022601
Test: Ran app that export/import depth through AHB with cf

Change-Id: I07e60729b18a9f15e0d795c33c462ba4b4f255b6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/5636740
Tested-by: Jean-François Thibert <jfthibert@google.com>
Reviewed-by: Dawn Han <dawnhan@google.com>
Commit-Queue: Jean-François Thibert <jfthibert@google.com>
Reviewed-by: Jason Macnak <natsu@google.com>
2024-06-26 15:22:27 +00:00
Marcin Radomski
b1dc373138 Merge remote-tracking branch 'cros/main'
To pull in https://crrev.com/c/5352370 and https://crrev.com/c/5352371.

Additionally, add backend_mock.c to Android.bp. It was added in
https://crrev.com/c/4923791, and drv.c uses symbols defined there
unconditionally.

The one merge conflict was an i915->is_media_compression_enabled assert
in i915_num_planes_from_modifier [1] that was removed upstream in
https://crrev.com/c/5118242. The assertion referenced a flag that was
set through an ENABLE_INTEL_MEDIA_COMPRESSION environment variable.
There are no references to that variable in AOSP sources.

[1] https://cs.android.com/android/platform/superproject/main/+/main:external/minigbm/i915.c;l=591;drc=350c09cf0fa662928e208eb6749a1f3ca34dac9f

Bug: b/328181805
Test: lunch aosp_cf_x86_64_only_phone-trunk_staging-userdebug
Test: m && cvd start && atest SurfaceFlinger_test
Change-Id: I8faba268580ad984af92a63c47366d6a69e8c9d0
2024-03-12 14:52:29 +00:00
Kaiyi Li
4baf42e47c virtgpu: define capset ids as macros
... to avoid using magic numbers.

TEST=compile
BUG=b:322199104

Change-Id: I8522596f2cb2d0e9bdc381440c7e9ad3bbaa3165
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/5246254
Tested-by: Kaiyi Li <kaiyili@google.com>
Commit-Queue: Kaiyi Li <kaiyili@google.com>
Reviewed-by: Dominik Behr <dbehr@chromium.org>
Auto-Submit: Kaiyi Li <kaiyili@google.com>
2024-01-31 01:44:11 +00:00
Kaiyi Li
52c63ae1a7 virtgpu virgl: assume 0 caps for unrecognized capset IDs
minigbm gralloc + gfxstream on the host will always fail the get caps
ioctl, but gralloc itself still works fine.

TEST=build and run the emulator
BUG=b:322199104

Change-Id: I35ebbdddbfb050ead76d61626f13f028cf909229
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/5241884
Auto-Submit: Kaiyi Li <kaiyili@google.com>
Commit-Queue: Kaiyi Li <kaiyili@google.com>
Tested-by: Kaiyi Li <kaiyili@google.com>
Reviewed-by: Dominik Behr <dbehr@chromium.org>
2024-01-30 20:55:34 +00:00
Amit Pundir
21fc4f10c8 Merge remote-tracking branch 'aosp/upstream-main' into 'aosp/main'
* aosp/upstream-main: (27 commits)
  minigbm: add some validation check in cros_gralloc
  minigbm: update format of mediatek.c
  Revert "i915: Vertical align video encode buffers to macroblock size"
  minigbm: drv: Fix MINIGBM_DEBUG usage on Android
  mediatek: Add BO_USE_PROTECTED use_flag for gpu and video decoder
  i915: Vertical align video encode buffers to macroblock size
  Don't print verbose messages by default
  virgl: Store format modifier in blob's bo meta
  Fix convertToFenceHandle()
  minigbm: update drv_get_os_option() to try getenv() first
  Update usage to 64-bit
  virtgpu_cross_domain: fix prop query for mt8183 camera quirk
  virtgpu_virgl: use blobs for ABGR8888
  minigbm: move camera work-around
  mediatek: Add BO_USE_PROTECTED use_flag to support secure buffer allocation
  i915: prefer tile4 for non-linear scanout buffers
  i915: allow linear mapping for P010 scanout
  minigbm: remove `close_gem_handle`
  mediatek: Exclude MT8173's FP16 and 10-bit ABGR support
  minigbm: Use clflushopt if supported
  ...

Change-Id: I38fb3f2c699205f73633e07d1824c4fd48dac5f5
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
2023-07-21 10:11:44 +05:30
Bartłomiej Grzesik
3af863ad23 virgl: Store format modifier in blob's bo meta
Prior this change the format modifier was not set for blob's meta, which
lead to incorrect reporting of format modifier to clients.
This changes fixes this issue.

BUG=b:267299128
TEST=ExoPlayer demo app

Change-Id: I15c2f9095d3cb20e2a5a34d749af6657e98f7ba6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4628256
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2023-06-21 20:24:46 +00:00
Lloyd Pique
b20510aefc virtgpu_virgl: use blobs for ABGR8888
This is slightly modified version of another patch originally created by
David Stevens (stevensd@chromium.org), but since reverted.

https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3256451

Use blob buffers for ABGR8888 format buffers. This is necessary on ARCVM
to mitigate a performance problem with the
`testSurfaceTransaction_setEnableBackPressure` test from the
`CtsViewTestCases`, as the test expects to be able to read back rendered
buffers at 60fps.

Almost all the code is the same, with the only differences (besides some
minor conflict resolutions resurrecting this patch) being in the
switch statement in `should_use_blob` in `virtgpu_virgl.c` where a check
for ABGR8888 is added.

The rest of the change is as authored by stevensd@, which requires
knowing the host buffer layout before creating the blob resource, and
using an LRU cache of layouts to avoid the overhead of querying the host
every time a buffer is created.

As noted in stevensd@'s CL, virgpu_cross_domain will be the preferred
replacement to virgpu_virgl, and which is expected to have better
performance without this kludge.

TEST=CtsViewTestCases on hatch
BUG=b:235308831

Change-Id: Ia58573a8477e0c17239d6a0768ee53782fac1dd3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4505920
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: Lloyd Pique <lpique@chromium.org>
Auto-Submit: Lloyd Pique <lpique@chromium.org>
Tested-by: Lloyd Pique <lpique@chromium.org>
2023-05-09 23:42:32 +00:00
Dawn Han
84b3a09ef0 minigbm: clean up bo.handles
The multi-planar formats are being allocated into a single plane,
and the minigbm exynos backend is dropped. So we can use `handle` instead of handles as of now.

Remove some of the helper functions that calculate the number of planes.
There is no need to check if there is more than one kernel buffer per buffer object.

Added a new function `drv_gem_close` in `drv_helpers` that can be used by `drv_gem_bo_destroy` and `drv_prime_bo_import`. It can be used to clean the unused gem_handle.

Bug=b:266776512
TEST=camera and screenshot work fine after deploying the change #strongbad
TEST=camera and screenshot work fine after deploying the change #kukui-arc-r
TEST=camera and screenshot work fine after deploying the change, tested a couple of apps in the Google Play Store, and checked file `dma_buf/bufinfo` to see there's no object leaking. #guybrush

Change-Id: Ib63559504e4cb8f1a32ae90170925146613d694f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4297873
Commit-Queue: Dawn Han <dawnhan@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Dawn Han <dawnhan@google.com>
2023-04-09 18:57:40 +00:00
Yiwei Zhang
ea61838d9b Merge remote-tracking branch 'cros/main' into 'aosp/master'
Bug: 273794453
Test: build
Change-Id: Ie66e6c5026f2151ea7f38d7aef080350ec0f7bce
2023-03-15 21:11:03 +00:00
Chia-I Wu
5ff4a55d37 drv: pass stride_align to drv_bo_from_format
drv_bo_from_format will apply stride_align to all planes.  Since we
always pass 1 for stride_align, there is no change except when the
format is DRM_FORMAT_YVU420_ANDROID.

When the format is DRM_FORMAT_YVU420_ANDROID, and when stride_align is 0
or 1, drv_bo_from_format assumes there is no hw requirement and forces
stride_align to 16.  But because we used to require stride to be aligned
to 32, there is no actual change either.

BUG=b:265746435
TEST=subset of CTS and CTS Verifier on grunt, guybrush and skyrim

Change-Id: Ia6ef89bb744c39d2baead07bc47f11b0eea96b97
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4336265
Tested-by: Chia-I Wu <olv@google.com>
Commit-Queue: Chia-I Wu <olv@google.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Dawn Han <dawnhan@google.com>
2023-03-15 05:13:37 +00:00
Dawn Han
ecbc89179e minigbm: Remove plane in bo_map
Remove the parameter to align with upstream gbm.
For some places that use the number of planes. The number is 1. The
multi-planar formats are being allocated into a single plane, and
minigbm exynos backend is dropped. So we can just set the plane
index to 0 if needed.

Fixed the format in i915.c.

Bug=b:266776512
TEST=camera works after deploying the change #strongbad
TEST=camera works after deploying the change #corsola

Change-Id: I0880917754c01b9d0f27d21f3c42d87f00a09f50
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4249501
Commit-Queue: Dawn Han <dawnhan@google.com>
Tested-by: Dawn Han <dawnhan@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olv@google.com>
2023-02-27 19:34:38 +00:00
Yiwei Zhang
49756130de Merge remote-tracking branch 'cros/main' into 'aosp/master'
Bug: 158617858
Bug: 174146421
Bug: 269565421
Test: CtsNNAPITestCases and CtsCameraTestCases
Change-Id: Ifca6fd0c2dcfcfc3426441f13cd04b8ba02b21ac
2023-02-20 22:59:22 +00:00
Yiwei Zhang
b377924a7b minigbm: format fix and add missing header
BUG=n/a
TEST=build

Change-Id: Id2dac9a25190ba8ee05f42ef3a4ff8a1e3965844
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4269511
Reviewed-by: Satoshi Niwa <niwa@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Auto-Submit: Yiwei Zhang <zzyiwei@chromium.org>
2023-02-20 22:49:46 +00:00
Lepton Wu
deea0549d6 virtgpu_virgl: Set BO_USE_RENDERING for ARC Screen capture buffers.
This helps syncing back the host side content to the screen capture buffer in guest.

BUG=b:267892346
TEST=manual - Run AnyDesk on ARCVM

Change-Id: I230bd896ade2176f5e7e317f6cb227f45e89807e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4241419
Tested-by: Lepton Wu <lepton@chromium.org>
Auto-Submit: Lepton Wu <lepton@chromium.org>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2023-02-12 07:35:16 +00:00
Yi Xie
464fee5671 minigbm: Align BO tile size for llvmpipe on dumb driver
Mesa's llvmpipe software renderer generates instructions that require
memory to be aligned properly, otherwise it will crash with general
protection exception. To support crosvm on headless VM with vkms we'd
like to always align memory properly on dumb driver.

BUG=b:239110721
TEST=Run betty-arc-r on headless VM with vkms enabled

Change-Id: I4b119f450cbb9b36d0d35d37be9ca97102924963
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4134929
Tested-by: Yi Xie <yixie@chromium.org>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: Yi Xie <yixie@chromium.org>
2023-01-13 14:24:45 +00:00
Yiwei Zhang
6e59e6f189 Merge remote-tracking branch 'cros/main' into 'aosp/master'
Bug: 264408280
Test: build
Change-Id: I4e9f98e0d9626117860375732c4b5633c0e646f9
2023-01-12 07:04:17 +00:00
Yiwei Zhang
8d3d4eb347 virtgpu_virgl: force linear for non-camera impl defined format
This is a workaround until the consumer side surface expresses the
intended usage bits to resolve.

BUG=b:264408280
TEST=build

Change-Id: Icf631f026b5d4d9b465cf16e48ccb86694ac6f16
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4159974
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Alan Ding <alanding@chromium.org>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
2023-01-12 06:59:35 +00:00
Yiwei Zhang
4c63ec5aec virtgpu_virgl: force linear for hw encoder with impl defined
BUG=b:264408280
TEST=video capture

Change-Id: Iffefbefb061def63905c6db7982c19bc16f2c223
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4137158
Reviewed-by: Dominik Laskowski <domlaskowski@chromium.org>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Auto-Submit: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: Dawn Han <dawnhan@google.com>
Reviewed-by: Dawn Han <dawnhan@google.com>
2023-01-05 21:59:01 +00:00
Yiwei Zhang
6b4b5d3b03 virtgpu_virgl: properly resolve flexible formats
DRM_FORMAT_FLEX_YCbCr_420_888 gets the fallthrough but
DRM_FORMAT_FLEX_IMPLEMENTATION_DEFINED is missed. This change updates to
resolve flexible format into explicit format first and then further
resolve explicit format in a 2nd pass.

BUG=b:260032660
TEST=cts

Change-Id: I69724f5845299a79a315ab32ddf5a207cdfa26b6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4133686
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2023-01-03 22:33:49 +00:00
David Stevens
a1b820fa9f Revert "virtgpu_virgl: use blobs NV12 encoder input"
This reverts commit 7eb9e826a7.

Reason for revert: b/260322776

Original change's description:
> virtgpu_virgl: use blobs NV12 encoder input
>
> Use blob buffers for encoder NV12 input, even when software access is
> required. This is helpful for ARCVM, since the v4l2_codec2 stack
> sometimes needs to do a format conversion in the guest as the
> virtio-video encoder only supports NV12/I420 input.
>
> Supporting this requires knowing the host buffer layout before creating
> the blob resource. This is done by creating a temporary resource to
> query the layout. To avoid the overhead of querying the host every time
> a buffer is created, the allocator process keeps a cache of the most
> recently used buffer formats and their host layout.
>
> Creating temporary resources to discover host buffer parameters is a bit
> of a cludge. However, since virtgpu_virgl will eventually be deprecated
> in favor of virtgpu_cross_domain, a self-contained and simple approach
> like this gives some nice performance gains on low end devices.
>
> TEST=decode-edit-encode workflows
> TEST=Cts{NativeHardware,Camera,Graphics,Video}TestCases on volteer
> BUG=b:203380807, b:232531771
>
> Change-Id: Ibda500862b42680ba898ba689e1600ebe5d258bd
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3256451
> Auto-Submit: David Stevens <stevensd@chromium.org>
> Reviewed-by: Lepton Wu <lepton@chromium.org>
> Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
> Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
> Tested-by: David Stevens <stevensd@chromium.org>

Bug: b:203380807, b:232531771
Change-Id: I36d3ce104c71461e931d0413ab4b00588f02ee22
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4060933
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
2022-12-01 01:31:03 +00:00
David Stevens
7eb9e826a7 virtgpu_virgl: use blobs NV12 encoder input
Use blob buffers for encoder NV12 input, even when software access is
required. This is helpful for ARCVM, since the v4l2_codec2 stack
sometimes needs to do a format conversion in the guest as the
virtio-video encoder only supports NV12/I420 input.

Supporting this requires knowing the host buffer layout before creating
the blob resource. This is done by creating a temporary resource to
query the layout. To avoid the overhead of querying the host every time
a buffer is created, the allocator process keeps a cache of the most
recently used buffer formats and their host layout.

Creating temporary resources to discover host buffer parameters is a bit
of a cludge. However, since virtgpu_virgl will eventually be deprecated
in favor of virtgpu_cross_domain, a self-contained and simple approach
like this gives some nice performance gains on low end devices.

TEST=decode-edit-encode workflows
TEST=Cts{NativeHardware,Camera,Graphics,Video}TestCases on volteer
BUG=b:203380807, b:232531771

Change-Id: Ibda500862b42680ba898ba689e1600ebe5d258bd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3256451
Auto-Submit: David Stevens <stevensd@chromium.org>
Reviewed-by: Lepton Wu <lepton@chromium.org>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: David Stevens <stevensd@chromium.org>
2022-11-16 01:37:22 +00:00
Jason Macnak
c7f2cc7e03 Merge remote-tracking branch 'aosp/upstream-main' into 'aosp/master'
... to pull in https://crrev.com/c/4018143 for Cuttlefish to remove
some logspam.

Bug: b/258516895
Test: cts -m CtsNativeHardwareTestCases
Change-Id: I605a76e5a518ae499671bb4b517e88f00b7b6292
2022-11-15 09:09:58 -08:00
Fei Shao
fc3146f5b7 virtgpu_virgl: Fix format style
clang-format fixes the formatting in presubmit.

BUG=None
TEST=repo upload . --cbr

Change-Id: I77a958b3a2bc3e923b2ee8abc0aa322382490ec9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3998337
Commit-Queue: Fei Shao <fshao@chromium.org>
Reviewed-by: Hsin-Yi Wang <hsinyi@chromium.org>
Tested-by: Fei Shao <fshao@chromium.org>
Reviewed-by: Miguel Casas-Sanchez <mcasas@chromium.org>
2022-11-15 12:24:57 +00:00
David Stevens
bef7c87c29 virtgpu_virgl: remove unused parameter
Format is no longer used when computing virgl bind flags, so drop the
parameter.

BUG=None
TEST=compiles

Change-Id: I7c0526584c442f981aa1b109c6b785a01d1e7ddf
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4014226
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
Tested-by: David Stevens <stevensd@chromium.org>
2022-11-14 02:17:47 +00:00
Yiwei Zhang
a11fc6dcd0 Merge remote-tracking branch 'cros/main' into 'aosp/master'
Bug: 246814802
Test: Blob_BlobTest_GpuDataBufferVertexBuffer_BLOB
Change-Id: Id33aa12d2684218f2a38eaaee55bb2c456ee6602
2022-09-15 19:03:32 +00:00
Yiwei Zhang
8f16db9fc8 virtgpu: always make it mappable for GPU_DATA_BUFFER
Venus device memory mapping setup must succeed for AHB VkBuffer.
Meanwhile, the imported AHB can be allocated with only GPU_DATA_BUFFER
flag. So we must add mappable flag in virtgpu backends accordingly.

BUG=b:246814802
TEST=Blob_BlobTest_GpuDataBufferVertexBuffer_BLOB

Change-Id: I88f63c732d3b133daf755d73ed54578605d27112
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3896159
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olv@google.com>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Rob Clark <robdclark@chromium.org>
2022-09-15 04:52:47 +00:00
Nicholas Bishop
dbe7f03f0c virtgpu_virgl: Add basic support for modifiers
In recent kernel versions virtgpu reports support for the linear
modifier due to commit "drm: add support modifiers for drivers whose
planes only support linear layout" [1].

This causes the UI to when it calls gbm_bo_create_with_modifiers; it
hits an early return in drv_bo_create_with_modifiers due to the
virtgpu backend setting neither bo_create_with_modifiers nor
bo_compute_metadata.

Fix by adding a virgl_bo_create_with_modifiers modeled on
dumb_bo_create_with_modifiers. If the requested modifiers include
the linear modifier, pass the request on to virgl_bo_create.
Otherwise fail with EINVAL.

[1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=8be576837b6e62b2ad0de2f9ba31cef618fa2891

BUG=b:243569755
TEST=Deploy minigbm to a reven-kernelnext VM
TEST=Restart UI, observe UI is no longer black
TEST=Logs don't show "Failed to create scanout buffer" errors

Change-Id: If8d02225a7a50600b5ae4685cc963ad391bd9bf7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3862241
Reviewed-by: Dominik Behr <dbehr@chromium.org>
Commit-Queue: Dominik Behr <dbehr@chromium.org>
Tested-by: Nicholas Bishop <nicholasbishop@google.com>
Auto-Submit: Nicholas Bishop <nicholasbishop@google.com>
2022-08-31 02:51:09 +00:00
Yiwei Zhang
9c34d76be0 Merge remote-tracking branch 'cros/main' into 'aosp/master'
Test: build
Change-Id: I281daffb82b7e959cadd1073b15b45f8f0ec7722
2022-07-25 18:32:51 +00:00
Jason Macnak
98d34a82b5 virtgpu_virgl: Allow BLOBs with SENSOR_DIRECT_DATA
BUG=b:238609372
TEST= vts -m VtsHalSensorsV2_1TargetTest

Change-Id: I33d9afb41fa546c97faffdbbd996a4d65a5ee156
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3774934
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: Jason Macnak <natsu@google.com>
Tested-by: Jason Macnak <natsu@google.com>
2022-07-23 06:27:03 +00:00
Yiwei Zhang
0495473b90 minigbm: deprecate drv_log to favor log level
TEST=build

Change-Id: I3f0021bfd05eb1ab7c3b35ae2f31d806bc0a58dc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3761446
Reviewed-by: Jason Macnak <natsu@google.com>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Auto-Submit: Yiwei Zhang <zzyiwei@chromium.org>
2022-07-19 04:16:15 +00:00
Yiwei Zhang
7b3cbeabbb drv/virtgpu: add log level for logging
Harmless initialization logging should be info instead of error.

TEST=build and check logcat
BUG=b:234143058

Change-Id: I41ff39b428feb85d01663eec74b3f826007337c1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3759415
Commit-Queue: Dominik Behr <dbehr@chromium.org>
Reviewed-by: Dominik Behr <dbehr@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Jason Macnak <natsu@google.com>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
2022-07-14 08:48:27 +00:00
Jason Macnak
c616c5faa0 Merge remote-tracking branch 'aosp/upstream-main' into 'aosp/master'
... to update Minigbm for Cuttlefish to pull in
https://crrev.com/c/3688450 to ensure TRANSFER_FROM_HOST copies happen
when `gralloc->lock()` is called on GPU_DATA_BUFFER usage buffers.

Bug: b/234513607
Test: launch_cvd --gpu_mode=guest_swiftshader
Test: launch_cvd --gpu_mode=gfxstream
Change-Id: I98cbc32a2418ffcf8b138084580e8a783bef7024
2022-06-06 09:48:11 -07:00
Jason Macnak
f08bb293f6 virtgpu_virgl: invalidate with BO_USE_GPU_DATA_BUFFER
... as the host may write to the buffer in a compute shader.

BUG=b:234513607
TEST=cts -m CtsNativeHardwareTestCases -t
     android.hardware.nativehardware.cts.AHardwareBufferNativeTests#Blob_BlobTest_GpuDataBufferCpuRead_BLOB

Change-Id: Ied49e7861e9ae0cbc9e25ecfb7feec30cc733864
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3688450
Tested-by: Jason Macnak <natsu@google.com>
Commit-Queue: Jason Macnak <natsu@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
2022-06-06 16:34:22 +00:00
Robert Tarasov
335711e592 minigbm/virgl: Add NV12 to texture formats
Add NV12 to the list of supported texture source formats for virgl.

Bug: 218708219
Test: run cts -m CtsNativeHardwareTestCases
Change-Id: I771551287400bc974530b273372c01e2645f8f52
2022-05-31 10:20:45 -07:00
Jason Macnak
bc51ff31d2 virtgpu_virgl: enable P010 for 3D mode
BUG=b:191084459
TEST=cvd start --gpu_mode=gfxstream
TEST=Camera2Video sample app
TEST=cts -m CtsCameraTestCases

Change-Id: I7b2c902298fed7d1ccab7c31eac8376b0077b718
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3579857
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Jason Macnak <natsu@google.com>
Commit-Queue: Jason Macnak <natsu@google.com>
2022-04-19 03:37:24 +00:00
Emilian Peev
f76db9871f virtgpu_virgl: Extend the supported P010 usage cases
Implementation defined camera outputs can enable
'BO_USE_TEXTURE' at the consumer side in cases where
the producer/camera overrides the pixel format to P010.

BUG=b:216308391
TEST=`atest RobustnessTest#testMandatory10BitStreamCombinations`

Change-Id: I21946cc7e4db14f207942ecce2c1cf8269790024
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3418596
Auto-Submit: Emilian Peev <epeev@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Emilian Peev <epeev@google.com>
Commit-Queue: Emilian Peev <epeev@google.com>
2022-01-28 21:49:20 +00:00