OpenXR-SDK-Source icon indicating copy to clipboard operation
OpenXR-SDK-Source copied to clipboard

validation layer fails to validate chained ext structs

Open ChristophHaag opened this issue 3 years ago • 2 comments

Example chain that fails to be validated:

XrCreateSession -> XrSessionCreateInfoOverlayEXTX -> XrGraphicsBindingVulkanKHR

The generator currently generates code that claims nothing can be chained to XrSessionCreateInfoOverlayEXTX.

The registry contains

...
<type category="struct" name="XrSessionCreateInfoOverlayEXTX" structextends="XrSessionCreateInfo">
...
<type category="struct" name="XrGraphicsBindingVulkanKHR" structextends="XrSessionCreateInfo">
...

In reg.py the validextensionstructs map from these drectives looks like this

XrSessionCreateInfo     ['XrGraphicsBindingD3D11KHR', 'XrGraphicsBindingD3D12KHR', 'XrGraphicsBindingEGLMNDX', 'XrGraphicsBindingOpenGLESAndroidKHR', 'XrGraphicsBindingOpenGLWaylandKHR', 'XrGraphicsBindingOpenGLWin32KHR', 'XrGraphicsBindingOpenGLXcbKHR', 'XrGraphicsBindingOpenGLXlibKHR', 'XrGraphicsBindingVulkanKHR', 'XrHolographicWindowAttachmentMSFT', 'XrSessionCreateInfoOverlayEXTX']
XrSpaceLocation ['XrEyeGazeSampleTimeEXT', 'XrSpaceVelocity']
XrCompositionLayerProjectionView        ['XrCompositionLayerDepthInfoKHR']
XrInstanceCreateInfo    ['XrDebugUtilsMessengerCreateInfoEXT', 'XrInstanceCreateInfoAndroidKHR']
XrViewConfigurationView ['XrFoveatedViewConfigurationViewVARJO', 'XrViewConfigurationDepthRangeEXT', 'XrViewConfigurationViewFovEPIC']
XrInteractionProfileSuggestedBinding    ['XrBindingModificationsKHR', 'XrInteractionProfileAnalogThresholdVALVE']
XrSystemProperties      ['XrSystemEyeGazeInteractionPropertiesEXT', 'XrSystemFoveatedRenderingPropertiesVARJO', 'XrSystemHandTrackingMeshPropertiesMSFT', 'XrSystemHandTrackingPropertiesEXT']
XrHandJointLocationsEXT ['XrHandJointVelocitiesEXT']
XrHandJointsLocateInfoEXT       ['XrHandJointsMotionRangeInfoEXT']
XrHandTrackerCreateInfoEXT      ['XrHandPoseTypeInfoMSFT']
XrSessionBeginInfo      ['XrSecondaryViewConfigurationSessionBeginInfoMSFT']
XrFrameState    ['XrSecondaryViewConfigurationFrameStateMSFT']
XrFrameEndInfo  ['XrSecondaryViewConfigurationFrameEndInfoMSFT']
XrSwapchainCreateInfo   ['XrAndroidSurfaceSwapchainCreateInfoFB', 'XrSecondaryViewConfigurationSwapchainCreateInfoMSFT']
XrCompositionLayerBaseHeader    ['XrCompositionLayerColorScaleBiasKHR']
XrNewSceneComputeInfoMSFT       ['XrVisualMeshComputeLodInfoMSFT']
XrSceneComponentsMSFT   ['XrSceneMeshesMSFT', 'XrSceneObjectsMSFT', 'XrScenePlanesMSFT']
XrSceneComponentsGetInfoMSFT    ['XrSceneComponentParentFilterInfoMSFT', 'XrSceneObjectTypesFilterInfoMSFT', 'XrScenePlaneAlignmentFilterInfoMSFT']
XrCompositionLayerProjection    ['XrCompositionLayerDepthTestVARJO', 'XrCompositionLayerReprojectionInfoMSFT', 'XrCompositionLayerReprojectionPlaneOverrideMSFT']
XrViewLocateInfo        ['XrViewLocateFoveatedRenderingVARJO']

The validation layer generator only generates code that makes it valid to chain structs from the list in the values to the key struct.

Two ways to solve this:

  1. Add keys for all structs that can have another struct chained to it (XrSessionCreateInfoOverlayEXTX, XrGraphicsBindingVulkanKHR) as keys to the validextensionstructs map and duplicate the lists of valid structs that can be chained
  2. Make the validation layer generator generate code that allows chaining "siblings of the parent" struct

Option 2. is conceptually much nicer. Here is a proof of concept but it doesn't look very nice: https://github.com/ChristophHaag/OpenXR-SDK/commit/cf4ab7037a489c856625738c5eda79d68a6898ef

ChristophHaag avatar Jun 21 '21 23:06 ChristophHaag

An issue (number 1575) has been filed to correspond to this issue in the internal Khronos GitLab (Khronos members only: KHR:openxr/openxr#1575 ), to facilitate working group processes.

This GitHub issue will continue to be the main site of discussion.

rpavlik-bot avatar Jun 24 '21 17:06 rpavlik-bot

I've also been running into validation issues with .next chaining. Specifically with overlay and graphics, but also in other cases. I haven't pinned it down to specific items, but in cases where I have .next chains greater than 1 deep, I've run into validation layer issues. Here's one such validation layer "fix" I've had to add.

https://github.com/StereoKit/StereoKit/commit/efb8edd0b59b5399eef0d9571e5922c23ac63f49

maluoi avatar Oct 05 '23 21:10 maluoi