From 85dbd823c410a2817b077e2c6d1ee0cda7e247dd Mon Sep 17 00:00:00 2001 From: Mark Lobodzinski Date: Thu, 26 Jan 2017 13:34:13 -0700 Subject: [PATCH] repo: Clang-format LVL source files using Google Switch clang-format standard from the LLVM style to the Google style for more consistency. Change-Id: I247c4abc275d7873a91522e1e234198adaa24033 --- common/android_util.cpp | 8 +- common/vulkan_wrapper.cpp | 3 +- common/vulkan_wrapper.h | 2 +- demos/cube.c | 67 +- demos/cube.cpp | 500 +++--- demos/linmath.h | 81 +- demos/smoke/Game.h | 8 +- demos/smoke/Helpers.h | 4 +- demos/smoke/Main.cpp | 4 +- demos/smoke/Meshes.cpp | 41 +- demos/smoke/Meshes.h | 6 +- demos/smoke/Shell.cpp | 51 +- demos/smoke/Shell.h | 8 +- demos/smoke/ShellAndroid.cpp | 105 +- demos/smoke/ShellAndroid.h | 6 +- demos/smoke/ShellWayland.cpp | 72 +- demos/smoke/ShellWayland.h | 6 +- demos/smoke/ShellWin32.cpp | 81 +- demos/smoke/ShellWin32.h | 9 +- demos/smoke/ShellXcb.cpp | 100 +- demos/smoke/ShellXcb.h | 6 +- demos/smoke/Simulation.cpp | 85 +- demos/smoke/Simulation.h | 14 +- demos/smoke/Smoke.cpp | 113 +- demos/smoke/Smoke.h | 10 +- demos/vulkaninfo.c | 118 +- layers/buffer_validation.h | 2 +- layers/core_validation.cpp | 3236 ++++++++++++++++------------------ layers/core_validation.h | 61 +- layers/core_validation_error_enums.h | 2 +- layers/core_validation_types.h | 155 +- layers/descriptor_sets.cpp | 670 ++++--- layers/descriptor_sets.h | 42 +- layers/image.cpp | 154 +- layers/image.h | 57 +- layers/object_tracker.cpp | 577 +++--- layers/object_tracker.h | 120 +- layers/parameter_name.h | 14 +- layers/parameter_validation.cpp | 168 +- layers/parameter_validation_utils.h | 87 +- layers/swapchain.cpp | 72 +- layers/swapchain.h | 84 +- layers/threading.cpp | 55 +- layers/threading.h | 53 +- layers/unique_objects.cpp | 9 +- layers/unique_objects.h | 9 +- layers/vk_layer_config.cpp | 24 +- layers/vk_layer_data.h | 5 +- layers/vk_layer_extension_utils.h | 4 +- layers/vk_layer_logging.h | 18 +- layers/vk_layer_utils.cpp | 645 ++++--- layers/vk_layer_utils.h | 4 +- loader/cJSON.c | 604 +++---- loader/debug_report.c | 3 +- loader/dev_ext_trampoline.c | 2 +- loader/extensions.c | 6 +- loader/gpa_helper.h | 432 ++--- loader/loader.c | 815 +++++---- loader/loader.h | 33 +- loader/murmurhash.c | 32 +- loader/phys_dev_ext.c | 32 +- loader/table_ops.h | 496 ++---- loader/trampoline.c | 60 +- loader/vk_loader_platform.h | 25 +- loader/wsi.c | 193 +- loader/wsi.h | 18 +- 66 files changed, 4908 insertions(+), 5678 deletions(-) diff --git a/common/android_util.cpp b/common/android_util.cpp index 772df06..1480f44 100644 --- a/common/android_util.cpp +++ b/common/android_util.cpp @@ -31,8 +31,7 @@ char **get_args(struct android_app *app, const char *intent_extra_data_key, cons std::vector args; JavaVM &vm = *app->activity->vm; JNIEnv *p_env; - if (vm.AttachCurrentThread(&p_env, nullptr) != JNI_OK) - return nullptr; + if (vm.AttachCurrentThread(&p_env, nullptr) != JNI_OK) return nullptr; JNIEnv &env = *p_env; jobject activity = app->activity->clazz; @@ -60,8 +59,7 @@ char **get_args(struct android_app *app, const char *intent_extra_data_key, cons std::stringstream ss(args_str); std::string arg; while (std::getline(ss, arg, ' ')) { - if (!arg.empty()) - args.push_back(arg); + if (!arg.empty()) args.push_back(arg); } // Convert our STL results to C friendly constructs @@ -81,4 +79,4 @@ char **get_args(struct android_app *app, const char *intent_extra_data_key, cons return vector; } -} // extern "C" +} // extern "C" diff --git a/common/vulkan_wrapper.cpp b/common/vulkan_wrapper.cpp index a3d517e..2f7d806 100644 --- a/common/vulkan_wrapper.cpp +++ b/common/vulkan_wrapper.cpp @@ -23,8 +23,7 @@ extern "C" { int InitVulkan(void) { void *libvulkan = dlopen("libvulkan.so", RTLD_NOW | RTLD_LOCAL); - if (!libvulkan) - return 0; + if (!libvulkan) return 0; // Vulkan supported, set function addresses vkCreateInstance = reinterpret_cast(dlsym(libvulkan, "vkCreateInstance")); diff --git a/common/vulkan_wrapper.h b/common/vulkan_wrapper.h index bf08766..679278f 100644 --- a/common/vulkan_wrapper.h +++ b/common/vulkan_wrapper.h @@ -235,4 +235,4 @@ extern PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR vkGetPhysicalDeviceWin } #endif -#endif // VULKAN_WRAPPER_H +#endif // VULKAN_WRAPPER_H diff --git a/demos/cube.c b/demos/cube.c index 8379184..49fd9e7 100644 --- a/demos/cube.c +++ b/demos/cube.c @@ -37,7 +37,7 @@ #ifdef _WIN32 #pragma comment(linker, "/subsystem:windows") #define APP_NAME_STR_LEN 80 -#endif // _WIN32 +#endif // _WIN32 #if defined(VK_USE_PLATFORM_MIR_KHR) #warning "Cube does not have code for Mir at this time" @@ -75,47 +75,45 @@ #ifdef _WIN32 bool in_callback = false; -#define ERR_EXIT(err_msg, err_class) \ - do { \ - if (!demo->suppress_popups) \ - MessageBox(NULL, err_msg, err_class, MB_OK); \ - exit(1); \ +#define ERR_EXIT(err_msg, err_class) \ + do { \ + if (!demo->suppress_popups) MessageBox(NULL, err_msg, err_class, MB_OK); \ + exit(1); \ } while (0) #elif defined __ANDROID__ #include -#define ERR_EXIT(err_msg, err_class) \ - do { \ - ((void)__android_log_print(ANDROID_LOG_INFO, "Cube", err_msg)); \ - exit(1); \ +#define ERR_EXIT(err_msg, err_class) \ + do { \ + ((void)__android_log_print(ANDROID_LOG_INFO, "Cube", err_msg)); \ + exit(1); \ } while (0) #else -#define ERR_EXIT(err_msg, err_class) \ - do { \ - printf(err_msg); \ - fflush(stdout); \ - exit(1); \ +#define ERR_EXIT(err_msg, err_class) \ + do { \ + printf(err_msg); \ + fflush(stdout); \ + exit(1); \ } while (0) #endif -#define GET_INSTANCE_PROC_ADDR(inst, entrypoint) \ - { \ - demo->fp##entrypoint = (PFN_vk##entrypoint)vkGetInstanceProcAddr(inst, "vk" #entrypoint); \ - if (demo->fp##entrypoint == NULL) { \ - ERR_EXIT("vkGetInstanceProcAddr failed to find vk" #entrypoint, "vkGetInstanceProcAddr Failure"); \ - } \ +#define GET_INSTANCE_PROC_ADDR(inst, entrypoint) \ + { \ + demo->fp##entrypoint = (PFN_vk##entrypoint)vkGetInstanceProcAddr(inst, "vk" #entrypoint); \ + if (demo->fp##entrypoint == NULL) { \ + ERR_EXIT("vkGetInstanceProcAddr failed to find vk" #entrypoint, "vkGetInstanceProcAddr Failure"); \ + } \ } static PFN_vkGetDeviceProcAddr g_gdpa = NULL; -#define GET_DEVICE_PROC_ADDR(dev, entrypoint) \ - { \ - if (!g_gdpa) \ - g_gdpa = (PFN_vkGetDeviceProcAddr)vkGetInstanceProcAddr(demo->inst, "vkGetDeviceProcAddr"); \ - demo->fp##entrypoint = (PFN_vk##entrypoint)g_gdpa(dev, "vk" #entrypoint); \ - if (demo->fp##entrypoint == NULL) { \ - ERR_EXIT("vkGetDeviceProcAddr failed to find vk" #entrypoint, "vkGetDeviceProcAddr Failure"); \ - } \ +#define GET_DEVICE_PROC_ADDR(dev, entrypoint) \ + { \ + if (!g_gdpa) g_gdpa = (PFN_vkGetDeviceProcAddr)vkGetInstanceProcAddr(demo->inst, "vkGetDeviceProcAddr"); \ + demo->fp##entrypoint = (PFN_vk##entrypoint)g_gdpa(dev, "vk" #entrypoint); \ + if (demo->fp##entrypoint == NULL) { \ + ERR_EXIT("vkGetDeviceProcAddr failed to find vk" #entrypoint, "vkGetDeviceProcAddr Failure"); \ + } \ } /* @@ -282,10 +280,10 @@ typedef struct { struct demo { #if defined(VK_USE_PLATFORM_WIN32_KHR) #define APP_NAME_STR_LEN 80 - HINSTANCE connection; // hInstance - Windows Instance - char name[APP_NAME_STR_LEN]; // Name to put on the window/icon - HWND window; // hWnd - window handle - POINT minsize; // minimum window size + HINSTANCE connection; // hInstance - Windows Instance + char name[APP_NAME_STR_LEN]; // Name to put on the window/icon + HWND window; // hWnd - window handle + POINT minsize; // minimum window size #elif defined(VK_USE_PLATFORM_XLIB_KHR) Display *display; Window xlib_window; @@ -366,7 +364,7 @@ struct demo { struct texture_object textures[DEMO_TEXTURE_COUNT]; struct texture_object staging_texture; - VkCommandBuffer cmd; // Buffer for initialization commands + VkCommandBuffer cmd; // Buffer for initialization commands VkPipelineLayout pipeline_layout; VkDescriptorSetLayout desc_layout; VkPipelineCache pipelineCache; @@ -403,7 +401,6 @@ struct demo { VKAPI_ATTR VkBool32 VKAPI_CALL dbgFunc(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType, uint64_t srcObject, size_t location, int32_t msgCode, const char *pLayerPrefix, const char *pMsg, void *pUserData) { - // clang-format off char *message = (char *)malloc(strlen(pMsg) + 100); diff --git a/demos/cube.cpp b/demos/cube.cpp index 4d9c722..f607bc0 100644 --- a/demos/cube.cpp +++ b/demos/cube.cpp @@ -56,18 +56,17 @@ #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) #ifdef _WIN32 -#define ERR_EXIT(err_msg, err_class) \ - do { \ - if (!suppress_popups) \ - MessageBox(nullptr, err_msg, err_class, MB_OK); \ - exit(1); \ +#define ERR_EXIT(err_msg, err_class) \ + do { \ + if (!suppress_popups) MessageBox(nullptr, err_msg, err_class, MB_OK); \ + exit(1); \ } while (0) #else -#define ERR_EXIT(err_msg, err_class) \ - do { \ - printf(err_msg); \ - fflush(stdout); \ - exit(1); \ +#define ERR_EXIT(err_msg, err_class) \ + do { \ + printf(err_msg); \ + fflush(stdout); \ + exit(1); \ } while (0) #endif @@ -233,23 +232,49 @@ struct Demo { : #if defined(VK_USE_PLATFORM_WIN32_KHR) connection{nullptr}, - window{nullptr}, minsize(POINT{0, 0}), // Use explicit construction to avoid MSVC error C2797. + window{nullptr}, + minsize(POINT{0, 0}), // Use explicit construction to avoid MSVC error C2797. #endif #if defined(VK_USE_PLATFORM_XLIB_KHR) - xlib_window{0}, xlib_wm_delete_window{0}, display{nullptr}, + xlib_window{0}, + xlib_wm_delete_window{0}, + display{nullptr}, #elif defined(VK_USE_PLATFORM_XCB_KHR) xcb_window{0}, - screen{nullptr}, connection{nullptr}, + screen{nullptr}, + connection{nullptr}, #elif defined(VK_USE_PLATFORM_WAYLAND_KHR) display{nullptr}, - registry{nullptr}, compositor{nullptr}, window{nullptr}, shell{nullptr}, shell_surface{nullptr}, + registry{nullptr}, + compositor{nullptr}, + window{nullptr}, + shell{nullptr}, + shell_surface{nullptr}, #elif defined(VK_USE_PLATFORM_MIR_KHR) #endif - prepared{false}, use_staging_buffer{false}, use_xlib{false}, graphics_queue_family_index{0}, - present_queue_family_index{0}, enabled_extension_count{0}, enabled_layer_count{0}, width{0}, height{0}, - swapchainImageCount{0}, frame_index{0}, spin_angle{0.0f}, spin_increment{0.0f}, pause{false}, quit{false}, curFrame{0}, - frameCount{0}, validate{false}, use_break{false}, suppress_popups{false}, current_buffer{0}, queue_family_count{0} { + prepared{false}, + use_staging_buffer{false}, + use_xlib{false}, + graphics_queue_family_index{0}, + present_queue_family_index{0}, + enabled_extension_count{0}, + enabled_layer_count{0}, + width{0}, + height{0}, + swapchainImageCount{0}, + frame_index{0}, + spin_angle{0.0f}, + spin_increment{0.0f}, + pause{false}, + quit{false}, + curFrame{0}, + frameCount{0}, + validate{false}, + use_break{false}, + suppress_popups{false}, + current_buffer{0}, + queue_family_count{0} { #if defined(VK_USE_PLATFORM_WIN32_KHR) memset(name, '\0', APP_NAME_STR_LEN); #endif @@ -625,12 +650,13 @@ struct Demo { continue; } - fprintf(stderr, "Usage:\n %s [--use_staging] [--validate] [--break] " - "[--c ] [--suppress_popups] [--present_mode ]\n" - "VK_PRESENT_MODE_IMMEDIATE_KHR = %d\n" - "VK_PRESENT_MODE_MAILBOX_KHR = %d\n" - "VK_PRESENT_MODE_FIFO_KHR = %d\n" - "VK_PRESENT_MODE_FIFO_RELAXED_KHR = %d\n", + fprintf(stderr, + "Usage:\n %s [--use_staging] [--validate] [--break] " + "[--c ] [--suppress_popups] [--present_mode ]\n" + "VK_PRESENT_MODE_IMMEDIATE_KHR = %d\n" + "VK_PRESENT_MODE_MAILBOX_KHR = %d\n" + "VK_PRESENT_MODE_FIFO_KHR = %d\n" + "VK_PRESENT_MODE_FIFO_RELAXED_KHR = %d\n", APP_SHORT_NAME, VK_PRESENT_MODE_IMMEDIATE_KHR, VK_PRESENT_MODE_MAILBOX_KHR, VK_PRESENT_MODE_FIFO_KHR, VK_PRESENT_MODE_FIFO_RELAXED_KHR); fflush(stderr); @@ -654,7 +680,7 @@ struct Demo { mat4x4_look_at(view_matrix, eye, origin, up); mat4x4_identity(model_matrix); - projection_matrix[1][1] *= -1; // Flip projection matrix from GL to Vulkan orientation. + projection_matrix[1][1] *= -1; // Flip projection matrix from GL to Vulkan orientation. } void init_connection() { @@ -665,24 +691,25 @@ struct Demo { connection = xcb_connect(nullptr, &scr); if (xcb_connection_has_error(connection) > 0) { - printf("Cannot find a compatible Vulkan installable client driver " - "(ICD).\nExiting ...\n"); + printf( + "Cannot find a compatible Vulkan installable client driver " + "(ICD).\nExiting ...\n"); fflush(stdout); exit(1); } setup = xcb_get_setup(connection); iter = xcb_setup_roots_iterator(setup); - while (scr-- > 0) - xcb_screen_next(&iter); + while (scr-- > 0) xcb_screen_next(&iter); screen = iter.data; #elif defined(VK_USE_PLATFORM_WAYLAND_KHR) display = wl_display_connect(nullptr); if (display == nullptr) { - printf("Cannot find a compatible Vulkan installable client driver " - "(ICD).\nExiting ...\n"); + printf( + "Cannot find a compatible Vulkan installable client driver " + "(ICD).\nExiting ...\n"); fflush(stdout); exit(1); } @@ -741,11 +768,12 @@ struct Demo { } if (!validation_found) { - ERR_EXIT("vkEnumerateInstanceLayerProperties failed to find " - "required validation layer.\n\n" - "Please look at the Getting Started guide for " - "additional information.\n", - "vkCreateInstance Failure"); + ERR_EXIT( + "vkEnumerateInstanceLayerProperties failed to find " + "required validation layer.\n\n" + "Please look at the Getting Started guide for " + "additional information.\n", + "vkCreateInstance Failure"); } } @@ -794,49 +822,59 @@ struct Demo { } if (!surfaceExtFound) { - ERR_EXIT("vkEnumerateInstanceExtensionProperties failed to find " - "the " VK_KHR_SURFACE_EXTENSION_NAME " extension.\n\n" - "Do you have a compatible Vulkan installable client " - "driver (ICD) installed?\n" - "Please look at the Getting Started guide for additional " - "information.\n", - "vkCreateInstance Failure"); + ERR_EXIT( + "vkEnumerateInstanceExtensionProperties failed to find " + "the " VK_KHR_SURFACE_EXTENSION_NAME + " extension.\n\n" + "Do you have a compatible Vulkan installable client " + "driver (ICD) installed?\n" + "Please look at the Getting Started guide for additional " + "information.\n", + "vkCreateInstance Failure"); } if (!platformSurfaceExtFound) { #if defined(VK_USE_PLATFORM_WIN32_KHR) - ERR_EXIT("vkEnumerateInstanceExtensionProperties failed to find " - "the " VK_KHR_WIN32_SURFACE_EXTENSION_NAME " extension.\n\n" - "Do you have a compatible Vulkan installable client " - "driver (ICD) installed?\n" - "Please look at the Getting Started guide for additional " - "information.\n", - "vkCreateInstance Failure"); + ERR_EXIT( + "vkEnumerateInstanceExtensionProperties failed to find " + "the " VK_KHR_WIN32_SURFACE_EXTENSION_NAME + " extension.\n\n" + "Do you have a compatible Vulkan installable client " + "driver (ICD) installed?\n" + "Please look at the Getting Started guide for additional " + "information.\n", + "vkCreateInstance Failure"); #elif defined(VK_USE_PLATFORM_XCB_KHR) - ERR_EXIT("vkEnumerateInstanceExtensionProperties failed to find " - "the " VK_KHR_XCB_SURFACE_EXTENSION_NAME " extension.\n\n" - "Do you have a compatible Vulkan installable client " - "driver (ICD) installed?\n" - "Please look at the Getting Started guide for additional " - "information.\n", - "vkCreateInstance Failure"); + ERR_EXIT( + "vkEnumerateInstanceExtensionProperties failed to find " + "the " VK_KHR_XCB_SURFACE_EXTENSION_NAME + " extension.\n\n" + "Do you have a compatible Vulkan installable client " + "driver (ICD) installed?\n" + "Please look at the Getting Started guide for additional " + "information.\n", + "vkCreateInstance Failure"); #elif defined(VK_USE_PLATFORM_WAYLAND_KHR) - ERR_EXIT("vkEnumerateInstanceExtensionProperties failed to find " - "the " VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME " extension.\n\n" - "Do you have a compatible Vulkan installable client " - "driver (ICD) installed?\n" - "Please look at the Getting Started guide for additional " - "information.\n", - "vkCreateInstance Failure"); + ERR_EXIT( + "vkEnumerateInstanceExtensionProperties failed to find " + "the " VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME + " extension.\n\n" + "Do you have a compatible Vulkan installable client " + "driver (ICD) installed?\n" + "Please look at the Getting Started guide for additional " + "information.\n", + "vkCreateInstance Failure"); #elif defined(VK_USE_PLATFORM_MIR_KHR) #elif defined(VK_USE_PLATFORM_XLIB_KHR) - ERR_EXIT("vkEnumerateInstanceExtensionProperties failed to find " - "the " VK_KHR_XLIB_SURFACE_EXTENSION_NAME " extension.\n\n" - "Do you have a compatible Vulkan installable client " - "driver (ICD) installed?\n" - "Please look at the Getting Started guide for additional " - "information.\n", - "vkCreateInstance Failure"); + ERR_EXIT( + "vkEnumerateInstanceExtensionProperties failed to find " + "the " VK_KHR_XLIB_SURFACE_EXTENSION_NAME + " extension.\n\n" + "Do you have a compatible Vulkan installable client " + "driver (ICD) installed?\n" + "Please look at the Getting Started guide for additional " + "information.\n", + "vkCreateInstance Failure"); #endif } auto const app = vk::ApplicationInfo() @@ -854,22 +892,25 @@ struct Demo { result = vk::createInstance(&inst_info, nullptr, &inst); if (result == vk::Result::eErrorIncompatibleDriver) { - ERR_EXIT("Cannot find a compatible Vulkan installable client " - "driver (ICD).\n\n" - "Please look at the Getting Started guide for additional " - "information.\n", - "vkCreateInstance Failure"); + ERR_EXIT( + "Cannot find a compatible Vulkan installable client " + "driver (ICD).\n\n" + "Please look at the Getting Started guide for additional " + "information.\n", + "vkCreateInstance Failure"); } else if (result == vk::Result::eErrorExtensionNotPresent) { - ERR_EXIT("Cannot find a specified extension library.\n" - "Make sure your layers path is set appropriately.\n", - "vkCreateInstance Failure"); + ERR_EXIT( + "Cannot find a specified extension library.\n" + "Make sure your layers path is set appropriately.\n", + "vkCreateInstance Failure"); } else if (result != vk::Result::eSuccess) { - ERR_EXIT("vkCreateInstance failed.\n\n" - "Do you have a compatible Vulkan installable client " - "driver (ICD) installed?\n" - "Please look at the Getting Started guide for additional " - "information.\n", - "vkCreateInstance Failure"); + ERR_EXIT( + "vkCreateInstance failed.\n\n" + "Do you have a compatible Vulkan installable client " + "driver (ICD) installed?\n" + "Please look at the Getting Started guide for additional " + "information.\n", + "vkCreateInstance Failure"); } /* Make initial call to query gpu_count, then second call for gpu info*/ @@ -885,13 +926,14 @@ struct Demo { /* For cube demo we just grab the first physical device */ gpu = physical_devices[0]; } else { - ERR_EXIT("vkEnumeratePhysicalDevices reported zero accessible " - "devices.\n\n" - "Do you have a compatible Vulkan installable client " - "driver (ICD) installed?\n" - "Please look at the Getting Started guide for additional " - "information.\n", - "vkEnumeratePhysicalDevices Failure"); + ERR_EXIT( + "vkEnumeratePhysicalDevices reported zero accessible " + "devices.\n\n" + "Do you have a compatible Vulkan installable client " + "driver (ICD) installed?\n" + "Please look at the Getting Started guide for additional " + "information.\n", + "vkEnumeratePhysicalDevices Failure"); } /* Look for device extensions */ @@ -918,13 +960,15 @@ struct Demo { } if (!swapchainExtFound) { - ERR_EXIT("vkEnumerateDeviceExtensionProperties failed to find " - "the " VK_KHR_SWAPCHAIN_EXTENSION_NAME " extension.\n\n" - "Do you have a compatible Vulkan installable client " - "driver (ICD) installed?\n" - "Please look at the Getting Started guide for additional " - "information.\n", - "vkCreateInstance Failure"); + ERR_EXIT( + "vkEnumerateDeviceExtensionProperties failed to find " + "the " VK_KHR_SWAPCHAIN_EXTENSION_NAME + " extension.\n\n" + "Do you have a compatible Vulkan installable client " + "driver (ICD) installed?\n" + "Please look at the Getting Started guide for additional " + "information.\n", + "vkCreateInstance Failure"); } gpu.getProperties(&gpu_props); @@ -1333,9 +1377,9 @@ struct Demo { uniform_data.mem_alloc.setAllocationSize(mem_reqs.size); uniform_data.mem_alloc.setMemoryTypeIndex(0); - bool const pass = memory_type_from_properties(mem_reqs.memoryTypeBits, vk::MemoryPropertyFlagBits::eHostVisible | - vk::MemoryPropertyFlagBits::eHostCoherent, - &uniform_data.mem_alloc.memoryTypeIndex); + bool const pass = memory_type_from_properties( + mem_reqs.memoryTypeBits, vk::MemoryPropertyFlagBits::eHostVisible | vk::MemoryPropertyFlagBits::eHostCoherent, + &uniform_data.mem_alloc.memoryTypeIndex); VERIFY(pass); result = device.allocateMemory(&uniform_data.mem_alloc, nullptr, &(uniform_data.mem)); @@ -1892,29 +1936,29 @@ struct Demo { vk::AccessFlags flags; switch (layout) { - case vk::ImageLayout::eTransferDstOptimal: - // Make sure anything that was copying from this image has - // completed - flags = vk::AccessFlagBits::eTransferWrite; - break; - case vk::ImageLayout::eColorAttachmentOptimal: - flags = vk::AccessFlagBits::eColorAttachmentWrite; - break; - case vk::ImageLayout::eDepthStencilAttachmentOptimal: - flags = vk::AccessFlagBits::eDepthStencilAttachmentWrite; - break; - case vk::ImageLayout::eShaderReadOnlyOptimal: - // Make sure any Copy or CPU writes to image are flushed - flags = vk::AccessFlagBits::eShaderRead | vk::AccessFlagBits::eInputAttachmentRead; - break; - case vk::ImageLayout::eTransferSrcOptimal: - flags = vk::AccessFlagBits::eTransferRead; - break; - case vk::ImageLayout::ePresentSrcKHR: - flags = vk::AccessFlagBits::eMemoryRead; - break; - default: - break; + case vk::ImageLayout::eTransferDstOptimal: + // Make sure anything that was copying from this image has + // completed + flags = vk::AccessFlagBits::eTransferWrite; + break; + case vk::ImageLayout::eColorAttachmentOptimal: + flags = vk::AccessFlagBits::eColorAttachmentWrite; + break; + case vk::ImageLayout::eDepthStencilAttachmentOptimal: + flags = vk::AccessFlagBits::eDepthStencilAttachmentWrite; + break; + case vk::ImageLayout::eShaderReadOnlyOptimal: + // Make sure any Copy or CPU writes to image are flushed + flags = vk::AccessFlagBits::eShaderRead | vk::AccessFlagBits::eInputAttachmentRead; + break; + case vk::ImageLayout::eTransferSrcOptimal: + flags = vk::AccessFlagBits::eTransferRead; + break; + case vk::ImageLayout::ePresentSrcKHR: + flags = vk::AccessFlagBits::eMemoryRead; + break; + default: + break; } return flags; @@ -1960,7 +2004,7 @@ struct Demo { } char header[256]; - char *cPtr = fgets(header, 256, fPtr); // P6 + char *cPtr = fgets(header, 256, fPtr); // P6 if (cPtr == nullptr || strncmp(header, "P6\n", 3)) { fclose(fPtr); return false; @@ -1980,7 +2024,7 @@ struct Demo { return true; } - char *result = fgets(header, 256, fPtr); // Format + char *result = fgets(header, 256, fPtr); // Format VERIFY(result != nullptr); if (cPtr == nullptr || strncmp(header, "255\n", 3)) { fclose(fPtr); @@ -2045,7 +2089,7 @@ struct Demo { win_class.lpfnWndProc = WndProc; win_class.cbClsExtra = 0; win_class.cbWndExtra = 0; - win_class.hInstance = connection; // hInstance + win_class.hInstance = connection; // hInstance win_class.hIcon = LoadIcon(nullptr, IDI_APPLICATION); win_class.hCursor = LoadCursor(nullptr, IDC_ARROW); win_class.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); @@ -2065,17 +2109,17 @@ struct Demo { RECT wr = {0, 0, static_cast(width), static_cast(height)}; AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, FALSE); window = CreateWindowEx(0, - name, // class name - name, // app name - WS_OVERLAPPEDWINDOW | // window style + name, // class name + name, // app name + WS_OVERLAPPEDWINDOW | // window style WS_VISIBLE | WS_SYSMENU, - 100, 100, // x/y coords - wr.right - wr.left, // width - wr.bottom - wr.top, // height - nullptr, // handle to parent - nullptr, // handle to menu - connection, // hInstance - nullptr); // no extra parameters + 100, 100, // x/y coords + wr.right - wr.left, // width + wr.bottom - wr.top, // height + nullptr, // handle to parent + nullptr, // handle to menu + connection, // hInstance + nullptr); // no extra parameters if (!window) { // It didn't work, so try to give a useful error: @@ -2119,36 +2163,36 @@ struct Demo { void handle_xlib_event(const XEvent *event) { switch (event->type) { - case ClientMessage: - if ((Atom)event->xclient.data.l[0] == xlib_wm_delete_window) { - quit = true; - } - break; - case KeyPress: - switch (event->xkey.keycode) { - case 0x9: // Escape - quit = true; + case ClientMessage: + if ((Atom)event->xclient.data.l[0] == xlib_wm_delete_window) { + quit = true; + } break; - case 0x71: // left arrow key - spin_angle -= spin_increment; + case KeyPress: + switch (event->xkey.keycode) { + case 0x9: // Escape + quit = true; + break; + case 0x71: // left arrow key + spin_angle -= spin_increment; + break; + case 0x72: // right arrow key + spin_angle += spin_increment; + break; + case 0x41: // space bar + pause = !pause; + break; + } break; - case 0x72: // right arrow key - spin_angle += spin_increment; + case ConfigureNotify: + if (((int32_t)width != event->xconfigure.width) || ((int32_t)height != event->xconfigure.height)) { + width = event->xconfigure.width; + height = event->xconfigure.height; + resize(); + } break; - case 0x41: // space bar - pause = !pause; + default: break; - } - break; - case ConfigureNotify: - if (((int32_t)width != event->xconfigure.width) || ((int32_t)height != event->xconfigure.height)) { - width = event->xconfigure.width; - height = event->xconfigure.height; - resize(); - } - break; - default: - break; } } @@ -2179,42 +2223,42 @@ struct Demo { void handle_xcb_event(const xcb_generic_event_t *event) { uint8_t event_code = event->response_type & 0x7f; switch (event_code) { - case XCB_EXPOSE: - // TODO: Resize window - break; - case XCB_CLIENT_MESSAGE: - if ((*(xcb_client_message_event_t *)event).data.data32[0] == (*atom_wm_delete_window).atom) { - quit = true; - } - break; - case XCB_KEY_RELEASE: { - const xcb_key_release_event_t *key = (const xcb_key_release_event_t *)event; - - switch (key->detail) { - case 0x9: // Escape - quit = true; + case XCB_EXPOSE: + // TODO: Resize window break; - case 0x71: // left arrow key - spin_angle -= spin_increment; - break; - case 0x72: // right arrow key - spin_angle += spin_increment; + case XCB_CLIENT_MESSAGE: + if ((*(xcb_client_message_event_t *)event).data.data32[0] == (*atom_wm_delete_window).atom) { + quit = true; + } break; - case 0x41: // space bar - pause = !pause; + case XCB_KEY_RELEASE: { + const xcb_key_release_event_t *key = (const xcb_key_release_event_t *)event; + + switch (key->detail) { + case 0x9: // Escape + quit = true; + break; + case 0x71: // left arrow key + spin_angle -= spin_increment; + break; + case 0x72: // right arrow key + spin_angle += spin_increment; + break; + case 0x41: // space bar + pause = !pause; + break; + } + } break; + case XCB_CONFIGURE_NOTIFY: { + const xcb_configure_notify_event_t *cfg = (const xcb_configure_notify_event_t *)event; + if ((width != cfg->width) || (height != cfg->height)) { + width = cfg->width; + height = cfg->height; + resize(); + } + } break; + default: break; - } - } break; - case XCB_CONFIGURE_NOTIFY: { - const xcb_configure_notify_event_t *cfg = (const xcb_configure_notify_event_t *)event; - if ((width != cfg->width) || (height != cfg->height)) { - width = cfg->width; - height = cfg->height; - resize(); - } - } break; - default: - break; } } @@ -2311,10 +2355,10 @@ struct Demo { #endif #if defined(VK_USE_PLATFORM_WIN32_KHR) - HINSTANCE connection; // hInstance - Windows Instance - HWND window; // hWnd - window handle - POINT minsize; // minimum window size - char name[APP_NAME_STR_LEN]; // Name to put on the window/icon + HINSTANCE connection; // hInstance - Windows Instance + HWND window; // hWnd - window handle + POINT minsize; // minimum window size + char name[APP_NAME_STR_LEN]; // Name to put on the window/icon #elif defined(VK_USE_PLATFORM_XLIB_KHR) Window xlib_window; Atom xlib_wm_delete_window; @@ -2393,7 +2437,7 @@ struct Demo { vk::DescriptorBufferInfo buffer_info; } uniform_data; - vk::CommandBuffer cmd; // Buffer for initialization commands + vk::CommandBuffer cmd; // Buffer for initialization commands vk::PipelineLayout pipeline_layout; vk::DescriptorSetLayout desc_layout; vk::PipelineCache pipelineCache; @@ -2436,27 +2480,27 @@ Demo demo; // MS-Windows event handling function: LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { - case WM_CLOSE: - PostQuitMessage(validation_error); - break; - case WM_PAINT: - demo.run(); - break; - case WM_GETMINMAXINFO: // set window's minimum size - ((MINMAXINFO *)lParam)->ptMinTrackSize = demo.minsize; - return 0; - case WM_SIZE: - // Resize the application to the new window size, except when - // it was minimized. Vulkan doesn't support images or swapchains - // with width=0 and height=0. - if (wParam != SIZE_MINIMIZED) { - demo.width = lParam & 0xffff; - demo.height = (lParam & 0xffff0000) >> 16; - demo.resize(); - } - break; - default: - break; + case WM_CLOSE: + PostQuitMessage(validation_error); + break; + case WM_PAINT: + demo.run(); + break; + case WM_GETMINMAXINFO: // set window's minimum size + ((MINMAXINFO *)lParam)->ptMinTrackSize = demo.minsize; + return 0; + case WM_SIZE: + // Resize the application to the new window size, except when + // it was minimized. Vulkan doesn't support images or swapchains + // with width=0 and height=0. + if (wParam != SIZE_MINIMIZED) { + demo.width = lParam & 0xffff; + demo.height = (lParam & 0xffff0000) >> 16; + demo.resize(); + } + break; + default: + break; } return (DefWindowProc(hWnd, uMsg, wParam, lParam)); @@ -2464,8 +2508,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pCmdLine, int nCmdShow) { // TODO: Gah.. refactor. This isn't 1989. - MSG msg; // message - bool done; // flag saying when app is complete + MSG msg; // message + bool done; // flag saying when app is complete int argc; char **argv; @@ -2518,14 +2562,14 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pCmdLine, demo.prepare(); - done = false; // initialize loop condition variable + done = false; // initialize loop condition variable // main message loop while (!done) { PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE); - if (msg.message == WM_QUIT) // check for a quit message + if (msg.message == WM_QUIT) // check for a quit message { - done = true; // if found, quit app + done = true; // if found, quit app } else { /* Translate and dispatch to event queue*/ TranslateMessage(&msg); diff --git a/demos/linmath.h b/demos/linmath.h index a36b188..b4d386c 100644 --- a/demos/linmath.h +++ b/demos/linmath.h @@ -32,24 +32,20 @@ typedef float vec3[3]; static inline void vec3_add(vec3 r, vec3 const a, vec3 const b) { int i; - for (i = 0; i < 3; ++i) - r[i] = a[i] + b[i]; + for (i = 0; i < 3; ++i) r[i] = a[i] + b[i]; } static inline void vec3_sub(vec3 r, vec3 const a, vec3 const b) { int i; - for (i = 0; i < 3; ++i) - r[i] = a[i] - b[i]; + for (i = 0; i < 3; ++i) r[i] = a[i] - b[i]; } static inline void vec3_scale(vec3 r, vec3 const v, float const s) { int i; - for (i = 0; i < 3; ++i) - r[i] = v[i] * s; + for (i = 0; i < 3; ++i) r[i] = v[i] * s; } static inline float vec3_mul_inner(vec3 const a, vec3 const b) { float p = 0.f; int i; - for (i = 0; i < 3; ++i) - p += b[i] * a[i]; + for (i = 0; i < 3; ++i) p += b[i] * a[i]; return p; } static inline void vec3_mul_cross(vec3 r, vec3 const a, vec3 const b) { @@ -65,31 +61,26 @@ static inline void vec3_norm(vec3 r, vec3 const v) { static inline void vec3_reflect(vec3 r, vec3 const v, vec3 const n) { float p = 2.f * vec3_mul_inner(v, n); int i; - for (i = 0; i < 3; ++i) - r[i] = v[i] - p * n[i]; + for (i = 0; i < 3; ++i) r[i] = v[i] - p * n[i]; } typedef float vec4[4]; static inline void vec4_add(vec4 r, vec4 const a, vec4 const b) { int i; - for (i = 0; i < 4; ++i) - r[i] = a[i] + b[i]; + for (i = 0; i < 4; ++i) r[i] = a[i] + b[i]; } static inline void vec4_sub(vec4 r, vec4 const a, vec4 const b) { int i; - for (i = 0; i < 4; ++i) - r[i] = a[i] - b[i]; + for (i = 0; i < 4; ++i) r[i] = a[i] - b[i]; } static inline void vec4_scale(vec4 r, vec4 v, float s) { int i; - for (i = 0; i < 4; ++i) - r[i] = v[i] * s; + for (i = 0; i < 4; ++i) r[i] = v[i] * s; } static inline float vec4_mul_inner(vec4 a, vec4 b) { float p = 0.f; int i; - for (i = 0; i < 4; ++i) - p += b[i] * a[i]; + for (i = 0; i < 4; ++i) p += b[i] * a[i]; return p; } static inline void vec4_mul_cross(vec4 r, vec4 a, vec4 b) { @@ -106,53 +97,44 @@ static inline void vec4_norm(vec4 r, vec4 v) { static inline void vec4_reflect(vec4 r, vec4 v, vec4 n) { float p = 2.f * vec4_mul_inner(v, n); int i; - for (i = 0; i < 4; ++i) - r[i] = v[i] - p * n[i]; + for (i = 0; i < 4; ++i) r[i] = v[i] - p * n[i]; } typedef vec4 mat4x4[4]; static inline void mat4x4_identity(mat4x4 M) { int i, j; for (i = 0; i < 4; ++i) - for (j = 0; j < 4; ++j) - M[i][j] = i == j ? 1.f : 0.f; + for (j = 0; j < 4; ++j) M[i][j] = i == j ? 1.f : 0.f; } static inline void mat4x4_dup(mat4x4 M, mat4x4 N) { int i, j; for (i = 0; i < 4; ++i) - for (j = 0; j < 4; ++j) - M[i][j] = N[i][j]; + for (j = 0; j < 4; ++j) M[i][j] = N[i][j]; } static inline void mat4x4_row(vec4 r, mat4x4 M, int i) { int k; - for (k = 0; k < 4; ++k) - r[k] = M[k][i]; + for (k = 0; k < 4; ++k) r[k] = M[k][i]; } static inline void mat4x4_col(vec4 r, mat4x4 M, int i) { int k; - for (k = 0; k < 4; ++k) - r[k] = M[i][k]; + for (k = 0; k < 4; ++k) r[k] = M[i][k]; } static inline void mat4x4_transpose(mat4x4 M, mat4x4 N) { int i, j; for (j = 0; j < 4; ++j) - for (i = 0; i < 4; ++i) - M[i][j] = N[j][i]; + for (i = 0; i < 4; ++i) M[i][j] = N[j][i]; } static inline void mat4x4_add(mat4x4 M, mat4x4 a, mat4x4 b) { int i; - for (i = 0; i < 4; ++i) - vec4_add(M[i], a[i], b[i]); + for (i = 0; i < 4; ++i) vec4_add(M[i], a[i], b[i]); } static inline void mat4x4_sub(mat4x4 M, mat4x4 a, mat4x4 b) { int i; - for (i = 0; i < 4; ++i) - vec4_sub(M[i], a[i], b[i]); + for (i = 0; i < 4; ++i) vec4_sub(M[i], a[i], b[i]); } static inline void mat4x4_scale(mat4x4 M, mat4x4 a, float k) { int i; - for (i = 0; i < 4; ++i) - vec4_scale(M[i], a[i], k); + for (i = 0; i < 4; ++i) vec4_scale(M[i], a[i], k); } static inline void mat4x4_scale_aniso(mat4x4 M, mat4x4 a, float x, float y, float z) { int i; @@ -168,16 +150,14 @@ static inline void mat4x4_mul(mat4x4 M, mat4x4 a, mat4x4 b) { for (c = 0; c < 4; ++c) for (r = 0; r < 4; ++r) { M[c][r] = 0.f; - for (k = 0; k < 4; ++k) - M[c][r] += a[k][r] * b[c][k]; + for (k = 0; k < 4; ++k) M[c][r] += a[k][r] * b[c][k]; } } static inline void mat4x4_mul_vec4(vec4 r, mat4x4 M, vec4 v) { int i, j; for (j = 0; j < 4; ++j) { r[j] = 0.f; - for (i = 0; i < 4; ++i) - r[j] += M[i][j] * v[i]; + for (i = 0; i < 4; ++i) r[j] += M[i][j] * v[i]; } } static inline void mat4x4_translate(mat4x4 T, float x, float y, float z) { @@ -198,8 +178,7 @@ static inline void mat4x4_translate_in_place(mat4x4 M, float x, float y, float z static inline void mat4x4_from_vec3_mul_outer(mat4x4 M, vec3 a, vec3 b) { int i, j; for (i = 0; i < 4; ++i) - for (j = 0; j < 4; ++j) - M[i][j] = i < 3 && j < 3 ? a[i] * b[j] : 0.f; + for (j = 0; j < 4; ++j) M[i][j] = i < 3 && j < 3 ? a[i] * b[j] : 0.f; } static inline void mat4x4_rotate(mat4x4 R, mat4x4 M, float x, float y, float z, float angle) { float s = sinf(angle); @@ -413,13 +392,11 @@ static inline void quat_identity(quat q) { } static inline void quat_add(quat r, quat a, quat b) { int i; - for (i = 0; i < 4; ++i) - r[i] = a[i] + b[i]; + for (i = 0; i < 4; ++i) r[i] = a[i] + b[i]; } static inline void quat_sub(quat r, quat a, quat b) { int i; - for (i = 0; i < 4; ++i) - r[i] = a[i] - b[i]; + for (i = 0; i < 4; ++i) r[i] = a[i] - b[i]; } static inline void quat_mul(quat r, quat p, quat q) { vec3 w; @@ -432,20 +409,17 @@ static inline void quat_mul(quat r, quat p, quat q) { } static inline void quat_scale(quat r, quat v, float s) { int i; - for (i = 0; i < 4; ++i) - r[i] = v[i] * s; + for (i = 0; i < 4; ++i) r[i] = v[i] * s; } static inline float quat_inner_product(quat a, quat b) { float p = 0.f; int i; - for (i = 0; i < 4; ++i) - p += b[i] * a[i]; + for (i = 0; i < 4; ++i) p += b[i] * a[i]; return p; } static inline void quat_conj(quat r, quat q) { int i; - for (i = 0; i < 3; ++i) - r[i] = -q[i]; + for (i = 0; i < 3; ++i) r[i] = -q[i]; r[3] = q[3]; } #define quat_norm vec4_norm @@ -505,8 +479,7 @@ static inline void quat_from_mat4x4(quat q, mat4x4 M) { for (i = 0; i < 3; i++) { float m = M[i][i]; - if (m < r) - continue; + if (m < r) continue; m = r; p = &perm[i]; } diff --git a/demos/smoke/Game.h b/demos/smoke/Game.h index 3d060de..f19a313 100644 --- a/demos/smoke/Game.h +++ b/demos/smoke/Game.h @@ -25,7 +25,7 @@ class Shell; class Game { - public: + public: Game(const Game &game) = delete; Game &operator=(const Game &game) = delete; virtual ~Game() {} @@ -78,7 +78,7 @@ class Game { void print_stats(); void quit(); - protected: + protected: int frame_count; std::chrono::time_point start_time; @@ -113,7 +113,7 @@ class Game { Settings settings_; Shell *shell_; - private: + private: void parse_args(const std::vector &args) { for (auto it = args.begin(); it != args.end(); ++it) { if (*it == "--b") { @@ -147,4 +147,4 @@ class Game { } }; -#endif // GAME_H +#endif // GAME_H diff --git a/demos/smoke/Helpers.h b/demos/smoke/Helpers.h index c849311..c1eb68d 100644 --- a/demos/smoke/Helpers.h +++ b/demos/smoke/Helpers.h @@ -102,6 +102,6 @@ inline VkResult get(VkDevice dev, VkSwapchainKHR swapchain, std::vector return vk::GetSwapchainImagesKHR(dev, swapchain, &count, images.data()); } -} // namespace vk +} // namespace vk -#endif // HELPERS_H +#endif // HELPERS_H diff --git a/demos/smoke/Main.cpp b/demos/smoke/Main.cpp index 471e579..f2fbbe2 100644 --- a/demos/smoke/Main.cpp +++ b/demos/smoke/Main.cpp @@ -30,7 +30,7 @@ Game *create_game(int argc, char **argv) { return new Smoke(args); } -} // namespace +} // namespace #if defined(VK_USE_PLATFORM_XCB_KHR) @@ -95,4 +95,4 @@ int main(int argc, char **argv) { return 0; } -#endif // VK_USE_PLATFORM_XCB_KHR +#endif // VK_USE_PLATFORM_XCB_KHR diff --git a/demos/smoke/Meshes.cpp b/demos/smoke/Meshes.cpp index dac0a1f..e077be7 100644 --- a/demos/smoke/Meshes.cpp +++ b/demos/smoke/Meshes.cpp @@ -26,7 +26,7 @@ namespace { class Mesh { - public: + public: struct Position { float x; float y; @@ -96,8 +96,7 @@ class Mesh { } faces_.reserve(faces.size()); - for (const auto &f : faces) - faces_.emplace_back(Face{f[0], f[1], f[2]}); + for (const auto &f : faces) faces_.emplace_back(Face{f[0], f[1], f[2]}); } uint32_t vertex_count() const { return static_cast(positions_.size()); } @@ -139,7 +138,7 @@ class Mesh { }; class BuildPyramid { - public: + public: BuildPyramid(Mesh &mesh) { const std::vector> vertices = { // position normal @@ -157,16 +156,15 @@ class BuildPyramid { }; class BuildIcosphere { - public: + public: BuildIcosphere(Mesh &mesh) : mesh_(mesh), radius_(1.0f) { const int tessellate_level = 2; build_icosahedron(); - for (int i = 0; i < tessellate_level; i++) - tessellate(); + for (int i = 0; i < tessellate_level; i++) tessellate(); } - private: + private: void build_icosahedron() { // https://en.wikipedia.org/wiki/Regular_icosahedron const float l1 = std::sqrt(2.0f / (5.0f + std::sqrt(5.0f))) * radius_; @@ -277,8 +275,7 @@ class BuildIcosphere { int add_middle_point(int a, int b) { uint64_t key = (a < b) ? ((uint64_t)a << 32 | b) : ((uint64_t)b << 32 | a); auto it = middle_points_.find(key); - if (it != middle_points_.end()) - return it->second; + if (it != middle_points_.end()) return it->second; const Mesh::Position &pos_a = mesh_.positions_[a]; const Mesh::Position &pos_b = mesh_.positions_[b]; @@ -310,7 +307,7 @@ class BuildIcosphere { }; class BuildTeapot { - public: + public: BuildTeapot(Mesh &mesh) { #include "Meshes.teapot.h" const int position_count = sizeof(teapot_positions) / sizeof(teapot_positions[0]); @@ -346,10 +343,8 @@ class BuildTeapot { }; for (int i = 3; i < position_count; i += 3) { for (int j = 0; j < 3; j++) { - if (min[j] > positions[i + j]) - min[j] = positions[i + j]; - if (max[j] < positions[i + j]) - max[j] = positions[i + j]; + if (min[j] > positions[i + j]) min[j] = positions[i + j]; + if (max[j] < positions[i + j]) max[j] = positions[i + j]; } } @@ -362,10 +357,8 @@ class BuildTeapot { }; float max_extent = extents[0]; - if (max_extent < extents[1]) - max_extent = extents[1]; - if (max_extent < extents[2]) - max_extent = extents[2]; + if (max_extent < extents[1]) max_extent = extents[1]; + if (max_extent < extents[2]) max_extent = extents[2]; scale = 1.0f / max_extent; } @@ -377,11 +370,15 @@ void build_meshes(std::array &meshes) { BuildTeapot build_teapot(meshes[Meshes::MESH_TEAPOT]); } -} // namespace +} // namespace Meshes::Meshes(VkDevice dev, const std::vector &mem_flags) - : dev_(dev), vertex_input_binding_(Mesh::vertex_input_binding()), vertex_input_attrs_(Mesh::vertex_input_attributes()), - vertex_input_state_(), input_assembly_state_(Mesh::input_assembly_state()), index_type_(Mesh::index_type()) { + : dev_(dev), + vertex_input_binding_(Mesh::vertex_input_binding()), + vertex_input_attrs_(Mesh::vertex_input_attributes()), + vertex_input_state_(), + input_assembly_state_(Mesh::input_assembly_state()), + index_type_(Mesh::index_type()) { vertex_input_state_.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; vertex_input_state_.vertexBindingDescriptionCount = 1; vertex_input_state_.pVertexBindingDescriptions = &vertex_input_binding_; diff --git a/demos/smoke/Meshes.h b/demos/smoke/Meshes.h index 27d4224..bc5bf99 100644 --- a/demos/smoke/Meshes.h +++ b/demos/smoke/Meshes.h @@ -21,7 +21,7 @@ #include class Meshes { - public: + public: Meshes(VkDevice dev, const std::vector &mem_flags); ~Meshes(); @@ -39,7 +39,7 @@ class Meshes { void cmd_bind_buffers(VkCommandBuffer cmd) const; void cmd_draw(VkCommandBuffer cmd, Type type) const; - private: + private: void allocate_resources(VkDeviceSize vb_size, VkDeviceSize ib_size, const std::vector &mem_flags); VkDevice dev_; @@ -58,4 +58,4 @@ class Meshes { VkDeviceSize ib_mem_offset_; }; -#endif // MESHES_H +#endif // MESHES_H diff --git a/demos/smoke/Shell.cpp b/demos/smoke/Shell.cpp index b8bd399..be2c188 100644 --- a/demos/smoke/Shell.cpp +++ b/demos/smoke/Shell.cpp @@ -51,8 +51,7 @@ void Shell::init_vk() { } void Shell::cleanup_vk() { - if (settings_.validate) - vk::DestroyDebugReportCallbackEXT(ctx_.instance, ctx_.debug_report, nullptr); + if (settings_.validate) vk::DestroyDebugReportCallbackEXT(ctx_.instance, ctx_.debug_report, nullptr); vk::DestroyInstance(ctx_.instance, nullptr); } @@ -83,8 +82,7 @@ void Shell::assert_all_instance_layers() const { vk::enumerate(layers); std::set layer_names; - for (const auto &layer : layers) - layer_names.insert(layer.layerName); + for (const auto &layer : layers) layer_names.insert(layer.layerName); // all listed instance layers are required for (const auto &name : instance_layers_) { @@ -102,8 +100,7 @@ void Shell::assert_all_instance_extensions() const { vk::enumerate(nullptr, exts); std::set ext_names; - for (const auto &ext : exts) - ext_names.insert(ext.extensionName); + for (const auto &ext : exts) ext_names.insert(ext.extensionName); // all listed instance extensions are required for (const auto &name : instance_extensions_) { @@ -121,13 +118,11 @@ bool Shell::has_all_device_extensions(VkPhysicalDevice phy) const { vk::enumerate(phy, nullptr, exts); std::set ext_names; - for (const auto &ext : exts) - ext_names.insert(ext.extensionName); + for (const auto &ext : exts) ext_names.insert(ext.extensionName); // all listed device extensions are required for (const auto &name : device_extensions_) { - if (ext_names.find(name) == ext_names.end()) - return false; + if (ext_names.find(name) == ext_names.end()) return false; } return true; @@ -155,8 +150,7 @@ void Shell::init_instance() { } void Shell::init_debug_report() { - if (!settings_.validate) - return; + if (!settings_.validate) return; VkDebugReportCallbackCreateInfoEXT debug_report_info = {}; debug_report_info.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT; @@ -180,8 +174,7 @@ void Shell::init_physical_dev() { ctx_.physical_dev = VK_NULL_HANDLE; for (auto phy : phys) { - if (!has_all_device_extensions(phy)) - continue; + if (!has_all_device_extensions(phy)) continue; // get queue properties std::vector queues; @@ -193,15 +186,12 @@ void Shell::init_physical_dev() { // requires only GRAPHICS for game queues const VkFlags game_queue_flags = VK_QUEUE_GRAPHICS_BIT; - if (game_queue_family < 0 && (q.queueFlags & game_queue_flags) == game_queue_flags) - game_queue_family = i; + if (game_queue_family < 0 && (q.queueFlags & game_queue_flags) == game_queue_flags) game_queue_family = i; // present queue must support the surface - if (present_queue_family < 0 && can_present(phy, i)) - present_queue_family = i; + if (present_queue_family < 0 && can_present(phy, i)) present_queue_family = i; - if (game_queue_family >= 0 && present_queue_family >= 0) - break; + if (game_queue_family >= 0 && present_queue_family >= 0) break; } if (game_queue_family >= 0 && present_queue_family >= 0) { @@ -212,8 +202,7 @@ void Shell::init_physical_dev() { } } - if (ctx_.physical_dev == VK_NULL_HANDLE) - throw std::runtime_error("failed to find any capable Vulkan physical device"); + if (ctx_.physical_dev == VK_NULL_HANDLE) throw std::runtime_error("failed to find any capable Vulkan physical device"); } void Shell::create_context() { @@ -232,8 +221,7 @@ void Shell::create_context() { } void Shell::destroy_context() { - if (ctx_.dev == VK_NULL_HANDLE) - return; + if (ctx_.dev == VK_NULL_HANDLE) return; vk::DeviceWaitIdle(ctx_.dev); @@ -371,8 +359,7 @@ void Shell::resize_swapchain(uint32_t width_hint, uint32_t height_hint) { else if (extent.height > caps.maxImageExtent.height) extent.height = caps.maxImageExtent.height; - if (ctx_.extent.width == extent.width && ctx_.extent.height == extent.height) - return; + if (ctx_.extent.width == extent.width && ctx_.extent.height == extent.height) return; uint32_t image_count = settings_.back_buffer_count; if (image_count < caps.minImageCount) @@ -444,8 +431,7 @@ void Shell::resize_swapchain(uint32_t width_hint, uint32_t height_hint) { void Shell::add_game_time(float time) { int max_ticks = 3; - if (!settings_.no_tick) - game_time_ += time; + if (!settings_.no_tick) game_time_ += time; while (game_time_ >= game_tick_ && max_ticks--) { game_.on_tick(); @@ -455,8 +441,7 @@ void Shell::add_game_time(float time) { void Shell::acquire_back_buffer() { // acquire just once when not presenting - if (settings_.no_present && ctx_.acquired_back_buffer.acquire_semaphore != VK_NULL_HANDLE) - return; + if (settings_.no_present && ctx_.acquired_back_buffer.acquire_semaphore != VK_NULL_HANDLE) return; auto &buf = ctx_.back_buffers.front(); @@ -475,8 +460,7 @@ void Shell::acquire_back_buffer() { void Shell::present_back_buffer() { const auto &buf = ctx_.acquired_back_buffer; - if (!settings_.no_render) - game_.on_frame(game_time_ / game_tick_); + if (!settings_.no_render) game_.on_frame(game_time_ / game_tick_); if (settings_.no_present) { fake_present(); @@ -516,6 +500,5 @@ void Shell::fake_present() { } // push the buffer back just once for Shell::cleanup_vk - if (buf.acquire_semaphore != ctx_.back_buffers.back().acquire_semaphore) - ctx_.back_buffers.push(buf); + if (buf.acquire_semaphore != ctx_.back_buffers.back().acquire_semaphore) ctx_.back_buffers.push(buf); } diff --git a/demos/smoke/Shell.h b/demos/smoke/Shell.h index acc29a1..7cb6687 100644 --- a/demos/smoke/Shell.h +++ b/demos/smoke/Shell.h @@ -27,7 +27,7 @@ class Game; class Shell { - public: + public: Shell(const Shell &sh) = delete; Shell &operator=(const Shell &sh) = delete; virtual ~Shell() {} @@ -77,7 +77,7 @@ class Shell { virtual void run() = 0; virtual void quit() = 0; - protected: + protected: Shell(Game &game); void init_vk(); @@ -101,7 +101,7 @@ class Shell { std::vector device_extensions_; - private: + private: bool debug_report_callback(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT obj_type, uint64_t object, size_t location, int32_t msg_code, const char *layer_prefix, const char *msg); static VKAPI_ATTR VkBool32 VKAPI_CALL debug_report_callback(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT obj_type, @@ -140,4 +140,4 @@ class Shell { float game_time_; }; -#endif // SHELL_H +#endif // SHELL_H diff --git a/demos/smoke/ShellAndroid.cpp b/demos/smoke/ShellAndroid.cpp index 7b0dfdc..1e52905 100644 --- a/demos/smoke/ShellAndroid.cpp +++ b/demos/smoke/ShellAndroid.cpp @@ -27,7 +27,7 @@ namespace { // copied from ShellXCB.cpp class PosixTimer { - public: + public: PosixTimer() { reset(); } void reset() { clock_gettime(CLOCK_MONOTONIC, &start_); } @@ -52,11 +52,11 @@ class PosixTimer { return static_cast(s) + static_cast(ns) / one_s_in_ns_d; } - private: + private: struct timespec start_; }; -} // namespace +} // namespace std::vector ShellAndroid::get_args(android_app &app) { const char intent_extra_data_key[] = "args"; @@ -64,8 +64,7 @@ std::vector ShellAndroid::get_args(android_app &app) { JavaVM &vm = *app.activity->vm; JNIEnv *p_env; - if (vm.AttachCurrentThread(&p_env, nullptr) != JNI_OK) - return args; + if (vm.AttachCurrentThread(&p_env, nullptr) != JNI_OK) return args; JNIEnv &env = *p_env; jobject activity = app.activity->clazz; @@ -96,8 +95,7 @@ std::vector ShellAndroid::get_args(android_app &app) { std::stringstream ss(args_str); std::string arg; while (std::getline(ss, arg, ' ')) { - if (!arg.empty()) - args.push_back(arg); + if (!arg.empty()) args.push_back(arg); } return args; @@ -133,21 +131,21 @@ void ShellAndroid::log(LogPriority priority, const char *msg) { int prio; switch (priority) { - case LOG_DEBUG: - prio = ANDROID_LOG_DEBUG; - break; - case LOG_INFO: - prio = ANDROID_LOG_INFO; - break; - case LOG_WARN: - prio = ANDROID_LOG_WARN; - break; - case LOG_ERR: - prio = ANDROID_LOG_ERROR; - break; - default: - prio = ANDROID_LOG_UNKNOWN; - break; + case LOG_DEBUG: + prio = ANDROID_LOG_DEBUG; + break; + case LOG_INFO: + prio = ANDROID_LOG_INFO; + break; + case LOG_WARN: + prio = ANDROID_LOG_WARN; + break; + case LOG_ERR: + prio = ANDROID_LOG_ERROR; + break; + default: + prio = ANDROID_LOG_UNKNOWN; + break; } __android_log_write(prio, settings_.name.c_str(), msg); @@ -158,11 +156,9 @@ PFN_vkGetInstanceProcAddr ShellAndroid::load_vk() { void *handle = nullptr, *symbol = nullptr; handle = dlopen(filename, RTLD_LAZY); - if (handle) - symbol = dlsym(handle, "vkGetInstanceProcAddr"); + if (handle) symbol = dlsym(handle, "vkGetInstanceProcAddr"); if (!symbol) { - if (handle) - dlclose(handle); + if (handle) dlclose(handle); throw std::runtime_error(dlerror()); } @@ -185,37 +181,36 @@ VkSurfaceKHR ShellAndroid::create_surface(VkInstance instance) { void ShellAndroid::on_app_cmd(int32_t cmd) { switch (cmd) { - case APP_CMD_INIT_WINDOW: - create_context(); - resize_swapchain(0, 0); - break; - case APP_CMD_TERM_WINDOW: - destroy_context(); - break; - case APP_CMD_WINDOW_RESIZED: - resize_swapchain(0, 0); - break; - case APP_CMD_STOP: - ANativeActivity_finish(app_.activity); - break; - default: - break; + case APP_CMD_INIT_WINDOW: + create_context(); + resize_swapchain(0, 0); + break; + case APP_CMD_TERM_WINDOW: + destroy_context(); + break; + case APP_CMD_WINDOW_RESIZED: + resize_swapchain(0, 0); + break; + case APP_CMD_STOP: + ANativeActivity_finish(app_.activity); + break; + default: + break; } } int32_t ShellAndroid::on_input_event(const AInputEvent *event) { - if (AInputEvent_getType(event) != AINPUT_EVENT_TYPE_MOTION) - return false; + if (AInputEvent_getType(event) != AINPUT_EVENT_TYPE_MOTION) return false; bool handled = false; switch (AMotionEvent_getAction(event) & AMOTION_EVENT_ACTION_MASK) { - case AMOTION_EVENT_ACTION_UP: - game_.on_key(Game::KEY_SPACE); - handled = true; - break; - default: - break; + case AMOTION_EVENT_ACTION_UP: + game_.on_key(Game::KEY_SPACE); + handled = true; + break; + default: + break; } return handled; @@ -232,18 +227,14 @@ void ShellAndroid::run() { struct android_poll_source *source; while (true) { int timeout = (settings_.animate && app_.window) ? 0 : -1; - if (ALooper_pollAll(timeout, nullptr, nullptr, reinterpret_cast(&source)) < 0) - break; + if (ALooper_pollAll(timeout, nullptr, nullptr, reinterpret_cast(&source)) < 0) break; - if (source) - source->process(&app_, source); + if (source) source->process(&app_, source); } - if (app_.destroyRequested) - break; + if (app_.destroyRequested) break; - if (!app_.window) - continue; + if (!app_.window) continue; acquire_back_buffer(); diff --git a/demos/smoke/ShellAndroid.h b/demos/smoke/ShellAndroid.h index 1827ec5..8e28f74 100644 --- a/demos/smoke/ShellAndroid.h +++ b/demos/smoke/ShellAndroid.h @@ -21,7 +21,7 @@ #include "Shell.h" class ShellAndroid : public Shell { - public: + public: static std::vector get_args(android_app &app); ShellAndroid(android_app &app, Game &game); @@ -32,7 +32,7 @@ class ShellAndroid : public Shell { void run(); void quit(); - private: + private: PFN_vkGetInstanceProcAddr load_vk(); bool can_present(VkPhysicalDevice phy, uint32_t queue_family) { return true; } @@ -59,4 +59,4 @@ int32_t ShellAndroid::on_input_event(android_app *app, AInputEvent *event) { return android->on_input_event(event); } -#endif // SHELL_ANDROID_H +#endif // SHELL_ANDROID_H diff --git a/demos/smoke/ShellWayland.cpp b/demos/smoke/ShellWayland.cpp index 5776c57..cb5715d 100644 --- a/demos/smoke/ShellWayland.cpp +++ b/demos/smoke/ShellWayland.cpp @@ -38,7 +38,7 @@ namespace { class PosixTimer { - public: + public: PosixTimer() { reset(); } void reset() { clock_gettime(CLOCK_MONOTONIC, &start_); } @@ -63,11 +63,11 @@ class PosixTimer { return static_cast(s) + static_cast(ns) / one_s_in_ns_d; } - private: + private: struct timespec start_; }; -} // namespace +} // namespace const struct wl_registry_listener ShellWayland::registry_listener_ = {ShellWayland::handle_global, ShellWayland::handle_global_remove}; @@ -99,8 +99,7 @@ void ShellWayland::handle_configure(void *data UNUSED, struct wl_shell_surface * void ShellWayland::handle_popup_done(void *data UNUSED, struct wl_shell_surface *shell_surface UNUSED) {} ShellWayland::ShellWayland(Game &game) : Shell(game) { - if (game.settings().validate) - instance_layers_.push_back("VK_LAYER_LUNARG_standard_validation"); + if (game.settings().validate) instance_layers_.push_back("VK_LAYER_LUNARG_standard_validation"); instance_extensions_.push_back(VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME); init_connection(); @@ -111,47 +110,33 @@ ShellWayland::~ShellWayland() { cleanup_vk(); dlclose(lib_handle_); - if (shell_surface_) - wl_shell_surface_destroy(shell_surface_); - if (surface_) - wl_surface_destroy(surface_); - if (shell_) - wl_shell_destroy(shell_); - if (compositor_) - wl_compositor_destroy(compositor_); - if (registry_) - wl_registry_destroy(registry_); - if (display_) - wl_display_disconnect(display_); + if (shell_surface_) wl_shell_surface_destroy(shell_surface_); + if (surface_) wl_surface_destroy(surface_); + if (shell_) wl_shell_destroy(shell_); + if (compositor_) wl_compositor_destroy(compositor_); + if (registry_) wl_registry_destroy(registry_); + if (display_) wl_display_disconnect(display_); } void ShellWayland::init_connection() { try { display_ = wl_display_connect(NULL); - if (!display_) - throw std::runtime_error("failed to connect to the display server"); + if (!display_) throw std::runtime_error("failed to connect to the display server"); registry_ = wl_display_get_registry(display_); - if (!registry_) - throw std::runtime_error("failed to get registry"); + if (!registry_) throw std::runtime_error("failed to get registry"); wl_registry_add_listener(registry_, ®istry_listener_, this); wl_display_roundtrip(display_); - if (!compositor_) - throw std::runtime_error("failed to bind compositor"); + if (!compositor_) throw std::runtime_error("failed to bind compositor"); - if (!shell_) - throw std::runtime_error("failed to bind shell"); + if (!shell_) throw std::runtime_error("failed to bind shell"); } catch (...) { - if (shell_) - wl_shell_destroy(shell_); - if (compositor_) - wl_compositor_destroy(compositor_); - if (registry_) - wl_registry_destroy(registry_); - if (display_) - wl_display_disconnect(display_); + if (shell_) wl_shell_destroy(shell_); + if (compositor_) wl_compositor_destroy(compositor_); + if (registry_) wl_registry_destroy(registry_); + if (display_) wl_display_disconnect(display_); throw; } @@ -159,12 +144,10 @@ void ShellWayland::init_connection() { void ShellWayland::create_window() { surface_ = wl_compositor_create_surface(compositor_); - if (!surface_) - throw std::runtime_error("failed to create surface"); + if (!surface_) throw std::runtime_error("failed to create surface"); shell_surface_ = wl_shell_get_shell_surface(shell_, surface_); - if (!shell_surface_) - throw std::runtime_error("failed to shell_surface"); + if (!shell_surface_) throw std::runtime_error("failed to shell_surface"); wl_shell_surface_add_listener(shell_surface_, &shell_surface_listener_, this); // set title @@ -178,21 +161,18 @@ PFN_vkGetInstanceProcAddr ShellWayland::load_vk() { #ifdef UNINSTALLED_LOADER handle = dlopen(UNINSTALLED_LOADER, RTLD_LAZY); - if (!handle) - handle = dlopen(filename, RTLD_LAZY); + if (!handle) handle = dlopen(filename, RTLD_LAZY); #else handle = dlopen(filename, RTLD_LAZY); #endif - if (handle) - symbol = dlsym(handle, "vkGetInstanceProcAddr"); + if (handle) symbol = dlsym(handle, "vkGetInstanceProcAddr"); if (!handle || !symbol) { std::stringstream ss; ss << "failed to load " << dlerror(); - if (handle) - dlclose(handle); + if (handle) dlclose(handle); throw std::runtime_error(ss.str()); } @@ -220,8 +200,7 @@ VkSurfaceKHR ShellWayland::create_surface(VkInstance instance) { void ShellWayland::loop_wait() { while (true) { - if (quit_) - break; + if (quit_) break; acquire_back_buffer(); present_back_buffer(); @@ -236,8 +215,7 @@ void ShellWayland::loop_poll() { int profile_present_count = 0; while (true) { - if (quit_) - break; + if (quit_) break; acquire_back_buffer(); diff --git a/demos/smoke/ShellWayland.h b/demos/smoke/ShellWayland.h index af63216..d3fd21f 100644 --- a/demos/smoke/ShellWayland.h +++ b/demos/smoke/ShellWayland.h @@ -20,14 +20,14 @@ #include "Shell.h" class ShellWayland : public Shell { - public: + public: ShellWayland(Game &game); ~ShellWayland(); void run(); void quit() { quit_ = true; } - private: + private: void init_connection(); PFN_vkGetInstanceProcAddr load_vk(); @@ -59,4 +59,4 @@ class ShellWayland : public Shell { static const struct wl_shell_surface_listener shell_surface_listener_; }; -#endif // SHELL_WAYLAND_H +#endif // SHELL_WAYLAND_H diff --git a/demos/smoke/ShellWin32.cpp b/demos/smoke/ShellWin32.cpp index a2e342c..f5b6825 100644 --- a/demos/smoke/ShellWin32.cpp +++ b/demos/smoke/ShellWin32.cpp @@ -25,7 +25,7 @@ namespace { class Win32Timer { - public: + public: Win32Timer() { LARGE_INTEGER freq; QueryPerformanceFrequency(&freq); @@ -43,16 +43,15 @@ class Win32Timer { return static_cast(now.QuadPart - start_.QuadPart) / freq_; } - private: + private: double freq_; LARGE_INTEGER start_; }; -} // namespace +} // namespace ShellWin32::ShellWin32(Game &game) : Shell(game), hwnd_(nullptr) { - if (game.settings().validate) - instance_layers_.push_back("VK_LAYER_LUNARG_standard_validation"); + if (game.settings().validate) instance_layers_.push_back("VK_LAYER_LUNARG_standard_validation"); instance_extensions_.push_back(VK_KHR_WIN32_SURFACE_EXTENSION_NAME); init_vk(); } @@ -102,8 +101,7 @@ PFN_vkGetInstanceProcAddr ShellWin32::load_vk() { std::stringstream ss; ss << "failed to load " << filename; - if (mod) - FreeLibrary(mod); + if (mod) FreeLibrary(mod); throw std::runtime_error(ss.str()); } @@ -131,43 +129,43 @@ VkSurfaceKHR ShellWin32::create_surface(VkInstance instance) { LRESULT ShellWin32::handle_message(UINT msg, WPARAM wparam, LPARAM lparam) { switch (msg) { - case WM_SIZE: { - UINT w = LOWORD(lparam); - UINT h = HIWORD(lparam); - resize_swapchain(w, h); - } break; - case WM_KEYDOWN: { - Game::Key key; - - switch (wparam) { - case VK_ESCAPE: - key = Game::KEY_ESC; - break; - case VK_UP: - key = Game::KEY_UP; - break; - case VK_DOWN: - key = Game::KEY_DOWN; + case WM_SIZE: { + UINT w = LOWORD(lparam); + UINT h = HIWORD(lparam); + resize_swapchain(w, h); + } break; + case WM_KEYDOWN: { + Game::Key key; + + switch (wparam) { + case VK_ESCAPE: + key = Game::KEY_ESC; + break; + case VK_UP: + key = Game::KEY_UP; + break; + case VK_DOWN: + key = Game::KEY_DOWN; + break; + case VK_SPACE: + key = Game::KEY_SPACE; + break; + default: + key = Game::KEY_UNKNOWN; + break; + } + + game_.on_key(key); + } break; + case WM_CLOSE: + game_.on_key(Game::KEY_SHUTDOWN); break; - case VK_SPACE: - key = Game::KEY_SPACE; + case WM_DESTROY: + quit(); break; default: - key = Game::KEY_UNKNOWN; + return DefWindowProc(hwnd_, msg, wparam, lparam); break; - } - - game_.on_key(key); - } break; - case WM_CLOSE: - game_.on_key(Game::KEY_SHUTDOWN); - break; - case WM_DESTROY: - quit(); - break; - default: - return DefWindowProc(hwnd_, msg, wparam, lparam); - break; } return 0; @@ -201,8 +199,7 @@ void ShellWin32::run() { DispatchMessage(&msg); } - if (quit) - break; + if (quit) break; acquire_back_buffer(); diff --git a/demos/smoke/ShellWin32.h b/demos/smoke/ShellWin32.h index 1232141..23f1e1e 100644 --- a/demos/smoke/ShellWin32.h +++ b/demos/smoke/ShellWin32.h @@ -21,14 +21,14 @@ #include "Shell.h" class ShellWin32 : public Shell { - public: + public: ShellWin32(Game &game); ~ShellWin32(); void run(); void quit(); - private: + private: PFN_vkGetInstanceProcAddr load_vk(); bool can_present(VkPhysicalDevice phy, uint32_t queue_family); @@ -39,8 +39,7 @@ class ShellWin32 : public Shell { ShellWin32 *shell = reinterpret_cast(GetWindowLongPtr(hwnd, GWLP_USERDATA)); // called from constructor, CreateWindowEx specifically. But why? - if (!shell) - return DefWindowProc(hwnd, uMsg, wParam, lParam); + if (!shell) return DefWindowProc(hwnd, uMsg, wParam, lParam); return shell->handle_message(uMsg, wParam, lParam); } @@ -52,4 +51,4 @@ class ShellWin32 : public Shell { HMODULE hmodule_; }; -#endif // SHELL_WIN32_H +#endif // SHELL_WIN32_H diff --git a/demos/smoke/ShellXcb.cpp b/demos/smoke/ShellXcb.cpp index 4a7d45c..6bbe332 100644 --- a/demos/smoke/ShellXcb.cpp +++ b/demos/smoke/ShellXcb.cpp @@ -26,7 +26,7 @@ namespace { class PosixTimer { - public: + public: PosixTimer() { reset(); } void reset() { clock_gettime(CLOCK_MONOTONIC, &start_); } @@ -51,7 +51,7 @@ class PosixTimer { return static_cast(s) + static_cast(ns) / one_s_in_ns_d; } - private: + private: struct timespec start_; }; @@ -70,11 +70,10 @@ xcb_atom_t intern_atom(xcb_connection_t *c, xcb_intern_atom_cookie_t cookie) { return atom; } -} // namespace +} // namespace ShellXcb::ShellXcb(Game &game) : Shell(game) { - if (game.settings().validate) - instance_layers_.push_back("VK_LAYER_LUNARG_standard_validation"); + if (game.settings().validate) instance_layers_.push_back("VK_LAYER_LUNARG_standard_validation"); instance_extensions_.push_back(VK_KHR_XCB_SURFACE_EXTENSION_NAME); init_connection(); @@ -99,8 +98,7 @@ void ShellXcb::init_connection() { const xcb_setup_t *setup = xcb_get_setup(c_); xcb_screen_iterator_t iter = xcb_setup_roots_iterator(setup); - while (scr-- > 0) - xcb_screen_next(&iter); + while (scr-- > 0) xcb_screen_next(&iter); scr_ = iter.data; } @@ -139,21 +137,18 @@ PFN_vkGetInstanceProcAddr ShellXcb::load_vk() { #ifdef UNINSTALLED_LOADER handle = dlopen(UNINSTALLED_LOADER, RTLD_LAZY); - if (!handle) - handle = dlopen(filename, RTLD_LAZY); + if (!handle) handle = dlopen(filename, RTLD_LAZY); #else handle = dlopen(filename, RTLD_LAZY); #endif - if (handle) - symbol = dlsym(handle, "vkGetInstanceProcAddr"); + if (handle) symbol = dlsym(handle, "vkGetInstanceProcAddr"); if (!handle || !symbol) { std::stringstream ss; ss << "failed to load " << dlerror(); - if (handle) - dlclose(handle); + if (handle) dlclose(handle); throw std::runtime_error(ss.str()); } @@ -181,56 +176,53 @@ VkSurfaceKHR ShellXcb::create_surface(VkInstance instance) { void ShellXcb::handle_event(const xcb_generic_event_t *ev) { switch (ev->response_type & 0x7f) { - case XCB_CONFIGURE_NOTIFY: { - const xcb_configure_notify_event_t *notify = reinterpret_cast(ev); - resize_swapchain(notify->width, notify->height); - } break; - case XCB_KEY_PRESS: { - const xcb_key_press_event_t *press = reinterpret_cast(ev); - Game::Key key; - - // TODO translate xcb_keycode_t - switch (press->detail) { - case 9: - key = Game::KEY_ESC; - break; - case 111: - key = Game::KEY_UP; - break; - case 116: - key = Game::KEY_DOWN; - break; - case 65: - key = Game::KEY_SPACE; - break; + case XCB_CONFIGURE_NOTIFY: { + const xcb_configure_notify_event_t *notify = reinterpret_cast(ev); + resize_swapchain(notify->width, notify->height); + } break; + case XCB_KEY_PRESS: { + const xcb_key_press_event_t *press = reinterpret_cast(ev); + Game::Key key; + + // TODO translate xcb_keycode_t + switch (press->detail) { + case 9: + key = Game::KEY_ESC; + break; + case 111: + key = Game::KEY_UP; + break; + case 116: + key = Game::KEY_DOWN; + break; + case 65: + key = Game::KEY_SPACE; + break; + default: + key = Game::KEY_UNKNOWN; + break; + } + + game_.on_key(key); + } break; + case XCB_CLIENT_MESSAGE: { + const xcb_client_message_event_t *msg = reinterpret_cast(ev); + if (msg->type == wm_protocols_ && msg->data.data32[0] == wm_delete_window_) game_.on_key(Game::KEY_SHUTDOWN); + } break; default: - key = Game::KEY_UNKNOWN; break; - } - - game_.on_key(key); - } break; - case XCB_CLIENT_MESSAGE: { - const xcb_client_message_event_t *msg = reinterpret_cast(ev); - if (msg->type == wm_protocols_ && msg->data.data32[0] == wm_delete_window_) - game_.on_key(Game::KEY_SHUTDOWN); - } break; - default: - break; } } void ShellXcb::loop_wait() { while (true) { xcb_generic_event_t *ev = xcb_wait_for_event(c_); - if (!ev) - continue; + if (!ev) continue; handle_event(ev); free(ev); - if (quit_) - break; + if (quit_) break; acquire_back_buffer(); present_back_buffer(); @@ -248,15 +240,13 @@ void ShellXcb::loop_poll() { // handle pending events while (true) { xcb_generic_event_t *ev = xcb_poll_for_event(c_); - if (!ev) - break; + if (!ev) break; handle_event(ev); free(ev); } - if (quit_) - break; + if (quit_) break; acquire_back_buffer(); diff --git a/demos/smoke/ShellXcb.h b/demos/smoke/ShellXcb.h index 7ba4a92..7577ebe 100644 --- a/demos/smoke/ShellXcb.h +++ b/demos/smoke/ShellXcb.h @@ -21,14 +21,14 @@ #include "Shell.h" class ShellXcb : public Shell { - public: + public: ShellXcb(Game &game); ~ShellXcb(); void run(); void quit() { quit_ = true; } - private: + private: void init_connection(); PFN_vkGetInstanceProcAddr load_vk(); @@ -53,4 +53,4 @@ class ShellXcb : public Shell { bool quit_; }; -#endif // SHELL_XCB_H +#endif // SHELL_XCB_H diff --git a/demos/smoke/Simulation.cpp b/demos/smoke/Simulation.cpp index b5f31de..35a4101 100644 --- a/demos/smoke/Simulation.cpp +++ b/demos/smoke/Simulation.cpp @@ -23,7 +23,7 @@ namespace { class MeshPicker { - public: + public: MeshPicker() : pattern_({{ Meshes::MESH_PYRAMID, Meshes::MESH_ICOSPHERE, Meshes::MESH_TEAPOT, Meshes::MESH_PYRAMID, Meshes::MESH_ICOSPHERE, @@ -40,42 +40,41 @@ class MeshPicker { float base = 0.005f; switch (type) { - case Meshes::MESH_PYRAMID: - default: - return base * 1.0f; - case Meshes::MESH_ICOSPHERE: - return base * 3.0f; - case Meshes::MESH_TEAPOT: - return base * 10.0f; + case Meshes::MESH_PYRAMID: + default: + return base * 1.0f; + case Meshes::MESH_ICOSPHERE: + return base * 3.0f; + case Meshes::MESH_TEAPOT: + return base * 10.0f; } } - private: + private: const std::array pattern_; int cur_; }; class ColorPicker { - public: + public: ColorPicker(unsigned int rng_seed) : rng_(rng_seed), red_(0.0f, 1.0f), green_(0.0f, 1.0f), blue_(0.0f, 1.0f) {} glm::vec3 pick() { return glm::vec3{red_(rng_), green_(rng_), blue_(rng_)}; } - private: + private: std::mt19937 rng_; std::uniform_real_distribution red_; std::uniform_real_distribution green_; std::uniform_real_distribution blue_; }; -} // namespace +} // namespace Animation::Animation(unsigned int rng_seed, float scale) : rng_(rng_seed), dir_(-1.0f, 1.0f), speed_(0.1f, 1.0f) { float x = dir_(rng_); float y = dir_(rng_); float z = dir_(rng_); - if (std::abs(x) + std::abs(y) + std::abs(z) == 0.0f) - x = 1.0f; + if (std::abs(x) + std::abs(y) + std::abs(z) == 0.0f) x = 1.0f; current_.axis = glm::normalize(glm::vec3(x, y, z)); @@ -92,7 +91,7 @@ glm::mat4 Animation::transformation(float t) { } class Curve { - public: + public: virtual ~Curve() {} virtual glm::vec3 evaluate(float t) = 0; }; @@ -106,14 +105,18 @@ enum CurveType { }; class RandomCurve : public Curve { - public: + public: RandomCurve(unsigned int rng_seed) - : rng_(rng_seed), direction_(-0.3f, 0.3f), duration_(1.0f, 5.0f), segment_start_(0.0f), segment_direction_(0.0f), - time_start_(0.0f), time_duration_(0.0f) {} + : rng_(rng_seed), + direction_(-0.3f, 0.3f), + duration_(1.0f, 5.0f), + segment_start_(0.0f), + segment_direction_(0.0f), + time_start_(0.0f), + time_duration_(0.0f) {} glm::vec3 evaluate(float t) { - if (t >= time_start_ + time_duration_) - new_segment(t); + if (t >= time_start_ + time_duration_) new_segment(t); pos_ += unit_dir_ * (t - last_); last_ = t; @@ -121,7 +124,7 @@ class RandomCurve : public Curve { return pos_; } - private: + private: void new_segment(float time_start) { segment_start_ += segment_direction_; segment_direction_ = glm::vec3(direction_(rng_), direction_(rng_), direction_(rng_)); @@ -149,7 +152,7 @@ class RandomCurve : public Curve { }; class CircleCurve : public Curve { - public: + public: CircleCurve(float radius, glm::vec3 axis) : r_(radius) { glm::vec3 a; @@ -175,13 +178,13 @@ class CircleCurve : public Curve { return (a_ * (glm::vec3(std::cos(t)) - glm::vec3(1.0f)) + b_ * glm::vec3(std::sin(t))) * glm::vec3(r_); } - private: + private: float r_; glm::vec3 a_; glm::vec3 b_; }; -} // namespace +} // namespace Path::Path(unsigned int rng_seed) : rng_(rng_seed), type_(0, CURVE_COUNT - 1), duration_(5.0f, 20.0f) { // trigger a subpath generation @@ -192,8 +195,7 @@ Path::Path(unsigned int rng_seed) : rng_(rng_seed), type_(0, CURVE_COUNT - 1), d glm::vec3 Path::position(float t) { current_.now += t; - while (current_.now >= current_.end) - generate_subpath(); + while (current_.now >= current_.end) generate_subpath(); return current_.origin + current_.curve->evaluate(current_.now - current_.start); } @@ -216,22 +218,21 @@ void Path::generate_subpath() { Curve *curve; switch (type) { - case CURVE_RANDOM: - curve = new RandomCurve(rng_()); - break; - case CURVE_CIRCLE: { - std::uniform_real_distribution dir(-1.0f, 1.0f); - glm::vec3 axis(dir(rng_), dir(rng_), dir(rng_)); - if (axis.x == 0.0f && axis.y == 0.0f && axis.z == 0.0f) - axis.x = 1.0f; - - std::uniform_real_distribution radius_(0.02f, 0.2f); - curve = new CircleCurve(radius_(rng_), axis); - } break; - default: - assert(!"unreachable"); - curve = nullptr; - break; + case CURVE_RANDOM: + curve = new RandomCurve(rng_()); + break; + case CURVE_CIRCLE: { + std::uniform_real_distribution dir(-1.0f, 1.0f); + glm::vec3 axis(dir(rng_), dir(rng_), dir(rng_)); + if (axis.x == 0.0f && axis.y == 0.0f && axis.z == 0.0f) axis.x = 1.0f; + + std::uniform_real_distribution radius_(0.02f, 0.2f); + curve = new CircleCurve(radius_(rng_), axis); + } break; + default: + assert(!"unreachable"); + curve = nullptr; + break; } current_.curve.reset(curve); diff --git a/demos/smoke/Simulation.h b/demos/smoke/Simulation.h index 0f50d7e..95bb946 100644 --- a/demos/smoke/Simulation.h +++ b/demos/smoke/Simulation.h @@ -26,12 +26,12 @@ #include "Meshes.h" class Animation { - public: + public: Animation(unsigned rng_seed, float scale); glm::mat4 transformation(float t); - private: + private: struct Data { glm::vec3 axis; float speed; @@ -50,12 +50,12 @@ class Animation { class Curve; class Path { - public: + public: Path(unsigned rng_seed); glm::vec3 position(float t); - private: + private: struct Subpath { glm::vec3 origin; float start; @@ -75,7 +75,7 @@ class Path { }; class Simulation { - public: + public: Simulation(int object_count); struct Object { @@ -98,9 +98,9 @@ class Simulation { void set_frame_data_size(uint32_t size); void update(float time, int begin, int end); - private: + private: std::random_device random_dev_; std::vector objects_; }; -#endif // SIMULATION_H +#endif // SIMULATION_H diff --git a/demos/smoke/Smoke.cpp b/demos/smoke/Smoke.cpp index 1395648..c0d3bef 100644 --- a/demos/smoke/Smoke.cpp +++ b/demos/smoke/Smoke.cpp @@ -35,11 +35,19 @@ struct ShaderParamBlock { float view_projection[4 * 4]; }; -} // namespace +} // namespace Smoke::Smoke(const std::vector &args) - : Game("Smoke", args), multithread_(true), use_push_constants_(false), sim_paused_(false), sim_(5000), camera_(2.5f), - frame_data_(), render_pass_clear_value_({{{0.0f, 0.1f, 0.2f, 1.0f}}}), render_pass_begin_info_(), primary_cmd_begin_info_(), + : Game("Smoke", args), + multithread_(true), + use_push_constants_(false), + sim_paused_(false), + sim_(5000), + camera_(2.5f), + frame_data_(), + render_pass_clear_value_({{{0.0f, 0.1f, 0.2f, 1.0f}}}), + render_pass_begin_info_(), + primary_cmd_begin_info_(), primary_cmd_submit_info_() { for (auto it = args.begin(); it != args.end(); ++it) { if (*it == "-s") @@ -98,8 +106,7 @@ void Smoke::attach_shell(Shell &sh) { VkPhysicalDeviceMemoryProperties mem_props; vk::GetPhysicalDeviceMemoryProperties(physical_dev_, &mem_props); mem_flags_.reserve(mem_props.memoryTypeCount); - for (uint32_t i = 0; i < mem_props.memoryTypeCount; i++) - mem_flags_.push_back(mem_props.memoryTypes[i].propertyFlags); + for (uint32_t i = 0; i < mem_props.memoryTypeCount; i++) mem_flags_.push_back(mem_props.memoryTypes[i].propertyFlags); meshes_ = new Meshes(dev_, mem_flags_); @@ -129,23 +136,20 @@ void Smoke::attach_shell(Shell &sh) { primary_cmd_submit_info_.signalSemaphoreCount = 1; if (multithread_) { - for (auto &worker : workers_) - worker->start(); + for (auto &worker : workers_) worker->start(); } } void Smoke::detach_shell() { if (multithread_) { - for (auto &worker : workers_) - worker->stop(); + for (auto &worker : workers_) worker->stop(); } destroy_frame_data(); vk::DestroyPipeline(dev_, pipeline_, nullptr); vk::DestroyPipelineLayout(dev_, pipeline_layout_, nullptr); - if (!use_push_constants_) - vk::DestroyDescriptorSetLayout(dev_, desc_set_layout_, nullptr); + if (!use_push_constants_) vk::DestroyDescriptorSetLayout(dev_, desc_set_layout_, nullptr); vk::DestroyShaderModule(dev_, fs_, nullptr); vk::DestroyShaderModule(dev_, vs_, nullptr); vk::DestroyRenderPass(dev_, render_pass_, nullptr); @@ -223,8 +227,7 @@ void Smoke::create_shader_modules() { } void Smoke::create_descriptor_set_layout() { - if (use_push_constants_) - return; + if (use_push_constants_) return; VkDescriptorSetLayoutBinding layout_binding = {}; layout_binding.binding = 0; @@ -360,17 +363,14 @@ void Smoke::destroy_frame_data() { vk::UnmapMemory(dev_, frame_data_mem_); vk::FreeMemory(dev_, frame_data_mem_, nullptr); - for (auto &data : frame_data_) - vk::DestroyBuffer(dev_, data.buf, nullptr); + for (auto &data : frame_data_) vk::DestroyBuffer(dev_, data.buf, nullptr); } - for (auto cmd_pool : worker_cmd_pools_) - vk::DestroyCommandPool(dev_, cmd_pool, nullptr); + for (auto cmd_pool : worker_cmd_pools_) vk::DestroyCommandPool(dev_, cmd_pool, nullptr); worker_cmd_pools_.clear(); vk::DestroyCommandPool(dev_, primary_cmd_pool_, nullptr); - for (auto &data : frame_data_) - vk::DestroyFence(dev_, data.fence, nullptr); + for (auto &data : frame_data_) vk::DestroyFence(dev_, data.fence, nullptr); frame_data_.clear(); } @@ -380,8 +380,7 @@ void Smoke::create_fences() { fence_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; fence_info.flags = VK_FENCE_CREATE_SIGNALED_BIT; - for (auto &data : frame_data_) - vk::assert_success(vk::CreateFence(dev_, &fence_info, nullptr, &data.fence)); + for (auto &data : frame_data_) vk::assert_success(vk::CreateFence(dev_, &fence_info, nullptr, &data.fence)); } void Smoke::create_command_buffers() { @@ -430,8 +429,7 @@ void Smoke::create_buffers() { VkDeviceSize object_data_size = sizeof(ShaderParamBlock); // align object data to device limit const VkDeviceSize &alignment = physical_dev_props_.limits.minStorageBufferOffsetAlignment; - if (object_data_size % alignment) - object_data_size += alignment - (object_data_size % alignment); + if (object_data_size % alignment) object_data_size += alignment - (object_data_size % alignment); // update simulation sim_.set_frame_data_size(static_cast(object_data_size)); @@ -442,8 +440,7 @@ void Smoke::create_buffers() { buf_info.usage = VK_BUFFER_USAGE_STORAGE_BUFFER_BIT; buf_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; - for (auto &data : frame_data_) - vk::assert_success(vk::CreateBuffer(dev_, &buf_info, nullptr, &data.buf)); + for (auto &data : frame_data_) vk::assert_success(vk::CreateBuffer(dev_, &buf_info, nullptr, &data.buf)); } void Smoke::create_buffer_memory() { @@ -544,10 +541,8 @@ void Smoke::attach_swapchain() { } void Smoke::detach_swapchain() { - for (auto fb : framebuffers_) - vk::DestroyFramebuffer(dev_, fb, nullptr); - for (auto view : image_views_) - vk::DestroyImageView(dev_, view, nullptr); + for (auto fb : framebuffers_) vk::DestroyFramebuffer(dev_, fb, nullptr); + for (auto view : image_views_) vk::DestroyImageView(dev_, view, nullptr); framebuffers_.clear(); image_views_.clear(); @@ -679,32 +674,30 @@ void Smoke::draw_objects(Worker &worker) { void Smoke::on_key(Key key) { switch (key) { - case KEY_SHUTDOWN: - case KEY_ESC: - quit(); - break; - case KEY_UP: - camera_.eye_pos -= glm::vec3(0.05f); - update_camera(); - break; - case KEY_DOWN: - camera_.eye_pos += glm::vec3(0.05f); - update_camera(); - break; - case KEY_SPACE: - sim_paused_ = !sim_paused_; - break; - default: - break; + case KEY_SHUTDOWN: + case KEY_ESC: + quit(); + break; + case KEY_UP: + camera_.eye_pos -= glm::vec3(0.05f); + update_camera(); + break; + case KEY_DOWN: + camera_.eye_pos += glm::vec3(0.05f); + update_camera(); + break; + case KEY_SPACE: + sim_paused_ = !sim_paused_; + break; + default: + break; } } void Smoke::on_tick() { - if (sim_paused_) - return; + if (sim_paused_) return; - for (auto &worker : workers_) - worker->update_simulation(); + for (auto &worker : workers_) worker->update_simulation(); } void Smoke::on_frame(float frame_pred) { @@ -725,8 +718,7 @@ void Smoke::on_frame(float frame_pred) { const Shell::BackBuffer &back = shell_->context().acquired_back_buffer; // ignore frame_pred - for (auto &worker : workers_) - worker->draw_objects(framebuffers_[back.image_index]); + for (auto &worker : workers_) worker->draw_objects(framebuffers_[back.image_index]); VkResult res = vk::BeginCommandBuffer(data.primary_cmd, &primary_cmd_begin_info_); @@ -749,8 +741,7 @@ void Smoke::on_frame(float frame_pred) { vk::CmdBeginRenderPass(data.primary_cmd, &render_pass_begin_info_, VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS); // record render pass commands - for (auto &worker : workers_) - worker->wait_idle(); + for (auto &worker : workers_) worker->wait_idle(); // Flush buffers if enabled if (settings_.flush_buffers) { @@ -782,8 +773,12 @@ void Smoke::on_frame(float frame_pred) { } Smoke::Worker::Worker(Smoke &smoke, int index, int object_begin, int object_end) - : smoke_(smoke), index_(index), object_begin_(object_begin), object_end_(object_end), - tick_interval_(1.0f / smoke.settings_.ticks_per_second), state_(INIT) {} + : smoke_(smoke), + index_(index), + object_begin_(object_begin), + object_end_(object_end), + tick_interval_(1.0f / smoke.settings_.ticks_per_second), + state_(INIT) {} void Smoke::Worker::start() { state_ = IDLE; @@ -840,8 +835,7 @@ void Smoke::Worker::wait_idle() { std::unique_lock lock(mutex_); bool started = (state_ != INIT); - if (started) - state_cv_.wait(lock, [this] { return (state_ == IDLE); }); + if (started) state_cv_.wait(lock, [this] { return (state_ == IDLE); }); } void Smoke::Worker::update_loop() { @@ -849,8 +843,7 @@ void Smoke::Worker::update_loop() { std::unique_lock lock(mutex_); state_cv_.wait(lock, [this] { return (state_ != IDLE); }); - if (state_ == INIT) - break; + if (state_ == INIT) break; assert(state_ == STEP || state_ == DRAW); if (state_ == STEP) diff --git a/demos/smoke/Smoke.h b/demos/smoke/Smoke.h index 822d141..64c078c 100644 --- a/demos/smoke/Smoke.h +++ b/demos/smoke/Smoke.h @@ -33,7 +33,7 @@ class Meshes; class Smoke : public Game { - public: + public: Smoke(const std::vector &args); ~Smoke(); @@ -48,9 +48,9 @@ class Smoke : public Game { void on_frame(float frame_pred); - private: + private: class Worker { - public: + public: Worker(Smoke &smoke, int index, int object_begin, int object_end); void start(); @@ -69,7 +69,7 @@ class Smoke : public Game { VkFramebuffer fb_; - private: + private: enum State { INIT, IDLE, @@ -187,4 +187,4 @@ class Smoke : public Game { void draw_objects(Worker &worker); }; -#endif // HOLOGRAM_H +#endif // HOLOGRAM_H diff --git a/demos/vulkaninfo.c b/demos/vulkaninfo.c index ddb5534..f103eaa 100644 --- a/demos/vulkaninfo.c +++ b/demos/vulkaninfo.c @@ -30,7 +30,7 @@ #ifdef _WIN32 #include #include -#endif // _WIN32 +#endif // _WIN32 #if defined(VK_USE_PLATFORM_XLIB_KHR) || defined(VK_USE_PLATFORM_XCB_KHR) #include @@ -56,21 +56,20 @@ static int ConsoleIsExclusive(void) { return num_pids <= 1; } -#define WAIT_FOR_CONSOLE_DESTROY \ - do { \ - if (ConsoleIsExclusive()) \ - Sleep(INFINITE); \ +#define WAIT_FOR_CONSOLE_DESTROY \ + do { \ + if (ConsoleIsExclusive()) Sleep(INFINITE); \ } while (0) #else #define WAIT_FOR_CONSOLE_DESTROY #endif -#define ERR_EXIT(err) \ - do { \ - ERR(err); \ - fflush(stdout); \ - WAIT_FOR_CONSOLE_DESTROY; \ - exit(-1); \ +#define ERR_EXIT(err) \ + do { \ + ERR(err); \ + fflush(stdout); \ + WAIT_FOR_CONSOLE_DESTROY; \ + exit(-1); \ } while (0) #if defined(NDEBUG) && defined(__GNUC__) @@ -105,7 +104,7 @@ struct AppInstance { uint32_t global_layer_count; struct LayerExtensionList *global_layers; uint32_t global_extension_count; - VkExtensionProperties *global_extensions; // Instance Extensions + VkExtensionProperties *global_extensions; // Instance Extensions PFN_vkGetPhysicalDeviceSurfaceSupportKHR vkGetPhysicalDeviceSurfaceSupportKHR; PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR vkGetPhysicalDeviceSurfaceCapabilitiesKHR; @@ -116,8 +115,8 @@ struct AppInstance { int width, height; #ifdef VK_USE_PLATFORM_WIN32_KHR - HINSTANCE h_instance; // Windows Instance - HWND h_wnd; // window handle + HINSTANCE h_instance; // Windows Instance + HWND h_wnd; // window handle #elif VK_USE_PLATFORM_XCB_KHR xcb_connection_t *xcb_connection; xcb_screen_t *xcb_screen; @@ -125,7 +124,7 @@ struct AppInstance { #elif VK_USE_PLATFORM_XLIB_KHR Display *xlib_display; Window xlib_window; -#elif VK_USE_PLATFORM_ANDROID_KHR // TODO +#elif VK_USE_PLATFORM_ANDROID_KHR // TODO ANativeWindow *window; #endif }; @@ -183,8 +182,8 @@ static VKAPI_ATTR VkBool32 VKAPI_CALL DbgCallback(VkFlags msgFlags, VkDebugRepor static const char *VkResultString(VkResult err) { switch (err) { -#define STR(r) \ - case r: \ +#define STR(r) \ + case r: \ return #r STR(VK_SUCCESS); STR(VK_NOT_READY); @@ -200,30 +199,30 @@ static const char *VkResultString(VkResult err) { STR(VK_ERROR_MEMORY_MAP_FAILED); STR(VK_ERROR_INCOMPATIBLE_DRIVER); #undef STR - default: - return "UNKNOWN_RESULT"; + default: + return "UNKNOWN_RESULT"; } } static const char *VkPhysicalDeviceTypeString(VkPhysicalDeviceType type) { switch (type) { -#define STR(r) \ - case VK_PHYSICAL_DEVICE_TYPE_##r: \ +#define STR(r) \ + case VK_PHYSICAL_DEVICE_TYPE_##r: \ return #r STR(OTHER); STR(INTEGRATED_GPU); STR(DISCRETE_GPU); STR(VIRTUAL_GPU); #undef STR - default: - return "UNKNOWN_DEVICE"; + default: + return "UNKNOWN_DEVICE"; } } static const char *VkFormatString(VkFormat fmt) { switch (fmt) { -#define STR(r) \ - case VK_FORMAT_##r: \ +#define STR(r) \ + case VK_FORMAT_##r: \ return #r STR(UNDEFINED); STR(R4G4_UNORM_PACK8); @@ -406,23 +405,23 @@ static const char *VkFormatString(VkFormat fmt) { STR(ASTC_12x12_UNORM_BLOCK); STR(ASTC_12x12_SRGB_BLOCK); #undef STR - default: - return "UNKNOWN_FORMAT"; + default: + return "UNKNOWN_FORMAT"; } } #if defined(VK_USE_PLATFORM_XCB_KHR) || defined(VK_USE_PLATFORM_XLIB_KHR) || defined(VK_USE_PLATFORM_WIN32_KHR) static const char *VkPresentModeString(VkPresentModeKHR mode) { switch (mode) { -#define STR(r) \ - case VK_PRESENT_MODE_##r: \ +#define STR(r) \ + case VK_PRESENT_MODE_##r: \ return #r STR(IMMEDIATE_KHR); STR(MAILBOX_KHR); STR(FIFO_KHR); STR(FIFO_RELAXED_KHR); #undef STR - default: - return "UNKNOWN_FORMAT"; + default: + return "UNKNOWN_FORMAT"; } } #endif @@ -495,8 +494,7 @@ static void AppDevInit(struct AppDev *dev, struct AppGpu *gpu) { info.ppEnabledExtensionNames = NULL; dev->gpu = gpu; err = vkCreateDevice(gpu->obj, &info, NULL, &dev->obj); - if (err) - ERR_EXIT(err); + if (err) ERR_EXIT(err); } static void AppDevDestroy(struct AppDev *dev) { @@ -585,8 +583,8 @@ static void AppCreateInstance(struct AppInstance *inst) { #define MAX_EXTENSIONS 4 uint32_t i = 0; uint32_t ext_count = 0; - const char *ext_names[MAX_EXTENSIONS]; // array of string pointers to - // extension names + const char *ext_names[MAX_EXTENSIONS]; // array of string pointers to + // extension names for (i = 0; (i < inst->global_extension_count); i++) { const char *found_name = inst->global_extensions[i].extensionName; if (!strcmp(VK_KHR_SURFACE_EXTENSION_NAME, found_name)) { @@ -594,7 +592,7 @@ static void AppCreateInstance(struct AppInstance *inst) { } } -#if defined(VK_USE_PLATFORM_XCB_KHR) || defined(VK_USE_PLATFORM_XLIB_KHR) || defined(VK_USE_PLATFORM_WAYLAND_KHR) || \ +#if defined(VK_USE_PLATFORM_XCB_KHR) || defined(VK_USE_PLATFORM_XLIB_KHR) || defined(VK_USE_PLATFORM_WAYLAND_KHR) || \ defined(VK_USE_PLATFORM_WIN32_KHR) || defined(VK_USE_PLATFORM_ANDROID_KHR) if (ext_count) for (i = 0; ((i < inst->global_extension_count) && (ext_count < MAX_EXTENSIONS)); i++) { @@ -625,8 +623,7 @@ static void AppCreateInstance(struct AppInstance *inst) { // If we don't find the KHR_SURFACE extension and at least one other // device-specific extension, // then give up on reporting presentable surface formats." - if (ext_count < 2) - ext_count = 0; + if (ext_count < 2) ext_count = 0; //---------------------------------------- const VkApplicationInfo app_info = { @@ -667,7 +664,7 @@ static void AppCreateInstance(struct AppInstance *inst) { if (ext_count > 0) { //--Load Extensions-- -#define GET_INSTANCE_PROC_ADDR(ENTRYPOINT) \ +#define GET_INSTANCE_PROC_ADDR(ENTRYPOINT) \ { inst->ENTRYPOINT = (void *)vkGetInstanceProcAddr(inst->instance, #ENTRYPOINT); } GET_INSTANCE_PROC_ADDR(vkGetPhysicalDeviceSurfaceSupportKHR) GET_INSTANCE_PROC_ADDR(vkGetPhysicalDeviceSurfaceCapabilitiesKHR) @@ -699,18 +696,15 @@ static void AppGpuInit(struct AppGpu *gpu, uint32_t id, VkPhysicalDevice obj) { gpu->queue_props = malloc(sizeof(gpu->queue_props[0]) * gpu->queue_count); - if (!gpu->queue_props) - ERR_EXIT(VK_ERROR_OUT_OF_HOST_MEMORY); + if (!gpu->queue_props) ERR_EXIT(VK_ERROR_OUT_OF_HOST_MEMORY); vkGetPhysicalDeviceQueueFamilyProperties(gpu->obj, &gpu->queue_count, gpu->queue_props); /* set up queue requests */ gpu->queue_reqs = malloc(sizeof(*gpu->queue_reqs) * gpu->queue_count); - if (!gpu->queue_reqs) - ERR_EXIT(VK_ERROR_OUT_OF_HOST_MEMORY); + if (!gpu->queue_reqs) ERR_EXIT(VK_ERROR_OUT_OF_HOST_MEMORY); for (i = 0; i < gpu->queue_count; i++) { float *queue_priorities = malloc(gpu->queue_props[i].queueCount * sizeof(float)); - if (!queue_priorities) - ERR_EXIT(VK_ERROR_OUT_OF_HOST_MEMORY); + if (!queue_priorities) ERR_EXIT(VK_ERROR_OUT_OF_HOST_MEMORY); memset(queue_priorities, 0, gpu->queue_props[i].queueCount * sizeof(float)); gpu->queue_reqs[i].sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO; gpu->queue_reqs[i].pNext = NULL; @@ -1281,8 +1275,7 @@ static void AppDumpExtensions(const char *indent, const char *layer_name, const static bool HasExtension(const char *extension_name, const uint32_t extension_count, const VkExtensionProperties *extension_properties) { for (uint32_t i = 0; i < extension_count; i++) { - if (!strcmp(extension_name, extension_properties[i].extensionName)) - return true; + if (!strcmp(extension_name, extension_properties[i].extensionName)) return true; } return false; } @@ -1293,7 +1286,7 @@ static void AppGpuDumpQueueProps(const struct AppGpu *gpu, uint32_t id) { printf("VkQueueFamilyProperties[%d]:\n", id); printf("===========================\n"); - char *sep = ""; // separator character + char *sep = ""; // separator character printf("\tqueueFlags = "); if (props->queueFlags & VK_QUEUE_GRAPHICS_BIT) { printf("GRAPHICS"); @@ -1332,9 +1325,8 @@ static void AppGpuDumpMemoryProps(const struct AppGpu *gpu) { // Print each named flag, if it is set. VkFlags flags = props->memoryTypes[i].propertyFlags; -#define PRINT_FLAG(FLAG) \ - if (flags & FLAG) \ - printf("\t\t\t" #FLAG "\n"); +#define PRINT_FLAG(FLAG) \ + if (flags & FLAG) printf("\t\t\t" #FLAG "\n"); PRINT_FLAG(VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) PRINT_FLAG(VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) PRINT_FLAG(VK_MEMORY_PROPERTY_HOST_COHERENT_BIT) @@ -1411,8 +1403,7 @@ int main(int argc, char **argv) { struct AppInstance inst; #ifdef _WIN32 - if (ConsoleIsExclusive()) - ConsoleEnlarge(); + if (ConsoleIsExclusive()) ConsoleEnlarge(); #endif major = VK_VERSION_MAJOR(VK_API_VERSION_1_0); @@ -1431,18 +1422,14 @@ int main(int argc, char **argv) { AppDumpExtensions("", "Instance", inst.global_extension_count, inst.global_extensions); err = vkEnumeratePhysicalDevices(inst.instance, &gpu_count, NULL); - if (err) - ERR_EXIT(err); + if (err) ERR_EXIT(err); objs = malloc(sizeof(objs[0]) * gpu_count); - if (!objs) - ERR_EXIT(VK_ERROR_OUT_OF_HOST_MEMORY); + if (!objs) ERR_EXIT(VK_ERROR_OUT_OF_HOST_MEMORY); err = vkEnumeratePhysicalDevices(inst.instance, &gpu_count, objs); - if (err) - ERR_EXIT(err); + if (err) ERR_EXIT(err); gpus = malloc(sizeof(gpus[0]) * gpu_count); - if (!gpus) - ERR_EXIT(VK_ERROR_OUT_OF_HOST_MEMORY); + if (!gpus) ERR_EXIT(VK_ERROR_OUT_OF_HOST_MEMORY); for (i = 0; i < gpu_count; i++) { AppGpuInit(&gpus[i], i, objs[i]); printf("\n\n"); @@ -1537,8 +1524,7 @@ int main(int argc, char **argv) { } #endif // TODO: Android / Wayland / MIR - if (!format_count && !present_mode_count) - printf("None found\n"); + if (!format_count && !present_mode_count) printf("None found\n"); //--------- for (i = 0; i < gpu_count; i++) { @@ -1546,8 +1532,7 @@ int main(int argc, char **argv) { printf("\n\n"); } - for (i = 0; i < gpu_count; i++) - AppGpuDestroy(&gpus[i]); + for (i = 0; i < gpu_count; i++) AppGpuDestroy(&gpus[i]); free(gpus); free(objs); @@ -1555,8 +1540,7 @@ int main(int argc, char **argv) { fflush(stdout); #ifdef _WIN32 - if (ConsoleIsExclusive()) - Sleep(INFINITE); + if (ConsoleIsExclusive()) Sleep(INFINITE); #endif return 0; diff --git a/layers/buffer_validation.h b/layers/buffer_validation.h index b8c094d..a5fd396 100644 --- a/layers/buffer_validation.h +++ b/layers/buffer_validation.h @@ -31,4 +31,4 @@ void PostCallRecordCreateImage(std::unordered_map *imageLayoutMap, const VkImageCreateInfo *pCreateInfo, VkImage *pImage); -#endif // CORE_VALIDATION_BUFFER_VALIDATION_H_ +#endif // CORE_VALIDATION_BUFFER_VALIDATION_H_ diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index e682aed..3feff50 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -72,10 +72,10 @@ #include #define LOGCONSOLE(...) ((void)__android_log_print(ANDROID_LOG_INFO, "DS", __VA_ARGS__)) #else -#define LOGCONSOLE(...) \ - { \ - printf(__VA_ARGS__); \ - printf("\n"); \ +#define LOGCONSOLE(...) \ + { \ + printf(__VA_ARGS__); \ + printf("\n"); \ } #endif @@ -139,7 +139,7 @@ struct layer_data { VkLayerDispatchTable dispatch_table; devExts device_extensions = {}; - unordered_set queues; // All queues under given device + unordered_set queues; // All queues under given device // Global set of all cmdBuffers that are inFlight on this device unordered_set globalInFlightCmdBuffers; // Layer specific data @@ -171,7 +171,7 @@ struct layer_data { VkDevice device = VK_NULL_HANDLE; VkPhysicalDevice physical_device = VK_NULL_HANDLE; - instance_layer_data *instance_data = nullptr; // from device to enclosing instance + instance_layer_data *instance_data = nullptr; // from device to enclosing instance VkPhysicalDeviceFeatures enabled_features = {}; // Device specific data @@ -190,7 +190,8 @@ static const VkLayerProperties global_layer = { "VK_LAYER_LUNARG_core_validation", VK_LAYER_API_VERSION, 1, "LunarG Validation Layer", }; -template void ValidateLayerOrdering(const TCreateInfo &createInfo) { +template +void ValidateLayerOrdering(const TCreateInfo &createInfo) { bool foundLayer = false; for (uint32_t i = 0; i < createInfo.enabledLayerCount; ++i) { if (!strcmp(createInfo.ppEnabledLayerNames[i], global_layer.layerName)) { @@ -235,13 +236,13 @@ struct spirv_inst_iter { bool operator!=(spirv_inst_iter const &other) { return it != other.it; } - spirv_inst_iter operator++(int) { // x++ + spirv_inst_iter operator++(int) { // x++ spirv_inst_iter ii = *this; it += len(); return ii; } - spirv_inst_iter operator++() { // ++x; + spirv_inst_iter operator++() { // ++x; it += len(); return *this; } @@ -261,13 +262,12 @@ struct shader_module { shader_module(VkShaderModuleCreateInfo const *pCreateInfo) : words((uint32_t *)pCreateInfo->pCode, (uint32_t *)pCreateInfo->pCode + pCreateInfo->codeSize / sizeof(uint32_t)), def_index() { - build_def_index(this); } // Expose begin() / end() to enable range-based for - spirv_inst_iter begin() const { return spirv_inst_iter(words.begin(), words.begin() + 5); } // First insn - spirv_inst_iter end() const { return spirv_inst_iter(words.begin(), words.end()); } // Just past last insn + spirv_inst_iter begin() const { return spirv_inst_iter(words.begin(), words.begin() + 5); } // First insn + spirv_inst_iter end() const { return spirv_inst_iter(words.begin(), words.end()); } // Just past last insn // Given an offset into the module, produce an iterator there. spirv_inst_iter at(unsigned offset) const { return spirv_inst_iter(words.begin(), words.begin() + offset); } @@ -408,12 +408,12 @@ SURFACE_STATE *getSurfaceState(instance_layer_data *instance_data, VkSurfaceKHR // Return ptr to memory binding for given handle of specified type static BINDABLE *GetObjectMemBinding(layer_data *my_data, uint64_t handle, VkDebugReportObjectTypeEXT type) { switch (type) { - case VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT: - return getImageState(my_data, VkImage(handle)); - case VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT: - return getBufferState(my_data, VkBuffer(handle)); - default: - break; + case VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT: + return getImageState(my_data, VkImage(handle)); + case VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT: + return getBufferState(my_data, VkBuffer(handle)); + default: + break; } return nullptr; } @@ -493,40 +493,40 @@ static void add_mem_obj_info(layer_data *my_data, void *object, const VkDeviceMe // TODO: Unify string helper functions, this should really come out of a string helper if not there already static const char *object_type_to_string(VkDebugReportObjectTypeEXT type) { switch (type) { - case VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT: - return "image"; - case VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT: - return "buffer"; - case VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_VIEW_EXT: - return "image view"; - case VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_VIEW_EXT: - return "buffer view"; - case VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT: - return "swapchain"; - case VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT: - return "descriptor set"; - case VK_DEBUG_REPORT_OBJECT_TYPE_FRAMEBUFFER_EXT: - return "framebuffer"; - case VK_DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT: - return "event"; - case VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT: - return "query pool"; - case VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT: - return "descriptor pool"; - case VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_POOL_EXT: - return "command pool"; - case VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT: - return "pipeline"; - case VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_EXT: - return "sampler"; - case VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT: - return "renderpass"; - case VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT: - return "device memory"; - case VK_DEBUG_REPORT_OBJECT_TYPE_SEMAPHORE_EXT: - return "semaphore"; - default: - return "unknown"; + case VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT: + return "image"; + case VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT: + return "buffer"; + case VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_VIEW_EXT: + return "image view"; + case VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_VIEW_EXT: + return "buffer view"; + case VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT: + return "swapchain"; + case VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT: + return "descriptor set"; + case VK_DEBUG_REPORT_OBJECT_TYPE_FRAMEBUFFER_EXT: + return "framebuffer"; + case VK_DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT: + return "event"; + case VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT: + return "query pool"; + case VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT: + return "descriptor pool"; + case VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_POOL_EXT: + return "command pool"; + case VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT: + return "pipeline"; + case VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_EXT: + return "sampler"; + case VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT: + return "renderpass"; + case VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT: + return "device memory"; + case VK_DEBUG_REPORT_OBJECT_TYPE_SEMAPHORE_EXT: + return "semaphore"; + default: + return "unknown"; } } @@ -596,7 +596,6 @@ static bool update_cmd_buf_and_mem_references(layer_data *dev_data, const VkComm // Skip validation if this image was created through WSI if (mem != MEMTRACKER_SWAP_CHAIN_IMAGE_KEY) { - // First update CB binding in MemObj mini CB list DEVICE_MEM_INFO *pMemInfo = getMemObjInfo(dev_data, mem); if (pMemInfo) { @@ -719,7 +718,7 @@ static bool ClearMemoryObjectBindings(layer_data *dev_data, uint64_t handle, VkD if (mem_binding) { if (!mem_binding->sparse) { skip = ClearMemoryObjectBinding(dev_data, handle, type, mem_binding->binding.mem); - } else { // Sparse, clear all bindings + } else { // Sparse, clear all bindings for (auto &sparse_mem_binding : mem_binding->sparse_bindings) { skip |= ClearMemoryObjectBinding(dev_data, handle, type, sparse_mem_binding.mem); } @@ -734,15 +733,15 @@ bool VerifyBoundMemoryIsValid(const layer_data *dev_data, VkDeviceMemory mem, ui bool result = false; if (VK_NULL_HANDLE == mem) { result = log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, handle, - __LINE__, error_code, "MEM", - "%s: Vk%s object 0x%" PRIxLEAST64 " used with no memory bound. Memory should be bound by calling " - "vkBind%sMemory(). %s", + __LINE__, error_code, "MEM", "%s: Vk%s object 0x%" PRIxLEAST64 + " used with no memory bound. Memory should be bound by calling " + "vkBind%sMemory(). %s", api_name, type_name, handle, type_name, validation_error_map[error_code]); } else if (MEMORY_UNBOUND == mem) { result = log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, handle, - __LINE__, error_code, "MEM", - "%s: Vk%s object 0x%" PRIxLEAST64 " used with no memory bound and previously bound memory was freed. " - "Memory must not be freed prior to this operation. %s", + __LINE__, error_code, "MEM", "%s: Vk%s object 0x%" PRIxLEAST64 + " used with no memory bound and previously bound memory was freed. " + "Memory must not be freed prior to this operation. %s", api_name, type_name, handle, validation_error_map[error_code]); } return result; @@ -856,98 +855,98 @@ static bool SetSparseMemBinding(layer_data *dev_data, MEM_BINDING binding, uint6 // Return a string representation of CMD_TYPE enum static string cmdTypeToString(CMD_TYPE cmd) { switch (cmd) { - case CMD_BINDPIPELINE: - return "CMD_BINDPIPELINE"; - case CMD_BINDPIPELINEDELTA: - return "CMD_BINDPIPELINEDELTA"; - case CMD_SETVIEWPORTSTATE: - return "CMD_SETVIEWPORTSTATE"; - case CMD_SETLINEWIDTHSTATE: - return "CMD_SETLINEWIDTHSTATE"; - case CMD_SETDEPTHBIASSTATE: - return "CMD_SETDEPTHBIASSTATE"; - case CMD_SETBLENDSTATE: - return "CMD_SETBLENDSTATE"; - case CMD_SETDEPTHBOUNDSSTATE: - return "CMD_SETDEPTHBOUNDSSTATE"; - case CMD_SETSTENCILREADMASKSTATE: - return "CMD_SETSTENCILREADMASKSTATE"; - case CMD_SETSTENCILWRITEMASKSTATE: - return "CMD_SETSTENCILWRITEMASKSTATE"; - case CMD_SETSTENCILREFERENCESTATE: - return "CMD_SETSTENCILREFERENCESTATE"; - case CMD_BINDDESCRIPTORSETS: - return "CMD_BINDDESCRIPTORSETS"; - case CMD_BINDINDEXBUFFER: - return "CMD_BINDINDEXBUFFER"; - case CMD_BINDVERTEXBUFFER: - return "CMD_BINDVERTEXBUFFER"; - case CMD_DRAW: - return "CMD_DRAW"; - case CMD_DRAWINDEXED: - return "CMD_DRAWINDEXED"; - case CMD_DRAWINDIRECT: - return "CMD_DRAWINDIRECT"; - case CMD_DRAWINDEXEDINDIRECT: - return "CMD_DRAWINDEXEDINDIRECT"; - case CMD_DISPATCH: - return "CMD_DISPATCH"; - case CMD_DISPATCHINDIRECT: - return "CMD_DISPATCHINDIRECT"; - case CMD_COPYBUFFER: - return "CMD_COPYBUFFER"; - case CMD_COPYIMAGE: - return "CMD_COPYIMAGE"; - case CMD_BLITIMAGE: - return "CMD_BLITIMAGE"; - case CMD_COPYBUFFERTOIMAGE: - return "CMD_COPYBUFFERTOIMAGE"; - case CMD_COPYIMAGETOBUFFER: - return "CMD_COPYIMAGETOBUFFER"; - case CMD_CLONEIMAGEDATA: - return "CMD_CLONEIMAGEDATA"; - case CMD_UPDATEBUFFER: - return "CMD_UPDATEBUFFER"; - case CMD_FILLBUFFER: - return "CMD_FILLBUFFER"; - case CMD_CLEARCOLORIMAGE: - return "CMD_CLEARCOLORIMAGE"; - case CMD_CLEARATTACHMENTS: - return "CMD_CLEARCOLORATTACHMENT"; - case CMD_CLEARDEPTHSTENCILIMAGE: - return "CMD_CLEARDEPTHSTENCILIMAGE"; - case CMD_RESOLVEIMAGE: - return "CMD_RESOLVEIMAGE"; - case CMD_SETEVENT: - return "CMD_SETEVENT"; - case CMD_RESETEVENT: - return "CMD_RESETEVENT"; - case CMD_WAITEVENTS: - return "CMD_WAITEVENTS"; - case CMD_PIPELINEBARRIER: - return "CMD_PIPELINEBARRIER"; - case CMD_BEGINQUERY: - return "CMD_BEGINQUERY"; - case CMD_ENDQUERY: - return "CMD_ENDQUERY"; - case CMD_RESETQUERYPOOL: - return "CMD_RESETQUERYPOOL"; - case CMD_COPYQUERYPOOLRESULTS: - return "CMD_COPYQUERYPOOLRESULTS"; - case CMD_WRITETIMESTAMP: - return "CMD_WRITETIMESTAMP"; - case CMD_INITATOMICCOUNTERS: - return "CMD_INITATOMICCOUNTERS"; - case CMD_LOADATOMICCOUNTERS: - return "CMD_LOADATOMICCOUNTERS"; - case CMD_SAVEATOMICCOUNTERS: - return "CMD_SAVEATOMICCOUNTERS"; - case CMD_BEGINRENDERPASS: - return "CMD_BEGINRENDERPASS"; - case CMD_ENDRENDERPASS: - return "CMD_ENDRENDERPASS"; - default: - return "UNKNOWN"; + case CMD_BINDPIPELINE: + return "CMD_BINDPIPELINE"; + case CMD_BINDPIPELINEDELTA: + return "CMD_BINDPIPELINEDELTA"; + case CMD_SETVIEWPORTSTATE: + return "CMD_SETVIEWPORTSTATE"; + case CMD_SETLINEWIDTHSTATE: + return "CMD_SETLINEWIDTHSTATE"; + case CMD_SETDEPTHBIASSTATE: + return "CMD_SETDEPTHBIASSTATE"; + case CMD_SETBLENDSTATE: + return "CMD_SETBLENDSTATE"; + case CMD_SETDEPTHBOUNDSSTATE: + return "CMD_SETDEPTHBOUNDSSTATE"; + case CMD_SETSTENCILREADMASKSTATE: + return "CMD_SETSTENCILREADMASKSTATE"; + case CMD_SETSTENCILWRITEMASKSTATE: + return "CMD_SETSTENCILWRITEMASKSTATE"; + case CMD_SETSTENCILREFERENCESTATE: + return "CMD_SETSTENCILREFERENCESTATE"; + case CMD_BINDDESCRIPTORSETS: + return "CMD_BINDDESCRIPTORSETS"; + case CMD_BINDINDEXBUFFER: + return "CMD_BINDINDEXBUFFER"; + case CMD_BINDVERTEXBUFFER: + return "CMD_BINDVERTEXBUFFER"; + case CMD_DRAW: + return "CMD_DRAW"; + case CMD_DRAWINDEXED: + return "CMD_DRAWINDEXED"; + case CMD_DRAWINDIRECT: + return "CMD_DRAWINDIRECT"; + case CMD_DRAWINDEXEDINDIRECT: + return "CMD_DRAWINDEXEDINDIRECT"; + case CMD_DISPATCH: + return "CMD_DISPATCH"; + case CMD_DISPATCHINDIRECT: + return "CMD_DISPATCHINDIRECT"; + case CMD_COPYBUFFER: + return "CMD_COPYBUFFER"; + case CMD_COPYIMAGE: + return "CMD_COPYIMAGE"; + case CMD_BLITIMAGE: + return "CMD_BLITIMAGE"; + case CMD_COPYBUFFERTOIMAGE: + return "CMD_COPYBUFFERTOIMAGE"; + case CMD_COPYIMAGETOBUFFER: + return "CMD_COPYIMAGETOBUFFER"; + case CMD_CLONEIMAGEDATA: + return "CMD_CLONEIMAGEDATA"; + case CMD_UPDATEBUFFER: + return "CMD_UPDATEBUFFER"; + case CMD_FILLBUFFER: + return "CMD_FILLBUFFER"; + case CMD_CLEARCOLORIMAGE: + return "CMD_CLEARCOLORIMAGE"; + case CMD_CLEARATTACHMENTS: + return "CMD_CLEARCOLORATTACHMENT"; + case CMD_CLEARDEPTHSTENCILIMAGE: + return "CMD_CLEARDEPTHSTENCILIMAGE"; + case CMD_RESOLVEIMAGE: + return "CMD_RESOLVEIMAGE"; + case CMD_SETEVENT: + return "CMD_SETEVENT"; + case CMD_RESETEVENT: + return "CMD_RESETEVENT"; + case CMD_WAITEVENTS: + return "CMD_WAITEVENTS"; + case CMD_PIPELINEBARRIER: + return "CMD_PIPELINEBARRIER"; + case CMD_BEGINQUERY: + return "CMD_BEGINQUERY"; + case CMD_ENDQUERY: + return "CMD_ENDQUERY"; + case CMD_RESETQUERYPOOL: + return "CMD_RESETQUERYPOOL"; + case CMD_COPYQUERYPOOLRESULTS: + return "CMD_COPYQUERYPOOLRESULTS"; + case CMD_WRITETIMESTAMP: + return "CMD_WRITETIMESTAMP"; + case CMD_INITATOMICCOUNTERS: + return "CMD_INITATOMICCOUNTERS"; + case CMD_LOADATOMICCOUNTERS: + return "CMD_LOADATOMICCOUNTERS"; + case CMD_SAVEATOMICCOUNTERS: + return "CMD_SAVEATOMICCOUNTERS"; + case CMD_BEGINRENDERPASS: + return "CMD_BEGINRENDERPASS"; + case CMD_ENDRENDERPASS: + return "CMD_ENDRENDERPASS"; + default: + return "UNKNOWN"; } } @@ -955,62 +954,62 @@ static string cmdTypeToString(CMD_TYPE cmd) { static void build_def_index(shader_module *module) { for (auto insn : *module) { switch (insn.opcode()) { - // Types - case spv::OpTypeVoid: - case spv::OpTypeBool: - case spv::OpTypeInt: - case spv::OpTypeFloat: - case spv::OpTypeVector: - case spv::OpTypeMatrix: - case spv::OpTypeImage: - case spv::OpTypeSampler: - case spv::OpTypeSampledImage: - case spv::OpTypeArray: - case spv::OpTypeRuntimeArray: - case spv::OpTypeStruct: - case spv::OpTypeOpaque: - case spv::OpTypePointer: - case spv::OpTypeFunction: - case spv::OpTypeEvent: - case spv::OpTypeDeviceEvent: - case spv::OpTypeReserveId: - case spv::OpTypeQueue: - case spv::OpTypePipe: - module->def_index[insn.word(1)] = insn.offset(); - break; + // Types + case spv::OpTypeVoid: + case spv::OpTypeBool: + case spv::OpTypeInt: + case spv::OpTypeFloat: + case spv::OpTypeVector: + case spv::OpTypeMatrix: + case spv::OpTypeImage: + case spv::OpTypeSampler: + case spv::OpTypeSampledImage: + case spv::OpTypeArray: + case spv::OpTypeRuntimeArray: + case spv::OpTypeStruct: + case spv::OpTypeOpaque: + case spv::OpTypePointer: + case spv::OpTypeFunction: + case spv::OpTypeEvent: + case spv::OpTypeDeviceEvent: + case spv::OpTypeReserveId: + case spv::OpTypeQueue: + case spv::OpTypePipe: + module->def_index[insn.word(1)] = insn.offset(); + break; - // Fixed constants - case spv::OpConstantTrue: - case spv::OpConstantFalse: - case spv::OpConstant: - case spv::OpConstantComposite: - case spv::OpConstantSampler: - case spv::OpConstantNull: - module->def_index[insn.word(2)] = insn.offset(); - break; + // Fixed constants + case spv::OpConstantTrue: + case spv::OpConstantFalse: + case spv::OpConstant: + case spv::OpConstantComposite: + case spv::OpConstantSampler: + case spv::OpConstantNull: + module->def_index[insn.word(2)] = insn.offset(); + break; - // Specialization constants - case spv::OpSpecConstantTrue: - case spv::OpSpecConstantFalse: - case spv::OpSpecConstant: - case spv::OpSpecConstantComposite: - case spv::OpSpecConstantOp: - module->def_index[insn.word(2)] = insn.offset(); - break; + // Specialization constants + case spv::OpSpecConstantTrue: + case spv::OpSpecConstantFalse: + case spv::OpSpecConstant: + case spv::OpSpecConstantComposite: + case spv::OpSpecConstantOp: + module->def_index[insn.word(2)] = insn.offset(); + break; - // Variables - case spv::OpVariable: - module->def_index[insn.word(2)] = insn.offset(); - break; + // Variables + case spv::OpVariable: + module->def_index[insn.word(2)] = insn.offset(); + break; - // Functions - case spv::OpFunction: - module->def_index[insn.word(2)] = insn.offset(); - break; + // Functions + case spv::OpFunction: + module->def_index[insn.word(2)] = insn.offset(); + break; - default: - // We don't care about any other defs for now. - break; + default: + // We don't care about any other defs for now. + break; } } } @@ -1032,32 +1031,32 @@ static spirv_inst_iter find_entrypoint(shader_module *src, char const *name, VkS static char const *storage_class_name(unsigned sc) { switch (sc) { - case spv::StorageClassInput: - return "input"; - case spv::StorageClassOutput: - return "output"; - case spv::StorageClassUniformConstant: - return "const uniform"; - case spv::StorageClassUniform: - return "uniform"; - case spv::StorageClassWorkgroup: - return "workgroup local"; - case spv::StorageClassCrossWorkgroup: - return "workgroup global"; - case spv::StorageClassPrivate: - return "private global"; - case spv::StorageClassFunction: - return "function"; - case spv::StorageClassGeneric: - return "generic"; - case spv::StorageClassAtomicCounter: - return "atomic counter"; - case spv::StorageClassImage: - return "image"; - case spv::StorageClassPushConstant: - return "push constant"; - default: - return "unknown"; + case spv::StorageClassInput: + return "input"; + case spv::StorageClassOutput: + return "output"; + case spv::StorageClassUniformConstant: + return "const uniform"; + case spv::StorageClassUniform: + return "uniform"; + case spv::StorageClassWorkgroup: + return "workgroup local"; + case spv::StorageClassCrossWorkgroup: + return "workgroup global"; + case spv::StorageClassPrivate: + return "private global"; + case spv::StorageClassFunction: + return "function"; + case spv::StorageClassGeneric: + return "generic"; + case spv::StorageClassAtomicCounter: + return "atomic counter"; + case spv::StorageClassImage: + return "image"; + case spv::StorageClassPushConstant: + return "push constant"; + default: + return "unknown"; } } @@ -1080,56 +1079,56 @@ static void describe_type_inner(std::ostringstream &ss, shader_module const *src assert(insn != src->end()); switch (insn.opcode()) { - case spv::OpTypeBool: - ss << "bool"; - break; - case spv::OpTypeInt: - ss << (insn.word(3) ? 's' : 'u') << "int" << insn.word(2); - break; - case spv::OpTypeFloat: - ss << "float" << insn.word(2); - break; - case spv::OpTypeVector: - ss << "vec" << insn.word(3) << " of "; - describe_type_inner(ss, src, insn.word(2)); - break; - case spv::OpTypeMatrix: - ss << "mat" << insn.word(3) << " of "; - describe_type_inner(ss, src, insn.word(2)); - break; - case spv::OpTypeArray: - ss << "arr[" << get_constant_value(src, insn.word(3)) << "] of "; - describe_type_inner(ss, src, insn.word(2)); - break; - case spv::OpTypePointer: - ss << "ptr to " << storage_class_name(insn.word(2)) << " "; - describe_type_inner(ss, src, insn.word(3)); - break; - case spv::OpTypeStruct: { - ss << "struct of ("; - for (unsigned i = 2; i < insn.len(); i++) { - describe_type_inner(ss, src, insn.word(i)); - if (i == insn.len() - 1) { - ss << ")"; - } else { - ss << ", "; + case spv::OpTypeBool: + ss << "bool"; + break; + case spv::OpTypeInt: + ss << (insn.word(3) ? 's' : 'u') << "int" << insn.word(2); + break; + case spv::OpTypeFloat: + ss << "float" << insn.word(2); + break; + case spv::OpTypeVector: + ss << "vec" << insn.word(3) << " of "; + describe_type_inner(ss, src, insn.word(2)); + break; + case spv::OpTypeMatrix: + ss << "mat" << insn.word(3) << " of "; + describe_type_inner(ss, src, insn.word(2)); + break; + case spv::OpTypeArray: + ss << "arr[" << get_constant_value(src, insn.word(3)) << "] of "; + describe_type_inner(ss, src, insn.word(2)); + break; + case spv::OpTypePointer: + ss << "ptr to " << storage_class_name(insn.word(2)) << " "; + describe_type_inner(ss, src, insn.word(3)); + break; + case spv::OpTypeStruct: { + ss << "struct of ("; + for (unsigned i = 2; i < insn.len(); i++) { + describe_type_inner(ss, src, insn.word(i)); + if (i == insn.len() - 1) { + ss << ")"; + } else { + ss << ", "; + } } + break; } - break; - } - case spv::OpTypeSampler: - ss << "sampler"; - break; - case spv::OpTypeSampledImage: - ss << "sampler+"; - describe_type_inner(ss, src, insn.word(2)); - break; - case spv::OpTypeImage: - ss << "image(dim=" << insn.word(3) << ", sampled=" << insn.word(7) << ")"; - break; - default: - ss << "oddtype"; - break; + case spv::OpTypeSampler: + ss << "sampler"; + break; + case spv::OpTypeSampledImage: + ss << "sampler+"; + describe_type_inner(ss, src, insn.word(2)); + break; + case spv::OpTypeImage: + ss << "image(dim=" << insn.word(3) << ", sampled=" << insn.word(7) << ")"; + break; + default: + ss << "oddtype"; + break; } } @@ -1140,8 +1139,7 @@ static std::string describe_type(shader_module const *src, unsigned type) { } static bool is_narrow_numeric_type(spirv_inst_iter type) { - if (type.opcode() != spv::OpTypeInt && type.opcode() != spv::OpTypeFloat) - return false; + if (type.opcode() != spv::OpTypeInt && type.opcode() != spv::OpTypeFloat) return false; return type.word(2) < 64; } @@ -1181,49 +1179,49 @@ static bool types_match(shader_module const *a, shader_module const *b, unsigned } switch (a_insn.opcode()) { - case spv::OpTypeBool: - return true; - case spv::OpTypeInt: - // Match on width, signedness - return a_insn.word(2) == b_insn.word(2) && a_insn.word(3) == b_insn.word(3); - case spv::OpTypeFloat: - // Match on width - return a_insn.word(2) == b_insn.word(2); - case spv::OpTypeVector: - // Match on element type, count. - if (!types_match(a, b, a_insn.word(2), b_insn.word(2), a_arrayed, b_arrayed, false)) - return false; - if (relaxed && is_narrow_numeric_type(a->get_def(a_insn.word(2)))) { - return a_insn.word(3) >= b_insn.word(3); - } else { - return a_insn.word(3) == b_insn.word(3); - } - case spv::OpTypeMatrix: - // Match on element type, count. - return types_match(a, b, a_insn.word(2), b_insn.word(2), a_arrayed, b_arrayed, false) && a_insn.word(3) == b_insn.word(3); - case spv::OpTypeArray: - // Match on element type, count. these all have the same layout. we don't get here if b_arrayed. This differs from - // vector & matrix types in that the array size is the id of a constant instruction, * not a literal within OpTypeArray - return types_match(a, b, a_insn.word(2), b_insn.word(2), a_arrayed, b_arrayed, false) && - get_constant_value(a, a_insn.word(3)) == get_constant_value(b, b_insn.word(3)); - case spv::OpTypeStruct: - // Match on all element types - { - if (a_insn.len() != b_insn.len()) { - return false; // Structs cannot match if member counts differ - } - - for (unsigned i = 2; i < a_insn.len(); i++) { - if (!types_match(a, b, a_insn.word(i), b_insn.word(i), a_arrayed, b_arrayed, false)) { - return false; - } + case spv::OpTypeBool: + return true; + case spv::OpTypeInt: + // Match on width, signedness + return a_insn.word(2) == b_insn.word(2) && a_insn.word(3) == b_insn.word(3); + case spv::OpTypeFloat: + // Match on width + return a_insn.word(2) == b_insn.word(2); + case spv::OpTypeVector: + // Match on element type, count. + if (!types_match(a, b, a_insn.word(2), b_insn.word(2), a_arrayed, b_arrayed, false)) return false; + if (relaxed && is_narrow_numeric_type(a->get_def(a_insn.word(2)))) { + return a_insn.word(3) >= b_insn.word(3); + } else { + return a_insn.word(3) == b_insn.word(3); } + case spv::OpTypeMatrix: + // Match on element type, count. + return types_match(a, b, a_insn.word(2), b_insn.word(2), a_arrayed, b_arrayed, false) && + a_insn.word(3) == b_insn.word(3); + case spv::OpTypeArray: + // Match on element type, count. these all have the same layout. we don't get here if b_arrayed. This differs from + // vector & matrix types in that the array size is the id of a constant instruction, * not a literal within OpTypeArray + return types_match(a, b, a_insn.word(2), b_insn.word(2), a_arrayed, b_arrayed, false) && + get_constant_value(a, a_insn.word(3)) == get_constant_value(b, b_insn.word(3)); + case spv::OpTypeStruct: + // Match on all element types + { + if (a_insn.len() != b_insn.len()) { + return false; // Structs cannot match if member counts differ + } - return true; - } - default: - // Remaining types are CLisms, or may not appear in the interfaces we are interested in. Just claim no match. - return false; + for (unsigned i = 2; i < a_insn.len(); i++) { + if (!types_match(a, b, a_insn.word(i), b_insn.word(i), a_arrayed, b_arrayed, false)) { + return false; + } + } + + return true; + } + default: + // Remaining types are CLisms, or may not appear in the interfaces we are interested in. Just claim no match. + return false; } } @@ -1240,46 +1238,46 @@ static unsigned get_locations_consumed_by_type(shader_module const *src, unsigne assert(insn != src->end()); switch (insn.opcode()) { - case spv::OpTypePointer: - // See through the ptr -- this is only ever at the toplevel for graphics shaders we're never actually passing - // pointers around. - return get_locations_consumed_by_type(src, insn.word(3), strip_array_level); - case spv::OpTypeArray: - if (strip_array_level) { - return get_locations_consumed_by_type(src, insn.word(2), false); - } else { - return get_constant_value(src, insn.word(3)) * get_locations_consumed_by_type(src, insn.word(2), false); - } - case spv::OpTypeMatrix: - // Num locations is the dimension * element size - return insn.word(3) * get_locations_consumed_by_type(src, insn.word(2), false); - case spv::OpTypeVector: { - auto scalar_type = src->get_def(insn.word(2)); - auto bit_width = - (scalar_type.opcode() == spv::OpTypeInt || scalar_type.opcode() == spv::OpTypeFloat) ? scalar_type.word(2) : 32; + case spv::OpTypePointer: + // See through the ptr -- this is only ever at the toplevel for graphics shaders we're never actually passing + // pointers around. + return get_locations_consumed_by_type(src, insn.word(3), strip_array_level); + case spv::OpTypeArray: + if (strip_array_level) { + return get_locations_consumed_by_type(src, insn.word(2), false); + } else { + return get_constant_value(src, insn.word(3)) * get_locations_consumed_by_type(src, insn.word(2), false); + } + case spv::OpTypeMatrix: + // Num locations is the dimension * element size + return insn.word(3) * get_locations_consumed_by_type(src, insn.word(2), false); + case spv::OpTypeVector: { + auto scalar_type = src->get_def(insn.word(2)); + auto bit_width = + (scalar_type.opcode() == spv::OpTypeInt || scalar_type.opcode() == spv::OpTypeFloat) ? scalar_type.word(2) : 32; - // Locations are 128-bit wide; 3- and 4-component vectors of 64 bit types require two. - return (bit_width * insn.word(3) + 127) / 128; - } - default: - // Everything else is just 1. - return 1; + // Locations are 128-bit wide; 3- and 4-component vectors of 64 bit types require two. + return (bit_width * insn.word(3) + 127) / 128; + } + default: + // Everything else is just 1. + return 1; - // TODO: extend to handle 64bit scalar types, whose vectors may need multiple locations. + // TODO: extend to handle 64bit scalar types, whose vectors may need multiple locations. } } static unsigned get_locations_consumed_by_format(VkFormat format) { switch (format) { - case VK_FORMAT_R64G64B64A64_SFLOAT: - case VK_FORMAT_R64G64B64A64_SINT: - case VK_FORMAT_R64G64B64A64_UINT: - case VK_FORMAT_R64G64B64_SFLOAT: - case VK_FORMAT_R64G64B64_SINT: - case VK_FORMAT_R64G64B64_UINT: - return 2; - default: - return 1; + case VK_FORMAT_R64G64B64A64_SFLOAT: + case VK_FORMAT_R64G64B64A64_SINT: + case VK_FORMAT_R64G64B64A64_UINT: + case VK_FORMAT_R64G64B64_SFLOAT: + case VK_FORMAT_R64G64B64_SINT: + case VK_FORMAT_R64G64B64_UINT: + return 2; + default: + return 1; } } @@ -1309,7 +1307,6 @@ static shader_stage_attributes shader_stage_attribs[] = { static spirv_inst_iter get_struct_type(shader_module const *src, spirv_inst_iter def, bool is_array_of_verts) { while (true) { - if (def.opcode() == spv::OpTypePointer) { def = src->get_def(def.word(3)); } else if (def.opcode() == spv::OpTypeArray && is_array_of_verts) { @@ -1383,7 +1380,6 @@ static void collect_interface_block_members(shader_module const *src, std::map collect_interface_by_location(shader_module const *src, spirv_inst_iter entrypoint, spv::StorageClass sinterface, bool is_array_of_verts) { - std::unordered_map var_locations; std::unordered_map var_builtins; std::unordered_map var_components; @@ -1392,7 +1388,6 @@ static std::map collect_interface_by_location(shader_ std::unordered_map var_relaxed_precision; for (auto insn : *src) { - // We consider two interface models: SSO rendezvous-by-location, and builtins. Complain about anything that // fits neither model. if (insn.opcode() == spv::OpDecorate) { @@ -1446,7 +1441,7 @@ static std::map collect_interface_by_location(shader_ int location = value_or_default(var_locations, id, -1); int builtin = value_or_default(var_builtins, id, -1); - unsigned component = value_or_default(var_components, id, 0); // Unspecified is OK, is 0 + unsigned component = value_or_default(var_components, id, 0); // Unspecified is OK, is 0 bool is_patch = var_patch.find(id) != var_patch.end(); bool is_relaxed_precision = var_relaxed_precision.find(id) != var_relaxed_precision.end(); @@ -1480,10 +1475,8 @@ static std::map collect_interface_by_location(shader_ return out; } -static std::vector> -collect_interface_by_input_attachment_index(debug_report_data *report_data, shader_module const *src, - std::unordered_set const &accessible_ids) { - +static std::vector> collect_interface_by_input_attachment_index( + debug_report_data *report_data, shader_module const *src, std::unordered_set const &accessible_ids) { std::vector> out; for (auto insn : *src) { @@ -1514,10 +1507,8 @@ collect_interface_by_input_attachment_index(debug_report_data *report_data, shad return out; } -static std::vector> -collect_interface_by_descriptor_slot(debug_report_data *report_data, shader_module const *src, - std::unordered_set const &accessible_ids) { - +static std::vector> collect_interface_by_descriptor_slot( + debug_report_data *report_data, shader_module const *src, std::unordered_set const &accessible_ids) { std::unordered_map var_sets; std::unordered_map var_bindings; @@ -1634,61 +1625,61 @@ static bool validate_interface_between_stages(debug_report_data *report_data, sh enum FORMAT_TYPE { FORMAT_TYPE_UNDEFINED, - FORMAT_TYPE_FLOAT, // UNORM, SNORM, FLOAT, USCALED, SSCALED, SRGB -- anything we consider float in the shader + FORMAT_TYPE_FLOAT, // UNORM, SNORM, FLOAT, USCALED, SSCALED, SRGB -- anything we consider float in the shader FORMAT_TYPE_SINT, FORMAT_TYPE_UINT, }; static unsigned get_format_type(VkFormat fmt) { switch (fmt) { - case VK_FORMAT_UNDEFINED: - return FORMAT_TYPE_UNDEFINED; - case VK_FORMAT_R8_SINT: - case VK_FORMAT_R8G8_SINT: - case VK_FORMAT_R8G8B8_SINT: - case VK_FORMAT_R8G8B8A8_SINT: - case VK_FORMAT_R16_SINT: - case VK_FORMAT_R16G16_SINT: - case VK_FORMAT_R16G16B16_SINT: - case VK_FORMAT_R16G16B16A16_SINT: - case VK_FORMAT_R32_SINT: - case VK_FORMAT_R32G32_SINT: - case VK_FORMAT_R32G32B32_SINT: - case VK_FORMAT_R32G32B32A32_SINT: - case VK_FORMAT_R64_SINT: - case VK_FORMAT_R64G64_SINT: - case VK_FORMAT_R64G64B64_SINT: - case VK_FORMAT_R64G64B64A64_SINT: - case VK_FORMAT_B8G8R8_SINT: - case VK_FORMAT_B8G8R8A8_SINT: - case VK_FORMAT_A8B8G8R8_SINT_PACK32: - case VK_FORMAT_A2B10G10R10_SINT_PACK32: - case VK_FORMAT_A2R10G10B10_SINT_PACK32: - return FORMAT_TYPE_SINT; - case VK_FORMAT_R8_UINT: - case VK_FORMAT_R8G8_UINT: - case VK_FORMAT_R8G8B8_UINT: - case VK_FORMAT_R8G8B8A8_UINT: - case VK_FORMAT_R16_UINT: - case VK_FORMAT_R16G16_UINT: - case VK_FORMAT_R16G16B16_UINT: - case VK_FORMAT_R16G16B16A16_UINT: - case VK_FORMAT_R32_UINT: - case VK_FORMAT_R32G32_UINT: - case VK_FORMAT_R32G32B32_UINT: - case VK_FORMAT_R32G32B32A32_UINT: - case VK_FORMAT_R64_UINT: - case VK_FORMAT_R64G64_UINT: - case VK_FORMAT_R64G64B64_UINT: - case VK_FORMAT_R64G64B64A64_UINT: - case VK_FORMAT_B8G8R8_UINT: - case VK_FORMAT_B8G8R8A8_UINT: - case VK_FORMAT_A8B8G8R8_UINT_PACK32: - case VK_FORMAT_A2B10G10R10_UINT_PACK32: - case VK_FORMAT_A2R10G10B10_UINT_PACK32: - return FORMAT_TYPE_UINT; - default: - return FORMAT_TYPE_FLOAT; + case VK_FORMAT_UNDEFINED: + return FORMAT_TYPE_UNDEFINED; + case VK_FORMAT_R8_SINT: + case VK_FORMAT_R8G8_SINT: + case VK_FORMAT_R8G8B8_SINT: + case VK_FORMAT_R8G8B8A8_SINT: + case VK_FORMAT_R16_SINT: + case VK_FORMAT_R16G16_SINT: + case VK_FORMAT_R16G16B16_SINT: + case VK_FORMAT_R16G16B16A16_SINT: + case VK_FORMAT_R32_SINT: + case VK_FORMAT_R32G32_SINT: + case VK_FORMAT_R32G32B32_SINT: + case VK_FORMAT_R32G32B32A32_SINT: + case VK_FORMAT_R64_SINT: + case VK_FORMAT_R64G64_SINT: + case VK_FORMAT_R64G64B64_SINT: + case VK_FORMAT_R64G64B64A64_SINT: + case VK_FORMAT_B8G8R8_SINT: + case VK_FORMAT_B8G8R8A8_SINT: + case VK_FORMAT_A8B8G8R8_SINT_PACK32: + case VK_FORMAT_A2B10G10R10_SINT_PACK32: + case VK_FORMAT_A2R10G10B10_SINT_PACK32: + return FORMAT_TYPE_SINT; + case VK_FORMAT_R8_UINT: + case VK_FORMAT_R8G8_UINT: + case VK_FORMAT_R8G8B8_UINT: + case VK_FORMAT_R8G8B8A8_UINT: + case VK_FORMAT_R16_UINT: + case VK_FORMAT_R16G16_UINT: + case VK_FORMAT_R16G16B16_UINT: + case VK_FORMAT_R16G16B16A16_UINT: + case VK_FORMAT_R32_UINT: + case VK_FORMAT_R32G32_UINT: + case VK_FORMAT_R32G32B32_UINT: + case VK_FORMAT_R32G32B32A32_UINT: + case VK_FORMAT_R64_UINT: + case VK_FORMAT_R64G64_UINT: + case VK_FORMAT_R64G64B64_UINT: + case VK_FORMAT_R64G64B64A64_UINT: + case VK_FORMAT_B8G8R8_UINT: + case VK_FORMAT_B8G8R8A8_UINT: + case VK_FORMAT_A8B8G8R8_UINT_PACK32: + case VK_FORMAT_A2B10G10R10_UINT_PACK32: + case VK_FORMAT_A2R10G10B10_UINT_PACK32: + return FORMAT_TYPE_UINT; + default: + return FORMAT_TYPE_FLOAT; } } @@ -1698,23 +1689,23 @@ static unsigned get_fundamental_type(shader_module const *src, unsigned type) { assert(insn != src->end()); switch (insn.opcode()) { - case spv::OpTypeInt: - return insn.word(3) ? FORMAT_TYPE_SINT : FORMAT_TYPE_UINT; - case spv::OpTypeFloat: - return FORMAT_TYPE_FLOAT; - case spv::OpTypeVector: - return get_fundamental_type(src, insn.word(2)); - case spv::OpTypeMatrix: - return get_fundamental_type(src, insn.word(2)); - case spv::OpTypeArray: - return get_fundamental_type(src, insn.word(2)); - case spv::OpTypePointer: - return get_fundamental_type(src, insn.word(3)); - case spv::OpTypeImage: - return get_fundamental_type(src, insn.word(2)); - - default: - return FORMAT_TYPE_UNDEFINED; + case spv::OpTypeInt: + return insn.word(3) ? FORMAT_TYPE_SINT : FORMAT_TYPE_UINT; + case spv::OpTypeFloat: + return FORMAT_TYPE_FLOAT; + case spv::OpTypeVector: + return get_fundamental_type(src, insn.word(2)); + case spv::OpTypeMatrix: + return get_fundamental_type(src, insn.word(2)); + case spv::OpTypeArray: + return get_fundamental_type(src, insn.word(2)); + case spv::OpTypePointer: + return get_fundamental_type(src, insn.word(3)); + case spv::OpTypeImage: + return get_fundamental_type(src, insn.word(2)); + + default: + return FORMAT_TYPE_UNDEFINED; } } @@ -1818,8 +1809,7 @@ static bool validate_fs_outputs_against_render_pass(debug_report_data *report_da auto subpass = rpci->pSubpasses[subpass_index]; for (auto i = 0u; i < subpass.colorAttachmentCount; ++i) { uint32_t attachment = subpass.pColorAttachments[i].attachment; - if (attachment == VK_ATTACHMENT_UNUSED) - continue; + if (attachment == VK_ATTACHMENT_UNUSED) continue; if (rpci->pAttachments[attachment].format != VK_FORMAT_UNDEFINED) { color_attachments[i] = rpci->pAttachments[attachment].format; } @@ -1902,92 +1892,92 @@ static std::unordered_set mark_accessible_ids(shader_module const *src // Try to add to the output set if (!ids.insert(id).second) { - continue; // If we already saw this id, we don't want to walk it again. + continue; // If we already saw this id, we don't want to walk it again. } switch (insn.opcode()) { - case spv::OpFunction: - // Scan whole body of the function, enlisting anything interesting - while (++insn, insn.opcode() != spv::OpFunctionEnd) { - switch (insn.opcode()) { - case spv::OpLoad: - case spv::OpAtomicLoad: - case spv::OpAtomicExchange: - case spv::OpAtomicCompareExchange: - case spv::OpAtomicCompareExchangeWeak: - case spv::OpAtomicIIncrement: - case spv::OpAtomicIDecrement: - case spv::OpAtomicIAdd: - case spv::OpAtomicISub: - case spv::OpAtomicSMin: - case spv::OpAtomicUMin: - case spv::OpAtomicSMax: - case spv::OpAtomicUMax: - case spv::OpAtomicAnd: - case spv::OpAtomicOr: - case spv::OpAtomicXor: - worklist.insert(insn.word(3)); // ptr - break; - case spv::OpStore: - case spv::OpAtomicStore: - worklist.insert(insn.word(1)); // ptr - break; - case spv::OpAccessChain: - case spv::OpInBoundsAccessChain: - worklist.insert(insn.word(3)); // base ptr - break; - case spv::OpSampledImage: - case spv::OpImageSampleImplicitLod: - case spv::OpImageSampleExplicitLod: - case spv::OpImageSampleDrefImplicitLod: - case spv::OpImageSampleDrefExplicitLod: - case spv::OpImageSampleProjImplicitLod: - case spv::OpImageSampleProjExplicitLod: - case spv::OpImageSampleProjDrefImplicitLod: - case spv::OpImageSampleProjDrefExplicitLod: - case spv::OpImageFetch: - case spv::OpImageGather: - case spv::OpImageDrefGather: - case spv::OpImageRead: - case spv::OpImage: - case spv::OpImageQueryFormat: - case spv::OpImageQueryOrder: - case spv::OpImageQuerySizeLod: - case spv::OpImageQuerySize: - case spv::OpImageQueryLod: - case spv::OpImageQueryLevels: - case spv::OpImageQuerySamples: - case spv::OpImageSparseSampleImplicitLod: - case spv::OpImageSparseSampleExplicitLod: - case spv::OpImageSparseSampleDrefImplicitLod: - case spv::OpImageSparseSampleDrefExplicitLod: - case spv::OpImageSparseSampleProjImplicitLod: - case spv::OpImageSparseSampleProjExplicitLod: - case spv::OpImageSparseSampleProjDrefImplicitLod: - case spv::OpImageSparseSampleProjDrefExplicitLod: - case spv::OpImageSparseFetch: - case spv::OpImageSparseGather: - case spv::OpImageSparseDrefGather: - case spv::OpImageTexelPointer: - worklist.insert(insn.word(3)); // Image or sampled image - break; - case spv::OpImageWrite: - worklist.insert(insn.word(1)); // Image -- different operand order to above - break; - case spv::OpFunctionCall: - for (uint32_t i = 3; i < insn.len(); i++) { - worklist.insert(insn.word(i)); // fn itself, and all args - } - break; + case spv::OpFunction: + // Scan whole body of the function, enlisting anything interesting + while (++insn, insn.opcode() != spv::OpFunctionEnd) { + switch (insn.opcode()) { + case spv::OpLoad: + case spv::OpAtomicLoad: + case spv::OpAtomicExchange: + case spv::OpAtomicCompareExchange: + case spv::OpAtomicCompareExchangeWeak: + case spv::OpAtomicIIncrement: + case spv::OpAtomicIDecrement: + case spv::OpAtomicIAdd: + case spv::OpAtomicISub: + case spv::OpAtomicSMin: + case spv::OpAtomicUMin: + case spv::OpAtomicSMax: + case spv::OpAtomicUMax: + case spv::OpAtomicAnd: + case spv::OpAtomicOr: + case spv::OpAtomicXor: + worklist.insert(insn.word(3)); // ptr + break; + case spv::OpStore: + case spv::OpAtomicStore: + worklist.insert(insn.word(1)); // ptr + break; + case spv::OpAccessChain: + case spv::OpInBoundsAccessChain: + worklist.insert(insn.word(3)); // base ptr + break; + case spv::OpSampledImage: + case spv::OpImageSampleImplicitLod: + case spv::OpImageSampleExplicitLod: + case spv::OpImageSampleDrefImplicitLod: + case spv::OpImageSampleDrefExplicitLod: + case spv::OpImageSampleProjImplicitLod: + case spv::OpImageSampleProjExplicitLod: + case spv::OpImageSampleProjDrefImplicitLod: + case spv::OpImageSampleProjDrefExplicitLod: + case spv::OpImageFetch: + case spv::OpImageGather: + case spv::OpImageDrefGather: + case spv::OpImageRead: + case spv::OpImage: + case spv::OpImageQueryFormat: + case spv::OpImageQueryOrder: + case spv::OpImageQuerySizeLod: + case spv::OpImageQuerySize: + case spv::OpImageQueryLod: + case spv::OpImageQueryLevels: + case spv::OpImageQuerySamples: + case spv::OpImageSparseSampleImplicitLod: + case spv::OpImageSparseSampleExplicitLod: + case spv::OpImageSparseSampleDrefImplicitLod: + case spv::OpImageSparseSampleDrefExplicitLod: + case spv::OpImageSparseSampleProjImplicitLod: + case spv::OpImageSparseSampleProjExplicitLod: + case spv::OpImageSparseSampleProjDrefImplicitLod: + case spv::OpImageSparseSampleProjDrefExplicitLod: + case spv::OpImageSparseFetch: + case spv::OpImageSparseGather: + case spv::OpImageSparseDrefGather: + case spv::OpImageTexelPointer: + worklist.insert(insn.word(3)); // Image or sampled image + break; + case spv::OpImageWrite: + worklist.insert(insn.word(1)); // Image -- different operand order to above + break; + case spv::OpFunctionCall: + for (uint32_t i = 3; i < insn.len(); i++) { + worklist.insert(insn.word(i)); // fn itself, and all args + } + break; - case spv::OpExtInst: - for (uint32_t i = 5; i < insn.len(); i++) { - worklist.insert(insn.word(i)); // Operands to ext inst + case spv::OpExtInst: + for (uint32_t i = 5; i < insn.len(); i++) { + worklist.insert(insn.word(i)); // Operands to ext inst + } + break; } - break; } - } - break; + break; } } @@ -2008,10 +1998,9 @@ static bool validate_push_constant_block_against_pipeline(debug_report_data *rep // TODO: arrays, matrices, weird sizes for (auto insn : *src) { if (insn.opcode() == spv::OpMemberDecorate && insn.word(1) == type.word(1)) { - if (insn.word(3) == spv::DecorationOffset) { unsigned offset = insn.word(4); - auto size = 4; // Bytes; TODO: calculate this based on the type + auto size = 4; // Bytes; TODO: calculate this based on the type bool found_range = false; for (auto const &range : *push_constant_ranges) { @@ -2068,12 +2057,9 @@ static bool validate_push_constant_usage(debug_report_data *report_data, // has the requested binding at slot.second and return ptr to that binding static VkDescriptorSetLayoutBinding const *get_descriptor_binding(PIPELINE_LAYOUT_NODE const *pipelineLayout, descriptor_slot_t slot) { + if (!pipelineLayout) return nullptr; - if (!pipelineLayout) - return nullptr; - - if (slot.first >= pipelineLayout->set_layouts.size()) - return nullptr; + if (slot.first >= pipelineLayout->set_layouts.size()) return nullptr; return pipelineLayout->set_layouts[slot.first]->GetDescriptorSetLayoutBindingPtrFromBinding(slot.second); } @@ -2087,8 +2073,7 @@ static VkDescriptorSetLayoutBinding const *get_descriptor_binding(PIPELINE_LAYOU static bool hasDrawCmd(GLOBAL_CB_NODE *pCB) { for (uint32_t i = 0; i < NUM_DRAW_TYPES; i++) { - if (pCB->drawCount[i]) - return true; + if (pCB->drawCount[i]) return true; } return false; } @@ -2150,8 +2135,7 @@ static PIPELINE_LAYOUT_NODE const *getPipelineLayout(layer_data const *my_data, static bool isDynamic(const PIPELINE_STATE *pPipeline, const VkDynamicState state) { if (pPipeline && pPipeline->graphicsPipelineCI.pDynamicState) { for (uint32_t i = 0; i < pPipeline->graphicsPipelineCI.pDynamicState->dynamicStateCount; i++) { - if (state == pPipeline->graphicsPipelineCI.pDynamicState->pDynamicStates[i]) - return true; + if (state == pPipeline->graphicsPipelineCI.pDynamicState->pDynamicStates[i]) return true; } } return false; @@ -2216,13 +2200,11 @@ static bool attachment_references_compatible(const uint32_t index, const VkAttac } else if (pSecondary == nullptr) { return false; } - if (index >= primaryCount) { // Check secondary as if primary is VK_ATTACHMENT_UNUSED - if (VK_ATTACHMENT_UNUSED == pSecondary[index].attachment) - return true; - } else if (index >= secondaryCount) { // Check primary as if secondary is VK_ATTACHMENT_UNUSED - if (VK_ATTACHMENT_UNUSED == pPrimary[index].attachment) - return true; - } else { // Format and sample count must match + if (index >= primaryCount) { // Check secondary as if primary is VK_ATTACHMENT_UNUSED + if (VK_ATTACHMENT_UNUSED == pSecondary[index].attachment) return true; + } else if (index >= secondaryCount) { // Check primary as if secondary is VK_ATTACHMENT_UNUSED + if (VK_ATTACHMENT_UNUSED == pPrimary[index].attachment) return true; + } else { // Format and sample count must match if ((pPrimary[index].attachment == VK_ATTACHMENT_UNUSED) && (pSecondary[index].attachment == VK_ATTACHMENT_UNUSED)) { return true; } else if ((pPrimary[index].attachment == VK_ATTACHMENT_UNUSED) || (pSecondary[index].attachment == VK_ATTACHMENT_UNUSED)) { @@ -2335,7 +2317,6 @@ static bool validate_specialization_offsets(debug_report_data *report_data, VkPi i, spec->pMapEntries[i].constantID, spec->pMapEntries[i].offset, spec->pMapEntries[i].offset + spec->pMapEntries[i].size - 1, spec->dataSize, validation_error_map[VALIDATION_ERROR_00590])) { - pass = false; } } @@ -2362,70 +2343,71 @@ static bool descriptor_type_match(shader_module const *module, uint32_t type_id, } switch (type.opcode()) { - case spv::OpTypeStruct: { - for (auto insn : *module) { - if (insn.opcode() == spv::OpDecorate && insn.word(1) == type.word(1)) { - if (insn.word(2) == spv::DecorationBlock) { - return descriptor_type == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER || - descriptor_type == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; - } else if (insn.word(2) == spv::DecorationBufferBlock) { - return descriptor_type == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER || - descriptor_type == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC; + case spv::OpTypeStruct: { + for (auto insn : *module) { + if (insn.opcode() == spv::OpDecorate && insn.word(1) == type.word(1)) { + if (insn.word(2) == spv::DecorationBlock) { + return descriptor_type == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER || + descriptor_type == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; + } else if (insn.word(2) == spv::DecorationBufferBlock) { + return descriptor_type == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER || + descriptor_type == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC; + } } } - } - // Invalid - return false; - } + // Invalid + return false; + } - case spv::OpTypeSampler: - return descriptor_type == VK_DESCRIPTOR_TYPE_SAMPLER || descriptor_type == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; + case spv::OpTypeSampler: + return descriptor_type == VK_DESCRIPTOR_TYPE_SAMPLER || descriptor_type == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; - case spv::OpTypeSampledImage: - if (descriptor_type == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) { - // Slight relaxation for some GLSL historical madness: samplerBuffer doesn't really have a sampler, and a texel - // buffer descriptor doesn't really provide one. Allow this slight mismatch. - auto image_type = module->get_def(type.word(2)); - auto dim = image_type.word(3); - auto sampled = image_type.word(7); - return dim == spv::DimBuffer && sampled == 1; - } - return descriptor_type == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; + case spv::OpTypeSampledImage: + if (descriptor_type == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) { + // Slight relaxation for some GLSL historical madness: samplerBuffer doesn't really have a sampler, and a texel + // buffer descriptor doesn't really provide one. Allow this slight mismatch. + auto image_type = module->get_def(type.word(2)); + auto dim = image_type.word(3); + auto sampled = image_type.word(7); + return dim == spv::DimBuffer && sampled == 1; + } + return descriptor_type == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; - case spv::OpTypeImage: { - // Many descriptor types backing image types-- depends on dimension and whether the image will be used with a sampler. - // SPIRV for Vulkan requires that sampled be 1 or 2 -- leaving the decision to runtime is unacceptable. - auto dim = type.word(3); - auto sampled = type.word(7); + case spv::OpTypeImage: { + // Many descriptor types backing image types-- depends on dimension and whether the image will be used with a sampler. + // SPIRV for Vulkan requires that sampled be 1 or 2 -- leaving the decision to runtime is unacceptable. + auto dim = type.word(3); + auto sampled = type.word(7); - if (dim == spv::DimSubpassData) { - return descriptor_type == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; - } else if (dim == spv::DimBuffer) { - if (sampled == 1) { - return descriptor_type == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; + if (dim == spv::DimSubpassData) { + return descriptor_type == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; + } else if (dim == spv::DimBuffer) { + if (sampled == 1) { + return descriptor_type == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; + } else { + return descriptor_type == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; + } + } else if (sampled == 1) { + return descriptor_type == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE || + descriptor_type == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; } else { - return descriptor_type == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; + return descriptor_type == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; } - } else if (sampled == 1) { - return descriptor_type == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE || - descriptor_type == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; - } else { - return descriptor_type == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; } - } - // We shouldn't really see any other junk types -- but if we do, they're a mismatch. - default: - return false; // Mismatch + // We shouldn't really see any other junk types -- but if we do, they're a mismatch. + default: + return false; // Mismatch } } static bool require_feature(debug_report_data *report_data, VkBool32 feature, char const *feature_name) { if (!feature) { if (log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VkDebugReportObjectTypeEXT(0), 0, __LINE__, - SHADER_CHECKER_FEATURE_NOT_ENABLED, "SC", "Shader requires VkPhysicalDeviceFeatures::%s but is not " - "enabled on the device", + SHADER_CHECKER_FEATURE_NOT_ENABLED, "SC", + "Shader requires VkPhysicalDeviceFeatures::%s but is not " + "enabled on the device", feature_name)) { return false; } @@ -2441,131 +2423,131 @@ static bool validate_shader_capabilities(debug_report_data *report_data, shader_ for (auto insn : *src) { if (insn.opcode() == spv::OpCapability) { switch (insn.word(1)) { - case spv::CapabilityMatrix: - case spv::CapabilityShader: - case spv::CapabilityInputAttachment: - case spv::CapabilitySampled1D: - case spv::CapabilityImage1D: - case spv::CapabilitySampledBuffer: - case spv::CapabilityImageBuffer: - case spv::CapabilityImageQuery: - case spv::CapabilityDerivativeControl: - // Always supported by a Vulkan 1.0 implementation -- no feature bits. - break; + case spv::CapabilityMatrix: + case spv::CapabilityShader: + case spv::CapabilityInputAttachment: + case spv::CapabilitySampled1D: + case spv::CapabilityImage1D: + case spv::CapabilitySampledBuffer: + case spv::CapabilityImageBuffer: + case spv::CapabilityImageQuery: + case spv::CapabilityDerivativeControl: + // Always supported by a Vulkan 1.0 implementation -- no feature bits. + break; - case spv::CapabilityGeometry: - pass &= require_feature(report_data, enabledFeatures->geometryShader, "geometryShader"); - break; + case spv::CapabilityGeometry: + pass &= require_feature(report_data, enabledFeatures->geometryShader, "geometryShader"); + break; - case spv::CapabilityTessellation: - pass &= require_feature(report_data, enabledFeatures->tessellationShader, "tessellationShader"); - break; + case spv::CapabilityTessellation: + pass &= require_feature(report_data, enabledFeatures->tessellationShader, "tessellationShader"); + break; - case spv::CapabilityFloat64: - pass &= require_feature(report_data, enabledFeatures->shaderFloat64, "shaderFloat64"); - break; + case spv::CapabilityFloat64: + pass &= require_feature(report_data, enabledFeatures->shaderFloat64, "shaderFloat64"); + break; - case spv::CapabilityInt64: - pass &= require_feature(report_data, enabledFeatures->shaderInt64, "shaderInt64"); - break; + case spv::CapabilityInt64: + pass &= require_feature(report_data, enabledFeatures->shaderInt64, "shaderInt64"); + break; - case spv::CapabilityTessellationPointSize: - case spv::CapabilityGeometryPointSize: - pass &= require_feature(report_data, enabledFeatures->shaderTessellationAndGeometryPointSize, - "shaderTessellationAndGeometryPointSize"); - break; + case spv::CapabilityTessellationPointSize: + case spv::CapabilityGeometryPointSize: + pass &= require_feature(report_data, enabledFeatures->shaderTessellationAndGeometryPointSize, + "shaderTessellationAndGeometryPointSize"); + break; - case spv::CapabilityImageGatherExtended: - pass &= require_feature(report_data, enabledFeatures->shaderImageGatherExtended, "shaderImageGatherExtended"); - break; + case spv::CapabilityImageGatherExtended: + pass &= require_feature(report_data, enabledFeatures->shaderImageGatherExtended, "shaderImageGatherExtended"); + break; - case spv::CapabilityStorageImageMultisample: - pass &= - require_feature(report_data, enabledFeatures->shaderStorageImageMultisample, "shaderStorageImageMultisample"); - break; + case spv::CapabilityStorageImageMultisample: + pass &= require_feature(report_data, enabledFeatures->shaderStorageImageMultisample, + "shaderStorageImageMultisample"); + break; - case spv::CapabilityUniformBufferArrayDynamicIndexing: - pass &= require_feature(report_data, enabledFeatures->shaderUniformBufferArrayDynamicIndexing, - "shaderUniformBufferArrayDynamicIndexing"); - break; + case spv::CapabilityUniformBufferArrayDynamicIndexing: + pass &= require_feature(report_data, enabledFeatures->shaderUniformBufferArrayDynamicIndexing, + "shaderUniformBufferArrayDynamicIndexing"); + break; - case spv::CapabilitySampledImageArrayDynamicIndexing: - pass &= require_feature(report_data, enabledFeatures->shaderSampledImageArrayDynamicIndexing, - "shaderSampledImageArrayDynamicIndexing"); - break; + case spv::CapabilitySampledImageArrayDynamicIndexing: + pass &= require_feature(report_data, enabledFeatures->shaderSampledImageArrayDynamicIndexing, + "shaderSampledImageArrayDynamicIndexing"); + break; - case spv::CapabilityStorageBufferArrayDynamicIndexing: - pass &= require_feature(report_data, enabledFeatures->shaderStorageBufferArrayDynamicIndexing, - "shaderStorageBufferArrayDynamicIndexing"); - break; + case spv::CapabilityStorageBufferArrayDynamicIndexing: + pass &= require_feature(report_data, enabledFeatures->shaderStorageBufferArrayDynamicIndexing, + "shaderStorageBufferArrayDynamicIndexing"); + break; - case spv::CapabilityStorageImageArrayDynamicIndexing: - pass &= require_feature(report_data, enabledFeatures->shaderStorageImageArrayDynamicIndexing, - "shaderStorageImageArrayDynamicIndexing"); - break; + case spv::CapabilityStorageImageArrayDynamicIndexing: + pass &= require_feature(report_data, enabledFeatures->shaderStorageImageArrayDynamicIndexing, + "shaderStorageImageArrayDynamicIndexing"); + break; - case spv::CapabilityClipDistance: - pass &= require_feature(report_data, enabledFeatures->shaderClipDistance, "shaderClipDistance"); - break; + case spv::CapabilityClipDistance: + pass &= require_feature(report_data, enabledFeatures->shaderClipDistance, "shaderClipDistance"); + break; - case spv::CapabilityCullDistance: - pass &= require_feature(report_data, enabledFeatures->shaderCullDistance, "shaderCullDistance"); - break; + case spv::CapabilityCullDistance: + pass &= require_feature(report_data, enabledFeatures->shaderCullDistance, "shaderCullDistance"); + break; - case spv::CapabilityImageCubeArray: - pass &= require_feature(report_data, enabledFeatures->imageCubeArray, "imageCubeArray"); - break; + case spv::CapabilityImageCubeArray: + pass &= require_feature(report_data, enabledFeatures->imageCubeArray, "imageCubeArray"); + break; - case spv::CapabilitySampleRateShading: - pass &= require_feature(report_data, enabledFeatures->sampleRateShading, "sampleRateShading"); - break; + case spv::CapabilitySampleRateShading: + pass &= require_feature(report_data, enabledFeatures->sampleRateShading, "sampleRateShading"); + break; - case spv::CapabilitySparseResidency: - pass &= require_feature(report_data, enabledFeatures->shaderResourceResidency, "shaderResourceResidency"); - break; + case spv::CapabilitySparseResidency: + pass &= require_feature(report_data, enabledFeatures->shaderResourceResidency, "shaderResourceResidency"); + break; - case spv::CapabilityMinLod: - pass &= require_feature(report_data, enabledFeatures->shaderResourceMinLod, "shaderResourceMinLod"); - break; + case spv::CapabilityMinLod: + pass &= require_feature(report_data, enabledFeatures->shaderResourceMinLod, "shaderResourceMinLod"); + break; - case spv::CapabilitySampledCubeArray: - pass &= require_feature(report_data, enabledFeatures->imageCubeArray, "imageCubeArray"); - break; + case spv::CapabilitySampledCubeArray: + pass &= require_feature(report_data, enabledFeatures->imageCubeArray, "imageCubeArray"); + break; - case spv::CapabilityImageMSArray: - pass &= - require_feature(report_data, enabledFeatures->shaderStorageImageMultisample, "shaderStorageImageMultisample"); - break; + case spv::CapabilityImageMSArray: + pass &= require_feature(report_data, enabledFeatures->shaderStorageImageMultisample, + "shaderStorageImageMultisample"); + break; - case spv::CapabilityStorageImageExtendedFormats: - pass &= require_feature(report_data, enabledFeatures->shaderStorageImageExtendedFormats, - "shaderStorageImageExtendedFormats"); - break; + case spv::CapabilityStorageImageExtendedFormats: + pass &= require_feature(report_data, enabledFeatures->shaderStorageImageExtendedFormats, + "shaderStorageImageExtendedFormats"); + break; - case spv::CapabilityInterpolationFunction: - pass &= require_feature(report_data, enabledFeatures->sampleRateShading, "sampleRateShading"); - break; + case spv::CapabilityInterpolationFunction: + pass &= require_feature(report_data, enabledFeatures->sampleRateShading, "sampleRateShading"); + break; - case spv::CapabilityStorageImageReadWithoutFormat: - pass &= require_feature(report_data, enabledFeatures->shaderStorageImageReadWithoutFormat, - "shaderStorageImageReadWithoutFormat"); - break; + case spv::CapabilityStorageImageReadWithoutFormat: + pass &= require_feature(report_data, enabledFeatures->shaderStorageImageReadWithoutFormat, + "shaderStorageImageReadWithoutFormat"); + break; - case spv::CapabilityStorageImageWriteWithoutFormat: - pass &= require_feature(report_data, enabledFeatures->shaderStorageImageWriteWithoutFormat, - "shaderStorageImageWriteWithoutFormat"); - break; + case spv::CapabilityStorageImageWriteWithoutFormat: + pass &= require_feature(report_data, enabledFeatures->shaderStorageImageWriteWithoutFormat, + "shaderStorageImageWriteWithoutFormat"); + break; - case spv::CapabilityMultiViewport: - pass &= require_feature(report_data, enabledFeatures->multiViewport, "multiViewport"); - break; + case spv::CapabilityMultiViewport: + pass &= require_feature(report_data, enabledFeatures->multiViewport, "multiViewport"); + break; - default: - if (log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VkDebugReportObjectTypeEXT(0), 0, __LINE__, - SHADER_CHECKER_BAD_CAPABILITY, "SC", "Shader declares capability %u, not supported in Vulkan.", - insn.word(1))) - pass = false; - break; + default: + if (log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VkDebugReportObjectTypeEXT(0), 0, __LINE__, + SHADER_CHECKER_BAD_CAPABILITY, "SC", "Shader declares capability %u, not supported in Vulkan.", + insn.word(1))) + pass = false; + break; } } } @@ -2578,45 +2560,44 @@ static uint32_t descriptor_type_to_reqs(shader_module const *module, uint32_t ty while (true) { switch (type.opcode()) { - case spv::OpTypeArray: - case spv::OpTypeSampledImage: - type = module->get_def(type.word(2)); - break; - case spv::OpTypePointer: - type = module->get_def(type.word(3)); - break; - case spv::OpTypeImage: { - auto dim = type.word(3); - auto arrayed = type.word(5); - auto msaa = type.word(6); - - switch (dim) { - case spv::Dim1D: - return arrayed ? DESCRIPTOR_REQ_VIEW_TYPE_1D_ARRAY : DESCRIPTOR_REQ_VIEW_TYPE_1D; - case spv::Dim2D: - return (msaa ? DESCRIPTOR_REQ_MULTI_SAMPLE : DESCRIPTOR_REQ_SINGLE_SAMPLE) | - (arrayed ? DESCRIPTOR_REQ_VIEW_TYPE_2D_ARRAY : DESCRIPTOR_REQ_VIEW_TYPE_2D); - case spv::Dim3D: - return DESCRIPTOR_REQ_VIEW_TYPE_3D; - case spv::DimCube: - return arrayed ? DESCRIPTOR_REQ_VIEW_TYPE_CUBE_ARRAY : DESCRIPTOR_REQ_VIEW_TYPE_CUBE; - case spv::DimSubpassData: - return msaa ? DESCRIPTOR_REQ_MULTI_SAMPLE : DESCRIPTOR_REQ_SINGLE_SAMPLE; - default: // buffer, etc. - return 0; + case spv::OpTypeArray: + case spv::OpTypeSampledImage: + type = module->get_def(type.word(2)); + break; + case spv::OpTypePointer: + type = module->get_def(type.word(3)); + break; + case spv::OpTypeImage: { + auto dim = type.word(3); + auto arrayed = type.word(5); + auto msaa = type.word(6); + + switch (dim) { + case spv::Dim1D: + return arrayed ? DESCRIPTOR_REQ_VIEW_TYPE_1D_ARRAY : DESCRIPTOR_REQ_VIEW_TYPE_1D; + case spv::Dim2D: + return (msaa ? DESCRIPTOR_REQ_MULTI_SAMPLE : DESCRIPTOR_REQ_SINGLE_SAMPLE) | + (arrayed ? DESCRIPTOR_REQ_VIEW_TYPE_2D_ARRAY : DESCRIPTOR_REQ_VIEW_TYPE_2D); + case spv::Dim3D: + return DESCRIPTOR_REQ_VIEW_TYPE_3D; + case spv::DimCube: + return arrayed ? DESCRIPTOR_REQ_VIEW_TYPE_CUBE_ARRAY : DESCRIPTOR_REQ_VIEW_TYPE_CUBE; + case spv::DimSubpassData: + return msaa ? DESCRIPTOR_REQ_MULTI_SAMPLE : DESCRIPTOR_REQ_SINGLE_SAMPLE; + default: // buffer, etc. + return 0; + } } - } - default: - return 0; + default: + return 0; } } } -static bool -validate_pipeline_shader_stage(debug_report_data *report_data, VkPipelineShaderStageCreateInfo const *pStage, - PIPELINE_STATE *pipeline, shader_module **out_module, spirv_inst_iter *out_entrypoint, - VkPhysicalDeviceFeatures const *enabledFeatures, - std::unordered_map> const &shaderModuleMap) { +static bool validate_pipeline_shader_stage( + debug_report_data *report_data, VkPipelineShaderStageCreateInfo const *pStage, PIPELINE_STATE *pipeline, + shader_module **out_module, spirv_inst_iter *out_entrypoint, VkPhysicalDeviceFeatures const *enabledFeatures, + std::unordered_map> const &shaderModuleMap) { bool pass = true; auto module_it = shaderModuleMap.find(pStage->module); auto module = *out_module = module_it->second.get(); @@ -2627,7 +2608,7 @@ validate_pipeline_shader_stage(debug_report_data *report_data, VkPipelineShaderS if (log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VkDebugReportObjectTypeEXT(0), 0, __LINE__, VALIDATION_ERROR_00510, "SC", "No entrypoint found named `%s` for stage %s. %s.", pStage->pName, string_VkShaderStageFlagBits(pStage->stage), validation_error_map[VALIDATION_ERROR_00510])) { - return false; // no point continuing beyond here, any analysis is just going to be garbage. + return false; // no point continuing beyond here, any analysis is just going to be garbage. } } @@ -2664,18 +2645,20 @@ validate_pipeline_shader_stage(debug_report_data *report_data, VkPipelineShaderS } } else if (~binding->stageFlags & pStage->stage) { if (log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, 0, __LINE__, - SHADER_CHECKER_DESCRIPTOR_NOT_ACCESSIBLE_FROM_STAGE, "SC", "Shader uses descriptor slot %u.%u (used " - "as type `%s`) but descriptor not " - "accessible from stage %s", + SHADER_CHECKER_DESCRIPTOR_NOT_ACCESSIBLE_FROM_STAGE, "SC", + "Shader uses descriptor slot %u.%u (used " + "as type `%s`) but descriptor not " + "accessible from stage %s", use.first.first, use.first.second, describe_type(module, use.second.type_id).c_str(), string_VkShaderStageFlagBits(pStage->stage))) { pass = false; } } else if (!descriptor_type_match(module, use.second.type_id, binding->descriptorType, required_descriptor_count)) { if (log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VkDebugReportObjectTypeEXT(0), 0, __LINE__, - SHADER_CHECKER_DESCRIPTOR_TYPE_MISMATCH, "SC", "Type mismatch on descriptor slot " - "%u.%u (used as type `%s`) but " - "descriptor of type %s", + SHADER_CHECKER_DESCRIPTOR_TYPE_MISMATCH, "SC", + "Type mismatch on descriptor slot " + "%u.%u (used as type `%s`) but " + "descriptor of type %s", use.first.first, use.first.second, describe_type(module, use.second.type_id).c_str(), string_VkDescriptorType(binding->descriptorType))) { pass = false; @@ -2726,10 +2709,9 @@ validate_pipeline_shader_stage(debug_report_data *report_data, VkPipelineShaderS // Validate that the shaders used by the given pipeline and store the active_slots // that are actually used by the pipeline into pPipeline->active_slots -static bool -validate_and_capture_pipeline_shader_state(debug_report_data *report_data, PIPELINE_STATE *pPipeline, - VkPhysicalDeviceFeatures const *enabledFeatures, - std::unordered_map> const &shaderModuleMap) { +static bool validate_and_capture_pipeline_shader_state( + debug_report_data *report_data, PIPELINE_STATE *pPipeline, VkPhysicalDeviceFeatures const *enabledFeatures, + std::unordered_map> const &shaderModuleMap) { auto pCreateInfo = pPipeline->graphicsPipelineCI.ptr(); int vertex_stage = get_shader_stage_id(VK_SHADER_STAGE_VERTEX_BIT); int fragment_stage = get_shader_stage_id(VK_SHADER_STAGE_FRAGMENT_BIT); @@ -2749,8 +2731,7 @@ validate_and_capture_pipeline_shader_state(debug_report_data *report_data, PIPEL } // if the shader stages are no good individually, cross-stage validation is pointless. - if (!pass) - return false; + if (!pass) return false; vi = pCreateInfo->pVertexInputState; @@ -2841,13 +2822,14 @@ static bool ValidatePipelineDrawtimeState(layer_data const *my_data, LAST_BOUND_ auto vertex_binding = pPipeline->vertexBindingDescriptions[i].binding; if ((pCB->currentDrawData.buffers.size() < (vertex_binding + 1)) || (pCB->currentDrawData.buffers[vertex_binding] == VK_NULL_HANDLE)) { - skip_call |= log_msg( - my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, - DRAWSTATE_VTX_INDEX_OUT_OF_BOUNDS, "DS", - "The Pipeline State Object (0x%" PRIxLEAST64 ") expects that this Command Buffer's vertex binding Index %u " - "should be set via vkCmdBindVertexBuffers. This is because VkVertexInputBindingDescription struct " - "at index " PRINTF_SIZE_T_SPECIFIER " of pVertexBindingDescriptions has a binding value of %u.", - (uint64_t)state.pipeline_state->pipeline, vertex_binding, i, vertex_binding); + skip_call |= + log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, + DRAWSTATE_VTX_INDEX_OUT_OF_BOUNDS, "DS", + "The Pipeline State Object (0x%" PRIxLEAST64 + ") expects that this Command Buffer's vertex binding Index %u " + "should be set via vkCmdBindVertexBuffers. This is because VkVertexInputBindingDescription struct " + "at index " PRINTF_SIZE_T_SPECIFIER " of pVertexBindingDescriptions has a binding value of %u.", + (uint64_t)state.pipeline_state->pipeline, vertex_binding, i, vertex_binding); } } } else { @@ -2911,7 +2893,8 @@ static bool ValidatePipelineDrawtimeState(layer_data const *my_data, LAST_BOUND_ log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, reinterpret_cast(pPipeline->pipeline), __LINE__, DRAWSTATE_INVALID_RENDERPASS, "DS", "Render pass subpass %u mismatch with blending state defined and blend state attachment " - "count %u while subpass color attachment count %u in Pipeline (0x%" PRIxLEAST64 ")! These " + "count %u while subpass color attachment count %u in Pipeline (0x%" PRIxLEAST64 + ")! These " "must be the same at draw-time.", pCB->activeSubpass, color_blend_state->attachmentCount, subpass_desc->colorAttachmentCount, reinterpret_cast(pPipeline->pipeline)); @@ -2957,7 +2940,8 @@ static bool ValidatePipelineDrawtimeState(layer_data const *my_data, LAST_BOUND_ skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, reinterpret_cast(pPipeline->pipeline), __LINE__, DRAWSTATE_RENDERPASS_INCOMPATIBLE, "DS", - "At Draw time the active render pass (0x%" PRIxLEAST64 ") is incompatible w/ gfx pipeline " + "At Draw time the active render pass (0x%" PRIxLEAST64 + ") is incompatible w/ gfx pipeline " "(0x%" PRIxLEAST64 ") that was created w/ render pass (0x%" PRIxLEAST64 ") due to: %s", reinterpret_cast(pCB->activeRenderPass->renderPass), reinterpret_cast(pPipeline->pipeline), @@ -2990,8 +2974,7 @@ static bool ValidateDrawState(layer_data *my_data, GLOBAL_CB_NODE *cb_node, cons DRAWSTATE_INVALID_PIPELINE, "DS", "At Draw/Dispatch time no valid VkPipeline is bound! This is illegal. Please bind one with vkCmdBindPipeline()."); // Early return as any further checks below will be busted w/o a pipeline - if (result) - return true; + if (result) return true; } // First check flag states if (VK_PIPELINE_BIND_POINT_GRAPHICS == bind_point) @@ -3021,7 +3004,7 @@ static bool ValidateDrawState(layer_data *my_data, GLOBAL_CB_NODE *cb_node, cons ") bound as set #%u is not compatible with overlapping VkPipelineLayout 0x%" PRIxLEAST64 " due to: %s", reinterpret_cast(setHandle), setIndex, reinterpret_cast(pipeline_layout.layout), errorString.c_str()); - } else { // Valid set is bound and layout compatible, validate that it's updated + } else { // Valid set is bound and layout compatible, validate that it's updated // Pull the set node cvdescriptorset::DescriptorSet *descriptor_set = state.boundDescriptorSets[setIndex]; // Gather active bindings @@ -3034,12 +3017,13 @@ static bool ValidateDrawState(layer_data *my_data, GLOBAL_CB_NODE *cb_node, cons if (!descriptor_set->IsUpdated()) { for (auto binding : active_bindings) { if (!descriptor_set->GetImmutableSamplerPtrFromBinding(binding)) { - result |= log_msg( - my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT, - (uint64_t)descriptor_set->GetSet(), __LINE__, DRAWSTATE_DESCRIPTOR_SET_NOT_UPDATED, "DS", - "Descriptor Set 0x%" PRIxLEAST64 " bound but was never updated. It is now being used to draw so " - "this will result in undefined behavior.", - (uint64_t)descriptor_set->GetSet()); + result |= log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, + VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT, (uint64_t)descriptor_set->GetSet(), + __LINE__, DRAWSTATE_DESCRIPTOR_SET_NOT_UPDATED, "DS", + "Descriptor Set 0x%" PRIxLEAST64 + " bound but was never updated. It is now being used to draw so " + "this will result in undefined behavior.", + (uint64_t)descriptor_set->GetSet()); } } } @@ -3058,8 +3042,7 @@ static bool ValidateDrawState(layer_data *my_data, GLOBAL_CB_NODE *cb_node, cons } // Check general pipeline state that needs to be validated at drawtime - if (VK_PIPELINE_BIND_POINT_GRAPHICS == bind_point) - result |= ValidatePipelineDrawtimeState(my_data, state, cb_node, pPipe); + if (VK_PIPELINE_BIND_POINT_GRAPHICS == bind_point) result |= ValidatePipelineDrawtimeState(my_data, state, cb_node, pPipe); return result; } @@ -3090,16 +3073,18 @@ static bool verifyLineWidth(layer_data *my_data, DRAW_STATE_ERROR dsError, const // First check to see if the physical device supports wide lines. if ((VK_FALSE == my_data->enabled_features.wideLines) && (1.0f != lineWidth)) { skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, target, __LINE__, - dsError, "DS", "Attempt to set lineWidth to %f but physical device wideLines feature " - "not supported/enabled so lineWidth must be 1.0f!", + dsError, "DS", + "Attempt to set lineWidth to %f but physical device wideLines feature " + "not supported/enabled so lineWidth must be 1.0f!", lineWidth); } else { // Otherwise, make sure the width falls in the valid range. if ((my_data->phys_dev_properties.properties.limits.lineWidthRange[0] > lineWidth) || (my_data->phys_dev_properties.properties.limits.lineWidthRange[1] < lineWidth)) { skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, target, - __LINE__, dsError, "DS", "Attempt to set lineWidth to %f but physical device limits line width " - "to between [%f, %f]!", + __LINE__, dsError, "DS", + "Attempt to set lineWidth to %f but physical device limits line width " + "to between [%f, %f]!", lineWidth, my_data->phys_dev_properties.properties.limits.lineWidthRange[0], my_data->phys_dev_properties.properties.limits.lineWidthRange[1]); } @@ -3156,11 +3141,11 @@ static bool verifyPipelineCreateState(layer_data *my_data, std::vector(pAttachments), static_cast(&pAttachments[i]), sizeof(pAttachments[0]))) { - skip_call |= - log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, - VALIDATION_ERROR_01532, "DS", "Invalid Pipeline CreateInfo: If independent blend feature not " - "enabled, all elements of pAttachments must be identical. %s", - validation_error_map[VALIDATION_ERROR_01532]); + skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, + __LINE__, VALIDATION_ERROR_01532, "DS", + "Invalid Pipeline CreateInfo: If independent blend feature not " + "enabled, all elements of pAttachments must be identical. %s", + validation_error_map[VALIDATION_ERROR_01532]); break; } } @@ -3181,8 +3166,9 @@ static bool verifyPipelineCreateState(layer_data *my_data, std::vectorgraphicsPipelineCI.renderPass); if (renderPass && pPipeline->graphicsPipelineCI.subpass >= renderPass->createInfo.subpassCount) { skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, - VALIDATION_ERROR_02122, "DS", "Invalid Pipeline CreateInfo State: Subpass index %u " - "is out of range for this renderpass (0..%u). %s", + VALIDATION_ERROR_02122, "DS", + "Invalid Pipeline CreateInfo State: Subpass index %u " + "is out of range for this renderpass (0..%u). %s", pPipeline->graphicsPipelineCI.subpass, renderPass->createInfo.subpassCount - 1, validation_error_map[VALIDATION_ERROR_02122]); } @@ -3236,18 +3222,20 @@ static bool verifyPipelineCreateState(layer_data *my_data, std::vectorgraphicsPipelineCI.pInputAssemblyState || pPipeline->graphicsPipelineCI.pInputAssemblyState->topology != VK_PRIMITIVE_TOPOLOGY_PATCH_LIST)) { skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, - VALIDATION_ERROR_02099, "DS", "Invalid Pipeline CreateInfo State: " - "VK_PRIMITIVE_TOPOLOGY_PATCH_LIST must be set as IA " - "topology for tessellation pipelines. %s", + VALIDATION_ERROR_02099, "DS", + "Invalid Pipeline CreateInfo State: " + "VK_PRIMITIVE_TOPOLOGY_PATCH_LIST must be set as IA " + "topology for tessellation pipelines. %s", validation_error_map[VALIDATION_ERROR_02099]); } if (pPipeline->graphicsPipelineCI.pInputAssemblyState && pPipeline->graphicsPipelineCI.pInputAssemblyState->topology == VK_PRIMITIVE_TOPOLOGY_PATCH_LIST) { if (~pPipeline->active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) { skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, - VALIDATION_ERROR_02100, "DS", "Invalid Pipeline CreateInfo State: " - "VK_PRIMITIVE_TOPOLOGY_PATCH_LIST primitive " - "topology is only valid for tessellation pipelines. %s", + VALIDATION_ERROR_02100, "DS", + "Invalid Pipeline CreateInfo State: " + "VK_PRIMITIVE_TOPOLOGY_PATCH_LIST primitive " + "topology is only valid for tessellation pipelines. %s", validation_error_map[VALIDATION_ERROR_02100]); } } @@ -3257,10 +3245,11 @@ static bool verifyPipelineCreateState(layer_data *my_data, std::vectorgraphicsPipelineCI.pTessellationState->patchControlPoints > my_data->phys_dev_properties.properties.limits.maxTessellationPatchSize))) { skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, - VALIDATION_ERROR_01426, "DS", "Invalid Pipeline CreateInfo State: " - "VK_PRIMITIVE_TOPOLOGY_PATCH_LIST primitive " - "topology used with patchControlPoints value %u." - " patchControlPoints should be >0 and <=%u. %s", + VALIDATION_ERROR_01426, "DS", + "Invalid Pipeline CreateInfo State: " + "VK_PRIMITIVE_TOPOLOGY_PATCH_LIST primitive " + "topology used with patchControlPoints value %u." + " patchControlPoints should be >0 and <=%u. %s", pPipeline->graphicsPipelineCI.pTessellationState->patchControlPoints, my_data->phys_dev_properties.properties.limits.maxTessellationPatchSize, validation_error_map[VALIDATION_ERROR_01426]); @@ -3297,8 +3286,7 @@ static bool verifyPipelineCreateState(layer_data *my_data, std::vectorpipelineMap.size() <= 0) - return; + if (my_data->pipelineMap.size() <= 0) return; for (auto &pipe_map_pair : my_data->pipelineMap) { delete pipe_map_pair.second; } @@ -3319,27 +3307,27 @@ DESCRIPTOR_POOL_STATE *getDescriptorPoolState(const layer_data *dev_data, const // Return false if update struct is of valid type, otherwise flag error and return code from callback static bool validUpdateStruct(layer_data *my_data, const VkDevice device, const GENERIC_HEADER *pUpdateStruct) { switch (pUpdateStruct->sType) { - case VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET: - case VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET: - return false; - default: - return log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, - DRAWSTATE_INVALID_UPDATE_STRUCT, "DS", - "Unexpected UPDATE struct of type %s (value %u) in vkUpdateDescriptors() struct tree", - string_VkStructureType(pUpdateStruct->sType), pUpdateStruct->sType); + case VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET: + case VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET: + return false; + default: + return log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, + DRAWSTATE_INVALID_UPDATE_STRUCT, "DS", + "Unexpected UPDATE struct of type %s (value %u) in vkUpdateDescriptors() struct tree", + string_VkStructureType(pUpdateStruct->sType), pUpdateStruct->sType); } } // Set count for given update struct in the last parameter static uint32_t getUpdateCount(layer_data *my_data, const VkDevice device, const GENERIC_HEADER *pUpdateStruct) { switch (pUpdateStruct->sType) { - case VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET: - return ((VkWriteDescriptorSet *)pUpdateStruct)->descriptorCount; - case VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET: - // TODO : Need to understand this case better and make sure code is correct - return ((VkCopyDescriptorSet *)pUpdateStruct)->descriptorCount; - default: - return 0; + case VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET: + return ((VkWriteDescriptorSet *)pUpdateStruct)->descriptorCount; + case VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET: + // TODO : Need to understand this case better and make sure code is correct + return ((VkCopyDescriptorSet *)pUpdateStruct)->descriptorCount; + default: + return 0; } } @@ -3361,18 +3349,18 @@ static bool validateUpdateConsistency(layer_data *my_data, const VkDevice device bool skip_call = false; VkDescriptorType actualType = VK_DESCRIPTOR_TYPE_MAX_ENUM; switch (pUpdateStruct->sType) { - case VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET: - actualType = ((VkWriteDescriptorSet *)pUpdateStruct)->descriptorType; - break; - case VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET: - // No need to validate - return false; - break; - default: - skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, - DRAWSTATE_INVALID_UPDATE_STRUCT, "DS", - "Unexpected UPDATE struct of type %s (value %u) in vkUpdateDescriptors() struct tree", - string_VkStructureType(pUpdateStruct->sType), pUpdateStruct->sType); + case VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET: + actualType = ((VkWriteDescriptorSet *)pUpdateStruct)->descriptorType; + break; + case VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET: + // No need to validate + return false; + break; + default: + skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, + DRAWSTATE_INVALID_UPDATE_STRUCT, "DS", + "Unexpected UPDATE struct of type %s (value %u) in vkUpdateDescriptors() struct tree", + string_VkStructureType(pUpdateStruct->sType), pUpdateStruct->sType); } if (!skip_call) { if (layout_type != actualType) { @@ -3450,8 +3438,7 @@ bool FindLayout(const GLOBAL_CB_NODE *pCB, VkImage image, VkImageSubresource ran if (node.layout == VK_IMAGE_LAYOUT_MAX_ENUM) { imgpair = {image, false, VkImageSubresource()}; auto imgsubIt = pCB->imageLayoutMap.find(imgpair); - if (imgsubIt == pCB->imageLayoutMap.end()) - return false; + if (imgsubIt == pCB->imageLayoutMap.end()) return false; node = imgsubIt->second; } return true; @@ -3467,8 +3454,7 @@ bool FindLayout(const layer_data *my_data, ImageSubresourcePair imgpair, VkImage if (layout == VK_IMAGE_LAYOUT_MAX_ENUM) { imgpair = {imgpair.image, false, VkImageSubresource()}; auto imgsubIt = my_data->imageLayoutMap.find(imgpair); - if (imgsubIt == my_data->imageLayoutMap.end()) - return false; + if (imgsubIt == my_data->imageLayoutMap.end()) return false; layout = imgsubIt->second.layout; } return true; @@ -3481,11 +3467,9 @@ bool FindLayout(const layer_data *my_data, VkImage image, VkImageSubresource ran bool FindLayouts(const layer_data *my_data, VkImage image, std::vector &layouts) { auto sub_data = my_data->imageSubresourceMap.find(image); - if (sub_data == my_data->imageSubresourceMap.end()) - return false; + if (sub_data == my_data->imageSubresourceMap.end()) return false; auto image_state = getImageState(my_data, image); - if (!image_state) - return false; + if (!image_state) return false; bool ignoreGlobal = false; // TODO: Make this robust for >1 aspect mask. Now it will just say ignore // potential errors in this case. @@ -3493,8 +3477,7 @@ bool FindLayouts(const layer_data *my_data, VkImage image, std::vectorsecond) { - if (ignoreGlobal && !imgsubpair.hasSubresource) - continue; + if (ignoreGlobal && !imgsubpair.hasSubresource) continue; auto img_data = my_data->imageLayoutMap.find(imgsubpair); if (img_data != my_data->imageLayoutMap.end()) { layouts.push_back(img_data->second.layout); @@ -3559,7 +3542,8 @@ void SetLayout(OBJECT *pObject, VkImage image, VkImageSubresource range, const L SetLayout(pObject, imgpair, layout, VK_IMAGE_ASPECT_METADATA_BIT); } -template void SetLayout(OBJECT *pObject, VkImage image, const LAYOUT &layout) { +template +void SetLayout(OBJECT *pObject, VkImage image, const LAYOUT &layout) { ImageSubresourcePair imgpair = {image, false, VkImageSubresource()}; SetLayout(pObject, image, imgpair, layout); } @@ -3593,8 +3577,7 @@ void SetLayout(const layer_data *dev_data, GLOBAL_CB_NODE *pCB, VkImageView imag // Return false if no errors occur // Return true if validation error occurs and callback returns true (to skip upcoming API call down the chain) static bool validateIdleDescriptorSet(const layer_data *dev_data, VkDescriptorSet set, std::string func_str) { - if (dev_data->instance_data->disabled.idle_descriptor_set) - return false; + if (dev_data->instance_data->disabled.idle_descriptor_set) return false; bool skip_call = false; auto set_node = dev_data->setMap.find(set); if (set_node == dev_data->setMap.end()) { @@ -3623,8 +3606,7 @@ static void freeDescriptorSet(layer_data *dev_data, cvdescriptorset::DescriptorS // Free all DS Pools including their Sets & related sub-structs // NOTE : Calls to this function should be wrapped in mutex static void deletePools(layer_data *my_data) { - if (my_data->descriptorPoolMap.size() <= 0) - return; + if (my_data->descriptorPoolMap.size() <= 0) return; for (auto ii = my_data->descriptorPoolMap.begin(); ii != my_data->descriptorPoolMap.end(); ++ii) { // Remove this pools' sets from setMap and delete them for (auto ds : (*ii).second->sets) { @@ -3682,8 +3664,7 @@ static bool report_error_no_cb_begin(const layer_data *dev_data, const VkCommand // If a renderpass is active, verify that the given command type is appropriate for current subpass state bool ValidateCmdSubpassState(const layer_data *dev_data, const GLOBAL_CB_NODE *pCB, const CMD_TYPE cmd_type) { - if (!pCB->activeRenderPass) - return false; + if (!pCB->activeRenderPass) return false; bool skip_call = false; if (pCB->activeSubpassContents == VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS && (cmd_type != CMD_EXECUTECOMMANDS && cmd_type != CMD_NEXTSUBPASS && cmd_type != CMD_ENDRENDERPASS)) { @@ -3730,61 +3711,61 @@ static bool ValidateCmd(layer_data *my_data, GLOBAL_CB_NODE *pCB, const CMD_TYPE if (pPool) { VkQueueFlags flags = my_data->phys_dev_properties.queue_family_properties[pPool->queueFamilyIndex].queueFlags; switch (cmd) { - case CMD_BINDPIPELINE: - case CMD_BINDPIPELINEDELTA: - case CMD_BINDDESCRIPTORSETS: - case CMD_FILLBUFFER: - case CMD_CLEARCOLORIMAGE: - case CMD_SETEVENT: - case CMD_RESETEVENT: - case CMD_WAITEVENTS: - case CMD_BEGINQUERY: - case CMD_ENDQUERY: - case CMD_RESETQUERYPOOL: - case CMD_COPYQUERYPOOLRESULTS: - case CMD_WRITETIMESTAMP: - skip_call |= checkGraphicsOrComputeBit(my_data, flags, cmdTypeToString(cmd).c_str()); - break; - case CMD_SETVIEWPORTSTATE: - case CMD_SETSCISSORSTATE: - case CMD_SETLINEWIDTHSTATE: - case CMD_SETDEPTHBIASSTATE: - case CMD_SETBLENDSTATE: - case CMD_SETDEPTHBOUNDSSTATE: - case CMD_SETSTENCILREADMASKSTATE: - case CMD_SETSTENCILWRITEMASKSTATE: - case CMD_SETSTENCILREFERENCESTATE: - case CMD_BINDINDEXBUFFER: - case CMD_BINDVERTEXBUFFER: - case CMD_DRAW: - case CMD_DRAWINDEXED: - case CMD_DRAWINDIRECT: - case CMD_DRAWINDEXEDINDIRECT: - case CMD_BLITIMAGE: - case CMD_CLEARATTACHMENTS: - case CMD_CLEARDEPTHSTENCILIMAGE: - case CMD_RESOLVEIMAGE: - case CMD_BEGINRENDERPASS: - case CMD_NEXTSUBPASS: - case CMD_ENDRENDERPASS: - skip_call |= checkGraphicsBit(my_data, flags, cmdTypeToString(cmd).c_str()); - break; - case CMD_DISPATCH: - case CMD_DISPATCHINDIRECT: - skip_call |= checkComputeBit(my_data, flags, cmdTypeToString(cmd).c_str()); - break; - case CMD_COPYBUFFER: - case CMD_COPYIMAGE: - case CMD_COPYBUFFERTOIMAGE: - case CMD_COPYIMAGETOBUFFER: - case CMD_CLONEIMAGEDATA: - case CMD_UPDATEBUFFER: - case CMD_PIPELINEBARRIER: - case CMD_EXECUTECOMMANDS: - case CMD_END: - break; - default: - break; + case CMD_BINDPIPELINE: + case CMD_BINDPIPELINEDELTA: + case CMD_BINDDESCRIPTORSETS: + case CMD_FILLBUFFER: + case CMD_CLEARCOLORIMAGE: + case CMD_SETEVENT: + case CMD_RESETEVENT: + case CMD_WAITEVENTS: + case CMD_BEGINQUERY: + case CMD_ENDQUERY: + case CMD_RESETQUERYPOOL: + case CMD_COPYQUERYPOOLRESULTS: + case CMD_WRITETIMESTAMP: + skip_call |= checkGraphicsOrComputeBit(my_data, flags, cmdTypeToString(cmd).c_str()); + break; + case CMD_SETVIEWPORTSTATE: + case CMD_SETSCISSORSTATE: + case CMD_SETLINEWIDTHSTATE: + case CMD_SETDEPTHBIASSTATE: + case CMD_SETBLENDSTATE: + case CMD_SETDEPTHBOUNDSSTATE: + case CMD_SETSTENCILREADMASKSTATE: + case CMD_SETSTENCILWRITEMASKSTATE: + case CMD_SETSTENCILREFERENCESTATE: + case CMD_BINDINDEXBUFFER: + case CMD_BINDVERTEXBUFFER: + case CMD_DRAW: + case CMD_DRAWINDEXED: + case CMD_DRAWINDIRECT: + case CMD_DRAWINDEXEDINDIRECT: + case CMD_BLITIMAGE: + case CMD_CLEARATTACHMENTS: + case CMD_CLEARDEPTHSTENCILIMAGE: + case CMD_RESOLVEIMAGE: + case CMD_BEGINRENDERPASS: + case CMD_NEXTSUBPASS: + case CMD_ENDRENDERPASS: + skip_call |= checkGraphicsBit(my_data, flags, cmdTypeToString(cmd).c_str()); + break; + case CMD_DISPATCH: + case CMD_DISPATCHINDIRECT: + skip_call |= checkComputeBit(my_data, flags, cmdTypeToString(cmd).c_str()); + break; + case CMD_COPYBUFFER: + case CMD_COPYIMAGE: + case CMD_COPYBUFFERTOIMAGE: + case CMD_COPYIMAGETOBUFFER: + case CMD_CLONEIMAGEDATA: + case CMD_UPDATEBUFFER: + case CMD_PIPELINEBARRIER: + case CMD_EXECUTECOMMANDS: + case CMD_END: + break; + default: + break; } } if (pCB->state != CB_RECORDING) { @@ -3804,66 +3785,66 @@ static void UpdateCmdBufferLastCmd(layer_data *my_data, GLOBAL_CB_NODE *cb_state BASE_NODE *GetStateStructPtrFromObject(layer_data *dev_data, VK_OBJECT object_struct) { BASE_NODE *base_ptr = nullptr; switch (object_struct.type) { - case VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT: { - base_ptr = getSetNode(dev_data, reinterpret_cast(object_struct.handle)); - break; - } - case VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_EXT: { - base_ptr = getSamplerState(dev_data, reinterpret_cast(object_struct.handle)); - break; - } - case VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT: { - base_ptr = getQueryPoolNode(dev_data, reinterpret_cast(object_struct.handle)); - break; - } - case VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT: { - base_ptr = getPipelineState(dev_data, reinterpret_cast(object_struct.handle)); - break; - } - case VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT: { - base_ptr = getBufferState(dev_data, reinterpret_cast(object_struct.handle)); - break; - } - case VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_VIEW_EXT: { - base_ptr = getBufferViewState(dev_data, reinterpret_cast(object_struct.handle)); - break; - } - case VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT: { - base_ptr = getImageState(dev_data, reinterpret_cast(object_struct.handle)); - break; - } - case VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_VIEW_EXT: { - base_ptr = getImageViewState(dev_data, reinterpret_cast(object_struct.handle)); - break; - } - case VK_DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT: { - base_ptr = getEventNode(dev_data, reinterpret_cast(object_struct.handle)); - break; - } - case VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT: { - base_ptr = getDescriptorPoolState(dev_data, reinterpret_cast(object_struct.handle)); - break; - } - case VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_POOL_EXT: { - base_ptr = getCommandPoolNode(dev_data, reinterpret_cast(object_struct.handle)); - break; - } - case VK_DEBUG_REPORT_OBJECT_TYPE_FRAMEBUFFER_EXT: { - base_ptr = getFramebufferState(dev_data, reinterpret_cast(object_struct.handle)); - break; - } - case VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT: { - base_ptr = getRenderPassState(dev_data, reinterpret_cast(object_struct.handle)); - break; - } - case VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT: { - base_ptr = getMemObjInfo(dev_data, reinterpret_cast(object_struct.handle)); - break; - } - default: - // TODO : Any other objects to be handled here? - assert(0); - break; + case VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT: { + base_ptr = getSetNode(dev_data, reinterpret_cast(object_struct.handle)); + break; + } + case VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_EXT: { + base_ptr = getSamplerState(dev_data, reinterpret_cast(object_struct.handle)); + break; + } + case VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT: { + base_ptr = getQueryPoolNode(dev_data, reinterpret_cast(object_struct.handle)); + break; + } + case VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT: { + base_ptr = getPipelineState(dev_data, reinterpret_cast(object_struct.handle)); + break; + } + case VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT: { + base_ptr = getBufferState(dev_data, reinterpret_cast(object_struct.handle)); + break; + } + case VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_VIEW_EXT: { + base_ptr = getBufferViewState(dev_data, reinterpret_cast(object_struct.handle)); + break; + } + case VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT: { + base_ptr = getImageState(dev_data, reinterpret_cast(object_struct.handle)); + break; + } + case VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_VIEW_EXT: { + base_ptr = getImageViewState(dev_data, reinterpret_cast(object_struct.handle)); + break; + } + case VK_DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT: { + base_ptr = getEventNode(dev_data, reinterpret_cast(object_struct.handle)); + break; + } + case VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT: { + base_ptr = getDescriptorPoolState(dev_data, reinterpret_cast(object_struct.handle)); + break; + } + case VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_POOL_EXT: { + base_ptr = getCommandPoolNode(dev_data, reinterpret_cast(object_struct.handle)); + break; + } + case VK_DEBUG_REPORT_OBJECT_TYPE_FRAMEBUFFER_EXT: { + base_ptr = getFramebufferState(dev_data, reinterpret_cast(object_struct.handle)); + break; + } + case VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT: { + base_ptr = getRenderPassState(dev_data, reinterpret_cast(object_struct.handle)); + break; + } + case VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT: { + base_ptr = getMemObjInfo(dev_data, reinterpret_cast(object_struct.handle)); + break; + } + default: + // TODO : Any other objects to be handled here? + assert(0); + break; } return base_ptr; } @@ -3878,8 +3859,7 @@ static void addCommandBufferBinding(std::unordered_set *cb_bin // For a given object, if cb_node is in that objects cb_bindings, remove cb_node static void removeCommandBufferBinding(layer_data *dev_data, VK_OBJECT const *object, GLOBAL_CB_NODE *cb_node) { BASE_NODE *base_obj = GetStateStructPtrFromObject(dev_data, *object); - if (base_obj) - base_obj->cb_bindings.erase(cb_node); + if (base_obj) base_obj->cb_bindings.erase(cb_node); } // Reset the command buffer state // Maintain the createInfo and set state to CB_NEW, but clear all other state @@ -3942,8 +3922,7 @@ static void resetCB(layer_data *dev_data, const VkCommandBuffer cb) { // Remove this cmdBuffer's reference from each FrameBuffer's CB ref list for (auto framebuffer : pCB->framebuffers) { auto fb_state = getFramebufferState(dev_data, framebuffer); - if (fb_state) - fb_state->cb_bindings.erase(pCB); + if (fb_state) fb_state->cb_bindings.erase(pCB); } pCB->framebuffers.clear(); pCB->activeFramebuffer = VK_NULL_HANDLE; @@ -3954,7 +3933,7 @@ static void resetCB(layer_data *dev_data, const VkCommandBuffer cb) { static void set_cb_pso_status(GLOBAL_CB_NODE *pCB, const PIPELINE_STATE *pPipe) { // Account for any dynamic state not set via this PSO if (!pPipe->graphicsPipelineCI.pDynamicState || - !pPipe->graphicsPipelineCI.pDynamicState->dynamicStateCount) { // All state is static + !pPipe->graphicsPipelineCI.pDynamicState->dynamicStateCount) { // All state is static pCB->status |= CBSTATUS_ALL_STATE_SET; } else { // First consider all state on @@ -3963,30 +3942,30 @@ static void set_cb_pso_status(GLOBAL_CB_NODE *pCB, const PIPELINE_STATE *pPipe) CBStatusFlags psoDynStateMask = CBSTATUS_ALL_STATE_SET; for (uint32_t i = 0; i < pPipe->graphicsPipelineCI.pDynamicState->dynamicStateCount; i++) { switch (pPipe->graphicsPipelineCI.pDynamicState->pDynamicStates[i]) { - case VK_DYNAMIC_STATE_LINE_WIDTH: - psoDynStateMask &= ~CBSTATUS_LINE_WIDTH_SET; - break; - case VK_DYNAMIC_STATE_DEPTH_BIAS: - psoDynStateMask &= ~CBSTATUS_DEPTH_BIAS_SET; - break; - case VK_DYNAMIC_STATE_BLEND_CONSTANTS: - psoDynStateMask &= ~CBSTATUS_BLEND_CONSTANTS_SET; - break; - case VK_DYNAMIC_STATE_DEPTH_BOUNDS: - psoDynStateMask &= ~CBSTATUS_DEPTH_BOUNDS_SET; - break; - case VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK: - psoDynStateMask &= ~CBSTATUS_STENCIL_READ_MASK_SET; - break; - case VK_DYNAMIC_STATE_STENCIL_WRITE_MASK: - psoDynStateMask &= ~CBSTATUS_STENCIL_WRITE_MASK_SET; - break; - case VK_DYNAMIC_STATE_STENCIL_REFERENCE: - psoDynStateMask &= ~CBSTATUS_STENCIL_REFERENCE_SET; - break; - default: - // TODO : Flag error here - break; + case VK_DYNAMIC_STATE_LINE_WIDTH: + psoDynStateMask &= ~CBSTATUS_LINE_WIDTH_SET; + break; + case VK_DYNAMIC_STATE_DEPTH_BIAS: + psoDynStateMask &= ~CBSTATUS_DEPTH_BIAS_SET; + break; + case VK_DYNAMIC_STATE_BLEND_CONSTANTS: + psoDynStateMask &= ~CBSTATUS_BLEND_CONSTANTS_SET; + break; + case VK_DYNAMIC_STATE_DEPTH_BOUNDS: + psoDynStateMask &= ~CBSTATUS_DEPTH_BOUNDS_SET; + break; + case VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK: + psoDynStateMask &= ~CBSTATUS_STENCIL_READ_MASK_SET; + break; + case VK_DYNAMIC_STATE_STENCIL_WRITE_MASK: + psoDynStateMask &= ~CBSTATUS_STENCIL_WRITE_MASK_SET; + break; + case VK_DYNAMIC_STATE_STENCIL_REFERENCE: + psoDynStateMask &= ~CBSTATUS_STENCIL_REFERENCE_SET; + break; + default: + // TODO : Flag error here + break; } } pCB->status |= psoDynStateMask; @@ -4023,7 +4002,6 @@ static bool outsideRenderPass(const layer_data *my_data, GLOBAL_CB_NODE *pCB, co } static void init_core_validation(instance_layer_data *instance_data, const VkAllocationCallbacks *pAllocator) { - layer_debug_actions(instance_data->report_data, instance_data->logging_callback, pAllocator, "lunarg_core_validation"); } @@ -4067,15 +4045,13 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateInstance(const VkInstanceCreateInfo *pCreat assert(chain_info->u.pLayerInfo); PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr; PFN_vkCreateInstance fpCreateInstance = (PFN_vkCreateInstance)fpGetInstanceProcAddr(NULL, "vkCreateInstance"); - if (fpCreateInstance == NULL) - return VK_ERROR_INITIALIZATION_FAILED; + if (fpCreateInstance == NULL) return VK_ERROR_INITIALIZATION_FAILED; // Advance the link info for the next element on the chain chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext; VkResult result = fpCreateInstance(pCreateInfo, pAllocator, pInstance); - if (result != VK_SUCCESS) - return result; + if (result != VK_SUCCESS) return result; instance_layer_data *instance_data = get_my_data_ptr(get_dispatch_key(*pInstance), instance_layer_data_map); instance_data->instance = *pInstance; @@ -4153,13 +4129,13 @@ static bool ValidateRequestedQueueFamilyProperties(instance_layer_data *instance "Invalid queue create request in vkCreateDevice(). Invalid queueFamilyIndex %u requested.", requestedIndex); } else if (create_info->pQueueCreateInfos[i].queueCount > physical_device_state->queue_family_properties[requestedIndex].queueCount) { - skip_call |= - log_msg(instance_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, - VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, __LINE__, DEVLIMITS_INVALID_QUEUE_CREATE_REQUEST, - "DL", "Invalid queue create request in vkCreateDevice(). QueueFamilyIndex %u only has %u queues, but " - "requested queueCount is %u.", - requestedIndex, physical_device_state->queue_family_properties[requestedIndex].queueCount, - create_info->pQueueCreateInfos[i].queueCount); + skip_call |= log_msg( + instance_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, + __LINE__, DEVLIMITS_INVALID_QUEUE_CREATE_REQUEST, "DL", + "Invalid queue create request in vkCreateDevice(). QueueFamilyIndex %u only has %u queues, but " + "requested queueCount is %u.", + requestedIndex, physical_device_state->queue_family_properties[requestedIndex].queueCount, + create_info->pQueueCreateInfos[i].queueCount); } } } @@ -4182,11 +4158,12 @@ static bool ValidateRequestedFeatures(instance_layer_data *dev_data, VkPhysicalD for (uint32_t i = 0; i < total_bools; i++) { if (requested[i] > actual[i]) { // TODO: Add index to struct member name helper to be able to include a feature name - skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, - VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, __LINE__, DEVLIMITS_INVALID_FEATURE_REQUESTED, - "DL", "While calling vkCreateDevice(), requesting feature #%u in VkPhysicalDeviceFeatures struct, " - "which is not available on this device.", - i); + skip_call |= + log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, + __LINE__, DEVLIMITS_INVALID_FEATURE_REQUESTED, "DL", + "While calling vkCreateDevice(), requesting feature #%u in VkPhysicalDeviceFeatures struct, " + "which is not available on this device.", + i); errors++; } } @@ -4318,16 +4295,18 @@ static bool ValidateStageMaskGsTsEnables(layer_data *dev_data, VkPipelineStageFl bool skip = false; if (!dev_data->enabled_features.geometryShader && (stageMask & VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT)) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, - geo_error_id, "DL", "%s call includes a stageMask with VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT bit set when " - "device does not have geometryShader feature enabled. %s", + geo_error_id, "DL", + "%s call includes a stageMask with VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT bit set when " + "device does not have geometryShader feature enabled. %s", caller, validation_error_map[geo_error_id]); } if (!dev_data->enabled_features.tessellationShader && (stageMask & (VK_PIPELINE_STAGE_TESSELLATION_CONTROL_SHADER_BIT | VK_PIPELINE_STAGE_TESSELLATION_EVALUATION_SHADER_BIT))) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, - tess_error_id, "DL", "%s call includes a stageMask with VK_PIPELINE_STAGE_TESSELLATION_CONTROL_SHADER_BIT " - "and/or VK_PIPELINE_STAGE_TESSELLATION_EVALUATION_SHADER_BIT bit(s) set when device " - "does not have tessellationShader feature enabled. %s", + tess_error_id, "DL", + "%s call includes a stageMask with VK_PIPELINE_STAGE_TESSELLATION_CONTROL_SHADER_BIT " + "and/or VK_PIPELINE_STAGE_TESSELLATION_EVALUATION_SHADER_BIT bit(s) set when device " + "does not have tessellationShader feature enabled. %s", caller, validation_error_map[tess_error_id]); } return skip; @@ -4360,13 +4339,14 @@ static bool ValidateCmdBufImageLayouts(layer_data *dev_data, GLOBAL_CB_NODE *pCB cb_image_data.first.subresource.arrayLayer, cb_image_data.first.subresource.mipLevel, string_VkImageLayout(imageLayout), string_VkImageLayout(cb_image_data.second.initialLayout)); } else { - skip_call |= log_msg( - dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast(pCB->commandBuffer), __LINE__, DRAWSTATE_INVALID_IMAGE_LAYOUT, "DS", - "Cannot submit cmd buffer using image (0x%" PRIx64 ") with layout %s when " - "first use is %s.", - reinterpret_cast(cb_image_data.first.image), string_VkImageLayout(imageLayout), - string_VkImageLayout(cb_image_data.second.initialLayout)); + skip_call |= + log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, + VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, reinterpret_cast(pCB->commandBuffer), + __LINE__, DRAWSTATE_INVALID_IMAGE_LAYOUT, "DS", "Cannot submit cmd buffer using image (0x%" PRIx64 + ") with layout %s when " + "first use is %s.", + reinterpret_cast(cb_image_data.first.image), string_VkImageLayout(imageLayout), + string_VkImageLayout(cb_image_data.second.initialLayout)); } } SetLayout(dev_data, cb_image_data.first, cb_image_data.second.layout); @@ -4383,79 +4363,79 @@ static bool ValidateAndIncrementBoundObjects(layer_data *dev_data, GLOBAL_CB_NOD BASE_NODE *base_obj = nullptr; for (auto obj : cb_node->object_bindings) { switch (obj.type) { - case VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT: { - base_obj = getSetNode(dev_data, reinterpret_cast(obj.handle)); - error_code = DRAWSTATE_INVALID_DESCRIPTOR_SET; - break; - } - case VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_EXT: { - base_obj = getSamplerState(dev_data, reinterpret_cast(obj.handle)); - error_code = DRAWSTATE_INVALID_SAMPLER; - break; - } - case VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT: { - base_obj = getQueryPoolNode(dev_data, reinterpret_cast(obj.handle)); - error_code = DRAWSTATE_INVALID_QUERY_POOL; - break; - } - case VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT: { - base_obj = getPipelineState(dev_data, reinterpret_cast(obj.handle)); - error_code = DRAWSTATE_INVALID_PIPELINE; - break; - } - case VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT: { - base_obj = getBufferState(dev_data, reinterpret_cast(obj.handle)); - error_code = DRAWSTATE_INVALID_BUFFER; - break; - } - case VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_VIEW_EXT: { - base_obj = getBufferViewState(dev_data, reinterpret_cast(obj.handle)); - error_code = DRAWSTATE_INVALID_BUFFER_VIEW; - break; - } - case VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT: { - base_obj = getImageState(dev_data, reinterpret_cast(obj.handle)); - error_code = DRAWSTATE_INVALID_IMAGE; - break; - } - case VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_VIEW_EXT: { - base_obj = getImageViewState(dev_data, reinterpret_cast(obj.handle)); - error_code = DRAWSTATE_INVALID_IMAGE_VIEW; - break; - } - case VK_DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT: { - base_obj = getEventNode(dev_data, reinterpret_cast(obj.handle)); - error_code = DRAWSTATE_INVALID_EVENT; - break; - } - case VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT: { - base_obj = getDescriptorPoolState(dev_data, reinterpret_cast(obj.handle)); - error_code = DRAWSTATE_INVALID_DESCRIPTOR_POOL; - break; - } - case VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_POOL_EXT: { - base_obj = getCommandPoolNode(dev_data, reinterpret_cast(obj.handle)); - error_code = DRAWSTATE_INVALID_COMMAND_POOL; - break; - } - case VK_DEBUG_REPORT_OBJECT_TYPE_FRAMEBUFFER_EXT: { - base_obj = getFramebufferState(dev_data, reinterpret_cast(obj.handle)); - error_code = DRAWSTATE_INVALID_FRAMEBUFFER; - break; - } - case VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT: { - base_obj = getRenderPassState(dev_data, reinterpret_cast(obj.handle)); - error_code = DRAWSTATE_INVALID_RENDERPASS; - break; - } - case VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT: { - base_obj = getMemObjInfo(dev_data, reinterpret_cast(obj.handle)); - error_code = DRAWSTATE_INVALID_DEVICE_MEMORY; - break; - } - default: - // TODO : Merge handling of other objects types into this code - break; + case VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT: { + base_obj = getSetNode(dev_data, reinterpret_cast(obj.handle)); + error_code = DRAWSTATE_INVALID_DESCRIPTOR_SET; + break; + } + case VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_EXT: { + base_obj = getSamplerState(dev_data, reinterpret_cast(obj.handle)); + error_code = DRAWSTATE_INVALID_SAMPLER; + break; + } + case VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT: { + base_obj = getQueryPoolNode(dev_data, reinterpret_cast(obj.handle)); + error_code = DRAWSTATE_INVALID_QUERY_POOL; + break; + } + case VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT: { + base_obj = getPipelineState(dev_data, reinterpret_cast(obj.handle)); + error_code = DRAWSTATE_INVALID_PIPELINE; + break; + } + case VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT: { + base_obj = getBufferState(dev_data, reinterpret_cast(obj.handle)); + error_code = DRAWSTATE_INVALID_BUFFER; + break; + } + case VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_VIEW_EXT: { + base_obj = getBufferViewState(dev_data, reinterpret_cast(obj.handle)); + error_code = DRAWSTATE_INVALID_BUFFER_VIEW; + break; + } + case VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT: { + base_obj = getImageState(dev_data, reinterpret_cast(obj.handle)); + error_code = DRAWSTATE_INVALID_IMAGE; + break; + } + case VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_VIEW_EXT: { + base_obj = getImageViewState(dev_data, reinterpret_cast(obj.handle)); + error_code = DRAWSTATE_INVALID_IMAGE_VIEW; + break; + } + case VK_DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT: { + base_obj = getEventNode(dev_data, reinterpret_cast(obj.handle)); + error_code = DRAWSTATE_INVALID_EVENT; + break; + } + case VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT: { + base_obj = getDescriptorPoolState(dev_data, reinterpret_cast(obj.handle)); + error_code = DRAWSTATE_INVALID_DESCRIPTOR_POOL; + break; + } + case VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_POOL_EXT: { + base_obj = getCommandPoolNode(dev_data, reinterpret_cast(obj.handle)); + error_code = DRAWSTATE_INVALID_COMMAND_POOL; + break; + } + case VK_DEBUG_REPORT_OBJECT_TYPE_FRAMEBUFFER_EXT: { + base_obj = getFramebufferState(dev_data, reinterpret_cast(obj.handle)); + error_code = DRAWSTATE_INVALID_FRAMEBUFFER; + break; + } + case VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT: { + base_obj = getRenderPassState(dev_data, reinterpret_cast(obj.handle)); + error_code = DRAWSTATE_INVALID_RENDERPASS; + break; + } + case VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT: { + base_obj = getMemObjInfo(dev_data, reinterpret_cast(obj.handle)); + error_code = DRAWSTATE_INVALID_DEVICE_MEMORY; + break; + } + default: + // TODO : Merge handling of other objects types into this code + break; } if (!base_obj) { skip |= @@ -4494,8 +4474,7 @@ static bool validateAndIncrementResources(layer_data *dev_data, GLOBAL_CB_NODE * } for (auto event : cb_node->writeEventsBeforeWait) { auto event_state = getEventNode(dev_data, event); - if (event_state) - event_state->write_in_use++; + if (event_state) event_state->write_in_use++; } return skip_call; } @@ -4661,8 +4640,7 @@ static bool validateCommandBufferSimultaneousUse(layer_data *dev_data, GLOBAL_CB static bool validateCommandBufferState(layer_data *dev_data, GLOBAL_CB_NODE *pCB, const char *call_source) { bool skip = false; - if (dev_data->instance_data->disabled.command_buffer_state) - return skip; + if (dev_data->instance_data->disabled.command_buffer_state) return skip; // Validate ONE_TIME_SUBMIT_BIT CB is not being submitted more than once if ((pCB->beginInfo.flags & VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT) && (pCB->submitCount > 1)) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, 0, @@ -4687,7 +4665,7 @@ static bool validateCommandBufferState(layer_data *dev_data, GLOBAL_CB_NODE *pCB "You are submitting command buffer 0x%p that is invalid because bound %s 0x%" PRIxLEAST64 " was %s.", pCB->commandBuffer, type_str, obj.handle, cause_str); } - } else { // Flag error for using CB w/o vkEndCommandBuffer() called + } else { // Flag error for using CB w/o vkEndCommandBuffer() called skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, (uint64_t)(pCB->commandBuffer), __LINE__, DRAWSTATE_NO_END_COMMAND_BUFFER, "DS", "You must call vkEndCommandBuffer() on command buffer 0x%p before this call to %s!", pCB->commandBuffer, @@ -4851,12 +4829,11 @@ VKAPI_ATTR VkResult VKAPI_CALL QueueSubmit(VkQueue queue, uint32_t submitCount, cbs.push_back(secondaryCmdBuffer); } - cb_node->submitCount++; // increment submit count + cb_node->submitCount++; // increment submit count skip_call |= validatePrimaryCommandBufferState(dev_data, cb_node); skip_call |= validateQueueFamilyIndices(dev_data, cb_node, queue); // Potential early exit here as bad object state may crash in delayed function calls - if (skip_call) - return result; + if (skip_call) return result; // Call submit-time functions to validate/update state for (auto &function : cb_node->validate_functions) { skip_call |= function(); @@ -4883,8 +4860,7 @@ VKAPI_ATTR VkResult VKAPI_CALL QueueSubmit(VkQueue queue, uint32_t submitCount, } lock.unlock(); - if (!skip_call) - result = dev_data->dispatch_table.QueueSubmit(queue, submitCount, pSubmits, fence); + if (!skip_call) result = dev_data->dispatch_table.QueueSubmit(queue, submitCount, pSubmits, fence); return result; } @@ -4926,8 +4902,7 @@ VKAPI_ATTR VkResult VKAPI_CALL AllocateMemory(VkDevice device, const VkMemoryAll // For given obj node, if it is use, flag a validation error and return callback result, else return false bool ValidateObjectNotInUse(const layer_data *dev_data, BASE_NODE *obj_node, VK_OBJECT obj_struct, UNIQUE_VALIDATION_ERROR_CODE error_code) { - if (dev_data->instance_data->disabled.object_in_use) - return false; + if (dev_data->instance_data->disabled.object_in_use) return false; bool skip = false; if (obj_node->in_use.load()) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, obj_struct.type, obj_struct.handle, __LINE__, @@ -4940,8 +4915,7 @@ bool ValidateObjectNotInUse(const layer_data *dev_data, BASE_NODE *obj_node, VK_ static bool PreCallValidateFreeMemory(layer_data *dev_data, VkDeviceMemory mem, DEVICE_MEM_INFO **mem_info, VK_OBJECT *obj_struct) { *mem_info = getMemObjInfo(dev_data, mem); *obj_struct = {reinterpret_cast(mem), VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT}; - if (dev_data->instance_data->disabled.free_memory) - return false; + if (dev_data->instance_data->disabled.free_memory) return false; bool skip = false; if (*mem_info) { skip |= ValidateObjectNotInUse(dev_data, *mem_info, *obj_struct, VALIDATION_ERROR_00620); @@ -4956,21 +4930,21 @@ static void PostCallRecordFreeMemory(layer_data *dev_data, VkDeviceMemory mem, D "MEM", "VK Object 0x%" PRIxLEAST64 " still has a reference to mem obj 0x%" PRIxLEAST64, obj.handle, (uint64_t)mem_info->mem); switch (obj.type) { - case VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT: { - auto image_state = getImageState(dev_data, reinterpret_cast(obj.handle)); - assert(image_state); // Any destroyed images should already be removed from bindings - image_state->binding.mem = MEMORY_UNBOUND; - break; - } - case VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT: { - auto buffer_state = getBufferState(dev_data, reinterpret_cast(obj.handle)); - assert(buffer_state); // Any destroyed buffers should already be removed from bindings - buffer_state->binding.mem = MEMORY_UNBOUND; - break; - } - default: - // Should only have buffer or image objects bound to memory - assert(0); + case VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT: { + auto image_state = getImageState(dev_data, reinterpret_cast(obj.handle)); + assert(image_state); // Any destroyed images should already be removed from bindings + image_state->binding.mem = MEMORY_UNBOUND; + break; + } + case VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT: { + auto buffer_state = getBufferState(dev_data, reinterpret_cast(obj.handle)); + assert(buffer_state); // Any destroyed buffers should already be removed from bindings + buffer_state->binding.mem = MEMORY_UNBOUND; + break; + } + default: + // Should only have buffer or image objects bound to memory + assert(0); } } // Any bound cmd buffers are now invalid @@ -5117,7 +5091,8 @@ static inline bool verifyWaitFenceState(layer_data *dev_data, VkFence fence, con if (pFence->state == FENCE_UNSIGNALED) { skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT, reinterpret_cast(fence), __LINE__, MEMTRACK_INVALID_FENCE_STATE, "MEM", - "%s called for fence 0x%" PRIxLEAST64 " which has not been submitted on a Queue or during " + "%s called for fence 0x%" PRIxLEAST64 + " which has not been submitted on a Queue or during " "acquire next image.", apiCall, reinterpret_cast(fence)); } @@ -5138,8 +5113,7 @@ static void RetireFence(layer_data *dev_data, VkFence fence) { } static bool PreCallValidateWaitForFences(layer_data *dev_data, uint32_t fence_count, const VkFence *fences) { - if (dev_data->instance_data->disabled.wait_for_fences) - return false; + if (dev_data->instance_data->disabled.wait_for_fences) return false; bool skip = false; for (uint32_t i = 0; i < fence_count; i++) { skip |= verifyWaitFenceState(dev_data, fences[i], "vkWaitForFences"); @@ -5167,8 +5141,7 @@ VKAPI_ATTR VkResult VKAPI_CALL WaitForFences(VkDevice device, uint32_t fenceCoun std::unique_lock lock(global_lock); bool skip = PreCallValidateWaitForFences(dev_data, fenceCount, pFences); lock.unlock(); - if (skip) - return VK_ERROR_VALIDATION_FAILED_EXT; + if (skip) return VK_ERROR_VALIDATION_FAILED_EXT; VkResult result = dev_data->dispatch_table.WaitForFences(device, fenceCount, pFences, waitAll, timeout); @@ -5181,8 +5154,7 @@ VKAPI_ATTR VkResult VKAPI_CALL WaitForFences(VkDevice device, uint32_t fenceCoun } static bool PreCallValidateGetFenceStatus(layer_data *dev_data, VkFence fence) { - if (dev_data->instance_data->disabled.get_fence_state) - return false; + if (dev_data->instance_data->disabled.get_fence_state) return false; return verifyWaitFenceState(dev_data, fence, "vkGetFenceStatus"); } @@ -5193,8 +5165,7 @@ VKAPI_ATTR VkResult VKAPI_CALL GetFenceStatus(VkDevice device, VkFence fence) { std::unique_lock lock(global_lock); bool skip = PreCallValidateGetFenceStatus(dev_data, fence); lock.unlock(); - if (skip) - return VK_ERROR_VALIDATION_FAILED_EXT; + if (skip) return VK_ERROR_VALIDATION_FAILED_EXT; VkResult result = dev_data->dispatch_table.GetFenceStatus(device, fence); if (result == VK_SUCCESS) { @@ -5226,8 +5197,7 @@ VKAPI_ATTR void VKAPI_CALL GetDeviceQueue(VkDevice device, uint32_t queueFamilyI static bool PreCallValidateQueueWaitIdle(layer_data *dev_data, VkQueue queue, QUEUE_STATE **queue_state) { *queue_state = getQueueState(dev_data, queue); - if (dev_data->instance_data->disabled.queue_wait_idle) - return false; + if (dev_data->instance_data->disabled.queue_wait_idle) return false; return VerifyQueueStateToSeq(dev_data, *queue_state, (*queue_state)->seq + (*queue_state)->submissions.size()); } @@ -5241,8 +5211,7 @@ VKAPI_ATTR VkResult VKAPI_CALL QueueWaitIdle(VkQueue queue) { std::unique_lock lock(global_lock); bool skip = PreCallValidateQueueWaitIdle(dev_data, queue, &queue_state); lock.unlock(); - if (skip) - return VK_ERROR_VALIDATION_FAILED_EXT; + if (skip) return VK_ERROR_VALIDATION_FAILED_EXT; VkResult result = dev_data->dispatch_table.QueueWaitIdle(queue); if (VK_SUCCESS == result) { lock.lock(); @@ -5253,8 +5222,7 @@ VKAPI_ATTR VkResult VKAPI_CALL QueueWaitIdle(VkQueue queue) { } static bool PreCallValidateDeviceWaitIdle(layer_data *dev_data) { - if (dev_data->instance_data->disabled.device_wait_idle) - return false; + if (dev_data->instance_data->disabled.device_wait_idle) return false; bool skip = false; for (auto &queue : dev_data->queueMap) { skip |= VerifyQueueStateToSeq(dev_data, &queue.second, queue.second.seq + queue.second.submissions.size()); @@ -5273,8 +5241,7 @@ VKAPI_ATTR VkResult VKAPI_CALL DeviceWaitIdle(VkDevice device) { std::unique_lock lock(global_lock); bool skip = PreCallValidateDeviceWaitIdle(dev_data); lock.unlock(); - if (skip) - return VK_ERROR_VALIDATION_FAILED_EXT; + if (skip) return VK_ERROR_VALIDATION_FAILED_EXT; VkResult result = dev_data->dispatch_table.DeviceWaitIdle(device); if (VK_SUCCESS == result) { lock.lock(); @@ -5287,8 +5254,7 @@ VKAPI_ATTR VkResult VKAPI_CALL DeviceWaitIdle(VkDevice device) { static bool PreCallValidateDestroyFence(layer_data *dev_data, VkFence fence, FENCE_NODE **fence_node, VK_OBJECT *obj_struct) { *fence_node = getFenceNode(dev_data, fence); *obj_struct = {reinterpret_cast(fence), VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT}; - if (dev_data->instance_data->disabled.destroy_fence) - return false; + if (dev_data->instance_data->disabled.destroy_fence) return false; bool skip = false; if (*fence_node) { if ((*fence_node)->state == FENCE_INFLIGHT) { @@ -5322,8 +5288,7 @@ static bool PreCallValidateDestroySemaphore(layer_data *dev_data, VkSemaphore se VK_OBJECT *obj_struct) { *sema_node = getSemaphoreNode(dev_data, semaphore); *obj_struct = {reinterpret_cast(semaphore), VK_DEBUG_REPORT_OBJECT_TYPE_SEMAPHORE_EXT}; - if (dev_data->instance_data->disabled.destroy_semaphore) - return false; + if (dev_data->instance_data->disabled.destroy_semaphore) return false; bool skip = false; if (*sema_node) { skip |= ValidateObjectNotInUse(dev_data, *sema_node, *obj_struct, VALIDATION_ERROR_00199); @@ -5350,8 +5315,7 @@ VKAPI_ATTR void VKAPI_CALL DestroySemaphore(VkDevice device, VkSemaphore semapho static bool PreCallValidateDestroyEvent(layer_data *dev_data, VkEvent event, EVENT_STATE **event_state, VK_OBJECT *obj_struct) { *event_state = getEventNode(dev_data, event); *obj_struct = {reinterpret_cast(event), VK_DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT}; - if (dev_data->instance_data->disabled.destroy_event) - return false; + if (dev_data->instance_data->disabled.destroy_event) return false; bool skip = false; if (*event_state) { skip |= ValidateObjectNotInUse(dev_data, *event_state, *obj_struct, VALIDATION_ERROR_00213); @@ -5382,8 +5346,7 @@ static bool PreCallValidateDestroyQueryPool(layer_data *dev_data, VkQueryPool qu VK_OBJECT *obj_struct) { *qp_state = getQueryPoolNode(dev_data, query_pool); *obj_struct = {reinterpret_cast(query_pool), VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT}; - if (dev_data->instance_data->disabled.destroy_query_pool) - return false; + if (dev_data->instance_data->disabled.destroy_query_pool) return false; bool skip = false; if (*qp_state) { skip |= ValidateObjectNotInUse(dev_data, *qp_state, *obj_struct, VALIDATION_ERROR_01012); @@ -5419,8 +5382,7 @@ static bool PreCallValidateGetQueryPoolResults(layer_data *dev_data, VkQueryPool (*queries_in_flight)[query_state_pair.first].push_back(cmd_buffer); } } - if (dev_data->instance_data->disabled.get_query_pool_results) - return false; + if (dev_data->instance_data->disabled.get_query_pool_results) return false; bool skip = false; for (uint32_t i = 0; i < query_count; ++i) { QueryObject query = {query_pool, first_query + i}; @@ -5506,8 +5468,7 @@ VKAPI_ATTR VkResult VKAPI_CALL GetQueryPoolResults(VkDevice device, VkQueryPool std::unique_lock lock(global_lock); bool skip = PreCallValidateGetQueryPoolResults(dev_data, queryPool, firstQuery, queryCount, flags, &queries_in_flight); lock.unlock(); - if (skip) - return VK_ERROR_VALIDATION_FAILED_EXT; + if (skip) return VK_ERROR_VALIDATION_FAILED_EXT; VkResult result = dev_data->dispatch_table.GetQueryPoolResults(device, queryPool, firstQuery, queryCount, dataSize, pData, stride, flags); lock.lock(); @@ -5550,10 +5511,8 @@ static bool rangesIntersect(layer_data const *dev_data, MEMORY_RANGE const *rang if (range1->linear != range2->linear) { pad_align = dev_data->phys_dev_properties.properties.limits.bufferImageGranularity; } - if ((r1_end & ~(pad_align - 1)) < (r2_start & ~(pad_align - 1))) - return false; - if ((r1_start & ~(pad_align - 1)) > (r2_end & ~(pad_align - 1))) - return false; + if ((r1_end & ~(pad_align - 1)) < (r2_start & ~(pad_align - 1))) return false; + if ((r1_start & ~(pad_align - 1)) > (r2_end & ~(pad_align - 1))) return false; if (range1->linear != range2->linear) { // In linear vs. non-linear case, warn of aliasing @@ -5681,8 +5640,7 @@ static bool PreCallValidateDestroyBuffer(layer_data *dev_data, VkBuffer buffer, VK_OBJECT *obj_struct) { *buffer_state = getBufferState(dev_data, buffer); *obj_struct = {reinterpret_cast(buffer), VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT}; - if (dev_data->instance_data->disabled.destroy_buffer) - return false; + if (dev_data->instance_data->disabled.destroy_buffer) return false; bool skip = false; if (*buffer_state) { skip |= validateIdleBuffer(dev_data, buffer); @@ -5720,8 +5678,7 @@ static bool PreCallValidateDestroyBufferView(layer_data *dev_data, VkBufferView VK_OBJECT *obj_struct) { *buffer_view_state = getBufferViewState(dev_data, buffer_view); *obj_struct = {reinterpret_cast(buffer_view), VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_VIEW_EXT}; - if (dev_data->instance_data->disabled.destroy_buffer_view) - return false; + if (dev_data->instance_data->disabled.destroy_buffer_view) return false; bool skip = false; if (*buffer_view_state) { skip |= ValidateObjectNotInUse(dev_data, *buffer_view_state, *obj_struct, VALIDATION_ERROR_00701); @@ -5755,8 +5712,7 @@ VKAPI_ATTR void VKAPI_CALL DestroyBufferView(VkDevice device, VkBufferView buffe static bool PreCallValidateDestroyImage(layer_data *dev_data, VkImage image, IMAGE_STATE **image_state, VK_OBJECT *obj_struct) { *image_state = getImageState(dev_data, image); *obj_struct = {reinterpret_cast(image), VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT}; - if (dev_data->instance_data->disabled.destroy_image) - return false; + if (dev_data->instance_data->disabled.destroy_image) return false; bool skip = false; if (*image_state) { skip |= ValidateObjectNotInUse(dev_data, *image_state, *obj_struct, VALIDATION_ERROR_00743); @@ -5854,7 +5810,8 @@ VKAPI_ATTR VkResult VKAPI_CALL BindBufferMemory(VkDevice device, VkBuffer buffer if (vk_safe_modulo(memoryOffset, buffer_state->requirements.alignment) != 0) { skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, __LINE__, VALIDATION_ERROR_02174, "DS", - "vkBindBufferMemory(): memoryOffset is 0x%" PRIxLEAST64 " but must be an integer multiple of the " + "vkBindBufferMemory(): memoryOffset is 0x%" PRIxLEAST64 + " but must be an integer multiple of the " "VkMemoryRequirements::alignment value 0x%" PRIxLEAST64 ", returned from a call to vkGetBufferMemoryRequirements with buffer. %s", memoryOffset, buffer_state->requirements.alignment, validation_error_map[VALIDATION_ERROR_02174]); @@ -5867,8 +5824,12 @@ VKAPI_ATTR VkResult VKAPI_CALL BindBufferMemory(VkDevice device, VkBuffer buffer static const char *memory_type[3] = {"texel", "uniform", "storage"}; static const char *offset_name[3] = {"minTexelBufferOffsetAlignment", "minUniformBufferOffsetAlignment", "minStorageBufferOffsetAlignment"}; - static const UNIQUE_VALIDATION_ERROR_CODE msgCode[3] = {VALIDATION_ERROR_00794, VALIDATION_ERROR_00795, - VALIDATION_ERROR_00796}; + + // TODO: vk_validation_stats.py cannot abide braces immediately preceeding or following a validation error enum + // clang-format off + static const UNIQUE_VALIDATION_ERROR_CODE msgCode[3] = { VALIDATION_ERROR_00794, VALIDATION_ERROR_00795, + VALIDATION_ERROR_00796 }; + // clang-format on // Keep this one fresh! const VkDeviceSize offset_requirement[3] = { @@ -5880,12 +5841,12 @@ VKAPI_ATTR VkResult VKAPI_CALL BindBufferMemory(VkDevice device, VkBuffer buffer for (int i = 0; i < 3; i++) { if (usage & usage_list[i]) { if (vk_safe_modulo(memoryOffset, offset_requirement[i]) != 0) { - skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, - VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, __LINE__, msgCode[i], "DS", - "vkBindBufferMemory(): %s memoryOffset is 0x%" PRIxLEAST64 " but must be a multiple of " - "device limit %s 0x%" PRIxLEAST64 ". %s", - memory_type[i], memoryOffset, offset_name[i], offset_requirement[i], - validation_error_map[msgCode[i]]); + skip_call |= log_msg( + dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, + __LINE__, msgCode[i], "DS", "vkBindBufferMemory(): %s memoryOffset is 0x%" PRIxLEAST64 + " but must be a multiple of " + "device limit %s 0x%" PRIxLEAST64 ". %s", + memory_type[i], memoryOffset, offset_name[i], offset_requirement[i], validation_error_map[msgCode[i]]); } } } @@ -5922,8 +5883,7 @@ static bool PreCallValidateDestroyImageView(layer_data *dev_data, VkImageView im VK_OBJECT *obj_struct) { *image_view_state = getImageViewState(dev_data, image_view); *obj_struct = {reinterpret_cast(image_view), VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_VIEW_EXT}; - if (dev_data->instance_data->disabled.destroy_image_view) - return false; + if (dev_data->instance_data->disabled.destroy_image_view) return false; bool skip = false; if (*image_view_state) { skip |= ValidateObjectNotInUse(dev_data, *image_view_state, *obj_struct, VALIDATION_ERROR_00776); @@ -5968,8 +5928,7 @@ static bool PreCallValidateDestroyPipeline(layer_data *dev_data, VkPipeline pipe VK_OBJECT *obj_struct) { *pipeline_state = getPipelineState(dev_data, pipeline); *obj_struct = {reinterpret_cast(pipeline), VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT}; - if (dev_data->instance_data->disabled.destroy_pipeline) - return false; + if (dev_data->instance_data->disabled.destroy_pipeline) return false; bool skip = false; if (*pipeline_state) { skip |= ValidateObjectNotInUse(dev_data, *pipeline_state, *obj_struct, VALIDATION_ERROR_00555); @@ -6012,8 +5971,7 @@ static bool PreCallValidateDestroySampler(layer_data *dev_data, VkSampler sample VK_OBJECT *obj_struct) { *sampler_state = getSamplerState(dev_data, sampler); *obj_struct = {reinterpret_cast(sampler), VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_EXT}; - if (dev_data->instance_data->disabled.destroy_sampler) - return false; + if (dev_data->instance_data->disabled.destroy_sampler) return false; bool skip = false; if (*sampler_state) { skip |= ValidateObjectNotInUse(dev_data, *sampler_state, *obj_struct, VALIDATION_ERROR_00837); @@ -6024,8 +5982,7 @@ static bool PreCallValidateDestroySampler(layer_data *dev_data, VkSampler sample static void PostCallRecordDestroySampler(layer_data *dev_data, VkSampler sampler, SAMPLER_STATE *sampler_state, VK_OBJECT obj_struct) { // Any bound cmd buffers are now invalid - if (sampler_state) - invalidateCommandBuffers(dev_data, sampler_state->cb_bindings, obj_struct); + if (sampler_state) invalidateCommandBuffers(dev_data, sampler_state->cb_bindings, obj_struct); dev_data->samplerMap.erase(sampler); } @@ -6059,8 +6016,7 @@ static bool PreCallValidateDestroyDescriptorPool(layer_data *dev_data, VkDescrip DESCRIPTOR_POOL_STATE **desc_pool_state, VK_OBJECT *obj_struct) { *desc_pool_state = getDescriptorPoolState(dev_data, pool); *obj_struct = {reinterpret_cast(pool), VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT}; - if (dev_data->instance_data->disabled.destroy_descriptor_pool) - return false; + if (dev_data->instance_data->disabled.destroy_descriptor_pool) return false; bool skip = false; if (*desc_pool_state) { skip |= ValidateObjectNotInUse(dev_data, *desc_pool_state, *obj_struct, VALIDATION_ERROR_00901); @@ -6146,8 +6102,7 @@ VKAPI_ATTR void VKAPI_CALL FreeCommandBuffers(VkDevice device, VkCommandPool com } } - if (skip_call) - return; + if (skip_call) return; auto pPool = getCommandPoolNode(dev_data, commandPool); for (uint32_t i = 0; i < commandBufferCount; i++) { @@ -6185,7 +6140,6 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateCommandPool(VkDevice device, const VkComman VKAPI_ATTR VkResult VKAPI_CALL CreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkQueryPool *pQueryPool) { - layer_data *dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); bool skip = false; if (pCreateInfo && pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) { @@ -6212,8 +6166,7 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateQueryPool(VkDevice device, const VkQueryPoo static bool PreCallValidateDestroyCommandPool(layer_data *dev_data, VkCommandPool pool, COMMAND_POOL_NODE **cp_state) { *cp_state = getCommandPoolNode(dev_data, pool); - if (dev_data->instance_data->disabled.destroy_command_pool) - return false; + if (dev_data->instance_data->disabled.destroy_command_pool) return false; bool skip = false; if (*cp_state) { // Verify that command buffers in pool are complete (not in-flight) @@ -6235,11 +6188,10 @@ static void PostCallRecordDestroyCommandPool(layer_data *dev_data, VkCommandPool } for (auto framebuffer : cb_node->framebuffers) { auto fb_state = getFramebufferState(dev_data, framebuffer); - if (fb_state) - fb_state->cb_bindings.erase(cb_node); + if (fb_state) fb_state->cb_bindings.erase(cb_node); } - dev_data->commandBufferMap.erase(cb); // Remove this command buffer - delete cb_node; // delete CB info structure + dev_data->commandBufferMap.erase(cb); // Remove this command buffer + delete cb_node; // delete CB info structure } dev_data->commandPoolMap.erase(pool); } @@ -6267,8 +6219,7 @@ VKAPI_ATTR VkResult VKAPI_CALL ResetCommandPool(VkDevice device, VkCommandPool c skip_call |= checkCommandBuffersInFlight(dev_data, pPool, "reset command pool with", VALIDATION_ERROR_00072); lock.unlock(); - if (skip_call) - return VK_ERROR_VALIDATION_FAILED_EXT; + if (skip_call) return VK_ERROR_VALIDATION_FAILED_EXT; VkResult result = dev_data->dispatch_table.ResetCommandPool(device, commandPool, flags); @@ -6299,8 +6250,7 @@ VKAPI_ATTR VkResult VKAPI_CALL ResetFences(VkDevice device, uint32_t fenceCount, } lock.unlock(); - if (skip_call) - return VK_ERROR_VALIDATION_FAILED_EXT; + if (skip_call) return VK_ERROR_VALIDATION_FAILED_EXT; VkResult result = dev_data->dispatch_table.ResetFences(device, fenceCount, pFences); @@ -6335,8 +6285,7 @@ static bool PreCallValidateDestroyFramebuffer(layer_data *dev_data, VkFramebuffe FRAMEBUFFER_STATE **framebuffer_state, VK_OBJECT *obj_struct) { *framebuffer_state = getFramebufferState(dev_data, framebuffer); *obj_struct = {reinterpret_cast(framebuffer), VK_DEBUG_REPORT_OBJECT_TYPE_FRAMEBUFFER_EXT}; - if (dev_data->instance_data->disabled.destroy_framebuffer) - return false; + if (dev_data->instance_data->disabled.destroy_framebuffer) return false; bool skip = false; if (*framebuffer_state) { skip |= ValidateObjectNotInUse(dev_data, *framebuffer_state, *obj_struct, VALIDATION_ERROR_00422); @@ -6368,8 +6317,7 @@ static bool PreCallValidateDestroyRenderPass(layer_data *dev_data, VkRenderPass VK_OBJECT *obj_struct) { *rp_state = getRenderPassState(dev_data, render_pass); *obj_struct = {reinterpret_cast(render_pass), VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT}; - if (dev_data->instance_data->disabled.destroy_renderpass) - return false; + if (dev_data->instance_data->disabled.destroy_renderpass) return false; bool skip = false; if (*rp_state) { skip |= ValidateObjectNotInUse(dev_data, *rp_state, *obj_struct, VALIDATION_ERROR_00393); @@ -6436,8 +6384,7 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateBufferView(VkDevice device, const VkBufferV std::unique_lock lock(global_lock); bool skip_call = PreCallValidateCreateBufferView(dev_data, pCreateInfo); lock.unlock(); - if (skip_call) - return VK_ERROR_VALIDATION_FAILED_EXT; + if (skip_call) return VK_ERROR_VALIDATION_FAILED_EXT; VkResult result = dev_data->dispatch_table.CreateBufferView(device, pCreateInfo, pAllocator, pView); if (VK_SUCCESS == result) { lock.lock(); @@ -6516,9 +6463,10 @@ static bool ValidateImageAspectMask(layer_data *dev_data, VkImage image, VkForma } else if (vk_format_is_depth_and_stencil(format)) { if ((aspect_mask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) == 0) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, - (uint64_t)image, __LINE__, VALIDATION_ERROR_00741, "IMAGE", "%s: Depth/stencil image formats must have " - "at least one of VK_IMAGE_ASPECT_DEPTH_BIT " - "and VK_IMAGE_ASPECT_STENCIL_BIT set. %s", + (uint64_t)image, __LINE__, VALIDATION_ERROR_00741, "IMAGE", + "%s: Depth/stencil image formats must have " + "at least one of VK_IMAGE_ASPECT_DEPTH_BIT " + "and VK_IMAGE_ASPECT_STENCIL_BIT set. %s", func_name, validation_error_map[VALIDATION_ERROR_00741]); } else if ((aspect_mask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) != aspect_mask) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, @@ -6647,8 +6595,7 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateImageView(VkDevice device, const VkImageVie std::unique_lock lock(global_lock); bool skip = PreCallValidateCreateImageView(dev_data, pCreateInfo); lock.unlock(); - if (skip) - return VK_ERROR_VALIDATION_FAILED_EXT; + if (skip) return VK_ERROR_VALIDATION_FAILED_EXT; VkResult result = dev_data->dispatch_table.CreateImageView(device, pCreateInfo, pAllocator, pView); if (VK_SUCCESS == result) { lock.lock(); @@ -6860,8 +6807,7 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateSampler(VkDevice device, const VkSamplerCre } static bool PreCallValidateCreateDescriptorSetLayout(layer_data *dev_data, const VkDescriptorSetLayoutCreateInfo *create_info) { - if (dev_data->instance_data->disabled.create_descriptor_set_layout) - return false; + if (dev_data->instance_data->disabled.create_descriptor_set_layout) return false; return cvdescriptorset::DescriptorSetLayout::ValidateCreateInfo(dev_data->report_data, create_info); } @@ -6893,8 +6839,7 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateDescriptorSetLayout(VkDevice device, const // Note that the index argument is optional and only used by CreatePipelineLayout. static bool validatePushConstantRange(const layer_data *dev_data, const uint32_t offset, const uint32_t size, const char *caller_name, uint32_t index = 0) { - if (dev_data->instance_data->disabled.push_constant_range) - return false; + if (dev_data->instance_data->disabled.push_constant_range) return false; uint32_t const maxPushConstantsSize = dev_data->phys_dev_properties.properties.limits.maxPushConstantsSize; bool skip_call = false; // Check that offset + size don't exceed the max. @@ -6905,30 +6850,34 @@ static bool validatePushConstantRange(const layer_data *dev_data, const uint32_t if (offset >= maxPushConstantsSize) { skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, - VALIDATION_ERROR_00877, "DS", "%s call has push constants index %u with offset %u that " - "exceeds this device's maxPushConstantSize of %u. %s", + VALIDATION_ERROR_00877, "DS", + "%s call has push constants index %u with offset %u that " + "exceeds this device's maxPushConstantSize of %u. %s", caller_name, index, offset, maxPushConstantsSize, validation_error_map[VALIDATION_ERROR_00877]); } if (size > maxPushConstantsSize - offset) { skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, - VALIDATION_ERROR_00880, "DS", "%s call has push constants index %u with offset %u and size %u that " - "exceeds this device's maxPushConstantSize of %u. %s", + VALIDATION_ERROR_00880, "DS", + "%s call has push constants index %u with offset %u and size %u that " + "exceeds this device's maxPushConstantSize of %u. %s", caller_name, index, offset, size, maxPushConstantsSize, validation_error_map[VALIDATION_ERROR_00880]); } } else if (0 == strcmp(caller_name, "vkCmdPushConstants()")) { if (offset >= maxPushConstantsSize) { skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, - VALIDATION_ERROR_00991, "DS", "%s call has push constants index %u with offset %u that " - "exceeds this device's maxPushConstantSize of %u. %s", + VALIDATION_ERROR_00991, "DS", + "%s call has push constants index %u with offset %u that " + "exceeds this device's maxPushConstantSize of %u. %s", caller_name, index, offset, maxPushConstantsSize, validation_error_map[VALIDATION_ERROR_00991]); } if (size > maxPushConstantsSize - offset) { skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, - VALIDATION_ERROR_00992, "DS", "%s call has push constants index %u with offset %u and size %u that " - "exceeds this device's maxPushConstantSize of %u. %s", + VALIDATION_ERROR_00992, "DS", + "%s call has push constants index %u with offset %u and size %u that " + "exceeds this device's maxPushConstantSize of %u. %s", caller_name, index, offset, size, maxPushConstantsSize, validation_error_map[VALIDATION_ERROR_00992]); } } else { @@ -6941,27 +6890,31 @@ static bool validatePushConstantRange(const layer_data *dev_data, const uint32_t if (0 == strcmp(caller_name, "vkCreatePipelineLayout()")) { if (size == 0) { skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, - __LINE__, VALIDATION_ERROR_00878, "DS", "%s call has push constants index %u with " - "size %u. Size must be greater than zero. %s", + __LINE__, VALIDATION_ERROR_00878, "DS", + "%s call has push constants index %u with " + "size %u. Size must be greater than zero. %s", caller_name, index, size, validation_error_map[VALIDATION_ERROR_00878]); } if (size & 0x3) { skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, - __LINE__, VALIDATION_ERROR_00879, "DS", "%s call has push constants index %u with " - "size %u. Size must be a multiple of 4. %s", + __LINE__, VALIDATION_ERROR_00879, "DS", + "%s call has push constants index %u with " + "size %u. Size must be a multiple of 4. %s", caller_name, index, size, validation_error_map[VALIDATION_ERROR_00879]); } } else if (0 == strcmp(caller_name, "vkCmdPushConstants()")) { if (size == 0) { skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, - __LINE__, VALIDATION_ERROR_01000, "DS", "%s call has push constants index %u with " - "size %u. Size must be greater than zero. %s", + __LINE__, VALIDATION_ERROR_01000, "DS", + "%s call has push constants index %u with " + "size %u. Size must be greater than zero. %s", caller_name, index, size, validation_error_map[VALIDATION_ERROR_01000]); } if (size & 0x3) { skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, - __LINE__, VALIDATION_ERROR_00990, "DS", "%s call has push constants index %u with " - "size %u. Size must be a multiple of 4. %s", + __LINE__, VALIDATION_ERROR_00990, "DS", + "%s call has push constants index %u with " + "size %u. Size must be a multiple of 4. %s", caller_name, index, size, validation_error_map[VALIDATION_ERROR_00990]); } } else { @@ -6973,13 +6926,15 @@ static bool validatePushConstantRange(const layer_data *dev_data, const uint32_t if ((offset & 0x3) != 0) { if (0 == strcmp(caller_name, "vkCreatePipelineLayout()")) { skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, - VALIDATION_ERROR_02521, "DS", "%s call has push constants index %u with " - "offset %u. Offset must be a multiple of 4. %s", + VALIDATION_ERROR_02521, "DS", + "%s call has push constants index %u with " + "offset %u. Offset must be a multiple of 4. %s", caller_name, index, offset, validation_error_map[VALIDATION_ERROR_02521]); } else if (0 == strcmp(caller_name, "vkCmdPushConstants()")) { skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, - VALIDATION_ERROR_00989, "DS", "%s call has push constants with " - "offset %u. Offset must be a multiple of 4. %s", + VALIDATION_ERROR_00989, "DS", + "%s call has push constants with " + "offset %u. Offset must be a multiple of 4. %s", caller_name, offset, validation_error_map[VALIDATION_ERROR_00989]); } else { skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, @@ -7005,8 +6960,7 @@ VKAPI_ATTR VkResult VKAPI_CALL CreatePipelineLayout(VkDevice device, const VkPip validation_error_map[VALIDATION_ERROR_00882]); } } - if (skip_call) - return VK_ERROR_VALIDATION_FAILED_EXT; + if (skip_call) return VK_ERROR_VALIDATION_FAILED_EXT; // Each range has been validated. Now check for overlap between ranges (if they are good). // There's no explicit Valid Usage language against this, so issue a warning instead of an error. @@ -7017,11 +6971,11 @@ VKAPI_ATTR VkResult VKAPI_CALL CreatePipelineLayout(VkDevice device, const VkPip const uint32_t minB = pCreateInfo->pPushConstantRanges[j].offset; const uint32_t maxB = minB + pCreateInfo->pPushConstantRanges[j].size; if ((minA <= minB && maxA > minB) || (minB <= minA && maxB > minA)) { - skip_call |= - log_msg(dev_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, - DRAWSTATE_PUSH_CONSTANTS_ERROR, "DS", "vkCreatePipelineLayout() call has push constants with " - "overlapping ranges: %u:[%u, %u), %u:[%u, %u)", - i, minA, maxA, j, minB, maxB); + skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, + __LINE__, DRAWSTATE_PUSH_CONSTANTS_ERROR, "DS", + "vkCreatePipelineLayout() call has push constants with " + "overlapping ranges: %u:[%u, %u), %u:[%u, %u)", + i, minA, maxA, j, minB, maxB); } } } @@ -7084,8 +7038,7 @@ VKAPI_ATTR VkResult VKAPI_CALL ResetDescriptorPool(VkDevice device, VkDescriptor // as well as DescriptorSetLayout ptrs used for later update. static bool PreCallValidateAllocateDescriptorSets(layer_data *dev_data, const VkDescriptorSetAllocateInfo *pAllocateInfo, cvdescriptorset::AllocateDescriptorSetsData *common_data) { - if (dev_data->instance_data->disabled.allocate_descriptor_sets) - return false; + if (dev_data->instance_data->disabled.allocate_descriptor_sets) return false; // All state checks for AllocateDescriptorSets is done in single function return cvdescriptorset::ValidateAllocateDescriptorSets(dev_data->report_data, pAllocateInfo, dev_data, common_data); } @@ -7106,8 +7059,7 @@ VKAPI_ATTR VkResult VKAPI_CALL AllocateDescriptorSets(VkDevice device, const VkD bool skip_call = PreCallValidateAllocateDescriptorSets(dev_data, pAllocateInfo, &common_data); lock.unlock(); - if (skip_call) - return VK_ERROR_VALIDATION_FAILED_EXT; + if (skip_call) return VK_ERROR_VALIDATION_FAILED_EXT; VkResult result = dev_data->dispatch_table.AllocateDescriptorSets(device, pAllocateInfo, pDescriptorSets); @@ -7121,8 +7073,7 @@ VKAPI_ATTR VkResult VKAPI_CALL AllocateDescriptorSets(VkDevice device, const VkD // Verify state before freeing DescriptorSets static bool PreCallValidateFreeDescriptorSets(const layer_data *dev_data, VkDescriptorPool pool, uint32_t count, const VkDescriptorSet *descriptor_sets) { - if (dev_data->instance_data->disabled.free_descriptor_sets) - return false; + if (dev_data->instance_data->disabled.free_descriptor_sets) return false; bool skip_call = false; // First make sure sets being destroyed are not currently in-use for (uint32_t i = 0; i < count; ++i) @@ -7168,8 +7119,7 @@ VKAPI_ATTR VkResult VKAPI_CALL FreeDescriptorSets(VkDevice device, VkDescriptorP bool skip_call = PreCallValidateFreeDescriptorSets(dev_data, descriptorPool, count, pDescriptorSets); lock.unlock(); - if (skip_call) - return VK_ERROR_VALIDATION_FAILED_EXT; + if (skip_call) return VK_ERROR_VALIDATION_FAILED_EXT; VkResult result = dev_data->dispatch_table.FreeDescriptorSets(device, descriptorPool, count, pDescriptorSets); if (VK_SUCCESS == result) { lock.lock(); @@ -7185,8 +7135,7 @@ VKAPI_ATTR VkResult VKAPI_CALL FreeDescriptorSets(VkDevice device, VkDescriptorP static bool PreCallValidateUpdateDescriptorSets(layer_data *dev_data, uint32_t descriptorWriteCount, const VkWriteDescriptorSet *pDescriptorWrites, uint32_t descriptorCopyCount, const VkCopyDescriptorSet *pDescriptorCopies) { - if (dev_data->instance_data->disabled.update_descriptor_sets) - return false; + if (dev_data->instance_data->disabled.update_descriptor_sets) return false; // First thing to do is perform map look-ups. // NOTE : UpdateDescriptorSets is somewhat unique in that it's operating on a number of DescriptorSets // so we can't just do a single map look-up up-front, but do them individually in functions below @@ -7311,7 +7260,8 @@ VKAPI_ATTR VkResult VKAPI_CALL BeginCommandBuffer(VkCommandBuffer commandBuffer, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, reinterpret_cast(commandBuffer), __LINE__, VALIDATION_ERROR_00112, "DS", "vkBeginCommandBuffer(): Secondary Command " - "Buffer (0x%p) renderPass (0x%" PRIxLEAST64 ") is incompatible w/ framebuffer " + "Buffer (0x%p) renderPass (0x%" PRIxLEAST64 + ") is incompatible w/ framebuffer " "(0x%" PRIxLEAST64 ") w/ render pass (0x%" PRIxLEAST64 ") due to: %s. %s", commandBuffer, reinterpret_cast(pInfo->renderPass), reinterpret_cast(pInfo->framebuffer), @@ -7349,11 +7299,12 @@ VKAPI_ATTR VkResult VKAPI_CALL BeginCommandBuffer(VkCommandBuffer commandBuffer, } } if (CB_RECORDING == cb_node->state) { - skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, - VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, (uint64_t)commandBuffer, __LINE__, - VALIDATION_ERROR_00103, "DS", "vkBeginCommandBuffer(): Cannot call Begin on command buffer (0x%p" - ") in the RECORDING state. Must first call vkEndCommandBuffer(). %s", - commandBuffer, validation_error_map[VALIDATION_ERROR_00103]); + skip_call |= + log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, + (uint64_t)commandBuffer, __LINE__, VALIDATION_ERROR_00103, "DS", + "vkBeginCommandBuffer(): Cannot call Begin on command buffer (0x%p" + ") in the RECORDING state. Must first call vkEndCommandBuffer(). %s", + commandBuffer, validation_error_map[VALIDATION_ERROR_00103]); } else if (CB_RECORDED == cb_node->state || (CB_INVALID == cb_node->state && CMD_END == cb_node->last_cmd)) { VkCommandPool cmdPool = cb_node->createInfo.commandPool; auto pPool = getCommandPoolNode(dev_data, cmdPool); @@ -7447,8 +7398,7 @@ VKAPI_ATTR VkResult VKAPI_CALL ResetCommandBuffer(VkCommandBuffer commandBuffer, } skip_call |= checkCommandBufferInFlight(dev_data, pCB, "reset", VALIDATION_ERROR_00092); lock.unlock(); - if (skip_call) - return VK_ERROR_VALIDATION_FAILED_EXT; + if (skip_call) return VK_ERROR_VALIDATION_FAILED_EXT; VkResult result = dev_data->dispatch_table.ResetCommandBuffer(commandBuffer, flags); if (VK_SUCCESS == result) { lock.lock(); @@ -7501,8 +7451,7 @@ VKAPI_ATTR void VKAPI_CALL CmdBindPipeline(VkCommandBuffer commandBuffer, VkPipe } } lock.unlock(); - if (!skip) - dev_data->dispatch_table.CmdBindPipeline(commandBuffer, pipelineBindPoint, pipeline); + if (!skip) dev_data->dispatch_table.CmdBindPipeline(commandBuffer, pipelineBindPoint, pipeline); } VKAPI_ATTR void VKAPI_CALL CmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount, @@ -7517,8 +7466,7 @@ VKAPI_ATTR void VKAPI_CALL CmdSetViewport(VkCommandBuffer commandBuffer, uint32_ pCB->viewportMask |= ((1u << viewportCount) - 1u) << firstViewport; } lock.unlock(); - if (!skip_call) - dev_data->dispatch_table.CmdSetViewport(commandBuffer, firstViewport, viewportCount, pViewports); + if (!skip_call) dev_data->dispatch_table.CmdSetViewport(commandBuffer, firstViewport, viewportCount, pViewports); } VKAPI_ATTR void VKAPI_CALL CmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor, uint32_t scissorCount, @@ -7533,8 +7481,7 @@ VKAPI_ATTR void VKAPI_CALL CmdSetScissor(VkCommandBuffer commandBuffer, uint32_t pCB->scissorMask |= ((1u << scissorCount) - 1u) << firstScissor; } lock.unlock(); - if (!skip_call) - dev_data->dispatch_table.CmdSetScissor(commandBuffer, firstScissor, scissorCount, pScissors); + if (!skip_call) dev_data->dispatch_table.CmdSetScissor(commandBuffer, firstScissor, scissorCount, pScissors); } VKAPI_ATTR void VKAPI_CALL CmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) { @@ -7559,8 +7506,7 @@ VKAPI_ATTR void VKAPI_CALL CmdSetLineWidth(VkCommandBuffer commandBuffer, float } } lock.unlock(); - if (!skip_call) - dev_data->dispatch_table.CmdSetLineWidth(commandBuffer, lineWidth); + if (!skip_call) dev_data->dispatch_table.CmdSetLineWidth(commandBuffer, lineWidth); } VKAPI_ATTR void VKAPI_CALL CmdSetDepthBias(VkCommandBuffer commandBuffer, float depthBiasConstantFactor, float depthBiasClamp, @@ -7590,8 +7536,7 @@ VKAPI_ATTR void VKAPI_CALL CmdSetBlendConstants(VkCommandBuffer commandBuffer, c pCB->status |= CBSTATUS_BLEND_CONSTANTS_SET; } lock.unlock(); - if (!skip_call) - dev_data->dispatch_table.CmdSetBlendConstants(commandBuffer, blendConstants); + if (!skip_call) dev_data->dispatch_table.CmdSetBlendConstants(commandBuffer, blendConstants); } VKAPI_ATTR void VKAPI_CALL CmdSetDepthBounds(VkCommandBuffer commandBuffer, float minDepthBounds, float maxDepthBounds) { @@ -7605,8 +7550,7 @@ VKAPI_ATTR void VKAPI_CALL CmdSetDepthBounds(VkCommandBuffer commandBuffer, floa pCB->status |= CBSTATUS_DEPTH_BOUNDS_SET; } lock.unlock(); - if (!skip_call) - dev_data->dispatch_table.CmdSetDepthBounds(commandBuffer, minDepthBounds, maxDepthBounds); + if (!skip_call) dev_data->dispatch_table.CmdSetDepthBounds(commandBuffer, minDepthBounds, maxDepthBounds); } VKAPI_ATTR void VKAPI_CALL CmdSetStencilCompareMask(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, @@ -7621,8 +7565,7 @@ VKAPI_ATTR void VKAPI_CALL CmdSetStencilCompareMask(VkCommandBuffer commandBuffe pCB->status |= CBSTATUS_STENCIL_READ_MASK_SET; } lock.unlock(); - if (!skip_call) - dev_data->dispatch_table.CmdSetStencilCompareMask(commandBuffer, faceMask, compareMask); + if (!skip_call) dev_data->dispatch_table.CmdSetStencilCompareMask(commandBuffer, faceMask, compareMask); } VKAPI_ATTR void VKAPI_CALL CmdSetStencilWriteMask(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t writeMask) { @@ -7636,8 +7579,7 @@ VKAPI_ATTR void VKAPI_CALL CmdSetStencilWriteMask(VkCommandBuffer commandBuffer, pCB->status |= CBSTATUS_STENCIL_WRITE_MASK_SET; } lock.unlock(); - if (!skip_call) - dev_data->dispatch_table.CmdSetStencilWriteMask(commandBuffer, faceMask, writeMask); + if (!skip_call) dev_data->dispatch_table.CmdSetStencilWriteMask(commandBuffer, faceMask, writeMask); } VKAPI_ATTR void VKAPI_CALL CmdSetStencilReference(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t reference) { @@ -7651,8 +7593,7 @@ VKAPI_ATTR void VKAPI_CALL CmdSetStencilReference(VkCommandBuffer commandBuffer, pCB->status |= CBSTATUS_STENCIL_REFERENCE_SET; } lock.unlock(); - if (!skip_call) - dev_data->dispatch_table.CmdSetStencilReference(commandBuffer, faceMask, reference); + if (!skip_call) dev_data->dispatch_table.CmdSetStencilReference(commandBuffer, faceMask, reference); } VKAPI_ATTR void VKAPI_CALL CmdBindDescriptorSets(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, @@ -7719,7 +7660,7 @@ VKAPI_ATTR void VKAPI_CALL CmdBindDescriptorSets(VkCommandBuffer commandBuffer, "array. There must be one dynamic offset for each dynamic descriptor being bound.", i, (uint64_t)pDescriptorSets[i], descriptor_set->GetDynamicDescriptorCount(), (dynamicOffsetCount - totalDynamicDescriptors)); - } else { // Validate and store dynamic offsets with the set + } else { // Validate and store dynamic offsets with the set // Validate Dynamic Offset Minimums uint32_t cur_dyn_offset = totalDynamicDescriptors; for (uint32_t d = 0; d < descriptor_set->GetTotalDescriptorCount(); d++) { @@ -7730,8 +7671,9 @@ VKAPI_ATTR void VKAPI_CALL CmdBindDescriptorSets(VkCommandBuffer commandBuffer, skip_call |= log_msg( dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, __LINE__, VALIDATION_ERROR_00978, - "DS", "vkCmdBindDescriptorSets(): pDynamicOffsets[%d] is %d but must be a multiple of " - "device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ". %s", + "DS", + "vkCmdBindDescriptorSets(): pDynamicOffsets[%d] is %d but must be a multiple of " + "device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ". %s", cur_dyn_offset, pDynamicOffsets[cur_dyn_offset], dev_data->phys_dev_properties.properties.limits.minUniformBufferOffsetAlignment, validation_error_map[VALIDATION_ERROR_00978]); @@ -7744,8 +7686,9 @@ VKAPI_ATTR void VKAPI_CALL CmdBindDescriptorSets(VkCommandBuffer commandBuffer, skip_call |= log_msg( dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, __LINE__, VALIDATION_ERROR_00978, - "DS", "vkCmdBindDescriptorSets(): pDynamicOffsets[%d] is %d but must be a multiple of " - "device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ". %s", + "DS", + "vkCmdBindDescriptorSets(): pDynamicOffsets[%d] is %d but must be a multiple of " + "device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ". %s", cur_dyn_offset, pDynamicOffsets[cur_dyn_offset], dev_data->phys_dev_properties.properties.limits.minStorageBufferOffsetAlignment, validation_error_map[VALIDATION_ERROR_00978]); @@ -7770,7 +7713,7 @@ VKAPI_ATTR void VKAPI_CALL CmdBindDescriptorSets(VkCommandBuffer commandBuffer, skip_call |= ValidateCmd(dev_data, pCB, CMD_BINDDESCRIPTORSETS, "vkCmdBindDescriptorSets()"); UpdateCmdBufferLastCmd(dev_data, pCB, CMD_BINDDESCRIPTORSETS); // For any previously bound sets, need to set them to "invalid" if they were disturbed by this update - if (firstSet > 0) { // Check set #s below the first bound set + if (firstSet > 0) { // Check set #s below the first bound set for (uint32_t i = 0; i < firstSet; ++i) { if (pCB->lastBound[pipelineBindPoint].boundDescriptorSets[i] && !verify_set_layout_compatibility(dev_data, pCB->lastBound[pipelineBindPoint].boundDescriptorSets[i], @@ -7843,15 +7786,15 @@ VKAPI_ATTR void VKAPI_CALL CmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkB UpdateCmdBufferLastCmd(dev_data, cb_node, CMD_BINDINDEXBUFFER); VkDeviceSize offset_align = 0; switch (indexType) { - case VK_INDEX_TYPE_UINT16: - offset_align = 2; - break; - case VK_INDEX_TYPE_UINT32: - offset_align = 4; - break; - default: - // ParamChecker should catch bad enum, we'll also throw alignment error below if offset_align stays 0 - break; + case VK_INDEX_TYPE_UINT16: + offset_align = 2; + break; + case VK_INDEX_TYPE_UINT32: + offset_align = 4; + break; + default: + // ParamChecker should catch bad enum, we'll also throw alignment error below if offset_align stays 0 + break; } if (!offset_align || (offset % offset_align)) { skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, @@ -7864,8 +7807,7 @@ VKAPI_ATTR void VKAPI_CALL CmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkB assert(0); } lock.unlock(); - if (!skip_call) - dev_data->dispatch_table.CmdBindIndexBuffer(commandBuffer, buffer, offset, indexType); + if (!skip_call) dev_data->dispatch_table.CmdBindIndexBuffer(commandBuffer, buffer, offset, indexType); } void updateResourceTracking(GLOBAL_CB_NODE *pCB, uint32_t firstBinding, uint32_t bindingCount, const VkBuffer *pBuffers) { @@ -7905,16 +7847,14 @@ VKAPI_ATTR void VKAPI_CALL CmdBindVertexBuffers(VkCommandBuffer commandBuffer, u skip_call |= report_error_no_cb_begin(dev_data, commandBuffer, "vkCmdBindVertexBuffer()"); } lock.unlock(); - if (!skip_call) - dev_data->dispatch_table.CmdBindVertexBuffers(commandBuffer, firstBinding, bindingCount, pBuffers, pOffsets); + if (!skip_call) dev_data->dispatch_table.CmdBindVertexBuffers(commandBuffer, firstBinding, bindingCount, pBuffers, pOffsets); } // Expects global_lock to be held by caller static void MarkStoreImagesAndBuffersAsWritten(layer_data *dev_data, GLOBAL_CB_NODE *pCB) { for (auto imageView : pCB->updateImages) { auto view_state = getImageViewState(dev_data, imageView); - if (!view_state) - continue; + if (!view_state) continue; auto image_state = getImageState(dev_data, view_state->create_info.image); assert(image_state); @@ -8179,8 +8119,7 @@ VKAPI_ATTR void VKAPI_CALL CmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer assert(0); } lock.unlock(); - if (!skip_call) - dev_data->dispatch_table.CmdCopyBuffer(commandBuffer, srcBuffer, dstBuffer, regionCount, pRegions); + if (!skip_call) dev_data->dispatch_table.CmdCopyBuffer(commandBuffer, srcBuffer, dstBuffer, regionCount, pRegions); } static bool VerifySourceImageLayout(layer_data *dev_data, GLOBAL_CB_NODE *cb_node, VkImage srcImage, @@ -8198,11 +8137,11 @@ static bool VerifySourceImageLayout(layer_data *dev_data, GLOBAL_CB_NODE *cb_nod } if (node.layout != srcImageLayout) { // TODO: Improve log message in the next pass - skip_call |= - log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, 0, - __LINE__, DRAWSTATE_INVALID_IMAGE_LAYOUT, "DS", "Cannot copy from an image whose source layout is %s " - "and doesn't match the current layout %s.", - string_VkImageLayout(srcImageLayout), string_VkImageLayout(node.layout)); + skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, + VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, 0, __LINE__, DRAWSTATE_INVALID_IMAGE_LAYOUT, "DS", + "Cannot copy from an image whose source layout is %s " + "and doesn't match the current layout %s.", + string_VkImageLayout(srcImageLayout), string_VkImageLayout(node.layout)); } } if (srcImageLayout != VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL) { @@ -8238,11 +8177,11 @@ static bool VerifyDestImageLayout(layer_data *dev_data, GLOBAL_CB_NODE *cb_node, continue; } if (node.layout != destImageLayout) { - skip_call |= - log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, 0, - __LINE__, DRAWSTATE_INVALID_IMAGE_LAYOUT, "DS", "Cannot copy from an image whose dest layout is %s and " - "doesn't match the current layout %s.", - string_VkImageLayout(destImageLayout), string_VkImageLayout(node.layout)); + skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, + VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, 0, __LINE__, DRAWSTATE_INVALID_IMAGE_LAYOUT, "DS", + "Cannot copy from an image whose dest layout is %s and " + "doesn't match the current layout %s.", + string_VkImageLayout(destImageLayout), string_VkImageLayout(node.layout)); } } if (destImageLayout != VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL) { @@ -8287,8 +8226,9 @@ static bool VerifyClearImageLayout(layer_data *dev_data, GLOBAL_CB_NODE *cb_node assert(strcmp(func_name, "vkCmdClearColorImage()") == 0); } skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, - error_code, "DS", "%s: Layout for cleared image is %s but can only be " - "TRANSFER_DST_OPTIMAL or GENERAL. %s", + error_code, "DS", + "%s: Layout for cleared image is %s but can only be " + "TRANSFER_DST_OPTIMAL or GENERAL. %s", func_name, string_VkImageLayout(dest_image_layout), validation_error_map[error_code]); } } @@ -8310,12 +8250,12 @@ static bool VerifyClearImageLayout(layer_data *dev_data, GLOBAL_CB_NODE *cb_node } else { assert(strcmp(func_name, "vkCmdClearColorImage()") == 0); } - skip |= - log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, 0, - __LINE__, error_code, "DS", "%s: Cannot clear an image whose layout is %s and " - "doesn't match the current layout %s. %s", - func_name, string_VkImageLayout(dest_image_layout), string_VkImageLayout(node.layout), - validation_error_map[error_code]); + skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, + VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, 0, __LINE__, error_code, "DS", + "%s: Cannot clear an image whose layout is %s and " + "doesn't match the current layout %s. %s", + func_name, string_VkImageLayout(dest_image_layout), string_VkImageLayout(node.layout), + validation_error_map[error_code]); } } } @@ -8757,8 +8697,7 @@ VKAPI_ATTR void VKAPI_CALL CmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuff assert(0); } lock.unlock(); - if (!skip_call) - dev_data->dispatch_table.CmdUpdateBuffer(commandBuffer, dstBuffer, dstOffset, dataSize, pData); + if (!skip_call) dev_data->dispatch_table.CmdUpdateBuffer(commandBuffer, dstBuffer, dstOffset, dataSize, pData); } VKAPI_ATTR void VKAPI_CALL CmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, @@ -8789,8 +8728,7 @@ VKAPI_ATTR void VKAPI_CALL CmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer assert(0); } lock.unlock(); - if (!skip_call) - dev_data->dispatch_table.CmdFillBuffer(commandBuffer, dstBuffer, dstOffset, size, data); + if (!skip_call) dev_data->dispatch_table.CmdFillBuffer(commandBuffer, dstBuffer, dstOffset, size, data); } // Returns true if sub_rect is entirely contained within rect @@ -8852,9 +8790,9 @@ bool PreCallValidateCmdClearAttachments(layer_data *dev_data, VkCommandBuffer co .pAttachments[subpass_desc->pColorAttachments[clear_desc->colorAttachment].attachment]; } } else if (clear_desc->aspectMask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) { - if (!subpass_desc->pDepthStencilAttachment || // Says no DS will be used in active subpass + if (!subpass_desc->pDepthStencilAttachment || // Says no DS will be used in active subpass (subpass_desc->pDepthStencilAttachment->attachment == - VK_ATTACHMENT_UNUSED)) { // Says no DS will be used in active subpass + VK_ATTACHMENT_UNUSED)) { // Says no DS will be used in active subpass skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, @@ -8906,8 +8844,7 @@ VKAPI_ATTR void VKAPI_CALL CmdClearAttachments(VkCommandBuffer commandBuffer, ui std::lock_guard lock(global_lock); skip = PreCallValidateCmdClearAttachments(dev_data, commandBuffer, attachmentCount, pAttachments, rectCount, pRects); } - if (!skip) - dev_data->dispatch_table.CmdClearAttachments(commandBuffer, attachmentCount, pAttachments, rectCount, pRects); + if (!skip) dev_data->dispatch_table.CmdClearAttachments(commandBuffer, attachmentCount, pAttachments, rectCount, pRects); } VKAPI_ATTR void VKAPI_CALL CmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, @@ -8939,8 +8876,7 @@ VKAPI_ATTR void VKAPI_CALL CmdClearColorImage(VkCommandBuffer commandBuffer, VkI skip_call |= VerifyClearImageLayout(dev_data, cb_node, image, pRanges[i], imageLayout, "vkCmdClearColorImage()"); } lock.unlock(); - if (!skip_call) - dev_data->dispatch_table.CmdClearColorImage(commandBuffer, image, imageLayout, pColor, rangeCount, pRanges); + if (!skip_call) dev_data->dispatch_table.CmdClearColorImage(commandBuffer, image, imageLayout, pColor, rangeCount, pRanges); } VKAPI_ATTR void VKAPI_CALL CmdClearDepthStencilImage(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, @@ -9053,8 +8989,7 @@ VKAPI_ATTR void VKAPI_CALL CmdSetEvent(VkCommandBuffer commandBuffer, VkEvent ev pCB->eventUpdates.push_back(eventUpdate); } lock.unlock(); - if (!skip_call) - dev_data->dispatch_table.CmdSetEvent(commandBuffer, event, stageMask); + if (!skip_call) dev_data->dispatch_table.CmdSetEvent(commandBuffer, event, stageMask); } VKAPI_ATTR void VKAPI_CALL CmdResetEvent(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags stageMask) { @@ -9084,8 +9019,7 @@ VKAPI_ATTR void VKAPI_CALL CmdResetEvent(VkCommandBuffer commandBuffer, VkEvent pCB->eventUpdates.push_back(eventUpdate); } lock.unlock(); - if (!skip_call) - dev_data->dispatch_table.CmdResetEvent(commandBuffer, event, stageMask); + if (!skip_call) dev_data->dispatch_table.CmdResetEvent(commandBuffer, event, stageMask); } static bool TransitionImageAspectLayout(layer_data *dev_data, GLOBAL_CB_NODE *pCB, const VkImageMemoryBarrier *mem_barrier, @@ -9123,8 +9057,7 @@ static bool TransitionImageLayouts(VkCommandBuffer cmdBuffer, uint32_t memBarrie for (uint32_t i = 0; i < memBarrierCount; ++i) { auto mem_barrier = &pImgMemBarriers[i]; - if (!mem_barrier) - continue; + if (!mem_barrier) continue; // TODO: Do not iterate over every possibility - consolidate where // possible ResolveRemainingLevelsLayers(dev_data, &levelCount, &layerCount, mem_barrier->subresourceRange, mem_barrier->image); @@ -9182,9 +9115,10 @@ static bool ValidateMaskBits(const layer_data *my_data, VkCommandBuffer cmdBuffe } else { if (!required_bit) { skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, - DRAWSTATE_INVALID_BARRIER, "DS", "%s AccessMask %d %s must contain at least one of access bits %d " - "%s when layout is %s, unless the app has previously added a " - "barrier for this transition.", + DRAWSTATE_INVALID_BARRIER, "DS", + "%s AccessMask %d %s must contain at least one of access bits %d " + "%s when layout is %s, unless the app has previously added a " + "barrier for this transition.", type, accessMask, string_VkAccessFlags(accessMask).c_str(), optional_bits, string_VkAccessFlags(optional_bits).c_str(), string_VkImageLayout(layout)); } else { @@ -9195,9 +9129,10 @@ static bool ValidateMaskBits(const layer_data *my_data, VkCommandBuffer cmdBuffe opt_bits = "and may have optional bits " + ss.str() + ' ' + string_VkAccessFlags(optional_bits); } skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, - DRAWSTATE_INVALID_BARRIER, "DS", "%s AccessMask %d %s must have required access bit %d %s %s when " - "layout is %s, unless the app has previously added a barrier for " - "this transition.", + DRAWSTATE_INVALID_BARRIER, "DS", + "%s AccessMask %d %s must have required access bit %d %s %s when " + "layout is %s, unless the app has previously added a barrier for " + "this transition.", type, accessMask, string_VkAccessFlags(accessMask).c_str(), required_bit, string_VkAccessFlags(required_bit).c_str(), opt_bits.c_str(), string_VkImageLayout(layout)); } @@ -9209,51 +9144,52 @@ static bool ValidateMaskBitsFromLayouts(const layer_data *my_data, VkCommandBuff const VkImageLayout &layout, const char *type) { bool skip_call = false; switch (layout) { - case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL: { - skip_call |= ValidateMaskBits(my_data, cmdBuffer, accessMask, layout, VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, - VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT, type); - break; - } - case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL: { - skip_call |= ValidateMaskBits(my_data, cmdBuffer, accessMask, layout, VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, - VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT, type); - break; - } - case VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL: { - skip_call |= ValidateMaskBits(my_data, cmdBuffer, accessMask, layout, VK_ACCESS_TRANSFER_WRITE_BIT, 0, type); - break; - } - case VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL: { - skip_call |= ValidateMaskBits( - my_data, cmdBuffer, accessMask, layout, 0, - VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT, type); - break; - } - case VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL: { - skip_call |= ValidateMaskBits(my_data, cmdBuffer, accessMask, layout, 0, - VK_ACCESS_INPUT_ATTACHMENT_READ_BIT | VK_ACCESS_SHADER_READ_BIT, type); - break; - } - case VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL: { - skip_call |= ValidateMaskBits(my_data, cmdBuffer, accessMask, layout, VK_ACCESS_TRANSFER_READ_BIT, 0, type); - break; - } - case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR: { - skip_call |= ValidateMaskBits(my_data, cmdBuffer, accessMask, layout, VK_ACCESS_MEMORY_READ_BIT, 0, type); - break; - } - case VK_IMAGE_LAYOUT_UNDEFINED: { - if (accessMask != 0) { - // TODO: Verify against Valid Use section spec - skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, - DRAWSTATE_INVALID_BARRIER, "DS", - "Additional bits in %s accessMask 0x%X %s are specified when layout is %s.", type, accessMask, - string_VkAccessFlags(accessMask).c_str(), string_VkImageLayout(layout)); + case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL: { + skip_call |= ValidateMaskBits(my_data, cmdBuffer, accessMask, layout, VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, + VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT, type); + break; } - break; - } - case VK_IMAGE_LAYOUT_GENERAL: - default: { break; } + case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL: { + skip_call |= ValidateMaskBits(my_data, cmdBuffer, accessMask, layout, VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, + VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT, type); + break; + } + case VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL: { + skip_call |= ValidateMaskBits(my_data, cmdBuffer, accessMask, layout, VK_ACCESS_TRANSFER_WRITE_BIT, 0, type); + break; + } + case VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL: { + skip_call |= ValidateMaskBits( + my_data, cmdBuffer, accessMask, layout, 0, + VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT, + type); + break; + } + case VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL: { + skip_call |= ValidateMaskBits(my_data, cmdBuffer, accessMask, layout, 0, + VK_ACCESS_INPUT_ATTACHMENT_READ_BIT | VK_ACCESS_SHADER_READ_BIT, type); + break; + } + case VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL: { + skip_call |= ValidateMaskBits(my_data, cmdBuffer, accessMask, layout, VK_ACCESS_TRANSFER_READ_BIT, 0, type); + break; + } + case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR: { + skip_call |= ValidateMaskBits(my_data, cmdBuffer, accessMask, layout, VK_ACCESS_MEMORY_READ_BIT, 0, type); + break; + } + case VK_IMAGE_LAYOUT_UNDEFINED: { + if (accessMask != 0) { + // TODO: Verify against Valid Use section spec + skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, + __LINE__, DRAWSTATE_INVALID_BARRIER, "DS", + "Additional bits in %s accessMask 0x%X %s are specified when layout is %s.", type, accessMask, + string_VkAccessFlags(accessMask).c_str(), string_VkImageLayout(layout)); + } + break; + } + case VK_IMAGE_LAYOUT_GENERAL: + default: { break; } } return skip_call; } @@ -9268,8 +9204,9 @@ static bool ValidateBarriers(const char *funcName, VkCommandBuffer cmdBuffer, ui if (pCB->activeRenderPass && memBarrierCount) { if (!pCB->activeRenderPass->hasSelfDependency[pCB->activeSubpass]) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, - DRAWSTATE_INVALID_BARRIER, "DS", "%s: Barriers cannot be set during subpass %d " - "with no self dependency specified.", + DRAWSTATE_INVALID_BARRIER, "DS", + "%s: Barriers cannot be set during subpass %d " + "with no self dependency specified.", funcName, pCB->activeSubpass); } } @@ -9283,12 +9220,13 @@ static bool ValidateBarriers(const char *funcName, VkCommandBuffer cmdBuffer, ui // srcQueueFamilyIndex and dstQueueFamilyIndex must both // be VK_QUEUE_FAMILY_IGNORED if ((src_q_f_index != VK_QUEUE_FAMILY_IGNORED) || (dst_q_f_index != VK_QUEUE_FAMILY_IGNORED)) { - skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, - __LINE__, DRAWSTATE_INVALID_QUEUE_INDEX, "DS", - "%s: Image Barrier for image 0x%" PRIx64 " was created with sharingMode of " - "VK_SHARING_MODE_CONCURRENT. Src and dst " - "queueFamilyIndices must be VK_QUEUE_FAMILY_IGNORED.", - funcName, reinterpret_cast(mem_barrier->image)); + skip |= + log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, + DRAWSTATE_INVALID_QUEUE_INDEX, "DS", "%s: Image Barrier for image 0x%" PRIx64 + " was created with sharingMode of " + "VK_SHARING_MODE_CONCURRENT. Src and dst " + "queueFamilyIndices must be VK_QUEUE_FAMILY_IGNORED.", + funcName, reinterpret_cast(mem_barrier->image)); } } else { // Sharing mode is VK_SHARING_MODE_EXCLUSIVE. srcQueueFamilyIndex and @@ -9298,7 +9236,8 @@ static bool ValidateBarriers(const char *funcName, VkCommandBuffer cmdBuffer, ui (src_q_f_index != dst_q_f_index)) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, - DRAWSTATE_INVALID_QUEUE_INDEX, "DS", "%s: Image 0x%" PRIx64 " was created with sharingMode " + DRAWSTATE_INVALID_QUEUE_INDEX, "DS", "%s: Image 0x%" PRIx64 + " was created with sharingMode " "of VK_SHARING_MODE_EXCLUSIVE. If one of src- or " "dstQueueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, both " "must be.", @@ -9308,7 +9247,8 @@ static bool ValidateBarriers(const char *funcName, VkCommandBuffer cmdBuffer, ui (dst_q_f_index >= dev_data->phys_dev_properties.queue_family_properties.size()))) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, DRAWSTATE_INVALID_QUEUE_INDEX, "DS", - "%s: Image 0x%" PRIx64 " was created with sharingMode " + "%s: Image 0x%" PRIx64 + " was created with sharingMode " "of VK_SHARING_MODE_EXCLUSIVE, but srcQueueFamilyIndex %d" " or dstQueueFamilyIndex %d is greater than " PRINTF_SIZE_T_SPECIFIER "queueFamilies crated for this device.", @@ -9327,8 +9267,9 @@ static bool ValidateBarriers(const char *funcName, VkCommandBuffer cmdBuffer, ui } if (mem_barrier->newLayout == VK_IMAGE_LAYOUT_UNDEFINED || mem_barrier->newLayout == VK_IMAGE_LAYOUT_PREINITIALIZED) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, - DRAWSTATE_INVALID_BARRIER, "DS", "%s: Image Layout cannot be transitioned to UNDEFINED or " - "PREINITIALIZED.", + DRAWSTATE_INVALID_BARRIER, "DS", + "%s: Image Layout cannot be transitioned to UNDEFINED or " + "PREINITIALIZED.", funcName); } auto image_data = getImageState(dev_data, mem_barrier->image); @@ -9360,9 +9301,10 @@ static bool ValidateBarriers(const char *funcName, VkCommandBuffer cmdBuffer, ui : mem_barrier->subresourceRange.layerCount; if ((mem_barrier->subresourceRange.baseArrayLayer + layerCount) > arrayLayers) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, - __LINE__, DRAWSTATE_INVALID_BARRIER, "DS", "%s: Subresource must have the sum of the " - "baseArrayLayer (%d) and layerCount (%d) be less " - "than or equal to the total number of layers (%d).", + __LINE__, DRAWSTATE_INVALID_BARRIER, "DS", + "%s: Subresource must have the sum of the " + "baseArrayLayer (%d) and layerCount (%d) be less " + "than or equal to the total number of layers (%d).", funcName, mem_barrier->subresourceRange.baseArrayLayer, mem_barrier->subresourceRange.layerCount, arrayLayers); } @@ -9370,12 +9312,13 @@ static bool ValidateBarriers(const char *funcName, VkCommandBuffer cmdBuffer, ui ? 1 : mem_barrier->subresourceRange.levelCount; if ((mem_barrier->subresourceRange.baseMipLevel + levelCount) > mipLevels) { - skip |= log_msg( - dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, - DRAWSTATE_INVALID_BARRIER, "DS", "%s: Subresource must have the sum of the baseMipLevel " - "(%d) and levelCount (%d) be less than or equal to " - "the total number of levels (%d).", - funcName, mem_barrier->subresourceRange.baseMipLevel, mem_barrier->subresourceRange.levelCount, mipLevels); + skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, + __LINE__, DRAWSTATE_INVALID_BARRIER, "DS", + "%s: Subresource must have the sum of the baseMipLevel " + "(%d) and levelCount (%d) be less than or equal to " + "the total number of levels (%d).", + funcName, mem_barrier->subresourceRange.baseMipLevel, mem_barrier->subresourceRange.levelCount, + mipLevels); } } } @@ -9386,8 +9329,7 @@ static bool ValidateBarriers(const char *funcName, VkCommandBuffer cmdBuffer, ui skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, DRAWSTATE_INVALID_BARRIER, "DS", "%s: Buffer Barriers cannot be used during a render pass.", funcName); } - if (!mem_barrier) - continue; + if (!mem_barrier) continue; // Validate buffer barrier queue family indices if ((mem_barrier->srcQueueFamilyIndex != VK_QUEUE_FAMILY_IGNORED && @@ -9396,7 +9338,8 @@ static bool ValidateBarriers(const char *funcName, VkCommandBuffer cmdBuffer, ui mem_barrier->dstQueueFamilyIndex >= dev_data->phys_dev_properties.queue_family_properties.size())) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, DRAWSTATE_INVALID_QUEUE_INDEX, "DS", - "%s: Buffer Barrier 0x%" PRIx64 " has QueueFamilyIndex greater " + "%s: Buffer Barrier 0x%" PRIx64 + " has QueueFamilyIndex greater " "than the number of QueueFamilies (" PRINTF_SIZE_T_SPECIFIER ") for this device.", funcName, reinterpret_cast(mem_barrier->buffer), dev_data->phys_dev_properties.queue_family_properties.size()); @@ -9434,8 +9377,7 @@ bool validateEventStageMask(VkQueue queue, GLOBAL_CB_NODE *pCB, uint32_t eventCo for (uint32_t i = 0; i < eventCount; ++i) { auto event = pCB->events[firstEventIndex + i]; auto queue_data = dev_data->queueMap.find(queue); - if (queue_data == dev_data->queueMap.end()) - return false; + if (queue_data == dev_data->queueMap.end()) return false; auto event_data = queue_data->second.eventToStageMap.find(event); if (event_data != queue_data->second.eventToStageMap.end()) { stageMask |= event_data->second; @@ -9455,11 +9397,12 @@ bool validateEventStageMask(VkQueue queue, GLOBAL_CB_NODE *pCB, uint32_t eventCo // but set event can be called at any time. if (sourceStageMask != stageMask && sourceStageMask != (stageMask | VK_PIPELINE_STAGE_HOST_BIT)) { skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, - VALIDATION_ERROR_00254, "DS", "Submitting cmdbuffer with call to VkCmdWaitEvents " - "using srcStageMask 0x%X which must be the bitwise " - "OR of the stageMask parameters used in calls to " - "vkCmdSetEvent and VK_PIPELINE_STAGE_HOST_BIT if " - "used with vkSetEvent but instead is 0x%X. %s", + VALIDATION_ERROR_00254, "DS", + "Submitting cmdbuffer with call to VkCmdWaitEvents " + "using srcStageMask 0x%X which must be the bitwise " + "OR of the stageMask parameters used in calls to " + "vkCmdSetEvent and VK_PIPELINE_STAGE_HOST_BIT if " + "used with vkSetEvent but instead is 0x%X. %s", sourceStageMask, stageMask, validation_error_map[VALIDATION_ERROR_00254]); } return skip_call; @@ -9652,8 +9595,7 @@ VKAPI_ATTR void VKAPI_CALL CmdBeginQuery(VkCommandBuffer commandBuffer, VkQueryP {reinterpret_cast(queryPool), VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT}, pCB); } lock.unlock(); - if (!skip_call) - dev_data->dispatch_table.CmdBeginQuery(commandBuffer, queryPool, slot, flags); + if (!skip_call) dev_data->dispatch_table.CmdBeginQuery(commandBuffer, queryPool, slot, flags); } VKAPI_ATTR void VKAPI_CALL CmdEndQuery(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t slot) { @@ -9683,8 +9625,7 @@ VKAPI_ATTR void VKAPI_CALL CmdEndQuery(VkCommandBuffer commandBuffer, VkQueryPoo {reinterpret_cast(queryPool), VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT}, pCB); } lock.unlock(); - if (!skip_call) - dev_data->dispatch_table.CmdEndQuery(commandBuffer, queryPool, slot); + if (!skip_call) dev_data->dispatch_table.CmdEndQuery(commandBuffer, queryPool, slot); } VKAPI_ATTR void VKAPI_CALL CmdResetQueryPool(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t firstQuery, @@ -9711,16 +9652,14 @@ VKAPI_ATTR void VKAPI_CALL CmdResetQueryPool(VkCommandBuffer commandBuffer, VkQu {reinterpret_cast(queryPool), VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT}, pCB); } lock.unlock(); - if (!skip_call) - dev_data->dispatch_table.CmdResetQueryPool(commandBuffer, queryPool, firstQuery, queryCount); + if (!skip_call) dev_data->dispatch_table.CmdResetQueryPool(commandBuffer, queryPool, firstQuery, queryCount); } bool validateQuery(VkQueue queue, GLOBAL_CB_NODE *pCB, VkQueryPool queryPool, uint32_t queryCount, uint32_t firstQuery) { bool skip_call = false; layer_data *dev_data = get_my_data_ptr(get_dispatch_key(pCB->commandBuffer), layer_data_map); auto queue_data = dev_data->queueMap.find(queue); - if (queue_data == dev_data->queueMap.end()) - return false; + if (queue_data == dev_data->queueMap.end()) return false; for (uint32_t i = 0; i < queryCount; i++) { QueryObject query = {queryPool, firstQuery + i}; auto query_data = queue_data->second.queryToStateMap.find(query); @@ -9834,7 +9773,8 @@ VKAPI_ATTR void VKAPI_CALL CmdPushConstants(VkCommandBuffer commandBuffer, VkPip // There were no ranges that matched the stageFlags. skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, - VALIDATION_ERROR_00988, "DS", "vkCmdPushConstants() stageFlags = 0x%" PRIx32 " do not match " + VALIDATION_ERROR_00988, "DS", "vkCmdPushConstants() stageFlags = 0x%" PRIx32 + " do not match " "the stageFlags in any of the ranges in pipeline layout 0x%" PRIx64 ". %s", (uint32_t)stageFlags, (uint64_t)layout, validation_error_map[VALIDATION_ERROR_00988]); } else { @@ -9871,17 +9811,18 @@ VKAPI_ATTR void VKAPI_CALL CmdPushConstants(VkCommandBuffer commandBuffer, VkPip } } if (!contained_in_a_range) { - skip_call |= log_msg( - dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, - VALIDATION_ERROR_00988, "DS", "vkCmdPushConstants() Push constant range [%d, %d) " - "with stageFlags = 0x%" PRIx32 " " - "not within flag-matching ranges in pipeline layout 0x%" PRIx64 ". %s", - offset, offset + size, (uint32_t)stageFlags, (uint64_t)layout, validation_error_map[VALIDATION_ERROR_00988]); + skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, + VALIDATION_ERROR_00988, "DS", + "vkCmdPushConstants() Push constant range [%d, %d) " + "with stageFlags = 0x%" PRIx32 + " " + "not within flag-matching ranges in pipeline layout 0x%" PRIx64 ". %s", + offset, offset + size, (uint32_t)stageFlags, (uint64_t)layout, + validation_error_map[VALIDATION_ERROR_00988]); } } lock.unlock(); - if (!skip_call) - dev_data->dispatch_table.CmdPushConstants(commandBuffer, layout, stageFlags, offset, size, pValues); + if (!skip_call) dev_data->dispatch_table.CmdPushConstants(commandBuffer, layout, stageFlags, offset, size, pValues); } VKAPI_ATTR void VKAPI_CALL CmdWriteTimestamp(VkCommandBuffer commandBuffer, VkPipelineStageFlagBits pipelineStage, @@ -9902,8 +9843,7 @@ VKAPI_ATTR void VKAPI_CALL CmdWriteTimestamp(VkCommandBuffer commandBuffer, VkPi } } lock.unlock(); - if (!skip_call) - dev_data->dispatch_table.CmdWriteTimestamp(commandBuffer, pipelineStage, queryPool, slot); + if (!skip_call) dev_data->dispatch_table.CmdWriteTimestamp(commandBuffer, pipelineStage, queryPool, slot); } static bool MatchUsage(layer_data *dev_data, uint32_t count, const VkAttachmentReference *attachments, @@ -10119,8 +10059,7 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateFramebuffer(VkDevice device, const VkFrameb bool skip_call = PreCallValidateCreateFramebuffer(dev_data, pCreateInfo); lock.unlock(); - if (skip_call) - return VK_ERROR_VALIDATION_FAILED_EXT; + if (skip_call) return VK_ERROR_VALIDATION_FAILED_EXT; VkResult result = dev_data->dispatch_table.CreateFramebuffer(device, pCreateInfo, pAllocator, pFramebuffer); @@ -10135,15 +10074,13 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateFramebuffer(VkDevice device, const VkFrameb static bool FindDependency(const int index, const int dependent, const std::vector &subpass_to_node, std::unordered_set &processed_nodes) { // If we have already checked this node we have not found a dependency path so return false. - if (processed_nodes.count(index)) - return false; + if (processed_nodes.count(index)) return false; processed_nodes.insert(index); const DAGNode &node = subpass_to_node[index]; // Look for a dependency path. If one exists return true else recurse on the previous nodes. if (std::find(node.prev.begin(), node.prev.end(), static_cast(dependent)) == node.prev.end()) { for (auto elem : node.prev) { - if (FindDependency(elem, dependent, subpass_to_node, processed_nodes)) - return true; + if (FindDependency(elem, dependent, subpass_to_node, processed_nodes)) return true; } } else { return true; @@ -10156,8 +10093,7 @@ static bool CheckDependencyExists(const layer_data *dev_data, const int subpass, bool result = true; // Loop through all subpasses that share the same attachment and make sure a dependency exists for (uint32_t k = 0; k < dependent_subpasses.size(); ++k) { - if (static_cast(subpass) == dependent_subpasses[k]) - continue; + if (static_cast(subpass) == dependent_subpasses[k]) continue; const DAGNode &node = subpass_to_node[subpass]; // Check for a specified dependency between the two nodes. If one exists we are done. auto prev_elem = std::find(node.prev.begin(), node.prev.end(), dependent_subpasses[k]); @@ -10184,12 +10120,10 @@ static bool CheckPreserved(const layer_data *dev_data, const VkRenderPassCreateI // If this node writes to the attachment return true as next nodes need to preserve the attachment. const VkSubpassDescription &subpass = pCreateInfo->pSubpasses[index]; for (uint32_t j = 0; j < subpass.colorAttachmentCount; ++j) { - if (attachment == subpass.pColorAttachments[j].attachment) - return true; + if (attachment == subpass.pColorAttachments[j].attachment) return true; } if (subpass.pDepthStencilAttachment && subpass.pDepthStencilAttachment->attachment != VK_ATTACHMENT_UNUSED) { - if (attachment == subpass.pDepthStencilAttachment->attachment) - return true; + if (attachment == subpass.pDepthStencilAttachment->attachment) return true; } bool result = false; // Loop through previous nodes and see if any of them write to the attachment. @@ -10216,7 +10150,8 @@ static bool CheckPreserved(const layer_data *dev_data, const VkRenderPassCreateI return result; } -template bool isRangeOverlapping(T offset1, T size1, T offset2, T size2) { +template +bool isRangeOverlapping(T offset1, T size1, T offset2, T size2) { return (((offset1 + size1) > offset2) && ((offset1 + size1) < (offset2 + size2))) || ((offset1 > offset2) && (offset1 < (offset2 + size2))); } @@ -10275,14 +10210,16 @@ static bool ValidateDependencies(const layer_data *dev_data, FRAMEBUFFER_STATE c for (auto other_attachment : overlapping_attachments[i]) { if (!(pCreateInfo->pAttachments[attachment].flags & VK_ATTACHMENT_DESCRIPTION_MAY_ALIAS_BIT)) { skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, - __LINE__, VALIDATION_ERROR_00324, "DS", "Attachment %d aliases attachment %d but doesn't " - "set VK_ATTACHMENT_DESCRIPTION_MAY_ALIAS_BIT. %s", + __LINE__, VALIDATION_ERROR_00324, "DS", + "Attachment %d aliases attachment %d but doesn't " + "set VK_ATTACHMENT_DESCRIPTION_MAY_ALIAS_BIT. %s", attachment, other_attachment, validation_error_map[VALIDATION_ERROR_00324]); } if (!(pCreateInfo->pAttachments[other_attachment].flags & VK_ATTACHMENT_DESCRIPTION_MAY_ALIAS_BIT)) { skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, - __LINE__, VALIDATION_ERROR_00324, "DS", "Attachment %d aliases attachment %d but doesn't " - "set VK_ATTACHMENT_DESCRIPTION_MAY_ALIAS_BIT. %s", + __LINE__, VALIDATION_ERROR_00324, "DS", + "Attachment %d aliases attachment %d but doesn't " + "set VK_ATTACHMENT_DESCRIPTION_MAY_ALIAS_BIT. %s", other_attachment, attachment, validation_error_map[VALIDATION_ERROR_00324]); } } @@ -10294,8 +10231,7 @@ static bool ValidateDependencies(const layer_data *dev_data, FRAMEBUFFER_STATE c attachmentIndices.clear(); for (uint32_t j = 0; j < subpass.inputAttachmentCount; ++j) { uint32_t attachment = subpass.pInputAttachments[j].attachment; - if (attachment == VK_ATTACHMENT_UNUSED) - continue; + if (attachment == VK_ATTACHMENT_UNUSED) continue; input_attachment_to_subpass[attachment].push_back(i); for (auto overlapping_attachment : overlapping_attachments[attachment]) { input_attachment_to_subpass[overlapping_attachment].push_back(i); @@ -10303,8 +10239,7 @@ static bool ValidateDependencies(const layer_data *dev_data, FRAMEBUFFER_STATE c } for (uint32_t j = 0; j < subpass.colorAttachmentCount; ++j) { uint32_t attachment = subpass.pColorAttachments[j].attachment; - if (attachment == VK_ATTACHMENT_UNUSED) - continue; + if (attachment == VK_ATTACHMENT_UNUSED) continue; output_attachment_to_subpass[attachment].push_back(i); for (auto overlapping_attachment : overlapping_attachments[attachment]) { output_attachment_to_subpass[overlapping_attachment].push_back(i); @@ -10332,15 +10267,13 @@ static bool ValidateDependencies(const layer_data *dev_data, FRAMEBUFFER_STATE c // If the attachment is an input then all subpasses that output must have a dependency relationship for (uint32_t j = 0; j < subpass.inputAttachmentCount; ++j) { uint32_t attachment = subpass.pInputAttachments[j].attachment; - if (attachment == VK_ATTACHMENT_UNUSED) - continue; + if (attachment == VK_ATTACHMENT_UNUSED) continue; CheckDependencyExists(dev_data, i, output_attachment_to_subpass[attachment], subpass_to_node, skip_call); } // If the attachment is an output then all subpasses that use the attachment must have a dependency relationship for (uint32_t j = 0; j < subpass.colorAttachmentCount; ++j) { uint32_t attachment = subpass.pColorAttachments[j].attachment; - if (attachment == VK_ATTACHMENT_UNUSED) - continue; + if (attachment == VK_ATTACHMENT_UNUSED) continue; CheckDependencyExists(dev_data, i, output_attachment_to_subpass[attachment], subpass_to_node, skip_call); CheckDependencyExists(dev_data, i, input_attachment_to_subpass[attachment], subpass_to_node, skip_call); } @@ -10389,26 +10322,25 @@ static bool ValidateLayouts(const layer_data *dev_data, VkDevice device, const V const VkSubpassDescription &subpass = pCreateInfo->pSubpasses[i]; for (uint32_t j = 0; j < subpass.colorAttachmentCount; ++j) { auto attach_index = subpass.pColorAttachments[j].attachment; - if (attach_index == VK_ATTACHMENT_UNUSED) - continue; + if (attach_index == VK_ATTACHMENT_UNUSED) continue; switch (subpass.pColorAttachments[j].layout) { - case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL: - // This is ideal. - break; + case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL: + // This is ideal. + break; - case VK_IMAGE_LAYOUT_GENERAL: - // May not be optimal; TODO: reconsider this warning based on other constraints? - skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, - VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, DRAWSTATE_INVALID_IMAGE_LAYOUT, "DS", - "Layout for color attachment is GENERAL but should be COLOR_ATTACHMENT_OPTIMAL."); - break; + case VK_IMAGE_LAYOUT_GENERAL: + // May not be optimal; TODO: reconsider this warning based on other constraints? + skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, + VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, DRAWSTATE_INVALID_IMAGE_LAYOUT, "DS", + "Layout for color attachment is GENERAL but should be COLOR_ATTACHMENT_OPTIMAL."); + break; - default: - skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, - __LINE__, DRAWSTATE_INVALID_IMAGE_LAYOUT, "DS", - "Layout for color attachment is %s but can only be COLOR_ATTACHMENT_OPTIMAL or GENERAL.", - string_VkImageLayout(subpass.pColorAttachments[j].layout)); + default: + skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, + 0, __LINE__, DRAWSTATE_INVALID_IMAGE_LAYOUT, "DS", + "Layout for color attachment is %s but can only be COLOR_ATTACHMENT_OPTIMAL or GENERAL.", + string_VkImageLayout(subpass.pColorAttachments[j].layout)); } if (attach_first_use[attach_index]) { @@ -10419,26 +10351,27 @@ static bool ValidateLayouts(const layer_data *dev_data, VkDevice device, const V } if (subpass.pDepthStencilAttachment && subpass.pDepthStencilAttachment->attachment != VK_ATTACHMENT_UNUSED) { switch (subpass.pDepthStencilAttachment->layout) { - case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL: - case VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL: - // These are ideal. - break; + case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL: + case VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL: + // These are ideal. + break; - case VK_IMAGE_LAYOUT_GENERAL: - // May not be optimal; TODO: reconsider this warning based on other constraints? GENERAL can be better than doing - // a bunch of transitions. - skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, - VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, DRAWSTATE_INVALID_IMAGE_LAYOUT, "DS", - "GENERAL layout for depth attachment may not give optimal performance."); - break; + case VK_IMAGE_LAYOUT_GENERAL: + // May not be optimal; TODO: reconsider this warning based on other constraints? GENERAL can be better than + // doing + // a bunch of transitions. + skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, + VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, DRAWSTATE_INVALID_IMAGE_LAYOUT, "DS", + "GENERAL layout for depth attachment may not give optimal performance."); + break; - default: - // No other layouts are acceptable - skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, - __LINE__, DRAWSTATE_INVALID_IMAGE_LAYOUT, "DS", - "Layout for depth attachment is %s but can only be DEPTH_STENCIL_ATTACHMENT_OPTIMAL, " - "DEPTH_STENCIL_READ_ONLY_OPTIMAL or GENERAL.", - string_VkImageLayout(subpass.pDepthStencilAttachment->layout)); + default: + // No other layouts are acceptable + skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, + 0, __LINE__, DRAWSTATE_INVALID_IMAGE_LAYOUT, "DS", + "Layout for depth attachment is %s but can only be DEPTH_STENCIL_ATTACHMENT_OPTIMAL, " + "DEPTH_STENCIL_READ_ONLY_OPTIMAL or GENERAL.", + string_VkImageLayout(subpass.pDepthStencilAttachment->layout)); } auto attach_index = subpass.pDepthStencilAttachment->attachment; @@ -10450,28 +10383,27 @@ static bool ValidateLayouts(const layer_data *dev_data, VkDevice device, const V } for (uint32_t j = 0; j < subpass.inputAttachmentCount; ++j) { auto attach_index = subpass.pInputAttachments[j].attachment; - if (attach_index == VK_ATTACHMENT_UNUSED) - continue; + if (attach_index == VK_ATTACHMENT_UNUSED) continue; switch (subpass.pInputAttachments[j].layout) { - case VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL: - case VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL: - // These are ideal. - break; + case VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL: + case VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL: + // These are ideal. + break; - case VK_IMAGE_LAYOUT_GENERAL: - // May not be optimal. TODO: reconsider this warning based on other constraints. - skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, - VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, DRAWSTATE_INVALID_IMAGE_LAYOUT, "DS", - "Layout for input attachment is GENERAL but should be READ_ONLY_OPTIMAL."); - break; + case VK_IMAGE_LAYOUT_GENERAL: + // May not be optimal. TODO: reconsider this warning based on other constraints. + skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, + VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, DRAWSTATE_INVALID_IMAGE_LAYOUT, "DS", + "Layout for input attachment is GENERAL but should be READ_ONLY_OPTIMAL."); + break; - default: - // No other layouts are acceptable - skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, - DRAWSTATE_INVALID_IMAGE_LAYOUT, "DS", - "Layout for input attachment is %s but can only be READ_ONLY_OPTIMAL or GENERAL.", - string_VkImageLayout(subpass.pInputAttachments[j].layout)); + default: + // No other layouts are acceptable + skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, + __LINE__, DRAWSTATE_INVALID_IMAGE_LAYOUT, "DS", + "Layout for input attachment is %s but can only be READ_ONLY_OPTIMAL or GENERAL.", + string_VkImageLayout(subpass.pInputAttachments[j].layout)); } if (attach_first_use[attach_index]) { @@ -10534,8 +10466,7 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateShaderModule(VkDevice device, const VkShade spvDiagnosticDestroy(diag); spvContextDestroy(ctx); - if (skip_call) - return VK_ERROR_VALIDATION_FAILED_EXT; + if (skip_call) return VK_ERROR_VALIDATION_FAILED_EXT; VkResult res = dev_data->dispatch_table.CreateShaderModule(device, pCreateInfo, pAllocator, pShaderModule); @@ -10636,8 +10567,9 @@ static bool ValidateRenderpassAttachmentUsage(layer_data *dev_data, const VkRend if (sample_count && !IsPowerOfTwo(sample_count)) { skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VkDebugReportObjectTypeEXT(0), 0, __LINE__, - VALIDATION_ERROR_00337, "DS", "CreateRenderPass: Subpass %u attempts to render to " - "attachments with inconsistent sample counts. %s", + VALIDATION_ERROR_00337, "DS", + "CreateRenderPass: Subpass %u attempts to render to " + "attachments with inconsistent sample counts. %s", i, validation_error_map[VALIDATION_ERROR_00337]); } } @@ -10723,8 +10655,9 @@ static bool VerifyFramebufferAndRenderPassLayouts(layer_data *dev_data, GLOBAL_C auto const &framebufferInfo = dev_data->frameBufferMap[pRenderPassBegin->framebuffer]->createInfo; if (pRenderPassInfo->attachmentCount != framebufferInfo.attachmentCount) { skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, - DRAWSTATE_INVALID_RENDERPASS, "DS", "You cannot start a render pass using a framebuffer " - "with a different number of attachments."); + DRAWSTATE_INVALID_RENDERPASS, "DS", + "You cannot start a render pass using a framebuffer " + "with a different number of attachments."); } for (uint32_t i = 0; i < pRenderPassInfo->attachmentCount; ++i) { const VkImageView &image_view = framebufferInfo.pAttachments[i]; @@ -10772,12 +10705,10 @@ static void TransitionAttachmentRefLayout(layer_data *dev_data, GLOBAL_CB_NODE * static void TransitionSubpassLayouts(layer_data *dev_data, GLOBAL_CB_NODE *pCB, const VkRenderPassBeginInfo *pRenderPassBegin, const int subpass_index) { auto renderPass = getRenderPassState(dev_data, pRenderPassBegin->renderPass); - if (!renderPass) - return; + if (!renderPass) return; auto framebuffer = getFramebufferState(dev_data, pRenderPassBegin->framebuffer); - if (!framebuffer) - return; + if (!framebuffer) return; auto const &subpass = renderPass->createInfo.pSubpasses[subpass_index]; for (uint32_t j = 0; j < subpass.inputAttachmentCount; ++j) { @@ -10805,13 +10736,11 @@ static bool validatePrimaryCommandBuffer(const layer_data *dev_data, const GLOBA static void TransitionFinalSubpassLayouts(layer_data *dev_data, GLOBAL_CB_NODE *pCB, const VkRenderPassBeginInfo *pRenderPassBegin) { auto renderPass = getRenderPassState(dev_data, pRenderPassBegin->renderPass); - if (!renderPass) - return; + if (!renderPass) return; const VkRenderPassCreateInfo *pRenderPassInfo = renderPass->createInfo.ptr(); auto framebuffer = getFramebufferState(dev_data, pRenderPassBegin->framebuffer); - if (!framebuffer) - return; + if (!framebuffer) return; for (uint32_t i = 0; i < pRenderPassInfo->attachmentCount; ++i) { auto image_view = framebuffer->createInfo.pAttachments[i]; @@ -10842,7 +10771,8 @@ static bool VerifyRenderAreaBounds(const layer_data *dev_data, const VkRenderPas // If this is a stencil format, make sure the stencil[Load|Store]Op flag is checked, while if it is a depth/color attachment the // [load|store]Op flag must be checked // TODO: The memory valid flag in DEVICE_MEM_INFO should probably be split to track the validity of stencil memory separately. -template static bool FormatSpecificLoadAndStoreOpSettings(VkFormat format, T color_depth_op, T stencil_op, T op) { +template +static bool FormatSpecificLoadAndStoreOpSettings(VkFormat format, T color_depth_op, T stencil_op, T op) { if (color_depth_op != op && stencil_op != op) { return false; } @@ -10863,7 +10793,7 @@ VKAPI_ATTR void VKAPI_CALL CmdBeginRenderPass(VkCommandBuffer commandBuffer, con auto framebuffer = pRenderPassBegin ? getFramebufferState(dev_data, pRenderPassBegin->framebuffer) : nullptr; if (cb_node) { if (renderPass) { - uint32_t clear_op_size = 0; // Make sure pClearValues is at least as large as last LOAD_OP_CLEAR + uint32_t clear_op_size = 0; // Make sure pClearValues is at least as large as last LOAD_OP_CLEAR cb_node->activeFramebuffer = pRenderPassBegin->framebuffer; for (uint32_t i = 0; i < renderPass->createInfo.attachmentCount; ++i) { MT_FB_ATTACHMENT_INFO &fb_info = framebuffer->attachments[i]; @@ -10905,7 +10835,8 @@ VKAPI_ATTR void VKAPI_CALL CmdBeginRenderPass(VkCommandBuffer commandBuffer, con reinterpret_cast(renderPass), __LINE__, VALIDATION_ERROR_00442, "DS", "In vkCmdBeginRenderPass() the VkRenderPassBeginInfo struct has a clearValueCount of %u but there must " "be at least %u entries in pClearValues array to account for the highest index attachment in renderPass " - "0x%" PRIx64 " that uses VK_ATTACHMENT_LOAD_OP_CLEAR is %u. Note that the pClearValues array " + "0x%" PRIx64 + " that uses VK_ATTACHMENT_LOAD_OP_CLEAR is %u. Note that the pClearValues array " "is indexed by attachment number so even if some pClearValues entries between 0 and %u correspond to " "attachments that aren't cleared they will be ignored. %s", pRenderPassBegin->clearValueCount, clear_op_size, reinterpret_cast(renderPass), clear_op_size, @@ -10966,8 +10897,7 @@ VKAPI_ATTR void VKAPI_CALL CmdNextSubpass(VkCommandBuffer commandBuffer, VkSubpa } lock.unlock(); - if (skip_call) - return; + if (skip_call) return; dev_data->dispatch_table.CmdNextSubpass(commandBuffer, contents); @@ -11022,8 +10952,7 @@ VKAPI_ATTR void VKAPI_CALL CmdEndRenderPass(VkCommandBuffer commandBuffer) { } lock.unlock(); - if (skip_call) - return; + if (skip_call) return; dev_data->dispatch_table.CmdEndRenderPass(commandBuffer); @@ -11039,10 +10968,10 @@ VKAPI_ATTR void VKAPI_CALL CmdEndRenderPass(VkCommandBuffer commandBuffer) { static bool logInvalidAttachmentMessage(layer_data *dev_data, VkCommandBuffer secondaryBuffer, uint32_t primaryAttach, uint32_t secondaryAttach, const char *msg) { return log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, - VALIDATION_ERROR_02059, "DS", - "vkCmdExecuteCommands() called w/ invalid Secondary Cmd Buffer 0x%" PRIx64 " which has a render pass " - "that is not compatible with the Primary Cmd Buffer current render pass. " - "Attachment %u is not compatible with %u: %s. %s", + VALIDATION_ERROR_02059, "DS", "vkCmdExecuteCommands() called w/ invalid Secondary Cmd Buffer 0x%" PRIx64 + " which has a render pass " + "that is not compatible with the Primary Cmd Buffer current render pass. " + "Attachment %u is not compatible with %u: %s. %s", reinterpret_cast(secondaryBuffer), primaryAttach, secondaryAttach, msg, validation_error_map[VALIDATION_ERROR_02059]); } @@ -11208,14 +11137,14 @@ static bool validateSecondaryCommandBufferState(layer_data *dev_data, GLOBAL_CB_ pSubCB->beginInfo.pInheritanceInfo) { VkQueryPipelineStatisticFlags cmdBufStatistics = pSubCB->beginInfo.pInheritanceInfo->pipelineStatistics; if ((cmdBufStatistics & queryPoolData->second.createInfo.pipelineStatistics) != cmdBufStatistics) { - skip_call |= - log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, - VALIDATION_ERROR_02065, "DS", "vkCmdExecuteCommands() called w/ invalid Cmd Buffer 0x%p " - "which has invalid active query pool 0x%" PRIx64 - ". Pipeline statistics is being queried so the command " - "buffer must have all bits set on the queryPool. %s", - pCB->commandBuffer, reinterpret_cast(queryPoolData->first), - validation_error_map[VALIDATION_ERROR_02065]); + skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, + __LINE__, VALIDATION_ERROR_02065, "DS", + "vkCmdExecuteCommands() called w/ invalid Cmd Buffer 0x%p " + "which has invalid active query pool 0x%" PRIx64 + ". Pipeline statistics is being queried so the command " + "buffer must have all bits set on the queryPool. %s", + pCB->commandBuffer, reinterpret_cast(queryPoolData->first), + validation_error_map[VALIDATION_ERROR_02065]); } } activeTypes.insert(queryPoolData->second.createInfo.queryType); @@ -11224,14 +11153,14 @@ static bool validateSecondaryCommandBufferState(layer_data *dev_data, GLOBAL_CB_ for (auto queryObject : pSubCB->startedQueries) { auto queryPoolData = dev_data->queryPoolMap.find(queryObject.pool); if (queryPoolData != dev_data->queryPoolMap.end() && activeTypes.count(queryPoolData->second.createInfo.queryType)) { - skip_call |= - log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, - DRAWSTATE_INVALID_SECONDARY_COMMAND_BUFFER, "DS", - "vkCmdExecuteCommands() called w/ invalid Cmd Buffer 0x%p " - "which has invalid active query pool 0x%" PRIx64 "of type %d but a query of that type has been started on " - "secondary Cmd Buffer 0x%p.", - pCB->commandBuffer, reinterpret_cast(queryPoolData->first), - queryPoolData->second.createInfo.queryType, pSubCB->commandBuffer); + skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, + DRAWSTATE_INVALID_SECONDARY_COMMAND_BUFFER, "DS", + "vkCmdExecuteCommands() called w/ invalid Cmd Buffer 0x%p " + "which has invalid active query pool 0x%" PRIx64 + "of type %d but a query of that type has been started on " + "secondary Cmd Buffer 0x%p.", + pCB->commandBuffer, reinterpret_cast(queryPoolData->first), + queryPoolData->second.createInfo.queryType, pSubCB->commandBuffer); } } @@ -11266,7 +11195,7 @@ VKAPI_ATTR void VKAPI_CALL CmdExecuteCommands(VkCommandBuffer commandBuffer, uin "vkCmdExecuteCommands() called w/ Primary Cmd Buffer 0x%p in element %u of pCommandBuffers " "array. All cmd buffers in pCommandBuffers array must be secondary. %s", pCommandBuffers[i], i, validation_error_map[VALIDATION_ERROR_00153]); - } else if (pCB->activeRenderPass) { // Secondary CB w/i RenderPass must have *CONTINUE_BIT set + } else if (pCB->activeRenderPass) { // Secondary CB w/i RenderPass must have *CONTINUE_BIT set auto secondary_rp_state = getRenderPassState(dev_data, pSubCB->beginInfo.pInheritanceInfo->renderPass); if (!(pSubCB->beginInfo.flags & VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT)) { skip_call |= log_msg( @@ -11307,12 +11236,12 @@ VKAPI_ATTR void VKAPI_CALL CmdExecuteCommands(VkCommandBuffer commandBuffer, uin // being recorded if (!(pSubCB->beginInfo.flags & VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT)) { if (dev_data->globalInFlightCmdBuffers.find(pSubCB->commandBuffer) != dev_data->globalInFlightCmdBuffers.end()) { - skip_call |= - log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, - VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, (uint64_t)(pCB->commandBuffer), __LINE__, - VALIDATION_ERROR_00154, "DS", "Attempt to simultaneously execute command buffer 0x%p" - " without VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT set! %s", - pCB->commandBuffer, validation_error_map[VALIDATION_ERROR_00154]); + skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, + VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, (uint64_t)(pCB->commandBuffer), __LINE__, + VALIDATION_ERROR_00154, "DS", + "Attempt to simultaneously execute command buffer 0x%p" + " without VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT set! %s", + pCB->commandBuffer, validation_error_map[VALIDATION_ERROR_00154]); } if (pCB->beginInfo.flags & VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT) { // Warn that non-simultaneous secondary cmd buffer renders primary non-simultaneous @@ -11328,13 +11257,14 @@ VKAPI_ATTR void VKAPI_CALL CmdExecuteCommands(VkCommandBuffer commandBuffer, uin } } if (!pCB->activeQueries.empty() && !dev_data->enabled_features.inheritedQueries) { - skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, - VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, reinterpret_cast(pCommandBuffers[i]), - __LINE__, VALIDATION_ERROR_02062, "DS", "vkCmdExecuteCommands(): Secondary Command Buffer " - "(0x%p) cannot be submitted with a query in " - "flight and inherited queries not " - "supported on this device. %s", - pCommandBuffers[i], validation_error_map[VALIDATION_ERROR_02062]); + skip_call |= + log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, + reinterpret_cast(pCommandBuffers[i]), __LINE__, VALIDATION_ERROR_02062, "DS", + "vkCmdExecuteCommands(): Secondary Command Buffer " + "(0x%p) cannot be submitted with a query in " + "flight and inherited queries not " + "supported on this device. %s", + pCommandBuffers[i], validation_error_map[VALIDATION_ERROR_02062]); } // Propagate layout transitions to the primary cmd buffer for (auto ilm_entry : pSubCB->imageLayoutMap) { @@ -11352,8 +11282,7 @@ VKAPI_ATTR void VKAPI_CALL CmdExecuteCommands(VkCommandBuffer commandBuffer, uin UpdateCmdBufferLastCmd(dev_data, pCB, CMD_EXECUTECOMMANDS); } lock.unlock(); - if (!skip_call) - dev_data->dispatch_table.CmdExecuteCommands(commandBuffer, commandBuffersCount, pCommandBuffers); + if (!skip_call) dev_data->dispatch_table.CmdExecuteCommands(commandBuffer, commandBuffersCount, pCommandBuffers); } // For any image objects that overlap mapped memory, verify that their layouts are PREINIT or GENERAL @@ -11372,11 +11301,11 @@ static bool ValidateMapImageLayouts(VkDevice device, DEVICE_MEM_INFO const *mem_ if (FindLayouts(dev_data, VkImage(image_handle), layouts)) { for (auto layout : layouts) { if (layout != VK_IMAGE_LAYOUT_PREINITIALIZED && layout != VK_IMAGE_LAYOUT_GENERAL) { - skip_call |= - log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, - __LINE__, DRAWSTATE_INVALID_IMAGE_LAYOUT, "DS", "Cannot map an image with layout %s. Only " - "GENERAL or PREINITIALIZED are supported.", - string_VkImageLayout(layout)); + skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, + (VkDebugReportObjectTypeEXT)0, 0, __LINE__, DRAWSTATE_INVALID_IMAGE_LAYOUT, "DS", + "Cannot map an image with layout %s. Only " + "GENERAL or PREINITIALIZED are supported.", + string_VkImageLayout(layout)); } } } @@ -11445,13 +11374,13 @@ static bool validateMemoryIsMapped(layer_data *dev_data, const char *funcName, u if (mem_info) { if (pMemRanges[i].size == VK_WHOLE_SIZE) { if (mem_info->mem_range.offset > pMemRanges[i].offset) { - skip |= - log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, - (uint64_t)pMemRanges[i].memory, __LINE__, VALIDATION_ERROR_00643, "MEM", - "%s: Flush/Invalidate offset (" PRINTF_SIZE_T_SPECIFIER ") is less than Memory Object's offset " - "(" PRINTF_SIZE_T_SPECIFIER "). %s", - funcName, static_cast(pMemRanges[i].offset), - static_cast(mem_info->mem_range.offset), validation_error_map[VALIDATION_ERROR_00643]); + skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, + VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, (uint64_t)pMemRanges[i].memory, __LINE__, + VALIDATION_ERROR_00643, "MEM", "%s: Flush/Invalidate offset (" PRINTF_SIZE_T_SPECIFIER + ") is less than Memory Object's offset " + "(" PRINTF_SIZE_T_SPECIFIER "). %s", + funcName, static_cast(pMemRanges[i].offset), + static_cast(mem_info->mem_range.offset), validation_error_map[VALIDATION_ERROR_00643]); } } else { const uint64_t data_end = (mem_info->mem_range.size == VK_WHOLE_SIZE) @@ -11672,8 +11601,7 @@ VKAPI_ATTR VkResult VKAPI_CALL SetEvent(VkDevice device, VkEvent event) { event_entry->second |= VK_PIPELINE_STAGE_HOST_BIT; } } - if (!skip_call) - result = dev_data->dispatch_table.SetEvent(device, event); + if (!skip_call) result = dev_data->dispatch_table.SetEvent(device, event); return result; } @@ -11781,8 +11709,7 @@ VKAPI_ATTR VkResult VKAPI_CALL QueueBindSparse(VkQueue queue, uint32_t bindInfoC lock.unlock(); - if (!skip_call) - return dev_data->dispatch_table.QueueBindSparse(queue, bindInfoCount, pBindInfo, fence); + if (!skip_call) return dev_data->dispatch_table.QueueBindSparse(queue, bindInfoCount, pBindInfo, fence); return result; } @@ -11838,7 +11765,7 @@ static bool PreCallValidateCreateSwapchainKHR(layer_data *dev_data, const char * reinterpret_cast(dev_data->physical_device), __LINE__, DRAWSTATE_SWAPCHAIN_CREATE_BEFORE_QUERY, "DS", "%s: surface capabilities not retrieved for this physical device", func_name)) return true; - } else { // have valid capabilities + } else { // have valid capabilities auto &capabilities = physical_device_state->surfaceCapabilities; // Validate pCreateInfo->minImageCount against VkSurfaceCapabilitiesKHR::{min|max}ImageCount: if (pCreateInfo->minImageCount < capabilities.minImageCount) { @@ -12094,17 +12021,14 @@ VKAPI_ATTR void VKAPI_CALL DestroySwapchainKHR(VkDevice device, VkSwapchainKHR s auto surface_state = getSurfaceState(dev_data->instance_data, swapchain_data->createInfo.surface); if (surface_state) { - if (surface_state->swapchain == swapchain_data) - surface_state->swapchain = nullptr; - if (surface_state->old_swapchain == swapchain_data) - surface_state->old_swapchain = nullptr; + if (surface_state->swapchain == swapchain_data) surface_state->swapchain = nullptr; + if (surface_state->old_swapchain == swapchain_data) surface_state->old_swapchain = nullptr; } dev_data->device_extensions.swapchainMap.erase(swapchain); } lock.unlock(); - if (!skip_call) - dev_data->dispatch_table.DestroySwapchainKHR(device, swapchain, pAllocator); + if (!skip_call) dev_data->dispatch_table.DestroySwapchainKHR(device, swapchain, pAllocator); } VKAPI_ATTR VkResult VKAPI_CALL GetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain, uint32_t *pCount, @@ -12114,8 +12038,7 @@ VKAPI_ATTR VkResult VKAPI_CALL GetSwapchainImagesKHR(VkDevice device, VkSwapchai if (result == VK_SUCCESS && pSwapchainImages != NULL) { // This should never happen and is checked by param checker. - if (!pCount) - return result; + if (!pCount) return result; std::lock_guard lock(global_lock); const size_t count = *pCount; auto swapchain_node = getSwapchainNode(dev_data, swapchain); @@ -12225,15 +12148,16 @@ VKAPI_ATTR VkResult VKAPI_CALL QueuePresentKHR(VkQueue queue, const VkPresentInf skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT, reinterpret_cast(pPresentInfo->pSwapchains[i]), __LINE__, - DRAWSTATE_SWAPCHAIN_UNSUPPORTED_QUEUE, "DS", "vkQueuePresentKHR: Presenting image without calling " - "vkGetPhysicalDeviceSurfaceSupportKHR"); + DRAWSTATE_SWAPCHAIN_UNSUPPORTED_QUEUE, "DS", + "vkQueuePresentKHR: Presenting image without calling " + "vkGetPhysicalDeviceSurfaceSupportKHR"); } else if (!support_it->second) { - skip_call |= - log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT, - reinterpret_cast(pPresentInfo->pSwapchains[i]), __LINE__, VALIDATION_ERROR_01961, - "DS", "vkQueuePresentKHR: Presenting image on queue that cannot " - "present to this surface. %s", - validation_error_map[VALIDATION_ERROR_01961]); + skip_call |= log_msg( + dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT, + reinterpret_cast(pPresentInfo->pSwapchains[i]), __LINE__, VALIDATION_ERROR_01961, "DS", + "vkQueuePresentKHR: Presenting image on queue that cannot " + "present to this surface. %s", + validation_error_map[VALIDATION_ERROR_01961]); } } } @@ -12262,8 +12186,7 @@ VKAPI_ATTR VkResult VKAPI_CALL QueuePresentKHR(VkQueue queue, const VkPresentInf // itself just as much. auto local_result = pPresentInfo->pResults ? pPresentInfo->pResults[i] : result; - if (local_result != VK_SUCCESS && local_result != VK_SUBOPTIMAL_KHR) - continue; // this present didn't actually happen. + if (local_result != VK_SUCCESS && local_result != VK_SUBOPTIMAL_KHR) continue; // this present didn't actually happen. // Mark the image as having been released to the WSI auto swapchain_data = getSwapchainNode(dev_data, pPresentInfo->pSwapchains[i]); @@ -12404,8 +12327,7 @@ VKAPI_ATTR VkResult VKAPI_CALL AcquireNextImageKHR(VkDevice device, VkSwapchainK lock.unlock(); - if (skip_call) - return VK_ERROR_VALIDATION_FAILED_EXT; + if (skip_call) return VK_ERROR_VALIDATION_FAILED_EXT; VkResult result = dev_data->dispatch_table.AcquireNextImageKHR(device, swapchain, timeout, semaphore, fence, pImageIndex); @@ -12413,7 +12335,7 @@ VKAPI_ATTR VkResult VKAPI_CALL AcquireNextImageKHR(VkDevice device, VkSwapchainK if (result == VK_SUCCESS || result == VK_SUBOPTIMAL_KHR) { if (pFence) { pFence->state = FENCE_INFLIGHT; - pFence->signaler.first = VK_NULL_HANDLE; // ANI isn't on a queue, so this can't participate in a completion proof. + pFence->signaler.first = VK_NULL_HANDLE; // ANI isn't on a queue, so this can't participate in a completion proof. } // A successful call to AcquireNextImageKHR counts as a signal operation on semaphore @@ -12449,7 +12371,7 @@ VKAPI_ATTR VkResult VKAPI_CALL EnumeratePhysicalDevices(VkInstance instance, uin VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, 0, __LINE__, DEVLIMITS_MISSING_QUERY_COUNT, "DL", "Call sequence has vkEnumeratePhysicalDevices() w/ non-NULL pPhysicalDevices. You should first " "call vkEnumeratePhysicalDevices() w/ NULL pPhysicalDevices to query pPhysicalDeviceCount."); - } // TODO : Could also flag a warning if re-calling this function in QUERY_DETAILS state + } // TODO : Could also flag a warning if re-calling this function in QUERY_DETAILS state else if (instance_data->physical_devices_count != *pPhysicalDeviceCount) { // Having actual count match count from app is not a requirement, so this can be a warning skip_call |= log_msg(instance_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, @@ -12466,7 +12388,7 @@ VKAPI_ATTR VkResult VKAPI_CALL EnumeratePhysicalDevices(VkInstance instance, uin VkResult result = instance_data->dispatch_table.EnumeratePhysicalDevices(instance, pPhysicalDeviceCount, pPhysicalDevices); if (NULL == pPhysicalDevices) { instance_data->physical_devices_count = *pPhysicalDeviceCount; - } else if (result == VK_SUCCESS) { // Save physical devices + } else if (result == VK_SUCCESS) { // Save physical devices for (uint32_t i = 0; i < *pPhysicalDeviceCount; i++) { auto &phys_device_state = instance_data->physical_device_map[pPhysicalDevices[i]]; phys_device_state.phys_device = pPhysicalDevices[i]; @@ -12498,7 +12420,6 @@ VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevi } // Then verify that pCount that is passed in on second call matches what was returned if (physical_device_state->queueFamilyPropertiesCount != *pCount) { - // TODO: this is not a requirement of the Valid Usage section for vkGetPhysicalDeviceQueueFamilyProperties, so // provide as warning skip_call |= log_msg(instance_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, @@ -12515,7 +12436,7 @@ VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevi instance_data->dispatch_table.GetPhysicalDeviceQueueFamilyProperties(physicalDevice, pCount, pQueueFamilyProperties); if (!pQueueFamilyProperties) { physical_device_state->queueFamilyPropertiesCount = *pCount; - } else { // Save queue family properties + } else { // Save queue family properties if (physical_device_state->queue_family_properties.size() < *pCount) physical_device_state->queue_family_properties.resize(*pCount); for (uint32_t i = 0; i < *pCount; i++) { @@ -12575,42 +12496,42 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateAndroidSurfaceKHR(VkInstance instance, cons const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { return CreateSurface(instance, pCreateInfo, pAllocator, pSurface, &VkLayerInstanceDispatchTable::CreateAndroidSurfaceKHR); } -#endif // VK_USE_PLATFORM_ANDROID_KHR +#endif // VK_USE_PLATFORM_ANDROID_KHR #ifdef VK_USE_PLATFORM_MIR_KHR VKAPI_ATTR VkResult VKAPI_CALL CreateMirSurfaceKHR(VkInstance instance, const VkMirSurfaceCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { return CreateSurface(instance, pCreateInfo, pAllocator, pSurface, &VkLayerInstanceDispatchTable::CreateMirSurfaceKHR); } -#endif // VK_USE_PLATFORM_MIR_KHR +#endif // VK_USE_PLATFORM_MIR_KHR #ifdef VK_USE_PLATFORM_WAYLAND_KHR VKAPI_ATTR VkResult VKAPI_CALL CreateWaylandSurfaceKHR(VkInstance instance, const VkWaylandSurfaceCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { return CreateSurface(instance, pCreateInfo, pAllocator, pSurface, &VkLayerInstanceDispatchTable::CreateWaylandSurfaceKHR); } -#endif // VK_USE_PLATFORM_WAYLAND_KHR +#endif // VK_USE_PLATFORM_WAYLAND_KHR #ifdef VK_USE_PLATFORM_WIN32_KHR VKAPI_ATTR VkResult VKAPI_CALL CreateWin32SurfaceKHR(VkInstance instance, const VkWin32SurfaceCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { return CreateSurface(instance, pCreateInfo, pAllocator, pSurface, &VkLayerInstanceDispatchTable::CreateWin32SurfaceKHR); } -#endif // VK_USE_PLATFORM_WIN32_KHR +#endif // VK_USE_PLATFORM_WIN32_KHR #ifdef VK_USE_PLATFORM_XCB_KHR VKAPI_ATTR VkResult VKAPI_CALL CreateXcbSurfaceKHR(VkInstance instance, const VkXcbSurfaceCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { return CreateSurface(instance, pCreateInfo, pAllocator, pSurface, &VkLayerInstanceDispatchTable::CreateXcbSurfaceKHR); } -#endif // VK_USE_PLATFORM_XCB_KHR +#endif // VK_USE_PLATFORM_XCB_KHR #ifdef VK_USE_PLATFORM_XLIB_KHR VKAPI_ATTR VkResult VKAPI_CALL CreateXlibSurfaceKHR(VkInstance instance, const VkXlibSurfaceCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { return CreateSurface(instance, pCreateInfo, pAllocator, pSurface, &VkLayerInstanceDispatchTable::CreateXlibSurfaceKHR); } -#endif // VK_USE_PLATFORM_XLIB_KHR +#endif // VK_USE_PLATFORM_XLIB_KHR VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceSurfaceCapabilitiesKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, VkSurfaceCapabilitiesKHR *pSurfaceCapabilities) { @@ -12662,47 +12583,44 @@ VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceSurfacePresentModesKHR(VkPhysica // Compare the preliminary value of *pPresentModeCount with the value this time: auto prev_mode_count = (uint32_t)physical_device_state->present_modes.size(); switch (call_state) { - case UNCALLED: - skip_call |= log_msg( - instance_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, - reinterpret_cast(physicalDevice), __LINE__, DEVLIMITS_MUST_QUERY_COUNT, "DL", - "vkGetPhysicalDeviceSurfacePresentModesKHR() called with non-NULL pPresentModeCount; but no prior positive " - "value has been seen for pPresentModeCount."); - break; - default: - // both query count and query details - if (*pPresentModeCount != prev_mode_count) { + case UNCALLED: skip_call |= log_msg( instance_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, - reinterpret_cast(physicalDevice), __LINE__, DEVLIMITS_COUNT_MISMATCH, "DL", - "vkGetPhysicalDeviceSurfacePresentModesKHR() called with *pPresentModeCount (%u) that differs from the value " - "(%u) that was returned when pPresentModes was NULL.", - *pPresentModeCount, prev_mode_count); - } - break; + reinterpret_cast(physicalDevice), __LINE__, DEVLIMITS_MUST_QUERY_COUNT, "DL", + "vkGetPhysicalDeviceSurfacePresentModesKHR() called with non-NULL pPresentModeCount; but no prior positive " + "value has been seen for pPresentModeCount."); + break; + default: + // both query count and query details + if (*pPresentModeCount != prev_mode_count) { + skip_call |= log_msg(instance_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, + VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, + reinterpret_cast(physicalDevice), __LINE__, DEVLIMITS_COUNT_MISMATCH, "DL", + "vkGetPhysicalDeviceSurfacePresentModesKHR() called with *pPresentModeCount (%u) that " + "differs from the value " + "(%u) that was returned when pPresentModes was NULL.", + *pPresentModeCount, prev_mode_count); + } + break; } } lock.unlock(); - if (skip_call) - return VK_ERROR_VALIDATION_FAILED_EXT; + if (skip_call) return VK_ERROR_VALIDATION_FAILED_EXT; auto result = instance_data->dispatch_table.GetPhysicalDeviceSurfacePresentModesKHR(physicalDevice, surface, pPresentModeCount, pPresentModes); if (result == VK_SUCCESS || result == VK_INCOMPLETE) { - lock.lock(); if (*pPresentModeCount) { - if (call_state < QUERY_COUNT) - call_state = QUERY_COUNT; + if (call_state < QUERY_COUNT) call_state = QUERY_COUNT; if (*pPresentModeCount > physical_device_state->present_modes.size()) physical_device_state->present_modes.resize(*pPresentModeCount); } if (pPresentModes) { - if (call_state < QUERY_DETAILS) - call_state = QUERY_DETAILS; + if (call_state < QUERY_DETAILS) call_state = QUERY_DETAILS; for (uint32_t i = 0; i < *pPresentModeCount; i++) { physical_device_state->present_modes[i] = pPresentModes[i]; } @@ -12725,50 +12643,49 @@ VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevi auto prev_format_count = (uint32_t)physical_device_state->surface_formats.size(); switch (call_state) { - case UNCALLED: - // Since we haven't recorded a preliminary value of *pSurfaceFormatCount, that likely means that the application didn't - // previously call this function with a NULL value of pSurfaceFormats: - skip_call |= log_msg( - instance_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, - reinterpret_cast(physicalDevice), __LINE__, DEVLIMITS_MUST_QUERY_COUNT, "DL", - "vkGetPhysicalDeviceSurfaceFormatsKHR() called with non-NULL pSurfaceFormatCount; but no prior positive " - "value has been seen for pSurfaceFormats."); - break; - default: - if (prev_format_count != *pSurfaceFormatCount) { + case UNCALLED: + // Since we haven't recorded a preliminary value of *pSurfaceFormatCount, that likely means that the application + // didn't + // previously call this function with a NULL value of pSurfaceFormats: skip_call |= log_msg( instance_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, - reinterpret_cast(physicalDevice), __LINE__, DEVLIMITS_COUNT_MISMATCH, "DL", - "vkGetPhysicalDeviceSurfaceFormatsKHR() called with non-NULL pSurfaceFormatCount, and with pSurfaceFormats set " - "to " - "a value (%u) that is greater than the value (%u) that was returned when pSurfaceFormatCount was NULL.", - *pSurfaceFormatCount, prev_format_count); - } - break; + reinterpret_cast(physicalDevice), __LINE__, DEVLIMITS_MUST_QUERY_COUNT, "DL", + "vkGetPhysicalDeviceSurfaceFormatsKHR() called with non-NULL pSurfaceFormatCount; but no prior positive " + "value has been seen for pSurfaceFormats."); + break; + default: + if (prev_format_count != *pSurfaceFormatCount) { + skip_call |= log_msg( + instance_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, + VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, reinterpret_cast(physicalDevice), __LINE__, + DEVLIMITS_COUNT_MISMATCH, "DL", + "vkGetPhysicalDeviceSurfaceFormatsKHR() called with non-NULL pSurfaceFormatCount, and with pSurfaceFormats " + "set " + "to " + "a value (%u) that is greater than the value (%u) that was returned when pSurfaceFormatCount was NULL.", + *pSurfaceFormatCount, prev_format_count); + } + break; } } lock.unlock(); - if (skip_call) - return VK_ERROR_VALIDATION_FAILED_EXT; + if (skip_call) return VK_ERROR_VALIDATION_FAILED_EXT; // Call down the call chain: auto result = instance_data->dispatch_table.GetPhysicalDeviceSurfaceFormatsKHR(physicalDevice, surface, pSurfaceFormatCount, pSurfaceFormats); if (result == VK_SUCCESS || result == VK_INCOMPLETE) { - lock.lock(); if (*pSurfaceFormatCount) { - if (call_state < QUERY_COUNT) - call_state = QUERY_COUNT; + if (call_state < QUERY_COUNT) call_state = QUERY_COUNT; if (*pSurfaceFormatCount > physical_device_state->surface_formats.size()) physical_device_state->surface_formats.resize(*pSurfaceFormatCount); } if (pSurfaceFormats) { - if (call_state < QUERY_DETAILS) - call_state = QUERY_DETAILS; + if (call_state < QUERY_DETAILS) call_state = QUERY_DETAILS; for (uint32_t i = 0; i < *pSurfaceFormatCount; i++) { physical_device_state->surface_formats[i] = pSurfaceFormats[i]; } @@ -12824,8 +12741,7 @@ VKAPI_ATTR VkResult VKAPI_CALL EnumerateInstanceExtensionProperties(const char * VKAPI_ATTR VkResult VKAPI_CALL EnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, const char *pLayerName, uint32_t *pCount, VkExtensionProperties *pProperties) { - if (pLayerName && !strcmp(pLayerName, global_layer.layerName)) - return util_GetExtensionProperties(0, NULL, pCount, pProperties); + if (pLayerName && !strcmp(pLayerName, global_layer.layerName)) return util_GetExtensionProperties(0, NULL, pCount, pProperties); assert(physicalDevice); @@ -12845,48 +12761,38 @@ static PFN_vkVoidFunction intercept_extension_instance_commands(const char *name VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetDeviceProcAddr(VkDevice dev, const char *funcName) { PFN_vkVoidFunction proc = intercept_core_device_command(funcName); - if (proc) - return proc; + if (proc) return proc; assert(dev); proc = intercept_khr_swapchain_command(funcName, dev); - if (proc) - return proc; + if (proc) return proc; layer_data *dev_data = get_my_data_ptr(get_dispatch_key(dev), layer_data_map); auto &table = dev_data->dispatch_table; - if (!table.GetDeviceProcAddr) - return nullptr; + if (!table.GetDeviceProcAddr) return nullptr; return table.GetDeviceProcAddr(dev, funcName); } VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetInstanceProcAddr(VkInstance instance, const char *funcName) { PFN_vkVoidFunction proc = intercept_core_instance_command(funcName); - if (!proc) - proc = intercept_core_device_command(funcName); - if (!proc) - proc = intercept_khr_swapchain_command(funcName, VK_NULL_HANDLE); - if (!proc) - proc = intercept_khr_surface_command(funcName, instance); - if (proc) - return proc; + if (!proc) proc = intercept_core_device_command(funcName); + if (!proc) proc = intercept_khr_swapchain_command(funcName, VK_NULL_HANDLE); + if (!proc) proc = intercept_khr_surface_command(funcName, instance); + if (proc) return proc; assert(instance); instance_layer_data *instance_data = get_my_data_ptr(get_dispatch_key(instance), instance_layer_data_map); proc = debug_report_get_instance_proc_addr(instance_data->report_data, funcName); - if (proc) - return proc; + if (proc) return proc; proc = intercept_extension_instance_commands(funcName, instance); - if (proc) - return proc; + if (proc) return proc; auto &table = instance_data->dispatch_table; - if (!table.GetInstanceProcAddr) - return nullptr; + if (!table.GetInstanceProcAddr) return nullptr; return table.GetInstanceProcAddr(instance, funcName); } @@ -12896,8 +12802,7 @@ VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetPhysicalDeviceProcAddr(VkInstance in instance_layer_data *instance_data = get_my_data_ptr(get_dispatch_key(instance), instance_layer_data_map); auto &table = instance_data->dispatch_table; - if (!table.GetPhysicalDeviceProcAddr) - return nullptr; + if (!table.GetPhysicalDeviceProcAddr) return nullptr; return table.GetPhysicalDeviceProcAddr(instance, funcName); } @@ -12921,8 +12826,7 @@ static PFN_vkVoidFunction intercept_core_instance_command(const char *name) { }; for (size_t i = 0; i < ARRAY_SIZE(core_instance_commands); i++) { - if (!strcmp(core_instance_commands[i].name, name)) - return core_instance_commands[i].proc; + if (!strcmp(core_instance_commands[i].name, name)) return core_instance_commands[i].proc; } return nullptr; @@ -13052,8 +12956,7 @@ static PFN_vkVoidFunction intercept_core_device_command(const char *name) { }; for (size_t i = 0; i < ARRAY_SIZE(core_device_commands); i++) { - if (!strcmp(core_device_commands[i].name, name)) - return core_device_commands[i].proc; + if (!strcmp(core_device_commands[i].name, name)) return core_device_commands[i].proc; } return nullptr; @@ -13074,22 +12977,18 @@ static PFN_vkVoidFunction intercept_khr_swapchain_command(const char *name, VkDe if (dev) { dev_data = get_my_data_ptr(get_dispatch_key(dev), layer_data_map); - if (!dev_data->device_extensions.wsi_enabled) - return nullptr; + if (!dev_data->device_extensions.wsi_enabled) return nullptr; } for (size_t i = 0; i < ARRAY_SIZE(khr_swapchain_commands); i++) { - if (!strcmp(khr_swapchain_commands[i].name, name)) - return khr_swapchain_commands[i].proc; + if (!strcmp(khr_swapchain_commands[i].name, name)) return khr_swapchain_commands[i].proc; } if (dev_data) { - if (!dev_data->device_extensions.wsi_display_swapchain_enabled) - return nullptr; + if (!dev_data->device_extensions.wsi_display_swapchain_enabled) return nullptr; } - if (!strcmp("vkCreateSharedSwapchainsKHR", name)) - return reinterpret_cast(CreateSharedSwapchainsKHR); + if (!strcmp("vkCreateSharedSwapchainsKHR", name)) return reinterpret_cast(CreateSharedSwapchainsKHR); return nullptr; } @@ -13103,27 +13002,27 @@ static PFN_vkVoidFunction intercept_khr_surface_command(const char *name, VkInst #ifdef VK_USE_PLATFORM_ANDROID_KHR {"vkCreateAndroidSurfaceKHR", reinterpret_cast(CreateAndroidSurfaceKHR), &instance_layer_data::androidSurfaceExtensionEnabled}, -#endif // VK_USE_PLATFORM_ANDROID_KHR +#endif // VK_USE_PLATFORM_ANDROID_KHR #ifdef VK_USE_PLATFORM_MIR_KHR {"vkCreateMirSurfaceKHR", reinterpret_cast(CreateMirSurfaceKHR), &instance_layer_data::mirSurfaceExtensionEnabled}, -#endif // VK_USE_PLATFORM_MIR_KHR +#endif // VK_USE_PLATFORM_MIR_KHR #ifdef VK_USE_PLATFORM_WAYLAND_KHR {"vkCreateWaylandSurfaceKHR", reinterpret_cast(CreateWaylandSurfaceKHR), &instance_layer_data::waylandSurfaceExtensionEnabled}, -#endif // VK_USE_PLATFORM_WAYLAND_KHR +#endif // VK_USE_PLATFORM_WAYLAND_KHR #ifdef VK_USE_PLATFORM_WIN32_KHR {"vkCreateWin32SurfaceKHR", reinterpret_cast(CreateWin32SurfaceKHR), &instance_layer_data::win32SurfaceExtensionEnabled}, -#endif // VK_USE_PLATFORM_WIN32_KHR +#endif // VK_USE_PLATFORM_WIN32_KHR #ifdef VK_USE_PLATFORM_XCB_KHR {"vkCreateXcbSurfaceKHR", reinterpret_cast(CreateXcbSurfaceKHR), &instance_layer_data::xcbSurfaceExtensionEnabled}, -#endif // VK_USE_PLATFORM_XCB_KHR +#endif // VK_USE_PLATFORM_XCB_KHR #ifdef VK_USE_PLATFORM_XLIB_KHR {"vkCreateXlibSurfaceKHR", reinterpret_cast(CreateXlibSurfaceKHR), &instance_layer_data::xlibSurfaceExtensionEnabled}, -#endif // VK_USE_PLATFORM_XLIB_KHR +#endif // VK_USE_PLATFORM_XLIB_KHR {"vkCreateDisplayPlaneSurfaceKHR", reinterpret_cast(CreateDisplayPlaneSurfaceKHR), &instance_layer_data::displayExtensionEnabled}, {"vkDestroySurfaceKHR", reinterpret_cast(DestroySurfaceKHR), @@ -13145,8 +13044,7 @@ static PFN_vkVoidFunction intercept_khr_surface_command(const char *name, VkInst for (size_t i = 0; i < ARRAY_SIZE(khr_surface_commands); i++) { if (!strcmp(khr_surface_commands[i].name, name)) { - if (instance_data && !(instance_data->*(khr_surface_commands[i].enable))) - return nullptr; + if (instance_data && !(instance_data->*(khr_surface_commands[i].enable))) return nullptr; return khr_surface_commands[i].proc; } } @@ -13156,7 +13054,7 @@ static PFN_vkVoidFunction intercept_khr_surface_command(const char *name, VkInst static PFN_vkVoidFunction intercept_extension_instance_commands(const char *name, VkInstance instance) { return NULL; } -} // namespace core_validation +} // namespace core_validation // vk_layer_logging.h expects these to be defined diff --git a/layers/core_validation.h b/layers/core_validation.h index dc0e0ff..e6c92b2 100644 --- a/layers/core_validation.h +++ b/layers/core_validation.h @@ -69,23 +69,23 @@ struct CHECK_DISABLED { bool command_buffer_state; bool create_descriptor_set_layout; - bool destroy_buffer_view; // Skip validation at DestroyBufferView time - bool destroy_image_view; // Skip validation at DestroyImageView time - bool destroy_pipeline; // Skip validation at DestroyPipeline time - bool destroy_descriptor_pool; // Skip validation at DestroyDescriptorPool time - bool destroy_framebuffer; // Skip validation at DestroyFramebuffer time - bool destroy_renderpass; // Skip validation at DestroyRenderpass time - bool destroy_image; // Skip validation at DestroyImage time - bool destroy_sampler; // Skip validation at DestroySampler time - bool destroy_command_pool; // Skip validation at DestroyCommandPool time - bool destroy_event; // Skip validation at DestroyEvent time - bool free_memory; // Skip validation at FreeMemory time - bool object_in_use; // Skip all object in_use checking - bool idle_descriptor_set; // Skip check to verify that descriptor set is no in-use - bool push_constant_range; // Skip push constant range checks - bool free_descriptor_sets; // Skip validation prior to vkFreeDescriptorSets() - bool allocate_descriptor_sets; // Skip validation prior to vkAllocateDescriptorSets() - bool update_descriptor_sets; // Skip validation prior to vkUpdateDescriptorSets() + bool destroy_buffer_view; // Skip validation at DestroyBufferView time + bool destroy_image_view; // Skip validation at DestroyImageView time + bool destroy_pipeline; // Skip validation at DestroyPipeline time + bool destroy_descriptor_pool; // Skip validation at DestroyDescriptorPool time + bool destroy_framebuffer; // Skip validation at DestroyFramebuffer time + bool destroy_renderpass; // Skip validation at DestroyRenderpass time + bool destroy_image; // Skip validation at DestroyImage time + bool destroy_sampler; // Skip validation at DestroySampler time + bool destroy_command_pool; // Skip validation at DestroyCommandPool time + bool destroy_event; // Skip validation at DestroyEvent time + bool free_memory; // Skip validation at FreeMemory time + bool object_in_use; // Skip all object in_use checking + bool idle_descriptor_set; // Skip check to verify that descriptor set is no in-use + bool push_constant_range; // Skip push constant range checks + bool free_descriptor_sets; // Skip validation prior to vkFreeDescriptorSets() + bool allocate_descriptor_sets; // Skip validation prior to vkAllocateDescriptorSets() + bool update_descriptor_sets; // Skip validation prior to vkUpdateDescriptorSets() bool wait_for_fences; bool get_fence_state; bool queue_wait_idle; @@ -140,7 +140,7 @@ struct GENERIC_HEADER { }; class PHYS_DEV_PROPERTIES_NODE { - public: + public: VkPhysicalDeviceProperties properties; std::vector queue_family_properties; }; @@ -148,7 +148,7 @@ class PHYS_DEV_PROPERTIES_NODE { enum FENCE_STATE { FENCE_UNSIGNALED, FENCE_INFLIGHT, FENCE_RETIRED }; class FENCE_NODE { - public: + public: VkFence fence; VkFenceCreateInfo createInfo; std::pair signaler; @@ -159,36 +159,36 @@ class FENCE_NODE { }; class SEMAPHORE_NODE : public BASE_NODE { - public: + public: std::pair signaler; bool signaled; }; class EVENT_STATE : public BASE_NODE { - public: + public: int write_in_use; bool needsSignaled; VkPipelineStageFlags stageMask; }; class QUEUE_STATE { - public: + public: VkQueue queue; uint32_t queueFamilyIndex; std::unordered_map eventToStageMap; - std::unordered_map queryToStateMap; // 0 is unavailable, 1 is available + std::unordered_map queryToStateMap; // 0 is unavailable, 1 is available uint64_t seq; std::deque submissions; }; class QUERY_POOL_NODE : public BASE_NODE { - public: + public: VkQueryPoolCreateInfo createInfo; }; class FRAMEBUFFER_STATE : public BASE_NODE { - public: + public: VkFramebuffer framebuffer; safe_VkFramebufferCreateInfo createInfo; safe_VkRenderPassCreateInfo renderPassCreateInfo; @@ -203,14 +203,14 @@ struct COMMAND_POOL_NODE : public BASE_NODE { VkCommandPoolCreateFlags createFlags; uint32_t queueFamilyIndex; // TODO: why is this std::list? - std::list commandBuffers; // container of cmd buffers allocated from this pool + std::list commandBuffers; // container of cmd buffers allocated from this pool }; // Stuff from Device Limits Layer enum CALL_STATE { - UNCALLED, // Function has not been called - QUERY_COUNT, // Function called once to query a count - QUERY_DETAILS, // Function called w/ a count to query details + UNCALLED, // Function has not been called + QUERY_COUNT, // Function called once to query a count + QUERY_DETAILS, // Function called w/ a count to query details }; struct PHYSICAL_DEVICE_STATE { @@ -241,7 +241,8 @@ inline bool operator==(GpuQueue const &lhs, GpuQueue const &rhs) { } namespace std { -template <> struct hash { +template <> +struct hash { size_t operator()(GpuQueue gq) const throw() { return hash()((uint64_t)(gq.gpu)) ^ hash()(gq.queue_family_index); } diff --git a/layers/core_validation_error_enums.h b/layers/core_validation_error_enums.h index 4f9c230..e4dd0bb 100644 --- a/layers/core_validation_error_enums.h +++ b/layers/core_validation_error_enums.h @@ -189,4 +189,4 @@ enum DEV_LIMITS_ERROR { DEVLIMITS_COUNT_MISMATCH, DEVLIMITS_INVALID_QUEUE_CREATE_REQUEST, }; -#endif // CORE_VALIDATION_ERROR_ENUMS_H_ +#endif // CORE_VALIDATION_ERROR_ENUMS_H_ diff --git a/layers/core_validation_types.h b/layers/core_validation_types.h index d64d30f..e2b95f5 100644 --- a/layers/core_validation_types.h +++ b/layers/core_validation_types.h @@ -66,7 +66,7 @@ class DescriptorSet; struct GLOBAL_CB_NODE; class BASE_NODE { - public: + public: // Track when object is being used by an in-flight command buffer std::atomic_int in_use; // Track command buffers that this object is bound to @@ -87,7 +87,8 @@ struct VK_OBJECT { inline bool operator==(VK_OBJECT a, VK_OBJECT b) NOEXCEPT { return a.handle == b.handle && a.type == b.type; } namespace std { -template <> struct hash { +template <> +struct hash { size_t operator()(VK_OBJECT obj) const NOEXCEPT { return hash()(obj.handle) ^ hash()(obj.type); } }; } @@ -112,18 +113,22 @@ enum descriptor_req { struct DESCRIPTOR_POOL_STATE : BASE_NODE { VkDescriptorPool pool; - uint32_t maxSets; // Max descriptor sets allowed in this pool - uint32_t availableSets; // Available descriptor sets in this pool + uint32_t maxSets; // Max descriptor sets allowed in this pool + uint32_t availableSets; // Available descriptor sets in this pool VkDescriptorPoolCreateInfo createInfo; - std::unordered_set sets; // Collection of all sets in this pool - std::vector maxDescriptorTypeCount; // Max # of descriptors of each type in this pool - std::vector availableDescriptorTypeCount; // Available # of descriptors of each type in this pool + std::unordered_set sets; // Collection of all sets in this pool + std::vector maxDescriptorTypeCount; // Max # of descriptors of each type in this pool + std::vector availableDescriptorTypeCount; // Available # of descriptors of each type in this pool DESCRIPTOR_POOL_STATE(const VkDescriptorPool pool, const VkDescriptorPoolCreateInfo *pCreateInfo) - : pool(pool), maxSets(pCreateInfo->maxSets), availableSets(pCreateInfo->maxSets), createInfo(*pCreateInfo), - maxDescriptorTypeCount(VK_DESCRIPTOR_TYPE_RANGE_SIZE, 0), availableDescriptorTypeCount(VK_DESCRIPTOR_TYPE_RANGE_SIZE, 0) { - if (createInfo.poolSizeCount) { // Shadow type struct from ptr into local struct + : pool(pool), + maxSets(pCreateInfo->maxSets), + availableSets(pCreateInfo->maxSets), + createInfo(*pCreateInfo), + maxDescriptorTypeCount(VK_DESCRIPTOR_TYPE_RANGE_SIZE, 0), + availableDescriptorTypeCount(VK_DESCRIPTOR_TYPE_RANGE_SIZE, 0) { + if (createInfo.poolSizeCount) { // Shadow type struct from ptr into local struct size_t poolSizeCountSize = createInfo.poolSizeCount * sizeof(VkDescriptorPoolSize); createInfo.pPoolSizes = new VkDescriptorPoolSize[poolSizeCountSize]; memcpy((void *)createInfo.pPoolSizes, pCreateInfo->pPoolSizes, poolSizeCountSize); @@ -136,7 +141,7 @@ struct DESCRIPTOR_POOL_STATE : BASE_NODE { availableDescriptorTypeCount[typeIndex] = maxDescriptorTypeCount[typeIndex]; } } else { - createInfo.pPoolSizes = NULL; // Make sure this is NULL so we don't try to clean it up + createInfo.pPoolSizes = NULL; // Make sure this is NULL so we don't try to clean it up } } ~DESCRIPTOR_POOL_STATE() { @@ -156,7 +161,8 @@ struct MEM_BINDING { inline bool operator==(MEM_BINDING a, MEM_BINDING b) NOEXCEPT { return a.mem == b.mem && a.offset == b.offset && a.size == b.size; } namespace std { -template <> struct hash { +template <> +struct hash { size_t operator()(MEM_BINDING mb) const NOEXCEPT { auto intermediate = hash()(reinterpret_cast(mb.mem)) ^ hash()(mb.offset); return intermediate ^ hash()(mb.size); @@ -166,8 +172,8 @@ template <> struct hash { // Superclass for bindable object state (currently images and buffers) class BINDABLE : public BASE_NODE { - public: - bool sparse; // Is this object being bound with sparse memory or not? + public: + bool sparse; // Is this object being bound with sparse memory or not? // Non-sparse binding data MEM_BINDING binding; // Memory requirements for this BINDABLE @@ -194,7 +200,7 @@ class BINDABLE : public BASE_NODE { }; class BUFFER_STATE : public BINDABLE { - public: + public: VkBuffer buffer; VkBufferCreateInfo createInfo; BUFFER_STATE(VkBuffer buff, const VkBufferCreateInfo *pCreateInfo) : buffer(buff), createInfo(*pCreateInfo) { @@ -207,7 +213,7 @@ class BUFFER_STATE : public BINDABLE { }; class BUFFER_VIEW_STATE : public BASE_NODE { - public: + public: VkBufferView buffer_view; VkBufferViewCreateInfo create_info; BUFFER_VIEW_STATE(VkBufferView bv, const VkBufferViewCreateInfo *ci) : buffer_view(bv), create_info(*ci){}; @@ -222,11 +228,11 @@ struct SAMPLER_STATE : public BASE_NODE { }; class IMAGE_STATE : public BINDABLE { - public: + public: VkImage image; VkImageCreateInfo createInfo; - bool valid; // If this is a swapchain image backing memory track valid here as it doesn't have DEVICE_MEM_INFO - bool acquired; // If this is a swapchain image, has it been acquired by the app. + bool valid; // If this is a swapchain image backing memory track valid here as it doesn't have DEVICE_MEM_INFO + bool acquired; // If this is a swapchain image, has it been acquired by the app. IMAGE_STATE(VkImage img, const VkImageCreateInfo *pCreateInfo) : image(img), createInfo(*pCreateInfo), valid(false), acquired(false) { if (createInfo.flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) { @@ -238,7 +244,7 @@ class IMAGE_STATE : public BINDABLE { }; class IMAGE_VIEW_STATE : public BASE_NODE { - public: + public: VkImageView image_view; VkImageViewCreateInfo create_info; IMAGE_VIEW_STATE(VkImageView iv, const VkImageViewCreateInfo *ci) : image_view(iv), create_info(*ci){}; @@ -252,43 +258,50 @@ struct MemRange { struct MEMORY_RANGE { uint64_t handle; - bool image; // True for image, false for buffer - bool linear; // True for buffers and linear images - bool valid; // True if this range is know to be valid + bool image; // True for image, false for buffer + bool linear; // True for buffers and linear images + bool valid; // True if this range is know to be valid VkDeviceMemory memory; VkDeviceSize start; VkDeviceSize size; - VkDeviceSize end; // Store this pre-computed for simplicity + VkDeviceSize end; // Store this pre-computed for simplicity // Set of ptrs to every range aliased with this one std::unordered_set aliases; }; // Data struct for tracking memory object struct DEVICE_MEM_INFO : public BASE_NODE { - void *object; // Dispatchable object used to create this memory (device of swapchain) - bool global_valid; // If allocation is mapped, set to "true" to be picked up by subsequently bound ranges + void *object; // Dispatchable object used to create this memory (device of swapchain) + bool global_valid; // If allocation is mapped, set to "true" to be picked up by subsequently bound ranges VkDeviceMemory mem; VkMemoryAllocateInfo alloc_info; - std::unordered_set obj_bindings; // objects bound to this memory - std::unordered_map bound_ranges; // Map of object to its binding range + std::unordered_set obj_bindings; // objects bound to this memory + std::unordered_map bound_ranges; // Map of object to its binding range // Convenience vectors image/buff handles to speed up iterating over images or buffers independently std::unordered_set bound_images; std::unordered_set bound_buffers; MemRange mem_range; - void *shadow_copy_base; // Base of layer's allocation for guard band, data, and alignment space - void *shadow_copy; // Pointer to start of guard-band data before mapped region - uint64_t shadow_pad_size; // Size of the guard-band data before and after actual data. It MUST be a - // multiple of limits.minMemoryMapAlignment - void *p_driver_data; // Pointer to application's actual memory + void *shadow_copy_base; // Base of layer's allocation for guard band, data, and alignment space + void *shadow_copy; // Pointer to start of guard-band data before mapped region + uint64_t shadow_pad_size; // Size of the guard-band data before and after actual data. It MUST be a + // multiple of limits.minMemoryMapAlignment + void *p_driver_data; // Pointer to application's actual memory DEVICE_MEM_INFO(void *disp_object, const VkDeviceMemory in_mem, const VkMemoryAllocateInfo *p_alloc_info) - : object(disp_object), global_valid(false), mem(in_mem), alloc_info(*p_alloc_info), mem_range{}, shadow_copy_base(0), - shadow_copy(0), shadow_pad_size(0), p_driver_data(0){}; + : object(disp_object), + global_valid(false), + mem(in_mem), + alloc_info(*p_alloc_info), + mem_range{}, + shadow_copy_base(0), + shadow_copy(0), + shadow_pad_size(0), + p_driver_data(0){}; }; class SWAPCHAIN_NODE { - public: + public: safe_VkSwapchainCreateInfoKHR createInfo; VkSwapchainKHR swapchain; std::vector images; @@ -308,7 +321,7 @@ enum DRAW_TYPE { }; class IMAGE_CMD_BUF_LAYOUT_NODE { - public: + public: IMAGE_CMD_BUF_LAYOUT_NODE() = default; IMAGE_CMD_BUF_LAYOUT_NODE(VkImageLayout initialLayoutInput, VkImageLayout layoutInput) : initialLayout(initialLayoutInput), layout(layoutInput) {} @@ -387,14 +400,14 @@ enum CMD_TYPE { CMD_NEXTSUBPASS, CMD_ENDRENDERPASS, CMD_EXECUTECOMMANDS, - CMD_END, // Should be last command in any RECORDED cmd buffer + CMD_END, // Should be last command in any RECORDED cmd buffer }; enum CB_STATE { - CB_NEW, // Newly created CB w/o any cmds - CB_RECORDING, // BeginCB has been called on this CB - CB_RECORDED, // EndCB has been called on this CB - CB_INVALID // CB had a bound descriptor set destroyed or updated + CB_NEW, // Newly created CB w/o any cmds + CB_RECORDING, // BeginCB has been called on this CB + CB_RECORDED, // EndCB has been called on this CB + CB_INVALID // CB had a bound descriptor set destroyed or updated }; // CB Status -- used to track status of various bindings on cmd buffer objects @@ -424,7 +437,8 @@ inline bool operator==(const QueryObject &query1, const QueryObject &query2) { } namespace std { -template <> struct hash { +template <> +struct hash { size_t operator()(QueryObject query) const throw() { return hash()((uint64_t)(query.pool)) ^ hash()(query.index); } @@ -441,15 +455,15 @@ struct ImageSubresourcePair { }; inline bool operator==(const ImageSubresourcePair &img1, const ImageSubresourcePair &img2) { - if (img1.image != img2.image || img1.hasSubresource != img2.hasSubresource) - return false; + if (img1.image != img2.image || img1.hasSubresource != img2.hasSubresource) return false; return !img1.hasSubresource || (img1.subresource.aspectMask == img2.subresource.aspectMask && img1.subresource.mipLevel == img2.subresource.mipLevel && img1.subresource.arrayLayer == img2.subresource.arrayLayer); } namespace std { -template <> struct hash { +template <> +struct hash { size_t operator()(ImageSubresourcePair img) const throw() { size_t hashVal = hash()(reinterpret_cast(img.image)); hashVal ^= hash()(img.hasSubresource); @@ -479,7 +493,7 @@ struct PIPELINE_LAYOUT_NODE { }; class PIPELINE_STATE : public BASE_NODE { - public: + public: VkPipeline pipeline; safe_VkGraphicsPipelineCreateInfo graphicsPipelineCI; safe_VkComputePipelineCreateInfo computePipelineCI; @@ -492,15 +506,24 @@ class PIPELINE_STATE : public BASE_NODE { std::vector vertexBindingDescriptions; std::vector vertexAttributeDescriptions; std::vector attachments; - bool blendConstantsEnabled; // Blend constants enabled for any attachments + bool blendConstantsEnabled; // Blend constants enabled for any attachments // Store RPCI b/c renderPass may be destroyed after Pipeline creation safe_VkRenderPassCreateInfo render_pass_ci; PIPELINE_LAYOUT_NODE pipeline_layout; // Default constructor PIPELINE_STATE() - : pipeline{}, graphicsPipelineCI{}, computePipelineCI{}, active_shaders(0), duplicate_shaders(0), active_slots(), - vertexBindingDescriptions(), vertexAttributeDescriptions(), attachments(), blendConstantsEnabled(false), render_pass_ci(), + : pipeline{}, + graphicsPipelineCI{}, + computePipelineCI{}, + active_shaders(0), + duplicate_shaders(0), + active_slots(), + vertexBindingDescriptions(), + vertexAttributeDescriptions(), + attachments(), + blendConstantsEnabled(false), + render_pass_ci(), pipeline_layout() {} void initGraphicsPipeline(const VkGraphicsPipelineCreateInfo *pCreateInfo) { @@ -539,12 +562,12 @@ class PIPELINE_STATE : public BASE_NODE { VkGraphicsPipelineCreateInfo emptyGraphicsCI = {}; graphicsPipelineCI.initialize(&emptyGraphicsCI); switch (computePipelineCI.stage.stage) { - case VK_SHADER_STAGE_COMPUTE_BIT: - this->active_shaders |= VK_SHADER_STAGE_COMPUTE_BIT; - break; - default: - // TODO : Flag error - break; + case VK_SHADER_STAGE_COMPUTE_BIT: + this->active_shaders |= VK_SHADER_STAGE_COMPUTE_BIT; + break; + default: + // TODO : Flag error + break; } } }; @@ -572,13 +595,13 @@ struct GLOBAL_CB_NODE : public BASE_NODE { VkCommandBufferAllocateInfo createInfo; VkCommandBufferBeginInfo beginInfo; VkCommandBufferInheritanceInfo inheritanceInfo; - VkDevice device; // device this CB belongs to - uint64_t numCmds; // number of cmds in this CB - uint64_t drawCount[NUM_DRAW_TYPES]; // Count of each type of draw in this CB - CB_STATE state; // Track cmd buffer update state - uint64_t submitCount; // Number of times CB has been submitted - CBStatusFlags status; // Track status of various bindings on cmd buffer - CMD_TYPE last_cmd; // Last command written to the CB + VkDevice device; // device this CB belongs to + uint64_t numCmds; // number of cmds in this CB + uint64_t drawCount[NUM_DRAW_TYPES]; // Count of each type of draw in this CB + CB_STATE state; // Track cmd buffer update state + uint64_t submitCount; // Number of times CB has been submitted + CBStatusFlags status; // Track status of various bindings on cmd buffer + CMD_TYPE last_cmd; // Last command written to the CB // Currently storing "lastBound" objects on per-CB basis // long-term may want to create caches of "lastBound" states and could have // each individual CMD_NODE referencing its own "lastBound" state @@ -602,7 +625,7 @@ struct GLOBAL_CB_NODE : public BASE_NODE { std::vector writeEventsBeforeWait; std::vector events; std::unordered_map> waitedEventsBeforeQueryReset; - std::unordered_map queryToStateMap; // 0 is unavailable, 1 is available + std::unordered_map queryToStateMap; // 0 is unavailable, 1 is available std::unordered_set activeQueries; std::unordered_set startedQueries; std::unordered_map imageLayoutMap; @@ -610,7 +633,7 @@ struct GLOBAL_CB_NODE : public BASE_NODE { std::unordered_map eventToStageMap; std::vector drawData; DRAW_DATA currentDrawData; - bool vertex_buffer_used; // Track for perf warning to make sure any bound vtx buffer used + bool vertex_buffer_used; // Track for perf warning to make sure any bound vtx buffer used VkCommandBuffer primaryCommandBuffer; // Track images and buffers that are updated by this CB at the point of a draw std::unordered_set updateImages; @@ -671,4 +694,4 @@ void AddCommandBufferBindingBuffer(const layer_data *, GLOBAL_CB_NODE *, BUFFER_ void AddCommandBufferBindingBufferView(const layer_data *, GLOBAL_CB_NODE *, BUFFER_VIEW_STATE *); } -#endif // CORE_VALIDATION_TYPES_H_ +#endif // CORE_VALIDATION_TYPES_H_ diff --git a/layers/descriptor_sets.cpp b/layers/descriptor_sets.cpp index 6ad8dc0..f071fcd 100644 --- a/layers/descriptor_sets.cpp +++ b/layers/descriptor_sets.cpp @@ -37,11 +37,11 @@ cvdescriptorset::DescriptorSetLayout::DescriptorSetLayout(const VkDescriptorSetL for (uint32_t i = 0; i < binding_count_; ++i) { auto binding_num = p_create_info->pBindings[i].binding; descriptor_count_ += p_create_info->pBindings[i].descriptorCount; - uint32_t insert_index = 0; // Track vector index where we insert element + uint32_t insert_index = 0; // Track vector index where we insert element if (bindings_.empty() || binding_num > bindings_.back().binding) { bindings_.push_back(safe_VkDescriptorSetLayoutBinding(&p_create_info->pBindings[i])); insert_index = static_cast(bindings_.size()) - 1; - } else { // out-of-order binding number, need to insert into vector in-order + } else { // out-of-order binding number, need to insert into vector in-order auto it = bindings_.begin(); // Find currently binding's spot in vector while (binding_num > it->binding) { @@ -99,22 +99,20 @@ bool cvdescriptorset::DescriptorSetLayout::ValidateCreateInfo(debug_report_data // put all bindings into the given set void cvdescriptorset::DescriptorSetLayout::FillBindingSet(std::unordered_set *binding_set) const { - for (auto binding_index_pair : binding_to_index_map_) - binding_set->insert(binding_index_pair.first); + for (auto binding_index_pair : binding_to_index_map_) binding_set->insert(binding_index_pair.first); } -VkDescriptorSetLayoutBinding const * -cvdescriptorset::DescriptorSetLayout::GetDescriptorSetLayoutBindingPtrFromBinding(const uint32_t binding) const { +VkDescriptorSetLayoutBinding const *cvdescriptorset::DescriptorSetLayout::GetDescriptorSetLayoutBindingPtrFromBinding( + const uint32_t binding) const { const auto &bi_itr = binding_to_index_map_.find(binding); if (bi_itr != binding_to_index_map_.end()) { return bindings_[bi_itr->second].ptr(); } return nullptr; } -VkDescriptorSetLayoutBinding const * -cvdescriptorset::DescriptorSetLayout::GetDescriptorSetLayoutBindingPtrFromIndex(const uint32_t index) const { - if (index >= bindings_.size()) - return nullptr; +VkDescriptorSetLayoutBinding const *cvdescriptorset::DescriptorSetLayout::GetDescriptorSetLayoutBindingPtrFromIndex( + const uint32_t index) const { + if (index >= bindings_.size()) return nullptr; return bindings_[index].ptr(); } // Return descriptorCount for given binding, 0 if index is unavailable @@ -127,8 +125,7 @@ uint32_t cvdescriptorset::DescriptorSetLayout::GetDescriptorCountFromBinding(con } // Return descriptorCount for given index, 0 if index is unavailable uint32_t cvdescriptorset::DescriptorSetLayout::GetDescriptorCountFromIndex(const uint32_t index) const { - if (index >= bindings_.size()) - return 0; + if (index >= bindings_.size()) return 0; return bindings_[index].descriptorCount; } // For the given binding, return descriptorType @@ -151,10 +148,9 @@ VkDescriptorType cvdescriptorset::DescriptorSetLayout::GetTypeFromGlobalIndex(co uint32_t global_offset = 0; for (auto binding : bindings_) { global_offset += binding.descriptorCount; - if (index < global_offset) - return binding.descriptorType; + if (index < global_offset) return binding.descriptorType; } - assert(0); // requested global index is out of bounds + assert(0); // requested global index is out of bounds return VK_DESCRIPTOR_TYPE_MAX_ENUM; } // For the given binding, return stageFlags @@ -206,14 +202,13 @@ VkSampler const *cvdescriptorset::DescriptorSetLayout::GetImmutableSamplerPtrFro // else return false and fill in error_msg will description of what causes incompatibility bool cvdescriptorset::DescriptorSetLayout::IsCompatible(const DescriptorSetLayout *rh_ds_layout, std::string *error_msg) const { // Trivial case - if (layout_ == rh_ds_layout->GetDescriptorSetLayout()) - return true; + if (layout_ == rh_ds_layout->GetDescriptorSetLayout()) return true; if (descriptor_count_ != rh_ds_layout->descriptor_count_) { std::stringstream error_str; error_str << "DescriptorSetLayout " << layout_ << " has " << descriptor_count_ << " descriptors, but DescriptorSetLayout " << rh_ds_layout->GetDescriptorSetLayout() << " has " << rh_ds_layout->descriptor_count_ << " descriptors."; *error_msg = error_str.str(); - return false; // trivial fail case + return false; // trivial fail case } // Descriptor counts match so need to go through bindings one-by-one // and verify that type and stageFlags match @@ -250,8 +245,7 @@ bool cvdescriptorset::DescriptorSetLayout::IsCompatible(const DescriptorSetLayou } bool cvdescriptorset::DescriptorSetLayout::IsNextBindingConsistent(const uint32_t binding) const { - if (!binding_to_index_map_.count(binding + 1)) - return false; + if (!binding_to_index_map_.count(binding + 1)) return false; auto const &bi_itr = binding_to_index_map_.find(binding); if (bi_itr != binding_to_index_map_.end()) { const auto &next_bi_itr = binding_to_index_map_.find(binding + 1); @@ -288,7 +282,7 @@ bool cvdescriptorset::DescriptorSetLayout::VerifyUpdateConsistency(uint32_t curr binding_remaining = GetDescriptorCountFromBinding(++current_binding); } binding_remaining -= offset; - while (update_count > binding_remaining) { // While our updates overstep current binding + while (update_count > binding_remaining) { // While our updates overstep current binding // Verify next consecutive binding matches type, stage flags & immutable sampler use if (!IsNextBindingConsistent(current_binding++)) { std::stringstream error_str; @@ -316,48 +310,48 @@ cvdescriptorset::DescriptorSet::DescriptorSet(const VkDescriptorSet set, const V for (uint32_t i = 0; i < p_layout_->GetBindingCount(); ++i) { auto type = p_layout_->GetTypeFromIndex(i); switch (type) { - case VK_DESCRIPTOR_TYPE_SAMPLER: { - auto immut_sampler = p_layout_->GetImmutableSamplerPtrFromIndex(i); - for (uint32_t di = 0; di < p_layout_->GetDescriptorCountFromIndex(i); ++di) { - if (immut_sampler) - descriptors_.emplace_back(new SamplerDescriptor(immut_sampler + di)); - else - descriptors_.emplace_back(new SamplerDescriptor()); + case VK_DESCRIPTOR_TYPE_SAMPLER: { + auto immut_sampler = p_layout_->GetImmutableSamplerPtrFromIndex(i); + for (uint32_t di = 0; di < p_layout_->GetDescriptorCountFromIndex(i); ++di) { + if (immut_sampler) + descriptors_.emplace_back(new SamplerDescriptor(immut_sampler + di)); + else + descriptors_.emplace_back(new SamplerDescriptor()); + } + break; } - break; - } - case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER: { - auto immut = p_layout_->GetImmutableSamplerPtrFromIndex(i); - for (uint32_t di = 0; di < p_layout_->GetDescriptorCountFromIndex(i); ++di) { - if (immut) - descriptors_.emplace_back(new ImageSamplerDescriptor(immut + di)); - else - descriptors_.emplace_back(new ImageSamplerDescriptor()); + case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER: { + auto immut = p_layout_->GetImmutableSamplerPtrFromIndex(i); + for (uint32_t di = 0; di < p_layout_->GetDescriptorCountFromIndex(i); ++di) { + if (immut) + descriptors_.emplace_back(new ImageSamplerDescriptor(immut + di)); + else + descriptors_.emplace_back(new ImageSamplerDescriptor()); + } + break; } - break; - } - // ImageDescriptors - case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE: - case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT: - case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE: - for (uint32_t di = 0; di < p_layout_->GetDescriptorCountFromIndex(i); ++di) - descriptors_.emplace_back(new ImageDescriptor(type)); - break; - case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER: - case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER: - for (uint32_t di = 0; di < p_layout_->GetDescriptorCountFromIndex(i); ++di) - descriptors_.emplace_back(new TexelDescriptor(type)); - break; - case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER: - case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC: - case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER: - case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC: - for (uint32_t di = 0; di < p_layout_->GetDescriptorCountFromIndex(i); ++di) - descriptors_.emplace_back(new BufferDescriptor(type)); - break; - default: - assert(0); // Bad descriptor type specified - break; + // ImageDescriptors + case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE: + case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT: + case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE: + for (uint32_t di = 0; di < p_layout_->GetDescriptorCountFromIndex(i); ++di) + descriptors_.emplace_back(new ImageDescriptor(type)); + break; + case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER: + case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER: + for (uint32_t di = 0; di < p_layout_->GetDescriptorCountFromIndex(i); ++di) + descriptors_.emplace_back(new TexelDescriptor(type)); + break; + case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER: + case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC: + case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER: + case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC: + for (uint32_t di = 0; di < p_layout_->GetDescriptorCountFromIndex(i); ++di) + descriptors_.emplace_back(new BufferDescriptor(type)); + break; + default: + assert(0); // Bad descriptor type specified + break; } } } @@ -368,14 +362,12 @@ static std::string string_descriptor_req_view_type(descriptor_req req) { std::string result(""); for (unsigned i = 0; i <= VK_IMAGE_VIEW_TYPE_END_RANGE; i++) { if (req & (1 << i)) { - if (result.size()) - result += ", "; + if (result.size()) result += ", "; result += string_VkImageViewType(VkImageViewType(i)); } } - if (!result.size()) - result = "(none)"; + if (!result.size()) result = "(none)"; return result; } @@ -405,7 +397,7 @@ bool cvdescriptorset::DescriptorSet::ValidateDrawState(const std::mapGetGlobalEndIndexFromBinding(binding); - auto array_idx = 0; // Track array idx if we're dealing with array descriptors + auto array_idx = 0; // Track array idx if we're dealing with array descriptors for (uint32_t i = start_idx; i <= end_idx; ++i, ++array_idx) { if (!descriptors_[i]->updated) { std::stringstream error_str; @@ -579,8 +571,7 @@ void cvdescriptorset::DescriptorSet::PerformWriteUpdate(const VkWriteDescriptorS offset = 0; binding_being_updated++; } - if (update->descriptorCount) - some_update_ = true; + if (update->descriptorCount) some_update_ = true; InvalidateBoundCmdBuffers(); } @@ -670,8 +661,7 @@ bool cvdescriptorset::DescriptorSet::ValidateCopyUpdate(const debug_report_data } } // Update parameters all look good and descriptor updated so verify update contents - if (!VerifyCopyUpdateContents(update, src_set, src_type, src_start_idx, error_code, error_msg)) - return false; + if (!VerifyCopyUpdateContents(update, src_set, src_type, src_start_idx, error_code, error_msg)) return false; // All checks passed so update is good return true; @@ -684,8 +674,7 @@ void cvdescriptorset::DescriptorSet::PerformCopyUpdate(const VkCopyDescriptorSet for (uint32_t di = 0; di < update->descriptorCount; ++di) { descriptors_[dst_start_idx + di]->CopyUpdate(src_set->descriptors_[src_start_idx + di].get()); } - if (update->descriptorCount) - some_update_ = true; + if (update->descriptorCount) some_update_ = true; InvalidateBoundCmdBuffers(); } @@ -785,72 +774,72 @@ bool cvdescriptorset::ValidateImageUpdate(VkImageView image_view, VkImageLayout // vkCreateImageView(). What's the best way to create unique id for these cases? bool ds = vk_format_is_depth_or_stencil(format); switch (image_layout) { - case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL: - // Only Color bit must be set - if ((aspect_mask & VK_IMAGE_ASPECT_COLOR_BIT) != VK_IMAGE_ASPECT_COLOR_BIT) { - std::stringstream error_str; - error_str << "ImageView (" << image_view << ") uses layout VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL but does " - "not have VK_IMAGE_ASPECT_COLOR_BIT set."; - *error_msg = error_str.str(); - return false; - } - // format must NOT be DS - if (ds) { - std::stringstream error_str; - error_str << "ImageView (" << image_view - << ") uses layout VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL but the image format is " - << string_VkFormat(format) << " which is not a color format."; - *error_msg = error_str.str(); - return false; - } - break; - case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL: - case VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL: - // Depth or stencil bit must be set, but both must NOT be set - if (aspect_mask & VK_IMAGE_ASPECT_DEPTH_BIT) { - if (aspect_mask & VK_IMAGE_ASPECT_STENCIL_BIT) { - // both must NOT be set + case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL: + // Only Color bit must be set + if ((aspect_mask & VK_IMAGE_ASPECT_COLOR_BIT) != VK_IMAGE_ASPECT_COLOR_BIT) { std::stringstream error_str; - error_str << "ImageView (" << image_view << ") has both STENCIL and DEPTH aspects set"; + error_str << "ImageView (" << image_view << ") uses layout VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL but does " + "not have VK_IMAGE_ASPECT_COLOR_BIT set."; *error_msg = error_str.str(); return false; } - } else if (!(aspect_mask & VK_IMAGE_ASPECT_STENCIL_BIT)) { - // Neither were set - std::stringstream error_str; - error_str << "ImageView (" << image_view << ") has layout " << string_VkImageLayout(image_layout) - << " but does not have STENCIL or DEPTH aspects set"; - *error_msg = error_str.str(); - return false; - } - // format must be DS - if (!ds) { - std::stringstream error_str; - error_str << "ImageView (" << image_view << ") has layout " << string_VkImageLayout(image_layout) - << " but the image format is " << string_VkFormat(format) << " which is not a depth/stencil format."; - *error_msg = error_str.str(); - return false; - } - break; - default: - // For other layouts if the source is depth/stencil image, both aspect bits must not be set - if (ds) { + // format must NOT be DS + if (ds) { + std::stringstream error_str; + error_str << "ImageView (" << image_view + << ") uses layout VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL but the image format is " + << string_VkFormat(format) << " which is not a color format."; + *error_msg = error_str.str(); + return false; + } + break; + case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL: + case VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL: + // Depth or stencil bit must be set, but both must NOT be set if (aspect_mask & VK_IMAGE_ASPECT_DEPTH_BIT) { if (aspect_mask & VK_IMAGE_ASPECT_STENCIL_BIT) { // both must NOT be set std::stringstream error_str; - error_str << "ImageView (" << image_view << ") has layout " << string_VkImageLayout(image_layout) - << " and is using depth/stencil image of format " << string_VkFormat(format) - << " but it has both STENCIL and DEPTH aspects set, which is illegal. When using a depth/stencil " - "image in a descriptor set, please only set either VK_IMAGE_ASPECT_DEPTH_BIT or " - "VK_IMAGE_ASPECT_STENCIL_BIT depending on whether it will be used for depth reads or stencil " - "reads respectively."; + error_str << "ImageView (" << image_view << ") has both STENCIL and DEPTH aspects set"; *error_msg = error_str.str(); return false; } + } else if (!(aspect_mask & VK_IMAGE_ASPECT_STENCIL_BIT)) { + // Neither were set + std::stringstream error_str; + error_str << "ImageView (" << image_view << ") has layout " << string_VkImageLayout(image_layout) + << " but does not have STENCIL or DEPTH aspects set"; + *error_msg = error_str.str(); + return false; } - } - break; + // format must be DS + if (!ds) { + std::stringstream error_str; + error_str << "ImageView (" << image_view << ") has layout " << string_VkImageLayout(image_layout) + << " but the image format is " << string_VkFormat(format) << " which is not a depth/stencil format."; + *error_msg = error_str.str(); + return false; + } + break; + default: + // For other layouts if the source is depth/stencil image, both aspect bits must not be set + if (ds) { + if (aspect_mask & VK_IMAGE_ASPECT_DEPTH_BIT) { + if (aspect_mask & VK_IMAGE_ASPECT_STENCIL_BIT) { + // both must NOT be set + std::stringstream error_str; + error_str << "ImageView (" << image_view << ") has layout " << string_VkImageLayout(image_layout) + << " and is using depth/stencil image of format " << string_VkFormat(format) + << " but it has both STENCIL and DEPTH aspects set, which is illegal. When using a depth/stencil " + "image in a descriptor set, please only set either VK_IMAGE_ASPECT_DEPTH_BIT or " + "VK_IMAGE_ASPECT_STENCIL_BIT depending on whether it will be used for depth reads or stencil " + "reads respectively."; + *error_msg = error_str.str(); + return false; + } + } + } + break; } // Now validate that usage flags are correctly set for given type of update // As we're switching per-type, if any type has specific layout requirements, check those here as well @@ -860,36 +849,37 @@ bool cvdescriptorset::ValidateImageUpdate(VkImageView image_view, VkImageLayout // identify swizzle std::string error_usage_bit; switch (type) { - case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE: - case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER: { - if (!(usage & VK_IMAGE_USAGE_SAMPLED_BIT)) { - error_usage_bit = "VK_IMAGE_USAGE_SAMPLED_BIT"; + case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE: + case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER: { + if (!(usage & VK_IMAGE_USAGE_SAMPLED_BIT)) { + error_usage_bit = "VK_IMAGE_USAGE_SAMPLED_BIT"; + } + break; } - break; - } - case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE: { - if (!(usage & VK_IMAGE_USAGE_STORAGE_BIT)) { - error_usage_bit = "VK_IMAGE_USAGE_STORAGE_BIT"; - } else if (VK_IMAGE_LAYOUT_GENERAL != image_layout) { - std::stringstream error_str; - // TODO : Need to create custom enum error code for this case - error_str << "ImageView (" << image_view << ") of VK_DESCRIPTOR_TYPE_STORAGE_IMAGE type is being updated with layout " - << string_VkImageLayout(image_layout) - << " but according to spec section 13.1 Descriptor Types, 'Load and store operations on storage images can " - "only be done on images in VK_IMAGE_LAYOUT_GENERAL layout.'"; - *error_msg = error_str.str(); - return false; + case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE: { + if (!(usage & VK_IMAGE_USAGE_STORAGE_BIT)) { + error_usage_bit = "VK_IMAGE_USAGE_STORAGE_BIT"; + } else if (VK_IMAGE_LAYOUT_GENERAL != image_layout) { + std::stringstream error_str; + // TODO : Need to create custom enum error code for this case + error_str + << "ImageView (" << image_view << ") of VK_DESCRIPTOR_TYPE_STORAGE_IMAGE type is being updated with layout " + << string_VkImageLayout(image_layout) + << " but according to spec section 13.1 Descriptor Types, 'Load and store operations on storage images can " + "only be done on images in VK_IMAGE_LAYOUT_GENERAL layout.'"; + *error_msg = error_str.str(); + return false; + } + break; } - break; - } - case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT: { - if (!(usage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT)) { - error_usage_bit = "VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT"; + case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT: { + if (!(usage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT)) { + error_usage_bit = "VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT"; + } + break; } - break; - } - default: - break; + default: + break; } if (!error_usage_bit.empty()) { std::stringstream error_str; @@ -918,8 +908,7 @@ void cvdescriptorset::SamplerDescriptor::CopyUpdate(const Descriptor *src) { void cvdescriptorset::SamplerDescriptor::BindCommandBuffer(const core_validation::layer_data *dev_data, GLOBAL_CB_NODE *cb_node) { if (!immutable_) { auto sampler_state = getSamplerState(dev_data, sampler_); - if (sampler_state) - core_validation::AddCommandBufferBindingSampler(cb_node, sampler_state); + if (sampler_state) core_validation::AddCommandBufferBindingSampler(cb_node, sampler_state); } } @@ -965,8 +954,7 @@ void cvdescriptorset::ImageSamplerDescriptor::BindCommandBuffer(const core_valid // First add binding for any non-immutable sampler if (!immutable_) { auto sampler_state = getSamplerState(dev_data, sampler_); - if (sampler_state) - core_validation::AddCommandBufferBindingSampler(cb_node, sampler_state); + if (sampler_state) core_validation::AddCommandBufferBindingSampler(cb_node, sampler_state); } // Add binding for image auto iv_state = getImageViewState(dev_data, image_view_); @@ -979,8 +967,7 @@ cvdescriptorset::ImageDescriptor::ImageDescriptor(const VkDescriptorType type) : storage_(false), image_view_(VK_NULL_HANDLE), image_layout_(VK_IMAGE_LAYOUT_UNDEFINED) { updated = false; descriptor_class = Image; - if (VK_DESCRIPTOR_TYPE_STORAGE_IMAGE == type) - storage_ = true; + if (VK_DESCRIPTOR_TYPE_STORAGE_IMAGE == type) storage_ = true; }; void cvdescriptorset::ImageDescriptor::WriteUpdate(const VkWriteDescriptorSet *update, const uint32_t index) { @@ -1037,15 +1024,13 @@ void cvdescriptorset::BufferDescriptor::CopyUpdate(const Descriptor *src) { void cvdescriptorset::BufferDescriptor::BindCommandBuffer(const core_validation::layer_data *dev_data, GLOBAL_CB_NODE *cb_node) { auto buffer_node = getBufferState(dev_data, buffer_); - if (buffer_node) - core_validation::AddCommandBufferBindingBuffer(dev_data, cb_node, buffer_node); + if (buffer_node) core_validation::AddCommandBufferBindingBuffer(dev_data, cb_node, buffer_node); } cvdescriptorset::TexelDescriptor::TexelDescriptor(const VkDescriptorType type) : buffer_view_(VK_NULL_HANDLE), storage_(false) { updated = false; descriptor_class = TexelBuffer; - if (VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER == type) - storage_ = true; + if (VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER == type) storage_ = true; }; void cvdescriptorset::TexelDescriptor::WriteUpdate(const VkWriteDescriptorSet *update, const uint32_t index) { @@ -1227,34 +1212,34 @@ bool cvdescriptorset::DescriptorSet::ValidateBufferUsage(BUFFER_STATE const *buf auto usage = buffer_node->createInfo.usage; std::string error_usage_bit; switch (type) { - case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER: - if (!(usage & VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT)) { - *error_code = VALIDATION_ERROR_00950; - error_usage_bit = "VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT"; - } - break; - case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER: - if (!(usage & VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT)) { - *error_code = VALIDATION_ERROR_00951; - error_usage_bit = "VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT"; - } - break; - case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER: - case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC: - if (!(usage & VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT)) { - *error_code = VALIDATION_ERROR_00946; - error_usage_bit = "VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT"; - } - break; - case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER: - case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC: - if (!(usage & VK_BUFFER_USAGE_STORAGE_BUFFER_BIT)) { - *error_code = VALIDATION_ERROR_00947; - error_usage_bit = "VK_BUFFER_USAGE_STORAGE_BUFFER_BIT"; - } - break; - default: - break; + case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER: + if (!(usage & VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT)) { + *error_code = VALIDATION_ERROR_00950; + error_usage_bit = "VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT"; + } + break; + case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER: + if (!(usage & VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT)) { + *error_code = VALIDATION_ERROR_00951; + error_usage_bit = "VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT"; + } + break; + case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER: + case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC: + if (!(usage & VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT)) { + *error_code = VALIDATION_ERROR_00946; + error_usage_bit = "VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT"; + } + break; + case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER: + case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC: + if (!(usage & VK_BUFFER_USAGE_STORAGE_BUFFER_BIT)) { + *error_code = VALIDATION_ERROR_00947; + error_usage_bit = "VK_BUFFER_USAGE_STORAGE_BUFFER_BIT"; + } + break; + default: + break; } if (!error_usage_bit.empty()) { std::stringstream error_str; @@ -1326,91 +1311,92 @@ bool cvdescriptorset::DescriptorSet::VerifyWriteUpdateContents(const VkWriteDesc UNIQUE_VALIDATION_ERROR_CODE *error_code, std::string *error_msg) const { switch (update->descriptorType) { - case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER: { - for (uint32_t di = 0; di < update->descriptorCount; ++di) { - // Validate image - auto image_view = update->pImageInfo[di].imageView; - auto image_layout = update->pImageInfo[di].imageLayout; - if (!ValidateImageUpdate(image_view, image_layout, update->descriptorType, device_data_, error_code, error_msg)) { - std::stringstream error_str; - error_str << "Attempted write update to combined image sampler descriptor failed due to: " << error_msg->c_str(); - *error_msg = error_str.str(); - return false; - } - } - // Intentional fall-through to validate sampler - } - case VK_DESCRIPTOR_TYPE_SAMPLER: { - for (uint32_t di = 0; di < update->descriptorCount; ++di) { - if (!descriptors_[index + di].get()->IsImmutableSampler()) { - if (!ValidateSampler(update->pImageInfo[di].sampler, device_data_)) { - *error_code = VALIDATION_ERROR_00942; + case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER: { + for (uint32_t di = 0; di < update->descriptorCount; ++di) { + // Validate image + auto image_view = update->pImageInfo[di].imageView; + auto image_layout = update->pImageInfo[di].imageLayout; + if (!ValidateImageUpdate(image_view, image_layout, update->descriptorType, device_data_, error_code, error_msg)) { std::stringstream error_str; - error_str << "Attempted write update to sampler descriptor with invalid sampler: " - << update->pImageInfo[di].sampler << "."; + error_str << "Attempted write update to combined image sampler descriptor failed due to: " + << error_msg->c_str(); *error_msg = error_str.str(); return false; } - } else { - // TODO : Warn here } + // Intentional fall-through to validate sampler } - break; - } - case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE: - case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT: - case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE: { - for (uint32_t di = 0; di < update->descriptorCount; ++di) { - auto image_view = update->pImageInfo[di].imageView; - auto image_layout = update->pImageInfo[di].imageLayout; - if (!ValidateImageUpdate(image_view, image_layout, update->descriptorType, device_data_, error_code, error_msg)) { - std::stringstream error_str; - error_str << "Attempted write update to image descriptor failed due to: " << error_msg->c_str(); - *error_msg = error_str.str(); - return false; + case VK_DESCRIPTOR_TYPE_SAMPLER: { + for (uint32_t di = 0; di < update->descriptorCount; ++di) { + if (!descriptors_[index + di].get()->IsImmutableSampler()) { + if (!ValidateSampler(update->pImageInfo[di].sampler, device_data_)) { + *error_code = VALIDATION_ERROR_00942; + std::stringstream error_str; + error_str << "Attempted write update to sampler descriptor with invalid sampler: " + << update->pImageInfo[di].sampler << "."; + *error_msg = error_str.str(); + return false; + } + } else { + // TODO : Warn here + } } + break; } - break; - } - case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER: - case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER: { - for (uint32_t di = 0; di < update->descriptorCount; ++di) { - auto buffer_view = update->pTexelBufferView[di]; - auto bv_state = getBufferViewState(device_data_, buffer_view); - if (!bv_state) { - *error_code = VALIDATION_ERROR_00940; - std::stringstream error_str; - error_str << "Attempted write update to texel buffer descriptor with invalid buffer view: " << buffer_view; - *error_msg = error_str.str(); - return false; + case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE: + case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT: + case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE: { + for (uint32_t di = 0; di < update->descriptorCount; ++di) { + auto image_view = update->pImageInfo[di].imageView; + auto image_layout = update->pImageInfo[di].imageLayout; + if (!ValidateImageUpdate(image_view, image_layout, update->descriptorType, device_data_, error_code, error_msg)) { + std::stringstream error_str; + error_str << "Attempted write update to image descriptor failed due to: " << error_msg->c_str(); + *error_msg = error_str.str(); + return false; + } } - auto buffer = bv_state->create_info.buffer; - if (!ValidateBufferUsage(getBufferState(device_data_, buffer), update->descriptorType, error_code, error_msg)) { - std::stringstream error_str; - error_str << "Attempted write update to texel buffer descriptor failed due to: " << error_msg->c_str(); - *error_msg = error_str.str(); - return false; + break; + } + case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER: + case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER: { + for (uint32_t di = 0; di < update->descriptorCount; ++di) { + auto buffer_view = update->pTexelBufferView[di]; + auto bv_state = getBufferViewState(device_data_, buffer_view); + if (!bv_state) { + *error_code = VALIDATION_ERROR_00940; + std::stringstream error_str; + error_str << "Attempted write update to texel buffer descriptor with invalid buffer view: " << buffer_view; + *error_msg = error_str.str(); + return false; + } + auto buffer = bv_state->create_info.buffer; + if (!ValidateBufferUsage(getBufferState(device_data_, buffer), update->descriptorType, error_code, error_msg)) { + std::stringstream error_str; + error_str << "Attempted write update to texel buffer descriptor failed due to: " << error_msg->c_str(); + *error_msg = error_str.str(); + return false; + } } + break; } - break; - } - case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER: - case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC: - case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER: - case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC: { - for (uint32_t di = 0; di < update->descriptorCount; ++di) { - if (!ValidateBufferUpdate(update->pBufferInfo + di, update->descriptorType, error_code, error_msg)) { - std::stringstream error_str; - error_str << "Attempted write update to buffer descriptor failed due to: " << error_msg->c_str(); - *error_msg = error_str.str(); - return false; + case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER: + case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC: + case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER: + case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC: { + for (uint32_t di = 0; di < update->descriptorCount; ++di) { + if (!ValidateBufferUpdate(update->pBufferInfo + di, update->descriptorType, error_code, error_msg)) { + std::stringstream error_str; + error_str << "Attempted write update to buffer descriptor failed due to: " << error_msg->c_str(); + *error_msg = error_str.str(); + return false; + } } + break; } - break; - } - default: - assert(0); // We've already verified update type so should never get here - break; + default: + assert(0); // We've already verified update type so should never get here + break; } // All checks passed so update contents are good return true; @@ -1423,101 +1409,101 @@ bool cvdescriptorset::DescriptorSet::VerifyCopyUpdateContents(const VkCopyDescri // Note : Repurposing some Write update error codes here as specific details aren't called out for copy updates like they are // for write updates switch (src_set->descriptors_[index]->descriptor_class) { - case PlainSampler: { - for (uint32_t di = 0; di < update->descriptorCount; ++di) { - if (!src_set->descriptors_[index + di]->IsImmutableSampler()) { - auto update_sampler = static_cast(src_set->descriptors_[index + di].get())->GetSampler(); - if (!ValidateSampler(update_sampler, device_data_)) { - *error_code = VALIDATION_ERROR_00942; + case PlainSampler: { + for (uint32_t di = 0; di < update->descriptorCount; ++di) { + if (!src_set->descriptors_[index + di]->IsImmutableSampler()) { + auto update_sampler = static_cast(src_set->descriptors_[index + di].get())->GetSampler(); + if (!ValidateSampler(update_sampler, device_data_)) { + *error_code = VALIDATION_ERROR_00942; + std::stringstream error_str; + error_str << "Attempted copy update to sampler descriptor with invalid sampler: " << update_sampler << "."; + *error_msg = error_str.str(); + return false; + } + } else { + // TODO : Warn here + } + } + break; + } + case ImageSampler: { + for (uint32_t di = 0; di < update->descriptorCount; ++di) { + auto img_samp_desc = static_cast(src_set->descriptors_[index + di].get()); + // First validate sampler + if (!img_samp_desc->IsImmutableSampler()) { + auto update_sampler = img_samp_desc->GetSampler(); + if (!ValidateSampler(update_sampler, device_data_)) { + *error_code = VALIDATION_ERROR_00942; + std::stringstream error_str; + error_str << "Attempted copy update to sampler descriptor with invalid sampler: " << update_sampler << "."; + *error_msg = error_str.str(); + return false; + } + } else { + // TODO : Warn here + } + // Validate image + auto image_view = img_samp_desc->GetImageView(); + auto image_layout = img_samp_desc->GetImageLayout(); + if (!ValidateImageUpdate(image_view, image_layout, type, device_data_, error_code, error_msg)) { std::stringstream error_str; - error_str << "Attempted copy update to sampler descriptor with invalid sampler: " << update_sampler << "."; + error_str << "Attempted copy update to combined image sampler descriptor failed due to: " << error_msg->c_str(); *error_msg = error_str.str(); return false; } - } else { - // TODO : Warn here } + break; } - break; - } - case ImageSampler: { - for (uint32_t di = 0; di < update->descriptorCount; ++di) { - auto img_samp_desc = static_cast(src_set->descriptors_[index + di].get()); - // First validate sampler - if (!img_samp_desc->IsImmutableSampler()) { - auto update_sampler = img_samp_desc->GetSampler(); - if (!ValidateSampler(update_sampler, device_data_)) { - *error_code = VALIDATION_ERROR_00942; + case Image: { + for (uint32_t di = 0; di < update->descriptorCount; ++di) { + auto img_desc = static_cast(src_set->descriptors_[index + di].get()); + auto image_view = img_desc->GetImageView(); + auto image_layout = img_desc->GetImageLayout(); + if (!ValidateImageUpdate(image_view, image_layout, type, device_data_, error_code, error_msg)) { std::stringstream error_str; - error_str << "Attempted copy update to sampler descriptor with invalid sampler: " << update_sampler << "."; + error_str << "Attempted copy update to image descriptor failed due to: " << error_msg->c_str(); *error_msg = error_str.str(); return false; } - } else { - // TODO : Warn here - } - // Validate image - auto image_view = img_samp_desc->GetImageView(); - auto image_layout = img_samp_desc->GetImageLayout(); - if (!ValidateImageUpdate(image_view, image_layout, type, device_data_, error_code, error_msg)) { - std::stringstream error_str; - error_str << "Attempted copy update to combined image sampler descriptor failed due to: " << error_msg->c_str(); - *error_msg = error_str.str(); - return false; - } - } - break; - } - case Image: { - for (uint32_t di = 0; di < update->descriptorCount; ++di) { - auto img_desc = static_cast(src_set->descriptors_[index + di].get()); - auto image_view = img_desc->GetImageView(); - auto image_layout = img_desc->GetImageLayout(); - if (!ValidateImageUpdate(image_view, image_layout, type, device_data_, error_code, error_msg)) { - std::stringstream error_str; - error_str << "Attempted copy update to image descriptor failed due to: " << error_msg->c_str(); - *error_msg = error_str.str(); - return false; } + break; } - break; - } - case TexelBuffer: { - for (uint32_t di = 0; di < update->descriptorCount; ++di) { - auto buffer_view = static_cast(src_set->descriptors_[index + di].get())->GetBufferView(); - auto bv_state = getBufferViewState(device_data_, buffer_view); - if (!bv_state) { - *error_code = VALIDATION_ERROR_00940; - std::stringstream error_str; - error_str << "Attempted copy update to texel buffer descriptor with invalid buffer view: " << buffer_view; - *error_msg = error_str.str(); - return false; - } - auto buffer = bv_state->create_info.buffer; - if (!ValidateBufferUsage(getBufferState(device_data_, buffer), type, error_code, error_msg)) { - std::stringstream error_str; - error_str << "Attempted copy update to texel buffer descriptor failed due to: " << error_msg->c_str(); - *error_msg = error_str.str(); - return false; + case TexelBuffer: { + for (uint32_t di = 0; di < update->descriptorCount; ++di) { + auto buffer_view = static_cast(src_set->descriptors_[index + di].get())->GetBufferView(); + auto bv_state = getBufferViewState(device_data_, buffer_view); + if (!bv_state) { + *error_code = VALIDATION_ERROR_00940; + std::stringstream error_str; + error_str << "Attempted copy update to texel buffer descriptor with invalid buffer view: " << buffer_view; + *error_msg = error_str.str(); + return false; + } + auto buffer = bv_state->create_info.buffer; + if (!ValidateBufferUsage(getBufferState(device_data_, buffer), type, error_code, error_msg)) { + std::stringstream error_str; + error_str << "Attempted copy update to texel buffer descriptor failed due to: " << error_msg->c_str(); + *error_msg = error_str.str(); + return false; + } } + break; } - break; - } - case GeneralBuffer: { - for (uint32_t di = 0; di < update->descriptorCount; ++di) { - auto buffer = static_cast(src_set->descriptors_[index + di].get())->GetBuffer(); - if (!ValidateBufferUsage(getBufferState(device_data_, buffer), type, error_code, error_msg)) { - std::stringstream error_str; - error_str << "Attempted copy update to buffer descriptor failed due to: " << error_msg->c_str(); - *error_msg = error_str.str(); - return false; + case GeneralBuffer: { + for (uint32_t di = 0; di < update->descriptorCount; ++di) { + auto buffer = static_cast(src_set->descriptors_[index + di].get())->GetBuffer(); + if (!ValidateBufferUsage(getBufferState(device_data_, buffer), type, error_code, error_msg)) { + std::stringstream error_str; + error_str << "Attempted copy update to buffer descriptor failed due to: " << error_msg->c_str(); + *error_msg = error_str.str(); + return false; + } } + break; } - break; - } - default: - assert(0); // We've already verified update type so should never get here - break; + default: + assert(0); // We've already verified update type so should never get here + break; } // All checks passed so update contents are good return true; diff --git a/layers/descriptor_sets.h b/layers/descriptor_sets.h index 055985a..c51b373 100644 --- a/layers/descriptor_sets.h +++ b/layers/descriptor_sets.h @@ -90,7 +90,7 @@ */ namespace cvdescriptorset { class DescriptorSetLayout { - public: + public: // Constructors and destructor DescriptorSetLayout(const VkDescriptorSetLayoutCreateInfo *p_create_info, const VkDescriptorSetLayout layout); // Validate create info - should be called prior to creation @@ -126,7 +126,7 @@ class DescriptorSetLayout { int32_t GetDynamicOffsetIndexFromBinding(uint32_t binding) const { auto dyn_off = binding_to_dynamic_array_idx_map_.find(binding); if (dyn_off == binding_to_dynamic_array_idx_map_.end()) { - assert(0); // Requesting dyn offset for invalid binding/array idx pair + assert(0); // Requesting dyn offset for invalid binding/array idx pair return -1; } return dyn_off->second; @@ -139,7 +139,7 @@ class DescriptorSetLayout { // updated, verify that for any binding boundaries crossed, the update is consistent bool VerifyUpdateConsistency(uint32_t, uint32_t, uint32_t, const char *, const VkDescriptorSet, std::string *) const; - private: + private: VkDescriptorSetLayout layout_; std::map binding_to_index_map_; std::unordered_map binding_to_global_start_index_map_; @@ -147,9 +147,9 @@ class DescriptorSetLayout { // For a given binding map to associated index in the dynamic offset array std::unordered_map binding_to_dynamic_array_idx_map_; // VkDescriptorSetLayoutCreateFlags flags_; - uint32_t binding_count_; // # of bindings in this layout + uint32_t binding_count_; // # of bindings in this layout std::vector bindings_; - uint32_t descriptor_count_; // total # descriptors in this layout + uint32_t descriptor_count_; // total # descriptors in this layout uint32_t dynamic_descriptor_count_; }; @@ -164,7 +164,7 @@ class DescriptorSetLayout { enum DescriptorClass { PlainSampler, ImageSampler, Image, TexelBuffer, GeneralBuffer }; class Descriptor { - public: + public: virtual ~Descriptor(){}; virtual void WriteUpdate(const VkWriteDescriptorSet *, const uint32_t) = 0; virtual void CopyUpdate(const Descriptor *) = 0; @@ -177,7 +177,7 @@ class Descriptor { virtual bool IsDynamic() const { return false; }; // Check for storage descriptor type virtual bool IsStorage() const { return false; }; - bool updated; // Has descriptor been updated? + bool updated; // Has descriptor been updated? DescriptorClass descriptor_class; }; // Shared helper functions - These are useful because the shared sampler image descriptor type @@ -187,7 +187,7 @@ bool ValidateImageUpdate(VkImageView, VkImageLayout, VkDescriptorType, const cor UNIQUE_VALIDATION_ERROR_CODE *, std::string *); class SamplerDescriptor : public Descriptor { - public: + public: SamplerDescriptor(); SamplerDescriptor(const VkSampler *); void WriteUpdate(const VkWriteDescriptorSet *, const uint32_t) override; @@ -196,14 +196,14 @@ class SamplerDescriptor : public Descriptor { virtual bool IsImmutableSampler() const override { return immutable_; }; VkSampler GetSampler() const { return sampler_; } - private: + private: // bool ValidateSampler(const VkSampler) const; VkSampler sampler_; bool immutable_; }; class ImageSamplerDescriptor : public Descriptor { - public: + public: ImageSamplerDescriptor(); ImageSamplerDescriptor(const VkSampler *); void WriteUpdate(const VkWriteDescriptorSet *, const uint32_t) override; @@ -214,7 +214,7 @@ class ImageSamplerDescriptor : public Descriptor { VkImageView GetImageView() const { return image_view_; } VkImageLayout GetImageLayout() const { return image_layout_; } - private: + private: VkSampler sampler_; bool immutable_; VkImageView image_view_; @@ -222,7 +222,7 @@ class ImageSamplerDescriptor : public Descriptor { }; class ImageDescriptor : public Descriptor { - public: + public: ImageDescriptor(const VkDescriptorType); void WriteUpdate(const VkWriteDescriptorSet *, const uint32_t) override; void CopyUpdate(const Descriptor *) override; @@ -231,14 +231,14 @@ class ImageDescriptor : public Descriptor { VkImageView GetImageView() const { return image_view_; } VkImageLayout GetImageLayout() const { return image_layout_; } - private: + private: bool storage_; VkImageView image_view_; VkImageLayout image_layout_; }; class TexelDescriptor : public Descriptor { - public: + public: TexelDescriptor(const VkDescriptorType); void WriteUpdate(const VkWriteDescriptorSet *, const uint32_t) override; void CopyUpdate(const Descriptor *) override; @@ -246,13 +246,13 @@ class TexelDescriptor : public Descriptor { virtual bool IsStorage() const override { return storage_; } VkBufferView GetBufferView() const { return buffer_view_; } - private: + private: VkBufferView buffer_view_; bool storage_; }; class BufferDescriptor : public Descriptor { - public: + public: BufferDescriptor(const VkDescriptorType); void WriteUpdate(const VkWriteDescriptorSet *, const uint32_t) override; void CopyUpdate(const Descriptor *) override; @@ -263,7 +263,7 @@ class BufferDescriptor : public Descriptor { VkDeviceSize GetOffset() const { return offset_; } VkDeviceSize GetRange() const { return range_; } - private: + private: bool storage_; bool dynamic_; VkBuffer buffer_; @@ -311,7 +311,7 @@ void PerformAllocateDescriptorSets(const VkDescriptorSetAllocateInfo *, const Vk * be correct at the time of update. */ class DescriptorSet : public BASE_NODE { - public: + public: DescriptorSet(const VkDescriptorSet, const VkDescriptorPool, const DescriptorSetLayout *, const core_validation::layer_data *); ~DescriptorSet(); // A number of common Get* functions that return data based on layout from which this set was created @@ -381,7 +381,7 @@ class DescriptorSet : public BASE_NODE { // Return true if any part of set has ever been updated bool IsUpdated() const { return some_update_; }; - private: + private: bool VerifyWriteUpdateContents(const VkWriteDescriptorSet *, const uint32_t, UNIQUE_VALIDATION_ERROR_CODE *, std::string *) const; bool VerifyCopyUpdateContents(const VkCopyDescriptorSet *, const DescriptorSet *, VkDescriptorType, uint32_t, @@ -391,7 +391,7 @@ class DescriptorSet : public BASE_NODE { std::string *) const; // Private helper to set all bound cmd buffers to INVALID state void InvalidateBoundCmdBuffers(); - bool some_update_; // has any part of the set ever been updated? + bool some_update_; // has any part of the set ever been updated? VkDescriptorSet set_; DESCRIPTOR_POOL_STATE *pool_state_; const DescriptorSetLayout *p_layout_; @@ -400,4 +400,4 @@ class DescriptorSet : public BASE_NODE { const core_validation::layer_data *device_data_; }; } -#endif // CORE_VALIDATION_DESCRIPTOR_SETS_H_ +#endif // CORE_VALIDATION_DESCRIPTOR_SETS_H_ diff --git a/layers/image.cpp b/layers/image.cpp index 08c9b0a..c82c0ac 100644 --- a/layers/image.cpp +++ b/layers/image.cpp @@ -68,7 +68,10 @@ struct layer_data { unordered_map imageMap; layer_data() - : report_data(nullptr), device_dispatch_table(nullptr), instance_dispatch_table(nullptr), physicalDevice(0), + : report_data(nullptr), + device_dispatch_table(nullptr), + instance_dispatch_table(nullptr), + physicalDevice(0), physicalDeviceProperties(){}; }; @@ -131,8 +134,7 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateInstance(const VkInstanceCreateInfo *pCreat chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext; VkResult result = fpCreateInstance(pCreateInfo, pAllocator, pInstance); - if (result != VK_SUCCESS) - return result; + if (result != VK_SUCCESS) return result; layer_data *my_data = get_my_data_ptr(get_dispatch_key(*pInstance), layer_data_map); my_data->instance = *pInstance; @@ -307,23 +309,23 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateImage(VkDevice device, const VkImageCreateI // Make sure all required dimension are non-zero at least. bool failedMinSize = false; switch (pCreateInfo->imageType) { - case VK_IMAGE_TYPE_3D: - if (pCreateInfo->extent.depth == 0) { - failedMinSize = true; - } - // Intentional fall-through - case VK_IMAGE_TYPE_2D: - if (pCreateInfo->extent.height == 0) { - failedMinSize = true; - } - // Intentional fall-through - case VK_IMAGE_TYPE_1D: - if (pCreateInfo->extent.width == 0) { - failedMinSize = true; - } - break; - default: - break; + case VK_IMAGE_TYPE_3D: + if (pCreateInfo->extent.depth == 0) { + failedMinSize = true; + } + // Intentional fall-through + case VK_IMAGE_TYPE_2D: + if (pCreateInfo->extent.height == 0) { + failedMinSize = true; + } + // Intentional fall-through + case VK_IMAGE_TYPE_1D: + if (pCreateInfo->extent.width == 0) { + failedMinSize = true; + } + break; + default: + break; } // TODO: VALIDATION_ERROR_00716 // this is *almost* VU 00716, except should not be condidtional on image type - all extents must be non-zero for all types @@ -490,8 +492,9 @@ VKAPI_ATTR void VKAPI_CALL CmdClearDepthStencilImage(VkCommandBuffer commandBuff for (uint32_t i = 0; i < rangeCount; i++) { if (((pRanges[i].aspectMask & VK_IMAGE_ASPECT_DEPTH_BIT) != VK_IMAGE_ASPECT_DEPTH_BIT) && ((pRanges[i].aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT) != VK_IMAGE_ASPECT_STENCIL_BIT)) { - char const str[] = "vkCmdClearDepthStencilImage aspectMasks for all subresource ranges must be " - "set to VK_IMAGE_ASPECT_DEPTH_BIT and/or VK_IMAGE_ASPECT_STENCIL_BIT"; + char const str[] = + "vkCmdClearDepthStencilImage aspectMasks for all subresource ranges must be " + "set to VK_IMAGE_ASPECT_DEPTH_BIT and/or VK_IMAGE_ASPECT_STENCIL_BIT"; skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, (uint64_t)commandBuffer, __LINE__, IMAGE_INVALID_IMAGE_ASPECT, "IMAGE", str); @@ -532,18 +535,18 @@ static bool RegionIntersects(const VkImageCopy *src, const VkImageCopy *dst, VkI dst->dstSubresource.layerCount))) { result = true; switch (type) { - case VK_IMAGE_TYPE_3D: - result &= RangesIntersect(src->srcOffset.z, src->extent.depth, dst->dstOffset.z, dst->extent.depth); - // Intentionally fall through to 2D case - case VK_IMAGE_TYPE_2D: - result &= RangesIntersect(src->srcOffset.y, src->extent.height, dst->dstOffset.y, dst->extent.height); - // Intentionally fall through to 1D case - case VK_IMAGE_TYPE_1D: - result &= RangesIntersect(src->srcOffset.x, src->extent.width, dst->dstOffset.x, dst->extent.width); - break; - default: - // Unrecognized or new IMAGE_TYPE enums will be caught in parameter_validation - assert(false); + case VK_IMAGE_TYPE_3D: + result &= RangesIntersect(src->srcOffset.z, src->extent.depth, dst->dstOffset.z, dst->extent.depth); + // Intentionally fall through to 2D case + case VK_IMAGE_TYPE_2D: + result &= RangesIntersect(src->srcOffset.y, src->extent.height, dst->dstOffset.y, dst->extent.height); + // Intentionally fall through to 1D case + case VK_IMAGE_TYPE_1D: + result &= RangesIntersect(src->srcOffset.x, src->extent.width, dst->dstOffset.x, dst->extent.width); + break; + default: + // Unrecognized or new IMAGE_TYPE enums will be caught in parameter_validation + assert(false); } } return result; @@ -554,26 +557,26 @@ static bool ExceedsBounds(const VkOffset3D *offset, const VkExtent3D *extent, co bool result = false; // Extents/depths cannot be negative but checks left in for clarity switch (image->imageType) { - case VK_IMAGE_TYPE_3D: // Validate z and depth - if ((offset->z + extent->depth > image->extent.depth) || (offset->z < 0) || - ((offset->z + static_cast(extent->depth)) < 0)) { - result = true; - } - // Intentionally fall through to 2D case to check height - case VK_IMAGE_TYPE_2D: // Validate y and height - if ((offset->y + extent->height > image->extent.height) || (offset->y < 0) || - ((offset->y + static_cast(extent->height)) < 0)) { - result = true; - } - // Intentionally fall through to 1D case to check width - case VK_IMAGE_TYPE_1D: // Validate x and width - if ((offset->x + extent->width > image->extent.width) || (offset->x < 0) || - ((offset->x + static_cast(extent->width)) < 0)) { - result = true; - } - break; - default: - assert(false); + case VK_IMAGE_TYPE_3D: // Validate z and depth + if ((offset->z + extent->depth > image->extent.depth) || (offset->z < 0) || + ((offset->z + static_cast(extent->depth)) < 0)) { + result = true; + } + // Intentionally fall through to 2D case to check height + case VK_IMAGE_TYPE_2D: // Validate y and height + if ((offset->y + extent->height > image->extent.height) || (offset->y < 0) || + ((offset->y + static_cast(extent->height)) < 0)) { + result = true; + } + // Intentionally fall through to 1D case to check width + case VK_IMAGE_TYPE_1D: // Validate x and width + if ((offset->x + extent->width > image->extent.width) || (offset->x < 0) || + ((offset->x + static_cast(extent->width)) < 0)) { + result = true; + } + break; + default: + assert(false); } return result; } @@ -588,9 +591,7 @@ bool PreCallValidateCmdCopyImage(VkCommandBuffer command_buffer, VkImage src_ima // TODO: This does not cover swapchain-created images. This should fall out when this layer is moved // into the core_validation layer if (src_image_entry && dst_image_entry) { - for (uint32_t i = 0; i < region_count; i++) { - if (regions[i].srcSubresource.layerCount == 0) { std::stringstream ss; ss << "vkCmdCopyImage: number of layers in pRegions[" << i << "] srcSubresource is zero"; @@ -770,7 +771,6 @@ bool PreCallValidateCmdCopyImage(VkCommandBuffer command_buffer, VkImage src_ima VKAPI_ATTR void VKAPI_CALL CmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageCopy *pRegions) { - bool skip = false; layer_data *device_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); @@ -810,8 +810,9 @@ VKAPI_ATTR void VKAPI_CALL CmdClearAttachments(VkCommandBuffer commandBuffer, ui // Having eliminated all other possibilities, image aspect must be depth or stencil or both if (((aspectMask & VK_IMAGE_ASPECT_DEPTH_BIT) != VK_IMAGE_ASPECT_DEPTH_BIT) && ((aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT) != VK_IMAGE_ASPECT_STENCIL_BIT)) { - char const str[] = "vkCmdClearAttachments aspectMask [%d] must be set to VK_IMAGE_ASPECT_DEPTH_BIT and/or " - "VK_IMAGE_ASPECT_STENCIL_BIT. %s"; + char const str[] = + "vkCmdClearAttachments aspectMask [%d] must be set to VK_IMAGE_ASPECT_DEPTH_BIT and/or " + "VK_IMAGE_ASPECT_STENCIL_BIT. %s"; skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, (uint64_t)commandBuffer, __LINE__, VALIDATION_ERROR_01127, "IMAGE", str, i, validation_error_map[VALIDATION_ERROR_01127]); @@ -829,10 +830,8 @@ static bool ValidateBufferImageCopyData(layer_data *dev_data, uint32_t regionCou bool skip = false; for (uint32_t i = 0; i < regionCount; i++) { - auto image_info = getImageState(dev_data, image); if (image_info) { - if ((image_info->imageType == VK_IMAGE_TYPE_1D) || (image_info->imageType == VK_IMAGE_TYPE_2D)) { if ((pRegions[i].imageOffset.z != 0) || (pRegions[i].imageExtent.depth != 1)) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, @@ -960,7 +959,6 @@ VKAPI_ATTR void VKAPI_CALL CmdBlitImage(VkCommandBuffer commandBuffer, VkImage s auto dstImageEntry = getImageState(device_data, dstImage); if (srcImageEntry && dstImageEntry) { - VkFormat srcFormat = srcImageEntry->format; VkFormat dstFormat = dstImageEntry->format; @@ -1262,8 +1260,7 @@ VKAPI_ATTR VkResult VKAPI_CALL EnumerateInstanceExtensionProperties(const char * VKAPI_ATTR VkResult VKAPI_CALL EnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, const char *pLayerName, uint32_t *pCount, VkExtensionProperties *pProperties) { // Image does not have any physical device extensions - if (pLayerName && !strcmp(pLayerName, global_layer.layerName)) - return util_GetExtensionProperties(0, NULL, pCount, pProperties); + if (pLayerName && !strcmp(pLayerName, global_layer.layerName)) return util_GetExtensionProperties(0, NULL, pCount, pProperties); assert(physicalDevice); @@ -1278,8 +1275,7 @@ static PFN_vkVoidFunction intercept_core_device_command(const char *name); VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetDeviceProcAddr(VkDevice device, const char *funcName) { PFN_vkVoidFunction proc = intercept_core_device_command(funcName); - if (proc) - return proc; + if (proc) return proc; assert(device); @@ -1287,29 +1283,24 @@ VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetDeviceProcAddr(VkDevice device, cons VkLayerDispatchTable *pTable = my_data->device_dispatch_table; { - if (pTable->GetDeviceProcAddr == NULL) - return NULL; + if (pTable->GetDeviceProcAddr == NULL) return NULL; return pTable->GetDeviceProcAddr(device, funcName); } } VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetInstanceProcAddr(VkInstance instance, const char *funcName) { PFN_vkVoidFunction proc = intercept_core_instance_command(funcName); - if (!proc) - proc = intercept_core_device_command(funcName); - if (proc) - return proc; + if (!proc) proc = intercept_core_device_command(funcName); + if (proc) return proc; assert(instance); layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); proc = debug_report_get_instance_proc_addr(my_data->report_data, funcName); - if (proc) - return proc; + if (proc) return proc; VkLayerInstanceDispatchTable *pTable = my_data->instance_dispatch_table; - if (pTable->GetInstanceProcAddr == NULL) - return NULL; + if (pTable->GetInstanceProcAddr == NULL) return NULL; return pTable->GetInstanceProcAddr(instance, funcName); } @@ -1319,8 +1310,7 @@ VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetPhysicalDeviceProcAddr(VkInstance in layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); VkLayerInstanceDispatchTable *pTable = my_data->instance_dispatch_table; - if (pTable->GetPhysicalDeviceProcAddr == NULL) - return NULL; + if (pTable->GetPhysicalDeviceProcAddr == NULL) return NULL; return pTable->GetPhysicalDeviceProcAddr(instance, funcName); } @@ -1342,8 +1332,7 @@ static PFN_vkVoidFunction intercept_core_instance_command(const char *name) { }; for (size_t i = 0; i < ARRAY_SIZE(core_instance_commands); i++) { - if (!strcmp(core_instance_commands[i].name, name)) - return core_instance_commands[i].proc; + if (!strcmp(core_instance_commands[i].name, name)) return core_instance_commands[i].proc; } return nullptr; @@ -1372,14 +1361,13 @@ static PFN_vkVoidFunction intercept_core_device_command(const char *name) { }; for (size_t i = 0; i < ARRAY_SIZE(core_device_commands); i++) { - if (!strcmp(core_device_commands[i].name, name)) - return core_device_commands[i].proc; + if (!strcmp(core_device_commands[i].name, name)) return core_device_commands[i].proc; } return nullptr; } -} // namespace image +} // namespace image // vk_layer_logging.h expects these to be defined diff --git a/layers/image.h b/layers/image.h index 1c10d50..727980a 100644 --- a/layers/image.h +++ b/layers/image.h @@ -27,24 +27,24 @@ // Image ERROR codes enum IMAGE_ERROR { - IMAGE_NONE, // Used for INFO & other non-error messages - IMAGE_FORMAT_UNSUPPORTED, // Request to create Image or RenderPass with a format that is not supported - IMAGE_RENDERPASS_INVALID_ATTACHMENT, // Invalid image layouts and/or load/storeOps for an attachment when creating RenderPass - IMAGE_RENDERPASS_INVALID_DS_ATTACHMENT, // If no depth/stencil attachment for a RenderPass, verify that subpass DS attachment - // is set to UNUSED - IMAGE_INVALID_IMAGE_ASPECT, // Image aspect mask bits are invalid for this API call - IMAGE_MISMATCHED_IMAGE_ASPECT, // Image aspect masks for source and dest images do not match - IMAGE_VIEW_CREATE_ERROR, // Error occurred trying to create Image View - IMAGE_MISMATCHED_IMAGE_TYPE, // Image types for source and dest images do not match - IMAGE_MISMATCHED_IMAGE_FORMAT, // Image formats for source and dest images do not match - IMAGE_INVALID_RESOLVE_SAMPLES, // Image resolve source samples less than two or dest samples greater than one - IMAGE_INVALID_FORMAT, // Operation specifies an invalid format, or there is a format mismatch - IMAGE_INVALID_FILTER, // Operation specifies an invalid filter setting - IMAGE_INVALID_IMAGE_RESOURCE, // Image resource/subresource called with invalid setting - IMAGE_INVALID_FORMAT_LIMITS_VIOLATION, // Device limits for this format have been exceeded - IMAGE_INVALID_LAYOUT, // Operation specifies an invalid layout - IMAGE_INVALID_EXTENTS, // Operation specifies invalid image extents - IMAGE_INVALID_USAGE, // Image was created without necessary usage for operation + IMAGE_NONE, // Used for INFO & other non-error messages + IMAGE_FORMAT_UNSUPPORTED, // Request to create Image or RenderPass with a format that is not supported + IMAGE_RENDERPASS_INVALID_ATTACHMENT, // Invalid image layouts and/or load/storeOps for an attachment when creating RenderPass + IMAGE_RENDERPASS_INVALID_DS_ATTACHMENT, // If no depth/stencil attachment for a RenderPass, verify that subpass DS attachment + // is set to UNUSED + IMAGE_INVALID_IMAGE_ASPECT, // Image aspect mask bits are invalid for this API call + IMAGE_MISMATCHED_IMAGE_ASPECT, // Image aspect masks for source and dest images do not match + IMAGE_VIEW_CREATE_ERROR, // Error occurred trying to create Image View + IMAGE_MISMATCHED_IMAGE_TYPE, // Image types for source and dest images do not match + IMAGE_MISMATCHED_IMAGE_FORMAT, // Image formats for source and dest images do not match + IMAGE_INVALID_RESOLVE_SAMPLES, // Image resolve source samples less than two or dest samples greater than one + IMAGE_INVALID_FORMAT, // Operation specifies an invalid format, or there is a format mismatch + IMAGE_INVALID_FILTER, // Operation specifies an invalid filter setting + IMAGE_INVALID_IMAGE_RESOURCE, // Image resource/subresource called with invalid setting + IMAGE_INVALID_FORMAT_LIMITS_VIOLATION, // Device limits for this format have been exceeded + IMAGE_INVALID_LAYOUT, // Operation specifies an invalid layout + IMAGE_INVALID_EXTENTS, // Operation specifies invalid image extents + IMAGE_INVALID_USAGE, // Image was created without necessary usage for operation }; struct IMAGE_STATE { @@ -57,12 +57,23 @@ struct IMAGE_STATE { VkImageCreateFlags flags; VkImageUsageFlags usage; IMAGE_STATE() - : mipLevels(0), arraySize(0), format(VK_FORMAT_UNDEFINED), samples(VK_SAMPLE_COUNT_1_BIT), - imageType(VK_IMAGE_TYPE_RANGE_SIZE), extent{}, flags(0), usage(0){}; + : mipLevels(0), + arraySize(0), + format(VK_FORMAT_UNDEFINED), + samples(VK_SAMPLE_COUNT_1_BIT), + imageType(VK_IMAGE_TYPE_RANGE_SIZE), + extent{}, + flags(0), + usage(0){}; IMAGE_STATE(const VkImageCreateInfo *pCreateInfo) - : mipLevels(pCreateInfo->mipLevels), arraySize(pCreateInfo->arrayLayers), format(pCreateInfo->format), - samples(pCreateInfo->samples), imageType(pCreateInfo->imageType), extent(pCreateInfo->extent), flags(pCreateInfo->flags), + : mipLevels(pCreateInfo->mipLevels), + arraySize(pCreateInfo->arrayLayers), + format(pCreateInfo->format), + samples(pCreateInfo->samples), + imageType(pCreateInfo->imageType), + extent(pCreateInfo->extent), + flags(pCreateInfo->flags), usage(pCreateInfo->usage){}; }; -#endif // IMAGE_H +#endif // IMAGE_H diff --git a/layers/object_tracker.cpp b/layers/object_tracker.cpp index e9a97bd..6b854be 100644 --- a/layers/object_tracker.cpp +++ b/layers/object_tracker.cpp @@ -49,7 +49,6 @@ namespace object_tracker { static uint32_t loader_layer_if_version = CURRENT_LOADER_LAYER_INTERFACE_VERSION; static void InitObjectTracker(layer_data *my_data, const VkAllocationCallbacks *pAllocator) { - layer_debug_actions(my_data->report_data, my_data->logging_callback, pAllocator, "lunarg_object_tracker"); } @@ -250,8 +249,14 @@ static void CreateSwapchainImageObject(VkDevice dispatchable_object, VkImage swa device_data->swapchainImageMap[reinterpret_cast(swapchain_image)] = pNewObjNode; } -template uint64_t handle_value(T handle) { return reinterpret_cast(handle); } -template uint64_t handle_value(T *handle) { return reinterpret_cast(handle); } +template +uint64_t handle_value(T handle) { + return reinterpret_cast(handle); +} +template +uint64_t handle_value(T *handle) { + return reinterpret_cast(handle); +} template static void CreateObject(T1 dispatchable_object, T2 object, VkDebugReportObjectTypeEXT object_type, @@ -289,7 +294,6 @@ static void DestroyObject(T1 dispatchable_object, T2 object, VkDebugReportObject if (object_handle != VK_NULL_HANDLE) { auto item = device_data->object_map[object_type].find(object_handle); if (item != device_data->object_map[object_type].end()) { - OBJTRACK_NODE *pNode = item->second; assert(device_data->num_total_objects > 0); device_data->num_total_objects--; @@ -451,7 +455,6 @@ VKAPI_ATTR void VKAPI_CALL DestroyInstance(VkInstance instance, const VkAllocati } VKAPI_ATTR void VKAPI_CALL DestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator) { - std::unique_lock lock(global_lock); ValidateObject(device, device, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, true, VALIDATION_ERROR_00052); DestroyObject(device, device, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, pAllocator, VALIDATION_ERROR_00050, @@ -2797,7 +2800,7 @@ VKAPI_ATTR VkBool32 VKAPI_CALL GetPhysicalDeviceWin32PresentationSupportKHR(VkPh ->GetPhysicalDeviceWin32PresentationSupportKHR(physicalDevice, queueFamilyIndex); return result; } -#endif // VK_USE_PLATFORM_WIN32_KHR +#endif // VK_USE_PLATFORM_WIN32_KHR #ifdef VK_USE_PLATFORM_XCB_KHR VKAPI_ATTR VkResult VKAPI_CALL CreateXcbSurfaceKHR(VkInstance instance, const VkXcbSurfaceCreateInfoKHR *pCreateInfo, @@ -2837,7 +2840,7 @@ VKAPI_ATTR VkBool32 VKAPI_CALL GetPhysicalDeviceXcbPresentationSupportKHR(VkPhys ->GetPhysicalDeviceXcbPresentationSupportKHR(physicalDevice, queueFamilyIndex, connection, visual_id); return result; } -#endif // VK_USE_PLATFORM_XCB_KHR +#endif // VK_USE_PLATFORM_XCB_KHR #ifdef VK_USE_PLATFORM_XLIB_KHR VKAPI_ATTR VkResult VKAPI_CALL CreateXlibSurfaceKHR(VkInstance instance, const VkXlibSurfaceCreateInfoKHR *pCreateInfo, @@ -2877,7 +2880,7 @@ VKAPI_ATTR VkBool32 VKAPI_CALL GetPhysicalDeviceXlibPresentationSupportKHR(VkPhy ->GetPhysicalDeviceXlibPresentationSupportKHR(physicalDevice, queueFamilyIndex, dpy, visualID); return result; } -#endif // VK_USE_PLATFORM_XLIB_KHR +#endif // VK_USE_PLATFORM_XLIB_KHR #ifdef VK_USE_PLATFORM_MIR_KHR VKAPI_ATTR VkResult VKAPI_CALL CreateMirSurfaceKHR(VkInstance instance, const VkMirSurfaceCreateInfoKHR *pCreateInfo, @@ -2916,7 +2919,7 @@ VKAPI_ATTR VkBool32 VKAPI_CALL GetPhysicalDeviceMirPresentationSupportKHR(VkPhys ->GetPhysicalDeviceMirPresentationSupportKHR(physicalDevice, queueFamilyIndex, connection); return result; } -#endif // VK_USE_PLATFORM_MIR_KHR +#endif // VK_USE_PLATFORM_MIR_KHR #ifdef VK_USE_PLATFORM_WAYLAND_KHR VKAPI_ATTR VkResult VKAPI_CALL CreateWaylandSurfaceKHR(VkInstance instance, const VkWaylandSurfaceCreateInfoKHR *pCreateInfo, @@ -2956,7 +2959,7 @@ VKAPI_ATTR VkBool32 VKAPI_CALL GetPhysicalDeviceWaylandPresentationSupportKHR(Vk ->GetPhysicalDeviceWaylandPresentationSupportKHR(physicalDevice, queueFamilyIndex, display); return result; } -#endif // VK_USE_PLATFORM_WAYLAND_KHR +#endif // VK_USE_PLATFORM_WAYLAND_KHR #ifdef VK_USE_PLATFORM_ANDROID_KHR VKAPI_ATTR VkResult VKAPI_CALL CreateAndroidSurfaceKHR(VkInstance instance, const VkAndroidSurfaceCreateInfoKHR *pCreateInfo, @@ -2979,7 +2982,7 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateAndroidSurfaceKHR(VkInstance instance, cons } return result; } -#endif // VK_USE_PLATFORM_ANDROID_KHR +#endif // VK_USE_PLATFORM_ANDROID_KHR VKAPI_ATTR VkResult VKAPI_CALL CreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount, const VkSwapchainCreateInfoKHR *pCreateInfos, @@ -3049,8 +3052,8 @@ VKAPI_ATTR void VKAPI_CALL DebugReportMessageEXT(VkInstance instance, VkDebugRep static const VkExtensionProperties instance_extensions[] = {{VK_EXT_DEBUG_REPORT_EXTENSION_NAME, VK_EXT_DEBUG_REPORT_SPEC_VERSION}}; static const VkLayerProperties globalLayerProps = {"VK_LAYER_LUNARG_object_tracker", - VK_LAYER_API_VERSION, // specVersion - 1, // implementationVersion + VK_LAYER_API_VERSION, // specVersion + 1, // implementationVersion "LunarG Validation Layer"}; VKAPI_ATTR VkResult VKAPI_CALL EnumerateInstanceLayerProperties(uint32_t *pCount, VkLayerProperties *pProperties) { @@ -3090,11 +3093,9 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateDisplayPlaneSurfaceKHR(VkInstance instance, static inline PFN_vkVoidFunction InterceptWsiEnabledCommand(const char *name, VkInstance instance) { VkLayerInstanceDispatchTable *pTable = get_dispatch_table(ot_instance_table_map, instance); - if (instanceExtMap.size() == 0 || !instanceExtMap[pTable].wsi_enabled) - return nullptr; + if (instanceExtMap.size() == 0 || !instanceExtMap[pTable].wsi_enabled) return nullptr; - if (!strcmp("vkDestroySurfaceKHR", name)) - return reinterpret_cast(DestroySurfaceKHR); + if (!strcmp("vkDestroySurfaceKHR", name)) return reinterpret_cast(DestroySurfaceKHR); if (!strcmp("vkGetPhysicalDeviceSurfaceSupportKHR", name)) return reinterpret_cast(GetPhysicalDeviceSurfaceSupportKHR); if (!strcmp("vkGetPhysicalDeviceSurfaceCapabilitiesKHR", name)) @@ -3111,35 +3112,35 @@ static inline PFN_vkVoidFunction InterceptWsiEnabledCommand(const char *name, Vk return reinterpret_cast(CreateWin32SurfaceKHR); if ((instanceExtMap[pTable].win32_enabled == true) && !strcmp("vkGetPhysicalDeviceWin32PresentationSupportKHR", name)) return reinterpret_cast(GetPhysicalDeviceWin32PresentationSupportKHR); -#endif // VK_USE_PLATFORM_WIN32_KHR +#endif // VK_USE_PLATFORM_WIN32_KHR #ifdef VK_USE_PLATFORM_XCB_KHR if ((instanceExtMap[pTable].xcb_enabled == true) && !strcmp("vkCreateXcbSurfaceKHR", name)) return reinterpret_cast(CreateXcbSurfaceKHR); if ((instanceExtMap[pTable].xcb_enabled == true) && !strcmp("vkGetPhysicalDeviceXcbPresentationSupportKHR", name)) return reinterpret_cast(GetPhysicalDeviceXcbPresentationSupportKHR); -#endif // VK_USE_PLATFORM_XCB_KHR +#endif // VK_USE_PLATFORM_XCB_KHR #ifdef VK_USE_PLATFORM_XLIB_KHR if ((instanceExtMap[pTable].xlib_enabled == true) && !strcmp("vkCreateXlibSurfaceKHR", name)) return reinterpret_cast(CreateXlibSurfaceKHR); if ((instanceExtMap[pTable].xlib_enabled == true) && !strcmp("vkGetPhysicalDeviceXlibPresentationSupportKHR", name)) return reinterpret_cast(GetPhysicalDeviceXlibPresentationSupportKHR); -#endif // VK_USE_PLATFORM_XLIB_KHR +#endif // VK_USE_PLATFORM_XLIB_KHR #ifdef VK_USE_PLATFORM_MIR_KHR if ((instanceExtMap[pTable].mir_enabled == true) && !strcmp("vkCreateMirSurfaceKHR", name)) return reinterpret_cast(CreateMirSurfaceKHR); if ((instanceExtMap[pTable].mir_enabled == true) && !strcmp("vkGetPhysicalDeviceMirPresentationSupportKHR", name)) return reinterpret_cast(GetPhysicalDeviceMirPresentationSupportKHR); -#endif // VK_USE_PLATFORM_MIR_KHR +#endif // VK_USE_PLATFORM_MIR_KHR #ifdef VK_USE_PLATFORM_WAYLAND_KHR if ((instanceExtMap[pTable].wayland_enabled == true) && !strcmp("vkCreateWaylandSurfaceKHR", name)) return reinterpret_cast(CreateWaylandSurfaceKHR); if ((instanceExtMap[pTable].wayland_enabled == true) && !strcmp("vkGetPhysicalDeviceWaylandPresentationSupportKHR", name)) return reinterpret_cast(GetPhysicalDeviceWaylandPresentationSupportKHR); -#endif // VK_USE_PLATFORM_WAYLAND_KHR +#endif // VK_USE_PLATFORM_WAYLAND_KHR #ifdef VK_USE_PLATFORM_ANDROID_KHR if ((instanceExtMap[pTable].android_enabled == true) && !strcmp("vkCreateAndroidSurfaceKHR", name)) return reinterpret_cast(CreateAndroidSurfaceKHR); -#endif // VK_USE_PLATFORM_ANDROID_KHR +#endif // VK_USE_PLATFORM_ANDROID_KHR return nullptr; } @@ -3791,7 +3792,6 @@ VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceExternalImageFormatPropertiesNV( VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkExternalMemoryHandleTypeFlagsNV externalHandleType, VkExternalImageFormatPropertiesNV *pExternalImageFormatProperties) { - bool skip_call = false; { std::lock_guard lock(global_lock); @@ -3951,7 +3951,7 @@ VKAPI_ATTR VkResult VKAPI_CALL GetMemoryWin32HandleNV(VkDevice device, VkDeviceM VkResult result = get_dispatch_table(ot_device_table_map, device)->GetMemoryWin32HandleNV(device, memory, handleType, pHandle); return result; } -#endif // VK_USE_PLATFORM_WIN32_KHR +#endif // VK_USE_PLATFORM_WIN32_KHR // VK_AMD_draw_indirect_count Extension VKAPI_ATTR void VKAPI_CALL CmdDrawIndirectCountAMD(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, @@ -4285,7 +4285,7 @@ VKAPI_ATTR VkResult VKAPI_CALL GetRandROutputDisplayEXT(VkPhysicalDevice physica return result; } -#endif // VK_USE_PLATFORM_XLIB_XRANDR_EXT +#endif // VK_USE_PLATFORM_XLIB_XRANDR_EXT // VK_EXT_display_surface_counter Extension VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceSurfaceCapabilities2EXT(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, @@ -4385,309 +4385,163 @@ VKAPI_ATTR VkResult VKAPI_CALL GetSwapchainCounterEXT(VkDevice device, VkSwapcha } static inline PFN_vkVoidFunction InterceptCoreDeviceCommand(const char *name) { - if (!name || name[0] != 'v' || name[1] != 'k') - return NULL; + if (!name || name[0] != 'v' || name[1] != 'k') return NULL; name += 2; - if (!strcmp(name, "GetDeviceProcAddr")) - return (PFN_vkVoidFunction)GetDeviceProcAddr; - if (!strcmp(name, "DestroyDevice")) - return (PFN_vkVoidFunction)DestroyDevice; - if (!strcmp(name, "GetDeviceQueue")) - return (PFN_vkVoidFunction)GetDeviceQueue; - if (!strcmp(name, "QueueSubmit")) - return (PFN_vkVoidFunction)QueueSubmit; - if (!strcmp(name, "QueueWaitIdle")) - return (PFN_vkVoidFunction)QueueWaitIdle; - if (!strcmp(name, "DeviceWaitIdle")) - return (PFN_vkVoidFunction)DeviceWaitIdle; - if (!strcmp(name, "AllocateMemory")) - return (PFN_vkVoidFunction)AllocateMemory; - if (!strcmp(name, "FreeMemory")) - return (PFN_vkVoidFunction)FreeMemory; - if (!strcmp(name, "MapMemory")) - return (PFN_vkVoidFunction)MapMemory; - if (!strcmp(name, "UnmapMemory")) - return (PFN_vkVoidFunction)UnmapMemory; - if (!strcmp(name, "FlushMappedMemoryRanges")) - return (PFN_vkVoidFunction)FlushMappedMemoryRanges; - if (!strcmp(name, "InvalidateMappedMemoryRanges")) - return (PFN_vkVoidFunction)InvalidateMappedMemoryRanges; - if (!strcmp(name, "GetDeviceMemoryCommitment")) - return (PFN_vkVoidFunction)GetDeviceMemoryCommitment; - if (!strcmp(name, "BindBufferMemory")) - return (PFN_vkVoidFunction)BindBufferMemory; - if (!strcmp(name, "BindImageMemory")) - return (PFN_vkVoidFunction)BindImageMemory; - if (!strcmp(name, "GetBufferMemoryRequirements")) - return (PFN_vkVoidFunction)GetBufferMemoryRequirements; - if (!strcmp(name, "GetImageMemoryRequirements")) - return (PFN_vkVoidFunction)GetImageMemoryRequirements; - if (!strcmp(name, "GetImageSparseMemoryRequirements")) - return (PFN_vkVoidFunction)GetImageSparseMemoryRequirements; - if (!strcmp(name, "QueueBindSparse")) - return (PFN_vkVoidFunction)QueueBindSparse; - if (!strcmp(name, "CreateFence")) - return (PFN_vkVoidFunction)CreateFence; - if (!strcmp(name, "DestroyFence")) - return (PFN_vkVoidFunction)DestroyFence; - if (!strcmp(name, "ResetFences")) - return (PFN_vkVoidFunction)ResetFences; - if (!strcmp(name, "GetFenceStatus")) - return (PFN_vkVoidFunction)GetFenceStatus; - if (!strcmp(name, "WaitForFences")) - return (PFN_vkVoidFunction)WaitForFences; - if (!strcmp(name, "CreateSemaphore")) - return (PFN_vkVoidFunction)CreateSemaphore; - if (!strcmp(name, "DestroySemaphore")) - return (PFN_vkVoidFunction)DestroySemaphore; - if (!strcmp(name, "CreateEvent")) - return (PFN_vkVoidFunction)CreateEvent; - if (!strcmp(name, "DestroyEvent")) - return (PFN_vkVoidFunction)DestroyEvent; - if (!strcmp(name, "GetEventStatus")) - return (PFN_vkVoidFunction)GetEventStatus; - if (!strcmp(name, "SetEvent")) - return (PFN_vkVoidFunction)SetEvent; - if (!strcmp(name, "ResetEvent")) - return (PFN_vkVoidFunction)ResetEvent; - if (!strcmp(name, "CreateQueryPool")) - return (PFN_vkVoidFunction)CreateQueryPool; - if (!strcmp(name, "DestroyQueryPool")) - return (PFN_vkVoidFunction)DestroyQueryPool; - if (!strcmp(name, "GetQueryPoolResults")) - return (PFN_vkVoidFunction)GetQueryPoolResults; - if (!strcmp(name, "CreateBuffer")) - return (PFN_vkVoidFunction)CreateBuffer; - if (!strcmp(name, "DestroyBuffer")) - return (PFN_vkVoidFunction)DestroyBuffer; - if (!strcmp(name, "CreateBufferView")) - return (PFN_vkVoidFunction)CreateBufferView; - if (!strcmp(name, "DestroyBufferView")) - return (PFN_vkVoidFunction)DestroyBufferView; - if (!strcmp(name, "CreateImage")) - return (PFN_vkVoidFunction)CreateImage; - if (!strcmp(name, "DestroyImage")) - return (PFN_vkVoidFunction)DestroyImage; - if (!strcmp(name, "GetImageSubresourceLayout")) - return (PFN_vkVoidFunction)GetImageSubresourceLayout; - if (!strcmp(name, "CreateImageView")) - return (PFN_vkVoidFunction)CreateImageView; - if (!strcmp(name, "DestroyImageView")) - return (PFN_vkVoidFunction)DestroyImageView; - if (!strcmp(name, "CreateShaderModule")) - return (PFN_vkVoidFunction)CreateShaderModule; - if (!strcmp(name, "DestroyShaderModule")) - return (PFN_vkVoidFunction)DestroyShaderModule; - if (!strcmp(name, "CreatePipelineCache")) - return (PFN_vkVoidFunction)CreatePipelineCache; - if (!strcmp(name, "DestroyPipelineCache")) - return (PFN_vkVoidFunction)DestroyPipelineCache; - if (!strcmp(name, "GetPipelineCacheData")) - return (PFN_vkVoidFunction)GetPipelineCacheData; - if (!strcmp(name, "MergePipelineCaches")) - return (PFN_vkVoidFunction)MergePipelineCaches; - if (!strcmp(name, "CreateGraphicsPipelines")) - return (PFN_vkVoidFunction)CreateGraphicsPipelines; - if (!strcmp(name, "CreateComputePipelines")) - return (PFN_vkVoidFunction)CreateComputePipelines; - if (!strcmp(name, "DestroyPipeline")) - return (PFN_vkVoidFunction)DestroyPipeline; - if (!strcmp(name, "CreatePipelineLayout")) - return (PFN_vkVoidFunction)CreatePipelineLayout; - if (!strcmp(name, "DestroyPipelineLayout")) - return (PFN_vkVoidFunction)DestroyPipelineLayout; - if (!strcmp(name, "CreateSampler")) - return (PFN_vkVoidFunction)CreateSampler; - if (!strcmp(name, "DestroySampler")) - return (PFN_vkVoidFunction)DestroySampler; - if (!strcmp(name, "CreateDescriptorSetLayout")) - return (PFN_vkVoidFunction)CreateDescriptorSetLayout; - if (!strcmp(name, "DestroyDescriptorSetLayout")) - return (PFN_vkVoidFunction)DestroyDescriptorSetLayout; - if (!strcmp(name, "CreateDescriptorPool")) - return (PFN_vkVoidFunction)CreateDescriptorPool; - if (!strcmp(name, "DestroyDescriptorPool")) - return (PFN_vkVoidFunction)DestroyDescriptorPool; - if (!strcmp(name, "ResetDescriptorPool")) - return (PFN_vkVoidFunction)ResetDescriptorPool; - if (!strcmp(name, "AllocateDescriptorSets")) - return (PFN_vkVoidFunction)AllocateDescriptorSets; - if (!strcmp(name, "FreeDescriptorSets")) - return (PFN_vkVoidFunction)FreeDescriptorSets; - if (!strcmp(name, "UpdateDescriptorSets")) - return (PFN_vkVoidFunction)UpdateDescriptorSets; - if (!strcmp(name, "CreateFramebuffer")) - return (PFN_vkVoidFunction)CreateFramebuffer; - if (!strcmp(name, "DestroyFramebuffer")) - return (PFN_vkVoidFunction)DestroyFramebuffer; - if (!strcmp(name, "CreateRenderPass")) - return (PFN_vkVoidFunction)CreateRenderPass; - if (!strcmp(name, "DestroyRenderPass")) - return (PFN_vkVoidFunction)DestroyRenderPass; - if (!strcmp(name, "GetRenderAreaGranularity")) - return (PFN_vkVoidFunction)GetRenderAreaGranularity; - if (!strcmp(name, "CreateCommandPool")) - return (PFN_vkVoidFunction)CreateCommandPool; - if (!strcmp(name, "DestroyCommandPool")) - return (PFN_vkVoidFunction)DestroyCommandPool; - if (!strcmp(name, "ResetCommandPool")) - return (PFN_vkVoidFunction)ResetCommandPool; - if (!strcmp(name, "AllocateCommandBuffers")) - return (PFN_vkVoidFunction)AllocateCommandBuffers; - if (!strcmp(name, "FreeCommandBuffers")) - return (PFN_vkVoidFunction)FreeCommandBuffers; - if (!strcmp(name, "BeginCommandBuffer")) - return (PFN_vkVoidFunction)BeginCommandBuffer; - if (!strcmp(name, "EndCommandBuffer")) - return (PFN_vkVoidFunction)EndCommandBuffer; - if (!strcmp(name, "ResetCommandBuffer")) - return (PFN_vkVoidFunction)ResetCommandBuffer; - if (!strcmp(name, "CmdBindPipeline")) - return (PFN_vkVoidFunction)CmdBindPipeline; - if (!strcmp(name, "CmdSetViewport")) - return (PFN_vkVoidFunction)CmdSetViewport; - if (!strcmp(name, "CmdSetScissor")) - return (PFN_vkVoidFunction)CmdSetScissor; - if (!strcmp(name, "CmdSetLineWidth")) - return (PFN_vkVoidFunction)CmdSetLineWidth; - if (!strcmp(name, "CmdSetDepthBias")) - return (PFN_vkVoidFunction)CmdSetDepthBias; - if (!strcmp(name, "CmdSetBlendConstants")) - return (PFN_vkVoidFunction)CmdSetBlendConstants; - if (!strcmp(name, "CmdSetDepthBounds")) - return (PFN_vkVoidFunction)CmdSetDepthBounds; - if (!strcmp(name, "CmdSetStencilCompareMask")) - return (PFN_vkVoidFunction)CmdSetStencilCompareMask; - if (!strcmp(name, "CmdSetStencilWriteMask")) - return (PFN_vkVoidFunction)CmdSetStencilWriteMask; - if (!strcmp(name, "CmdSetStencilReference")) - return (PFN_vkVoidFunction)CmdSetStencilReference; - if (!strcmp(name, "CmdBindDescriptorSets")) - return (PFN_vkVoidFunction)CmdBindDescriptorSets; - if (!strcmp(name, "CmdBindIndexBuffer")) - return (PFN_vkVoidFunction)CmdBindIndexBuffer; - if (!strcmp(name, "CmdBindVertexBuffers")) - return (PFN_vkVoidFunction)CmdBindVertexBuffers; - if (!strcmp(name, "CmdDraw")) - return (PFN_vkVoidFunction)CmdDraw; - if (!strcmp(name, "CmdDrawIndexed")) - return (PFN_vkVoidFunction)CmdDrawIndexed; - if (!strcmp(name, "CmdDrawIndirect")) - return (PFN_vkVoidFunction)CmdDrawIndirect; - if (!strcmp(name, "CmdDrawIndexedIndirect")) - return (PFN_vkVoidFunction)CmdDrawIndexedIndirect; - if (!strcmp(name, "CmdDispatch")) - return (PFN_vkVoidFunction)CmdDispatch; - if (!strcmp(name, "CmdDispatchIndirect")) - return (PFN_vkVoidFunction)CmdDispatchIndirect; - if (!strcmp(name, "CmdCopyBuffer")) - return (PFN_vkVoidFunction)CmdCopyBuffer; - if (!strcmp(name, "CmdCopyImage")) - return (PFN_vkVoidFunction)CmdCopyImage; - if (!strcmp(name, "CmdBlitImage")) - return (PFN_vkVoidFunction)CmdBlitImage; - if (!strcmp(name, "CmdCopyBufferToImage")) - return (PFN_vkVoidFunction)CmdCopyBufferToImage; - if (!strcmp(name, "CmdCopyImageToBuffer")) - return (PFN_vkVoidFunction)CmdCopyImageToBuffer; - if (!strcmp(name, "CmdUpdateBuffer")) - return (PFN_vkVoidFunction)CmdUpdateBuffer; - if (!strcmp(name, "CmdFillBuffer")) - return (PFN_vkVoidFunction)CmdFillBuffer; - if (!strcmp(name, "CmdClearColorImage")) - return (PFN_vkVoidFunction)CmdClearColorImage; - if (!strcmp(name, "CmdClearDepthStencilImage")) - return (PFN_vkVoidFunction)CmdClearDepthStencilImage; - if (!strcmp(name, "CmdClearAttachments")) - return (PFN_vkVoidFunction)CmdClearAttachments; - if (!strcmp(name, "CmdResolveImage")) - return (PFN_vkVoidFunction)CmdResolveImage; - if (!strcmp(name, "CmdSetEvent")) - return (PFN_vkVoidFunction)CmdSetEvent; - if (!strcmp(name, "CmdResetEvent")) - return (PFN_vkVoidFunction)CmdResetEvent; - if (!strcmp(name, "CmdWaitEvents")) - return (PFN_vkVoidFunction)CmdWaitEvents; - if (!strcmp(name, "CmdPipelineBarrier")) - return (PFN_vkVoidFunction)CmdPipelineBarrier; - if (!strcmp(name, "CmdBeginQuery")) - return (PFN_vkVoidFunction)CmdBeginQuery; - if (!strcmp(name, "CmdEndQuery")) - return (PFN_vkVoidFunction)CmdEndQuery; - if (!strcmp(name, "CmdResetQueryPool")) - return (PFN_vkVoidFunction)CmdResetQueryPool; - if (!strcmp(name, "CmdWriteTimestamp")) - return (PFN_vkVoidFunction)CmdWriteTimestamp; - if (!strcmp(name, "CmdCopyQueryPoolResults")) - return (PFN_vkVoidFunction)CmdCopyQueryPoolResults; - if (!strcmp(name, "CmdPushConstants")) - return (PFN_vkVoidFunction)CmdPushConstants; - if (!strcmp(name, "CmdBeginRenderPass")) - return (PFN_vkVoidFunction)CmdBeginRenderPass; - if (!strcmp(name, "CmdNextSubpass")) - return (PFN_vkVoidFunction)CmdNextSubpass; - if (!strcmp(name, "CmdEndRenderPass")) - return (PFN_vkVoidFunction)CmdEndRenderPass; - if (!strcmp(name, "CmdExecuteCommands")) - return (PFN_vkVoidFunction)CmdExecuteCommands; - if (!strcmp(name, "DebugMarkerSetObjectTagEXT")) - return (PFN_vkVoidFunction)DebugMarkerSetObjectTagEXT; - if (!strcmp(name, "DebugMarkerSetObjectNameEXT")) - return (PFN_vkVoidFunction)DebugMarkerSetObjectNameEXT; - if (!strcmp(name, "CmdDebugMarkerBeginEXT")) - return (PFN_vkVoidFunction)CmdDebugMarkerBeginEXT; - if (!strcmp(name, "CmdDebugMarkerEndEXT")) - return (PFN_vkVoidFunction)CmdDebugMarkerEndEXT; - if (!strcmp(name, "CmdDebugMarkerInsertEXT")) - return (PFN_vkVoidFunction)CmdDebugMarkerInsertEXT; + if (!strcmp(name, "GetDeviceProcAddr")) return (PFN_vkVoidFunction)GetDeviceProcAddr; + if (!strcmp(name, "DestroyDevice")) return (PFN_vkVoidFunction)DestroyDevice; + if (!strcmp(name, "GetDeviceQueue")) return (PFN_vkVoidFunction)GetDeviceQueue; + if (!strcmp(name, "QueueSubmit")) return (PFN_vkVoidFunction)QueueSubmit; + if (!strcmp(name, "QueueWaitIdle")) return (PFN_vkVoidFunction)QueueWaitIdle; + if (!strcmp(name, "DeviceWaitIdle")) return (PFN_vkVoidFunction)DeviceWaitIdle; + if (!strcmp(name, "AllocateMemory")) return (PFN_vkVoidFunction)AllocateMemory; + if (!strcmp(name, "FreeMemory")) return (PFN_vkVoidFunction)FreeMemory; + if (!strcmp(name, "MapMemory")) return (PFN_vkVoidFunction)MapMemory; + if (!strcmp(name, "UnmapMemory")) return (PFN_vkVoidFunction)UnmapMemory; + if (!strcmp(name, "FlushMappedMemoryRanges")) return (PFN_vkVoidFunction)FlushMappedMemoryRanges; + if (!strcmp(name, "InvalidateMappedMemoryRanges")) return (PFN_vkVoidFunction)InvalidateMappedMemoryRanges; + if (!strcmp(name, "GetDeviceMemoryCommitment")) return (PFN_vkVoidFunction)GetDeviceMemoryCommitment; + if (!strcmp(name, "BindBufferMemory")) return (PFN_vkVoidFunction)BindBufferMemory; + if (!strcmp(name, "BindImageMemory")) return (PFN_vkVoidFunction)BindImageMemory; + if (!strcmp(name, "GetBufferMemoryRequirements")) return (PFN_vkVoidFunction)GetBufferMemoryRequirements; + if (!strcmp(name, "GetImageMemoryRequirements")) return (PFN_vkVoidFunction)GetImageMemoryRequirements; + if (!strcmp(name, "GetImageSparseMemoryRequirements")) return (PFN_vkVoidFunction)GetImageSparseMemoryRequirements; + if (!strcmp(name, "QueueBindSparse")) return (PFN_vkVoidFunction)QueueBindSparse; + if (!strcmp(name, "CreateFence")) return (PFN_vkVoidFunction)CreateFence; + if (!strcmp(name, "DestroyFence")) return (PFN_vkVoidFunction)DestroyFence; + if (!strcmp(name, "ResetFences")) return (PFN_vkVoidFunction)ResetFences; + if (!strcmp(name, "GetFenceStatus")) return (PFN_vkVoidFunction)GetFenceStatus; + if (!strcmp(name, "WaitForFences")) return (PFN_vkVoidFunction)WaitForFences; + if (!strcmp(name, "CreateSemaphore")) return (PFN_vkVoidFunction)CreateSemaphore; + if (!strcmp(name, "DestroySemaphore")) return (PFN_vkVoidFunction)DestroySemaphore; + if (!strcmp(name, "CreateEvent")) return (PFN_vkVoidFunction)CreateEvent; + if (!strcmp(name, "DestroyEvent")) return (PFN_vkVoidFunction)DestroyEvent; + if (!strcmp(name, "GetEventStatus")) return (PFN_vkVoidFunction)GetEventStatus; + if (!strcmp(name, "SetEvent")) return (PFN_vkVoidFunction)SetEvent; + if (!strcmp(name, "ResetEvent")) return (PFN_vkVoidFunction)ResetEvent; + if (!strcmp(name, "CreateQueryPool")) return (PFN_vkVoidFunction)CreateQueryPool; + if (!strcmp(name, "DestroyQueryPool")) return (PFN_vkVoidFunction)DestroyQueryPool; + if (!strcmp(name, "GetQueryPoolResults")) return (PFN_vkVoidFunction)GetQueryPoolResults; + if (!strcmp(name, "CreateBuffer")) return (PFN_vkVoidFunction)CreateBuffer; + if (!strcmp(name, "DestroyBuffer")) return (PFN_vkVoidFunction)DestroyBuffer; + if (!strcmp(name, "CreateBufferView")) return (PFN_vkVoidFunction)CreateBufferView; + if (!strcmp(name, "DestroyBufferView")) return (PFN_vkVoidFunction)DestroyBufferView; + if (!strcmp(name, "CreateImage")) return (PFN_vkVoidFunction)CreateImage; + if (!strcmp(name, "DestroyImage")) return (PFN_vkVoidFunction)DestroyImage; + if (!strcmp(name, "GetImageSubresourceLayout")) return (PFN_vkVoidFunction)GetImageSubresourceLayout; + if (!strcmp(name, "CreateImageView")) return (PFN_vkVoidFunction)CreateImageView; + if (!strcmp(name, "DestroyImageView")) return (PFN_vkVoidFunction)DestroyImageView; + if (!strcmp(name, "CreateShaderModule")) return (PFN_vkVoidFunction)CreateShaderModule; + if (!strcmp(name, "DestroyShaderModule")) return (PFN_vkVoidFunction)DestroyShaderModule; + if (!strcmp(name, "CreatePipelineCache")) return (PFN_vkVoidFunction)CreatePipelineCache; + if (!strcmp(name, "DestroyPipelineCache")) return (PFN_vkVoidFunction)DestroyPipelineCache; + if (!strcmp(name, "GetPipelineCacheData")) return (PFN_vkVoidFunction)GetPipelineCacheData; + if (!strcmp(name, "MergePipelineCaches")) return (PFN_vkVoidFunction)MergePipelineCaches; + if (!strcmp(name, "CreateGraphicsPipelines")) return (PFN_vkVoidFunction)CreateGraphicsPipelines; + if (!strcmp(name, "CreateComputePipelines")) return (PFN_vkVoidFunction)CreateComputePipelines; + if (!strcmp(name, "DestroyPipeline")) return (PFN_vkVoidFunction)DestroyPipeline; + if (!strcmp(name, "CreatePipelineLayout")) return (PFN_vkVoidFunction)CreatePipelineLayout; + if (!strcmp(name, "DestroyPipelineLayout")) return (PFN_vkVoidFunction)DestroyPipelineLayout; + if (!strcmp(name, "CreateSampler")) return (PFN_vkVoidFunction)CreateSampler; + if (!strcmp(name, "DestroySampler")) return (PFN_vkVoidFunction)DestroySampler; + if (!strcmp(name, "CreateDescriptorSetLayout")) return (PFN_vkVoidFunction)CreateDescriptorSetLayout; + if (!strcmp(name, "DestroyDescriptorSetLayout")) return (PFN_vkVoidFunction)DestroyDescriptorSetLayout; + if (!strcmp(name, "CreateDescriptorPool")) return (PFN_vkVoidFunction)CreateDescriptorPool; + if (!strcmp(name, "DestroyDescriptorPool")) return (PFN_vkVoidFunction)DestroyDescriptorPool; + if (!strcmp(name, "ResetDescriptorPool")) return (PFN_vkVoidFunction)ResetDescriptorPool; + if (!strcmp(name, "AllocateDescriptorSets")) return (PFN_vkVoidFunction)AllocateDescriptorSets; + if (!strcmp(name, "FreeDescriptorSets")) return (PFN_vkVoidFunction)FreeDescriptorSets; + if (!strcmp(name, "UpdateDescriptorSets")) return (PFN_vkVoidFunction)UpdateDescriptorSets; + if (!strcmp(name, "CreateFramebuffer")) return (PFN_vkVoidFunction)CreateFramebuffer; + if (!strcmp(name, "DestroyFramebuffer")) return (PFN_vkVoidFunction)DestroyFramebuffer; + if (!strcmp(name, "CreateRenderPass")) return (PFN_vkVoidFunction)CreateRenderPass; + if (!strcmp(name, "DestroyRenderPass")) return (PFN_vkVoidFunction)DestroyRenderPass; + if (!strcmp(name, "GetRenderAreaGranularity")) return (PFN_vkVoidFunction)GetRenderAreaGranularity; + if (!strcmp(name, "CreateCommandPool")) return (PFN_vkVoidFunction)CreateCommandPool; + if (!strcmp(name, "DestroyCommandPool")) return (PFN_vkVoidFunction)DestroyCommandPool; + if (!strcmp(name, "ResetCommandPool")) return (PFN_vkVoidFunction)ResetCommandPool; + if (!strcmp(name, "AllocateCommandBuffers")) return (PFN_vkVoidFunction)AllocateCommandBuffers; + if (!strcmp(name, "FreeCommandBuffers")) return (PFN_vkVoidFunction)FreeCommandBuffers; + if (!strcmp(name, "BeginCommandBuffer")) return (PFN_vkVoidFunction)BeginCommandBuffer; + if (!strcmp(name, "EndCommandBuffer")) return (PFN_vkVoidFunction)EndCommandBuffer; + if (!strcmp(name, "ResetCommandBuffer")) return (PFN_vkVoidFunction)ResetCommandBuffer; + if (!strcmp(name, "CmdBindPipeline")) return (PFN_vkVoidFunction)CmdBindPipeline; + if (!strcmp(name, "CmdSetViewport")) return (PFN_vkVoidFunction)CmdSetViewport; + if (!strcmp(name, "CmdSetScissor")) return (PFN_vkVoidFunction)CmdSetScissor; + if (!strcmp(name, "CmdSetLineWidth")) return (PFN_vkVoidFunction)CmdSetLineWidth; + if (!strcmp(name, "CmdSetDepthBias")) return (PFN_vkVoidFunction)CmdSetDepthBias; + if (!strcmp(name, "CmdSetBlendConstants")) return (PFN_vkVoidFunction)CmdSetBlendConstants; + if (!strcmp(name, "CmdSetDepthBounds")) return (PFN_vkVoidFunction)CmdSetDepthBounds; + if (!strcmp(name, "CmdSetStencilCompareMask")) return (PFN_vkVoidFunction)CmdSetStencilCompareMask; + if (!strcmp(name, "CmdSetStencilWriteMask")) return (PFN_vkVoidFunction)CmdSetStencilWriteMask; + if (!strcmp(name, "CmdSetStencilReference")) return (PFN_vkVoidFunction)CmdSetStencilReference; + if (!strcmp(name, "CmdBindDescriptorSets")) return (PFN_vkVoidFunction)CmdBindDescriptorSets; + if (!strcmp(name, "CmdBindIndexBuffer")) return (PFN_vkVoidFunction)CmdBindIndexBuffer; + if (!strcmp(name, "CmdBindVertexBuffers")) return (PFN_vkVoidFunction)CmdBindVertexBuffers; + if (!strcmp(name, "CmdDraw")) return (PFN_vkVoidFunction)CmdDraw; + if (!strcmp(name, "CmdDrawIndexed")) return (PFN_vkVoidFunction)CmdDrawIndexed; + if (!strcmp(name, "CmdDrawIndirect")) return (PFN_vkVoidFunction)CmdDrawIndirect; + if (!strcmp(name, "CmdDrawIndexedIndirect")) return (PFN_vkVoidFunction)CmdDrawIndexedIndirect; + if (!strcmp(name, "CmdDispatch")) return (PFN_vkVoidFunction)CmdDispatch; + if (!strcmp(name, "CmdDispatchIndirect")) return (PFN_vkVoidFunction)CmdDispatchIndirect; + if (!strcmp(name, "CmdCopyBuffer")) return (PFN_vkVoidFunction)CmdCopyBuffer; + if (!strcmp(name, "CmdCopyImage")) return (PFN_vkVoidFunction)CmdCopyImage; + if (!strcmp(name, "CmdBlitImage")) return (PFN_vkVoidFunction)CmdBlitImage; + if (!strcmp(name, "CmdCopyBufferToImage")) return (PFN_vkVoidFunction)CmdCopyBufferToImage; + if (!strcmp(name, "CmdCopyImageToBuffer")) return (PFN_vkVoidFunction)CmdCopyImageToBuffer; + if (!strcmp(name, "CmdUpdateBuffer")) return (PFN_vkVoidFunction)CmdUpdateBuffer; + if (!strcmp(name, "CmdFillBuffer")) return (PFN_vkVoidFunction)CmdFillBuffer; + if (!strcmp(name, "CmdClearColorImage")) return (PFN_vkVoidFunction)CmdClearColorImage; + if (!strcmp(name, "CmdClearDepthStencilImage")) return (PFN_vkVoidFunction)CmdClearDepthStencilImage; + if (!strcmp(name, "CmdClearAttachments")) return (PFN_vkVoidFunction)CmdClearAttachments; + if (!strcmp(name, "CmdResolveImage")) return (PFN_vkVoidFunction)CmdResolveImage; + if (!strcmp(name, "CmdSetEvent")) return (PFN_vkVoidFunction)CmdSetEvent; + if (!strcmp(name, "CmdResetEvent")) return (PFN_vkVoidFunction)CmdResetEvent; + if (!strcmp(name, "CmdWaitEvents")) return (PFN_vkVoidFunction)CmdWaitEvents; + if (!strcmp(name, "CmdPipelineBarrier")) return (PFN_vkVoidFunction)CmdPipelineBarrier; + if (!strcmp(name, "CmdBeginQuery")) return (PFN_vkVoidFunction)CmdBeginQuery; + if (!strcmp(name, "CmdEndQuery")) return (PFN_vkVoidFunction)CmdEndQuery; + if (!strcmp(name, "CmdResetQueryPool")) return (PFN_vkVoidFunction)CmdResetQueryPool; + if (!strcmp(name, "CmdWriteTimestamp")) return (PFN_vkVoidFunction)CmdWriteTimestamp; + if (!strcmp(name, "CmdCopyQueryPoolResults")) return (PFN_vkVoidFunction)CmdCopyQueryPoolResults; + if (!strcmp(name, "CmdPushConstants")) return (PFN_vkVoidFunction)CmdPushConstants; + if (!strcmp(name, "CmdBeginRenderPass")) return (PFN_vkVoidFunction)CmdBeginRenderPass; + if (!strcmp(name, "CmdNextSubpass")) return (PFN_vkVoidFunction)CmdNextSubpass; + if (!strcmp(name, "CmdEndRenderPass")) return (PFN_vkVoidFunction)CmdEndRenderPass; + if (!strcmp(name, "CmdExecuteCommands")) return (PFN_vkVoidFunction)CmdExecuteCommands; + if (!strcmp(name, "DebugMarkerSetObjectTagEXT")) return (PFN_vkVoidFunction)DebugMarkerSetObjectTagEXT; + if (!strcmp(name, "DebugMarkerSetObjectNameEXT")) return (PFN_vkVoidFunction)DebugMarkerSetObjectNameEXT; + if (!strcmp(name, "CmdDebugMarkerBeginEXT")) return (PFN_vkVoidFunction)CmdDebugMarkerBeginEXT; + if (!strcmp(name, "CmdDebugMarkerEndEXT")) return (PFN_vkVoidFunction)CmdDebugMarkerEndEXT; + if (!strcmp(name, "CmdDebugMarkerInsertEXT")) return (PFN_vkVoidFunction)CmdDebugMarkerInsertEXT; #ifdef VK_USE_PLATFORM_WIN32_KHR - if (!strcmp(name, "GetMemoryWin32HandleNV")) - return (PFN_vkVoidFunction)GetMemoryWin32HandleNV; -#endif // VK_USE_PLATFORM_WIN32_KHR - if (!strcmp(name, "CmdDrawIndirectCountAMD")) - return (PFN_vkVoidFunction)CmdDrawIndirectCountAMD; - if (!strcmp(name, "CmdDrawIndexedIndirectCountAMD")) - return (PFN_vkVoidFunction)CmdDrawIndexedIndirectCountAMD; + if (!strcmp(name, "GetMemoryWin32HandleNV")) return (PFN_vkVoidFunction)GetMemoryWin32HandleNV; +#endif // VK_USE_PLATFORM_WIN32_KHR + if (!strcmp(name, "CmdDrawIndirectCountAMD")) return (PFN_vkVoidFunction)CmdDrawIndirectCountAMD; + if (!strcmp(name, "CmdDrawIndexedIndirectCountAMD")) return (PFN_vkVoidFunction)CmdDrawIndexedIndirectCountAMD; return NULL; } static inline PFN_vkVoidFunction InterceptCoreInstanceCommand(const char *name) { - if (!name || name[0] != 'v' || name[1] != 'k') - return NULL; + if (!name || name[0] != 'v' || name[1] != 'k') return NULL; name += 2; - if (!strcmp(name, "CreateInstance")) - return (PFN_vkVoidFunction)CreateInstance; - if (!strcmp(name, "DestroyInstance")) - return (PFN_vkVoidFunction)DestroyInstance; - if (!strcmp(name, "EnumeratePhysicalDevices")) - return (PFN_vkVoidFunction)EnumeratePhysicalDevices; - if (!strcmp(name, "_layerGetPhysicalDeviceProcAddr")) - return (PFN_vkVoidFunction)GetPhysicalDeviceProcAddr; - if (!strcmp(name, "GetPhysicalDeviceFeatures")) - return (PFN_vkVoidFunction)GetPhysicalDeviceFeatures; - if (!strcmp(name, "GetPhysicalDeviceFormatProperties")) - return (PFN_vkVoidFunction)GetPhysicalDeviceFormatProperties; - if (!strcmp(name, "GetPhysicalDeviceImageFormatProperties")) - return (PFN_vkVoidFunction)GetPhysicalDeviceImageFormatProperties; - if (!strcmp(name, "GetPhysicalDeviceProperties")) - return (PFN_vkVoidFunction)GetPhysicalDeviceProperties; - if (!strcmp(name, "GetPhysicalDeviceQueueFamilyProperties")) - return (PFN_vkVoidFunction)GetPhysicalDeviceQueueFamilyProperties; - if (!strcmp(name, "GetPhysicalDeviceMemoryProperties")) - return (PFN_vkVoidFunction)GetPhysicalDeviceMemoryProperties; - if (!strcmp(name, "GetInstanceProcAddr")) - return (PFN_vkVoidFunction)GetInstanceProcAddr; - if (!strcmp(name, "CreateDevice")) - return (PFN_vkVoidFunction)CreateDevice; - if (!strcmp(name, "EnumerateInstanceExtensionProperties")) - return (PFN_vkVoidFunction)EnumerateInstanceExtensionProperties; - if (!strcmp(name, "EnumerateInstanceLayerProperties")) - return (PFN_vkVoidFunction)EnumerateInstanceLayerProperties; - if (!strcmp(name, "EnumerateDeviceLayerProperties")) - return (PFN_vkVoidFunction)EnumerateDeviceLayerProperties; + if (!strcmp(name, "CreateInstance")) return (PFN_vkVoidFunction)CreateInstance; + if (!strcmp(name, "DestroyInstance")) return (PFN_vkVoidFunction)DestroyInstance; + if (!strcmp(name, "EnumeratePhysicalDevices")) return (PFN_vkVoidFunction)EnumeratePhysicalDevices; + if (!strcmp(name, "_layerGetPhysicalDeviceProcAddr")) return (PFN_vkVoidFunction)GetPhysicalDeviceProcAddr; + if (!strcmp(name, "GetPhysicalDeviceFeatures")) return (PFN_vkVoidFunction)GetPhysicalDeviceFeatures; + if (!strcmp(name, "GetPhysicalDeviceFormatProperties")) return (PFN_vkVoidFunction)GetPhysicalDeviceFormatProperties; + if (!strcmp(name, "GetPhysicalDeviceImageFormatProperties")) return (PFN_vkVoidFunction)GetPhysicalDeviceImageFormatProperties; + if (!strcmp(name, "GetPhysicalDeviceProperties")) return (PFN_vkVoidFunction)GetPhysicalDeviceProperties; + if (!strcmp(name, "GetPhysicalDeviceQueueFamilyProperties")) return (PFN_vkVoidFunction)GetPhysicalDeviceQueueFamilyProperties; + if (!strcmp(name, "GetPhysicalDeviceMemoryProperties")) return (PFN_vkVoidFunction)GetPhysicalDeviceMemoryProperties; + if (!strcmp(name, "GetInstanceProcAddr")) return (PFN_vkVoidFunction)GetInstanceProcAddr; + if (!strcmp(name, "CreateDevice")) return (PFN_vkVoidFunction)CreateDevice; + if (!strcmp(name, "EnumerateInstanceExtensionProperties")) return (PFN_vkVoidFunction)EnumerateInstanceExtensionProperties; + if (!strcmp(name, "EnumerateInstanceLayerProperties")) return (PFN_vkVoidFunction)EnumerateInstanceLayerProperties; + if (!strcmp(name, "EnumerateDeviceLayerProperties")) return (PFN_vkVoidFunction)EnumerateDeviceLayerProperties; if (!strcmp(name, "GetPhysicalDeviceSparseImageFormatProperties")) return (PFN_vkVoidFunction)GetPhysicalDeviceSparseImageFormatProperties; if (!strcmp(name, "GetPhysicalDeviceExternalImageFormatPropertiesNV")) @@ -4700,38 +4554,25 @@ static inline PFN_vkVoidFunction InterceptDeviceExtensionCommand(const char *nam if (device) { layer_data *device_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); - if (!name || name[0] != 'v' || name[1] != 'k') - return NULL; + if (!name || name[0] != 'v' || name[1] != 'k') return NULL; name += 2; if (device_data->nvx_device_generated_commands_enabled) { - if (!strcmp(name, "CmdProcessCommandsNVX")) - return (PFN_vkVoidFunction)CmdProcessCommandsNVX; - if (!strcmp(name, "CmdReserveSpaceForCommandsNVX")) - return (PFN_vkVoidFunction)CmdReserveSpaceForCommandsNVX; - if (!strcmp(name, "CreateIndirectCommandsLayoutNVX")) - return (PFN_vkVoidFunction)CreateIndirectCommandsLayoutNVX; - if (!strcmp(name, "DestroyIndirectCommandsLayoutNVX")) - return (PFN_vkVoidFunction)DestroyIndirectCommandsLayoutNVX; - if (!strcmp(name, "CreateObjectTableNVX")) - return (PFN_vkVoidFunction)CreateObjectTableNVX; - if (!strcmp(name, "DestroyObjectTableNVX")) - return (PFN_vkVoidFunction)DestroyObjectTableNVX; - if (!strcmp(name, "RegisterObjectsNVX")) - return (PFN_vkVoidFunction)RegisterObjectsNVX; - if (!strcmp(name, "UnregisterObjectsNVX")) - return (PFN_vkVoidFunction)UnregisterObjectsNVX; + if (!strcmp(name, "CmdProcessCommandsNVX")) return (PFN_vkVoidFunction)CmdProcessCommandsNVX; + if (!strcmp(name, "CmdReserveSpaceForCommandsNVX")) return (PFN_vkVoidFunction)CmdReserveSpaceForCommandsNVX; + if (!strcmp(name, "CreateIndirectCommandsLayoutNVX")) return (PFN_vkVoidFunction)CreateIndirectCommandsLayoutNVX; + if (!strcmp(name, "DestroyIndirectCommandsLayoutNVX")) return (PFN_vkVoidFunction)DestroyIndirectCommandsLayoutNVX; + if (!strcmp(name, "CreateObjectTableNVX")) return (PFN_vkVoidFunction)CreateObjectTableNVX; + if (!strcmp(name, "DestroyObjectTableNVX")) return (PFN_vkVoidFunction)DestroyObjectTableNVX; + if (!strcmp(name, "RegisterObjectsNVX")) return (PFN_vkVoidFunction)RegisterObjectsNVX; + if (!strcmp(name, "UnregisterObjectsNVX")) return (PFN_vkVoidFunction)UnregisterObjectsNVX; } if (device_data->ext_display_control_enabled) { - if (!strcmp(name, "DisplayPowerControlEXT")) - return (PFN_vkVoidFunction)DisplayPowerControlEXT; - if (!strcmp(name, "RegisterDeviceEventEXT")) - return (PFN_vkVoidFunction)RegisterDeviceEventEXT; - if (!strcmp(name, "RegisterDisplayEventEXT")) - return (PFN_vkVoidFunction)RegisterDisplayEventEXT; - if (!strcmp(name, "GetSwapchainCounterEXT")) - return (PFN_vkVoidFunction)GetSwapchainCounterEXT; + if (!strcmp(name, "DisplayPowerControlEXT")) return (PFN_vkVoidFunction)DisplayPowerControlEXT; + if (!strcmp(name, "RegisterDeviceEventEXT")) return (PFN_vkVoidFunction)RegisterDeviceEventEXT; + if (!strcmp(name, "RegisterDisplayEventEXT")) return (PFN_vkVoidFunction)RegisterDisplayEventEXT; + if (!strcmp(name, "GetSwapchainCounterEXT")) return (PFN_vkVoidFunction)GetSwapchainCounterEXT; } } @@ -4739,39 +4580,31 @@ static inline PFN_vkVoidFunction InterceptDeviceExtensionCommand(const char *nam } static inline PFN_vkVoidFunction InterceptInstanceExtensionCommand(const char *name) { - if (!name || name[0] != 'v' || name[1] != 'k') - return NULL; + if (!name || name[0] != 'v' || name[1] != 'k') return NULL; name += 2; // VK_KHR_get_physical_device_properties2 Extension - if (!strcmp(name, "GetPhysicalDeviceFeatures2KHR")) - return (PFN_vkVoidFunction)GetPhysicalDeviceFeatures2KHR; - if (!strcmp(name, "GetPhysicalDeviceProperties2KHR")) - return (PFN_vkVoidFunction)GetPhysicalDeviceProperties2KHR; - if (!strcmp(name, "GetPhysicalDeviceFormatProperties2KHR")) - return (PFN_vkVoidFunction)GetPhysicalDeviceFormatProperties2KHR; + if (!strcmp(name, "GetPhysicalDeviceFeatures2KHR")) return (PFN_vkVoidFunction)GetPhysicalDeviceFeatures2KHR; + if (!strcmp(name, "GetPhysicalDeviceProperties2KHR")) return (PFN_vkVoidFunction)GetPhysicalDeviceProperties2KHR; + if (!strcmp(name, "GetPhysicalDeviceFormatProperties2KHR")) return (PFN_vkVoidFunction)GetPhysicalDeviceFormatProperties2KHR; if (!strcmp(name, "GetPhysicalDeviceImageFormatProperties2KHR")) return (PFN_vkVoidFunction)GetPhysicalDeviceImageFormatProperties2KHR; if (!strcmp(name, "GetPhysicalDeviceQueueFamilyProperties2KHR")) return (PFN_vkVoidFunction)GetPhysicalDeviceQueueFamilyProperties2KHR; - if (!strcmp(name, "GetPhysicalDeviceMemoryProperties2KHR")) - return (PFN_vkVoidFunction)GetPhysicalDeviceMemoryProperties2KHR; + if (!strcmp(name, "GetPhysicalDeviceMemoryProperties2KHR")) return (PFN_vkVoidFunction)GetPhysicalDeviceMemoryProperties2KHR; if (!strcmp(name, "GetPhysicalDeviceSparseImageFormatProperties2KHR")) return (PFN_vkVoidFunction)GetPhysicalDeviceSparseImageFormatProperties2KHR; // VK_NVX_device_generated_commands Extension if (!strcmp(name, "GetPhysicalDeviceGeneratedCommandsPropertiesNVX")) return (PFN_vkVoidFunction)GetPhysicalDeviceGeneratedCommandsPropertiesNVX; // VK_EXT_direct_mode_display Extension - if (!strcmp(name, "ReleaseDisplayEXT")) - return (PFN_vkVoidFunction)ReleaseDisplayEXT; + if (!strcmp(name, "ReleaseDisplayEXT")) return (PFN_vkVoidFunction)ReleaseDisplayEXT; #ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT // VK_EXT_acquire_xlib_display Extension - if (!strcmp(name, "AcquireXlibDisplayEXT")) - return (PFN_vkVoidFunction)AcquireXlibDisplayEXT; - if (!strcmp(name, "GetRandROutputDisplayEXT")) - return (PFN_vkVoidFunction)GetRandROutputDisplayEXT; -#endif // VK_USE_PLATFORM_XLIB_XRANDR_EXT + if (!strcmp(name, "AcquireXlibDisplayEXT")) return (PFN_vkVoidFunction)AcquireXlibDisplayEXT; + if (!strcmp(name, "GetRandROutputDisplayEXT")) return (PFN_vkVoidFunction)GetRandROutputDisplayEXT; +#endif // VK_USE_PLATFORM_XLIB_XRANDR_EXT // VK_EXT_display_surface_counter Extension if (!strcmp(name, "GetPhysicalDeviceSurfaceCapabilities2EXT")) return (PFN_vkVoidFunction)GetPhysicalDeviceSurfaceCapabilities2EXT; @@ -4784,16 +4617,11 @@ static inline PFN_vkVoidFunction InterceptWsiEnabledCommand(const char *name, Vk layer_data *device_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); if (device_data->wsi_enabled) { - if (!strcmp("vkCreateSwapchainKHR", name)) - return reinterpret_cast(CreateSwapchainKHR); - if (!strcmp("vkDestroySwapchainKHR", name)) - return reinterpret_cast(DestroySwapchainKHR); - if (!strcmp("vkGetSwapchainImagesKHR", name)) - return reinterpret_cast(GetSwapchainImagesKHR); - if (!strcmp("vkAcquireNextImageKHR", name)) - return reinterpret_cast(AcquireNextImageKHR); - if (!strcmp("vkQueuePresentKHR", name)) - return reinterpret_cast(QueuePresentKHR); + if (!strcmp("vkCreateSwapchainKHR", name)) return reinterpret_cast(CreateSwapchainKHR); + if (!strcmp("vkDestroySwapchainKHR", name)) return reinterpret_cast(DestroySwapchainKHR); + if (!strcmp("vkGetSwapchainImagesKHR", name)) return reinterpret_cast(GetSwapchainImagesKHR); + if (!strcmp("vkAcquireNextImageKHR", name)) return reinterpret_cast(AcquireNextImageKHR); + if (!strcmp("vkQueuePresentKHR", name)) return reinterpret_cast(QueuePresentKHR); } if (device_data->wsi_display_swapchain_enabled) { @@ -4811,8 +4639,7 @@ static inline PFN_vkVoidFunction InterceptWsiEnabledCommand(const char *name, Vk return reinterpret_cast(GetDisplayPlaneSupportedDisplaysKHR); if (!strcmp("vkGetDisplayModePropertiesKHR", name)) return reinterpret_cast(GetDisplayModePropertiesKHR); - if (!strcmp("vkCreateDisplayModeKHR", name)) - return reinterpret_cast(CreateDisplayModeKHR); + if (!strcmp("vkCreateDisplayModeKHR", name)) return reinterpret_cast(CreateDisplayModeKHR); if (!strcmp("vkGetDisplayPlaneCapabilitiesKHR", name)) return reinterpret_cast(GetDisplayPlaneCapabilitiesKHR); if (!strcmp("vkCreateDisplayPlaneSurfaceKHR", name)) @@ -4886,7 +4713,7 @@ VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetPhysicalDeviceProcAddr(VkInstance in return get_dispatch_table(ot_instance_table_map, instance)->GetPhysicalDeviceProcAddr(instance, funcName); } -} // namespace object_tracker +} // namespace object_tracker // vk_layer_logging.h expects these to be defined VKAPI_ATTR VkResult VKAPI_CALL vkCreateDebugReportCallbackEXT(VkInstance instance, diff --git a/layers/object_tracker.h b/layers/object_tracker.h index 327c527..abbe3c2 100644 --- a/layers/object_tracker.h +++ b/layers/object_tracker.h @@ -32,36 +32,36 @@ namespace object_tracker { // Object Tracker ERROR codes enum OBJECT_TRACK_ERROR { - OBJTRACK_NONE, // Used for INFO & other non-error messages - OBJTRACK_UNKNOWN_OBJECT, // Updating uses of object that's not in global object list - OBJTRACK_INTERNAL_ERROR, // Bug with data tracking within the layer - OBJTRACK_OBJECT_LEAK, // OBJECT was not correctly freed/destroyed - OBJTRACK_INVALID_OBJECT, // Object used that has never been created - OBJTRACK_DESCRIPTOR_POOL_MISMATCH, // Descriptor Pools specified incorrectly - OBJTRACK_COMMAND_POOL_MISMATCH, // Command Pools specified incorrectly - OBJTRACK_ALLOCATOR_MISMATCH, // Created with custom allocator but destroyed without + OBJTRACK_NONE, // Used for INFO & other non-error messages + OBJTRACK_UNKNOWN_OBJECT, // Updating uses of object that's not in global object list + OBJTRACK_INTERNAL_ERROR, // Bug with data tracking within the layer + OBJTRACK_OBJECT_LEAK, // OBJECT was not correctly freed/destroyed + OBJTRACK_INVALID_OBJECT, // Object used that has never been created + OBJTRACK_DESCRIPTOR_POOL_MISMATCH, // Descriptor Pools specified incorrectly + OBJTRACK_COMMAND_POOL_MISMATCH, // Command Pools specified incorrectly + OBJTRACK_ALLOCATOR_MISMATCH, // Created with custom allocator but destroyed without }; // Object Status -- used to track state of individual objects typedef VkFlags ObjectStatusFlags; enum ObjectStatusFlagBits { - OBJSTATUS_NONE = 0x00000000, // No status is set - OBJSTATUS_FENCE_IS_SUBMITTED = 0x00000001, // Fence has been submitted - OBJSTATUS_VIEWPORT_BOUND = 0x00000002, // Viewport state object has been bound - OBJSTATUS_RASTER_BOUND = 0x00000004, // Viewport state object has been bound - OBJSTATUS_COLOR_BLEND_BOUND = 0x00000008, // Viewport state object has been bound - OBJSTATUS_DEPTH_STENCIL_BOUND = 0x00000010, // Viewport state object has been bound - OBJSTATUS_GPU_MEM_MAPPED = 0x00000020, // Memory object is currently mapped - OBJSTATUS_COMMAND_BUFFER_SECONDARY = 0x00000040, // Command Buffer is of type SECONDARY - OBJSTATUS_CUSTOM_ALLOCATOR = 0x00000080, // Allocated with custom allocator + OBJSTATUS_NONE = 0x00000000, // No status is set + OBJSTATUS_FENCE_IS_SUBMITTED = 0x00000001, // Fence has been submitted + OBJSTATUS_VIEWPORT_BOUND = 0x00000002, // Viewport state object has been bound + OBJSTATUS_RASTER_BOUND = 0x00000004, // Viewport state object has been bound + OBJSTATUS_COLOR_BLEND_BOUND = 0x00000008, // Viewport state object has been bound + OBJSTATUS_DEPTH_STENCIL_BOUND = 0x00000010, // Viewport state object has been bound + OBJSTATUS_GPU_MEM_MAPPED = 0x00000020, // Memory object is currently mapped + OBJSTATUS_COMMAND_BUFFER_SECONDARY = 0x00000040, // Command Buffer is of type SECONDARY + OBJSTATUS_CUSTOM_ALLOCATOR = 0x00000080, // Allocated with custom allocator }; // Object and state information structure struct OBJTRACK_NODE { - uint64_t handle; // Object handle (new) - VkDebugReportObjectTypeEXT object_type; // Object type identifier - ObjectStatusFlags status; // Object state - uint64_t parent_object; // Parent object + uint64_t handle; // Object handle (new) + VkDebugReportObjectTypeEXT object_type; // Object type identifier + ObjectStatusFlags status; // Object state + uint64_t parent_object; // Parent object }; // Track Queue information @@ -119,10 +119,20 @@ struct layer_data { VkLayerDispatchTable dispatch_table; // Default constructor layer_data() - : instance(nullptr), physical_device(nullptr), num_objects{}, num_total_objects(0), report_data(nullptr), - wsi_enabled(false), wsi_display_swapchain_enabled(false), wsi_display_extension_enabled(false), - objtrack_extensions_enabled(false), num_tmp_callbacks(0), tmp_dbg_create_infos(nullptr), tmp_callbacks(nullptr), - object_map{}, dispatch_table{} { + : instance(nullptr), + physical_device(nullptr), + num_objects{}, + num_total_objects(0), + report_data(nullptr), + wsi_enabled(false), + wsi_display_swapchain_enabled(false), + wsi_display_extension_enabled(false), + objtrack_extensions_enabled(false), + num_tmp_callbacks(0), + tmp_dbg_create_infos(nullptr), + tmp_callbacks(nullptr), + object_map{}, + dispatch_table{} { object_map.resize(VK_DEBUG_REPORT_OBJECT_TYPE_RANGE_SIZE_EXT + 1); } }; @@ -136,36 +146,36 @@ static uint64_t object_track_index = 0; // Array of object name strings for OBJECT_TYPE enum conversion static const char *object_name[VK_DEBUG_REPORT_OBJECT_TYPE_RANGE_SIZE_EXT] = { - "Unknown", // VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN - "Instance", // VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT - "Physical Device", // VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT - "Device", // VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT - "Queue", // VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT - "Semaphore", // VK_DEBUG_REPORT_OBJECT_TYPE_SEMAPHORE_EXT - "Command Buffer", // VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT - "Fence", // VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT - "Device Memory", // VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT - "Buffer", // VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT - "Image", // VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT - "Event", // VK_DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT - "Query Pool", // VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT - "Buffer View", // VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_VIEW_EXT - "Image View", // VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_VIEW_EXT - "Shader Module", // VK_DEBUG_REPORT_OBJECT_TYPE_SHADER_MODULE_EXT - "Pipeline Cache", // VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_CACHE_EXT - "Pipeline Layout", // VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_LAYOUT_EXT - "Render Pass", // VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT - "Pipeline", // VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT - "Descriptor Set Layout", // VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT_EXT - "Sampler", // VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_EXT - "Descriptor Pool", // VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT - "Descriptor Set", // VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT - "Framebuffer", // VK_DEBUG_REPORT_OBJECT_TYPE_FRAMEBUFFER_EXT - "Command Pool", // VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_POOL_EXT - "SurfaceKHR", // VK_DEBUG_REPORT_OBJECT_TYPE_SURFACE_KHR_EXT - "SwapchainKHR", // VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT - "Debug Report"}; // VK_DEBUG_REPORT_OBJECT_TYPE_DEBUG_REPORT_EXT + "Unknown", // VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN + "Instance", // VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT + "Physical Device", // VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT + "Device", // VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT + "Queue", // VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT + "Semaphore", // VK_DEBUG_REPORT_OBJECT_TYPE_SEMAPHORE_EXT + "Command Buffer", // VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT + "Fence", // VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT + "Device Memory", // VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT + "Buffer", // VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT + "Image", // VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT + "Event", // VK_DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT + "Query Pool", // VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT + "Buffer View", // VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_VIEW_EXT + "Image View", // VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_VIEW_EXT + "Shader Module", // VK_DEBUG_REPORT_OBJECT_TYPE_SHADER_MODULE_EXT + "Pipeline Cache", // VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_CACHE_EXT + "Pipeline Layout", // VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_LAYOUT_EXT + "Render Pass", // VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT + "Pipeline", // VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT + "Descriptor Set Layout", // VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT_EXT + "Sampler", // VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_EXT + "Descriptor Pool", // VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT + "Descriptor Set", // VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT + "Framebuffer", // VK_DEBUG_REPORT_OBJECT_TYPE_FRAMEBUFFER_EXT + "Command Pool", // VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_POOL_EXT + "SurfaceKHR", // VK_DEBUG_REPORT_OBJECT_TYPE_SURFACE_KHR_EXT + "SwapchainKHR", // VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT + "Debug Report"}; // VK_DEBUG_REPORT_OBJECT_TYPE_DEBUG_REPORT_EXT #include "vk_dispatch_table_helper.h" -} // namespace object_tracker +} // namespace object_tracker diff --git a/layers/parameter_name.h b/layers/parameter_name.h index b788584..6459b5e 100644 --- a/layers/parameter_name.h +++ b/layers/parameter_name.h @@ -42,7 +42,7 @@ * validate_stype(ParameterName("pCreateInfo[%i].sType", IndexVector{ i }), pCreateInfo[i].sType); */ class ParameterName { - public: + public: /// Container for index values to be used with parameter name string formatting. typedef std::vector IndexVector; @@ -50,7 +50,7 @@ class ParameterName { /// one format specifier for each index value specified. const std::string IndexFormatSpecifier = "%i"; - public: + public: /** * Construct a ParameterName object from a string literal, without formatting. * @@ -105,7 +105,7 @@ class ParameterName { /// Retrive the formatted name string. std::string get_name() const { return (args_.empty()) ? source_ : Format(); } - private: + private: /// Replace the %i format specifiers in the source string with the values from the index vector. std::string Format() const { std::string::size_type current = 0; @@ -140,9 +140,9 @@ class ParameterName { return (count == args_.size()); } - private: - std::string source_; ///< Format string. - IndexVector args_; ///< Array index values for formatting. + private: + std::string source_; ///< Format string. + IndexVector args_; ///< Array index values for formatting. }; -#endif // PARAMETER_NAME_H +#endif // PARAMETER_NAME_H diff --git a/layers/parameter_validation.cpp b/layers/parameter_validation.cpp index 61949c6..6ee9665 100644 --- a/layers/parameter_validation.cpp +++ b/layers/parameter_validation.cpp @@ -101,7 +101,6 @@ static std::unordered_map layer_data_map; static std::unordered_map instance_layer_data_map; static void init_parameter_validation(instance_layer_data *my_data, const VkAllocationCallbacks *pAllocator) { - layer_debug_actions(my_data->report_data, my_data->logging_callback, pAllocator, "lunarg_parameter_validation"); } @@ -1228,7 +1227,6 @@ static bool validate_string(debug_report_data *report_data, const char *apiName, if (result == VK_STRING_ERROR_NONE) { return skip; } else if (result & VK_STRING_ERROR_LENGTH) { - skip = log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, INVALID_USAGE, LayerName, "%s: string %s exceeds max length %d", apiName, stringName.get_name().c_str(), MaxParamCheckerStringLength); @@ -1278,8 +1276,9 @@ static bool validate_queue_family_indices(layer_data *device_data, const char *f const auto &queue_data = device_data->queueFamilyIndexMap.find(indices[i]); if (queue_data == device_data->queueFamilyIndexMap.end()) { skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, - LayerName, "%s: %s[%d] (%d) must be one of the indices specified when the device was " - "created, via the VkDeviceQueueCreateInfo structure.", + LayerName, + "%s: %s[%d] (%d) must be one of the indices specified when the device was " + "created, via the VkDeviceQueueCreateInfo structure.", function_name, parameter_name, i, indices[i]); return false; } @@ -1565,7 +1564,6 @@ static void validateDeviceCreateInfo(VkPhysicalDevice physicalDevice, const VkDe } static void CheckInstanceRegisterExtensions(const VkInstanceCreateInfo *pCreateInfo, instance_layer_data *instance_data) { - for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { auto name = pCreateInfo->ppEnabledExtensionNames[i]; @@ -2503,11 +2501,11 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateImage(VkDevice device, const VkImageCreateI // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) && (pCreateInfo->extent.height != 1) && (pCreateInfo->extent.depth != 1)) { - skip |= - log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, - VALIDATION_ERROR_02129, LayerName, "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both " - "pCreateInfo->extent.height and pCreateInfo->extent.depth must be 1. %s", - validation_error_map[VALIDATION_ERROR_02129]); + skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, + VALIDATION_ERROR_02129, LayerName, + "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both " + "pCreateInfo->extent.height and pCreateInfo->extent.depth must be 1. %s", + validation_error_map[VALIDATION_ERROR_02129]); } if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) { @@ -2620,46 +2618,52 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateImageView(VkDevice device, const VkImageVie if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_1D) || (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_2D)) { if ((pCreateInfo->subresourceRange.layerCount != 1) && (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS)) { - skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, - LayerName, "vkCreateImageView: if pCreateInfo->viewType is VK_IMAGE_TYPE_%dD, " - "pCreateInfo->subresourceRange.layerCount must be 1", - ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_1D) ? 1 : 2)); + skip |= + log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, LayerName, + "vkCreateImageView: if pCreateInfo->viewType is VK_IMAGE_TYPE_%dD, " + "pCreateInfo->subresourceRange.layerCount must be 1", + ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_1D) ? 1 : 2)); } } else if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_1D_ARRAY) || (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_2D_ARRAY)) { if ((pCreateInfo->subresourceRange.layerCount < 1) && (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS)) { - skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, - LayerName, "vkCreateImageView: if pCreateInfo->viewType is VK_IMAGE_TYPE_%dD_ARRAY, " - "pCreateInfo->subresourceRange.layerCount must be >= 1", - ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_1D_ARRAY) ? 1 : 2)); + skip |= + log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, LayerName, + "vkCreateImageView: if pCreateInfo->viewType is VK_IMAGE_TYPE_%dD_ARRAY, " + "pCreateInfo->subresourceRange.layerCount must be >= 1", + ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_1D_ARRAY) ? 1 : 2)); } } else if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE) { if ((pCreateInfo->subresourceRange.layerCount != 6) && (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS)) { - skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, - LayerName, "vkCreateImageView: if pCreateInfo->viewType is VK_IMAGE_TYPE_CUBE, " - "pCreateInfo->subresourceRange.layerCount must be 6"); + skip |= + log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, LayerName, + "vkCreateImageView: if pCreateInfo->viewType is VK_IMAGE_TYPE_CUBE, " + "pCreateInfo->subresourceRange.layerCount must be 6"); } } else if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) { if (((pCreateInfo->subresourceRange.layerCount == 0) || ((pCreateInfo->subresourceRange.layerCount % 6) != 0)) && (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS)) { - skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, - LayerName, "vkCreateImageView: if pCreateInfo->viewType is VK_IMAGE_TYPE_CUBE_ARRAY, " - "pCreateInfo->subresourceRange.layerCount must be a multiple of 6"); + skip |= + log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, LayerName, + "vkCreateImageView: if pCreateInfo->viewType is VK_IMAGE_TYPE_CUBE_ARRAY, " + "pCreateInfo->subresourceRange.layerCount must be a multiple of 6"); } } else if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_3D) { if (pCreateInfo->subresourceRange.baseArrayLayer != 0) { - skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, - LayerName, "vkCreateImageView: if pCreateInfo->viewType is VK_IMAGE_TYPE_3D, " - "pCreateInfo->subresourceRange.baseArrayLayer must be 0"); + skip |= + log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, LayerName, + "vkCreateImageView: if pCreateInfo->viewType is VK_IMAGE_TYPE_3D, " + "pCreateInfo->subresourceRange.baseArrayLayer must be 0"); } if ((pCreateInfo->subresourceRange.layerCount != 1) && (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS)) { - skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, - LayerName, "vkCreateImageView: if pCreateInfo->viewType is VK_IMAGE_TYPE_3D, " - "pCreateInfo->subresourceRange.layerCount must be 1"); + skip |= + log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, LayerName, + "vkCreateImageView: if pCreateInfo->viewType is VK_IMAGE_TYPE_3D, " + "pCreateInfo->subresourceRange.layerCount must be 1"); } } } @@ -3433,12 +3437,12 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateDescriptorSetLayout(VkDevice device, const for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount; ++descriptor_index) { if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) { - skip |= - log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, - __LINE__, REQUIRED_PARAMETER, LayerName, "vkCreateDescriptorSetLayout: required parameter " - "pCreateInfo->pBindings[%d].pImmutableSamplers[%d]" - " specified as VK_NULL_HANDLE", - i, descriptor_index); + skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, + __LINE__, REQUIRED_PARAMETER, LayerName, + "vkCreateDescriptorSetLayout: required parameter " + "pCreateInfo->pBindings[%d].pImmutableSamplers[%d]" + " specified as VK_NULL_HANDLE", + i, descriptor_index); } } } @@ -4721,7 +4725,6 @@ VKAPI_ATTR void VKAPI_CALL CmdResetQueryPool(VkCommandBuffer commandBuffer, VkQu bool PostCmdWriteTimestamp(VkCommandBuffer commandBuffer, VkPipelineStageFlagBits pipelineStage, VkQueryPool queryPool, uint32_t slot) { - ValidateEnumerator(pipelineStage); return true; @@ -4834,8 +4837,7 @@ VKAPI_ATTR VkResult VKAPI_CALL EnumerateInstanceExtensionProperties(const char * VKAPI_ATTR VkResult VKAPI_CALL EnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, const char *pLayerName, uint32_t *pCount, VkExtensionProperties *pProperties) { /* parameter_validation does not have any physical device extensions */ - if (pLayerName && !strcmp(pLayerName, global_layer.layerName)) - return util_GetExtensionProperties(0, NULL, pCount, pProperties); + if (pLayerName && !strcmp(pLayerName, global_layer.layerName)) return util_GetExtensionProperties(0, NULL, pCount, pProperties); assert(physicalDevice); @@ -5112,7 +5114,7 @@ VKAPI_ATTR VkBool32 VKAPI_CALL GetPhysicalDeviceWin32PresentationSupportKHR(VkPh return result; } -#endif // VK_USE_PLATFORM_WIN32_KHR +#endif // VK_USE_PLATFORM_WIN32_KHR #ifdef VK_USE_PLATFORM_XCB_KHR VKAPI_ATTR VkResult VKAPI_CALL CreateXcbSurfaceKHR(VkInstance instance, const VkXcbSurfaceCreateInfoKHR *pCreateInfo, @@ -5159,7 +5161,7 @@ VKAPI_ATTR VkBool32 VKAPI_CALL GetPhysicalDeviceXcbPresentationSupportKHR(VkPhys return result; } -#endif // VK_USE_PLATFORM_XCB_KHR +#endif // VK_USE_PLATFORM_XCB_KHR #ifdef VK_USE_PLATFORM_XLIB_KHR VKAPI_ATTR VkResult VKAPI_CALL CreateXlibSurfaceKHR(VkInstance instance, const VkXlibSurfaceCreateInfoKHR *pCreateInfo, @@ -5205,7 +5207,7 @@ VKAPI_ATTR VkBool32 VKAPI_CALL GetPhysicalDeviceXlibPresentationSupportKHR(VkPhy } return result; } -#endif // VK_USE_PLATFORM_XLIB_KHR +#endif // VK_USE_PLATFORM_XLIB_KHR #ifdef VK_USE_PLATFORM_MIR_KHR VKAPI_ATTR VkResult VKAPI_CALL CreateMirSurfaceKHR(VkInstance instance, const VkMirSurfaceCreateInfoKHR *pCreateInfo, @@ -5249,7 +5251,7 @@ VKAPI_ATTR VkBool32 VKAPI_CALL GetPhysicalDeviceMirPresentationSupportKHR(VkPhys } return result; } -#endif // VK_USE_PLATFORM_MIR_KHR +#endif // VK_USE_PLATFORM_MIR_KHR #ifdef VK_USE_PLATFORM_WAYLAND_KHR VKAPI_ATTR VkResult VKAPI_CALL CreateWaylandSurfaceKHR(VkInstance instance, const VkWaylandSurfaceCreateInfoKHR *pCreateInfo, @@ -5294,7 +5296,7 @@ VKAPI_ATTR VkBool32 VKAPI_CALL GetPhysicalDeviceWaylandPresentationSupportKHR(Vk return result; } -#endif // VK_USE_PLATFORM_WAYLAND_KHR +#endif // VK_USE_PLATFORM_WAYLAND_KHR #ifdef VK_USE_PLATFORM_ANDROID_KHR VKAPI_ATTR VkResult VKAPI_CALL CreateAndroidSurfaceKHR(VkInstance instance, const VkAndroidSurfaceCreateInfoKHR *pCreateInfo, @@ -5318,7 +5320,7 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateAndroidSurfaceKHR(VkInstance instance, cons return result; } -#endif // VK_USE_PLATFORM_ANDROID_KHR +#endif // VK_USE_PLATFORM_ANDROID_KHR VKAPI_ATTR VkResult VKAPI_CALL CreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount, const VkSwapchainCreateInfoKHR *pCreateInfos, @@ -5645,7 +5647,6 @@ VKAPI_ATTR void VKAPI_CALL TrimCommandPoolKHR(VkDevice device, VkCommandPool com #ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT VKAPI_ATTR VkResult VKAPI_CALL AcquireXlibDisplayEXT(VkPhysicalDevice physicalDevice, Display *dpy, VkDisplayKHR display) { - VkResult result = VK_ERROR_VALIDATION_FAILED_EXT; auto my_data = get_my_data_ptr(get_dispatch_key(physicalDevice), instance_layer_data_map); assert(my_data != NULL); @@ -5662,7 +5663,6 @@ VKAPI_ATTR VkResult VKAPI_CALL AcquireXlibDisplayEXT(VkPhysicalDevice physicalDe VKAPI_ATTR VkResult VKAPI_CALL GetRandROutputDisplayEXT(VkPhysicalDevice physicalDevice, Display *dpy, RROutput rrOutput, VkDisplayKHR *pDisplay) { - VkResult result = VK_ERROR_VALIDATION_FAILED_EXT; auto my_data = get_my_data_ptr(get_dispatch_key(physicalDevice), instance_layer_data_map); assert(my_data != NULL); @@ -5676,7 +5676,7 @@ VKAPI_ATTR VkResult VKAPI_CALL GetRandROutputDisplayEXT(VkPhysicalDevice physica } return result; } -#endif // VK_USE_PLATFORM_XLIB_XRANDR_EXT +#endif // VK_USE_PLATFORM_XLIB_XRANDR_EXT // Definitions for the VK_EXT_debug_marker Extension @@ -5759,14 +5759,13 @@ VKAPI_ATTR void VKAPI_CALL CmdDebugMarkerInsertEXT(VkCommandBuffer commandBuffer // Definitions for the VK_EXT_direct_mode_display extension VKAPI_ATTR VkResult VKAPI_CALL ReleaseDisplayEXT(VkPhysicalDevice physicalDevice, VkDisplayKHR display) { - VkResult result = VK_ERROR_VALIDATION_FAILED_EXT; auto my_data = get_my_data_ptr(get_dispatch_key(physicalDevice), instance_layer_data_map); assert(my_data != NULL); bool skip = false; skip |= require_instance_extension(physicalDevice, &instance_extension_enables::ext_direct_mode_display_enabled, "vkReleaseDisplayEXT", VK_EXT_DIRECT_MODE_DISPLAY_EXTENSION_NAME); -#if 0 // Validation not automatically generated +#if 0 // Validation not automatically generated skip |= parameter_validation_vkReleaseDisplayEXT(my_data->report_data, display); #endif if (!skip) { @@ -5780,7 +5779,6 @@ VKAPI_ATTR VkResult VKAPI_CALL ReleaseDisplayEXT(VkPhysicalDevice physicalDevice VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceSurfaceCapabilities2EXT(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, VkSurfaceCapabilities2EXT *pSurfaceCapabilities) { - VkResult result = VK_ERROR_VALIDATION_FAILED_EXT; auto my_data = get_my_data_ptr(get_dispatch_key(physicalDevice), instance_layer_data_map); assert(my_data != NULL); @@ -5801,7 +5799,6 @@ VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceExternalImageFormatPropertiesNV( VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkExternalMemoryHandleTypeFlagsNV externalHandleType, VkExternalImageFormatPropertiesNV *pExternalImageFormatProperties) { - VkResult result = VK_ERROR_VALIDATION_FAILED_EXT; bool skip = false; auto my_data = get_my_data_ptr(get_dispatch_key(physicalDevice), instance_layer_data_map); @@ -5829,7 +5826,6 @@ VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceExternalImageFormatPropertiesNV( #ifdef VK_USE_PLATFORM_WIN32_KHR VKAPI_ATTR VkResult VKAPI_CALL GetMemoryWin32HandleNV(VkDevice device, VkDeviceMemory memory, VkExternalMemoryHandleTypeFlagsNV handleType, HANDLE *pHandle) { - VkResult result = VK_ERROR_VALIDATION_FAILED_EXT; bool skip = false; layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); @@ -5846,7 +5842,7 @@ VKAPI_ATTR VkResult VKAPI_CALL GetMemoryWin32HandleNV(VkDevice device, VkDeviceM return result; } -#endif // VK_USE_PLATFORM_WIN32_KHR +#endif // VK_USE_PLATFORM_WIN32_KHR // VK_NVX_device_generated_commands Extension @@ -5902,7 +5898,7 @@ VKAPI_ATTR void VKAPI_CALL DestroyIndirectCommandsLayoutNVX(VkDevice device, VkI assert(my_data != NULL); skip |= require_device_extension(my_data, my_data->enables.nvx_device_generated_commands, "vkDestroyIndirectCommandsLayoutNVX", VK_NVX_DEVICE_GENERATED_COMMANDS_EXTENSION_NAME); -#if 0 // Validation not automatically generated +#if 0 // Validation not automatically generated skip |= parameter_validation_vkDestroyIndirectCommandsLayoutNVX(my_data->report_data, indirectCommandsLayout, pAllocator); #endif if (!skip) { @@ -5933,7 +5929,7 @@ VKAPI_ATTR void VKAPI_CALL DestroyObjectTableNVX(VkDevice device, VkObjectTableN assert(my_data != NULL); skip |= require_device_extension(my_data, my_data->enables.nvx_device_generated_commands, "vkDestroyObjectTableNVX", VK_NVX_DEVICE_GENERATED_COMMANDS_EXTENSION_NAME); -#if 0 // Validation not automatically generated +#if 0 // Validation not automatically generated skip |= parameter_validation_vkDestroyObjectTableNVX(my_data->report_data, objectTable, pAllocator); #endif if (!skip) { @@ -6010,49 +6006,38 @@ VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetDeviceProcAddr(VkDevice device, cons } PFN_vkVoidFunction proc = intercept_core_device_command(funcName); - if (proc) - return proc; + if (proc) return proc; proc = InterceptWsiEnabledCommand(funcName, device); - if (proc) - return proc; + if (proc) return proc; proc = intercept_extension_device_command(funcName, device); - if (proc) - return proc; + if (proc) return proc; - if (!data->dispatch_table.GetDeviceProcAddr) - return nullptr; + if (!data->dispatch_table.GetDeviceProcAddr) return nullptr; return data->dispatch_table.GetDeviceProcAddr(device, funcName); } VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetInstanceProcAddr(VkInstance instance, const char *funcName) { PFN_vkVoidFunction proc = intercept_core_instance_command(funcName); - if (!proc) - proc = intercept_core_device_command(funcName); + if (!proc) proc = intercept_core_device_command(funcName); - if (!proc) - proc = InterceptWsiEnabledCommand(funcName, VkDevice(VK_NULL_HANDLE)); + if (!proc) proc = InterceptWsiEnabledCommand(funcName, VkDevice(VK_NULL_HANDLE)); - if (proc) - return proc; + if (proc) return proc; assert(instance); auto data = get_my_data_ptr(get_dispatch_key(instance), instance_layer_data_map); proc = debug_report_get_instance_proc_addr(data->report_data, funcName); - if (!proc) - proc = InterceptWsiEnabledCommand(funcName, instance); + if (!proc) proc = InterceptWsiEnabledCommand(funcName, instance); - if (!proc) - proc = intercept_extension_instance_command(funcName, instance); + if (!proc) proc = intercept_extension_instance_command(funcName, instance); - if (proc) - return proc; + if (proc) return proc; - if (!data->dispatch_table.GetInstanceProcAddr) - return nullptr; + if (!data->dispatch_table.GetInstanceProcAddr) return nullptr; return data->dispatch_table.GetInstanceProcAddr(instance, funcName); } @@ -6060,8 +6045,7 @@ VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetPhysicalDeviceProcAddr(VkInstance in assert(instance); auto data = get_my_data_ptr(get_dispatch_key(instance), instance_layer_data_map); - if (!data->dispatch_table.GetPhysicalDeviceProcAddr) - return nullptr; + if (!data->dispatch_table.GetPhysicalDeviceProcAddr) return nullptr; return data->dispatch_table.GetPhysicalDeviceProcAddr(instance, funcName); } @@ -6096,8 +6080,7 @@ static PFN_vkVoidFunction intercept_core_instance_command(const char *name) { }; for (size_t i = 0; i < ARRAY_SIZE(core_instance_commands); i++) { - if (!strcmp(core_instance_commands[i].name, name)) - return core_instance_commands[i].proc; + if (!strcmp(core_instance_commands[i].name, name)) return core_instance_commands[i].proc; } return nullptr; @@ -6231,7 +6214,7 @@ static PFN_vkVoidFunction intercept_core_device_command(const char *name) { {"vkCmdDebugMarkerInsertEXT", reinterpret_cast(CmdDebugMarkerInsertEXT)}, #ifdef VK_USE_PLATFORM_WIN32_KHR {"vkGetMemoryWin32HandleNV", reinterpret_cast(GetMemoryWin32HandleNV)}, -#endif // VK_USE_PLATFORM_WIN32_KHR +#endif // VK_USE_PLATFORM_WIN32_KHR // NVX_device_generated_commands {"vkCmdProcessCommandsNVX", reinterpret_cast(CmdProcessCommandsNVX)}, {"vkCmdReserveSpaceForCommandsNVX", reinterpret_cast(CmdReserveSpaceForCommandsNVX)}, @@ -6244,8 +6227,7 @@ static PFN_vkVoidFunction intercept_core_device_command(const char *name) { }; for (size_t i = 0; i < ARRAY_SIZE(core_device_commands); i++) { - if (!strcmp(core_device_commands[i].name, name)) - return core_device_commands[i].proc; + if (!strcmp(core_device_commands[i].name, name)) return core_device_commands[i].proc; } return nullptr; @@ -6266,8 +6248,7 @@ static PFN_vkVoidFunction InterceptWsiEnabledCommand(const char *name, VkDevice if (device) { for (size_t i = 0; i < ARRAY_SIZE(wsi_device_commands); i++) { - if (!strcmp(wsi_device_commands[i].name, name)) - return wsi_device_commands[i].proc; + if (!strcmp(wsi_device_commands[i].name, name)) return wsi_device_commands[i].proc; } if (!strcmp("vkCreateSharedSwapchainsKHR", name)) { @@ -6329,8 +6310,7 @@ static PFN_vkVoidFunction InterceptWsiEnabledCommand(const char *name, VkInstanc }; for (size_t i = 0; i < ARRAY_SIZE(wsi_instance_commands); i++) { - if (!strcmp(wsi_instance_commands[i].name, name)) - return wsi_instance_commands[i].proc; + if (!strcmp(wsi_instance_commands[i].name, name)) return wsi_instance_commands[i].proc; } return nullptr; @@ -6360,8 +6340,7 @@ static PFN_vkVoidFunction intercept_extension_instance_command(const char *name, }; for (size_t i = 0; i < ARRAY_SIZE(extension_instance_commands); i++) { - if (!strcmp(extension_instance_commands[i].name, name)) - return extension_instance_commands[i].proc; + if (!strcmp(extension_instance_commands[i].name, name)) return extension_instance_commands[i].proc; } return nullptr; @@ -6377,7 +6356,7 @@ static PFN_vkVoidFunction intercept_extension_device_command(const char *name, V #ifdef VK_USE_PLATFORM_WIN32_KHR // NV_external_memory_win32 {"vkGetMemoryWin32HandleNV", reinterpret_cast(GetMemoryWin32HandleNV)}, -#endif // VK_USE_PLATFORM_WIN32_KHR +#endif // VK_USE_PLATFORM_WIN32_KHR // EXT_debug_marker {"vkDebugMarkerSetObjectTagEXT", reinterpret_cast(DebugMarkerSetObjectTagEXT)}, {"vkDebugMarkerSetObjectNameEXT", reinterpret_cast(DebugMarkerSetObjectNameEXT)}, @@ -6396,15 +6375,14 @@ static PFN_vkVoidFunction intercept_extension_device_command(const char *name, V if (device) { for (size_t i = 0; i < ARRAY_SIZE(extension_device_commands); i++) { - if (!strcmp(extension_device_commands[i].name, name)) - return extension_device_commands[i].proc; + if (!strcmp(extension_device_commands[i].name, name)) return extension_device_commands[i].proc; } } return nullptr; } -} // namespace parameter_validation +} // namespace parameter_validation // vk_layer_logging.h expects these to be defined diff --git a/layers/parameter_validation_utils.h b/layers/parameter_validation_utils.h index 3cc85c0..e3197b6 100644 --- a/layers/parameter_validation_utils.h +++ b/layers/parameter_validation_utils.h @@ -35,32 +35,32 @@ namespace parameter_validation { enum ErrorCode { - NONE, // Used for INFO & other non-error messages - INVALID_USAGE, // The value of a parameter is not consistent - // with the valid usage criteria defined in - // the Vulkan specification. - INVALID_STRUCT_STYPE, // The sType field of a Vulkan structure does - // not contain the value expected for a structure - // of that type. - INVALID_STRUCT_PNEXT, // The pNext field of a Vulkan structure references - // a value that is not compatible with a structure of - // that type or is not NULL when a structure of that - // type has no compatible pNext values. - REQUIRED_PARAMETER, // A required parameter was specified as 0 or NULL. - RESERVED_PARAMETER, // A parameter reserved for future use was not - // specified as 0 or NULL. - UNRECOGNIZED_VALUE, // A Vulkan enumeration, VkFlags, or VkBool32 parameter - // contains a value that is not recognized as valid for - // that type. - DEVICE_LIMIT, // A specified parameter exceeds the limits returned - // by the physical device - DEVICE_FEATURE, // Use of a requested feature is not supported by - // the device - FAILURE_RETURN_CODE, // A Vulkan return code indicating a failure condition - // was encountered. - EXTENSION_NOT_ENABLED, // An extension entrypoint was called, but the required - // extension was not enabled at CreateInstance or - // CreateDevice time. + NONE, // Used for INFO & other non-error messages + INVALID_USAGE, // The value of a parameter is not consistent + // with the valid usage criteria defined in + // the Vulkan specification. + INVALID_STRUCT_STYPE, // The sType field of a Vulkan structure does + // not contain the value expected for a structure + // of that type. + INVALID_STRUCT_PNEXT, // The pNext field of a Vulkan structure references + // a value that is not compatible with a structure of + // that type or is not NULL when a structure of that + // type has no compatible pNext values. + REQUIRED_PARAMETER, // A required parameter was specified as 0 or NULL. + RESERVED_PARAMETER, // A parameter reserved for future use was not + // specified as 0 or NULL. + UNRECOGNIZED_VALUE, // A Vulkan enumeration, VkFlags, or VkBool32 parameter + // contains a value that is not recognized as valid for + // that type. + DEVICE_LIMIT, // A specified parameter exceeds the limits returned + // by the physical device + DEVICE_FEATURE, // Use of a requested feature is not supported by + // the device + FAILURE_RETURN_CODE, // A Vulkan return code indicating a failure condition + // was encountered. + EXTENSION_NOT_ENABLED, // An extension entrypoint was called, but the required + // extension was not enabled at CreateInstance or + // CreateDevice time. }; struct GenericHeader { @@ -99,14 +99,16 @@ const std::string UnsupportedResultString = "Unhandled VkResult"; // See Appendix C.10 "Assigning Extension Token Values" from the Vulkan specification const uint32_t ExtEnumBaseValue = 1000000000; -template bool is_extension_added_token(T value) { +template +bool is_extension_added_token(T value) { return (static_cast(std::abs(static_cast(value))) >= ExtEnumBaseValue); } // VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE token is a special case that was converted from a core token to an // extension added token. Its original value was intentionally preserved after the conversion, so it does not use // the base value that other extension added tokens use, and it does not fall within the enum's begin/end range. -template <> bool is_extension_added_token(VkSamplerAddressMode value) { +template <> +bool is_extension_added_token(VkSamplerAddressMode value) { bool result = (static_cast(std::abs(static_cast(value))) >= ExtEnumBaseValue); return (result || (value == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE)); } @@ -152,7 +154,6 @@ static bool validate_required_pointer(debug_report_data *report_data, const char bool skip_call = false; if (value == NULL) { - skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, REQUIRED_PARAMETER, LayerName, "%s: required parameter %s specified as NULL", apiName, parameterName.get_name().c_str()); @@ -486,10 +487,11 @@ static bool validate_struct_pnext(debug_report_data *report_data, const char *ap const char *allowed_struct_names, const void *next, size_t allowed_type_count, const VkStructureType *allowed_types, uint32_t header_version) { bool skip_call = false; - const char disclaimer[] = "This warning is based on the Valid Usage documentation for version %d of the Vulkan header. It " - "is possible that you are using a struct from a private extension or an extension that was added " - "to a later version of the Vulkan header, in which case your use of %s is perfectly valid but " - "is not guaranteed to work correctly with validation enabled"; + const char disclaimer[] = + "This warning is based on the Valid Usage documentation for version %d of the Vulkan header. It " + "is possible that you are using a struct from a private extension or an extension that was added " + "to a later version of the Vulkan header, in which case your use of %s is perfectly valid but " + "is not guaranteed to work correctly with validation enabled"; if (next != NULL) { if (allowed_type_count == 0) { @@ -508,8 +510,9 @@ static bool validate_struct_pnext(debug_report_data *report_data, const char *ap std::string type_name = string_VkStructureType(current->sType); if (type_name == UnsupportedStructureTypeString) { - std::string message = "%s: %s chain includes a structure with unexpected VkStructureType (%d); Allowed " - "structures are [%s]. "; + std::string message = + "%s: %s chain includes a structure with unexpected VkStructureType (%d); Allowed " + "structures are [%s]. "; message += disclaimer; skip_call |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, INVALID_STRUCT_PNEXT, LayerName, message.c_str(), api_name, @@ -583,11 +586,11 @@ bool validate_ranged_enum(debug_report_data *report_data, const char *apiName, c bool skip_call = false; if (((value < begin) || (value > end)) && !is_extension_added_token(value)) { - skip_call |= - log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, - UNRECOGNIZED_VALUE, LayerName, "%s: value of %s (%d) does not fall within the begin..end range of the core %s " - "enumeration tokens and is not an extension added token", - apiName, parameterName.get_name().c_str(), value, enumName); + skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, + UNRECOGNIZED_VALUE, LayerName, + "%s: value of %s (%d) does not fall within the begin..end range of the core %s " + "enumeration tokens and is not an extension added token", + apiName, parameterName.get_name().c_str(), value, enumName); } return skip_call; @@ -820,6 +823,6 @@ static void validate_result(debug_report_data *report_data, const char *apiName, } } -} // namespace parameter_validation +} // namespace parameter_validation -#endif // PARAMETER_VALIDATION_UTILS_H +#endif // PARAMETER_VALIDATION_UTILS_H diff --git a/layers/swapchain.cpp b/layers/swapchain.cpp index 29ec8b4..cd7f601 100644 --- a/layers/swapchain.cpp +++ b/layers/swapchain.cpp @@ -88,7 +88,6 @@ static void checkInstanceRegisterExtensions(const VkInstanceCreateInfo *pCreateI // vkEnumerateInstanceExtensionProperties(), since the loader handles that. for (i = 0; i < pCreateInfo->enabledExtensionCount; i++) { if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_DISPLAY_EXTENSION_NAME) == 0) { - my_data->instanceMap[instance].displayExtensionEnabled = true; } } @@ -96,7 +95,6 @@ static void checkInstanceRegisterExtensions(const VkInstanceCreateInfo *pCreateI #include "vk_dispatch_table_helper.h" static void init_swapchain(layer_data *my_data, const VkAllocationCallbacks *pAllocator) { - layer_debug_actions(my_data->report_data, my_data->logging_callback, pAllocator, "lunarg_swapchain"); } @@ -201,7 +199,6 @@ VKAPI_ATTR void VKAPI_CALL DestroyInstance(VkInstance instance, const VkAllocati // Delete all of the SwpPhysicalDevice's, SwpSurface's, and the // SwpInstance associated with this instance: for (auto it = pInstance->physicalDevices.begin(); it != pInstance->physicalDevices.end(); it++) { - // Free memory that was allocated for/by this SwpPhysicalDevice: SwpPhysicalDevice *pPhysicalDevice = it->second; if (pPhysicalDevice) { @@ -219,7 +216,6 @@ VKAPI_ATTR void VKAPI_CALL DestroyInstance(VkInstance instance, const VkAllocati my_data->physicalDeviceMap.erase(it->second->physicalDevice); } for (auto it = pInstance->surfaces.begin(); it != pInstance->surfaces.end(); it++) { - // Free memory that was allocated for/by this SwpPhysicalDevice: SwpSurface *pSurface = it->second; if (pSurface) { @@ -320,7 +316,7 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateAndroidSurfaceKHR(VkInstance instance, cons } return VK_ERROR_VALIDATION_FAILED_EXT; } -#endif // VK_USE_PLATFORM_ANDROID_KHR +#endif // VK_USE_PLATFORM_ANDROID_KHR #ifdef VK_USE_PLATFORM_MIR_KHR VKAPI_ATTR VkResult VKAPI_CALL CreateMirSurfaceKHR(VkInstance instance, const VkMirSurfaceCreateInfoKHR *pCreateInfo, @@ -389,7 +385,7 @@ VKAPI_ATTR VkBool32 VKAPI_CALL GetPhysicalDeviceMirPresentationSupportKHR(VkPhys } return result; } -#endif // VK_USE_PLATFORM_MIR_KHR +#endif // VK_USE_PLATFORM_MIR_KHR #ifdef VK_USE_PLATFORM_WAYLAND_KHR VKAPI_ATTR VkResult VKAPI_CALL CreateWaylandSurfaceKHR(VkInstance instance, const VkWaylandSurfaceCreateInfoKHR *pCreateInfo, @@ -459,7 +455,7 @@ VKAPI_ATTR VkBool32 VKAPI_CALL GetPhysicalDeviceWaylandPresentationSupportKHR(Vk } return result; } -#endif // VK_USE_PLATFORM_WAYLAND_KHR +#endif // VK_USE_PLATFORM_WAYLAND_KHR #ifdef VK_USE_PLATFORM_WIN32_KHR VKAPI_ATTR VkResult VKAPI_CALL CreateWin32SurfaceKHR(VkInstance instance, const VkWin32SurfaceCreateInfoKHR *pCreateInfo, @@ -527,7 +523,7 @@ VKAPI_ATTR VkBool32 VKAPI_CALL GetPhysicalDeviceWin32PresentationSupportKHR(VkPh } return result; } -#endif // VK_USE_PLATFORM_WIN32_KHR +#endif // VK_USE_PLATFORM_WIN32_KHR #ifdef VK_USE_PLATFORM_XCB_KHR VKAPI_ATTR VkResult VKAPI_CALL CreateXcbSurfaceKHR(VkInstance instance, const VkXcbSurfaceCreateInfoKHR *pCreateInfo, @@ -597,7 +593,7 @@ VKAPI_ATTR VkBool32 VKAPI_CALL GetPhysicalDeviceXcbPresentationSupportKHR(VkPhys } return result; } -#endif // VK_USE_PLATFORM_XCB_KHR +#endif // VK_USE_PLATFORM_XCB_KHR #ifdef VK_USE_PLATFORM_XLIB_KHR VKAPI_ATTR VkResult VKAPI_CALL CreateXlibSurfaceKHR(VkInstance instance, const VkXlibSurfaceCreateInfoKHR *pCreateInfo, @@ -667,7 +663,7 @@ VKAPI_ATTR VkBool32 VKAPI_CALL GetPhysicalDeviceXlibPresentationSupportKHR(VkPhy } return result; } -#endif // VK_USE_PLATFORM_XLIB_KHR +#endif // VK_USE_PLATFORM_XLIB_KHR VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceDisplayPlanePropertiesKHR(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount, VkDisplayPlanePropertiesKHR *pProperties) { @@ -1320,8 +1316,7 @@ static PFN_vkVoidFunction intercept_khr_swapchain_command(const char *name, VkDe VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetDeviceProcAddr(VkDevice device, const char *funcName) { PFN_vkVoidFunction proc = intercept_core_device_command(funcName); - if (proc) - return proc; + if (proc) return proc; assert(device); @@ -1331,22 +1326,17 @@ VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetDeviceProcAddr(VkDevice device, cons VkLayerDispatchTable *pDisp = my_data->device_dispatch_table; proc = intercept_khr_swapchain_command(funcName, device); - if (proc) - return proc; + if (proc) return proc; - if (pDisp->GetDeviceProcAddr == NULL) - return NULL; + if (pDisp->GetDeviceProcAddr == NULL) return NULL; return pDisp->GetDeviceProcAddr(device, funcName); } VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetInstanceProcAddr(VkInstance instance, const char *funcName) { PFN_vkVoidFunction proc = intercept_core_instance_command(funcName); - if (!proc) - proc = intercept_core_device_command(funcName); - if (!proc) - proc = intercept_khr_swapchain_command(funcName, VK_NULL_HANDLE); - if (proc) - return proc; + if (!proc) proc = intercept_core_device_command(funcName); + if (!proc) proc = intercept_khr_swapchain_command(funcName, VK_NULL_HANDLE); + if (proc) return proc; assert(instance); @@ -1355,13 +1345,10 @@ VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetInstanceProcAddr(VkInstance instance VkLayerInstanceDispatchTable *pTable = my_data->instance_dispatch_table; proc = debug_report_get_instance_proc_addr(my_data->report_data, funcName); - if (!proc) - proc = intercept_khr_surface_command(funcName, instance); - if (proc) - return proc; + if (!proc) proc = intercept_khr_surface_command(funcName, instance); + if (proc) return proc; - if (pTable->GetInstanceProcAddr == NULL) - return NULL; + if (pTable->GetInstanceProcAddr == NULL) return NULL; return pTable->GetInstanceProcAddr(instance, funcName); } @@ -1372,8 +1359,7 @@ VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetPhysicalDeviceProcAddr(VkInstance in my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); VkLayerInstanceDispatchTable *pTable = my_data->instance_dispatch_table; - if (pTable->GetPhysicalDeviceProcAddr == NULL) - return NULL; + if (pTable->GetPhysicalDeviceProcAddr == NULL) return NULL; return pTable->GetPhysicalDeviceProcAddr(instance, funcName); } @@ -1396,8 +1382,7 @@ static PFN_vkVoidFunction intercept_core_instance_command(const char *name) { }; for (size_t i = 0; i < ARRAY_SIZE(core_instance_commands); i++) { - if (!strcmp(core_instance_commands[i].name, name)) - return core_instance_commands[i].proc; + if (!strcmp(core_instance_commands[i].name, name)) return core_instance_commands[i].proc; } return nullptr; @@ -1410,32 +1395,32 @@ static PFN_vkVoidFunction intercept_khr_surface_command(const char *name, VkInst } khr_surface_commands[] = { #ifdef VK_USE_PLATFORM_ANDROID_KHR {"vkCreateAndroidSurfaceKHR", reinterpret_cast(CreateAndroidSurfaceKHR)}, -#endif // VK_USE_PLATFORM_ANDROID_KHR +#endif // VK_USE_PLATFORM_ANDROID_KHR #ifdef VK_USE_PLATFORM_MIR_KHR {"vkCreateMirSurfaceKHR", reinterpret_cast(CreateMirSurfaceKHR)}, {"vkGetPhysicalDeviceMirPresentationSupportKHR", reinterpret_cast(GetPhysicalDeviceMirPresentationSupportKHR)}, -#endif // VK_USE_PLATFORM_MIR_KHR +#endif // VK_USE_PLATFORM_MIR_KHR #ifdef VK_USE_PLATFORM_WAYLAND_KHR {"vkCreateWaylandSurfaceKHR", reinterpret_cast(CreateWaylandSurfaceKHR)}, {"vkGetPhysicalDeviceWaylandPresentationSupportKHR", reinterpret_cast(GetPhysicalDeviceWaylandPresentationSupportKHR)}, -#endif // VK_USE_PLATFORM_WAYLAND_KHR +#endif // VK_USE_PLATFORM_WAYLAND_KHR #ifdef VK_USE_PLATFORM_WIN32_KHR {"vkCreateWin32SurfaceKHR", reinterpret_cast(CreateWin32SurfaceKHR)}, {"vkGetPhysicalDeviceWin32PresentationSupportKHR", reinterpret_cast(GetPhysicalDeviceWin32PresentationSupportKHR)}, -#endif // VK_USE_PLATFORM_WIN32_KHR +#endif // VK_USE_PLATFORM_WIN32_KHR #ifdef VK_USE_PLATFORM_XCB_KHR {"vkCreateXcbSurfaceKHR", reinterpret_cast(CreateXcbSurfaceKHR)}, {"vkGetPhysicalDeviceXcbPresentationSupportKHR", reinterpret_cast(GetPhysicalDeviceXcbPresentationSupportKHR)}, -#endif // VK_USE_PLATFORM_XCB_KHR +#endif // VK_USE_PLATFORM_XCB_KHR #ifdef VK_USE_PLATFORM_XLIB_KHR {"vkCreateXlibSurfaceKHR", reinterpret_cast(CreateXlibSurfaceKHR)}, {"vkGetPhysicalDeviceXlibPresentationSupportKHR", reinterpret_cast(GetPhysicalDeviceXlibPresentationSupportKHR)}, -#endif // VK_USE_PLATFORM_XLIB_KHR +#endif // VK_USE_PLATFORM_XLIB_KHR {"vkDestroySurfaceKHR", reinterpret_cast(DestroySurfaceKHR)}, {"vkGetPhysicalDeviceSurfaceSupportKHR", reinterpret_cast(GetPhysicalDeviceSurfaceSupportKHR)}, {"vkGetPhysicalDeviceDisplayPlanePropertiesKHR", @@ -1448,8 +1433,7 @@ static PFN_vkVoidFunction intercept_khr_surface_command(const char *name, VkInst // do not check if VK_KHR_*_surface is enabled (why?) for (size_t i = 0; i < ARRAY_SIZE(khr_surface_commands); i++) { - if (!strcmp(khr_surface_commands[i].name, name)) - return khr_surface_commands[i].proc; + if (!strcmp(khr_surface_commands[i].name, name)) return khr_surface_commands[i].proc; } return nullptr; @@ -1466,8 +1450,7 @@ static PFN_vkVoidFunction intercept_core_device_command(const char *name) { }; for (size_t i = 0; i < ARRAY_SIZE(core_device_commands); i++) { - if (!strcmp(core_device_commands[i].name, name)) - return core_device_commands[i].proc; + if (!strcmp(core_device_commands[i].name, name)) return core_device_commands[i].proc; } return nullptr; @@ -1486,14 +1469,13 @@ static PFN_vkVoidFunction intercept_khr_swapchain_command(const char *name, VkDe // do not check if VK_KHR_swapchain is enabled (why?) for (size_t i = 0; i < ARRAY_SIZE(khr_swapchain_commands); i++) { - if (!strcmp(khr_swapchain_commands[i].name, name)) - return khr_swapchain_commands[i].proc; + if (!strcmp(khr_swapchain_commands[i].name, name)) return khr_swapchain_commands[i].proc; } return nullptr; } -} // namespace swapchain +} // namespace swapchain // vk_layer_logging.h expects these to be defined diff --git a/layers/swapchain.h b/layers/swapchain.h index 2346d1e..d2913aa 100644 --- a/layers/swapchain.h +++ b/layers/swapchain.h @@ -30,42 +30,44 @@ // Swapchain ERROR codes enum SWAPCHAIN_ERROR { - SWAPCHAIN_INVALID_HANDLE, // Handle used that isn't currently valid - SWAPCHAIN_NULL_POINTER, // Pointer set to NULL, instead of being a valid pointer - SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, // Did not enable WSI extension, but called WSI function - SWAPCHAIN_DEL_OBJECT_BEFORE_CHILDREN, // Called vkDestroyDevice() before vkDestroySwapchainKHR() - SWAPCHAIN_CREATE_UNSUPPORTED_SURFACE, // Called vkCreateSwapchainKHR() with a pCreateInfo->surface that wasn't seen as supported - // by vkGetPhysicalDeviceSurfaceSupportKHR for the device - SWAPCHAIN_CREATE_SWAP_WITHOUT_QUERY, // Called vkCreateSwapchainKHR() without calling a query (e.g. - // vkGetPhysicalDeviceSurfaceCapabilitiesKHR()) - SWAPCHAIN_CREATE_SWAP_OUT_OF_BOUNDS_EXTENTS, // Called vkCreateSwapchainKHR() with out-of-bounds imageExtent - SWAPCHAIN_CREATE_SWAP_EXTENTS_NO_MATCH_WIN, // Called vkCreateSwapchainKHR() with imageExtent that doesn't match window's extent - SWAPCHAIN_CREATE_SWAP_BAD_PRE_TRANSFORM, // Called vkCreateSwapchainKHR() with a non-supported preTransform - SWAPCHAIN_CREATE_SWAP_BAD_COMPOSITE_ALPHA, // Called vkCreateSwapchainKHR() with a non-supported compositeAlpha - SWAPCHAIN_CREATE_SWAP_BAD_IMG_ARRAY_LAYERS, // Called vkCreateSwapchainKHR() with a non-supported imageArrayLayers - SWAPCHAIN_CREATE_SWAP_BAD_IMG_USAGE_FLAGS, // Called vkCreateSwapchainKHR() with a non-supported imageUsageFlags - SWAPCHAIN_CREATE_SWAP_BAD_IMG_COLOR_SPACE, // Called vkCreateSwapchainKHR() with a non-supported imageColorSpace - SWAPCHAIN_CREATE_SWAP_BAD_IMG_FORMAT, // Called vkCreateSwapchainKHR() with a non-supported imageFormat - SWAPCHAIN_CREATE_SWAP_BAD_IMG_FMT_CLR_SP, // Called vkCreateSwapchainKHR() with a non-supported imageColorSpace - SWAPCHAIN_CREATE_SWAP_BAD_PRESENT_MODE, // Called vkCreateSwapchainKHR() with a non-supported presentMode - SWAPCHAIN_CREATE_SWAP_BAD_SHARING_MODE, // Called vkCreateSwapchainKHR() with a non-supported imageSharingMode - SWAPCHAIN_CREATE_SWAP_BAD_SHARING_VALUES, // Called vkCreateSwapchainKHR() with bad values when imageSharingMode is - // VK_SHARING_MODE_CONCURRENT - SWAPCHAIN_BAD_BOOL, // VkBool32 that doesn't have value of VK_TRUE or VK_FALSE (e.g. is a non-zero form of true) - SWAPCHAIN_PRIOR_COUNT, // Query must be called first to get value of pCount, then called second time - SWAPCHAIN_INVALID_COUNT, // Second time a query called, the pCount value didn't match first time - SWAPCHAIN_WRONG_STYPE, // The sType for a struct has the wrong value - SWAPCHAIN_WRONG_NEXT, // The pNext for a struct is not NULL - SWAPCHAIN_ZERO_VALUE, // A value should be non-zero - SWAPCHAIN_DID_NOT_QUERY_QUEUE_FAMILIES, // A function using a queueFamilyIndex was called before - // vkGetPhysicalDeviceQueueFamilyProperties() was called - SWAPCHAIN_QUEUE_FAMILY_INDEX_TOO_LARGE, // A queueFamilyIndex value is not less than pQueueFamilyPropertyCount returned by - // vkGetPhysicalDeviceQueueFamilyProperties() - SWAPCHAIN_SURFACE_NOT_SUPPORTED_WITH_QUEUE, // A surface is not supported by a given queueFamilyIndex, as seen by - // vkGetPhysicalDeviceSurfaceSupportKHR() - SWAPCHAIN_GET_SUPPORTED_DISPLAYS_WITHOUT_QUERY, // vkGetDisplayPlaneSupportedDisplaysKHR should be called after querying - // device display plane properties - SWAPCHAIN_PLANE_INDEX_TOO_LARGE, // a planeIndex value is larger than what vkGetDisplayPlaneSupportedDisplaysKHR returns + SWAPCHAIN_INVALID_HANDLE, // Handle used that isn't currently valid + SWAPCHAIN_NULL_POINTER, // Pointer set to NULL, instead of being a valid pointer + SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, // Did not enable WSI extension, but called WSI function + SWAPCHAIN_DEL_OBJECT_BEFORE_CHILDREN, // Called vkDestroyDevice() before vkDestroySwapchainKHR() + SWAPCHAIN_CREATE_UNSUPPORTED_SURFACE, // Called vkCreateSwapchainKHR() with a pCreateInfo->surface that wasn't seen as + // supported + // by vkGetPhysicalDeviceSurfaceSupportKHR for the device + SWAPCHAIN_CREATE_SWAP_WITHOUT_QUERY, // Called vkCreateSwapchainKHR() without calling a query (e.g. + // vkGetPhysicalDeviceSurfaceCapabilitiesKHR()) + SWAPCHAIN_CREATE_SWAP_OUT_OF_BOUNDS_EXTENTS, // Called vkCreateSwapchainKHR() with out-of-bounds imageExtent + SWAPCHAIN_CREATE_SWAP_EXTENTS_NO_MATCH_WIN, // Called vkCreateSwapchainKHR() with imageExtent that doesn't match window's + // extent + SWAPCHAIN_CREATE_SWAP_BAD_PRE_TRANSFORM, // Called vkCreateSwapchainKHR() with a non-supported preTransform + SWAPCHAIN_CREATE_SWAP_BAD_COMPOSITE_ALPHA, // Called vkCreateSwapchainKHR() with a non-supported compositeAlpha + SWAPCHAIN_CREATE_SWAP_BAD_IMG_ARRAY_LAYERS, // Called vkCreateSwapchainKHR() with a non-supported imageArrayLayers + SWAPCHAIN_CREATE_SWAP_BAD_IMG_USAGE_FLAGS, // Called vkCreateSwapchainKHR() with a non-supported imageUsageFlags + SWAPCHAIN_CREATE_SWAP_BAD_IMG_COLOR_SPACE, // Called vkCreateSwapchainKHR() with a non-supported imageColorSpace + SWAPCHAIN_CREATE_SWAP_BAD_IMG_FORMAT, // Called vkCreateSwapchainKHR() with a non-supported imageFormat + SWAPCHAIN_CREATE_SWAP_BAD_IMG_FMT_CLR_SP, // Called vkCreateSwapchainKHR() with a non-supported imageColorSpace + SWAPCHAIN_CREATE_SWAP_BAD_PRESENT_MODE, // Called vkCreateSwapchainKHR() with a non-supported presentMode + SWAPCHAIN_CREATE_SWAP_BAD_SHARING_MODE, // Called vkCreateSwapchainKHR() with a non-supported imageSharingMode + SWAPCHAIN_CREATE_SWAP_BAD_SHARING_VALUES, // Called vkCreateSwapchainKHR() with bad values when imageSharingMode is + // VK_SHARING_MODE_CONCURRENT + SWAPCHAIN_BAD_BOOL, // VkBool32 that doesn't have value of VK_TRUE or VK_FALSE (e.g. is a non-zero form of true) + SWAPCHAIN_PRIOR_COUNT, // Query must be called first to get value of pCount, then called second time + SWAPCHAIN_INVALID_COUNT, // Second time a query called, the pCount value didn't match first time + SWAPCHAIN_WRONG_STYPE, // The sType for a struct has the wrong value + SWAPCHAIN_WRONG_NEXT, // The pNext for a struct is not NULL + SWAPCHAIN_ZERO_VALUE, // A value should be non-zero + SWAPCHAIN_DID_NOT_QUERY_QUEUE_FAMILIES, // A function using a queueFamilyIndex was called before + // vkGetPhysicalDeviceQueueFamilyProperties() was called + SWAPCHAIN_QUEUE_FAMILY_INDEX_TOO_LARGE, // A queueFamilyIndex value is not less than pQueueFamilyPropertyCount returned by + // vkGetPhysicalDeviceQueueFamilyProperties() + SWAPCHAIN_SURFACE_NOT_SUPPORTED_WITH_QUEUE, // A surface is not supported by a given queueFamilyIndex, as seen by + // vkGetPhysicalDeviceSurfaceSupportKHR() + SWAPCHAIN_GET_SUPPORTED_DISPLAYS_WITHOUT_QUERY, // vkGetDisplayPlaneSupportedDisplaysKHR should be called after querying + // device display plane properties + SWAPCHAIN_PLANE_INDEX_TOO_LARGE, // a planeIndex value is larger than what vkGetDisplayPlaneSupportedDisplaysKHR returns }; // The following is for logging error messages: @@ -230,8 +232,12 @@ struct layer_data { std::unordered_map queueMap; layer_data() - : report_data(nullptr), device_dispatch_table(nullptr), instance_dispatch_table(nullptr), num_tmp_callbacks(0), - tmp_dbg_create_infos(nullptr), tmp_callbacks(nullptr){}; + : report_data(nullptr), + device_dispatch_table(nullptr), + instance_dispatch_table(nullptr), + num_tmp_callbacks(0), + tmp_dbg_create_infos(nullptr), + tmp_callbacks(nullptr){}; }; -#endif // SWAPCHAIN_H +#endif // SWAPCHAIN_H diff --git a/layers/threading.cpp b/layers/threading.cpp index 1997f78..0c6e3f1 100644 --- a/layers/threading.cpp +++ b/layers/threading.cpp @@ -42,7 +42,6 @@ namespace threading { static uint32_t loader_layer_if_version = CURRENT_LOADER_LAYER_INTERFACE_VERSION; static void initThreading(layer_data *my_data, const VkAllocationCallbacks *pAllocator) { - layer_debug_actions(my_data->report_data, my_data->logging_callback, pAllocator, "google_threading"); } @@ -61,8 +60,7 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateInstance(const VkInstanceCreateInfo *pCreat chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext; VkResult result = fpCreateInstance(pCreateInfo, pAllocator, pInstance); - if (result != VK_SUCCESS) - return result; + if (result != VK_SUCCESS) return result; layer_data *my_data = get_my_data_ptr(get_dispatch_key(*pInstance), layer_data_map); my_data->instance = *pInstance; @@ -178,14 +176,13 @@ static const VkExtensionProperties threading_extensions[] = { static const VkLayerProperties layerProps = { "VK_LAYER_GOOGLE_threading", - VK_LAYER_API_VERSION, // specVersion + VK_LAYER_API_VERSION, // specVersion 1, "Google Validation Layer", }; static inline PFN_vkVoidFunction layer_intercept_proc(const char *name) { for (unsigned int i = 0; i < sizeof(procmap) / sizeof(procmap[0]); i++) { - if (!strcmp(name, procmap[i].name)) - return procmap[i].pFunc; + if (!strcmp(name, procmap[i].name)) return procmap[i].pFunc; } return NULL; } @@ -224,28 +221,18 @@ VKAPI_ATTR VkResult VKAPI_CALL EnumerateDeviceExtensionProperties(VkPhysicalDevi VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetPhysicalDeviceProcAddr(VkInstance instance, const char *funcName); static inline PFN_vkVoidFunction layer_intercept_instance_proc(const char *name) { - if (!name || name[0] != 'v' || name[1] != 'k') - return NULL; + if (!name || name[0] != 'v' || name[1] != 'k') return NULL; name += 2; - if (!strcmp(name, "CreateInstance")) - return (PFN_vkVoidFunction)CreateInstance; - if (!strcmp(name, "DestroyInstance")) - return (PFN_vkVoidFunction)DestroyInstance; - if (!strcmp(name, "EnumerateInstanceLayerProperties")) - return (PFN_vkVoidFunction)EnumerateInstanceLayerProperties; - if (!strcmp(name, "EnumerateInstanceExtensionProperties")) - return (PFN_vkVoidFunction)EnumerateInstanceExtensionProperties; - if (!strcmp(name, "EnumerateDeviceLayerProperties")) - return (PFN_vkVoidFunction)EnumerateDeviceLayerProperties; - if (!strcmp(name, "EnumerateDeviceExtensionProperties")) - return (PFN_vkVoidFunction)EnumerateDeviceExtensionProperties; - if (!strcmp(name, "CreateDevice")) - return (PFN_vkVoidFunction)CreateDevice; - if (!strcmp(name, "GetInstanceProcAddr")) - return (PFN_vkVoidFunction)GetInstanceProcAddr; - if (!strcmp(name, "GetPhysicalDeviceProcAddr")) - return (PFN_vkVoidFunction)GetPhysicalDeviceProcAddr; + if (!strcmp(name, "CreateInstance")) return (PFN_vkVoidFunction)CreateInstance; + if (!strcmp(name, "DestroyInstance")) return (PFN_vkVoidFunction)DestroyInstance; + if (!strcmp(name, "EnumerateInstanceLayerProperties")) return (PFN_vkVoidFunction)EnumerateInstanceLayerProperties; + if (!strcmp(name, "EnumerateInstanceExtensionProperties")) return (PFN_vkVoidFunction)EnumerateInstanceExtensionProperties; + if (!strcmp(name, "EnumerateDeviceLayerProperties")) return (PFN_vkVoidFunction)EnumerateDeviceLayerProperties; + if (!strcmp(name, "EnumerateDeviceExtensionProperties")) return (PFN_vkVoidFunction)EnumerateDeviceExtensionProperties; + if (!strcmp(name, "CreateDevice")) return (PFN_vkVoidFunction)CreateDevice; + if (!strcmp(name, "GetInstanceProcAddr")) return (PFN_vkVoidFunction)GetInstanceProcAddr; + if (!strcmp(name, "GetPhysicalDeviceProcAddr")) return (PFN_vkVoidFunction)GetPhysicalDeviceProcAddr; return NULL; } @@ -257,14 +244,12 @@ VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetDeviceProcAddr(VkDevice device, cons assert(device); addr = layer_intercept_proc(funcName); - if (addr) - return addr; + if (addr) return addr; dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); VkLayerDispatchTable *pTable = dev_data->device_dispatch_table; - if (pTable->GetDeviceProcAddr == NULL) - return NULL; + if (pTable->GetDeviceProcAddr == NULL) return NULL; return pTable->GetDeviceProcAddr(device, funcName); } @@ -273,8 +258,7 @@ VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetInstanceProcAddr(VkInstance instance layer_data *my_data; addr = layer_intercept_instance_proc(funcName); - if (!addr) - addr = layer_intercept_proc(funcName); + if (!addr) addr = layer_intercept_proc(funcName); if (addr) { return addr; } @@ -301,8 +285,7 @@ VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetPhysicalDeviceProcAddr(VkInstance in my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); VkLayerInstanceDispatchTable *pTable = my_data->instance_dispatch_table; - if (pTable->GetPhysicalDeviceProcAddr == NULL) - return NULL; + if (pTable->GetPhysicalDeviceProcAddr == NULL) return NULL; return pTable->GetPhysicalDeviceProcAddr(instance, funcName); } @@ -382,7 +365,7 @@ VKAPI_ATTR void VKAPI_CALL FreeCommandBuffers(VkDevice device, VkCommandPool com dispatch_key key = get_dispatch_key(device); layer_data *my_data = get_my_data_ptr(key, layer_data_map); VkLayerDispatchTable *pTable = my_data->device_dispatch_table; - const bool lockCommandPool = false; // pool is already directly locked + const bool lockCommandPool = false; // pool is already directly locked bool threadChecks = startMultiThread(); if (threadChecks) { startReadObject(my_data, device); @@ -408,7 +391,7 @@ VKAPI_ATTR void VKAPI_CALL FreeCommandBuffers(VkDevice device, VkCommandPool com } } -} // namespace threading +} // namespace threading // vk_layer_logging.h expects these to be defined diff --git a/layers/threading.h b/layers/threading.h index 9bd8424..481acd4 100644 --- a/layers/threading.h +++ b/layers/threading.h @@ -26,7 +26,7 @@ #include "vk_layer_config.h" #include "vk_layer_logging.h" -#if defined(__LP64__) || defined(_WIN64) || defined(__x86_64__) || defined(_M_X64) || defined(__ia64) || defined(_M_IA64) || \ +#if defined(__LP64__) || defined(_WIN64) || defined(__x86_64__) || defined(_M_X64) || defined(__ia64) || defined(_M_IA64) || \ defined(__aarch64__) || defined(__powerpc64__) // If pointers are 64-bit, then there can be separate counters for each // NONDISPATCHABLE_HANDLE type. Otherwise they are all typedef uint64_t. @@ -35,9 +35,9 @@ // Draw State ERROR codes enum THREADING_CHECKER_ERROR { - THREADING_CHECKER_NONE, // Used for INFO & other non-error messages - THREADING_CHECKER_MULTIPLE_THREADS, // Object used simultaneously by multiple threads - THREADING_CHECKER_SINGLE_THREAD_REUSE, // Object used simultaneously by recursion in single thread + THREADING_CHECKER_NONE, // Used for INFO & other non-error messages + THREADING_CHECKER_MULTIPLE_THREADS, // Object used simultaneously by multiple threads + THREADING_CHECKER_SINGLE_THREAD_REUSE, // Object used simultaneously by recursion in single thread }; struct object_use_data { @@ -66,10 +66,11 @@ inline bool startMultiThread() { // finishing check if an application is using vulkan from multiple threads. inline void finishMultiThread() { vulkan_in_use = false; } -} // namespace threading +} // namespace threading -template class counter { - public: +template +class counter { + public: const char *typeName; VkDebugReportObjectTypeEXT objectType; std::unordered_map uses; @@ -247,12 +248,15 @@ struct layer_data { counter c_VkDebugReportCallbackEXT; counter c_VkObjectTableNVX; counter c_VkIndirectCommandsLayoutNVX; -#else // DISTINCT_NONDISPATCHABLE_HANDLES +#else // DISTINCT_NONDISPATCHABLE_HANDLES counter c_uint64_t; -#endif // DISTINCT_NONDISPATCHABLE_HANDLES +#endif // DISTINCT_NONDISPATCHABLE_HANDLES layer_data() - : report_data(nullptr), num_tmp_callbacks(0), tmp_dbg_create_infos(nullptr), tmp_callbacks(nullptr), + : report_data(nullptr), + num_tmp_callbacks(0), + tmp_dbg_create_infos(nullptr), + tmp_callbacks(nullptr), c_VkCommandBuffer("VkCommandBuffer", VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT), c_VkDevice("VkDevice", VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT), c_VkInstance("VkInstance", VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT), @@ -265,7 +269,8 @@ struct layer_data { c_VkDescriptorSet("VkDescriptorSet", VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT), c_VkDescriptorSetLayout("VkDescriptorSetLayout", VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT_EXT), c_VkDeviceMemory("VkDeviceMemory", VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT), - c_VkEvent("VkEvent", VK_DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT), c_VkFence("VkFence", VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT), + c_VkEvent("VkEvent", VK_DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT), + c_VkFence("VkFence", VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT), c_VkFramebuffer("VkFramebuffer", VK_DEBUG_REPORT_OBJECT_TYPE_FRAMEBUFFER_EXT), c_VkImage("VkImage", VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT), c_VkImageView("VkImageView", VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_VIEW_EXT), @@ -280,20 +285,20 @@ struct layer_data { c_VkDebugReportCallbackEXT("VkDebugReportCallbackEXT", VK_DEBUG_REPORT_OBJECT_TYPE_DEBUG_REPORT_EXT), c_VkObjectTableNVX("VkObjectTableNVX", VK_DEBUG_REPORT_OBJECT_TYPE_OBJECT_TABLE_NVX_EXT), c_VkIndirectCommandsLayoutNVX("VkIndirectCommandsLayoutNVX", VK_DEBUG_REPORT_OBJECT_TYPE_INDIRECT_COMMANDS_LAYOUT_NVX_EXT) -#else // DISTINCT_NONDISPATCHABLE_HANDLES +#else // DISTINCT_NONDISPATCHABLE_HANDLES c_uint64_t("NON_DISPATCHABLE_HANDLE", VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT) -#endif // DISTINCT_NONDISPATCHABLE_HANDLES +#endif // DISTINCT_NONDISPATCHABLE_HANDLES {}; }; -#define WRAPPER(type) \ - static void startWriteObject(struct layer_data *my_data, type object) { \ - my_data->c_##type.startWrite(my_data->report_data, object); \ - } \ - static void finishWriteObject(struct layer_data *my_data, type object) { my_data->c_##type.finishWrite(object); } \ - static void startReadObject(struct layer_data *my_data, type object) { \ - my_data->c_##type.startRead(my_data->report_data, object); \ - } \ +#define WRAPPER(type) \ + static void startWriteObject(struct layer_data *my_data, type object) { \ + my_data->c_##type.startWrite(my_data->report_data, object); \ + } \ + static void finishWriteObject(struct layer_data *my_data, type object) { my_data->c_##type.finishWrite(object); } \ + static void startReadObject(struct layer_data *my_data, type object) { \ + my_data->c_##type.startRead(my_data->report_data, object); \ + } \ static void finishReadObject(struct layer_data *my_data, type object) { my_data->c_##type.finishRead(object); } WRAPPER(VkDevice) @@ -323,9 +328,9 @@ WRAPPER(VkShaderModule) WRAPPER(VkDebugReportCallbackEXT) WRAPPER(VkObjectTableNVX) WRAPPER(VkIndirectCommandsLayoutNVX) -#else // DISTINCT_NONDISPATCHABLE_HANDLES +#else // DISTINCT_NONDISPATCHABLE_HANDLES WRAPPER(uint64_t) -#endif // DISTINCT_NONDISPATCHABLE_HANDLES +#endif // DISTINCT_NONDISPATCHABLE_HANDLES static std::unordered_map layer_data_map; static std::mutex command_pool_lock; @@ -364,4 +369,4 @@ static void finishReadObject(struct layer_data *my_data, VkCommandBuffer object) lock.unlock(); finishReadObject(my_data, pool); } -#endif // THREADING_H +#endif // THREADING_H diff --git a/layers/unique_objects.cpp b/layers/unique_objects.cpp index 08f1ded..f973ec5 100644 --- a/layers/unique_objects.cpp +++ b/layers/unique_objects.cpp @@ -260,8 +260,8 @@ VKAPI_ATTR void VKAPI_CALL DestroyDevice(VkDevice device, const VkAllocationCall } static const VkLayerProperties globalLayerProps = {"VK_LAYER_GOOGLE_unique_objects", - VK_LAYER_API_VERSION, // specVersion - 1, // implementationVersion + VK_LAYER_API_VERSION, // specVersion + 1, // implementationVersion "Google Validation Layer"}; /// Declare prototype for these functions @@ -269,8 +269,7 @@ VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetPhysicalDeviceProcAddr(VkInstance in static inline PFN_vkVoidFunction layer_intercept_proc(const char *name) { for (unsigned int i = 0; i < sizeof(procmap) / sizeof(procmap[0]); i++) { - if (!strcmp(name, procmap[i].name)) - return procmap[i].pFunc; + if (!strcmp(name, procmap[i].name)) return procmap[i].pFunc; } if (0 == strcmp(name, "vk_layerGetPhysicalDeviceProcAddr")) { return (PFN_vkVoidFunction)GetPhysicalDeviceProcAddr; @@ -717,7 +716,7 @@ VKAPI_ATTR VkResult VKAPI_CALL GetDisplayPlaneCapabilitiesKHR(VkPhysicalDevice p } #endif -} // namespace unique_objects +} // namespace unique_objects // vk_layer_logging.h expects these to be defined VKAPI_ATTR VkResult VKAPI_CALL vkCreateDebugReportCallbackEXT(VkInstance instance, diff --git a/layers/unique_objects.h b/layers/unique_objects.h index 717f679..85d35fe 100644 --- a/layers/unique_objects.h +++ b/layers/unique_objects.h @@ -108,7 +108,7 @@ struct layer_data { VkDebugReportCallbackEXT *tmp_callbacks; bool wsi_enabled; - std::unordered_map unique_id_mapping; // Map uniqueID to actual object handle + std::unordered_map unique_id_mapping; // Map uniqueID to actual object handle VkPhysicalDevice gpu; layer_data() : wsi_enabled(false), gpu(VK_NULL_HANDLE){}; @@ -128,14 +128,15 @@ struct instance_extension_enables { static std::unordered_map instance_ext_map; static std::unordered_map layer_data_map; -static std::mutex global_lock; // Protect map accesses and unique_id increments +static std::mutex global_lock; // Protect map accesses and unique_id increments struct GenericHeader { VkStructureType sType; void *pNext; }; -template bool ContainsExtStruct(const T *target, VkStructureType ext_type) { +template +bool ContainsExtStruct(const T *target, VkStructureType ext_type) { assert(target != nullptr); const GenericHeader *ext_struct = reinterpret_cast(target->pNext); @@ -151,4 +152,4 @@ template bool ContainsExtStruct(const T *target, VkStructureType ex return false; } -} // namespace unique_objects +} // namespace unique_objects diff --git a/layers/vk_layer_config.cpp b/layers/vk_layer_config.cpp index 49cbb9d..ffefbcd 100644 --- a/layers/vk_layer_config.cpp +++ b/layers/vk_layer_config.cpp @@ -34,14 +34,14 @@ #define MAX_CHARS_PER_LINE 4096 class ConfigFile { - public: + public: ConfigFile(); ~ConfigFile(); const char *getOption(const std::string &_option); void setOption(const std::string &_option, const std::string &_val); - private: + private: bool m_fileIsParsed; std::map m_valueMap; @@ -98,7 +98,6 @@ VkFlags GetLayerOptionFlags(std::string _option, std::unordered_map #include "vk_layer_table.h" -template DATA_T *get_my_data_ptr(void *data_key, std::unordered_map &layer_data_map) { +template +DATA_T *get_my_data_ptr(void *data_key, std::unordered_map &layer_data_map) { DATA_T *debug_data; typename std::unordered_map::const_iterator got; @@ -40,4 +41,4 @@ template DATA_T *get_my_data_ptr(void *data_key, std::unordere return debug_data; } -#endif // LAYER_DATA_H +#endif // LAYER_DATA_H diff --git a/layers/vk_layer_extension_utils.h b/layers/vk_layer_extension_utils.h index b593768..4a51c16 100644 --- a/layers/vk_layer_extension_utils.h +++ b/layers/vk_layer_extension_utils.h @@ -36,5 +36,5 @@ VK_LAYER_EXPORT VkResult util_GetExtensionProperties(const uint32_t count, const VK_LAYER_EXPORT VkResult util_GetLayerProperties(const uint32_t count, const VkLayerProperties *layer_properties, uint32_t *pCount, VkLayerProperties *pProperties); -} // extern "C" -#endif // LAYER_EXTENSION_UTILS_H +} // extern "C" +#endif // LAYER_EXTENSION_UTILS_H diff --git a/layers/vk_layer_logging.h b/layers/vk_layer_logging.h index 542ee26..b033d1f 100644 --- a/layers/vk_layer_logging.h +++ b/layers/vk_layer_logging.h @@ -53,7 +53,6 @@ static inline bool debug_report_log_msg(const debug_report_data *debug_data, VkF // Add a debug message callback node structure to the specified callback linked list static inline void AddDebugMessageCallback(debug_report_data *debug_data, VkLayerDbgFunctionNode **list_head, VkLayerDbgFunctionNode *new_node) { - new_node->pNext = *list_head; *list_head = new_node; } @@ -130,13 +129,12 @@ static inline bool debug_report_log_msg(const debug_report_data *debug_data, VkF return bail; } -static inline debug_report_data * -debug_report_create_instance(VkLayerInstanceDispatchTable *table, VkInstance inst, uint32_t extension_count, - const char *const *ppEnabledExtensions) // layer or extension name to be enabled +static inline debug_report_data *debug_report_create_instance( + VkLayerInstanceDispatchTable *table, VkInstance inst, uint32_t extension_count, + const char *const *ppEnabledExtensions) // layer or extension name to be enabled { debug_report_data *debug_data = (debug_report_data *)malloc(sizeof(debug_report_data)); - if (!debug_data) - return NULL; + if (!debug_data) return NULL; memset(debug_data, 0, sizeof(debug_report_data)); for (uint32_t i = 0; i < extension_count; i++) { @@ -176,12 +174,10 @@ static inline VkResult layer_create_msg_callback(debug_report_data *debug_data, const VkDebugReportCallbackCreateInfoEXT *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDebugReportCallbackEXT *pCallback) { VkLayerDbgFunctionNode *pNewDbgFuncNode = (VkLayerDbgFunctionNode *)malloc(sizeof(VkLayerDbgFunctionNode)); - if (!pNewDbgFuncNode) - return VK_ERROR_OUT_OF_HOST_MEMORY; + if (!pNewDbgFuncNode) return VK_ERROR_OUT_OF_HOST_MEMORY; // Handle of 0 is logging_callback so use allocated Node address as unique handle - if (!(*pCallback)) - *pCallback = (VkDebugReportCallbackEXT)pNewDbgFuncNode; + if (!(*pCallback)) *pCallback = (VkDebugReportCallbackEXT)pNewDbgFuncNode; pNewDbgFuncNode->msgCallback = *pCallback; pNewDbgFuncNode->pfnMsgCallback = pCreateInfo->pfnCallback; pNewDbgFuncNode->msgFlags = pCreateInfo->flags; @@ -387,4 +383,4 @@ static inline VKAPI_ATTR VkBool32 VKAPI_CALL win32_debug_output_msg(VkFlags msgF return false; } -#endif // LAYER_LOGGING_H +#endif // LAYER_LOGGING_H diff --git a/layers/vk_layer_utils.cpp b/layers/vk_layer_utils.cpp index 00ea4cf..e83e4f9 100644 --- a/layers/vk_layer_utils.cpp +++ b/layers/vk_layer_utils.cpp @@ -245,13 +245,13 @@ VK_LAYER_EXPORT bool vk_format_is_depth_and_stencil(VkFormat format) { bool is_ds = false; switch (format) { - case VK_FORMAT_D16_UNORM_S8_UINT: - case VK_FORMAT_D24_UNORM_S8_UINT: - case VK_FORMAT_D32_SFLOAT_S8_UINT: - is_ds = true; - break; - default: - break; + case VK_FORMAT_D16_UNORM_S8_UINT: + case VK_FORMAT_D24_UNORM_S8_UINT: + case VK_FORMAT_D32_SFLOAT_S8_UINT: + is_ds = true; + break; + default: + break; } return is_ds; } @@ -264,13 +264,13 @@ VK_LAYER_EXPORT bool vk_format_is_depth_only(VkFormat format) { bool is_depth = false; switch (format) { - case VK_FORMAT_D16_UNORM: - case VK_FORMAT_X8_D24_UNORM_PACK32: - case VK_FORMAT_D32_SFLOAT: - is_depth = true; - break; - default: - break; + case VK_FORMAT_D16_UNORM: + case VK_FORMAT_X8_D24_UNORM_PACK32: + case VK_FORMAT_D32_SFLOAT: + is_depth = true; + break; + default: + break; } return is_depth; @@ -281,71 +281,71 @@ VK_LAYER_EXPORT bool vk_format_is_norm(VkFormat format) { bool is_norm = false; switch (format) { - case VK_FORMAT_R4G4_UNORM_PACK8: - case VK_FORMAT_R4G4B4A4_UNORM_PACK16: - case VK_FORMAT_R5G6B5_UNORM_PACK16: - case VK_FORMAT_R5G5B5A1_UNORM_PACK16: - case VK_FORMAT_A1R5G5B5_UNORM_PACK16: - case VK_FORMAT_R8_UNORM: - case VK_FORMAT_R8_SNORM: - case VK_FORMAT_R8G8_UNORM: - case VK_FORMAT_R8G8_SNORM: - case VK_FORMAT_R8G8B8_UNORM: - case VK_FORMAT_R8G8B8_SNORM: - case VK_FORMAT_R8G8B8A8_UNORM: - case VK_FORMAT_R8G8B8A8_SNORM: - case VK_FORMAT_A8B8G8R8_UNORM_PACK32: - case VK_FORMAT_A8B8G8R8_SNORM_PACK32: - case VK_FORMAT_A2B10G10R10_UNORM_PACK32: - case VK_FORMAT_A2B10G10R10_SNORM_PACK32: - case VK_FORMAT_R16_UNORM: - case VK_FORMAT_R16_SNORM: - case VK_FORMAT_R16G16_UNORM: - case VK_FORMAT_R16G16_SNORM: - case VK_FORMAT_R16G16B16_UNORM: - case VK_FORMAT_R16G16B16_SNORM: - case VK_FORMAT_R16G16B16A16_UNORM: - case VK_FORMAT_R16G16B16A16_SNORM: - case VK_FORMAT_BC1_RGB_UNORM_BLOCK: - case VK_FORMAT_BC2_UNORM_BLOCK: - case VK_FORMAT_BC3_UNORM_BLOCK: - case VK_FORMAT_BC4_UNORM_BLOCK: - case VK_FORMAT_BC4_SNORM_BLOCK: - case VK_FORMAT_BC5_UNORM_BLOCK: - case VK_FORMAT_BC5_SNORM_BLOCK: - case VK_FORMAT_BC7_UNORM_BLOCK: - case VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK: - case VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK: - case VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK: - case VK_FORMAT_EAC_R11_UNORM_BLOCK: - case VK_FORMAT_EAC_R11_SNORM_BLOCK: - case VK_FORMAT_EAC_R11G11_UNORM_BLOCK: - case VK_FORMAT_EAC_R11G11_SNORM_BLOCK: - case VK_FORMAT_ASTC_4x4_UNORM_BLOCK: - case VK_FORMAT_ASTC_5x4_UNORM_BLOCK: - case VK_FORMAT_ASTC_5x5_UNORM_BLOCK: - case VK_FORMAT_ASTC_6x5_UNORM_BLOCK: - case VK_FORMAT_ASTC_6x6_UNORM_BLOCK: - case VK_FORMAT_ASTC_8x5_UNORM_BLOCK: - case VK_FORMAT_ASTC_8x6_UNORM_BLOCK: - case VK_FORMAT_ASTC_8x8_UNORM_BLOCK: - case VK_FORMAT_ASTC_10x5_UNORM_BLOCK: - case VK_FORMAT_ASTC_10x6_UNORM_BLOCK: - case VK_FORMAT_ASTC_10x8_UNORM_BLOCK: - case VK_FORMAT_ASTC_10x10_UNORM_BLOCK: - case VK_FORMAT_ASTC_12x10_UNORM_BLOCK: - case VK_FORMAT_ASTC_12x12_UNORM_BLOCK: - case VK_FORMAT_B5G6R5_UNORM_PACK16: - case VK_FORMAT_B8G8R8_UNORM: - case VK_FORMAT_B8G8R8_SNORM: - case VK_FORMAT_B8G8R8A8_UNORM: - case VK_FORMAT_B8G8R8A8_SNORM: - case VK_FORMAT_A2R10G10B10_UNORM_PACK32: - case VK_FORMAT_A2R10G10B10_SNORM_PACK32: - is_norm = true; - break; - default: - break; + case VK_FORMAT_R4G4_UNORM_PACK8: + case VK_FORMAT_R4G4B4A4_UNORM_PACK16: + case VK_FORMAT_R5G6B5_UNORM_PACK16: + case VK_FORMAT_R5G5B5A1_UNORM_PACK16: + case VK_FORMAT_A1R5G5B5_UNORM_PACK16: + case VK_FORMAT_R8_UNORM: + case VK_FORMAT_R8_SNORM: + case VK_FORMAT_R8G8_UNORM: + case VK_FORMAT_R8G8_SNORM: + case VK_FORMAT_R8G8B8_UNORM: + case VK_FORMAT_R8G8B8_SNORM: + case VK_FORMAT_R8G8B8A8_UNORM: + case VK_FORMAT_R8G8B8A8_SNORM: + case VK_FORMAT_A8B8G8R8_UNORM_PACK32: + case VK_FORMAT_A8B8G8R8_SNORM_PACK32: + case VK_FORMAT_A2B10G10R10_UNORM_PACK32: + case VK_FORMAT_A2B10G10R10_SNORM_PACK32: + case VK_FORMAT_R16_UNORM: + case VK_FORMAT_R16_SNORM: + case VK_FORMAT_R16G16_UNORM: + case VK_FORMAT_R16G16_SNORM: + case VK_FORMAT_R16G16B16_UNORM: + case VK_FORMAT_R16G16B16_SNORM: + case VK_FORMAT_R16G16B16A16_UNORM: + case VK_FORMAT_R16G16B16A16_SNORM: + case VK_FORMAT_BC1_RGB_UNORM_BLOCK: + case VK_FORMAT_BC2_UNORM_BLOCK: + case VK_FORMAT_BC3_UNORM_BLOCK: + case VK_FORMAT_BC4_UNORM_BLOCK: + case VK_FORMAT_BC4_SNORM_BLOCK: + case VK_FORMAT_BC5_UNORM_BLOCK: + case VK_FORMAT_BC5_SNORM_BLOCK: + case VK_FORMAT_BC7_UNORM_BLOCK: + case VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK: + case VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK: + case VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK: + case VK_FORMAT_EAC_R11_UNORM_BLOCK: + case VK_FORMAT_EAC_R11_SNORM_BLOCK: + case VK_FORMAT_EAC_R11G11_UNORM_BLOCK: + case VK_FORMAT_EAC_R11G11_SNORM_BLOCK: + case VK_FORMAT_ASTC_4x4_UNORM_BLOCK: + case VK_FORMAT_ASTC_5x4_UNORM_BLOCK: + case VK_FORMAT_ASTC_5x5_UNORM_BLOCK: + case VK_FORMAT_ASTC_6x5_UNORM_BLOCK: + case VK_FORMAT_ASTC_6x6_UNORM_BLOCK: + case VK_FORMAT_ASTC_8x5_UNORM_BLOCK: + case VK_FORMAT_ASTC_8x6_UNORM_BLOCK: + case VK_FORMAT_ASTC_8x8_UNORM_BLOCK: + case VK_FORMAT_ASTC_10x5_UNORM_BLOCK: + case VK_FORMAT_ASTC_10x6_UNORM_BLOCK: + case VK_FORMAT_ASTC_10x8_UNORM_BLOCK: + case VK_FORMAT_ASTC_10x10_UNORM_BLOCK: + case VK_FORMAT_ASTC_12x10_UNORM_BLOCK: + case VK_FORMAT_ASTC_12x12_UNORM_BLOCK: + case VK_FORMAT_B5G6R5_UNORM_PACK16: + case VK_FORMAT_B8G8R8_UNORM: + case VK_FORMAT_B8G8R8_SNORM: + case VK_FORMAT_B8G8R8A8_UNORM: + case VK_FORMAT_B8G8R8A8_SNORM: + case VK_FORMAT_A2R10G10B10_UNORM_PACK32: + case VK_FORMAT_A2R10G10B10_SNORM_PACK32: + is_norm = true; + break; + default: + break; } return is_norm; @@ -359,31 +359,31 @@ VK_LAYER_EXPORT bool vk_format_is_uint(VkFormat format) { bool is_uint = false; switch (format) { - case VK_FORMAT_R8_UINT: - case VK_FORMAT_R8G8_UINT: - case VK_FORMAT_R8G8B8_UINT: - case VK_FORMAT_R8G8B8A8_UINT: - case VK_FORMAT_A8B8G8R8_UINT_PACK32: - case VK_FORMAT_A2B10G10R10_UINT_PACK32: - case VK_FORMAT_R16_UINT: - case VK_FORMAT_R16G16_UINT: - case VK_FORMAT_R16G16B16_UINT: - case VK_FORMAT_R16G16B16A16_UINT: - case VK_FORMAT_R32_UINT: - case VK_FORMAT_R32G32_UINT: - case VK_FORMAT_R32G32B32_UINT: - case VK_FORMAT_R32G32B32A32_UINT: - case VK_FORMAT_R64_UINT: - case VK_FORMAT_R64G64_UINT: - case VK_FORMAT_R64G64B64_UINT: - case VK_FORMAT_R64G64B64A64_UINT: - case VK_FORMAT_B8G8R8_UINT: - case VK_FORMAT_B8G8R8A8_UINT: - case VK_FORMAT_A2R10G10B10_UINT_PACK32: - is_uint = true; - break; - default: - break; + case VK_FORMAT_R8_UINT: + case VK_FORMAT_R8G8_UINT: + case VK_FORMAT_R8G8B8_UINT: + case VK_FORMAT_R8G8B8A8_UINT: + case VK_FORMAT_A8B8G8R8_UINT_PACK32: + case VK_FORMAT_A2B10G10R10_UINT_PACK32: + case VK_FORMAT_R16_UINT: + case VK_FORMAT_R16G16_UINT: + case VK_FORMAT_R16G16B16_UINT: + case VK_FORMAT_R16G16B16A16_UINT: + case VK_FORMAT_R32_UINT: + case VK_FORMAT_R32G32_UINT: + case VK_FORMAT_R32G32B32_UINT: + case VK_FORMAT_R32G32B32A32_UINT: + case VK_FORMAT_R64_UINT: + case VK_FORMAT_R64G64_UINT: + case VK_FORMAT_R64G64B64_UINT: + case VK_FORMAT_R64G64B64A64_UINT: + case VK_FORMAT_B8G8R8_UINT: + case VK_FORMAT_B8G8R8A8_UINT: + case VK_FORMAT_A2R10G10B10_UINT_PACK32: + is_uint = true; + break; + default: + break; } return is_uint; @@ -394,31 +394,31 @@ VK_LAYER_EXPORT bool vk_format_is_sint(VkFormat format) { bool is_sint = false; switch (format) { - case VK_FORMAT_R8_SINT: - case VK_FORMAT_R8G8_SINT: - case VK_FORMAT_R8G8B8_SINT: - case VK_FORMAT_R8G8B8A8_SINT: - case VK_FORMAT_A8B8G8R8_SINT_PACK32: - case VK_FORMAT_A2B10G10R10_SINT_PACK32: - case VK_FORMAT_R16_SINT: - case VK_FORMAT_R16G16_SINT: - case VK_FORMAT_R16G16B16_SINT: - case VK_FORMAT_R16G16B16A16_SINT: - case VK_FORMAT_R32_SINT: - case VK_FORMAT_R32G32_SINT: - case VK_FORMAT_R32G32B32_SINT: - case VK_FORMAT_R32G32B32A32_SINT: - case VK_FORMAT_R64_SINT: - case VK_FORMAT_R64G64_SINT: - case VK_FORMAT_R64G64B64_SINT: - case VK_FORMAT_R64G64B64A64_SINT: - case VK_FORMAT_B8G8R8_SINT: - case VK_FORMAT_B8G8R8A8_SINT: - case VK_FORMAT_A2R10G10B10_SINT_PACK32: - is_sint = true; - break; - default: - break; + case VK_FORMAT_R8_SINT: + case VK_FORMAT_R8G8_SINT: + case VK_FORMAT_R8G8B8_SINT: + case VK_FORMAT_R8G8B8A8_SINT: + case VK_FORMAT_A8B8G8R8_SINT_PACK32: + case VK_FORMAT_A2B10G10R10_SINT_PACK32: + case VK_FORMAT_R16_SINT: + case VK_FORMAT_R16G16_SINT: + case VK_FORMAT_R16G16B16_SINT: + case VK_FORMAT_R16G16B16A16_SINT: + case VK_FORMAT_R32_SINT: + case VK_FORMAT_R32G32_SINT: + case VK_FORMAT_R32G32B32_SINT: + case VK_FORMAT_R32G32B32A32_SINT: + case VK_FORMAT_R64_SINT: + case VK_FORMAT_R64G64_SINT: + case VK_FORMAT_R64G64B64_SINT: + case VK_FORMAT_R64G64B64A64_SINT: + case VK_FORMAT_B8G8R8_SINT: + case VK_FORMAT_B8G8R8A8_SINT: + case VK_FORMAT_A2R10G10B10_SINT_PACK32: + is_sint = true; + break; + default: + break; } return is_sint; @@ -429,26 +429,26 @@ VK_LAYER_EXPORT bool vk_format_is_float(VkFormat format) { bool is_float = false; switch (format) { - case VK_FORMAT_R16_SFLOAT: - case VK_FORMAT_R16G16_SFLOAT: - case VK_FORMAT_R16G16B16_SFLOAT: - case VK_FORMAT_R16G16B16A16_SFLOAT: - case VK_FORMAT_R32_SFLOAT: - case VK_FORMAT_R32G32_SFLOAT: - case VK_FORMAT_R32G32B32_SFLOAT: - case VK_FORMAT_R32G32B32A32_SFLOAT: - case VK_FORMAT_R64_SFLOAT: - case VK_FORMAT_R64G64_SFLOAT: - case VK_FORMAT_R64G64B64_SFLOAT: - case VK_FORMAT_R64G64B64A64_SFLOAT: - case VK_FORMAT_B10G11R11_UFLOAT_PACK32: - case VK_FORMAT_E5B9G9R9_UFLOAT_PACK32: - case VK_FORMAT_BC6H_UFLOAT_BLOCK: - case VK_FORMAT_BC6H_SFLOAT_BLOCK: - is_float = true; - break; - default: - break; + case VK_FORMAT_R16_SFLOAT: + case VK_FORMAT_R16G16_SFLOAT: + case VK_FORMAT_R16G16B16_SFLOAT: + case VK_FORMAT_R16G16B16A16_SFLOAT: + case VK_FORMAT_R32_SFLOAT: + case VK_FORMAT_R32G32_SFLOAT: + case VK_FORMAT_R32G32B32_SFLOAT: + case VK_FORMAT_R32G32B32A32_SFLOAT: + case VK_FORMAT_R64_SFLOAT: + case VK_FORMAT_R64G64_SFLOAT: + case VK_FORMAT_R64G64B64_SFLOAT: + case VK_FORMAT_R64G64B64A64_SFLOAT: + case VK_FORMAT_B10G11R11_UFLOAT_PACK32: + case VK_FORMAT_E5B9G9R9_UFLOAT_PACK32: + case VK_FORMAT_BC6H_UFLOAT_BLOCK: + case VK_FORMAT_BC6H_SFLOAT_BLOCK: + is_float = true; + break; + default: + break; } return is_float; @@ -459,38 +459,38 @@ VK_LAYER_EXPORT bool vk_format_is_srgb(VkFormat format) { bool is_srgb = false; switch (format) { - case VK_FORMAT_R8_SRGB: - case VK_FORMAT_R8G8_SRGB: - case VK_FORMAT_R8G8B8_SRGB: - case VK_FORMAT_R8G8B8A8_SRGB: - case VK_FORMAT_A8B8G8R8_SRGB_PACK32: - case VK_FORMAT_BC1_RGB_SRGB_BLOCK: - case VK_FORMAT_BC2_SRGB_BLOCK: - case VK_FORMAT_BC3_SRGB_BLOCK: - case VK_FORMAT_BC7_SRGB_BLOCK: - case VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK: - case VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK: - case VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK: - case VK_FORMAT_ASTC_4x4_SRGB_BLOCK: - case VK_FORMAT_ASTC_5x4_SRGB_BLOCK: - case VK_FORMAT_ASTC_5x5_SRGB_BLOCK: - case VK_FORMAT_ASTC_6x5_SRGB_BLOCK: - case VK_FORMAT_ASTC_6x6_SRGB_BLOCK: - case VK_FORMAT_ASTC_8x5_SRGB_BLOCK: - case VK_FORMAT_ASTC_8x6_SRGB_BLOCK: - case VK_FORMAT_ASTC_8x8_SRGB_BLOCK: - case VK_FORMAT_ASTC_10x5_SRGB_BLOCK: - case VK_FORMAT_ASTC_10x6_SRGB_BLOCK: - case VK_FORMAT_ASTC_10x8_SRGB_BLOCK: - case VK_FORMAT_ASTC_10x10_SRGB_BLOCK: - case VK_FORMAT_ASTC_12x10_SRGB_BLOCK: - case VK_FORMAT_ASTC_12x12_SRGB_BLOCK: - case VK_FORMAT_B8G8R8_SRGB: - case VK_FORMAT_B8G8R8A8_SRGB: - is_srgb = true; - break; - default: - break; + case VK_FORMAT_R8_SRGB: + case VK_FORMAT_R8G8_SRGB: + case VK_FORMAT_R8G8B8_SRGB: + case VK_FORMAT_R8G8B8A8_SRGB: + case VK_FORMAT_A8B8G8R8_SRGB_PACK32: + case VK_FORMAT_BC1_RGB_SRGB_BLOCK: + case VK_FORMAT_BC2_SRGB_BLOCK: + case VK_FORMAT_BC3_SRGB_BLOCK: + case VK_FORMAT_BC7_SRGB_BLOCK: + case VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK: + case VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK: + case VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK: + case VK_FORMAT_ASTC_4x4_SRGB_BLOCK: + case VK_FORMAT_ASTC_5x4_SRGB_BLOCK: + case VK_FORMAT_ASTC_5x5_SRGB_BLOCK: + case VK_FORMAT_ASTC_6x5_SRGB_BLOCK: + case VK_FORMAT_ASTC_6x6_SRGB_BLOCK: + case VK_FORMAT_ASTC_8x5_SRGB_BLOCK: + case VK_FORMAT_ASTC_8x6_SRGB_BLOCK: + case VK_FORMAT_ASTC_8x8_SRGB_BLOCK: + case VK_FORMAT_ASTC_10x5_SRGB_BLOCK: + case VK_FORMAT_ASTC_10x6_SRGB_BLOCK: + case VK_FORMAT_ASTC_10x8_SRGB_BLOCK: + case VK_FORMAT_ASTC_10x10_SRGB_BLOCK: + case VK_FORMAT_ASTC_12x10_SRGB_BLOCK: + case VK_FORMAT_ASTC_12x12_SRGB_BLOCK: + case VK_FORMAT_B8G8R8_SRGB: + case VK_FORMAT_B8G8R8A8_SRGB: + is_srgb = true; + break; + default: + break; } return is_srgb; @@ -499,63 +499,63 @@ VK_LAYER_EXPORT bool vk_format_is_srgb(VkFormat format) { // Return true if format is compressed VK_LAYER_EXPORT bool vk_format_is_compressed(VkFormat format) { switch (format) { - case VK_FORMAT_BC1_RGB_UNORM_BLOCK: - case VK_FORMAT_BC1_RGB_SRGB_BLOCK: - case VK_FORMAT_BC1_RGBA_UNORM_BLOCK: - case VK_FORMAT_BC1_RGBA_SRGB_BLOCK: - case VK_FORMAT_BC2_UNORM_BLOCK: - case VK_FORMAT_BC2_SRGB_BLOCK: - case VK_FORMAT_BC3_UNORM_BLOCK: - case VK_FORMAT_BC3_SRGB_BLOCK: - case VK_FORMAT_BC4_UNORM_BLOCK: - case VK_FORMAT_BC4_SNORM_BLOCK: - case VK_FORMAT_BC5_UNORM_BLOCK: - case VK_FORMAT_BC5_SNORM_BLOCK: - case VK_FORMAT_BC6H_UFLOAT_BLOCK: - case VK_FORMAT_BC6H_SFLOAT_BLOCK: - case VK_FORMAT_BC7_UNORM_BLOCK: - case VK_FORMAT_BC7_SRGB_BLOCK: - case VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK: - case VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK: - case VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK: - case VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK: - case VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK: - case VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK: - case VK_FORMAT_EAC_R11_UNORM_BLOCK: - case VK_FORMAT_EAC_R11_SNORM_BLOCK: - case VK_FORMAT_EAC_R11G11_UNORM_BLOCK: - case VK_FORMAT_EAC_R11G11_SNORM_BLOCK: - case VK_FORMAT_ASTC_4x4_UNORM_BLOCK: - case VK_FORMAT_ASTC_4x4_SRGB_BLOCK: - case VK_FORMAT_ASTC_5x4_UNORM_BLOCK: - case VK_FORMAT_ASTC_5x4_SRGB_BLOCK: - case VK_FORMAT_ASTC_5x5_UNORM_BLOCK: - case VK_FORMAT_ASTC_5x5_SRGB_BLOCK: - case VK_FORMAT_ASTC_6x5_UNORM_BLOCK: - case VK_FORMAT_ASTC_6x5_SRGB_BLOCK: - case VK_FORMAT_ASTC_6x6_UNORM_BLOCK: - case VK_FORMAT_ASTC_6x6_SRGB_BLOCK: - case VK_FORMAT_ASTC_8x5_UNORM_BLOCK: - case VK_FORMAT_ASTC_8x5_SRGB_BLOCK: - case VK_FORMAT_ASTC_8x6_UNORM_BLOCK: - case VK_FORMAT_ASTC_8x6_SRGB_BLOCK: - case VK_FORMAT_ASTC_8x8_UNORM_BLOCK: - case VK_FORMAT_ASTC_8x8_SRGB_BLOCK: - case VK_FORMAT_ASTC_10x5_UNORM_BLOCK: - case VK_FORMAT_ASTC_10x5_SRGB_BLOCK: - case VK_FORMAT_ASTC_10x6_UNORM_BLOCK: - case VK_FORMAT_ASTC_10x6_SRGB_BLOCK: - case VK_FORMAT_ASTC_10x8_UNORM_BLOCK: - case VK_FORMAT_ASTC_10x8_SRGB_BLOCK: - case VK_FORMAT_ASTC_10x10_UNORM_BLOCK: - case VK_FORMAT_ASTC_10x10_SRGB_BLOCK: - case VK_FORMAT_ASTC_12x10_UNORM_BLOCK: - case VK_FORMAT_ASTC_12x10_SRGB_BLOCK: - case VK_FORMAT_ASTC_12x12_UNORM_BLOCK: - case VK_FORMAT_ASTC_12x12_SRGB_BLOCK: - return true; - default: - return false; + case VK_FORMAT_BC1_RGB_UNORM_BLOCK: + case VK_FORMAT_BC1_RGB_SRGB_BLOCK: + case VK_FORMAT_BC1_RGBA_UNORM_BLOCK: + case VK_FORMAT_BC1_RGBA_SRGB_BLOCK: + case VK_FORMAT_BC2_UNORM_BLOCK: + case VK_FORMAT_BC2_SRGB_BLOCK: + case VK_FORMAT_BC3_UNORM_BLOCK: + case VK_FORMAT_BC3_SRGB_BLOCK: + case VK_FORMAT_BC4_UNORM_BLOCK: + case VK_FORMAT_BC4_SNORM_BLOCK: + case VK_FORMAT_BC5_UNORM_BLOCK: + case VK_FORMAT_BC5_SNORM_BLOCK: + case VK_FORMAT_BC6H_UFLOAT_BLOCK: + case VK_FORMAT_BC6H_SFLOAT_BLOCK: + case VK_FORMAT_BC7_UNORM_BLOCK: + case VK_FORMAT_BC7_SRGB_BLOCK: + case VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK: + case VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK: + case VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK: + case VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK: + case VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK: + case VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK: + case VK_FORMAT_EAC_R11_UNORM_BLOCK: + case VK_FORMAT_EAC_R11_SNORM_BLOCK: + case VK_FORMAT_EAC_R11G11_UNORM_BLOCK: + case VK_FORMAT_EAC_R11G11_SNORM_BLOCK: + case VK_FORMAT_ASTC_4x4_UNORM_BLOCK: + case VK_FORMAT_ASTC_4x4_SRGB_BLOCK: + case VK_FORMAT_ASTC_5x4_UNORM_BLOCK: + case VK_FORMAT_ASTC_5x4_SRGB_BLOCK: + case VK_FORMAT_ASTC_5x5_UNORM_BLOCK: + case VK_FORMAT_ASTC_5x5_SRGB_BLOCK: + case VK_FORMAT_ASTC_6x5_UNORM_BLOCK: + case VK_FORMAT_ASTC_6x5_SRGB_BLOCK: + case VK_FORMAT_ASTC_6x6_UNORM_BLOCK: + case VK_FORMAT_ASTC_6x6_SRGB_BLOCK: + case VK_FORMAT_ASTC_8x5_UNORM_BLOCK: + case VK_FORMAT_ASTC_8x5_SRGB_BLOCK: + case VK_FORMAT_ASTC_8x6_UNORM_BLOCK: + case VK_FORMAT_ASTC_8x6_SRGB_BLOCK: + case VK_FORMAT_ASTC_8x8_UNORM_BLOCK: + case VK_FORMAT_ASTC_8x8_SRGB_BLOCK: + case VK_FORMAT_ASTC_10x5_UNORM_BLOCK: + case VK_FORMAT_ASTC_10x5_SRGB_BLOCK: + case VK_FORMAT_ASTC_10x6_UNORM_BLOCK: + case VK_FORMAT_ASTC_10x6_SRGB_BLOCK: + case VK_FORMAT_ASTC_10x8_UNORM_BLOCK: + case VK_FORMAT_ASTC_10x8_SRGB_BLOCK: + case VK_FORMAT_ASTC_10x10_UNORM_BLOCK: + case VK_FORMAT_ASTC_10x10_SRGB_BLOCK: + case VK_FORMAT_ASTC_12x10_UNORM_BLOCK: + case VK_FORMAT_ASTC_12x10_SRGB_BLOCK: + case VK_FORMAT_ASTC_12x12_UNORM_BLOCK: + case VK_FORMAT_ASTC_12x12_SRGB_BLOCK: + return true; + default: + return false; } } @@ -563,90 +563,90 @@ VK_LAYER_EXPORT bool vk_format_is_compressed(VkFormat format) { VK_LAYER_EXPORT VkExtent2D vk_format_compressed_block_size(VkFormat format) { VkExtent2D block_size = {1, 1}; switch (format) { - case VK_FORMAT_BC1_RGB_UNORM_BLOCK: - case VK_FORMAT_BC1_RGB_SRGB_BLOCK: - case VK_FORMAT_BC1_RGBA_UNORM_BLOCK: - case VK_FORMAT_BC1_RGBA_SRGB_BLOCK: - case VK_FORMAT_BC2_UNORM_BLOCK: - case VK_FORMAT_BC2_SRGB_BLOCK: - case VK_FORMAT_BC3_UNORM_BLOCK: - case VK_FORMAT_BC3_SRGB_BLOCK: - case VK_FORMAT_BC4_UNORM_BLOCK: - case VK_FORMAT_BC4_SNORM_BLOCK: - case VK_FORMAT_BC5_UNORM_BLOCK: - case VK_FORMAT_BC5_SNORM_BLOCK: - case VK_FORMAT_BC6H_UFLOAT_BLOCK: - case VK_FORMAT_BC6H_SFLOAT_BLOCK: - case VK_FORMAT_BC7_UNORM_BLOCK: - case VK_FORMAT_BC7_SRGB_BLOCK: - case VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK: - case VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK: - case VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK: - case VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK: - case VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK: - case VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK: - case VK_FORMAT_EAC_R11_UNORM_BLOCK: - case VK_FORMAT_EAC_R11_SNORM_BLOCK: - case VK_FORMAT_EAC_R11G11_UNORM_BLOCK: - case VK_FORMAT_EAC_R11G11_SNORM_BLOCK: - case VK_FORMAT_ASTC_4x4_UNORM_BLOCK: - case VK_FORMAT_ASTC_4x4_SRGB_BLOCK: - block_size = {4, 4}; - break; - case VK_FORMAT_ASTC_5x4_UNORM_BLOCK: - case VK_FORMAT_ASTC_5x4_SRGB_BLOCK: - block_size = {5, 4}; - break; - case VK_FORMAT_ASTC_5x5_UNORM_BLOCK: - case VK_FORMAT_ASTC_5x5_SRGB_BLOCK: - block_size = {5, 5}; - break; - case VK_FORMAT_ASTC_6x5_UNORM_BLOCK: - case VK_FORMAT_ASTC_6x5_SRGB_BLOCK: - block_size = {6, 5}; - break; - case VK_FORMAT_ASTC_6x6_UNORM_BLOCK: - case VK_FORMAT_ASTC_6x6_SRGB_BLOCK: - block_size = {6, 6}; - break; - case VK_FORMAT_ASTC_8x5_UNORM_BLOCK: - case VK_FORMAT_ASTC_8x5_SRGB_BLOCK: - block_size = {8, 5}; - break; - case VK_FORMAT_ASTC_8x6_UNORM_BLOCK: - case VK_FORMAT_ASTC_8x6_SRGB_BLOCK: - block_size = {8, 6}; - break; - case VK_FORMAT_ASTC_8x8_UNORM_BLOCK: - case VK_FORMAT_ASTC_8x8_SRGB_BLOCK: - block_size = {8, 8}; - break; - case VK_FORMAT_ASTC_10x5_UNORM_BLOCK: - case VK_FORMAT_ASTC_10x5_SRGB_BLOCK: - block_size = {10, 5}; - break; - case VK_FORMAT_ASTC_10x6_UNORM_BLOCK: - case VK_FORMAT_ASTC_10x6_SRGB_BLOCK: - block_size = {10, 6}; - break; - case VK_FORMAT_ASTC_10x8_UNORM_BLOCK: - case VK_FORMAT_ASTC_10x8_SRGB_BLOCK: - block_size = {10, 8}; - break; - case VK_FORMAT_ASTC_10x10_UNORM_BLOCK: - case VK_FORMAT_ASTC_10x10_SRGB_BLOCK: - block_size = {10, 10}; - break; - case VK_FORMAT_ASTC_12x10_UNORM_BLOCK: - case VK_FORMAT_ASTC_12x10_SRGB_BLOCK: - block_size = {12, 10}; - break; - case VK_FORMAT_ASTC_12x12_UNORM_BLOCK: - case VK_FORMAT_ASTC_12x12_SRGB_BLOCK: - block_size = {12, 12}; - break; - default: - break; + case VK_FORMAT_BC1_RGB_UNORM_BLOCK: + case VK_FORMAT_BC1_RGB_SRGB_BLOCK: + case VK_FORMAT_BC1_RGBA_UNORM_BLOCK: + case VK_FORMAT_BC1_RGBA_SRGB_BLOCK: + case VK_FORMAT_BC2_UNORM_BLOCK: + case VK_FORMAT_BC2_SRGB_BLOCK: + case VK_FORMAT_BC3_UNORM_BLOCK: + case VK_FORMAT_BC3_SRGB_BLOCK: + case VK_FORMAT_BC4_UNORM_BLOCK: + case VK_FORMAT_BC4_SNORM_BLOCK: + case VK_FORMAT_BC5_UNORM_BLOCK: + case VK_FORMAT_BC5_SNORM_BLOCK: + case VK_FORMAT_BC6H_UFLOAT_BLOCK: + case VK_FORMAT_BC6H_SFLOAT_BLOCK: + case VK_FORMAT_BC7_UNORM_BLOCK: + case VK_FORMAT_BC7_SRGB_BLOCK: + case VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK: + case VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK: + case VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK: + case VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK: + case VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK: + case VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK: + case VK_FORMAT_EAC_R11_UNORM_BLOCK: + case VK_FORMAT_EAC_R11_SNORM_BLOCK: + case VK_FORMAT_EAC_R11G11_UNORM_BLOCK: + case VK_FORMAT_EAC_R11G11_SNORM_BLOCK: + case VK_FORMAT_ASTC_4x4_UNORM_BLOCK: + case VK_FORMAT_ASTC_4x4_SRGB_BLOCK: + block_size = {4, 4}; + break; + case VK_FORMAT_ASTC_5x4_UNORM_BLOCK: + case VK_FORMAT_ASTC_5x4_SRGB_BLOCK: + block_size = {5, 4}; + break; + case VK_FORMAT_ASTC_5x5_UNORM_BLOCK: + case VK_FORMAT_ASTC_5x5_SRGB_BLOCK: + block_size = {5, 5}; + break; + case VK_FORMAT_ASTC_6x5_UNORM_BLOCK: + case VK_FORMAT_ASTC_6x5_SRGB_BLOCK: + block_size = {6, 5}; + break; + case VK_FORMAT_ASTC_6x6_UNORM_BLOCK: + case VK_FORMAT_ASTC_6x6_SRGB_BLOCK: + block_size = {6, 6}; + break; + case VK_FORMAT_ASTC_8x5_UNORM_BLOCK: + case VK_FORMAT_ASTC_8x5_SRGB_BLOCK: + block_size = {8, 5}; + break; + case VK_FORMAT_ASTC_8x6_UNORM_BLOCK: + case VK_FORMAT_ASTC_8x6_SRGB_BLOCK: + block_size = {8, 6}; + break; + case VK_FORMAT_ASTC_8x8_UNORM_BLOCK: + case VK_FORMAT_ASTC_8x8_SRGB_BLOCK: + block_size = {8, 8}; + break; + case VK_FORMAT_ASTC_10x5_UNORM_BLOCK: + case VK_FORMAT_ASTC_10x5_SRGB_BLOCK: + block_size = {10, 5}; + break; + case VK_FORMAT_ASTC_10x6_UNORM_BLOCK: + case VK_FORMAT_ASTC_10x6_SRGB_BLOCK: + block_size = {10, 6}; + break; + case VK_FORMAT_ASTC_10x8_UNORM_BLOCK: + case VK_FORMAT_ASTC_10x8_SRGB_BLOCK: + block_size = {10, 8}; + break; + case VK_FORMAT_ASTC_10x10_UNORM_BLOCK: + case VK_FORMAT_ASTC_10x10_SRGB_BLOCK: + block_size = {10, 10}; + break; + case VK_FORMAT_ASTC_12x10_UNORM_BLOCK: + case VK_FORMAT_ASTC_12x10_SRGB_BLOCK: + block_size = {12, 10}; + break; + case VK_FORMAT_ASTC_12x12_UNORM_BLOCK: + case VK_FORMAT_ASTC_12x12_SRGB_BLOCK: + block_size = {12, 12}; + break; + default: + break; } return block_size; } @@ -753,7 +753,6 @@ VK_LAYER_EXPORT bool white_list(const char *item, const char *list) { // callback will cause the default callbacks to be unregisterd and removed. VK_LAYER_EXPORT void layer_debug_actions(debug_report_data *report_data, std::vector &logging_callback, const VkAllocationCallbacks *pAllocator, const char *layer_identifier) { - VkDebugReportCallbackEXT callback = VK_NULL_HANDLE; std::string report_flags_key = layer_identifier; diff --git a/layers/vk_layer_utils.h b/layers/vk_layer_utils.h index a70ae6b..943f846 100644 --- a/layers/vk_layer_utils.h +++ b/layers/vk_layer_utils.h @@ -24,9 +24,9 @@ #include "vk_layer_logging.h" #ifndef WIN32 -#include // For ffs() +#include // For ffs() #else -#include // For __lzcnt() +#include // For __lzcnt() #endif #ifdef __cplusplus diff --git a/loader/cJSON.c b/loader/cJSON.c index 9c800e1..a7671c4 100644 --- a/loader/cJSON.c +++ b/loader/cJSON.c @@ -47,8 +47,7 @@ static char *cJSON_strdup(const char *str) { char *copy; len = strlen(str) + 1; - if (!(copy = (char *)cJSON_malloc(len))) - return 0; + if (!(copy = (char *)cJSON_malloc(len))) return 0; memcpy(copy, str, len); return copy; } @@ -67,8 +66,7 @@ void cJSON_InitHooks(cJSON_Hooks *hooks) { /* Internal constructor. */ static cJSON *cJSON_New_Item(void) { cJSON *node = (cJSON *)cJSON_malloc(sizeof(cJSON)); - if (node) - memset(node, 0, sizeof(cJSON)); + if (node) memset(node, 0, sizeof(cJSON)); return node; } @@ -77,12 +75,9 @@ void cJSON_Delete(cJSON *c) { cJSON *next; while (c) { next = c->next; - if (!(c->type & cJSON_IsReference) && c->child) - cJSON_Delete(c->child); - if (!(c->type & cJSON_IsReference) && c->valuestring) - cJSON_free(c->valuestring); - if (!(c->type & cJSON_StringIsConst) && c->string) - cJSON_free(c->string); + if (!(c->type & cJSON_IsReference) && c->child) cJSON_Delete(c->child); + if (!(c->type & cJSON_IsReference) && c->valuestring) cJSON_free(c->valuestring); + if (!(c->type & cJSON_StringIsConst) && c->string) cJSON_free(c->string); cJSON_free(c); c = next; } @@ -96,12 +91,9 @@ static const char *parse_number(cJSON *item, const char *num) { double n = 0, sign = 1, scale = 0; int subscale = 0, signsubscale = 1; - if (*num == '-') - sign = -1, num++; /* Has sign? */ - if (*num == '0') - num++; /* is zero */ - if (*num >= '1' && *num <= '9') - do + if (*num == '-') sign = -1, num++; /* Has sign? */ + if (*num == '0') num++; /* is zero */ + if (*num >= '1' && *num <= '9') do n = (n * 10.0) + (*num++ - '0'); while (*num >= '0' && *num <= '9'); /* Number? */ if (*num == '.' && num[1] >= '0' && num[1] <= '9') { @@ -116,9 +108,8 @@ static const char *parse_number(cJSON *item, const char *num) { if (*num == '+') num++; else if (*num == '-') - signsubscale = -1, num++; /* With sign? */ - while (*num >= '0' && *num <= '9') - subscale = (subscale * 10) + (*num++ - '0'); /* Number? */ + signsubscale = -1, num++; /* With sign? */ + while (*num >= '0' && *num <= '9') subscale = (subscale * 10) + (*num++ - '0'); /* Number? */ } n = sign * n * pow(10.0, (scale + subscale * signsubscale)); /* number = +/- @@ -150,11 +141,9 @@ typedef struct { static char *ensure(printbuffer *p, size_t needed) { char *newbuffer; size_t newsize; - if (!p || !p->buffer) - return 0; + if (!p || !p->buffer) return 0; needed += p->offset; - if (needed <= p->length) - return p->buffer + p->offset; + if (needed <= p->length) return p->buffer + p->offset; newsize = pow2gt(needed); newbuffer = (char *)cJSON_malloc(newsize); @@ -163,8 +152,7 @@ static char *ensure(printbuffer *p, size_t needed) { p->length = 0, p->buffer = 0; return 0; } - if (newbuffer) - memcpy(newbuffer, p->buffer, p->length); + if (newbuffer) memcpy(newbuffer, p->buffer, p->length); cJSON_free(p->buffer); p->length = newsize; p->buffer = newbuffer; @@ -173,8 +161,7 @@ static char *ensure(printbuffer *p, size_t needed) { static size_t update(printbuffer *p) { char *str; - if (!p || !p->buffer) - return 0; + if (!p || !p->buffer) return 0; str = p->buffer + p->offset; return p->offset + strlen(str); } @@ -188,15 +175,13 @@ static char *print_number(cJSON *item, printbuffer *p) { str = ensure(p, 2); else str = (char *)cJSON_malloc(2); /* special case for 0. */ - if (str) - strcpy(str, "0"); + if (str) strcpy(str, "0"); } else if (fabs(((double)item->valueint) - d) <= DBL_EPSILON && d <= INT_MAX && d >= INT_MIN) { if (p) str = ensure(p, 21); else str = (char *)cJSON_malloc(21); /* 2^64+1 can be represented in 21 chars. */ - if (str) - sprintf(str, "%d", item->valueint); + if (str) sprintf(str, "%d", item->valueint); } else { if (p) str = ensure(p, 64); @@ -271,12 +256,10 @@ static const char *parse_string(cJSON *item, const char *str) { } /* not a string! */ while (*ptr != '\"' && *ptr && ++len) - if (*ptr++ == '\\') - ptr++; /* Skip escaped quotes. */ + if (*ptr++ == '\\') ptr++; /* Skip escaped quotes. */ out = (char *)cJSON_malloc(len + 1); /* This is how long we need for the string, roughly. */ - if (!out) - return 0; + if (!out) return 0; ptr = str + 1; ptr2 = out; @@ -286,73 +269,69 @@ static const char *parse_string(cJSON *item, const char *str) { else { ptr++; switch (*ptr) { - case 'b': - *ptr2++ = '\b'; - break; - case 'f': - *ptr2++ = '\f'; - break; - case 'n': - *ptr2++ = '\n'; - break; - case 'r': - *ptr2++ = '\r'; - break; - case 't': - *ptr2++ = '\t'; - break; - case 'u': /* transcode utf16 to utf8. */ - uc = parse_hex4(ptr + 1); - ptr += 4; /* get the unicode char. */ - - if ((uc >= 0xDC00 && uc <= 0xDFFF) || uc == 0) - break; /* check for invalid. */ - - if (uc >= 0xD800 && uc <= 0xDBFF) /* UTF16 surrogate pairs. */ - { - if (ptr[1] != '\\' || ptr[2] != 'u') - break; /* missing second-half of surrogate. */ - uc2 = parse_hex4(ptr + 3); - ptr += 6; - if (uc2 < 0xDC00 || uc2 > 0xDFFF) - break; /* invalid second-half of surrogate. */ - uc = 0x10000 + (((uc & 0x3FF) << 10) | (uc2 & 0x3FF)); - } - - len = 4; - if (uc < 0x80) - len = 1; - else if (uc < 0x800) - len = 2; - else if (uc < 0x10000) - len = 3; - ptr2 += len; - - switch (len) { - case 4: - *--ptr2 = ((uc | 0x80) & 0xBF); - uc >>= 6; - case 3: - *--ptr2 = ((uc | 0x80) & 0xBF); - uc >>= 6; - case 2: - *--ptr2 = ((uc | 0x80) & 0xBF); - uc >>= 6; - case 1: - *--ptr2 = ((unsigned char)uc | firstByteMark[len]); - } - ptr2 += len; - break; - default: - *ptr2++ = *ptr; - break; + case 'b': + *ptr2++ = '\b'; + break; + case 'f': + *ptr2++ = '\f'; + break; + case 'n': + *ptr2++ = '\n'; + break; + case 'r': + *ptr2++ = '\r'; + break; + case 't': + *ptr2++ = '\t'; + break; + case 'u': /* transcode utf16 to utf8. */ + uc = parse_hex4(ptr + 1); + ptr += 4; /* get the unicode char. */ + + if ((uc >= 0xDC00 && uc <= 0xDFFF) || uc == 0) break; /* check for invalid. */ + + if (uc >= 0xD800 && uc <= 0xDBFF) /* UTF16 surrogate pairs. */ + { + if (ptr[1] != '\\' || ptr[2] != 'u') break; /* missing second-half of surrogate. */ + uc2 = parse_hex4(ptr + 3); + ptr += 6; + if (uc2 < 0xDC00 || uc2 > 0xDFFF) break; /* invalid second-half of surrogate. */ + uc = 0x10000 + (((uc & 0x3FF) << 10) | (uc2 & 0x3FF)); + } + + len = 4; + if (uc < 0x80) + len = 1; + else if (uc < 0x800) + len = 2; + else if (uc < 0x10000) + len = 3; + ptr2 += len; + + switch (len) { + case 4: + *--ptr2 = ((uc | 0x80) & 0xBF); + uc >>= 6; + case 3: + *--ptr2 = ((uc | 0x80) & 0xBF); + uc >>= 6; + case 2: + *--ptr2 = ((uc | 0x80) & 0xBF); + uc >>= 6; + case 1: + *--ptr2 = ((unsigned char)uc | firstByteMark[len]); + } + ptr2 += len; + break; + default: + *ptr2++ = *ptr; + break; } ptr++; } } *ptr2 = 0; - if (*ptr == '\"') - ptr++; + if (*ptr == '\"') ptr++; item->valuestring = out; item->type = cJSON_String; return ptr; @@ -366,16 +345,14 @@ static char *print_string_ptr(const char *str, printbuffer *p) { size_t len = 0, flag = 0; unsigned char token; - for (ptr = str; *ptr; ptr++) - flag |= ((*ptr > 0 && *ptr < 32) || (*ptr == '\"') || (*ptr == '\\')) ? 1 : 0; + for (ptr = str; *ptr; ptr++) flag |= ((*ptr > 0 && *ptr < 32) || (*ptr == '\"') || (*ptr == '\\')) ? 1 : 0; if (!flag) { len = ptr - str; if (p) out = ensure(p, len + 3); else out = (char *)cJSON_malloc(len + 3); - if (!out) - return 0; + if (!out) return 0; ptr2 = out; *ptr2++ = '\"'; strcpy(ptr2, str); @@ -389,8 +366,7 @@ static char *print_string_ptr(const char *str, printbuffer *p) { out = ensure(p, 3); else out = (char *)cJSON_malloc(3); - if (!out) - return 0; + if (!out) return 0; strcpy(out, "\"\""); return out; } @@ -407,8 +383,7 @@ static char *print_string_ptr(const char *str, printbuffer *p) { out = ensure(p, len + 3); else out = (char *)cJSON_malloc(len + 3); - if (!out) - return 0; + if (!out) return 0; ptr2 = out; ptr = str; @@ -418,31 +393,31 @@ static char *print_string_ptr(const char *str, printbuffer *p) { *ptr2++ = *ptr++; else { switch (token = *ptr++) { - case '\\': - *ptr2++ = '\\'; - break; - case '\"': - *ptr2++ = '\"'; - break; - case '\b': - *ptr2++ = '\b'; - break; - case '\f': - *ptr2++ = '\f'; - break; - case '\n': - *ptr2++ = '\n'; - break; - case '\r': - *ptr2++ = '\r'; - break; - case '\t': - *ptr2++ = '\t'; - break; - default: - sprintf(ptr2, "u%04x", token); - ptr2 += 5; - break; /* escape and print */ + case '\\': + *ptr2++ = '\\'; + break; + case '\"': + *ptr2++ = '\"'; + break; + case '\b': + *ptr2++ = '\b'; + break; + case '\f': + *ptr2++ = '\f'; + break; + case '\n': + *ptr2++ = '\n'; + break; + case '\r': + *ptr2++ = '\r'; + break; + case '\t': + *ptr2++ = '\t'; + break; + default: + sprintf(ptr2, "u%04x", token); + ptr2 += 5; + break; /* escape and print */ } } } @@ -463,8 +438,7 @@ static char *print_object(cJSON *item, int depth, int fmt, printbuffer *p); /* Utility to jump whitespace and cr/lf */ static const char *skip(const char *in) { - while (in && *in && (unsigned char)*in <= 32) - in++; + while (in && *in && (unsigned char)*in <= 32) in++; return in; } @@ -473,8 +447,7 @@ cJSON *cJSON_ParseWithOpts(const char *value, const char **return_parse_end, int const char *end = 0; cJSON *c = cJSON_New_Item(); ep = 0; - if (!c) - return 0; /* memory fail */ + if (!c) return 0; /* memory fail */ end = parse_value(c, skip(value)); if (!end) { @@ -492,8 +465,7 @@ cJSON *cJSON_ParseWithOpts(const char *value, const char **return_parse_end, int return 0; } } - if (return_parse_end) - *return_parse_end = end; + if (return_parse_end) *return_parse_end = end; return c; } /* Default options for cJSON_Parse */ @@ -513,8 +485,7 @@ char *cJSON_PrintBuffered(cJSON *item, int prebuffer, int fmt) { /* Parser core - when encountering text, process appropriately. */ static const char *parse_value(cJSON *item, const char *value) { - if (!value) - return 0; /* Fail on null. */ + if (!value) return 0; /* Fail on null. */ if (!strncmp(value, "null", 4)) { item->type = cJSON_NULL; return value + 4; @@ -548,64 +519,60 @@ static const char *parse_value(cJSON *item, const char *value) { /* Render a value to text. */ static char *print_value(cJSON *item, int depth, int fmt, printbuffer *p) { char *out = 0; - if (!item) - return 0; + if (!item) return 0; if (p) { switch ((item->type) & 255) { - case cJSON_NULL: { - out = ensure(p, 5); - if (out) - strcpy(out, "null"); - break; - } - case cJSON_False: { - out = ensure(p, 6); - if (out) - strcpy(out, "false"); - break; - } - case cJSON_True: { - out = ensure(p, 5); - if (out) - strcpy(out, "true"); - break; - } - case cJSON_Number: - out = print_number(item, p); - break; - case cJSON_String: - out = print_string(item, p); - break; - case cJSON_Array: - out = print_array(item, depth, fmt, p); - break; - case cJSON_Object: - out = print_object(item, depth, fmt, p); - break; + case cJSON_NULL: { + out = ensure(p, 5); + if (out) strcpy(out, "null"); + break; + } + case cJSON_False: { + out = ensure(p, 6); + if (out) strcpy(out, "false"); + break; + } + case cJSON_True: { + out = ensure(p, 5); + if (out) strcpy(out, "true"); + break; + } + case cJSON_Number: + out = print_number(item, p); + break; + case cJSON_String: + out = print_string(item, p); + break; + case cJSON_Array: + out = print_array(item, depth, fmt, p); + break; + case cJSON_Object: + out = print_object(item, depth, fmt, p); + break; } } else { switch ((item->type) & 255) { - case cJSON_NULL: - out = cJSON_strdup("null"); - break; - case cJSON_False: - out = cJSON_strdup("false"); - break; - case cJSON_True: - out = cJSON_strdup("true"); - break; - case cJSON_Number: - out = print_number(item, 0); - break; - case cJSON_String: - out = print_string(item, 0); - break; - case cJSON_Array: - out = print_array(item, depth, fmt, 0); - break; - case cJSON_Object: - out = print_object(item, depth, fmt, 0); - break; + case cJSON_NULL: + out = cJSON_strdup("null"); + break; + case cJSON_False: + out = cJSON_strdup("false"); + break; + case cJSON_True: + out = cJSON_strdup("true"); + break; + case cJSON_Number: + out = print_number(item, 0); + break; + case cJSON_String: + out = print_string(item, 0); + break; + case cJSON_Array: + out = print_array(item, depth, fmt, 0); + break; + case cJSON_Object: + out = print_object(item, depth, fmt, 0); + break; } } return out; @@ -621,30 +588,24 @@ static const char *parse_array(cJSON *item, const char *value) { item->type = cJSON_Array; value = skip(value + 1); - if (*value == ']') - return value + 1; /* empty array. */ + if (*value == ']') return value + 1; /* empty array. */ item->child = child = cJSON_New_Item(); - if (!item->child) - return 0; /* memory fail */ + if (!item->child) return 0; /* memory fail */ value = skip(parse_value(child, skip(value))); /* skip any spacing, get the value. */ - if (!value) - return 0; + if (!value) return 0; while (*value == ',') { cJSON *new_item; - if (!(new_item = cJSON_New_Item())) - return 0; /* memory fail */ + if (!(new_item = cJSON_New_Item())) return 0; /* memory fail */ child->next = new_item; new_item->prev = child; child = new_item; value = skip(parse_value(child, skip(value + 1))); - if (!value) - return 0; /* memory fail */ + if (!value) return 0; /* memory fail */ } - if (*value == ']') - return value + 1; /* end of array */ + if (*value == ']') return value + 1; /* end of array */ ep = value; return 0; /* malformed. */ } @@ -659,16 +620,14 @@ static char *print_array(cJSON *item, int depth, int fmt, printbuffer *p) { size_t tmplen = 0, i = 0; /* How many entries in the array? */ - while (child) - numentries++, child = child->next; + while (child) numentries++, child = child->next; /* Explicitly handle numentries==0 */ if (!numentries) { if (p) out = ensure(p, 3); else out = (char *)cJSON_malloc(3); - if (out) - strcpy(out, "[]"); + if (out) strcpy(out, "[]"); return out; } @@ -676,8 +635,7 @@ static char *print_array(cJSON *item, int depth, int fmt, printbuffer *p) { /* Compose the output array. */ i = p->offset; ptr = ensure(p, 1); - if (!ptr) - return 0; + if (!ptr) return 0; *ptr = '['; p->offset++; child = item->child; @@ -687,27 +645,23 @@ static char *print_array(cJSON *item, int depth, int fmt, printbuffer *p) { if (child->next) { len = fmt ? 2 : 1; ptr = ensure(p, len + 1); - if (!ptr) - return 0; + if (!ptr) return 0; *ptr++ = ','; - if (fmt) - *ptr++ = ' '; + if (fmt) *ptr++ = ' '; *ptr = 0; p->offset += len; } child = child->next; } ptr = ensure(p, 2); - if (!ptr) - return 0; + if (!ptr) return 0; *ptr++ = ']'; *ptr = 0; out = (p->buffer) + i; } else { /* Allocate an array to hold the values for each */ entries = (char **)cJSON_malloc(numentries * sizeof(char *)); - if (!entries) - return 0; + if (!entries) return 0; memset(entries, 0, numentries * sizeof(char *)); /* Retrieve all the results: */ child = item->child; @@ -722,17 +676,14 @@ static char *print_array(cJSON *item, int depth, int fmt, printbuffer *p) { } /* If we didn't fail, try to malloc the output string */ - if (!fail) - out = (char *)cJSON_malloc(len); + if (!fail) out = (char *)cJSON_malloc(len); /* If that fails, we fail. */ - if (!out) - fail = 1; + if (!out) fail = 1; /* Handle failure. */ if (fail) { for (j = 0; j < numentries; j++) - if (entries[j]) - cJSON_free(entries[j]); + if (entries[j]) cJSON_free(entries[j]); cJSON_free(entries); return 0; } @@ -747,8 +698,7 @@ static char *print_array(cJSON *item, int depth, int fmt, printbuffer *p) { ptr += tmplen; if (j != numentries - 1) { *ptr++ = ','; - if (fmt) - *ptr++ = ' '; + if (fmt) *ptr++ = ' '; *ptr = 0; } cJSON_free(entries[j]); @@ -770,15 +720,12 @@ static const char *parse_object(cJSON *item, const char *value) { item->type = cJSON_Object; value = skip(value + 1); - if (*value == '}') - return value + 1; /* empty array. */ + if (*value == '}') return value + 1; /* empty array. */ item->child = child = cJSON_New_Item(); - if (!item->child) - return 0; + if (!item->child) return 0; value = skip(parse_string(child, skip(value))); - if (!value) - return 0; + if (!value) return 0; child->string = child->valuestring; child->valuestring = 0; if (*value != ':') { @@ -786,19 +733,16 @@ static const char *parse_object(cJSON *item, const char *value) { return 0; } /* fail! */ value = skip(parse_value(child, skip(value + 1))); /* skip any spacing, get the value. */ - if (!value) - return 0; + if (!value) return 0; while (*value == ',') { cJSON *new_item; - if (!(new_item = cJSON_New_Item())) - return 0; /* memory fail */ + if (!(new_item = cJSON_New_Item())) return 0; /* memory fail */ child->next = new_item; new_item->prev = child; child = new_item; value = skip(parse_string(child, skip(value + 1))); - if (!value) - return 0; + if (!value) return 0; child->string = child->valuestring; child->valuestring = 0; if (*value != ':') { @@ -806,12 +750,10 @@ static const char *parse_object(cJSON *item, const char *value) { return 0; } /* fail! */ value = skip(parse_value(child, skip(value + 1))); /* skip any spacing, get the value. */ - if (!value) - return 0; + if (!value) return 0; } - if (*value == '}') - return value + 1; /* end of array */ + if (*value == '}') return value + 1; /* end of array */ ep = value; return 0; /* malformed. */ } @@ -825,22 +767,19 @@ static char *print_object(cJSON *item, int depth, int fmt, printbuffer *p) { int numentries = 0, fail = 0, k; size_t tmplen = 0, i = 0, len = 7; /* Count the number of entries. */ - while (child) - numentries++, child = child->next; + while (child) numentries++, child = child->next; /* Explicitly handle empty object case */ if (!numentries) { if (p) out = ensure(p, fmt ? depth + 4 : 3); else out = (char *)cJSON_malloc(fmt ? depth + 4 : 3); - if (!out) - return 0; + if (!out) return 0; ptr = out; *ptr++ = '{'; if (fmt) { *ptr++ = '\n'; - for (j = 0; j < depth - 1; j++) - *ptr++ = '\t'; + for (j = 0; j < depth - 1; j++) *ptr++ = '\t'; } *ptr++ = '}'; *ptr++ = 0; @@ -851,11 +790,9 @@ static char *print_object(cJSON *item, int depth, int fmt, printbuffer *p) { i = p->offset; len = fmt ? 2 : 1; ptr = ensure(p, len + 1); - if (!ptr) - return 0; + if (!ptr) return 0; *ptr++ = '{'; - if (fmt) - *ptr++ = '\n'; + if (fmt) *ptr++ = '\n'; *ptr = 0; p->offset += len; child = item->child; @@ -863,10 +800,8 @@ static char *print_object(cJSON *item, int depth, int fmt, printbuffer *p) { while (child) { if (fmt) { ptr = ensure(p, depth); - if (!ptr) - return 0; - for (j = 0; j < depth; j++) - *ptr++ = '\t'; + if (!ptr) return 0; + for (j = 0; j < depth; j++) *ptr++ = '\t'; p->offset += depth; } print_string_ptr(child->string, p); @@ -874,11 +809,9 @@ static char *print_object(cJSON *item, int depth, int fmt, printbuffer *p) { len = fmt ? 2 : 1; ptr = ensure(p, len); - if (!ptr) - return 0; + if (!ptr) return 0; *ptr++ = ':'; - if (fmt) - *ptr++ = '\t'; + if (fmt) *ptr++ = '\t'; p->offset += len; print_value(child, depth, fmt, p); @@ -886,30 +819,24 @@ static char *print_object(cJSON *item, int depth, int fmt, printbuffer *p) { len = (fmt ? 1 : 0) + (child->next ? 1 : 0); ptr = ensure(p, len + 1); - if (!ptr) - return 0; - if (child->next) - *ptr++ = ','; - if (fmt) - *ptr++ = '\n'; + if (!ptr) return 0; + if (child->next) *ptr++ = ','; + if (fmt) *ptr++ = '\n'; *ptr = 0; p->offset += len; child = child->next; } ptr = ensure(p, fmt ? (depth + 1) : 2); - if (!ptr) - return 0; + if (!ptr) return 0; if (fmt) - for (j = 0; j < depth - 1; j++) - *ptr++ = '\t'; + for (j = 0; j < depth - 1; j++) *ptr++ = '\t'; *ptr++ = '}'; *ptr = 0; out = (p->buffer) + i; } else { /* Allocate space for the names and the objects */ entries = (char **)cJSON_malloc(numentries * sizeof(char *)); - if (!entries) - return 0; + if (!entries) return 0; names = (char **)cJSON_malloc(numentries * sizeof(char *)); if (!names) { cJSON_free(entries); @@ -921,8 +848,7 @@ static char *print_object(cJSON *item, int depth, int fmt, printbuffer *p) { /* Collect all the results into our arrays: */ child = item->child; depth++; - if (fmt) - len += depth; + if (fmt) len += depth; while (child) { names[i] = str = print_string_ptr(child->string, 0); entries[i++] = ret = print_value(child, depth, fmt, 0); @@ -934,18 +860,14 @@ static char *print_object(cJSON *item, int depth, int fmt, printbuffer *p) { } /* Try to allocate the output string */ - if (!fail) - out = (char *)cJSON_malloc(len); - if (!out) - fail = 1; + if (!fail) out = (char *)cJSON_malloc(len); + if (!out) fail = 1; /* Handle failure */ if (fail) { for (j = 0; j < numentries; j++) { - if (names[i]) - cJSON_free(names[j]); - if (entries[j]) - cJSON_free(entries[j]); + if (names[i]) cJSON_free(names[j]); + if (entries[j]) cJSON_free(entries[j]); } cJSON_free(names); cJSON_free(entries); @@ -955,25 +877,20 @@ static char *print_object(cJSON *item, int depth, int fmt, printbuffer *p) { /* Compose the output: */ *out = '{'; ptr = out + 1; - if (fmt) - *ptr++ = '\n'; + if (fmt) *ptr++ = '\n'; *ptr = 0; for (j = 0; j < numentries; j++) { if (fmt) - for (k = 0; k < depth; k++) - *ptr++ = '\t'; + for (k = 0; k < depth; k++) *ptr++ = '\t'; tmplen = strlen(names[j]); memcpy(ptr, names[j], tmplen); ptr += tmplen; *ptr++ = ':'; - if (fmt) - *ptr++ = '\t'; + if (fmt) *ptr++ = '\t'; strcpy(ptr, entries[j]); ptr += strlen(entries[j]); - if (j != numentries - 1) - *ptr++ = ','; - if (fmt) - *ptr++ = '\n'; + if (j != numentries - 1) *ptr++ = ','; + if (fmt) *ptr++ = '\n'; *ptr = 0; cJSON_free(names[j]); cJSON_free(entries[j]); @@ -982,8 +899,7 @@ static char *print_object(cJSON *item, int depth, int fmt, printbuffer *p) { cJSON_free(names); cJSON_free(entries); if (fmt) - for (j = 0; j < depth - 1; j++) - *ptr++ = '\t'; + for (j = 0; j < depth - 1; j++) *ptr++ = '\t'; *ptr++ = '}'; *ptr++ = 0; } @@ -994,20 +910,17 @@ static char *print_object(cJSON *item, int depth, int fmt, printbuffer *p) { int cJSON_GetArraySize(cJSON *array) { cJSON *c = array->child; int i = 0; - while (c) - i++, c = c->next; + while (c) i++, c = c->next; return i; } cJSON *cJSON_GetArrayItem(cJSON *array, int item) { cJSON *c = array->child; - while (c && item > 0) - item--, c = c->next; + while (c && item > 0) item--, c = c->next; return c; } cJSON *cJSON_GetObjectItem(cJSON *object, const char *string) { cJSON *c = object->child; - while (c && strcmp(c->string, string)) - c = c->next; + while (c && strcmp(c->string, string)) c = c->next; return c; } @@ -1019,8 +932,7 @@ static void suffix_object(cJSON *prev, cJSON *item) { /* Utility for handling references. */ static cJSON *create_reference(cJSON *item) { cJSON *ref = cJSON_New_Item(); - if (!ref) - return 0; + if (!ref) return 0; memcpy(ref, item, sizeof(cJSON)); ref->string = 0; ref->type |= cJSON_IsReference; @@ -1031,29 +943,23 @@ static cJSON *create_reference(cJSON *item) { /* Add item to array/object. */ void cJSON_AddItemToArray(cJSON *array, cJSON *item) { cJSON *c = array->child; - if (!item) - return; + if (!item) return; if (!c) { array->child = item; } else { - while (c && c->next) - c = c->next; + while (c && c->next) c = c->next; suffix_object(c, item); } } void cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item) { - if (!item) - return; - if (item->string) - cJSON_free(item->string); + if (!item) return; + if (item->string) cJSON_free(item->string); item->string = cJSON_strdup(string); cJSON_AddItemToArray(object, item); } void cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item) { - if (!item) - return; - if (!(item->type & cJSON_StringIsConst) && item->string) - cJSON_free(item->string); + if (!item) return; + if (!(item->type & cJSON_StringIsConst) && item->string) cJSON_free(item->string); item->string = (char *)string; item->type |= cJSON_StringIsConst; cJSON_AddItemToArray(object, item); @@ -1065,16 +971,11 @@ void cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *it cJSON *cJSON_DetachItemFromArray(cJSON *array, int which) { cJSON *c = array->child; - while (c && which > 0) - c = c->next, which--; - if (!c) - return 0; - if (c->prev) - c->prev->next = c->next; - if (c->next) - c->next->prev = c->prev; - if (c == array->child) - array->child = c->next; + while (c && which > 0) c = c->next, which--; + if (!c) return 0; + if (c->prev) c->prev->next = c->next; + if (c->next) c->next->prev = c->prev; + if (c == array->child) array->child = c->next; c->prev = c->next = 0; return c; } @@ -1082,10 +983,8 @@ void cJSON_DeleteItemFromArray(cJSON *array, int which) { cJSON_Delete(cJSON_Det cJSON *cJSON_DetachItemFromObject(cJSON *object, const char *string) { int i = 0; cJSON *c = object->child; - while (c && strcmp(c->string, string)) - i++, c = c->next; - if (c) - return cJSON_DetachItemFromArray(object, i); + while (c && strcmp(c->string, string)) i++, c = c->next; + if (c) return cJSON_DetachItemFromArray(object, i); return 0; } void cJSON_DeleteItemFromObject(cJSON *object, const char *string) { cJSON_Delete(cJSON_DetachItemFromObject(object, string)); } @@ -1093,8 +992,7 @@ void cJSON_DeleteItemFromObject(cJSON *object, const char *string) { cJSON_Delet /* Replace array/object items with new ones. */ void cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem) { cJSON *c = array->child; - while (c && which > 0) - c = c->next, which--; + while (c && which > 0) c = c->next, which--; if (!c) { cJSON_AddItemToArray(array, newitem); return; @@ -1109,14 +1007,11 @@ void cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem) { } void cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem) { cJSON *c = array->child; - while (c && which > 0) - c = c->next, which--; - if (!c) - return; + while (c && which > 0) c = c->next, which--; + if (!c) return; newitem->next = c->next; newitem->prev = c->prev; - if (newitem->next) - newitem->next->prev = newitem; + if (newitem->next) newitem->next->prev = newitem; if (c == array->child) array->child = newitem; else @@ -1127,8 +1022,7 @@ void cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem) { void cJSON_ReplaceItemInObject(cJSON *object, const char *string, cJSON *newitem) { int i = 0; cJSON *c = object->child; - while (c && strcmp(c->string, string)) - i++, c = c->next; + while (c && strcmp(c->string, string)) i++, c = c->next; if (c) { newitem->string = cJSON_strdup(string); cJSON_ReplaceItemInArray(object, i, newitem); @@ -1138,26 +1032,22 @@ void cJSON_ReplaceItemInObject(cJSON *object, const char *string, cJSON *newitem /* Create basic types: */ cJSON *cJSON_CreateNull(void) { cJSON *item = cJSON_New_Item(); - if (item) - item->type = cJSON_NULL; + if (item) item->type = cJSON_NULL; return item; } cJSON *cJSON_CreateTrue(void) { cJSON *item = cJSON_New_Item(); - if (item) - item->type = cJSON_True; + if (item) item->type = cJSON_True; return item; } cJSON *cJSON_CreateFalse(void) { cJSON *item = cJSON_New_Item(); - if (item) - item->type = cJSON_False; + if (item) item->type = cJSON_False; return item; } cJSON *cJSON_CreateBool(int b) { cJSON *item = cJSON_New_Item(); - if (item) - item->type = b ? cJSON_True : cJSON_False; + if (item) item->type = b ? cJSON_True : cJSON_False; return item; } cJSON *cJSON_CreateNumber(double num) { @@ -1179,14 +1069,12 @@ cJSON *cJSON_CreateString(const char *string) { } cJSON *cJSON_CreateArray(void) { cJSON *item = cJSON_New_Item(); - if (item) - item->type = cJSON_Array; + if (item) item->type = cJSON_Array; return item; } cJSON *cJSON_CreateObject(void) { cJSON *item = cJSON_New_Item(); - if (item) - item->type = cJSON_Object; + if (item) item->type = cJSON_Object; return item; } @@ -1248,12 +1136,10 @@ cJSON *cJSON_CreateStringArray(const char **strings, int count) { cJSON *cJSON_Duplicate(cJSON *item, int recurse) { cJSON *newitem, *cptr, *nptr = 0, *newchild; /* Bail on bad ptr */ - if (!item) - return 0; + if (!item) return 0; /* Create new item */ newitem = cJSON_New_Item(); - if (!newitem) - return 0; + if (!newitem) return 0; /* Copy over all vars */ newitem->type = item->type & (~cJSON_IsReference), newitem->valueint = item->valueint, newitem->valuedouble = item->valuedouble; if (item->valuestring) { @@ -1271,8 +1157,7 @@ cJSON *cJSON_Duplicate(cJSON *item, int recurse) { } } /* If non-recursive, then we're done! */ - if (!recurse) - return newitem; + if (!recurse) return newitem; /* Walk the ->next chain for the child. */ cptr = item->child; while (cptr) { @@ -1307,18 +1192,15 @@ void cJSON_Minify(char *json) { else if (*json == '\n') json++; else if (*json == '/' && json[1] == '/') - while (*json && *json != '\n') - json++; /* double-slash comments, to end of line. */ + while (*json && *json != '\n') json++; /* double-slash comments, to end of line. */ else if (*json == '/' && json[1] == '*') { - while (*json && !(*json == '*' && json[1] == '/')) - json++; + while (*json && !(*json == '*' && json[1] == '/')) json++; json += 2; } /* multiline comments. */ else if (*json == '\"') { *into++ = *json++; while (*json && *json != '\"') { - if (*json == '\\') - *into++ = *json++; + if (*json == '\\') *into++ = *json++; *into++ = *json++; } *into++ = *json++; diff --git a/loader/debug_report.c b/loader/debug_report.c index 84b8549..bd46282 100644 --- a/loader/debug_report.c +++ b/loader/debug_report.c @@ -120,8 +120,7 @@ void util_DestroyDebugReportCallback(struct loader_instance *inst, VkDebugReport while (pTrav) { if (pTrav->msgCallback == callback) { pPrev->pNext = pTrav->pNext; - if (inst->DbgFunctionHead == pTrav) - inst->DbgFunctionHead = pTrav->pNext; + if (inst->DbgFunctionHead == pTrav) inst->DbgFunctionHead = pTrav->pNext; #if (DEBUG_DISABLE_APP_ALLOCATORS == 1) { #else diff --git a/loader/dev_ext_trampoline.c b/loader/dev_ext_trampoline.c index 5de697c..c5c549a 100644 --- a/loader/dev_ext_trampoline.c +++ b/loader/dev_ext_trampoline.c @@ -21,7 +21,7 @@ #include "vk_loader_platform.h" #include "loader.h" #if defined(__GNUC__) && !defined(__clang__) -#pragma GCC optimize(3) // force gcc to use tail-calls +#pragma GCC optimize(3) // force gcc to use tail-calls #endif // Clang-format does not understand macros. diff --git a/loader/extensions.c b/loader/extensions.c index 0b5c000..fb05809 100644 --- a/loader/extensions.c +++ b/loader/extensions.c @@ -425,7 +425,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryWin32HandleNV(VkDevice device, VkDevic return disp->GetMemoryWin32HandleNV(device, memory, handleType, pHandle); } -#endif // VK_USE_PLATFORM_WIN32_KHR +#endif // VK_USE_PLATFORM_WIN32_KHR // Definitions for the VK_NVX_device_generated_commands @@ -573,7 +573,7 @@ bool extension_instance_gpa(struct loader_instance *ptr_instance, const char *na return true; } -#endif // VK_USE_PLATFORM_XLIB_XRANDR_EXT +#endif // VK_USE_PLATFORM_XLIB_XRANDR_EXT // Definitions for the VK_EXT_debug_marker extension commands which // need to have a terminator function. Since these are device @@ -631,7 +631,7 @@ bool extension_instance_gpa(struct loader_instance *ptr_instance, const char *na return true; } -#endif // VK_USE_PLATFORM_WIN32_KHR +#endif // VK_USE_PLATFORM_WIN32_KHR // Functions for the VK_NVX_device_generated_commands extension diff --git a/loader/gpa_helper.h b/loader/gpa_helper.h index e3e41ba..93d60df 100644 --- a/loader/gpa_helper.h +++ b/loader/gpa_helper.h @@ -26,289 +26,154 @@ static inline void *trampolineGetProcAddr(struct loader_instance *inst, const char *funcName) { // Don't include or check global functions - if (!strcmp(funcName, "vkGetInstanceProcAddr")) - return (PFN_vkVoidFunction)vkGetInstanceProcAddr; - if (!strcmp(funcName, "vkDestroyInstance")) - return (PFN_vkVoidFunction)vkDestroyInstance; - if (!strcmp(funcName, "vkEnumeratePhysicalDevices")) - return (PFN_vkVoidFunction)vkEnumeratePhysicalDevices; - if (!strcmp(funcName, "vkGetPhysicalDeviceFeatures")) - return (PFN_vkVoidFunction)vkGetPhysicalDeviceFeatures; - if (!strcmp(funcName, "vkGetPhysicalDeviceFormatProperties")) - return (PFN_vkVoidFunction)vkGetPhysicalDeviceFormatProperties; + if (!strcmp(funcName, "vkGetInstanceProcAddr")) return (PFN_vkVoidFunction)vkGetInstanceProcAddr; + if (!strcmp(funcName, "vkDestroyInstance")) return (PFN_vkVoidFunction)vkDestroyInstance; + if (!strcmp(funcName, "vkEnumeratePhysicalDevices")) return (PFN_vkVoidFunction)vkEnumeratePhysicalDevices; + if (!strcmp(funcName, "vkGetPhysicalDeviceFeatures")) return (PFN_vkVoidFunction)vkGetPhysicalDeviceFeatures; + if (!strcmp(funcName, "vkGetPhysicalDeviceFormatProperties")) return (PFN_vkVoidFunction)vkGetPhysicalDeviceFormatProperties; if (!strcmp(funcName, "vkGetPhysicalDeviceImageFormatProperties")) return (PFN_vkVoidFunction)vkGetPhysicalDeviceImageFormatProperties; if (!strcmp(funcName, "vkGetPhysicalDeviceSparseImageFormatProperties")) return (PFN_vkVoidFunction)vkGetPhysicalDeviceSparseImageFormatProperties; - if (!strcmp(funcName, "vkGetPhysicalDeviceProperties")) - return (PFN_vkVoidFunction)vkGetPhysicalDeviceProperties; + if (!strcmp(funcName, "vkGetPhysicalDeviceProperties")) return (PFN_vkVoidFunction)vkGetPhysicalDeviceProperties; if (!strcmp(funcName, "vkGetPhysicalDeviceQueueFamilyProperties")) return (PFN_vkVoidFunction)vkGetPhysicalDeviceQueueFamilyProperties; - if (!strcmp(funcName, "vkGetPhysicalDeviceMemoryProperties")) - return (PFN_vkVoidFunction)vkGetPhysicalDeviceMemoryProperties; - if (!strcmp(funcName, "vkEnumerateDeviceLayerProperties")) - return (PFN_vkVoidFunction)vkEnumerateDeviceLayerProperties; - if (!strcmp(funcName, "vkEnumerateDeviceExtensionProperties")) - return (PFN_vkVoidFunction)vkEnumerateDeviceExtensionProperties; - if (!strcmp(funcName, "vkCreateDevice")) - return (PFN_vkVoidFunction)vkCreateDevice; - if (!strcmp(funcName, "vkGetDeviceProcAddr")) - return (PFN_vkVoidFunction)vkGetDeviceProcAddr; - if (!strcmp(funcName, "vkDestroyDevice")) - return (PFN_vkVoidFunction)vkDestroyDevice; - if (!strcmp(funcName, "vkGetDeviceQueue")) - return (PFN_vkVoidFunction)vkGetDeviceQueue; - if (!strcmp(funcName, "vkQueueSubmit")) - return (PFN_vkVoidFunction)vkQueueSubmit; - if (!strcmp(funcName, "vkQueueWaitIdle")) - return (PFN_vkVoidFunction)vkQueueWaitIdle; - if (!strcmp(funcName, "vkDeviceWaitIdle")) - return (PFN_vkVoidFunction)vkDeviceWaitIdle; - if (!strcmp(funcName, "vkAllocateMemory")) - return (PFN_vkVoidFunction)vkAllocateMemory; - if (!strcmp(funcName, "vkFreeMemory")) - return (PFN_vkVoidFunction)vkFreeMemory; - if (!strcmp(funcName, "vkMapMemory")) - return (PFN_vkVoidFunction)vkMapMemory; - if (!strcmp(funcName, "vkUnmapMemory")) - return (PFN_vkVoidFunction)vkUnmapMemory; - if (!strcmp(funcName, "vkFlushMappedMemoryRanges")) - return (PFN_vkVoidFunction)vkFlushMappedMemoryRanges; - if (!strcmp(funcName, "vkInvalidateMappedMemoryRanges")) - return (PFN_vkVoidFunction)vkInvalidateMappedMemoryRanges; - if (!strcmp(funcName, "vkGetDeviceMemoryCommitment")) - return (PFN_vkVoidFunction)vkGetDeviceMemoryCommitment; - if (!strcmp(funcName, "vkGetImageSparseMemoryRequirements")) - return (PFN_vkVoidFunction)vkGetImageSparseMemoryRequirements; - if (!strcmp(funcName, "vkGetImageMemoryRequirements")) - return (PFN_vkVoidFunction)vkGetImageMemoryRequirements; - if (!strcmp(funcName, "vkGetBufferMemoryRequirements")) - return (PFN_vkVoidFunction)vkGetBufferMemoryRequirements; - if (!strcmp(funcName, "vkBindImageMemory")) - return (PFN_vkVoidFunction)vkBindImageMemory; - if (!strcmp(funcName, "vkBindBufferMemory")) - return (PFN_vkVoidFunction)vkBindBufferMemory; - if (!strcmp(funcName, "vkQueueBindSparse")) - return (PFN_vkVoidFunction)vkQueueBindSparse; - if (!strcmp(funcName, "vkCreateFence")) - return (PFN_vkVoidFunction)vkCreateFence; - if (!strcmp(funcName, "vkDestroyFence")) - return (PFN_vkVoidFunction)vkDestroyFence; - if (!strcmp(funcName, "vkGetFenceStatus")) - return (PFN_vkVoidFunction)vkGetFenceStatus; - if (!strcmp(funcName, "vkResetFences")) - return (PFN_vkVoidFunction)vkResetFences; - if (!strcmp(funcName, "vkWaitForFences")) - return (PFN_vkVoidFunction)vkWaitForFences; - if (!strcmp(funcName, "vkCreateSemaphore")) - return (PFN_vkVoidFunction)vkCreateSemaphore; - if (!strcmp(funcName, "vkDestroySemaphore")) - return (PFN_vkVoidFunction)vkDestroySemaphore; - if (!strcmp(funcName, "vkCreateEvent")) - return (PFN_vkVoidFunction)vkCreateEvent; - if (!strcmp(funcName, "vkDestroyEvent")) - return (PFN_vkVoidFunction)vkDestroyEvent; - if (!strcmp(funcName, "vkGetEventStatus")) - return (PFN_vkVoidFunction)vkGetEventStatus; - if (!strcmp(funcName, "vkSetEvent")) - return (PFN_vkVoidFunction)vkSetEvent; - if (!strcmp(funcName, "vkResetEvent")) - return (PFN_vkVoidFunction)vkResetEvent; - if (!strcmp(funcName, "vkCreateQueryPool")) - return (PFN_vkVoidFunction)vkCreateQueryPool; - if (!strcmp(funcName, "vkDestroyQueryPool")) - return (PFN_vkVoidFunction)vkDestroyQueryPool; - if (!strcmp(funcName, "vkGetQueryPoolResults")) - return (PFN_vkVoidFunction)vkGetQueryPoolResults; - if (!strcmp(funcName, "vkCreateBuffer")) - return (PFN_vkVoidFunction)vkCreateBuffer; - if (!strcmp(funcName, "vkDestroyBuffer")) - return (PFN_vkVoidFunction)vkDestroyBuffer; - if (!strcmp(funcName, "vkCreateBufferView")) - return (PFN_vkVoidFunction)vkCreateBufferView; - if (!strcmp(funcName, "vkDestroyBufferView")) - return (PFN_vkVoidFunction)vkDestroyBufferView; - if (!strcmp(funcName, "vkCreateImage")) - return (PFN_vkVoidFunction)vkCreateImage; - if (!strcmp(funcName, "vkDestroyImage")) - return (PFN_vkVoidFunction)vkDestroyImage; - if (!strcmp(funcName, "vkGetImageSubresourceLayout")) - return (PFN_vkVoidFunction)vkGetImageSubresourceLayout; - if (!strcmp(funcName, "vkCreateImageView")) - return (PFN_vkVoidFunction)vkCreateImageView; - if (!strcmp(funcName, "vkDestroyImageView")) - return (PFN_vkVoidFunction)vkDestroyImageView; - if (!strcmp(funcName, "vkCreateShaderModule")) - return (PFN_vkVoidFunction)vkCreateShaderModule; - if (!strcmp(funcName, "vkDestroyShaderModule")) - return (PFN_vkVoidFunction)vkDestroyShaderModule; - if (!strcmp(funcName, "vkCreatePipelineCache")) - return (PFN_vkVoidFunction)vkCreatePipelineCache; - if (!strcmp(funcName, "vkDestroyPipelineCache")) - return (PFN_vkVoidFunction)vkDestroyPipelineCache; - if (!strcmp(funcName, "vkGetPipelineCacheData")) - return (PFN_vkVoidFunction)vkGetPipelineCacheData; - if (!strcmp(funcName, "vkMergePipelineCaches")) - return (PFN_vkVoidFunction)vkMergePipelineCaches; - if (!strcmp(funcName, "vkCreateGraphicsPipelines")) - return (PFN_vkVoidFunction)vkCreateGraphicsPipelines; - if (!strcmp(funcName, "vkCreateComputePipelines")) - return (PFN_vkVoidFunction)vkCreateComputePipelines; - if (!strcmp(funcName, "vkDestroyPipeline")) - return (PFN_vkVoidFunction)vkDestroyPipeline; - if (!strcmp(funcName, "vkCreatePipelineLayout")) - return (PFN_vkVoidFunction)vkCreatePipelineLayout; - if (!strcmp(funcName, "vkDestroyPipelineLayout")) - return (PFN_vkVoidFunction)vkDestroyPipelineLayout; - if (!strcmp(funcName, "vkCreateSampler")) - return (PFN_vkVoidFunction)vkCreateSampler; - if (!strcmp(funcName, "vkDestroySampler")) - return (PFN_vkVoidFunction)vkDestroySampler; - if (!strcmp(funcName, "vkCreateDescriptorSetLayout")) - return (PFN_vkVoidFunction)vkCreateDescriptorSetLayout; - if (!strcmp(funcName, "vkDestroyDescriptorSetLayout")) - return (PFN_vkVoidFunction)vkDestroyDescriptorSetLayout; - if (!strcmp(funcName, "vkCreateDescriptorPool")) - return (PFN_vkVoidFunction)vkCreateDescriptorPool; - if (!strcmp(funcName, "vkDestroyDescriptorPool")) - return (PFN_vkVoidFunction)vkDestroyDescriptorPool; - if (!strcmp(funcName, "vkResetDescriptorPool")) - return (PFN_vkVoidFunction)vkResetDescriptorPool; - if (!strcmp(funcName, "vkAllocateDescriptorSets")) - return (PFN_vkVoidFunction)vkAllocateDescriptorSets; - if (!strcmp(funcName, "vkFreeDescriptorSets")) - return (PFN_vkVoidFunction)vkFreeDescriptorSets; - if (!strcmp(funcName, "vkUpdateDescriptorSets")) - return (PFN_vkVoidFunction)vkUpdateDescriptorSets; - if (!strcmp(funcName, "vkCreateFramebuffer")) - return (PFN_vkVoidFunction)vkCreateFramebuffer; - if (!strcmp(funcName, "vkDestroyFramebuffer")) - return (PFN_vkVoidFunction)vkDestroyFramebuffer; - if (!strcmp(funcName, "vkCreateRenderPass")) - return (PFN_vkVoidFunction)vkCreateRenderPass; - if (!strcmp(funcName, "vkDestroyRenderPass")) - return (PFN_vkVoidFunction)vkDestroyRenderPass; - if (!strcmp(funcName, "vkGetRenderAreaGranularity")) - return (PFN_vkVoidFunction)vkGetRenderAreaGranularity; - if (!strcmp(funcName, "vkCreateCommandPool")) - return (PFN_vkVoidFunction)vkCreateCommandPool; - if (!strcmp(funcName, "vkDestroyCommandPool")) - return (PFN_vkVoidFunction)vkDestroyCommandPool; - if (!strcmp(funcName, "vkResetCommandPool")) - return (PFN_vkVoidFunction)vkResetCommandPool; - if (!strcmp(funcName, "vkAllocateCommandBuffers")) - return (PFN_vkVoidFunction)vkAllocateCommandBuffers; - if (!strcmp(funcName, "vkFreeCommandBuffers")) - return (PFN_vkVoidFunction)vkFreeCommandBuffers; - if (!strcmp(funcName, "vkBeginCommandBuffer")) - return (PFN_vkVoidFunction)vkBeginCommandBuffer; - if (!strcmp(funcName, "vkEndCommandBuffer")) - return (PFN_vkVoidFunction)vkEndCommandBuffer; - if (!strcmp(funcName, "vkResetCommandBuffer")) - return (PFN_vkVoidFunction)vkResetCommandBuffer; - if (!strcmp(funcName, "vkCmdBindPipeline")) - return (PFN_vkVoidFunction)vkCmdBindPipeline; - if (!strcmp(funcName, "vkCmdBindDescriptorSets")) - return (PFN_vkVoidFunction)vkCmdBindDescriptorSets; - if (!strcmp(funcName, "vkCmdBindVertexBuffers")) - return (PFN_vkVoidFunction)vkCmdBindVertexBuffers; - if (!strcmp(funcName, "vkCmdBindIndexBuffer")) - return (PFN_vkVoidFunction)vkCmdBindIndexBuffer; - if (!strcmp(funcName, "vkCmdSetViewport")) - return (PFN_vkVoidFunction)vkCmdSetViewport; - if (!strcmp(funcName, "vkCmdSetScissor")) - return (PFN_vkVoidFunction)vkCmdSetScissor; - if (!strcmp(funcName, "vkCmdSetLineWidth")) - return (PFN_vkVoidFunction)vkCmdSetLineWidth; - if (!strcmp(funcName, "vkCmdSetDepthBias")) - return (PFN_vkVoidFunction)vkCmdSetDepthBias; - if (!strcmp(funcName, "vkCmdSetBlendConstants")) - return (PFN_vkVoidFunction)vkCmdSetBlendConstants; - if (!strcmp(funcName, "vkCmdSetDepthBounds")) - return (PFN_vkVoidFunction)vkCmdSetDepthBounds; - if (!strcmp(funcName, "vkCmdSetStencilCompareMask")) - return (PFN_vkVoidFunction)vkCmdSetStencilCompareMask; - if (!strcmp(funcName, "vkCmdSetStencilWriteMask")) - return (PFN_vkVoidFunction)vkCmdSetStencilWriteMask; - if (!strcmp(funcName, "vkCmdSetStencilReference")) - return (PFN_vkVoidFunction)vkCmdSetStencilReference; - if (!strcmp(funcName, "vkCmdDraw")) - return (PFN_vkVoidFunction)vkCmdDraw; - if (!strcmp(funcName, "vkCmdDrawIndexed")) - return (PFN_vkVoidFunction)vkCmdDrawIndexed; - if (!strcmp(funcName, "vkCmdDrawIndirect")) - return (PFN_vkVoidFunction)vkCmdDrawIndirect; - if (!strcmp(funcName, "vkCmdDrawIndexedIndirect")) - return (PFN_vkVoidFunction)vkCmdDrawIndexedIndirect; - if (!strcmp(funcName, "vkCmdDispatch")) - return (PFN_vkVoidFunction)vkCmdDispatch; - if (!strcmp(funcName, "vkCmdDispatchIndirect")) - return (PFN_vkVoidFunction)vkCmdDispatchIndirect; - if (!strcmp(funcName, "vkCmdCopyBuffer")) - return (PFN_vkVoidFunction)vkCmdCopyBuffer; - if (!strcmp(funcName, "vkCmdCopyImage")) - return (PFN_vkVoidFunction)vkCmdCopyImage; - if (!strcmp(funcName, "vkCmdBlitImage")) - return (PFN_vkVoidFunction)vkCmdBlitImage; - if (!strcmp(funcName, "vkCmdCopyBufferToImage")) - return (PFN_vkVoidFunction)vkCmdCopyBufferToImage; - if (!strcmp(funcName, "vkCmdCopyImageToBuffer")) - return (PFN_vkVoidFunction)vkCmdCopyImageToBuffer; - if (!strcmp(funcName, "vkCmdUpdateBuffer")) - return (PFN_vkVoidFunction)vkCmdUpdateBuffer; - if (!strcmp(funcName, "vkCmdFillBuffer")) - return (PFN_vkVoidFunction)vkCmdFillBuffer; - if (!strcmp(funcName, "vkCmdClearColorImage")) - return (PFN_vkVoidFunction)vkCmdClearColorImage; - if (!strcmp(funcName, "vkCmdClearDepthStencilImage")) - return (PFN_vkVoidFunction)vkCmdClearDepthStencilImage; - if (!strcmp(funcName, "vkCmdClearAttachments")) - return (PFN_vkVoidFunction)vkCmdClearAttachments; - if (!strcmp(funcName, "vkCmdResolveImage")) - return (PFN_vkVoidFunction)vkCmdResolveImage; - if (!strcmp(funcName, "vkCmdSetEvent")) - return (PFN_vkVoidFunction)vkCmdSetEvent; - if (!strcmp(funcName, "vkCmdResetEvent")) - return (PFN_vkVoidFunction)vkCmdResetEvent; - if (!strcmp(funcName, "vkCmdWaitEvents")) - return (PFN_vkVoidFunction)vkCmdWaitEvents; - if (!strcmp(funcName, "vkCmdPipelineBarrier")) - return (PFN_vkVoidFunction)vkCmdPipelineBarrier; - if (!strcmp(funcName, "vkCmdBeginQuery")) - return (PFN_vkVoidFunction)vkCmdBeginQuery; - if (!strcmp(funcName, "vkCmdEndQuery")) - return (PFN_vkVoidFunction)vkCmdEndQuery; - if (!strcmp(funcName, "vkCmdResetQueryPool")) - return (PFN_vkVoidFunction)vkCmdResetQueryPool; - if (!strcmp(funcName, "vkCmdWriteTimestamp")) - return (PFN_vkVoidFunction)vkCmdWriteTimestamp; - if (!strcmp(funcName, "vkCmdCopyQueryPoolResults")) - return (PFN_vkVoidFunction)vkCmdCopyQueryPoolResults; - if (!strcmp(funcName, "vkCmdPushConstants")) - return (PFN_vkVoidFunction)vkCmdPushConstants; - if (!strcmp(funcName, "vkCmdBeginRenderPass")) - return (PFN_vkVoidFunction)vkCmdBeginRenderPass; - if (!strcmp(funcName, "vkCmdNextSubpass")) - return (PFN_vkVoidFunction)vkCmdNextSubpass; - if (!strcmp(funcName, "vkCmdEndRenderPass")) - return (PFN_vkVoidFunction)vkCmdEndRenderPass; - if (!strcmp(funcName, "vkCmdExecuteCommands")) - return (PFN_vkVoidFunction)vkCmdExecuteCommands; + if (!strcmp(funcName, "vkGetPhysicalDeviceMemoryProperties")) return (PFN_vkVoidFunction)vkGetPhysicalDeviceMemoryProperties; + if (!strcmp(funcName, "vkEnumerateDeviceLayerProperties")) return (PFN_vkVoidFunction)vkEnumerateDeviceLayerProperties; + if (!strcmp(funcName, "vkEnumerateDeviceExtensionProperties")) return (PFN_vkVoidFunction)vkEnumerateDeviceExtensionProperties; + if (!strcmp(funcName, "vkCreateDevice")) return (PFN_vkVoidFunction)vkCreateDevice; + if (!strcmp(funcName, "vkGetDeviceProcAddr")) return (PFN_vkVoidFunction)vkGetDeviceProcAddr; + if (!strcmp(funcName, "vkDestroyDevice")) return (PFN_vkVoidFunction)vkDestroyDevice; + if (!strcmp(funcName, "vkGetDeviceQueue")) return (PFN_vkVoidFunction)vkGetDeviceQueue; + if (!strcmp(funcName, "vkQueueSubmit")) return (PFN_vkVoidFunction)vkQueueSubmit; + if (!strcmp(funcName, "vkQueueWaitIdle")) return (PFN_vkVoidFunction)vkQueueWaitIdle; + if (!strcmp(funcName, "vkDeviceWaitIdle")) return (PFN_vkVoidFunction)vkDeviceWaitIdle; + if (!strcmp(funcName, "vkAllocateMemory")) return (PFN_vkVoidFunction)vkAllocateMemory; + if (!strcmp(funcName, "vkFreeMemory")) return (PFN_vkVoidFunction)vkFreeMemory; + if (!strcmp(funcName, "vkMapMemory")) return (PFN_vkVoidFunction)vkMapMemory; + if (!strcmp(funcName, "vkUnmapMemory")) return (PFN_vkVoidFunction)vkUnmapMemory; + if (!strcmp(funcName, "vkFlushMappedMemoryRanges")) return (PFN_vkVoidFunction)vkFlushMappedMemoryRanges; + if (!strcmp(funcName, "vkInvalidateMappedMemoryRanges")) return (PFN_vkVoidFunction)vkInvalidateMappedMemoryRanges; + if (!strcmp(funcName, "vkGetDeviceMemoryCommitment")) return (PFN_vkVoidFunction)vkGetDeviceMemoryCommitment; + if (!strcmp(funcName, "vkGetImageSparseMemoryRequirements")) return (PFN_vkVoidFunction)vkGetImageSparseMemoryRequirements; + if (!strcmp(funcName, "vkGetImageMemoryRequirements")) return (PFN_vkVoidFunction)vkGetImageMemoryRequirements; + if (!strcmp(funcName, "vkGetBufferMemoryRequirements")) return (PFN_vkVoidFunction)vkGetBufferMemoryRequirements; + if (!strcmp(funcName, "vkBindImageMemory")) return (PFN_vkVoidFunction)vkBindImageMemory; + if (!strcmp(funcName, "vkBindBufferMemory")) return (PFN_vkVoidFunction)vkBindBufferMemory; + if (!strcmp(funcName, "vkQueueBindSparse")) return (PFN_vkVoidFunction)vkQueueBindSparse; + if (!strcmp(funcName, "vkCreateFence")) return (PFN_vkVoidFunction)vkCreateFence; + if (!strcmp(funcName, "vkDestroyFence")) return (PFN_vkVoidFunction)vkDestroyFence; + if (!strcmp(funcName, "vkGetFenceStatus")) return (PFN_vkVoidFunction)vkGetFenceStatus; + if (!strcmp(funcName, "vkResetFences")) return (PFN_vkVoidFunction)vkResetFences; + if (!strcmp(funcName, "vkWaitForFences")) return (PFN_vkVoidFunction)vkWaitForFences; + if (!strcmp(funcName, "vkCreateSemaphore")) return (PFN_vkVoidFunction)vkCreateSemaphore; + if (!strcmp(funcName, "vkDestroySemaphore")) return (PFN_vkVoidFunction)vkDestroySemaphore; + if (!strcmp(funcName, "vkCreateEvent")) return (PFN_vkVoidFunction)vkCreateEvent; + if (!strcmp(funcName, "vkDestroyEvent")) return (PFN_vkVoidFunction)vkDestroyEvent; + if (!strcmp(funcName, "vkGetEventStatus")) return (PFN_vkVoidFunction)vkGetEventStatus; + if (!strcmp(funcName, "vkSetEvent")) return (PFN_vkVoidFunction)vkSetEvent; + if (!strcmp(funcName, "vkResetEvent")) return (PFN_vkVoidFunction)vkResetEvent; + if (!strcmp(funcName, "vkCreateQueryPool")) return (PFN_vkVoidFunction)vkCreateQueryPool; + if (!strcmp(funcName, "vkDestroyQueryPool")) return (PFN_vkVoidFunction)vkDestroyQueryPool; + if (!strcmp(funcName, "vkGetQueryPoolResults")) return (PFN_vkVoidFunction)vkGetQueryPoolResults; + if (!strcmp(funcName, "vkCreateBuffer")) return (PFN_vkVoidFunction)vkCreateBuffer; + if (!strcmp(funcName, "vkDestroyBuffer")) return (PFN_vkVoidFunction)vkDestroyBuffer; + if (!strcmp(funcName, "vkCreateBufferView")) return (PFN_vkVoidFunction)vkCreateBufferView; + if (!strcmp(funcName, "vkDestroyBufferView")) return (PFN_vkVoidFunction)vkDestroyBufferView; + if (!strcmp(funcName, "vkCreateImage")) return (PFN_vkVoidFunction)vkCreateImage; + if (!strcmp(funcName, "vkDestroyImage")) return (PFN_vkVoidFunction)vkDestroyImage; + if (!strcmp(funcName, "vkGetImageSubresourceLayout")) return (PFN_vkVoidFunction)vkGetImageSubresourceLayout; + if (!strcmp(funcName, "vkCreateImageView")) return (PFN_vkVoidFunction)vkCreateImageView; + if (!strcmp(funcName, "vkDestroyImageView")) return (PFN_vkVoidFunction)vkDestroyImageView; + if (!strcmp(funcName, "vkCreateShaderModule")) return (PFN_vkVoidFunction)vkCreateShaderModule; + if (!strcmp(funcName, "vkDestroyShaderModule")) return (PFN_vkVoidFunction)vkDestroyShaderModule; + if (!strcmp(funcName, "vkCreatePipelineCache")) return (PFN_vkVoidFunction)vkCreatePipelineCache; + if (!strcmp(funcName, "vkDestroyPipelineCache")) return (PFN_vkVoidFunction)vkDestroyPipelineCache; + if (!strcmp(funcName, "vkGetPipelineCacheData")) return (PFN_vkVoidFunction)vkGetPipelineCacheData; + if (!strcmp(funcName, "vkMergePipelineCaches")) return (PFN_vkVoidFunction)vkMergePipelineCaches; + if (!strcmp(funcName, "vkCreateGraphicsPipelines")) return (PFN_vkVoidFunction)vkCreateGraphicsPipelines; + if (!strcmp(funcName, "vkCreateComputePipelines")) return (PFN_vkVoidFunction)vkCreateComputePipelines; + if (!strcmp(funcName, "vkDestroyPipeline")) return (PFN_vkVoidFunction)vkDestroyPipeline; + if (!strcmp(funcName, "vkCreatePipelineLayout")) return (PFN_vkVoidFunction)vkCreatePipelineLayout; + if (!strcmp(funcName, "vkDestroyPipelineLayout")) return (PFN_vkVoidFunction)vkDestroyPipelineLayout; + if (!strcmp(funcName, "vkCreateSampler")) return (PFN_vkVoidFunction)vkCreateSampler; + if (!strcmp(funcName, "vkDestroySampler")) return (PFN_vkVoidFunction)vkDestroySampler; + if (!strcmp(funcName, "vkCreateDescriptorSetLayout")) return (PFN_vkVoidFunction)vkCreateDescriptorSetLayout; + if (!strcmp(funcName, "vkDestroyDescriptorSetLayout")) return (PFN_vkVoidFunction)vkDestroyDescriptorSetLayout; + if (!strcmp(funcName, "vkCreateDescriptorPool")) return (PFN_vkVoidFunction)vkCreateDescriptorPool; + if (!strcmp(funcName, "vkDestroyDescriptorPool")) return (PFN_vkVoidFunction)vkDestroyDescriptorPool; + if (!strcmp(funcName, "vkResetDescriptorPool")) return (PFN_vkVoidFunction)vkResetDescriptorPool; + if (!strcmp(funcName, "vkAllocateDescriptorSets")) return (PFN_vkVoidFunction)vkAllocateDescriptorSets; + if (!strcmp(funcName, "vkFreeDescriptorSets")) return (PFN_vkVoidFunction)vkFreeDescriptorSets; + if (!strcmp(funcName, "vkUpdateDescriptorSets")) return (PFN_vkVoidFunction)vkUpdateDescriptorSets; + if (!strcmp(funcName, "vkCreateFramebuffer")) return (PFN_vkVoidFunction)vkCreateFramebuffer; + if (!strcmp(funcName, "vkDestroyFramebuffer")) return (PFN_vkVoidFunction)vkDestroyFramebuffer; + if (!strcmp(funcName, "vkCreateRenderPass")) return (PFN_vkVoidFunction)vkCreateRenderPass; + if (!strcmp(funcName, "vkDestroyRenderPass")) return (PFN_vkVoidFunction)vkDestroyRenderPass; + if (!strcmp(funcName, "vkGetRenderAreaGranularity")) return (PFN_vkVoidFunction)vkGetRenderAreaGranularity; + if (!strcmp(funcName, "vkCreateCommandPool")) return (PFN_vkVoidFunction)vkCreateCommandPool; + if (!strcmp(funcName, "vkDestroyCommandPool")) return (PFN_vkVoidFunction)vkDestroyCommandPool; + if (!strcmp(funcName, "vkResetCommandPool")) return (PFN_vkVoidFunction)vkResetCommandPool; + if (!strcmp(funcName, "vkAllocateCommandBuffers")) return (PFN_vkVoidFunction)vkAllocateCommandBuffers; + if (!strcmp(funcName, "vkFreeCommandBuffers")) return (PFN_vkVoidFunction)vkFreeCommandBuffers; + if (!strcmp(funcName, "vkBeginCommandBuffer")) return (PFN_vkVoidFunction)vkBeginCommandBuffer; + if (!strcmp(funcName, "vkEndCommandBuffer")) return (PFN_vkVoidFunction)vkEndCommandBuffer; + if (!strcmp(funcName, "vkResetCommandBuffer")) return (PFN_vkVoidFunction)vkResetCommandBuffer; + if (!strcmp(funcName, "vkCmdBindPipeline")) return (PFN_vkVoidFunction)vkCmdBindPipeline; + if (!strcmp(funcName, "vkCmdBindDescriptorSets")) return (PFN_vkVoidFunction)vkCmdBindDescriptorSets; + if (!strcmp(funcName, "vkCmdBindVertexBuffers")) return (PFN_vkVoidFunction)vkCmdBindVertexBuffers; + if (!strcmp(funcName, "vkCmdBindIndexBuffer")) return (PFN_vkVoidFunction)vkCmdBindIndexBuffer; + if (!strcmp(funcName, "vkCmdSetViewport")) return (PFN_vkVoidFunction)vkCmdSetViewport; + if (!strcmp(funcName, "vkCmdSetScissor")) return (PFN_vkVoidFunction)vkCmdSetScissor; + if (!strcmp(funcName, "vkCmdSetLineWidth")) return (PFN_vkVoidFunction)vkCmdSetLineWidth; + if (!strcmp(funcName, "vkCmdSetDepthBias")) return (PFN_vkVoidFunction)vkCmdSetDepthBias; + if (!strcmp(funcName, "vkCmdSetBlendConstants")) return (PFN_vkVoidFunction)vkCmdSetBlendConstants; + if (!strcmp(funcName, "vkCmdSetDepthBounds")) return (PFN_vkVoidFunction)vkCmdSetDepthBounds; + if (!strcmp(funcName, "vkCmdSetStencilCompareMask")) return (PFN_vkVoidFunction)vkCmdSetStencilCompareMask; + if (!strcmp(funcName, "vkCmdSetStencilWriteMask")) return (PFN_vkVoidFunction)vkCmdSetStencilWriteMask; + if (!strcmp(funcName, "vkCmdSetStencilReference")) return (PFN_vkVoidFunction)vkCmdSetStencilReference; + if (!strcmp(funcName, "vkCmdDraw")) return (PFN_vkVoidFunction)vkCmdDraw; + if (!strcmp(funcName, "vkCmdDrawIndexed")) return (PFN_vkVoidFunction)vkCmdDrawIndexed; + if (!strcmp(funcName, "vkCmdDrawIndirect")) return (PFN_vkVoidFunction)vkCmdDrawIndirect; + if (!strcmp(funcName, "vkCmdDrawIndexedIndirect")) return (PFN_vkVoidFunction)vkCmdDrawIndexedIndirect; + if (!strcmp(funcName, "vkCmdDispatch")) return (PFN_vkVoidFunction)vkCmdDispatch; + if (!strcmp(funcName, "vkCmdDispatchIndirect")) return (PFN_vkVoidFunction)vkCmdDispatchIndirect; + if (!strcmp(funcName, "vkCmdCopyBuffer")) return (PFN_vkVoidFunction)vkCmdCopyBuffer; + if (!strcmp(funcName, "vkCmdCopyImage")) return (PFN_vkVoidFunction)vkCmdCopyImage; + if (!strcmp(funcName, "vkCmdBlitImage")) return (PFN_vkVoidFunction)vkCmdBlitImage; + if (!strcmp(funcName, "vkCmdCopyBufferToImage")) return (PFN_vkVoidFunction)vkCmdCopyBufferToImage; + if (!strcmp(funcName, "vkCmdCopyImageToBuffer")) return (PFN_vkVoidFunction)vkCmdCopyImageToBuffer; + if (!strcmp(funcName, "vkCmdUpdateBuffer")) return (PFN_vkVoidFunction)vkCmdUpdateBuffer; + if (!strcmp(funcName, "vkCmdFillBuffer")) return (PFN_vkVoidFunction)vkCmdFillBuffer; + if (!strcmp(funcName, "vkCmdClearColorImage")) return (PFN_vkVoidFunction)vkCmdClearColorImage; + if (!strcmp(funcName, "vkCmdClearDepthStencilImage")) return (PFN_vkVoidFunction)vkCmdClearDepthStencilImage; + if (!strcmp(funcName, "vkCmdClearAttachments")) return (PFN_vkVoidFunction)vkCmdClearAttachments; + if (!strcmp(funcName, "vkCmdResolveImage")) return (PFN_vkVoidFunction)vkCmdResolveImage; + if (!strcmp(funcName, "vkCmdSetEvent")) return (PFN_vkVoidFunction)vkCmdSetEvent; + if (!strcmp(funcName, "vkCmdResetEvent")) return (PFN_vkVoidFunction)vkCmdResetEvent; + if (!strcmp(funcName, "vkCmdWaitEvents")) return (PFN_vkVoidFunction)vkCmdWaitEvents; + if (!strcmp(funcName, "vkCmdPipelineBarrier")) return (PFN_vkVoidFunction)vkCmdPipelineBarrier; + if (!strcmp(funcName, "vkCmdBeginQuery")) return (PFN_vkVoidFunction)vkCmdBeginQuery; + if (!strcmp(funcName, "vkCmdEndQuery")) return (PFN_vkVoidFunction)vkCmdEndQuery; + if (!strcmp(funcName, "vkCmdResetQueryPool")) return (PFN_vkVoidFunction)vkCmdResetQueryPool; + if (!strcmp(funcName, "vkCmdWriteTimestamp")) return (PFN_vkVoidFunction)vkCmdWriteTimestamp; + if (!strcmp(funcName, "vkCmdCopyQueryPoolResults")) return (PFN_vkVoidFunction)vkCmdCopyQueryPoolResults; + if (!strcmp(funcName, "vkCmdPushConstants")) return (PFN_vkVoidFunction)vkCmdPushConstants; + if (!strcmp(funcName, "vkCmdBeginRenderPass")) return (PFN_vkVoidFunction)vkCmdBeginRenderPass; + if (!strcmp(funcName, "vkCmdNextSubpass")) return (PFN_vkVoidFunction)vkCmdNextSubpass; + if (!strcmp(funcName, "vkCmdEndRenderPass")) return (PFN_vkVoidFunction)vkCmdEndRenderPass; + if (!strcmp(funcName, "vkCmdExecuteCommands")) return (PFN_vkVoidFunction)vkCmdExecuteCommands; // Instance extensions void *addr; - if (debug_report_instance_gpa(inst, funcName, &addr)) - return addr; + if (debug_report_instance_gpa(inst, funcName, &addr)) return addr; - if (wsi_swapchain_instance_gpa(inst, funcName, &addr)) - return addr; + if (wsi_swapchain_instance_gpa(inst, funcName, &addr)) return addr; - if (extension_instance_gpa(inst, funcName, &addr)) - return addr; + if (extension_instance_gpa(inst, funcName, &addr)) return addr; // Unknown physical device extensions - if (loader_phys_dev_ext_gpa(inst, funcName, true, &addr, NULL)) - return addr; + if (loader_phys_dev_ext_gpa(inst, funcName, true, &addr, NULL)) return addr; // Unknown device extensions addr = loader_dev_ext_gpa(inst, funcName); @@ -316,34 +181,25 @@ static inline void *trampolineGetProcAddr(struct loader_instance *inst, const ch } static inline void *globalGetProcAddr(const char *name) { - if (!name || name[0] != 'v' || name[1] != 'k') - return NULL; + if (!name || name[0] != 'v' || name[1] != 'k') return NULL; name += 2; - if (!strcmp(name, "CreateInstance")) - return (void *)vkCreateInstance; - if (!strcmp(name, "EnumerateInstanceExtensionProperties")) - return (void *)vkEnumerateInstanceExtensionProperties; - if (!strcmp(name, "EnumerateInstanceLayerProperties")) - return (void *)vkEnumerateInstanceLayerProperties; + if (!strcmp(name, "CreateInstance")) return (void *)vkCreateInstance; + if (!strcmp(name, "EnumerateInstanceExtensionProperties")) return (void *)vkEnumerateInstanceExtensionProperties; + if (!strcmp(name, "EnumerateInstanceLayerProperties")) return (void *)vkEnumerateInstanceLayerProperties; return NULL; } static inline void *loader_non_passthrough_gdpa(const char *name) { - if (!name || name[0] != 'v' || name[1] != 'k') - return NULL; + if (!name || name[0] != 'v' || name[1] != 'k') return NULL; name += 2; - if (!strcmp(name, "GetDeviceProcAddr")) - return (void *)vkGetDeviceProcAddr; - if (!strcmp(name, "DestroyDevice")) - return (void *)vkDestroyDevice; - if (!strcmp(name, "GetDeviceQueue")) - return (void *)vkGetDeviceQueue; - if (!strcmp(name, "AllocateCommandBuffers")) - return (void *)vkAllocateCommandBuffers; + if (!strcmp(name, "GetDeviceProcAddr")) return (void *)vkGetDeviceProcAddr; + if (!strcmp(name, "DestroyDevice")) return (void *)vkDestroyDevice; + if (!strcmp(name, "GetDeviceQueue")) return (void *)vkGetDeviceQueue; + if (!strcmp(name, "AllocateCommandBuffers")) return (void *)vkAllocateCommandBuffers; return NULL; } diff --git a/loader/loader.c b/loader/loader.c index b002d43..9c43525 100644 --- a/loader/loader.c +++ b/loader/loader.c @@ -34,9 +34,9 @@ #include #if defined(_WIN32) #include "dirent_on_windows.h" -#else // _WIN32 +#else // _WIN32 #include -#endif // _WIN32 +#endif // _WIN32 #include "vk_loader_platform.h" #include "loader.h" #include "gpa_helper.h" @@ -346,8 +346,7 @@ static inline char *loader_getenv(const char *name, const struct loader_instance // valSize DOES include the null terminator, so for any set variable // will always be at least 1. If it's 0, the variable wasn't set. - if (valSize == 0) - return NULL; + if (valSize == 0) return NULL; // Allocate the space necessary for the registry entry if (NULL != inst && NULL != inst->alloc_callbacks.pfnAllocation) { @@ -465,11 +464,11 @@ void loader_log(const struct loader_instance *inst, VkFlags msg_type, int32_t ms } VKAPI_ATTR VkResult VKAPI_CALL vkSetInstanceDispatch(VkInstance instance, void *object) { - struct loader_instance *inst = loader_get_instance(instance); if (!inst) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "vkSetInstanceDispatch: Can not retrieve Instance " - "dispatch table."); + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "vkSetInstanceDispatch: Can not retrieve Instance " + "dispatch table."); return VK_ERROR_INITIALIZATION_FAILED; } loader_set_dispatch(object, inst->disp); @@ -539,8 +538,9 @@ VkResult loaderGetRegistryFiles(const struct loader_instance *inst, char *locati if (NULL == *reg_data) { *reg_data = loader_instance_heap_alloc(inst, total_size, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); if (NULL == *reg_data) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loaderGetRegistryFiles: Failed to allocate " - "space for registry data for key %s", + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loaderGetRegistryFiles: Failed to allocate " + "space for registry data for key %s", name); result = VK_ERROR_OUT_OF_HOST_MEMORY; goto out; @@ -550,8 +550,9 @@ VkResult loaderGetRegistryFiles(const struct loader_instance *inst, char *locati *reg_data = loader_instance_heap_realloc(inst, *reg_data, total_size, total_size * 2, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); if (NULL == *reg_data) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loaderGetRegistryFiles: Failed to reallocate " - "space for registry value of size %d for key %s", + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loaderGetRegistryFiles: Failed to reallocate " + "space for registry value of size %d for key %s", total_size * 2, name); result = VK_ERROR_OUT_OF_HOST_MEMORY; goto out; @@ -579,7 +580,7 @@ out: return result; } -#endif // WIN32 +#endif // WIN32 /** * Combine path elements, separating each element with the platform-specific @@ -667,8 +668,7 @@ bool compare_vk_extension_properties(const VkExtensionProperties *op1, const VkE bool has_vk_extension_property_array(const VkExtensionProperties *vk_ext_prop, const uint32_t count, const VkExtensionProperties *ext_array) { for (uint32_t i = 0; i < count; i++) { - if (compare_vk_extension_properties(vk_ext_prop, &ext_array[i])) - return true; + if (compare_vk_extension_properties(vk_ext_prop, &ext_array[i])) return true; } return false; } @@ -679,8 +679,7 @@ bool has_vk_extension_property_array(const VkExtensionProperties *vk_ext_prop, c */ bool has_vk_extension_property(const VkExtensionProperties *vk_ext_prop, const struct loader_extension_list *ext_list) { for (uint32_t i = 0; i < ext_list->count; i++) { - if (compare_vk_extension_properties(&ext_list->list[i], vk_ext_prop)) - return true; + if (compare_vk_extension_properties(&ext_list->list[i], vk_ext_prop)) return true; } return false; } @@ -690,8 +689,7 @@ bool has_vk_extension_property(const VkExtensionProperties *vk_ext_prop, const s */ bool has_vk_dev_ext_property(const VkExtensionProperties *ext_prop, const struct loader_device_extension_list *ext_list) { for (uint32_t i = 0; i < ext_list->count; i++) { - if (compare_vk_extension_properties(&ext_list->list[i].props, ext_prop)) - return true; + if (compare_vk_extension_properties(&ext_list->list[i].props, ext_prop)) return true; } return false; } @@ -702,8 +700,7 @@ bool has_vk_dev_ext_property(const VkExtensionProperties *ext_prop, const struct static struct loader_layer_properties *loader_get_layer_property(const char *name, const struct loader_layer_list *layer_list) { for (uint32_t i = 0; i < layer_list->count; i++) { const VkLayerProperties *item = &layer_list->list[i].info; - if (strcmp(name, item->layerName) == 0) - return &layer_list->list[i]; + if (strcmp(name, item->layerName) == 0) return &layer_list->list[i]; } return NULL; } @@ -717,8 +714,9 @@ static struct loader_layer_properties *loader_get_next_layer_property(const stru layer_list->list = loader_instance_heap_alloc(inst, sizeof(struct loader_layer_properties) * 64, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); if (layer_list->list == NULL) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_get_next_layer_property: Out of memory can " - "not add any layer properties to list"); + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_get_next_layer_property: Out of memory can " + "not add any layer properties to list"); return NULL; } memset(layer_list->list, 0, sizeof(struct loader_layer_properties) * 64); @@ -730,8 +728,9 @@ static struct loader_layer_properties *loader_get_next_layer_property(const stru layer_list->list = loader_instance_heap_realloc(inst, layer_list->list, layer_list->capacity, layer_list->capacity * 2, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); if (layer_list->list == NULL) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_get_next_layer_property: realloc failed for " - "layer list"); + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_get_next_layer_property: realloc failed for " + "layer list"); return NULL; } layer_list->capacity *= 2; @@ -747,8 +746,7 @@ static struct loader_layer_properties *loader_get_next_layer_property(const stru void loader_delete_layer_properties(const struct loader_instance *inst, struct loader_layer_list *layer_list) { uint32_t i, j; struct loader_device_extension_list *dev_ext_list; - if (!layer_list) - return; + if (!layer_list) return; for (i = 0; i < layer_list->count; i++) { loader_destroy_generic_list(inst, (struct loader_generic_list *)&layer_list->list[i].instance_extension_list); @@ -783,8 +781,9 @@ static VkResult loader_add_instance_extensions(const struct loader_instance *ins res = fp_get_props(NULL, &count, NULL); if (res != VK_SUCCESS) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_add_instance_extensions: Error getting Instance " - "extension count from %s", + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_add_instance_extensions: Error getting Instance " + "extension count from %s", lib_name); goto out; } @@ -802,8 +801,9 @@ static VkResult loader_add_instance_extensions(const struct loader_instance *ins res = fp_get_props(NULL, &count, ext_props); if (res != VK_SUCCESS) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_add_instance_extensions: Error getting Instance " - "extensions from %s", + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_add_instance_extensions: Error getting Instance " + "extensions from %s", lib_name); goto out; } @@ -820,8 +820,9 @@ static VkResult loader_add_instance_extensions(const struct loader_instance *ins res = loader_add_to_ext_list(inst, ext_list, 1, &ext_props[i]); if (res != VK_SUCCESS) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_add_instance_extensions: Failed to add %s " - "to Instance extension list", + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_add_instance_extensions: Failed to add %s " + "to Instance extension list", lib_name); goto out; } @@ -855,8 +856,7 @@ static VkResult loader_init_device_extensions(const struct loader_instance *inst loader_log(inst, VK_DEBUG_REPORT_DEBUG_BIT_EXT, 0, "Device Extension: %s (%s) version %s", ext_props[i].extensionName, phys_dev_term->this_icd_term->scanned_icd->lib_name, spec_version); res = loader_add_to_ext_list(inst, ext_list, 1, &ext_props[i]); - if (res != VK_SUCCESS) - return res; + if (res != VK_SUCCESS) return res; } return VK_SUCCESS; @@ -874,8 +874,9 @@ VkResult loader_add_device_extensions(const struct loader_instance *inst, if (res == VK_SUCCESS && count > 0) { ext_props = loader_stack_alloc(count * sizeof(VkExtensionProperties)); if (!ext_props) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_add_device_extensions: Failed to allocate space" - " for device extension properties."); + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_add_device_extensions: Failed to allocate space" + " for device extension properties."); return VK_ERROR_OUT_OF_HOST_MEMORY; } res = fpEnumerateDeviceExtensionProperties(physical_device, NULL, &count, ext_props); @@ -895,8 +896,9 @@ VkResult loader_add_device_extensions(const struct loader_instance *inst, } } } else { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_add_device_extensions: Error getting physical " - "device extension info count from library %s", + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_add_device_extensions: Error getting physical " + "device extension info count from library %s", lib_name); return res; } @@ -910,8 +912,9 @@ VkResult loader_init_generic_list(const struct loader_instance *inst, struct loa list_info->capacity = 0; list_info->list = loader_instance_heap_alloc(inst, capacity, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); if (list_info->list == NULL) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_init_generic_list: Failed to allocate space " - "for generic list"); + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_init_generic_list: Failed to allocate space " + "for generic list"); return VK_ERROR_OUT_OF_HOST_MEMORY; } memset(list_info->list, 0, capacity); @@ -954,13 +957,13 @@ VkResult loader_add_to_ext_list(const struct loader_instance *inst, struct loade // add to list at end // check for enough capacity if (ext_list->count * sizeof(VkExtensionProperties) >= ext_list->capacity) { - ext_list->list = loader_instance_heap_realloc(inst, ext_list->list, ext_list->capacity, ext_list->capacity * 2, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); if (ext_list->list == NULL) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_add_to_ext_list: Failed to reallocate " - "space for extension list"); + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_add_to_ext_list: Failed to reallocate " + "space for extension list"); return VK_ERROR_OUT_OF_HOST_MEMORY; } @@ -999,13 +1002,13 @@ VkResult loader_add_to_dev_ext_list(const struct loader_instance *inst, struct l // add to list at end // check for enough capacity if (idx * sizeof(struct loader_dev_ext_props) >= ext_list->capacity) { - ext_list->list = loader_instance_heap_realloc(inst, ext_list->list, ext_list->capacity, ext_list->capacity * 2, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); if (ext_list->list == NULL) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_add_to_dev_ext_list: Failed to reallocate " - "space for device extension list"); + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_add_to_dev_ext_list: Failed to reallocate " + "space for device extension list"); return VK_ERROR_OUT_OF_HOST_MEMORY; } @@ -1018,8 +1021,9 @@ VkResult loader_add_to_dev_ext_list(const struct loader_instance *inst, struct l ext_list->list[idx].entrypoints = loader_instance_heap_alloc(inst, sizeof(char *) * entry_count, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); if (ext_list->list[idx].entrypoints == NULL) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_add_to_dev_ext_list: Failed to allocate space " - "for device extension entrypoint list in list %d", + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_add_to_dev_ext_list: Failed to allocate space " + "for device extension entrypoint list in list %d", idx); ext_list->list[idx].entrypoint_count = 0; return VK_ERROR_OUT_OF_HOST_MEMORY; @@ -1034,8 +1038,9 @@ VkResult loader_add_to_dev_ext_list(const struct loader_instance *inst, struct l loader_instance_heap_free(inst, ext_list->list[idx].entrypoints); ext_list->list[idx].entrypoint_count = 0; ext_list->list[idx].entrypoints = NULL; - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_add_to_dev_ext_list: Failed to allocate space " - "for device extension entrypoint %d name", + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_add_to_dev_ext_list: Failed to allocate space " + "for device extension entrypoint %d name", i); return VK_ERROR_OUT_OF_HOST_MEMORY; } @@ -1061,8 +1066,9 @@ static VkResult loader_add_layer_names_to_list(const struct loader_instance *ins const char *search_target = names[i]; layer_prop = loader_get_layer_property(search_target, search_list); if (!layer_prop) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_add_layer_names_to_list: Unable to find layer" - " %s", + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_add_layer_names_to_list: Unable to find layer" + " %s", search_target); err = VK_ERROR_LAYER_NOT_PRESENT; continue; @@ -1105,8 +1111,7 @@ void loader_destroy_layer_list(const struct loader_instance *inst, struct loader */ bool has_vk_layer_property(const VkLayerProperties *vk_layer_prop, const struct loader_layer_list *list) { for (uint32_t i = 0; i < list->count; i++) { - if (strcmp(vk_layer_prop->layerName, list->list[i].info.layerName) == 0) - return true; + if (strcmp(vk_layer_prop->layerName, list->list[i].info.layerName) == 0) return true; } return false; } @@ -1117,8 +1122,7 @@ bool has_vk_layer_property(const VkLayerProperties *vk_layer_prop, const struct */ bool has_layer_name(const char *name, const struct loader_layer_list *list) { for (uint32_t i = 0; i < list->count; i++) { - if (strcmp(name, list->list[i].info.layerName) == 0) - return true; + if (strcmp(name, list->list[i].info.layerName) == 0) return true; } return false; } @@ -1136,8 +1140,7 @@ VkResult loader_add_to_layer_list(const struct loader_instance *inst, struct loa loader_init_layer_list(inst, list); } - if (list->list == NULL) - return VK_SUCCESS; + if (list->list == NULL) return VK_SUCCESS; for (i = 0; i < prop_list_count; i++) { layer = (struct loader_layer_properties *)&props[i]; @@ -1150,12 +1153,12 @@ VkResult loader_add_to_layer_list(const struct loader_instance *inst, struct loa // add to list at end // check for enough capacity if (list->count * sizeof(struct loader_layer_properties) >= list->capacity) { - list->list = loader_instance_heap_realloc(inst, list->list, list->capacity, list->capacity * 2, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); if (NULL == list->list) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_add_to_layer_list: Realloc failed for " - "when attempting to add new layer"); + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_add_to_layer_list: Realloc failed for " + "when attempting to add new layer"); return VK_ERROR_OUT_OF_HOST_MEMORY; } // double capacity @@ -1189,24 +1192,23 @@ void loader_find_layer_name_add_list(const struct loader_instance *inst, const c } } if (!found) { - loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, "loader_find_layer_name_add_list: Failed to find layer name " - "%s to activate", + loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, + "loader_find_layer_name_add_list: Failed to find layer name " + "%s to activate", name); } } static VkExtensionProperties *get_extension_property(const char *name, const struct loader_extension_list *list) { for (uint32_t i = 0; i < list->count; i++) { - if (strcmp(name, list->list[i].extensionName) == 0) - return &list->list[i]; + if (strcmp(name, list->list[i].extensionName) == 0) return &list->list[i]; } return NULL; } static VkExtensionProperties *get_dev_extension_property(const char *name, const struct loader_device_extension_list *list) { for (uint32_t i = 0; i < list->count; i++) { - if (strcmp(name, list->list[i].props.extensionName) == 0) - return &list->list[i].props; + if (strcmp(name, list->list[i].props.extensionName) == 0) return &list->list[i].props; } return NULL; } @@ -1249,7 +1251,6 @@ VkResult loader_get_icd_loader_instance_extensions(const struct loader_instance if (VK_SUCCESS == res) { // Remove any extensions not recognized by the loader for (int32_t j = 0; j < (int32_t)icd_exts.count; j++) { - // See if the extension is in the list of supported extensions bool found = false; for (uint32_t k = 0; LOADER_INSTANCE_EXTENSIONS[k] != NULL; k++) { @@ -1330,8 +1331,9 @@ struct loader_device *loader_create_logical_device(const struct loader_instance } if (!new_dev) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_create_logical_device: Failed to alloc struct " - "loader_device"); + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_create_logical_device: Failed to alloc struct " + "loader_device"); return NULL; } @@ -1352,8 +1354,7 @@ void loader_remove_logical_device(const struct loader_instance *inst, struct loa struct loader_device *found_dev, const VkAllocationCallbacks *pAllocator) { struct loader_device *dev, *prev_dev; - if (!icd_term || !found_dev) - return; + if (!icd_term || !found_dev) return; prev_dev = NULL; dev = icd_term->logical_device_list; @@ -1422,7 +1423,6 @@ static struct loader_icd_term *loader_icd_add(struct loader_instance *ptr_inst, * by the loader, false indicates the version is not supported */ bool loader_get_icd_interface_version(PFN_vkNegotiateLoaderICDInterfaceVersion fp_negotiate_icd_version, uint32_t *pVersion) { - if (fp_negotiate_icd_version == NULL) { // ICD does not support the negotiation API, it supports version 0 or 1 // calling code must determine if it is version 0 or 1 @@ -1451,8 +1451,7 @@ bool loader_get_icd_interface_version(PFN_vkNegotiateLoaderICDInterfaceVersion f } void loader_scanned_icd_clear(const struct loader_instance *inst, struct loader_icd_tramp_list *icd_tramp_list) { - if (icd_tramp_list->capacity == 0) - return; + if (icd_tramp_list->capacity == 0) return; for (uint32_t i = 0; i < icd_tramp_list->count; i++) { loader_platform_close_library(icd_tramp_list->scanned_list[i].handle); loader_instance_heap_free(inst, icd_tramp_list->scanned_list[i].lib_name); @@ -1469,8 +1468,9 @@ static VkResult loader_scanned_icd_init(const struct loader_instance *inst, stru icd_tramp_list->capacity = 8 * sizeof(struct loader_scanned_icd); icd_tramp_list->scanned_list = loader_instance_heap_alloc(inst, icd_tramp_list->capacity, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); if (NULL == icd_tramp_list->scanned_list) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_scanned_icd_init: Realloc failed for layer list when " - "attempting to add new layer"); + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_scanned_icd_init: Realloc failed for layer list when " + "attempting to add new layer"); err = VK_ERROR_OUT_OF_HOST_MEMORY; } return err; @@ -1500,8 +1500,9 @@ static VkResult loader_scanned_icd_add(const struct loader_instance *inst, struc fp_negotiate_icd_version = loader_platform_get_proc_address(handle, "vk_icdNegotiateLoaderICDInterfaceVersion"); if (!loader_get_icd_interface_version(fp_negotiate_icd_version, &interface_vers)) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_scanned_icd_add: ICD %s doesn't support interface" - " version compatible with loader, skip this ICD.", + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_scanned_icd_add: ICD %s doesn't support interface" + " version compatible with loader, skip this ICD.", filename); goto out; } @@ -1512,30 +1513,34 @@ static VkResult loader_scanned_icd_add(const struct loader_instance *inst, struc // Use deprecated interface from version 0 fp_get_proc_addr = loader_platform_get_proc_address(handle, "vkGetInstanceProcAddr"); if (NULL == fp_get_proc_addr) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_scanned_icd_add: Attempt to retreive either " - "\'vkGetInstanceProcAddr\' or " - "\'vk_icdGetInstanceProcAddr\' from ICD %s failed.", + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_scanned_icd_add: Attempt to retreive either " + "\'vkGetInstanceProcAddr\' or " + "\'vk_icdGetInstanceProcAddr\' from ICD %s failed.", filename); goto out; } else { - loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, "loader_scanned_icd_add: Using deprecated ICD " - "interface of \'vkGetInstanceProcAddr\' instead of " - "\'vk_icdGetInstanceProcAddr\' for ICD %s", + loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, + "loader_scanned_icd_add: Using deprecated ICD " + "interface of \'vkGetInstanceProcAddr\' instead of " + "\'vk_icdGetInstanceProcAddr\' for ICD %s", filename); } fp_create_inst = loader_platform_get_proc_address(handle, "vkCreateInstance"); if (NULL == fp_create_inst) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_scanned_icd_add: Failed querying " - "\'vkCreateInstance\' via dlsym/loadlibrary for " - "ICD %s", + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_scanned_icd_add: Failed querying " + "\'vkCreateInstance\' via dlsym/loadlibrary for " + "ICD %s", filename); goto out; } fp_get_inst_ext_props = loader_platform_get_proc_address(handle, "vkEnumerateInstanceExtensionProperties"); if (NULL == fp_get_inst_ext_props) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_scanned_icd_add: Could not get \'vkEnumerate" - "InstanceExtensionProperties\' via dlsym/loadlibrary " - "for ICD %s", + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_scanned_icd_add: Could not get \'vkEnumerate" + "InstanceExtensionProperties\' via dlsym/loadlibrary " + "for ICD %s", filename); goto out; } @@ -1547,18 +1552,20 @@ static VkResult loader_scanned_icd_add(const struct loader_instance *inst, struc fp_create_inst = (PFN_vkCreateInstance)fp_get_proc_addr(NULL, "vkCreateInstance"); if (NULL == fp_create_inst) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_scanned_icd_add: Could not get " - "\'vkCreateInstance\' via \'vk_icdGetInstanceProcAddr\'" - " for ICD %s", + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_scanned_icd_add: Could not get " + "\'vkCreateInstance\' via \'vk_icdGetInstanceProcAddr\'" + " for ICD %s", filename); goto out; } fp_get_inst_ext_props = (PFN_vkEnumerateInstanceExtensionProperties)fp_get_proc_addr(NULL, "vkEnumerateInstanceExtensionProperties"); if (NULL == fp_get_inst_ext_props) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_scanned_icd_add: Could not get \'vkEnumerate" - "InstanceExtensionProperties\' via " - "\'vk_icdGetInstanceProcAddr\' for ICD %s", + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_scanned_icd_add: Could not get \'vkEnumerate" + "InstanceExtensionProperties\' via " + "\'vk_icdGetInstanceProcAddr\' for ICD %s", filename); goto out; } @@ -1567,14 +1574,14 @@ static VkResult loader_scanned_icd_add(const struct loader_instance *inst, struc // check for enough capacity if ((icd_tramp_list->count * sizeof(struct loader_scanned_icd)) >= icd_tramp_list->capacity) { - icd_tramp_list->scanned_list = loader_instance_heap_realloc(inst, icd_tramp_list->scanned_list, icd_tramp_list->capacity, icd_tramp_list->capacity * 2, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); if (NULL == icd_tramp_list->scanned_list) { res = VK_ERROR_OUT_OF_HOST_MEMORY; - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_scanned_icd_add: Realloc failed on icd library" - " list for ICD %s", + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_scanned_icd_add: Realloc failed on icd library" + " list for ICD %s", filename); goto out; } @@ -1608,14 +1615,14 @@ out: static bool loader_icd_init_entrys(struct loader_icd_term *icd_term, VkInstance inst, const PFN_vkGetInstanceProcAddr fp_gipa) { /* initialize entrypoint function pointers */ -#define LOOKUP_GIPA(func, required) \ - do { \ - icd_term->func = (PFN_vk##func)fp_gipa(inst, "vk" #func); \ - if (!icd_term->func && required) { \ - loader_log((struct loader_instance *)inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, \ - loader_platform_get_proc_address_error("vk" #func)); \ - return false; \ - } \ +#define LOOKUP_GIPA(func, required) \ + do { \ + icd_term->func = (PFN_vk##func)fp_gipa(inst, "vk" #func); \ + if (!icd_term->func && required) { \ + loader_log((struct loader_instance *)inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, \ + loader_platform_get_proc_address_error("vk" #func)); \ + return false; \ + } \ } while (0) LOOKUP_GIPA(GetDeviceProcAddr, true); @@ -1707,8 +1714,7 @@ static bool loader_icd_init_entrys(struct loader_icd_term *icd_term, VkInstance static void loader_debug_init(void) { char *env, *orig; - if (g_loader_debug > 0) - return; + if (g_loader_debug > 0) return; g_loader_debug = 0; @@ -1745,8 +1751,7 @@ static void loader_debug_init(void) { } } - if (!p) - break; + if (!p) break; env = p + 1; } @@ -1786,8 +1791,7 @@ static char *loader_get_next_path(char *path) { uint32_t len; char *next; - if (path == NULL) - return NULL; + if (path == NULL) return NULL; next = strchr(path, PATH_SEPARATOR); if (next == NULL) { len = (uint32_t)strlen(path); @@ -1876,8 +1880,9 @@ static VkResult loader_get_json(const struct loader_instance *inst, const char * fseek(file, 0, SEEK_SET); json_buf = (char *)loader_stack_alloc(len + 1); if (json_buf == NULL) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_get_json: Failed to allocate space for " - "JSON file %s buffer of length %d", + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_get_json: Failed to allocate space for " + "JSON file %s buffer of length %d", filename, len); res = VK_ERROR_OUT_OF_HOST_MEMORY; goto out; @@ -1892,9 +1897,10 @@ static VkResult loader_get_json(const struct loader_instance *inst, const char * // parse text from file *json = cJSON_Parse(json_buf); if (*json == NULL) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_get_json: Failed to parse JSON file %s, " - "this is usually because something ran out of " - "memory.", + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_get_json: Failed to parse JSON file %s, " + "this is usually because something ran out of " + "memory.", filename); res = VK_ERROR_OUT_OF_HOST_MEMORY; goto out; @@ -1918,8 +1924,9 @@ VkResult loader_copy_layer_properties(const struct loader_instance *inst, struct dst->instance_extension_list.list = loader_instance_heap_alloc( inst, sizeof(VkExtensionProperties) * src->instance_extension_list.count, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); if (NULL == dst->instance_extension_list.list) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_copy_layer_properties: Failed to allocate space " - "for instance extension list of size %d.", + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_copy_layer_properties: Failed to allocate space " + "for instance extension list of size %d.", src->instance_extension_list.count); return VK_ERROR_OUT_OF_HOST_MEMORY; } @@ -1928,8 +1935,9 @@ VkResult loader_copy_layer_properties(const struct loader_instance *inst, struct dst->device_extension_list.list = loader_instance_heap_alloc( inst, sizeof(struct loader_dev_ext_props) * src->device_extension_list.count, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); if (NULL == dst->device_extension_list.list) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_copy_layer_properties: Failed to allocate space " - "for device extension list of size %d.", + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_copy_layer_properties: Failed to allocate space " + "for device extension list of size %d.", src->device_extension_list.count); return VK_ERROR_OUT_OF_HOST_MEMORY; } @@ -1942,8 +1950,9 @@ VkResult loader_copy_layer_properties(const struct loader_instance *inst, struct dst->device_extension_list.list->entrypoints = loader_instance_heap_alloc(inst, sizeof(char *) * cnt, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); if (NULL == dst->device_extension_list.list->entrypoints) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_copy_layer_properties: Failed to allocate space " - "for device extension entrypoint list of size %d.", + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_copy_layer_properties: Failed to allocate space " + "for device extension entrypoint list of size %d.", cnt); return VK_ERROR_OUT_OF_HOST_MEMORY; } @@ -1953,9 +1962,10 @@ VkResult loader_copy_layer_properties(const struct loader_instance *inst, struct dst->device_extension_list.list->entrypoints[i] = loader_instance_heap_alloc( inst, strlen(src->device_extension_list.list->entrypoints[i]) + 1, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); if (NULL == dst->device_extension_list.list->entrypoints[i]) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_copy_layer_properties: Failed to " - "allocate space for device extension entrypoint " - "%d name of length", + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_copy_layer_properties: Failed to " + "allocate space for device extension entrypoint " + "%d name of length", i); return VK_ERROR_OUT_OF_HOST_MEMORY; } @@ -1967,29 +1977,23 @@ VkResult loader_copy_layer_properties(const struct loader_instance *inst, struct } static bool loader_find_layer_name_list(const char *name, const struct loader_layer_list *layer_list) { - if (!layer_list) - return false; + if (!layer_list) return false; for (uint32_t j = 0; j < layer_list->count; j++) - if (!strcmp(name, layer_list->list[j].info.layerName)) - return true; + if (!strcmp(name, layer_list->list[j].info.layerName)) return true; return false; } static bool loader_find_layer_name(const char *name, uint32_t layer_count, const char **layer_list) { - if (!layer_list) - return false; + if (!layer_list) return false; for (uint32_t j = 0; j < layer_count; j++) - if (!strcmp(name, layer_list[j])) - return true; + if (!strcmp(name, layer_list[j])) return true; return false; } bool loader_find_layer_name_array(const char *name, uint32_t layer_count, const char layer_list[][VK_MAX_EXTENSION_NAME_SIZE]) { - if (!layer_list) - return false; + if (!layer_list) return false; for (uint32_t j = 0; j < layer_count; j++) - if (!strcmp(name, layer_list[j])) - return true; + if (!strcmp(name, layer_list[j])) return true; return false; } @@ -2008,12 +2012,11 @@ bool loader_find_layer_name_array(const char *name, uint32_t layer_count, const VkResult loader_expand_layer_names(struct loader_instance *inst, const char *key_name, uint32_t expand_count, const char expand_names[][VK_MAX_EXTENSION_NAME_SIZE], uint32_t *layer_count, char const *const **ppp_layer_names) { - char const *const *pp_src_layers = *ppp_layer_names; if (!loader_find_layer_name(key_name, *layer_count, (char const **)pp_src_layers)) { inst->activated_layers_are_std_val = false; - return VK_SUCCESS; // didn't find the key_name in the list. + return VK_SUCCESS; // didn't find the key_name in the list. } loader_log(inst, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, "Found meta layer %s, replacing with actual layer group", key_name); @@ -2022,8 +2025,9 @@ VkResult loader_expand_layer_names(struct loader_instance *inst, const char *key char const **pp_dst_layers = loader_instance_heap_alloc(inst, (expand_count + *layer_count - 1) * sizeof(char const *), VK_SYSTEM_ALLOCATION_SCOPE_COMMAND); if (NULL == pp_dst_layers) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_expand_layer_names:: Failed to allocate space for " - "std_validation layer names in pp_dst_layers."); + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_expand_layer_names:: Failed to allocate space for " + "std_validation layer names in pp_dst_layers."); return VK_ERROR_OUT_OF_HOST_MEMORY; } @@ -2088,19 +2092,15 @@ static void loader_add_layer_property_meta(const struct loader_instance *inst, u bool found; struct loader_layer_list *layer_list; - if (0 == layer_count || (!layer_instance_list)) - return; - if (layer_instance_list && (layer_count > layer_instance_list->count)) - return; + if (0 == layer_count || (!layer_instance_list)) return; + if (layer_instance_list && (layer_count > layer_instance_list->count)) return; layer_list = layer_instance_list; found = true; - if (layer_list == NULL) - return; + if (layer_list == NULL) return; for (i = 0; i < layer_count; i++) { - if (loader_find_layer_name_list(layer_names[i], layer_list)) - continue; + if (loader_find_layer_name_list(layer_names[i], layer_list)) continue; found = false; break; } @@ -2144,39 +2144,42 @@ static void loader_read_json_layer(const struct loader_instance *inst, struct lo * (required for implicit layers) “disable_environment” */ -#define GET_JSON_OBJECT(node, var) \ - { \ - var = cJSON_GetObjectItem(node, #var); \ - if (var == NULL) { \ - layer_node = layer_node->next; \ - loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, "Didn't find required layer object %s in manifest " \ - "JSON file, skipping this layer", \ - #var); \ - return; \ - } \ - } -#define GET_JSON_ITEM(node, var) \ - { \ - item = cJSON_GetObjectItem(node, #var); \ - if (item == NULL) { \ - layer_node = layer_node->next; \ - loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, "Didn't find required layer value %s in manifest JSON " \ - "file, skipping this layer", \ - #var); \ - return; \ - } \ - temp = cJSON_Print(item); \ - if (temp == NULL) { \ - layer_node = layer_node->next; \ - loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, "Problem accessing layer value %s in manifest JSON " \ - "file, skipping this layer", \ - #var); \ - return; \ - } \ - temp[strlen(temp) - 1] = '\0'; \ - var = loader_stack_alloc(strlen(temp) + 1); \ - strcpy(var, &temp[1]); \ - cJSON_Free(temp); \ +#define GET_JSON_OBJECT(node, var) \ + { \ + var = cJSON_GetObjectItem(node, #var); \ + if (var == NULL) { \ + layer_node = layer_node->next; \ + loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, \ + "Didn't find required layer object %s in manifest " \ + "JSON file, skipping this layer", \ + #var); \ + return; \ + } \ + } +#define GET_JSON_ITEM(node, var) \ + { \ + item = cJSON_GetObjectItem(node, #var); \ + if (item == NULL) { \ + layer_node = layer_node->next; \ + loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, \ + "Didn't find required layer value %s in manifest JSON " \ + "file, skipping this layer", \ + #var); \ + return; \ + } \ + temp = cJSON_Print(item); \ + if (temp == NULL) { \ + layer_node = layer_node->next; \ + loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, \ + "Problem accessing layer value %s in manifest JSON " \ + "file, skipping this layer", \ + #var); \ + return; \ + } \ + temp[strlen(temp) - 1] = '\0'; \ + var = loader_stack_alloc(strlen(temp) + 1); \ + strcpy(var, &temp[1]); \ + cJSON_Free(temp); \ } GET_JSON_ITEM(layer_node, name) GET_JSON_ITEM(layer_node, type) @@ -2238,8 +2241,9 @@ static void loader_read_json_layer(const struct loader_instance *inst, struct lo props->info.description[sizeof(props->info.description) - 1] = '\0'; if (is_implicit) { if (!disable_environment || !disable_environment->child) { - loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, "Didn't find required layer child value disable_environment" - "in manifest JSON file, skipping this layer"); + loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, + "Didn't find required layer child value disable_environment" + "in manifest JSON file, skipping this layer"); layer_node = layer_node->next; return; } @@ -2256,20 +2260,20 @@ static void loader_read_json_layer(const struct loader_instance *inst, struct lo * device_extensions * enable_environment (implicit layers only) */ -#define GET_JSON_OBJECT(node, var) \ +#define GET_JSON_OBJECT(node, var) \ { var = cJSON_GetObjectItem(node, #var); } -#define GET_JSON_ITEM(node, var) \ - { \ - item = cJSON_GetObjectItem(node, #var); \ - if (item != NULL) { \ - temp = cJSON_Print(item); \ - if (temp != NULL) { \ - temp[strlen(temp) - 1] = '\0'; \ - var = loader_stack_alloc(strlen(temp) + 1); \ - strcpy(var, &temp[1]); \ - cJSON_Free(temp); \ - } \ - } \ +#define GET_JSON_ITEM(node, var) \ + { \ + item = cJSON_GetObjectItem(node, #var); \ + if (item != NULL) { \ + temp = cJSON_Print(item); \ + if (temp != NULL) { \ + temp[strlen(temp) - 1] = '\0'; \ + var = loader_stack_alloc(strlen(temp) + 1); \ + strcpy(var, &temp[1]); \ + cJSON_Free(temp); \ + } \ + } \ } cJSON *instance_extensions, *device_extensions, *functions, *enable_environment; @@ -2302,24 +2306,26 @@ static void loader_read_json_layer(const struct loader_instance *inst, struct lo if (vkGetInstanceProcAddr != NULL) { strncpy(props->functions.str_gipa, vkGetInstanceProcAddr, sizeof(props->functions.str_gipa)); if (version.major > 1 || version.minor >= 1) { - loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, "Indicating layer-specific vkGetInstanceProcAddr " - "function is deprecated starting with JSON file " - "version 1.1.0. Instead, use the new " - "vkNegotiateLayerInterfaceVersion function to " - "return the GetInstanceProcAddr function for this" - "layer"); + loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, + "Indicating layer-specific vkGetInstanceProcAddr " + "function is deprecated starting with JSON file " + "version 1.1.0. Instead, use the new " + "vkNegotiateLayerInterfaceVersion function to " + "return the GetInstanceProcAddr function for this" + "layer"); } } props->functions.str_gipa[sizeof(props->functions.str_gipa) - 1] = '\0'; if (vkGetDeviceProcAddr != NULL) { strncpy(props->functions.str_gdpa, vkGetDeviceProcAddr, sizeof(props->functions.str_gdpa)); if (version.major > 1 || version.minor >= 1) { - loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, "Indicating layer-specific vkGetDeviceProcAddr " - "function is deprecated starting with JSON file " - "version 1.1.0. Instead, use the new " - "vkNegotiateLayerInterfaceVersion function to " - "return the GetDeviceProcAddr function for this" - "layer"); + loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, + "Indicating layer-specific vkGetDeviceProcAddr " + "function is deprecated starting with JSON file " + "version 1.1.0. Instead, use the new " + "vkNegotiateLayerInterfaceVersion function to " + "return the GetDeviceProcAddr function for this" + "layer"); } } props->functions.str_gdpa[sizeof(props->functions.str_gdpa) - 1] = '\0'; @@ -2481,8 +2487,9 @@ static void loader_add_layer_properties(const struct loader_instance *inst, stru } if (!is_valid_layer_json_version(&json_version)) { - loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, "loader_add_layer_properties: %s invalid layer " - " manifest file version %d.%d.%d. May cause errors.", + loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, + "loader_add_layer_properties: %s invalid layer " + " manifest file version %d.%d.%d. May cause errors.", filename, json_version.major, json_version.minor, json_version.patch); } cJSON_Free(file_vers); @@ -2492,17 +2499,19 @@ static void loader_add_layer_properties(const struct loader_instance *inst, stru if (layers_node != NULL) { int numItems = cJSON_GetArraySize(layers_node); if (!layer_json_supports_layers_tag(&json_version)) { - loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, "loader_add_layer_properties: \'layers\' tag not " - "supported until file version 1.0.1, but %s is " - "reporting version %s", + loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, + "loader_add_layer_properties: \'layers\' tag not " + "supported until file version 1.0.1, but %s is " + "reporting version %s", filename, file_vers); } for (int curLayer = 0; curLayer < numItems; curLayer++) { layer_node = cJSON_GetArrayItem(layers_node, curLayer); if (layer_node == NULL) { - loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, "loader_add_layer_properties: Can not find " - "\'layers\' array element %d object in manifest " - "JSON file %s. Skipping this file", + loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, + "loader_add_layer_properties: Can not find " + "\'layers\' array element %d object in manifest " + "JSON file %s. Skipping this file", curLayer, filename); return; } @@ -2513,8 +2522,9 @@ static void loader_add_layer_properties(const struct loader_instance *inst, stru // Otherwise, try to read in individual layers layer_node = cJSON_GetObjectItem(json, "layer"); if (layer_node == NULL) { - loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, "loader_add_layer_properties: Can not find \'layer\' " - "object in manifest JSON file %s. Skipping this file.", + loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, + "loader_add_layer_properties: Can not find \'layer\' " + "object in manifest JSON file %s. Skipping this file.", filename); return; } @@ -2531,9 +2541,10 @@ static void loader_add_layer_properties(const struct loader_instance *inst, stru // versions newer than 1.0.0. Having multiple objects with the same // name at the same level is actually a JSON standard violation. if (layer_count > 1 && layer_json_supports_layers_tag(&json_version)) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_add_layer_properties: Multiple \'layer\' nodes" - " are deprecated starting in file version \"1.0.1\". " - "Please use \'layers\' : [] array instead in %s.", + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_add_layer_properties: Multiple \'layer\' nodes" + " are deprecated starting in file version \"1.0.1\". " + "Please use \'layers\' : [] array instead in %s.", filename); } else { do { @@ -2611,8 +2622,9 @@ static VkResult loader_get_manifest_files(const struct loader_instance *inst, co home_location = NULL; if (location == NULL) { #endif - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_get_manifest_files: Can not get manifest files with " - "NULL location, env_override=%s", + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_get_manifest_files: Can not get manifest files with " + "NULL location, env_override=%s", (env_override != NULL) ? env_override : ""); res = VK_ERROR_INITIALIZATION_FAILED; goto out; @@ -2628,8 +2640,9 @@ static VkResult loader_get_manifest_files(const struct loader_instance *inst, co if (override == NULL) { loc = loader_stack_alloc(strlen(location) + 1); if (loc == NULL) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_get_manifest_files: Failed to allocate " - "%d bytes for manifest file location.", + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_get_manifest_files: Failed to allocate " + "%d bytes for manifest file location.", strlen(location)); res = VK_ERROR_OUT_OF_HOST_MEMORY; goto out; @@ -2639,9 +2652,10 @@ static VkResult loader_get_manifest_files(const struct loader_instance *inst, co VkResult reg_result = loaderGetRegistryFiles(inst, loc, ®); if (VK_SUCCESS != reg_result || NULL == reg) { if (!is_layer) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_get_manifest_files: Registry lookup failed " - "to get ICD manifest files. Possibly missing Vulkan" - " driver?"); + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_get_manifest_files: Registry lookup failed " + "to get ICD manifest files. Possibly missing Vulkan" + " driver?"); if (VK_SUCCESS == reg_result || VK_ERROR_OUT_OF_HOST_MEMORY == reg_result) { res = reg_result; } else { @@ -2650,8 +2664,9 @@ static VkResult loader_get_manifest_files(const struct loader_instance *inst, co } else { if (warn_if_not_present) { // This is only a warning for layers - loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, "loader_get_manifest_files: Registry lookup failed " - "to get layer manifest files."); + loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, + "loader_get_manifest_files: Registry lookup failed " + "to get layer manifest files."); } if (reg_result == VK_ERROR_OUT_OF_HOST_MEMORY) { res = reg_result; @@ -2668,8 +2683,9 @@ static VkResult loader_get_manifest_files(const struct loader_instance *inst, co } else { loc = loader_stack_alloc(strlen(override) + 1); if (loc == NULL) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_get_manifest_files: Failed to allocate space for " - "override environment variable of length %d", + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_get_manifest_files: Failed to allocate space for " + "override environment variable of length %d", strlen(override) + 1); res = VK_ERROR_OUT_OF_HOST_MEMORY; goto out; @@ -2688,8 +2704,7 @@ static VkResult loader_get_manifest_files(const struct loader_instance *inst, co name = NULL; if (sysdir) { dent = readdir(sysdir); - if (dent == NULL) - break; + if (dent == NULL) break; name = &(dent->d_name[0]); loader_get_fullpath(name, file, sizeof(full_path), full_path); name = full_path; @@ -2703,8 +2718,9 @@ static VkResult loader_get_manifest_files(const struct loader_instance *inst, co // make a copy of location so it isn't modified dir = loader_stack_alloc(strlen(loc) + 1); if (dir == NULL) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_get_manifest_files: Failed to allocate " - "space for relative location path length %d", + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_get_manifest_files: Failed to allocate " + "space for relative location path length %d", strlen(loc) + 1); goto out; } @@ -2730,16 +2746,18 @@ static VkResult loader_get_manifest_files(const struct loader_instance *inst, co alloced_count *= 2; } if (out_files->filename_list == NULL) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_get_manifest_files: Failed to allocate " - "space for manifest file name list"); + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_get_manifest_files: Failed to allocate " + "space for manifest file name list"); res = VK_ERROR_OUT_OF_HOST_MEMORY; goto out; } out_files->filename_list[out_files->count] = loader_instance_heap_alloc(inst, strlen(name) + 1, VK_SYSTEM_ALLOCATION_SCOPE_COMMAND); if (out_files->filename_list[out_files->count] == NULL) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_get_manifest_files: Failed to allocate " - "space for manifest file %d list", + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_get_manifest_files: Failed to allocate " + "space for manifest file %d list", out_files->count); res = VK_ERROR_OUT_OF_HOST_MEMORY; goto out; @@ -2772,11 +2790,11 @@ static VkResult loader_get_manifest_files(const struct loader_instance *inst, co char *xdgdatahome = secure_getenv("XDG_DATA_HOME"); size_t len; if (xdgdatahome != NULL) { - char *home_loc = loader_stack_alloc(strlen(xdgdatahome) + 2 + strlen(home_location)); if (home_loc == NULL) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_get_manifest_files: Failed to allocate " - "space for manifest file XDG Home location"); + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_get_manifest_files: Failed to allocate " + "space for manifest file XDG Home location"); res = VK_ERROR_OUT_OF_HOST_MEMORY; goto out; } @@ -2797,13 +2815,13 @@ static VkResult loader_get_manifest_files(const struct loader_instance *inst, co list_is_dirs = true; } else { - char *home = secure_getenv("HOME"); if (home != NULL) { char *home_loc = loader_stack_alloc(strlen(home) + 16 + strlen(home_location)); if (home_loc == NULL) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_get_manifest_files: Failed to allocate " - "space for manifest file Home location"); + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_get_manifest_files: Failed to allocate " + "space for manifest file Home location"); res = VK_ERROR_OUT_OF_HOST_MEMORY; goto out; } @@ -2922,8 +2940,9 @@ VkResult loader_icd_scan(const struct loader_instance *inst, struct loader_icd_t if (num_good_icds == 0) { res = VK_ERROR_INITIALIZATION_FAILED; } - loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, "loader_icd_scan: ICD JSON %s does not have a" - " \'file_format_version\' field. Skipping ICD JSON.", + loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, + "loader_icd_scan: ICD JSON %s does not have a" + " \'file_format_version\' field. Skipping ICD JSON.", file_str); cJSON_Delete(json); json = NULL; @@ -2936,8 +2955,9 @@ VkResult loader_icd_scan(const struct loader_instance *inst, struct loader_icd_t if (num_good_icds == 0) { res = VK_ERROR_OUT_OF_HOST_MEMORY; } - loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, "loader_icd_scan: Failed retrieving ICD JSON %s" - " \'file_format_version\' field. Skipping ICD JSON", + loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, + "loader_icd_scan: Failed retrieving ICD JSON %s" + " \'file_format_version\' field. Skipping ICD JSON", file_str); cJSON_Delete(json); json = NULL; @@ -2958,8 +2978,9 @@ VkResult loader_icd_scan(const struct loader_instance *inst, struct loader_icd_t } } if (file_major_vers != 1 || file_minor_vers != 0 || file_patch_vers > 1) - loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, "loader_icd_scan: Unexpected manifest file version " - "(expected 1.0.0 or 1.0.1), may cause errors"); + loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, + "loader_icd_scan: Unexpected manifest file version " + "(expected 1.0.0 or 1.0.1), may cause errors"); cJSON_Free(file_vers); itemICD = cJSON_GetObjectItem(json, "ICD"); if (itemICD != NULL) { @@ -2970,8 +2991,9 @@ VkResult loader_icd_scan(const struct loader_instance *inst, struct loader_icd_t if (num_good_icds == 0) { res = VK_ERROR_OUT_OF_HOST_MEMORY; } - loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, "loader_icd_scan: Failed retrieving ICD JSON %s" - " \'library_path\' field. Skipping ICD JSON.", + loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, + "loader_icd_scan: Failed retrieving ICD JSON %s" + " \'library_path\' field. Skipping ICD JSON.", file_str); cJSON_Free(temp); cJSON_Delete(json); @@ -2982,9 +3004,10 @@ VkResult loader_icd_scan(const struct loader_instance *inst, struct loader_icd_t temp[strlen(temp) - 1] = '\0'; char *library_path = loader_stack_alloc(strlen(temp) + 1); if (NULL == library_path) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_icd_scan: Failed to allocate space for " - "ICD JSON %s \'library_path\' value. Skipping " - "ICD JSON.", + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_icd_scan: Failed to allocate space for " + "ICD JSON %s \'library_path\' value. Skipping " + "ICD JSON.", file_str); res = VK_ERROR_OUT_OF_HOST_MEMORY; cJSON_Free(temp); @@ -2995,8 +3018,9 @@ VkResult loader_icd_scan(const struct loader_instance *inst, struct loader_icd_t strcpy(library_path, &temp[1]); cJSON_Free(temp); if (strlen(library_path) == 0) { - loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, "loader_icd_scan: ICD JSON %s \'library_path\'" - " field is empty. Skipping ICD JSON.", + loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, + "loader_icd_scan: ICD JSON %s \'library_path\'" + " field is empty. Skipping ICD JSON.", file_str); cJSON_Delete(json); json = NULL; @@ -3023,8 +3047,9 @@ VkResult loader_icd_scan(const struct loader_instance *inst, struct loader_icd_t if (item != NULL) { temp = cJSON_Print(item); if (NULL == temp) { - loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, "loader_icd_scan: Failed retrieving ICD JSON %s" - " \'api_version\' field. Skipping ICD JSON.", + loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, + "loader_icd_scan: Failed retrieving ICD JSON %s" + " \'api_version\' field. Skipping ICD JSON.", file_str); // Only reason the print can fail is if there was an @@ -3041,27 +3066,31 @@ VkResult loader_icd_scan(const struct loader_instance *inst, struct loader_icd_t vers = loader_make_version(temp); cJSON_Free(temp); } else { - loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, "loader_icd_scan: ICD JSON %s does not have an" - " \'api_version\' field.", + loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, + "loader_icd_scan: ICD JSON %s does not have an" + " \'api_version\' field.", file_str); } res = loader_scanned_icd_add(inst, icd_tramp_list, fullpath, vers); if (VK_SUCCESS != res) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_icd_scan: Failed to add ICD JSON %s. " - " Skipping ICD JSON.", + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_icd_scan: Failed to add ICD JSON %s. " + " Skipping ICD JSON.", fullpath); continue; } num_good_icds++; } else { - loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, "loader_icd_scan: Failed to find \'library_path\' " - "object in ICD JSON file %s. Skipping ICD JSON.", + loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, + "loader_icd_scan: Failed to find \'library_path\' " + "object in ICD JSON file %s. Skipping ICD JSON.", file_str); } } else { - loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, "loader_icd_scan: Can not find \'ICD\' object in ICD JSON " - "file %s. Skipping ICD JSON", + loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, + "loader_icd_scan: Can not find \'ICD\' object in ICD JSON " + "file %s. Skipping ICD JSON", file_str); } @@ -3090,7 +3119,7 @@ out: void loader_layer_scan(const struct loader_instance *inst, struct loader_layer_list *instance_layers) { char *file_str; - struct loader_manifest_files manifest_files[2]; // [0] = explicit, [1] = implicit + struct loader_manifest_files manifest_files[2]; // [0] = explicit, [1] = implicit cJSON *json; uint32_t implicit; bool lockedMutex = false; @@ -3124,8 +3153,7 @@ void loader_layer_scan(const struct loader_instance *inst, struct loader_layer_l for (implicit = 0; implicit < 2; implicit++) { for (uint32_t i = 0; i < manifest_files[implicit].count; i++) { file_str = manifest_files[implicit].filename_list[i]; - if (file_str == NULL) - continue; + if (file_str == NULL) continue; // parse file into JSON struct VkResult res = loader_get_json(inst, file_str, &json); @@ -3216,8 +3244,7 @@ static VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL loader_gpdpa_instance_internal(V VkLayerInstanceDispatchTable *disp_table = *(VkLayerInstanceDispatchTable **)inst; void *addr; - if (disp_table == NULL) - return NULL; + if (disp_table == NULL) return NULL; bool found_name; addr = loader_lookup_instance_dispatch_table(disp_table, pName, &found_name); @@ -3225,8 +3252,7 @@ static VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL loader_gpdpa_instance_internal(V return addr; } - if (loader_phys_dev_ext_gpa(loader_get_instance(inst), pName, true, NULL, &addr)) - return addr; + if (loader_phys_dev_ext_gpa(loader_get_instance(inst), pName, true, NULL, &addr)) return addr; // Don't call down the chain, this would be an infinite loop loader_log(NULL, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, "loader_gpdpa_instance_internal() unrecognized name %s", pName); @@ -3241,8 +3267,7 @@ static VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL loader_gpdpa_instance_terminator VkLayerInstanceDispatchTable *disp_table = *(VkLayerInstanceDispatchTable **)inst; void *addr; - if (disp_table == NULL) - return NULL; + if (disp_table == NULL) return NULL; bool found_name; addr = loader_lookup_instance_dispatch_table(disp_table, pName, &found_name); @@ -3282,8 +3307,7 @@ static VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL loader_gpa_instance_internal(VkI VkLayerInstanceDispatchTable *disp_table = *(VkLayerInstanceDispatchTable **)inst; void *addr; - if (disp_table == NULL) - return NULL; + if (disp_table == NULL) return NULL; bool found_name; addr = loader_lookup_instance_dispatch_table(disp_table, pName, &found_name); @@ -3339,15 +3363,13 @@ static void loader_init_dispatch_dev_ext_entry(struct loader_instance *inst, str void *gdpa_value; if (dev != NULL) { gdpa_value = dev->loader_dispatch.core_dispatch.GetDeviceProcAddr(dev->chain_device, funcName); - if (gdpa_value != NULL) - dev->loader_dispatch.ext_dispatch.dev_ext[idx] = (PFN_vkDevExt)gdpa_value; + if (gdpa_value != NULL) dev->loader_dispatch.ext_dispatch.dev_ext[idx] = (PFN_vkDevExt)gdpa_value; } else { for (struct loader_icd_term *icd_term = inst->icd_terms; icd_term != NULL; icd_term = icd_term->next) { struct loader_device *ldev = icd_term->logical_device_list; while (ldev) { gdpa_value = ldev->loader_dispatch.core_dispatch.GetDeviceProcAddr(ldev->chain_device, funcName); - if (gdpa_value != NULL) - ldev->loader_dispatch.ext_dispatch.dev_ext[idx] = (PFN_vkDevExt)gdpa_value; + if (gdpa_value != NULL) ldev->loader_dispatch.ext_dispatch.dev_ext[idx] = (PFN_vkDevExt)gdpa_value; ldev = ldev->next; } } @@ -3417,8 +3439,9 @@ static bool loader_add_dev_ext_table(struct loader_instance *inst, uint32_t *ptr inst->dev_ext_disp_hash[idx].func_name = (char *)loader_instance_heap_alloc(inst, strlen(funcName) + 1, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); if (inst->dev_ext_disp_hash[idx].func_name == NULL) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_add_dev_ext_table: Failed to allocate memory " - "for func_name %s", + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_add_dev_ext_table: Failed to allocate memory " + "for func_name %s", funcName); return false; } @@ -3430,8 +3453,9 @@ static bool loader_add_dev_ext_table(struct loader_instance *inst, uint32_t *ptr if (list->capacity == 0) { list->index = loader_instance_heap_alloc(inst, 8 * sizeof(*(list->index)), VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); if (list->index == NULL) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_add_dev_ext_table: Failed to allocate memory " - "for list index", + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_add_dev_ext_table: Failed to allocate memory " + "for list index", funcName); return false; } @@ -3440,8 +3464,9 @@ static bool loader_add_dev_ext_table(struct loader_instance *inst, uint32_t *ptr list->index = loader_instance_heap_realloc(inst, list->index, list->capacity, list->capacity * 2, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); if (list->index == NULL) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_add_dev_ext_table: Failed to reallocate memory " - "for list index", + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_add_dev_ext_table: Failed to reallocate memory " + "for list index", funcName); return false; } @@ -3456,8 +3481,9 @@ static bool loader_add_dev_ext_table(struct loader_instance *inst, uint32_t *ptr inst->dev_ext_disp_hash[i].func_name = (char *)loader_instance_heap_alloc(inst, strlen(funcName) + 1, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); if (inst->dev_ext_disp_hash[i].func_name == NULL) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_add_dev_ext_table: Failed to allocate memory " - "for func_name %s", + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_add_dev_ext_table: Failed to allocate memory " + "for func_name %s", funcName); return false; } @@ -3470,16 +3496,16 @@ static bool loader_add_dev_ext_table(struct loader_instance *inst, uint32_t *ptr i = (i + 1) % MAX_NUM_UNKNOWN_EXTS; } while (i != idx); - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_add_dev_ext_table: Could not insert into hash table; is " - "it full?"); + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_add_dev_ext_table: Could not insert into hash table; is " + "it full?"); return false; } static bool loader_name_in_dev_ext_table(struct loader_instance *inst, uint32_t *idx, const char *funcName) { uint32_t alt_idx; - if (inst->dev_ext_disp_hash[*idx].func_name && !strcmp(inst->dev_ext_disp_hash[*idx].func_name, funcName)) - return true; + if (inst->dev_ext_disp_hash[*idx].func_name && !strcmp(inst->dev_ext_disp_hash[*idx].func_name, funcName)) return true; // funcName wasn't at the primary spot in the hash table // search the list of secondary locations (shallow search, not deep search) @@ -3589,8 +3615,9 @@ static bool loader_add_phys_dev_ext_table(struct loader_instance *inst, uint32_t inst->phys_dev_ext_disp_hash[idx].func_name = (char *)loader_instance_heap_alloc(inst, strlen(funcName) + 1, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); if (inst->phys_dev_ext_disp_hash[idx].func_name == NULL) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_add_phys_dev_ext_table() can't allocate memory for " - "func_name"); + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_add_phys_dev_ext_table() can't allocate memory for " + "func_name"); return false; } strncpy(inst->phys_dev_ext_disp_hash[idx].func_name, funcName, strlen(funcName) + 1); @@ -3623,8 +3650,9 @@ static bool loader_add_phys_dev_ext_table(struct loader_instance *inst, uint32_t inst->phys_dev_ext_disp_hash[i].func_name = (char *)loader_instance_heap_alloc(inst, strlen(funcName) + 1, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); if (inst->phys_dev_ext_disp_hash[i].func_name == NULL) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_add_dev_ext_table() can't rallocate " - "func_name memory"); + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_add_dev_ext_table() can't rallocate " + "func_name memory"); return false; } strncpy(inst->phys_dev_ext_disp_hash[i].func_name, funcName, strlen(funcName) + 1); @@ -3636,8 +3664,9 @@ static bool loader_add_phys_dev_ext_table(struct loader_instance *inst, uint32_t i = (i + 1) % MAX_NUM_UNKNOWN_EXTS; } while (i != idx); - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_add_phys_dev_ext_table() couldn't insert into hash table; is " - "it full?"); + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_add_phys_dev_ext_table() couldn't insert into hash table; is " + "it full?"); return false; } @@ -3778,7 +3807,6 @@ struct loader_instance *loader_get_instance(const VkInstance instance) { static loader_platform_dl_handle loader_open_layer_lib(const struct loader_instance *inst, const char *chain_type, struct loader_layer_properties *prop) { - if ((prop->lib_handle = loader_platform_open_library(prop->lib_name)) == NULL) { loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_open_layer_lib: Failed to open library %s", prop->lib_name); } else { @@ -3789,7 +3817,6 @@ static loader_platform_dl_handle loader_open_layer_lib(const struct loader_insta } static void loader_close_layer_lib(const struct loader_instance *inst, struct loader_layer_properties *prop) { - if (prop->lib_handle) { loader_platform_close_library(prop->lib_handle); loader_log(inst, VK_DEBUG_REPORT_DEBUG_BIT_EXT, 0, "Unloading layer library %s", prop->lib_name); @@ -3830,8 +3857,7 @@ static void loader_add_layer_implicit(const struct loader_instance *inst, const enable = true; } else { env_value = loader_getenv(prop->enable_env_var.name, inst); - if (env_value && !strcmp(prop->enable_env_var.value, env_value)) - enable = true; + if (env_value && !strcmp(prop->enable_env_var.value, env_value)) enable = true; loader_free_getenv(env_value, inst); } @@ -3883,8 +3909,7 @@ static void loader_add_layer_env(struct loader_instance *inst, const enum layer_ */ loader_log(inst, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, "Expanding meta layer %s found in environment variable", std_validation_str); - if (type == VK_LAYER_TYPE_INSTANCE_EXPLICIT) - inst->activated_layers_are_std_val = true; + if (type == VK_LAYER_TYPE_INSTANCE_EXPLICIT) inst->activated_layers_are_std_val = true; for (uint32_t i = 0; i < sizeof(std_validation_names) / sizeof(std_validation_names[0]); i++) { loader_find_layer_name_add_list(inst, std_validation_names[i], type, search_list, layer_list); } @@ -3904,8 +3929,9 @@ VkResult loader_enable_instance_layers(struct loader_instance *inst, const VkIns assert(inst && "Cannot have null instance"); if (!loader_init_layer_list(inst, &inst->activated_layer_list)) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_enable_instance_layers: Failed to initialize" - " the layer list"); + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_enable_instance_layers: Failed to initialize" + " the layer list"); return VK_ERROR_OUT_OF_HOST_MEMORY; } @@ -3925,7 +3951,6 @@ VkResult loader_enable_instance_layers(struct loader_instance *inst, const VkIns // Determine the layer interface version to use. bool loader_get_layer_interface_version(PFN_vkNegotiateLoaderLayerInterfaceVersion fp_negotiate_layer_version, VkNegotiateLayerInterface *interface_struct) { - memset(interface_struct, 0, sizeof(VkNegotiateLayerInterface)); // Base assumption is that all layers are version 1 at least. @@ -3987,7 +4012,6 @@ VkResult loader_create_instance_chain(const VkInstanceCreateInfo *pCreateInfo, c memcpy(&loader_create_info, pCreateInfo, sizeof(VkInstanceCreateInfo)); if (inst->activated_layer_list.count > 0) { - chain_info.u.pLayerInfo = NULL; chain_info.pNext = pCreateInfo->pNext; chain_info.sType = VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO; @@ -3996,8 +4020,9 @@ VkResult loader_create_instance_chain(const VkInstanceCreateInfo *pCreateInfo, c layer_instance_link_info = loader_stack_alloc(sizeof(VkLayerInstanceLink) * inst->activated_layer_list.count); if (!layer_instance_link_info) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_create_instance_chain: Failed to alloc Instance" - " objects for layer"); + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_create_instance_chain: Failed to alloc Instance" + " objects for layer"); return VK_ERROR_OUT_OF_HOST_MEMORY; } @@ -4032,7 +4057,6 @@ VkResult loader_create_instance_chain(const VkInstanceCreateInfo *pCreateInfo, c VkNegotiateLayerInterface interface_struct; if (loader_get_layer_interface_version(negotiate_interface, &interface_struct)) { - // Go ahead and set the properites version to the // correct value. layer_prop->interface_version = interface_struct.loaderLayerInterfaceVersion; @@ -4065,9 +4089,10 @@ VkResult loader_create_instance_chain(const VkInstanceCreateInfo *pCreateInfo, c } if (NULL == cur_gipa) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_create_instance_chain: Failed to" - " find \'vkGetInstanceProcAddr\' in " - "layer %s", + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_create_instance_chain: Failed to" + " find \'vkGetInstanceProcAddr\' in " + "layer %s", layer_prop->lib_name); continue; } @@ -4106,8 +4131,9 @@ VkResult loader_create_instance_chain(const VkInstanceCreateInfo *pCreateInfo, c loader_create_info.pNext = &create_info_disp; res = fpCreateInstance(&loader_create_info, pAllocator, created_instance); } else { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_create_instance_chain: Failed to find " - "\'vkCreateInstance\'"); + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_create_instance_chain: Failed to find " + "\'vkCreateInstance\'"); // Couldn't find CreateInstance function! res = VK_ERROR_INITIALIZATION_FAILED; } @@ -4121,7 +4147,6 @@ VkResult loader_create_instance_chain(const VkInstanceCreateInfo *pCreateInfo, c } void loader_activate_instance_layer_extensions(struct loader_instance *inst, VkInstance created_inst) { - loader_init_instance_extension_dispatch_table(&inst->disp->layer_inst_disp, inst->disp->layer_inst_disp.GetInstanceProcAddr, created_inst); } @@ -4142,8 +4167,9 @@ VkResult loader_create_device_chain(const struct loader_physical_device_tramp *p layer_device_link_info = loader_stack_alloc(sizeof(VkLayerDeviceLink) * dev->activated_layer_list.count); if (!layer_device_link_info) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_create_device_chain: Failed to alloc Device objects" - " for layer. Skipping Layer."); + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_create_device_chain: Failed to alloc Device objects" + " for layer. Skipping Layer."); return VK_ERROR_OUT_OF_HOST_MEMORY; } @@ -4185,7 +4211,6 @@ VkResult loader_create_device_chain(const struct loader_physical_device_tramp *p VkNegotiateLayerInterface interface_struct; if (loader_get_layer_interface_version(negotiate_interface, &interface_struct)) { - // Go ahead and set the properites version to the // correct value. layer_prop->interface_version = interface_struct.loaderLayerInterfaceVersion; @@ -4215,9 +4240,10 @@ VkResult loader_create_device_chain(const struct loader_physical_device_tramp *p fpGIPA = (PFN_vkGetInstanceProcAddr)loader_platform_get_proc_address(lib_handle, layer_prop->functions.str_gipa); if (!fpGIPA) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_create_device_chain: Failed to find " - "\'vkGetInstanceProcAddr\' in layer %s. Skipping" - " layer.", + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_create_device_chain: Failed to find " + "\'vkGetInstanceProcAddr\' in layer %s. Skipping" + " layer.", layer_prop->lib_name); continue; } @@ -4268,8 +4294,9 @@ VkResult loader_create_device_chain(const struct loader_physical_device_tramp *p } dev->chain_device = created_device; } else { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_create_device_chain: Failed to find \'vkCreateDevice\' " - "in layer %s"); + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_create_device_chain: Failed to find \'vkCreateDevice\' " + "in layer %s"); // Couldn't find CreateDevice function! return VK_ERROR_INITIALIZATION_FAILED; } @@ -4287,15 +4314,17 @@ VkResult loader_validate_layers(const struct loader_instance *inst, const uint32 for (uint32_t i = 0; i < layer_count; i++) { VkStringErrorFlags result = vk_string_validate(MaxLoaderStringLength, ppEnabledLayerNames[i]); if (result != VK_STRING_ERROR_NONE) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_validate_layers: Device ppEnabledLayerNames " - "contains string that is too long or is badly formed"); + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_validate_layers: Device ppEnabledLayerNames " + "contains string that is too long or is badly formed"); return VK_ERROR_LAYER_NOT_PRESENT; } prop = loader_get_layer_property(ppEnabledLayerNames[i], list); if (!prop) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_validate_layers: Layer %d does not exist in " - "the list of available layers", + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_validate_layers: Layer %d does not exist in " + "the list of available layers", i); return VK_ERROR_LAYER_NOT_PRESENT; } @@ -4306,16 +4335,16 @@ VkResult loader_validate_layers(const struct loader_instance *inst, const uint32 VkResult loader_validate_instance_extensions(const struct loader_instance *inst, const struct loader_extension_list *icd_exts, const struct loader_layer_list *instance_layers, const VkInstanceCreateInfo *pCreateInfo) { - VkExtensionProperties *extension_prop; struct loader_layer_properties *layer_prop; for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { VkStringErrorFlags result = vk_string_validate(MaxLoaderStringLength, pCreateInfo->ppEnabledExtensionNames[i]); if (result != VK_STRING_ERROR_NONE) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_validate_instance_extensions: Instance " - "ppEnabledExtensionNames contains " - "string that is too long or is badly formed"); + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_validate_instance_extensions: Instance " + "ppEnabledExtensionNames contains " + "string that is too long or is badly formed"); return VK_ERROR_EXTENSION_NOT_PRESENT; } @@ -4330,8 +4359,9 @@ VkResult loader_validate_instance_extensions(const struct loader_instance *inst, // If it isn't in the list, return an error if (!found) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_validate_instance_extensions: Extension %d " - "not found in list of available extensions.", + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_validate_instance_extensions: Extension %d " + "not found in list of available extensions.", i); return VK_ERROR_EXTENSION_NOT_PRESENT; } @@ -4364,8 +4394,9 @@ VkResult loader_validate_instance_extensions(const struct loader_instance *inst, if (!extension_prop) { // Didn't find extension name in any of the global layers, error out - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_validate_instance_extensions: Extension %d " - "not found in enabled layer list extensions.", + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_validate_instance_extensions: Extension %d " + "not found in enabled layer list extensions.", i); return VK_ERROR_EXTENSION_NOT_PRESENT; } @@ -4380,12 +4411,12 @@ VkResult loader_validate_device_extensions(struct loader_physical_device_tramp * struct loader_layer_properties *layer_prop; for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { - VkStringErrorFlags result = vk_string_validate(MaxLoaderStringLength, pCreateInfo->ppEnabledExtensionNames[i]); if (result != VK_STRING_ERROR_NONE) { - loader_log(phys_dev->this_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_validate_device_extensions: Device " - "ppEnabledExtensionNames contains " - "string that is too long or is badly formed"); + loader_log(phys_dev->this_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_validate_device_extensions: Device " + "ppEnabledExtensionNames contains " + "string that is too long or is badly formed"); return VK_ERROR_EXTENSION_NOT_PRESENT; } @@ -4409,8 +4440,9 @@ VkResult loader_validate_device_extensions(struct loader_physical_device_tramp * if (!extension_prop) { // Didn't find extension name in any of the device layers, error out - loader_log(phys_dev->this_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_validate_device_extensions: Extension %d " - "not found in enabled layer list extensions.", + loader_log(phys_dev->this_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "loader_validate_device_extensions: Extension %d " + "not found in enabled layer list extensions.", i); return VK_ERROR_EXTENSION_NOT_PRESENT; } @@ -4441,8 +4473,9 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateInstance(const VkInstanceCreateI // just in the same library. filtered_extension_names = loader_stack_alloc(pCreateInfo->enabledExtensionCount * sizeof(char *)); if (!filtered_extension_names) { - loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "terminator_CreateInstance: Failed create extension name " - "array for %d extensions", + loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "terminator_CreateInstance: Failed create extension name " + "array for %d extensions", pCreateInfo->enabledExtensionCount); res = VK_ERROR_OUT_OF_HOST_MEMORY; goto out; @@ -4452,8 +4485,9 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateInstance(const VkInstanceCreateI for (uint32_t i = 0; i < ptr_instance->icd_tramp_list.count; i++) { icd_term = loader_icd_add(ptr_instance, &ptr_instance->icd_tramp_list.scanned_list[i]); if (NULL == icd_term) { - loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "terminator_CreateInstance: Failed to add ICD %d to ICD " - "trampoline list.", + loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "terminator_CreateInstance: Failed to add ICD %d to ICD " + "trampoline list.", i); res = VK_ERROR_OUT_OF_HOST_MEMORY; goto out; @@ -4512,8 +4546,9 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateInstance(const VkInstanceCreateI res = VK_ERROR_OUT_OF_HOST_MEMORY; goto out; } else if (VK_SUCCESS != icd_result) { - loader_log(ptr_instance, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, "terminator_CreateInstance: Failed to CreateInstance in " - "ICD %d. Skipping ICD.", + loader_log(ptr_instance, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, + "terminator_CreateInstance: Failed to CreateInstance in " + "ICD %d. Skipping ICD.", i); ptr_instance->icd_terms = icd_term->next; icd_term->next = NULL; @@ -4670,8 +4705,9 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDevice(VkPhysicalDevice physical filtered_extension_names[localCreateInfo.enabledExtensionCount] = (char *)extension_name; localCreateInfo.enabledExtensionCount++; } else { - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, "vkCreateDevice extension %s not available for " - "devices associated with ICD %s", + loader_log(icd_term->this_instance, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, + "vkCreateDevice extension %s not available for " + "devices associated with ICD %s", extension_name, icd_term->scanned_icd->lib_name); } } @@ -4718,8 +4754,9 @@ VkResult setupLoaderTrampPhysDevs(VkInstance instance) { new_phys_devs = (struct loader_physical_device_tramp **)loader_instance_heap_alloc( inst, total_count * sizeof(struct loader_physical_device_tramp *), VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); if (NULL == new_phys_devs) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "setupLoaderTrampPhysDevs: Failed to allocate new physical device" - " array of size %d", + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "setupLoaderTrampPhysDevs: Failed to allocate new physical device" + " array of size %d", total_count); res = VK_ERROR_OUT_OF_HOST_MEMORY; goto out; @@ -4730,8 +4767,9 @@ VkResult setupLoaderTrampPhysDevs(VkInstance instance) { // returned VkPhysicalDevice values. local_phys_devs = loader_stack_alloc(sizeof(VkPhysicalDevice) * total_count); if (NULL == local_phys_devs) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "setupLoaderTrampPhysDevs: Failed to allocate local " - "physical device array of size %d", + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "setupLoaderTrampPhysDevs: Failed to allocate local " + "physical device array of size %d", total_count); res = VK_ERROR_OUT_OF_HOST_MEMORY; goto out; @@ -4740,15 +4778,15 @@ VkResult setupLoaderTrampPhysDevs(VkInstance instance) { res = inst->disp->layer_inst_disp.EnumeratePhysicalDevices(instance, &total_count, local_phys_devs); if (VK_SUCCESS != res) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "setupLoaderTrampPhysDevs: Failed during dispatch call " - "of \'vkEnumeratePhysicalDevices\' to lower layers or " - "loader."); + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "setupLoaderTrampPhysDevs: Failed during dispatch call " + "of \'vkEnumeratePhysicalDevices\' to lower layers or " + "loader."); goto out; } // Copy or create everything to fill the new array of physical devices for (uint32_t new_idx = 0; new_idx < total_count; new_idx++) { - // Check if this physical device is already in the old buffer for (uint32_t old_idx = 0; old_idx < inst->phys_dev_count_tramp; old_idx++) { if (local_phys_devs[new_idx] == inst->phys_devs_tramp[old_idx]->phys_dev) { @@ -4762,8 +4800,9 @@ VkResult setupLoaderTrampPhysDevs(VkInstance instance) { new_phys_devs[new_idx] = (struct loader_physical_device_tramp *)loader_instance_heap_alloc( inst, sizeof(struct loader_physical_device_tramp), VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); if (NULL == new_phys_devs[new_idx]) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "setupLoaderTrampPhysDevs: Failed to allocate " - "physical device trampoline object %d", + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "setupLoaderTrampPhysDevs: Failed to allocate " + "physical device trampoline object %d", new_idx); total_count = new_idx; res = VK_ERROR_OUT_OF_HOST_MEMORY; @@ -4828,8 +4867,9 @@ VkResult setupLoaderTermPhysDevs(struct loader_instance *inst) { icd_phys_dev_array = (struct loader_phys_dev_per_icd *)loader_stack_alloc(sizeof(struct loader_phys_dev_per_icd) * inst->total_icd_count); if (NULL == icd_phys_dev_array) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "setupLoaderTermPhysDevs: Failed to allocate temporary " - "ICD Physical device info array of size %d", + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "setupLoaderTermPhysDevs: Failed to allocate temporary " + "ICD Physical device info array of size %d", inst->total_gpu_count); res = VK_ERROR_OUT_OF_HOST_MEMORY; goto out; @@ -4842,9 +4882,10 @@ VkResult setupLoaderTermPhysDevs(struct loader_instance *inst) { while (NULL != icd_term) { res = icd_term->EnumeratePhysicalDevices(icd_term->instance, &icd_phys_dev_array[i].count, NULL); if (VK_SUCCESS != res) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "setupLoaderTermPhysDevs: Call to " - "ICD %d's \'vkEnumeratePhysicalDevices\' failed with" - " error 0x%08x", + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "setupLoaderTermPhysDevs: Call to " + "ICD %d's \'vkEnumeratePhysicalDevices\' failed with" + " error 0x%08x", i, res); goto out; } @@ -4852,8 +4893,9 @@ VkResult setupLoaderTermPhysDevs(struct loader_instance *inst) { icd_phys_dev_array[i].phys_devs = (VkPhysicalDevice *)loader_stack_alloc(icd_phys_dev_array[i].count * sizeof(VkPhysicalDevice)); if (NULL == icd_phys_dev_array[i].phys_devs) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "setupLoaderTermPhysDevs: Failed to allocate temporary " - "ICD Physical device array for ICD %d of size %d", + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "setupLoaderTermPhysDevs: Failed to allocate temporary " + "ICD Physical device array for ICD %d of size %d", i, inst->total_gpu_count); res = VK_ERROR_OUT_OF_HOST_MEMORY; goto out; @@ -4872,8 +4914,9 @@ VkResult setupLoaderTermPhysDevs(struct loader_instance *inst) { } if (0 == inst->total_gpu_count) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "setupLoaderTermPhysDevs: Failed to detect any valid" - " GPUs in the current config"); + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "setupLoaderTermPhysDevs: Failed to detect any valid" + " GPUs in the current config"); res = VK_ERROR_INITIALIZATION_FAILED; goto out; } @@ -4881,8 +4924,9 @@ VkResult setupLoaderTermPhysDevs(struct loader_instance *inst) { new_phys_devs = loader_instance_heap_alloc(inst, sizeof(struct loader_physical_device_term *) * inst->total_gpu_count, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); if (NULL == new_phys_devs) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "setupLoaderTermPhysDevs: Failed to allocate new physical" - " device array of size %d", + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "setupLoaderTermPhysDevs: Failed to allocate new physical" + " device array of size %d", inst->total_gpu_count); res = VK_ERROR_OUT_OF_HOST_MEMORY; goto out; @@ -4893,7 +4937,6 @@ VkResult setupLoaderTermPhysDevs(struct loader_instance *inst) { uint32_t idx = 0; for (uint32_t icd_idx = 0; icd_idx < inst->total_icd_count; icd_idx++) { for (uint32_t pd_idx = 0; pd_idx < icd_phys_dev_array[icd_idx].count; pd_idx++) { - // Check if this physical device is already in the old buffer if (NULL != inst->phys_devs_term) { for (uint32_t old_idx = 0; old_idx < inst->phys_dev_count_term; old_idx++) { @@ -4909,8 +4952,9 @@ VkResult setupLoaderTermPhysDevs(struct loader_instance *inst) { new_phys_devs[idx] = loader_instance_heap_alloc(inst, sizeof(struct loader_physical_device_term), VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); if (NULL == new_phys_devs[idx]) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "setupLoaderTermPhysDevs: Failed to allocate " - "physical device terminator object %d", + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "setupLoaderTermPhysDevs: Failed to allocate " + "physical device terminator object %d", idx); inst->total_gpu_count = idx; res = VK_ERROR_OUT_OF_HOST_MEMORY; @@ -5185,8 +5229,9 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_EnumerateDeviceLayerProperties(VkPhysi VkLayerProperties *pProperties) { struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "Encountered the vkEnumerateDeviceLayerProperties " - "terminator. This means a layer improperly continued."); + loader_log(icd_term->this_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "Encountered the vkEnumerateDeviceLayerProperties " + "terminator. This means a layer improperly continued."); // Should never get here this call isn't dispatched down the chain return VK_ERROR_INITIALIZATION_FAILED; } diff --git a/loader/loader.h b/loader/loader.h index e355b55..fb0bc89 100644 --- a/loader/loader.h +++ b/loader/loader.h @@ -135,7 +135,7 @@ struct loader_layer_functions { struct loader_layer_properties { VkLayerProperties info; enum layer_type type; - uint32_t interface_version; // PFN_vkNegotiateLoaderLayerInterfaceVersion + uint32_t interface_version; // PFN_vkNegotiateLoaderLayerInterfaceVersion char lib_name[MAX_STRING_SIZE]; loader_platform_dl_handle lib_handle; struct loader_layer_functions functions; @@ -154,7 +154,7 @@ struct loader_layer_list { struct loader_dispatch_hash_list { size_t capacity; uint32_t count; - uint32_t *index; // index into the dev_ext dispatch table + uint32_t *index; // index into the dev_ext dispatch table }; // loader_dispatch_hash_entry and loader_dev_ext_dispatch_table.dev_ext have @@ -163,7 +163,7 @@ struct loader_dispatch_hash_list { // Also have a one to one correspondence with functions in dev_ext_trampoline.c struct loader_dispatch_hash_entry { char *func_name; - struct loader_dispatch_hash_list list; // to handle hashing collisions + struct loader_dispatch_hash_list list; // to handle hashing collisions }; typedef void(VKAPI_PTR *PFN_vkDevExt)(VkDevice device); @@ -179,8 +179,8 @@ struct loader_dev_dispatch_table { // per CreateDevice structure struct loader_device { struct loader_dev_dispatch_table loader_dispatch; - VkDevice chain_device; // device object from the dispatch chain - VkDevice icd_device; // device object from the icd + VkDevice chain_device; // device object from the dispatch chain + VkDevice icd_device; // device object from the icd struct loader_physical_device_term *phys_dev_term; struct loader_layer_list activated_layer_list; @@ -196,7 +196,7 @@ struct loader_icd_term { const struct loader_scanned_icd *scanned_icd; const struct loader_instance *this_instance; struct loader_device *logical_device_list; - VkInstance instance; // instance object from the icd + VkInstance instance; // instance object from the icd PFN_vkGetDeviceProcAddr GetDeviceProcAddr; PFN_vkDestroyInstance DestroyInstance; PFN_vkEnumeratePhysicalDevices EnumeratePhysicalDevices; @@ -306,7 +306,7 @@ union loader_instance_extension_enables { }; struct loader_instance_dispatch_table { - VkLayerInstanceDispatchTable layer_inst_disp; // must be first entry in structure + VkLayerInstanceDispatchTable layer_inst_disp; // must be first entry in structure // Physical device functions unknown to the loader PFN_PhysDevExt phys_dev_ext[MAX_NUM_UNKNOWN_EXTS]; @@ -314,7 +314,7 @@ struct loader_instance_dispatch_table { // per instance structure struct loader_instance { - struct loader_instance_dispatch_table *disp; // must be first entry in structure + struct loader_instance_dispatch_table *disp; // must be first entry in structure uint32_t total_gpu_count; uint32_t phys_dev_count_term; @@ -336,9 +336,9 @@ struct loader_instance { struct loader_layer_list instance_layer_list; struct loader_layer_list activated_layer_list; bool activated_layers_are_std_val; - VkInstance instance; // layers/ICD instance returned to trampoline + VkInstance instance; // layers/ICD instance returned to trampoline - struct loader_extension_list ext_list; // icds and loaders extensions + struct loader_extension_list ext_list; // icds and loaders extensions union loader_instance_extension_enables enabled_known_extensions; VkLayerDbgFunctionNode *DbgFunctionHead; @@ -385,17 +385,17 @@ struct loader_instance { /* per enumerated PhysicalDevice structure, used to wrap in trampoline code and also same structure used to wrap in terminator code */ struct loader_physical_device_tramp { - struct loader_instance_dispatch_table *disp; // must be first entry in structure + struct loader_instance_dispatch_table *disp; // must be first entry in structure struct loader_instance *this_instance; - VkPhysicalDevice phys_dev; // object from layers/loader terminator + VkPhysicalDevice phys_dev; // object from layers/loader terminator }; /* per enumerated PhysicalDevice structure, used to wrap in terminator code */ struct loader_physical_device_term { - struct loader_instance_dispatch_table *disp; // must be first entry in structure + struct loader_instance_dispatch_table *disp; // must be first entry in structure struct loader_icd_term *this_icd_term; uint8_t icd_index; - VkPhysicalDevice phys_dev; // object from ICD + VkPhysicalDevice phys_dev; // object from ICD }; struct loader_struct { @@ -438,8 +438,9 @@ static inline struct loader_instance_dispatch_table *loader_get_instance_dispatc static inline void loader_init_dispatch(void *obj, const void *data) { #ifdef DEBUG - assert(valid_loader_magic_value(obj) && "Incompatible ICD, first dword must be initialized to " - "ICD_LOADER_MAGIC. See loader/README.md for details."); + assert(valid_loader_magic_value(obj) && + "Incompatible ICD, first dword must be initialized to " + "ICD_LOADER_MAGIC. See loader/README.md for details."); #endif loader_set_dispatch(obj, data); diff --git a/loader/murmurhash.c b/loader/murmurhash.c index 5e5d0de..db6276f 100644 --- a/loader/murmurhash.c +++ b/loader/murmurhash.c @@ -41,16 +41,16 @@ uint32_t murmurhash(const char *key, size_t len, uint32_t seed) { uint32_t n = 0xe6546b64; uint32_t h = 0; uint32_t k = 0; - uint8_t *d = (uint8_t *)key; // 32 bit extract from `key' + uint8_t *d = (uint8_t *)key; // 32 bit extract from `key' const uint32_t *chunks = NULL; - const uint8_t *tail = NULL; // tail - last 8 bytes + const uint8_t *tail = NULL; // tail - last 8 bytes int i = 0; - int l = (int)len / 4; // chunk length + int l = (int)len / 4; // chunk length h = seed; - chunks = (const uint32_t *)(d + l * 4); // body - tail = (const uint8_t *)(d + l * 4); // last 8 byte chunk of `key' + chunks = (const uint32_t *)(d + l * 4); // body + tail = (const uint8_t *)(d + l * 4); // last 8 byte chunk of `key' // for each 4 byte chunk of `key' for (i = -l; i != 0; ++i) { @@ -71,18 +71,18 @@ uint32_t murmurhash(const char *key, size_t len, uint32_t seed) { k = 0; // remainder - switch (len & 3) { // `len % 4' - case 3: - k ^= (tail[2] << 16); - case 2: - k ^= (tail[1] << 8); + switch (len & 3) { // `len % 4' + case 3: + k ^= (tail[2] << 16); + case 2: + k ^= (tail[1] << 8); - case 1: - k ^= tail[0]; - k *= c1; - k = (k << r1) | (k >> (32 - r1)); - k *= c2; - h ^= k; + case 1: + k ^= tail[0]; + k *= c1; + k = (k << r1) | (k >> (32 - r1)); + k *= c2; + h ^= k; } h ^= len; diff --git a/loader/phys_dev_ext.c b/loader/phys_dev_ext.c index cf2ada5..d668b1b 100644 --- a/loader/phys_dev_ext.c +++ b/loader/phys_dev_ext.c @@ -30,28 +30,28 @@ #include "loader.h" #if defined(__GNUC__) && !defined(__clang__) -#pragma GCC optimize(3) // force gcc to use tail-calls +#pragma GCC optimize(3) // force gcc to use tail-calls #endif // Trampoline function macro for unknown physical device extension command. -#define PhysDevExtTramp(num) \ - VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp##num(VkPhysicalDevice physical_device) { \ - const struct loader_instance_dispatch_table *disp; \ - disp = loader_get_instance_dispatch(physical_device); \ - disp->phys_dev_ext[num](loader_unwrap_physical_device(physical_device)); \ +#define PhysDevExtTramp(num) \ + VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp##num(VkPhysicalDevice physical_device) { \ + const struct loader_instance_dispatch_table *disp; \ + disp = loader_get_instance_dispatch(physical_device); \ + disp->phys_dev_ext[num](loader_unwrap_physical_device(physical_device)); \ } // Terminator function macro for unknown physical device extension command. -#define PhysDevExtTermin(num) \ - VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin##num(VkPhysicalDevice physical_device) { \ - struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physical_device; \ - struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; \ - struct loader_instance *inst = (struct loader_instance *)icd_term->this_instance; \ - if (NULL == icd_term->phys_dev_ext[num]) { \ - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "Extension %s not supported for this physical device", \ - inst->phys_dev_ext_disp_hash[num].func_name); \ - } \ - icd_term->phys_dev_ext[num](phys_dev_term->phys_dev); \ +#define PhysDevExtTermin(num) \ + VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin##num(VkPhysicalDevice physical_device) { \ + struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physical_device; \ + struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; \ + struct loader_instance *inst = (struct loader_instance *)icd_term->this_instance; \ + if (NULL == icd_term->phys_dev_ext[num]) { \ + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "Extension %s not supported for this physical device", \ + inst->phys_dev_ext_disp_hash[num].func_name); \ + } \ + icd_term->phys_dev_ext[num](phys_dev_term->phys_dev); \ } // Disable clang-format for lists of macros diff --git a/loader/table_ops.h b/loader/table_ops.h index 15a7e99..cb4f622 100644 --- a/loader/table_ops.h +++ b/loader/table_ops.h @@ -44,8 +44,7 @@ static VkResult VKAPI_CALL vkDevExtError(VkDevice dev) { static inline void loader_init_device_dispatch_table(struct loader_dev_dispatch_table *dev_table, PFN_vkGetDeviceProcAddr gpa, VkDevice dev) { VkLayerDispatchTable *table = &dev_table->core_dispatch; - for (uint32_t i = 0; i < MAX_NUM_UNKNOWN_EXTS; i++) - dev_table->ext_dispatch.dev_ext[i] = (PFN_vkDevExt)vkDevExtError; + for (uint32_t i = 0; i < MAX_NUM_UNKNOWN_EXTS; i++) dev_table->ext_dispatch.dev_ext[i] = (PFN_vkDevExt)vkDevExtError; table->GetDeviceProcAddr = (PFN_vkGetDeviceProcAddr)gpa(dev, "vkGetDeviceProcAddr"); table->DestroyDevice = (PFN_vkDestroyDevice)gpa(dev, "vkDestroyDevice"); @@ -221,260 +220,134 @@ static inline void loader_init_device_extension_dispatch_table(struct loader_dev } static inline void *loader_lookup_device_dispatch_table(const VkLayerDispatchTable *table, const char *name) { - if (!name || name[0] != 'v' || name[1] != 'k') - return NULL; + if (!name || name[0] != 'v' || name[1] != 'k') return NULL; name += 2; - if (!strcmp(name, "GetDeviceProcAddr")) - return (void *)table->GetDeviceProcAddr; - if (!strcmp(name, "DestroyDevice")) - return (void *)table->DestroyDevice; - if (!strcmp(name, "GetDeviceQueue")) - return (void *)table->GetDeviceQueue; - if (!strcmp(name, "QueueSubmit")) - return (void *)table->QueueSubmit; - if (!strcmp(name, "QueueWaitIdle")) - return (void *)table->QueueWaitIdle; - if (!strcmp(name, "DeviceWaitIdle")) - return (void *)table->DeviceWaitIdle; - if (!strcmp(name, "AllocateMemory")) - return (void *)table->AllocateMemory; - if (!strcmp(name, "FreeMemory")) - return (void *)table->FreeMemory; - if (!strcmp(name, "MapMemory")) - return (void *)table->MapMemory; - if (!strcmp(name, "UnmapMemory")) - return (void *)table->UnmapMemory; - if (!strcmp(name, "FlushMappedMemoryRanges")) - return (void *)table->FlushMappedMemoryRanges; - if (!strcmp(name, "InvalidateMappedMemoryRanges")) - return (void *)table->InvalidateMappedMemoryRanges; - if (!strcmp(name, "GetDeviceMemoryCommitment")) - return (void *)table->GetDeviceMemoryCommitment; - if (!strcmp(name, "GetImageSparseMemoryRequirements")) - return (void *)table->GetImageSparseMemoryRequirements; - if (!strcmp(name, "GetBufferMemoryRequirements")) - return (void *)table->GetBufferMemoryRequirements; - if (!strcmp(name, "GetImageMemoryRequirements")) - return (void *)table->GetImageMemoryRequirements; - if (!strcmp(name, "BindBufferMemory")) - return (void *)table->BindBufferMemory; - if (!strcmp(name, "BindImageMemory")) - return (void *)table->BindImageMemory; - if (!strcmp(name, "QueueBindSparse")) - return (void *)table->QueueBindSparse; - if (!strcmp(name, "CreateFence")) - return (void *)table->CreateFence; - if (!strcmp(name, "DestroyFence")) - return (void *)table->DestroyFence; - if (!strcmp(name, "ResetFences")) - return (void *)table->ResetFences; - if (!strcmp(name, "GetFenceStatus")) - return (void *)table->GetFenceStatus; - if (!strcmp(name, "WaitForFences")) - return (void *)table->WaitForFences; - if (!strcmp(name, "CreateSemaphore")) - return (void *)table->CreateSemaphore; - if (!strcmp(name, "DestroySemaphore")) - return (void *)table->DestroySemaphore; - if (!strcmp(name, "CreateEvent")) - return (void *)table->CreateEvent; - if (!strcmp(name, "DestroyEvent")) - return (void *)table->DestroyEvent; - if (!strcmp(name, "GetEventStatus")) - return (void *)table->GetEventStatus; - if (!strcmp(name, "SetEvent")) - return (void *)table->SetEvent; - if (!strcmp(name, "ResetEvent")) - return (void *)table->ResetEvent; - if (!strcmp(name, "CreateQueryPool")) - return (void *)table->CreateQueryPool; - if (!strcmp(name, "DestroyQueryPool")) - return (void *)table->DestroyQueryPool; - if (!strcmp(name, "GetQueryPoolResults")) - return (void *)table->GetQueryPoolResults; - if (!strcmp(name, "CreateBuffer")) - return (void *)table->CreateBuffer; - if (!strcmp(name, "DestroyBuffer")) - return (void *)table->DestroyBuffer; - if (!strcmp(name, "CreateBufferView")) - return (void *)table->CreateBufferView; - if (!strcmp(name, "DestroyBufferView")) - return (void *)table->DestroyBufferView; - if (!strcmp(name, "CreateImage")) - return (void *)table->CreateImage; - if (!strcmp(name, "DestroyImage")) - return (void *)table->DestroyImage; - if (!strcmp(name, "GetImageSubresourceLayout")) - return (void *)table->GetImageSubresourceLayout; - if (!strcmp(name, "CreateImageView")) - return (void *)table->CreateImageView; - if (!strcmp(name, "DestroyImageView")) - return (void *)table->DestroyImageView; - if (!strcmp(name, "CreateShaderModule")) - return (void *)table->CreateShaderModule; - if (!strcmp(name, "DestroyShaderModule")) - return (void *)table->DestroyShaderModule; - if (!strcmp(name, "CreatePipelineCache")) - return (void *)vkCreatePipelineCache; - if (!strcmp(name, "DestroyPipelineCache")) - return (void *)vkDestroyPipelineCache; - if (!strcmp(name, "GetPipelineCacheData")) - return (void *)vkGetPipelineCacheData; - if (!strcmp(name, "MergePipelineCaches")) - return (void *)vkMergePipelineCaches; - if (!strcmp(name, "CreateGraphicsPipelines")) - return (void *)vkCreateGraphicsPipelines; - if (!strcmp(name, "CreateComputePipelines")) - return (void *)vkCreateComputePipelines; - if (!strcmp(name, "DestroyPipeline")) - return (void *)table->DestroyPipeline; - if (!strcmp(name, "CreatePipelineLayout")) - return (void *)table->CreatePipelineLayout; - if (!strcmp(name, "DestroyPipelineLayout")) - return (void *)table->DestroyPipelineLayout; - if (!strcmp(name, "CreateSampler")) - return (void *)table->CreateSampler; - if (!strcmp(name, "DestroySampler")) - return (void *)table->DestroySampler; - if (!strcmp(name, "CreateDescriptorSetLayout")) - return (void *)table->CreateDescriptorSetLayout; - if (!strcmp(name, "DestroyDescriptorSetLayout")) - return (void *)table->DestroyDescriptorSetLayout; - if (!strcmp(name, "CreateDescriptorPool")) - return (void *)table->CreateDescriptorPool; - if (!strcmp(name, "DestroyDescriptorPool")) - return (void *)table->DestroyDescriptorPool; - if (!strcmp(name, "ResetDescriptorPool")) - return (void *)table->ResetDescriptorPool; - if (!strcmp(name, "AllocateDescriptorSets")) - return (void *)table->AllocateDescriptorSets; - if (!strcmp(name, "FreeDescriptorSets")) - return (void *)table->FreeDescriptorSets; - if (!strcmp(name, "UpdateDescriptorSets")) - return (void *)table->UpdateDescriptorSets; - if (!strcmp(name, "CreateFramebuffer")) - return (void *)table->CreateFramebuffer; - if (!strcmp(name, "DestroyFramebuffer")) - return (void *)table->DestroyFramebuffer; - if (!strcmp(name, "CreateRenderPass")) - return (void *)table->CreateRenderPass; - if (!strcmp(name, "DestroyRenderPass")) - return (void *)table->DestroyRenderPass; - if (!strcmp(name, "GetRenderAreaGranularity")) - return (void *)table->GetRenderAreaGranularity; - if (!strcmp(name, "CreateCommandPool")) - return (void *)table->CreateCommandPool; - if (!strcmp(name, "DestroyCommandPool")) - return (void *)table->DestroyCommandPool; - if (!strcmp(name, "ResetCommandPool")) - return (void *)table->ResetCommandPool; - if (!strcmp(name, "AllocateCommandBuffers")) - return (void *)table->AllocateCommandBuffers; - if (!strcmp(name, "FreeCommandBuffers")) - return (void *)table->FreeCommandBuffers; - if (!strcmp(name, "BeginCommandBuffer")) - return (void *)table->BeginCommandBuffer; - if (!strcmp(name, "EndCommandBuffer")) - return (void *)table->EndCommandBuffer; - if (!strcmp(name, "ResetCommandBuffer")) - return (void *)table->ResetCommandBuffer; - if (!strcmp(name, "CmdBindPipeline")) - return (void *)table->CmdBindPipeline; - if (!strcmp(name, "CmdSetViewport")) - return (void *)table->CmdSetViewport; - if (!strcmp(name, "CmdSetScissor")) - return (void *)table->CmdSetScissor; - if (!strcmp(name, "CmdSetLineWidth")) - return (void *)table->CmdSetLineWidth; - if (!strcmp(name, "CmdSetDepthBias")) - return (void *)table->CmdSetDepthBias; - if (!strcmp(name, "CmdSetBlendConstants")) - return (void *)table->CmdSetBlendConstants; - if (!strcmp(name, "CmdSetDepthBounds")) - return (void *)table->CmdSetDepthBounds; - if (!strcmp(name, "CmdSetStencilCompareMask")) - return (void *)table->CmdSetStencilCompareMask; - if (!strcmp(name, "CmdSetStencilwriteMask")) - return (void *)table->CmdSetStencilWriteMask; - if (!strcmp(name, "CmdSetStencilReference")) - return (void *)table->CmdSetStencilReference; - if (!strcmp(name, "CmdBindDescriptorSets")) - return (void *)table->CmdBindDescriptorSets; - if (!strcmp(name, "CmdBindVertexBuffers")) - return (void *)table->CmdBindVertexBuffers; - if (!strcmp(name, "CmdBindIndexBuffer")) - return (void *)table->CmdBindIndexBuffer; - if (!strcmp(name, "CmdDraw")) - return (void *)table->CmdDraw; - if (!strcmp(name, "CmdDrawIndexed")) - return (void *)table->CmdDrawIndexed; - if (!strcmp(name, "CmdDrawIndirect")) - return (void *)table->CmdDrawIndirect; - if (!strcmp(name, "CmdDrawIndexedIndirect")) - return (void *)table->CmdDrawIndexedIndirect; - if (!strcmp(name, "CmdDispatch")) - return (void *)table->CmdDispatch; - if (!strcmp(name, "CmdDispatchIndirect")) - return (void *)table->CmdDispatchIndirect; - if (!strcmp(name, "CmdCopyBuffer")) - return (void *)table->CmdCopyBuffer; - if (!strcmp(name, "CmdCopyImage")) - return (void *)table->CmdCopyImage; - if (!strcmp(name, "CmdBlitImage")) - return (void *)table->CmdBlitImage; - if (!strcmp(name, "CmdCopyBufferToImage")) - return (void *)table->CmdCopyBufferToImage; - if (!strcmp(name, "CmdCopyImageToBuffer")) - return (void *)table->CmdCopyImageToBuffer; - if (!strcmp(name, "CmdUpdateBuffer")) - return (void *)table->CmdUpdateBuffer; - if (!strcmp(name, "CmdFillBuffer")) - return (void *)table->CmdFillBuffer; - if (!strcmp(name, "CmdClearColorImage")) - return (void *)table->CmdClearColorImage; - if (!strcmp(name, "CmdClearDepthStencilImage")) - return (void *)table->CmdClearDepthStencilImage; - if (!strcmp(name, "CmdClearAttachments")) - return (void *)table->CmdClearAttachments; - if (!strcmp(name, "CmdResolveImage")) - return (void *)table->CmdResolveImage; - if (!strcmp(name, "CmdSetEvent")) - return (void *)table->CmdSetEvent; - if (!strcmp(name, "CmdResetEvent")) - return (void *)table->CmdResetEvent; - if (!strcmp(name, "CmdWaitEvents")) - return (void *)table->CmdWaitEvents; - if (!strcmp(name, "CmdPipelineBarrier")) - return (void *)table->CmdPipelineBarrier; - if (!strcmp(name, "CmdBeginQuery")) - return (void *)table->CmdBeginQuery; - if (!strcmp(name, "CmdEndQuery")) - return (void *)table->CmdEndQuery; - if (!strcmp(name, "CmdResetQueryPool")) - return (void *)table->CmdResetQueryPool; - if (!strcmp(name, "CmdWriteTimestamp")) - return (void *)table->CmdWriteTimestamp; - if (!strcmp(name, "CmdCopyQueryPoolResults")) - return (void *)table->CmdCopyQueryPoolResults; - if (!strcmp(name, "CmdPushConstants")) - return (void *)table->CmdPushConstants; - if (!strcmp(name, "CmdBeginRenderPass")) - return (void *)table->CmdBeginRenderPass; - if (!strcmp(name, "CmdNextSubpass")) - return (void *)table->CmdNextSubpass; - if (!strcmp(name, "CmdEndRenderPass")) - return (void *)table->CmdEndRenderPass; - if (!strcmp(name, "CmdExecuteCommands")) - return (void *)table->CmdExecuteCommands; - if (!strcmp(name, "DestroySwapchainKHR")) - return (void *)table->DestroySwapchainKHR; - if (!strcmp(name, "GetSwapchainImagesKHR")) - return (void *)table->GetSwapchainImagesKHR; - if (!strcmp(name, "AcquireNextImageKHR")) - return (void *)table->AcquireNextImageKHR; - if (!strcmp(name, "QueuePresentKHR")) - return (void *)table->QueuePresentKHR; + if (!strcmp(name, "GetDeviceProcAddr")) return (void *)table->GetDeviceProcAddr; + if (!strcmp(name, "DestroyDevice")) return (void *)table->DestroyDevice; + if (!strcmp(name, "GetDeviceQueue")) return (void *)table->GetDeviceQueue; + if (!strcmp(name, "QueueSubmit")) return (void *)table->QueueSubmit; + if (!strcmp(name, "QueueWaitIdle")) return (void *)table->QueueWaitIdle; + if (!strcmp(name, "DeviceWaitIdle")) return (void *)table->DeviceWaitIdle; + if (!strcmp(name, "AllocateMemory")) return (void *)table->AllocateMemory; + if (!strcmp(name, "FreeMemory")) return (void *)table->FreeMemory; + if (!strcmp(name, "MapMemory")) return (void *)table->MapMemory; + if (!strcmp(name, "UnmapMemory")) return (void *)table->UnmapMemory; + if (!strcmp(name, "FlushMappedMemoryRanges")) return (void *)table->FlushMappedMemoryRanges; + if (!strcmp(name, "InvalidateMappedMemoryRanges")) return (void *)table->InvalidateMappedMemoryRanges; + if (!strcmp(name, "GetDeviceMemoryCommitment")) return (void *)table->GetDeviceMemoryCommitment; + if (!strcmp(name, "GetImageSparseMemoryRequirements")) return (void *)table->GetImageSparseMemoryRequirements; + if (!strcmp(name, "GetBufferMemoryRequirements")) return (void *)table->GetBufferMemoryRequirements; + if (!strcmp(name, "GetImageMemoryRequirements")) return (void *)table->GetImageMemoryRequirements; + if (!strcmp(name, "BindBufferMemory")) return (void *)table->BindBufferMemory; + if (!strcmp(name, "BindImageMemory")) return (void *)table->BindImageMemory; + if (!strcmp(name, "QueueBindSparse")) return (void *)table->QueueBindSparse; + if (!strcmp(name, "CreateFence")) return (void *)table->CreateFence; + if (!strcmp(name, "DestroyFence")) return (void *)table->DestroyFence; + if (!strcmp(name, "ResetFences")) return (void *)table->ResetFences; + if (!strcmp(name, "GetFenceStatus")) return (void *)table->GetFenceStatus; + if (!strcmp(name, "WaitForFences")) return (void *)table->WaitForFences; + if (!strcmp(name, "CreateSemaphore")) return (void *)table->CreateSemaphore; + if (!strcmp(name, "DestroySemaphore")) return (void *)table->DestroySemaphore; + if (!strcmp(name, "CreateEvent")) return (void *)table->CreateEvent; + if (!strcmp(name, "DestroyEvent")) return (void *)table->DestroyEvent; + if (!strcmp(name, "GetEventStatus")) return (void *)table->GetEventStatus; + if (!strcmp(name, "SetEvent")) return (void *)table->SetEvent; + if (!strcmp(name, "ResetEvent")) return (void *)table->ResetEvent; + if (!strcmp(name, "CreateQueryPool")) return (void *)table->CreateQueryPool; + if (!strcmp(name, "DestroyQueryPool")) return (void *)table->DestroyQueryPool; + if (!strcmp(name, "GetQueryPoolResults")) return (void *)table->GetQueryPoolResults; + if (!strcmp(name, "CreateBuffer")) return (void *)table->CreateBuffer; + if (!strcmp(name, "DestroyBuffer")) return (void *)table->DestroyBuffer; + if (!strcmp(name, "CreateBufferView")) return (void *)table->CreateBufferView; + if (!strcmp(name, "DestroyBufferView")) return (void *)table->DestroyBufferView; + if (!strcmp(name, "CreateImage")) return (void *)table->CreateImage; + if (!strcmp(name, "DestroyImage")) return (void *)table->DestroyImage; + if (!strcmp(name, "GetImageSubresourceLayout")) return (void *)table->GetImageSubresourceLayout; + if (!strcmp(name, "CreateImageView")) return (void *)table->CreateImageView; + if (!strcmp(name, "DestroyImageView")) return (void *)table->DestroyImageView; + if (!strcmp(name, "CreateShaderModule")) return (void *)table->CreateShaderModule; + if (!strcmp(name, "DestroyShaderModule")) return (void *)table->DestroyShaderModule; + if (!strcmp(name, "CreatePipelineCache")) return (void *)vkCreatePipelineCache; + if (!strcmp(name, "DestroyPipelineCache")) return (void *)vkDestroyPipelineCache; + if (!strcmp(name, "GetPipelineCacheData")) return (void *)vkGetPipelineCacheData; + if (!strcmp(name, "MergePipelineCaches")) return (void *)vkMergePipelineCaches; + if (!strcmp(name, "CreateGraphicsPipelines")) return (void *)vkCreateGraphicsPipelines; + if (!strcmp(name, "CreateComputePipelines")) return (void *)vkCreateComputePipelines; + if (!strcmp(name, "DestroyPipeline")) return (void *)table->DestroyPipeline; + if (!strcmp(name, "CreatePipelineLayout")) return (void *)table->CreatePipelineLayout; + if (!strcmp(name, "DestroyPipelineLayout")) return (void *)table->DestroyPipelineLayout; + if (!strcmp(name, "CreateSampler")) return (void *)table->CreateSampler; + if (!strcmp(name, "DestroySampler")) return (void *)table->DestroySampler; + if (!strcmp(name, "CreateDescriptorSetLayout")) return (void *)table->CreateDescriptorSetLayout; + if (!strcmp(name, "DestroyDescriptorSetLayout")) return (void *)table->DestroyDescriptorSetLayout; + if (!strcmp(name, "CreateDescriptorPool")) return (void *)table->CreateDescriptorPool; + if (!strcmp(name, "DestroyDescriptorPool")) return (void *)table->DestroyDescriptorPool; + if (!strcmp(name, "ResetDescriptorPool")) return (void *)table->ResetDescriptorPool; + if (!strcmp(name, "AllocateDescriptorSets")) return (void *)table->AllocateDescriptorSets; + if (!strcmp(name, "FreeDescriptorSets")) return (void *)table->FreeDescriptorSets; + if (!strcmp(name, "UpdateDescriptorSets")) return (void *)table->UpdateDescriptorSets; + if (!strcmp(name, "CreateFramebuffer")) return (void *)table->CreateFramebuffer; + if (!strcmp(name, "DestroyFramebuffer")) return (void *)table->DestroyFramebuffer; + if (!strcmp(name, "CreateRenderPass")) return (void *)table->CreateRenderPass; + if (!strcmp(name, "DestroyRenderPass")) return (void *)table->DestroyRenderPass; + if (!strcmp(name, "GetRenderAreaGranularity")) return (void *)table->GetRenderAreaGranularity; + if (!strcmp(name, "CreateCommandPool")) return (void *)table->CreateCommandPool; + if (!strcmp(name, "DestroyCommandPool")) return (void *)table->DestroyCommandPool; + if (!strcmp(name, "ResetCommandPool")) return (void *)table->ResetCommandPool; + if (!strcmp(name, "AllocateCommandBuffers")) return (void *)table->AllocateCommandBuffers; + if (!strcmp(name, "FreeCommandBuffers")) return (void *)table->FreeCommandBuffers; + if (!strcmp(name, "BeginCommandBuffer")) return (void *)table->BeginCommandBuffer; + if (!strcmp(name, "EndCommandBuffer")) return (void *)table->EndCommandBuffer; + if (!strcmp(name, "ResetCommandBuffer")) return (void *)table->ResetCommandBuffer; + if (!strcmp(name, "CmdBindPipeline")) return (void *)table->CmdBindPipeline; + if (!strcmp(name, "CmdSetViewport")) return (void *)table->CmdSetViewport; + if (!strcmp(name, "CmdSetScissor")) return (void *)table->CmdSetScissor; + if (!strcmp(name, "CmdSetLineWidth")) return (void *)table->CmdSetLineWidth; + if (!strcmp(name, "CmdSetDepthBias")) return (void *)table->CmdSetDepthBias; + if (!strcmp(name, "CmdSetBlendConstants")) return (void *)table->CmdSetBlendConstants; + if (!strcmp(name, "CmdSetDepthBounds")) return (void *)table->CmdSetDepthBounds; + if (!strcmp(name, "CmdSetStencilCompareMask")) return (void *)table->CmdSetStencilCompareMask; + if (!strcmp(name, "CmdSetStencilwriteMask")) return (void *)table->CmdSetStencilWriteMask; + if (!strcmp(name, "CmdSetStencilReference")) return (void *)table->CmdSetStencilReference; + if (!strcmp(name, "CmdBindDescriptorSets")) return (void *)table->CmdBindDescriptorSets; + if (!strcmp(name, "CmdBindVertexBuffers")) return (void *)table->CmdBindVertexBuffers; + if (!strcmp(name, "CmdBindIndexBuffer")) return (void *)table->CmdBindIndexBuffer; + if (!strcmp(name, "CmdDraw")) return (void *)table->CmdDraw; + if (!strcmp(name, "CmdDrawIndexed")) return (void *)table->CmdDrawIndexed; + if (!strcmp(name, "CmdDrawIndirect")) return (void *)table->CmdDrawIndirect; + if (!strcmp(name, "CmdDrawIndexedIndirect")) return (void *)table->CmdDrawIndexedIndirect; + if (!strcmp(name, "CmdDispatch")) return (void *)table->CmdDispatch; + if (!strcmp(name, "CmdDispatchIndirect")) return (void *)table->CmdDispatchIndirect; + if (!strcmp(name, "CmdCopyBuffer")) return (void *)table->CmdCopyBuffer; + if (!strcmp(name, "CmdCopyImage")) return (void *)table->CmdCopyImage; + if (!strcmp(name, "CmdBlitImage")) return (void *)table->CmdBlitImage; + if (!strcmp(name, "CmdCopyBufferToImage")) return (void *)table->CmdCopyBufferToImage; + if (!strcmp(name, "CmdCopyImageToBuffer")) return (void *)table->CmdCopyImageToBuffer; + if (!strcmp(name, "CmdUpdateBuffer")) return (void *)table->CmdUpdateBuffer; + if (!strcmp(name, "CmdFillBuffer")) return (void *)table->CmdFillBuffer; + if (!strcmp(name, "CmdClearColorImage")) return (void *)table->CmdClearColorImage; + if (!strcmp(name, "CmdClearDepthStencilImage")) return (void *)table->CmdClearDepthStencilImage; + if (!strcmp(name, "CmdClearAttachments")) return (void *)table->CmdClearAttachments; + if (!strcmp(name, "CmdResolveImage")) return (void *)table->CmdResolveImage; + if (!strcmp(name, "CmdSetEvent")) return (void *)table->CmdSetEvent; + if (!strcmp(name, "CmdResetEvent")) return (void *)table->CmdResetEvent; + if (!strcmp(name, "CmdWaitEvents")) return (void *)table->CmdWaitEvents; + if (!strcmp(name, "CmdPipelineBarrier")) return (void *)table->CmdPipelineBarrier; + if (!strcmp(name, "CmdBeginQuery")) return (void *)table->CmdBeginQuery; + if (!strcmp(name, "CmdEndQuery")) return (void *)table->CmdEndQuery; + if (!strcmp(name, "CmdResetQueryPool")) return (void *)table->CmdResetQueryPool; + if (!strcmp(name, "CmdWriteTimestamp")) return (void *)table->CmdWriteTimestamp; + if (!strcmp(name, "CmdCopyQueryPoolResults")) return (void *)table->CmdCopyQueryPoolResults; + if (!strcmp(name, "CmdPushConstants")) return (void *)table->CmdPushConstants; + if (!strcmp(name, "CmdBeginRenderPass")) return (void *)table->CmdBeginRenderPass; + if (!strcmp(name, "CmdNextSubpass")) return (void *)table->CmdNextSubpass; + if (!strcmp(name, "CmdEndRenderPass")) return (void *)table->CmdEndRenderPass; + if (!strcmp(name, "CmdExecuteCommands")) return (void *)table->CmdExecuteCommands; + if (!strcmp(name, "DestroySwapchainKHR")) return (void *)table->DestroySwapchainKHR; + if (!strcmp(name, "GetSwapchainImagesKHR")) return (void *)table->GetSwapchainImagesKHR; + if (!strcmp(name, "AcquireNextImageKHR")) return (void *)table->AcquireNextImageKHR; + if (!strcmp(name, "QueuePresentKHR")) return (void *)table->QueuePresentKHR; // NOTE: Device Funcs needing Trampoline/Terminator. // Overrides for device functions needing a trampoline and @@ -608,48 +481,36 @@ static inline void loader_init_instance_extension_dispatch_table(VkLayerInstance static inline void *loader_lookup_instance_extension_dispatch_table(const VkLayerInstanceDispatchTable *table, const char *name, bool *found_name) { - *found_name = true; // KHR_get_physical_device_properties2 - if (!strcmp(name, "GetPhysicalDeviceFeatures2KHR")) - return (void *)table->GetPhysicalDeviceFeatures2KHR; - if (!strcmp(name, "GetPhysicalDeviceProperties2KHR")) - return (void *)table->GetPhysicalDeviceProperties2KHR; - if (!strcmp(name, "GetPhysicalDeviceFormatProperties2KHR")) - return (void *)table->GetPhysicalDeviceFormatProperties2KHR; + if (!strcmp(name, "GetPhysicalDeviceFeatures2KHR")) return (void *)table->GetPhysicalDeviceFeatures2KHR; + if (!strcmp(name, "GetPhysicalDeviceProperties2KHR")) return (void *)table->GetPhysicalDeviceProperties2KHR; + if (!strcmp(name, "GetPhysicalDeviceFormatProperties2KHR")) return (void *)table->GetPhysicalDeviceFormatProperties2KHR; if (!strcmp(name, "GetPhysicalDeviceImageFormatProperties2KHR")) return (void *)table->GetPhysicalDeviceImageFormatProperties2KHR; if (!strcmp(name, "GetPhysicalDeviceQueueFamilyProperties2KHR")) return (void *)table->GetPhysicalDeviceQueueFamilyProperties2KHR; - if (!strcmp(name, "GetPhysicalDeviceMemoryProperties2KHR")) - return (void *)table->GetPhysicalDeviceMemoryProperties2KHR; + if (!strcmp(name, "GetPhysicalDeviceMemoryProperties2KHR")) return (void *)table->GetPhysicalDeviceMemoryProperties2KHR; if (!strcmp(name, "GetPhysicalDeviceSparseImageFormatProperties2KHR")) return (void *)table->GetPhysicalDeviceSparseImageFormatProperties2KHR; // EXT_acquire_xlib_display #ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT - if (!strcmp(name, "AcquireXlibDisplayEXT")) - return (void *)table->AcquireXlibDisplayEXT; - if (!strcmp(name, "GetRandROutputDisplayEXT")) - return (void *)table->GetRandROutputDisplayEXT; + if (!strcmp(name, "AcquireXlibDisplayEXT")) return (void *)table->AcquireXlibDisplayEXT; + if (!strcmp(name, "GetRandROutputDisplayEXT")) return (void *)table->GetRandROutputDisplayEXT; #endif // EXT_debug_report - if (!strcmp(name, "CreateDebugReportCallbackEXT")) - return (void *)table->CreateDebugReportCallbackEXT; - if (!strcmp(name, "DestroyDebugReportCallbackEXT")) - return (void *)table->DestroyDebugReportCallbackEXT; - if (!strcmp(name, "DebugReportMessageEXT")) - return (void *)table->DebugReportMessageEXT; + if (!strcmp(name, "CreateDebugReportCallbackEXT")) return (void *)table->CreateDebugReportCallbackEXT; + if (!strcmp(name, "DestroyDebugReportCallbackEXT")) return (void *)table->DestroyDebugReportCallbackEXT; + if (!strcmp(name, "DebugReportMessageEXT")) return (void *)table->DebugReportMessageEXT; // EXT_direct_mode_display - if (!strcmp(name, "ReleaseDisplayEXT")) - return (void *)table->ReleaseDisplayEXT; + if (!strcmp(name, "ReleaseDisplayEXT")) return (void *)table->ReleaseDisplayEXT; // EXT_display_surface_counter - if (!strcmp(name, "GetPhysicalDeviceSurfaceCapabilities2EXT")) - return (void *)table->GetPhysicalDeviceSurfaceCapabilities2EXT; + if (!strcmp(name, "GetPhysicalDeviceSurfaceCapabilities2EXT")) return (void *)table->GetPhysicalDeviceSurfaceCapabilities2EXT; // NV_external_memory_capabilities if (!strcmp(name, "GetPhysicalDeviceExternalImageFormatPropertiesNV")) @@ -672,84 +533,57 @@ static inline void *loader_lookup_instance_dispatch_table(const VkLayerInstanceD *found_name = true; name += 2; - if (!strcmp(name, "DestroyInstance")) - return (void *)table->DestroyInstance; - if (!strcmp(name, "EnumeratePhysicalDevices")) - return (void *)table->EnumeratePhysicalDevices; - if (!strcmp(name, "GetPhysicalDeviceFeatures")) - return (void *)table->GetPhysicalDeviceFeatures; - if (!strcmp(name, "GetPhysicalDeviceImageFormatProperties")) - return (void *)table->GetPhysicalDeviceImageFormatProperties; - if (!strcmp(name, "GetPhysicalDeviceFormatProperties")) - return (void *)table->GetPhysicalDeviceFormatProperties; + if (!strcmp(name, "DestroyInstance")) return (void *)table->DestroyInstance; + if (!strcmp(name, "EnumeratePhysicalDevices")) return (void *)table->EnumeratePhysicalDevices; + if (!strcmp(name, "GetPhysicalDeviceFeatures")) return (void *)table->GetPhysicalDeviceFeatures; + if (!strcmp(name, "GetPhysicalDeviceImageFormatProperties")) return (void *)table->GetPhysicalDeviceImageFormatProperties; + if (!strcmp(name, "GetPhysicalDeviceFormatProperties")) return (void *)table->GetPhysicalDeviceFormatProperties; if (!strcmp(name, "GetPhysicalDeviceSparseImageFormatProperties")) return (void *)table->GetPhysicalDeviceSparseImageFormatProperties; - if (!strcmp(name, "GetPhysicalDeviceProperties")) - return (void *)table->GetPhysicalDeviceProperties; - if (!strcmp(name, "GetPhysicalDeviceQueueFamilyProperties")) - return (void *)table->GetPhysicalDeviceQueueFamilyProperties; - if (!strcmp(name, "GetPhysicalDeviceMemoryProperties")) - return (void *)table->GetPhysicalDeviceMemoryProperties; - if (!strcmp(name, "GetInstanceProcAddr")) - return (void *)table->GetInstanceProcAddr; - if (!strcmp(name, "EnumerateDeviceExtensionProperties")) - return (void *)table->EnumerateDeviceExtensionProperties; - if (!strcmp(name, "EnumerateDeviceLayerProperties")) - return (void *)table->EnumerateDeviceLayerProperties; - if (!strcmp(name, "DestroySurfaceKHR")) - return (void *)table->DestroySurfaceKHR; - if (!strcmp(name, "GetPhysicalDeviceSurfaceSupportKHR")) - return (void *)table->GetPhysicalDeviceSurfaceSupportKHR; - if (!strcmp(name, "GetPhysicalDeviceSurfaceCapabilitiesKHR")) - return (void *)table->GetPhysicalDeviceSurfaceCapabilitiesKHR; - if (!strcmp(name, "GetPhysicalDeviceSurfaceFormatsKHR")) - return (void *)table->GetPhysicalDeviceSurfaceFormatsKHR; - if (!strcmp(name, "GetPhysicalDeviceSurfacePresentModesKHR")) - return (void *)table->GetPhysicalDeviceSurfacePresentModesKHR; + if (!strcmp(name, "GetPhysicalDeviceProperties")) return (void *)table->GetPhysicalDeviceProperties; + if (!strcmp(name, "GetPhysicalDeviceQueueFamilyProperties")) return (void *)table->GetPhysicalDeviceQueueFamilyProperties; + if (!strcmp(name, "GetPhysicalDeviceMemoryProperties")) return (void *)table->GetPhysicalDeviceMemoryProperties; + if (!strcmp(name, "GetInstanceProcAddr")) return (void *)table->GetInstanceProcAddr; + if (!strcmp(name, "EnumerateDeviceExtensionProperties")) return (void *)table->EnumerateDeviceExtensionProperties; + if (!strcmp(name, "EnumerateDeviceLayerProperties")) return (void *)table->EnumerateDeviceLayerProperties; + if (!strcmp(name, "DestroySurfaceKHR")) return (void *)table->DestroySurfaceKHR; + if (!strcmp(name, "GetPhysicalDeviceSurfaceSupportKHR")) return (void *)table->GetPhysicalDeviceSurfaceSupportKHR; + if (!strcmp(name, "GetPhysicalDeviceSurfaceCapabilitiesKHR")) return (void *)table->GetPhysicalDeviceSurfaceCapabilitiesKHR; + if (!strcmp(name, "GetPhysicalDeviceSurfaceFormatsKHR")) return (void *)table->GetPhysicalDeviceSurfaceFormatsKHR; + if (!strcmp(name, "GetPhysicalDeviceSurfacePresentModesKHR")) return (void *)table->GetPhysicalDeviceSurfacePresentModesKHR; #ifdef VK_USE_PLATFORM_MIR_KHR - if (!strcmp(name, "CreateMirSurfaceKHR")) - return (void *)table->CreateMirSurfaceKHR; + if (!strcmp(name, "CreateMirSurfaceKHR")) return (void *)table->CreateMirSurfaceKHR; if (!strcmp(name, "GetPhysicalDeviceMirPresentationSupportKHR")) return (void *)table->GetPhysicalDeviceMirPresentationSupportKHR; #endif #ifdef VK_USE_PLATFORM_WAYLAND_KHR - if (!strcmp(name, "CreateWaylandSurfaceKHR")) - return (void *)table->CreateWaylandSurfaceKHR; + if (!strcmp(name, "CreateWaylandSurfaceKHR")) return (void *)table->CreateWaylandSurfaceKHR; if (!strcmp(name, "GetPhysicalDeviceWaylandPresentationSupportKHR")) return (void *)table->GetPhysicalDeviceWaylandPresentationSupportKHR; #endif #ifdef VK_USE_PLATFORM_WIN32_KHR - if (!strcmp(name, "CreateWin32SurfaceKHR")) - return (void *)table->CreateWin32SurfaceKHR; + if (!strcmp(name, "CreateWin32SurfaceKHR")) return (void *)table->CreateWin32SurfaceKHR; if (!strcmp(name, "GetPhysicalDeviceWin32PresentationSupportKHR")) return (void *)table->GetPhysicalDeviceWin32PresentationSupportKHR; #endif #ifdef VK_USE_PLATFORM_XCB_KHR - if (!strcmp(name, "CreateXcbSurfaceKHR")) - return (void *)table->CreateXcbSurfaceKHR; + if (!strcmp(name, "CreateXcbSurfaceKHR")) return (void *)table->CreateXcbSurfaceKHR; if (!strcmp(name, "GetPhysicalDeviceXcbPresentationSupportKHR")) return (void *)table->GetPhysicalDeviceXcbPresentationSupportKHR; #endif #ifdef VK_USE_PLATFORM_XLIB_KHR - if (!strcmp(name, "CreateXlibSurfaceKHR")) - return (void *)table->CreateXlibSurfaceKHR; + if (!strcmp(name, "CreateXlibSurfaceKHR")) return (void *)table->CreateXlibSurfaceKHR; if (!strcmp(name, "GetPhysicalDeviceXlibPresentationSupportKHR")) return (void *)table->GetPhysicalDeviceXlibPresentationSupportKHR; #endif - if (!strcmp(name, "GetPhysicalDeviceDisplayPropertiesKHR")) - return (void *)table->GetPhysicalDeviceDisplayPropertiesKHR; + if (!strcmp(name, "GetPhysicalDeviceDisplayPropertiesKHR")) return (void *)table->GetPhysicalDeviceDisplayPropertiesKHR; if (!strcmp(name, "GetPhysicalDeviceDisplayPlanePropertiesKHR")) return (void *)table->GetPhysicalDeviceDisplayPlanePropertiesKHR; - if (!strcmp(name, "GetDisplayPlaneSupportedDisplaysKHR")) - return (void *)table->GetDisplayPlaneSupportedDisplaysKHR; - if (!strcmp(name, "GetDisplayModePropertiesKHR")) - return (void *)table->GetDisplayModePropertiesKHR; - if (!strcmp(name, "CreateDisplayModeKHR")) - return (void *)table->CreateDisplayModeKHR; - if (!strcmp(name, "GetDisplayPlaneCapabilitiesKHR")) - return (void *)table->GetDisplayPlaneCapabilitiesKHR; - if (!strcmp(name, "CreateDisplayPlaneSurfaceKHR")) - return (void *)table->CreateDisplayPlaneSurfaceKHR; + if (!strcmp(name, "GetDisplayPlaneSupportedDisplaysKHR")) return (void *)table->GetDisplayPlaneSupportedDisplaysKHR; + if (!strcmp(name, "GetDisplayModePropertiesKHR")) return (void *)table->GetDisplayModePropertiesKHR; + if (!strcmp(name, "CreateDisplayModeKHR")) return (void *)table->CreateDisplayModeKHR; + if (!strcmp(name, "GetDisplayPlaneCapabilitiesKHR")) return (void *)table->GetDisplayPlaneCapabilitiesKHR; + if (!strcmp(name, "CreateDisplayPlaneSurfaceKHR")) return (void *)table->CreateDisplayPlaneSurfaceKHR; return loader_lookup_instance_extension_dispatch_table(table, name, found_name); } diff --git a/loader/trampoline.c b/loader/trampoline.c index 31352ae..23a1b70 100644 --- a/loader/trampoline.c +++ b/loader/trampoline.c @@ -46,7 +46,6 @@ * functions both core and extensions. */ LOADER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance, const char *pName) { - void *addr; addr = globalGetProcAddr(pName); @@ -56,13 +55,11 @@ LOADER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkI return addr; } else { // if a global entrypoint return NULL - if (addr) - return NULL; + if (addr) return NULL; } struct loader_instance *ptr_instance = loader_get_instance(instance); - if (ptr_instance == NULL) - return NULL; + if (ptr_instance == NULL) return NULL; // Return trampoline code for non-global entrypoints including any // extensions. // Device extensions are returned if a layer or ICD supports the extension. @@ -94,20 +91,16 @@ LOADER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetDeviceProcAddr(VkDev /* Although CreateDevice is on device chain it's dispatchable object isn't * a VkDevice or child of VkDevice so return NULL. */ - if (!strcmp(pName, "CreateDevice")) - return NULL; + if (!strcmp(pName, "CreateDevice")) return NULL; /* return the dispatch table entrypoint for the fastest case */ const VkLayerDispatchTable *disp_table = *(VkLayerDispatchTable **)device; - if (disp_table == NULL) - return NULL; + if (disp_table == NULL) return NULL; addr = loader_lookup_device_dispatch_table(disp_table, pName); - if (addr) - return addr; + if (addr) return addr; - if (disp_table->GetDeviceProcAddr == NULL) - return NULL; + if (disp_table->GetDeviceProcAddr == NULL) return NULL; return disp_table->GetDeviceProcAddr(device, pName); } @@ -129,8 +122,9 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceExtensionPropert /* get layer libraries if needed */ if (pLayerName && strlen(pLayerName) != 0) { if (vk_string_validate(MaxLoaderStringLength, pLayerName) != VK_STRING_ERROR_NONE) { - assert(VK_FALSE && "vkEnumerateInstanceExtensionProperties: " - "pLayerName is too long or is badly formed"); + assert(VK_FALSE && + "vkEnumerateInstanceExtensionProperties: " + "pLayerName is too long or is badly formed"); res = VK_ERROR_EXTENSION_NOT_PRESENT; goto out; } @@ -213,7 +207,6 @@ out: LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceLayerProperties(uint32_t *pPropertyCount, VkLayerProperties *pProperties) { - struct loader_layer_list instance_layer_list; tls_instance = NULL; @@ -351,8 +344,9 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(const VkInstanceCr ptr_instance->disp = loader_instance_heap_alloc(ptr_instance, sizeof(VkLayerInstanceDispatchTable), VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); if (ptr_instance->disp == NULL) { - loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "vkCreateInstance: Failed to allocate Instance dispatch" - " table."); + loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "vkCreateInstance: Failed to allocate Instance dispatch" + " table."); res = VK_ERROR_OUT_OF_HOST_MEMORY; goto out; } @@ -494,8 +488,9 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumeratePhysicalDevices(VkInstan // structures in the loader. res = disp->EnumeratePhysicalDevices(instance, pPhysicalDeviceCount, pPhysicalDevices); if (VK_SUCCESS != res) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "vkEnumeratePhysicalDevices: Failed in dispatch call" - " used to determine number of available GPUs"); + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "vkEnumeratePhysicalDevices: Failed in dispatch call" + " used to determine number of available GPUs"); } } @@ -512,8 +507,9 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumeratePhysicalDevices(VkInstan // Wrap the PhysDev object for loader usage, return wrapped objects if (inst->total_gpu_count > *pPhysicalDeviceCount) { - loader_log(inst, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, "vkEnumeratePhysicalDevices: Trimming device count down" - " by application request from %d to %d physical devices", + loader_log(inst, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, + "vkEnumeratePhysicalDevices: Trimming device count down" + " by application request from %d to %d physical devices", inst->total_gpu_count, *pPhysicalDeviceCount); count = *pPhysicalDeviceCount; res = VK_INCOMPLETE; @@ -632,8 +628,9 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice phy dev->activated_layer_list.list = loader_device_heap_alloc(dev, inst->activated_layer_list.capacity, VK_SYSTEM_ALLOCATION_SCOPE_DEVICE); if (dev->activated_layer_list.list == NULL) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "vkCreateDevice: Failed to allocate activated layer" - "list of size %d.", + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "vkCreateDevice: Failed to allocate activated layer" + "list of size %d.", inst->activated_layer_list.capacity); res = VK_ERROR_OUT_OF_HOST_MEMORY; goto out; @@ -714,7 +711,6 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceExtensionPropertie disp = loader_get_instance_layer_dispatch(physicalDevice); res = disp->EnumerateDeviceExtensionProperties(phys_dev->phys_dev, NULL, pPropertyCount, pProperties); } else { - uint32_t count; uint32_t copy_size; const struct loader_instance *inst = phys_dev->this_instance; @@ -766,8 +762,9 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceExtensionPropertie return VK_INCOMPLETE; } } else { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "vkEnumerateDeviceExtensionProperties: pLayerName " - "is too long or is badly formed"); + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "vkEnumerateDeviceExtensionProperties: pLayerName " + "is too long or is badly formed"); loader_platform_thread_unlock_mutex(&loader_lock); return VK_ERROR_EXTENSION_NOT_PRESENT; } @@ -796,8 +793,7 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceLayerProperties(Vk const struct loader_instance *inst = phys_dev->this_instance; uint32_t count = inst->activated_layer_list.count; - if (inst->activated_layers_are_std_val) - count = count - std_val_count + 1; + if (inst->activated_layers_are_std_val) count = count - std_val_count + 1; if (pProperties == NULL) { *pPropertyCount = count; loader_platform_thread_unlock_mutex(&loader_lock); @@ -811,15 +807,15 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceLayerProperties(Vk enabled_layers->capacity = enabled_layers->count * sizeof(struct loader_layer_properties); enabled_layers->list = loader_instance_heap_alloc(inst, enabled_layers->capacity, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); if (!enabled_layers->list) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "vkEnumerateDeviceLayerProperties: Failed to allocate enabled" - "layer list of size %d", + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "vkEnumerateDeviceLayerProperties: Failed to allocate enabled" + "layer list of size %d", enabled_layers->capacity); return VK_ERROR_OUT_OF_HOST_MEMORY; } uint32_t j = 0; for (uint32_t i = 0; i < inst->activated_layer_list.count; j++) { - if (loader_find_layer_name_array(inst->activated_layer_list.list[i].info.layerName, std_val_count, std_validation_names)) { struct loader_layer_properties props; diff --git a/loader/vk_loader_platform.h b/loader/vk_loader_platform.h index e0af896..8a70865 100644 --- a/loader/vk_loader_platform.h +++ b/loader/vk_loader_platform.h @@ -25,7 +25,7 @@ #if defined(_WIN32) // WinSock2.h must be included *BEFORE* windows.h #include -#endif // _WIN32 +#endif // _WIN32 #include "vulkan/vk_platform.h" #include "vulkan/vk_sdk_platform.h" @@ -77,14 +77,14 @@ #define EXTRA_ILAYERS_DATADIR_INFO #endif -#define DEFAULT_VK_DRIVERS_INFO \ - SYSCONFDIR VULKAN_DIR VULKAN_ICDCONF_DIR \ +#define DEFAULT_VK_DRIVERS_INFO \ + SYSCONFDIR VULKAN_DIR VULKAN_ICDCONF_DIR \ ":" DATADIR VULKAN_DIR VULKAN_ICDCONF_DIR EXTRA_DRIVERS_SYSCONFDIR_INFO EXTRA_DRIVERS_DATADIR_INFO -#define DEFAULT_VK_ELAYERS_INFO \ - SYSCONFDIR VULKAN_DIR VULKAN_ELAYERCONF_DIR \ +#define DEFAULT_VK_ELAYERS_INFO \ + SYSCONFDIR VULKAN_DIR VULKAN_ELAYERCONF_DIR \ ":" DATADIR VULKAN_DIR VULKAN_ELAYERCONF_DIR EXTRA_ELAYERS_SYSCONFDIR_INFO EXTRA_ELAYERS_DATADIR_INFO -#define DEFAULT_VK_ILAYERS_INFO \ - SYSCONFDIR VULKAN_DIR VULKAN_ILAYERCONF_DIR \ +#define DEFAULT_VK_ILAYERS_INFO \ + SYSCONFDIR VULKAN_DIR VULKAN_ILAYERCONF_DIR \ ":" DATADIR VULKAN_DIR VULKAN_ILAYERCONF_DIR EXTRA_ILAYERS_SYSCONFDIR_INFO EXTRA_ILAYERS_DATADIR_INFO #define DEFAULT_VK_DRIVERS_PATH "" @@ -165,7 +165,7 @@ static inline void loader_platform_thread_cond_broadcast(loader_platform_thread_ #define loader_stack_alloc(size) alloca(size) -#elif defined(_WIN32) // defined(__linux__) +#elif defined(_WIN32) // defined(__linux__) /* Windows-specific common code: */ // WinBase.h defines CreateSemaphore and synchapi.h defines CreateEvent // undefine them to avoid conflicts with VkLayerDispatchTable struct members. @@ -184,7 +184,7 @@ static inline void loader_platform_thread_cond_broadcast(loader_platform_thread_ #ifdef __cplusplus #include #include -#endif // __cplusplus +#endif // __cplusplus // VK Library Filenames, Paths, etc.: #define PATH_SEPARATOR ';' @@ -225,8 +225,7 @@ static inline char *loader_platform_dirname(char *path) { for (current = path; *current != '\0'; current = next) { next = strchr(current, DIRECTORY_SYMBOL); if (next == NULL) { - if (current != path) - *(current - 1) = '\0'; + if (current != path) *(current - 1) = '\0'; return path; } else { // Point one character past the DIRECTORY_SYMBOL: @@ -319,7 +318,7 @@ static void loader_platform_thread_cond_broadcast(loader_platform_thread_cond *p char *loader_get_registry_string(const HKEY hive, const LPCTSTR sub_key, const char *value); #define loader_stack_alloc(size) _alloca(size) -#else // defined(_WIN32) +#else // defined(_WIN32) #error The "loader_platform.h" file must be modified for this OS. @@ -330,7 +329,7 @@ char *loader_get_registry_string(const HKEY hive, const LPCTSTR sub_key, const c // NOTE: Other OS-specific changes are also needed for this OS. Search for // files with "WIN32" in it, as a quick way to find files that must be changed. -#endif // defined(_WIN32) +#endif // defined(_WIN32) // returns true if the given string appears to be a relative or absolute // path, as opposed to a bare filename. diff --git a/loader/wsi.c b/loader/wsi.c index a34498f..257e114 100644 --- a/loader/wsi.c +++ b/loader/wsi.c @@ -39,22 +39,22 @@ void wsi_create_instance(struct loader_instance *ptr_instance, const VkInstanceC #ifdef VK_USE_PLATFORM_WIN32_KHR ptr_instance->wsi_win32_surface_enabled = false; -#endif // VK_USE_PLATFORM_WIN32_KHR +#endif // VK_USE_PLATFORM_WIN32_KHR #ifdef VK_USE_PLATFORM_MIR_KHR ptr_instance->wsi_mir_surface_enabled = false; -#endif // VK_USE_PLATFORM_MIR_KHR +#endif // VK_USE_PLATFORM_MIR_KHR #ifdef VK_USE_PLATFORM_WAYLAND_KHR ptr_instance->wsi_wayland_surface_enabled = false; -#endif // VK_USE_PLATFORM_WAYLAND_KHR +#endif // VK_USE_PLATFORM_WAYLAND_KHR #ifdef VK_USE_PLATFORM_XCB_KHR ptr_instance->wsi_xcb_surface_enabled = false; -#endif // VK_USE_PLATFORM_XCB_KHR +#endif // VK_USE_PLATFORM_XCB_KHR #ifdef VK_USE_PLATFORM_XLIB_KHR ptr_instance->wsi_xlib_surface_enabled = false; -#endif // VK_USE_PLATFORM_XLIB_KHR +#endif // VK_USE_PLATFORM_XLIB_KHR #ifdef VK_USE_PLATFORM_ANDROID_KHR ptr_instance->wsi_android_surface_enabled = false; -#endif // VK_USE_PLATFORM_ANDROID_KHR +#endif // VK_USE_PLATFORM_ANDROID_KHR ptr_instance->wsi_display_enabled = false; @@ -68,37 +68,37 @@ void wsi_create_instance(struct loader_instance *ptr_instance, const VkInstanceC ptr_instance->wsi_win32_surface_enabled = true; continue; } -#endif // VK_USE_PLATFORM_WIN32_KHR +#endif // VK_USE_PLATFORM_WIN32_KHR #ifdef VK_USE_PLATFORM_MIR_KHR if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_MIR_SURFACE_EXTENSION_NAME) == 0) { ptr_instance->wsi_mir_surface_enabled = true; continue; } -#endif // VK_USE_PLATFORM_MIR_KHR +#endif // VK_USE_PLATFORM_MIR_KHR #ifdef VK_USE_PLATFORM_WAYLAND_KHR if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME) == 0) { ptr_instance->wsi_wayland_surface_enabled = true; continue; } -#endif // VK_USE_PLATFORM_WAYLAND_KHR +#endif // VK_USE_PLATFORM_WAYLAND_KHR #ifdef VK_USE_PLATFORM_XCB_KHR if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_XCB_SURFACE_EXTENSION_NAME) == 0) { ptr_instance->wsi_xcb_surface_enabled = true; continue; } -#endif // VK_USE_PLATFORM_XCB_KHR +#endif // VK_USE_PLATFORM_XCB_KHR #ifdef VK_USE_PLATFORM_XLIB_KHR if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_XLIB_SURFACE_EXTENSION_NAME) == 0) { ptr_instance->wsi_xlib_surface_enabled = true; continue; } -#endif // VK_USE_PLATFORM_XLIB_KHR +#endif // VK_USE_PLATFORM_XLIB_KHR #ifdef VK_USE_PLATFORM_ANDROID_KHR if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_ANDROID_SURFACE_EXTENSION_NAME) == 0) { ptr_instance->wsi_android_surface_enabled = true; continue; } -#endif // VK_USE_PLATFORM_ANDROID_KHR +#endif // VK_USE_PLATFORM_ANDROID_KHR if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_DISPLAY_EXTENSION_NAME) == 0) { ptr_instance->wsi_display_enabled = true; continue; @@ -117,21 +117,17 @@ void wsi_create_instance(struct loader_instance *ptr_instance, const VkInstanceC // built to support the extension. bool wsi_unsupported_instance_extension(const VkExtensionProperties *ext_prop) { #ifndef VK_USE_PLATFORM_MIR_KHR - if (!strcmp(ext_prop->extensionName, "VK_KHR_mir_surface")) - return true; -#endif // VK_USE_PLATFORM_MIR_KHR + if (!strcmp(ext_prop->extensionName, "VK_KHR_mir_surface")) return true; +#endif // VK_USE_PLATFORM_MIR_KHR #ifndef VK_USE_PLATFORM_WAYLAND_KHR - if (!strcmp(ext_prop->extensionName, "VK_KHR_wayland_surface")) - return true; -#endif // VK_USE_PLATFORM_WAYLAND_KHR + if (!strcmp(ext_prop->extensionName, "VK_KHR_wayland_surface")) return true; +#endif // VK_USE_PLATFORM_WAYLAND_KHR #ifndef VK_USE_PLATFORM_XCB_KHR - if (!strcmp(ext_prop->extensionName, "VK_KHR_xcb_surface")) - return true; -#endif // VK_USE_PLATFORM_XCB_KHR + if (!strcmp(ext_prop->extensionName, "VK_KHR_xcb_surface")) return true; +#endif // VK_USE_PLATFORM_XCB_KHR #ifndef VK_USE_PLATFORM_XLIB_KHR - if (!strcmp(ext_prop->extensionName, "VK_KHR_xlib_surface")) - return true; -#endif // VK_USE_PLATFORM_XLIB_KHR + if (!strcmp(ext_prop->extensionName, "VK_KHR_xlib_surface")) return true; +#endif // VK_USE_PLATFORM_XLIB_KHR return false; } @@ -193,14 +189,14 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceSupportKH VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, VkSurfaceKHR surface, VkBool32 *pSupported) { - // First, check to ensure the appropriate extension was enabled: struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; struct loader_instance *ptr_instance = (struct loader_instance *)icd_term->this_instance; if (!ptr_instance->wsi_surface_enabled) { - loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "VK_KHR_VK_KHR_surface extension not enabled. " - "vkGetPhysicalDeviceSurfaceSupportKHR not executed!\n"); + loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "VK_KHR_VK_KHR_surface extension not enabled. " + "vkGetPhysicalDeviceSurfaceSupportKHR not executed!\n"); return VK_SUCCESS; } @@ -222,7 +218,6 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceSupportKHR(VkP // This is the trampoline entrypoint for GetPhysicalDeviceSurfaceCapabilitiesKHR LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceCapabilitiesKHR( VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, VkSurfaceCapabilitiesKHR *pSurfaceCapabilities) { - const VkLayerInstanceDispatchTable *disp; VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); disp = loader_get_instance_layer_dispatch(physicalDevice); @@ -235,20 +230,21 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceCapabilit VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceCapabilitiesKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, VkSurfaceCapabilitiesKHR *pSurfaceCapabilities) { - // First, check to ensure the appropriate extension was enabled: struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; struct loader_instance *ptr_instance = (struct loader_instance *)icd_term->this_instance; if (!ptr_instance->wsi_surface_enabled) { - loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "VK_KHR_surface extension not enabled. " - "vkGetPhysicalDeviceSurfaceCapabilitiesKHR not executed!\n"); + loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "VK_KHR_surface extension not enabled. " + "vkGetPhysicalDeviceSurfaceCapabilitiesKHR not executed!\n"); return VK_SUCCESS; } // Next, if so, proceed with the implementation of this function: - assert(pSurfaceCapabilities && "GetPhysicalDeviceSurfaceCapabilitiesKHR: " - "Error, null pSurfaceCapabilities"); + assert(pSurfaceCapabilities && + "GetPhysicalDeviceSurfaceCapabilitiesKHR: " + "Error, null pSurfaceCapabilities"); assert(icd_term->GetPhysicalDeviceSurfaceCapabilitiesKHR && "loader: null GetPhysicalDeviceSurfaceCapabilitiesKHR ICD pointer"); @@ -278,14 +274,14 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceFormatsKH VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t *pSurfaceFormatCount, VkSurfaceFormatKHR *pSurfaceFormats) { - // First, check to ensure the appropriate extension was enabled: struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; struct loader_instance *ptr_instance = (struct loader_instance *)icd_term->this_instance; if (!ptr_instance->wsi_surface_enabled) { - loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "VK_KHR_surface extension not enabled. " - "vkGetPhysicalDeviceSurfaceFormatsKHR not executed!\n"); + loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "VK_KHR_surface extension not enabled. " + "vkGetPhysicalDeviceSurfaceFormatsKHR not executed!\n"); return VK_SUCCESS; } @@ -321,20 +317,21 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfacePresentMo VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t *pPresentModeCount, VkPresentModeKHR *pPresentModes) { - // First, check to ensure the appropriate extension was enabled: struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; struct loader_instance *ptr_instance = (struct loader_instance *)icd_term->this_instance; if (!ptr_instance->wsi_surface_enabled) { - loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "VK_KHR_surface extension not enabled. " - "vkGetPhysicalDeviceSurfacePresentModesKHR not executed!\n"); + loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "VK_KHR_surface extension not enabled. " + "vkGetPhysicalDeviceSurfacePresentModesKHR not executed!\n"); return VK_SUCCESS; } // Next, if so, proceed with the implementation of this function: - assert(pPresentModeCount && "GetPhysicalDeviceSurfacePresentModesKHR: " - "Error, null pPresentModeCount"); + assert(pPresentModeCount && + "GetPhysicalDeviceSurfacePresentModesKHR: " + "Error, null pPresentModeCount"); assert(icd_term->GetPhysicalDeviceSurfacePresentModesKHR && "loader: null GetPhysicalDeviceSurfacePresentModesKHR ICD pointer"); @@ -474,8 +471,9 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateWin32SurfaceKHR(VkInstance insta // First, check to ensure the appropriate extension was enabled: struct loader_instance *ptr_instance = loader_get_instance(instance); if (!ptr_instance->wsi_win32_surface_enabled) { - loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "VK_KHR_win32_surface extension not enabled. " - "vkCreateWin32SurfaceKHR not executed!\n"); + loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "VK_KHR_win32_surface extension not enabled. " + "vkCreateWin32SurfaceKHR not executed!\n"); vkRes = VK_ERROR_EXTENSION_NOT_PRESENT; goto out; } @@ -557,7 +555,7 @@ VKAPI_ATTR VkBool32 VKAPI_CALL terminator_GetPhysicalDeviceWin32PresentationSupp return icd_term->GetPhysicalDeviceWin32PresentationSupportKHR(phys_dev_term->phys_dev, queueFamilyIndex); } -#endif // VK_USE_PLATFORM_WIN32_KHR +#endif // VK_USE_PLATFORM_WIN32_KHR #ifdef VK_USE_PLATFORM_MIR_KHR @@ -586,8 +584,9 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateMirSurfaceKHR(VkInstance instanc // First, check to ensure the appropriate extension was enabled: struct loader_instance *ptr_instance = loader_get_instance(instance); if (!ptr_instance->wsi_mir_surface_enabled) { - loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "VK_KHR_mir_surface extension not enabled. " - "vkCreateMirSurfaceKHR not executed!\n"); + loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "VK_KHR_mir_surface extension not enabled. " + "vkCreateMirSurfaceKHR not executed!\n"); vkRes = VK_ERROR_EXTENSION_NOT_PRESENT; goto out; } @@ -653,14 +652,14 @@ LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceMirPresentationS VKAPI_ATTR VkBool32 VKAPI_CALL terminator_GetPhysicalDeviceMirPresentationSupportKHR(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, MirConnection *connection) { - // First, check to ensure the appropriate extension was enabled: struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; struct loader_instance *ptr_instance = (struct loader_instance *)icd_term->this_instance; if (!ptr_instance->wsi_mir_surface_enabled) { - loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "VK_KHR_mir_surface extension not enabled. " - "vkGetPhysicalDeviceMirPresentationSupportKHR not executed!\n"); + loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "VK_KHR_mir_surface extension not enabled. " + "vkGetPhysicalDeviceMirPresentationSupportKHR not executed!\n"); return VK_SUCCESS; } @@ -670,7 +669,7 @@ VKAPI_ATTR VkBool32 VKAPI_CALL terminator_GetPhysicalDeviceMirPresentationSuppor return icd_term->GetPhysicalDeviceMirPresentationSupportKHR(phys_dev_term->phys_dev, queueFamilyIndex, connection); } -#endif // VK_USE_PLATFORM_MIR_KHR +#endif // VK_USE_PLATFORM_MIR_KHR #ifdef VK_USE_PLATFORM_WAYLAND_KHR @@ -701,8 +700,9 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateWaylandSurfaceKHR(VkInstance ins // First, check to ensure the appropriate extension was enabled: struct loader_instance *ptr_instance = loader_get_instance(instance); if (!ptr_instance->wsi_wayland_surface_enabled) { - loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "VK_KHR_wayland_surface extension not enabled. " - "vkCreateWaylandSurfaceKHR not executed!\n"); + loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "VK_KHR_wayland_surface extension not enabled. " + "vkCreateWaylandSurfaceKHR not executed!\n"); vkRes = VK_ERROR_EXTENSION_NOT_PRESENT; goto out; } @@ -768,7 +768,6 @@ LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceWaylandPresentat VKAPI_ATTR VkBool32 VKAPI_CALL terminator_GetPhysicalDeviceWaylandPresentationSupportKHR(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, struct wl_display *display) { - // First, check to ensure the appropriate extension was enabled: struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; @@ -787,7 +786,7 @@ VKAPI_ATTR VkBool32 VKAPI_CALL terminator_GetPhysicalDeviceWaylandPresentationSu return icd_term->GetPhysicalDeviceWaylandPresentationSupportKHR(phys_dev_term->phys_dev, queueFamilyIndex, display); } -#endif // VK_USE_PLATFORM_WAYLAND_KHR +#endif // VK_USE_PLATFORM_WAYLAND_KHR #ifdef VK_USE_PLATFORM_XCB_KHR @@ -816,8 +815,9 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateXcbSurfaceKHR(VkInstance instanc // First, check to ensure the appropriate extension was enabled: struct loader_instance *ptr_instance = loader_get_instance(instance); if (!ptr_instance->wsi_xcb_surface_enabled) { - loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "VK_KHR_xcb_surface extension not enabled. " - "vkCreateXcbSurfaceKHR not executed!\n"); + loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "VK_KHR_xcb_surface extension not enabled. " + "vkCreateXcbSurfaceKHR not executed!\n"); vkRes = VK_ERROR_EXTENSION_NOT_PRESENT; goto out; } @@ -885,14 +885,14 @@ VKAPI_ATTR VkBool32 VKAPI_CALL terminator_GetPhysicalDeviceXcbPresentationSuppor uint32_t queueFamilyIndex, xcb_connection_t *connection, xcb_visualid_t visual_id) { - // First, check to ensure the appropriate extension was enabled: struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; struct loader_instance *ptr_instance = (struct loader_instance *)icd_term->this_instance; if (!ptr_instance->wsi_xcb_surface_enabled) { - loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "VK_KHR_xcb_surface extension not enabled. " - "vkGetPhysicalDeviceXcbPresentationSupportKHR not executed!\n"); + loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "VK_KHR_xcb_surface extension not enabled. " + "vkGetPhysicalDeviceXcbPresentationSupportKHR not executed!\n"); return VK_SUCCESS; } @@ -902,7 +902,7 @@ VKAPI_ATTR VkBool32 VKAPI_CALL terminator_GetPhysicalDeviceXcbPresentationSuppor return icd_term->GetPhysicalDeviceXcbPresentationSupportKHR(phys_dev_term->phys_dev, queueFamilyIndex, connection, visual_id); } -#endif // VK_USE_PLATFORM_XCB_KHR +#endif // VK_USE_PLATFORM_XCB_KHR #ifdef VK_USE_PLATFORM_XLIB_KHR @@ -931,8 +931,9 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateXlibSurfaceKHR(VkInstance instan // First, check to ensure the appropriate extension was enabled: struct loader_instance *ptr_instance = loader_get_instance(instance); if (!ptr_instance->wsi_xlib_surface_enabled) { - loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "VK_KHR_xlib_surface extension not enabled. " - "vkCreateXlibSurfaceKHR not executed!\n"); + loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "VK_KHR_xlib_surface extension not enabled. " + "vkCreateXlibSurfaceKHR not executed!\n"); vkRes = VK_ERROR_EXTENSION_NOT_PRESENT; goto out; } @@ -998,14 +999,14 @@ LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceXlibPresentation VKAPI_ATTR VkBool32 VKAPI_CALL terminator_GetPhysicalDeviceXlibPresentationSupportKHR(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, Display *dpy, VisualID visualID) { - // First, check to ensure the appropriate extension was enabled: struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; struct loader_instance *ptr_instance = (struct loader_instance *)icd_term->this_instance; if (!ptr_instance->wsi_xlib_surface_enabled) { - loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "VK_KHR_xlib_surface extension not enabled. " - "vkGetPhysicalDeviceXlibPresentationSupportKHR not executed!\n"); + loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "VK_KHR_xlib_surface extension not enabled. " + "vkGetPhysicalDeviceXlibPresentationSupportKHR not executed!\n"); return VK_SUCCESS; } @@ -1015,7 +1016,7 @@ VKAPI_ATTR VkBool32 VKAPI_CALL terminator_GetPhysicalDeviceXlibPresentationSuppo return icd_term->GetPhysicalDeviceXlibPresentationSupportKHR(phys_dev_term->phys_dev, queueFamilyIndex, dpy, visualID); } -#endif // VK_USE_PLATFORM_XLIB_KHR +#endif // VK_USE_PLATFORM_XLIB_KHR #ifdef VK_USE_PLATFORM_ANDROID_KHR @@ -1039,8 +1040,9 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateAndroidSurfaceKHR(VkInstance ins // First, check to ensure the appropriate extension was enabled: struct loader_instance *ptr_instance = loader_get_instance(instance); if (!ptr_instance->wsi_display_enabled) { - loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "VK_KHR_display extension not enabled. " - "vkCreateAndroidSurfaceKHR not executed!\n"); + loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "VK_KHR_display extension not enabled. " + "vkCreateAndroidSurfaceKHR not executed!\n"); return VK_ERROR_EXTENSION_NOT_PRESENT; } @@ -1060,7 +1062,7 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateAndroidSurfaceKHR(VkInstance ins return VK_SUCCESS; } -#endif // VK_USE_PLATFORM_ANDROID_KHR +#endif // VK_USE_PLATFORM_ANDROID_KHR // Functions for the VK_KHR_display instance extension: LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physicalDevice, @@ -1076,14 +1078,14 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceDisplayPropertie VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount, VkDisplayPropertiesKHR *pProperties) { - // First, check to ensure the appropriate extension was enabled: struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; struct loader_instance *ptr_instance = (struct loader_instance *)icd_term->this_instance; if (!ptr_instance->wsi_display_enabled) { - loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "VK_KHR_display extension not enabled. " - "vkGetPhysicalDeviceDisplayPropertiesKHR not executed!\n"); + loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "VK_KHR_display extension not enabled. " + "vkGetPhysicalDeviceDisplayPropertiesKHR not executed!\n"); return VK_SUCCESS; } @@ -1105,14 +1107,14 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceDisplayPlaneProp VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceDisplayPlanePropertiesKHR(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount, VkDisplayPlanePropertiesKHR *pProperties) { - // First, check to ensure the appropriate extension was enabled: struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; struct loader_instance *ptr_instance = (struct loader_instance *)icd_term->this_instance; if (!ptr_instance->wsi_display_enabled) { - loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "VK_KHR_display extension not enabled. " - "vkGetPhysicalDeviceDisplayPlanePropertiesKHR not executed!\n"); + loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "VK_KHR_display extension not enabled. " + "vkGetPhysicalDeviceDisplayPlanePropertiesKHR not executed!\n"); return VK_SUCCESS; } @@ -1135,14 +1137,14 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetDisplayPlaneSupportedDisplaysK VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physicalDevice, uint32_t planeIndex, uint32_t *pDisplayCount, VkDisplayKHR *pDisplays) { - // First, check to ensure the appropriate extension was enabled: struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; struct loader_instance *ptr_instance = (struct loader_instance *)icd_term->this_instance; if (!ptr_instance->wsi_display_enabled) { - loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "VK_KHR_display extension not enabled. " - "vkGetDisplayPlaneSupportedDisplaysKHR not executed!\n"); + loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "VK_KHR_display extension not enabled. " + "vkGetDisplayPlaneSupportedDisplaysKHR not executed!\n"); return VK_SUCCESS; } @@ -1165,14 +1167,14 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetDisplayModePropertiesKHR(VkPhy VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDisplayModePropertiesKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, uint32_t *pPropertyCount, VkDisplayModePropertiesKHR *pProperties) { - // First, check to ensure the appropriate extension was enabled: struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; struct loader_instance *ptr_instance = (struct loader_instance *)icd_term->this_instance; if (!ptr_instance->wsi_display_enabled) { - loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "VK_KHR_display extension not enabled. " - "vkGetDisplayModePropertiesKHR not executed!\n"); + loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "VK_KHR_display extension not enabled. " + "vkGetDisplayModePropertiesKHR not executed!\n"); return VK_SUCCESS; } @@ -1196,14 +1198,14 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDisplayModeKHR(VkPhysicalDe VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, const VkDisplayModeCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDisplayModeKHR *pMode) { - // First, check to ensure the appropriate extension was enabled: struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; struct loader_instance *ptr_instance = (struct loader_instance *)icd_term->this_instance; if (!ptr_instance->wsi_display_enabled) { - loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "VK_KHR_display extension not enabled. " - "vkCreateDisplayModeKHR not executed!\n"); + loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "VK_KHR_display extension not enabled. " + "vkCreateDisplayModeKHR not executed!\n"); return VK_ERROR_EXTENSION_NOT_PRESENT; } @@ -1226,14 +1228,14 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetDisplayPlaneCapabilitiesKHR(Vk VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDisplayPlaneCapabilitiesKHR(VkPhysicalDevice physicalDevice, VkDisplayModeKHR mode, uint32_t planeIndex, VkDisplayPlaneCapabilitiesKHR *pCapabilities) { - // First, check to ensure the appropriate extension was enabled: struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; struct loader_instance *ptr_instance = (struct loader_instance *)icd_term->this_instance; if (!ptr_instance->wsi_display_enabled) { - loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "VK_KHR_display extension not enabled. " - "vkGetDisplayPlaneCapabilitiesKHR not executed!\n"); + loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "VK_KHR_display extension not enabled. " + "vkGetDisplayPlaneCapabilitiesKHR not executed!\n"); return VK_SUCCESS; } @@ -1265,8 +1267,9 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDisplayPlaneSurfaceKHR(VkInstanc uint32_t i = 0; if (!inst->wsi_display_enabled) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "VK_KHR_surface extension not enabled. " - "vkCreateDisplayPlaneSurfaceKHR not executed!\n"); + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "VK_KHR_surface extension not enabled. " + "vkCreateDisplayPlaneSurfaceKHR not executed!\n"); vkRes = VK_ERROR_EXTENSION_NOT_PRESENT; goto out; } @@ -1424,7 +1427,7 @@ bool wsi_swapchain_instance_gpa(struct loader_instance *ptr_instance, const char *addr = ptr_instance->wsi_win32_surface_enabled ? (void *)vkGetPhysicalDeviceWin32PresentationSupportKHR : NULL; return true; } -#endif // VK_USE_PLATFORM_WIN32_KHR +#endif // VK_USE_PLATFORM_WIN32_KHR #ifdef VK_USE_PLATFORM_MIR_KHR // Functions for the VK_KHR_mir_surface extension: @@ -1436,7 +1439,7 @@ bool wsi_swapchain_instance_gpa(struct loader_instance *ptr_instance, const char *addr = ptr_instance->wsi_mir_surface_enabled ? (void *)vkGetPhysicalDeviceMirPresentationSupportKHR : NULL; return true; } -#endif // VK_USE_PLATFORM_MIR_KHR +#endif // VK_USE_PLATFORM_MIR_KHR #ifdef VK_USE_PLATFORM_WAYLAND_KHR // Functions for the VK_KHR_wayland_surface extension: @@ -1448,7 +1451,7 @@ bool wsi_swapchain_instance_gpa(struct loader_instance *ptr_instance, const char *addr = ptr_instance->wsi_wayland_surface_enabled ? (void *)vkGetPhysicalDeviceWaylandPresentationSupportKHR : NULL; return true; } -#endif // VK_USE_PLATFORM_WAYLAND_KHR +#endif // VK_USE_PLATFORM_WAYLAND_KHR #ifdef VK_USE_PLATFORM_XCB_KHR // Functions for the VK_KHR_xcb_surface extension: @@ -1460,7 +1463,7 @@ bool wsi_swapchain_instance_gpa(struct loader_instance *ptr_instance, const char *addr = ptr_instance->wsi_xcb_surface_enabled ? (void *)vkGetPhysicalDeviceXcbPresentationSupportKHR : NULL; return true; } -#endif // VK_USE_PLATFORM_XCB_KHR +#endif // VK_USE_PLATFORM_XCB_KHR #ifdef VK_USE_PLATFORM_XLIB_KHR // Functions for the VK_KHR_xlib_surface extension: @@ -1472,7 +1475,7 @@ bool wsi_swapchain_instance_gpa(struct loader_instance *ptr_instance, const char *addr = ptr_instance->wsi_xlib_surface_enabled ? (void *)vkGetPhysicalDeviceXlibPresentationSupportKHR : NULL; return true; } -#endif // VK_USE_PLATFORM_XLIB_KHR +#endif // VK_USE_PLATFORM_XLIB_KHR #ifdef VK_USE_PLATFORM_ANDROID_KHR // Functions for the VK_KHR_android_surface extension: @@ -1480,7 +1483,7 @@ bool wsi_swapchain_instance_gpa(struct loader_instance *ptr_instance, const char *addr = ptr_instance->wsi_xlib_surface_enabled ? (void *)vkCreateAndroidSurfaceKHR : NULL; return true; } -#endif // VK_USE_PLATFORM_ANDROID_KHR +#endif // VK_USE_PLATFORM_ANDROID_KHR // Functions for VK_KHR_display extension: if (!strcmp("vkGetPhysicalDeviceDisplayPropertiesKHR", name)) { diff --git a/loader/wsi.h b/loader/wsi.h index c5cf871..5a13bf4 100644 --- a/loader/wsi.h +++ b/loader/wsi.h @@ -29,25 +29,25 @@ typedef struct { union { #ifdef VK_USE_PLATFORM_MIR_KHR VkIcdSurfaceMir mir_surf; -#endif // VK_USE_PLATFORM_MIR_KHR +#endif // VK_USE_PLATFORM_MIR_KHR #ifdef VK_USE_PLATFORM_WAYLAND_KHR VkIcdSurfaceWayland wayland_surf; -#endif // VK_USE_PLATFORM_WAYLAND_KHR +#endif // VK_USE_PLATFORM_WAYLAND_KHR #ifdef VK_USE_PLATFORM_WIN32_KHR VkIcdSurfaceWin32 win_surf; -#endif // VK_USE_PLATFORM_WIN32_KHR +#endif // VK_USE_PLATFORM_WIN32_KHR #ifdef VK_USE_PLATFORM_XCB_KHR VkIcdSurfaceXcb xcb_surf; -#endif // VK_USE_PLATFORM_XCB_KHR +#endif // VK_USE_PLATFORM_XCB_KHR #ifdef VK_USE_PLATFORM_XLIB_KHR VkIcdSurfaceXlib xlib_surf; -#endif // VK_USE_PLATFORM_XLIB_KHR +#endif // VK_USE_PLATFORM_XLIB_KHR VkIcdSurfaceDisplay display_surf; }; - uint32_t base_size; // Size of VkIcdSurfaceBase - uint32_t platform_size; // Size of corresponding VkIcdSurfaceXXX - uint32_t non_platform_offset; // Start offset to base_size - uint32_t entire_size; // Size of entire VkIcdSurface + uint32_t base_size; // Size of VkIcdSurfaceBase + uint32_t platform_size; // Size of corresponding VkIcdSurfaceXXX + uint32_t non_platform_offset; // Start offset to base_size + uint32_t entire_size; // Size of entire VkIcdSurface VkSurfaceKHR *real_icd_surfaces; } VkIcdSurface; -- 2.7.4