Previously the loader would destroy any debug callbacks created during instance creation
to later create new ones during instance destruction. This required a memory allocation
to occur inside vkDestroyInstance, which can cause leaks if an OOM occurs during
instance destruction.
This commit simplifies the logic by keeping around the allocations made during instance
creation by moving them into their own debug node chain. Then during instance destruction
moves them back.
Also renames several functions to better describe their intended purpose.
Created wrapper functions loader_alloc, loader_calloc, loader_free,
and loader_realloc. Made the existing loader allocation functions use
them. Replaced manual usage of VkAllocatorCallbacks with the new
wrapper functions.
When handle wrapping is performed in a layer, the loader would provide the incorrect
instance handles after the recent handle validation changes. This was exposed by
RenderDoc.
Also add several tests to catch this case.
Separated headers into common groups, with system headers being first, then
Vulkan API headers, followed by loader headers.
Then alphabetized headers in each group. Due to moving _GNU_SOURCE to being set
by cmake, there isn't any implicit dependency between the include order used.
Made sure headers should be able to be included independently, such as
including the vulkan headers where appropriate.
Moves the many instances of #define _GNU_SOURCE into a single cmake call which
sets the macro in all translation units for the vulkan library. This way it
cannot be forgotten and makes behavior across the library consistent.
This commit separates the structure definitions from the function declarations.
The reason to do this is to allow splitting of loader.h/.c functionality into
individual headers, which may require access to these structs but don't need to
know about the other functions.
This change allows the loader to know extensions enabled in the layers
as well as extensions enabled but handled by layers.
This should fix several issues where the enabled extensions is not
known soon enough for layers to use.
Previously, clang-format was required for all new commits but the codebase
itself wasn't conformant. This commit formats the source files in the loader
folder.
When creating debug callbacks or messengers, each of them is added to a
linked list from the terminator, with the handle provided by the ICD.
When enabling some validation layers, this handle is renamed as part of
the chain and the application gets a different one.
In the removal process, the application usually receives one of these
function pointers using vkGetInstanceProcAddr:
- debug_utils_DestroyDebugReportCallbackEXT
- debug_utils_DestroyDebugUtilsMessengerEXT
Those trigger the chain calls but then try to remove the callback or
messenger from the linked list using the application-level handle, which
is not found because it doesn't match the one from the ICD.
The linked list should be accessed from the destruction terminators,
when the handle has already been unwrapped by the layers.
If an ICD also supported the VK_EXT_debug_utils extension, then
any call to vkSubmitDebutUtilsMessageEXT would get duplicated.
Change-Id: Ica3224ee598a99a925ec9343b6618d4d8ba190d0
This affects the loader, scripts, and layers and introduces the
changes to support the VK_EXT_debug_utils extension.
Change-Id: Ia5336f63e85b00f1e59416c06aacd4ae331fd692