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.txt[] 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, HuaWei 18 19=== Description 20 21The rays to trace may be sparse in some use cases. 22For example, the scene only have a few regions to reflect. 23Providing an invocation mask image to the ray tracing commands could 24potentially give the hardware the hint to do certain optimization without 25invoking an additional pass to compact the ray buffer. 26 27include::{generated}/interfaces/VK_HUAWEI_invocation_mask.txt[] 28 29=== Examples 30 31RT mask is updated before each traceRay. 32 33Step 1. 34Generate InvocationMask. 35 36[source,c] 37--------------------------------------------------- 38//the rt mask image bind as color attachment in the fragment shader 39Layout(location = 2) out vec4 outRTmask 40vec4 mask = vec4(x,x,x,x); 41outRTmask = mask; 42--------------------------------------------------- 43 44Step 2. 45traceRay with InvocationMask 46 47[source,c] 48--------------------------------------------------- 49vkCmdBindPipeline( 50 commandBuffers[imageIndex], 51 VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR, m_rtPipeline); 52 vkCmdBindDescriptorSets(commandBuffers[imageIndex], 53 VK_PIPELINE_BIND_POINT_RAY_TRACING_NV, 54 m_rtPipelineLayout, 0, 1, &m_rtDescriptorSet, 55 0, nullptr); 56 57vkCmdBindInvocationMaskHUAWEI( 58 commandBuffers[imageIndex], 59 InvocationMaskimageView, 60 InvocationMaskimageLayout); 61 vkCmdTraceRaysKHR(commandBuffers[imageIndex], 62 pRaygenShaderBindingTable, 63 pMissShaderBindingTable, 64 swapChainExtent.width, 65 swapChainExtent.height, 1); 66--------------------------------------------------- 67 68=== Version History 69 70 * Revision 1, 2021-05-27 (Yunpeng Zhu) 71 - Initial draft. 72