diff options
| author | Charles Giessen <charles@lunarg.com> | 2019-10-08 10:02:17 -0600 |
|---|---|---|
| committer | Charles Giessen <46324611+charles-lunarg@users.noreply.github.com> | 2019-10-15 11:37:21 -0600 |
| commit | b2c22307c5e14978c007b33869e51eaa127547cc (patch) | |
| tree | a93b6817a8495e809e64affd80d9dff580052bcf /vulkaninfo/vulkaninfo.cpp | |
| parent | cdb7624451f5f641c4b6f8045869802e2ab12dca (diff) | |
| download | usermoji-b2c22307c5e14978c007b33869e51eaa127547cc.tar.xz | |
vulkaninfo: Present Surfaces now wont show duplicates
If a machine has multiple surface types that work with the
same gpu and have the same properties, vulkainfo will now
list them in a short array instead of duplicating the entire
surfaces information. To do this required being able to compare
vulkan objects, necesitating the autogeneration of comparators
for vulkan structs. This patch also refactors some of the
device creation code to better reflect the actual data
dependencies of the various vulkan objects.
files modified
- vulkaninfo/vulkaninfo.cpp
- vulkaninfo/vulkaninfo.h
- scripts/vulkaninfo_generator.py
- vulkaninfo/generated/vulkaninfo.hpp
Change-Id: Ifda51eacc3883982a6e2f7f60439827eb355c204
Diffstat (limited to 'vulkaninfo/vulkaninfo.cpp')
| -rw-r--r-- | vulkaninfo/vulkaninfo.cpp | 82 |
1 files changed, 58 insertions, 24 deletions
diff --git a/vulkaninfo/vulkaninfo.cpp b/vulkaninfo/vulkaninfo.cpp index fbfda81a..75a653d8 100644 --- a/vulkaninfo/vulkaninfo.cpp +++ b/vulkaninfo/vulkaninfo.cpp @@ -53,7 +53,7 @@ void DumpExtensions(Printer &p, std::string layer_name, std::vector<VkExtensionP p.ArrayEnd(); } -void DumpLayers(Printer &p, std::vector<LayerExtensionList> layers, std::vector<AppGpu *> gpus) { +void DumpLayers(Printer &p, std::vector<LayerExtensionList> layers, const std::vector<std::unique_ptr<AppGpu>> &gpus) { std::sort(layers.begin(), layers.end(), [](LayerExtensionList &left, LayerExtensionList &right) -> int { const char *a = left.layer_properties.layerName; const char *b = right.layer_properties.layerName; @@ -146,7 +146,7 @@ void DumpSurfaceCapabilities(Printer &p, AppInstance &inst, AppGpu &gpu, AppSurf chain_iterator_surface_capabilities2(p, inst, gpu, surface.surface_capabilities2_khr.pNext); } -void DumpSurface(Printer &p, AppInstance &inst, AppGpu &gpu, AppSurface &surface) { +void DumpSurface(Printer &p, AppInstance &inst, AppGpu &gpu, AppSurface &surface, std::vector<std::string> surface_types) { std::string header; if (p.Type() == OutputType::text) header = std::string("GPU id : ") + std::to_string(gpu.id) + " (" + gpu.props.deviceName + ")"; @@ -154,7 +154,15 @@ void DumpSurface(Printer &p, AppInstance &inst, AppGpu &gpu, AppSurface &surface header = std::string("GPU id : <span class='val'>") + std::to_string(gpu.id) + "</span> (" + gpu.props.deviceName + ")"; p.ObjectStart(header); - p.SetAsType().PrintKeyValue("Surface type", surface.surface_extension.name); + if (surface_types.size() == 0) { + p.SetAsType().PrintKeyValue("Surface type", surface.surface_extension.name); + } else { + p.ArrayStart("Surface types", surface_types.size()); + for (auto &name : surface_types) { + p.PrintElement(name); + } + p.ArrayEnd(); + } DumpSurfaceFormats(p, inst, surface); @@ -166,14 +174,43 @@ void DumpSurface(Printer &p, AppInstance &inst, AppGpu &gpu, AppSurface &surface p.AddNewline(); } -void DumpPresentableSurfaces(Printer &p, AppInstance &inst, std::vector<AppGpu *> &gpus, std::vector<AppSurface *> &surfaces) { +struct SurfaceTypeGroup { + AppSurface *surface; + std::vector<std::string> surface_types; + AppGpu *gpu; +}; + +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; +} + +void DumpPresentableSurfaces(Printer &p, AppInstance &inst, const std::vector<std::unique_ptr<AppGpu>> &gpus, + const std::vector<std::unique_ptr<AppSurface>> &surfaces) { p.SetHeader().ObjectStart("Presentable Surfaces"); p.IndentDecrease(); + std::vector<SurfaceTypeGroup> surface_list; + for (auto &surface : surfaces) { for (auto &gpu : gpus) { - DumpSurface(p, inst, *gpu, *surface); + auto exists = surface_list.end(); + for (auto it = surface_list.begin(); it != surface_list.end(); it++) { + // use custom comparator to check if the surface has the same values + if (it->gpu == gpu.get() && *it->surface == *surface.get()) { + exists = it; + } + } + if (exists != surface_list.end()) { + exists->surface_types.push_back(surface.get()->surface_extension.name); + } else { + surface_list.push_back({surface.get(), {surface.get()->surface_extension.name}, gpu.get()}); + } } } + for (auto &group : surface_list) { + DumpSurface(p, inst, *group.gpu, *group.surface, group.surface_types); + } p.IndentIncrease(); p.ObjectEnd(); p.AddNewline(); @@ -671,34 +708,31 @@ int main(int argc, char **argv) { auto pNext_chains = get_chain_infos(); - auto gpu_holder = FindGpus(instance, pNext_chains); + auto phys_devices = instance.FindPhysicalDevices(); - std::vector<AppGpu *> gpus; - for (auto &gpu : gpu_holder) { - gpus.push_back(gpu.get()); - } - - if (selected_gpu >= gpus.size()) { - selected_gpu = 0; - } - - std::vector<std::unique_ptr<AppSurface>> surfaces_holder; + std::vector<std::unique_ptr<AppSurface>> surfaces; #if defined(VK_USE_PLATFORM_XCB_KHR) || defined(VK_USE_PLATFORM_XLIB_KHR) || defined(VK_USE_PLATFORM_WIN32_KHR) || \ defined(VK_USE_PLATFORM_MACOS_MVK) || defined(VK_USE_PLATFORM_WAYLAND_KHR) for (auto &surface_extension : instance.surface_extensions) { surface_extension.create_window(instance); surface_extension.surface = surface_extension.create_surface(instance); - for (auto &gpu : gpus) { - surfaces_holder.push_back( - std::unique_ptr<AppSurface>(new AppSurface(instance, gpu, surface_extension, pNext_chains.surface_capabilities2))); + for (auto &phys_device : phys_devices) { + surfaces.push_back(std::unique_ptr<AppSurface>( + new AppSurface(instance, phys_device, surface_extension, pNext_chains.surface_capabilities2))); } } +#endif - std::vector<AppSurface *> surfaces; - for (auto &surface : surfaces_holder) { - surfaces.push_back(surface.get()); + std::vector<std::unique_ptr<AppGpu>> gpus; + + uint32_t gpu_counter = 0; + for (auto &phys_device : phys_devices) { + gpus.push_back(std::unique_ptr<AppGpu>(new AppGpu(instance, gpu_counter++, phys_device, pNext_chains))); + } + + if (selected_gpu >= gpus.size()) { + selected_gpu = 0; } -#endif std::vector<std::unique_ptr<Printer>> printers; @@ -738,7 +772,7 @@ int main(int argc, char **argv) { for (auto &gpu : gpus) { if ((p->Type() == OutputType::json && gpu->id == selected_gpu) || p->Type() == OutputType::text || p->Type() == OutputType::html) { - DumpGpu(*p.get(), *gpu, show_formats, pNext_chains); + DumpGpu(*p.get(), *gpu.get(), show_formats, pNext_chains); } } if (p->Type() != OutputType::json) { |
