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.
Features¶
The feature-level of Zink depends on two things; what’s implemented in Zink, as well as the features of the Vulkan driver.
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:logicOpfillModeNonSolidwideLineslargePointsalphaToOneshaderClipDistance
Device extensions:
VK_EXT_line_rasterization, with the following
VkPhysicalDeviceLineRasterizationFeaturesEXT:rectangularLinesbresenhamLinessmoothLinesstippledRectangularLinesstippledBresenhamLinesstippledSmoothLines
In addition to this, VK_KHR_external_memory is required to support the DRI code-path.
We also require either the VK_EXT_scalar_block_layout extension or
Vulkan 1.2, with the scalarBlockLayout feature.
OpenGL 3.0¶
For OpenGL 3.0 support, the following additional requirements needs to be supported:
VkPhysicalDeviceFeatures:independentBlend
Device extensions:
OpenGL 3.1¶
For OpenGL 3.1 support, the following additional VkPhysicalDeviceLimits
are required:
maxPerStageDescriptorSamplers≥ 16
OpenGL 3.2¶
For OpenGL 3.2 support, the following additional VkPhysicalDeviceFeatures
are required to be supported, although some of these might not actually get
verified:
depthClampgeometryShadershaderTessellationAndGeometryPointSize
OpenGL 3.3¶
For OpenGL 3.3 support, the following additional requirements needs to be supported, although some of these might not actually get verified:
VkPhysicalDeviceFeatures:occlusionQueryPrecise
Device extensions:
OpenGL 4.0¶
For OpenGL 4.0 support, the following additional requirements needs to be supported:
VkPhysicalDeviceFeatures:sampleRateShadingtessellationShaderimageCubeArray
Device extensions:
Formats requiring
VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT:VK_FORMAT_R32G32B32_SFLOATVK_FORMAT_R32G32B32_SINTVK_FORMAT_R32G32B32_UINT
OpenGL 4.1¶
For OpenGL 4.1 support, the following additional VkPhysicalDeviceLimits
are required:
maxImageDimension2D≥ 16384maxViewports≥ 16
OpenGL 4.2¶
For OpenGL 4.2 support, the following additional requirements needs to be supported:
VkPhysicalDeviceLimits:shaderStorageImageExtendedFormatsshaderStorageImageWriteWithoutFormat
For Vulkan 1.2 and above:
VkPhysicalDeviceVulkan11Features:shaderDrawParametersvertexPipelineStoresAndAtomicsfragmentStoresAndAtomicstextureCompressionBC
For Vulkan 1.1 and below:
Device extensions:
Formats requiring
VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT:VK_FORMAT_BC7_UNORM_BLOCKVK_FORMAT_BC7_SRGB_BLOCKVK_FORMAT_BC6H_SFLOAT_BLOCKVK_FORMAT_BC6H_UFLOAT_BLOCK
OpenGL 4.3¶
For OpenGL 4.3 support, the following additional requirements needs to be supported:
VkPhysicalDeviceFeatures:robustBufferAccessmultiViewport
Formats requiring
VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT:VK_FORMAT_R8G8B8A8_UNORMVK_FORMAT_R8G8B8A8_SRGBVK_FORMAT_R16_UNORMVK_FORMAT_R16G16_UNORMVK_FORMAT_R16_SNORMVK_FORMAT_R16G16_SNORMVK_FORMAT_D32_SFLOAT_S8_UINT
OpenGL 4.4¶
For OpenGL 4.4 support, the following additional requirements needs to be supported:
Formats requiring
VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT:VK_FORMAT_B10G11R11_UFLOAT_PACK32
Device extensions:
OpenGL 4.5¶
For OpenGL 4.5 support, the following additional VkPhysicalDeviceFeatures
are required to be supported
shaderCullDistance
OpenGL 4.6¶
For OpenGL 4.6 support, the following additional VkPhysicalDeviceFeatures
are required to be supported
VkPhysicalDeviceFeatures:samplerAnisotropypipelineStatisticsQuerydepthBiasClamp
Device extensions:
Performance¶
If you notice poor performance and high CPU usage while running an application, changing the descriptor manager may improve performance:
-
ZINK_DESCRIPTORSType: mode, Default: "auto"¶
autoAutomatically detect best mode. This is the default.
lazyDisable caching and attempt to use the least amount of CPU.
nofallbackAlways use caching to try reducing GPU churn.
notemplatesThe same as auto, but disables the use of VK_KHR_descriptor_templates.
Debugging¶
There’s a few tools that are useful for debugging Zink, like this environment variable:
-
ZINK_DEBUGType: flags, Default: ""¶
nirPrint the NIR form of all shaders to stderr.
spirvWrite 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.
tgsiPrint the TGSI form of TGSI shaders to stderr.
validationDump Validation layer output.
Vulkan Validation Layers¶
Another useful tool for debugging is the Vulkan Validation Layers.
The validation layers effectively insert extra checking between Zink and the
Vulkan driver, pointing out incorrect usage of the Vulkan API. The layers can
be enabled by setting the environment variable VK_INSTANCE_LAYERS to
“VK_LAYER_KHRONOS_validation”. You can read more about the Validation Layers
in the link above.
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 questions, don’t hesitate to visit #zink on OFTC and say hi!