2020-07-19 12:13:40 +02:00
Zink
====
Overview
--------
The Zink driver is a Gallium driver that emits Vulkan API calls instead
of targeting a specific GPU architecture. This can be used to get full
desktop OpenGL support on devices that only support Vulkan.
2020-10-13 18:09:05 +02:00
Features
--------
The feature-level of Zink depends on two things; what's implemented in Zink,
2023-03-09 14:25:19 +01:00
as well as the capabilities of the Vulkan driver.
2022-10-24 18:28:09 +02:00
2022-11-02 20:39:05 +01:00
The feature-levels implemented by Zink are exposed by `Vulkan Profiles
<https://dev.vulkan.org/tools#vulkan-profiles> `__ in the
:file: `VP_ZINK_requirements.json` profiles file.
2022-10-24 18:28:09 +02:00
2022-11-02 20:39:05 +01:00
Used with the `Vulkan Profiles tools <https://github.com/KhronosGroup/Vulkan-Profiles> `__ ,
2023-03-09 14:25:19 +01:00
we can compare the ZINK profiles with Vulkan devices profiles generated with
2022-11-02 20:39:05 +01:00
`Vulkaninfo <https://vulkan.lunarg.com/doc/view/latest/windows/vulkaninfo.html> `__
or `downloaded from GPUinfo.org`_
2022-10-24 18:28:09 +02:00
to establish the feature-levels supported by these drivers.
2020-10-13 18:09:05 +02:00
OpenGL 2.1
^^^^^^^^^^
OpenGL 2.1 is the minimum version Zink can support, and will always be
exposed, given Vulkan support. There's a few features that are required
for correct behavior, but not all of these are validated; instead you'll
see rendering-issues and likely validation error, or even crashes.
Here's a list of those requirements:
* Vulkan 1.0
* `` VkPhysicalDeviceFeatures `` :
2023-03-09 14:23:14 +01:00
* :vk-feat: `logicOp`
* :vk-feat: `fillModeNonSolid`
* :vk-feat: `alphaToOne`
* :vk-feat: `shaderClipDistance`
2020-10-13 18:09:05 +02:00
* Device extensions:
2022-11-08 12:05:36 +01:00
* :ext: `VK_KHR_maintenance1`
* :ext: `VK_KHR_create_renderpass2`
* :ext: `VK_KHR_imageless_framebuffer`
* :ext: `VK_KHR_timeline_semaphore`
* :ext: `VK_EXT_custom_border_color` with `` customBorderColorWithoutFormat ``
* :ext: `VK_EXT_provoking_vertex`
* :ext: `VK_EXT_line_rasterization` , with the following `` VkPhysicalDeviceLineRasterizationFeaturesEXT `` :
2021-07-09 12:16:10 +02:00
2023-03-09 14:23:14 +01:00
* :vk-feat: `rectangularLines`
* :vk-feat: `bresenhamLines`
* :vk-feat: `smoothLines`
* :vk-feat: `stippledRectangularLines`
* :vk-feat: `stippledBresenhamLines`
* :vk-feat: `stippledSmoothLines`
2021-03-30 17:57:56 +02:00
2022-11-08 12:05:36 +01:00
* :ext: `VK_KHR_swapchain_mutable_format`
* :ext: `VK_EXT_border_color_swizzle`
* :ext: `VK_KHR_descriptor_update_template`
2022-07-22 12:39:14 +02:00
2022-11-08 12:05:36 +01:00
In addition to this, :ext: `VK_KHR_external_memory` is required to support the
2021-03-30 17:57:56 +02:00
DRI code-path.
2020-10-13 18:09:05 +02:00
2022-11-08 12:05:36 +01:00
We also require either the :ext: `VK_EXT_scalar_block_layout` extension or
2023-03-09 14:23:14 +01:00
Vulkan 1.2, with the :vk-feat: `scalarBlockLayout` feature.
2021-04-09 09:53:31 +02:00
2020-10-13 18:09:05 +02:00
OpenGL 3.0
^^^^^^^^^^
2022-03-09 15:40:25 +01:00
For OpenGL 3.0 support, the following additional requirements must be
2023-03-10 14:16:21 +01:00
met:
2021-01-22 10:45:20 +01:00
* `` VkPhysicalDeviceFeatures `` :
2023-03-09 14:23:14 +01:00
* :vk-feat: `independentBlend`
2021-01-22 10:45:20 +01:00
* Device extensions:
2022-11-08 12:05:36 +01:00
* :ext: `VK_EXT_transform_feedback`
* :ext: `VK_EXT_conditional_rendering`
2020-10-13 18:09:05 +02:00
2020-10-23 09:00:43 +02:00
OpenGL 3.1
^^^^^^^^^^
For OpenGL 3.1 support, the following additional `` VkPhysicalDeviceLimits ``
are required:
* `` maxPerStageDescriptorSamplers `` ≥ 16
OpenGL 3.2
^^^^^^^^^^
2022-06-08 18:25:54 +02:00
For OpenGL 3.2 support, the following additional requirements must be
2023-03-10 14:16:21 +01:00
met, although some of these might not actually get verified:
2022-06-08 18:25:54 +02:00
* `` VkPhysicalDeviceFeatures `` :
2023-03-09 14:23:14 +01:00
* :vk-feat: `depthClamp`
* :vk-feat: `geometryShader`
* :vk-feat: `shaderTessellationAndGeometryPointSize`
2022-06-08 18:25:54 +02:00
* Device extensions:
2020-10-23 09:00:43 +02:00
2022-11-08 12:05:36 +01:00
* :ext: `VK_EXT_depth_clip_enable`
2020-10-23 09:00:43 +02:00
OpenGL 3.3
^^^^^^^^^^
2022-03-09 15:40:25 +01:00
For OpenGL 3.3 support, the following additional requirements must be
2023-03-10 14:16:21 +01:00
met, although some of these might not actually get verified:
2020-10-23 09:00:43 +02:00
2021-01-22 20:37:57 +01:00
* `` VkPhysicalDeviceFeatures `` :
2020-10-23 09:00:43 +02:00
2023-03-09 14:23:14 +01:00
* :vk-feat: `dualSrcBlend`
2020-10-23 09:00:43 +02:00
* Device extensions:
2022-11-08 12:05:36 +01:00
* :ext: `VK_EXT_vertex_attribute_divisor`
2020-10-23 09:00:43 +02:00
2021-01-22 11:04:33 +01:00
OpenGL 4.0
^^^^^^^^^^
2022-03-09 15:40:25 +01:00
For OpenGL 4.0 support, the following additional requirements must be
2023-03-10 14:16:21 +01:00
met:
2021-01-22 11:04:33 +01:00
* `` VkPhysicalDeviceFeatures `` :
2023-03-09 14:23:14 +01:00
* :vk-feat: `sampleRateShading`
* :vk-feat: `tessellationShader`
* :vk-feat: `imageCubeArray`
2021-01-22 11:04:33 +01:00
* Device extensions:
2022-11-08 12:05:36 +01:00
* :ext: `VK_KHR_maintenance2`
2021-01-22 11:04:33 +01:00
2022-06-14 08:46:05 +02:00
* Formats requiring `` VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT `` :
2021-01-22 11:04:33 +01:00
2021-03-16 10:44:27 +01:00
* `` VK_FORMAT_R32G32B32_SFLOAT ``
* `` VK_FORMAT_R32G32B32_SINT ``
* `` VK_FORMAT_R32G32B32_UINT ``
2021-01-22 11:04:33 +01:00
2021-01-22 11:24:53 +01:00
OpenGL 4.1
^^^^^^^^^^
2022-03-09 15:40:25 +01:00
For OpenGL 4.1 support, the following additional requirements must be
2023-03-10 14:16:21 +01:00
met:
2022-03-09 12:03:37 +01:00
* `` VkPhysicalDeviceFeatures `` :
2021-01-22 11:24:53 +01:00
2023-03-09 14:23:14 +01:00
* :vk-feat: `multiViewport`
2022-03-09 12:03:37 +01:00
* `` VkPhysicalDeviceLimits ``
2022-11-16 13:18:54 +01:00
* `` maxImageDimension1D `` ≥ 16384
2022-03-09 12:03:37 +01:00
* `` maxImageDimension2D `` ≥ 16384
2022-11-16 14:03:51 +01:00
* `` maxImageDimension3D `` ≥ 2048
* `` maxImageDimensionCube `` ≥ 16384
* `` maxImageArrayLayers `` ≥ 2048
2022-03-09 12:03:37 +01:00
* `` maxViewports `` ≥ 16
2021-01-22 11:24:53 +01:00
2021-01-22 12:15:33 +01:00
OpenGL 4.2
^^^^^^^^^^
2022-03-09 15:40:25 +01:00
For OpenGL 4.2 support, the following additional requirements must be
2023-03-10 14:16:21 +01:00
met:
2021-01-22 12:15:33 +01:00
2022-06-10 16:45:23 -04:00
* Device extensions:
2022-11-08 12:05:36 +01:00
* :ext: `VK_EXT_image_2d_view_of_3d`
2022-06-10 16:45:23 -04:00
2021-04-26 14:11:56 +02:00
* `` VkPhysicalDeviceLimits `` :
2021-04-26 17:35:21 +02:00
* `` shaderStorageImageExtendedFormats ``
* `` shaderStorageImageWriteWithoutFormat ``
2022-11-16 12:53:57 +01:00
* `` vertexPipelineStoresAndAtomics ``
* `` fragmentStoresAndAtomics ``
2021-04-26 14:11:56 +02:00
2021-02-13 04:56:23 +08:00
* For Vulkan 1.2 and above:
2022-04-19 16:39:52 +08:00
2021-02-13 04:56:23 +08:00
* `` VkPhysicalDeviceVulkan11Features `` :
2023-03-09 14:23:14 +01:00
* :vk-feat: `shaderDrawParameters`
2021-02-13 04:56:23 +08:00
* For Vulkan 1.1 and below:
* Device extensions:
2022-11-08 12:05:36 +01:00
* :ext: `VK_KHR_shader_draw_parameters`
2021-01-22 12:15:33 +01:00
2021-03-15 17:21:38 +01:00
OpenGL 4.3
^^^^^^^^^^
2022-03-09 15:40:25 +01:00
For OpenGL 4.3 support, the following additional requirements must be
2023-03-10 14:16:21 +01:00
met:
2021-03-15 17:21:38 +01:00
* `` VkPhysicalDeviceFeatures `` :
2023-03-09 14:23:14 +01:00
* :vk-feat: `robustBufferAccess`
2021-03-15 17:21:38 +01:00
2021-03-16 10:44:27 +01:00
* Formats requiring `` VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT `` :
2021-03-15 17:21:38 +01:00
2021-03-16 10:44:27 +01:00
* `` VK_FORMAT_R8G8B8A8_UNORM ``
* `` VK_FORMAT_R8G8B8A8_SRGB ``
* `` VK_FORMAT_R16_UNORM ``
* `` VK_FORMAT_R16G16_UNORM ``
* `` VK_FORMAT_R16_SNORM ``
* `` VK_FORMAT_R16G16_SNORM ``
* `` VK_FORMAT_D32_SFLOAT_S8_UINT ``
2021-03-15 17:21:38 +01:00
2021-03-15 17:27:04 +01:00
OpenGL 4.4
^^^^^^^^^^
2022-03-09 15:40:25 +01:00
For OpenGL 4.4 support, the following additional requirements must be
2023-03-10 14:16:21 +01:00
met:
2021-03-24 17:11:19 +01:00
* Formats requiring `` VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT `` :
2021-03-15 17:27:04 +01:00
2021-03-16 10:44:27 +01:00
* `` VK_FORMAT_B10G11R11_UFLOAT_PACK32 ``
2021-03-15 17:27:04 +01:00
2023-03-10 14:10:22 +01:00
* For Vulkan 1.2 and above:
* `` VkPhysicalDeviceVulkan12Features `` :
* `` samplerMirrorClampToEdge ``
* For Vulkan 1.1 and below:
* Device extensions:
2021-03-24 17:11:19 +01:00
2023-03-10 14:10:22 +01:00
* :ext: `VK_KHR_sampler_mirror_clamp_to_edge`
2021-03-24 17:11:19 +01:00
2021-03-15 17:38:28 +01:00
OpenGL 4.5
^^^^^^^^^^
For OpenGL 4.5 support, the following additional `` VkPhysicalDeviceFeatures ``
are required to be supported
2023-03-09 14:23:14 +01:00
* :vk-feat: `shaderCullDistance`
2021-03-15 17:38:28 +01:00
2021-03-15 17:44:13 +01:00
OpenGL 4.6
^^^^^^^^^^
2023-03-09 14:27:14 +01:00
For OpenGL 4.6 support, the following additional requirements must be
2023-03-10 14:16:21 +01:00
met:
2021-03-15 17:44:13 +01:00
* `` VkPhysicalDeviceFeatures `` :
2023-03-09 14:23:14 +01:00
* :vk-feat: `samplerAnisotropy`
* :vk-feat: `depthBiasClamp`
2021-03-15 17:44:13 +01:00
* Device extensions:
2022-11-08 12:05:36 +01:00
* :ext: `VK_KHR_draw_indirect_count`
2021-03-15 17:44:13 +01:00
2023-01-02 09:31:20 -05:00
Performance
-----------
If you notice poor performance and high CPU usage while running an application,
changing the descriptor manager may improve performance:
.. envvar :: ZINK_DESCRIPTORS <mode> ("auto")
`` auto ``
Automatically detect best mode. This is the default.
`` lazy ``
Attempt to use the least amount of CPU by binding descriptors opportunistically.
2022-10-26 12:08:08 -04:00
`` db ``
Use EXT_descriptor_buffer when possible.
2023-01-02 09:31:20 -05:00
2020-07-19 12:13:40 +02:00
Debugging
---------
There's a few tools that are useful for debugging Zink, like this environment
variable:
2022-11-08 10:24:07 +01:00
.. envvar :: ZINK_DEBUG
Accepts the following comma-separated list of flags:
2020-07-19 12:13:40 +02:00
2022-11-08 10:18:02 +01:00
`` nir ``
Print the NIR form of all shaders to stderr.
`` spirv ``
Write the binary SPIR-V form of all compiled shaders to a file in the
current directory, and print a message with the filename to stderr.
`` tgsi ``
Print the TGSI form of TGSI shaders to stderr.
`` validation ``
Dump Validation layer output.
`` sync ``
Emit full synchronization barriers before every draw and dispatch.
`` compact ``
Use a maximum of 4 descriptor sets
`` noreorder ``
Do not reorder or optimize GL command streams
`` gpl ``
Force using Graphics Pipeline Library for all shaders
2023-02-13 17:15:57 -05:00
`` rp ``
2023-04-26 14:33:59 +02:00
Enable render pass optimizations (for tiling GPUs)
2023-02-13 17:15:57 -05:00
`` norp ``
2023-04-26 14:33:59 +02:00
Disable render pass optimizations (for tiling GPUs)
2023-02-20 09:01:32 -05:00
`` map ``
Print info about mapped VRAM
2023-03-16 08:41:55 -04:00
`` flushsync ``
Force synchronous flushes/presents
2023-04-03 12:52:32 -04:00
`` noshobj ``
Disable EXT_shader_object
2023-05-04 10:11:02 -04:00
`` optimal_keys ``
Debug/use optimal_keys
2023-05-05 12:58:03 -04:00
`` noopt ``
Disable async optimized pipeline compiles
2023-05-08 08:54:01 -04:00
`` nobgc ``
Disable all async pipeline compiles
2023-06-13 10:58:12 -04:00
`` mem ``
Enable memory allocation debugging
2023-09-06 07:45:43 -04:00
`` quiet ``
Suppress probably-harmless warnings
2020-07-19 12:13:40 +02:00
Vulkan Validation Layers
^^^^^^^^^^^^^^^^^^^^^^^^
Another useful tool for debugging is the `Vulkan Validation Layers
2023-10-06 10:53:32 +02:00
<https://github.com/KhronosGroup/Vulkan-ValidationLayers/blob/main/README.md> `__.
2020-07-19 12:13:40 +02:00
The validation layers effectively insert extra checking between Zink and the
Vulkan driver, pointing out incorrect usage of the Vulkan API. The layers can
2024-04-01 17:06:34 +01:00
be enabled by setting the environment variable :envvar: `VK_LOADER_LAYERS_ENABLE` to
2024-04-01 18:36:23 +01:00
`` VK_LAYER_KHRONOS_validation `` . You can read more about the Validation Layers
2020-07-19 12:13:40 +02:00
in the link above.
2024-03-22 09:07:58 +00:00
Apple macOS and MoltenVK
------------------------
Zink on macOS is experimental with very limited capabilities.
The Vulkan SDK (1.3.250 or newer) is required to build Zink.
Set the build option `` -Dmoltenvk-dir=<directory> `` to point at your Vulkan SDK install or MoltenVK build.
Add Zink to the Gallium drivers build option `` -Dgallium-drivers=zink `` .
If installed using `` brew `` , you can set `` -D moltenvk-dir=$(brew --prefix molten-vk) `` .
2020-07-19 12:13:40 +02:00
IRC
---
In order to make things a bit easier to follow, we have decided to create our
own IRC channel. If you're interested in contributing, or have any technical
2021-05-21 12:49:20 +02:00
questions, don't hesitate to visit `#zink on OFTC
<irc://irc.oftc.net/zink> `__ and say hi!
2020-10-13 18:09:05 +02:00
2022-11-07 13:11:13 +01:00
.. _downloaded from GPUinfo.org: https://www.saschawillems.de/blog/2022/03/12/vulkan-profiles-support-for-the-vulkan-hardware-capability-viewer-and-database/