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>
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
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)
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
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>
... 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
This reverts commit b7a9a2b7d5.
Reason for revert: Crash resolved by Ieb07b5bbc206f07f69e4afba921149f49d6fe8c4
Bug: 349870098
Change-Id: I49848f6e7311c1f44e6c988cb42107ed79da3a6b
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
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>
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>
* 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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
... to pull in https://crrev.com/c/4018143 for Cuttlefish to remove
some logspam.
Bug: b/258516895
Test: cts -m CtsNativeHardwareTestCases
Change-Id: I605a76e5a518ae499671bb4b517e88f00b7b6292
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>
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>
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>
... 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
... 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>
Add NV12 to the list of supported texture source formats for virgl.
Bug: 218708219
Test: run cts -m CtsNativeHardwareTestCases
Change-Id: I771551287400bc974530b273372c01e2645f8f52
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>