Commit Graph

147 Commits

Author SHA1 Message Date
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