Vulkan-Docs/chapters/VK_NV_ray_tracing/raytracing-shaders.txt
Jon Leech e24e42dcff Change log for November 4, 2018 Vulkan 1.1.91 spec update:
* Update release number to 91.

Public Issues:

  * Update Ubuntu subsystem build instructions in `BUILD.adoc` (public pull
    request 624).
  * Delete the `VK_KHR_mir_surface` extension from the Specification and
    XML, due to EOL of the only driver known to have supported it, and
    near-EOL of Mir itself (public issue 814).
  * Fix options for some figures that were using old ones (public pull
    request 841).
  * Fix various accidentally repeated words (public pull request 843).
  * Use `time.process_time()`, introduced in Python 3.3, in the scripts
    instead of `time.clock()`, which will be removed in Python 3.8 (public
    pull request 844).

Internal Issues:

  * Update valid usage statements for
    `VK_ANDROID_external_memory_android_hardware_buffer` in
    slink:VkMemoryAllocateInfo,
    slink:VkImportAndroidHardwareBufferInfoANDROID, and
    flink:vkGetAndroidHardwareBufferPropertiesANDROID to actually be
    verifiable (internal issue 1419).
  * Update valid usage statements for
    `VK_ANDROID_external_memory_android_hardware_buffer` in
    slink:VkMemoryAllocateInfo, slink:VkImageCreateInfo, and
    slink:VkImageViewCreateInfo to move valid usage statements in
    doubly-nested bullet points up one level, accomodating limitations of
    the valid usage extraction script that creates `validusage.json`
    (internal issue 1434).
  * Fix typo etext:VK_ACCESS_SHADING_RATE_IMAGE_BIT_NV to the correct
    ename:VK_ACCESS_SHADING_RATE_IMAGE_READ_BIT_NV.
  * Add missing etext:VK_STRUCTURE_TYPE_* tokens to appendices for
    extensions missing them.

New Extensions:

  * `VK_AMD_memory_overallocation_behavior`
  * `VK_NV_ray_tracing`, replacing `VK_NVX_raytracing`
2018-11-03 23:50:13 -07:00

104 lines
3.6 KiB
Plaintext

// This section is included inside the Shaders chapter (shaders.txt)
[[shaders-raytracing-shaders]]
[[shaders-ray-generation]]
== Ray Generation Shaders
A ray generation shader is similar to a compute shader.
Its main purpose is to execute ray tracing queries using code:OpTraceNV
instructions and process the results.
[[shaders-ray-generation-execution]]
=== Ray Generation Shader Execution
One ray generation shader is executed per ray tracing dispatch.
Its location in the shader binding table (see <<shader-binding-table,Shader
Binding Table>> for details) is passed directly into fname:vkCmdTraceRaysNV
using the pname:raygenShaderBindingTableBuffer and
pname:raygenShaderBindingOffset parameters.
[[shaders-intersection]]
== Intersection Shaders
Intersection shaders enable the implementation of arbitrary, application
defined geometric primitives.
An intersection shader for a primitive is executed whenever its axis-aligned
bounding box is hit by a ray.
A built-in intersection shader for triangle primitives that is used
automatically whenever geometry of type ename:VK_GEOMETRY_TYPE_TRIANGLES_NV
is specified.
Like other ray tracing shader domains, an intersection shader operates on a
single ray at a time.
It also operates on a single primitive at a time.
It is therefore the purpose of an intersection shader to compute the
ray-primitive intersections and report them.
To report an intersection, the shader calls the code:OpReportIntersectionNV
instruction.
An intersection shader communicates with any hit and closest shaders by
generating attribute values that they can read.
Intersection shaders cannot read or modify the ray payload.
[[shaders-intersection-execution]]
=== Intersection Shader Execution
[[shaders-any-hit]]
== Any Hit Shaders
The any hit shader is executed after the intersection shader reports an
intersection that lies within the current [tmin,tmax] of the ray.
The main use of any hit shaders is to programmatically decide whether or not
an intersection should be accepted.
The intersection will be accepted unless the shader calls the
code:OpIgnoreIntersectionNV instruction.
[[shaders-any-hit-execution]]
=== Any Hit Shader Execution
The order in which intersections are found along a ray, and therefore the
order in which any hit shaders are executed, is unspecified.
The any hit shader of the closest hit is guaranteed to be executed at some
point during traversal, unless the ray is forcibly terminated.
[[shaders-closest-hit]]
== Closest Hit Shaders
Closest hit shaders have read-only access to the attributes generated by the
corresponding intersection shader, and may: read or modify the ray payload.
They also have access to a number of system-generated values.
Closest hit shaders may call code:OpTraceNV to recursively trace rays.
[[shaders-closest-hit-execution]]
=== Closest Hit Shader Execution
Exactly one closest hit shader is executed when traversal is finished and an
intersection has been found and accepted.
[[shaders-miss]]
== Miss Shaders
Miss shaders can access the ray payload and can trace new rays through the
code:OpTraceNV instruction, but cannot access attributes since they are not
associated with an intersection.
[[shaders-miss-execution]]
=== Miss Shader Execution
A miss shader is executed instead of a closest hit shader if no intersection
was found during traversal.
[[shaders-callable]]
== Callable Shaders
Callable shaders may: access a callable payload that works similarly to ray
payloads to do subroutine work.
[[shaders-callable-execution]]
=== Callable Shader Execution
A callable shader is executed by calling code:OpExecuteCallableNV from an
allowed shader stage.