VK_HUAWEI_invocation_mask

Other Extension Metadata

Last Modified Date

2021-05-27

Interactions and External Dependencies
Contributors
  • Yunpeng Zhu
  • Juntao Li, Huawei
  • Liang Chen, Huawei
  • Shaozhuang Shi, Huawei
  • Hailong Chu, Huawei

Description

The rays to trace may be sparse in some use cases. For example, the scene only have a few regions to reflect. Providing an invocation mask image to the ray tracing commands could potentially give the hardware the hint to do certain optimization without invoking an additional pass to compact the ray buffer.

New Commands

New Structures

New Enum Constants

  • VK_HUAWEI_INVOCATION_MASK_EXTENSION_NAME
  • VK_HUAWEI_INVOCATION_MASK_SPEC_VERSION
  • Extending VkAccessFlagBits2:
    • VK_ACCESS_2_INVOCATION_MASK_READ_BIT_HUAWEI
  • Extending VkImageUsageFlagBits:
    • VK_IMAGE_USAGE_INVOCATION_MASK_BIT_HUAWEI
  • Extending VkPipelineStageFlagBits2:
    • VK_PIPELINE_STAGE_2_INVOCATION_MASK_BIT_HUAWEI
  • Extending VkStructureType:
    • VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_INVOCATION_MASK_FEATURES_HUAWEI

Examples

RT mask is updated before each traceRay.

Step 1. Generate InvocationMask.

//the rt mask image bind as color attachment in the fragment shader
Layout(location = 2) out vec4 outRTmask
vec4 mask = vec4(x,x,x,x);
outRTmask = mask;

Step 2. traceRay with InvocationMask

vkCmdBindPipeline(
    commandBuffers[imageIndex],
    VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR, m_rtPipeline);
    vkCmdBindDescriptorSets(commandBuffers[imageIndex],
    VK_PIPELINE_BIND_POINT_RAY_TRACING_NV,
    m_rtPipelineLayout, 0, 1, &m_rtDescriptorSet,
    0, nullptr);

vkCmdBindInvocationMaskHUAWEI(
    commandBuffers[imageIndex],
    InvocationMaskimageView,
    InvocationMaskimageLayout);
    vkCmdTraceRaysKHR(commandBuffers[imageIndex],
    pRaygenShaderBindingTable,
    pMissShaderBindingTable,
    swapChainExtent.width,
    swapChainExtent.height, 1);

Version History

  • Revision 1, 2021-05-27 (Yunpeng Zhu)
    • Initial draft.