HORIZON HASKELLDocslts/ghc-9.14.x45dd5372026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · 45dd537 · 2026-10-11

Modulevulkan-3.27GHC2021

Vulkan.Extensions.VK_NV_optical_flow

Name

VK_NV_optical_flow - device extension

VK_NV_optical_flow

Name String

VK_NV_optical_flow

Extension Type

Device extension

Registered Extension Number

465

Revision

1

Ratification Status

Not ratified

Extension and Version Dependencies

VK_KHR_get_physical_device_properties2          or

Vulkan Version 1.1      and

VK_KHR_format_feature_flags2      and

VK_KHR_synchronization2 or Vulkan Version 1.3

Contact

Other Extension Metadata

Last Modified Date

2022-09-26

Contributors
  • Carsten Rohde, NVIDIA

  • Vipul Parashar, NVIDIA

  • Jeff Bolz, NVIDIA

  • Eric Werness, NVIDIA

Description

Optical flow are fundamental algorithms in computer vision (CV) area. This extension allows applications to estimate 2D displacement of pixels between two frames.

This extension is designed to be used with upcoming NVIDIA Optical Flow SDK Version 5 which will be available on NVIDIA Developer webpage.

New Object Types

New Commands

New Structures

New Enums

New Bitmasks

New Enum Constants

Examples

// Example querying available input formats
VkOpticalFlowImageFormatInfoNV ofFormatInfo = { VK_STRUCTURE_TYPE_OPTICAL_FLOW_IMAGE_FORMAT_INFO_NV };
ofFormatInfo.usage = VK_OPTICAL_FLOW_USAGE_INPUT_BIT_NV;

uint32_t count = 0;
vkGetPhysicalDeviceOpticalFlowImageFormatsNV(physicalDevice, &ofFormatInfo, &count, NULL);
VkOpticalFlowImageFormatPropertiesNV* fmt = new VkOpticalFlowImageFormatPropertiesNV[count];
memset(fmt, 0, count  * sizeof(VkOpticalFlowImageFormatPropertiesNV));
for (uint32_t i = 0; i < count; i++) {
    fmt[i].sType = VK_STRUCTURE_TYPE_OPTICAL_FLOW_IMAGE_FORMAT_PROPERTIES_NV;
}
vkGetPhysicalDeviceOpticalFlowImageFormatsNV(physicalDevice, &ofFormatInfo, &count, fmt);

// Pick one of the available formats
VkFormat inputFormat = fmt[0].format;

// Check feature support for optimal tiling
VkFormatProperties3 formatProperties3 = { VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_3 };
VkFormatProperties2 formatProperties2 = { VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2, &formatProperties3 };
vkGetPhysicalDeviceFormatProperties2(physicalDevice, inputFormat, &formatProperties2);
if (!(formatProperties3.optimalTilingFeatures & VK_FORMAT_FEATURE_2_OPTICAL_FLOW_IMAGE_BIT_NV)) {
    return false;
}

// Check support for image creation parameters
VkPhysicalDeviceImageFormatInfo2 imageFormatInfo2 = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2, &ofFormatInfo };
imageFormatInfo2.format = inputFormat;
imageFormatInfo2.type = VK_IMAGE_TYPE_2D;
imageFormatInfo2.tiling = VK_IMAGE_TILING_OPTIMAL;
imageFormatInfo2.usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;

VkImageFormatProperties2 imageFormatProperties2 = { VK_STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2 };
if (vkGetPhysicalDeviceImageFormatProperties2(physicalDevice, &imageFormatInfo2, &imageFormatProperties2) != VK_SUCCESS) {
    return false;
}

VkImageCreateInfo imageCreateInfo = { VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, &ofFormatInfo };
imageCreateInfo.imageType = VK_IMAGE_TYPE_2D;
imageCreateInfo.format = inputFormat;
imageCreateInfo.extent = { width, height, (uint32_t)1};
imageCreateInfo.mipLevels = 1;
imageCreateInfo.arrayLayers = 1;
imageCreateInfo.samples = VK_SAMPLE_COUNT_1_BIT;
imageCreateInfo.usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
imageCreateInfo.tiling = VK_IMAGE_TILING_OPTIMAL;

vkCreateImage(device, &imageCreateInfo, NULL, &input);
"allocate memory, bind image, create view"

"do the same for reference and output"

// Create optical flow session
VkOpticalFlowSessionCreateInfoNV sessionCreateInfo = { VK_STRUCTURE_TYPE_OPTICAL_FLOW_SESSION_CREATE_INFO_NV };
sessionCreateInfo.width = width;
sessionCreateInfo.height = height;
sessionCreateInfo.imageFormat = inputFormat;
sessionCreateInfo.flowVectorFormat = outputFormat;
sessionCreateInfo.outputGridSize = VK_OPTICAL_FLOW_GRID_SIZE_4X4_BIT_NV;
sessionCreateInfo.performanceLevel = VK_OPTICAL_FLOW_PERFORMANCE_LEVEL_SLOW_NV;
VkOpticalFlowSessionNV session;
vkCreateOpticalFlowSessionNV(device, &sessionCreateInfo, NULL, &session);

"allocate command buffer"

"transfer images to VK_PIPELINE_STAGE_2_OPTICAL_FLOW_BIT_NV"
"transfer input images to VK_ACCESS_2_OPTICAL_FLOW_READ_BIT_NV and output image to VK_ACCESS_2_OPTICAL_FLOW_WRITE_BIT_NV"

vkBindOpticalFlowSessionImageNV(device, session, VK_OPTICAL_FLOW_SESSION_BINDING_POINT_INPUT_NV, inputView, VK_IMAGE_LAYOUT_GENERAL);
vkBindOpticalFlowSessionImageNV(device, session, VK_OPTICAL_FLOW_SESSION_BINDING_POINT_REFERENCE_NV, refView, VK_IMAGE_LAYOUT_GENERAL);
vkBindOpticalFlowSessionImageNV(device, session, VK_OPTICAL_FLOW_SESSION_BINDING_POINT_FLOW_VECTOR_NV, outputView, VK_IMAGE_LAYOUT_GENERAL);

VkOpticalFlowExecuteInfoNV opticalFlowExecuteInfo = { VK_STRUCTURE_TYPE_OPTICAL_FLOW_EXECUTE_INFO_NV };
vkCmdOpticalFlowExecuteNV(cmd, session, &opticalFlowExecuteInfo);

"submit command buffer"

Version History

  • Revision 1, 2022-09-26 (Carsten Rohde)

    • Internal revisions

See Also

No cross-references are available

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.

  • 20 types
  • 6 values
  • Packagevulkan-3.27
  • Exports59
  • LanguageGHC2021
  • LicenceBSD-3-Clause
  • SourceVK_NV_optical_flow.hs
valuegetPhysicalDeviceOpticalFlowImageFormatsNV
  1. :: MonadIO io
  2. => PhysicalDevice

    physicalDevice is the physical device being queried.

  3. -> OpticalFlowImageFormatInfoNV

    pOpticalFlowImageFormatInfo is a pointer to a OpticalFlowImageFormatInfoNV structure specifying the optical flow usage for which information is returned.

  4. -> io (Result, "imageFormatProperties" ::: Vector OpticalFlowImageFormatPropertiesNV)
#

vkGetPhysicalDeviceOpticalFlowImageFormatsNV - Query image formats for optical flow

Description

If pImageFormatProperties is NULL, then the number of optical flow properties supported for the given physicalDevice is returned in pFormatCount. Otherwise, pFormatCount must point to a variable set by the application to the number of elements in the pImageFormatProperties array, and on return the variable is overwritten with the number of values actually written to pImageFormatProperties. If the value of pFormatCount is less than the number of optical flow properties supported, at most pFormatCount values will be written to pImageFormatProperties, and INCOMPLETE will be returned instead of SUCCESS, to indicate that not all the available values were returned.

Before creating an image to be used as an optical flow frame, obtain the supported image creation parameters by querying with getPhysicalDeviceFormatProperties2 and getPhysicalDeviceImageFormatProperties2 using one of the reported formats and adding OpticalFlowImageFormatInfoNV to the pNext chain of PhysicalDeviceImageFormatInfo2.

When querying the parameters with getPhysicalDeviceImageFormatProperties2 for images used for optical flow operations, the OpticalFlowImageFormatInfoNV::usage field must contain one or more of the bits defined in OpticalFlowUsageFlagBitsNV.

Valid Usage (Implicit)

  • pOpticalFlowImageFormatInfo must be a valid pointer to a valid OpticalFlowImageFormatInfoNV structure

  • pFormatCount must be a valid pointer to a uint32_t value

  • If the value referenced by pFormatCount is not 0, and pImageFormatProperties is not NULL, pImageFormatProperties must be a valid pointer to an array of pFormatCount OpticalFlowImageFormatPropertiesNV structures

Return Codes

Success
Failure

FORMAT_B8G8R8A8_UNORM, FORMAT_R8_UNORM and FORMAT_G8_B8R8_2PLANE_420_UNORM are initially supported for images with optical usage OPTICAL_FLOW_USAGE_INPUT_BIT_NV.

FORMAT_R16G16_SFIXED5_NV is initially supported for images with optical flow usage OPTICAL_FLOW_USAGE_OUTPUT_BIT_NV, OPTICAL_FLOW_USAGE_HINT_BIT_NV and OPTICAL_FLOW_USAGE_GLOBAL_FLOW_BIT_NV.

FORMAT_R8_UINT and FORMAT_R32_UINT are initially supported for images with optical flow usage OPTICAL_FLOW_USAGE_COST_BIT_NV. It is recommended to use FORMAT_R8_UINT because of the lower bandwidth.

See Also

VK_NV_optical_flow, OpticalFlowImageFormatInfoNV, OpticalFlowImageFormatPropertiesNV, PhysicalDevice

valuecreateOpticalFlowSessionNV
  1. :: (Extendss OpticalFlowSessionCreateInfoNV a, PokeChain a, MonadIO io)
  2. => Device

    device is the logical device that creates the optical flow session object.

  3. -> OpticalFlowSessionCreateInfoNV a

    pCreateInfo is a pointer to a OpticalFlowSessionCreateInfoNV structure containing parameters specifying the creation of the optical flow session.

  4. -> "allocator" ::: Maybe AllocationCallbacks

    pAllocator controls host memory allocation as described in the Memory Allocation chapter.

  5. -> io OpticalFlowSessionNV
#

vkCreateOpticalFlowSessionNV - Creates an optical flow session object

Valid Usage (Implicit)

  • device must be a valid Device handle

Return Codes

Success
Failure

See Also

VK_NV_optical_flow, AllocationCallbacks, Device, OpticalFlowSessionCreateInfoNV, OpticalFlowSessionNV

A convenience wrapper to make a compatible pair of calls to createOpticalFlowSessionNV and destroyOpticalFlowSessionNV

To ensure that destroyOpticalFlowSessionNV is always called: pass bracket (or the allocate function from your favourite resource management library) as the last argument. To just extract the pair pass (,) as the last argument.

valuedestroyOpticalFlowSessionNV
  1. :: MonadIO io
  2. => Device

    device is the device that was used for the creation of the optical flow session.

  3. -> OpticalFlowSessionNV

    session is the optical flow session to be destroyed.

  4. -> "allocator" ::: Maybe AllocationCallbacks

    pAllocator controls host memory allocation as described in the Memory Allocation chapter.

  5. -> io ()
#

vkDestroyOpticalFlowSessionNV - Destroy optical flow session object

Valid Usage (Implicit)

  • device must be a valid Device handle

  • session must be a valid OpticalFlowSessionNV handle

  • If pAllocator is not NULL, pAllocator must be a valid pointer to a valid AllocationCallbacks structure

  • session must have been created, allocated, or retrieved from device

See Also

VK_NV_optical_flow, AllocationCallbacks, Device, OpticalFlowSessionNV

valuebindOpticalFlowSessionImageNV
  1. :: MonadIO io
  2. => Device

    device is the device which owns the optical flow session object session.

  3. -> OpticalFlowSessionNV

    session is the optical flow session object to which the image view is to be bound.

  4. -> OpticalFlowSessionBindingPointNV

    bindingPoint specifies the binding point OpticalFlowSessionBindingPointNV to which the image view is bound.

  5. -> ImageView

    view is a ImageView to be bound.

  6. -> ImageLayout

    layout must specify the layout that the image subresources accessible from view will be in at the time the optical flow vectors are calculated with cmdOpticalFlowExecuteNV on a Device.

  7. -> io ()
#

vkBindOpticalFlowSessionImageNV - Bind image to an optical flow session

Valid Usage (Implicit)

  • device must be a valid Device handle

Return Codes

Success
Failure

See Also

VK_NV_optical_flow, Device, ImageLayout, ImageView, OpticalFlowSessionBindingPointNV, OpticalFlowSessionNV

valuecmdOpticalFlowExecuteNV
  1. :: MonadIO io
  2. => CommandBuffer

    commandBuffer is the command buffer into which the command will be recorded.

  3. -> OpticalFlowSessionNV

    session is the optical flow session object on which this command is operating.

  4. -> OpticalFlowExecuteInfoNV

    pExecuteInfo Info is a pointer to a OpticalFlowExecuteInfoNV.

  5. -> io ()
#

vkCmdOpticalFlowExecuteNV - Calculate optical flow vectors

Valid Usage (Implicit)

  • session must be a valid OpticalFlowSessionNV handle

  • pExecuteInfo must be a valid pointer to a valid OpticalFlowExecuteInfoNV structure

  • commandBuffer must be in the recording state

  • The CommandPool that commandBuffer was allocated from must support QUEUE_OPTICAL_FLOW_BIT_NV operations

  • This command must only be called outside of a render pass instance

  • This command must not be called between suspended render pass instances

  • This command must only be called outside of a video coding scope

  • Both of commandBuffer, and session must have been created, allocated, or retrieved from the same Device

Host Synchronization

  • Host access to the CommandPool that commandBuffer was allocated from must be externally synchronized

Command Properties

'

Command Buffer Levels

Render Pass Scope

Video Coding Scope

Supported Queue Types

Command Type

Primary Secondary

Outside

Outside

VK_QUEUE_OPTICAL_FLOW_BIT_NV

Action

Conditional Rendering

vkCmdOpticalFlowExecuteNV is not affected by conditional rendering

See Also

VK_NV_optical_flow, CommandBuffer, OpticalFlowExecuteInfoNV, OpticalFlowSessionNV

VkPhysicalDeviceOpticalFlowFeaturesNV - Structure describing the optical flow features supported by the implementation

Members

This structure describes the following feature:

Description

If the PhysicalDeviceOpticalFlowFeaturesNV structure is included in the pNext chain of the PhysicalDeviceFeatures2 structure passed to getPhysicalDeviceFeatures2, it is filled in to indicate whether each corresponding feature is supported. If the application wishes to use a Device with any features described by PhysicalDeviceOpticalFlowFeaturesNV, it must add an instance of the structure, with the desired feature members set to TRUE, to the pNext chain of DeviceCreateInfo when creating the Device.

Structure Chaining

Extends the structures

See Also

VK_NV_optical_flow, Bool32, StructureType

Constructors

Instances6Eq, Show, Storable, FromCStruct, ToCStruct, Zero

VkPhysicalDeviceOpticalFlowPropertiesNV - Structure describing properties supported by VK_NV_optical_flow

Description

If the PhysicalDeviceOpticalFlowPropertiesNV structure is included in the pNext chain of the PhysicalDeviceProperties2 structure passed to getPhysicalDeviceProperties2, it is filled in with each corresponding implementation-dependent property.

Structure Chaining

Extends the structure

See Also

VK_NV_optical_flow, Bool32, OpticalFlowGridSizeFlagsNV, StructureType

Constructors

Instances6Eq, Show, Storable, FromCStruct, ToCStruct, Zero

VkOpticalFlowImageFormatInfoNV - Structure describing optical flow image format info

Structure Chaining

Extends the structures

See Also

VK_NV_optical_flow, OpticalFlowUsageFlagsNV, StructureType, getPhysicalDeviceOpticalFlowImageFormatsNV

Constructors

Instances6Eq, Show, Storable, FromCStruct, ToCStruct, Zero

VkOpticalFlowImageFormatPropertiesNV - Structure describing properties of an optical flow image format

Valid Usage (Implicit)

See Also

VK_NV_optical_flow, Format, StructureType, getPhysicalDeviceOpticalFlowImageFormatsNV

Constructors

Instances6Eq, Show, Storable, FromCStruct, ToCStruct, Zero
datadata OpticalFlowSessionCreateInfoNV (es :: [Type])
#

VkOpticalFlowSessionCreateInfoNV - Structure specifying parameters of a newly created optical flow session

Valid Usage

Valid Usage (Implicit)

See Also

VK_NV_optical_flow, Format, OpticalFlowGridSizeFlagsNV, OpticalFlowPerformanceLevelNV, OpticalFlowSessionCreateFlagsNV, StructureType, createOpticalFlowSessionNV

Constructors

Instances5Extensible, Show, FromCStruct, ToCStruct, Zero

VkOpticalFlowSessionCreatePrivateDataInfoNV - Structure for NV internal use only

Structure Chaining

Extends the structure

See Also

VK_NV_optical_flow, StructureType

Constructors

Instances5Show, Storable, FromCStruct, ToCStruct, Zero

VkOpticalFlowExecuteInfoNV - Structure specifying parameters of an optical flow vector calculation

Valid Usage

Valid Usage (Implicit)

  • pNext must be NULL

  • flags must be a valid combination of OpticalFlowExecuteFlagBitsNV values

  • If regionCount is not 0, pRegions must be a valid pointer to an array of regionCount Rect2D structures

See Also

VK_NV_optical_flow, OpticalFlowExecuteFlagsNV, Rect2D, StructureType, cmdOpticalFlowExecuteNV

Constructors

Instances4Show, FromCStruct, ToCStruct, Zero
newtypenewtype OpticalFlowGridSizeFlagBitsNV
#

VkOpticalFlowGridSizeFlagBitsNV - Bits specifying grid sizes for optical flow operations

Description

See Also

VK_NV_optical_flow, OpticalFlowGridSizeFlagsNV

Instances8Eq, Ord, Read, Show, Bits, FiniteBits, …
newtypenewtype OpticalFlowUsageFlagBitsNV
#

VkOpticalFlowUsageFlagBitsNV - Bits specifying usage for optical flow operations

Description

See Also

VK_NV_optical_flow, OpticalFlowUsageFlagsNV

Instances8Eq, Ord, Read, Show, Bits, FiniteBits, …
newtypenewtype OpticalFlowPerformanceLevelNV
#

VkOpticalFlowPerformanceLevelNV - Optical flow performance level types

Description

See Also

VK_NV_optical_flow, OpticalFlowSessionCreateInfoNV

Instances6Eq, Ord, Read, Show, Storable, Zero

VkOpticalFlowSessionBindingPointNV - Binding points of an optical flow session

Description

See Also

VK_NV_optical_flow, bindOpticalFlowSessionImageNV

Instances6Eq, Ord, Read, Show, Storable, Zero

VkOpticalFlowSessionCreateFlagBitsNV - Bits specifying flags for optical flow session

Description

See Also

VK_NV_optical_flow, OpticalFlowSessionCreateFlagsNV

Instances8Eq, Ord, Read, Show, Bits, FiniteBits, …
newtypenewtype OpticalFlowExecuteFlagBitsNV
#

VkOpticalFlowExecuteFlagBitsNV - Bits specifying flags for an optical flow vector calculation

Description

  • OPTICAL_FLOW_EXECUTE_DISABLE_TEMPORAL_HINTS_BIT_NV specifies that temporal hints from previously generated flow vectors are not used. If temporal hints are enabled, optical flow vectors from previous cmdOpticalFlowExecuteNV call are automatically used as hints for the current cmdOpticalFlowExecuteNV call, to take advantage of temporal correlation in a video sequence. Temporal hints should be disabled if there is a-priori knowledge of no temporal correlation (e.g. a scene change, independent successive frame pairs).

See Also

VK_NV_optical_flow, OpticalFlowExecuteFlagsNV

Instances8Eq, Ord, Read, Show, Bits, FiniteBits, …
newtypenewtype OpticalFlowSessionNV
#
Instances7Eq, Ord, Show, Storable, HasObjectType, IsHandle, …