17ec681f3SmrgZink 27ec681f3Smrg==== 37ec681f3Smrg 47ec681f3SmrgOverview 57ec681f3Smrg-------- 67ec681f3Smrg 77ec681f3SmrgThe Zink driver is a Gallium driver that emits Vulkan API calls instead 87ec681f3Smrgof targeting a specific GPU architecture. This can be used to get full 97ec681f3Smrgdesktop OpenGL support on devices that only support Vulkan. 107ec681f3Smrg 117ec681f3SmrgFeatures 127ec681f3Smrg-------- 137ec681f3Smrg 147ec681f3SmrgThe feature-level of Zink depends on two things; what's implemented in Zink, 157ec681f3Smrgas well as the features of the Vulkan driver. 167ec681f3Smrg 177ec681f3SmrgOpenGL 2.1 187ec681f3Smrg^^^^^^^^^^ 197ec681f3Smrg 207ec681f3SmrgOpenGL 2.1 is the minimum version Zink can support, and will always be 217ec681f3Smrgexposed, given Vulkan support. There's a few features that are required 227ec681f3Smrgfor correct behavior, but not all of these are validated; instead you'll 237ec681f3Smrgsee rendering-issues and likely validation error, or even crashes. 247ec681f3Smrg 257ec681f3SmrgHere's a list of those requirements: 267ec681f3Smrg 277ec681f3Smrg* Vulkan 1.0 287ec681f3Smrg* ``VkPhysicalDeviceFeatures``: 297ec681f3Smrg 307ec681f3Smrg * ``logicOp`` 317ec681f3Smrg * ``fillModeNonSolid`` 327ec681f3Smrg * ``wideLines`` 337ec681f3Smrg * ``largePoints`` 347ec681f3Smrg * ``alphaToOne`` 357ec681f3Smrg * ``shaderClipDistance`` 367ec681f3Smrg 377ec681f3Smrg* Device extensions: 387ec681f3Smrg 397ec681f3Smrg * `VK_KHR_maintenance1`_ 407ec681f3Smrg * `VK_EXT_custom_border_color`_ 417ec681f3Smrg * `VK_EXT_provoking_vertex`_ 427ec681f3Smrg * `VK_EXT_line_rasterization`_, with the following ``VkPhysicalDeviceLineRasterizationFeaturesEXT``: 437ec681f3Smrg 447ec681f3Smrg * ``rectangularLines`` 457ec681f3Smrg * ``bresenhamLines`` 467ec681f3Smrg * ``smoothLines`` 477ec681f3Smrg * ``stippledRectangularLines`` 487ec681f3Smrg * ``stippledBresenhamLines`` 497ec681f3Smrg * ``stippledSmoothLines`` 507ec681f3Smrg 517ec681f3SmrgIn addition to this, `VK_KHR_external_memory`_ is required to support the 527ec681f3SmrgDRI code-path. 537ec681f3Smrg 547ec681f3SmrgWe also require either the `VK_EXT_scalar_block_layout`_ extension or 557ec681f3SmrgVulkan 1.2, with the ``scalarBlockLayout`` feature. 567ec681f3Smrg 577ec681f3SmrgOpenGL 3.0 587ec681f3Smrg^^^^^^^^^^ 597ec681f3Smrg 607ec681f3Smrg 617ec681f3SmrgFor OpenGL 3.0 support, the following additional requirements needs to be 627ec681f3Smrgsupported: 637ec681f3Smrg 647ec681f3Smrg* ``VkPhysicalDeviceFeatures``: 657ec681f3Smrg 667ec681f3Smrg * ``independentBlend`` 677ec681f3Smrg 687ec681f3Smrg* Device extensions: 697ec681f3Smrg 707ec681f3Smrg * `VK_EXT_transform_feedback`_ 717ec681f3Smrg * `VK_EXT_conditional_rendering`_ 727ec681f3Smrg 737ec681f3Smrg 747ec681f3SmrgOpenGL 3.1 757ec681f3Smrg^^^^^^^^^^ 767ec681f3Smrg 777ec681f3SmrgFor OpenGL 3.1 support, the following additional ``VkPhysicalDeviceLimits`` 787ec681f3Smrgare required: 797ec681f3Smrg 807ec681f3Smrg* ``maxPerStageDescriptorSamplers`` ≥ 16 817ec681f3Smrg 827ec681f3SmrgOpenGL 3.2 837ec681f3Smrg^^^^^^^^^^ 847ec681f3Smrg 857ec681f3SmrgFor OpenGL 3.2 support, the following additional ``VkPhysicalDeviceFeatures`` 867ec681f3Smrgare required to be supported, although some of these might not actually get 877ec681f3Smrgverified: 887ec681f3Smrg 897ec681f3Smrg* ``depthClamp`` 907ec681f3Smrg* ``geometryShader`` 917ec681f3Smrg* ``shaderTessellationAndGeometryPointSize`` 927ec681f3Smrg 937ec681f3SmrgOpenGL 3.3 947ec681f3Smrg^^^^^^^^^^ 957ec681f3Smrg 967ec681f3SmrgFor OpenGL 3.3 support, the following additional requirements needs to be 977ec681f3Smrgsupported, although some of these might not actually get verified: 987ec681f3Smrg 997ec681f3Smrg* ``VkPhysicalDeviceFeatures``: 1007ec681f3Smrg 1017ec681f3Smrg * ``occlusionQueryPrecise`` 1027ec681f3Smrg 1037ec681f3Smrg* Device extensions: 1047ec681f3Smrg 1057ec681f3Smrg * `VK_EXT_vertex_attribute_divisor`_ 1067ec681f3Smrg 1077ec681f3SmrgOpenGL 4.0 1087ec681f3Smrg^^^^^^^^^^ 1097ec681f3Smrg 1107ec681f3SmrgFor OpenGL 4.0 support, the following additional requirements needs to be 1117ec681f3Smrgsupported: 1127ec681f3Smrg 1137ec681f3Smrg* ``VkPhysicalDeviceFeatures``: 1147ec681f3Smrg 1157ec681f3Smrg * ``sampleRateShading`` 1167ec681f3Smrg * ``tessellationShader`` 1177ec681f3Smrg * ``imageCubeArray`` 1187ec681f3Smrg 1197ec681f3Smrg* Device extensions: 1207ec681f3Smrg 1217ec681f3Smrg * `VK_KHR_maintenance2`_ 1227ec681f3Smrg 1237ec681f3Smrg* Formats requiring ``VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT``: 1247ec681f3Smrg 1257ec681f3Smrg * ``VK_FORMAT_R32G32B32_SFLOAT`` 1267ec681f3Smrg * ``VK_FORMAT_R32G32B32_SINT`` 1277ec681f3Smrg * ``VK_FORMAT_R32G32B32_UINT`` 1287ec681f3Smrg 1297ec681f3SmrgOpenGL 4.1 1307ec681f3Smrg^^^^^^^^^^ 1317ec681f3Smrg 1327ec681f3SmrgFor OpenGL 4.1 support, the following additional ``VkPhysicalDeviceLimits`` 1337ec681f3Smrgare required: 1347ec681f3Smrg 1357ec681f3Smrg* ``maxImageDimension2D`` ≥ 16384 1367ec681f3Smrg* ``maxViewports`` ≥ 16 1377ec681f3Smrg 1387ec681f3SmrgOpenGL 4.2 1397ec681f3Smrg^^^^^^^^^^ 1407ec681f3Smrg 1417ec681f3SmrgFor OpenGL 4.2 support, the following additional requirements needs to be 1427ec681f3Smrgsupported: 1437ec681f3Smrg 1447ec681f3Smrg* ``VkPhysicalDeviceLimits``: 1457ec681f3Smrg 1467ec681f3Smrg * ``shaderStorageImageExtendedFormats`` 1477ec681f3Smrg * ``shaderStorageImageWriteWithoutFormat`` 1487ec681f3Smrg 1497ec681f3Smrg* For Vulkan 1.2 and above: 1507ec681f3Smrg 1517ec681f3Smrg * ``VkPhysicalDeviceVulkan11Features``: 1527ec681f3Smrg 1537ec681f3Smrg * ``shaderDrawParameters`` 1547ec681f3Smrg * ``vertexPipelineStoresAndAtomics`` 1557ec681f3Smrg * ``fragmentStoresAndAtomics`` 1567ec681f3Smrg * ``textureCompressionBC`` 1577ec681f3Smrg 1587ec681f3Smrg* For Vulkan 1.1 and below: 1597ec681f3Smrg 1607ec681f3Smrg * Device extensions: 1617ec681f3Smrg 1627ec681f3Smrg * `VK_KHR_shader_draw_parameters`_ 1637ec681f3Smrg 1647ec681f3Smrg* Formats requiring ``VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT``: 1657ec681f3Smrg 1667ec681f3Smrg * ``VK_FORMAT_BC7_UNORM_BLOCK`` 1677ec681f3Smrg * ``VK_FORMAT_BC7_SRGB_BLOCK`` 1687ec681f3Smrg * ``VK_FORMAT_BC6H_SFLOAT_BLOCK`` 1697ec681f3Smrg * ``VK_FORMAT_BC6H_UFLOAT_BLOCK`` 1707ec681f3Smrg 1717ec681f3SmrgOpenGL 4.3 1727ec681f3Smrg^^^^^^^^^^ 1737ec681f3Smrg 1747ec681f3SmrgFor OpenGL 4.3 support, the following additional requirements needs to be 1757ec681f3Smrgsupported: 1767ec681f3Smrg 1777ec681f3Smrg* ``VkPhysicalDeviceFeatures``: 1787ec681f3Smrg 1797ec681f3Smrg * ``robustBufferAccess`` 1807ec681f3Smrg * ``multiViewport`` 1817ec681f3Smrg 1827ec681f3Smrg* Formats requiring ``VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT``: 1837ec681f3Smrg 1847ec681f3Smrg * ``VK_FORMAT_R8G8B8A8_UNORM`` 1857ec681f3Smrg * ``VK_FORMAT_R8G8B8A8_SRGB`` 1867ec681f3Smrg * ``VK_FORMAT_R16_UNORM`` 1877ec681f3Smrg * ``VK_FORMAT_R16G16_UNORM`` 1887ec681f3Smrg * ``VK_FORMAT_R16_SNORM`` 1897ec681f3Smrg * ``VK_FORMAT_R16G16_SNORM`` 1907ec681f3Smrg * ``VK_FORMAT_D32_SFLOAT_S8_UINT`` 1917ec681f3Smrg 1927ec681f3SmrgOpenGL 4.4 1937ec681f3Smrg^^^^^^^^^^ 1947ec681f3Smrg 1957ec681f3SmrgFor OpenGL 4.4 support, the following additional requirements needs to be 1967ec681f3Smrgsupported: 1977ec681f3Smrg 1987ec681f3Smrg* Formats requiring ``VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT``: 1997ec681f3Smrg 2007ec681f3Smrg * ``VK_FORMAT_B10G11R11_UFLOAT_PACK32`` 2017ec681f3Smrg 2027ec681f3Smrg* Device extensions: 2037ec681f3Smrg 2047ec681f3Smrg * `VK_KHR_sampler_mirror_clamp_to_edge`_ 2057ec681f3Smrg 2067ec681f3SmrgOpenGL 4.5 2077ec681f3Smrg^^^^^^^^^^ 2087ec681f3Smrg 2097ec681f3SmrgFor OpenGL 4.5 support, the following additional ``VkPhysicalDeviceFeatures`` 2107ec681f3Smrgare required to be supported 2117ec681f3Smrg 2127ec681f3Smrg* ``shaderCullDistance`` 2137ec681f3Smrg 2147ec681f3SmrgOpenGL 4.6 2157ec681f3Smrg^^^^^^^^^^ 2167ec681f3Smrg 2177ec681f3SmrgFor OpenGL 4.6 support, the following additional ``VkPhysicalDeviceFeatures`` 2187ec681f3Smrgare required to be supported 2197ec681f3Smrg 2207ec681f3Smrg* ``VkPhysicalDeviceFeatures``: 2217ec681f3Smrg 2227ec681f3Smrg * ``samplerAnisotropy`` 2237ec681f3Smrg * ``pipelineStatisticsQuery`` 2247ec681f3Smrg * ``depthBiasClamp`` 2257ec681f3Smrg 2267ec681f3Smrg* Device extensions: 2277ec681f3Smrg 2287ec681f3Smrg * `VK_KHR_draw_indirect_count`_ 2297ec681f3Smrg 2307ec681f3SmrgPerformance 2317ec681f3Smrg----------- 2327ec681f3Smrg 2337ec681f3SmrgIf you notice poor performance and high CPU usage while running an application, 2347ec681f3Smrgchanging the descriptor manager may improve performance: 2357ec681f3Smrg 2367ec681f3Smrg.. envvar:: ZINK_DESCRIPTORS <mode> ("auto") 2377ec681f3Smrg 2387ec681f3Smrg``auto`` 2397ec681f3Smrg Automatically detect best mode. This is the default. 2407ec681f3Smrg``lazy`` 2417ec681f3Smrg Disable caching and attempt to use the least amount of CPU. 2427ec681f3Smrg``nofallback`` 2437ec681f3Smrg Always use caching to try reducing GPU churn. 2447ec681f3Smrg``notemplates`` 2457ec681f3Smrg The same as `auto`, but disables the use of `VK_KHR_descriptor_templates`. 2467ec681f3Smrg 2477ec681f3SmrgDebugging 2487ec681f3Smrg--------- 2497ec681f3Smrg 2507ec681f3SmrgThere's a few tools that are useful for debugging Zink, like this environment 2517ec681f3Smrgvariable: 2527ec681f3Smrg 2537ec681f3Smrg.. envvar:: ZINK_DEBUG <flags> ("") 2547ec681f3Smrg 2557ec681f3Smrg``nir`` 2567ec681f3Smrg Print the NIR form of all shaders to stderr. 2577ec681f3Smrg``spirv`` 2587ec681f3Smrg Write the binary SPIR-V form of all compiled shaders to a file in the 2597ec681f3Smrg current directory, and print a message with the filename to stderr. 2607ec681f3Smrg``tgsi`` 2617ec681f3Smrg Print the TGSI form of TGSI shaders to stderr. 2627ec681f3Smrg``validation`` 2637ec681f3Smrg Dump Validation layer output. 2647ec681f3Smrg 2657ec681f3SmrgVulkan Validation Layers 2667ec681f3Smrg^^^^^^^^^^^^^^^^^^^^^^^^ 2677ec681f3Smrg 2687ec681f3SmrgAnother useful tool for debugging is the `Vulkan Validation Layers 2697ec681f3Smrg<https://github.com/KhronosGroup/Vulkan-ValidationLayers/blob/master/README.md>`_. 2707ec681f3Smrg 2717ec681f3SmrgThe validation layers effectively insert extra checking between Zink and the 2727ec681f3SmrgVulkan driver, pointing out incorrect usage of the Vulkan API. The layers can 2737ec681f3Smrgbe enabled by setting the environment variable :envvar:`VK_INSTANCE_LAYERS` to 2747ec681f3Smrg"VK_LAYER_KHRONOS_validation". You can read more about the Validation Layers 2757ec681f3Smrgin the link above. 2767ec681f3Smrg 2777ec681f3SmrgIRC 2787ec681f3Smrg--- 2797ec681f3Smrg 2807ec681f3SmrgIn order to make things a bit easier to follow, we have decided to create our 2817ec681f3Smrgown IRC channel. If you're interested in contributing, or have any technical 2827ec681f3Smrgquestions, don't hesitate to visit `#zink on OFTC 2837ec681f3Smrg<irc://irc.oftc.net/zink>`__ and say hi! 2847ec681f3Smrg 2857ec681f3Smrg 2867ec681f3Smrg.. _VK_KHR_maintenance1: https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VK_KHR_maintenance1.html 2877ec681f3Smrg.. _VK_KHR_external_memory: https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VK_KHR_external_memory.html 2887ec681f3Smrg.. _VK_EXT_scalar_block_layout: https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VK_EXT_scalar_block_layout.html 2897ec681f3Smrg.. _VK_EXT_transform_feedback: https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VK_EXT_transform_feedback.html 2907ec681f3Smrg.. _VK_EXT_conditional_rendering: https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VK_EXT_conditional_rendering.html 2917ec681f3Smrg.. _VK_EXT_vertex_attribute_divisor: https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VK_EXT_vertex_attribute_divisor.html 2927ec681f3Smrg.. _VK_KHR_maintenance2: https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VK_KHR_maintenance2.html 2937ec681f3Smrg.. _VK_KHR_shader_draw_parameters: https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VK_KHR_shader_draw_parameters.html 2947ec681f3Smrg.. _VK_KHR_draw_indirect_count: https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VK_KHR_draw_indirect_count.html 2957ec681f3Smrg.. _VK_KHR_sampler_mirror_clamp_to_edge: https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VK_KHR_sampler_mirror_clamp_to_edge.html 2967ec681f3Smrg.. _VK_EXT_custom_border_color: https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VK_EXT_custom_border_color.html 2977ec681f3Smrg.. _VK_EXT_provoking_vertex: https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VK_EXT_provoking_vertex.html 2987ec681f3Smrg.. _VK_EXT_line_rasterization: https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VK_EXT_line_rasterization.html 299