Commit Graph

335 Commits

Author SHA1 Message Date
Chia-I Wu bfa245e0c1 venus: fix vn_instance_wait_roundtrip when seqno wraps
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14026>
2021-12-02 15:02:15 -08:00
Ryan Neph 996e855e66 venus: ignore framebuffer for VkCommandBuffer executed outside of render pass
The vulkan spec states[1]:
> If the VkCommandBuffer will not be executed within a render pass instance,
> or if the render pass instance was begun with vkCmdBeginRenderingKHR,
> renderPass, subpass, and framebuffer are ignored.

but venus will still try to encode them, resulting in a guest-side
assert or host-side command stream error.

[1]: https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkCommandBufferInheritanceInfo.html#_description

Signed-off-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13988>
2021-12-01 23:35:42 +00:00
Jason Ekstrand 4108fda426 vulkan: Move all the common object code to runtime/
Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13156>
2021-10-29 23:12:32 +00:00
Yiwei Zhang 65abd1d4ae venus: implement vn_buffer_cache_entries_create
1. advertise high hit rate cache combinations, and we should limit the
   caches to those only require device memory pool alloc
2. use size = 1 to ask for buffer memory requirements so that we do a
   sanity check on our assumption of returned size and alignment. For
   implementations don't meet our assumption, continue without cache.

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13428>
2021-10-28 00:23:14 +00:00
Yiwei Zhang af505ff3c8 venus: implement vn_buffer_cache_get_memory_requirements
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13428>
2021-10-28 00:23:14 +00:00
Yiwei Zhang a74f2495ca venus: implement vn_buffer_get_max_buffer_size
This change estimates the max_buffer_size with quick sort. Try to
avoid some traffic upon device creation time, but not worth adding a
buffer simple create api to avoid the extra requirement query traffic
since this is temporary.

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13428>
2021-10-28 00:23:14 +00:00
Yiwei Zhang 13f2e50aee venus: add buffer cache init and usage flows
1. struct vn_buffer_cache_entry for buffer memory requirements
2. struct vn_buffer_cache for all buffer related cached info
3. implement vn_buffer_cache_init
4. implement vn_buffer_cache_fini
5. empty vn_buffer_get_max_buffer_size
6. empty vn_buffer_cache_entries_create
7. implement vn_buffer_cache_entries_destroy
8. empty vn_buffer_cache_get_memory_requirements

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13428>
2021-10-28 00:23:14 +00:00
Yiwei Zhang fc237f80c6 venus: add struct vn_image_memory_requirements
This aligns with vn_buffer_memory_requirements and can potentially
simplify future image memory requirements cache init.

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13428>
2021-10-28 00:23:14 +00:00
Yiwei Zhang b108e096d1 venus: add struct vn_buffer_memory_requirements
This will simplify later buffer cache api.

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13428>
2021-10-28 00:23:14 +00:00
Yiwei Zhang 927dea7c34 venus: refactor the ahb buffer mem_type_bits query api
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13428>
2021-10-28 00:23:14 +00:00
Yiwei Zhang 34b7d820e2 venus: refactor to add vn_buffer_init
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13428>
2021-10-28 00:23:14 +00:00
Yiwei Zhang df93a8a6dd venus: refactor to add vn_device_init
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13428>
2021-10-28 00:23:14 +00:00
Yiwei Zhang 2a79dfb724 venus: release queues on device creation failure
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13428>
2021-10-28 00:23:14 +00:00
Yiwei Zhang 5a2513a515 venus: assign valid memoryTypeIndex of exportable ahb memory for image
The current AHB spec leaves the input memoryTypeIndex undefined when
allocating exportable AHB memory backing an external image.

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13537>
2021-10-28 00:02:54 +00:00
Yiwei Zhang 9fa702f28c venus: refactor private descriptor_set helpers to be private
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13522>
2021-10-27 18:33:11 +00:00
Jason Ekstrand 1f2ef68bab venus: Use the common WSI wrappers
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13234>
2021-10-13 00:06:15 +00:00
Jason Ekstrand 916c9335b4 meson: Add and use an idep for Vulkan WSI
Acked-by: Chia-I Wu <olvaffe@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13234>
2021-10-13 00:06:15 +00:00
Chia-I Wu 6df3973b61 venus: add atrace support
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13255>
2021-10-09 00:42:32 +00:00
Mike Blumenkrantz 7cc85dba71 build: unify vulkan cpp platform args
these were duplicated all over the place, and it's annoying to have to keep
duplicating them any time a new component includes the vulkan header

Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13141>
2021-10-06 14:19:35 +00:00
Chia-I Wu 443bf16782 venus: keep layouts of descriptor sets alive
We might reorder vkCmdBindDescriptorSets after
vkDestroyDescriptorSetLayout due to batching, which is likely invalid.
Keep the layouts alive with the sets to defer
vkDestroyDescriptorSetLayout.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13090>
2021-09-30 03:16:19 +00:00
Chia-I Wu e88c7191aa venus: add vn_refcount to vn_descriptor_set_layout
The reference count does not go beyond 1 yet.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13090>
2021-09-30 03:16:19 +00:00
Chia-I Wu 5337fb1e06 venus: add a helper to destroy vn_descriptor_set
Add vn_descriptor_set_destroy.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13090>
2021-09-30 03:16:19 +00:00
Chia-I Wu d7560a71a2 venus: convert bo and shmem to use vn_refcount
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13090>
2021-09-30 03:16:19 +00:00
Chia-I Wu 5cdbf75615 venus: add vn_refcount
Memory ordering is hard.  Add vn_refcount to take care of the details.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13090>
2021-09-30 03:16:19 +00:00
Chia-I Wu a3f2ffcc02 venus: copy VkPhysicalDeviceImageDrmFormatModifierInfoEXT
We should not drop VkPhysicalDeviceImageDrmFormatModifierInfoEXT when it
is provided.

Fixes dEQP-VK.drm_format_modifiers.export_import.*.

Fixes: efa185ed5c ("venus: rework external memory capability queries")
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/13094>
2021-09-29 22:41:01 +00:00
Yiwei Zhang 5a9f907d94 venus: properly check and fill ahb buffer properties
When it comes to AHB, pExternalBufferInfo->handleType is already
overridden to the renderer handle type. Thus the AHB buffer prop path is
not used. However, this is not caught by cts, vvl or apps because the
host renderer memory features so far satisfy the ahb requirement.

Fixes: ebf0e45506 ("venus: add ahb image and buffer properties query support")
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13076>
2021-09-28 20:41:40 +00:00
Chia-I Wu ca1622830e venus: separate physical device init and filter
It is not an error when a physical device is filtered out.  But it is an
error when a physical device fails to initialize.

Fixed
dEQP-VK.api.device_init.create_instance_device_intentional_alloc_fail.

v2: separate success and fail paths

Fixes: 7dfac808 ("venus: no supported device is not an error")
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org> (v1)
Reviewed-by: Ryan Neph <ryanneph@google.com> (v1)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12723>
2021-09-09 20:07:18 +00:00
Chia-I Wu e14bec2ef3 venus: refactor vn_instance_enumerate_physical_devices
Move device enumeration to a new function.

v2: separate success and fail paths, rename functions
    (suggested by Ryan)

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org> (v1)
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12723>
2021-09-09 20:07:18 +00:00
Chia-I Wu e38c58c808 venus: raise the ring buffer size to 64KB
When the renderer supports largeRing, raise the ring buffer size to 64KB
and raise the direct submit threshold to 4KB.  The numbers are randomly
picked.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12568>
2021-09-08 16:38:24 +00:00
Chia-I Wu c9eedba75d venus: make ring buffer size configurable
Until we can assume large ring support.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12568>
2021-09-08 16:38:24 +00:00
Chia-I Wu eb88c8e1d4 venus: rework vn_instance_submission
The goal is to remove local_cs_data.  To that end, vn_ring_submit is
modified to take a cs than a pointer.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12568>
2021-09-08 16:38:24 +00:00
Chia-I Wu 862244ccc6 venus: add and use VN_CS_ENCODER_INITIALIZER
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12568>
2021-09-08 16:38:24 +00:00
Chia-I Wu 0641a230a0 venus: init experimental features before the ring
We can no longer use
vn_call_vkGetVenusExperimentalFeatureData100000MESA which requires the
ring to be initialized.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12568>
2021-09-08 16:38:24 +00:00
Chia-I Wu e5a005dd0c venus: support reply shmem without ring
Let vn_instance_get_reply_shmem_locked use the renderer if it is called
before the ring is initialized.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12568>
2021-09-08 16:38:24 +00:00
Chia-I Wu 68eb682a23 venus: add vn_renderer_submit_simple_sync
It submits a command stream to the renderer and waits.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12568>
2021-09-08 16:38:24 +00:00
Chia-I Wu 2996c707cf venus: init roundtrip fields in vn_instance later
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12568>
2021-09-08 16:38:24 +00:00
Chia-I Wu 3bba38ab71 venus: reorder version fields in vn_instance
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12568>
2021-09-08 16:38:24 +00:00
Yiwei Zhang cc62fbed6d venus: suggest the proper sampler ycbcr model conversion based on format
Cc: 21.2.3 mesa-stable

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12694>
2021-09-02 18:09:04 +00:00
Yiwei Zhang 97aa90dec2 venus: workaround a blob_mem mappable size check issue
For blob_mem allocated from virtgpu_virgl backend, the guest mappable
size queried can be smaller than the size returned from image memory
requirement query from the host side. Here we temporarily workaround
until we switch to use cross-domain backend in minigbm.

Cc: 21.2.3 mesa-stable

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12687>
2021-09-01 22:38:48 +00:00
Yiwei Zhang cbdec34db3 venus: renderer to check map size only when mappable
Cc: 21.2.3 mesa-stable

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12687>
2021-09-01 22:38:48 +00:00
Chia-I Wu bd04ff972e venus: initialize physical devices once
Avoid re-enumeration when there is no device or no supported device.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12653>
2021-09-01 20:27:50 +00:00
Chia-I Wu 7dfac808b0 venus: no supported device is not an error
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12653>
2021-09-01 20:27:50 +00:00
Chia-I Wu fc74233363 venus: group physical device fields with a struct
This makes it clear what the mutex protects.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12653>
2021-09-01 20:27:50 +00:00
Yiwei Zhang 4a2adb36ae venus: set maxMipLevels to 1 for ahb images
Fixes: dEQP-VK.api.external.memory.android_hardware_buffer.image_formats.*

Cc: 21.2.2 mesa-stable

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12639>
2021-08-31 21:50:25 +00:00
Chia-I Wu 86cb30baaf venus: fix device group enumeration with unsupported devices
instance->physical_devices includes only supported devices, not all
devices.  One example is that it does not include 1.0 devices.  We need
to fix up VkPhysicalDeviceGroupProperties to exclude unsupported
devices.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12637>
2021-08-31 20:54:06 +00:00
Chia-I Wu a7ebcbbd6b venus: pre-initialize device groups
We don't need to worry about how vkEnumeratePhysicalDeviceGroups is
called (props is NULL, props is non-NULL but count is 0, etc.) this way.
It also allows us to fix up VkPhysicalDeviceGroupProperties easily.

v2: let the for-loop increment (Yiwei)

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org> (v1)
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12637>
2021-08-31 20:54:06 +00:00
Chia-I Wu e2020484eb venus: minor cleanup to physical device init loop
v2: let the for-loop increment (Yiwei)

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org> (v1)
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12637>
2021-08-31 20:54:06 +00:00
Yiwei Zhang 3538b5af6d venus: conditionally enable async descriptor set allocation
When VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT is not used to
create the pool, set allocation is guaranteed to not return
VK_ERROR_FRAGMENTED_POOL, and we can safely move set allocation to async
after doing resource tracking in the driver.

Enable after fully tested with assert(false) in the failure case.

Tested with:
- dEQP-VK.api.descriptor*
- dEQP-VK.api.object_management.*
- dEQP-VK.binding_model.descriptor*
- dEQP-VK.descriptor_indexing.*

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12501>
2021-08-26 17:56:19 +00:00
Yiwei Zhang 288ce1b033 venus: check descriptor allocations against pool resource
Only kick in when async_set_allocation is enabled.

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12501>
2021-08-26 17:56:19 +00:00
Yiwei Zhang 70b03e96f9 venus: descriptor set to track descriptor count of last binding
Track the descriptor count to be used instead of the variable descriptor
count to avoid duplicate checks in later accounting.

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12501>
2021-08-26 17:56:19 +00:00
Yiwei Zhang a1e91b1163 venus: descriptor pool to track pool state
It also tracks whether async set allocation is enabled.

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12501>
2021-08-26 17:56:19 +00:00
Yiwei Zhang d2b1a7c2bb venus: layout to track variable descriptor count binding info
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12501>
2021-08-26 17:56:19 +00:00
Yiwei Zhang d8e89b4e33 venus: descriptor layout to track more binding infos
Rename existing max_binding to last_binding to be consistent.

1. layout to track last binding index
2. binding to track descriptor type
3. binding to track descriptor count

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12501>
2021-08-26 17:56:19 +00:00
Yiwei Zhang ad934eb680 venus: add vn_descriptor_set_layout_init
Just a refactoring without functional changes.

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12501>
2021-08-26 17:56:19 +00:00
Yiwei Zhang d4878636fe venus: refactor failure path for sets allocation
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12501>
2021-08-26 17:56:19 +00:00
Chia-I Wu 572ed22494 venus: use uint32_t in vn_ring_submit
And in vn_ring_write_buffer as well, to fix the assert in
vn_ring_write_buffer.

The ring code uses 32-bit unsigned integers and relies on that their
overflow/underflow behavior is well-defined.  When ring->shared.head is
about to overflow and ring->cur has overflowed, this expression

  ring->cur + size - vn_ring_load_head(ring)

gives an incorrect result when size is 64-bit.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12494>
2021-08-24 08:56:16 -07:00
Yiwei Zhang e9be86adda venus: scrub ignored fields of pipeline info when rasterization is disable
v2: use vk_alloc instead of vk_zalloc because of full memcpy

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com> (v1)
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12499>
2021-08-23 20:00:58 +00:00
Yiwei Zhang b816167312 venus: fix all missing vn_object_base_fini
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12498>
2021-08-23 18:51:38 +00:00
Chia-I Wu da000ea2ef venus: free queues after vkDestroyDevice is emitted
Otherwise, another thread might reuse their object ids for other
objects.  For example,

  T1: free queue with object id X
  T2: reuse id X
  T2: emit vkCreateFoo with id X
  T1: emit vkDestroyDevice

virglrenderer happily accepts that which leads to double frees of the
queue: once when X is updated to point to another object and once when
vkDestroyDevice is executed.  virglrenderer should be fixed to catch
such invalid object id reuse as well.

Fixes
dEQP-VK.api.object_management.multithreaded_shared_resources.device_group.

Fixes: ddd7533055 ("venus: initial support for queue/fence/semaphore")
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12252>
2021-08-06 19:48:49 +00:00
Rob Clark 6edf0d8e90 driconfig: Add support for device specific config
Add support for driconf overrides on a per-device level, for cases
where we don't want to override behavior for all devices supported
by a particular driver.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12135>
2021-08-02 16:37:24 -07:00
Chia-I Wu a753f50668 venus: break up vn_device.c
Break it up into vn_{device,instance,physical_device}.c.  Suggested by
Ryan Neph.

vn_EnumerateDeviceExtensionProperties and
vn_EnumerateDeviceLayerProperties were previously said to be device
commands.  But in this commit, we move them to vn_physical_device.c
instead.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12144>
2021-08-02 22:45:45 +00:00
Chia-I Wu 22cb100ea0 venus: break up vn_device.h
Break it up into vn_{device,instance,physical_device}.h.  Suggested by
Ryan Neph.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12144>
2021-08-02 22:45:45 +00:00
Yiwei Zhang e08960482a venus: cache ahb backed buffer memory type bits requirement
To properly init buffer memory requirement for AHB, memory type bits
from dma_buf fd properties need to be masked. However, creating a test
AHB at buffer creation is too costy. This patch caches the ahb backed
buffer memory type bits at device creation time if the app is requesting
AHB extension.

Cc: 21.2 mesa-stable

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/12171>
2021-08-02 17:03:06 +00:00
Chia-I Wu a94192f69d venus: print warnings when stuck in busy waits
The first warning is printed after stuck in vn_relax for at least about
3.5s.  The actual time can be much longer depending on the
kernel/load/hw.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12115>
2021-07-28 22:50:36 +00:00
Chia-I Wu 71912de1d2 venus: log more WSI messages
They can be useful before resorting to gdb or perfetto.

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/12073>
2021-07-27 06:21:47 +00:00
Chia-I Wu 567bbfd56b venus: suballocate memory in more cases
When a dedicated allocation is not required, ignore it and suballocate.

Fixes dEQP-VK.api.invariance.random.

Cc: 21.2 mesa-stable
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/12072>
2021-07-27 03:53:52 +00:00
Chia-I Wu f06b0df741 venus: clean up vn_AllocateMemory
Mainly to add vn_device_memory_should_suballocate.

Cc: 21.2 mesa-stable
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/12072>
2021-07-27 03:53:52 +00:00
Chia-I Wu bd9550b026 vulkan/wsi: replace prime_blit_buffer by a bool
venus only needs to know if a WSI image is a prime blit source.  In an
upcoming swapchain image rework, the prime blit destination is unknown
when the WSI image is created.  Replace prime_blit_buffer by a bool.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12046>
2021-07-23 15:31:20 -07:00
Chia-I Wu 12d18abfe7 venus: refactor vn_EndCommandBuffer
Add vn_cmd_submit as a wrapper to vn_instance_ring_submit.  It is also
designed such that it can be called from any of the vn_Cmd* functions.

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/11896>
2021-07-15 00:52:43 +00:00
Marek Olšák 6ede24cf31 util/idalloc: fold the size call into init
It's required, otherwise idalloc would fail.

v2: renamed util_idalloc_(mt_)init param initial_num_ids  (Pierre-Eric)

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> (v1)
Reviewed-by: Marek Olšák <marek.olsak@amd.com> (v2)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11493>
2021-07-09 10:05:46 +00:00
Chia-I Wu d0fa4933b7 venus: fix empty submits with BOs
Empty submits with BOs (!batch_count && bo_count) were incorrectly
skipped.

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/11791>
2021-07-08 21:51:23 +00:00
Yiwei Zhang 73c71a37f4 venus: fix AHB VkBuffer memory requirement
Layering AHB on top of dma_buf_fd requires venus to combine the memory
type bits internally for VkBuffer.

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/11661>
2021-07-01 03:42:24 +00:00
Yiwei Zhang 4f2b98dc40 venus: handle ahb backed VkBuffer creation properly
Venus needs to override the external handle type from AHB to dma buf.

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/11661>
2021-07-01 03:42:24 +00:00
Yiwei Zhang 3527146a26 venus: prepare vn_CreateBuffer for AHB
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/11661>
2021-07-01 03:42:24 +00:00
Yiwei Zhang 0ea726b5fd venus: add more logs for Android WSI debugging
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/11661>
2021-07-01 03:42:24 +00:00
Yiwei Zhang 58a4ae3b99 venus: resolve AHB external format with DRM format
AHardwareBuffer_Format is lossier than DRM_FORMAT_*, which ends up with
unable to resolve implementation defined format upon creating sampler
ycbcr conversion. So we now use DRM format as AHB external format.

An external format error return in vkCreateSamplerYcbcrConversion is
also removed here since that is already an invalid usage per spec
(partly because there is no proper error code to return here).

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/11480>
2021-06-28 22:18:19 +00:00
Yiwei Zhang 0679cffb02 venus: remove unsupported AHB formats
Likely not going to support them either.

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/11480>
2021-06-28 22:18:19 +00:00
Yiwei Zhang 891cf98a88 venus: use the mesa "drm-uapi/drm_fourcc.h" header
Prepare for later CI integration.

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/11480>
2021-06-28 22:18:19 +00:00
Yiwei Zhang 8391fb98cd venus: properly support GPU_DATA_BUFFER for AHB
CrOS gralloc was missing support for GPU_DATA_BUFFER, which was only
fixed until recently. Now we can allcate properly.

This patch also removes a redundant TODO regarding image format list
support for AHB. vkGetPhysicalDeviceImageFormatProperties2 has already
checked the support for such though it only checks whether the optimal
tiling and the associated drm format modifier for the AHB image format
itself applies to the entire format list or not. Given the use case for
such combination is quite limited, we choose not to add new gralloc
support to force linear modifier as a fallback for wider coverage.

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/11501>
2021-06-28 21:13:54 +00:00
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 ac27493824 venus: add debug info for experimental features during init
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/11387>
2021-06-15 21:25:28 +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 d249cff1e7 venus: silence a build warning
Address -Wsometimes-uninitialized

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
Chia-I Wu 17375c5d2d venus: be verbose about which physical devices are skipped
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/11369>
2021-06-15 18:20:41 +00:00
Chia-I Wu c496dc1120 venus: fix compatibility with older host drivers
Unlike on Android, KHR_swapchain may be advertised even when the host
driver does not support EXT_image_drm_format_modifier and
EXT_queue_family_foreign.  Do not request those extensions when they are
not supported.

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/11369>
2021-06-15 18:20:41 +00:00
Chia-I Wu 84ec64c4e4 venus: clean up vn_physical_device_get_native_extensions
Separate Android and non-Android paths.  No real change.

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/11369>
2021-06-15 18:20:41 +00:00
Chia-I Wu 5e4ff4ef1f venus: add support for external semaphores on Android
This is a hack.

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/11253>
2021-06-11 23:44:45 +00:00
Chia-I Wu e2ac01aaac venus: add support for external fence on Android
This is a hack.

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/11253>
2021-06-11 23:44:45 +00:00
Chia-I Wu 823d889b21 venus: simplify vn_renderer_sync creation
Remove the ability to init/release repeatedly.

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/11253>
2021-06-11 23:44:45 +00:00
Chia-I Wu 517828784c venus: move vn_renderer_sync_ops to vn_renderer
To follow vn_renderer_{shmem,bo}_ops.

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/11253>
2021-06-11 23:44:45 +00:00
Yiwei Zhang 93f67055c4 venus: forward the host renderer hardware info
Some game engines rely on the real hardware info to adjust default
graphics quality and other attributes.

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/11175>
2021-06-07 23:54:52 +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
Chia-I Wu ae4ef6491d venus: query experimental features in one call
It is simpler.  But I mainly want to work around

../src/virtio/vulkan/vn_cs.h:173:4: error: argument 1 null where non-null expected [-Werror=nonnull]
  173 |    memcpy(val, dec->cur, val_size);

We trust virglrenderer and it never instructs the decoder to memcpy to
pData when it is NULL.  The compiler does not know however.  A proper
fix will be to generate

  if (!pData)
    unreachable();

to help the compiler.

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/11174>
2021-06-03 13:39:27 -07: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
Chia-I Wu 551d7032df venus: silence compiler warnings
Silence warnings in release builds.

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/11166>
2021-06-03 17:48:30 +00:00
Chia-I Wu 736e24bdce venus: use vk_default_allocator
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4870
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Acked-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11117>
2021-06-03 08:13:27 +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 889a8df5bd venus: enable wsi image ownership transfer for common wsi
v2: this is split out from the last commit

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org> (v1)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10709>
2021-06-03 06:03:31 +00:00
Chia-I Wu 676abf12dc venus: reland wsi image ownership transfer for Android
This takes a different approach.  It turns out we can patch
vkCmd{Begin,End}RenderPass, vkCmdWaitEvents, and vkCmdPipelineBarrier to
do queue family ownership transfers without tracking image ownerships.

v2: check the value of VN_PRESENT_SRC_INTERNAL_LAYOUT and keep this
    Android-only

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org> (v1)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10709>
2021-06-03 06:03:31 +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 93abaf6fe8 venus: clean up vn_get_intercepted_barriers
Add vn_cmd_{wait_events,pipeline_barrier}_fix_image_memory_barries to
replace vn_get_intercepted_barriers.  The two new functions are
identical currently, but that will change soon.

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 7ec6cb61ad venus: add vn_cmd_get_image_memory_barriers
And call it regardless of ANDROID or not.

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 142e452e9a venus: add vn_image_memory_barrier_has_present_src
And call it regardless of ANDROID or not.

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 fb6fc24771 venus: remember cmd buffer fb attachments
We need them for wsi queue ownership transfer.

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 ccf85f6604 venus: remember cmd buffer render pass and framebuffer
We need them for wsi queue ownership transfer.

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 c85aa41046 venus: remember framebuffer attachments
We need them for wsi queue ownership transfer.

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 65e4bfe7ab venus: remember image view image
We need that for wsi queue ownership transfer.

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 cef50d08e9 venus: remember render pass PRESENT_SRC barriers
We need them for wsi queue ownership transfer.

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 9fe833dfd9 venus: remember render pass PRESENT_SRC attachments
We need them for wsi queue ownership transfer.

v2: make VN_PRESENT_SRC_INTERNAL_LAYOUT public

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org> (v1)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10709>
2021-06-03 06:03:31 +00:00
Chia-I Wu 6661e47b59 venus: handle VN_COMMAND_BUFFER_STATE_INVALID
If the state was set to VN_COMMAND_BUFFER_STATE_INVALID, return
VK_ERROR_OUT_OF_HOST_MEMORY in vn_EndCommandBuffer.

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
Chia-I Wu f42f3ac1f7 venus: move wsi_image_create_info parsing
Move it from vn_CreateImage to vn_wsi_create_image.

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 9814cd8153 venus: fix opaque fd re-import
dEQP-VK.api.external.memory.opaque_fd.* re-imports and fails because
external_handles was VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT on
allocation and is VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT on
re-import.

Fixes: ccefcb0baf ("venus: fix misaligned bo_flags between import and query")
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/11154>
2021-06-03 05:53:24 +00:00
Chia-I Wu 4bd7a3829e venus: fix asserts on mem bo
They failed to check the result before asserting.

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/11154>
2021-06-03 05:53:24 +00:00
Chia-I Wu 67ad9f7580 venus: add vn_device_memory_alloc as a helper
It is used for the most common case (non-ahb, non-import, and
non-suballocate).

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/11154>
2021-06-03 05:53:24 +00:00
Chia-I Wu 447e80ac9b vulkan/wsi: provide more info in wsi_image_create_info
Always chain wsi_image_create_info to VkImageCreateInfo, which indicates
that the image is a wsi image and can be transitioned to/from
VK_IMAGE_LAYOUT_PRESENT_SRC_KHR.

Add prime_blit_buffer to the struct as well.  When set, it indicates the
prime blit destination and implies that the image is a prime blit
source.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10789>
2021-06-03 04:24:55 +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 ccefcb0baf venus: fix misaligned bo_flags between import and query
For importing an dma_buf fd, export info is not required. Leaving the
bo_flags missing VIRTGPU_BLOB_FLAG_USE_SHAREABLE bit as well as the
VIRTGPU_BLOB_FLAG_USE_CROSS_DEVICE bit. Upon querying fd properties,
DMA_BUF handle type will be specified which generates a new bo_flags
not matching the prior one.

This patch aligns the above 2 bits for the dma_buf import path.

Test: vkGetAndroidHardwareBufferPropertiesANDROID should succeed with
      a valid AHB with AHARDWAREBUFFER_FORMAT_BLOB 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/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
Chia-I Wu 1d2a33c705 venus: ignore pInheritanceInfo when we should
pInheritanceInfo should be ignored when the command buffer is primary.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4850
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/11067>
2021-05-28 23:09:22 +00:00
Chia-I Wu f7001f7a2d venus: remember cmd buffer level and queue family
We need them for wsi queue ownership transfer and others.

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/11067>
2021-05-28 23:09:22 +00:00
Chia-I Wu fb549d21d8 venus: add struct vn_command_buffer_builder
We are going to remember more 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/11067>
2021-05-28 23:09:22 +00:00
Yiwei Zhang 7adb9c42e0 venus: advertise VK_ANDROID_external_memory_android_hardware_buffer
Besides advertising AHB support, for Android, we do not advertise
KHR_external_memory_fd, EXT_external_memory_dma_buf or
EXT_image_drm_format_modifier so that AHB remains the sole channel for
external resource sharing.

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 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 4958ce582c venus: refactor device memory fd import
This patch wraps up fd import logic, which will be used later by ahb
import. This patch also removes a redundant check in need_bo.

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 19b7b09885 venus: prepare image creation helpers for AHB
Store image create info for deferred creation of AHB image.

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 ebf0e45506 venus: add ahb image and buffer properties query 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/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 d661e32bfb venus: stop advertising KHR_driver_properties for Android
This is to pass the Android cts requirement. We will re-advertise the
extension after venus has a valid driver id defined.

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/10819>
2021-05-17 04:44:01 +00:00
Yiwei Zhang a49346979a venus: fix vkEnumeratePhysicalDeviceGroups
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/10819>
2021-05-17 04:44:01 +00:00
Joshua Ashton 6fcf3314d0 venus: Fix zero-initialized fd causing apps to hang/crash
Some apps such as Gamescope crash under the mere presence of the virtio Vulkan driver without using a device.

This is because virtgpu::fd is zero-initialized upon allocation, which causes fd 0 to be closed in virtgpu_destroy.

Cc: mesa-stable
Fixes: 247232d5 ("venus: add experimental renderers")
Signed-off-by: Joshua Ashton <joshua@froggi.es>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10814>
2021-05-16 01:47:01 +00:00
Chia-I Wu 77d959814c venus: get rid of #ifdef's in vn_CreateImage
No real change after compiler optimizations.

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/10779>
2021-05-12 22:37:05 +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
Chia-I Wu 390722620e venus: clean up vn_device_fix_create_info
The extension list should be more correct now.

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/10556>
2021-05-03 20:51:46 +00:00