vulkan-zig icon indicating copy to clipboard operation
vulkan-zig copied to clipboard

Autodetect "enumerate" functions

Open poconn opened this issue 1 year ago • 1 comments

Followup from #146, posting the issue as a reminder for myself :)

We've currently got a hardcoded list but should instead automatically decide whether to generate an *Alloc() wrapper based on the parameter's "length" attribute and possibly other factors such as an "incomplete" return code.

I won't get to this right away but hopefully in the next few weeks or so.

poconn avatar Jun 30 '24 23:06 poconn

@Snektron Hey, sorry for the delay on this! I haven't started on the implementation but did finally look into how these functions can be classified.

Seems like the most reliable indicators are that (a) the last parameter is an optional pointer, and (b) the previous parameter is tagged as its associated length. That rule seems to correctly classify everything, aside from false positives on some vkCmd*() functions which can be filtered out by name (not a hardcoded list, just reject any name with that prefix). There are a few additional checks we can add for redundancy, e.g. the aforementioned "incomplete" return code.

Full list:

  • vkEnumerateDeviceExtensionProperties
  • vkEnumerateDeviceLayerProperties
  • vkEnumerateInstanceExtensionProperties
  • vkEnumerateInstanceLayerProperties
  • vkEnumeratePhysicalDeviceGroups
  • vkEnumeratePhysicalDevices
  • vkGetCudaModuleCacheNV
  • vkGetDeviceImageSparseMemoryRequirements
  • vkGetDisplayModeProperties2KHR
  • vkGetDisplayModePropertiesKHR
  • vkGetDisplayPlaneSupportedDisplaysKHR
  • vkGetEncodedVideoSessionParametersKHR
  • vkGetFaultData
  • vkGetFramebufferTilePropertiesQCOM
  • vkGetImageSparseMemoryRequirements
  • vkGetImageSparseMemoryRequirements2
  • vkGetPastPresentationTimingGOOGLE
  • vkGetPhysicalDeviceCalibrateableTimeDomainsKHR
  • vkGetPhysicalDeviceCooperativeMatrixPropertiesKHR
  • vkGetPhysicalDeviceCooperativeMatrixPropertiesNV
  • vkGetPhysicalDeviceDisplayPlaneProperties2KHR
  • vkGetPhysicalDeviceDisplayPlanePropertiesKHR
  • vkGetPhysicalDeviceDisplayProperties2KHR
  • vkGetPhysicalDeviceDisplayPropertiesKHR
  • vkGetPhysicalDeviceFragmentShadingRatesKHR
  • vkGetPhysicalDeviceOpticalFlowImageFormatsNV
  • vkGetPhysicalDevicePresentRectanglesKHR
  • vkGetPhysicalDeviceQueueFamilyProperties
  • vkGetPhysicalDeviceQueueFamilyProperties2
  • vkGetPhysicalDeviceRefreshableObjectTypesKHR
  • vkGetPhysicalDeviceSparseImageFormatProperties
  • vkGetPhysicalDeviceSparseImageFormatProperties2
  • vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV
  • vkGetPhysicalDeviceSurfaceFormats2KHR
  • vkGetPhysicalDeviceSurfaceFormatsKHR
  • vkGetPhysicalDeviceSurfacePresentModes2EXT
  • vkGetPhysicalDeviceSurfacePresentModesKHR
  • vkGetPhysicalDeviceToolProperties
  • vkGetPhysicalDeviceVideoFormatPropertiesKHR
  • vkGetPipelineCacheData
  • vkGetPipelineExecutableInternalRepresentationsKHR
  • vkGetPipelineExecutablePropertiesKHR
  • vkGetPipelineExecutableStatisticsKHR
  • vkGetQueueCheckpointData2NV
  • vkGetQueueCheckpointDataNV
  • vkGetShaderBinaryDataEXT
  • vkGetShaderInfoAMD
  • vkGetSwapchainImagesKHR
  • vkGetValidationCacheDataEXT
  • vkGetVideoSessionMemoryRequirementsKHR

So yeah, seems real doable. I should have a PR for you soon, hopefully this weekend at the latest.

poconn avatar Sep 09 '24 13:09 poconn