| 1 |
Zink |
| 2 |
==== |
| 3 |
|
| 4 |
Overview |
| 5 |
-------- |
| 6 |
|
| 7 |
The Zink driver is a Gallium driver that emits Vulkan API calls instead |
| 8 |
of targeting a specific GPU architecture. This can be used to get full |
| 9 |
desktop OpenGL support on devices that only support Vulkan. |
| 10 |
|
| 11 |
Features |
| 12 |
-------- |
| 13 |
|
| 14 |
The feature-level of Zink depends on two things; what's implemented in Zink, |
| 15 |
as well as the capabilities of the Vulkan driver. |
| 16 |
|
| 17 |
The feature-levels implemented by Zink are exposed by `Vulkan Profiles |
| 18 |
<https://dev.vulkan.org/tools#vulkan-profiles>`__ in the |
| 19 |
:file:`VP_ZINK_requirements.json` profiles file. |
| 20 |
|
| 21 |
Used with the `Vulkan Profiles tools <https://github.com/KhronosGroup/Vulkan-Profiles>`__, |
| 22 |
we can compare the ZINK profiles with Vulkan devices profiles generated with |
| 23 |
`Vulkaninfo <https://vulkan.lunarg.com/doc/view/latest/windows/vulkaninfo.html>`__ |
| 24 |
or `downloaded from GPUinfo.org`_ |
| 25 |
to establish the feature-levels supported by these drivers. |
| 26 |
You can check a running driver against the Zink profiles by building mesa with |
| 27 |
``--tools=zink`` and running |
| 28 |
``./src/gallium/drivers/zink/check_requirements/zink_check_requirements`` |
| 29 |
from the build directory. |
| 30 |
|
| 31 |
OpenGL 2.1 |
| 32 |
^^^^^^^^^^ |
| 33 |
|
| 34 |
OpenGL 2.1 is the minimum version Zink can support, and will always be |
| 35 |
exposed, given Vulkan support. There's a few features that are required |
| 36 |
for correct behavior, but not all of these are validated; instead you'll |
| 37 |
see rendering-issues and likely validation error, or even crashes. |
| 38 |
|
| 39 |
Here's a list of those requirements: |
| 40 |
|
| 41 |
* Vulkan 1.0 |
| 42 |
* ``VkPhysicalDeviceFeatures``: |
| 43 |
|
| 44 |
* :vk-feat:`logicOp` |
| 45 |
* :vk-feat:`fillModeNonSolid` |
| 46 |
* :vk-feat:`alphaToOne` |
| 47 |
* :vk-feat:`shaderClipDistance` |
| 48 |
|
| 49 |
* Device extensions: |
| 50 |
|
| 51 |
* :ext:`VK_KHR_maintenance1` |
| 52 |
* :ext:`VK_KHR_create_renderpass2` |
| 53 |
* :ext:`VK_KHR_imageless_framebuffer` |
| 54 |
* :ext:`VK_KHR_timeline_semaphore` |
| 55 |
* :ext:`VK_EXT_custom_border_color` with ``customBorderColorWithoutFormat`` |
| 56 |
* :ext:`VK_EXT_provoking_vertex` |
| 57 |
* :ext:`VK_EXT_line_rasterization`, with the following ``VkPhysicalDeviceLineRasterizationFeaturesEXT``: |
| 58 |
|
| 59 |
* :vk-feat:`rectangularLines` |
| 60 |
* :vk-feat:`bresenhamLines` |
| 61 |
* :vk-feat:`smoothLines` |
| 62 |
* :vk-feat:`stippledRectangularLines` |
| 63 |
* :vk-feat:`stippledBresenhamLines` |
| 64 |
* :vk-feat:`stippledSmoothLines` |
| 65 |
|
| 66 |
* :ext:`VK_KHR_swapchain_mutable_format` |
| 67 |
* :ext:`VK_EXT_border_color_swizzle` |
| 68 |
* :ext:`VK_KHR_descriptor_update_template` |
| 69 |
|
| 70 |
In addition to this, :ext:`VK_KHR_external_memory` is required to support the |
| 71 |
DRI code-path. |
| 72 |
|
| 73 |
We also require either the :ext:`VK_EXT_scalar_block_layout` extension or |
| 74 |
Vulkan 1.2, with the :vk-feat:`scalarBlockLayout` feature. |
| 75 |
|
| 76 |
OpenGL 3.0 |
| 77 |
^^^^^^^^^^ |
| 78 |
|
| 79 |
|
| 80 |
For OpenGL 3.0 support, the following additional requirements must be |
| 81 |
met: |
| 82 |
|
| 83 |
* ``VkPhysicalDeviceFeatures``: |
| 84 |
|
| 85 |
* :vk-feat:`independentBlend` |
| 86 |
|
| 87 |
* Device extensions: |
| 88 |
|
| 89 |
* :ext:`VK_EXT_transform_feedback` |
| 90 |
* :ext:`VK_EXT_conditional_rendering` |
| 91 |
|
| 92 |
OpenGL 3.1 |
| 93 |
^^^^^^^^^^ |
| 94 |
|
| 95 |
For OpenGL 3.1 support, the following additional ``VkPhysicalDeviceLimits`` |
| 96 |
are required: |
| 97 |
|
| 98 |
* ``maxPerStageDescriptorSamplers`` ≥ 16 |
| 99 |
|
| 100 |
OpenGL 3.2 |
| 101 |
^^^^^^^^^^ |
| 102 |
|
| 103 |
For OpenGL 3.2 support, the following additional requirements must be |
| 104 |
met, although some of these might not actually get verified: |
| 105 |
|
| 106 |
* ``VkPhysicalDeviceFeatures``: |
| 107 |
|
| 108 |
* :vk-feat:`depthClamp` |
| 109 |
* :vk-feat:`geometryShader` |
| 110 |
* :vk-feat:`shaderTessellationAndGeometryPointSize` |
| 111 |
|
| 112 |
* Device extensions: |
| 113 |
|
| 114 |
* :ext:`VK_EXT_depth_clip_enable` |
| 115 |
|
| 116 |
OpenGL 3.3 |
| 117 |
^^^^^^^^^^ |
| 118 |
|
| 119 |
For OpenGL 3.3 support, the following additional requirements must be |
| 120 |
met, although some of these might not actually get verified: |
| 121 |
|
| 122 |
* ``VkPhysicalDeviceFeatures``: |
| 123 |
|
| 124 |
* :vk-feat:`dualSrcBlend` |
| 125 |
|
| 126 |
* Device extensions: |
| 127 |
|
| 128 |
* :ext:`VK_EXT_vertex_attribute_divisor` |
| 129 |
|
| 130 |
OpenGL 4.0 |
| 131 |
^^^^^^^^^^ |
| 132 |
|
| 133 |
For OpenGL 4.0 support, the following additional requirements must be |
| 134 |
met: |
| 135 |
|
| 136 |
* ``VkPhysicalDeviceFeatures``: |
| 137 |
|
| 138 |
* :vk-feat:`sampleRateShading` |
| 139 |
* :vk-feat:`tessellationShader` |
| 140 |
* :vk-feat:`imageCubeArray` |
| 141 |
|
| 142 |
* Device extensions: |
| 143 |
|
| 144 |
* :ext:`VK_KHR_maintenance2` |
| 145 |
|
| 146 |
* Formats requiring ``VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT``: |
| 147 |
|
| 148 |
* ``VK_FORMAT_R32G32B32_SFLOAT`` |
| 149 |
* ``VK_FORMAT_R32G32B32_SINT`` |
| 150 |
* ``VK_FORMAT_R32G32B32_UINT`` |
| 151 |
|
| 152 |
OpenGL 4.1 |
| 153 |
^^^^^^^^^^ |
| 154 |
|
| 155 |
For OpenGL 4.1 support, the following additional requirements must be |
| 156 |
met: |
| 157 |
|
| 158 |
* ``VkPhysicalDeviceFeatures``: |
| 159 |
|
| 160 |
* :vk-feat:`multiViewport` |
| 161 |
|
| 162 |
* ``VkPhysicalDeviceLimits`` |
| 163 |
|
| 164 |
* ``maxImageDimension1D`` ≥ 16384 |
| 165 |
* ``maxImageDimension2D`` ≥ 16384 |
| 166 |
* ``maxImageDimension3D`` ≥ 2048 |
| 167 |
* ``maxImageDimensionCube`` ≥ 16384 |
| 168 |
* ``maxImageArrayLayers`` ≥ 2048 |
| 169 |
* ``maxViewports`` ≥ 16 |
| 170 |
|
| 171 |
OpenGL 4.2 |
| 172 |
^^^^^^^^^^ |
| 173 |
|
| 174 |
For OpenGL 4.2 support, the following additional requirements must be |
| 175 |
met: |
| 176 |
|
| 177 |
* Device extensions: |
| 178 |
* :ext:`VK_EXT_image_2d_view_of_3d` |
| 179 |
|
| 180 |
* ``VkPhysicalDeviceLimits``: |
| 181 |
|
| 182 |
* ``shaderStorageImageExtendedFormats`` |
| 183 |
* ``shaderStorageImageWriteWithoutFormat`` |
| 184 |
* ``vertexPipelineStoresAndAtomics`` |
| 185 |
* ``fragmentStoresAndAtomics`` |
| 186 |
|
| 187 |
* For Vulkan 1.2 and above: |
| 188 |
|
| 189 |
* ``VkPhysicalDeviceVulkan11Features``: |
| 190 |
|
| 191 |
* :vk-feat:`shaderDrawParameters` |
| 192 |
|
| 193 |
* For Vulkan 1.1 and below: |
| 194 |
|
| 195 |
* Device extensions: |
| 196 |
|
| 197 |
* :ext:`VK_KHR_shader_draw_parameters` |
| 198 |
|
| 199 |
OpenGL 4.3 |
| 200 |
^^^^^^^^^^ |
| 201 |
|
| 202 |
For OpenGL 4.3 support, the following additional requirements must be |
| 203 |
met: |
| 204 |
|
| 205 |
* ``VkPhysicalDeviceFeatures``: |
| 206 |
|
| 207 |
* :vk-feat:`robustBufferAccess` |
| 208 |
|
| 209 |
* Formats requiring ``VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT``: |
| 210 |
|
| 211 |
* ``VK_FORMAT_R8G8B8A8_UNORM`` |
| 212 |
* ``VK_FORMAT_R8G8B8A8_SRGB`` |
| 213 |
* ``VK_FORMAT_R16_UNORM`` |
| 214 |
* ``VK_FORMAT_R16G16_UNORM`` |
| 215 |
* ``VK_FORMAT_R16_SNORM`` |
| 216 |
* ``VK_FORMAT_R16G16_SNORM`` |
| 217 |
* ``VK_FORMAT_D32_SFLOAT_S8_UINT`` |
| 218 |
|
| 219 |
OpenGL 4.4 |
| 220 |
^^^^^^^^^^ |
| 221 |
|
| 222 |
For OpenGL 4.4 support, the following additional requirements must be |
| 223 |
met: |
| 224 |
|
| 225 |
* Formats requiring ``VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT``: |
| 226 |
|
| 227 |
* ``VK_FORMAT_B10G11R11_UFLOAT_PACK32`` |
| 228 |
|
| 229 |
* For Vulkan 1.2 and above: |
| 230 |
|
| 231 |
* ``VkPhysicalDeviceVulkan12Features``: |
| 232 |
|
| 233 |
* ``samplerMirrorClampToEdge`` |
| 234 |
|
| 235 |
* For Vulkan 1.1 and below: |
| 236 |
|
| 237 |
* Device extensions: |
| 238 |
|
| 239 |
* :ext:`VK_KHR_sampler_mirror_clamp_to_edge` |
| 240 |
|
| 241 |
OpenGL 4.5 |
| 242 |
^^^^^^^^^^ |
| 243 |
|
| 244 |
For OpenGL 4.5 support, the following additional ``VkPhysicalDeviceFeatures`` |
| 245 |
are required to be supported |
| 246 |
|
| 247 |
* :vk-feat:`shaderCullDistance` |
| 248 |
|
| 249 |
OpenGL 4.6 |
| 250 |
^^^^^^^^^^ |
| 251 |
|
| 252 |
For OpenGL 4.6 support, the following additional requirements must be |
| 253 |
met: |
| 254 |
|
| 255 |
* ``VkPhysicalDeviceFeatures``: |
| 256 |
|
| 257 |
* :vk-feat:`samplerAnisotropy` |
| 258 |
* :vk-feat:`depthBiasClamp` |
| 259 |
|
| 260 |
* Device extensions: |
| 261 |
|
| 262 |
* :ext:`VK_KHR_draw_indirect_count` |
| 263 |
|
| 264 |
Performance |
| 265 |
----------- |
| 266 |
|
| 267 |
If you notice poor performance and high CPU usage while running an application, |
| 268 |
changing the descriptor manager may improve performance: |
| 269 |
|
| 270 |
.. envvar:: ZINK_DESCRIPTORS <mode> ("auto") |
| 271 |
|
| 272 |
``auto`` |
| 273 |
Automatically detect best mode. This is the default. |
| 274 |
``lazy`` |
| 275 |
Attempt to use the least amount of CPU by binding descriptors opportunistically. |
| 276 |
``db`` |
| 277 |
Use EXT_descriptor_buffer when possible. |
| 278 |
|
| 279 |
Debugging |
| 280 |
--------- |
| 281 |
|
| 282 |
There's a few tools that are useful for debugging Zink, like this environment |
| 283 |
variable: |
| 284 |
|
| 285 |
.. envvar:: ZINK_DEBUG |
| 286 |
|
| 287 |
Accepts the following comma-separated list of flags: |
| 288 |
|
| 289 |
``nir`` |
| 290 |
Print the NIR form of all shaders to stderr. |
| 291 |
``spirv`` |
| 292 |
Write the binary SPIR-V form of all compiled shaders to a file in the |
| 293 |
current directory, and print a message with the filename to stderr. |
| 294 |
``tgsi`` |
| 295 |
Print the TGSI form of TGSI shaders to stderr. |
| 296 |
``validation`` |
| 297 |
Dump Validation layer output. |
| 298 |
``sync`` |
| 299 |
Emit full synchronization barriers before every draw and dispatch. |
| 300 |
``compact`` |
| 301 |
Use a maximum of 4 descriptor sets |
| 302 |
``noreorder`` |
| 303 |
Do not reorder or optimize GL command streams |
| 304 |
``gpl`` |
| 305 |
Force using Graphics Pipeline Library for all shaders |
| 306 |
``rp`` |
| 307 |
Enable render pass optimizations (for tiling GPUs) |
| 308 |
``norp`` |
| 309 |
Disable render pass optimizations (for tiling GPUs) |
| 310 |
``map`` |
| 311 |
Print info about mapped VRAM |
| 312 |
``flushsync`` |
| 313 |
Force synchronous flushes/presents |
| 314 |
``noshobj`` |
| 315 |
Disable EXT_shader_object |
| 316 |
``optimal_keys`` |
| 317 |
Debug/use optimal_keys |
| 318 |
``noopt`` |
| 319 |
Disable async optimized pipeline compiles |
| 320 |
``nobgc`` |
| 321 |
Disable all async pipeline compiles |
| 322 |
``mem`` |
| 323 |
Enable memory allocation debugging |
| 324 |
``quiet`` |
| 325 |
Suppress probably-harmless warnings |
| 326 |
``nopc`` |
| 327 |
No precompilation |
| 328 |
``msaaopt`` |
| 329 |
Optimize out loads/stores of MSAA attachments (nonconformant) |
| 330 |
``rploads`` |
| 331 |
Zap renderpass loads for DONT_CARE |
| 332 |
``nogeneral`` |
| 333 |
Disable GENERAL layout usage for supported hardware |
| 334 |
|
| 335 |
Vulkan Validation Layers |
| 336 |
^^^^^^^^^^^^^^^^^^^^^^^^ |
| 337 |
|
| 338 |
Another useful tool for debugging is the `Vulkan Validation Layers |
| 339 |
<https://github.com/KhronosGroup/Vulkan-ValidationLayers/blob/main/README.md>`__. |
| 340 |
|
| 341 |
The validation layers effectively insert extra checking between Zink and the |
| 342 |
Vulkan driver, pointing out incorrect usage of the Vulkan API. The layers can |
| 343 |
be enabled by setting the environment variable :envvar:`VK_LOADER_LAYERS_ENABLE` to |
| 344 |
``VK_LAYER_KHRONOS_validation``. You can read more about the Validation Layers |
| 345 |
in the link above. |
| 346 |
|
| 347 |
Apple macOS and MoltenVK |
| 348 |
------------------------ |
| 349 |
|
| 350 |
Zink on macOS is experimental with very limited capabilities. |
| 351 |
The Vulkan SDK (1.3.250 or newer) is required to build Zink. |
| 352 |
Set the build option ``-Dmoltenvk-dir=<directory>`` to point at your Vulkan SDK install or MoltenVK build. |
| 353 |
Add Zink to the Gallium drivers build option ``-Dgallium-drivers=zink``. |
| 354 |
If installed using ``brew``, you can set ``-D moltenvk-dir=$(brew --prefix molten-vk)``. |
| 355 |
|
| 356 |
|
| 357 |
IRC |
| 358 |
--- |
| 359 |
|
| 360 |
In order to make things a bit easier to follow, we have decided to create our |
| 361 |
own IRC channel. If you're interested in contributing, or have any technical |
| 362 |
questions, don't hesitate to visit `#zink on OFTC |
| 363 |
<irc://irc.oftc.net/zink>`__ and say hi! |
| 364 |
|
| 365 |
|
| 366 |
.. _downloaded from GPUinfo.org: https://www.saschawillems.de/blog/2022/03/12/vulkan-profiles-support-for-the-vulkan-hardware-capability-viewer-and-database/ |