Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't always provide Win32Monitor handle when full_screen_exclusive is not FullScreenExclusive::Default #2477

Open
AlexMcFarland opened this issue Feb 24, 2024 · 2 comments

Comments

@AlexMcFarland
Copy link

  • 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
@Rua
Copy link
Contributor

Rua commented Feb 24, 2024

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?

@AlexHickie
Copy link

vkGetPhysicalDeviceSurfaceCapabilities2KHR()

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

Spec

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 the pNext chain includes a VkSurfaceFullScreenExclusiveInfoEXT structure with its fullScreenExclusive member set to VK_FULL_SCREEN_EXCLUSIVE_APPLICATION_CONTROLLED_EXT, and surface was created using vkCreateWin32SurfaceKHR, a VkSurfaceFullScreenExclusiveWin32InfoEXT structure must be included in the pNext chain

Spec

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

Spec

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants