1// Copyright 2018-2022 The Khronos Group Inc. 2// 3// SPDX-License-Identifier: CC-BY-4.0 4 5[[video-encode-operations]] 6== Video Encode Operations 7 8Before the application can start recording Vulkan command buffers for the 9Video Encode Operations, it must: do the following, beforehand: 10 11 . Ensure that the implementation can encode the Video Content by querying 12 the supported codec operations and profiles using 13 flink:vkGetPhysicalDeviceQueueFamilyProperties2. 14 . By using flink:vkGetPhysicalDeviceVideoFormatPropertiesKHR and providing 15 one or more video profiles, choose the Vulkan formats supported by the 16 implementation. 17 The formats for <<encode-input-picture,input>> and 18 <<reference-picture,reference>> pictures must: be queried and chosen 19 separately. 20 Refer to the section on <<video-format-capabilities,Video Format 21 Capabilities>>. 22 . Before creating an image to be used as a video picture resource, obtain 23 the supported image creation parameters by querying with 24 flink:vkGetPhysicalDeviceFormatProperties2 and 25 flink:vkGetPhysicalDeviceImageFormatProperties2 using one of the 26 reported formats and adding slink:VkVideoProfileListInfoKHR to the 27 pname:pNext chain of slink:VkFormatProperties2. 28 When querying the parameters with 29 flink:vkGetPhysicalDeviceImageFormatProperties2 for images targeting 30 <<encode-input-picture,input>> and <<reference-picture,reference (DPB)>> 31 pictures, the slink:VkPhysicalDeviceImageFormatInfo2::pname:usage field 32 should contain ename:VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR and 33 ename:VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR, respectively. 34 . Create none, some, or all of the required <<VkImage,images>> for the 35 <<encode-input-picture,input>> and <<reference-picture,reference>> 36 pictures. 37 More Video Picture Resources can: be created at some later point if 38 needed while processing the content to be encoded. 39 Also, if the size of the picture to be encoded is expected to change, 40 the images can: be created based on the maximum expected content size. 41 . Create the <<video-session,video session>> to be used for video encode 42 operations. 43 Before creating the Encode Video Session, the encode capabilities 44 should: be queried with flink:vkGetPhysicalDeviceVideoCapabilitiesKHR to 45 obtain the limits of the parameters allowed by the implementation for a 46 particular codec profile. 47 . Bind memory resources with the encode video session by calling 48 flink:vkBindVideoSessionMemoryKHR. 49 The video session cannot: be used until memory resources are allocated 50 and bound to it. 51 In order to determine the required memory sizes and heap types of the 52 device memory allocations, flink:vkGetVideoSessionMemoryRequirementsKHR 53 should: be called. 54 . Create one or more <<video-session-parameters,Video Session Parameter 55 objects>> for use across command buffer recording operations, if 56 required by the codec extension in use. 57 These objects must: be created against a <<video-session,video session>> 58 with the parameters required by the codec. 59 Each <<video-session-parameters,Video Session Parameter object>> created 60 is a child object of the associated <<video-session, Session object>> 61 and cannot: be bound in the command buffer with any other 62 <<video-session,Session Object>>. 63 64 65The recording of Video Encode Commands against a Vulkan Command Buffer 66consists of the following sequence: 67 68 . flink:vkCmdBeginVideoCodingKHR starts the recording of one or more Video 69 Encode operations in the command buffer. 70 For each Video Encode Command operation, a Video Session must: be bound 71 to the command buffer within this command. 72 This command establishes a Vulkan Video Encode Context that consists of 73 the bound Video Session Object, Session Parameters Object, and the 74 required Video Picture Resources. 75 The established Video Encode Context is in effect until the 76 flink:vkCmdEndVideoCodingKHR command is recorded. 77 If more Video Encode operations are to be required after the 78 flink:vkCmdEndVideoCodingKHR command, another Video Encode Context can: 79 be started with the flink:vkCmdBeginVideoCodingKHR command. 80 . flink:vkCmdEncodeVideoKHR specifies one or more frames to be encoded. 81 The slink:VkVideoEncodeInfoKHR parameters, and the codec extension 82 structures chained to this, specify the details of the encode operation. 83 . flink:vkCmdControlVideoCodingKHR records operations against the encoded 84 data, encoding device, or the Video Session state. 85 . flink:vkCmdEndVideoCodingKHR signals the end of the recording of the 86 Vulkan Video Encode Context, as established by 87 flink:vkCmdBeginVideoCodingKHR. 88 89In addition to the above, the following commands can: be recorded between 90flink:vkCmdBeginVideoCodingKHR and flink:vkCmdEndVideoCodingKHR: 91 92 * Query operations 93 * Global Memory Barriers 94 * Buffer Memory Barriers 95 * Image Memory Barriers (these must: be used to transition the Video 96 Picture Resources to the proper 97 ename:VK_IMAGE_LAYOUT_VIDEO_ENCODE_SRC_KHR and 98 ename:VK_IMAGE_LAYOUT_VIDEO_ENCODE_DPB_KHR layouts). 99 * Pipeline Barriers 100 * Events 101 * Timestamps 102 * Device Groups (device mask) 103 104The following Video Encode related commands must: be recorded *outside* the 105Vulkan Video Encode Context established with the 106flink:vkCmdBeginVideoCodingKHR and flink:vkCmdEndVideoCodingKHR commands: 107 108 * Sparse Memory Binding 109 * Copy Commands 110 * Clear Commands 111 112 113[[encode-input-picture]] 114=== Encode Input Picture 115 116The primary source of input pixels for the video encoding process is the 117_Encode Input Picture_, represented by a slink:VkImageView. 118It may: also be a direct target of 119ifdef::VK_KHR_video_decode_queue[] 120video decode, 121endif::VK_KHR_video_decode_queue[] 122graphics, or compute operations 123ifdef::VK_KHR_surface[] 124, or with <<wsi, Window System Integration>> APIs 125endif::VK_KHR_surface[] 126. 127 128 129=== Capabilities 130 131[open,refpage='VkVideoEncodeCapabilitiesKHR',desc='Structure specifying encode capabilities',type='structs'] 132-- 133When calling flink:vkGetPhysicalDeviceVideoCapabilitiesKHR with 134pname:pVideoProfile->videoCodecOperation specified as one of the encode 135operation bits, the slink:VkVideoEncodeCapabilitiesKHR structure must: be 136included in the pname:pNext chain of the slink:VkVideoCapabilitiesKHR 137structure to retrieve capabilities specific to video encoding. 138 139The sname:VkVideoEncodeCapabilitiesKHR structure is defined as: 140 141include::{generated}/api/structs/VkVideoEncodeCapabilitiesKHR.adoc[] 142 143 * pname:sType is the type of this structure. 144 * pname:pNext is `NULL` or a pointer to a structure extending this 145 structure. 146 * pname:flags is a bitmask of elink:VkVideoEncodeCapabilityFlagBitsKHR 147 describing supported encoding features. 148 * pname:rateControlModes is a bitmask of 149 elink:VkVideoEncodeRateControlModeFlagBitsKHR describing supported rate 150 control modes. 151 All implementations must: support 152 ename:VK_VIDEO_ENCODE_RATE_CONTROL_MODE_NONE_BIT_KHR. 153 * pname:rateControlLayerCount reports the maximum number of rate control 154 layers supported. 155 Implementations must: report at least 1. 156 * pname:qualityLevelCount is the number of discrete quality levels 157 supported. 158 Implementations must: report at least 1. 159 * pname:inputImageDataFillAlignment reports alignment of data that should 160 be filled in the input image horizontally and vertically in pixels 161 before encode operations are performed on the input image. 162 163The input content and encode resolution (specified in 164slink:VkVideoEncodeInfoKHR::pname:codedExtent) may not be aligned with the 165codec-specific coding block size. 166For example, the input content may be 1920x1080 and the coding block size 167may be 16x16 pixel blocks. 168In this example, the content is horizontally aligned with the coding block 169size, but not vertically aligned with the coding block size. 170Encoding of the last row of blocks may be impacted by contents of the input 171image in pixel rows 1081 to 1088 (the next vertical alignment with the 172coding block size). 173In general, to ensure efficient encoding for the last row/column of blocks, 174and/or to ensure consistent encoding results between repeated encoding of 175the same input content, these extra pixel rows/columns should be filled to 176known values up to the coding block size alignment before encoding 177operations are performed. 178Some implementations support performing auto-fill of unaligned pixels beyond 179a specific alignment, which is reported in 180pname:inputImageDataFillAlignment. 181For example, if an implementation reports 1x1 in 182pname:inputImageDataFillAlignment, then the implementation will perform 183auto-fill for any unaligned pixels beyond the encode resolution up to the 184next coding block size. 185For a coding block size of 16x16, if the implementation reports 16x16 in 186pname:inputImageDataFillAlignment, then it is the application's 187responsibility to fill any unaligned pixels, if desired. 188If not, it may impact the encoding efficiency, but it will not affect the 189validity of the generated bitstream. 190If the implementation reports 8x8 in pname:inputImageDataFillAlignment, then 191for the 1920x1080 example, since the content is aligned to 8 pixels 192vertically, the implementation will auto-fill pixel rows 1081 to 1088 (up to 193the 16x16 coding block size in the example). 194The auto-fill value(s) are implementation-specific. 195The auto-fill value(s) are not written to the input image memory, but are 196used as part of the encoding operation on the input image. 197 198include::{generated}/validity/structs/VkVideoEncodeCapabilitiesKHR.adoc[] 199-- 200 201[open,refpage='VkVideoEncodeCapabilityFlagsKHR',desc='Bitmask of VkVideoEncodeCapabilityFlagBitsKHR',type='flags'] 202-- 203include::{generated}/api/flags/VkVideoEncodeCapabilityFlagsKHR.adoc[] 204 205tname:VkVideoEncodeCapabilityFlagsKHR is a bitmask type for setting a mask 206of zero or more elink:VkVideoEncodeCapabilityFlagBitsKHR. 207-- 208 209[open,refpage='VkVideoEncodeCapabilityFlagBitsKHR',desc='Video encode capability flags',type='enums'] 210-- 211Bits which may: be set in slink:VkVideoEncodeCapabilitiesKHR::pname:flags, 212indicating the encoding tools supported, are: 213 214include::{generated}/api/enums/VkVideoEncodeCapabilityFlagBitsKHR.adoc[] 215 216 * ename:VK_VIDEO_ENCODE_CAPABILITY_PRECEDING_EXTERNALLY_ENCODED_BYTES_BIT_KHR 217 reports that the implementation supports use of 218 slink:VkVideoEncodeInfoKHR::pname:precedingExternallyEncodedBytes. 219-- 220 221=== Video Encode Commands 222 223[open,refpage='vkCmdEncodeVideoKHR',desc='Encode operation for bitstream generation',type='protos'] 224-- 225To launch video encode operations, call: 226 227include::{generated}/api/protos/vkCmdEncodeVideoKHR.adoc[] 228 229 * pname:commandBuffer is the command buffer to be filled with this 230 function for encoding to generate a bitstream. 231 * pname:pEncodeInfo is a pointer to a slink:VkVideoEncodeInfoKHR 232 structure. 233 234Each call issues one or more video encode operations. 235The implicit parameter pname:opCount corresponds to the number of video 236encode operations issued by the command. 237After calling this command, the 238<<queries-operation-active-query-index,active query index>> of each 239<<queries-operation-active,active>> query is incremented by pname:opCount. 240 241Currently each call to this command results in the issue of a single video 242encode operation. 243 244.Valid Usage 245**** 246 * [[VUID-vkCmdEncodeVideoKHR-opCount-07174]] 247 For each <<queries-operation-active,active>> query, the 248 <<queries-operation-active-query-index,active query index>> 249 corresponding to the query type of that query plus pname:opCount must: 250 be less than or equal to the 251 <<queries-operation-last-activatable-query-index,last activatable query 252 index>> corresponding to the query type of that query plus one 253**** 254 255include::{generated}/validity/protos/vkCmdEncodeVideoKHR.adoc[] 256-- 257 258[open,refpage='VkVideoEncodeInfoKHR',desc='Structure to chain codec-specific structures to',type='structs'] 259-- 260The sname:VkVideoEncodeInfoKHR structure is defined as: 261 262include::{generated}/api/structs/VkVideoEncodeInfoKHR.adoc[] 263 264 * pname:sType is the type of this structure. 265 * pname:pNext is a pointer to a structure extending this structure. 266 A codec-specific extension structure must: be chained to specify what 267 bitstream unit to generate with this encode operation. 268 * pname:flags is reserved for future use. 269 * pname:qualityLevel is the coding quality level of the encoding. 270 It is defined by the codec-specific extensions. 271 * pname:dstBitstreamBuffer is the buffer where the encoded bitstream 272 output will be produced. 273 * pname:dstBitstreamBufferOffset is the offset in the 274 pname:dstBitstreamBuffer where the encoded bitstream output will start. 275 pname:dstBitstreamBufferOffset's value must: be aligned to 276 slink:VkVideoCapabilitiesKHR::pname:minBitstreamBufferOffsetAlignment, 277 as reported by the implementation. 278 * pname:dstBitstreamBufferMaxRange is the maximum size of the 279 pname:dstBitstreamBuffer that can be used while the encoded bitstream 280 output is produced. 281 pname:dstBitstreamBufferMaxRange's value must: be aligned to 282 slink:VkVideoCapabilitiesKHR::pname:minBitstreamBufferSizeAlignment, as 283 reported by the implementation. 284 * pname:srcPictureResource is the Picture Resource of the 285 <<encode-input-picture,Input Picture>> to be encoded by the operation. 286 * pname:pSetupReferenceSlot is a pointer to a 287 slink:VkVideoReferenceSlotInfoKHR structure used for generating a 288 reconstructed reference slot and Picture Resource. 289 pname:pSetupReferenceSlot->slotIndex specifies the slot index number to 290 use as a target for producing the Reconstructed (DPB) data. 291 pname:pSetupReferenceSlot must: be one of the entries provided in 292 slink:VkVideoBeginCodingInfoKHR via the pname:pReferenceSlots within the 293 flink:vkCmdBeginVideoCodingKHR command that established the Vulkan Video 294 Encode Context for this command. 295 * pname:referenceSlotCount is the number of Reconstructed Reference 296 Pictures that will be used when this encoding operation is executing. 297 * pname:pReferenceSlots is `NULL` or a pointer to an array of 298 slink:VkVideoReferenceSlotInfoKHR structures that will be used when this 299 encoding operation is executing. 300 Each entry in pname:pReferenceSlots must: be one of the entries provided 301 in slink:VkVideoBeginCodingInfoKHR via the pname:pReferenceSlots within 302 the flink:vkCmdBeginVideoCodingKHR command that established the Vulkan 303 Video Encode Context for this command. 304 * pname:precedingExternallyEncodedBytes is the number of bytes externally 305 encoded for insertion in the active video encode session overall 306 bitstream prior to the bitstream that will be generated by the 307 implementation for this instance of sname:VkVideoEncodeInfoKHR. 308 Valid when slink:VkVideoEncodeRateControlInfoKHR::pname:rateControlMode 309 is not ename:VK_VIDEO_ENCODE_RATE_CONTROL_MODE_NONE_BIT_KHR. 310 The value provided is used to update the implementation's rate control 311 algorithm for the rate control layer this instance of 312 sname:VkVideoEncodeInfoKHR belongs to, by accounting for the bitrate 313 budget consumed by these externally encoded bytes. 314 See slink:VkVideoEncodeRateControlInfoKHR for additional information 315 about encode rate control. 316 317The coded size of the encode operation is specified in pname:codedExtent of 318pname:srcPictureResource. 319 320Multiple flink:vkCmdEncodeVideoKHR commands may: be recorded within a Vulkan 321Video Encode Context. 322The execution of each flink:vkCmdEncodeVideoKHR command will result in 323generating codec-specific bitstream units. 324These bitstream units are generated consecutively into the bitstream buffer 325specified in pname:dstBitstreamBuffer of a sname:VkVideoEncodeInfoKHR 326structure within the flink:vkCmdBeginVideoCodingKHR command. 327The produced bitstream is the sum of all these bitstream units, including 328any padding between the bitstream units. 329Any bitstream padding must: be filled with data compliant to the codec 330standard so as not to cause any syntax errors during decoding of the 331bitstream units with the padding included. 332The range of the bitstream buffer written can: be queried via 333<<queries-video-encode-bitstream-buffer-range, video encode bitstream buffer 334range queries>>. 335 336.Valid Usage 337**** 338 * [[VUID-VkVideoEncodeInfoKHR-None-07012]] 339 The bound video session must: not be in <<video-session-uninitialized, 340 uninitialized>> state at the time the command is executed on the device 341**** 342 343include::{generated}/validity/structs/VkVideoEncodeInfoKHR.adoc[] 344-- 345 346[open,refpage='VkVideoEncodeFlagsKHR',desc='Reserved for future use',type='flags'] 347-- 348include::{generated}/api/flags/VkVideoEncodeFlagsKHR.adoc[] 349 350tlink:VkVideoEncodeFlagsKHR is a bitmask type for setting a mask, but is 351currently reserved for future use. 352-- 353 354[open,refpage='VkVideoEncodeRateControlInfoKHR',desc='Structure to set encode stream rate control parameters',type='structs'] 355-- 356The sname:VkVideoEncodeRateControlInfoKHR structure is defined as: 357 358include::{generated}/api/structs/VkVideoEncodeRateControlInfoKHR.adoc[] 359 360 * pname:sType is the type of this structure. 361 * pname:pNext is `NULL` or a pointer to a structure extending this 362 structure. 363 * pname:flags is reserved for future use. 364 * pname:rateControlMode is a elink:VkVideoEncodeRateControlModeFlagBitsKHR 365 value specifying the encode stream rate control mode. 366 * pname:layerCount specifies the number of rate control layers in the 367 video encode stream. 368 * pname:pLayerConfigs is a pointer to an array of 369 slink:VkVideoEncodeRateControlLayerInfoKHR structures specifying the 370 rate control configurations of pname:layerCount rate control layers. 371 372Including this structure in the pname:pNext chain of 373slink:VkVideoCodingControlInfoKHR and including 374ename:VK_VIDEO_CODING_CONTROL_ENCODE_RATE_CONTROL_BIT_KHR in 375slink:VkVideoCodingControlInfoKHR::pname:flags will define stream rate 376control settings for video encoding. 377 378Additional structures providing codec-specific rate control parameters may: 379need to be included in the pname:pNext chain of 380sname:VkVideoCodingControlInfoKHR depending on the codec profile the bound 381video session was created with and the parameters specified in 382sname:VkVideoEncodeRateControlInfoKHR (see <<video-coding-control,Video 383Coding Control>>). 384 385To ensure that the video session is properly initialized with stream-level 386rate control settings, the application must: call 387flink:vkCmdControlVideoCodingKHR with stream-level rate control settings at 388least once in execution order before the first flink:vkCmdEncodeVideoKHR 389command that is executed after video session reset. 390If not provided, default implementation-specific stream rate control 391settings will be used. 392 393Stream rate control settings can: also be re-initialized during an active 394video encoding session. 395The re-initialization takes effect whenever the 396sname:VkVideoEncodeRateControlInfoKHR structure is included in the 397pname:pNext chain of the slink:VkVideoCodingControlInfoKHR structure in the 398call to flink:vkCmdControlVideoCodingKHR, and only impacts 399flink:vkCmdEncodeVideoKHR operations that follow in execution order. 400 401include::{generated}/validity/structs/VkVideoEncodeRateControlInfoKHR.adoc[] 402-- 403 404[open,refpage='VkVideoEncodeRateControlFlagsKHR',desc='Reserved for future use',type='flags'] 405-- 406include::{generated}/api/flags/VkVideoEncodeRateControlFlagsKHR.adoc[] 407 408tname:VkVideoEncodeRateControlFlagsKHR is a bitmask type for setting a mask, 409but currently reserved for future use. 410-- 411 412[open,refpage='VkVideoEncodeRateControlModeFlagBitsKHR',desc='Video encode rate control modes',type='enums'] 413-- 414The rate control modes are defined with the following enums: 415 416include::{generated}/api/enums/VkVideoEncodeRateControlModeFlagBitsKHR.adoc[] 417 418 * ename:VK_VIDEO_ENCODE_RATE_CONTROL_MODE_NONE_BIT_KHR for disabling rate 419 control. 420 * ename:VK_VIDEO_ENCODE_RATE_CONTROL_MODE_CBR_BIT_KHR for constant bitrate 421 rate control mode. 422 * ename:VK_VIDEO_ENCODE_RATE_CONTROL_MODE_VBR_BIT_KHR for variable bitrate 423 rate control mode. 424-- 425 426[open,refpage='VkVideoEncodeRateControlModeFlagsKHR',desc='Bitmask of VkVideoEncodeRateControlModeFlagBitsKHR', type='flags'] 427-- 428include::{generated}/api/flags/VkVideoEncodeRateControlModeFlagsKHR.adoc[] 429 430tname:VkVideoEncodeRateControlModeFlagsKHR is a bitmask type for setting a 431mask of zero or more elink:VkVideoEncodeRateControlModeFlagBitsKHR. 432-- 433 434[open,refpage='VkVideoEncodeRateControlLayerInfoKHR',desc='Structure to set encode per-layer rate control parameters',type='structs'] 435-- 436The sname:VkVideoEncodeRateControlLayerInfoKHR structure is defined as: 437 438include::{generated}/api/structs/VkVideoEncodeRateControlLayerInfoKHR.adoc[] 439 440 * pname:sType is the type of this structure. 441 * pname:pNext is a pointer to a structure extending this structure. 442 * pname:averageBitrate is the average bitrate in bits/second. 443 Valid when rate control mode is not 444 ename:VK_VIDEO_ENCODE_RATE_CONTROL_MODE_NONE_BIT_KHR. 445 * pname:maxBitrate is the peak bitrate in bits/second. 446 Valid when rate control mode is 447 ename:VK_VIDEO_ENCODE_RATE_CONTROL_MODE_VBR_BIT_KHR. 448 * pname:frameRateNumerator is the numerator of the frame rate. 449 Valid when rate control mode is not 450 ename:VK_VIDEO_ENCODE_RATE_CONTROL_MODE_NONE_BIT_KHR. 451 * pname:frameRateDenominator is the denominator of the frame rate. 452 Valid when rate control mode is not 453 ename:VK_VIDEO_ENCODE_RATE_CONTROL_MODE_NONE_BIT_KHR. 454 * pname:virtualBufferSizeInMs is the leaky bucket model virtual buffer 455 size in milliseconds, with respect to peak bitrate. 456 Valid when rate control mode is not 457 ename:VK_VIDEO_ENCODE_RATE_CONTROL_MODE_NONE_BIT_KHR. 458 For example, virtual buffer size is (pname:virtualBufferSizeInMs {times} 459 pname:maxBitrate / 1000). 460 * pname:initialVirtualBufferSizeInMs is the initial occupancy in 461 milliseconds of the virtual buffer in the leaky bucket model. 462 Valid when the rate control mode is not 463 ename:VK_VIDEO_ENCODE_RATE_CONTROL_MODE_NONE_BIT_KHR. 464 465A codec-specific structure specifying additional per-layer rate control 466settings must: be chained to sname:VkVideoEncodeRateControlLayerInfoKHR. 467If multiple rate control layers are enabled 468(slink:VkVideoEncodeRateControlInfoKHR::pname:layerCount is greater than 1), 469then the chained codec-specific extension structure also identifies the 470specific video coding layer its parent 471sname:VkVideoEncodeRateControlLayerInfoKHR applies to. 472If multiple rate control layers are enabled, the number of rate control 473layers must: match the number of video coding layers. 474The specification for an encode codec-specific extension would describe how 475multiple video coding layers are enabled for the corresponding codec. 476 477Per-layer rate control settings for all enabled rate control layers must: be 478initialized or re-initialized whenever stream rate control settings are 479provided via slink:VkVideoEncodeRateControlInfoKHR. 480This is done by specifying settings for all enabled rate control layers in 481slink:VkVideoEncodeRateControlInfoKHR::pname:pLayerConfigs. 482 483Including this structure in the pname:pNext chain of 484slink:VkVideoCodingControlInfoKHR and including 485ename:VK_VIDEO_CODING_CONTROL_ENCODE_RATE_CONTROL_LAYER_BIT_KHR in 486slink:VkVideoCodingControlInfoKHR::pname:flags will define stream rate 487control settings for individual layers during video encoding. 488This adjustment only impacts the specified layer without impacting the rate 489control settings or implementation rate control algorithm behavior for any 490other enabled rate control layers. 491The adjustment takes effect whenever the corresponding 492flink:vkCmdControlVideoCodingKHR is executed, and only impacts 493flink:vkCmdEncodeVideoKHR operations pertaining to the corresponding video 494coding layer that follow in execution order. 495 496It is possible for an application to enable multiple video coding layers 497(via codec-specific extensions to encoding operations) while only enabling a 498single layer of rate control for the entire video stream. 499To achieve this, pname:layerCount in slink:VkVideoEncodeRateControlInfoKHR 500must: be set to 1, and the single sname:VkVideoEncodeRateControlLayerInfoKHR 501provided in pname:pLayerConfigs would apply to all encoded segments of the 502video stream, regardless of which codec-defined video coding layer they 503belong to. 504In this case, the implementation decides bitrate distribution across video 505coding layers (if applicable to the specified stream rate control mode). 506 507include::{generated}/validity/structs/VkVideoEncodeRateControlLayerInfoKHR.adoc[] 508-- 509 510