Class NVShadingRateImage
- java.lang.Object
-
- org.lwjgl.vulkan.NVShadingRateImage
-
public class NVShadingRateImage extends java.lang.Object
This extension allows applications to use a variable shading rate when processing fragments of rasterized primitives. By default, Vulkan will spawn one fragment shader for each pixel covered by a primitive. In this extension, applications can bind a shading rate image that can be used to vary the number of fragment shader invocations across the framebuffer. Some portions of the screen may be configured to spawn up to 16 fragment shaders for each pixel, while other portions may use a single fragment shader invocation for a 4x4 block of pixels. This can be useful for use cases like eye tracking, where the portion of the framebuffer that the user is looking at directly can be processed at high frequency, while distant corners of the image can be processed at lower frequency. Each texel in the shading rate image represents a fixed-size rectangle in the framebuffer, covering 16x16 pixels in the initial implementation of this extension. When rasterizing a primitive covering one of these rectangles, the Vulkan implementation reads a texel in the bound shading rate image and looks up the fetched value in a palette to determine a base shading rate.In addition to the API support controlling rasterization, this extension also adds Vulkan support for the
SPV_NV_shading_rate
extension to SPIR-V. That extension provides two fragment shader variable decorations that allow fragment shaders to determine the shading rate used for processing the fragment:FragmentSizeNV
, which indicates the width and height of the set of pixels processed by the fragment shader.InvocationsPerPixel
, which indicates the maximum number of fragment shader invocations that could be spawned for the pixel(s) covered by the fragment.
When using SPIR-V in conjunction with the OpenGL Shading Language (GLSL), the fragment shader capabilities are provided by the
GL_NV_shading_rate_image
language extension and correspond to the built-in variablesgl_FragmentSizeNV
andgl_InvocationsPerPixelNV
, respectively.- Name String
VK_NV_shading_rate_image
- Extension Type
- Device extension
- Registered Extension Number
- 165
- Revision
- 3
- Extension and Version Dependencies
- Requires Vulkan 1.0
- Requires
VK_KHR_get_physical_device_properties2
- Contact
- Pat Brown nvpbrown
- Last Modified Date
- 2019-07-18
- Contributors
- Pat Brown, NVIDIA
- Carsten Rohde, NVIDIA
- Jeff Bolz, NVIDIA
- Daniel Koch, NVIDIA
- Mathias Schott, NVIDIA
- Matthew Netsch, Qualcomm Technologies, Inc.
-
-
Field Summary
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
nvkCmdSetCoarseSampleOrderNV(VkCommandBuffer commandBuffer, int sampleOrderType, int customSampleOrderCount, long pCustomSampleOrders)
Unsafe version of:CmdSetCoarseSampleOrderNV
static void
nvkCmdSetViewportShadingRatePaletteNV(VkCommandBuffer commandBuffer, int firstViewport, int viewportCount, long pShadingRatePalettes)
Unsafe version of:CmdSetViewportShadingRatePaletteNV
static void
vkCmdBindShadingRateImageNV(VkCommandBuffer commandBuffer, long imageView, int imageLayout)
Bind a shading rate image on a command buffer.static void
vkCmdSetCoarseSampleOrderNV(VkCommandBuffer commandBuffer, int sampleOrderType, VkCoarseSampleOrderCustomNV.Buffer pCustomSampleOrders)
Set sample order for coarse fragments on a command buffer.static void
vkCmdSetViewportShadingRatePaletteNV(VkCommandBuffer commandBuffer, int firstViewport, VkShadingRatePaletteNV.Buffer pShadingRatePalettes)
Set shading rate image palettes on a command buffer.
-
-
-
Field Detail
-
VK_NV_SHADING_RATE_IMAGE_SPEC_VERSION
The extension specification version.
-
VK_NV_SHADING_RATE_IMAGE_EXTENSION_NAME
The extension name.
-
VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADING_RATE_IMAGE_FEATURES_NV, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADING_RATE_IMAGE_PROPERTIES_NV, VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV
ExtendsVkStructureType
.Enum values:
-
VK_IMAGE_LAYOUT_SHADING_RATE_OPTIMAL_NV
ExtendsVkImageLayout
.
-
VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV, VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV
ExtendsVkDynamicState
.Enum values:
-
VK_ACCESS_SHADING_RATE_IMAGE_READ_BIT_NV
ExtendsVkAccessFlagBits
.
-
VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV
ExtendsVkImageUsageFlagBits
.
-
VK_PIPELINE_STAGE_SHADING_RATE_IMAGE_BIT_NV
ExtendsVkPipelineStageFlagBits
.
-
VK_SHADING_RATE_PALETTE_ENTRY_NO_INVOCATIONS_NV, VK_SHADING_RATE_PALETTE_ENTRY_16_INVOCATIONS_PER_PIXEL_NV, VK_SHADING_RATE_PALETTE_ENTRY_8_INVOCATIONS_PER_PIXEL_NV, VK_SHADING_RATE_PALETTE_ENTRY_4_INVOCATIONS_PER_PIXEL_NV, VK_SHADING_RATE_PALETTE_ENTRY_2_INVOCATIONS_PER_PIXEL_NV, VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_PIXEL_NV, VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV
VkShadingRatePaletteEntryNV - Shading rate image palette entry typesDescription
The following table indicates the width and height (in pixels) of each fragment generated using the indicated shading rate, as well as the maximum number of fragment shader invocations launched for each fragment. When processing regions of a primitive that have a shading rate of
SHADING_RATE_PALETTE_ENTRY_NO_INVOCATIONS_NV
, no fragments will be generated in that region.See Also
-
VK_COARSE_SAMPLE_ORDER_TYPE_DEFAULT_NV, VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, VK_COARSE_SAMPLE_ORDER_TYPE_PIXEL_MAJOR_NV, VK_COARSE_SAMPLE_ORDER_TYPE_SAMPLE_MAJOR_NV
VkCoarseSampleOrderTypeNV - Shading rate image sample ordering typesDescription
COARSE_SAMPLE_ORDER_TYPE_DEFAULT_NV
specifies that coverage samples will be ordered in an implementation-dependent manner.COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV
specifies that coverage samples will be ordered according to the array of custom orderings provided in either thepCustomSampleOrders
member ofVkPipelineViewportCoarseSampleOrderStateCreateInfoNV
or thepCustomSampleOrders
member ofCmdSetCoarseSampleOrderNV
.COARSE_SAMPLE_ORDER_TYPE_PIXEL_MAJOR_NV
specifies that coverage samples will be ordered sequentially, sorted first by pixel coordinate (in row-major order) and then by coverage sample number.COARSE_SAMPLE_ORDER_TYPE_SAMPLE_MAJOR_NV
specifies that coverage samples will be ordered sequentially, sorted first by coverage sample number and then by pixel coordinate (in row-major order).
See Also
VkPipelineViewportCoarseSampleOrderStateCreateInfoNV
,CmdSetCoarseSampleOrderNV
-
-
Method Detail
-
vkCmdBindShadingRateImageNV
public static void vkCmdBindShadingRateImageNV(VkCommandBuffer commandBuffer, long imageView, int imageLayout)
Bind a shading rate image on a command buffer.C Specification
When shading rate image usage is enabled in the bound pipeline, the pipeline uses a shading rate image specified by the command:
void vkCmdBindShadingRateImageNV( VkCommandBuffer commandBuffer, VkImageView imageView, VkImageLayout imageLayout);
Valid Usage
- The shading rate image feature must be enabled.
- If
imageView
is notNULL_HANDLE
, it must be a validVkImageView
handle of typeIMAGE_VIEW_TYPE_2D
orIMAGE_VIEW_TYPE_2D_ARRAY
. - If
imageView
is notNULL_HANDLE
, it must have a format ofFORMAT_R8_UINT
. - If
imageView
is notNULL_HANDLE
, it must have been created with ausage
value includingIMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV
- If
imageView
is notNULL_HANDLE
,imageLayout
must match the actualVkImageLayout
of each subresource accessible fromimageView
at the time the subresource is accessed. - If
imageView
is notNULL_HANDLE
,imageLayout
must beIMAGE_LAYOUT_SHADING_RATE_OPTIMAL_NV
orIMAGE_LAYOUT_GENERAL
.
Valid Usage (Implicit)
commandBuffer
must be a validVkCommandBuffer
handle- If
imageView
is notNULL_HANDLE
,imageView
must be a validVkImageView
handle imageLayout
must be a validVkImageLayout
valuecommandBuffer
must be in the recording state- The
VkCommandPool
thatcommandBuffer
was allocated from must support graphics operations - Both of
commandBuffer
, andimageView
that are valid handles must have been created, allocated, or retrieved from the sameVkDevice
Host Synchronization
- Host access to
commandBuffer
must be externally synchronized - Host access to the
VkCommandPool
thatcommandBuffer
was allocated from must be externally synchronized
Command Properties
Command Buffer Levels Render Pass Scope Supported Queue Types Pipeline Type Primary Secondary Both Graphics - Parameters:
commandBuffer
- the command buffer into which the command will be recorded.imageView
- an image view handle that specifies the shading rate image.imageView
may be set toNULL_HANDLE
, which is equivalent to specifying a view of an image filled with zero values.imageLayout
- the layout that the image subresources accessible fromimageView
will be in when the shading rate image is accessed.
-
nvkCmdSetViewportShadingRatePaletteNV
public static void nvkCmdSetViewportShadingRatePaletteNV(VkCommandBuffer commandBuffer, int firstViewport, int viewportCount, long pShadingRatePalettes)
Unsafe version of:CmdSetViewportShadingRatePaletteNV
- Parameters:
viewportCount
- the number of viewports whose shading rate palettes are updated by the command.
-
vkCmdSetViewportShadingRatePaletteNV
public static void vkCmdSetViewportShadingRatePaletteNV(VkCommandBuffer commandBuffer, int firstViewport, VkShadingRatePaletteNV.Buffer pShadingRatePalettes)
Set shading rate image palettes on a command buffer.C Specification
If a pipeline state object is created with
DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV
enabled, the per-viewport shading rate image palettes are set by the command:void vkCmdSetViewportShadingRatePaletteNV( VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount, const VkShadingRatePaletteNV* pShadingRatePalettes);
Valid Usage
- The shading rate image feature must be enabled.
- The bound graphics pipeline must have been created with the
DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV
dynamic state enabled firstViewport
must be less thanVkPhysicalDeviceLimits
::maxViewports
- The sum of
firstViewport
andviewportCount
must be between 1 andVkPhysicalDeviceLimits
::maxViewports
, inclusive - If the multiple viewports feature is not enabled,
firstViewport
must be 0 - If the multiple viewports feature is not enabled,
viewportCount
must be 1
Valid Usage (Implicit)
commandBuffer
must be a validVkCommandBuffer
handlepShadingRatePalettes
must be a valid pointer to an array ofviewportCount
validVkShadingRatePaletteNV
structurescommandBuffer
must be in the recording state- The
VkCommandPool
thatcommandBuffer
was allocated from must support graphics operations viewportCount
must be greater than 0
Host Synchronization
- Host access to
commandBuffer
must be externally synchronized - Host access to the
VkCommandPool
thatcommandBuffer
was allocated from must be externally synchronized
Command Properties
Command Buffer Levels Render Pass Scope Supported Queue Types Pipeline Type Primary Secondary Both Graphics See Also
- Parameters:
commandBuffer
- the command buffer into which the command will be recorded.firstViewport
- the index of the first viewport whose shading rate palette is updated by the command.pShadingRatePalettes
- a pointer to an array ofVkShadingRatePaletteNV
structures defining the palette for each viewport.
-
nvkCmdSetCoarseSampleOrderNV
public static void nvkCmdSetCoarseSampleOrderNV(VkCommandBuffer commandBuffer, int sampleOrderType, int customSampleOrderCount, long pCustomSampleOrders)
Unsafe version of:CmdSetCoarseSampleOrderNV
- Parameters:
customSampleOrderCount
- specifies the number of custom sample orderings to use when ordering coverage samples.
-
vkCmdSetCoarseSampleOrderNV
public static void vkCmdSetCoarseSampleOrderNV(VkCommandBuffer commandBuffer, int sampleOrderType, @Nullable VkCoarseSampleOrderCustomNV.Buffer pCustomSampleOrders)
Set sample order for coarse fragments on a command buffer.C Specification
If a pipeline state object is created with
DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV
enabled, the order of coverage samples in fragments larger than one pixel is set by the command:void vkCmdSetCoarseSampleOrderNV( VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount, const VkCoarseSampleOrderCustomNV* pCustomSampleOrders);
Description
If
sampleOrderType
isCOARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV
, the coverage sample order used for any combination of fragment area and coverage sample count not enumerated inpCustomSampleOrders
will be identical to that used forCOARSE_SAMPLE_ORDER_TYPE_DEFAULT_NV
.Valid Usage
- If
sampleOrderType
is notCOARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV
,customSamplerOrderCount
must be 0 - The array
pCustomSampleOrders
must not contain two structures with matching values for both theshadingRate
andsampleCount
members.
Valid Usage (Implicit)
commandBuffer
must be a validVkCommandBuffer
handlesampleOrderType
must be a validVkCoarseSampleOrderTypeNV
value- If
customSampleOrderCount
is not 0,pCustomSampleOrders
must be a valid pointer to an array ofcustomSampleOrderCount
validVkCoarseSampleOrderCustomNV
structures commandBuffer
must be in the recording state- The
VkCommandPool
thatcommandBuffer
was allocated from must support graphics operations
Host Synchronization
- Host access to
commandBuffer
must be externally synchronized - Host access to the
VkCommandPool
thatcommandBuffer
was allocated from must be externally synchronized
Command Properties
Command Buffer Levels Render Pass Scope Supported Queue Types Pipeline Type Primary Secondary Both Graphics See Also
- Parameters:
commandBuffer
- the command buffer into which the command will be recorded.sampleOrderType
- specifies the mechanism used to order coverage samples in fragments larger than one pixel.pCustomSampleOrders
- a pointer to an array ofVkCoarseSampleOrderCustomNV
structures, each of which specifies the coverage sample order for a single combination of fragment area and coverage sample count.
- If
-
-