| 3239 | #endif |
| 3240 | #if defined(VK_USE_PLATFORM_DISPLAY_KHR) |
| 3241 | static VkResult demo_create_display_surface(struct demo *demo) { |
| 3242 | VkResult U_ASSERT_ONLY err; |
| 3243 | uint32_t display_count; |
| 3244 | uint32_t mode_count; |
| 3245 | uint32_t plane_count; |
| 3246 | VkDisplayPropertiesKHR display_props; |
| 3247 | VkDisplayKHR display; |
| 3248 | VkDisplayModePropertiesKHR mode_props; |
| 3249 | VkDisplayPlanePropertiesKHR *plane_props; |
| 3250 | VkBool32 found_plane = VK_FALSE; |
| 3251 | uint32_t plane_index; |
| 3252 | VkExtent2D image_extent; |
| 3253 | VkDisplaySurfaceCreateInfoKHR create_info; |
| 3254 | |
| 3255 | // Get the first display |
| 3256 | display_count = 1; |
| 3257 | err = vkGetPhysicalDeviceDisplayPropertiesKHR(demo->gpu, &display_count, &display_props); |
| 3258 | assert(!err || (err == VK_INCOMPLETE)); |
| 3259 | |
| 3260 | display = display_props.display; |
| 3261 | |
| 3262 | // Get the first mode of the display |
| 3263 | err = vkGetDisplayModePropertiesKHR(demo->gpu, display, &mode_count, NULL); |
| 3264 | assert(!err); |
| 3265 | |
| 3266 | if (mode_count == 0) { |
| 3267 | printf("Cannot find any mode for the display!\n"); |
| 3268 | fflush(stdout); |
| 3269 | exit(1); |
| 3270 | } |
| 3271 | |
| 3272 | mode_count = 1; |
| 3273 | err = vkGetDisplayModePropertiesKHR(demo->gpu, display, &mode_count, &mode_props); |
| 3274 | assert(!err || (err == VK_INCOMPLETE)); |
| 3275 | |
| 3276 | // Get the list of planes |
| 3277 | err = vkGetPhysicalDeviceDisplayPlanePropertiesKHR(demo->gpu, &plane_count, NULL); |
| 3278 | assert(!err); |
| 3279 | |
| 3280 | if (plane_count == 0) { |
| 3281 | printf("Cannot find any plane!\n"); |
| 3282 | fflush(stdout); |
| 3283 | exit(1); |
| 3284 | } |
| 3285 | |
| 3286 | plane_props = malloc(sizeof(VkDisplayPlanePropertiesKHR) * plane_count); |
| 3287 | assert(plane_props); |
| 3288 | |
| 3289 | err = vkGetPhysicalDeviceDisplayPlanePropertiesKHR(demo->gpu, &plane_count, plane_props); |
| 3290 | assert(!err); |
| 3291 | |
| 3292 | // Find a plane compatible with the display |
| 3293 | for (plane_index = 0; plane_index < plane_count; plane_index++) { |
| 3294 | uint32_t supported_count; |
| 3295 | VkDisplayKHR *supported_displays; |
| 3296 | |
| 3297 | // Disqualify planes that are bound to a different display |
| 3298 | if ((plane_props[plane_index].currentDisplay != VK_NULL_HANDLE) && (plane_props[plane_index].currentDisplay != display)) { |
no test coverage detected