Top Description Fields Constructors Methods
org.lwjgl.vulkan

public Class KHRFragmentShadingRate

extends Object
Class Inheritance
Imports
javax.annotation.*, java.nio.*, org.lwjgl.system.*

This extension adds the ability to change the rate at which fragments are shaded. Rather than the usual single fragment invocation for each pixel covered by a primitive, multiple pixels can be shaded by a single fragment shader invocation.

Up to three methods are available to the application to change the fragment shading rate:

Additionally, these rates can all be specified and combined in order to adjust the overall detail in the image at each point.

This functionality can be used to focus shading efforts where higher levels of detail are needed in some parts of a scene compared to others. This can be particularly useful in high resolution rendering, or for XR contexts.

This extension also adds support for the SPV_KHR_fragment_shading_rate extension which enables setting the primitive fragment shading rate, and allows querying the final shading rate from a fragment shader.

VK_KHR_fragment_shading_rate
Name String
VK_KHR_fragment_shading_rate
Extension Type
Device extension
Registered Extension Number
227
Revision
2
Extension and Version Dependencies
VK_KHR_create_renderpass2      or      Version 1.2 and      VK_KHR_get_physical_device_properties2      or      Version 1.1
Contact
Extension Proposal
VK_KHR_fragment_shading_rate
Other Extension Metadata
Last Modified Date
2021-09-30
Interactions and External Dependencies
Contributors
  • Tobias Hector, AMD
  • Guennadi Riguer, AMD
  • Matthaeus Chajdas, AMD
  • Pat Brown, Nvidia
  • Matthew Netsch, Qualcomm
  • Slawomir Grajewski, Intel
  • Jan-Harald Fredriksen, Arm
  • Jeff Bolz, Nvidia
  • Arseny Kapoulkine, Roblox
  • Contributors to the VK_NV_shading_rate_image specification
  • Contributors to the VK_EXT_fragment_density_map specification

Field Summary

Modifier and TypeField and Description
public static final int
public static final int
public static final long
public static final int
public static final int
VK_FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_KHR

VkFragmentShadingRateCombinerOpKHR - Control how fragment shading rates are combined Description

public static final int
VK_FRAGMENT_SHADING_RATE_COMBINER_OP_MAX_KHR

VkFragmentShadingRateCombinerOpKHR - Control how fragment shading rates are combined Description

public static final int
VK_FRAGMENT_SHADING_RATE_COMBINER_OP_MIN_KHR

VkFragmentShadingRateCombinerOpKHR - Control how fragment shading rates are combined Description

public static final int
VK_FRAGMENT_SHADING_RATE_COMBINER_OP_MUL_KHR

VkFragmentShadingRateCombinerOpKHR - Control how fragment shading rates are combined Description

public static final int
VK_FRAGMENT_SHADING_RATE_COMBINER_OP_REPLACE_KHR

VkFragmentShadingRateCombinerOpKHR - Control how fragment shading rates are combined Description

public static final int
public static final int
public static final String
public static final int
VK_KHR_FRAGMENT_SHADING_RATE_SPEC_VERSION

The extension specification version.

public static final int
public static final int
public static final int
public static final int
public static final int
public static final int

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public static void
nvkCmdSetFragmentShadingRateKHR(VkCommandBuffer commandBuffer, long pFragmentSize, long combinerOps)

Unsafe version of: CmdSetFragmentShadingRateKHR

public static int
nvkGetPhysicalDeviceFragmentShadingRatesKHR(VkPhysicalDevice physicalDevice, long
a pointer to an integer related to the number of fragment shading rates available or queried, as described below.
pFragmentShadingRateCount
,
long pFragmentShadingRates)

Unsafe version of: GetPhysicalDeviceFragmentShadingRatesKHR

public static void
vkCmdSetFragmentShadingRateKHR(VkCommandBuffer
the command buffer into which the command will be recorded.
commandBuffer
,
VkExtent2D
specifies the pipeline fragment shading rate for subsequent drawing commands.
pFragmentSize
,
IntBuffer
specifies a VkFragmentShadingRateCombinerOpKHR determining how the pipeline, primitive, and attachment shading rates are combined for fragments generated by subsequent drawing commands.
combinerOps
)

Set pipeline fragment shading rate and combiner operation dynamically for a command buffer.

public static void
vkCmdSetFragmentShadingRateKHR(VkCommandBuffer commandBuffer, VkExtent2D pFragmentSize, int[] combinerOps)

Array version of: CmdSetFragmentShadingRateKHR

public static int
vkGetPhysicalDeviceFragmentShadingRatesKHR(VkPhysicalDevice
the handle to the physical device whose properties will be queried.
physicalDevice
,
IntBuffer
a pointer to an integer related to the number of fragment shading rates available or queried, as described below.
pFragmentShadingRateCount
,
VkPhysicalDeviceFragmentShadingRateKHR.Buffer
either NULL or a pointer to an array of VkPhysicalDeviceFragmentShadingRateKHR structures.
pFragmentShadingRates
)

Get available shading rates for a physical device.

public static int
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

VK_ACCESS_FRAGMENT_SHADING_RATE_ATTACHMENT_READ_BIT_KHRback to summary
public static final int VK_ACCESS_FRAGMENT_SHADING_RATE_ATTACHMENT_READ_BIT_KHR

Extends VkAccessFlagBits.

VK_DYNAMIC_STATE_FRAGMENT_SHADING_RATE_KHRback to summary
public static final int VK_DYNAMIC_STATE_FRAGMENT_SHADING_RATE_KHR

Extends VkDynamicState.

VK_FORMAT_FEATURE_2_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHRback to summary
public static final long VK_FORMAT_FEATURE_2_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR

Extends VkFormatFeatureFlagBits2.

VK_FORMAT_FEATURE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHRback to summary
public static final int VK_FORMAT_FEATURE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR

Extends VkFormatFeatureFlagBits.

VK_FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_KHRback to summary
public static final int VK_FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_KHR

VkFragmentShadingRateCombinerOpKHR - Control how fragment shading rates are combined

Description

where combine(Axy,Bxy) is the combine operation, and Axy and Bxy are the inputs to the operation.

If fragmentShadingRateStrictMultiplyCombiner is FALSE, using FRAGMENT_SHADING_RATE_COMBINER_OP_MUL_KHR with values of 1 for both A and B in the same dimension results in the value 2 being produced for that dimension. See the definition of fragmentShadingRateStrictMultiplyCombiner for more information.

These operations are performed in a component-wise fashion.

See Also

VkPipelineFragmentShadingRateEnumStateCreateInfoNV, VkPipelineFragmentShadingRateStateCreateInfoKHR, CmdSetFragmentShadingRateEnumNV, CmdSetFragmentShadingRateKHR

VK_FRAGMENT_SHADING_RATE_COMBINER_OP_MAX_KHRback to summary
public static final int VK_FRAGMENT_SHADING_RATE_COMBINER_OP_MAX_KHR

VkFragmentShadingRateCombinerOpKHR - Control how fragment shading rates are combined

Description

where combine(Axy,Bxy) is the combine operation, and Axy and Bxy are the inputs to the operation.

If fragmentShadingRateStrictMultiplyCombiner is FALSE, using FRAGMENT_SHADING_RATE_COMBINER_OP_MUL_KHR with values of 1 for both A and B in the same dimension results in the value 2 being produced for that dimension. See the definition of fragmentShadingRateStrictMultiplyCombiner for more information.

These operations are performed in a component-wise fashion.

See Also

VkPipelineFragmentShadingRateEnumStateCreateInfoNV, VkPipelineFragmentShadingRateStateCreateInfoKHR, CmdSetFragmentShadingRateEnumNV, CmdSetFragmentShadingRateKHR

VK_FRAGMENT_SHADING_RATE_COMBINER_OP_MIN_KHRback to summary
public static final int VK_FRAGMENT_SHADING_RATE_COMBINER_OP_MIN_KHR

VkFragmentShadingRateCombinerOpKHR - Control how fragment shading rates are combined

Description

where combine(Axy,Bxy) is the combine operation, and Axy and Bxy are the inputs to the operation.

If fragmentShadingRateStrictMultiplyCombiner is FALSE, using FRAGMENT_SHADING_RATE_COMBINER_OP_MUL_KHR with values of 1 for both A and B in the same dimension results in the value 2 being produced for that dimension. See the definition of fragmentShadingRateStrictMultiplyCombiner for more information.

These operations are performed in a component-wise fashion.

See Also

VkPipelineFragmentShadingRateEnumStateCreateInfoNV, VkPipelineFragmentShadingRateStateCreateInfoKHR, CmdSetFragmentShadingRateEnumNV, CmdSetFragmentShadingRateKHR

VK_FRAGMENT_SHADING_RATE_COMBINER_OP_MUL_KHRback to summary
public static final int VK_FRAGMENT_SHADING_RATE_COMBINER_OP_MUL_KHR

VkFragmentShadingRateCombinerOpKHR - Control how fragment shading rates are combined

Description

where combine(Axy,Bxy) is the combine operation, and Axy and Bxy are the inputs to the operation.

If fragmentShadingRateStrictMultiplyCombiner is FALSE, using FRAGMENT_SHADING_RATE_COMBINER_OP_MUL_KHR with values of 1 for both A and B in the same dimension results in the value 2 being produced for that dimension. See the definition of fragmentShadingRateStrictMultiplyCombiner for more information.

These operations are performed in a component-wise fashion.

See Also

VkPipelineFragmentShadingRateEnumStateCreateInfoNV, VkPipelineFragmentShadingRateStateCreateInfoKHR, CmdSetFragmentShadingRateEnumNV, CmdSetFragmentShadingRateKHR

VK_FRAGMENT_SHADING_RATE_COMBINER_OP_REPLACE_KHRback to summary
public static final int VK_FRAGMENT_SHADING_RATE_COMBINER_OP_REPLACE_KHR

VkFragmentShadingRateCombinerOpKHR - Control how fragment shading rates are combined

Description

where combine(Axy,Bxy) is the combine operation, and Axy and Bxy are the inputs to the operation.

If fragmentShadingRateStrictMultiplyCombiner is FALSE, using FRAGMENT_SHADING_RATE_COMBINER_OP_MUL_KHR with values of 1 for both A and B in the same dimension results in the value 2 being produced for that dimension. See the definition of fragmentShadingRateStrictMultiplyCombiner for more information.

These operations are performed in a component-wise fashion.

See Also

VkPipelineFragmentShadingRateEnumStateCreateInfoNV, VkPipelineFragmentShadingRateStateCreateInfoKHR, CmdSetFragmentShadingRateEnumNV, CmdSetFragmentShadingRateKHR

VK_IMAGE_LAYOUT_FRAGMENT_SHADING_RATE_ATTACHMENT_OPTIMAL_KHRback to summary
public static final int VK_IMAGE_LAYOUT_FRAGMENT_SHADING_RATE_ATTACHMENT_OPTIMAL_KHR

Extends VkImageLayout.

VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHRback to summary
public static final int VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR

Extends VkImageUsageFlagBits.

VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAMEback to summary
public static final String VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME

The extension name.

VK_KHR_FRAGMENT_SHADING_RATE_SPEC_VERSIONback to summary
public static final int VK_KHR_FRAGMENT_SHADING_RATE_SPEC_VERSION

The extension specification version.

VK_PIPELINE_STAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHRback to summary
public static final int VK_PIPELINE_STAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR

Extends VkPipelineStageFlagBits.

VK_STRUCTURE_TYPE_FRAGMENT_SHADING_RATE_ATTACHMENT_INFO_KHRback to summary
public static final int VK_STRUCTURE_TYPE_FRAGMENT_SHADING_RATE_ATTACHMENT_INFO_KHR

Extends VkStructureType.

Enum values:
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADING_RATE_FEATURES_KHRback to summary
public static final int VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADING_RATE_FEATURES_KHR

Extends VkStructureType.

Enum values:
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADING_RATE_KHRback to summary
public static final int VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADING_RATE_KHR

Extends VkStructureType.

Enum values:
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADING_RATE_PROPERTIES_KHRback to summary
public static final int VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADING_RATE_PROPERTIES_KHR

Extends VkStructureType.

Enum values:
VK_STRUCTURE_TYPE_PIPELINE_FRAGMENT_SHADING_RATE_STATE_CREATE_INFO_KHRback to summary
public static final int VK_STRUCTURE_TYPE_PIPELINE_FRAGMENT_SHADING_RATE_STATE_CREATE_INFO_KHR

Extends VkStructureType.

Enum values:

Constructor Detail

KHRFragmentShadingRateback to summary
protected KHRFragmentShadingRate()

Method Detail

nvkCmdSetFragmentShadingRateKHRback to summary
public static void nvkCmdSetFragmentShadingRateKHR(VkCommandBuffer commandBuffer, long pFragmentSize, long combinerOps)

Unsafe version of: CmdSetFragmentShadingRateKHR

nvkGetPhysicalDeviceFragmentShadingRatesKHRback to summary
public static int nvkGetPhysicalDeviceFragmentShadingRatesKHR(VkPhysicalDevice physicalDevice, long pFragmentShadingRateCount, long pFragmentShadingRates)

Unsafe version of: GetPhysicalDeviceFragmentShadingRatesKHR

Parameters
pFragmentShadingRateCount:long

a pointer to an integer related to the number of fragment shading rates available or queried, as described below.

vkCmdSetFragmentShadingRateKHRback to summary
public static void vkCmdSetFragmentShadingRateKHR(VkCommandBuffer commandBuffer, VkExtent2D pFragmentSize, IntBuffer combinerOps)

Set pipeline fragment shading rate and combiner operation dynamically for a command buffer.

C Specification

To dynamically set the pipeline fragment shading rate and combiner operation, call:


void vkCmdSetFragmentShadingRateKHR(
    VkCommandBuffer                             commandBuffer,
    const VkExtent2D*                           pFragmentSize,
    const VkFragmentShadingRateCombinerOpKHR    combinerOps[2]);
Description

This command sets the pipeline fragment shading rate and combiner operation for subsequent drawing commands when drawing using shader objects, or when the graphics pipeline is created with DYNAMIC_STATE_FRAGMENT_SHADING_RATE_KHR set in VkPipelineDynamicStateCreateInfo::pDynamicStates. Otherwise, this state is specified by the VkPipelineFragmentShadingRateStateCreateInfoKHR values used to create the currently active pipeline.

Valid Usage
Valid Usage (Implicit)
  • commandBuffer must be a valid VkCommandBuffer handle
  • pFragmentSize must be a valid pointer to a valid VkExtent2D structure
  • Each element of combinerOps must be a valid VkFragmentShadingRateCombinerOpKHR value
  • commandBuffer must be in the recording state
  • The VkCommandPool that commandBuffer was allocated from must support graphics operations
  • This command must only be called outside of a video coding scope
Host Synchronization
  • Host access to commandBuffer must be externally synchronized
  • Host access to the VkCommandPool that commandBuffer was allocated from must be externally synchronized
Command Properties
Command Buffer LevelsRender Pass ScopeVideo Coding ScopeSupported Queue TypesCommand Type
Primary SecondaryBothOutsideGraphicsState
See Also

VkExtent2D

Parameters
commandBuffer:VkCommandBuffer

the command buffer into which the command will be recorded.

pFragmentSize:VkExtent2D

specifies the pipeline fragment shading rate for subsequent drawing commands.

combinerOps:IntBuffer

specifies a VkFragmentShadingRateCombinerOpKHR determining how the pipeline, primitive, and attachment shading rates are combined for fragments generated by subsequent drawing commands.

vkCmdSetFragmentShadingRateKHRback to summary
public static void vkCmdSetFragmentShadingRateKHR(VkCommandBuffer commandBuffer, VkExtent2D pFragmentSize, int[] combinerOps)

Array version of: CmdSetFragmentShadingRateKHR

vkGetPhysicalDeviceFragmentShadingRatesKHRback to summary
public static int vkGetPhysicalDeviceFragmentShadingRatesKHR(VkPhysicalDevice physicalDevice, IntBuffer pFragmentShadingRateCount, VkPhysicalDeviceFragmentShadingRateKHR.Buffer pFragmentShadingRates)

Get available shading rates for a physical device.

C Specification

To query available shading rates, call:


VkResult vkGetPhysicalDeviceFragmentShadingRatesKHR(
    VkPhysicalDevice                            physicalDevice,
    uint32_t*                                   pFragmentShadingRateCount,
    VkPhysicalDeviceFragmentShadingRateKHR*     pFragmentShadingRates);
Description

If pFragmentShadingRates is NULL, then the number of fragment shading rates available is returned in pFragmentShadingRateCount. Otherwise, pFragmentShadingRateCount must point to a variable set by the user to the number of elements in the pFragmentShadingRates array, and on return the variable is overwritten with the number of structures actually written to pFragmentShadingRates. If pFragmentShadingRateCount is less than the number of fragment shading rates available, at most pFragmentShadingRateCount structures will be written, and INCOMPLETE will be returned instead of SUCCESS, to indicate that not all the available fragment shading rates were returned.

The returned array of fragment shading rates must be ordered from largest fragmentSize.width value to smallest, and each set of fragment shading rates with the same fragmentSize.width value must be ordered from largest fragmentSize.height to smallest. Any two entries in the array must not have the same fragmentSize values.

For any entry in the array, the following rules also apply:

  • The value of fragmentSize.width must be less than or equal to maxFragmentSize.width.
  • The value of fragmentSize.width must be greater than or equal to 1.
  • The value of fragmentSize.width must be a power-of-two.
  • The value of fragmentSize.height must be less than or equal to maxFragmentSize.height.
  • The value of fragmentSize.height must be greater than or equal to 1.
  • The value of fragmentSize.height must be a power-of-two.
  • The highest sample count in sampleCounts must be less than or equal to maxFragmentShadingRateRasterizationSamples.
  • The product of fragmentSize.width, fragmentSize.height, and the highest sample count in sampleCounts must be less than or equal to maxFragmentShadingRateCoverageSamples.

Implementations must support at least the following shading rates:

sampleCountsfragmentSize
SAMPLE_COUNT_1_BIT | SAMPLE_COUNT_4_BIT{2,2}
SAMPLE_COUNT_1_BIT | SAMPLE_COUNT_4_BIT{2,1}
~0{1,1}

If framebufferColorSampleCounts, includes SAMPLE_COUNT_2_BIT, the required rates must also include SAMPLE_COUNT_2_BIT.

Note

Including the {1,1} fragment size is done for completeness; it has no actual effect on the support of rendering without setting the fragment size. All sample counts and render pass transforms are supported for this rate.

The returned set of fragment shading rates must be returned in the native (rotated) coordinate system. For rasterization using render pass transform not equal to SURFACE_TRANSFORM_IDENTITY_BIT_KHR, the application must transform the returned fragment shading rates into the current (unrotated) coordinate system to get the supported rates for that transform.

Note

For example, consider an implementation returning support for 4x2, but not 2x4 in the set of supported fragment shading rates. This means that for transforms SURFACE_TRANSFORM_ROTATE_90_BIT_KHR and SURFACE_TRANSFORM_ROTATE_270_BIT_KHR, 2x4 is a supported rate, but 4x2 is an unsupported rate.

Valid Usage (Implicit)
  • physicalDevice must be a valid VkPhysicalDevice handle
  • pFragmentShadingRateCount must be a valid pointer to a uint32_t value
  • If the value referenced by pFragmentShadingRateCount is not 0, and pFragmentShadingRates is not NULL, pFragmentShadingRates must be a valid pointer to an array of pFragmentShadingRateCount VkPhysicalDeviceFragmentShadingRateKHR structures
Return Codes
On success, this command returns
On failure, this command returns
See Also

VkPhysicalDeviceFragmentShadingRateKHR

Parameters
physicalDevice:VkPhysicalDevice

the handle to the physical device whose properties will be queried.

pFragmentShadingRateCount:IntBuffer

a pointer to an integer related to the number of fragment shading rates available or queried, as described below.

pFragmentShadingRates:VkPhysicalDeviceFragmentShadingRateKHR.Buffer

either NULL or a pointer to an array of VkPhysicalDeviceFragmentShadingRateKHR structures.

Annotations
@NativeType:VkResult
vkGetPhysicalDeviceFragmentShadingRatesKHRback to summary
public static int vkGetPhysicalDeviceFragmentShadingRatesKHR(VkPhysicalDevice physicalDevice, int[] pFragmentShadingRateCount, VkPhysicalDeviceFragmentShadingRateKHR.Buffer pFragmentShadingRates)

Array version of: GetPhysicalDeviceFragmentShadingRatesKHR

Annotations
@NativeType:VkResult