1// Copyright 2021-2024 The Khronos Group Inc. 2// 3// SPDX-License-Identifier: CC-BY-4.0 4 5= VK_KHR_maintenance5 6:toc: left 7:refpage: https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/ 8:sectnums: 9 10This proposal details and addresses the issues solved by the `VK_KHR_maintenance5` extension. 11 12== Problem Statement 13 14Over time, a collection of minor features, none of which would warrant an entire extension of their own, requires the creation of a maintenance extension. 15 16The following is a list of issues considered in this proposal: 17 18 * Allow PointSize to take a default value of 1.0 when it is not written, rather than being undefined 19 * A device property to indicate whether non-strict lines use parallelogram or Bresenham. 20 * Add a A1B5G5R5 format (corresponding to `GL_UNSIGNED_SHORT_1_5_5_5_REV`) 21 * Allow vkGetPhysicalDeviceFormatProperties with unknown formats 22 * Add a vkGetRenderAreaGranularity equivalent for dynamic rendering 23 * Require vkGetDeviceProcAddr to return NULL for functions beyond app version 24 * Index buffer range specification 25 * Add a property to indicate multisample coverage operations are performed after sample counting in EarlyFragmentTests mode 26 * Add VK_REMAINING_ARRAY_LAYERS support to VkImageSubresourceLayers.layerCount 27 * Allow VK_WHOLE_SIZE for pSizes argument of vkCmdBindVertexBuffers2 28 * Add support for a new vkGetDeviceImageSubresourceLayout to allow a vkGetImageSubresourceLayout query without having to create a dummy image 29 * Ensure we have a reliable/deterministic way to detect device loss 30 * We are running out of spare bits in various FlagBits 31 * Add a property to indicate sample mask test operations are performed after sample counting in EarlyFragmentTests mode 32 * Deprecate shader modules to avoid management of that object in the API 33 * Add a A8_UNORM format 34 * Relax VkBufferView creation requirements 35 * Appearance when using VK_POLYGON_MODE_POINT together with PointSize 36 * Enabling copies between images of any dimensionality 37 * Need a way to indicate when SWIZZLE_ONE has defined results when used with depth-stencil formats 38 39 40== Issue Details and Solution Space 41 42=== Default PointSize of 1.0 43 44It is unclear in the specification if the `PointSize` builtin is required to be written, and if it is not, what the default size is. 45 46=== Indication of parallelogram or Bresenham non-strict lines 47 48Some applications need to know whether the rasterization algorithm used for non-strict lines is parallelogram or Bresenham style. 49 50=== A1B5G5R5 format 51 52There is a request to add a format equivalent to GL_UNSIGNED_SHORT_1_5_5_5_REV for emulation. 53 54=== vkGetPhysicalDeviceFormatProperties with unknown formats 55 56The current specification prohibits `vkGetPhysicalDeviceFormatProperties` from being called with a `VkFormat` that is from an API version higher than that of the device, or from a device-level extension that is not supported by the device. 57In order to query a format's support, applications must first query the relevant extension/version/feature beforehand, complicating format queries. 58 59=== A vkGetRenderAreaGranularity equivalent for dynamic rendering 60 61Some tile-based GPUs can benefit from providing an optimal render area granularity as the basis for a performance hint. 62 63=== vkGetDeviceProcAddr to return NULL for functions beyond app version 64 65Existing implementations have different behaviour when returning function pointers from `vkGetDeviceProcAddr()` 66for supported core functions of versions greater than than the version requested by the application. 67 68=== Add vkCmdBindIndexBuffer2KHR with a size parameter 69 70With `vkCmdBindIndexBuffer`, it is not possible to communicate the size of the subrange buffer used as index data. 71Robustness therefore operates on the size of the underlying buffer, which may be larger than the subrange that contains index data. 72A new function can be introduced to add the necessary size information for robustness. 73 74=== Multisample coverage operations and sample counting property 75 76Some hardware performs sample counting after multisample coverage operations when the EarlyFragmentTests execution mode is declared in a pixel shader, but the specification says "If the fragment shader declares the EarlyFragmentTests execution mode, fragment shading and multisample coverage operations are instead performed after sample counting." 77 78=== VK_REMAINING_ARRAY_LAYERS for VkImageSubresourceLayers.layerCount 79 80`layerCount` in `VkImageSubresourceLayers` unintentionally does not support `VK_REMAINING_ARRAY_LAYERS`. 81 82=== VK_WHOLE_SIZE for pSizes argument of vkCmdBindVertexBuffers2 83 84`pSizes` in `vkCmdBindVertexBuffers2` unintentionally does not support `VK_WHOLE_SIZE`. 85 86=== vkGetImageSubresourceLayout query without having to create a dummy image 87 88There is a potential implementation overhead when querying the subresource layout of an image due to object creation. This overhead could be reduced by a function that works in a similar way to `vkGetDeviceImageMemoryRequirements()` which uses the image creation properties, rather than an image object, to perform the query. 89 90=== Reliable/deterministic way to detect device loss 91 92All existing entrypoints that are capable of returning 93ename:VK_ERROR_DEVICE_LOST have some form of exemption or 94special-case allowing for other return values to be returned even when a device 95is irrecoverably lost. These exemptions are all necessary due to the 96asynchronous nature of device-loss detection, but this makes it difficult for 97application developers to reason about how to reliably detect device-loss. 98 99=== Lack of available flag bits 100 101Both `VkPipelineCreateFlagBits` and `VkBufferCreateFlagBits` are running out of available bits for new extensions. 102 103=== Sample mask test and sample counting property 104 105The specification says "If the fragment shader declares the EarlyFragmentTests 106execution mode, fragment shading and multisample coverage operations are instead 107performed after sample counting", but some hardware performs the sample mask test 108after sample counting operations when the EarlyFragmentTests execution mode is 109declared in a pixel shader. 110 111=== Deprecation of VkShaderModule 112 113Shader modules are transient objects used to create pipelines, 114originally put in the Vulkan API to enable pre-compilation of 115SPIR-V to reduce duplicated work at pipeline creation. 116 117In practice though, few implementations do anything useful with these objects, and they 118end up just being an unnecessary copy and a waste of memory while they 119exist. 120They also are yet another object for applications to manage, which is 121development overhead that would be useful to remove. 122 123Solutions here should have the following properties: 124 125 * Not require object creation 126 * Allow shader code to be passed directly from application memory to the pipeline 127 creation 128 * Be as simple as possible 129 130link:{refpage}VK_EXT_graphics_pipeline_library.html[VK_EXT_graphics_pipeline_library] 131already introduced a simple way to do this, which is adopted by this 132extension. 133 134=== A8_UNORM format === 135 136This provides direct compatibility with D3D11 and D3D12 for layering. 137 138=== Relax VkBufferView creation requirement 139 140Some users of the Vulkan API (for example, OpenGL API emulation libraries) have a 141hard time figuring out in advance how one of their VkBuffer objects is going to be 142used with VkBufferView. Relaxing the requirement that the VkBufferView format is 143supported for all the usages of the VkBuffer would help. 144 145=== Appearance when using VK_POLYGON_MODE_POINT together with PointSize 146 147Some hardware does not take point size into account when rasterizing polygons with VK_POLYGON_MODE_POINT. 148 149=== Copying between different image types 150 151Copies between different image types other than between 2D and 3D is unclear, and untested. This flexibility is useful for some applications. 152 153=== Need a way to indicate when SWIZZLE_ONE has defined results when used with depth-stencil formats === 154 155Some implementations have undefined results when SWIZZLE_ONE is used with a depth-stencil format, so the default Vulkan behavior in this case is undefined. 156For many implementations this combination _is_ defined, however, so it is useful to be able to determine programmatically when that is the case. 157 158== Proposal 159 160Items introduced by this extension are: 161 162=== Default PointSize of 1.0 163 164Points now take a default size of 1.0 if the `PointSize` builtin is not written. 165 166=== Indication of parallelogram or Bresenham non-strict lines 167 168Two new properties are added: 169 170 - `nonStrictSinglePixelWideLinesUseParallelogram` reports the rasterization algorithm used for lines of width 1.0 171 - `nonStrictWideLinesUseParallelogram` reports the rasterization algorithm used for lines of width greater than 1.0 172 173=== A1B5G5R5 format 174 175An optional format VK_FORMAT_A1B5G5R5_UNORM_PACK16_KHR is added. 176 177=== vkGetPhysicalDeviceFormatProperties with unknown formats 178 179Physical-device-level functions can now be called with any value in the valid range for a type beyond the defined enumerants, such that applications can avoid checking individual features, extensions, or versions before querying supported properties of a particular enumerant. 180 181=== A vkGetRenderAreaGranularity equivalent for dynamic rendering 182 183A new function provides the ability to query the implementation's preferred 184render area granularity for a render pass instance: 185 186[source,c] 187---- 188void vkGetRenderingAreaGranularityKHR( 189 VkDevice device, 190 const VkRenderingAreaInfoKHR* pRenderingAreaInfo, 191 VkExtent2D* pGranularity); 192---- 193 194=== vkGetDeviceProcAddr to return NULL for functions beyond app version 195 196The specification has been changed to require `vkGetDeviceProcAddr()` to return `NULL` for supported core functions beyond the version requested by the application. 197 198=== Add vkCmdBindIndexBuffer2KHR with a size parameter 199 200A new entry point `vkCmdBindIndexBuffer2KHR` is added: 201 202[source,c] 203---- 204VKAPI_ATTR void VKAPI_CALL vkCmdBindIndexBuffer2KHR( 205 VkCommandBuffer commandBuffer, 206 VkBuffer buffer, 207 VkDeviceSize offset, 208 VkDeviceSize size, 209 VkIndexType indexType); 210---- 211 212=== Multisample coverage operations and sample counting property 213 214A new `earlyFragmentMultisampleCoverageAfterSampleCounting` property is added. 215 216=== VK_REMAINING_ARRAY_LAYERS for VkImageSubresourceLayers.layerCount 217 218Support for using `VK_REMAINING_ARRAY_LAYERS` as the `layerCount` member of `VkImageSubresourceLayers` is added. 219 220=== VK_WHOLE_SIZE for pSizes argument of vkCmdBindVertexBuffers2 221 222Support for using `VK_WHOLE_SIZE` in the `pSizes` parameter of `vkCmdBindVertexBuffers2` is added. 223 224=== vkGetImageSubresourceLayout query without having to create a dummy image 225 226A new `vkGetDeviceImageSubresourceLayoutKHR` function provides the ability to query the subresource layout for an image without requiring an image object, and a KHR version of `vkGetImageSubresourceLayout2EXT`: 227 228[source,c] 229---- 230 231typedef struct VkImageSubresource2KHR { 232 VkStructureType sType; 233 void* pNext; 234 VkImageSubresource imageSubresource; 235} VkImageSubresource2KHR; 236 237typedef struct VkSubresourceLayout2KHR { 238 VkStructureType sType; 239 void* pNext; 240 VkSubresourceLayout subresourceLayout; 241} VkSubresourceLayout2KHR; 242 243typedef VkSubresourceLayout2KHR VkSubresourceLayout2EXT; 244typedef VkImageSubresource2KHR VkImageSubresource2EXT; 245 246typedef struct VkDeviceImageSubresourceInfoKHR { 247 VkStructureType sType; 248 const void* pNext; 249 const VkImageCreateInfo* pCreateInfo; 250 const VkImageSubresource2KHR* pSubresource; 251} VkDeviceImageSubresourceInfoKHR; 252 253VKAPI_ATTR void VKAPI_CALL vkGetDeviceImageSubresourceLayoutKHR( 254 VkDevice device, 255 const VkDeviceImageSubresourceInfoKHR* pInfo, 256 VkSubresourceLayout2KHR* pLayout); 257 258VKAPI_ATTR void VKAPI_CALL vkGetImageSubresourceLayout2KHR( 259 VkDevice device, 260 VkImage image, 261 const VkImageSubresource2KHR* pSubresource, 262 VkSubresourceLayout2KHR* pLayout); 263---- 264 265=== Reliable/deterministic way to detect device loss 266 267Following device-loss, entrypoints that may return `VK_ERROR_DEVICE_LOST` do so 268in a more consistent manner. 269 270=== Lack of available flag bits 271 272Two new flags words are added, along with structures to use them: 273 274* `VkPipelineCreateFlagBits2KHR` and `VkPipelineCreateFlags2CreateInfoKHR` 275* `VkBufferUsageFlagBits2KHR` and `VkBufferUsageFlags2CreateInfoKHR` 276 277=== Sample mask test and sample counting property 278 279A new `earlyFragmentSampleMaskTestBeforeSampleCounting` property is added. 280 281=== Deprecating Shader Modules 282 283Shader modules are deprecated by allowing 284link:{refpage}VkShaderModuleCreateInfo.html[VkShaderModuleCreateInfo] to be 285chained to 286link:{refpage}VkPipelineShaderStageCreateInfo.html[VkPipelineShaderStageCreateInfo], 287and allowing the link:{refpage}VkShaderModule.html[VkShaderModule] to be 288link:{refpage}VK_NULL_HANDLE.html[VK_NULL_HANDLE] in this case. 289Shader modules are not being removed, but it is recommended to not use them in order to save memory and avoid unnecessary copies. 290 291For example, where previously an application would have to create a shader 292module, it can now simply do this: 293 294[source,c] 295---- 296VkShaderModuleCreateInfo computeShader = { 297 .sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO, 298 .pNext = NULL, 299 .flags = 0, 300 .codeSize = ..., 301 .pCode = ... }; 302 303VkComputePipelineCreateInfo computePipeline = { 304 .sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, 305 .pNext = NULL, 306 .flags = 0, 307 .stage = { 308 .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, 309 .pNext = &computeShader, 310 .flags = VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT | VK_PIPELINE_SHADER_STAGE_CREATE_REQUIRE_FULL_SUBGROUPS_BIT, 311 .stage = VK_SHADER_STAGE_COMPUTE_BIT, 312 .module = VK_NULL_HANDLE, 313 .pName = ..., 314 .pSpecializationInfo = ... }, 315 .layout = ..., 316 .basePipelineHandle = 0, 317 .basePipelineIndex = 0 }; 318---- 319 320=== A8_UNORM format 321 322An optional format VK_FORMAT_A8_UNORM_KHR is added. 323 324=== Relax VkBufferView creation requirement 325 326Use the new `VkBufferUsageFlags2CreateInfoKHR` structure chained 327into the `pNext` of `VkBufferViewCreateInfo` to specify a 328subset of usage of the associated `VkBuffer`. 329 330=== Appearance when using VK_POLYGON_MODE_POINT together with PointSize 331 332A new `polygonModePointSize` property is added. 333 334=== Copying between different image types 335 336Allow copies between different image types, treating 1D images as 2D images 337with a height of 1. 338 339=== Need a way to indicate when SWIZZLE_ONE has defined results when used with depth-stencil formats === 340 341Introduce a `depthStencilSwizzleOneSupport` 342property which an implementation should expose to indicate that this 343behavior is defined. 344 345== Issues 346 347None. 348 349 350== Further Functionality 351 352None. 353