KhronosGroup / KhronosGroup/Vulkan-Loader
vkEnumerateInstanceExtensionProperties is incorrectly implemented
- Dominant language
- C
- Stars
- 695
- Forks
- 343
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 17
Description
**Environment:**
- OS: Windows
- GPU and driver version: NVIDIA GEFORCE RTX 3090
- SDK or header version if building from repo: 1.3.280.0
- Options enabled (synchronization, best practices, etc.):
**Describe the Issue**
vkEnumerateInstanceExtensionProperties is a "pre-instance function" (https://vulkan.lunarg.com/doc/view/1.3.280.0/windows/loader_and_layer_interface.html#user-content-pre-instance-functions), and therefore requires special handling via `Vk...Chain` in order to be properly layered. Because this is not properly implemented, VVL's `EnumerateInstanceExtensionProperties()` function does not appear to ever get executed.
For example, calling: `vkEnumerateInstanceExtensionProperties(NULL, NULL, NULL)` will not report the `VUID-vkEnumerateInstanceExtensionProperties-pPropertyCount-parameter` validation error.
It's also worth noting that if an app calls `vkEnumerateInstanceExtensionProperties()` prior to `vkCreateInstance()`, the `VkLayer_khronos_validation.dll` does not get loaded, as would be expected if the function was correctly layered.
Lastly, the `chassis.cpp::EnumerateInstanceExtensionProperties()` implementation does not correctly handle the case when `pLayerName == NULL`
This set of issues likely applies to the other "pre-instance functions".
**Expected behavior**
1. Calls to `vkEnumerateInstanceExtensionProperties()` prior to `vkCreateInstance()` would load `VkLayer_khronos_validation.dll` and run validation checks
2. Calling `vkEnumerateInstanceExtensionProperties(NULL, NULL, NULL)` should report `VUID-vkEnumerateInstanceExtensionProperties-pPropertyCount-parameter` validation error.
3. Calling `vkEnumerateInstanceExtensionProperties(NULL, &count, NULL)` should result in VVL calling down the chain so that `extensions provided by the Vulkan implementation or by implicitly enabled layers are returned` (per vkEnumerateInstanceExtensionProperties's spec)
**Valid Usage ID**
VUID-vkEnumerateInstanceExtensionProperties-* don't get reported
**Additional context**
It's worth noting that according to the vulkan spec, VVL is not actually allowed layer the pre-instance functions: `In order to intercept the pre-instance functions, several conditions must be met: ... The layer must be implicit`. I'm not sure how VVL is expected to reconcile that, but thought it would be worth mentioning.
Contributor guide
Research direction
Start by tracing pre-instance function dispatch and layering for vkEnumerateInstanceExtensionProperties before vkCreateInstance(), then inspect chassis.cpp::EnumerateInstanceExtensionProperties(). Reproduce the calls with NULL parameters and verify validation reporting, layer loading, and extension results against the expected behavior and VUID.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100