Commit graph

49 commits

Author SHA1 Message Date
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-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
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
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
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
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
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
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
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
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
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
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
Jason Macnak
c06cc9cccb virtgpu_virgl: tighten max texture size on 2D path
... to that of SwiftShader + ANGLE (SwANGLE). With SwANGLE,
GL_MAX_TEXTURE_SIZE comes from a combination of
VkPhysicalDeviceLimits::maxFramebufferWidth and
VkPhysicalDeviceLimits::maxImageDimension2Dcomes  to meet GLES 3.1
requirements (see https://crrev.com/c/1917130).

BUG=b:194426249
TEST=`cts -m CtsNativeHardwareTestCases` with aosp/1845813

Change-Id: Ia14f241b59742c1bb864ef8f6e19de82bbe8fba4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3208931
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Jason Macnak <natsu@google.com>
Commit-Queue: Jason Macnak <natsu@google.com>
2021-10-07 03:40:48 +00:00
Yiwei Zhang
3a171db9be gralloc: move the logic to strip BO_USE_HW_VIDEO_ENCODER to the backends
BUG=b:199524294
TEST=CQ

Change-Id: I2b36a0ef17cd6ecb77723d4a9d95196ad27ff4ad
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3200148
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Jason Macnak <natsu@google.com>
Reviewed-by: Jason Macnak <natsu@google.com>
Reviewed-by: Chia-I Wu <olv@google.com>
2021-10-05 11:05:13 +00:00
Yiwei Zhang
b8ad7b88ca minigbm: refactor to add unified resolve_format_and_use_flags helper
It makes more sense to resovle the format and use_flags together to
avoid duplicates.

Add the helper to vc4 and dumb_driver backends since that's missed
from prior frontend refactoring.

Split the resolve helper in virtgpu_virgl for the 3d and 2d paths to
make code logic cleaner.

BUG=b:199524294
TEST=CQ

Change-Id: I89b633ea484f0fc5bb9b4e0548cad017b9970cc6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3200143
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Jason Macnak <natsu@google.com>
Reviewed-by: Chia-I Wu <olv@google.com>
Reviewed-by: Jason Macnak <natsu@google.com>
Reviewed-by: Dominik Behr <dbehr@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2021-10-05 03:43:18 +00:00
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)