Flappy Pannus
Veteran
You Can Use Vulkan Without Pipelines Today
Khronus Blog said:Today, Khronos® is releasing a new multi-vendor Vulkan® extension that aims to radically simplify how applications specify shaders and shader state while maintaining Vulkan’s ethos of being a highly performant “API without secrets.”
This extension is VK_EXT_shader_object. It introduces a new VkShaderEXT object type which represents a single compiled shader stage, along with 4 new functions to manipulate and use VkShaderEXT objects.
Shader objects serve a role similar to pipelines but expose a simpler, more flexible interface designed to empower applications whose architectures and/or needs for “dynamism” might have previously made the use of pipelines difficult. In environments where VK_EXT_shader_object is supported, applications can choose to use only pipelines, only shader objects, or an arbitrary mix of the two.
In comparison with pipelines, shader objects differ in a number of key ways:
- Pipelines require every desired combination of shaders (all stages when using conventional “monolithic” pipelines, or certain pre-defined combinations of stages when using pipeline libraries) to be compiled together, whereas shader objects allow stages to be compiled in arbitrary combinations, including compiling every shader individually.
- With pipelines, linking is an explicit step that creates a new object with its own lifetime that needs to be managed by the application. With shader objects, linking is simply a creation-time promise from the application to the implementation that it will always use certain combinations of shader objects together.
- Pipelines must always be linked before being used, whereas linking shader objects is optional.
- Pipelines allow implementations to require some state to be statically provided at compile time, whereas with shader objects all state is always set dynamically and is independent from shaders.
- Pipelines require rendering attachment formats to be specified at pipeline creation time, whereas shader objects don’t. Shader objects can be used with any valid combination of attachment formats supported by the device.
- With pipelines, compiled shader code can be retrieved and reused by the application in the form of a pipeline cache, but this data is not usable by itself to create new pipelines. With shader objects, compiled shader code can be retrieved directly from any shader object and is guaranteed to be usable to create an equivalent shader object on any compatible physical device without the need to provide the original SPIR-V.
In summary, shader objects impose substantially fewer restrictions on applications compared to pipelines, and enable dynamism-heavy applications like games and game engines to avoid the explosive pipeline permutation combinatorics, which until now might have been seen as a cost of admission for access to modern graphics APIs.