Vulkan-Docs/chapters/VK_NV_mesh_shader/mesh.txt

126 lines
5.3 KiB
Plaintext
Raw Permalink Normal View History

Change log for September 19, 2018 Vulkan 1.1.85 spec update: * Update release number to 85. Public Issues: * Add self-dependency ename:VK_DEPENDENCY_BY_REGION_BIT valid usage statements for slink:VkSubpassDependency(public pull request 778). * Apply fix from pull request 742 to slink:VkSubpassDependency and slink:VkSubpassDependency2 (public pull request 779). * Specify the units of slink:VkBufferImageCopy::pname:bufferRowLength and pname:bufferImageHeight as texels (public pull request 781). * Better specify promoted parameter mapping in the `<<VK_KHR_create_renderpass2>>` appendix (public pull request 782). Internal Issues: * Only include the <<fundamentals-validusage-versions, Valid Usage for Newer Core Versions>> section in Vulkan 1.1 or later (internal issue 1381). Other Issues: * Clean up redundant valid usage language for the `VK_ANDROID_external_memory_android_hardware_buffer` extension interaction with slink:VkImageCreateInfo. * Fix error in a flag name within valid usage statements for slink:VkMemoryAllocateInfo. * Clarify that memory types are not totally ordered in slink:VkPhysicalDeviceMemoryProperties. * For slink:VkWriteDescriptorSetInlineUniformBlockEXT, set structextends="VkWriteDescriptorSet" in `vk.xml`, and make slink:VkDescriptorSetLayoutBindingFlagsCreateInfoEXT::pname:pBindingFlags optional. * Add documentation of 'provisional' XML attribute to registry.txt. New Extensions: * `VK_NV_compute_shader_derivatives` * `VK_NV_corner_sampled_image` * `VK_NV_fragment_shader_barycentric` * `VK_NV_mesh_shader` * `VK_NV_representative_fragment_test` * `VK_NV_scissor_exclusive` * `VK_NV_shader_image_footprint` * `VK_NV_shading_rate_image` * `VK_NVX_raytracing`
2018-09-16 01:35:16 +00:00
[[mesh]]
= Mesh Shading
<<shaders-task,Task>> and <<shaders-mesh,mesh shaders>> operate in
workgroups to produce a collection of primitives that will be processed by
subsequent stages of the graphics pipeline.
Work on the mesh pipeline is initiated by the application
<<drawing-mesh-shading,drawing>> a set of mesh tasks organized in global
workgroups.
If the optional task shader is active, each workgroup triggers the execution
of task shader invocations that will create a new set of mesh workgroups
upon completion.
Each of these created workgroups, or each of the original workgroups if no
task shader is present, triggers the execution of mesh shader invocations.
Each mesh shader workgroup emits zero or more output primitives along with
the group of vertices and their associated data required for each output
primitive.
[[mesh-task-input]]
== Task Shader Input
For every workgroup issued via the drawing commands a group of task shader
invocations is executed.
There are no inputs other than the builtin workgroup identifiers.
[[mesh-task-output]]
== Task Shader Output
The task shader can emit zero or more mesh workgroups to be generated using
the <<interfaces-builtin-variables,built-in variable>> code:TaskCountNV.
This value must: be less than or equal to
sname:VkPhysicalDeviceMeshShaderPropertiesNV::pname:maxTaskOutputCount.
It can also output user-defined data that is passed as input to all mesh
shader invocations that the task creates.
These outputs are decorated as code:PerTaskNV.
[[mesh-generation]]
== Mesh Generation
If a task shader exists, the mesh assembler creates a variable amount of
mesh workgroups depending on each task's output.
If there is no task shader, the drawing commands emit the mesh shader
invocations directly.
[[mesh-input]]
== Mesh Shader Input
The only inputs available to the mesh shader are variables identifying the
specific workgroup and invocation and, if applicable, any outputs written as
code:PerTaskNV by the task shader that spawned the mesh shader's workgroup.
The mesh shader can operate without a task shader as well.
[[mesh-output]]
== Mesh Shader Output Primitives
A mesh shader generates primitives in one of three output modes: points,
lines, or triangles.
The primitive mode is specified in the shader using an code:OpExecutionMode
instruction with the code:OutputPoints, code:OutputLinesNV, or
code:OutputTrianglesNV modes, respectively.
Each mesh shader must: include exactly one output primitive mode.
The maximum output vertex count is specified as a literal in the shader
using an code:OpExecutionMode instruction with the mode set to
code:OutputVertices and must: be less than or equal to
sname:VkPhysicalDeviceMeshShaderPropertiesNV::pname:maxMeshOutputVertices.
The maximum output primitive count is specified as a literal in the shader
using an code:OpExecutionMode instruction with the mode set to
code:OutputPrimitivesNV and must: be less than or equal to
sname:VkPhysicalDeviceMeshShaderPropertiesNV::pname:maxMeshOutputPrimitives.
The number of primitives output by the mesh shader is provided via writing
to the <<interfaces-builtin-variables,built-in variable>>
code:PrimitiveCountNV and must: be less than or equal to the maximum output
primitive count specified in the shader.
A variable decorated with code:PrimitiveIndicesNV is an output array of
local index values into the vertex output arrays from which primitives are
assembled according to the output primitive type.
These resulting primitives are then further processed as described in
<<primsrast>>.
[[mesh-output-perview]]
== Mesh Shader Per-View Outputs
The mesh shader outputs decorated with the code:PositionPerViewNV,
code:ClipDistancePerViewNV, code:CullDistancePerViewNV, code:LayerPerViewNV,
and code:ViewportMaskPerViewNV built-in decorations are the per-view
versions of the single-view variables with equivalent names (that is
code:Position, code:ClipDistance, code:CullDistance, code:Layer, and
code:ViewportMaskNV, respectively).
If a shader statically assigns a value to any element of a per-view array it
must: not statically assign a value to the equivalent single-view variable.
Each of these outputs is considered arrayed, with separate values for each
view.
The view number is used to index the first dimension of these arrays.
The second dimension of the code:ClipDistancePerViewNV, and
code:CullDistancePerViewNV arrays have the same requirements as the
code:ClipDistance, and code:CullDistance arrays.
If a mesh shader output is _per-view_, the corresponding fragment shader
input is taken from the element of the per-view output array that
corresponds to the view that is currently being processed by the fragment
shader.
[[mesh-ordering]]
== Mesh Shader Primitive Ordering
Following guarantees are provided for the relative ordering of primitives
produced by a mesh shader, as they pertain to <<drawing-primitive-order,
primitive order>>.
* When a task shader is used, mesh workgroups spawned from lower tasks
will be ordered prior those workgroups from subsequent tasks.
* All output primitives generated from a given mesh workgroup are passed
to subsequent pipeline stages before any output primitives generated
from subsequent input workgroups.
* All output primitives within a mesh workgroup, will be generated in the
ordering provided by the builtin primitive indexbuffer (from low address
to high address).