2016-02-16 09:53:44 +00:00
|
|
|
// Copyright (c) 2015-2016 The Khronos Group Inc.
|
|
|
|
// Copyright notice at https://www.khronos.org/registry/speccopyright.html
|
|
|
|
|
|
|
|
[appendix]
|
|
|
|
= Invariance
|
|
|
|
|
|
|
|
The {apiname} specification is not pixel exact. It therefore does not
|
|
|
|
guarantee an exact match between images produced by different {apiname}
|
|
|
|
implementations. However, the specification does specify exact matches, in
|
|
|
|
some cases, for images produced by the same implementation. The purpose of
|
|
|
|
this appendix is to identify and provide justification for those cases that
|
|
|
|
require exact matches.
|
|
|
|
|
|
|
|
== Repeatability
|
|
|
|
|
|
|
|
The obvious and most fundamental case is repeated issuance of a series of
|
|
|
|
{apiname} commands. For any given {apiname} and framebuffer state vector,
|
|
|
|
and for any {apiname} command, the resulting {apiname} and framebuffer state
|
|
|
|
must: be identical whenever the command is executed on that initial
|
|
|
|
{apiname} and framebuffer state. This repeatability requirement doesn't
|
|
|
|
apply when using shaders containing side effects (image and buffer variable
|
|
|
|
stores and atomic operations), because these memory operations are not
|
|
|
|
guaranteed to be processed in a defined order.
|
|
|
|
|
|
|
|
One purpose of repeatability is avoidance of visual artifacts when a
|
|
|
|
doublebuffered scene is redrawn. If rendering is not repeatable, swapping
|
|
|
|
between two buffers rendered with the same command sequence may: result in
|
|
|
|
visible changes in the image. Such false motion is distracting to the
|
|
|
|
viewer. Another reason for repeatability is testability.
|
|
|
|
|
|
|
|
Repeatability, while important, is a weak requirement. Given only
|
|
|
|
repeatability as a requirement, two scenes rendered with one (small) polygon
|
|
|
|
changed in position might differ at every pixel. Such a difference, while
|
|
|
|
within the law of repeatability, is certainly not within its spirit.
|
|
|
|
Additional invariance rules are desirable to ensure useful operation.
|
|
|
|
|
|
|
|
|
|
|
|
== Multi-pass Algorithms
|
|
|
|
|
|
|
|
Invariance is necessary for a whole set of useful multi-pass algorithms.
|
|
|
|
Such algorithms render multiple times, each time with a different {apiname}
|
|
|
|
mode vector, to eventually produce a result in the framebuffer. Examples of
|
|
|
|
these algorithms include:
|
|
|
|
|
|
|
|
* ``Erasing'' a primitive from the framebuffer by redrawing it, either in
|
|
|
|
a different color or using the XOR logical operation.
|
|
|
|
* Using stencil operations to compute capping planes.
|
|
|
|
|
|
|
|
|
|
|
|
== Invariance Rules
|
|
|
|
|
|
|
|
For a given instantiation of an {apiname} rendering context:
|
|
|
|
|
|
|
|
*Rule 1* _For any given {apiname} and framebuffer state vector, and for any
|
|
|
|
given {apiname} command, the resulting {apiname} and framebuffer state must:
|
|
|
|
be identical each time the command is executed on that initial {apiname} and
|
|
|
|
framebuffer state._
|
|
|
|
|
|
|
|
*Rule 2* _Changes to the following state values have no side effects (the
|
|
|
|
use of any other state value is not affected by the change):_
|
|
|
|
|
|
|
|
*Required:*
|
|
|
|
|
|
|
|
* _Framebuffer contents (all bitplanes)_
|
|
|
|
* _The color buffers enabled for writing_
|
|
|
|
* _Scissor parameters (other than enable)_
|
|
|
|
* _Writemasks (color, depth, stencil)_
|
|
|
|
* _Clear values (color, depth, stencil)_
|
|
|
|
|
|
|
|
*Strongly suggested:*
|
|
|
|
|
|
|
|
* _Stencil Parameters (other than enable)_
|
|
|
|
* _Depth test parameters (other than enable)_
|
|
|
|
* _Blend parameters (other than enable)_
|
|
|
|
* _Logical operation parameters (other than enable)_
|
|
|
|
* _Pixel storage state_
|
|
|
|
|
|
|
|
*Corollary 1* _Fragment generation is invariant with respect to the state
|
Change log for February 25, 2015 Vulkan 1.0.4 spec update:
* Bump API patch number from 3 to 4 for the first public update to the
spec. Add patch number to the spec title (this will be done
automatically from XML, later).
* Fixes for numerous editorial issues. Regularize descriptions of
variable-length array queries. Properly tag enumerants so they come
out in the right font (many were mislabeled in usage tags in vk.xml,
or not tagged). Spelling and markup corrections (public issue 4).
* Fix typos and clearly separate description of different types of
memory areas (public issue 5).
* Use standards-compliant preprocessor guard symbols on headers
(public issue 7).
* Note that Github users can't currently set labels on issues, and
recommend a fallback approach (public issue 15).
* Use latexmath prefix on len= attributes (public issue 29).
* Make flink:vkCmdUpdateBuffer pname:dataSize limit consistent (public
issue 65).
* Add VK_KHR_mirror_clamp_to_edge extension to core API branch, as an
optional feature not introducing new commands or enums (internal
issue 104).
* Cleanup invariance language inherited from the GL specification to
not refer to nonexistent (GL-specific) state (internal issue 111).
* Modify the flink:vkCmdDrawIndexed pname:vertexOffset definition to
not be the "base offset within the index buffer" but rather the
"value added to the vertex index before indexing into the vertex
buffer" (internal issue 118).
* Fix drawing chapter in the "Programmable Primitive Shading" section
where it described categories of drawing commands. It referenced
flink:vkCmdDrawIndexed twice. Replace the second reference with
flink:vkCmdDrawIndexedIndirect (internal issue 119).
* Typo fixed in <<sparsememory-examples-advanced,Advanced Sparse
Resources>> sparse memory example (internal issue 122).
* Add flink:VkDisplayPlaneAlphaFlagsKHR to <require> section of
VK_KHR_display extension (internal issue 125)
* Add missing optional="false,true" to
flink:vkGetImageSparseMemoryRequirements
pname:pSparseMemoryRequirementCount parameter (internal issue 132)
* Rename ename:VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT to
ename:VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT
(internal issue 133)
* Fix a handful of broken cross-references in the
<<samplers,Samplers>> chapter (internal issue 134).
* Fix "Input Attachement" GLSL example to use correct syntax (internal
issue 135).
* Update XML schema and documentation to accomodate recently added
attributes for validity. Add some introductory material describing
design choices and pointing to the public repository to file issues.
* Put include of validity in the core spec extensions chapter on its
own line, so that asciidoc is happy.
* Fix vertexOffset language to specify that it's the value added to
the vertex index before indexing into the vertex buffer, not the
base offset within the index buffer.
* Fix error in the description of flink:vkCmdNextSubpass.
2016-02-25 06:02:34 +00:00
|
|
|
values listed in Rule 2._
|
2016-02-16 09:53:44 +00:00
|
|
|
|
|
|
|
*Rule 3* _The arithmetic of each per-fragment operation is invariant except
|
|
|
|
with respect to parameters that directly control it._
|
|
|
|
|
|
|
|
*Corollary 2* _Images rendered into different color buffers sharing the same
|
|
|
|
framebuffer, either simultaneously or separately using the same command
|
|
|
|
sequence, are pixel identical._
|
|
|
|
|
|
|
|
*Rule 4* _The same vertex or fragment shader will produce the same result
|
|
|
|
when run multiple times with the same input. The wording ``the same shader''
|
|
|
|
means a program object that is populated with the same SPIR-V binary, which
|
|
|
|
is used to create pipelines, possibly multiple times, and which program
|
|
|
|
object is then executed using the same {apiname} state vector. Invariance is
|
|
|
|
relaxed for shaders with side effects, such as performing stores or
|
|
|
|
atomics._
|
|
|
|
|
|
|
|
*Rule 5* _All fragment shaders that either conditionally or unconditionally
|
|
|
|
assign_ code:FragCoord.z _to_ code:FragDepth _are depth-invariant with
|
|
|
|
respect to each other, for those fragments where the assignment to_
|
|
|
|
code:FragDepth _actually is done._
|
|
|
|
|
|
|
|
If a sequence of {apiname} commands specifies primitives to be rendered with
|
|
|
|
shaders containing side effects (image and buffer variable stores and atomic
|
|
|
|
operations), invariance rules are relaxed. In particular, rule 1, corollary
|
|
|
|
2, and rule 4 do not apply in the presence of shader side effects.
|
|
|
|
|
|
|
|
The following weaker versions of rules 1 and 4 apply to {apiname} commands
|
|
|
|
involving shader side effects:
|
|
|
|
|
|
|
|
*Rule 6* _For any given {apiname} and framebuffer state vector, and for any
|
|
|
|
given {apiname} command, the contents of any framebuffer state not directly
|
|
|
|
or indirectly affected by results of shader image or buffer variable stores
|
|
|
|
or atomic operations must: be identical each time the command is executed on
|
|
|
|
that initial {apiname} and framebuffer state._
|
|
|
|
|
|
|
|
*Rule 7* _The same vertex or fragment shader will produce the same result
|
|
|
|
when run multiple times with the same input as long as:_
|
|
|
|
|
|
|
|
* _shader invocations do not use image atomic operations;_
|
|
|
|
* _no framebuffer memory is written to more than once by image stores,
|
|
|
|
unless all such stores write the same value; and_
|
|
|
|
* _no shader invocation, or other operation performed to process the
|
|
|
|
sequence of commands, reads memory written to by an image store._
|
|
|
|
|
|
|
|
When any sequence of {apiname} commands triggers shader invocations that
|
|
|
|
perform image stores or atomic operations, and subsequent {apiname} commands
|
|
|
|
read the memory written by those shader invocations, these operations must:
|
|
|
|
be explicitly synchronized.
|
|
|
|
|
|
|
|
|
|
|
|
== Tessellation Invariance
|
|
|
|
|
|
|
|
When using a program containing tessellation evaluation shaders, the
|
|
|
|
fixed-function tessellation primitive generator consumes the input patch
|
|
|
|
specified by an application and emits a new set of primitives. The following
|
|
|
|
invariance rules are intended to provide repeatability guarantees.
|
|
|
|
Additionally, they are intended to allow an application with a carefully
|
|
|
|
crafted tessellation evaluation shader to ensure that the sets of triangles
|
|
|
|
generated for two adjacent patches have identical vertices along shared
|
|
|
|
patch edges, avoiding ``cracks'' caused by minor differences in the
|
|
|
|
positions of vertices along shared edges.
|
|
|
|
|
|
|
|
*Rule 1* _When processing two patches with identical outer and inner
|
|
|
|
tessellation levels, the tessellation primitive generator will emit an
|
|
|
|
identical set of point, line, or triangle primitives as long as the active
|
|
|
|
program used to process the patch primitives has tessellation evaluation
|
|
|
|
shaders specifying the same tessellation mode, spacing, vertex order, and
|
|
|
|
point mode decorations. Two sets of primitives are considered identical if
|
|
|
|
and only if they contain the same number and type of primitives and the
|
|
|
|
generated tessellation coordinates for the vertex numbered m of the
|
|
|
|
primitive numbered n are identical for all values of m and n._
|
|
|
|
|
|
|
|
*Rule 2* _The set of vertices generated along the outer edge of the
|
|
|
|
subdivided primitive in triangle and quad tessellation, and the tessellation
|
|
|
|
coordinates of each, depends only on the corresponding outer tessellation
|
|
|
|
level and the spacing decorations in the tessellation shaders of the
|
|
|
|
pipeline._
|
|
|
|
|
|
|
|
*Rule 3* _The set of vertices generated when subdividing any outer primitive
|
|
|
|
edge is always symmetric. For triangle tessellation, if the subdivision
|
|
|
|
generates a vertex with tessellation coordinates of the form (0, x, 1-x),
|
|
|
|
(x, 0, 1-x), or (x, 1-x, 0), it will also generate a vertex with coordinates
|
|
|
|
of exactly (0, 1-x, x), (1-x, 0, x), or (1-x, x, 0), respectively. For quad
|
|
|
|
tessellation, if the subdivision generates a vertex with coordinates of (x,
|
|
|
|
0) or (0, x), it will also generate a vertex with coordinates of exactly
|
|
|
|
(1-x, 0) or (0, 1-x), respectively. For isoline tessellation, if it
|
|
|
|
generates vertices at (0, x) and (1, x) where x is not zero, it will also
|
|
|
|
generate vertices at exactly (0, 1-x) and (1, 1-x), respectively._
|
|
|
|
|
|
|
|
*Rule 4* _The set of vertices generated when subdividing outer edges in
|
|
|
|
triangular and quad tessellation must: be independent of the specific edge
|
|
|
|
subdivided, given identical outer tessellation levels and spacing. For
|
|
|
|
example, if vertices at (x, 1 - x, 0) and (1-x, x, 0) are generated when
|
|
|
|
subdividing the w = 0 edge in triangular tessellation, vertices must: be
|
|
|
|
generated at (x, 0, 1-x) and (1-x, 0, x) when subdividing an otherwise
|
|
|
|
identical v = 0 edge. For quad tessellation, if vertices at (x, 0) and
|
|
|
|
(1-x, 0) are generated when subdividing the v = 0 edge, vertices must: be
|
|
|
|
generated at (0, x) and (0, 1-x) when subdividing an otherwise identical
|
|
|
|
u = 0 edge._
|
|
|
|
|
|
|
|
*Rule 5* _When processing two patches that are identical in all respects
|
|
|
|
enumerated in rule 1 except for vertex order, the set of triangles generated
|
|
|
|
for triangle and quad tessellation must: be identical except for vertex and
|
|
|
|
triangle order. For each triangle n1 produced by processing the first patch,
|
|
|
|
there must: be a triangle n2 produced when processing the second patch each
|
|
|
|
of whose vertices has the same tessellation coordinates as one of the
|
|
|
|
vertices in n1._
|
|
|
|
|
|
|
|
*Rule 6* _When processing two patches that are identical in all respects
|
|
|
|
enumerated in rule 1 other than matching outer tessellation levels and/or
|
|
|
|
vertex order, the set of interior triangles generated for triangle and quad
|
|
|
|
tessellation must: be identical in all respects except for vertex and
|
|
|
|
triangle order. For each interior triangle n1 produced by processing the
|
|
|
|
first patch, there must: be a triangle n2 produced when processing the
|
|
|
|
second patch each of whose vertices has the same tessellation coordinates as
|
|
|
|
one of the vertices in n1. A triangle produced by the tessellator is
|
|
|
|
considered an interior triangle if none of its vertices lie on an outer edge
|
|
|
|
of the subdivided primitive._
|
|
|
|
|
|
|
|
*Rule 7* _For quad and triangle tessellation, the set of triangles
|
|
|
|
connecting an inner and outer edge depends only on the inner and outer
|
|
|
|
tessellation levels corresponding to that edge and the spacing decorations._
|
|
|
|
|
|
|
|
*Rule 8* _The value of all defined components of_ code:TessellationCoord
|
|
|
|
_will be in the range [0, 1]. Additionally, for any defined component x of_
|
|
|
|
code:TessellationCoord, _the results of computing 1.0-x in a tessellation
|
|
|
|
evaluation shader will be exact. If any floating-point values in the range
|
|
|
|
[0, 1] fail to satisfy this property, such values mustnot: be used as
|
|
|
|
tessellation coordinate components._
|