Skip to content

Commit

Permalink
vulkaninfo: Correctly query per-surface queue support
Browse files Browse the repository at this point in the history
The previous implementation did not differentiate when a single queue
supported a specific surface. It will now print 'true' if all surfaces
support presentation with a queue, 'false' if none, and otherwise prints
each surface type's support if they aren't uniform in value.

This makes the info regarding which queue supports presentation on a
surface much easier to validate the correctness of.
  • Loading branch information
charles-lunarg committed Sep 27, 2024
1 parent 961b9e7 commit 1626752
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
14 changes: 8 additions & 6 deletions vulkaninfo/vulkaninfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,17 +396,19 @@ void GpuDumpQueueProps(Printer &p, AppGpu &gpu, const AppQueueFamilyProperties &
p.PrintKeyString("queueFlags", VkQueueFlagsString(props.queueFlags));
p.PrintKeyValue("timestampValidBits", props.timestampValidBits);

if (queue.is_present_platform_agnostic) {
p.PrintKeyString("present support", queue.platforms_support_present ? "true" : "false");
if (!queue.can_present) {
p.PrintKeyString("present support", "false");
} else if (queue.can_always_present) {
p.PrintKeyString("present support", "true");
} else {
size_t width = 0;
for (auto &surface : gpu.inst.surface_extensions) {
if (surface.name.size() > width) width = surface.name.size();
for (const auto &support : queue.present_support) {
if (support.first.size() > width) width = support.first.size();
}
ObjectWrapper obj_present_support(p, "present support");
p.SetMinKeyWidth(width);
for (auto &surface : gpu.inst.surface_extensions) {
p.PrintKeyString(surface.name, surface.supports_present ? "true" : "false");
for (const auto &support : queue.present_support) {
p.PrintKeyString(support.first, support.second ? "true" : "false");
}
}
chain_iterator_queue_properties2(p, gpu, queue.pNext);
Expand Down
24 changes: 11 additions & 13 deletions vulkaninfo/vulkaninfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,8 @@ struct SurfaceExtension {
VkSurfaceKHR (*create_surface)(AppInstance &) = nullptr;
void (*destroy_window)(AppInstance &) = nullptr;
VkSurfaceKHR surface = VK_NULL_HANDLE;
VkBool32 supports_present = 0;

bool operator==(const SurfaceExtension &other) {
return name == other.name && surface == other.surface && supports_present == other.supports_present;
}
bool operator==(const SurfaceExtension &other) { return name == other.name && surface == other.surface; }
};

class APIVersion {
Expand Down Expand Up @@ -1398,21 +1395,22 @@ struct AppQueueFamilyProperties {
VkQueueFamilyProperties props;
uint32_t queue_index;
void *pNext = nullptr; // assumes the lifetime of the pNext chain outlives this object, eg parent object must keep both alive
bool is_present_platform_agnostic = true;
VkBool32 platforms_support_present = VK_FALSE;
bool can_present = false;
bool can_always_present = true;
std::vector<std::pair<std::string, VkBool32>> present_support;
AppQueueFamilyProperties(AppInstance &inst, VkPhysicalDevice physical_device, VkQueueFamilyProperties family_properties,
uint32_t queue_index, void *pNext = nullptr)
: props(family_properties), queue_index(queue_index), pNext(pNext) {
for (auto &surface_ext : inst.surface_extensions) {
for (const auto &surface_ext : inst.surface_extensions) {
present_support.push_back({surface_ext.name, VK_FALSE});
VkResult err = vkGetPhysicalDeviceSurfaceSupportKHR(physical_device, queue_index, surface_ext.surface,
&surface_ext.supports_present);
&present_support.back().second);
if (err) THROW_VK_ERR("vkGetPhysicalDeviceSurfaceSupportKHR", err);

const bool first = (surface_ext == inst.surface_extensions.at(0));
if (!first && platforms_support_present != surface_ext.supports_present) {
is_present_platform_agnostic = false;
if (present_support.back().second) {
can_present = true;
} else {
can_always_present = false;
}
platforms_support_present = surface_ext.supports_present;
}
}
};
Expand Down

0 comments on commit 1626752

Please sign in to comment.