Commit Graph

32 Commits

Author SHA1 Message Date
Yiwei Zhang b8ce8530a0 venus: remove workarounds for multi-planar format interop
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11282>
2021-06-16 20:31:32 +00:00
Yiwei Zhang 04e28356b4 venus: moves GPU rendering off CPU timeline for Android WSI
When globalFencing is supported, we can export a native sync fd for
presentation to move rendering off CPU timeline.

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11342>
2021-06-15 19:50:10 +00:00
Yiwei Zhang c7b405b39d venus: refactor vn_AcquireImageANDROID with globalFencing
This patch refactors to use vn_Import*FdKHR for Android WSI native sync
fence import when globalFencing is supported. Currently there's no perf
win from this, but will move the composer release fence waiting to the
GPU device side automatically when the entire Venus fencing support is
improved.

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11342>
2021-06-15 19:50:10 +00:00
Yiwei Zhang 5bc47c9cc2 venus: unify VkNativeBufferANDROID and AHardwareBuffer image create info
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11195>
2021-06-05 22:50:23 +00:00
Yiwei Zhang 3a894d00bc venus: refactor gralloc buffer and drm modifier properties query
1. Code clean up
2. Fixed a misused allocator
3. Add error logs for external memory interop

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11195>
2021-06-05 22:50:23 +00:00
Yiwei Zhang d08930f2fa venus: support AHB prop query with host dma_buf size
Upon instance creation, venus experimental features are cached in the
vn_instance. If memoryResourceAllocationSize feature is supported, chain
VkMemoryResourceAllocationSizeProperties100000MESA to the pNext of
VkMemoryResourcePropertiesMESA to get the host allocation size of the
dma_buf fd.

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11048>
2021-06-03 19:23:04 +00:00
Yiwei Zhang 5054f74ce1 venus: initial AHB support for multi-planar format
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11150>
2021-06-03 07:36:09 +00:00
Chia-I Wu a52f6b20b9 venus: undo wsi iamge ownership transfer for Android
This reverts most of commit 96ec6b3d8f.
It keeps vn_image::sharing_mode.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10709>
2021-06-03 06:03:31 +00:00
Chia-I Wu eed11c2778 venus: remember image wsi states
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10709>
2021-06-03 06:03:31 +00:00
Yiwei Zhang 60f513279c venus: fix mismatched bo mmap_size for export and multiple imports
Spec requires apps to use the size returned from
vkGetAndroidHardwareBufferPropertiesANDROID for AHB import, which
includes dedicated image/buffer import and non-dedicated buffer import.

Spec requires venus to use the size from image and buffer memory
requirement for dma_buf fd import if it's dedicated. If not dedicated,
the actual payload size should be used.

For AHB export allocation of VkImage, the app provided size will be 0,
and internally we must use the size from image memory requirement.

For AHB export allocation of VkBuffer, the app provided size comes from
buffer memory requirements and it can be smaller than the actual AHB
size due to page alignment. Internally that's the size we must use.

For AHB import, app must use the size from AHB prop query. Internally,
we have to override that with the size from memory requirement if the
import operation is dedicated to a VkImage or a VkBuffer. If not
dedicated, the actual payload size should be used.

The not working scenario is:
1. App creates an AHB backed VkBuffer, and the exported AHB size is
   larger than the buffer memory requirement (very common).
2. App imports the AHB without a dedicated VkBuffer. Then the entire
   AHB payload will be imported and the mmap_size might increase.

Test: dEQP-VK.api.external.memory.android_hardware_buffer.*

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11055>
2021-05-29 04:48:50 +00:00
Yiwei Zhang beb80858d8 venus: refactor for property query of dma_buf fd
With a TODO to route host storage size instead of that from the guest.

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11055>
2021-05-29 04:48:50 +00:00
Yiwei Zhang 1df4c960c6 venus: rename dmabuf to dma_buf when it represents a type
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11055>
2021-05-29 04:48:50 +00:00
Yiwei Zhang 47bf8be024 venus: support AHB external format for sampler YCbCr conversion
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10960>
2021-05-26 20:26:19 +00:00
Yiwei Zhang 78b30a0696 venus: implement vn_GetMemoryAndroidHardwareBufferANDROID
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10960>
2021-05-26 20:26:19 +00:00
Yiwei Zhang 7370f33953 venus: implement AHB allocation and import (part 2/2)
TODO left to fix plane count > 1 case for external memory.

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10960>
2021-05-26 20:26:19 +00:00
Yiwei Zhang 1743892f24 venus: implement AHB allocation and import (part 1/2)
This patch refactors the struct look up logic for memory allocation, and
it prepares the necessary info for ahb allocation and import.

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10960>
2021-05-26 20:26:19 +00:00
Yiwei Zhang 910c0602c4 venus: implement image creation for ahb handle type
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10960>
2021-05-26 20:26:18 +00:00
Yiwei Zhang 53e35f716e venus: fix AHB image format properties query
1. bail early if there's no compatiable AHB format
2. check against the corresponding drm format modifier

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10960>
2021-05-26 20:26:18 +00:00
Yiwei Zhang 7f52544f6f venus: fix vn_GetAndroidHardwareBufferPropertiesANDROID
Append a VK_FORMAT_FEATURE_MIDPOINT_CHROMA_SAMPLES_BIT bit to pass cts.

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10960>
2021-05-26 20:26:18 +00:00
Yiwei Zhang 8c06f018a4 venus: complete the format conversion between AHB and Vulkan
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10960>
2021-05-26 20:26:18 +00:00
Yiwei Zhang c82e836490 venus: tiny refactor of vn_android_get_gralloc_buffer_info
Return false if the queried drm format modifier is invalid.

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10960>
2021-05-26 20:26:18 +00:00
Yiwei Zhang 10a826e340 venus: vn_GetAndroidHardwareBufferPropertiesANDROID (part 2/2)
Support VkAndroidHardwareBufferFormatPropertiesANDROID query.

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10847>
2021-05-20 19:57:58 +00:00
Yiwei Zhang 58f518ce17 venus: vn_GetAndroidHardwareBufferPropertiesANDROID (part 1/2)
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10847>
2021-05-20 19:57:58 +00:00
Yiwei Zhang 008bcefb32 venus: add vn_android_get_ahb_usage helper function
See "AHardwareBuffer Usage Equivalence" in the spec.

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10847>
2021-05-20 19:57:58 +00:00
Yiwei Zhang 5cd04adb8a venus: add AHB format and VkFormat conversion helper functions
See "AHardwareBuffer Format Equivalence" in the spec.

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10847>
2021-05-20 19:57:58 +00:00
Yiwei Zhang 055ce78f31 venus: clean up vn_android api names
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10847>
2021-05-20 19:57:58 +00:00
Yiwei Zhang 0c94b3f55b venus: populate VK_ERROR_OUT_OF_HOST_MEMORY if applied
Fix dEQP-VK.wsi.android.swapchain.simulate_oom.* failures.

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10639>
2021-05-05 16:57:42 +00:00
Yiwei Zhang e44b4feb33 venus: query extended resource info from gralloc
Creating Android swapchain image from gralloc buffer requires to use
VkImageDrmFormatModifierExplicitCreateInfoEXT. To fill the struct info,
we need to query extended resource info from gralloc.

With the queried modifier from gralloc, we can ask the driver for the
plane count of the given format and modifier pair.

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10553>
2021-05-04 19:52:13 +00:00
Yiwei Zhang 96ec6b3d8f venus: handle wsi image queue ownership transfer for Android
1. pre-allocate command pools at device creation if anb enabled
2. force VK_SHARING_MODE_CONCURRENT for wsi image if necessary
3. pre-allocate and record command buffers at android wsi image creation
4. transfer in the ownership at vkAcquireImageANDROID
5. transfer out the ownership at vkQueueSignalReleaseImageANDROID

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10335>
2021-04-29 17:33:52 +00:00
Yiwei Zhang 95844b0978 venus: use VK_EXT_image_drm_format_modifier
This commit contains a hack to retrieve extended buffer info, which will
be fixed by moving the logic into gralloc HAL implementation.

With this hack, the rendering result is correct.

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10259>
2021-04-27 00:15:39 +00:00
Yiwei Zhang 34f37fb780 venus: implement VK_ANDROID_native_buffer v7
1. Android native buffer import
2. vkGetSwapchainGrallocUsage2ANDROID
3. vkAcquireImageANDROID
4. vkQueueSignalReleaseImageANDROID
5. not advertise shared presentable image support

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10259>
2021-04-27 00:15:39 +00:00
Yiwei Zhang 82bb90e072 venus: bring up Android support
1. implement hwvulkan_device_t
2. mask Android extension support

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10112>
2021-04-08 18:51:24 +00:00