Skip to content

Commit

Permalink
Macos debug messages
Browse files Browse the repository at this point in the history
  • Loading branch information
beau-lunarg committed Jan 20, 2025
1 parent d62859e commit b81b02a
Showing 1 changed file with 30 additions and 15 deletions.
45 changes: 30 additions & 15 deletions test/test_apps/common/test_app_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ class VulkanFunctions
if (!library)
library = dlopen("libvulkan.so", RTLD_NOW | RTLD_LOCAL);
#elif defined(__APPLE__)
std::cout << "looking for apple libvulkan" << std::endl;
library = dlopen("libvulkan.dylib", RTLD_NOW | RTLD_LOCAL);
if (!library)
library = dlopen("libvulkan.1.dylib", RTLD_NOW | RTLD_LOCAL);
Expand All @@ -181,7 +182,10 @@ class VulkanFunctions
assert(false && "Unsupported platform");
#endif
if (!library)
{
std::cout << "did not find libvulkan" << std::endl;
return false;
}
load_func(ptr_vkGetInstanceProcAddr, "vkGetInstanceProcAddr");
return ptr_vkGetInstanceProcAddr != nullptr;
}
Expand Down Expand Up @@ -821,9 +825,11 @@ Instance InstanceBuilder::build() const
};
bool khr_surface_added = check_add_window_ext("VK_KHR_surface");
bool added_window_exts = false;
if (std::getenv("GFXRECON_TESTAPP_HEADLESS") != nullptr) {
if (std::getenv("GFXRECON_TESTAPP_HEADLESS") != nullptr)
{
added_window_exts = check_add_window_ext("VK_EXT_headless_surface");
} else
}
else
{
#if defined(_WIN32)
added_window_exts = check_add_window_ext("VK_KHR_win32_surface");
Expand All @@ -834,8 +840,8 @@ Instance InstanceBuilder::build() const
#elif defined(__linux__)
// make sure all three calls to check_add_window_ext, don't allow short circuiting
added_window_exts = check_add_window_ext("VK_KHR_xcb_surface");
added_window_exts = check_add_window_ext("VK_KHR_xlib_surface") || added_window_exts;
added_window_exts = check_add_window_ext("VK_KHR_wayland_surface") || added_window_exts;
added_window_exts = check_add_window_ext("VK_KHR_xlib_surface") || added_window_exts;
added_window_exts = check_add_window_ext("VK_KHR_wayland_surface") || added_window_exts;
#elif defined(__APPLE__)
added_window_exts = check_add_window_ext("VK_EXT_metal_surface");
#endif
Expand Down Expand Up @@ -2714,12 +2720,14 @@ VkSurfaceKHR create_surface_sdl(VkInstance instance, SDL_Window* window, VkAlloc
return surface;
}

VkSurfaceKHR create_surface_headless(VkInstance instance, vkb::InstanceDispatchTable& disp, VkAllocationCallbacks* callbacks)
VkSurfaceKHR
create_surface_headless(VkInstance instance, vkb::InstanceDispatchTable& disp, VkAllocationCallbacks* callbacks)
{
VkSurfaceKHR surface = VK_NULL_HANDLE;
VkSurfaceKHR surface = VK_NULL_HANDLE;
VkHeadlessSurfaceCreateInfoEXT create_info{};
create_info.sType = VK_STRUCTURE_TYPE_HEADLESS_SURFACE_CREATE_INFO_EXT;
VERIFY_VK_RESULT("failed to create headless surface", disp.createHeadlessSurfaceEXT(&create_info, callbacks, &surface));
VERIFY_VK_RESULT("failed to create headless surface",
disp.createHeadlessSurfaceEXT(&create_info, callbacks, &surface));
return surface;
}

Expand Down Expand Up @@ -2842,7 +2850,9 @@ void device_initialization_phase_2(InstanceBuilder const& instance_builder, Init
if (std::getenv("GFXRECON_TESTAPP_HEADLESS") == nullptr)
{
init.surface = create_surface_sdl(init.instance, init.window);
} else {
}
else
{
init.surface = create_surface_headless(init.instance, init.inst_disp);
}
}
Expand Down Expand Up @@ -2870,27 +2880,31 @@ void device_initialization_phase_5(SwapchainBuilder& swapchain_builder, InitInfo
static vkmock::TestConfig* try_load_test_config()
{
char const* mock_icd_location = std::getenv("GFXRECON_TESTAPP_MOCK_ICD");
if (mock_icd_location == nullptr) {
if (mock_icd_location == nullptr)
{
return nullptr;
}
#if defined(__linux__) || defined(__APPLE__)
auto library = dlopen(mock_icd_location, RTLD_NOW | RTLD_LOCAL);
if (library == nullptr) {
auto library = dlopen(mock_icd_location, RTLD_NOW | RTLD_LOCAL);
if (library == nullptr)
{
return nullptr;
}
PFN_mockICD_getTestConfig getTestConfig =
reinterpret_cast<PFN_mockICD_getTestConfig>(dlsym(library, "mockICD_getTestConfig"));
#elif defined(_WIN32)
auto module = LoadLibrary(TEXT(mock_icd_location));
if (module == nullptr) {
auto module = LoadLibrary(TEXT(mock_icd_location));
if (module == nullptr)
{
return nullptr;
}
PFN_mockICD_getTestConfig getTestConfig =
reinterpret_cast<PFN_mockICD_getTestConfig>(GetProcAddress(module, "mockICD_getTestConfig"));
#else
static_assert(false && "Unsupported platform");
#endif
if (getTestConfig == nullptr) {
if (getTestConfig == nullptr)
{
return nullptr;
}
return getTestConfig();
Expand Down Expand Up @@ -2927,7 +2941,8 @@ void cleanup_init(InitInfo& init)
destroy_device(init.device);
destroy_surface(init.instance, init.surface);
destroy_instance(init.instance);
if (init.window != nullptr) destroy_window_sdl(init.window);
if (init.window != nullptr)
destroy_window_sdl(init.window);
}

void recreate_init_swapchain(SwapchainBuilder& swapchain_builder, InitInfo& init, bool wait_for_idle)
Expand Down

0 comments on commit b81b02a

Please sign in to comment.