• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright (c) 2021 Huawei Technologies Co. Ltd.
2//
3// SPDX-License-Identifier: CC-BY-4.0
4
5include::{generated}/meta/{refprefix}VK_HUAWEI_invocation_mask.adoc[]
6
7=== Other Extension Metadata
8
9*Last Modified Date*::
10    2021-05-27
11*Interactions and External Dependencies*::
12  - This extension requires `apiext:VK_KHR_ray_tracing_pipeline`, which
13    allow to bind an invocation mask image before the ray tracing command
14  - This extension requires `apiext:VK_KHR_synchronization2`, which allows
15    new pipeline stage for the invocation mask image
16*Contributors*::
17  - Yunpeng Zhu
18  - Juntao Li, Huawei
19  - Liang Chen, Huawei
20  - Shaozhuang Shi, Huawei
21  - Hailong Chu, Huawei
22
23=== Description
24
25The rays to trace may be sparse in some use cases.
26For example, the scene only have a few regions to reflect.
27Providing an invocation mask image to the ray tracing commands could
28potentially give the hardware the hint to do certain optimization without
29invoking an additional pass to compact the ray buffer.
30
31include::{generated}/interfaces/VK_HUAWEI_invocation_mask.adoc[]
32
33=== Examples
34
35RT mask is updated before each traceRay.
36
37Step 1.
38Generate InvocationMask.
39
40[source,c]
41---------------------------------------------------
42//the rt mask image bind as color attachment in the fragment shader
43Layout(location = 2) out vec4 outRTmask
44vec4 mask = vec4(x,x,x,x);
45outRTmask = mask;
46---------------------------------------------------
47
48Step 2.
49traceRay with InvocationMask
50
51[source,c]
52---------------------------------------------------
53vkCmdBindPipeline(
54    commandBuffers[imageIndex],
55    VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR, m_rtPipeline);
56    vkCmdBindDescriptorSets(commandBuffers[imageIndex],
57    VK_PIPELINE_BIND_POINT_RAY_TRACING_NV,
58    m_rtPipelineLayout, 0, 1, &m_rtDescriptorSet,
59    0, nullptr);
60
61vkCmdBindInvocationMaskHUAWEI(
62    commandBuffers[imageIndex],
63    InvocationMaskimageView,
64    InvocationMaskimageLayout);
65    vkCmdTraceRaysKHR(commandBuffers[imageIndex],
66    pRaygenShaderBindingTable,
67    pMissShaderBindingTable,
68    swapChainExtent.width,
69    swapChainExtent.height, 1);
70---------------------------------------------------
71
72=== Version History
73
74  * Revision 1, 2021-05-27 (Yunpeng Zhu)
75  ** Initial draft.
76