loader: Header include cleanup

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.
This commit is contained in:
Charles Giessen 2021-09-04 23:23:28 -06:00 committed by Charles Giessen
parent de30d28284
commit 4799c294d6
15 changed files with 90 additions and 77 deletions

View File

@ -26,13 +26,14 @@
/* cJSON */
/* JSON parser in C. */
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <ctype.h>
#include <float.h>
#include <limits.h>
#include <ctype.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "cJSON.h"
#include "allocation.h"

View File

@ -23,21 +23,22 @@
*
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifndef WIN32
#include <signal.h>
#else
#endif
#include "vk_loader_platform.h"
#include "debug_utils.h"
#include "vulkan/vk_layer.h"
#include "vk_object_types.h"
#include "allocation.h"
#include "debug_utils.h"
#include "loader.h"
#include "vk_loader_platform.h"
// VK_EXT_debug_report related items

View File

@ -19,8 +19,8 @@
* Author: Lenny Komow <lenny@lunarg.com>
*/
#include "vk_loader_platform.h"
#include "loader.h"
#include "vk_loader_platform.h"
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC optimize(3) // force gcc to use tail-calls
#endif

View File

@ -8,14 +8,15 @@
*/
#include "dirent_on_windows.h"
#include <errno.h>
#include <io.h> /* _findfirst and _findnext set errno iff they return -1 */
#include <stdlib.h>
#include <string.h>
#include "vk_loader_platform.h"
#include "allocation.h"
#include "loader.h"
#include "vk_loader_platform.h"
#ifdef __cplusplus
extern "C" {

View File

@ -20,16 +20,20 @@
* Author: Charles Giessen <charles@lunarg.com>
*/
#include "extension_manual.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "vk_loader_platform.h"
#include "loader.h"
#include "vk_loader_extensions.h"
#include <vulkan/vk_icd.h>
#include "wsi.h"
#include "log.h"
#include "debug_utils.h"
#include "loader.h"
#include "log.h"
#include "vk_loader_extensions.h"
#include "vk_loader_platform.h"
#include "wsi.h"
// ---- Manually added trampoline/terminator functions

View File

@ -21,6 +21,8 @@
#pragma once
#include <vulkan/vulkan.h>
// ---- Manually added trampoline/terminator functions
// These functions, for whatever reason, require more complex changes than

View File

@ -20,6 +20,8 @@
* Author: Charles Giessen <charles@lunarg.com>
*/
#include "gpa_helper.h"
#include <string.h>
#include "loader.h"

View File

@ -54,17 +54,19 @@
#else // _WIN32
#include <dirent.h>
#endif // _WIN32
#include "vk_loader_platform.h"
#include "allocation.h"
#include "loader.h"
#include "gpa_helper.h"
#include "debug_utils.h"
#include "wsi.h"
#include "log.h"
#include "get_environment.h"
#include "vulkan/vk_icd.h"
#include "allocation.h"
#include "cJSON.h"
#include "debug_utils.h"
#include "get_environment.h"
#include "gpa_helper.h"
#include "loader.h"
#include "log.h"
#include "murmurhash.h"
#include "vk_loader_platform.h"
#include "wsi.h"
#if defined(_WIN32)
#include <cfgmgr32.h>

View File

@ -27,11 +27,12 @@
* USE OR OTHER DEALINGS IN THE MATERIALS.
*/
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include "murmurhash.h"
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
uint32_t murmurhash(const char *key, size_t len, uint32_t seed) {
uint32_t c1 = 0xcc9e2d51;
uint32_t c2 = 0x1b873593;

View File

@ -29,6 +29,7 @@
#pragma once
#include <stddef.h>
#include <stdint.h>
#define MURMURHASH_VERSION "0.0.3"

View File

@ -28,8 +28,8 @@
// unknown to the loader, it will use this code. Technically, this is not trampoline
// code since we don't want to optimize it out.
#include "vk_loader_platform.h"
#include "loader.h"
#include "vk_loader_platform.h"
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC optimize(3) // force gcc to use tail-calls

View File

@ -27,14 +27,14 @@
#include <stdlib.h>
#include <string.h>
#include "vk_loader_platform.h"
#include "allocation.h"
#include "loader.h"
#include "debug_utils.h"
#include "wsi.h"
#include "gpa_helper.h"
#include "loader.h"
#include "log.h"
#include "vk_loader_extensions.h"
#include "gpa_helper.h"
#include "vk_loader_platform.h"
#include "wsi.h"
// Trampoline entrypoints are in this file for core Vulkan commands

View File

@ -20,50 +20,50 @@
* Author: Charles Giessen <charles@lunarg.com>
*/
// This code is used to pass on physical device extensions through the call chain. It must do this without creating a stack frame,
// because the actual parameters of the call are not known. Since the first parameter is known to be a VkPhysicalDevice, it can
// This code is used to pass on physical device extensions through the call chain. It must do this without creating a stack frame,
// because the actual parameters of the call are not known. Since the first parameter is known to be a VkPhysicalDevice, it can
// unwrap the physical device, overwriting the wrapped device, and then jump to the next function in the call chain. This code
// attempts to accomplish this by relying on tail-call optimizations, but there is no guarantee that this will work. As a result,
// this code is only compiled on systems where an assembly alternative has not been written.
#include "loader.h"
#include "log.h"
#include "vk_loader_platform.h"
#include "loader.h"
#include "log.h"
#include "vk_loader_platform.h"
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC optimize(3) // force gcc to use tail-calls
#endif
#if defined(__GNUC__) && !defined(__clang__)
#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)); \
}
// 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)); \
}
// 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, VULKAN_LOADER_ERROR_BIT, 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, VULKAN_LOADER_ERROR_BIT, 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); \
}
// Trampoline function macro for unknown physical device extension command.
#define DevExtTramp(num) \
VKAPI_ATTR void VKAPI_CALL vkdev_ext##num(VkDevice device) { \
const struct loader_dev_dispatch_table *disp; \
disp = loader_get_dev_dispatch(device); \
disp->ext_dispatch.dev_ext[num](device); \
}
#define DevExtTramp(num) \
VKAPI_ATTR void VKAPI_CALL vkdev_ext##num(VkDevice device) { \
const struct loader_dev_dispatch_table *disp; \
disp = loader_get_dev_dispatch(device); \
disp->ext_dispatch.dev_ext[num](device); \
}
// clang-format off
// Instantiations of the trampoline
PhysDevExtTramp(0)
PhysDevExtTramp(1)

View File

@ -29,6 +29,10 @@
#include <winsock2.h>
#endif // _WIN32
#include <assert.h>
#include <string.h>
#include <stdbool.h>
#if defined(__Fuchsia__)
#include "dlopen_fuchsia.h"
#endif // defined(__Fuchsia__)
@ -38,9 +42,6 @@
// Note: The following file is for dynamic loading:
#include <dlfcn.h>
#include <pthread.h>
#include <assert.h>
#include <string.h>
#include <stdbool.h>
#include <stdlib.h>
#include <libgen.h>
@ -54,22 +55,18 @@
#ifdef CreateEvent
#undef CreateEvent
#endif
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <io.h>
#include <stdbool.h>
#include <shlwapi.h>
#include <direct.h>
#endif // defined(_WIN32)
#include "vulkan/vk_platform.h"
#include "vulkan/vk_sdk_platform.h"
#include <vulkan/vulkan.h>
#include <vulkan/vk_layer.h>
#include <vulkan/vk_icd.h>
#include <assert.h>
#include "vk_loader_layer.h"
#include "vk_layer_dispatch_table.h"
#include "vk_loader_extensions.h"

View File

@ -25,13 +25,14 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "vk_loader_platform.h"
#include <vulkan/vk_icd.h>
#include "allocation.h"
#include "loader.h"
#include "wsi.h"
#include "log.h"
#include <vulkan/vk_icd.h>
#include "vk_loader_platform.h"
#include "wsi.h"
// The first ICD/Loader interface that support querying the SurfaceKHR from
// the ICDs.