1e5c31af7Sopenharmony_ci// Copyright 2015-2021 The Khronos Group Inc. 2e5c31af7Sopenharmony_ci// 3e5c31af7Sopenharmony_ci// SPDX-License-Identifier: CC-BY-4.0 4e5c31af7Sopenharmony_ci 5e5c31af7Sopenharmony_ci[[writing]] 6e5c31af7Sopenharmony_ci= Writing Style 7e5c31af7Sopenharmony_ci 8e5c31af7Sopenharmony_ci 9e5c31af7Sopenharmony_ci[[writing-misc]] 10e5c31af7Sopenharmony_ci== Miscellaneous Grammar, Spelling, and Punctuation Issues 11e5c31af7Sopenharmony_ci 12e5c31af7Sopenharmony_ci=== Use the Oxford Comma (Serial Comma) 13e5c31af7Sopenharmony_ci 14e5c31af7Sopenharmony_ciWhen writing a sentence listing a series of items, include a comma before 15e5c31af7Sopenharmony_cithe "`and`" separating the last item. 16e5c31af7Sopenharmony_ci 17e5c31af7Sopenharmony_ci*Correct:* The red, green, blue, and alpha components. 18e5c31af7Sopenharmony_ci 19e5c31af7Sopenharmony_ci*Incorrect:* The red, green, blue and alpha components. 20e5c31af7Sopenharmony_ci 21e5c31af7Sopenharmony_ciAlso see this 22e5c31af7Sopenharmony_cilink:https://blog.oxforddictionaries.com/2015/01/21/video-oxford-comma/[video 23e5c31af7Sopenharmony_cidiscussion of the Oxford comma] provided by the Oxford Dictionary. 24e5c31af7Sopenharmony_ci 25e5c31af7Sopenharmony_ci 26e5c31af7Sopenharmony_ci=== Date Format 27e5c31af7Sopenharmony_ci 28e5c31af7Sopenharmony_ciWhenever possible, write dates in the <<iso-8601,ISO 8601>> format: 29e5c31af7Sopenharmony_ciYYYY-MM-DD. 30e5c31af7Sopenharmony_ci 31e5c31af7Sopenharmony_ciIf needed for consistency with existing dates, e.g. in appendix changelogs, 32e5c31af7Sopenharmony_ciyou can also write "`Month DD, YYYY`" where "`Month`" is the English name of 33e5c31af7Sopenharmony_cithe month. 34e5c31af7Sopenharmony_ci 35e5c31af7Sopenharmony_ciNever use ambigious formats such as "`09/12/16`". 36e5c31af7Sopenharmony_ci 37e5c31af7Sopenharmony_ci[source,asciidoc] 38e5c31af7Sopenharmony_ci.Example Markup 39e5c31af7Sopenharmony_ci---- 40e5c31af7Sopenharmony_ci * 2016-09-12 41e5c31af7Sopenharmony_ci * September 12, 2016 42e5c31af7Sopenharmony_ci---- 43e5c31af7Sopenharmony_ci 44e5c31af7Sopenharmony_ci 45e5c31af7Sopenharmony_ci[[writing-misc-a-an]] 46e5c31af7Sopenharmony_ci=== A/An and Markup Macros 47e5c31af7Sopenharmony_ci 48e5c31af7Sopenharmony_ciUse "`a`" and "`an`" 49e5c31af7Sopenharmony_cilink:https://www.grammar.com/a-vs-an-when-to-use/[correctly], based on the 50e5c31af7Sopenharmony_ci*sound* of the letter beginning the following word. 51e5c31af7Sopenharmony_ci 52e5c31af7Sopenharmony_ciIt is easy to get this wrong when talking about Vulkan API names tagged with 53e5c31af7Sopenharmony_cithe <<markup-macros,markup macros>>. 54e5c31af7Sopenharmony_ciFor example, if you wanted to say: 55e5c31af7Sopenharmony_ci 56e5c31af7Sopenharmony_ciA ename:VK_ERROR_DEVICE_LOST error 57e5c31af7Sopenharmony_ci 58e5c31af7Sopenharmony_cithe correct way to mark this up in asciidoctor would be: 59e5c31af7Sopenharmony_ci 60e5c31af7Sopenharmony_ci[source,asciidoc] 61e5c31af7Sopenharmony_ci---- 62e5c31af7Sopenharmony_ciA ename:VK_ERROR_DEVICE_LOST error 63e5c31af7Sopenharmony_ci---- 64e5c31af7Sopenharmony_ci 65e5c31af7Sopenharmony_ciHowever, on first glance at this it *appears* wrong, because the "`word`" 66e5c31af7Sopenharmony_cifollowing "`a`" is the macro name, "`ename{cl}`". 67e5c31af7Sopenharmony_ciThat starts with a vowel, so the temptation is to say 68e5c31af7Sopenharmony_ci 69e5c31af7Sopenharmony_ci[source,asciidoc] 70e5c31af7Sopenharmony_ci---- 71e5c31af7Sopenharmony_ciAn ename:VK_ERROR_DEVICE_LOST error may occur. 72e5c31af7Sopenharmony_ci---- 73e5c31af7Sopenharmony_ci 74e5c31af7Sopenharmony_ciWhat matters here is how the *output* document is formatted. 75e5c31af7Sopenharmony_ci 76e5c31af7Sopenharmony_ci 77e5c31af7Sopenharmony_ci=== Numbers in Text 78e5c31af7Sopenharmony_ci 79e5c31af7Sopenharmony_ciWhen describing the need for a small number of objects, smaller than ten, 80e5c31af7Sopenharmony_cispell the number out (e.g. "`one`"). 81e5c31af7Sopenharmony_ciIf you are describing a literal value that is a small number, you may use a 82e5c31af7Sopenharmony_cinumeric value (e.g. "`1`"). 83e5c31af7Sopenharmony_ci 84e5c31af7Sopenharmony_ciFor example, instead of writing that a bitmask "`contains 1 or more bits`", 85e5c31af7Sopenharmony_ciwrite that it "`contains one or more bits`". 86e5c31af7Sopenharmony_ciA counter example is that it is okay to write "`For non-stereoscopic-3D 87e5c31af7Sopenharmony_ciapplications, this value is 1.`" 88e5c31af7Sopenharmony_ci 89e5c31af7Sopenharmony_ci 90e5c31af7Sopenharmony_ci=== Use American Spelling Conventions 91e5c31af7Sopenharmony_ci 92e5c31af7Sopenharmony_ciIn case of conflict, use American rather than British spelling conventions, 93e5c31af7Sopenharmony_ciexcept for noted exceptions in the table below. 94e5c31af7Sopenharmony_ci 95e5c31af7Sopenharmony_ci.Spelling 96e5c31af7Sopenharmony_ci[width="60%",options="header"] 97e5c31af7Sopenharmony_ci|==== 98e5c31af7Sopenharmony_ci| Use Spelling | Instead Of | Comments 99e5c31af7Sopenharmony_ci| color | colour | 100e5c31af7Sopenharmony_ci| signaled | signalled | 101e5c31af7Sopenharmony_ci| tessellation | tesselation | Historical exception 102e5c31af7Sopenharmony_ci|==== 103e5c31af7Sopenharmony_ci 104e5c31af7Sopenharmony_ci 105e5c31af7Sopenharmony_ci[[writing-inclusivity]] 106e5c31af7Sopenharmony_ci=== Use Inclusive Language 107e5c31af7Sopenharmony_ci 108e5c31af7Sopenharmony_ciThe Vulkan Working Group has begun to apply the 109e5c31af7Sopenharmony_cilink:https://www.khronos.org/about/inclusive-language[Khronos Inclusive 110e5c31af7Sopenharmony_ciLanguage] list to our specifications and other documents. 111e5c31af7Sopenharmony_ciThe Khronos Inclusive Language list contains terms to avoid due to their use 112e5c31af7Sopenharmony_ciin discriminatory contexts that make people uncomfortable, or cause 113e5c31af7Sopenharmony_cidivision. 114e5c31af7Sopenharmony_ci 115e5c31af7Sopenharmony_ciWe are working through the Vulkan Specification repository to make 116e5c31af7Sopenharmony_ciappropriate changes, and enhancing the repository continuous integration 117e5c31af7Sopenharmony_ciscripts to report questionable terminology usage. 118e5c31af7Sopenharmony_ciThis process will take some time. 119e5c31af7Sopenharmony_ci 120e5c31af7Sopenharmony_ciSome files in the repository are incorporated unmodified from external 121e5c31af7Sopenharmony_ciprojects we do not control, and which may not comply with the Inclusive 122e5c31af7Sopenharmony_ciLanguage list. 123e5c31af7Sopenharmony_ciWe will ask those projects to update their terminology usage, but cannot 124e5c31af7Sopenharmony_cicontrol their choices. 125e5c31af7Sopenharmony_ci 126e5c31af7Sopenharmony_ci 127e5c31af7Sopenharmony_ci[[writing-pointers-instances]] 128e5c31af7Sopenharmony_ci=== Describing Pointers, Handles, Structures, and Arrays 129e5c31af7Sopenharmony_ci 130e5c31af7Sopenharmony_ciWhen describing pointer parameters or members, use "`is a pointer to`" 131e5c31af7Sopenharmony_cirather than more informal phrasing such as "`points to`". 132e5c31af7Sopenharmony_ci 133e5c31af7Sopenharmony_ciWhen describing individual structures, use "`VkStructname structure`" rather 134e5c31af7Sopenharmony_cithan longer phrasing such as "`instance of the VkStructname structure`" or 135e5c31af7Sopenharmony_ci"`structure of type VkStructname`". 136e5c31af7Sopenharmony_ci 137e5c31af7Sopenharmony_ciWhen describing array parameters or members, use "`is a pointer to an array 138e5c31af7Sopenharmony_ciof`" rather than "`is an array of`" unless it is a structure member that is 139e5c31af7Sopenharmony_cia fixed-size array. 140e5c31af7Sopenharmony_ciReference the dynamic size of the array that is pointed to (usually another 141e5c31af7Sopenharmony_cistructure member), or the static size for fixed-size arrays, in the 142e5c31af7Sopenharmony_cidescription. 143e5c31af7Sopenharmony_ci 144e5c31af7Sopenharmony_ciWhen describing pointers which may be `NULL`, use "`is `NULL` or a pointer 145e5c31af7Sopenharmony_cito`" rather than "`is an optional pointer`". 146e5c31af7Sopenharmony_ciThe same principle applies when describing a handle which may be 147e5c31af7Sopenharmony_cidname:VK_NULL_HANDLE. 148e5c31af7Sopenharmony_ci"`Optional pointer/handle`" are not well-defined terms in the Specification. 149e5c31af7Sopenharmony_ci 150e5c31af7Sopenharmony_ci[source,asciidoc] 151e5c31af7Sopenharmony_ci.Example Markup 152e5c31af7Sopenharmony_ci---- 153e5c31af7Sopenharmony_ci * pname:pInfo is a pointer to a slink:VkDebugUtilsLabelEXT structure 154e5c31af7Sopenharmony_ci specifying the parameters of the label to insert. 155e5c31af7Sopenharmony_ci * pname:pBindInfos is a pointer to an array of pname:bindInfoCount 156e5c31af7Sopenharmony_ci slink:VkBindBufferMemoryInfo structures describing buffers and memory to 157e5c31af7Sopenharmony_ci bind. 158e5c31af7Sopenharmony_ci * pname:pStrides is `NULL` or a pointer to an array 159e5c31af7Sopenharmony_ci of buffer strides. 160e5c31af7Sopenharmony_ci * pname:image is dlink:VK_NULL_HANDLE or a handle of an image which this 161e5c31af7Sopenharmony_ci memory will be bound to. 162e5c31af7Sopenharmony_ci---- 163e5c31af7Sopenharmony_ci 164e5c31af7Sopenharmony_ci 165e5c31af7Sopenharmony_ci[[writing-arrays]] 166e5c31af7Sopenharmony_ci=== Describing Properties of Array Elements 167e5c31af7Sopenharmony_ci 168e5c31af7Sopenharmony_ciMany Vulkan parameters are arrays, or pointers to arrays. 169e5c31af7Sopenharmony_ciWhen describing array elements, use the terminology "`each element`" when 170e5c31af7Sopenharmony_cithe description applies uniformly and independently to every element of the 171e5c31af7Sopenharmony_ciarray. 172e5c31af7Sopenharmony_ciFor example: 173e5c31af7Sopenharmony_ci 174e5c31af7Sopenharmony_ci[source,asciidoc] 175e5c31af7Sopenharmony_ci.Example Markup 176e5c31af7Sopenharmony_ci---- 177e5c31af7Sopenharmony_ci * Each element of the pname:pCommandBuffers member of each element of 178e5c31af7Sopenharmony_ci pname:pSubmits must: be in the <<commandbuffers-lifecycle, pending or 179e5c31af7Sopenharmony_ci executable state>>. 180e5c31af7Sopenharmony_ci---- 181e5c31af7Sopenharmony_ci 182e5c31af7Sopenharmony_ciUse the terminology "`any element`" when the description is of zero or more 183e5c31af7Sopenharmony_cielements of the array sharing a property. 184e5c31af7Sopenharmony_ciFor example: 185e5c31af7Sopenharmony_ci 186e5c31af7Sopenharmony_ci[source,asciidoc] 187e5c31af7Sopenharmony_ci.Example Markup 188e5c31af7Sopenharmony_ci---- 189e5c31af7Sopenharmony_ci * If any element of the pname:pCommandBuffers member of any element 190e5c31af7Sopenharmony_ci of pname:pSubmits was not recorded with the 191e5c31af7Sopenharmony_ci ename:VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT, it must: not be in 192e5c31af7Sopenharmony_ci the <<commandbuffers-lifecycle, pending state>>. 193e5c31af7Sopenharmony_ci---- 194e5c31af7Sopenharmony_ci 195e5c31af7Sopenharmony_ciNever use the redundant terminology "`any *given* element`". 196e5c31af7Sopenharmony_ci 197e5c31af7Sopenharmony_ci 198e5c31af7Sopenharmony_ci[[writing-compound-words]] 199e5c31af7Sopenharmony_ci=== Compound Words and Preferred Orthography 200e5c31af7Sopenharmony_ci 201e5c31af7Sopenharmony_ciUnless there is longstanding precedent in computer science literature, or 202e5c31af7Sopenharmony_cithe word is a noted exception in the table below, do not arbitrarily cram 203e5c31af7Sopenharmony_citerms together. 204e5c31af7Sopenharmony_ci 205e5c31af7Sopenharmony_ciThis does not apply to parameter names in the API, where capitalization is 206e5c31af7Sopenharmony_ciused to distinguish words. 207e5c31af7Sopenharmony_ciFor example, it is proper to refer to the use of a pname:colorSpace member 208e5c31af7Sopenharmony_ciof a structure as a "`color space`" value. 209e5c31af7Sopenharmony_ci 210e5c31af7Sopenharmony_ci.Spelling 211e5c31af7Sopenharmony_ci[width="70%",options="header",cols="20%,20%,60%"] 212e5c31af7Sopenharmony_ci|==== 213e5c31af7Sopenharmony_ci| Use Spelling | Instead Of | Comments 214e5c31af7Sopenharmony_ci| bit plane | bitplane | 215e5c31af7Sopenharmony_ci| compile time | compile-time | Per Wikipedia "`compile time`" 216e5c31af7Sopenharmony_ci| color space | colorspace | 217e5c31af7Sopenharmony_ci| cube map | cubemap | 218e5c31af7Sopenharmony_ci| double-buffer | doublebuffer | 219e5c31af7Sopenharmony_ci| entry point | entry-point + 220e5c31af7Sopenharmony_ci entrypoint 221e5c31af7Sopenharmony_ci | Except if needed to disambiguate from surrounding terms 222e5c31af7Sopenharmony_ci| flat shading | flatshading | 223e5c31af7Sopenharmony_ci| GitHub | Github | Site's preferred spelling 224e5c31af7Sopenharmony_ci| indirect (drawing/dispatching) command 225e5c31af7Sopenharmony_ci | indirect command (draw/dispatch) 226e5c31af7Sopenharmony_ci | Even though related commands are named 227e5c31af7Sopenharmony_ci ftext:vk*Draw*Indirect 228e5c31af7Sopenharmony_ci| LOD | lod + 229e5c31af7Sopenharmony_ci level of detail + 230e5c31af7Sopenharmony_ci level-of-detail| Acronym for "`Level of Detail`" 231e5c31af7Sopenharmony_ci| mip level + 232e5c31af7Sopenharmony_ci mip layer + 233e5c31af7Sopenharmony_ci mip size + 234e5c31af7Sopenharmony_ci mip tail 235e5c31af7Sopenharmony_ci | miplevel + 236e5c31af7Sopenharmony_ci miplayer + 237e5c31af7Sopenharmony_ci mipsize + 238e5c31af7Sopenharmony_ci miptail | "`mipmap *term*`" may be used in time 239e5c31af7Sopenharmony_ci| render pass | renderpass | 240e5c31af7Sopenharmony_ci| reuse | re-use | 241e5c31af7Sopenharmony_ci| side effect | side-effect | 242e5c31af7Sopenharmony_ci3+h| Exceptions 243e5c31af7Sopenharmony_ci| mipmap | mip map | Exception for historical reasons 244e5c31af7Sopenharmony_ci| pname:pNext chain 245e5c31af7Sopenharmony_ci | pname:pNext-chain + 246e5c31af7Sopenharmony_ci pname:pNext extension chain 247e5c31af7Sopenharmony_ci | 248e5c31af7Sopenharmony_ci| general-purpose 249e5c31af7Sopenharmony_ci | general purpose| When used as an adjective 250e5c31af7Sopenharmony_ci| implementation-dependent 251e5c31af7Sopenharmony_ci | implementation dependent 252e5c31af7Sopenharmony_ci | When used as an adjective 253e5c31af7Sopenharmony_ci| swapchain | swap chain | Exception due to heavy use in WSI extensions 254e5c31af7Sopenharmony_ci| happen-before + 255e5c31af7Sopenharmony_ci happen-after | happen before + 256e5c31af7Sopenharmony_ci happen after | As used in concurrent languages such as 257e5c31af7Sopenharmony_ci C++11, Java and OpenCL C. 258e5c31af7Sopenharmony_ci|==== 259e5c31af7Sopenharmony_ci 260e5c31af7Sopenharmony_ci==== Words With "Pre-" Prefixes 261e5c31af7Sopenharmony_ci 262e5c31af7Sopenharmony_ci// also: premultiply preorder prerotation predefined 263e5c31af7Sopenharmony_ci 264e5c31af7Sopenharmony_ciWhen using the prefix "`pre`" to indicate "`prior to`", such as in the words 265e5c31af7Sopenharmony_ci"`preinitialized`", "`preprocess`", and "`pretransform`", do not separate 266e5c31af7Sopenharmony_cithe prefix from the word with a hyphen. 267e5c31af7Sopenharmony_ciThis list is not intended to be complete. 268e5c31af7Sopenharmony_ci 269e5c31af7Sopenharmony_ci 270e5c31af7Sopenharmony_ci[[writing-references]] 271e5c31af7Sopenharmony_ci=== References 272e5c31af7Sopenharmony_ci 273e5c31af7Sopenharmony_ciWhen citing external references, use the appropriate <<acm-references, 274e5c31af7Sopenharmony_ciAssociation for Computing Machinery Citation Style>>. 275e5c31af7Sopenharmony_ciMost citations in our specifications should follow the _For an online 276e5c31af7Sopenharmony_cidocument/WWW resource_ style, using the actual date on the document being 277e5c31af7Sopenharmony_cireferenced rather than the document retrieval date. 278e5c31af7Sopenharmony_ciSee the <<vulkan-spec, Vulkan Specification>> citation in this document for 279e5c31af7Sopenharmony_cian example. 280e5c31af7Sopenharmony_ci 281e5c31af7Sopenharmony_ci 282e5c31af7Sopenharmony_ci[[writing-undefined]] 283e5c31af7Sopenharmony_ci== Describing Undefined Behavior 284e5c31af7Sopenharmony_ci 285e5c31af7Sopenharmony_ciWhen describing undefined behavior that results only in the values of 286e5c31af7Sopenharmony_cispecified variables, or the contents of specified memory, becoming undefined 287e5c31af7Sopenharmony_cior implementation-defined, use the undefined{cl} macro to indicate that each 288e5c31af7Sopenharmony_ciuse of the term "`undefined`" has been carefully considered and accurately 289e5c31af7Sopenharmony_cirepresents the degree of undefined behavior allowed. 290e5c31af7Sopenharmony_ci 291e5c31af7Sopenharmony_ciThe word "`undefined`" should not be used without the trailing {cl}. 292e5c31af7Sopenharmony_ciThis is enforced by internal CI tests. 293e5c31af7Sopenharmony_ci 294e5c31af7Sopenharmony_ciThe undefined{cl} macro does not result in visible markup in the output 295e5c31af7Sopenharmony_cidocument, and is not itself a normative term. 296e5c31af7Sopenharmony_ciThe macro is simply markup to help ensure that use of the word has been 297e5c31af7Sopenharmony_ciconsciously chosen. 298e5c31af7Sopenharmony_ci 299e5c31af7Sopenharmony_ciWhen describing more general types of undefined behavior (up to and 300e5c31af7Sopenharmony_ciincluding termination of the application), do *not* use the term 301e5c31af7Sopenharmony_ci"`undefined`". 302e5c31af7Sopenharmony_ciInstead, specify that the application must{cl} not create circumstances that 303e5c31af7Sopenharmony_ciwould lead to such behavior. 304e5c31af7Sopenharmony_ciSuch statements should be written as valid usage statements, if possible. 305e5c31af7Sopenharmony_ci 306e5c31af7Sopenharmony_ci 307e5c31af7Sopenharmony_ci[[writing-describing]] 308e5c31af7Sopenharmony_ci== Describing Commands and Parameters 309e5c31af7Sopenharmony_ci 310e5c31af7Sopenharmony_ciThe <<vulkan-spec,Vulkan API Specification>> describes API commands followed 311e5c31af7Sopenharmony_ciby descriptions of their parameters, which are usually simple scalar types, 312e5c31af7Sopenharmony_cihandles or pointers to Vulkan objects or arrays of objects; enumerated types 313e5c31af7Sopenharmony_cispecifying values or bitmasks which affect the operation of a command; or 314e5c31af7Sopenharmony_cistructures containing combinations of scalar types and objects. 315e5c31af7Sopenharmony_ciThe templates and examples shown and annotated here are based on the 316e5c31af7Sopenharmony_ci<<vulkan-spec,Vulkan API Specification>>. 317e5c31af7Sopenharmony_ciDo not vary from them without compelling need. 318e5c31af7Sopenharmony_ci 319e5c31af7Sopenharmony_ciNormative parts of the <<vulkan-spec,Vulkan API Specification>> should 320e5c31af7Sopenharmony_cidescribe _what_ something does, rather than _how_ or _why_ an application 321e5c31af7Sopenharmony_ciwould want to use it. 322e5c31af7Sopenharmony_ci 323e5c31af7Sopenharmony_ciWhen explicitly allowed by the Specification, the reserved value `NULL` may: 324e5c31af7Sopenharmony_cibe used for pointer parameters and members and dispatchable object handles, 325e5c31af7Sopenharmony_ciand the reserved value dname:VK_NULL_HANDLE may: be used for 326e5c31af7Sopenharmony_cinon-dispatchable Vulkan object handle parameters and members. 327e5c31af7Sopenharmony_ciOtherwise, pointers and handles must: refer to valid memory and valid Vulkan 328e5c31af7Sopenharmony_ciobjects, respectively. 329e5c31af7Sopenharmony_ci 330e5c31af7Sopenharmony_ci 331e5c31af7Sopenharmony_ci[NOTE] 332e5c31af7Sopenharmony_ci.Guideline 333e5c31af7Sopenharmony_ci==== 334e5c31af7Sopenharmony_ciAs a simple example, say 335e5c31af7Sopenharmony_ci 336e5c31af7Sopenharmony_ci"`To create a command pool, call fname:vkCreateCommandPool`" 337e5c31af7Sopenharmony_ci 338e5c31af7Sopenharmony_cirather than 339e5c31af7Sopenharmony_ci 340e5c31af7Sopenharmony_ci"`You/The application/The user can create a command pool by calling 341e5c31af7Sopenharmony_cifname:vkCreateCommandPool`". 342e5c31af7Sopenharmony_ci 343e5c31af7Sopenharmony_ci==== 344e5c31af7Sopenharmony_ci 345e5c31af7Sopenharmony_ciExplanations of _why_ and _how_ should largely be confined to reference 346e5c31af7Sopenharmony_cidocumentation, sample code, tutorials, and other such documents. 347e5c31af7Sopenharmony_ciOccasional non-normative explanations can be included in the 348e5c31af7Sopenharmony_ci<<vulkan-spec,Vulkan API Specification>> using 349e5c31af7Sopenharmony_ci<<markup-informative-notes,informative notes>>. 350e5c31af7Sopenharmony_ci 351e5c31af7Sopenharmony_ci 352e5c31af7Sopenharmony_ci[[writing-describing-errors]] 353e5c31af7Sopenharmony_ci=== Commands which Return Error Codes 354e5c31af7Sopenharmony_ci 355e5c31af7Sopenharmony_ciCommands which return elink:VkResult values must list all possible error 356e5c31af7Sopenharmony_cicodes for the command in the `errorcodes` XML attribute for the command. 357e5c31af7Sopenharmony_ciAlmost all such commands may return the ename:VK_ERROR_OUT_OF_HOST_MEMORY 358e5c31af7Sopenharmony_cierror code. 359e5c31af7Sopenharmony_ciAny exceptions to this rule should be carefully considered by the 360e5c31af7Sopenharmony_cispecification author, and a rationale for this anomalous behavior may be 361e5c31af7Sopenharmony_ciprovided in a NOTE or in the Issues section of the extension appendix 362e5c31af7Sopenharmony_cicorresponding to the new command. 363e5c31af7Sopenharmony_ci 364e5c31af7Sopenharmony_ciSee the "`Return Codes`" section of the <<vulkan-spec,Vulkan API 365e5c31af7Sopenharmony_ciSpecification>> for additional information. 366e5c31af7Sopenharmony_ci 367e5c31af7Sopenharmony_ci 368e5c31af7Sopenharmony_ci[[writing-describing-layers]] 369e5c31af7Sopenharmony_ci== Extensions and Grouping Related Language 370e5c31af7Sopenharmony_ci 371e5c31af7Sopenharmony_ciLanguage specifying behavior of a command or structure that does not 372e5c31af7Sopenharmony_cioriginate in an extension should be placed in a single contiguous region of 373e5c31af7Sopenharmony_cithe specification. 374e5c31af7Sopenharmony_ci 375e5c31af7Sopenharmony_ciWhen defining a new command or structure from an extension that introduces 376e5c31af7Sopenharmony_ciadditional behavior or options, do not insert such new language in a way 377e5c31af7Sopenharmony_cithat "`orphans`" part of an existing description by splitting up the 378e5c31af7Sopenharmony_ciexisting language. 379e5c31af7Sopenharmony_ci 380e5c31af7Sopenharmony_ciThis constraint does not apply to enumerated types. 381e5c31af7Sopenharmony_ciLanguage for new enumerants defined by extensions should be added to the 382e5c31af7Sopenharmony_ciexisting enumerant definition, <<extensions-documenting-extensions, 383e5c31af7Sopenharmony_ciprotected by asciidoctor conditionals>> for the new extension. 384e5c31af7Sopenharmony_ci 385e5c31af7Sopenharmony_ci[NOTE] 386e5c31af7Sopenharmony_ci.Guideline 387e5c31af7Sopenharmony_ci==== 388e5c31af7Sopenharmony_ciSpecification language should be structured, whenever possible, so it fits 389e5c31af7Sopenharmony_ciinto a single open block defining a <<writing-refpages, reference page>>. 390e5c31af7Sopenharmony_ci==== 391e5c31af7Sopenharmony_ci 392e5c31af7Sopenharmony_ci 393e5c31af7Sopenharmony_ci[[writing-math]] 394e5c31af7Sopenharmony_ci== Math Markup 395e5c31af7Sopenharmony_ci 396e5c31af7Sopenharmony_ciThere is a considerable amount of math in the documentation, ranging from 397e5c31af7Sopenharmony_cisimple arithmetic expressions to complicated conditionals. 398e5c31af7Sopenharmony_ciThere are two ways of marking up math expressions, described below. 399e5c31af7Sopenharmony_ci 400e5c31af7Sopenharmony_ci=== Asciidoc Math Markup 401e5c31af7Sopenharmony_ci 402e5c31af7Sopenharmony_ciWhere possible, math is marked up using straight asciidoctor features. 403e5c31af7Sopenharmony_ciFor commonality with LaTeX math (see below), some common LaTeX operators and 404e5c31af7Sopenharmony_cinames are defined as asciidoctor attributes using the same names, expanding 405e5c31af7Sopenharmony_cito the corresponding Unicode entities. 406e5c31af7Sopenharmony_ciThe complete set of these attributes is found in `config/attribs.txt`. 407e5c31af7Sopenharmony_ci 408e5c31af7Sopenharmony_ci.Spelling 409e5c31af7Sopenharmony_ci[width="100%",options="header",cols="20%,20%,60%"] 410e5c31af7Sopenharmony_ci|==== 411e5c31af7Sopenharmony_ci| Feature | Result | Sample Markup 412e5c31af7Sopenharmony_ci 413e5c31af7Sopenharmony_ci| Subscripts 414e5c31af7Sopenharmony_ci| [eq]#a~x~# 415e5c31af7Sopenharmony_ci| +++[eq]#a~x~#+++ 416e5c31af7Sopenharmony_ci 417e5c31af7Sopenharmony_ci| Superscripts 418e5c31af7Sopenharmony_ci| [eq]#-2^(b-1)^# 419e5c31af7Sopenharmony_ci| +++[eq]#-2^(b-1)^#+++ 420e5c31af7Sopenharmony_ci 421e5c31af7Sopenharmony_ci| Struct/parameter names as variables 422e5c31af7Sopenharmony_ci| [eq]#2^pname:bits^# 423e5c31af7Sopenharmony_ci| +++[eq]#2^pname:bits^#+++ 424e5c31af7Sopenharmony_ci 425e5c31af7Sopenharmony_ci| Greek Letters (selected) 426e5c31af7Sopenharmony_ci| [eq]#{alpha}, {beta}, {gamma}, {delta}, {DeltaUpper}, {epsilon}, {lambda}, 427e5c31af7Sopenharmony_ci {rho}, {tau}# 428e5c31af7Sopenharmony_ci| +++[eq]#{alpha}, {beta}, {gamma}, {delta}, {DeltaUpper}, {epsilon}, {lambda}, 429e5c31af7Sopenharmony_ci {rho}, {tau}#+++ 430e5c31af7Sopenharmony_ci 431e5c31af7Sopenharmony_ci| Fractions 432e5c31af7Sopenharmony_ci| [eq]#{onequarter} {plus} {onehalf}# 433e5c31af7Sopenharmony_ci| +++[eq]#{onequarter} {plus} {onehalf}#+++ 434e5c31af7Sopenharmony_ci 435e5c31af7Sopenharmony_ci| Closed Ranges 436e5c31af7Sopenharmony_ci| [eq]#[0,1]# 437e5c31af7Sopenharmony_ci| +++[eq]#[0,1]#+++ 438e5c31af7Sopenharmony_ci 439e5c31af7Sopenharmony_ci| Open Ranges 440e5c31af7Sopenharmony_ci| [eq]#[0,1)# 441e5c31af7Sopenharmony_ci| +++[eq]#[0,1)#+++ 442e5c31af7Sopenharmony_ci 443e5c31af7Sopenharmony_ci| Arithmetic and Relational Operators 444e5c31af7Sopenharmony_ci| [eq]#a {times} b#, [eq]#a {leq} b#, [eq]#a {neq} b#, [eq]#a {geq} b#, [eq]#{vert}x{vert}# 445e5c31af7Sopenharmony_ci| +++[eq]#a {times} b#+++, +++[eq]#a {leq} b#+++, +++[eq]#a {neq} b#+++, +++[eq]#a {geq} b#+++, +++[eq]#{vert}x{vert}#+++ 446e5c31af7Sopenharmony_ci 447e5c31af7Sopenharmony_ci| Floor 448e5c31af7Sopenharmony_ci| [eq]#{lfloor}w - {onehalf}{rfloor}# 449e5c31af7Sopenharmony_ci| +++[eq]#{lfloor}w - {onehalf}{rfloor}#+++ 450e5c31af7Sopenharmony_ci 451e5c31af7Sopenharmony_ci| Ceiling 452e5c31af7Sopenharmony_ci| [eq]#{lceil}log~2~(max(pname:width, pname:height)){rceil} {plus} 1# 453e5c31af7Sopenharmony_ci| +++[eq]#{lceil}log~2~(max(pname:width, pname:height)){rceil} {plus} 1#+++ 454e5c31af7Sopenharmony_ci 455e5c31af7Sopenharmony_ci| Logical and Set Operators 456e5c31af7Sopenharmony_ci| [eq]#{land} {lnot} {lor} {oplus} {elem}# 457e5c31af7Sopenharmony_ci| +++[eq]#{land} {lnot} {lor} {oplus} {elem}#+++ 458e5c31af7Sopenharmony_ci 459e5c31af7Sopenharmony_ci| Partial Derivatives 460e5c31af7Sopenharmony_ci| [eq]#{partial}r~x~ / {partial}x = 0# 461e5c31af7Sopenharmony_ci| +++[eq]#{partial}r~x~ / {partial}x = 0#+++ 462e5c31af7Sopenharmony_ci 463e5c31af7Sopenharmony_ci| Matrix/Vector Parameter Names 464e5c31af7Sopenharmony_ci| [eq]#**P** = t **P**~1~ {plus} (1-t) **P**~2~# 465e5c31af7Sopenharmony_ci| +++[eq]#**P** = t **P**~1~ {plus} (1-t) **P**~2~#+++ 466e5c31af7Sopenharmony_ci 467e5c31af7Sopenharmony_ci|==== 468e5c31af7Sopenharmony_ci 469e5c31af7Sopenharmony_ci 470e5c31af7Sopenharmony_ci[[writing-math-latexmath]] 471e5c31af7Sopenharmony_ci=== LaTeX Math Markup 472e5c31af7Sopenharmony_ci 473e5c31af7Sopenharmony_ciMath markup more complex than easily supported in straight asciidoctor 474e5c31af7Sopenharmony_cimarkup (examples found in the Vulkan Specification include matrices, 475e5c31af7Sopenharmony_citensors, summation notation, conditional assignments, and division of 476e5c31af7Sopenharmony_cicomplex expressions) are marked up using LaTeX math notation, which is 477e5c31af7Sopenharmony_cieither passed through to the KaTeX in-browser rendering script for HTML 478e5c31af7Sopenharmony_cioutputs, or passed through asciidoctor-mathematical for PDF outputs. 479e5c31af7Sopenharmony_ci 480e5c31af7Sopenharmony_ci[NOTE] 481e5c31af7Sopenharmony_ci.Note 482e5c31af7Sopenharmony_ci==== 483e5c31af7Sopenharmony_ciThere are font and style differences between LaTeX and asciidoctor math 484e5c31af7Sopenharmony_cimarkup which lead to minor visual inconsistencies. 485e5c31af7Sopenharmony_ciWe will try to make this better over time, but it is not significant enough 486e5c31af7Sopenharmony_cito be a big priority. 487e5c31af7Sopenharmony_ci==== 488e5c31af7Sopenharmony_ci 489e5c31af7Sopenharmony_ciWhile LaTeX math macros, including the amsmath package, are supported, 490e5c31af7Sopenharmony_cigeneral LaTeX constructs are not. 491e5c31af7Sopenharmony_ci 492e5c31af7Sopenharmony_ci_Inline math_ is encoded using the latexmath{cl} macro. 493e5c31af7Sopenharmony_ciFor example: 494e5c31af7Sopenharmony_ci 495e5c31af7Sopenharmony_ci * latexmath:[[0,1\]] 496e5c31af7Sopenharmony_ci * latexmath:[\frac{1 - \frac{x}{2}}{x - 1}] 497e5c31af7Sopenharmony_ci * latexmath:[\mathbf{c} = t \mathbf{c}_1 + (1-t) \mathbf{c}_2.] 498e5c31af7Sopenharmony_ci 499e5c31af7Sopenharmony_ci[source,asciidoc] 500e5c31af7Sopenharmony_ci.Example Markup 501e5c31af7Sopenharmony_ci---- 502e5c31af7Sopenharmony_ci * latexmath:[[0,1\]] 503e5c31af7Sopenharmony_ci * latexmath:[\frac{1 - \frac{x}{2}}{x - 1}] 504e5c31af7Sopenharmony_ci * latexmath:[\mathbf{c} = t \mathbf{c}_1 + (1-t) \mathbf{c}_2. ] 505e5c31af7Sopenharmony_ci---- 506e5c31af7Sopenharmony_ci 507e5c31af7Sopenharmony_ciNote the escaped bracket in markup for the first expression, which is 508e5c31af7Sopenharmony_cinecessary to work around asciidoctor macro parsing. 509e5c31af7Sopenharmony_ci 510e5c31af7Sopenharmony_ci_Block math_ is used for more complex equations. 511e5c31af7Sopenharmony_ciThis example uses the `aligned` environment to delimit the expression. 512e5c31af7Sopenharmony_ci 513e5c31af7Sopenharmony_ci[latexmath] 514e5c31af7Sopenharmony_ci+++++++++++++++++++ 515e5c31af7Sopenharmony_ci\begin{aligned} 516e5c31af7Sopenharmony_cic_{RGB} & = 517e5c31af7Sopenharmony_ci \begin{cases} 518e5c31af7Sopenharmony_ci \frac{c_{sRGB}}{12.92} & \text{for}\ c_{sRGB} \leq 0.04045 \\ 519e5c31af7Sopenharmony_ci \left ( \frac{c_{sRGB}+0.055}{1.055} \right )^{2.4} & \text{for}\ c_{sRGB} > 0.04045 520e5c31af7Sopenharmony_ci \end{cases} 521e5c31af7Sopenharmony_ci\end{aligned} 522e5c31af7Sopenharmony_ci+++++++++++++++++++ 523e5c31af7Sopenharmony_ci 524e5c31af7Sopenharmony_ci[source,asciidoc] 525e5c31af7Sopenharmony_ci.Example Markup 526e5c31af7Sopenharmony_ci---- 527e5c31af7Sopenharmony_ci[latexmath] 528e5c31af7Sopenharmony_ci+++++++++++++++++++ 529e5c31af7Sopenharmony_ci\begin{aligned} 530e5c31af7Sopenharmony_cic_{RGB} & = 531e5c31af7Sopenharmony_ci \begin{cases} 532e5c31af7Sopenharmony_ci \frac{c_{sRGB}}{12.92} & \text{for}\ c_{sRGB} \leq 0.04045 \\ 533e5c31af7Sopenharmony_ci \left ( \frac{c_{sRGB}+0.055}{1.055} \right )^{2.4} & \text{for}\ c_{sRGB} > 0.04045 534e5c31af7Sopenharmony_ci \end{cases} 535e5c31af7Sopenharmony_ci\end{aligned} 536e5c31af7Sopenharmony_ci+++++++++++++++++++ 537e5c31af7Sopenharmony_ci---- 538e5c31af7Sopenharmony_ci 539e5c31af7Sopenharmony_ci[NOTE] 540e5c31af7Sopenharmony_ci.Note 541e5c31af7Sopenharmony_ci==== 542e5c31af7Sopenharmony_ciThe KaTeX processor used to render LaTeX math inside HTML documents does not 543e5c31af7Sopenharmony_cisupport all features of LaTeX math. 544e5c31af7Sopenharmony_ci 545e5c31af7Sopenharmony_ciSimilarly, the asciidoctor-mathematical processor does not support 546e5c31af7Sopenharmony_cieverything, though does have some support for AMSMath. 547e5c31af7Sopenharmony_ci 548e5c31af7Sopenharmony_ciSome workarounds we use are: 549e5c31af7Sopenharmony_ci 550e5c31af7Sopenharmony_ci.LaTeX math replacements for KaTeX compatibility 551e5c31af7Sopenharmony_ci[width="70%",options="header",cols="20%,20%,60%"] 552e5c31af7Sopenharmony_ci|==== 553e5c31af7Sopenharmony_ci| Replace | With | Comments 554e5c31af7Sopenharmony_ci| `\begin{equation}` | _nothing_ | Unnecessary in blocks. Should not be used for inline. 555e5c31af7Sopenharmony_ci| `\end{equation}` | _nothing_ | Unnecessary in blocks. Should not be used for inline. 556e5c31af7Sopenharmony_ci| `\begin{align*}` | `\begin{aligned}` | 557e5c31af7Sopenharmony_ci| `\end{align*}` | `\end{aligned}` | 558e5c31af7Sopenharmony_ci| `\operatorname{foo}` | `\mathbin{foo}` | 559e5c31af7Sopenharmony_ci| `{\rm A}` | `\mathrm{A}` | 560e5c31af7Sopenharmony_ci| `\text{for }` | `\text{for}\ ` | Text ending in spaces is unpredictable - favour escaped spaces after text 561e5c31af7Sopenharmony_ci|==== 562e5c31af7Sopenharmony_ci 563e5c31af7Sopenharmony_ciThe KaTeX repository provides a 564e5c31af7Sopenharmony_cilink:https://github.com/Khan/KaTeX/wiki/Function-Support-in-KaTeX[list of 565e5c31af7Sopenharmony_cicurrently supported LaTeX functionality]. 566e5c31af7Sopenharmony_ciYou can also use the link:https://khan.github.io/KaTeX/[live katex preview 567e5c31af7Sopenharmony_citool] on the KaTeX website to double check support, without building the 568e5c31af7Sopenharmony_ciwhole specification. 569e5c31af7Sopenharmony_ci 570e5c31af7Sopenharmony_ciNote that we use a locally-cached copy of KaTeX which may lag the latest 571e5c31af7Sopenharmony_cipublished version on the website. 572e5c31af7Sopenharmony_ciAs of April 2021, we are using v0.11.1. 573e5c31af7Sopenharmony_ci 574e5c31af7Sopenharmony_ciSee the mtex2MML repository for a 575e5c31af7Sopenharmony_cilink:https://github.com/gjtorikian/mtex2MML/blob/master/SUPPORTED.md[list of 576e5c31af7Sopenharmony_cisupported operations in the PDF build]. 577e5c31af7Sopenharmony_ciIn particular, `\mathop` is not supported properly, but most other standard 578e5c31af7Sopenharmony_cifunctionality is included. 579e5c31af7Sopenharmony_ci 580e5c31af7Sopenharmony_ciIt is necessary to cross reference these two to make sure that support 581e5c31af7Sopenharmony_ciexists before using anything, but almost all standard functionality is 582e5c31af7Sopenharmony_cisupported for both. 583e5c31af7Sopenharmony_ci==== 584e5c31af7Sopenharmony_ci 585e5c31af7Sopenharmony_ciThis example is among the most complex expressions in the Vulkan 586e5c31af7Sopenharmony_cispecification: 587e5c31af7Sopenharmony_ci 588e5c31af7Sopenharmony_ci[latexmath] 589e5c31af7Sopenharmony_ci+++++++++++++++++++ 590e5c31af7Sopenharmony_ciV = 591e5c31af7Sopenharmony_ci \begin{cases} 592e5c31af7Sopenharmony_ci (-1)^S \times 0.0, & E = 0, M = 0 \\ 593e5c31af7Sopenharmony_ci (-1)^S \times 2^{-14} \times { M \over 2^{10} }, 594e5c31af7Sopenharmony_ci & E = 0, M \neq 0 \\ 595e5c31af7Sopenharmony_ci (-1)^S \times 2^{E-15} \times { \left( 1 + { M \over 2^{10} } \right) }, 596e5c31af7Sopenharmony_ci & 0 < E < 31 \\ 597e5c31af7Sopenharmony_ci (-1)^S \times Inf, & E = 31, M = 0 \\ 598e5c31af7Sopenharmony_ci NaN, & E = 31, M \neq 0 599e5c31af7Sopenharmony_ci \end{cases} 600e5c31af7Sopenharmony_ci+++++++++++++++++++ 601e5c31af7Sopenharmony_ci 602e5c31af7Sopenharmony_ci[source,asciidoc] 603e5c31af7Sopenharmony_ci.Example Markup 604e5c31af7Sopenharmony_ci---- 605e5c31af7Sopenharmony_ci[latexmath] 606e5c31af7Sopenharmony_ci+++++++++++++++++++ 607e5c31af7Sopenharmony_ciV = 608e5c31af7Sopenharmony_ci \begin{cases} 609e5c31af7Sopenharmony_ci (-1)^S \times 0.0, & E = 0, M = 0 \\ 610e5c31af7Sopenharmony_ci (-1)^S \times 2^{-14} \times { M \over 2^{10} }, 611e5c31af7Sopenharmony_ci & E = 0, M \neq 0 \\ 612e5c31af7Sopenharmony_ci (-1)^S \times 2^{E-15} \times { \left( 1 + { M \over 2^{10} } \right) }, 613e5c31af7Sopenharmony_ci & 0 < E < 31 \\ 614e5c31af7Sopenharmony_ci (-1)^S \times Inf, & E = 31, M = 0 \\ 615e5c31af7Sopenharmony_ci NaN, & E = 31, M \neq 0 616e5c31af7Sopenharmony_ci \end{cases} 617e5c31af7Sopenharmony_ci+++++++++++++++++++ 618e5c31af7Sopenharmony_ci---- 619e5c31af7Sopenharmony_ci 620e5c31af7Sopenharmony_ci 621e5c31af7Sopenharmony_ci[[writing-latexmath-in-table-cells]] 622e5c31af7Sopenharmony_ci=== LaTeX Math in Table Cells 623e5c31af7Sopenharmony_ci 624e5c31af7Sopenharmony_ciTo use `[latexmath]` or `latexmath{cl}` constructs inside table cells, the 625e5c31af7Sopenharmony_cicell separator must be `a|` instead of just `|`: 626e5c31af7Sopenharmony_ci 627e5c31af7Sopenharmony_ci[source,asciidoc] 628e5c31af7Sopenharmony_ci.Example Markup 629e5c31af7Sopenharmony_ci---- 630e5c31af7Sopenharmony_ci.Advanced Blend Overlap Modes 631e5c31af7Sopenharmony_ci[width="80%",options="header"] 632e5c31af7Sopenharmony_ci|==== 633e5c31af7Sopenharmony_ci| Overlap Mode | Weighting Equations 634e5c31af7Sopenharmony_ci| ename:VK_BLEND_OVERLAP_UNCORRELATED_EXT a| 635e5c31af7Sopenharmony_ci[latexmath] 636e5c31af7Sopenharmony_ci++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 637e5c31af7Sopenharmony_ci \begin{aligned} 638e5c31af7Sopenharmony_ci p_0(A_s,A_d) & = A_sA_d \\ 639e5c31af7Sopenharmony_ci p_1(A_s,A_d) & = A_s(1-A_d) \\ 640e5c31af7Sopenharmony_ci p_2(A_s,A_d) & = A_d(1-A_s) \\ 641e5c31af7Sopenharmony_ci \end{aligned} 642e5c31af7Sopenharmony_ci++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 643e5c31af7Sopenharmony_ci|==== 644e5c31af7Sopenharmony_ci---- 645e5c31af7Sopenharmony_ci 646e5c31af7Sopenharmony_ci 647e5c31af7Sopenharmony_ci[[writing-pNext-chain]] 648e5c31af7Sopenharmony_ci== Describing Extending Structure Chains 649e5c31af7Sopenharmony_ci 650e5c31af7Sopenharmony_ciWhen describing an extending structure which is passed to an existing 651e5c31af7Sopenharmony_cicommand by including it in the pname:pNext chain of a structure parameter of 652e5c31af7Sopenharmony_cithat command, introduce the structure description in this fashion: 653e5c31af7Sopenharmony_ci 654e5c31af7Sopenharmony_ci[source,asciidoc] 655e5c31af7Sopenharmony_ci---- 656e5c31af7Sopenharmony_ciWhen *performing an operation described by the extending structure*, add 657e5c31af7Sopenharmony_cia slink:VkExtensionStructNameID structure to the pname:pNext chain of the 658e5c31af7Sopenharmony_cislink:VkBaseExtensionStructName structure passed to the 659e5c31af7Sopenharmony_ciflink:vkBaseFunctionName command *saying what the extending structure 660e5c31af7Sopenharmony_cidoes*. 661e5c31af7Sopenharmony_ci---- 662e5c31af7Sopenharmony_ci 663e5c31af7Sopenharmony_ciWhen describing properties of a structure included in a pname:pNext chain, 664e5c31af7Sopenharmony_cirefer to that structure as "`included in the pname:pNext chain`" rather than 665e5c31af7Sopenharmony_ci`"present in`" or other similar terms, in this fashion: 666e5c31af7Sopenharmony_ci 667e5c31af7Sopenharmony_ci[source,asciidoc] 668e5c31af7Sopenharmony_ci---- 669e5c31af7Sopenharmony_ciIf the pname:pNext chain includes a slink:VkPhysicalDeviceFeatures2 670e5c31af7Sopenharmony_cistructure, then pname:pEnabledFeatures must: be `NULL` 671e5c31af7Sopenharmony_ci---- 672e5c31af7Sopenharmony_ci 673e5c31af7Sopenharmony_ci 674e5c31af7Sopenharmony_ci[[writing-example]] 675e5c31af7Sopenharmony_ci== Example Command, Structure, and Enumerant Descriptions 676e5c31af7Sopenharmony_ci 677e5c31af7Sopenharmony_ciThe <<sample-command,next section>> is a sample based on the 678e5c31af7Sopenharmony_ci<<vulkan-spec,Vulkan API Specification>>, and describes a command and 679e5c31af7Sopenharmony_cirelated structures and enumerated types in enough detail to see the 680e5c31af7Sopenharmony_cidifferent usage patterns and layout / markup used. 681e5c31af7Sopenharmony_ciInformative notes discussing markup and guidelines are interspersed with the 682e5c31af7Sopenharmony_ciexample description to explain how and why it looks as it does. 683e5c31af7Sopenharmony_ci 684e5c31af7Sopenharmony_ci 685e5c31af7Sopenharmony_ci[[sample-command]] 686e5c31af7Sopenharmony_ci== Sample Command Description: Creating Command Pools 687e5c31af7Sopenharmony_ci 688e5c31af7Sopenharmony_ci[open,refpage='vkCreateCommandPool',desc='Create a new command pool object',type='protos'] 689e5c31af7Sopenharmony_ci-- 690e5c31af7Sopenharmony_ciTo create a command pool, call: 691e5c31af7Sopenharmony_ci 692e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCreateCommandPool.txt[] 693e5c31af7Sopenharmony_ci 694e5c31af7Sopenharmony_ci[NOTE] 695e5c31af7Sopenharmony_ci.Guideline 696e5c31af7Sopenharmony_ci==== 697e5c31af7Sopenharmony_ciBegin the command description with an open block delimiting the contents as 698e5c31af7Sopenharmony_cia reference page. 699e5c31af7Sopenharmony_ciThe open block contains several required attribute values, as described for 700e5c31af7Sopenharmony_ci<<writing-refpages, automatic extraction into a reference page>>. 701e5c31af7Sopenharmony_ci 702e5c31af7Sopenharmony_ciUse a short, active sentence when describing what commands do, instead of 703e5c31af7Sopenharmony_cimore passive phrasing like "`A command pool is created by calling:`" or 704e5c31af7Sopenharmony_ci"`The application may create a command pool by calling:`". 705e5c31af7Sopenharmony_ci 706e5c31af7Sopenharmony_ciAfter the description, include the autogenerated prototype for the command 707e5c31af7Sopenharmony_cifrom the `\{generated}/api/protos/` directory: 708e5c31af7Sopenharmony_ci 709e5c31af7Sopenharmony_ci// The 'subs=attributes+' and '{blank}--' are one way to allow the inner 710e5c31af7Sopenharmony_ci// [source] block to show the correct two dashes. See 711e5c31af7Sopenharmony_ci// http://discuss.asciidoctor.org/Another-markup-escaping-question-td5665.html 712e5c31af7Sopenharmony_ci 713e5c31af7Sopenharmony_ci[source,asciidoc,subs=attributes+] 714e5c31af7Sopenharmony_ci~~~~ 715e5c31af7Sopenharmony_ci[open,refpage='vkCreateCommandPool',desc='Create a new command pool object',type='protos'] 716e5c31af7Sopenharmony_ci{blank}-- 717e5c31af7Sopenharmony_ciTo create a command pool, call: 718e5c31af7Sopenharmony_ci 719e5c31af7Sopenharmony_ci\include::\{generated}/api/protos/vkCreateCommandPool.txt[] 720e5c31af7Sopenharmony_ci~~~~ 721e5c31af7Sopenharmony_ci 722e5c31af7Sopenharmony_ciNote that each autogenerated command, enumeration, flag, or structure 723e5c31af7Sopenharmony_cidefinition include file also defines a corresponding asciidoctor anchor 724e5c31af7Sopenharmony_ciwhich is the base name of the file. 725e5c31af7Sopenharmony_ciIn this case, the anchor is named `vkCreateCommandPool`. 726e5c31af7Sopenharmony_ci==== 727e5c31af7Sopenharmony_ci 728e5c31af7Sopenharmony_ci * pname:device is the logical device that the command pool is created on. 729e5c31af7Sopenharmony_ci * pname:pCreateInfo is a pointer to a slink:VkCommandPoolCreateInfo 730e5c31af7Sopenharmony_ci structure specifying the state of the command pool object. 731e5c31af7Sopenharmony_ci * pname:pAllocator controls host memory allocation as described in the 732e5c31af7Sopenharmony_ci <<memory-allocation, Memory Allocation>> chapter. 733e5c31af7Sopenharmony_ci * pname:pCommandPool is a pointer to a slink:VkCommandPool handle in which 734e5c31af7Sopenharmony_ci the created pool is returned. 735e5c31af7Sopenharmony_ci 736e5c31af7Sopenharmony_ci[NOTE] 737e5c31af7Sopenharmony_ci.Guideline 738e5c31af7Sopenharmony_ci==== 739e5c31af7Sopenharmony_ciDescribe each command parameter in a separate bullet list item. 740e5c31af7Sopenharmony_ciin the same order that parameters appear in the command. 741e5c31af7Sopenharmony_ci 742e5c31af7Sopenharmony_ciEach description must begin with the parameter name. 743e5c31af7Sopenharmony_ciThis aids in extracting short descriptions of parameters for inclusion in 744e5c31af7Sopenharmony_ciannotated headers and similar documentation. 745e5c31af7Sopenharmony_ciMake sure to tag each parameter with the pname{cl} macro. 746e5c31af7Sopenharmony_ci 747e5c31af7Sopenharmony_ciStrive for compact notation, and in particular always try to use the 748e5c31af7Sopenharmony_ciphrasing "`pname{cl}param _is_`" rather than wordier forms such as 749e5c31af7Sopenharmony_ci"`pname{cl}param _specifies_`" or "`The pname{cl}param parameter 750e5c31af7Sopenharmony_cispecifies`". 751e5c31af7Sopenharmony_ciIn general there is no need to describe a parameter which is a Vulkan object 752e5c31af7Sopenharmony_cihandle *as* a handle; for example, say "`pname{cl}device is the logical 753e5c31af7Sopenharmony_cidevice`" rather than "`pname{cl}device is a handle to the logical device`". 754e5c31af7Sopenharmony_ciAn exception is object creation functions, where a pointer to a handle of 755e5c31af7Sopenharmony_cithe proper type is used to return the newly created object. 756e5c31af7Sopenharmony_ci==== 757e5c31af7Sopenharmony_ci 758e5c31af7Sopenharmony_ciThis is a general description of creating a command pool. 759e5c31af7Sopenharmony_ci 760e5c31af7Sopenharmony_ci.Valid Usage 761e5c31af7Sopenharmony_ci**** 762e5c31af7Sopenharmony_ci * [[VUID-vkCreateCommandPool-queueFamilyIndex-01937]] 763e5c31af7Sopenharmony_ci pname:pCreateInfo->queueFamilyIndex must: be the index of a queue family 764e5c31af7Sopenharmony_ci available in the logical device pname:device 765e5c31af7Sopenharmony_ci**** 766e5c31af7Sopenharmony_ci 767e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCreateCommandPool.txt[] 768e5c31af7Sopenharmony_ci-- 769e5c31af7Sopenharmony_ci 770e5c31af7Sopenharmony_ci[NOTE] 771e5c31af7Sopenharmony_ci.Guideline 772e5c31af7Sopenharmony_ci==== 773e5c31af7Sopenharmony_ciIf there is a general description of the command, add it following the 774e5c31af7Sopenharmony_ciparameter descriptions: 775e5c31af7Sopenharmony_ci 776e5c31af7Sopenharmony_ci[source,asciidoc,subs=attributes+] 777e5c31af7Sopenharmony_ci~~~~ 778e5c31af7Sopenharmony_ciThis is a general description of creating a command pool. 779e5c31af7Sopenharmony_ci~~~~ 780e5c31af7Sopenharmony_ci 781e5c31af7Sopenharmony_ciIf there are _explicit_ valid usage statements for the command, add them in 782e5c31af7Sopenharmony_citheir own valid usage block: 783e5c31af7Sopenharmony_ci 784e5c31af7Sopenharmony_ci[source,asciidoc,subs=attributes+] 785e5c31af7Sopenharmony_ci~~~~ 786e5c31af7Sopenharmony_ci.Valid Usage 787e5c31af7Sopenharmony_ci**** 788e5c31af7Sopenharmony_ci * [[VUID-vkCreateCommandPool-queueFamilyIndex-01937]] 789e5c31af7Sopenharmony_ci pname:pCreateInfo->queueFamilyIndex must: be the index of a queue family 790e5c31af7Sopenharmony_ci available in the logical device pname:device 791e5c31af7Sopenharmony_ci**** 792e5c31af7Sopenharmony_ci~~~~ 793e5c31af7Sopenharmony_ci 794e5c31af7Sopenharmony_ciAlthough a valid usage ID is shown in the rendered example above, do not 795e5c31af7Sopenharmony_cispecify the ID when initially writing the statement, as 796e5c31af7Sopenharmony_ci<<sample-writing-explicit-vu, described below>>. 797e5c31af7Sopenharmony_ciVUIDs are normally assigned immediately prior to publication. 798e5c31af7Sopenharmony_ci 799e5c31af7Sopenharmony_ciSome parameter and member validation language for commands and structures is 800e5c31af7Sopenharmony_ci_implicit_ (autogenerated from `vk.xml`), and included from the 801e5c31af7Sopenharmony_ci`\{generated}/validity/` directories. 802e5c31af7Sopenharmony_ciAll Vulkan command and structure language should include the autogenerated 803e5c31af7Sopenharmony_cifile at the end of their descriptions. 804e5c31af7Sopenharmony_ciIt is harmless to include a nonexistent file, in the rare cases where no 805e5c31af7Sopenharmony_ciimplicit validity language exists. 806e5c31af7Sopenharmony_ci 807e5c31af7Sopenharmony_ci[source,asciidoc,subs=attributes+] 808e5c31af7Sopenharmony_ci~~~~ 809e5c31af7Sopenharmony_ci\include::\{generated}/validity/protos/vkCreateCommandPool.txt[] 810e5c31af7Sopenharmony_ci{blank}-- 811e5c31af7Sopenharmony_ci~~~~ 812e5c31af7Sopenharmony_ci 813e5c31af7Sopenharmony_ciClose the open block surrounding the command description after the implicit 814e5c31af7Sopenharmony_civalidity include. 815e5c31af7Sopenharmony_ciAll content within the block will be extracted for the corresponding 816e5c31af7Sopenharmony_cireference page. 817e5c31af7Sopenharmony_ci 818e5c31af7Sopenharmony_ciOpen blocks delimiting reference page content should not themselves contain 819e5c31af7Sopenharmony_cisection headers, as asciidoctor cannot render such nested content correctly. 820e5c31af7Sopenharmony_ciReference pages should in general be relatively short, so this limitation is 821e5c31af7Sopenharmony_cinot severe. 822e5c31af7Sopenharmony_ci 823e5c31af7Sopenharmony_ciStructures and enumerations first introduced as parameters of a command are 824e5c31af7Sopenharmony_cidescribed next. 825e5c31af7Sopenharmony_ci==== 826e5c31af7Sopenharmony_ci 827e5c31af7Sopenharmony_ci[open,refpage='VkCommandPoolCreateInfo',desc='Structure specifying parameters of a newly created command pool',type='structs'] 828e5c31af7Sopenharmony_ci-- 829e5c31af7Sopenharmony_ciThe sname:VkCommandPoolCreateInfo structure is defined as: 830e5c31af7Sopenharmony_ci 831e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkCommandPoolCreateInfo.txt[] 832e5c31af7Sopenharmony_ci 833e5c31af7Sopenharmony_ci[NOTE] 834e5c31af7Sopenharmony_ci.Guideline 835e5c31af7Sopenharmony_ci==== 836e5c31af7Sopenharmony_ciBegin the structure description with an open block delimiting the contents 837e5c31af7Sopenharmony_cias a reference page, in the same fashion as described above for commands. 838e5c31af7Sopenharmony_ciThe open block contains several required attribute values, as described for 839e5c31af7Sopenharmony_ci<<writing-refpages, automatic extraction into a reference page>>. 840e5c31af7Sopenharmony_ci 841e5c31af7Sopenharmony_ciUse a short, active paragraph to introduce the structure, usually just "`The 842e5c31af7Sopenharmony_cisname:VkStructureName structure is defined as:`". 843e5c31af7Sopenharmony_ci 844e5c31af7Sopenharmony_ciAfter the description, include the autogenerated definition for the 845e5c31af7Sopenharmony_cistructure from the `\{generated}/api/structs/` directory: 846e5c31af7Sopenharmony_ci 847e5c31af7Sopenharmony_ci[source,asciidoc,subs=attributes+] 848e5c31af7Sopenharmony_ci~~~~ 849e5c31af7Sopenharmony_ci[open,refpage='VkCommandPoolCreateInfo',desc='Structure specifying parameters of a newly created command pool',type='structs'] 850e5c31af7Sopenharmony_ci{blank}-- 851e5c31af7Sopenharmony_ci 852e5c31af7Sopenharmony_ciThe sname:VkCommandPoolCreateInfo structure is defined as: 853e5c31af7Sopenharmony_ci 854e5c31af7Sopenharmony_ci\include::\{generated}/api/structs/VkCommandPoolCreateInfo.txt[] 855e5c31af7Sopenharmony_ci~~~~ 856e5c31af7Sopenharmony_ci==== 857e5c31af7Sopenharmony_ci 858e5c31af7Sopenharmony_ci * pname:sType is the type of this structure. 859e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 860e5c31af7Sopenharmony_ci structure. 861e5c31af7Sopenharmony_ci+ 862e5c31af7Sopenharmony_ci-- 863e5c31af7Sopenharmony_ciThis demonstrates how to create a continuation paragraph in a member 864e5c31af7Sopenharmony_cidescription. 865e5c31af7Sopenharmony_ciThis paragraph is not present in the actual specification the example is 866e5c31af7Sopenharmony_cibased on. 867e5c31af7Sopenharmony_ci-- 868e5c31af7Sopenharmony_ci * pname:flags is a bitmask of elink:VkCommandPoolCreateFlagBits indicating 869e5c31af7Sopenharmony_ci usage behavior for the pool and command buffers allocated from it. 870e5c31af7Sopenharmony_ci * pname:queueFamilyIndex designates a queue family as described in section 871e5c31af7Sopenharmony_ci <<devsandqueues-queueprops,Queue Family Properties>>. 872e5c31af7Sopenharmony_ci All command buffers allocated from this command pool must: be submitted 873e5c31af7Sopenharmony_ci on queues from the same queue family. 874e5c31af7Sopenharmony_ci 875e5c31af7Sopenharmony_ci[NOTE] 876e5c31af7Sopenharmony_ci.Guideline 877e5c31af7Sopenharmony_ci==== 878e5c31af7Sopenharmony_ciEach structure member is described in a separate bullet list item. 879e5c31af7Sopenharmony_ciFor structures with pname:sType and pname:pNext members, there is standard 880e5c31af7Sopenharmony_ciboilerplate for their descriptions. 881e5c31af7Sopenharmony_ciDescriptions of other members of the structure follow. 882e5c31af7Sopenharmony_ci 883e5c31af7Sopenharmony_ci[source,asciidoc,subs=attributes+] 884e5c31af7Sopenharmony_ci~~~~ 885e5c31af7Sopenharmony_ci * pname:sType is the type of this structure. 886e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 887e5c31af7Sopenharmony_ci structure. 888e5c31af7Sopenharmony_ci+ 889e5c31af7Sopenharmony_ci{blank}-- 890e5c31af7Sopenharmony_ciThis demonstrates how to create a continuation paragraph in a member 891e5c31af7Sopenharmony_cidescription. 892e5c31af7Sopenharmony_ciThis paragraph is not present in the actual specification the example is 893e5c31af7Sopenharmony_cibased on. 894e5c31af7Sopenharmony_ci{blank}-- 895e5c31af7Sopenharmony_ci * pname:flags is a bitmask of elink:VkCommandPoolCreateFlagBits indicating 896e5c31af7Sopenharmony_ci usage behavior for the pool and command buffers allocated from it. 897e5c31af7Sopenharmony_ci * pname:queueFamilyIndex designates a queue family as described in section 898e5c31af7Sopenharmony_ci <<devsandqueues-queueprops,Queue Family Properties>>. 899e5c31af7Sopenharmony_ci All command buffers allocated from this command pool must: be submitted 900e5c31af7Sopenharmony_ci on queues from the same queue family. 901e5c31af7Sopenharmony_ci~~~~ 902e5c31af7Sopenharmony_ci 903e5c31af7Sopenharmony_ciThese entries should be short and functional, without describing details of 904e5c31af7Sopenharmony_cie.g. new enumerant values, function of individual parameter settings, etc. 905e5c31af7Sopenharmony_ciThey can refer to other types using the appropriate *link: macros or to 906e5c31af7Sopenharmony_cirelated sections of the specification using asciidoctor xrefs. 907e5c31af7Sopenharmony_ci 908e5c31af7Sopenharmony_ciIn rare cases, a member description will cover multiple paragraphs. 909e5c31af7Sopenharmony_ciIn these cases the normal list nesting and indentation guidelines cannot be 910e5c31af7Sopenharmony_ciapplied due to limitations of the asciidoctor parser. 911e5c31af7Sopenharmony_ciIt is usually best to append a continuation block following the first 912e5c31af7Sopenharmony_ciparagraph of such a list item, as shown for pname:pNext above. 913e5c31af7Sopenharmony_ci 914e5c31af7Sopenharmony_ciAdd general descriptions of the structure, if any, following the member 915e5c31af7Sopenharmony_cidescriptions. 916e5c31af7Sopenharmony_ciNo general description is shown in this example. 917e5c31af7Sopenharmony_ci==== 918e5c31af7Sopenharmony_ci 919e5c31af7Sopenharmony_ci.Valid Usage 920e5c31af7Sopenharmony_ci**** 921e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1[] 922e5c31af7Sopenharmony_ci * [[VUID-VkCommandPoolCreateInfo-flags-02860]] 923e5c31af7Sopenharmony_ci If the protected memory feature is not enabled, the 924e5c31af7Sopenharmony_ci ename:VK_COMMAND_POOL_CREATE_PROTECTED_BIT bit of pname:flags must: not 925e5c31af7Sopenharmony_ci be set 926e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1[] 927e5c31af7Sopenharmony_ci**** 928e5c31af7Sopenharmony_ci 929e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkCommandPoolCreateInfo.txt[] 930e5c31af7Sopenharmony_ci-- 931e5c31af7Sopenharmony_ci 932e5c31af7Sopenharmony_ci[NOTE] 933e5c31af7Sopenharmony_ci.Guideline 934e5c31af7Sopenharmony_ci==== 935e5c31af7Sopenharmony_ciAdd explicit valid usage statements (if any) and the implicit autovalidity 936e5c31af7Sopenharmony_ciinclude in the same fashion as described for commands above, then close the 937e5c31af7Sopenharmony_ciopen block. 938e5c31af7Sopenharmony_ci 939e5c31af7Sopenharmony_ci[source,asciidoc,subs=attributes+] 940e5c31af7Sopenharmony_ci~~~~ 941e5c31af7Sopenharmony_ci.Valid Usage 942e5c31af7Sopenharmony_ci**** 943e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1[] 944e5c31af7Sopenharmony_ci * [[VUID-VkCommandPoolCreateInfo-flags-02860]] 945e5c31af7Sopenharmony_ci If the protected memory feature is not enabled, the 946e5c31af7Sopenharmony_ci ename:VK_COMMAND_POOL_CREATE_PROTECTED_BIT bit of pname:flags must: not 947e5c31af7Sopenharmony_ci be set 948e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1[] 949e5c31af7Sopenharmony_ci**** 950e5c31af7Sopenharmony_ci 951e5c31af7Sopenharmony_ci\include::\{generated}/validity/structs/VkCommandPoolCreateInfo.txt[] 952e5c31af7Sopenharmony_ci{blank}-- 953e5c31af7Sopenharmony_ci~~~~ 954e5c31af7Sopenharmony_ci==== 955e5c31af7Sopenharmony_ci 956e5c31af7Sopenharmony_ci[open,refpage='VkCommandPoolCreateFlagBits',desc='Bitmask specifying usage behavior for a command pool',type='enums'] 957e5c31af7Sopenharmony_ci-- 958e5c31af7Sopenharmony_ciBits which can: be set in slink:VkCommandPoolCreateInfo::pname:flags to 959e5c31af7Sopenharmony_cispecify usage behavior for a command pool are: 960e5c31af7Sopenharmony_ci 961e5c31af7Sopenharmony_ciinclude::{generated}/api/enums/VkCommandPoolCreateFlagBits.txt[] 962e5c31af7Sopenharmony_ci 963e5c31af7Sopenharmony_ci[NOTE] 964e5c31af7Sopenharmony_ci.Guideline 965e5c31af7Sopenharmony_ci==== 966e5c31af7Sopenharmony_ciBegin an enumerated type description with an open block delimiting the 967e5c31af7Sopenharmony_cicontents as a reference page, in the same fashion as described above for 968e5c31af7Sopenharmony_cicommands and structures. 969e5c31af7Sopenharmony_ci 970e5c31af7Sopenharmony_ciUse boilerplate language similar to that above to introduce the type. 971e5c31af7Sopenharmony_ci 972e5c31af7Sopenharmony_ci[source,asciidoc,subs=attributes+] 973e5c31af7Sopenharmony_ci~~~~ 974e5c31af7Sopenharmony_ci[open,refpage='VkCommandPoolCreateFlagBits',desc='Bitmask specifying usage behavior for a command pool',type='enums'] 975e5c31af7Sopenharmony_ci{blank}-- 976e5c31af7Sopenharmony_ciBits which can: be set in slink:VkCommandPoolCreateInfo::pname:flags to 977e5c31af7Sopenharmony_cispecify usage behavior for a command pool are: 978e5c31af7Sopenharmony_ci 979e5c31af7Sopenharmony_ci\include::\{generated}/api/enums/VkCommandPoolCreateFlagBits.txt[] 980e5c31af7Sopenharmony_ci~~~~ 981e5c31af7Sopenharmony_ci==== 982e5c31af7Sopenharmony_ci 983e5c31af7Sopenharmony_ci * ename:VK_COMMAND_POOL_CREATE_TRANSIENT_BIT specifies that command 984e5c31af7Sopenharmony_ci buffers allocated from the pool will be short-lived, meaning that they 985e5c31af7Sopenharmony_ci will be reset or freed in a relatively short timeframe. 986e5c31af7Sopenharmony_ci This flag may: be used by the implementation to control memory 987e5c31af7Sopenharmony_ci allocation behavior within the pool. 988e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1[] 989e5c31af7Sopenharmony_ci * ename:VK_COMMAND_POOL_CREATE_PROTECTED_BIT specifies that command 990e5c31af7Sopenharmony_ci buffers allocated from the pool are protected command buffers. 991e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1[] 992e5c31af7Sopenharmony_ci-- 993e5c31af7Sopenharmony_ci 994e5c31af7Sopenharmony_ci[NOTE] 995e5c31af7Sopenharmony_ci.Guideline 996e5c31af7Sopenharmony_ci==== 997e5c31af7Sopenharmony_ciEach enumerant in the enumerated type is described in a separate bullet list 998e5c31af7Sopenharmony_ciitem. 999e5c31af7Sopenharmony_ciMake sure to protect enumerants added to the type by extensions or future 1000e5c31af7Sopenharmony_cicore versions with asciidoctor conditionals. 1001e5c31af7Sopenharmony_ciClose the open block after all enumerants are described. 1002e5c31af7Sopenharmony_ci 1003e5c31af7Sopenharmony_ci[source,asciidoc,subs=attributes+] 1004e5c31af7Sopenharmony_ci~~~~ 1005e5c31af7Sopenharmony_ci * ename:VK_COMMAND_POOL_CREATE_TRANSIENT_BIT specifies that command 1006e5c31af7Sopenharmony_ci buffers allocated from the pool will be short-lived, meaning that they 1007e5c31af7Sopenharmony_ci will be reset or freed in a relatively short timeframe. 1008e5c31af7Sopenharmony_ci This flag may: be used by the implementation to control memory 1009e5c31af7Sopenharmony_ci allocation behavior within the pool. 1010e5c31af7Sopenharmony_ci\ifdef::VK_VERSION_1_1[] 1011e5c31af7Sopenharmony_ci * ename:VK_COMMAND_POOL_CREATE_PROTECTED_BIT specifies that command 1012e5c31af7Sopenharmony_ci buffers allocated from the pool are protected command buffers. 1013e5c31af7Sopenharmony_ci\endif::VK_VERSION_1_1[] 1014e5c31af7Sopenharmony_ci{blank}-- 1015e5c31af7Sopenharmony_ci~~~~ 1016e5c31af7Sopenharmony_ci==== 1017e5c31af7Sopenharmony_ci 1018e5c31af7Sopenharmony_ci 1019e5c31af7Sopenharmony_ci[[sample-writing-explicit-vu]] 1020e5c31af7Sopenharmony_ci== Writing Explicit Valid Usage Statements 1021e5c31af7Sopenharmony_ci 1022e5c31af7Sopenharmony_ciExplicit valid usage statements must be written at a point that all 1023e5c31af7Sopenharmony_ciinformation needed to evaluate them is known. 1024e5c31af7Sopenharmony_ciIn particular, if validity of structure parameters depends on other 1025e5c31af7Sopenharmony_ciparameters of a command that structure is passed to, such valid usage 1026e5c31af7Sopenharmony_cistatements must be written for the command, rather than the structure. 1027e5c31af7Sopenharmony_ci 1028e5c31af7Sopenharmony_ciEach explicit valid usage statement should be a single, self-contained 1029e5c31af7Sopenharmony_ciassertion, possibly involving multiple subexpressions or parameters. 1030e5c31af7Sopenharmony_ciFor example, instead of writing "`width, height, and depth must: all be 1031e5c31af7Sopenharmony_cigreater than zero`", write each condition as a separate statement. 1032e5c31af7Sopenharmony_ciIn contrast, "`width {times} height must: be less than 1024`" is a single 1033e5c31af7Sopenharmony_ciassertion involving multiple parameters. 1034e5c31af7Sopenharmony_ci 1035e5c31af7Sopenharmony_ciDo not use "`unless`" to call out exceptions - always write valid usage 1036e5c31af7Sopenharmony_cistatements of the form "`if _A_ then _B_`". 1037e5c31af7Sopenharmony_ciThis may result in harder to read statements in a few cases, but maintains 1038e5c31af7Sopenharmony_ciconsistency. 1039e5c31af7Sopenharmony_ciIn many cases, it may lead to a simpler VU statement, or splitting one large 1040e5c31af7Sopenharmony_ciVU into multiple new ones. 1041e5c31af7Sopenharmony_ci 1042e5c31af7Sopenharmony_ciDo not use nested bullet lists or other writing structure where valid usage 1043e5c31af7Sopenharmony_cistatements are not self-contained. 1044e5c31af7Sopenharmony_ciThis would make it impossible to extract semantically meaningful 1045e5c31af7Sopenharmony_cidescriptions for each assigned <<appendix-vuid, Valid Usage ID Tag>>. 1046e5c31af7Sopenharmony_ci 1047e5c31af7Sopenharmony_ciBe clear on the distinction between a "`valid pointer`" and a "`pointer to a 1048e5c31af7Sopenharmony_civalid object`" when writing valid usage statements. 1049e5c31af7Sopenharmony_ciSee the "`Valid Usage`" section of the Vulkan Specification, and 1050e5c31af7Sopenharmony_ciparticularly the "`Valid Usage for Pointers`" section. 1051e5c31af7Sopenharmony_ci 1052e5c31af7Sopenharmony_ciWhen valid usage statements apply only when specific extensions and/or core 1053e5c31af7Sopenharmony_ciAPI versions are enabled at runtime, surround those statements in their 1054e5c31af7Sopenharmony_cientirety with appropriate asciidoctor conditionals. 1055e5c31af7Sopenharmony_ciNever use asciidoctor conditionals _inside_ a valid usage statement. 1056e5c31af7Sopenharmony_ci 1057e5c31af7Sopenharmony_ciExplicit valid usage statements must be assigned Valid Usage ID tags before 1058e5c31af7Sopenharmony_cipublication. 1059e5c31af7Sopenharmony_ciThis process is described in the <<appendix-vuid, Valid Usage ID Tags>> 1060e5c31af7Sopenharmony_ciappendix, but is normally performed only when preparing to integrate 1061e5c31af7Sopenharmony_cifunctionality into the Vulkan Specification prior to publication. 1062e5c31af7Sopenharmony_ciIt is something authors of new functionality should be aware of, but are not 1063e5c31af7Sopenharmony_cithemselves responsible for. 1064e5c31af7Sopenharmony_ciFor example, when writing the explicit 1065e5c31af7Sopenharmony_ciflink:vkCreateCommandPool::pname:queueFamilyIndex valid usage statement 1066e5c31af7Sopenharmony_cishown above, the tag 1067e5c31af7Sopenharmony_ci 1068e5c31af7Sopenharmony_ci[source,asciidoc,subs=attributes+] 1069e5c31af7Sopenharmony_ci---- 1070e5c31af7Sopenharmony_ci[[VUID-vkCreateCommandPool-queueFamilyIndex-01937]] 1071e5c31af7Sopenharmony_ci---- 1072e5c31af7Sopenharmony_ci 1073e5c31af7Sopenharmony_ciwas inserted by a script, not the original author. 1074e5c31af7Sopenharmony_ci 1075e5c31af7Sopenharmony_ci[NOTE] 1076e5c31af7Sopenharmony_ci.Guideline 1077e5c31af7Sopenharmony_ci==== 1078e5c31af7Sopenharmony_ciIf the same set of valid usage statements are going to be common to multiple 1079e5c31af7Sopenharmony_cicommands or structures, these should be extracted into a separate file under 1080e5c31af7Sopenharmony_ci`chapters/commonvalidity/`. 1081e5c31af7Sopenharmony_ciThe file name should be short but to the point (e.g. `draw_common.txt`), and 1082e5c31af7Sopenharmony_cithen the file can be included in the relevant API features using standard 1083e5c31af7Sopenharmony_ciinclude syntax: 1084e5c31af7Sopenharmony_ci 1085e5c31af7Sopenharmony_ci[source,asciidoc,subs=attributes+] 1086e5c31af7Sopenharmony_ci~~~~ 1087e5c31af7Sopenharmony_ci.Valid Usage 1088e5c31af7Sopenharmony_ci**** 1089e5c31af7Sopenharmony_ci\include::\{chapters}/commonvalidity/draw_common.txt[] 1090e5c31af7Sopenharmony_ci\include::\{chapters}/commonvalidity/draw_vertex_binding.txt[] 1091e5c31af7Sopenharmony_ci * [[VUID-vkCmdDrawIndirectByteCountEXT-transformFeedback-02287]] 1092e5c31af7Sopenharmony_ci sname:VkPhysicalDeviceTransformFeedbackFeaturesEXT::pname:transformFeedback 1093e5c31af7Sopenharmony_ci must: be enabled 1094e5c31af7Sopenharmony_ci**** 1095e5c31af7Sopenharmony_ci~~~~ 1096e5c31af7Sopenharmony_ci 1097e5c31af7Sopenharmony_ciCommon VU includes should appear before individual VUs for consistency. 1098e5c31af7Sopenharmony_ci 1099e5c31af7Sopenharmony_ciThe file itself should be structured with the comment `// Common Valid 1100e5c31af7Sopenharmony_ciUsage` used as a delimiter at the start and end of the file, with a comment 1101e5c31af7Sopenharmony_cidescribing in more detail where these are included, and then the valid usage 1102e5c31af7Sopenharmony_cistatement bullets outside of a valid usage block. 1103e5c31af7Sopenharmony_ciFor example: 1104e5c31af7Sopenharmony_ci 1105e5c31af7Sopenharmony_ci[source,asciidoc] 1106e5c31af7Sopenharmony_ci~~~~ 1107e5c31af7Sopenharmony_ci// Common Valid Usage 1108e5c31af7Sopenharmony_ci// Common to drawing commands that consume vertex binding state 1109e5c31af7Sopenharmony_ci * All vertex input bindings accessed via vertex input variables declared 1110e5c31af7Sopenharmony_ci in the vertex shader entry point's interface must: have valid buffers 1111e5c31af7Sopenharmony_ci bound 1112e5c31af7Sopenharmony_ci * For a given vertex buffer binding, any attribute data fetched must: be 1113e5c31af7Sopenharmony_ci entirely contained within the corresponding vertex buffer binding, as 1114e5c31af7Sopenharmony_ci described in <<fxvertex-input>> 1115e5c31af7Sopenharmony_ci// Common Valid Usage 1116e5c31af7Sopenharmony_ci~~~~ 1117e5c31af7Sopenharmony_ci 1118e5c31af7Sopenharmony_ciFinally, the original feature section needs to define the `:refpage:` 1119e5c31af7Sopenharmony_ciattribute to match the name of the feature, as this is used to correctly 1120e5c31af7Sopenharmony_cigenerate links to expanded common valid usage statements in the built 1121e5c31af7Sopenharmony_cispecification. 1122e5c31af7Sopenharmony_ci 1123e5c31af7Sopenharmony_ci[source,asciidoc] 1124e5c31af7Sopenharmony_ci~~~~ 1125e5c31af7Sopenharmony_ci[open,refpage='vkCmdDrawIndirectByteCountEXT',desc='Draw primitives where the vertex count is derived from the counter byte value in the counter buffer',type='protos'] 1126e5c31af7Sopenharmony_ci-- 1127e5c31af7Sopenharmony_ci:refpage: vkCmdDrawIndirectByteCountEXT 1128e5c31af7Sopenharmony_ci~~~~ 1129e5c31af7Sopenharmony_ci 1130e5c31af7Sopenharmony_ciIn general, this methodology should be preferred over any other method of 1131e5c31af7Sopenharmony_ciconsolidation - e.g. calling out a block of common valid usage statements, 1132e5c31af7Sopenharmony_cior referencing the valid usage statements of another command. 1133e5c31af7Sopenharmony_ciHowever, for cases where the boilerplate of setting this up creates more 1134e5c31af7Sopenharmony_citext than a simple copy paste (e.g. only two commands consume a single 1135e5c31af7Sopenharmony_civalid usage statement), the original VUs can be left intact. 1136e5c31af7Sopenharmony_ci==== 1137e5c31af7Sopenharmony_ci 1138e5c31af7Sopenharmony_ci 1139e5c31af7Sopenharmony_ci[[writing-empty-enumerations]] 1140e5c31af7Sopenharmony_ci== Markup For Empty Enumerated Types 1141e5c31af7Sopenharmony_ci 1142e5c31af7Sopenharmony_ciSometimes an enumerated type has all values defined by extensions, and each 1143e5c31af7Sopenharmony_cienumerated value defined by the type will be surrounded by an asciidoctor 1144e5c31af7Sopenharmony_ciconditional for the corresponding extension. 1145e5c31af7Sopenharmony_ciWhen a specification is built without any of those extensions enabled, the 1146e5c31af7Sopenharmony_citype should still be included, even though it is empty. 1147e5c31af7Sopenharmony_ciIn this case, the enumerated value descriptions must be followed by one 1148e5c31af7Sopenharmony_ciadditional conditional section which is only included when *none* of the 1149e5c31af7Sopenharmony_cirelevant extensions are enabled. 1150e5c31af7Sopenharmony_ci 1151e5c31af7Sopenharmony_ciFor example, the relevant part of the 1152e5c31af7Sopenharmony_ciename:VkDescriptorSetLayoutCreateFlagBits description, whose only value is 1153e5c31af7Sopenharmony_cidefined by an extension, will look like this: 1154e5c31af7Sopenharmony_ci 1155e5c31af7Sopenharmony_ci[source,asciidoc,subs=attributes+] 1156e5c31af7Sopenharmony_ci---- 1157e5c31af7Sopenharmony_ci\include::\{generated}/api/enums/VkDescriptorSetLayoutCreateFlagBits.txt[] 1158e5c31af7Sopenharmony_ci 1159e5c31af7Sopenharmony_ci\ifdef::VK_KHR_push_descriptor[] 1160e5c31af7Sopenharmony_ci * ename:VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR specifies 1161e5c31af7Sopenharmony_ci that descriptor sets must: not be allocated using this layout, and 1162e5c31af7Sopenharmony_ci descriptors are instead pushed by flink:vkCmdPushDescriptorSetKHR. 1163e5c31af7Sopenharmony_ci\endif::VK_KHR_push_descriptor[] 1164e5c31af7Sopenharmony_ci 1165e5c31af7Sopenharmony_ci\ifndef::VK_KHR_push_descriptor[] 1166e5c31af7Sopenharmony_ci[NOTE] 1167e5c31af7Sopenharmony_ci.Note 1168e5c31af7Sopenharmony_ci==== 1169e5c31af7Sopenharmony_ciAll bits for this type are defined by extensions, and none of those 1170e5c31af7Sopenharmony_ciextensions are enabled in this build of the specification. 1171e5c31af7Sopenharmony_ci==== 1172e5c31af7Sopenharmony_ci\endif::VK_KHR_push_descriptor[] 1173e5c31af7Sopenharmony_ci---- 1174e5c31af7Sopenharmony_ci 1175e5c31af7Sopenharmony_ci 1176e5c31af7Sopenharmony_ci[[writing-refpages]] 1177e5c31af7Sopenharmony_ci== Markup For Automatic Reference Page Extraction 1178e5c31af7Sopenharmony_ci 1179e5c31af7Sopenharmony_ciThe Vulkan reference pages are (mostly) extracted from corresponding 1180e5c31af7Sopenharmony_cisections of the API Specification. 1181e5c31af7Sopenharmony_ciThis requires that the markup and writing conventions described above be 1182e5c31af7Sopenharmony_ciadhered to rigidly. 1183e5c31af7Sopenharmony_ci 1184e5c31af7Sopenharmony_ciThe extraction scripts for a given page rely on the existence of an 1185e5c31af7Sopenharmony_ciasciidoctor `open` block surrounding markup describing that page, with 1186e5c31af7Sopenharmony_ciattributes used to specify properties of the reference page. 1187e5c31af7Sopenharmony_ciAdditional heuristics and non-asciidoctor tags, described below, are used to 1188e5c31af7Sopenharmony_ciidentify subsections of a reference page in some cases. 1189e5c31af7Sopenharmony_ci 1190e5c31af7Sopenharmony_ciIn general the open block introduction will look like: 1191e5c31af7Sopenharmony_ci 1192e5c31af7Sopenharmony_ci[source,asciidoc] 1193e5c31af7Sopenharmony_ci---- 1194e5c31af7Sopenharmony_ci[open,refpage='name',desc='short description',type='pagetype',alias='alias',anchor='anchor',xrefs='xrefs'] 1195e5c31af7Sopenharmony_ci-- 1196e5c31af7Sopenharmony_ci---- 1197e5c31af7Sopenharmony_ci 1198e5c31af7Sopenharmony_ciAttributes which can be set on the block are: 1199e5c31af7Sopenharmony_ci 1200e5c31af7Sopenharmony_ci * *refpage* - the name of the reference page, e.g. the Vulkan interface 1201e5c31af7Sopenharmony_ci (command, structure, enumerant, handle, etc.) name. This attribute is 1202e5c31af7Sopenharmony_ci required. 1203e5c31af7Sopenharmony_ci * *desc* - short description / summary of the page, used in the page 1204e5c31af7Sopenharmony_ci title. 1205e5c31af7Sopenharmony_ci This attribute is required. 1206e5c31af7Sopenharmony_ci * *type* - type of the interface, which must match the directory name 1207e5c31af7Sopenharmony_ci following `api/` in the interface `include::` line within the block, and 1208e5c31af7Sopenharmony_ci must be one of `basetypes`, `defines`, `enums`, `flags`, `funcpointers`, 1209e5c31af7Sopenharmony_ci `handles`, `protos`, or `structs`; or the non-API block types `feature`, 1210e5c31af7Sopenharmony_ci `freeform`. or `spirv`. 1211e5c31af7Sopenharmony_ci This attribute is required. 1212e5c31af7Sopenharmony_ci * *alias* - list of comma-separated names of other API entities which this 1213e5c31af7Sopenharmony_ci refpage also describes. This is used when an API is promoted and the 1214e5c31af7Sopenharmony_ci refpage block describes both the old and promoted APIs. 1215e5c31af7Sopenharmony_ci This attribute is optional. 1216e5c31af7Sopenharmony_ci * *anchor* - anchor name at which this reference page is fully described 1217e5c31af7Sopenharmony_ci in the API specification document. 1218e5c31af7Sopenharmony_ci This attribute is optional except for the non-API block types, which do 1219e5c31af7Sopenharmony_ci not correspond to Vulkan APIs. 1220e5c31af7Sopenharmony_ci * *xrefs* - list of whitespace-separated names of other reference pages 1221e5c31af7Sopenharmony_ci which should be added to the `See Also` section of this page. 1222e5c31af7Sopenharmony_ci Most cross-references are automatically generated based on the immediate 1223e5c31af7Sopenharmony_ci dependency information in `vk.xml`, but in some cases, such as referring 1224e5c31af7Sopenharmony_ci between `*FlagBits` and `*Flags` types, this additional tagging is 1225e5c31af7Sopenharmony_ci useful. 1226e5c31af7Sopenharmony_ci This attribute is optional. 1227e5c31af7Sopenharmony_ci 1228e5c31af7Sopenharmony_ciAttributes of the open block must be written in this format, using single 1229e5c31af7Sopenharmony_ciquotes as delimiters (even though asciidoctor markup also allows double 1230e5c31af7Sopenharmony_ciquotes), and escape single quotes in e.g. the *desc* attribute value with 1231e5c31af7Sopenharmony_cibackquotes. 1232e5c31af7Sopenharmony_ci 1233e5c31af7Sopenharmony_ciAfter the open block is started, the following markup should be provided: 1234e5c31af7Sopenharmony_ci 1235e5c31af7Sopenharmony_ci * A single paragraph of text describing the definition of the interface. 1236e5c31af7Sopenharmony_ci This paragraph is optional, but strongly recommended. 1237e5c31af7Sopenharmony_ci * The `include` line for the interface, which must be consistent with the 1238e5c31af7Sopenharmony_ci page name and type in the open block attributes. 1239e5c31af7Sopenharmony_ci This paragraph is required. 1240e5c31af7Sopenharmony_ci * A bullet list describing function parameters, structure members, 1241e5c31af7Sopenharmony_ci enumerants in an enumerated type, etc. 1242e5c31af7Sopenharmony_ci This list should contain no empty lines, as the extraction script 1243e5c31af7Sopenharmony_ci classifies the uninterrupted block of text following the `include` 1244e5c31af7Sopenharmony_ci directive as the `Parameters` or `Members` section of the ref page. 1245e5c31af7Sopenharmony_ci This list is required, unless the interface has nothing to describe, 1246e5c31af7Sopenharmony_ci such as an empty structure or enumeration, or a function with no 1247e5c31af7Sopenharmony_ci parameters. 1248e5c31af7Sopenharmony_ci * Paragraphs of text making up the `Description` section of the ref page. 1249e5c31af7Sopenharmony_ci This section is optional. 1250e5c31af7Sopenharmony_ci If it is necessary due to constraints of asciidoctor markup to have an 1251e5c31af7Sopenharmony_ci empty line in the bullet list section, add a `// refBody` comment 1252e5c31af7Sopenharmony_ci immediately following the bullet list and preceding this section: 1253e5c31af7Sopenharmony_ci+ 1254e5c31af7Sopenharmony_ci[source,asciidoc] 1255e5c31af7Sopenharmony_ci---- 1256e5c31af7Sopenharmony_ci// refBody 1257e5c31af7Sopenharmony_ci---- 1258e5c31af7Sopenharmony_ci+ 1259e5c31af7Sopenharmony_ciThere are no examples of this usage in the Vulkan 1.2.192 Specification, 1260e5c31af7Sopenharmony_cibut it has been needed in the past and may again in the future. 1261e5c31af7Sopenharmony_ci+ 1262e5c31af7Sopenharmony_ci * An explicit valid usage block. 1263e5c31af7Sopenharmony_ci This block is required if the interface has such valid usage 1264e5c31af7Sopenharmony_ci constraints. 1265e5c31af7Sopenharmony_ci * The `include` line for the implicit valid usage block. 1266e5c31af7Sopenharmony_ci This line is required for commands and structures, but not for 1267e5c31af7Sopenharmony_ci interfaces such as enumerated types, which do not have implicit valid 1268e5c31af7Sopenharmony_ci usage blocks. 1269e5c31af7Sopenharmony_ci * Finally, a two-dash asciidoctor delimiter closing the open block: 1270e5c31af7Sopenharmony_ci+ 1271e5c31af7Sopenharmony_ci[source,asciidoc] 1272e5c31af7Sopenharmony_ci---- 1273e5c31af7Sopenharmony_ci-- 1274e5c31af7Sopenharmony_ci---- 1275e5c31af7Sopenharmony_ci 1276e5c31af7Sopenharmony_ciAll elements specifying an interface name (open block `refpage` attributes, 1277e5c31af7Sopenharmony_ciinterface `include` lines, and validity `include` lines) must use the same 1278e5c31af7Sopenharmony_ciinterface name, if present. 1279e5c31af7Sopenharmony_ciOtherwise the extraction script is either unable to extract that page, or 1280e5c31af7Sopenharmony_ciwill extract the wrong text - and the language will be structurally 1281e5c31af7Sopenharmony_ciincorrect, as well. 1282e5c31af7Sopenharmony_ciThe extraction process is somewhat fragile, so care should be taken and the 1283e5c31af7Sopenharmony_ciresults of reference page extraction verified after making changes to that 1284e5c31af7Sopenharmony_ciportion of the specification source. 1285e5c31af7Sopenharmony_ci 1286e5c31af7Sopenharmony_ciContent that should only appear in reference pages, such as 1287e5c31af7Sopenharmony_cideveloper-oriented guidelines for reference pages describing extensions, may 1288e5c31af7Sopenharmony_cibe conditionally included in the specification as follows: 1289e5c31af7Sopenharmony_ci 1290e5c31af7Sopenharmony_ci[source,asciidoc,subs=attributes+] 1291e5c31af7Sopenharmony_ci---- 1292e5c31af7Sopenharmony_ci\ifdef::isrefpage[] 1293e5c31af7Sopenharmony_ci 1294e5c31af7Sopenharmony_ci=== Refpage-Only Section 1295e5c31af7Sopenharmony_ci 1296e5c31af7Sopenharmony_ci*This section will appear only when generating an extension refpage, 1297e5c31af7Sopenharmony_cibut not in the specification extensions appendix.* 1298e5c31af7Sopenharmony_ci 1299e5c31af7Sopenharmony_ci\endif::isrefpage[] 1300e5c31af7Sopenharmony_ci---- 1301