Commit Graph

222 Commits

Author SHA1 Message Date
Mike Blumenkrantz
87a9018ff9 zink: reorder commands more aggressively
by starting resources in the unordered state in a given batch, they
gain more opportunities to be promoted to the barrier cmdbuf and avoid
breaking renderpasses

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20890>
2023-01-27 02:42:56 +00:00
Mike Blumenkrantz
7399b2241f zink: move semaphore caching to zink_reset_batch_state()
this makes semaphores available for reuse more rapidly

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20681>
2023-01-19 20:26:44 +00:00
Mike Blumenkrantz
b8252784cf zink: add a binary semaphore cache
after being waited upon, a binary semaphore can be reused, which saves
tons of present-related ioctls when fps is high

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20681>
2023-01-19 20:26:44 +00:00
Mike Blumenkrantz
48a0478126 zink: add renderdoc handling
renderdoc won't work with zink in frontends that aren't dri,
so ZINK_RENDERDOC should be used to specify start:end frames
to ensure that the vulkan command stream is captured

this is not a renderdoc issue: there are no frame boundaries in rusticl
or gallium-nine, so there is no possible way that renderdoc could
determine when/how to split frames

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20651>
2023-01-14 18:15:48 +00:00
Mike Blumenkrantz
7ab5c5d36d zink: use EXT_descriptor_buffer with ZINK_DESCRIPTORS=db
this should be bug-free, as it passes cts/piglit/gaming on multiple drivers,
but since it's new, it stays behind an env var for at least one release

Acked-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20489>
2023-01-03 09:20:45 -05:00
Mike Blumenkrantz
34ec611dc6 zink: simplify swapchain imageview handling
the zink_resource_object::views array already handles this, so don't
duplicate its functionality

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19307>
2022-10-27 14:43:50 +00:00
Mike Blumenkrantz
8dd314d203 zink: handle broken resource mapping deadlocks
some apps (most notably Wolfenstein: The New Order) have broken multi-context
buffer usage in which one context will attempt to write to a buffer while
another context holds unflushed usage, and the unflushed context will never
flush until the buffer write completes

it's impossible to handle this scenario correctly without deadlocking,
so add some handling to try waiting and then yolo the buffer write if
a deadlock would occur

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19141>
2022-10-26 18:29:16 +00:00
Mike Blumenkrantz
eef575b91d zink: add docs for zink_batch.c
Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19165>
2022-10-20 16:46:02 +00:00
Mike Blumenkrantz
d1acd88c14 zink: prevent ballooning of view object memory
if a resource is in use every frame and never goes idle, it becomes
impossible to execute pruning, as there is no tracking for when views
are no longer in use

to avoid eventually ooming in this scenario, add some data to zink_resource_object
which can effectively "queue" pruning of these views if ballooning is
detected at a time when the views are guaranteed to be safe to delete

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19056>
2022-10-13 03:56:02 +00:00
Mike Blumenkrantz
765debc602 zink: delete view objects when unsetting resource usage in batch reset
if the resource has no usage, it's guaranteed to be idle, which means view
objects can be pruned to avoid memory ballooning

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19056>
2022-10-13 03:56:02 +00:00
Mike Blumenkrantz
1bd0d30a53 zink: fix some batch tracking leaks
not leaking over time, just leaking on shutdown

Fixes: 83c76b8efb ("zink: rework batch tracking for resources")

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18784>
2022-09-26 21:58:58 +00:00
Mike Blumenkrantz
eab18cb7a2 zink: use screen params for program reference functions
these never used the context anyway

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18689>
2022-09-23 17:02:11 +00:00
Mike Blumenkrantz
f6bbd7875a zink: remove batch tracking/usage from view types
instead of incurring all the overhead of tracking lifetimes for these,
it makes more sense to just let them delete whenever and then store
the vk object onto its parent image/buffer to be deleted when that gets
freed, as the parent object's lifetime will always be >= the view's lifetime

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18664>
2022-09-22 21:38:47 +00:00
Mike Blumenkrantz
7172fb56d9 zink bump batch state limit a bit
this should yield better throughput

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18664>
2022-09-22 21:38:47 +00:00
Mike Blumenkrantz
83c76b8efb zink: rework batch tracking for resources
this uses a revised version of radeonsi's buffer list array to track
resources for lifetime/usage management, massively improving performance
by avoiding hash table lookups

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18664>
2022-09-22 21:38:47 +00:00
Mike Blumenkrantz
1896111d25 zink: defer more semaphore destruction
these have noticeable overhead, so handle them in the submit thread

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18664>
2022-09-22 21:38:47 +00:00
Mike Blumenkrantz
00a4dc57ce zink: defer acquire semaphore destruction
these have noticeable overhead, so handle them in the submit thread

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18364>
2022-09-19 19:49:11 +00:00
Yiwei Zhang
6d1e214238 zink: fix in-fence lifecycle
For in-fence handling, dri2 has this below sequence in a row:
1. create_fence_fd: import external fence fd
2. fence_server_sync: import the pipe fence into the driver ctx
3. fence_reference: deref the created pipe fence

Before this change, zink pushed the wrapped external semaphore to the
wait semaphores of the next batch but the followed fence_reference will
destroy the imported semaphore immediately. Instead of extending the
lifecycle of the pipe fence throughout the batch state, we can simply
transfer the semaphore ownership to the batch and destroy it upon batch
reset.

Fixes: 32597e116d ("zink: implement GL semaphores")

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18453>
2022-09-08 19:30:38 +00:00
Mike Blumenkrantz
8a5b3658df zink: split resource tracking into two sets for buffer/texture
this will make the hash lookups slightly faster to cut down overhead

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18135>
2022-08-20 01:27:13 +00:00
Mike Blumenkrantz
8b93f157de zink: make batch internal api static again
hooray

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18135>
2022-08-20 01:27:13 +00:00
Mike Blumenkrantz
40424cbe98 zink: merge all the batch state sets onto the struct
less memory fragmentation

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18135>
2022-08-20 01:27:13 +00:00
Mike Blumenkrantz
16ae4fb8b7 zink: add is_buffer param to zink_batch_resource_usage_set
this allows constants to be specified, reducing register pressure during
descriptor binds

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18135>
2022-08-20 01:27:13 +00:00
Mike Blumenkrantz
0b56ac82eb zink: move zink_batch_resource_usage_set to be static inline
this has to go in zink_resource.h to avoid infinite include dependency
conflicts

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18135>
2022-08-20 01:27:13 +00:00
Mike Blumenkrantz
3f163b173d zink: use a list for free batch states
this ensures "fairer" reuse and avoids having any states sitting idle
for too long with resources attached

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18135>
2022-08-20 01:27:13 +00:00
Mike Blumenkrantz
2ca46b66c3 zink: rename _lazy descriptor stuff
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18051>
2022-08-14 18:38:04 -04:00
Mike Blumenkrantz
30c51abd0b zink: move all types/enums into zink_types.h
this significantly untangles all the header includes and fixes an issue
where zink_descriptors.h couldn't be included by certain files due to
type conflicts

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18051>
2022-08-14 18:38:04 -04:00
Mike Blumenkrantz
58e6480ee0 zink: remove descriptor vtable
no longer used

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18051>
2022-08-14 18:38:04 -04:00
TSnake41
a02c026eb7 zink: print result code string on vulkan failure
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17726>
2022-07-28 16:06:50 +00:00
Mike Blumenkrantz
ca03e35821 zink: expand unordered_exec
track read+write

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17667>
2022-07-26 21:34:59 +00:00
Mike Blumenkrantz
e5c4c33fa6 zink: zink_resource::unordered_barrier -> unordered_exec
this is a bit more clear

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17667>
2022-07-26 21:34:59 +00:00
Mike Blumenkrantz
2ea0d735d4 zink: add env var to abort on device-lost if no reset callback is set
the alternative here is to just spin aimlessly until the process ooms,
which causes problems when trying to detect failures in cts caselists

a separate env var is used so that it can be exported without affecting
ZINK_DEBUG

Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17525>
2022-07-21 14:02:27 +00:00
Mike Blumenkrantz
1bc9db6879 zink: split out rp_changed to be more granular for dynamic render
sometimes a state change MAY require a renderpass change, but this change
will not require splitting the current renderpass

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17640>
2022-07-20 17:30:19 +00:00
Mike Blumenkrantz
1951065a16 zink: delete zink_resource_object::dt_has_data
this should be on the swapchain image

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17149>
2022-06-28 02:42:02 +00:00
Mike Blumenkrantz
92228a6d28 zink: move 'acquired' flag onto swapchain struct
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17149>
2022-06-28 02:42:02 +00:00
Mike Blumenkrantz
285a5144cc zink: add batch api for adding a wait semaphore
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17066>
2022-06-16 02:01:53 +00:00
Mike Blumenkrantz
48b56d2efd zink: use a dynarray for semaphore wait flags
ensure that any number of semaphore waits is handled as expected

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17066>
2022-06-16 02:01:53 +00:00
Mike Blumenkrantz
f5ac058812 zink: remove thread_queue
I had originally intended to hook this up properly with synchronization et al,
but I didn't do it, and now it's seeming less smart anyway, so let's
remove the footgun

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17066>
2022-06-16 02:01:53 +00:00
Mike Blumenkrantz
d301883aba zink: use uint64_t for batch_id
this maps directly to the vulkan api and allows removal of timeline
wrapping code

the consequence of this is a ~0.26% reduction in drawoverhead performance
on base cases (n=1000), but the simplification and deletions seem worth it

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17045>
2022-06-16 00:30:45 +00:00
Mike Blumenkrantz
5897ade22d zink: flag renderpass for change if image resource changes valid state
the next renderpass instance will need to use different load ops,
so flag it here to ensure that gets picked up

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16877>
2022-06-06 00:36:20 +00:00
Mike Blumenkrantz
3e2c65281d zink: track invalidation for image resources
an image only has valid data if:
* it's imported
* it's written to
* it's mapped for write

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16877>
2022-06-06 00:36:20 +00:00
Dave Airlie
87f4252a51 zink: don't finish barriers cmd buffer if not used.
finishing has some cpu overhead, which if the cmd buffer isn't
going to be used is pointless. just let it get reset next time.

Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16393>
2022-05-11 05:19:38 +00:00
Dave Airlie
57df27be5f zink: avoid extra submits for empty wait cmdbufs.
This just avoids cpu overheads from processing that won't get used.

Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16393>
2022-05-11 05:19:38 +00:00
Mike Blumenkrantz
b0cbe3d419 zink: remove driver-based max_fences throttling
there are no more fence objects, so there's no need to do driver-specific
clamping on them

the mechanism remains intact to handle ETOOMANYSUBMITS

Acked-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15904>
2022-04-18 23:45:30 +00:00
Mike Blumenkrantz
b5d7f61e0c zink: remove batch lock
this is no longer needed and allows deleting some awful code

Acked-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15904>
2022-04-18 23:45:30 +00:00
Mike Blumenkrantz
bc2e29accd zink: require timeline semaphores
this allows the removal of tons of awful code

Acked-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15904>
2022-04-18 23:45:30 +00:00
Mike Blumenkrantz
07c86e99b1 zink: do not create fences at all if timeline semaphores are supported
there's no point in doing this, as it's just extra objects that don't need
to ever be used

Acked-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15904>
2022-04-18 23:45:30 +00:00
Mike Blumenkrantz
b3ee943050 zink: only get swapchain present semaphore on batch flush if not presented
otherwise this has already been present-waited and can just be used whenever

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15820>
2022-04-08 19:54:08 +00:00
Mike Blumenkrantz
21496dea9c zink: only get swapchain present semaphore on batch flush after acquire
otherwise this was a no-op flush from the frontend that should be ignored

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15820>
2022-04-08 19:54:08 +00:00
Mike Blumenkrantz
f97014c3da zink: handle nonseamless cube sampler binding
now when a cube is sampled with a nonseamless sampler, the relevant shader
stage is flagged for a variant update, the

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15536>
2022-04-07 14:36:25 +00:00
Mike Blumenkrantz
7f56fd9655 zink: it's kopperin' time
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14541>
2022-04-07 00:17:40 +00:00