vulkaninfo: erroneous presentation surfaces
authorCharles Giessen <charles@lunarg.com>
Wed, 22 Jan 2020 20:40:13 +0000 (13:40 -0700)
committerCharles Giessen <46324611+charles-lunarg@users.noreply.github.com>
Wed, 22 Jan 2020 22:45:52 +0000 (15:45 -0700)
In the commit to reduce unecessary surfaces being listed where only the surface extension differed, the which gpu the surface was using wasn't considered, creating
a matrix of surfaces, when there should of been only 1. This fixes it by making
sure to only collate surface extensions if they share a GPU.

Change-Id: Ib0d17a229713b3e4cec6f2885f81c96c5232ee0b

vulkaninfo/vulkaninfo.cpp
vulkaninfo/vulkaninfo.h

index 02cd7cd..717360e 100644 (file)
@@ -194,9 +194,9 @@ struct SurfaceTypeGroup {
 };
 
 bool operator==(AppSurface const &a, AppSurface const &b) {
-    return a.surf_present_modes == b.surf_present_modes && a.surf_formats == b.surf_formats && a.surf_formats2 == b.surf_formats2 &&
-           a.surface_capabilities == b.surface_capabilities && a.surface_capabilities2_khr == b.surface_capabilities2_khr &&
-           a.surface_capabilities2_ext == b.surface_capabilities2_ext;
+    return a.phys_device == b.phys_device && a.surf_present_modes == b.surf_present_modes && a.surf_formats == b.surf_formats &&
+           a.surf_formats2 == b.surf_formats2 && a.surface_capabilities == b.surface_capabilities &&
+           a.surface_capabilities2_khr == b.surface_capabilities2_khr && a.surface_capabilities2_ext == b.surface_capabilities2_ext;
 }
 
 void DumpPresentableSurfaces(Printer &p, AppInstance &inst, const std::vector<std::unique_ptr<AppGpu>> &gpus,
@@ -206,20 +206,24 @@ void DumpPresentableSurfaces(Printer &p, AppInstance &inst, const std::vector<st
     std::vector<SurfaceTypeGroup> surface_list;
 
     for (auto &surface : surfaces) {
-        for (auto &gpu : gpus) {
-            auto exists = surface_list.end();
-            for (auto it = surface_list.begin(); it != surface_list.end(); it++) {
-                // This uses a custom comparator to check if the surfaces have the same values
-                if (it->gpu == gpu.get() && *(it->surface) == *(surface.get())) {
-                    exists = it;
-                    break;
-                }
+        auto exists = surface_list.end();
+        for (auto it = surface_list.begin(); it != surface_list.end(); it++) {
+            // check for duplicat surfaces that differ only by the surface extension
+            if (*(it->surface) == *(surface.get())) {
+                exists = it;
+                break;
             }
-            if (exists != surface_list.end()) {
-                exists->surface_types.insert(surface.get()->surface_extension.name);
-            } else {
-                surface_list.push_back({surface.get(), gpu.get(), {surface.get()->surface_extension.name}});
+        }
+        if (exists != surface_list.end()) {
+            exists->surface_types.insert(surface.get()->surface_extension.name);
+        } else {
+            // find surface.phys_device's corresponding AppGpu
+            AppGpu *corresponding_gpu = nullptr;
+            for (auto &gpu : gpus) {
+                if (gpu->phys_device == surface->phys_device) corresponding_gpu = gpu.get();
             }
+            if (corresponding_gpu != nullptr)
+                surface_list.push_back({surface.get(), corresponding_gpu, {surface.get()->surface_extension.name}});
         }
     }
     for (auto &group : surface_list) {
index 42ad3f3..7add1ca 100644 (file)
@@ -902,6 +902,7 @@ void SetupWindowExtensions(AppInstance &inst) {
 class AppSurface {
    public:
     AppInstance &inst;
+       VkPhysicalDevice phys_device;
     SurfaceExtension surface_extension;
 
     std::vector<VkPresentModeKHR> surf_present_modes;
@@ -915,7 +916,7 @@ class AppSurface {
 
     AppSurface(AppInstance &inst, VkPhysicalDevice phys_device, SurfaceExtension surface_extension,
                std::vector<pNextChainBuildingBlockInfo> &sur_extension_pNextChain)
-        : inst(inst), surface_extension(surface_extension) {
+        : inst(inst), phys_device(phys_device), surface_extension(surface_extension) {
         uint32_t present_mode_count = 0;
         VkResult error =
             inst.vkGetPhysicalDeviceSurfacePresentModesKHR(phys_device, surface_extension.surface, &present_mode_count, nullptr);