Commit Graph

147 Commits

Author SHA1 Message Date
Mike Blumenkrantz 7aca74e219 zink: inline mem cache hash table
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11966>
2021-07-22 00:32:50 +00:00
Mike Blumenkrantz fdfa155f2b zink: move mem cache to sub-struct
no functional changes

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11966>
2021-07-22 00:32:50 +00:00
Mike Blumenkrantz d8905446d6 zink: rework oom flushing
tracking mem usage on the context is bad because if an app is always using
a large amount of memory across multiple batches, it triggers the oom flushes
on every flush and forces fencing

instead, add an explicit flag for oom flushing and another for stalling, then
flag oom flushing and stalling as needed, with set_framebuffer_state being an
additional flush point now since it's guaranteed not to split renderpasses

also proactively prune pending batch states if there's a lot of them

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11965>
2021-07-22 00:22:24 +00:00
Mike Blumenkrantz f2f1892e62 zink: make descriptors_update hook return a bool if a flush occurred
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11964>
2021-07-20 00:25:31 +00:00
Mike Blumenkrantz 696542bd3b zink: populate modifier props onto screen object during init
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10782>
2021-07-13 00:21:51 +00:00
Mike Blumenkrantz 0cf643db5d zink: remove shader_id
now that shaders are per-program, shader_id is no longer useful

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11691>
2021-07-06 18:05:15 +00:00
Mike Blumenkrantz fd633c2444 zink: add a screen function for waiting on a batch id
this is super hacky for the non-timeline case but whatever

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11686>
2021-07-02 03:40:45 +00:00
Mike Blumenkrantz ce90f73eb0 zink: rework pipeline cache implementation
this is now a screen-based queue which can be triggered to serialize
cache updates, ensuring synchronization

the cache is on the program object, enabling incremental updates as well as
variant loading for an entire pipeline collection at once

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11595>
2021-07-02 00:09:33 +00:00
Mike Blumenkrantz 936c21d376 zink: attempt to handle some resource unmap cases in 32bit envs
address space is limited here, so in some cases it's worthwhile to
unmap resources

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11594>
2021-06-30 13:07:57 +00:00
Erik Faye-Lund ccb9f8670e zink: do not store moltenvk functions in screen
These functions are only used once anyway, no need to store them and
make the rest of Zink care.

Acked-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Acked-by: Hoe Hao Cheng <haochengho12907@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11554>
2021-06-24 10:46:55 +02:00
Erik Faye-Lund 95cbb560cf zink: remove unused moltenvk functions
These functions were added, but never used. Let's get rid of them.

Fixes: c2cb2dd3bc ("zink: Added support for MacOS MoltenVK APIs.")
Acked-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Acked-by: Hoe Hao Cheng <haochengho12907@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11554>
2021-06-24 10:46:52 +02:00
Erik Faye-Lund e979ecbd45 zink: remove unused function-pointers
We also forgot to remove these when we stoped using them, more stuff to
delete, yeah!

Fixes: 5574868103 ("zink: use the dispatch tables")
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Hoe Hao Cheng <haochengho12907@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11554>
2021-06-24 10:46:13 +02:00
Erik Faye-Lund efa863990a zink: drop unused macros
We stopped using these without removing them, let's tidy that bit up.

Fixes: 5574868103 ("zink: use the dispatch tables")
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Hoe Hao Cheng <haochengho12907@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11554>
2021-06-24 10:45:18 +02:00
Mike Blumenkrantz 478f129ee7 zink: move queue submit thread to screen
this needs to be a screen-based queue in order to serialize properly
with multiple contexts

Acked-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11437>
2021-06-22 20:57:33 +00:00
Mike Blumenkrantz 806251c72d zink: move queue init to screen creation
this is a race condition

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11398>
2021-06-16 15:03:22 +00:00
Mike Blumenkrantz a1fb2e9c27 zink: use u_live_shader_cache
let the duplicated shader madness end

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11403>
2021-06-16 04:49:45 +00:00
Mike Blumenkrantz 4e3768914d zink: add ZINK_DESCRIPTORS env var to explicitly set a mode
currently this supports 3 modes, with the default being a hybrid between
caching and lazy

Reviewed-by: Hoe Hao Cheng <haochengho12907@gmail.com>
Acked-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11188>
2021-06-15 20:15:58 -04:00
Michel Zou d31ea71c44 zink: Drop useless zink_dispatch_table
Reviewed-by: Hoe Hao Cheng <haochengho12907@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11338>
2021-06-14 19:48:36 +00:00
Hoe Hao Cheng b5d344c3af zink: move extension function verification to when it is used
Some vulkan functions are not loaded when the corresponding features are
not enabled, but the verifier checks for *all* functions, so make the
verifier more forgiving and use a stub to catch when we actually use a
function that is not loaded.

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11328>
2021-06-13 18:58:34 +00:00
Hoe Hao Cheng 5574868103 zink: use the dispatch tables
- removed all usage of GET_PROC_ADDR
- find-and-replaced all instances of `screen->vk_` to `screen->vk.`

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11036>
2021-06-10 20:24:40 +00:00
Hoe Hao Cheng ed2fb8099e zink: introduce vk_dispatch_table
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11036>
2021-06-10 20:24:40 +00:00
Mike Blumenkrantz 652db34f8a zink: populate maxSampleLocationGridSize for all available sample sizes on init
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11189>
2021-06-09 17:26:52 +00:00
Erik Faye-Lund 990ed280d0 zink: calculate spir-v version based on vk version
This moves the previous check up to the screen-creation, making it
possible to enable features based on the SPIR-V version.

The reason we want to be able to do this, is so we can force specific
SPIR-V versions, in order to work around bugs in tools.

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Hoe Hao Cheng <haochengho12907@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11044>
2021-06-07 12:00:15 +00:00
Mike Blumenkrantz bfdd1d8d89 zink: add a second descriptor manager
this is the "lazy" descriptor manager, which aims to perform the least
amount of work calculating updates while ignoring the overhead that an
update may incur: effectively the inverse of the caching manager

in this initial implementation, divergence exists between the descriptor
layouts of the cached manager and the lazy manager in order to avoid
incurring regressions in the existing descriptor architecture; this will
be reconciled in a followup MR that refactors and unifies descriptor layouts

during this interim period and until such reconciliation occurs,
the default descriptor manager is now the lazy manager for testing purposes as
there are no changes here which can affect the existing infrastructure

the caching descriptor manager can be selected with the ZINK_CACHE_DESCRIPTORS
env var and will be automatically used for vulkan drivers which don't support
the features required for lazy mode (templates)

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11093>
2021-06-01 23:29:19 +00:00
Erik Faye-Lund 1dfad514ea zink: add support for string-markers
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11004>
2021-05-29 09:02:13 +00:00
Mike Blumenkrantz 7a5800af3d zink: hook up push descriptor and descriptor template extensions
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10998>
2021-05-26 03:55:37 +00:00
Mike Blumenkrantz a29688a0d1 zink: implement tc idalloc resource id stuff
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10882>
2021-05-25 21:51:16 -04:00
Mike Blumenkrantz 6f5037c9de zink: move timeline_wait() to screen function
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10882>
2021-05-25 21:50:50 -04:00
Mike Blumenkrantz 425642bec1 zink: abstract descriptor functionality and make descriptor structs private
the first step to adding modular descriptor managers is to isolate the existing one
so that it can be easily swapped out

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10849>
2021-05-25 20:53:00 -04:00
Mike Blumenkrantz cca9201922 zink: start using dynamic front face state
this doesn't actually do anything other than test the codepath since
the hashed pipeline state will still change on every frontface change,
but it's a start

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10508>
2021-05-07 02:00:54 +00:00
Mike Blumenkrantz 27d1ecd54b zink: hook up dynamic dsa states
this is pretty straightforward, just adding some extra calls

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10508>
2021-05-07 02:00:54 +00:00
Mike Blumenkrantz d7a1bd94fb zink: check descriptor layout support before creating it
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9965>
2021-05-07 01:50:11 +00:00
Mike Blumenkrantz 00bd74fb6c zink: add a screen util function for handling VkResults
enforce device lost status always

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10509>
2021-05-05 02:46:06 +00:00
Mike Blumenkrantz d050be4b26 zink: grab GetPhysicalDeviceMemoryProperties2 from instance
Acked-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10511>
2021-05-05 02:08:44 +00:00
Mike Blumenkrantz 4b52a7f245 zink: hook up EXT_image_drm_format_modifier
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10520>
2021-04-29 12:32:59 +00:00
Mike Blumenkrantz 817a8fa22f zink: hook up VK_EXT_sample_locations
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10520>
2021-04-29 12:32:59 +00:00
Adam Jackson bbeee415ee zink: Learn about VK_KHR_swapchain
We're gonna want it eventually.

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10382>
2021-04-21 14:03:27 -04:00
Mike Blumenkrantz fa36a16c68 zink: make timeline semaphores per-screen
I misread the spec, and it turns out timeline ids can't be reused across
semaphores. This is obvious in retrospect, but what can be done?

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Tested-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10115>
2021-04-09 13:31:55 +00:00
Mike Blumenkrantz f19946ca6e zink: stop unmapping resources
it turns out there's not actually a requirement that resources be unmapped,
which means that a ton of overhead can be saved both in the unmap codepath
(the cpu overhead here is pretty insane) and then also when mapping cached
resource memory, as the map can now be added to the cache for immediate reuse

as seen in radeonsi

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9980>
2021-04-08 03:34:49 +00:00
Mike Blumenkrantz 7f28775edc zink: implement uniform inlining
this lets us inline away our problems

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9888>
2021-04-08 03:00:48 +00:00
Mike Blumenkrantz e4426d7828 zink: split total_mem off to total_video_mem, use total_mem for tc
tc needs the total host memory available, not the total video memory

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10006>
2021-04-05 22:45:52 +00:00
Mike Blumenkrantz 6433661cda zink: use 2 variant to check image format props during create
just to be pedantic

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9984>
2021-04-05 22:14:26 +00:00
Mike Blumenkrantz 733e07565f zink: use vkGetPhysicalDeviceFormatProperties2 when available
technically shouldn't matter but whatever

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9984>
2021-04-05 22:14:26 +00:00
Mike Blumenkrantz bbb00f739c zink: enforce device lost status
many apps don't request device-lost notification, so just calling the reset
callback isn't enough; once the device has been lost, no more cmdbufs should
be submitted and the queue should not be waited on

Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9963>
2021-04-01 13:25:51 +00:00
Mike Blumenkrantz 9a13add12e zink: hook up timeline semaphore signalling during batch submission
just basic parts, no waiting on semaphores yet

Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9963>
2021-04-01 13:25:51 +00:00
Mike Blumenkrantz a4e34f40a3 zink: track last completed batch id to optimize checking states
Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9963>
2021-04-01 13:25:51 +00:00
Mike Blumenkrantz d179c5d28e zink: implement threaded context
this includes:
* async buffer mapping/replacement
* async queue submission
* async (threaded) gallium flush handling

the main churn here is from handling async gallium flushes, which involves
creating multiple gallium fences (zink_tc_fence) for each zink fence (zink_fence).
a tc fence may begin waiting for completion at any time, even before the zink_fence
has had its cmdbuf(s) submitted, so handling this type of desync ends up needing
almost a complete rewrite of the existing queue architecture

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9935>
2021-03-31 20:16:05 -04:00
Mike Blumenkrantz 92a5ea13fc zink: implement a global framebuffer cache
this uses the same mechanics as surface caching, but it
also requires that surfaces keep refs of the framebuffers they're
attached to so that they can invalidate the fb object upon destruction,
as, similar to program objects, the fb objects are "owned" by their attachments

loosely based on patches by Antonio Caggiano

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9665>
2021-03-22 08:49:26 -04:00
Mike Blumenkrantz 23538ed7a8 zink: cache bufferviews
we can cache bufferviews just like we do surfaces, so let's do that

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9543>
2021-03-16 10:45:32 -04:00
Mike Blumenkrantz 545625600b zink: update null descriptor hashes to reflect current descriptor states
also add a bufferview hash since we use these now

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9543>
2021-03-16 10:45:32 -04:00
Mike Blumenkrantz 6fb4e1345d zink: determine whether the vulkan driver requires mesa flush wsi
this is used for ANV's implicit fencing (until we get wsi)

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9290>
2021-03-15 10:58:21 -04:00
Mike Blumenkrantz 38f7faa8a4 zink: implement a surface cache
this is a global cache for all surface objects, enabling some memory
optimizations as well as improved reuse of cached descriptors

loosely based on patches from Antonio Caggiano

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9541>
2021-03-15 09:42:30 -04:00
Mike Blumenkrantz 980a8b3fc0 zink: implement an extremely dumb resource memory cache
this stores a number (currently 5) of backing allocations for resources
for later reuse when creating matching resources

because this is on the screen object it requires locking, but this is still
far faster than allocating new memory each time

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9540>
2021-03-12 17:21:40 +00:00
Mike Blumenkrantz fa77cc2fbb zink: add a null sampler view descriptor hash to the screen
pre-hashing this saves us time later since we can just reuse it

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9348>
2021-03-12 16:32:53 +00:00
Mike Blumenkrantz 5945d7d2e9 zink: fix instance/device versioning (for real this time)
the maximum allowable runtime version of vk can be computed by MIN(instance_version, device_version)

despite this, instances and devices can be created using the maximum version available
for each respective type. the restriction is applied only at the point of
enabling/applying features and extensions, meaning that to correctly handle this,
zink must:

1. create an instance using the maximum allowable version
2. select a physical device using the instance
3. compute MIN(instance_version, device_version)
4. only now begin to enable/use features requiring vk 1.1+

ref #4392

Reviewed-by: Adam Jackson <ajax@redhat.com>
Acked-by: Hoe Hao Cheng <haochengho12907@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9479>
2021-03-09 18:33:15 +00:00
Mike Blumenkrantz 3c20b698e2 zink: rewrite macro for getting KHR device functions
we have the technology. we can improve our our lives with better macros.

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9398>
2021-03-03 17:27:22 -05:00
Mike Blumenkrantz 6a3e340288 zink: store total memory size on zink_screen
need this for oom handling

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9274>
2021-03-01 19:36:26 +00:00
Mike Blumenkrantz ee4b844b12 zink: pre-fetch all format properties during screen init
this ends up being a tradeoff where we waste a little startup time and
an extra ~4k memory for the overall screen object in exchange for never having
to fetch format properties again, which is a surprisingly expensive call
to be making as much as we have to make it

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9293>
2021-02-25 17:58:38 -05:00
Mike Blumenkrantz 51e527a9ba zink: setup CmdBindVertexBuffers2EXT member in screen for dynamic state
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9272>
2021-02-24 21:41:05 -05:00
Eric Anholt c43e8da535 zink: Use mesa_loge() for should-never-be-reached initialization errors.
dEQP in CI was hitting these, and debug_printf is not enabled on non-debug
(such as debugoptimized or release) builds.  Besides, mesa_loge() gets you
logging on Android, should someone ever do zink for that.

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8891>
2021-02-23 18:01:47 +00:00
Dave Airlie 40ea20c5f7 zink: use extensioned draw indirect functions.
The code was using the core versions, but for vulkan 1.0 at
least the extension versions are what is required to be asked for.

This fixes zink loading on lavapipe, and blows up the CI.

v2: Use LOCAL device extension variant (zmike)

Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9185>
2021-02-22 21:48:42 +00:00
Mike Blumenkrantz 575756274a zink: handle dual blending override from driconf
when this is enabled, we need to push gl_FragData[1] to location 0 and
index 1 so that it gets blended like the application expects

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9095>
2021-02-18 00:02:17 +00:00
Mike Blumenkrantz c4cc3d915b zink: add a disk cache for pipeline objects
this writes the pipeline cache to disk on shutdown

ideally we'd rather write this incrementally any time we make a new pipeline,
but that ends up breaking the disk cache infrastructure since we're always writing
to the same file, so this is the best we can do for now

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9094>
2021-02-17 02:59:52 +00:00
Mike Blumenkrantz eb3cb170fc zink: create a VkPipelineCache object on the screen and use it
this enables reuse of shaders across pipelines

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9094>
2021-02-17 02:59:52 +00:00
Adam Jackson f2573760b4 zink: Factor out instance setup a bit more
The VkInstance is really display state not screen state, as is the
loader version. Factor this out a bit further so that
zink_create_instance fills in a zink_instance_info. The latter struct
still lives in the zink_screen for now but that'll move soon.

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8968>
2021-02-10 20:31:42 +00:00
Erik Faye-Lund 6993109713 zink: setup compiler options during init
This avoids duplicating the options just to change a single one.

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8402>
2021-01-10 13:06:45 +00:00
Mike Blumenkrantz 1c01ad1b80 zink: add KHR_draw_indirect_count detection
this is a vk 1.2 feature

Reviewed-by: Hoe Hao Cheng <haochengho12907@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8233>
2020-12-31 13:41:30 +00:00
Mike Blumenkrantz 0f5726c503 zink: fix more instance detection stuff
this was broken during the transition to generated code

Fixes: fe669ff4a0 ("zink: replace old code with generated zink_instance")

Reviewed-by: Hoe Hao Cheng <haochengho12907@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8250>
2020-12-28 16:01:02 -05:00
Mike Blumenkrantz 2f8237754b zink: fix debug utils init
this was moved to a different struct without being updated

Fixes: fe669ff4a0 ("zink: replace old code with generated zink_instance")

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8220>
2020-12-24 01:49:00 +00:00
Hoe Hao Cheng fe669ff4a0 zink: replace old code with generated zink_instance
Acked-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7800>
2020-12-11 12:07:13 +00:00
Adam Jackson 12656de341 zink: factor out GET_PROC_ADDR and friends to zink_screen.h
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7800>
2020-12-11 12:07:13 +00:00
Mike Blumenkrantz b47407269d zink: initial shader key implementation
this is a squashed version of a previously-reviewed series
ref https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7193

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7801>
2020-12-08 17:35:48 +00:00
Erik Faye-Lund 37a706ad5d Revert "zink: initial implementation of shader keys"
This reverts commit 2be2a500a3.

Fixes: 2be2a500a3 ("zink: initial implementation of shader keys")
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7754>
2020-11-24 21:51:34 +00:00
Mike Blumenkrantz 968e360e47 zink: track custom border color samplers and verify against device limits
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7487>
2020-11-18 17:19:53 +00:00
Mike Blumenkrantz 2be2a500a3 zink: initial implementation of shader keys
these are cached per-program for now since we have to ensure that the slot map
always matches up between shader states

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7193>
2020-11-13 14:40:33 +00:00
Iago Toral Quiroga 46d2f2224f zink: only add MESA WSI structs for specific devices
Some drivers will drop warnings about seeing these structs in the
pNext chain and not handling them. This change makes it so we
only include the structs with Vulkan drivers that are known to
require them for proper behavior (v3dv only for now) to avoid the
warnings.

It should be noted that here we are only supressing the messages
from Zink. Since the Mesa Vulkan WSI code will include these structs,
when native Vulkan Mesa drivers are used without Zink they might
still dump these messages.

Requested by Mike Blumenkrantz.

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7523>
2020-11-11 08:16:32 +01:00
Duncan Hopkins d377d84496 zink: make physical device functions use a dynamic function pointers.
vkGetPhysicalDeviceFeatures2 and vkGetPhysicalDeviceProperties2 are not present on some MoltenVK versions.
VK_KHR_get_physical_device_properties2 exposes the KHR versions of the same functions.
These cannot be used via static linking, so we have to dynamically detect the loader version and then the extension
to work out which pointers to use.

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7447>
2020-11-08 06:09:16 +00:00
Duncan Hopkins f0bbd8fdd0 zink: have_triangle_fans support.
MoltenVK, at least upto 1.2.141, does not render triangle fans. This is reflected in the portability EXTX extension.
This code get the extensions properties and features and then sets the have_triangle_fans.
This extension is not avaiable on all systems, so an amout of the code has to be protected by the define VK_EXTX_PORTABILITY_SUBSET_EXTENSION_NAME.

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7457>
2020-11-06 16:39:49 +00:00
Duncan Hopkins feb9462bb1 zink: Added inbuilt debug logging from the VK_LAYER_LUNARG_standard_validation layer.
Set the ZINK_DEBUG environment variable to 'validation' to automatically setup.
The debug util extnsion callback is used to capture information and logs the results to the error stream.

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7431>
2020-11-06 13:44:20 +00:00
Duncan Hopkins c2cb2dd3bc zink: Added support for MacOS MoltenVK APIs.
Detects the MoltenVK layer and extension.
If present, get the ext function pointers and use to enable full swizzeling suport.
Fixes issues with Swizzling behaviour fro MoltenVk is disabled by default and needed to be enable via this API.

This also supplied the ground work to allow IOSurfaces to be used later for surface passing.

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7383>
2020-11-03 16:15:33 +00:00
Mike Blumenkrantz bab0d8630c zink: support VK_EXT_extended_dynamic_state
just the screen parts

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7099>
2020-10-12 18:26:56 +00:00
Hoe Hao Cheng b2d042b621 zink: remove old extension infrastructure
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6789>
2020-09-28 15:03:56 +00:00
Hoe Hao Cheng 0ed17a212c zink: hook zink_device_info.py to build system
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6789>
2020-09-28 15:03:56 +00:00
Mike Blumenkrantz cd1c21f8e5 zink: implement handling for VK_EXT_calibrated_timestamps
just the extension setup; we need this to handle device timestamp
queries outside of batches

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5913>
2020-08-03 14:22:39 +00:00
Mike Blumenkrantz 8930b19676 zink: store valid timestamp bits onto zink_screen
we need this for converting timestamp ticks to nonoseconds

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5913>
2020-08-03 14:22:39 +00:00
Mike Blumenkrantz 3e6366be68 zink: handle VK_EXT_vertex_attribute_divisor setup
this just enables the extension

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5913>
2020-08-03 14:22:39 +00:00
Mike Blumenkrantz 01d6220cff zink: implement VK_EXT_robustness2
this adds support for null descriptors, which is necessary for full
compliance with ARB_texture_buffer_object

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5913>
2020-08-03 14:22:39 +00:00
Mike Blumenkrantz f2f57ef9f7 zink: implement Vk_EXT_index_type_uint8
this is a simple extension that enables using uint8-sized index buffers,
which lets us avoid having those go through primconvert

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5712>
2020-07-02 07:11:27 +00:00
Mike Blumenkrantz 37778fcd9a zink: implement transform feedback support to finish off opengl 3.0
this adds:
* context hooks for gallium stream output methods
* handling for xfb-related queries
* barrier management for pausing and resuming xfb

loosely based on patches originally written by Dave Airlie <airlied@redhat.com>

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5163>
2020-06-17 20:42:01 +00:00
Dave Airlie 5743fa6e70 zink: enable conditional rendering if available
This doesn't seem to work perfect, but I'm not sure what is possible
in GL vs Vulkan here

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2867
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4835>
2020-05-11 09:09:34 +00:00
Erik Faye-Lund 36f3902213 zink: move format-checking to separate source
This code is more or less stand-alone, and this keeps the formats array
a bit more encapsulated.
2019-11-13 09:12:36 +01:00
Erik Faye-Lund 477f019812 zink: only enable KHR_external_memory_fd if supported
While we're at it, make sure we error out if it's not supported when
required.

This brings us a bit closer to being able to test on SwiftShader, which
doesn't currently support KHR_external_memory_fd.
2019-10-30 19:40:50 +00:00
Erik Faye-Lund 810fc75dab zink: emulate optional depth-formats
The Vulkan spec says that an implementation has to support one of
VK_FORMAT_X8_D24_UNORM_PACK32 and VK_FORMAT_D32_SFLOAT, as well of
one of VK_FORMAT_D24_UNORM_S8_UINT and VK_FORMAT_D32_SFLOAT_S8_UINT.

So let's keep track which one is supported of earch pair, and emulate
one on top of the other one.

This won't give the exact result for comparisons, or when mapping and
unmapping the resources. But it's better than flat out failing to create
the resource, and we can fix the map/unmap issue later if needed.

Tested-by: Duncan Hopkins <duncan@thefoundry.co.uk>
2019-10-28 17:57:49 +00:00
Erik Faye-Lund e6ea350fb0 zink: error if VK_KHR_maintenance1 isn't supported
While we're at it, remove the VK_-prefix from the extension bool; all
extensions have this so it's kinda superfluous.
2019-10-28 17:57:49 +00:00
Dave Airlie 9fa7400564 zink: add dri loader
export MESA_LOADER_DRIVER_OVERRIDE=zink should now work without using
swrast paths

Acked-by: Jordan Justen <jordan.l.justen@intel.com>
2019-10-28 08:51:43 +00:00
Erik Faye-Lund 48f1f20a9d zink: detect presence of VK_KHR_maintenance1
Acked-by: Jordan Justen <jordan.l.justen@intel.com>
2019-10-28 08:51:43 +00:00
Erik Faye-Lund 8d46e35d16 zink: introduce opengl over vulkan
Here's zink, a so far pretty simple vulkan-gallium driver that is able
to translate some applications from OpenGL to Vulkan.

The compiler is quite limited for now, this will be improved on later.

Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Acked-by: Jordan Justen <jordan.l.justen@intel.com>
2019-10-28 08:51:43 +00:00