Can't always provide `Win32Monitor` handle when `full_screen_exclusive` is not `FullScreenExclusive::Default`
Opened this issue · 2 comments
- Version of vulkano:
0.34
- OS:
Windows
- GPU (the selected PhysicalDevice):
NVIDIA GeForce GTX 1080
- GPU Driver:
GeForce Game Ready Driver 536.23
Issue
Currently when a full_screen_exclusive
value other than FullScreenExclusive::Default
is provided in SurfaceInfo
or SwapchainCreateInfo
, Vulkan will output a validation error if a Win32Monitor
handle is not provided.
Vulkano however expects that if and only if full_screen_exclusive
is FullScreenExclusive::ApplicationControlled
should a Win32Monitor
handle also be provided.
Since Vulkano will not let you provide a Win32Monitor
handle alongside other full_screen_exclusive
values like FullScreenExclusive::Allowed
or FullScreenExclusive::Disallowed
, it is impossible to use these values without triggering the following validation error:
VUID-vkGetPhysicalDeviceSurfaceCapabilities2KHR-pNext-02671(ERROR / SPEC): msgNum: -1949531159 - Validation Error: [ VUID-vkGetPhysicalDeviceSurfaceCapabilities2KHR-pNext-02671 ] Object 0: handle = 0x2298a106fe0, type = VK_OBJECT_TYPE_PHYSICAL_DEVICE; | MessageID = 0x8bcc83e9 | vkGetPhysicalDeviceSurfaceCapabilities2KHR(): pSurfaceCapabilities->pNext contains VkSurfaceCapabilitiesFullScreenExclusiveEXT, but pSurfaceInfo->pNext does not contain VkSurfaceFullScreenExclusiveWin32InfoEXT. The Vulkan spec states: If a VkSurfaceCapabilitiesFullScreenExclusiveEXT structure is included in the pNext chain of pSurfaceCapabilities, a VkSurfaceFullScreenExclusiveWin32InfoEXT structure must be included
in the pNext chain of pSurfaceInfo (https://vulkan.lunarg.com/doc/view/1.3.268.0/windows/1.3-extensions/vkspec.html#VUID-vkGetPhysicalDeviceSurfaceCapabilities2KHR-pNext-02671)
As the Vulkan spec states (for surface capabilities):
VUID-vkGetPhysicalDeviceSurfaceCapabilities2KHR-pNext-02671
If a VkSurfaceCapabilitiesFullScreenExclusiveEXT structure is included in the pNext chain of pSurfaceCapabilities, a VkSurfaceFullScreenExclusiveWin32InfoEXT structure must be included in the pNext chain of pSurfaceInfo
Note that it makes no mention of VK_FULL_SCREEN_EXCLUSIVE_APPLICATION_CONTROLLED_EXT
specifically.
As far as I'm aware, the fix would be to update these conditional checks (these are only the ones that I know of in Vulkano, but maybe there are more?):
https://github.com/vulkano-rs/vulkano/blob/master/vulkano/src/device/physical.rs#L2412
https://github.com/vulkano-rs/vulkano/blob/master/vulkano/src/device/physical.rs#L2683
https://github.com/vulkano-rs/vulkano/blob/master/vulkano/src/swapchain/mod.rs#L609-L610
https://github.com/vulkano-rs/vulkano/blob/master/vulkano/src/swapchain/mod.rs#L633-L634
surface.api() == SurfaceApi::Win32 && full_screen_exclusive == FullScreenExclusive::ApplicationControlled
To instead be:
surface.api() == SurfaceApi::Win32 && full_screen_exclusive != FullScreenExclusive::Default
The spec isn't really clear on when the monitor value will be used when provided, and when it will be ignored. I had assumed that if the value is not required, then the driver will always ignore it, but apparently that's not the case? Do you have any information on that perhaps?
vkGetPhysicalDeviceSurfaceCapabilities2KHR()
VUID-vkGetPhysicalDeviceSurfaceCapabilities2KHR-pNext-02671
If aVkSurfaceCapabilitiesFullScreenExclusiveEXT
structure is included in the pNext chain ofpSurfaceCapabilities
, aVkSurfaceFullScreenExclusiveWin32InfoEXT
structure must be included in thepNext
chain ofpSurfaceInfo
On windows, if full_screen_exclusive != Default
then VkSurfaceCapabilitiesFullScreenExclusiveEXT
is added to the chain so VkSurfaceFullScreenExclusiveWin32InfoEXT
is required. It is currently only added if full_screen_exclusive == ApplicationControlled
.
The ValidationError
provided in PhysicalDevice::surface_capabilities
references VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-02672
which is a subset of the requirements of VUID-vkGetPhysicalDeviceSurfaceCapabilities2KHR-pNext-02671
.
VkPhysicalDeviceSurfaceInfo2KHR
... chaining a
VkSurfaceFullScreenExclusiveWin32InfoEXT
structure may also report additional surface capabilities
VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-02672
If thepNext
chain includes aVkSurfaceFullScreenExclusiveInfoEXT
structure with itsfullScreenExclusive
member set toVK_FULL_SCREEN_EXCLUSIVE_APPLICATION_CONTROLLED_EXT
, and surface was created usingvkCreateWin32SurfaceKHR
, aVkSurfaceFullScreenExclusiveWin32InfoEXT
structure must be included in thepNext
chain
I.e. on windows VkSurfaceFullScreenExclusiveWin32InfoEXT
is required if full_screen_exclusive == ApplicationControlled
and may be optionally provided for additional capabilities (that are required by vkGetPhysicalDeviceSurfaceCapabilities2KHR()
).
PhysicalDevice::surface_formats
and PhysicalDevice::surface_present_modes
use VkPhysicalDeviceSurfaceInfo2KHR
.
VkSwapchainCreateInfoKHR
Same as VkPhysicalDeviceSurfaceInfo2KHR
but there is no advantage to providing it outside the required full_screen_exclusive == ApplicationControlled
.
So on windows, VkSurfaceFullScreenExclusiveWin32InfoEXT
is optional if full_screen_exclusive != Default
. It is required for VkPhysicalDeviceSurfaceInfo2KHR
with full_screen_exclusive == ApplicationControlled
and vkGetPhysicalDeviceSurfaceCapabilities2KHR()
with full_screen_exclusive != Default
.