Registered Extension Number

219

Revision

2

Extension and Version Dependencies

Contact

Other Extension Metadata

Last Modified Date

2021-09-30

Interactions and External Dependencies
Contributors
  • Matthew Netsch, Qualcomm Technologies, Inc.

  • Robert VanReenen, Qualcomm Technologies, Inc.

  • Jonathan Wicks, Qualcomm Technologies, Inc.

  • Tate Hornbeck, Qualcomm Technologies, Inc.

  • Sam Holmes, Qualcomm Technologies, Inc.

  • Jeff Leger, Qualcomm Technologies, Inc.

  • Jan-Harald Fredriksen, ARM

  • Jeff Bolz, NVIDIA

  • Pat Brown, NVIDIA

  • Daniel Rakos, AMD

  • Piers Daniell, NVIDIA

Description

This extension allows an application to specify areas of the render target where the fragment shader may be invoked fewer times. These fragments are broadcasted out to multiple pixels to cover the render target.

The primary use of this extension is to reduce workloads in areas where lower quality may not be perceived such as the distorted edges of a lens or the periphery of a user’s gaze.

New Structures

New Enum Constants

  • VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME

  • VK_EXT_FRAGMENT_DENSITY_MAP_SPEC_VERSION

  • Extending VkAccessFlagBits:

    • VK_ACCESS_FRAGMENT_DENSITY_MAP_READ_BIT_EXT

  • Extending VkFormatFeatureFlagBits:

    • VK_FORMAT_FEATURE_FRAGMENT_DENSITY_MAP_BIT_EXT

  • Extending VkImageCreateFlagBits:

    • VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT

  • Extending VkImageLayout:

    • VK_IMAGE_LAYOUT_FRAGMENT_DENSITY_MAP_OPTIMAL_EXT

  • Extending VkImageUsageFlagBits:

    • VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT

  • Extending VkImageViewCreateFlagBits:

    • VK_IMAGE_VIEW_CREATE_FRAGMENT_DENSITY_MAP_DYNAMIC_BIT_EXT

  • Extending VkPipelineStageFlagBits:

    • VK_PIPELINE_STAGE_FRAGMENT_DENSITY_PROCESS_BIT_EXT

  • Extending VkSamplerCreateFlagBits:

    • VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT

    • VK_SAMPLER_CREATE_SUBSAMPLED_COARSE_RECONSTRUCTION_BIT_EXT

  • Extending VkStructureType:

    • VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_DENSITY_MAP_FEATURES_EXT

    • VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_DENSITY_MAP_PROPERTIES_EXT

    • VK_STRUCTURE_TYPE_RENDER_PASS_FRAGMENT_DENSITY_MAP_CREATE_INFO_EXT

If VK_KHR_format_feature_flags2 is supported:

New or Modified Built-In Variables

New SPIR-V Capabilities

Version History

  • Revision 1, 2018-09-25 (Matthew Netsch)

    • Initial version

  • Revision 2, 2021-09-30 (Jon Leech)

Examples

Fragment Density Map

An image can be bound as a fragment density map attachment to a render pass. This image contains normalized (x, y) float component fragment density values for regions of the framebuffer that will be used in rasterization for every subpass. A float component ranges from (0.0, 1.0] where 1.0 means full density along that axis. Implementations use these values as hints to optimize rendering in areas of low density. Subpass color and depth attachments can be created as subsampled, which can help to further optimize rendering in areas of low density.

The density map image can be modified by the application until calling vkCmdBeginRenderPass for the render pass that uses the image. If VK_IMAGE_VIEW_CREATE_FRAGMENT_DENSITY_MAP_DYNAMIC_BIT_EXT is used, then the application can modify the image until the device reads it during VK_PIPELINE_STAGE_FRAGMENT_DENSITY_PROCESS_BIT_EXT.

// Create fragment density map
VkImageCreateInfo imageCreateInfo =
{
   ​VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
   nullptr,
   0,
   VK_IMAGE_TYPE_2D,       // Must be 2D
   VK_FORMAT_R8G8_UNORM,   // Must have VK_FORMAT_FEATURE_FRAGMENT_DENSITY_MAP_BIT_EXT
   {64, 64, 1},            // extent
   1,                      // mipLevels
   2,                      // arrayLayers; 1 for each multiview view
   VK_SAMPLE_COUNT_1_BIT,  // Must be 1x MSAA
   tiling,
   VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT,
   // ...
};

vkCreateImage(device, &imageCreateInfo, nullptr, &fdmImage);

VkImageViewCreateInfo viewCreateInfo =
{
   ​VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
   nullptr,
   0,                          // VkImageViewCreateFlags
   fdmImage,
   VK_IMAGE_VIEW_TYPE_2D_ARRAY,
   VK_FORMAT_R8G8_UNORM,
   {0},                        // VK_COMPONENT_SWIZZLE_IDENTITY
   {VK_IMAGE_ASPECT_COLOR_BIT,
    0,                         // baseMipLevel
    1,                         // levelCount; must be 1
    0,                         // baseArrayLayer
    2,                         // layerCount
   }
};

vkCreateImageView(device, &viewCreateInfo, nullptr, &fdmImageView);

// Add fdmImage to render pass

VkAttachmentReference fragmentDensityMapAttachmentReference =
{
   ​fdmAttachmentIdx,
   VK_IMAGE_LAYOUT_FRAGMENT_DENSITY_MAP_OPTIMAL_EXT,
};

VkRenderPassFragmentDensityMapCreateInfoEXT fdmAttachmentCreateInfo =
{
   ​VK_STRUCTURE_TYPE_RENDER_PASS_FRAGMENT_DENSITY_MAP_CREATE_INFO_EXT,
   // ...
   fragmentDensityMapAttachmentReference,
};

VkRenderPassCreateInfo2 renderPassCreateInfo =
{
   ​VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO_2,
   &fdmAttachmentCreateInfo,
   // ...
};

vkCreateRenderPass2(device, &renderPassCreateInfo, nullptr, &renderPass);

// Add fdmImage to framebuffer
// Color attachments can be created with VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT
// All attachments must be created with VK_IMAGE_CREATE_FRAGMENT_DENSITY_MAP_OFFSETS_BIT_EXT
VkFramebufferCreateInfo framebufferCreateInfo =
{
   ​VK_STRUCTURE_TYPE_FRAME_BUFFER_CREATE_INFO,
   // ...
   renderPass,
   // ...
   pAttachments, // Includes fdmImageView at fdmAttachmentIdx
   1024,         // width
   1024,         // height
   1             // layers; must be 1 if using multiview
};

vkCreateFramebuffer(device, &framebufferCreateInfo, nullptr, &framebuffer);

// Start recording render pass in command buffer

VkRenderPassBeginInfo renderPassBeginInfo =
{
   ​VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,
   // ...
   renderPass,
   framebuffer,
   // ...
};

// Can no longer modify the fdmImage's contents after this call
vkCmdBeginRenderPass2(commandBuffer, &renderPassBeginInfo, pSubpassBeginInfo);

See Also

Document Notes

For more information, see the Vulkan Specification

This page is a generated document. Fixes and changes should be made to the generator scripts, not directly.

Copyright 2014-2021 The Khronos Group Inc.

SPDX-License-Identifier: CC-BY-4.0