# Vulkan® 1.4.321 - A Specification (with all registered extensions)

The Khronos® Vulkan Working Group
version 1.4.321, 2025-07-17 19:31:47Z
from git branch: makepkg commit: dad857284bf63d027ac9d6a97e9a1689831bab0d

Loading… please wait.

Search:

## 17. Fragment Density Map Operations

### 17.1. Fragment Density Map Operations Overview

When a fragment is generated in a render pass that has a fragment density map attachment, its area is determined by the properties of the local framebuffer region that the fragment occupies. The framebuffer is divided into a uniform grid of these local regions, and their fragment area property is derived from the density map with the following operations:

- Fetch density value

  - Component swizzle

  - Component mapping

- Fragment area conversion

  - Fragment area filter

  - Fragment area clamp

### 17.2. Fetch Density Value

Each local framebuffer region at center coordinate (x,y) fetches a texel from the fragment density map.

First, the local framebuffer region center coordinate (x,y) is offset by the value specified in VkRenderPassFragmentDensityMapOffsetEndInfoEXT. If no offset is specified, then the default offset (0,0) is used. The offsetted coordinate (x',y') is computed as follows:

x′y′​=x−pF r a g m e n t De n s i t y O ff se t s[l a yer]x​=y−pF r a g m e n t De n s i t y O ff se t s[l a yer]y​​

Note | The offset is relative to the fragment density map, so it is subtracted from the framebuffer coordinates to make the adjustment relative to the framebuffer. In other words, applying a positive offset in the x component will shift the fragment density map to the right relative to the framebuffer. This means the framebuffer coordinates need to undergo a shift to the left.

The offsetted coordinate (x',y') fetches a texel from the fragment density map at integer coordinates:

  i=c l am p(⌊f r a g m e n t De n s i t y T e x e lS i z e w i d t h​x′​⌋,0,f r a g m e n t De n s i t y M a p w i d t h​−1)

  j=c l am p(⌊f r a g m e n t De n s i t y T e x e lS i z e h e i g h t​y′​⌋,0,f r a g m e n t De n s i t y M a p h e i g h t​−1)

Where the size of each region in the framebuffer is:

  f r a g m e n t De n s i t y T e x e lS i z e w i d t h′​=2⌈l o g 2​(f r a g m e n t De n s i t y M a p w i d t h​f r am e b u ff e r w i d t h​​)⌉

  f r a g m e n t De n s i t y T e x e lS i z e h e i g h t′​=2⌈l o g 2​(f r a g m e n t De n s i t y M a p h e i g h t​f r am e b u ff e r h e i g h t​​)⌉

This region is subject to the limits in `VkPhysicalDeviceFragmentDensityMapPropertiesEXT` and therefore the final region size is clamped:

  f r a g m e n t De n s i t y T e x e lS i z e w i d t h​=c l am p(f r a g m e n t De n s i t y T e x e lS i z e w i d t h′​,min F r a g m e n t De n s i t y T e x e lS i z e w i d t h​,ma x F r a g m e n t De n s i t y T e x e lS i z e w i d t h​)

  f r a g m e n t De n s i t y T e x e lS i z e h e i g h t​=c l am p(f r a g m e n t De n s i t y T e x e lS i z e h e i g h t′​,min F r a g m e n t De n s i t y T e x e lS i z e h e i g h t​,ma x F r a g m e n t De n s i t y T e x e lS i z e h e i g h t​)

When multiview is enabled for the render pass and the fragment density map attachment view was created with `layerCount` greater than `1`, the layer used for offsets and for fetching from the fragment density map is:

  l a yer=ba se A rr a y L a yer+Vi e w I n d e x

Otherwise, if the render pass was created with `VK_RENDER_PASS_CREATE_PER_LAYER_FRAGMENT_DENSITY_BIT_VALVE` specified, or the dynamic render pass was begun with `VK_RENDERING_PER_LAYER_FRAGMENT_DENSITY_BIT_VALVE` specified, then the layer used is:

  l a yer=ba se A rr a y L a yer+L a yer

Otherwise:

  l a yer=ba se A rr a y L a yer

The texel fetched from the density map at (i,j,layer) is next converted to density with the following operations.

#### 17.2.1. Component Swizzle

The `components` member of VkImageViewCreateInfo is applied to the fetched texel as defined in Image component swizzle.

#### 17.2.2. Component Mapping

The swizzled texel’s components are mapped to a density value:

  d e n s i t y Va l u e x y​=(C r′​,C g′​)

### 17.3. Fragment Area Conversion

Fragment area for the framebuffer region is undefined if the density fetched is not a normalized floating-point value greater than `0.0`. Otherwise, the fetched fragment area for that region is derived as:

  f r a g m e n t A re a w h​=d e n s i t y Va l u e x y​1.0​

#### 17.3.1. Fragment Area Filter

Optionally, the implementation may fetch additional density map texels in an implementation defined window around (i,j). The texels follow the standard conversion steps up to and including fragment area conversion.

A single fetched fragment area for the framebuffer region is chosen by the implementation and must have an area between the min and max areas of the fetched set.

#### 17.3.2. Fragment Area Clamp

The implementation may clamp the fetched fragment area to one that it supports. The clamped fragment area must have a size less than or equal to the original fetched value. Implementations may vary the supported set of fragment areas per framebuffer region. Fragment area (1,1) must always be in the supported set.

Note | For example, if the fetched fragment area is (1,4) but the implementation only supports areas of {(1,1),(2,2)}, it could choose to clamp the area to (2,2) since it has the same size as (1,4). While this would produce fragments that have lower quality strictly in the x-axis, the overall density is maintained.

The clamped fragment area is assigned to the corresponding framebuffer region.