Skip to content

Commit

Permalink
vulkaninfo: Use volk for function loading
Browse files Browse the repository at this point in the history
Make use of the volk library to fascilitate function loading.
  • Loading branch information
charles-lunarg committed Jan 12, 2024
1 parent af30c33 commit e156996
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 311 deletions.
1 change: 1 addition & 0 deletions vulkaninfo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ endif()
target_link_libraries(vulkaninfo PRIVATE
Vulkan::Headers
${CMAKE_DL_LIBS}
volk::volk_headers
)

if(WIN32)
Expand Down
14 changes: 6 additions & 8 deletions vulkaninfo/vulkaninfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,16 +194,15 @@ void DumpSurfaceCapabilities(Printer &p, AppInstance &inst, AppGpu &gpu, AppSurf
surface_caps2.sType = VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES_2_KHR;
surface_caps2.pNext = &SurfacePresentScalingCapabilitiesEXT;

VkResult err =
inst.ext_funcs.vkGetPhysicalDeviceSurfaceCapabilities2KHR(gpu.phys_device, &surface_info, &surface_caps2);
VkResult err = vkGetPhysicalDeviceSurfaceCapabilities2KHR(gpu.phys_device, &surface_info, &surface_caps2);
if (err != VK_SUCCESS) {
continue;
}

std::vector<VkPresentModeKHR> compatible_present_modes{SurfacePresentModeCompatibilityEXT.presentModeCount};
SurfacePresentModeCompatibilityEXT.pPresentModes = compatible_present_modes.data();

err = inst.ext_funcs.vkGetPhysicalDeviceSurfaceCapabilities2KHR(gpu.phys_device, &surface_info, &surface_caps2);
err = vkGetPhysicalDeviceSurfaceCapabilities2KHR(gpu.phys_device, &surface_info, &surface_caps2);

if (err == VK_SUCCESS) {
ObjectWrapper present_mode_obj(p, VkPresentModeKHRString(mode));
Expand Down Expand Up @@ -355,12 +354,12 @@ void GetAndDumpHostImageCopyPropertiesEXT(Printer &p, AppGpu &gpu) {
VkPhysicalDeviceProperties2KHR props2{};
props2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2_KHR;
props2.pNext = static_cast<void *>(&host_image_copy_properties_ext);
gpu.inst.ext_funcs.vkGetPhysicalDeviceProperties2KHR(gpu.phys_device, &props2);
vkGetPhysicalDeviceProperties2KHR(gpu.phys_device, &props2);
std::vector<VkImageLayout> src_layouts(host_image_copy_properties_ext.copySrcLayoutCount);
host_image_copy_properties_ext.pCopySrcLayouts = src_layouts.data();
std::vector<VkImageLayout> dst_layouts(host_image_copy_properties_ext.copyDstLayoutCount);
host_image_copy_properties_ext.pCopyDstLayouts = dst_layouts.data();
gpu.inst.ext_funcs.vkGetPhysicalDeviceProperties2KHR(gpu.phys_device, &props2);
vkGetPhysicalDeviceProperties2KHR(gpu.phys_device, &props2);
DumpVkPhysicalDeviceHostImageCopyPropertiesEXT(p, "VkPhysicalDeviceHostImageCopyPropertiesEXT", host_image_copy_properties_ext);
}

Expand Down Expand Up @@ -722,7 +721,7 @@ void DumpGpuProfileCapabilities(Printer &p, AppGpu &gpu) {
format_props2.formatProperties = formats.props;
std::unique_ptr<format_properties2_chain> chain_for_format_props2;
setup_format_properties2_chain(format_props2, chain_for_format_props2, gpu);
gpu.inst.ext_funcs.vkGetPhysicalDeviceFormatProperties2KHR(gpu.phys_device, fmt, &format_props2);
vkGetPhysicalDeviceFormatProperties2KHR(gpu.phys_device, fmt, &format_props2);
chain_iterator_format_properties2(p, gpu, format_props2.pNext);
}
already_printed_formats.insert(fmt);
Expand Down Expand Up @@ -1191,8 +1190,7 @@ int main(int argc, char **argv) {
try {
// check if the surface is supported by the physical device before adding it to the list
VkBool32 supported = VK_FALSE;
VkResult err = instance.ext_funcs.vkGetPhysicalDeviceSurfaceSupportKHR(gpu->phys_device, 0,
surface_extension.surface, &supported);
VkResult err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu->phys_device, 0, surface_extension.surface, &supported);
if (err != VK_SUCCESS || supported == VK_FALSE) continue;

surfaces.push_back(
Expand Down
Loading

0 comments on commit e156996

Please sign in to comment.