kondrak / vkQuake2

id Software's Quake 2 v3.21 with mission packs and Vulkan support (Windows, Linux, macOS, FreeBSD, Raspberry Pi 4)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Invalid usage of vkGetPhysicalDeviceSurfaceFormatsKHR

Nodli opened this issue · comments

Hi,

VK_VERIFY(vkGetPhysicalDeviceSurfaceFormatsKHR(devices[i], vk_surface, &formatCount, NULL));

https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceSurfaceFormatsKHR.html

vkGetPhysicalDeviceSurfaceFormatsKHR is used to determine if the device can be used with the surface but the spec says in "Valid Usage" that the surface parameter "must be supported by physicalDevice, as reported by vkGetPhysicalDeviceSurfaceSupportKHR or an equivalent platform-specific mechanism".
Moreover "The number of format pairs supported must be greater than or equal to 1" which means that the formatCount == 0 check is unnecessary.

From what i read in the spec, it seems that the right thing to do would be to remove the call to vkGetPhysicalDeviceSurfaceFormatsKHR or put it after vkGetPhysicalDeviceSurfaceSupportKHR .

VK_VERIFY(vkGetPhysicalDeviceSurfacePresentModesKHR(devices[i], vk_surface, &presentModesCount, NULL));

https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkPresentModeKHR.html

The call to vkGetPhysicalDeviceSurfacePresentModesKHR could be removed too. The call is not invalid but VK_PRESENT_MODE_FIFO_KHR is required to be supported by the spec (see Description above).
As long as it is checked that the device suports presentation with vkGetPhysicalDeviceSurfaceSupportKHR, then we are guaranteed to have VK_PRESENT_MODE_FIFO_KHR when calling vkGetPhysicalDeviceSurfacePresentModesKHR and the presentModesCount == 0 check is unnecessary.

Thanks, this is a valid point and the calls are in fact redundant in this case.