Class NVShadingRateImage
- java.lang.Object
-
- org.lwjgl.vulkan.NVShadingRateImage
-
public class NVShadingRateImage extends java.lang.ObjectThis 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_rateextension 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_imagelanguage extension and correspond to the built-in variablesgl_FragmentSizeNVandgl_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 voidnvkCmdSetCoarseSampleOrderNV(VkCommandBuffer commandBuffer, int sampleOrderType, int customSampleOrderCount, long pCustomSampleOrders)Unsafe version of:CmdSetCoarseSampleOrderNVstatic voidnvkCmdSetViewportShadingRatePaletteNV(VkCommandBuffer commandBuffer, int firstViewport, int viewportCount, long pShadingRatePalettes)Unsafe version of:CmdSetViewportShadingRatePaletteNVstatic voidvkCmdBindShadingRateImageNV(VkCommandBuffer commandBuffer, long imageView, int imageLayout)Bind a shading rate image on a command buffer.static voidvkCmdSetCoarseSampleOrderNV(VkCommandBuffer commandBuffer, int sampleOrderType, VkCoarseSampleOrderCustomNV.Buffer pCustomSampleOrders)Set sample order for coarse fragments on a command buffer.static voidvkCmdSetViewportShadingRatePaletteNV(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_NVspecifies that coverage samples will be ordered in an implementation-dependent manner.COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NVspecifies that coverage samples will be ordered according to the array of custom orderings provided in either thepCustomSampleOrdersmember ofVkPipelineViewportCoarseSampleOrderStateCreateInfoNVor thepCustomSampleOrdersmember ofCmdSetCoarseSampleOrderNV.COARSE_SAMPLE_ORDER_TYPE_PIXEL_MAJOR_NVspecifies 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_NVspecifies 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
imageViewis notNULL_HANDLE, it must be a validVkImageViewhandle of typeIMAGE_VIEW_TYPE_2DorIMAGE_VIEW_TYPE_2D_ARRAY. - If
imageViewis notNULL_HANDLE, it must have a format ofFORMAT_R8_UINT. - If
imageViewis notNULL_HANDLE, it must have been created with ausagevalue includingIMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV - If
imageViewis notNULL_HANDLE,imageLayoutmust match the actualVkImageLayoutof each subresource accessible fromimageViewat the time the subresource is accessed. - If
imageViewis notNULL_HANDLE,imageLayoutmust beIMAGE_LAYOUT_SHADING_RATE_OPTIMAL_NVorIMAGE_LAYOUT_GENERAL.
Valid Usage (Implicit)
commandBuffermust be a validVkCommandBufferhandle- If
imageViewis notNULL_HANDLE,imageViewmust be a validVkImageViewhandle imageLayoutmust be a validVkImageLayoutvaluecommandBuffermust be in the recording state- The
VkCommandPoolthatcommandBufferwas allocated from must support graphics operations - Both of
commandBuffer, andimageViewthat are valid handles must have been created, allocated, or retrieved from the sameVkDevice
Host Synchronization
- Host access to
commandBuffermust be externally synchronized - Host access to the
VkCommandPoolthatcommandBufferwas 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.imageViewmay 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 fromimageViewwill 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_NVenabled, 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_NVdynamic state enabled firstViewportmust be less thanVkPhysicalDeviceLimits::maxViewports- The sum of
firstViewportandviewportCountmust be between 1 andVkPhysicalDeviceLimits::maxViewports, inclusive - If the multiple viewports feature is not enabled,
firstViewportmust be 0 - If the multiple viewports feature is not enabled,
viewportCountmust be 1
Valid Usage (Implicit)
commandBuffermust be a validVkCommandBufferhandlepShadingRatePalettesmust be a valid pointer to an array ofviewportCountvalidVkShadingRatePaletteNVstructurescommandBuffermust be in the recording state- The
VkCommandPoolthatcommandBufferwas allocated from must support graphics operations viewportCountmust be greater than 0
Host Synchronization
- Host access to
commandBuffermust be externally synchronized - Host access to the
VkCommandPoolthatcommandBufferwas 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 ofVkShadingRatePaletteNVstructures 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_NVenabled, 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
sampleOrderTypeisCOARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, the coverage sample order used for any combination of fragment area and coverage sample count not enumerated inpCustomSampleOrderswill be identical to that used forCOARSE_SAMPLE_ORDER_TYPE_DEFAULT_NV.Valid Usage
- If
sampleOrderTypeis notCOARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV,customSamplerOrderCountmust be 0 - The array
pCustomSampleOrdersmust not contain two structures with matching values for both theshadingRateandsampleCountmembers.
Valid Usage (Implicit)
commandBuffermust be a validVkCommandBufferhandlesampleOrderTypemust be a validVkCoarseSampleOrderTypeNVvalue- If
customSampleOrderCountis not 0,pCustomSampleOrdersmust be a valid pointer to an array ofcustomSampleOrderCountvalidVkCoarseSampleOrderCustomNVstructures commandBuffermust be in the recording state- The
VkCommandPoolthatcommandBufferwas allocated from must support graphics operations
Host Synchronization
- Host access to
commandBuffermust be externally synchronized - Host access to the
VkCommandPoolthatcommandBufferwas 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 ofVkCoarseSampleOrderCustomNVstructures, each of which specifies the coverage sample order for a single combination of fragment area and coverage sample count.
- If
-
-