Commit graph

916 commits

Author SHA1 Message Date
Eric Engestrom
bb0791535a vn: enable VK_EXT_headless_surface on all platforms except Windows
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27448>
2024-02-06 20:32:38 +00:00
Juston Li
e48645250c venus: image format properties cache
Cache for vkGetPhysicalDeviceImageFormatProperties2 as it is observed
to be called repeatedly with zink/proton layers.

Cache design is the same as the image requirements cache, generating
a hash key from pImageFormatInfo and storing pImageFormatProperties
into a hash table.

There are a couple differences though:
- VkResult gets cached when the query returns NOT_SUPPORTED.
- Unlike pMemoryRequirements that returns VkMemoryRequirements2 and
possibly VkMemoryDedicatedRequirements, VkImageFormatProperties2
has various pNext chains that can be optionally passed in. Hash
the existence of these pNext so that they are considered different
queries and the underlying pNext struct can be optionally cached.
The alternative would be to modify the query to always chain these
pNext so all of them would be cached, but it is unlikely for queries
to only differ in pNext chains.

Signed-off-by: Juston Li <justonli@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27401>
2024-02-06 00:26:45 +00:00
Juston Li
680c912977 venus: extract cache hash/equals functions into common
drop the unnecessary casting in the equals function as well

Signed-off-by: Juston Li <justonli@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27401>
2024-02-06 00:26:45 +00:00
Juston Li
f3de6f17c1 venus: fix image reqs cache store locking
lock the entire scope when storing image reqs cache entry to prevent
entry being added between the split locks.

Fixes: b51ff22fbe ("venus: support caching image memory requirements")

Signed-off-by: Juston Li <justonli@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27401>
2024-02-06 00:26:44 +00:00
Yiwei Zhang
d32d010c24 venus: update tracepoints to align with later optimizations
We can remove redundant TPs no longer needed while updating and adding
some trivial ones helpful for next things.

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27450>
2024-02-03 00:35:39 +00:00
Yiwei Zhang
f245339120 venus: refactor to use DETECT_OS_ANDROID instead of ANDROID
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Acked-by: Yonggang Luo <luoyonggang@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27374>
2024-02-01 19:29:49 +00:00
Yiwei Zhang
5fbb00dbc7 venus: use obj handle instead of id in device memory report
Now the id is separately assigned in venus, while the test expects
handle.

Fixes: 7f9381782f ("venus: ensure object id is unique")
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27285>
2024-01-31 02:58:57 +00:00
Yiwei Zhang
1718980e85 venus: force async pipeline create on threads creating descriptor pools
This works around some Unity engine behaivor with ANGLE-on-Venus, when
cmd pools are created on main thread once while the render thread only
does descriptor pool creation for set allocations during recording time.

This change also explicitly forces async pipeline create for threads
creating the device instead of implicitly via feedback cmd pool create.
This ensures intended behavior when feedback is disabled.

Fixes: d17ddcc847 ("venus: dispatch background shader tasks to secondary ring")
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27347>
2024-01-30 23:50:47 +00:00
Daniel Schürmann
26c8f13ff5 vulkan: enable VK_KHR_shader_expect_assume
This implementation ignores the hints.

Acked-by: Caio Oliveira <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27265>
2024-01-30 19:09:42 +00:00
Collabora's Gfx CI Team
1c29869c20 Uprev Piglit to e9316bcd12544aaf7e753ce37fe50d64165d9598
f7db20b03d...e9316bcd12

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25449>
2024-01-29 18:27:07 +00:00
Gert Wollny
b9fea5ea6b virgl: Use better reporting for mirror_clamp features
Fixes: 9efe50c83b
    virgl: report MIRROR_CLAMP features better

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27106>
2024-01-29 09:01:26 +00:00
Juston Li
305256e344 venus: handle empty resolved query feedback list
On the off chance the combined list resolves to empty due to resets,
skip adding query feedback by not increasing the total cmd buffer
count for query feedback.

Signed-off-by: Juston Li <justonli@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27163>
2024-01-26 23:40:52 +00:00
Juston Li
df1cd20096 venus: recycle linked query feedback immediately during submission
Instead of just recyling 1 linked query feedback cmd for use and
defering the actualy recycle, recycle all linked cmds found when
setting up submission immediately.

Signed-off-by: Juston Li <justonli@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27163>
2024-01-26 23:40:52 +00:00
Juston Li
decc5d4539 venus: add comments for query feedback batch free list
Signed-off-by: Juston Li <justonli@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27163>
2024-01-26 23:40:52 +00:00
Juston Li
e2c4bafccc venus: free query batches for VK_COMMAND_POOL_RESET_RELEASE_RESOURCES_BIT
When a pool is reset with VK_COMMAND_POOL_RESET_RELEASE_RESOURCES_BIT,
free up all query batches in the pool.

Signed-off-by: Juston Li <justonli@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27163>
2024-01-26 23:40:52 +00:00
Juston Li
aceda1f5f6 venus: acquire mutex when recycling query feedback cmds
Fixes: 5b24ab91e4 ("venus: switch to unconditionally deferred query feedback")

Signed-off-by: Juston Li <justonli@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27163>
2024-01-26 23:40:52 +00:00
Juston Li
c3417c5bb8 venus: refactor query feedback cmds
The list free_query_feedback_cmds for recycling query feedback cmds was
only used in vn_command_pool when it was a vn_feedback_cmd_pool.

For clarity, refactor and store this list in vn_feedback_cmd_pool
instead and introduce a new struct vn_query_feedback_cmd that references
the feedback cmd and the feedback cmd pool for tracking.

Refactor out the allocation portion of query feedback cmds into its own
function for allocating the new vn_query_feedback_cmd struct.

Fixes: 5b24ab91e4 ("venus: switch to unconditionally deferred query feedback")

Signed-off-by: Juston Li <justonli@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27163>
2024-01-26 23:40:52 +00:00
Yiwei Zhang
42fc83a6e3 venus: default to enable GPL
Update the debug option to NO_GPL to help with runtime debug, and
default to enable GPL.

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27054>
2024-01-23 01:33:09 +00:00
Yiwei Zhang
85df907ad8 venus: allow tls ring submission to utilize the entire ring shmem
Ring submissions on tls ring are synchronous and single threaded, thus
without perf degradation, a single cmd can use the entire ring shmem.

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27054>
2024-01-23 01:33:09 +00:00
Yiwei Zhang
80a5df16fe venus: fix to respect the final pipeline layout
This fixes VUID-vkCmdDraw-None-08600 violation when running gpl cts:
dEQP-VK...graphics_library.misc.bind_null_descriptor_set.*, where the
final pipeline layout is falsely dropped, leading to incompatible with
the pipeline layout of the bound descriptor set.

Fixes: a65ac274ac ("venus: Do pipeline fixes for VK_EXT_graphics_pipeline_library")
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27054>
2024-01-23 01:33:09 +00:00
Yiwei Zhang
f713b17a16 venus: fix pipeline derivatives
This was unexpected dropped in the initial GPL impl.

Fixes: a65ac274ac ("venus: Do pipeline fixes for VK_EXT_graphics_pipeline_library")
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27054>
2024-01-23 01:33:09 +00:00
Yiwei Zhang
f256e8171c venus: drop some redundant comment
The render pass (legacy or dynamic) can be ignored only in a pipeline
library with just Vertex Input State. For other cases, even when raster
has been discarded, it is still needed at the api level to avoid
violating a bunch of VUs which validate against attachments. The legacy
pass byitself is also necessary to tell whether it's legacy or dynamic.
So venus implemented at the VK api level should not drop render pass in
those cases.

The layout to be ref'ed is the one to be used, so we don't care about
those being ignored, which has already been removed in the pipeline info
fix.

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27054>
2024-01-23 01:33:09 +00:00
Yiwei Zhang
b551b6e48a venus: fix pipeline layout lifetime
Should check the count instead of random ptr addr.

Fixes: 19f2b9d0bb ("venus: extend VkPipelineLayout lifetime for ...")
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27054>
2024-01-23 01:33:09 +00:00
Yiwei Zhang
7f9381782f venus: ensure object id is unique
Currently driver side heap alloc obj ptr is used as object id, which is
used on the renderer side for actual vk obj mapping. However, this adds
an implicit dependency between any driver obj destroy/free and new obj
create/allocate because the heap obj freed up can be immediately
reallocated out.

With venus moving to multi-ring, the ordering between asynchronous obj
destroy/free and new obj create/allocate has to be guaranteed via driver
side non-primary ring submission always waiting for primary ring idle.
This can defeat the purpose of multi-ring in certain scenarios. So this
change adds a way to assign unique id to object.

Even before multi-ring, the unique object id can make device and queue
object alloc/free more robust without hidden ordering requirements. This
also fixes some oom cts which can intentionally fail the submission of
an object destroy (renderer side obj is still present) while the driver
side freed object ptr being reused for another object creating, causing
object id reuse at renderer side object table.

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27083>
2024-01-18 01:13:59 +00:00
Ryan Neph
6e4bb8253e venus: fix shmem leak on vn_ring_destroy
Missed shmem unref when moving ring internals out of vn_instance.c.

Fixes: d1e29b7557 ("venus: move ring shmem into vn_ring")
Signed-off-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27125>
2024-01-17 21:44:15 +00:00
Yiwei Zhang
ecd50e70d4 venus: populate oom from ring submit alloc failures
ring_seqno_valid indicates a successful ring cmd submission, and can be
used to avoid invalid reply decoding due to failed submit alloc.
Otherwise, the garbled VkResult will mislead into initialization failure
instead of oom.

Below cts failure is fixed:
dEQP-VK.api.device_init.create_instance_device_intentional_alloc_fail.basic

Fixes: ec131c6e55 ("venus: use instance allocator for ring allocs")
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27026>
2024-01-12 19:56:34 +00:00
Yiwei Zhang
12d428bc68 venus: avoid redundant layout transition for optimal internal layout
This ensures no extra barriers when internal layout is wsi layout.

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27020>
2024-01-12 19:34:56 +00:00
Dmitry Osipenko
b9ad22d24e virtio/vdrm: Fix lockup in vdrm_host_sync()
The vdrm_execbuf() missed to set the seqno field for requests sent to host.
This causes vdrm_host_sync() to lock up due to the unset seqno in a case
where two or more threads are using vdrm_execbuf() and vdrm_send_req()
concurrently, like in this scenario:

	thread1: vdrm_send_req()  shmem->seqno=1 req->seqno=2
	thread2: vdrm_execbuf()   shmem->seqno=1 req->seqno=0
	thread1: vdrm_host_sync() shmem->seqno=0 req->seqno=2

Fix the lockup by setting the seqno in vdrm_execbuf().

Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27021>
2024-01-12 16:53:59 +00:00
Yiwei Zhang
0b0c0511b8 venus: allow to retrieve pipeline cache on TLS ring
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26838>
2024-01-11 06:05:01 +00:00
Yiwei Zhang
bec287b2a2 venus: clean up secondary ring
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26838>
2024-01-11 06:05:01 +00:00
Yiwei Zhang
945165acad venus: TLS ring
This change adds a new venus feature: TLS ring
- co-owned by TLS and VkInstance
- initialized in TLS upon requested
- teardown happens upon thread exit or instance destroy
- teardown is split into 2 stages:
  1. one owner locks and destroys the ring and mark destroyed
  2. the other owner locks and frees up the tls ring storage

TLS ring supercedes the prior secondary ring and enables multi-thread
shader compilation and reduces the loading time of ROTTR from ~110s to
~21s (native is ~19s).

TLS ring is in fact a synchronous ring by design, and can be used to
redirect all exisiting synchronous submissions trivially. e.g. upon any
vn_call_*, request a TLS ring, wait for deps and then submit.

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26838>
2024-01-11 06:05:01 +00:00
Yiwei Zhang
30316246d0 venus: make tls hint specific to pipeline creation
This is to prepare for a new multi-ring design. A preview is as below:
- primary ring will migrate to be asynchronous only
- synchronous commands will be via thread local rings
- pipeline creations will be synchronous and dispatched to thread local
  rings unless being forced to be async on primary ring
- perf option no_multi_ring is made generic to force a single ring

Pipeline cache retrieval is temporarily moved back to primary ring, but
will be moved to thread local later since it's a synchronous command.
The dependency resolving will follow the same with pipeline create with
detailed rationale later.

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26838>
2024-01-11 06:05:01 +00:00
Juston Li
813b1939f6 venus: add LRU cache eviction for image mem reqs cache
Signed-off-by: Juston Li <justonli@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26118>
2024-01-11 01:40:06 +00:00
Juston Li
b51ff22fbe venus: support caching image memory requirements
Similar idea to buffer memory requirements cache but CreateImage has
many more params that may affect the memory requirements.

Instead of a sparse array, generate a SHA1 hash of all the relevant
VkImageCreateInfo params including relevant pNext structures and use
part of the hash as a key to a hash table that stores the cache entries.

Signed-off-by: Juston Li <justonli@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26118>
2024-01-11 01:40:06 +00:00
Juston Li
a32d76b545 venus: use vk_format helper for plane count
Signed-off-by: Juston Li <justonli@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26118>
2024-01-11 01:40:06 +00:00
Juston Li
cb12a22264 venus: rename buffer cache to buffer reqs cache
Be more explicit in the name that it caches buffer memory requirements.

Signed-off-by: Juston Li <justonli@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26118>
2024-01-11 01:40:06 +00:00
Corentin Noël
b8e06fa48a virgl: Only send the same amount of data than declared in pipe_sampler_state
Adjust the masks to only send the data that we are sure to actually use.

Signed-off-by: Corentin Noël <corentin.noel@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26856>
2024-01-04 11:00:12 +00:00
VladimirTechMan
407fd1e1d7 venus/android: Switch to using u_gralloc
That enables testing and development of the Venus-based Vulkan HAL
on a wider range of Android systems - flavors of "Cuttlefish" are
of particular practical interest. At this point, only two gralloc
variants are supported: CrOS and IMapper v4. The fallback gralloc
and any gralloc adapter modules relying on it (GBM, QCOM) are out
of scope for Android Vulkan HAL now.

Signed-off-by: VladimirTechMan <VladimirTechMan@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26858>
2024-01-04 01:35:13 +00:00
Yiwei Zhang
68a9b3cc6f venus: properly ignore formats in VkPipelineRenderingCreateInfo
also remove a redundant trace point and adjust the position for another
to better tell whether fixes have been applied to the pipeline info

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26751>
2024-01-03 07:16:24 +00:00
Yiwei Zhang
a443d4dbc6 venus: refactor to add pipeline info fixes helpers
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26751>
2024-01-03 07:16:24 +00:00
Yiwei Zhang
c1d8056bbe venus: split up the pipeline fix description into self and pnext
prepare for fixing the pipeline pnext chain

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26751>
2024-01-03 07:16:23 +00:00
Yiwei Zhang
2e1c9b68df venus: clang format fixes
work around vk_outarray_append_typed till a better solution fits

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26751>
2024-01-03 07:16:23 +00:00
Chris Spencer
342dba5102 vulkan/android: Only limit advertised extensions in strict mode
Signed-off-by: Chris Spencer <spencercw@gmail.com>
Acked-by: Chia-I Wu <olvaffe@gmail.com>
Acked-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25101>
2023-12-13 20:09:37 +00:00
Chris Spencer
3c618d23d1 vn/android: Only limit advertised Vulkan version in strict mode
Signed-off-by: Chris Spencer <spencercw@gmail.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/25101>
2023-12-13 20:09:37 +00:00
Juston Li
4f2b4b81d1 venus: fix query feedback copy sanitize off by 1
Copy sanitization incorrectly included +1 range of the reset.

Eg Reset Query=0 QueryCount=5 is [0,5) exclusive, not [0,5] inclusive.

Fixes: 5b24ab91e4 ("venus: switch to unconditionally deferred query feedback")

Signed-off-by: Juston Li <justonli@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26603>
2023-12-09 01:32:05 +00:00
Yiwei Zhang
d17ddcc847 venus: dispatch background shader tasks to secondary ring
Summary:
- Add a perf option to force primary ring submission
- Let device own secondary ring(s) for ad-hoc spawn
- For threads where swapchain and command pool are created, track with
  TLS to instruct ring dispatch.
- If the pipeline creation or cache retrieval happens on the background
  threads not on the hot paths, force synchronous and dispatch to the
  secondary ring after waiting for primary ring becoming current.
- If the pipeline creation or cache retrieval happens on the hot paths
  threads, dispatch to the primary ring to avoid being blocked by those
  tasks on the secondary ring.

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26179>
2023-12-08 04:06:37 +00:00
Yiwei Zhang
5b26bebcf4 venus: add vn_gettid helper
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26179>
2023-12-08 04:06:37 +00:00
Yiwei Zhang
b170c1a391 venus: switch to vn_ring as the protocol interface - part 3
Sync protocol and fix all the interfaces, otherwise we have to generate
two sets of headers with both interfaces to separate protocol sync and
the driver side adaptation.

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26179>
2023-12-08 04:06:37 +00:00
Yiwei Zhang
5943f70c7a venus: switch to vn_ring as the protocol interface - part 2
Use instance ring as the primary ring of a logical device.

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26179>
2023-12-08 04:06:37 +00:00
Yiwei Zhang
d28ebf7b99 venus: switch to vn_ring as the protocol interface - part 1
No functional change but just preparations for switching instance
to ring to interface with the venus protocol headers.

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26179>
2023-12-08 04:06:37 +00:00