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