diff --git a/.gitmodules b/.gitmodules index d2a04bcb6..3a3621c2d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -37,3 +37,6 @@ [submodule "third_party/spirv-headers"] path = third_party/spirv-headers url = https://github.com/KhronosGroup/SPIRV-Headers +[submodule "third_party/volk"] + path = third_party/volk + url = https://github.com/zeux/volk.git diff --git a/premake5.lua b/premake5.lua index a3dd2a3c8..686c77e84 100644 --- a/premake5.lua +++ b/premake5.lua @@ -228,7 +228,7 @@ solution("xenia") include("third_party/libav.lua") include("third_party/snappy.lua") include("third_party/spirv-tools.lua") - include("third_party/vulkan/loader") + include("third_party/volk.lua") include("third_party/xxhash.lua") include("third_party/yaml-cpp.lua") diff --git a/src/xenia/app/premake5.lua b/src/xenia/app/premake5.lua index d4d9bb8e1..3b4b4b9c6 100644 --- a/src/xenia/app/premake5.lua +++ b/src/xenia/app/premake5.lua @@ -17,7 +17,7 @@ project("xenia-app") "libavutil", "snappy", "spirv-tools", - "vulkan-loader", + "volk", "xenia-apu", "xenia-apu-nop", "xenia-base", diff --git a/src/xenia/gpu/vulkan/buffer_cache.cc b/src/xenia/gpu/vulkan/buffer_cache.cc index 23e93e67a..0a0162d35 100644 --- a/src/xenia/gpu/vulkan/buffer_cache.cc +++ b/src/xenia/gpu/vulkan/buffer_cache.cc @@ -15,8 +15,7 @@ #include "xenia/base/profiling.h" #include "xenia/gpu/gpu_flags.h" #include "xenia/gpu/vulkan/vulkan_gpu_flags.h" - -#include "third_party/vulkan/vk_mem_alloc.h" +#include "xenia/ui/vulkan/vulkan_mem_alloc.h" using namespace xe::gpu::xenos; @@ -120,9 +119,13 @@ VkResult BufferCache::Initialize() { } // Create a memory allocator for textures. + VmaVulkanFunctions vulkan_funcs = {}; + ui::vulkan::FillVMAVulkanFunctions(&vulkan_funcs); + VmaAllocatorCreateInfo alloc_info = { - 0, *device_, *device_, 0, 0, nullptr, nullptr, + 0, *device_, *device_, 0, 0, nullptr, nullptr, 0, nullptr, &vulkan_funcs, }; + status = vmaCreateAllocator(&alloc_info, &mem_allocator_); if (status != VK_SUCCESS) { return status; diff --git a/src/xenia/gpu/vulkan/premake5.lua b/src/xenia/gpu/vulkan/premake5.lua index 146ac2bd7..b399914a8 100644 --- a/src/xenia/gpu/vulkan/premake5.lua +++ b/src/xenia/gpu/vulkan/premake5.lua @@ -7,7 +7,7 @@ project("xenia-gpu-vulkan") kind("StaticLib") language("C++") links({ - "vulkan-loader", + "volk", "xenia-base", "xenia-gpu", "xenia-ui", @@ -40,7 +40,7 @@ project("xenia-gpu-vulkan-trace-viewer") "libavutil", "snappy", "spirv-tools", - "vulkan-loader", + "volk", "xenia-apu", "xenia-apu-nop", "xenia-base", @@ -112,7 +112,7 @@ project("xenia-gpu-vulkan-trace-dump") "libavutil", "snappy", "spirv-tools", - "vulkan-loader", + "volk", "xenia-apu", "xenia-apu-nop", "xenia-base", diff --git a/src/xenia/gpu/vulkan/texture_cache.cc b/src/xenia/gpu/vulkan/texture_cache.cc index 15369643a..95ed924c5 100644 --- a/src/xenia/gpu/vulkan/texture_cache.cc +++ b/src/xenia/gpu/vulkan/texture_cache.cc @@ -17,8 +17,7 @@ #include "xenia/gpu/sampler_info.h" #include "xenia/gpu/texture_info.h" #include "xenia/gpu/vulkan/vulkan_gpu_flags.h" - -#include "third_party/vulkan/vk_mem_alloc.h" +#include "xenia/ui/vulkan/vulkan_mem_alloc.h" namespace xe { namespace gpu { @@ -198,8 +197,11 @@ VkResult TextureCache::Initialize() { } // Create a memory allocator for textures. + VmaVulkanFunctions vulkan_funcs = {}; + ui::vulkan::FillVMAVulkanFunctions(&vulkan_funcs); + VmaAllocatorCreateInfo alloc_info = { - 0, *device_, *device_, 0, 0, nullptr, nullptr, + 0, *device_, *device_, 0, 0, nullptr, nullptr, 0, nullptr, &vulkan_funcs, }; status = vmaCreateAllocator(&alloc_info, &mem_allocator_); if (status != VK_SUCCESS) { diff --git a/src/xenia/ui/vulkan/premake5.lua b/src/xenia/ui/vulkan/premake5.lua index ab31e3b90..51fd69aa5 100644 --- a/src/xenia/ui/vulkan/premake5.lua +++ b/src/xenia/ui/vulkan/premake5.lua @@ -31,7 +31,7 @@ project("xenia-ui-window-vulkan-demo") links({ "gflags", "imgui", - "vulkan-loader", + "volk", "xenia-base", "xenia-ui", "xenia-ui-spirv", diff --git a/src/xenia/ui/vulkan/vulkan.h b/src/xenia/ui/vulkan/vulkan.h index 38a4400f7..b091cb63f 100644 --- a/src/xenia/ui/vulkan/vulkan.h +++ b/src/xenia/ui/vulkan/vulkan.h @@ -22,8 +22,8 @@ #error Platform not yet supported. #endif // XE_PLATFORM_WIN32 -// We are statically linked with the loader, so use function prototypes. -#define VK_PROTOTYPES +// We use a loader with its own function prototypes. +#include "third_party/volk/volk.h" #include "third_party/vulkan/vulkan.h" // NOTE: header order matters here, unfortunately: diff --git a/src/xenia/ui/vulkan/vulkan_instance.cc b/src/xenia/ui/vulkan/vulkan_instance.cc index efadcfa39..1eb967b9b 100644 --- a/src/xenia/ui/vulkan/vulkan_instance.cc +++ b/src/xenia/ui/vulkan/vulkan_instance.cc @@ -16,6 +16,7 @@ #include #include "third_party/renderdoc/renderdoc_app.h" +#include "third_party/volk/volk.h" #include "xenia/base/assert.h" #include "xenia/base/logging.h" @@ -72,6 +73,10 @@ VulkanInstance::~VulkanInstance() { DestroyInstance(); } bool VulkanInstance::Initialize() { auto version = Version::Parse(VK_API_VERSION); XELOGVK("Initializing Vulkan %s...", version.pretty_string.c_str()); + if (volkInitialize() != VK_SUCCESS) { + XELOGE("volkInitialize() failed!"); + return false; + } // Get all of the global layers and extensions provided by the system. if (!QueryGlobals()) { @@ -271,6 +276,9 @@ bool VulkanInstance::CreateInstance() { return false; } + // Load Vulkan entrypoints and extensions. + volkLoadInstance(handle); + // Enable debug validation, if needed. EnableDebugValidation(); diff --git a/src/xenia/ui/vulkan/vulkan_mem_alloc.h b/src/xenia/ui/vulkan/vulkan_mem_alloc.h new file mode 100644 index 000000000..caf89aae6 --- /dev/null +++ b/src/xenia/ui/vulkan/vulkan_mem_alloc.h @@ -0,0 +1,44 @@ +/** + ****************************************************************************** + * Xenia : Xbox 360 Emulator Research Project * + ****************************************************************************** + * Copyright 2018 Ben Vanik. All rights reserved. * + * Released under the BSD license - see LICENSE in the root for more details. * + ****************************************************************************** + */ + +#ifndef XENIA_UI_VULKAN_VULKAN_MEM_ALLOC_H_ +#define XENIA_UI_VULKAN_VULKAN_MEM_ALLOC_H_ + +#include "third_party/volk/volk.h" + +#define VMA_STATIC_VULKAN_FUNCTIONS 0 +#include "third_party/vulkan/vk_mem_alloc.h" + +namespace xe { +namespace ui { +namespace vulkan { + +inline void FillVMAVulkanFunctions(VmaVulkanFunctions* vma_funcs) { + vma_funcs->vkGetPhysicalDeviceProperties = vkGetPhysicalDeviceProperties; + vma_funcs->vkGetPhysicalDeviceMemoryProperties = + vkGetPhysicalDeviceMemoryProperties; + vma_funcs->vkAllocateMemory = vkAllocateMemory; + vma_funcs->vkFreeMemory = vkFreeMemory; + vma_funcs->vkMapMemory = vkMapMemory; + vma_funcs->vkUnmapMemory = vkUnmapMemory; + vma_funcs->vkBindBufferMemory = vkBindBufferMemory; + vma_funcs->vkBindImageMemory = vkBindImageMemory; + vma_funcs->vkGetBufferMemoryRequirements = vkGetBufferMemoryRequirements; + vma_funcs->vkGetImageMemoryRequirements = vkGetImageMemoryRequirements; + vma_funcs->vkCreateBuffer = vkCreateBuffer; + vma_funcs->vkDestroyBuffer = vkDestroyBuffer; + vma_funcs->vkCreateImage = vkCreateImage; + vma_funcs->vkDestroyImage = vkDestroyImage; +} + +} // namespace vulkan +} // namespace ui +} // namespace xe + +#endif // XENIA_UI_VULKAN_VULKAN_MEM_ALLOC_H_ \ No newline at end of file diff --git a/src/xenia/ui/vulkan/vulkan_util.cc b/src/xenia/ui/vulkan/vulkan_util.cc index 9c0a4238a..2e2034f65 100644 --- a/src/xenia/ui/vulkan/vulkan_util.cc +++ b/src/xenia/ui/vulkan/vulkan_util.cc @@ -14,7 +14,7 @@ // Implement AMD's VMA here. #define VMA_IMPLEMENTATION -#include "third_party/vulkan/vk_mem_alloc.h" +#include "xenia/ui/vulkan/vulkan_mem_alloc.h" namespace xe { namespace ui { diff --git a/third_party/volk b/third_party/volk new file mode 160000 index 000000000..30a851b67 --- /dev/null +++ b/third_party/volk @@ -0,0 +1 @@ +Subproject commit 30a851b67e129a3d91f191b2e9dcdad65ba98438 diff --git a/third_party/volk.lua b/third_party/volk.lua new file mode 100644 index 000000000..7ba0dd618 --- /dev/null +++ b/third_party/volk.lua @@ -0,0 +1,30 @@ +group("third_party") +project("volk") + uuid("C9781C93-2DF5-47A2-94EE-2C5EBED61239") + kind("StaticLib") + language("C") + + defines({ + "_LIB", + "API_NAME=\"vulkan\"", + }) + removedefines({ + "_UNICODE", + "UNICODE", + }) + includedirs({ + "volk", + }) + files({ + "volk/volk.c", + "volk/volk.h", + }) + + filter("platforms:Windows") + defines({ + "VK_USE_PLATFORM_WIN32_KHR", + }) + filter("platforms:Linux") + defines({ + "VK_USE_PLATFORM_XCB_KHR", + }) diff --git a/third_party/vulkan/loader/cJSON.c b/third_party/vulkan/loader/cJSON.c deleted file mode 100644 index a7671c4a0..000000000 --- a/third_party/vulkan/loader/cJSON.c +++ /dev/null @@ -1,1212 +0,0 @@ -/* - Copyright (c) 2009 Dave Gamble - Copyright (c) 2015-2016 The Khronos Group Inc. - Copyright (c) 2015-2016 Valve Corporation - Copyright (c) 2015-2016 LunarG, Inc. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. -*/ - -/* cJSON */ -/* JSON parser in C. */ - -#include -#include -#include -#include -#include -#include -#include -#include "cJSON.h" - -static const char *ep; - -const char *cJSON_GetErrorPtr(void) { return ep; } - -static void *(*cJSON_malloc)(size_t sz) = malloc; -static void (*cJSON_free)(void *ptr) = free; - -static char *cJSON_strdup(const char *str) { - size_t len; - char *copy; - - len = strlen(str) + 1; - if (!(copy = (char *)cJSON_malloc(len))) return 0; - memcpy(copy, str, len); - return copy; -} - -void cJSON_InitHooks(cJSON_Hooks *hooks) { - if (!hooks) { /* Reset hooks */ - cJSON_malloc = malloc; - cJSON_free = free; - return; - } - - cJSON_malloc = (hooks->malloc_fn) ? hooks->malloc_fn : malloc; - cJSON_free = (hooks->free_fn) ? hooks->free_fn : free; -} - -/* Internal constructor. */ -static cJSON *cJSON_New_Item(void) { - cJSON *node = (cJSON *)cJSON_malloc(sizeof(cJSON)); - if (node) memset(node, 0, sizeof(cJSON)); - return node; -} - -/* Delete a cJSON structure. */ -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); - cJSON_free(c); - c = next; - } -} - -void cJSON_Free(void *p) { cJSON_free(p); } - -/* Parse the input text to generate a number, and populate the result into item. - */ -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 - n = (n * 10.0) + (*num++ - '0'); - while (*num >= '0' && *num <= '9'); /* Number? */ - if (*num == '.' && num[1] >= '0' && num[1] <= '9') { - num++; - do - n = (n * 10.0) + (*num++ - '0'), scale--; - while (*num >= '0' && *num <= '9'); - } /* Fractional part? */ - if (*num == 'e' || *num == 'E') /* Exponent? */ - { - num++; - if (*num == '+') - num++; - else if (*num == '-') - 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 = +/- - number.fraction * - 10^+/- exponent */ - - item->valuedouble = n; - item->valueint = (int)n; - item->type = cJSON_Number; - return num; -} - -static size_t pow2gt(size_t x) { - --x; - x |= x >> 1; - x |= x >> 2; - x |= x >> 4; - x |= x >> 8; - x |= x >> 16; - return x + 1; -} - -typedef struct { - char *buffer; - size_t length; - size_t offset; -} printbuffer; - -static char *ensure(printbuffer *p, size_t needed) { - char *newbuffer; - size_t newsize; - if (!p || !p->buffer) return 0; - needed += p->offset; - if (needed <= p->length) return p->buffer + p->offset; - - newsize = pow2gt(needed); - newbuffer = (char *)cJSON_malloc(newsize); - if (!newbuffer) { - cJSON_free(p->buffer); - p->length = 0, p->buffer = 0; - return 0; - } - if (newbuffer) memcpy(newbuffer, p->buffer, p->length); - cJSON_free(p->buffer); - p->length = newsize; - p->buffer = newbuffer; - return newbuffer + p->offset; -} - -static size_t update(printbuffer *p) { - char *str; - if (!p || !p->buffer) return 0; - str = p->buffer + p->offset; - return p->offset + strlen(str); -} - -/* Render the number nicely from the given item into a string. */ -static char *print_number(cJSON *item, printbuffer *p) { - char *str = 0; - double d = item->valuedouble; - if (d == 0) { - if (p) - str = ensure(p, 2); - else - str = (char *)cJSON_malloc(2); /* special case for 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); - } else { - if (p) - str = ensure(p, 64); - else - str = (char *)cJSON_malloc(64); /* This is a nice tradeoff. */ - if (str) { - if (fabs(floor(d) - d) <= DBL_EPSILON && fabs(d) < 1.0e60) - sprintf(str, "%.0f", d); - else if (fabs(d) < 1.0e-6 || fabs(d) > 1.0e9) - sprintf(str, "%e", d); - else - sprintf(str, "%f", d); - } - } - return str; -} - -static unsigned parse_hex4(const char *str) { - unsigned h = 0; - if (*str >= '0' && *str <= '9') - h += (*str) - '0'; - else if (*str >= 'A' && *str <= 'F') - h += 10 + (*str) - 'A'; - else if (*str >= 'a' && *str <= 'f') - h += 10 + (*str) - 'a'; - else - return 0; - h = h << 4; - str++; - if (*str >= '0' && *str <= '9') - h += (*str) - '0'; - else if (*str >= 'A' && *str <= 'F') - h += 10 + (*str) - 'A'; - else if (*str >= 'a' && *str <= 'f') - h += 10 + (*str) - 'a'; - else - return 0; - h = h << 4; - str++; - if (*str >= '0' && *str <= '9') - h += (*str) - '0'; - else if (*str >= 'A' && *str <= 'F') - h += 10 + (*str) - 'A'; - else if (*str >= 'a' && *str <= 'f') - h += 10 + (*str) - 'a'; - else - return 0; - h = h << 4; - str++; - if (*str >= '0' && *str <= '9') - h += (*str) - '0'; - else if (*str >= 'A' && *str <= 'F') - h += 10 + (*str) - 'A'; - else if (*str >= 'a' && *str <= 'f') - h += 10 + (*str) - 'a'; - else - return 0; - return h; -} - -/* Parse the input text into an unescaped cstring, and populate item. */ -static const unsigned char firstByteMark[7] = {0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC}; -static const char *parse_string(cJSON *item, const char *str) { - const char *ptr = str + 1; - char *ptr2; - char *out; - int len = 0; - unsigned uc, uc2; - if (*str != '\"') { - ep = str; - return 0; - } /* not a string! */ - - while (*ptr != '\"' && *ptr && ++len) - 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; - - ptr = str + 1; - ptr2 = out; - while (*ptr != '\"' && *ptr) { - if (*ptr != '\\') - *ptr2++ = *ptr++; - 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; - } - ptr++; - } - } - *ptr2 = 0; - if (*ptr == '\"') ptr++; - item->valuestring = out; - item->type = cJSON_String; - return ptr; -} - -/* Render the cstring provided to an escaped version that can be printed. */ -static char *print_string_ptr(const char *str, printbuffer *p) { - const char *ptr; - char *ptr2; - char *out; - size_t len = 0, flag = 0; - unsigned char token; - - 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; - ptr2 = out; - *ptr2++ = '\"'; - strcpy(ptr2, str); - ptr2[len] = '\"'; - ptr2[len + 1] = 0; - return out; - } - - if (!str) { - if (p) - out = ensure(p, 3); - else - out = (char *)cJSON_malloc(3); - if (!out) return 0; - strcpy(out, "\"\""); - return out; - } - ptr = str; - while ((token = *ptr) && ++len) { - if (strchr("\"\\\b\f\n\r\t", token)) - len++; - else if (token < 32) - len += 5; - ptr++; - } - - if (p) - out = ensure(p, len + 3); - else - out = (char *)cJSON_malloc(len + 3); - if (!out) return 0; - - ptr2 = out; - ptr = str; - *ptr2++ = '\"'; - while (*ptr) { - if ((unsigned char)*ptr > 31 && *ptr != '\"' && *ptr != '\\') - *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 */ - } - } - } - *ptr2++ = '\"'; - *ptr2++ = 0; - return out; -} -/* Invote print_string_ptr (which is useful) on an item. */ -static char *print_string(cJSON *item, printbuffer *p) { return print_string_ptr(item->valuestring, p); } - -/* Predeclare these prototypes. */ -static const char *parse_value(cJSON *item, const char *value); -static char *print_value(cJSON *item, int depth, int fmt, printbuffer *p); -static const char *parse_array(cJSON *item, const char *value); -static char *print_array(cJSON *item, int depth, int fmt, printbuffer *p); -static const char *parse_object(cJSON *item, const char *value); -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++; - return in; -} - -/* Parse an object - create a new root, and populate. */ -cJSON *cJSON_ParseWithOpts(const char *value, const char **return_parse_end, int require_null_terminated) { - const char *end = 0; - cJSON *c = cJSON_New_Item(); - ep = 0; - if (!c) return 0; /* memory fail */ - - end = parse_value(c, skip(value)); - if (!end) { - cJSON_Delete(c); - return 0; - } /* parse failure. ep is set. */ - - /* if we require null-terminated JSON without appended garbage, skip and - * then check for a null terminator */ - if (require_null_terminated) { - end = skip(end); - if (*end) { - cJSON_Delete(c); - ep = end; - return 0; - } - } - if (return_parse_end) *return_parse_end = end; - return c; -} -/* Default options for cJSON_Parse */ -cJSON *cJSON_Parse(const char *value) { return cJSON_ParseWithOpts(value, 0, 0); } - -/* Render a cJSON item/entity/structure to text. */ -char *cJSON_Print(cJSON *item) { return print_value(item, 0, 1, 0); } -char *cJSON_PrintUnformatted(cJSON *item) { return print_value(item, 0, 0, 0); } - -char *cJSON_PrintBuffered(cJSON *item, int prebuffer, int fmt) { - printbuffer p; - p.buffer = (char *)cJSON_malloc(prebuffer); - p.length = prebuffer; - p.offset = 0; - return print_value(item, 0, fmt, &p); -} - -/* 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 (!strncmp(value, "null", 4)) { - item->type = cJSON_NULL; - return value + 4; - } - if (!strncmp(value, "false", 5)) { - item->type = cJSON_False; - return value + 5; - } - if (!strncmp(value, "true", 4)) { - item->type = cJSON_True; - item->valueint = 1; - return value + 4; - } - if (*value == '\"') { - return parse_string(item, value); - } - if (*value == '-' || (*value >= '0' && *value <= '9')) { - return parse_number(item, value); - } - if (*value == '[') { - return parse_array(item, value); - } - if (*value == '{') { - return parse_object(item, value); - } - - ep = value; - return 0; /* failure. */ -} - -/* 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 (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; - } - } 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; - } - } - return out; -} - -/* Build an array from input text. */ -static const char *parse_array(cJSON *item, const char *value) { - cJSON *child; - if (*value != '[') { - ep = value; - return 0; - } /* not an array! */ - - item->type = cJSON_Array; - value = skip(value + 1); - if (*value == ']') return value + 1; /* empty array. */ - - item->child = child = cJSON_New_Item(); - if (!item->child) return 0; /* memory fail */ - value = skip(parse_value(child, skip(value))); /* skip any spacing, get the value. */ - if (!value) return 0; - - while (*value == ',') { - cJSON *new_item; - 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 value + 1; /* end of array */ - ep = value; - return 0; /* malformed. */ -} - -/* Render an array to text */ -static char *print_array(cJSON *item, int depth, int fmt, printbuffer *p) { - char **entries; - char *out = 0, *ptr, *ret; - size_t len = 5; - cJSON *child = item->child; - int numentries = 0, fail = 0, j = 0; - size_t tmplen = 0, i = 0; - - /* How many entries in the array? */ - 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, "[]"); - return out; - } - - if (p) { - /* Compose the output array. */ - i = p->offset; - ptr = ensure(p, 1); - if (!ptr) return 0; - *ptr = '['; - p->offset++; - child = item->child; - while (child && !fail) { - print_value(child, depth + 1, fmt, p); - p->offset = update(p); - if (child->next) { - len = fmt ? 2 : 1; - ptr = ensure(p, len + 1); - if (!ptr) return 0; - *ptr++ = ','; - if (fmt) *ptr++ = ' '; - *ptr = 0; - p->offset += len; - } - child = child->next; - } - ptr = ensure(p, 2); - 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; - memset(entries, 0, numentries * sizeof(char *)); - /* Retrieve all the results: */ - child = item->child; - while (child && !fail) { - ret = print_value(child, depth + 1, fmt, 0); - entries[i++] = ret; - if (ret) - len += strlen(ret) + 2 + (fmt ? 1 : 0); - else - fail = 1; - child = child->next; - } - - /* If we didn't fail, try to malloc the output string */ - if (!fail) out = (char *)cJSON_malloc(len); - /* If that fails, we fail. */ - if (!out) fail = 1; - - /* Handle failure. */ - if (fail) { - for (j = 0; j < numentries; j++) - if (entries[j]) cJSON_free(entries[j]); - cJSON_free(entries); - return 0; - } - - /* Compose the output array. */ - *out = '['; - ptr = out + 1; - *ptr = 0; - for (j = 0; j < numentries; j++) { - tmplen = strlen(entries[j]); - memcpy(ptr, entries[j], tmplen); - ptr += tmplen; - if (j != numentries - 1) { - *ptr++ = ','; - if (fmt) *ptr++ = ' '; - *ptr = 0; - } - cJSON_free(entries[j]); - } - cJSON_free(entries); - *ptr++ = ']'; - *ptr++ = 0; - } - return out; -} - -/* Build an object from the text. */ -static const char *parse_object(cJSON *item, const char *value) { - cJSON *child; - if (*value != '{') { - ep = value; - return 0; - } /* not an object! */ - - item->type = cJSON_Object; - value = skip(value + 1); - if (*value == '}') return value + 1; /* empty array. */ - - item->child = child = cJSON_New_Item(); - if (!item->child) return 0; - value = skip(parse_string(child, skip(value))); - if (!value) return 0; - child->string = child->valuestring; - child->valuestring = 0; - if (*value != ':') { - ep = value; - return 0; - } /* fail! */ - value = skip(parse_value(child, skip(value + 1))); /* skip any spacing, get the value. */ - if (!value) return 0; - - while (*value == ',') { - cJSON *new_item; - 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; - child->string = child->valuestring; - child->valuestring = 0; - if (*value != ':') { - ep = 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 value + 1; /* end of array */ - ep = value; - return 0; /* malformed. */ -} - -/* Render an object to text. */ -static char *print_object(cJSON *item, int depth, int fmt, printbuffer *p) { - char **entries = 0, **names = 0; - char *out = 0, *ptr, *ret, *str; - int j; - cJSON *child = item->child; - 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; - /* 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; - ptr = out; - *ptr++ = '{'; - if (fmt) { - *ptr++ = '\n'; - for (j = 0; j < depth - 1; j++) *ptr++ = '\t'; - } - *ptr++ = '}'; - *ptr++ = 0; - return out; - } - if (p) { - /* Compose the output: */ - i = p->offset; - len = fmt ? 2 : 1; - ptr = ensure(p, len + 1); - if (!ptr) return 0; - *ptr++ = '{'; - if (fmt) *ptr++ = '\n'; - *ptr = 0; - p->offset += len; - child = item->child; - depth++; - while (child) { - if (fmt) { - ptr = ensure(p, depth); - if (!ptr) return 0; - for (j = 0; j < depth; j++) *ptr++ = '\t'; - p->offset += depth; - } - print_string_ptr(child->string, p); - p->offset = update(p); - - len = fmt ? 2 : 1; - ptr = ensure(p, len); - if (!ptr) return 0; - *ptr++ = ':'; - if (fmt) *ptr++ = '\t'; - p->offset += len; - - print_value(child, depth, fmt, p); - p->offset = update(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'; - *ptr = 0; - p->offset += len; - child = child->next; - } - ptr = ensure(p, fmt ? (depth + 1) : 2); - if (!ptr) return 0; - if (fmt) - 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; - names = (char **)cJSON_malloc(numentries * sizeof(char *)); - if (!names) { - cJSON_free(entries); - return 0; - } - memset(entries, 0, sizeof(char *) * numentries); - memset(names, 0, sizeof(char *) * numentries); - - /* Collect all the results into our arrays: */ - child = item->child; - 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); - if (str && ret) - len += strlen(ret) + strlen(str) + 2 + (fmt ? 2 + depth : 0); - else - fail = 1; - child = child->next; - } - - /* Try to allocate the output string */ - 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]); - } - cJSON_free(names); - cJSON_free(entries); - return 0; - } - - /* Compose the output: */ - *out = '{'; - ptr = out + 1; - if (fmt) *ptr++ = '\n'; - *ptr = 0; - for (j = 0; j < numentries; j++) { - if (fmt) - for (k = 0; k < depth; k++) *ptr++ = '\t'; - tmplen = strlen(names[j]); - memcpy(ptr, names[j], tmplen); - ptr += tmplen; - *ptr++ = ':'; - if (fmt) *ptr++ = '\t'; - strcpy(ptr, entries[j]); - ptr += strlen(entries[j]); - if (j != numentries - 1) *ptr++ = ','; - if (fmt) *ptr++ = '\n'; - *ptr = 0; - cJSON_free(names[j]); - cJSON_free(entries[j]); - } - - cJSON_free(names); - cJSON_free(entries); - if (fmt) - for (j = 0; j < depth - 1; j++) *ptr++ = '\t'; - *ptr++ = '}'; - *ptr++ = 0; - } - return out; -} - -/* Get Array size/item / object item. */ -int cJSON_GetArraySize(cJSON *array) { - cJSON *c = array->child; - int i = 0; - 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; - return c; -} -cJSON *cJSON_GetObjectItem(cJSON *object, const char *string) { - cJSON *c = object->child; - while (c && strcmp(c->string, string)) c = c->next; - return c; -} - -/* Utility for array list handling. */ -static void suffix_object(cJSON *prev, cJSON *item) { - prev->next = item; - item->prev = prev; -} -/* Utility for handling references. */ -static cJSON *create_reference(cJSON *item) { - cJSON *ref = cJSON_New_Item(); - if (!ref) return 0; - memcpy(ref, item, sizeof(cJSON)); - ref->string = 0; - ref->type |= cJSON_IsReference; - ref->next = ref->prev = 0; - return ref; -} - -/* Add item to array/object. */ -void cJSON_AddItemToArray(cJSON *array, cJSON *item) { - cJSON *c = array->child; - if (!item) return; - if (!c) { - array->child = item; - } else { - 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); - 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); - item->string = (char *)string; - item->type |= cJSON_StringIsConst; - cJSON_AddItemToArray(object, item); -} -void cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item) { cJSON_AddItemToArray(array, create_reference(item)); } -void cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item) { - cJSON_AddItemToObject(object, string, create_reference(item)); -} - -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; - c->prev = c->next = 0; - return c; -} -void cJSON_DeleteItemFromArray(cJSON *array, int which) { cJSON_Delete(cJSON_DetachItemFromArray(array, which)); } -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); - return 0; -} -void cJSON_DeleteItemFromObject(cJSON *object, const char *string) { cJSON_Delete(cJSON_DetachItemFromObject(object, string)); } - -/* 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--; - if (!c) { - cJSON_AddItemToArray(array, newitem); - return; - } - newitem->next = c; - newitem->prev = c->prev; - c->prev = newitem; - if (c == array->child) - array->child = newitem; - else - newitem->prev->next = 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; - newitem->next = c->next; - newitem->prev = c->prev; - if (newitem->next) newitem->next->prev = newitem; - if (c == array->child) - array->child = newitem; - else - newitem->prev->next = newitem; - c->next = c->prev = 0; - cJSON_Delete(c); -} -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; - if (c) { - newitem->string = cJSON_strdup(string); - cJSON_ReplaceItemInArray(object, i, newitem); - } -} - -/* Create basic types: */ -cJSON *cJSON_CreateNull(void) { - cJSON *item = cJSON_New_Item(); - if (item) item->type = cJSON_NULL; - return item; -} -cJSON *cJSON_CreateTrue(void) { - cJSON *item = cJSON_New_Item(); - if (item) item->type = cJSON_True; - return item; -} -cJSON *cJSON_CreateFalse(void) { - cJSON *item = cJSON_New_Item(); - 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; - return item; -} -cJSON *cJSON_CreateNumber(double num) { - cJSON *item = cJSON_New_Item(); - if (item) { - item->type = cJSON_Number; - item->valuedouble = num; - item->valueint = (int)num; - } - return item; -} -cJSON *cJSON_CreateString(const char *string) { - cJSON *item = cJSON_New_Item(); - if (item) { - item->type = cJSON_String; - item->valuestring = cJSON_strdup(string); - } - return item; -} -cJSON *cJSON_CreateArray(void) { - cJSON *item = cJSON_New_Item(); - if (item) item->type = cJSON_Array; - return item; -} -cJSON *cJSON_CreateObject(void) { - cJSON *item = cJSON_New_Item(); - if (item) item->type = cJSON_Object; - return item; -} - -/* Create Arrays: */ -cJSON *cJSON_CreateIntArray(const int *numbers, int count) { - int i; - cJSON *n = 0, *p = 0, *a = cJSON_CreateArray(); - for (i = 0; a && i < count; i++) { - n = cJSON_CreateNumber(numbers[i]); - if (!i) - a->child = n; - else - suffix_object(p, n); - p = n; - } - return a; -} -cJSON *cJSON_CreateFloatArray(const float *numbers, int count) { - int i; - cJSON *n = 0, *p = 0, *a = cJSON_CreateArray(); - for (i = 0; a && i < count; i++) { - n = cJSON_CreateNumber(numbers[i]); - if (!i) - a->child = n; - else - suffix_object(p, n); - p = n; - } - return a; -} -cJSON *cJSON_CreateDoubleArray(const double *numbers, int count) { - int i; - cJSON *n = 0, *p = 0, *a = cJSON_CreateArray(); - for (i = 0; a && i < count; i++) { - n = cJSON_CreateNumber(numbers[i]); - if (!i) - a->child = n; - else - suffix_object(p, n); - p = n; - } - return a; -} -cJSON *cJSON_CreateStringArray(const char **strings, int count) { - int i; - cJSON *n = 0, *p = 0, *a = cJSON_CreateArray(); - for (i = 0; a && i < count; i++) { - n = cJSON_CreateString(strings[i]); - if (!i) - a->child = n; - else - suffix_object(p, n); - p = n; - } - return a; -} - -/* Duplication */ -cJSON *cJSON_Duplicate(cJSON *item, int recurse) { - cJSON *newitem, *cptr, *nptr = 0, *newchild; - /* Bail on bad ptr */ - if (!item) return 0; - /* Create new item */ - newitem = cJSON_New_Item(); - 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) { - newitem->valuestring = cJSON_strdup(item->valuestring); - if (!newitem->valuestring) { - cJSON_Delete(newitem); - return 0; - } - } - if (item->string) { - newitem->string = cJSON_strdup(item->string); - if (!newitem->string) { - cJSON_Delete(newitem); - return 0; - } - } - /* If non-recursive, then we're done! */ - if (!recurse) return newitem; - /* Walk the ->next chain for the child. */ - cptr = item->child; - while (cptr) { - newchild = cJSON_Duplicate(cptr, 1); /* Duplicate (with recurse) each item in the ->next chain */ - if (!newchild) { - cJSON_Delete(newitem); - return 0; - } - if (nptr) { - nptr->next = newchild, newchild->prev = nptr; - nptr = newchild; - } /* If newitem->child already set, then crosswire ->prev and ->next and - move on */ - else { - newitem->child = newchild; - nptr = newchild; - } /* Set newitem->child and move to it */ - cptr = cptr->next; - } - return newitem; -} - -void cJSON_Minify(char *json) { - char *into = json; - while (*json) { - if (*json == ' ') - json++; - else if (*json == '\t') - json++; /* Whitespace characters. */ - else if (*json == '\r') - json++; - else if (*json == '\n') - json++; - else if (*json == '/' && json[1] == '/') - while (*json && *json != '\n') json++; /* double-slash comments, to end of line. */ - else if (*json == '/' && json[1] == '*') { - while (*json && !(*json == '*' && json[1] == '/')) json++; - json += 2; - } /* multiline comments. */ - else if (*json == '\"') { - *into++ = *json++; - while (*json && *json != '\"') { - if (*json == '\\') *into++ = *json++; - *into++ = *json++; - } - *into++ = *json++; - } /* string literals, which are \" sensitive. */ - else - *into++ = *json++; /* All other characters. */ - } - *into = 0; /* and null-terminate. */ -} diff --git a/third_party/vulkan/loader/cJSON.h b/third_party/vulkan/loader/cJSON.h deleted file mode 100644 index f0059abdc..000000000 --- a/third_party/vulkan/loader/cJSON.h +++ /dev/null @@ -1,174 +0,0 @@ -/* - Copyright (c) 2009 Dave Gamble - Copyright (c) 2015-2016 The Khronos Group Inc. - Copyright (c) 2015-2016 Valve Corporation - Copyright (c) 2015-2016 LunarG, Inc. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. -*/ - -#ifndef cJSON__h -#define cJSON__h - -#ifdef __cplusplus -extern "C" { -#endif - -/* cJSON Types: */ -#define cJSON_False 0 -#define cJSON_True 1 -#define cJSON_NULL 2 -#define cJSON_Number 3 -#define cJSON_String 4 -#define cJSON_Array 5 -#define cJSON_Object 6 - -#define cJSON_IsReference 256 -#define cJSON_StringIsConst 512 - -/* The cJSON structure: */ -typedef struct cJSON { - struct cJSON *next, *prev; /* next/prev allow you to walk array/object - chains. Alternatively, use - GetArraySize/GetArrayItem/GetObjectItem */ - struct cJSON *child; /* An array or object item will have a child pointer - pointing to a chain of the items in the - array/object. */ - - int type; /* The type of the item, as above. */ - - char *valuestring; /* The item's string, if type==cJSON_String */ - int valueint; /* The item's number, if type==cJSON_Number */ - double valuedouble; /* The item's number, if type==cJSON_Number */ - - char *string; /* The item's name string, if this item is the child of, or is - in the list of subitems of an object. */ -} cJSON; - -typedef struct cJSON_Hooks { - void *(*malloc_fn)(size_t sz); - void (*free_fn)(void *ptr); -} cJSON_Hooks; - -/* Supply malloc, realloc and free functions to cJSON */ -extern void cJSON_InitHooks(cJSON_Hooks *hooks); - -/* Supply a block of JSON, and this returns a cJSON object you can interrogate. - * Call cJSON_Delete when finished. */ -extern cJSON *cJSON_Parse(const char *value); -/* Render a cJSON entity to text for transfer/storage. Free the char* when - * finished. */ -extern char *cJSON_Print(cJSON *item); -/* Render a cJSON entity to text for transfer/storage without any formatting. - * Free the char* when finished. */ -extern char *cJSON_PrintUnformatted(cJSON *item); -/* Render a cJSON entity to text using a buffered strategy. prebuffer is a guess - * at the final size. guessing well reduces reallocation. fmt=0 gives - * unformatted, =1 gives formatted */ -extern char *cJSON_PrintBuffered(cJSON *item, int prebuffer, int fmt); -/* Delete a cJSON entity and all subentities. */ -extern void cJSON_Delete(cJSON *c); -/* Delete an item allocated inside the JSON parser*/ -extern void cJSON_Free(void *p); - -/* Returns the number of items in an array (or object). */ -extern int cJSON_GetArraySize(cJSON *array); -/* Retrieve item number "item" from array "array". Returns NULL if unsuccessful. - */ -extern cJSON *cJSON_GetArrayItem(cJSON *array, int item); -/* Get item "string" from object. Case insensitive. */ -extern cJSON *cJSON_GetObjectItem(cJSON *object, const char *string); - -/* For analysing failed parses. This returns a pointer to the parse error. - * You'll probably need to look a few chars back to make sense of it. Defined - * when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */ -extern const char *cJSON_GetErrorPtr(void); - -/* These calls create a cJSON item of the appropriate type. */ -extern cJSON *cJSON_CreateNull(void); -extern cJSON *cJSON_CreateTrue(void); -extern cJSON *cJSON_CreateFalse(void); -extern cJSON *cJSON_CreateBool(int b); -extern cJSON *cJSON_CreateNumber(double num); -extern cJSON *cJSON_CreateString(const char *string); -extern cJSON *cJSON_CreateArray(void); -extern cJSON *cJSON_CreateObject(void); - -/* These utilities create an Array of count items. */ -extern cJSON *cJSON_CreateIntArray(const int *numbers, int count); -extern cJSON *cJSON_CreateFloatArray(const float *numbers, int count); -extern cJSON *cJSON_CreateDoubleArray(const double *numbers, int count); -extern cJSON *cJSON_CreateStringArray(const char **strings, int count); - -/* Append item to the specified array/object. */ -extern void cJSON_AddItemToArray(cJSON *array, cJSON *item); -extern void cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item); -extern void cJSON_AddItemToObjectCS(cJSON *object, const char *string, - cJSON *item); /* Use this when string is definitely const (i.e. a literal, - or as good as), and will definitely survive the cJSON - object */ -/* Append reference to item to the specified array/object. Use this when you - * want to add an existing cJSON to a new cJSON, but don't want to corrupt your - * existing cJSON. */ -extern void cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item); -extern void cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item); - -/* Remove/Detatch items from Arrays/Objects. */ -extern cJSON *cJSON_DetachItemFromArray(cJSON *array, int which); -extern void cJSON_DeleteItemFromArray(cJSON *array, int which); -extern cJSON *cJSON_DetachItemFromObject(cJSON *object, const char *string); -extern void cJSON_DeleteItemFromObject(cJSON *object, const char *string); - -/* Update array items. */ -extern void cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem); /* Shifts pre-existing items to the right. */ -extern void cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem); -extern void cJSON_ReplaceItemInObject(cJSON *object, const char *string, cJSON *newitem); - -/* Duplicate a cJSON item */ -extern cJSON *cJSON_Duplicate(cJSON *item, int recurse); -/* Duplicate will create a new, identical cJSON item to the one you pass, in new -memory that will -need to be released. With recurse!=0, it will duplicate any children connected -to the item. -The item->next and ->prev pointers are always zero on return from Duplicate. */ - -/* ParseWithOpts allows you to require (and check) that the JSON is null - * terminated, and to retrieve the pointer to the final byte parsed. */ -extern cJSON *cJSON_ParseWithOpts(const char *value, const char **return_parse_end, int require_null_terminated); - -extern void cJSON_Minify(char *json); - -/* Macros for creating things quickly. */ -#define cJSON_AddNullToObject(object, name) cJSON_AddItemToObject(object, name, cJSON_CreateNull()) -#define cJSON_AddTrueToObject(object, name) cJSON_AddItemToObject(object, name, cJSON_CreateTrue()) -#define cJSON_AddFalseToObject(object, name) cJSON_AddItemToObject(object, name, cJSON_CreateFalse()) -#define cJSON_AddBoolToObject(object, name, b) cJSON_AddItemToObject(object, name, cJSON_CreateBool(b)) -#define cJSON_AddNumberToObject(object, name, n) cJSON_AddItemToObject(object, name, cJSON_CreateNumber(n)) -#define cJSON_AddStringToObject(object, name, s) cJSON_AddItemToObject(object, name, cJSON_CreateString(s)) - -/* When assigning an integer value, it needs to be propagated to valuedouble - * too. */ -#define cJSON_SetIntValue(object, val) ((object) ? (object)->valueint = (object)->valuedouble = (val) : (val)) -#define cJSON_SetNumberValue(object, val) ((object) ? (object)->valueint = (object)->valuedouble = (val) : (val)) - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/third_party/vulkan/loader/debug_report.c b/third_party/vulkan/loader/debug_report.c deleted file mode 100644 index 04e55ccfc..000000000 --- a/third_party/vulkan/loader/debug_report.c +++ /dev/null @@ -1,466 +0,0 @@ -/* - * Copyright (c) 2015-2016 The Khronos Group Inc. - * Copyright (c) 2015-2016 Valve Corporation - * Copyright (c) 2015-2016 LunarG, Inc. - * Copyright (C) 2015-2016 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Author: Courtney Goeltzenleuchter - * Author: Jon Ashburn - * - */ - -#define _GNU_SOURCE -#include -#include -#include -#include -#ifndef WIN32 -#include -#else -#endif -#include "vk_loader_platform.h" -#include "debug_report.h" -#include "vulkan/vk_layer.h" - -typedef void(VKAPI_PTR *PFN_stringCallback)(char *message); - -static const VkExtensionProperties debug_report_extension_info = { - .extensionName = VK_EXT_DEBUG_REPORT_EXTENSION_NAME, .specVersion = VK_EXT_DEBUG_REPORT_SPEC_VERSION, -}; - -void debug_report_add_instance_extensions(const struct loader_instance *inst, struct loader_extension_list *ext_list) { - loader_add_to_ext_list(inst, ext_list, 1, &debug_report_extension_info); -} - -void debug_report_create_instance(struct loader_instance *ptr_instance, const VkInstanceCreateInfo *pCreateInfo) { - ptr_instance->enabled_known_extensions.ext_debug_report = 0; - - for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { - if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_DEBUG_REPORT_EXTENSION_NAME) == 0) { - ptr_instance->enabled_known_extensions.ext_debug_report = 1; - return; - } - } -} - -VkResult util_CreateDebugReportCallback(struct loader_instance *inst, VkDebugReportCallbackCreateInfoEXT *pCreateInfo, - const VkAllocationCallbacks *pAllocator, VkDebugReportCallbackEXT callback) { - VkLayerDbgFunctionNode *pNewDbgFuncNode = NULL; - -#if (DEBUG_DISABLE_APP_ALLOCATORS == 1) - { -#else - if (pAllocator != NULL) { - pNewDbgFuncNode = (VkLayerDbgFunctionNode *)pAllocator->pfnAllocation(pAllocator->pUserData, sizeof(VkLayerDbgFunctionNode), - sizeof(int *), VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); - } else { -#endif - pNewDbgFuncNode = (VkLayerDbgFunctionNode *)loader_instance_heap_alloc(inst, sizeof(VkLayerDbgFunctionNode), - VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); - } - if (!pNewDbgFuncNode) { - return VK_ERROR_OUT_OF_HOST_MEMORY; - } - memset(pNewDbgFuncNode, 0, sizeof(VkLayerDbgFunctionNode)); - - pNewDbgFuncNode->msgCallback = callback; - pNewDbgFuncNode->pfnMsgCallback = pCreateInfo->pfnCallback; - pNewDbgFuncNode->msgFlags = pCreateInfo->flags; - pNewDbgFuncNode->pUserData = pCreateInfo->pUserData; - pNewDbgFuncNode->pNext = inst->DbgFunctionHead; - inst->DbgFunctionHead = pNewDbgFuncNode; - - return VK_SUCCESS; -} - -static VKAPI_ATTR VkResult VKAPI_CALL -debug_report_CreateDebugReportCallbackEXT(VkInstance instance, const VkDebugReportCallbackCreateInfoEXT *pCreateInfo, - const VkAllocationCallbacks *pAllocator, VkDebugReportCallbackEXT *pCallback) { - struct loader_instance *inst = loader_get_instance(instance); - loader_platform_thread_lock_mutex(&loader_lock); - VkResult result = inst->disp->layer_inst_disp.CreateDebugReportCallbackEXT(instance, pCreateInfo, pAllocator, pCallback); - loader_platform_thread_unlock_mutex(&loader_lock); - return result; -} - -// Utility function to handle reporting -VkBool32 util_DebugReportMessage(const struct loader_instance *inst, VkFlags msgFlags, VkDebugReportObjectTypeEXT objectType, - uint64_t srcObject, size_t location, int32_t msgCode, const char *pLayerPrefix, const char *pMsg) { - VkBool32 bail = false; - VkLayerDbgFunctionNode *pTrav = inst->DbgFunctionHead; - while (pTrav) { - if (pTrav->msgFlags & msgFlags) { - if (pTrav->pfnMsgCallback(msgFlags, objectType, srcObject, location, msgCode, pLayerPrefix, pMsg, pTrav->pUserData)) { - bail = true; - } - } - pTrav = pTrav->pNext; - } - - return bail; -} - -void util_DestroyDebugReportCallback(struct loader_instance *inst, VkDebugReportCallbackEXT callback, - const VkAllocationCallbacks *pAllocator) { - VkLayerDbgFunctionNode *pTrav = inst->DbgFunctionHead; - VkLayerDbgFunctionNode *pPrev = pTrav; - - while (pTrav) { - if (pTrav->msgCallback == callback) { - pPrev->pNext = pTrav->pNext; - if (inst->DbgFunctionHead == pTrav) inst->DbgFunctionHead = pTrav->pNext; -#if (DEBUG_DISABLE_APP_ALLOCATORS == 1) - { -#else - if (pAllocator != NULL) { - pAllocator->pfnFree(pAllocator->pUserData, pTrav); - } else { -#endif - loader_instance_heap_free(inst, pTrav); - } - break; - } - pPrev = pTrav; - pTrav = pTrav->pNext; - } -} - -// This utility (used by vkInstanceCreateInfo(), looks at a pNext chain. It -// counts any VkDebugReportCallbackCreateInfoEXT structs that it finds. It -// then allocates array that can hold that many structs, as well as that many -// VkDebugReportCallbackEXT handles. It then copies each -// VkDebugReportCallbackCreateInfoEXT, and initializes each handle. -VkResult util_CopyDebugReportCreateInfos(const void *pChain, const VkAllocationCallbacks *pAllocator, uint32_t *num_callbacks, - VkDebugReportCallbackCreateInfoEXT **infos, VkDebugReportCallbackEXT **callbacks) { - uint32_t n = *num_callbacks = 0; - VkDebugReportCallbackCreateInfoEXT *pInfos = NULL; - VkDebugReportCallbackEXT *pCallbacks = NULL; - - // NOTE: The loader is not using pAllocator, and so this function doesn't - // either. - - const void *pNext = pChain; - while (pNext) { - // 1st, count the number VkDebugReportCallbackCreateInfoEXT: - if (((VkDebugReportCallbackCreateInfoEXT *)pNext)->sType == VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT) { - n++; - } - pNext = (void *)((VkDebugReportCallbackCreateInfoEXT *)pNext)->pNext; - } - if (n == 0) { - return VK_SUCCESS; - } - -// 2nd, allocate memory for each VkDebugReportCallbackCreateInfoEXT: -#if (DEBUG_DISABLE_APP_ALLOCATORS == 1) - { -#else - if (pAllocator != NULL) { - pInfos = *infos = ((VkDebugReportCallbackCreateInfoEXT *)pAllocator->pfnAllocation( - pAllocator->pUserData, n * sizeof(VkDebugReportCallbackCreateInfoEXT), sizeof(void *), - VK_SYSTEM_ALLOCATION_SCOPE_OBJECT)); - } else { -#endif - pInfos = *infos = ((VkDebugReportCallbackCreateInfoEXT *)malloc(n * sizeof(VkDebugReportCallbackCreateInfoEXT))); - } - if (!pInfos) { - return VK_ERROR_OUT_OF_HOST_MEMORY; - } -// 3rd, allocate memory for a unique handle for each callback: -#if (DEBUG_DISABLE_APP_ALLOCATORS == 1) - { -#else - if (pAllocator != NULL) { - pCallbacks = *callbacks = ((VkDebugReportCallbackEXT *)pAllocator->pfnAllocation( - pAllocator->pUserData, n * sizeof(VkDebugReportCallbackEXT), sizeof(void *), VK_SYSTEM_ALLOCATION_SCOPE_OBJECT)); - if (!pCallbacks) { - pAllocator->pfnFree(pAllocator->pUserData, pInfos); - return VK_ERROR_OUT_OF_HOST_MEMORY; - } - } else { -#endif - pCallbacks = *callbacks = ((VkDebugReportCallbackEXT *)malloc(n * sizeof(VkDebugReportCallbackEXT))); - if (!pCallbacks) { - free(pInfos); - return VK_ERROR_OUT_OF_HOST_MEMORY; - } - } - // 4th, copy each VkDebugReportCallbackCreateInfoEXT for use by - // vkDestroyInstance, and assign a unique handle to each callback (just - // use the address of the copied VkDebugReportCallbackCreateInfoEXT): - pNext = pChain; - while (pNext) { - if (((VkInstanceCreateInfo *)pNext)->sType == VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT) { - memcpy(pInfos, pNext, sizeof(VkDebugReportCallbackCreateInfoEXT)); - *pCallbacks++ = (VkDebugReportCallbackEXT)(uintptr_t)pInfos++; - } - pNext = (void *)((VkInstanceCreateInfo *)pNext)->pNext; - } - - *num_callbacks = n; - return VK_SUCCESS; -} - -void util_FreeDebugReportCreateInfos(const VkAllocationCallbacks *pAllocator, VkDebugReportCallbackCreateInfoEXT *infos, - VkDebugReportCallbackEXT *callbacks) { -#if (DEBUG_DISABLE_APP_ALLOCATORS == 1) - { -#else - if (pAllocator != NULL) { - pAllocator->pfnFree(pAllocator->pUserData, infos); - pAllocator->pfnFree(pAllocator->pUserData, callbacks); - } else { -#endif - free(infos); - free(callbacks); - } -} - -VkResult util_CreateDebugReportCallbacks(struct loader_instance *inst, const VkAllocationCallbacks *pAllocator, - uint32_t num_callbacks, VkDebugReportCallbackCreateInfoEXT *infos, - VkDebugReportCallbackEXT *callbacks) { - VkResult rtn = VK_SUCCESS; - for (uint32_t i = 0; i < num_callbacks; i++) { - rtn = util_CreateDebugReportCallback(inst, &infos[i], pAllocator, callbacks[i]); - if (rtn != VK_SUCCESS) { - for (uint32_t j = 0; j < i; j++) { - util_DestroyDebugReportCallback(inst, callbacks[j], pAllocator); - } - return rtn; - } - } - return rtn; -} - -void util_DestroyDebugReportCallbacks(struct loader_instance *inst, const VkAllocationCallbacks *pAllocator, uint32_t num_callbacks, - VkDebugReportCallbackEXT *callbacks) { - for (uint32_t i = 0; i < num_callbacks; i++) { - util_DestroyDebugReportCallback(inst, callbacks[i], pAllocator); - } -} - -static VKAPI_ATTR void VKAPI_CALL debug_report_DestroyDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackEXT callback, - const VkAllocationCallbacks *pAllocator) { - struct loader_instance *inst = loader_get_instance(instance); - loader_platform_thread_lock_mutex(&loader_lock); - - inst->disp->layer_inst_disp.DestroyDebugReportCallbackEXT(instance, callback, pAllocator); - - util_DestroyDebugReportCallback(inst, callback, pAllocator); - - loader_platform_thread_unlock_mutex(&loader_lock); -} - -static VKAPI_ATTR void VKAPI_CALL debug_report_DebugReportMessageEXT(VkInstance instance, VkDebugReportFlagsEXT flags, - VkDebugReportObjectTypeEXT objType, uint64_t object, - size_t location, int32_t msgCode, const char *pLayerPrefix, - const char *pMsg) { - struct loader_instance *inst = loader_get_instance(instance); - - inst->disp->layer_inst_disp.DebugReportMessageEXT(instance, flags, objType, object, location, msgCode, pLayerPrefix, pMsg); -} - -// This is the instance chain terminator function -// for CreateDebugReportCallback -VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDebugReportCallbackEXT(VkInstance instance, - const VkDebugReportCallbackCreateInfoEXT *pCreateInfo, - const VkAllocationCallbacks *pAllocator, - VkDebugReportCallbackEXT *pCallback) { - VkDebugReportCallbackEXT *icd_info = NULL; - const struct loader_icd_term *icd_term; - struct loader_instance *inst = (struct loader_instance *)instance; - VkResult res = VK_SUCCESS; - uint32_t storage_idx; - VkLayerDbgFunctionNode *pNewDbgFuncNode = NULL; - -#if (DEBUG_DISABLE_APP_ALLOCATORS == 1) - { -#else - if (pAllocator != NULL) { - icd_info = ((VkDebugReportCallbackEXT *)pAllocator->pfnAllocation(pAllocator->pUserData, - inst->total_icd_count * sizeof(VkDebugReportCallbackEXT), - sizeof(void *), VK_SYSTEM_ALLOCATION_SCOPE_OBJECT)); - if (icd_info) { - memset(icd_info, 0, inst->total_icd_count * sizeof(VkDebugReportCallbackEXT)); - } - } else { -#endif - icd_info = calloc(sizeof(VkDebugReportCallbackEXT), inst->total_icd_count); - } - if (!icd_info) { - res = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - - storage_idx = 0; - for (icd_term = inst->icd_terms; icd_term; icd_term = icd_term->next) { - if (!icd_term->dispatch.CreateDebugReportCallbackEXT) { - continue; - } - - res = icd_term->dispatch.CreateDebugReportCallbackEXT(icd_term->instance, pCreateInfo, pAllocator, &icd_info[storage_idx]); - - if (res != VK_SUCCESS) { - goto out; - } - storage_idx++; - } - -// Setup the debug report callback in the terminator since a layer may want -// to grab the information itself (RenderDoc) and then return back to the -// user callback a sub-set of the messages. -#if (DEBUG_DISABLE_APP_ALLOCATORS == 0) - if (pAllocator != NULL) { - pNewDbgFuncNode = (VkLayerDbgFunctionNode *)pAllocator->pfnAllocation(pAllocator->pUserData, sizeof(VkLayerDbgFunctionNode), - sizeof(int *), VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); - } else { -#else - { -#endif - pNewDbgFuncNode = (VkLayerDbgFunctionNode *)loader_instance_heap_alloc(inst, sizeof(VkLayerDbgFunctionNode), - VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); - } - if (!pNewDbgFuncNode) { - res = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - memset(pNewDbgFuncNode, 0, sizeof(VkLayerDbgFunctionNode)); - - pNewDbgFuncNode->pfnMsgCallback = pCreateInfo->pfnCallback; - pNewDbgFuncNode->msgFlags = pCreateInfo->flags; - pNewDbgFuncNode->pUserData = pCreateInfo->pUserData; - pNewDbgFuncNode->pNext = inst->DbgFunctionHead; - inst->DbgFunctionHead = pNewDbgFuncNode; - - *(VkDebugReportCallbackEXT **)pCallback = icd_info; - pNewDbgFuncNode->msgCallback = *pCallback; - -out: - - // Roll back on errors - if (VK_SUCCESS != res) { - storage_idx = 0; - for (icd_term = inst->icd_terms; icd_term; icd_term = icd_term->next) { - if (NULL == icd_term->dispatch.DestroyDebugReportCallbackEXT) { - continue; - } - - if (icd_info && icd_info[storage_idx]) { - icd_term->dispatch.DestroyDebugReportCallbackEXT(icd_term->instance, icd_info[storage_idx], pAllocator); - } - storage_idx++; - } - -#if (DEBUG_DISABLE_APP_ALLOCATORS == 1) - { -#else - if (pAllocator != NULL) { - if (NULL != pNewDbgFuncNode) { - pAllocator->pfnFree(pAllocator->pUserData, pNewDbgFuncNode); - } - if (NULL != icd_info) { - pAllocator->pfnFree(pAllocator->pUserData, icd_info); - } - } else { -#endif - if (NULL != pNewDbgFuncNode) { - free(pNewDbgFuncNode); - } - if (NULL != icd_info) { - free(icd_info); - } - } - } - - return res; -} - -// This is the instance chain terminator function for DestroyDebugReportCallback -VKAPI_ATTR void VKAPI_CALL terminator_DestroyDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackEXT callback, - const VkAllocationCallbacks *pAllocator) { - uint32_t storage_idx; - VkDebugReportCallbackEXT *icd_info; - const struct loader_icd_term *icd_term; - - struct loader_instance *inst = (struct loader_instance *)instance; - icd_info = *(VkDebugReportCallbackEXT **)&callback; - storage_idx = 0; - for (icd_term = inst->icd_terms; icd_term; icd_term = icd_term->next) { - if (NULL == icd_term->dispatch.DestroyDebugReportCallbackEXT) { - continue; - } - - if (icd_info[storage_idx]) { - icd_term->dispatch.DestroyDebugReportCallbackEXT(icd_term->instance, icd_info[storage_idx], pAllocator); - } - storage_idx++; - } - -#if (DEBUG_DISABLE_APP_ALLOCATORS == 1) - { -#else - if (pAllocator != NULL) { - pAllocator->pfnFree(pAllocator->pUserData, icd_info); - } else { -#endif - free(icd_info); - } -} - -// This is the instance chain terminator function for DebugReportMessage -VKAPI_ATTR void VKAPI_CALL terminator_DebugReportMessageEXT(VkInstance instance, VkDebugReportFlagsEXT flags, - VkDebugReportObjectTypeEXT objType, uint64_t object, size_t location, - int32_t msgCode, const char *pLayerPrefix, const char *pMsg) { - const struct loader_icd_term *icd_term; - - struct loader_instance *inst = (struct loader_instance *)instance; - - loader_platform_thread_lock_mutex(&loader_lock); - for (icd_term = inst->icd_terms; icd_term; icd_term = icd_term->next) { - if (icd_term->dispatch.DebugReportMessageEXT != NULL) { - icd_term->dispatch.DebugReportMessageEXT(icd_term->instance, flags, objType, object, location, msgCode, pLayerPrefix, - pMsg); - } - } - - // Now that all ICDs have seen the message, call the necessary callbacks. Ignoring "bail" return value - // as there is nothing to bail from at this point. - - util_DebugReportMessage(inst, flags, objType, object, location, msgCode, pLayerPrefix, pMsg); - - loader_platform_thread_unlock_mutex(&loader_lock); -} - -bool debug_report_instance_gpa(struct loader_instance *ptr_instance, const char *name, void **addr) { - // debug_report is currently advertised to be supported by the loader, - // so always return the entry points if name matches and it's enabled - *addr = NULL; - - if (!strcmp("vkCreateDebugReportCallbackEXT", name)) { - *addr = (ptr_instance->enabled_known_extensions.ext_debug_report == 1) ? (void *)debug_report_CreateDebugReportCallbackEXT - : NULL; - return true; - } - if (!strcmp("vkDestroyDebugReportCallbackEXT", name)) { - *addr = (ptr_instance->enabled_known_extensions.ext_debug_report == 1) ? (void *)debug_report_DestroyDebugReportCallbackEXT - : NULL; - return true; - } - if (!strcmp("vkDebugReportMessageEXT", name)) { - *addr = (ptr_instance->enabled_known_extensions.ext_debug_report == 1) ? (void *)debug_report_DebugReportMessageEXT : NULL; - return true; - } - return false; -} diff --git a/third_party/vulkan/loader/debug_report.h b/third_party/vulkan/loader/debug_report.h deleted file mode 100644 index 89074d7f7..000000000 --- a/third_party/vulkan/loader/debug_report.h +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (c) 2015-2016 The Khronos Group Inc. - * Copyright (c) 2015-2016 Valve Corporation - * Copyright (c) 2015-2016 LunarG, Inc. - * Copyright (C) 2015-2016 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Author: Courtney Goeltzenleuchter - * Author: Jon Ashburn - * - */ - -#include "vk_loader_platform.h" -#include "loader.h" - -// CreateMsgCallback is global and needs to be -// applied to all layers and ICDs. -// What happens if a layer is enabled on both the instance chain -// as well as the device chain and a call to CreateMsgCallback is made? -// Do we need to make sure that each layer / driver only gets called once? -// Should a layer implementing support for CreateMsgCallback only be allowed (?) -// to live on one chain? Or maybe make it the application's responsibility. -// If the app enables DRAW_STATE on at both CreateInstance time and CreateDevice -// time, CreateMsgCallback will call the DRAW_STATE layer twice. Once via -// the instance chain and once via the device chain. -// The loader should only return the DEBUG_REPORT extension as supported -// for the GetGlobalExtensionSupport call. That should help eliminate one -// duplication. -// Since the instance chain requires us iterating over the available ICDs -// and each ICD will have it's own unique MsgCallback object we need to -// track those objects to give back the right one. -// This also implies that the loader has to intercept vkDestroyObject and -// if the extension is enabled and the object type is a MsgCallback then -// we must translate the object into the proper ICD specific ones. -// DestroyObject works on a device chain. Should not be what's destroying -// the MsgCallback object. That needs to be an instance thing. So, since -// we used an instance to create it, we need a custom Destroy that also -// takes an instance. That way we can iterate over the ICDs properly. -// Example use: -// CreateInstance: DEBUG_REPORT -// Loader will create instance chain with enabled extensions. -// TODO: Should validation layers be enabled here? If not, they will not be in -// the instance chain. -// fn = GetProcAddr(INSTANCE, "vkCreateMsgCallback") -> point to loader's -// vkCreateMsgCallback -// App creates a callback object: fn(..., &MsgCallbackObject1) -// Have only established the instance chain so far. Loader will call the -// instance chain. -// Each layer in the instance chain will call down to the next layer, -// terminating with -// the CreateMsgCallback loader terminator function that creates the actual -// MsgCallbackObject1 object. -// The loader CreateMsgCallback terminator will iterate over the ICDs. -// Calling each ICD that supports vkCreateMsgCallback and collect answers in -// icd_msg_callback_map here. -// As result is sent back up the chain each layer has opportunity to record the -// callback operation and -// appropriate MsgCallback object. -// ... -// Any reports matching the flags set in MsgCallbackObject1 will generate the -// defined callback behavior -// in the layer / ICD that initiated that report. -// ... -// CreateDevice: MemTracker:... -// App does not include DEBUG_REPORT as that is a global extension. -// TODO: GetExtensionSupport must not report DEBUG_REPORT when using instance. -// App MUST include any desired validation layers or they will not participate -// in the device call chain. -// App creates a callback object: fn(..., &MsgCallbackObject2) -// Loader's vkCreateMsgCallback is called. -// Loader sends call down instance chain - this is a global extension - any -// validation layer that was -// enabled at CreateInstance will be able to register the callback. Loader will -// iterate over the ICDs and -// will record the ICD's version of the MsgCallback2 object here. -// ... -// Any report will go to the layer's report function and it will check the flags -// for MsgCallbackObject1 -// and MsgCallbackObject2 and take the appropriate action as indicated by the -// app. -// ... -// App calls vkDestroyMsgCallback( MsgCallbackObject1 ) -// Loader's DestroyMsgCallback is where call starts. DestroyMsgCallback will be -// sent down instance chain -// ending in the loader's DestroyMsgCallback terminator which will iterate over -// the ICD's destroying each -// ICD version of that MsgCallback object and then destroy the loader's version -// of the object. -// Any reports generated after this will only have MsgCallbackObject2 available. - -void debug_report_add_instance_extensions(const struct loader_instance *inst, struct loader_extension_list *ext_list); - -void debug_report_create_instance(struct loader_instance *ptr_instance, const VkInstanceCreateInfo *pCreateInfo); - -bool debug_report_instance_gpa(struct loader_instance *ptr_instance, const char *name, void **addr); - -VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDebugReportCallbackEXT(VkInstance instance, - const VkDebugReportCallbackCreateInfoEXT *pCreateInfo, - const VkAllocationCallbacks *pAllocator, - VkDebugReportCallbackEXT *pCallback); - -VKAPI_ATTR void VKAPI_CALL terminator_DestroyDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackEXT callback, - const VkAllocationCallbacks *pAllocator); - -VKAPI_ATTR void VKAPI_CALL terminator_DebugReportMessageEXT(VkInstance instance, VkDebugReportFlagsEXT flags, - VkDebugReportObjectTypeEXT objType, uint64_t object, size_t location, - int32_t msgCode, const char *pLayerPrefix, const char *pMsg); - -VkResult util_CreateDebugReportCallback(struct loader_instance *inst, VkDebugReportCallbackCreateInfoEXT *pCreateInfo, - const VkAllocationCallbacks *pAllocator, VkDebugReportCallbackEXT callback); - -void util_DestroyDebugReportCallback(struct loader_instance *inst, VkDebugReportCallbackEXT callback, - const VkAllocationCallbacks *pAllocator); - -VkResult util_CopyDebugReportCreateInfos(const void *pChain, const VkAllocationCallbacks *pAllocator, uint32_t *num_callbacks, - VkDebugReportCallbackCreateInfoEXT **infos, VkDebugReportCallbackEXT **callbacks); -void util_FreeDebugReportCreateInfos(const VkAllocationCallbacks *pAllocator, VkDebugReportCallbackCreateInfoEXT *infos, - VkDebugReportCallbackEXT *callbacks); -VkResult util_CreateDebugReportCallbacks(struct loader_instance *inst, const VkAllocationCallbacks *pAllocator, - uint32_t num_callbacks, VkDebugReportCallbackCreateInfoEXT *infos, - VkDebugReportCallbackEXT *callbacks); - -void util_DestroyDebugReportCallbacks(struct loader_instance *inst, const VkAllocationCallbacks *pAllocator, uint32_t num_callbacks, - VkDebugReportCallbackEXT *callbacks); - -VkBool32 util_DebugReportMessage(const struct loader_instance *inst, VkFlags msgFlags, VkDebugReportObjectTypeEXT objectType, - uint64_t srcObject, size_t location, int32_t msgCode, const char *pLayerPrefix, const char *pMsg); diff --git a/third_party/vulkan/loader/dev_ext_trampoline.c b/third_party/vulkan/loader/dev_ext_trampoline.c deleted file mode 100644 index 55eee0c25..000000000 --- a/third_party/vulkan/loader/dev_ext_trampoline.c +++ /dev/null @@ -1,538 +0,0 @@ -/* - * Copyright (c) 2015-2016 The Khronos Group Inc. - * Copyright (c) 2015-2016 Valve Corporation - * Copyright (c) 2015-2016 LunarG, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Author: Jon Ashburn - * Author: Lenny Komow - */ - -#include "vk_loader_platform.h" -#include "loader.h" -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC optimize(3) // force gcc to use tail-calls -#endif - -// Clang-format does not understand macros. -// clang-format off - -VKAPI_ATTR void VKAPI_CALL vkdev_ext0(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext1(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext2(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext3(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext4(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext5(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext6(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext7(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext8(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext9(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext10(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext11(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext12(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext13(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext14(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext15(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext16(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext17(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext18(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext19(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext20(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext21(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext22(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext23(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext24(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext25(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext26(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext27(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext28(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext29(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext30(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext31(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext32(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext33(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext34(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext35(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext36(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext37(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext38(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext39(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext40(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext41(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext42(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext43(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext44(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext45(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext46(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext47(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext48(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext49(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext50(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext51(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext52(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext53(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext54(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext55(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext56(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext57(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext58(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext59(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext60(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext61(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext62(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext63(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext64(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext65(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext66(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext67(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext68(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext69(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext70(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext71(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext72(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext73(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext74(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext75(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext76(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext77(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext78(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext79(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext80(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext81(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext82(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext83(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext84(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext85(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext86(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext87(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext88(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext89(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext90(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext91(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext92(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext93(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext94(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext95(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext96(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext97(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext98(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext99(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext100(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext101(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext102(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext103(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext104(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext105(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext106(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext107(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext108(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext109(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext110(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext111(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext112(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext113(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext114(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext115(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext116(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext117(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext118(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext119(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext120(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext121(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext122(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext123(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext124(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext125(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext126(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext127(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext128(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext129(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext130(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext131(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext132(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext133(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext134(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext135(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext136(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext137(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext138(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext139(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext140(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext141(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext142(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext143(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext144(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext145(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext146(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext147(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext148(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext149(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext150(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext151(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext152(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext153(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext154(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext155(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext156(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext157(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext158(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext159(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext160(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext161(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext162(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext163(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext164(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext165(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext166(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext167(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext168(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext169(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext170(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext171(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext172(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext173(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext174(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext175(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext176(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext177(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext178(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext179(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext180(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext181(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext182(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext183(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext184(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext185(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext186(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext187(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext188(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext189(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext190(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext191(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext192(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext193(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext194(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext195(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext196(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext197(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext198(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext199(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext200(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext201(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext202(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext203(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext204(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext205(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext206(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext207(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext208(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext209(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext210(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext211(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext212(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext213(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext214(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext215(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext216(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext217(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext218(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext219(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext220(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext221(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext222(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext223(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext224(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext225(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext226(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext227(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext228(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext229(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext230(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext231(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext232(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext233(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext234(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext235(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext236(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext237(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext238(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext239(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext240(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext241(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext242(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext243(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext244(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext245(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext246(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext247(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext248(VkDevice device); -VKAPI_ATTR void VKAPI_CALL vkdev_ext249(VkDevice device); - -void *loader_get_dev_ext_trampoline(uint32_t index) { - switch (index) { -#define CASE_HANDLE(num) case num: return vkdev_ext##num - CASE_HANDLE(0); - CASE_HANDLE(1); - CASE_HANDLE(2); - CASE_HANDLE(3); - CASE_HANDLE(4); - CASE_HANDLE(5); - CASE_HANDLE(6); - CASE_HANDLE(7); - CASE_HANDLE(8); - CASE_HANDLE(9); - CASE_HANDLE(10); - CASE_HANDLE(11); - CASE_HANDLE(12); - CASE_HANDLE(13); - CASE_HANDLE(14); - CASE_HANDLE(15); - CASE_HANDLE(16); - CASE_HANDLE(17); - CASE_HANDLE(18); - CASE_HANDLE(19); - CASE_HANDLE(20); - CASE_HANDLE(21); - CASE_HANDLE(22); - CASE_HANDLE(23); - CASE_HANDLE(24); - CASE_HANDLE(25); - CASE_HANDLE(26); - CASE_HANDLE(27); - CASE_HANDLE(28); - CASE_HANDLE(29); - CASE_HANDLE(30); - CASE_HANDLE(31); - CASE_HANDLE(32); - CASE_HANDLE(33); - CASE_HANDLE(34); - CASE_HANDLE(35); - CASE_HANDLE(36); - CASE_HANDLE(37); - CASE_HANDLE(38); - CASE_HANDLE(39); - CASE_HANDLE(40); - CASE_HANDLE(41); - CASE_HANDLE(42); - CASE_HANDLE(43); - CASE_HANDLE(44); - CASE_HANDLE(45); - CASE_HANDLE(46); - CASE_HANDLE(47); - CASE_HANDLE(48); - CASE_HANDLE(49); - CASE_HANDLE(50); - CASE_HANDLE(51); - CASE_HANDLE(52); - CASE_HANDLE(53); - CASE_HANDLE(54); - CASE_HANDLE(55); - CASE_HANDLE(56); - CASE_HANDLE(57); - CASE_HANDLE(58); - CASE_HANDLE(59); - CASE_HANDLE(60); - CASE_HANDLE(61); - CASE_HANDLE(62); - CASE_HANDLE(63); - CASE_HANDLE(64); - CASE_HANDLE(65); - CASE_HANDLE(66); - CASE_HANDLE(67); - CASE_HANDLE(68); - CASE_HANDLE(69); - CASE_HANDLE(70); - CASE_HANDLE(71); - CASE_HANDLE(72); - CASE_HANDLE(73); - CASE_HANDLE(74); - CASE_HANDLE(75); - CASE_HANDLE(76); - CASE_HANDLE(77); - CASE_HANDLE(78); - CASE_HANDLE(79); - CASE_HANDLE(80); - CASE_HANDLE(81); - CASE_HANDLE(82); - CASE_HANDLE(83); - CASE_HANDLE(84); - CASE_HANDLE(85); - CASE_HANDLE(86); - CASE_HANDLE(87); - CASE_HANDLE(88); - CASE_HANDLE(89); - CASE_HANDLE(90); - CASE_HANDLE(91); - CASE_HANDLE(92); - CASE_HANDLE(93); - CASE_HANDLE(94); - CASE_HANDLE(95); - CASE_HANDLE(96); - CASE_HANDLE(97); - CASE_HANDLE(98); - CASE_HANDLE(99); - CASE_HANDLE(100); - CASE_HANDLE(101); - CASE_HANDLE(102); - CASE_HANDLE(103); - CASE_HANDLE(104); - CASE_HANDLE(105); - CASE_HANDLE(106); - CASE_HANDLE(107); - CASE_HANDLE(108); - CASE_HANDLE(109); - CASE_HANDLE(110); - CASE_HANDLE(111); - CASE_HANDLE(112); - CASE_HANDLE(113); - CASE_HANDLE(114); - CASE_HANDLE(115); - CASE_HANDLE(116); - CASE_HANDLE(117); - CASE_HANDLE(118); - CASE_HANDLE(119); - CASE_HANDLE(120); - CASE_HANDLE(121); - CASE_HANDLE(122); - CASE_HANDLE(123); - CASE_HANDLE(124); - CASE_HANDLE(125); - CASE_HANDLE(126); - CASE_HANDLE(127); - CASE_HANDLE(128); - CASE_HANDLE(129); - CASE_HANDLE(130); - CASE_HANDLE(131); - CASE_HANDLE(132); - CASE_HANDLE(133); - CASE_HANDLE(134); - CASE_HANDLE(135); - CASE_HANDLE(136); - CASE_HANDLE(137); - CASE_HANDLE(138); - CASE_HANDLE(139); - CASE_HANDLE(140); - CASE_HANDLE(141); - CASE_HANDLE(142); - CASE_HANDLE(143); - CASE_HANDLE(144); - CASE_HANDLE(145); - CASE_HANDLE(146); - CASE_HANDLE(147); - CASE_HANDLE(148); - CASE_HANDLE(149); - CASE_HANDLE(150); - CASE_HANDLE(151); - CASE_HANDLE(152); - CASE_HANDLE(153); - CASE_HANDLE(154); - CASE_HANDLE(155); - CASE_HANDLE(156); - CASE_HANDLE(157); - CASE_HANDLE(158); - CASE_HANDLE(159); - CASE_HANDLE(160); - CASE_HANDLE(161); - CASE_HANDLE(162); - CASE_HANDLE(163); - CASE_HANDLE(164); - CASE_HANDLE(165); - CASE_HANDLE(166); - CASE_HANDLE(167); - CASE_HANDLE(168); - CASE_HANDLE(169); - CASE_HANDLE(170); - CASE_HANDLE(171); - CASE_HANDLE(172); - CASE_HANDLE(173); - CASE_HANDLE(174); - CASE_HANDLE(175); - CASE_HANDLE(176); - CASE_HANDLE(177); - CASE_HANDLE(178); - CASE_HANDLE(179); - CASE_HANDLE(180); - CASE_HANDLE(181); - CASE_HANDLE(182); - CASE_HANDLE(183); - CASE_HANDLE(184); - CASE_HANDLE(185); - CASE_HANDLE(186); - CASE_HANDLE(187); - CASE_HANDLE(188); - CASE_HANDLE(189); - CASE_HANDLE(190); - CASE_HANDLE(191); - CASE_HANDLE(192); - CASE_HANDLE(193); - CASE_HANDLE(194); - CASE_HANDLE(195); - CASE_HANDLE(196); - CASE_HANDLE(197); - CASE_HANDLE(198); - CASE_HANDLE(199); - CASE_HANDLE(200); - CASE_HANDLE(201); - CASE_HANDLE(202); - CASE_HANDLE(203); - CASE_HANDLE(204); - CASE_HANDLE(205); - CASE_HANDLE(206); - CASE_HANDLE(207); - CASE_HANDLE(208); - CASE_HANDLE(209); - CASE_HANDLE(210); - CASE_HANDLE(211); - CASE_HANDLE(212); - CASE_HANDLE(213); - CASE_HANDLE(214); - CASE_HANDLE(215); - CASE_HANDLE(216); - CASE_HANDLE(217); - CASE_HANDLE(218); - CASE_HANDLE(219); - CASE_HANDLE(220); - CASE_HANDLE(221); - CASE_HANDLE(222); - CASE_HANDLE(223); - CASE_HANDLE(224); - CASE_HANDLE(225); - CASE_HANDLE(226); - CASE_HANDLE(227); - CASE_HANDLE(228); - CASE_HANDLE(229); - CASE_HANDLE(230); - CASE_HANDLE(231); - CASE_HANDLE(232); - CASE_HANDLE(233); - CASE_HANDLE(234); - CASE_HANDLE(235); - CASE_HANDLE(236); - CASE_HANDLE(237); - CASE_HANDLE(238); - CASE_HANDLE(239); - CASE_HANDLE(240); - CASE_HANDLE(241); - CASE_HANDLE(242); - CASE_HANDLE(243); - CASE_HANDLE(244); - CASE_HANDLE(245); - CASE_HANDLE(246); - CASE_HANDLE(247); - CASE_HANDLE(248); - CASE_HANDLE(249); - } - - return NULL; -} diff --git a/third_party/vulkan/loader/dirent_on_windows.c b/third_party/vulkan/loader/dirent_on_windows.c deleted file mode 100644 index 16318cc70..000000000 --- a/third_party/vulkan/loader/dirent_on_windows.c +++ /dev/null @@ -1,128 +0,0 @@ -/* - - Implementation of POSIX directory browsing functions and types for Win32. - - Author: Kevlin Henney (kevlin@acm.org, kevlin@curbralan.com) - History: Created March 1997. Updated June 2003 and July 2012. - Rights: See end of file. - -*/ -#include "dirent_on_windows.h" -#include -#include /* _findfirst and _findnext set errno iff they return -1 */ -#include -#include -#include "vk_loader_platform.h" -#include "loader.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef ptrdiff_t handle_type; /* C99's intptr_t not sufficiently portable */ - -struct DIR { - handle_type handle; /* -1 for failed rewind */ - struct _finddata_t info; - struct dirent result; /* d_name null iff first time */ - char *name; /* null-terminated char string */ -}; - -DIR *opendir(const char *name) { - DIR *dir = 0; - - if (name && name[0]) { - size_t base_length = strlen(name); - const char *all = /* search pattern must end with suitable wildcard */ - strchr("/\\", name[base_length - 1]) ? "*" : "/*"; - - if ((dir = (DIR *)loader_instance_tls_heap_alloc(sizeof *dir)) != 0 && - (dir->name = (char *)loader_instance_tls_heap_alloc(base_length + strlen(all) + 1)) != 0) { - strcat(strcpy(dir->name, name), all); - - if ((dir->handle = (handle_type)_findfirst(dir->name, &dir->info)) != -1) { - dir->result.d_name = 0; - } else /* rollback */ - { - loader_instance_tls_heap_free(dir->name); - loader_instance_tls_heap_free(dir); - dir = 0; - } - } else /* rollback */ - { - loader_instance_tls_heap_free(dir); - dir = 0; - errno = ENOMEM; - } - } else { - errno = EINVAL; - } - - return dir; -} - -int closedir(DIR *dir) { - int result = -1; - - if (dir) { - if (dir->handle != -1) { - result = _findclose(dir->handle); - } - - loader_instance_tls_heap_free(dir->name); - loader_instance_tls_heap_free(dir); - } - - if (result == -1) /* map all errors to EBADF */ - { - errno = EBADF; - } - - return result; -} - -struct dirent *readdir(DIR *dir) { - struct dirent *result = 0; - - if (dir && dir->handle != -1) { - if (!dir->result.d_name || _findnext(dir->handle, &dir->info) != -1) { - result = &dir->result; - result->d_name = dir->info.name; - } - } else { - errno = EBADF; - } - - return result; -} - -void rewinddir(DIR *dir) { - if (dir && dir->handle != -1) { - _findclose(dir->handle); - dir->handle = (handle_type)_findfirst(dir->name, &dir->info); - dir->result.d_name = 0; - } else { - errno = EBADF; - } -} - -#ifdef __cplusplus -} -#endif - -/* - - Copyright Kevlin Henney, 1997, 2003, 2012. All rights reserved. - Copyright (c) 2015 The Khronos Group Inc. - Copyright (c) 2015 Valve Corporation - Copyright (c) 2015 LunarG, Inc. - Permission to use, copy, modify, and distribute this software and its - documentation for any purpose is hereby granted without fee, provided - that this copyright and permissions notice appear in all copies and - derivatives. - - This software is supplied "as is" without express or implied warranty. - - But that said, if there are any problems please get in touch. - -*/ diff --git a/third_party/vulkan/loader/dirent_on_windows.h b/third_party/vulkan/loader/dirent_on_windows.h deleted file mode 100644 index 8600f8ef0..000000000 --- a/third_party/vulkan/loader/dirent_on_windows.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef DIRENT_INCLUDED -#define DIRENT_INCLUDED - -/* - - Declaration of POSIX directory browsing functions and types for Win32. - - Author: Kevlin Henney (kevlin@acm.org, kevlin@curbralan.com) - History: Created March 1997. Updated June 2003. - Rights: See end of file. - -*/ - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct DIR DIR; - -struct dirent { - char *d_name; -}; - -DIR *opendir(const char *); -int closedir(DIR *); -struct dirent *readdir(DIR *); -void rewinddir(DIR *); - -/* - - Copyright Kevlin Henney, 1997, 2003. All rights reserved. - Copyright (c) 2015 The Khronos Group Inc. - Copyright (c) 2015 Valve Corporation - Copyright (c) 2015 LunarG, Inc. - - Permission to use, copy, modify, and distribute this software and its - documentation for any purpose is hereby granted without fee, provided - that this copyright and permissions notice appear in all copies and - derivatives. - - This software is supplied "as is" without express or implied warranty. - - But that said, if there are any problems please get in touch. - -*/ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/third_party/vulkan/loader/extension_manual.c b/third_party/vulkan/loader/extension_manual.c deleted file mode 100644 index ef62b52b1..000000000 --- a/third_party/vulkan/loader/extension_manual.c +++ /dev/null @@ -1,1345 +0,0 @@ -/* - * Copyright (c) 2015-2017 The Khronos Group Inc. - * Copyright (c) 2015-2017 Valve Corporation - * Copyright (c) 2015-2017 LunarG, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Author: Mark Young - * Author: Lenny Komow - */ - -#define _GNU_SOURCE -#include -#include -#include -#include "vk_loader_platform.h" -#include "loader.h" -#include "vk_loader_extensions.h" -#include -#include "wsi.h" -#include "debug_report.h" - -// ---- Manually added trampoline/terminator functions - -// These functions, for whatever reason, require more complex changes than -// can easily be automatically generated. -VkResult setupLoaderTrampPhysDevGroups(VkInstance instance); -VkResult setupLoaderTermPhysDevGroups(struct loader_instance *inst); - -// ---- VK_KHX_device_group extension trampoline/terminators - -VKAPI_ATTR VkResult VKAPI_CALL EnumeratePhysicalDeviceGroupsKHX( - VkInstance instance, uint32_t *pPhysicalDeviceGroupCount, - VkPhysicalDeviceGroupPropertiesKHX *pPhysicalDeviceGroupProperties) { - VkResult res = VK_SUCCESS; - uint32_t count; - uint32_t i; - struct loader_instance *inst = NULL; - - loader_platform_thread_lock_mutex(&loader_lock); - - inst = loader_get_instance(instance); - if (NULL == inst) { - res = VK_ERROR_INITIALIZATION_FAILED; - goto out; - } - - if (NULL == pPhysicalDeviceGroupCount) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "vkEnumeratePhysicalDeviceGroupsKHX: Received NULL pointer for physical " - "device group count return value."); - res = VK_ERROR_INITIALIZATION_FAILED; - goto out; - } - - VkResult setup_res = setupLoaderTrampPhysDevGroups(instance); - if (VK_SUCCESS != setup_res) { - res = setup_res; - goto out; - } - - count = inst->phys_dev_group_count_tramp; - - // Wrap the PhysDev object for loader usage, return wrapped objects - if (NULL != pPhysicalDeviceGroupProperties) { - if (inst->phys_dev_group_count_tramp > *pPhysicalDeviceGroupCount) { - loader_log(inst, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, - "vkEnumeratePhysicalDeviceGroupsKHX: Trimming device group count down" - " by application request from %d to %d physical device groups", - inst->phys_dev_group_count_tramp, *pPhysicalDeviceGroupCount); - count = *pPhysicalDeviceGroupCount; - res = VK_INCOMPLETE; - } - for (i = 0; i < count; i++) { - memcpy(&pPhysicalDeviceGroupProperties[i], inst->phys_dev_groups_tramp[i], - sizeof(VkPhysicalDeviceGroupPropertiesKHX)); - } - } - - *pPhysicalDeviceGroupCount = count; - -out: - - loader_platform_thread_unlock_mutex(&loader_lock); - return res; -} - -VKAPI_ATTR VkResult VKAPI_CALL terminator_EnumeratePhysicalDeviceGroupsKHX( - VkInstance instance, uint32_t *pPhysicalDeviceGroupCount, - VkPhysicalDeviceGroupPropertiesKHX *pPhysicalDeviceGroupProperties) { - struct loader_instance *inst = (struct loader_instance *)instance; - VkResult res = VK_SUCCESS; - - // Always call the setup loader terminator physical device groups because they may - // have changed at any point. - res = setupLoaderTermPhysDevGroups(inst); - if (VK_SUCCESS != res) { - goto out; - } - - uint32_t copy_count = inst->phys_dev_group_count_term; - if (NULL != pPhysicalDeviceGroupProperties) { - if (copy_count > *pPhysicalDeviceGroupCount) { - copy_count = *pPhysicalDeviceGroupCount; - res = VK_INCOMPLETE; - } - - for (uint32_t i = 0; i < copy_count; i++) { - memcpy(&pPhysicalDeviceGroupProperties[i], inst->phys_dev_groups_term[i], - sizeof(VkPhysicalDeviceGroupPropertiesKHX)); - } - } - - *pPhysicalDeviceGroupCount = copy_count; - -out: - - return res; -} - -// ---- VK_NV_external_memory_capabilities extension trampoline/terminators - -VKAPI_ATTR VkResult VKAPI_CALL -GetPhysicalDeviceExternalImageFormatPropertiesNV( - VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, - VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, - VkExternalMemoryHandleTypeFlagsNV externalHandleType, - VkExternalImageFormatPropertiesNV *pExternalImageFormatProperties) { - const VkLayerInstanceDispatchTable *disp; - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - - return disp->GetPhysicalDeviceExternalImageFormatPropertiesNV( - unwrapped_phys_dev, format, type, tiling, usage, flags, - externalHandleType, pExternalImageFormatProperties); -} - -VKAPI_ATTR VkResult VKAPI_CALL -terminator_GetPhysicalDeviceExternalImageFormatPropertiesNV( - VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, - VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, - VkExternalMemoryHandleTypeFlagsNV externalHandleType, - VkExternalImageFormatPropertiesNV *pExternalImageFormatProperties) { - 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; - - if (!icd_term->dispatch.GetPhysicalDeviceExternalImageFormatPropertiesNV) { - if (externalHandleType) { - return VK_ERROR_FORMAT_NOT_SUPPORTED; - } - - if (!icd_term->dispatch.GetPhysicalDeviceImageFormatProperties) { - return VK_ERROR_INITIALIZATION_FAILED; - } - - pExternalImageFormatProperties->externalMemoryFeatures = 0; - pExternalImageFormatProperties->exportFromImportedHandleTypes = 0; - pExternalImageFormatProperties->compatibleHandleTypes = 0; - - return icd_term->dispatch.GetPhysicalDeviceImageFormatProperties( - phys_dev_term->phys_dev, format, type, tiling, usage, flags, - &pExternalImageFormatProperties->imageFormatProperties); - } - - return icd_term->dispatch.GetPhysicalDeviceExternalImageFormatPropertiesNV( - phys_dev_term->phys_dev, format, type, tiling, usage, flags, - externalHandleType, pExternalImageFormatProperties); -} - -// ---- VK_KHR_get_physical_device_properties2 extension trampoline/terminators - -VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceFeatures2KHR(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures2KHR *pFeatures) { - const VkLayerInstanceDispatchTable *disp; - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - disp->GetPhysicalDeviceFeatures2KHR(unwrapped_phys_dev, pFeatures); -} - -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceFeatures2KHR(VkPhysicalDevice physicalDevice, - VkPhysicalDeviceFeatures2KHR *pFeatures) { - 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; - - if (icd_term->dispatch.GetPhysicalDeviceFeatures2KHR != NULL) { - // Pass the call to the driver - icd_term->dispatch.GetPhysicalDeviceFeatures2KHR(phys_dev_term->phys_dev, pFeatures); - } else { - // Emulate the call - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, - "vkGetPhysicalDeviceFeatures2KHR: Emulating call in ICD \"%s\" using vkGetPhysicalDeviceFeatures", - icd_term->scanned_icd->lib_name); - - // Write to the VkPhysicalDeviceFeatures2KHR struct - icd_term->dispatch.GetPhysicalDeviceFeatures(phys_dev_term->phys_dev, &pFeatures->features); - - void *pNext = pFeatures->pNext; - while (pNext != NULL) { - switch (*(VkStructureType *)pNext) { - case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES_KHX: { - // Skip the check if VK_KHX_multiview is enabled because it's a device extension - // Write to the VkPhysicalDeviceMultiviewFeaturesKHX struct - VkPhysicalDeviceMultiviewFeaturesKHX *multiview_features = pNext; - multiview_features->multiview = VK_FALSE; - multiview_features->multiviewGeometryShader = VK_FALSE; - multiview_features->multiviewTessellationShader = VK_FALSE; - - pNext = multiview_features->pNext; - break; - } - default: { - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, - "vkGetPhysicalDeviceFeatures2KHR: Emulation found unrecognized structure type in pFeatures->pNext - " - "this struct will be ignored"); - - struct VkStructureHeader *header = pNext; - pNext = (void *)header->pNext; - break; - } - } - } - } -} - -VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceProperties2KHR(VkPhysicalDevice physicalDevice, - VkPhysicalDeviceProperties2KHR *pProperties) { - const VkLayerInstanceDispatchTable *disp; - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - disp->GetPhysicalDeviceProperties2KHR(unwrapped_phys_dev, pProperties); -} - -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceProperties2KHR(VkPhysicalDevice physicalDevice, - VkPhysicalDeviceProperties2KHR *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; - - if (icd_term->dispatch.GetPhysicalDeviceProperties2KHR != NULL) { - // Pass the call to the driver - icd_term->dispatch.GetPhysicalDeviceProperties2KHR(phys_dev_term->phys_dev, pProperties); - } else { - // Emulate the call - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, - "vkGetPhysicalDeviceProperties2KHR: Emulating call in ICD \"%s\" using vkGetPhysicalDeviceProperties", - icd_term->scanned_icd->lib_name); - - // Write to the VkPhysicalDeviceProperties2KHR struct - icd_term->dispatch.GetPhysicalDeviceProperties(phys_dev_term->phys_dev, &pProperties->properties); - - void *pNext = pProperties->pNext; - while (pNext != NULL) { - switch (*(VkStructureType *)pNext) { - case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES_KHR: { - VkPhysicalDeviceIDPropertiesKHR *id_properties = pNext; - - // Verify that "VK_KHR_external_memory_capabilities" is enabled - if (icd_term->this_instance->enabled_known_extensions.khr_external_memory_capabilities) { - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, - "vkGetPhysicalDeviceProperties2KHR: Emulation cannot generate unique IDs for struct " - "VkPhysicalDeviceIDPropertiesKHR - setting IDs to zero instead"); - - // Write to the VkPhysicalDeviceIDPropertiesKHR struct - memset(id_properties->deviceUUID, 0, VK_UUID_SIZE); - memset(id_properties->driverUUID, 0, VK_UUID_SIZE); - id_properties->deviceLUIDValid = VK_FALSE; - } - - pNext = id_properties->pNext; - break; - } - default: { - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, - "vkGetPhysicalDeviceProperties2KHR: Emulation found unrecognized structure type in " - "pProperties->pNext - this struct will be ignored"); - - struct VkStructureHeader *header = pNext; - pNext = (void *)header->pNext; - break; - } - } - } - } -} - -VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceFormatProperties2KHR(VkPhysicalDevice physicalDevice, VkFormat format, - VkFormatProperties2KHR *pFormatProperties) { - const VkLayerInstanceDispatchTable *disp; - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - disp->GetPhysicalDeviceFormatProperties2KHR(unwrapped_phys_dev, format, pFormatProperties); -} - -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceFormatProperties2KHR(VkPhysicalDevice physicalDevice, VkFormat format, - VkFormatProperties2KHR *pFormatProperties) { - 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; - - if (icd_term->dispatch.GetPhysicalDeviceFormatProperties2KHR != NULL) { - // Pass the call to the driver - icd_term->dispatch.GetPhysicalDeviceFormatProperties2KHR(phys_dev_term->phys_dev, format, pFormatProperties); - } else { - // Emulate the call - loader_log( - icd_term->this_instance, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, - "vkGetPhysicalDeviceFormatProperties2KHR: Emulating call in ICD \"%s\" using vkGetPhysicalDeviceFormatProperties", - icd_term->scanned_icd->lib_name); - - // Write to the VkFormatProperties2KHR struct - icd_term->dispatch.GetPhysicalDeviceFormatProperties(phys_dev_term->phys_dev, format, &pFormatProperties->formatProperties); - - if (pFormatProperties->pNext != NULL) { - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, - "vkGetPhysicalDeviceFormatProperties2KHR: Emulation found unrecognized structure type in " - "pFormatProperties->pNext - this struct will be ignored"); - } - } -} - -VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceImageFormatProperties2KHR( - VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2KHR *pImageFormatInfo, - VkImageFormatProperties2KHR *pImageFormatProperties) { - const VkLayerInstanceDispatchTable *disp; - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - return disp->GetPhysicalDeviceImageFormatProperties2KHR(unwrapped_phys_dev, pImageFormatInfo, pImageFormatProperties); -} - -VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceImageFormatProperties2KHR( - VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2KHR *pImageFormatInfo, - VkImageFormatProperties2KHR *pImageFormatProperties) { - 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; - - if (icd_term->dispatch.GetPhysicalDeviceImageFormatProperties2KHR != NULL) { - // Pass the call to the driver - return icd_term->dispatch.GetPhysicalDeviceImageFormatProperties2KHR(phys_dev_term->phys_dev, pImageFormatInfo, - pImageFormatProperties); - } else { - // Emulate the call - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, - "vkGetPhysicalDeviceImageFormatProperties2KHR: Emulating call in ICD \"%s\" using " - "vkGetPhysicalDeviceImageFormatProperties", - icd_term->scanned_icd->lib_name); - - // If there is more info in either pNext, then this is unsupported - if (pImageFormatInfo->pNext != NULL || pImageFormatProperties->pNext != NULL) { - return VK_ERROR_FORMAT_NOT_SUPPORTED; - } - - // Write to the VkImageFormatProperties2KHR struct - return icd_term->dispatch.GetPhysicalDeviceImageFormatProperties( - phys_dev_term->phys_dev, pImageFormatInfo->format, pImageFormatInfo->type, pImageFormatInfo->tiling, - pImageFormatInfo->usage, pImageFormatInfo->flags, &pImageFormatProperties->imageFormatProperties); - } -} - -VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceQueueFamilyProperties2KHR(VkPhysicalDevice physicalDevice, - uint32_t *pQueueFamilyPropertyCount, - VkQueueFamilyProperties2KHR *pQueueFamilyProperties) { - const VkLayerInstanceDispatchTable *disp; - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - disp->GetPhysicalDeviceQueueFamilyProperties2KHR(unwrapped_phys_dev, pQueueFamilyPropertyCount, pQueueFamilyProperties); -} - -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceQueueFamilyProperties2KHR( - VkPhysicalDevice physicalDevice, uint32_t *pQueueFamilyPropertyCount, VkQueueFamilyProperties2KHR *pQueueFamilyProperties) { - 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; - - if (icd_term->dispatch.GetPhysicalDeviceQueueFamilyProperties2KHR != NULL) { - // Pass the call to the driver - icd_term->dispatch.GetPhysicalDeviceQueueFamilyProperties2KHR(phys_dev_term->phys_dev, pQueueFamilyPropertyCount, - pQueueFamilyProperties); - } else { - // Emulate the call - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, - "vkGetPhysicalDeviceQueueFamilyProperties2KHR: Emulating call in ICD \"%s\" using " - "vkGetPhysicalDeviceQueueFamilyProperties", - icd_term->scanned_icd->lib_name); - - if (pQueueFamilyProperties == NULL || *pQueueFamilyPropertyCount == 0) { - // Write to pQueueFamilyPropertyCount - icd_term->dispatch.GetPhysicalDeviceQueueFamilyProperties(phys_dev_term->phys_dev, pQueueFamilyPropertyCount, NULL); - } else { - // Allocate a temporary array for the output of the old function - VkQueueFamilyProperties *properties = loader_stack_alloc(*pQueueFamilyPropertyCount * sizeof(VkQueueFamilyProperties)); - if (properties == NULL) { - *pQueueFamilyPropertyCount = 0; - loader_log( - icd_term->this_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "vkGetPhysicalDeviceQueueFamilyProperties2KHR: Out of memory - Failed to allocate array for loader emulation."); - return; - } - - icd_term->dispatch.GetPhysicalDeviceQueueFamilyProperties(phys_dev_term->phys_dev, pQueueFamilyPropertyCount, - properties); - for (uint32_t i = 0; i < *pQueueFamilyPropertyCount; ++i) { - // Write to the VkQueueFamilyProperties2KHR struct - memcpy(&pQueueFamilyProperties[i].queueFamilyProperties, &properties[i], sizeof(VkQueueFamilyProperties)); - - if (pQueueFamilyProperties[i].pNext != NULL) { - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, - "vkGetPhysicalDeviceQueueFamilyProperties2KHR: Emulation found unrecognized structure type in " - "pQueueFamilyProperties[%d].pNext - this struct will be ignored", - i); - } - } - } - } -} - -VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceMemoryProperties2KHR(VkPhysicalDevice physicalDevice, - VkPhysicalDeviceMemoryProperties2KHR *pMemoryProperties) { - const VkLayerInstanceDispatchTable *disp; - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - disp->GetPhysicalDeviceMemoryProperties2KHR(unwrapped_phys_dev, pMemoryProperties); -} - -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceMemoryProperties2KHR( - VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties2KHR *pMemoryProperties) { - 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; - - if (icd_term->dispatch.GetPhysicalDeviceMemoryProperties2KHR != NULL) { - // Pass the call to the driver - icd_term->dispatch.GetPhysicalDeviceMemoryProperties2KHR(phys_dev_term->phys_dev, pMemoryProperties); - } else { - // Emulate the call - loader_log( - icd_term->this_instance, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, - "vkGetPhysicalDeviceMemoryProperties2KHR: Emulating call in ICD \"%s\" using vkGetPhysicalDeviceMemoryProperties", - icd_term->scanned_icd->lib_name); - - // Write to the VkPhysicalDeviceMemoryProperties2KHR struct - icd_term->dispatch.GetPhysicalDeviceMemoryProperties(phys_dev_term->phys_dev, &pMemoryProperties->memoryProperties); - - if (pMemoryProperties->pNext != NULL) { - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, - "vkGetPhysicalDeviceMemoryProperties2KHR: Emulation found unrecognized structure type in " - "pMemoryProperties->pNext - this struct will be ignored"); - } - } -} - -VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceSparseImageFormatProperties2KHR( - VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSparseImageFormatInfo2KHR *pFormatInfo, uint32_t *pPropertyCount, - VkSparseImageFormatProperties2KHR *pProperties) { - const VkLayerInstanceDispatchTable *disp; - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - disp->GetPhysicalDeviceSparseImageFormatProperties2KHR(unwrapped_phys_dev, pFormatInfo, pPropertyCount, pProperties); -} - -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceSparseImageFormatProperties2KHR( - VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSparseImageFormatInfo2KHR *pFormatInfo, uint32_t *pPropertyCount, - VkSparseImageFormatProperties2KHR *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; - - if (icd_term->dispatch.GetPhysicalDeviceSparseImageFormatProperties2KHR != NULL) { - // Pass the call to the driver - icd_term->dispatch.GetPhysicalDeviceSparseImageFormatProperties2KHR(phys_dev_term->phys_dev, pFormatInfo, pPropertyCount, - pProperties); - } else { - // Emulate the call - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, - "vkGetPhysicalDeviceSparseImageFormatProperties2KHR: Emulating call in ICD \"%s\" using " - "vkGetPhysicalDeviceSparseImageFormatProperties", - icd_term->scanned_icd->lib_name); - - if (pFormatInfo->pNext != NULL) { - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, - "vkGetPhysicalDeviceSparseImageFormatProperties2KHR: Emulation found unrecognized structure type in " - "pFormatInfo->pNext - this struct will be ignored"); - } - - if (pProperties == NULL || *pPropertyCount == 0) { - // Write to pPropertyCount - icd_term->dispatch.GetPhysicalDeviceSparseImageFormatProperties( - phys_dev_term->phys_dev, pFormatInfo->format, pFormatInfo->type, pFormatInfo->samples, pFormatInfo->usage, - pFormatInfo->tiling, pPropertyCount, NULL); - } else { - // Allocate a temporary array for the output of the old function - VkSparseImageFormatProperties *properties = - loader_stack_alloc(*pPropertyCount * sizeof(VkSparseImageMemoryRequirements)); - if (properties == NULL) { - *pPropertyCount = 0; - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "vkGetPhysicalDeviceSparseImageFormatProperties2KHR: Out of memory - Failed to allocate array for " - "loader emulation."); - return; - } - - icd_term->dispatch.GetPhysicalDeviceSparseImageFormatProperties( - phys_dev_term->phys_dev, pFormatInfo->format, pFormatInfo->type, pFormatInfo->samples, pFormatInfo->usage, - pFormatInfo->tiling, pPropertyCount, properties); - for (uint32_t i = 0; i < *pPropertyCount; ++i) { - // Write to the VkSparseImageFormatProperties2KHR struct - memcpy(&pProperties[i].properties, &properties[i], sizeof(VkSparseImageFormatProperties)); - - if (pProperties[i].pNext != NULL) { - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, - "vkGetPhysicalDeviceSparseImageFormatProperties2KHR: Emulation found unrecognized structure type in " - "pProperties[%d].pNext - this struct will be ignored", - i); - } - } - } - } -} - -// ---- VK_KHR_get_surface_capabilities2 extension trampoline/terminators - -VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceSurfaceCapabilities2KHR(VkPhysicalDevice physicalDevice, - const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, - VkSurfaceCapabilities2KHR *pSurfaceCapabilities) { - const VkLayerInstanceDispatchTable *disp; - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - return disp->GetPhysicalDeviceSurfaceCapabilities2KHR(unwrapped_phys_dev, pSurfaceInfo, pSurfaceCapabilities); -} - -VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceCapabilities2KHR( - VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, - VkSurfaceCapabilities2KHR *pSurfaceCapabilities) { - 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; - - VkIcdSurface *icd_surface = (VkIcdSurface *)(pSurfaceInfo->surface); - uint8_t icd_index = phys_dev_term->icd_index; - - if (icd_term->dispatch.GetPhysicalDeviceSurfaceCapabilities2KHR != NULL) { - // Pass the call to the driver, possibly unwrapping the ICD surface - if (icd_surface->real_icd_surfaces != NULL && (void *)icd_surface->real_icd_surfaces[icd_index] != NULL) { - VkPhysicalDeviceSurfaceInfo2KHR info_copy = *pSurfaceInfo; - info_copy.surface = icd_surface->real_icd_surfaces[icd_index]; - return icd_term->dispatch.GetPhysicalDeviceSurfaceCapabilities2KHR(phys_dev_term->phys_dev, &info_copy, - pSurfaceCapabilities); - } else { - return icd_term->dispatch.GetPhysicalDeviceSurfaceCapabilities2KHR(phys_dev_term->phys_dev, pSurfaceInfo, - pSurfaceCapabilities); - } - } else { - // Emulate the call - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, - "vkGetPhysicalDeviceSurfaceCapabilities2KHR: Emulating call in ICD \"%s\" using " - "vkGetPhysicalDeviceSurfaceCapabilitiesKHR", - icd_term->scanned_icd->lib_name); - - if (pSurfaceInfo->pNext != NULL) { - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, - "vkGetPhysicalDeviceSurfaceCapabilities2KHR: Emulation found unrecognized structure type in " - "pSurfaceInfo->pNext - this struct will be ignored"); - } - - // Write to the VkSurfaceCapabilities2KHR struct - VkSurfaceKHR surface = pSurfaceInfo->surface; - if (icd_surface->real_icd_surfaces != NULL && (void *)icd_surface->real_icd_surfaces[icd_index] != NULL) { - surface = icd_surface->real_icd_surfaces[icd_index]; - } - VkResult res = icd_term->dispatch.GetPhysicalDeviceSurfaceCapabilitiesKHR(phys_dev_term->phys_dev, surface, - &pSurfaceCapabilities->surfaceCapabilities); - - if (pSurfaceCapabilities->pNext != NULL) { - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, - "vkGetPhysicalDeviceSurfaceCapabilities2KHR: Emulation found unrecognized structure type in " - "pSurfaceCapabilities->pNext - this struct will be ignored"); - } - return res; - } -} - -VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceSurfaceFormats2KHR(VkPhysicalDevice physicalDevice, - const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, - uint32_t *pSurfaceFormatCount, - VkSurfaceFormat2KHR *pSurfaceFormats) { - const VkLayerInstanceDispatchTable *disp; - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - return disp->GetPhysicalDeviceSurfaceFormats2KHR(unwrapped_phys_dev, pSurfaceInfo, pSurfaceFormatCount, pSurfaceFormats); -} - -VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceFormats2KHR(VkPhysicalDevice physicalDevice, - const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, - uint32_t *pSurfaceFormatCount, - VkSurfaceFormat2KHR *pSurfaceFormats) { - 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; - - VkIcdSurface *icd_surface = (VkIcdSurface *)(pSurfaceInfo->surface); - uint8_t icd_index = phys_dev_term->icd_index; - - if (icd_term->dispatch.GetPhysicalDeviceSurfaceFormats2KHR != NULL) { - // Pass the call to the driver, possibly unwrapping the ICD surface - if (icd_surface->real_icd_surfaces != NULL && (void *)icd_surface->real_icd_surfaces[icd_index] != NULL) { - VkPhysicalDeviceSurfaceInfo2KHR info_copy = *pSurfaceInfo; - info_copy.surface = icd_surface->real_icd_surfaces[icd_index]; - return icd_term->dispatch.GetPhysicalDeviceSurfaceFormats2KHR(phys_dev_term->phys_dev, &info_copy, pSurfaceFormatCount, - pSurfaceFormats); - } else { - return icd_term->dispatch.GetPhysicalDeviceSurfaceFormats2KHR(phys_dev_term->phys_dev, pSurfaceInfo, - pSurfaceFormatCount, pSurfaceFormats); - } - } else { - // Emulate the call - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, - "vkGetPhysicalDeviceSurfaceFormats2KHR: Emulating call in ICD \"%s\" using vkGetPhysicalDeviceSurfaceFormatsKHR", - icd_term->scanned_icd->lib_name); - - if (pSurfaceInfo->pNext != NULL) { - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, - "vkGetPhysicalDeviceSurfaceFormats2KHR: Emulation found unrecognized structure type in pSurfaceInfo->pNext " - "- this struct will be ignored"); - } - - VkSurfaceKHR surface = pSurfaceInfo->surface; - if (icd_surface->real_icd_surfaces != NULL && (void *)icd_surface->real_icd_surfaces[icd_index] != NULL) { - surface = icd_surface->real_icd_surfaces[icd_index]; - } - - if (*pSurfaceFormatCount == 0 || pSurfaceFormats == NULL) { - // Write to pSurfaceFormatCount - return icd_term->dispatch.GetPhysicalDeviceSurfaceFormatsKHR(phys_dev_term->phys_dev, surface, pSurfaceFormatCount, - NULL); - } else { - // Allocate a temporary array for the output of the old function - VkSurfaceFormatKHR *formats = loader_stack_alloc(*pSurfaceFormatCount * sizeof(VkSurfaceFormatKHR)); - if (formats == NULL) { - return VK_ERROR_OUT_OF_HOST_MEMORY; - } - - VkResult res = icd_term->dispatch.GetPhysicalDeviceSurfaceFormatsKHR(phys_dev_term->phys_dev, surface, - pSurfaceFormatCount, formats); - for (uint32_t i = 0; i < *pSurfaceFormatCount; ++i) { - pSurfaceFormats[i].surfaceFormat = formats[i]; - if (pSurfaceFormats[i].pNext != NULL) { - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, - "vkGetPhysicalDeviceSurfaceFormats2KHR: Emulation found unrecognized structure type in " - "pSurfaceFormats[%d].pNext - this struct will be ignored", - i); - } - } - return res; - } - } -} - -// ---- VK_EXT_display_surface_counter extension trampoline/terminators - -VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceSurfaceCapabilities2EXT(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, - VkSurfaceCapabilities2EXT *pSurfaceCapabilities) { - const VkLayerInstanceDispatchTable *disp; - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - return disp->GetPhysicalDeviceSurfaceCapabilities2EXT(unwrapped_phys_dev, surface, pSurfaceCapabilities); -} - -VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceCapabilities2EXT( - VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, VkSurfaceCapabilities2EXT *pSurfaceCapabilities) { - 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; - - VkIcdSurface *icd_surface = (VkIcdSurface *)(surface); - uint8_t icd_index = phys_dev_term->icd_index; - - // Unwrap the surface if needed - VkSurfaceKHR unwrapped_surface = surface; - if (icd_surface->real_icd_surfaces != NULL && (void *)icd_surface->real_icd_surfaces[icd_index] != NULL) { - unwrapped_surface = icd_surface->real_icd_surfaces[icd_index]; - } - - if (icd_term->dispatch.GetPhysicalDeviceSurfaceCapabilities2EXT != NULL) { - // Pass the call to the driver - return icd_term->dispatch.GetPhysicalDeviceSurfaceCapabilities2EXT(phys_dev_term->phys_dev, unwrapped_surface, - pSurfaceCapabilities); - } else { - // Emulate the call - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, - "vkGetPhysicalDeviceSurfaceCapabilities2EXT: Emulating call in ICD \"%s\" using " - "vkGetPhysicalDeviceSurfaceCapabilitiesKHR", - icd_term->scanned_icd->lib_name); - - VkSurfaceCapabilitiesKHR surface_caps; - VkResult res = - icd_term->dispatch.GetPhysicalDeviceSurfaceCapabilitiesKHR(phys_dev_term->phys_dev, unwrapped_surface, &surface_caps); - pSurfaceCapabilities->minImageCount = surface_caps.minImageCount; - pSurfaceCapabilities->maxImageCount = surface_caps.maxImageCount; - pSurfaceCapabilities->currentExtent = surface_caps.currentExtent; - pSurfaceCapabilities->minImageExtent = surface_caps.minImageExtent; - pSurfaceCapabilities->maxImageExtent = surface_caps.maxImageExtent; - pSurfaceCapabilities->maxImageArrayLayers = surface_caps.maxImageArrayLayers; - pSurfaceCapabilities->supportedTransforms = surface_caps.supportedTransforms; - pSurfaceCapabilities->currentTransform = surface_caps.currentTransform; - pSurfaceCapabilities->supportedCompositeAlpha = surface_caps.supportedCompositeAlpha; - pSurfaceCapabilities->supportedUsageFlags = surface_caps.supportedUsageFlags; - pSurfaceCapabilities->supportedSurfaceCounters = 0; - - if (pSurfaceCapabilities->pNext != NULL) { - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, - "vkGetPhysicalDeviceSurfaceCapabilities2EXT: Emulation found unrecognized structure type in " - "pSurfaceCapabilities->pNext - this struct will be ignored"); - } - - return res; - } -} - -// ---- VK_EXT_direct_mode_display extension trampoline/terminators - -VKAPI_ATTR VkResult VKAPI_CALL ReleaseDisplayEXT(VkPhysicalDevice physicalDevice, VkDisplayKHR display) { - const VkLayerInstanceDispatchTable *disp; - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - return disp->ReleaseDisplayEXT(unwrapped_phys_dev, display); -} - -VKAPI_ATTR VkResult VKAPI_CALL terminator_ReleaseDisplayEXT(VkPhysicalDevice physicalDevice, VkDisplayKHR display) { - 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; - - if (icd_term->dispatch.ReleaseDisplayEXT == NULL) { - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "ICD \"%s\" associated with VkPhysicalDevice does not support vkReleaseDisplayEXT - Consequently, the call is " - "invalid because it should not be possible to acquire a display on this device", - icd_term->scanned_icd->lib_name); - } - return icd_term->dispatch.ReleaseDisplayEXT(phys_dev_term->phys_dev, display); -} - -// ---- VK_EXT_acquire_xlib_display extension trampoline/terminators - -#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT -VKAPI_ATTR VkResult VKAPI_CALL AcquireXlibDisplayEXT(VkPhysicalDevice physicalDevice, Display *dpy, VkDisplayKHR display) { - const VkLayerInstanceDispatchTable *disp; - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - return disp->AcquireXlibDisplayEXT(unwrapped_phys_dev, dpy, display); -} - -VKAPI_ATTR VkResult VKAPI_CALL terminator_AcquireXlibDisplayEXT(VkPhysicalDevice physicalDevice, Display *dpy, - VkDisplayKHR display) { - 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; - - if (icd_term->dispatch.AcquireXlibDisplayEXT != NULL) { - // Pass the call to the driver - return icd_term->dispatch.AcquireXlibDisplayEXT(phys_dev_term->phys_dev, dpy, display); - } else { - // Emulate the call - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, - "vkAcquireXLibDisplayEXT: Emulating call in ICD \"%s\" by returning error", icd_term->scanned_icd->lib_name); - - // Fail for the unsupported command - return VK_ERROR_INITIALIZATION_FAILED; - } -} - -VKAPI_ATTR VkResult VKAPI_CALL GetRandROutputDisplayEXT(VkPhysicalDevice physicalDevice, Display *dpy, RROutput rrOutput, - VkDisplayKHR *pDisplay) { - const VkLayerInstanceDispatchTable *disp; - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - return disp->GetRandROutputDisplayEXT(unwrapped_phys_dev, dpy, rrOutput, pDisplay); -} - -VKAPI_ATTR VkResult VKAPI_CALL terminator_GetRandROutputDisplayEXT(VkPhysicalDevice physicalDevice, Display *dpy, RROutput rrOutput, - VkDisplayKHR *pDisplay) { - 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; - - if (icd_term->dispatch.GetRandROutputDisplayEXT != NULL) { - // Pass the call to the driver - return icd_term->dispatch.GetRandROutputDisplayEXT(phys_dev_term->phys_dev, dpy, rrOutput, pDisplay); - } else { - // Emulate the call - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, - "vkGetRandROutputDisplayEXT: Emulating call in ICD \"%s\" by returning null display", - icd_term->scanned_icd->lib_name); - - // Return a null handle to indicate this can't be done - *pDisplay = VK_NULL_HANDLE; - return VK_SUCCESS; - } -} - -#endif // VK_USE_PLATFORM_XLIB_XRANDR_EXT - -// ---- VK_KHR_external_memory_capabilities extension trampoline/terminators - -VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceExternalBufferPropertiesKHR( - VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalBufferInfoKHR *pExternalBufferInfo, - VkExternalBufferPropertiesKHR *pExternalBufferProperties) { - const VkLayerInstanceDispatchTable *disp; - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - disp->GetPhysicalDeviceExternalBufferPropertiesKHR(unwrapped_phys_dev, pExternalBufferInfo, pExternalBufferProperties); -} - -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceExternalBufferPropertiesKHR( - VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalBufferInfoKHR *pExternalBufferInfo, - VkExternalBufferPropertiesKHR *pExternalBufferProperties) { - 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; - - if (icd_term->dispatch.GetPhysicalDeviceExternalBufferPropertiesKHR) { - // Pass the call to the driver - icd_term->dispatch.GetPhysicalDeviceExternalBufferPropertiesKHR(phys_dev_term->phys_dev, pExternalBufferInfo, - pExternalBufferProperties); - } else { - // Emulate the call - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, - "vkGetPhysicalDeviceExternalBufferPropertiesKHR: Emulating call in ICD \"%s\"", icd_term->scanned_icd->lib_name); - - if (pExternalBufferInfo->pNext != NULL) { - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, - "vkGetPhysicalDeviceExternalBufferPropertiesKHR: Emulation found unrecognized structure type in " - "pExternalBufferInfo->pNext - this struct will be ignored"); - } - - // Fill in everything being unsupported - memset(&pExternalBufferProperties->externalMemoryProperties, 0, sizeof(VkExternalMemoryPropertiesKHR)); - - if (pExternalBufferProperties->pNext != NULL) { - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, - "vkGetPhysicalDeviceExternalBufferPropertiesKHR: Emulation found unrecognized structure type in " - "pExternalBufferProperties->pNext - this struct will be ignored"); - } - } -} - -// ---- VK_KHR_external_semaphore_capabilities extension trampoline/terminators - -VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceExternalSemaphorePropertiesKHR( - VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalSemaphoreInfoKHR *pExternalSemaphoreInfo, - VkExternalSemaphorePropertiesKHR *pExternalSemaphoreProperties) { - const VkLayerInstanceDispatchTable *disp; - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - disp->GetPhysicalDeviceExternalSemaphorePropertiesKHR(unwrapped_phys_dev, pExternalSemaphoreInfo, pExternalSemaphoreProperties); -} - -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceExternalSemaphorePropertiesKHR( - VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalSemaphoreInfoKHR *pExternalSemaphoreInfo, - VkExternalSemaphorePropertiesKHR *pExternalSemaphoreProperties) { - 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; - - if (icd_term->dispatch.GetPhysicalDeviceExternalSemaphorePropertiesKHR != NULL) { - // Pass the call to the driver - icd_term->dispatch.GetPhysicalDeviceExternalSemaphorePropertiesKHR(phys_dev_term->phys_dev, pExternalSemaphoreInfo, - pExternalSemaphoreProperties); - } else { - // Emulate the call - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, - "vkGetPhysicalDeviceExternalSemaphorePropertiesKHR: Emulating call in ICD \"%s\"", - icd_term->scanned_icd->lib_name); - - if (pExternalSemaphoreInfo->pNext != NULL) { - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, - "vkGetPhysicalDeviceExternalSemaphorePropertiesKHR: Emulation found unrecognized structure type in " - "pExternalSemaphoreInfo->pNext - this struct will be ignored"); - } - - // Fill in everything being unsupported - pExternalSemaphoreProperties->exportFromImportedHandleTypes = 0; - pExternalSemaphoreProperties->compatibleHandleTypes = 0; - pExternalSemaphoreProperties->externalSemaphoreFeatures = 0; - - if (pExternalSemaphoreProperties->pNext != NULL) { - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, - "vkGetPhysicalDeviceExternalSemaphorePropertiesKHR: Emulation found unrecognized structure type in " - "pExternalSemaphoreProperties->pNext - this struct will be ignored"); - } - } -} - -// ---- VK_KHR_external_fence_capabilities extension trampoline/terminators - -VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceExternalFencePropertiesKHR( - VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalFenceInfoKHR *pExternalFenceInfo, - VkExternalFencePropertiesKHR *pExternalFenceProperties) { - const VkLayerInstanceDispatchTable *disp; - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - disp->GetPhysicalDeviceExternalFencePropertiesKHR(unwrapped_phys_dev, pExternalFenceInfo, pExternalFenceProperties); -} - -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceExternalFencePropertiesKHR( - VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalFenceInfoKHR *pExternalFenceInfo, - VkExternalFencePropertiesKHR *pExternalFenceProperties) { - 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; - - if (icd_term->dispatch.GetPhysicalDeviceExternalFencePropertiesKHR != NULL) { - // Pass the call to the driver - icd_term->dispatch.GetPhysicalDeviceExternalFencePropertiesKHR(phys_dev_term->phys_dev, pExternalFenceInfo, - pExternalFenceProperties); - } else { - // Emulate the call - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, - "vkGetPhysicalDeviceExternalFencePropertiesKHR: Emulating call in ICD \"%s\"", icd_term->scanned_icd->lib_name); - - if (pExternalFenceInfo->pNext != NULL) { - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, - "vkGetPhysicalDeviceExternalFencePropertiesKHR: Emulation found unrecognized structure type in " - "pExternalFenceInfo->pNext - this struct will be ignored"); - } - - // Fill in everything being unsupported - pExternalFenceProperties->exportFromImportedHandleTypes = 0; - pExternalFenceProperties->compatibleHandleTypes = 0; - pExternalFenceProperties->externalFenceFeatures = 0; - - if (pExternalFenceProperties->pNext != NULL) { - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, - "vkGetPhysicalDeviceExternalFencePropertiesKHR: Emulation found unrecognized structure type in " - "pExternalFenceProperties->pNext - this struct will be ignored"); - } - } -} - -// ---- Helper functions - -VkResult setupLoaderTrampPhysDevGroups(VkInstance instance) { - VkResult res = VK_SUCCESS; - struct loader_instance *inst; - uint32_t total_count = 0; - VkPhysicalDeviceGroupPropertiesKHX **new_phys_dev_groups = NULL; - VkPhysicalDeviceGroupPropertiesKHX *local_phys_dev_groups = NULL; - - inst = loader_get_instance(instance); - if (NULL == inst) { - res = VK_ERROR_INITIALIZATION_FAILED; - goto out; - } - - // Setup the trampoline loader physical devices. This will actually - // call down and setup the terminator loader physical devices during the - // process. - VkResult setup_res = setupLoaderTrampPhysDevs(instance); - if (setup_res != VK_SUCCESS && setup_res != VK_INCOMPLETE) { - res = setup_res; - goto out; - } - - // Query how many physical device groups there - res = inst->disp->layer_inst_disp.EnumeratePhysicalDeviceGroupsKHX(instance, &total_count, NULL); - if (res != VK_SUCCESS) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "setupLoaderTrampPhysDevGroups: Failed during dispatch call of " - "\'EnumeratePhysicalDeviceGroupsKHX\' to lower layers or " - "loader to get count."); - goto out; - } - - // Create an array for the new physical device groups, which will be stored - // in the instance for the trampoline code. - new_phys_dev_groups = (VkPhysicalDeviceGroupPropertiesKHX **)loader_instance_heap_alloc( - inst, total_count * sizeof(VkPhysicalDeviceGroupPropertiesKHX *), VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); - if (NULL == new_phys_dev_groups) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "setupLoaderTrampPhysDevGroups: Failed to allocate new physical device" - " group array of size %d", - total_count); - res = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - memset(new_phys_dev_groups, 0, total_count * sizeof(VkPhysicalDeviceGroupPropertiesKHX *)); - - // Create a temporary array (on the stack) to keep track of the - // returned VkPhysicalDevice values. - local_phys_dev_groups = loader_stack_alloc(sizeof(VkPhysicalDeviceGroupPropertiesKHX) * total_count); - if (NULL == local_phys_dev_groups) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "setupLoaderTrampPhysDevGroups: Failed to allocate local " - "physical device group array of size %d", - total_count); - res = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - // Initialize the memory to something valid - memset(local_phys_dev_groups, 0, sizeof(VkPhysicalDeviceGroupPropertiesKHX) * total_count); - for (uint32_t group = 0; group < total_count; group++) { - local_phys_dev_groups[group].sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GROUP_PROPERTIES_KHX; - local_phys_dev_groups[group].pNext = NULL; - local_phys_dev_groups[group].subsetAllocation = false; - } - - // Call down and get the content - res = inst->disp->layer_inst_disp.EnumeratePhysicalDeviceGroupsKHX(instance, &total_count, local_phys_dev_groups); - if (VK_SUCCESS != res) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "setupLoaderTrampPhysDevGroups: Failed during dispatch call of " - "\'EnumeratePhysicalDeviceGroupsKHX\' to lower layers or " - "loader to get content."); - goto out; - } - - // Replace all the physical device IDs with the proper loader values - for (uint32_t group = 0; group < total_count; group++) { - for (uint32_t group_gpu = 0; group_gpu < local_phys_dev_groups[group].physicalDeviceCount; group_gpu++) { - bool found = false; - for (uint32_t tramp_gpu = 0; tramp_gpu < inst->phys_dev_count_tramp; tramp_gpu++) { - if (local_phys_dev_groups[group].physicalDevices[group_gpu] == inst->phys_devs_tramp[tramp_gpu]->phys_dev) { - local_phys_dev_groups[group].physicalDevices[group_gpu] = (VkPhysicalDevice)inst->phys_devs_tramp[tramp_gpu]; - found = true; - break; - } - } - if (!found) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "setupLoaderTrampPhysDevGroups: Failed to find GPU %d in group %d" - " returned by \'EnumeratePhysicalDeviceGroupsKHX\' in list returned" - " by \'EnumeratePhysicalDevices\'", group_gpu, group); - res = VK_ERROR_INITIALIZATION_FAILED; - goto out; - } - } - } - - // Copy or create everything to fill the new array of physical device groups - for (uint32_t new_idx = 0; new_idx < total_count; new_idx++) { - // Check if this physical device group with the same contents is already in the old buffer - for (uint32_t old_idx = 0; old_idx < inst->phys_dev_group_count_tramp; old_idx++) { - if (local_phys_dev_groups[new_idx].physicalDeviceCount == inst->phys_dev_groups_tramp[old_idx]->physicalDeviceCount) { - bool found_all_gpus = true; - for (uint32_t old_gpu = 0; old_gpu < inst->phys_dev_groups_tramp[old_idx]->physicalDeviceCount; old_gpu++) { - bool found_gpu = false; - for (uint32_t new_gpu = 0; new_gpu < local_phys_dev_groups[new_idx].physicalDeviceCount; new_gpu++) { - if (local_phys_dev_groups[new_idx].physicalDevices[new_gpu] == inst->phys_dev_groups_tramp[old_idx]->physicalDevices[old_gpu]) { - found_gpu = true; - break; - } - } - - if (!found_gpu) { - found_all_gpus = false; - break; - } - } - if (!found_all_gpus) { - continue; - } else { - new_phys_dev_groups[new_idx] = inst->phys_dev_groups_tramp[old_idx]; - break; - } - } - } - - // If this physical device group isn't in the old buffer, create it - if (NULL == new_phys_dev_groups[new_idx]) { - new_phys_dev_groups[new_idx] = (VkPhysicalDeviceGroupPropertiesKHX *)loader_instance_heap_alloc( - inst, sizeof(VkPhysicalDeviceGroupPropertiesKHX), VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); - if (NULL == new_phys_dev_groups[new_idx]) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "setupLoaderTrampPhysDevGroups: Failed to allocate " - "physical device group trampoline object %d", - new_idx); - total_count = new_idx; - res = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - memcpy(new_phys_dev_groups[new_idx], &local_phys_dev_groups[new_idx], - sizeof(VkPhysicalDeviceGroupPropertiesKHX)); - } - } - -out: - - if (VK_SUCCESS != res) { - if (NULL != new_phys_dev_groups) { - for (uint32_t i = 0; i < total_count; i++) { - loader_instance_heap_free(inst, new_phys_dev_groups[i]); - } - loader_instance_heap_free(inst, new_phys_dev_groups); - } - total_count = 0; - } else { - // Free everything that didn't carry over to the new array of - // physical device groups - if (NULL != inst->phys_dev_groups_tramp) { - for (uint32_t i = 0; i < inst->phys_dev_group_count_tramp; i++) { - bool found = false; - for (uint32_t j = 0; j < total_count; j++) { - if (inst->phys_dev_groups_tramp[i] == new_phys_dev_groups[j]) { - found = true; - break; - } - } - if (!found) { - loader_instance_heap_free(inst, inst->phys_dev_groups_tramp[i]); - } - } - loader_instance_heap_free(inst, inst->phys_dev_groups_tramp); - } - - // Swap in the new physical device group list - inst->phys_dev_group_count_tramp = total_count; - inst->phys_dev_groups_tramp = new_phys_dev_groups; - } - - return res; -} - -VkResult setupLoaderTermPhysDevGroups(struct loader_instance *inst) { - VkResult res = VK_SUCCESS; - struct loader_icd_term *icd_term; - uint32_t total_count = 0; - uint32_t cur_icd_group_count = 0; - VkPhysicalDeviceGroupPropertiesKHX **new_phys_dev_groups = NULL; - VkPhysicalDeviceGroupPropertiesKHX *local_phys_dev_groups = NULL; - - if (0 == inst->phys_dev_count_term) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "setupLoaderTermPhysDevGroups: Loader failed to setup physical " - "device terminator info before calling \'EnumeratePhysicalDeviceGroupsKHX\'."); - assert(false); - res = VK_ERROR_INITIALIZATION_FAILED; - goto out; - } - - // For each ICD, query the number of physical device groups, and then get an - // internal value for those physical devices. - icd_term = inst->icd_terms; - for (uint32_t icd_idx = 0; NULL != icd_term; icd_term = icd_term->next, icd_idx++) { - cur_icd_group_count = 0; - if (NULL == icd_term->dispatch.EnumeratePhysicalDeviceGroupsKHX) { - // Treat each ICD's GPU as it's own group if the extension isn't supported - res = icd_term->dispatch.EnumeratePhysicalDevices(icd_term->instance, &cur_icd_group_count, NULL); - if (res != VK_SUCCESS) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "setupLoaderTermPhysDevGroups: Failed during dispatch call of " - "\'EnumeratePhysicalDevices\' to ICD %d to get plain phys dev count.", - icd_idx); - goto out; - } - } else { - // Query the actual group info - res = icd_term->dispatch.EnumeratePhysicalDeviceGroupsKHX(icd_term->instance, &cur_icd_group_count, NULL); - if (res != VK_SUCCESS) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "setupLoaderTermPhysDevGroups: Failed during dispatch call of " - "\'EnumeratePhysicalDeviceGroupsKHX\' to ICD %d to get count.", - icd_idx); - goto out; - } - } - total_count += cur_icd_group_count; - } - - // Create an array for the new physical device groups, which will be stored - // in the instance for the Terminator code. - new_phys_dev_groups = (VkPhysicalDeviceGroupPropertiesKHX **)loader_instance_heap_alloc( - inst, total_count * sizeof(VkPhysicalDeviceGroupPropertiesKHX *), VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); - if (NULL == new_phys_dev_groups) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "setupLoaderTermPhysDevGroups: Failed to allocate new physical device" - " group array of size %d", - total_count); - res = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - memset(new_phys_dev_groups, 0, total_count * sizeof(VkPhysicalDeviceGroupPropertiesKHX *)); - - // Create a temporary array (on the stack) to keep track of the - // returned VkPhysicalDevice values. - local_phys_dev_groups = loader_stack_alloc(sizeof(VkPhysicalDeviceGroupPropertiesKHX) * total_count); - if (NULL == local_phys_dev_groups) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "setupLoaderTermPhysDevGroups: Failed to allocate local " - "physical device group array of size %d", - total_count); - res = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - // Initialize the memory to something valid - memset(local_phys_dev_groups, 0, sizeof(VkPhysicalDeviceGroupPropertiesKHX) * total_count); - for (uint32_t group = 0; group < total_count; group++) { - local_phys_dev_groups[group].sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GROUP_PROPERTIES_KHX; - local_phys_dev_groups[group].pNext = NULL; - local_phys_dev_groups[group].subsetAllocation = false; - } - - cur_icd_group_count = 0; - icd_term = inst->icd_terms; - for (uint32_t icd_idx = 0; NULL != icd_term; icd_term = icd_term->next, icd_idx++) { - uint32_t count_this_time = total_count - cur_icd_group_count; - - if (NULL == icd_term->dispatch.EnumeratePhysicalDeviceGroupsKHX) { - VkPhysicalDevice* phys_dev_array = loader_stack_alloc(sizeof(VkPhysicalDevice) * count_this_time); - if (NULL == phys_dev_array) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "setupLoaderTermPhysDevGroups: Failed to allocate local " - "physical device array of size %d", - count_this_time); - res = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - - res = icd_term->dispatch.EnumeratePhysicalDevices(icd_term->instance, &count_this_time, phys_dev_array); - if (res != VK_SUCCESS) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "setupLoaderTermPhysDevGroups: Failed during dispatch call of " - "\'EnumeratePhysicalDevices\' to ICD %d to get plain phys dev count.", - icd_idx); - goto out; - } - - // Add each GPU as it's own group - for (uint32_t indiv_gpu = 0; indiv_gpu < count_this_time; indiv_gpu++) { - local_phys_dev_groups[indiv_gpu + cur_icd_group_count].physicalDeviceCount = 1; - local_phys_dev_groups[indiv_gpu + cur_icd_group_count].physicalDevices[0] = phys_dev_array[indiv_gpu]; - } - - } else { - res = icd_term->dispatch.EnumeratePhysicalDeviceGroupsKHX(icd_term->instance, &count_this_time, &local_phys_dev_groups[cur_icd_group_count]); - if (VK_SUCCESS != res) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "setupLoaderTermPhysDevGroups: Failed during dispatch call of " - "\'EnumeratePhysicalDeviceGroupsKHX\' to ICD %d to get content.", - icd_idx); - goto out; - } - } - - cur_icd_group_count += count_this_time; - } - - // Replace all the physical device IDs with the proper loader values - for (uint32_t group = 0; group < total_count; group++) { - for (uint32_t group_gpu = 0; group_gpu < local_phys_dev_groups[group].physicalDeviceCount; group_gpu++) { - bool found = false; - for (uint32_t term_gpu = 0; term_gpu < inst->phys_dev_count_term; term_gpu++) { - if (local_phys_dev_groups[group].physicalDevices[group_gpu] == inst->phys_devs_term[term_gpu]->phys_dev) { - local_phys_dev_groups[group].physicalDevices[group_gpu] = (VkPhysicalDevice)inst->phys_devs_term[term_gpu]; - found = true; - break; - } - } - if (!found) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "setupLoaderTermPhysDevGroups: Failed to find GPU %d in group %d" - " returned by \'EnumeratePhysicalDeviceGroupsKHX\' in list returned" - " by \'EnumeratePhysicalDevices\'", group_gpu, group); - res = VK_ERROR_INITIALIZATION_FAILED; - goto out; - } - } - } - - // Copy or create everything to fill the new array of physical device groups - for (uint32_t new_idx = 0; new_idx < total_count; new_idx++) { - // Check if this physical device group with the same contents is already in the old buffer - for (uint32_t old_idx = 0; old_idx < inst->phys_dev_group_count_term; old_idx++) { - if (local_phys_dev_groups[new_idx].physicalDeviceCount == inst->phys_dev_groups_term[old_idx]->physicalDeviceCount) { - bool found_all_gpus = true; - for (uint32_t old_gpu = 0; old_gpu < inst->phys_dev_groups_term[old_idx]->physicalDeviceCount; old_gpu++) { - bool found_gpu = false; - for (uint32_t new_gpu = 0; new_gpu < local_phys_dev_groups[new_idx].physicalDeviceCount; new_gpu++) { - if (local_phys_dev_groups[new_idx].physicalDevices[new_gpu] == inst->phys_dev_groups_term[old_idx]->physicalDevices[old_gpu]) { - found_gpu = true; - break; - } - } - - if (!found_gpu) { - found_all_gpus = false; - break; - } - } - if (!found_all_gpus) { - continue; - } else { - new_phys_dev_groups[new_idx] = inst->phys_dev_groups_term[old_idx]; - break; - } - } - } - - // If this physical device group isn't in the old buffer, create it - if (NULL == new_phys_dev_groups[new_idx]) { - new_phys_dev_groups[new_idx] = (VkPhysicalDeviceGroupPropertiesKHX *)loader_instance_heap_alloc( - inst, sizeof(VkPhysicalDeviceGroupPropertiesKHX), VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); - if (NULL == new_phys_dev_groups[new_idx]) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "setupLoaderTermPhysDevGroups: Failed to allocate " - "physical device group Terminator object %d", - new_idx); - total_count = new_idx; - res = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - memcpy(new_phys_dev_groups[new_idx], &local_phys_dev_groups[new_idx], - sizeof(VkPhysicalDeviceGroupPropertiesKHX)); - } - } - -out: - - if (VK_SUCCESS != res) { - if (NULL != new_phys_dev_groups) { - for (uint32_t i = 0; i < total_count; i++) { - loader_instance_heap_free(inst, new_phys_dev_groups[i]); - } - loader_instance_heap_free(inst, new_phys_dev_groups); - } - total_count = 0; - } else { - // Free everything that didn't carry over to the new array of - // physical device groups - if (NULL != inst->phys_dev_groups_term) { - for (uint32_t i = 0; i < inst->phys_dev_group_count_term; i++) { - bool found = false; - for (uint32_t j = 0; j < total_count; j++) { - if (inst->phys_dev_groups_term[i] == new_phys_dev_groups[j]) { - found = true; - break; - } - } - if (!found) { - loader_instance_heap_free(inst, inst->phys_dev_groups_term[i]); - } - } - loader_instance_heap_free(inst, inst->phys_dev_groups_term); - } - - // Swap in the new physical device group list - inst->phys_dev_group_count_term = total_count; - inst->phys_dev_groups_term = new_phys_dev_groups; - } - - return res; -} diff --git a/third_party/vulkan/loader/extension_manual.h b/third_party/vulkan/loader/extension_manual.h deleted file mode 100644 index 3b299d553..000000000 --- a/third_party/vulkan/loader/extension_manual.h +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright (c) 2015-2017 The Khronos Group Inc. - * Copyright (c) 2015-2017 Valve Corporation - * Copyright (c) 2015-2017 LunarG, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Author: Mark Young - */ - -#pragma once - -// ---- Manually added trampoline/terminator functions - -// These functions, for whatever reason, require more complex changes than -// can easily be automatically generated. - -VKAPI_ATTR VkResult VKAPI_CALL EnumeratePhysicalDeviceGroupsKHX( - VkInstance instance, uint32_t *pPhysicalDeviceGroupCount, - VkPhysicalDeviceGroupPropertiesKHX *pPhysicalDeviceGroupProperties); - -VKAPI_ATTR VkResult VKAPI_CALL terminator_EnumeratePhysicalDeviceGroupsKHX( - VkInstance instance, uint32_t *pPhysicalDeviceGroupCount, - VkPhysicalDeviceGroupPropertiesKHX *pPhysicalDeviceGroupProperties); - -VKAPI_ATTR VkResult VKAPI_CALL -GetPhysicalDeviceExternalImageFormatPropertiesNV( - VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, - VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, - VkExternalMemoryHandleTypeFlagsNV externalHandleType, - VkExternalImageFormatPropertiesNV *pExternalImageFormatProperties); - -VKAPI_ATTR VkResult VKAPI_CALL -terminator_GetPhysicalDeviceExternalImageFormatPropertiesNV( - VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, - VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, - VkExternalMemoryHandleTypeFlagsNV externalHandleType, - VkExternalImageFormatPropertiesNV *pExternalImageFormatProperties); - -VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceFeatures2KHR(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures2KHR* pFeatures); - -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceFeatures2KHR(VkPhysicalDevice physicalDevice, - VkPhysicalDeviceFeatures2KHR* pFeatures); - -VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceProperties2KHR(VkPhysicalDevice physicalDevice, - VkPhysicalDeviceProperties2KHR* pProperties); - -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceProperties2KHR(VkPhysicalDevice physicalDevice, - VkPhysicalDeviceProperties2KHR* pProperties); - -VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceFormatProperties2KHR(VkPhysicalDevice physicalDevice, VkFormat format, - VkFormatProperties2KHR* pFormatProperties); - -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceFormatProperties2KHR(VkPhysicalDevice physicalDevice, VkFormat format, - VkFormatProperties2KHR* pFormatProperties); - -VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceImageFormatProperties2KHR( - VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2KHR* pImageFormatInfo, - VkImageFormatProperties2KHR* pImageFormatProperties); - -VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceImageFormatProperties2KHR( - VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2KHR* pImageFormatInfo, - VkImageFormatProperties2KHR* pImageFormatProperties); - -VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceQueueFamilyProperties2KHR(VkPhysicalDevice physicalDevice, - uint32_t* pQueueFamilyPropertyCount, - VkQueueFamilyProperties2KHR* pQueueFamilyProperties); - -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceQueueFamilyProperties2KHR( - VkPhysicalDevice physicalDevice, uint32_t* pQueueFamilyPropertyCount, VkQueueFamilyProperties2KHR* pQueueFamilyProperties); - -VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceMemoryProperties2KHR(VkPhysicalDevice physicalDevice, - VkPhysicalDeviceMemoryProperties2KHR* pMemoryProperties); - -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceMemoryProperties2KHR( - VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties2KHR* pMemoryProperties); - -VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceSparseImageFormatProperties2KHR( - VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSparseImageFormatInfo2KHR* pFormatInfo, uint32_t* pPropertyCount, - VkSparseImageFormatProperties2KHR* pProperties); - -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceSparseImageFormatProperties2KHR( - VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSparseImageFormatInfo2KHR* pFormatInfo, uint32_t* pPropertyCount, - VkSparseImageFormatProperties2KHR* pProperties); - -VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceSurfaceCapabilities2KHR(VkPhysicalDevice physicalDevice, - const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo, - VkSurfaceCapabilities2KHR* pSurfaceCapabilities); - -VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceCapabilities2KHR( - VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo, - VkSurfaceCapabilities2KHR* pSurfaceCapabilities); - -VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceSurfaceFormats2KHR(VkPhysicalDevice physicalDevice, - const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo, - uint32_t* pSurfaceFormatCount, - VkSurfaceFormat2KHR* pSurfaceFormats); - -VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceFormats2KHR(VkPhysicalDevice physicalDevice, - const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo, - uint32_t* pSurfaceFormatCount, - VkSurfaceFormat2KHR* pSurfaceFormats); - -VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceSurfaceCapabilities2EXT(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, - VkSurfaceCapabilities2EXT* pSurfaceCapabilities); - -VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceCapabilities2EXT(VkPhysicalDevice physicalDevice, - VkSurfaceKHR surface, - VkSurfaceCapabilities2EXT* pSurfaceCapabilities); - -VKAPI_ATTR VkResult VKAPI_CALL ReleaseDisplayEXT(VkPhysicalDevice physicalDevice, VkDisplayKHR display); - -VKAPI_ATTR VkResult VKAPI_CALL terminator_ReleaseDisplayEXT(VkPhysicalDevice physicalDevice, VkDisplayKHR display); - -#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT -VKAPI_ATTR VkResult VKAPI_CALL AcquireXlibDisplayEXT(VkPhysicalDevice physicalDevice, Display* dpy, VkDisplayKHR display); - -VKAPI_ATTR VkResult VKAPI_CALL terminator_AcquireXlibDisplayEXT(VkPhysicalDevice physicalDevice, Display* dpy, - VkDisplayKHR display); - -VKAPI_ATTR VkResult VKAPI_CALL GetRandROutputDisplayEXT(VkPhysicalDevice physicalDevice, Display* dpy, RROutput rrOutput, - VkDisplayKHR* pDisplay); - -VKAPI_ATTR VkResult VKAPI_CALL terminator_GetRandROutputDisplayEXT(VkPhysicalDevice physicalDevice, Display* dpy, RROutput rrOutput, - VkDisplayKHR* pDisplay); -#endif // VK_USE_PLATFORM_XLIB_XRANDR_EXT - -VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceExternalBufferPropertiesKHR( - VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalBufferInfoKHR* pExternalBufferInfo, - VkExternalBufferPropertiesKHR* pExternalBufferProperties); - -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceExternalBufferPropertiesKHR( - VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalBufferInfoKHR* pExternalBufferInfo, - VkExternalBufferPropertiesKHR* pExternalBufferProperties); - -VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceExternalSemaphorePropertiesKHR( - VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalSemaphoreInfoKHR* pExternalSemaphoreInfo, - VkExternalSemaphorePropertiesKHR* pExternalSemaphoreProperties); - -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceExternalSemaphorePropertiesKHR( - VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalSemaphoreInfoKHR* pExternalSemaphoreInfo, - VkExternalSemaphorePropertiesKHR* pExternalSemaphoreProperties); - -VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceExternalFencePropertiesKHR( - VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalFenceInfoKHR* pExternalFenceInfo, - VkExternalFencePropertiesKHR* pExternalFenceProperties); - -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceExternalFencePropertiesKHR( - VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalFenceInfoKHR* pExternalFenceInfo, - VkExternalFencePropertiesKHR* pExternalFenceProperties); diff --git a/third_party/vulkan/loader/gpa_helper.h b/third_party/vulkan/loader/gpa_helper.h deleted file mode 100644 index 0763938bb..000000000 --- a/third_party/vulkan/loader/gpa_helper.h +++ /dev/null @@ -1,204 +0,0 @@ -/* - * - * Copyright (c) 2015 The Khronos Group Inc. - * Copyright (c) 2015 Valve Corporation - * Copyright (c) 2015 LunarG, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Author: Jon Ashburn - */ - -#include -#include "debug_report.h" -#include "wsi.h" - -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, "vkGetPhysicalDeviceImageFormatProperties")) - return (PFN_vkVoidFunction)vkGetPhysicalDeviceImageFormatProperties; - if (!strcmp(funcName, "vkGetPhysicalDeviceSparseImageFormatProperties")) - return (PFN_vkVoidFunction)vkGetPhysicalDeviceSparseImageFormatProperties; - 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; - - // Instance extensions - void *addr; - if (debug_report_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; - - // Unknown physical device extensions - if (loader_phys_dev_ext_gpa(inst, funcName, true, &addr, NULL)) return addr; - - // Unknown device extensions - addr = loader_dev_ext_gpa(inst, funcName); - return addr; -} - -static inline void *globalGetProcAddr(const char *name) { - 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; - - return NULL; -} - -static inline void *loader_non_passthrough_gdpa(const char *name) { - 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; - - return NULL; -} diff --git a/third_party/vulkan/loader/loader.c b/third_party/vulkan/loader/loader.c deleted file mode 100644 index f1bc58976..000000000 --- a/third_party/vulkan/loader/loader.c +++ /dev/null @@ -1,6065 +0,0 @@ -/* - * - * Copyright (c) 2014-2018 The Khronos Group Inc. - * Copyright (c) 2014-2018 Valve Corporation - * Copyright (c) 2014-2018 LunarG, Inc. - * Copyright (C) 2015 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - - * - * Author: Jon Ashburn - * Author: Courtney Goeltzenleuchter - * Author: Mark Young - * Author: Lenny Komow - * - */ - -#define _GNU_SOURCE -#include -#include -#include -#include -#include -#include - -#include -#if defined(_WIN32) -#include "dirent_on_windows.h" -#else // _WIN32 -#include -#endif // _WIN32 -#include "vk_loader_platform.h" -#include "loader.h" -#include "gpa_helper.h" -#include "debug_report.h" -#include "wsi.h" -#include "vulkan/vk_icd.h" -#include "cJSON.h" -#include "murmurhash.h" - -#if defined(_WIN32) -#include -#include -#include -#endif - -// This is a CMake generated file with #defines for any functions/includes -// that it found present. This is currently necessary to properly determine -// if secure_getenv or __secure_getenv are present -#if !defined(VULKAN_NON_CMAKE_BUILD) -#include "loader_cmake_config.h" -#endif // !defined(VULKAN_NON_CMAKE_BUILD) - -// Generated file containing all the extension data -#include "vk_loader_extensions.c" - -struct loader_struct loader = {0}; -// TLS for instance for alloc/free callbacks -THREAD_LOCAL_DECL struct loader_instance *tls_instance; - -static size_t loader_platform_combine_path(char *dest, size_t len, ...); - -struct loader_phys_dev_per_icd { - uint32_t count; - VkPhysicalDevice *phys_devs; - struct loader_icd_term *this_icd_term; -}; - -enum loader_debug { - LOADER_INFO_BIT = 0x01, - LOADER_WARN_BIT = 0x02, - LOADER_PERF_BIT = 0x04, - LOADER_ERROR_BIT = 0x08, - LOADER_DEBUG_BIT = 0x10, -}; - -uint32_t g_loader_debug = 0; -uint32_t g_loader_log_msgs = 0; - -// thread safety lock for accessing global data structures such as "loader" -// all entrypoints on the instance chain need to be locked except GPA -// additionally CreateDevice and DestroyDevice needs to be locked -loader_platform_thread_mutex loader_lock; -loader_platform_thread_mutex loader_json_lock; - -LOADER_PLATFORM_THREAD_ONCE_DECLARATION(once_init); - -void *loader_instance_heap_alloc(const struct loader_instance *instance, size_t size, VkSystemAllocationScope alloc_scope) { - void *pMemory = NULL; -#if (DEBUG_DISABLE_APP_ALLOCATORS == 1) - { -#else - if (instance && instance->alloc_callbacks.pfnAllocation) { - // These are internal structures, so it's best to align everything to - // the largest unit size which is the size of a uint64_t. - pMemory = instance->alloc_callbacks.pfnAllocation(instance->alloc_callbacks.pUserData, size, sizeof(uint64_t), alloc_scope); - } else { -#endif - pMemory = malloc(size); - } - - return pMemory; -} - -void loader_instance_heap_free(const struct loader_instance *instance, void *pMemory) { - if (pMemory != NULL) { -#if (DEBUG_DISABLE_APP_ALLOCATORS == 1) - { -#else - if (instance && instance->alloc_callbacks.pfnFree) { - instance->alloc_callbacks.pfnFree(instance->alloc_callbacks.pUserData, pMemory); - } else { -#endif - free(pMemory); - } - } -} - -void *loader_instance_heap_realloc(const struct loader_instance *instance, void *pMemory, size_t orig_size, size_t size, - VkSystemAllocationScope alloc_scope) { - void *pNewMem = NULL; - if (pMemory == NULL || orig_size == 0) { - pNewMem = loader_instance_heap_alloc(instance, size, alloc_scope); - } else if (size == 0) { - loader_instance_heap_free(instance, pMemory); -#if (DEBUG_DISABLE_APP_ALLOCATORS == 1) -#else - } else if (instance && instance->alloc_callbacks.pfnReallocation) { - // These are internal structures, so it's best to align everything to - // the largest unit size which is the size of a uint64_t. - pNewMem = instance->alloc_callbacks.pfnReallocation(instance->alloc_callbacks.pUserData, pMemory, size, sizeof(uint64_t), - alloc_scope); -#endif - } else { - pNewMem = realloc(pMemory, size); - } - return pNewMem; -} - -void *loader_instance_tls_heap_alloc(size_t size) { - return loader_instance_heap_alloc(tls_instance, size, VK_SYSTEM_ALLOCATION_SCOPE_COMMAND); -} - -void loader_instance_tls_heap_free(void *pMemory) { loader_instance_heap_free(tls_instance, pMemory); } - -void *loader_device_heap_alloc(const struct loader_device *device, size_t size, VkSystemAllocationScope alloc_scope) { - void *pMemory = NULL; -#if (DEBUG_DISABLE_APP_ALLOCATORS == 1) - { -#else - if (device && device->alloc_callbacks.pfnAllocation) { - // These are internal structures, so it's best to align everything to - // the largest unit size which is the size of a uint64_t. - pMemory = device->alloc_callbacks.pfnAllocation(device->alloc_callbacks.pUserData, size, sizeof(uint64_t), alloc_scope); - } else { -#endif - pMemory = malloc(size); - } - return pMemory; -} - -void loader_device_heap_free(const struct loader_device *device, void *pMemory) { - if (pMemory != NULL) { -#if (DEBUG_DISABLE_APP_ALLOCATORS == 1) - { -#else - if (device && device->alloc_callbacks.pfnFree) { - device->alloc_callbacks.pfnFree(device->alloc_callbacks.pUserData, pMemory); - } else { -#endif - free(pMemory); - } - } -} - -void *loader_device_heap_realloc(const struct loader_device *device, void *pMemory, size_t orig_size, size_t size, - VkSystemAllocationScope alloc_scope) { - void *pNewMem = NULL; - if (pMemory == NULL || orig_size == 0) { - pNewMem = loader_device_heap_alloc(device, size, alloc_scope); - } else if (size == 0) { - loader_device_heap_free(device, pMemory); -#if (DEBUG_DISABLE_APP_ALLOCATORS == 1) -#else - } else if (device && device->alloc_callbacks.pfnReallocation) { - // These are internal structures, so it's best to align everything to - // the largest unit size which is the size of a uint64_t. - pNewMem = device->alloc_callbacks.pfnReallocation(device->alloc_callbacks.pUserData, pMemory, size, sizeof(uint64_t), - alloc_scope); -#endif - } else { - pNewMem = realloc(pMemory, size); - } - return pNewMem; -} - -// Environment variables -#if defined(__linux__) - -static inline char *loader_getenv(const char *name, const struct loader_instance *inst) { - // No allocation of memory necessary for Linux, but we should at least touch - // the inst pointer to get rid of compiler warnings. - (void)inst; - return getenv(name); -} - -static inline char *loader_secure_getenv(const char *name, const struct loader_instance *inst) { - // No allocation of memory necessary for Linux, but we should at least touch - // the inst pointer to get rid of compiler warnings. - (void)inst; - -#ifdef HAVE_SECURE_GETENV - return secure_getenv(name); -#elif defined(HAVE___SECURE_GETENV) - return __secure_getenv(name); -#else -#pragma message( \ - "Warning: Falling back to non-secure getenv for environmental lookups! Consider" \ - " updating to a different libc.") - return loader_getenv(name, inst); -#endif -} - -static inline void loader_free_getenv(char *val, const struct loader_instance *inst) { - // No freeing of memory necessary for Linux, but we should at least touch - // the val and inst pointers to get rid of compiler warnings. - (void)val; - (void)inst; -} - -#elif defined(WIN32) - -static inline char *loader_getenv(const char *name, const struct loader_instance *inst) { - char *retVal; - DWORD valSize; - - valSize = GetEnvironmentVariableA(name, NULL, 0); - - // 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; - - // Allocate the space necessary for the registry entry - if (NULL != inst && NULL != inst->alloc_callbacks.pfnAllocation) { - retVal = (char *)inst->alloc_callbacks.pfnAllocation(inst->alloc_callbacks.pUserData, valSize, sizeof(char *), - VK_SYSTEM_ALLOCATION_SCOPE_COMMAND); - } else { - retVal = (char *)malloc(valSize); - } - - if (NULL != retVal) { - GetEnvironmentVariableA(name, retVal, valSize); - } - - return retVal; -} - -static inline char *loader_secure_getenv(const char *name, const struct loader_instance *inst) { - // No secure version for Windows as far as I know - return loader_getenv(name, inst); -} - -static inline void loader_free_getenv(char *val, const struct loader_instance *inst) { - if (NULL != inst && NULL != inst->alloc_callbacks.pfnFree) { - inst->alloc_callbacks.pfnFree(inst->alloc_callbacks.pUserData, val); - } else { - free((void *)val); - } -} - -#else - -static inline char *loader_getenv(const char *name, const struct loader_instance *inst) { - // stub func - (void)inst; - (void)name; - return NULL; -} -static inline void loader_free_getenv(char *val, const struct loader_instance *inst) { - // stub func - (void)val; - (void)inst; -} - -#endif - -void loader_log(const struct loader_instance *inst, VkFlags msg_type, int32_t msg_code, const char *format, ...) { - char msg[512]; - char cmd_line_msg[512]; - size_t cmd_line_size = sizeof(cmd_line_msg); - va_list ap; - int ret; - - va_start(ap, format); - ret = vsnprintf(msg, sizeof(msg), format, ap); - if ((ret >= (int)sizeof(msg)) || ret < 0) { - msg[sizeof(msg) - 1] = '\0'; - } - va_end(ap); - - if (inst) { - util_DebugReportMessage(inst, msg_type, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, (uint64_t)(uintptr_t)inst, 0, msg_code, - "loader", msg); - } - - if (!(msg_type & g_loader_log_msgs)) { - return; - } - - cmd_line_msg[0] = '\0'; - cmd_line_size -= 1; - size_t original_size = cmd_line_size; - - va_start(ap, format); - if ((msg_type & LOADER_INFO_BIT) != 0) { - strncat(cmd_line_msg, "INFO", cmd_line_size); - cmd_line_size -= 4; - } - if ((msg_type & LOADER_WARN_BIT) != 0) { - if (cmd_line_size != original_size) { - strncat(cmd_line_msg, " | ", cmd_line_size); - cmd_line_size -= 3; - } - strncat(cmd_line_msg, "WARNING", cmd_line_size); - cmd_line_size -= 7; - } - if ((msg_type & LOADER_PERF_BIT) != 0) { - if (cmd_line_size != original_size) { - strncat(cmd_line_msg, " | ", cmd_line_size); - cmd_line_size -= 3; - } - strncat(cmd_line_msg, "PERF", cmd_line_size); - cmd_line_size -= 4; - } - if ((msg_type & LOADER_ERROR_BIT) != 0) { - if (cmd_line_size != original_size) { - strncat(cmd_line_msg, " | ", cmd_line_size); - cmd_line_size -= 3; - } - strncat(cmd_line_msg, "ERROR", cmd_line_size); - cmd_line_size -= 5; - } - if ((msg_type & LOADER_DEBUG_BIT) != 0) { - if (cmd_line_size != original_size) { - strncat(cmd_line_msg, " | ", cmd_line_size); - cmd_line_size -= 3; - } - strncat(cmd_line_msg, "DEBUG", cmd_line_size); - cmd_line_size -= 5; - } - if (cmd_line_size != original_size) { - strncat(cmd_line_msg, ": ", cmd_line_size); - cmd_line_size -= 2; - } - - if (0 < cmd_line_size) { - // If the message is too long, trim it down - if (strlen(msg) > cmd_line_size) { - msg[cmd_line_size - 1] = '\0'; - } - strncat(cmd_line_msg, msg, cmd_line_size); - } else { - // Shouldn't get here, but check to make sure if we've already overrun - // the string boundary - assert(false); - } - -#if defined(WIN32) - OutputDebugString(cmd_line_msg); - OutputDebugString("\n"); -#endif - - fputs(cmd_line_msg, stderr); - fputc('\n', stderr); -} - -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."); - return VK_ERROR_INITIALIZATION_FAILED; - } - loader_set_dispatch(object, inst->disp); - return VK_SUCCESS; -} - -VKAPI_ATTR VkResult VKAPI_CALL vkSetDeviceDispatch(VkDevice device, void *object) { - struct loader_device *dev; - struct loader_icd_term *icd_term = loader_get_icd_and_device(device, &dev, NULL); - - if (NULL == icd_term) { - return VK_ERROR_INITIALIZATION_FAILED; - } - loader_set_dispatch(object, &dev->loader_dispatch); - return VK_SUCCESS; -} - -#if defined(_WIN32) -// Find the list of registry files (names VulkanDriverName/VulkanDriverNameWow) in hkr. -// -// This function looks for filename in given device handle, filename is then added to return list -// function return true if filename was appended to reg_data list -// If error occures result is updated with failure reason -bool loaderGetDeviceRegistryEntry(const struct loader_instance *inst, char **reg_data, PDWORD total_size, DEVINST dev_id, LPCTSTR value_name, VkResult *result) -{ - HKEY hkrKey = INVALID_HANDLE_VALUE; - DWORD requiredSize, data_type; - char *manifest_path = NULL; - bool found = false; - - if (NULL == total_size || NULL == reg_data) { - *result = VK_ERROR_INITIALIZATION_FAILED; - return false; - } - - CONFIGRET status = CM_Open_DevNode_Key(dev_id, KEY_QUERY_VALUE, 0, RegDisposition_OpenExisting, &hkrKey, CM_REGISTRY_SOFTWARE); - if (status != CR_SUCCESS) { - loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, - "loaderGetDeviceRegistryEntry: Failed to open registry key for DeviceID(%d)", dev_id); - *result = VK_ERROR_INITIALIZATION_FAILED; - return false; - } - - // query value - LSTATUS ret = RegQueryValueEx( - hkrKey, - value_name, - NULL, - NULL, - NULL, - &requiredSize); - - if (ret != ERROR_SUCCESS) { - if (ret == ERROR_FILE_NOT_FOUND) { - loader_log(inst, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, - "loaderGetDeviceRegistryEntry: Device ID(%d) Does not contain a value for \"%s\"", dev_id, value_name); - } else { - loader_log(inst, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, - "loaderGetDeviceRegistryEntry: DeviceID(%d) Failed to obtain %s size", dev_id, value_name); - } - goto out; - } - - manifest_path = loader_instance_heap_alloc(inst, requiredSize, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); - if (manifest_path == NULL) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "loaderGetDeviceRegistryEntry: Failed to allocate space for DriverName."); - *result = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - - ret = RegQueryValueEx( - hkrKey, - value_name, - NULL, - &data_type, - (BYTE *)manifest_path, - &requiredSize - ); - - if (ret != ERROR_SUCCESS) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "loaderGetDeviceRegistryEntry: DeviceID(%d) Failed to obtain %s", value_name); - - *result = VK_ERROR_INITIALIZATION_FAILED; - goto out; - } - - if (data_type != REG_SZ && data_type != REG_MULTI_SZ) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "loaderGetDeviceRegistryEntry: Invalid %s data type. Expected REG_SZ or REG_MULTI_SZ.", value_name); - *result = VK_ERROR_INITIALIZATION_FAILED; - goto out; - } - - 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, - "loaderGetDeviceRegistryEntry: Failed to allocate space for registry data for key %s", manifest_path); - *result = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - *reg_data[0] = '\0'; - } else if (strlen(*reg_data) + requiredSize + 1 > *total_size) { - void *new_ptr = loader_instance_heap_realloc(inst, *reg_data, *total_size, *total_size * 2, - VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); - if (NULL == new_ptr) { - loader_log( - inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "loaderGetDeviceRegistryEntry: Failed to reallocate space for registry value of size %d for key %s", - *total_size * 2, manifest_path); - *result = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - *reg_data = new_ptr; - *total_size *= 2; - } - - for (char *curr_filename = manifest_path; curr_filename[0] != '\0'; curr_filename += strlen(curr_filename) + 1) { - if (strlen(*reg_data) == 0) { - (void)snprintf(*reg_data, requiredSize + 1, "%s", curr_filename); - } else { - (void)snprintf(*reg_data + strlen(*reg_data), requiredSize + 2, "%c%s", PATH_SEPARATOR, curr_filename); - } - loader_log(inst, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, "%s: Located json file \"%s\" from PnP registry: %s", __FUNCTION__, curr_filename, value_name); - - if (data_type == REG_SZ) { - break; - } - } - found = true; - -out: - if (manifest_path != NULL) { - loader_instance_heap_free(inst, manifest_path); - } - RegCloseKey(hkrKey); - return found; -} - -// Find the list of registry files (names VulkanDriverName/VulkanDriverNameWow) in hkr . -// -// This function looks for display devices and childish software components -// for a list of files which are added to a returned list (function return -// value). -// Function return is a string with a ';' separated list of filenames. -// Function return is NULL if no valid name/value pairs are found in the key, -// or the key is not found. -// -// *reg_data contains a string list of filenames as pointer. -// When done using the returned string list, the caller should free the pointer. -VkResult loaderGetDeviceRegistryFiles(const struct loader_instance *inst, char **reg_data, PDWORD reg_data_size, LPCTSTR value_name) { - static const char* softwareComponentGUID = "{5c4c3332-344d-483c-8739-259e934c9cc8}"; - static const char* displayGUID = "{4d36e968-e325-11ce-bfc1-08002be10318}"; - const ULONG flags = CM_GETIDLIST_FILTER_CLASS | CM_GETIDLIST_FILTER_PRESENT; - - char childGuid[MAX_GUID_STRING_LEN + 2]; // +2 for brackets {} - ULONG childGuidSize = sizeof(childGuid); - - DEVINST devID = 0, childID = 0; - char *pDeviceNames = NULL; - ULONG deviceNamesSize = 0; - VkResult result = VK_SUCCESS; - bool found = false; - - if (NULL == reg_data) { - result = VK_ERROR_INITIALIZATION_FAILED; - return result; - } - - // if after obtaining the DeviceNameSize, new device is added start over - do { - CM_Get_Device_ID_List_Size(&deviceNamesSize, displayGUID, flags); - - if (pDeviceNames != NULL) { - loader_instance_heap_free(inst, pDeviceNames); - } - - pDeviceNames = loader_instance_heap_alloc(inst, deviceNamesSize, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); - if (pDeviceNames == NULL) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "loaderGetDeviceRegistryFiles: Failed to allocate space for display device names."); - result = VK_ERROR_OUT_OF_HOST_MEMORY; - return result; - } - } while (CM_Get_Device_ID_List(displayGUID, pDeviceNames, deviceNamesSize, flags) == CR_BUFFER_SMALL); - - if (pDeviceNames) { - - for (char *deviceName = pDeviceNames; *deviceName; deviceName += strlen(deviceName) + 1) { - CONFIGRET status = CM_Locate_DevNode(&devID, deviceName, CM_LOCATE_DEVNODE_NORMAL); - if (CR_SUCCESS != status) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "loaderGetRegistryFiles: failed to open DevNode %s", deviceName); - continue; - } - ULONG ulStatus, ulProblem; - status = CM_Get_DevNode_Status(&ulStatus, &ulProblem, devID, 0); - - if (CR_SUCCESS != status) - { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "loaderGetRegistryFiles: failed to probe device status %s", deviceName); - continue; - } - if ((ulStatus & DN_HAS_PROBLEM) && (ulProblem == CM_PROB_NEED_RESTART || ulProblem == DN_NEED_RESTART)) - { - loader_log(inst, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, - "loaderGetRegistryFiles: device %s is pending reboot, skipping ...", deviceName); - continue; - } - - loader_log(inst, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, - "loaderGetRegistryFiles: opening device %s", deviceName); - - if (loaderGetDeviceRegistryEntry(inst, reg_data, reg_data_size, devID, value_name, &result)) { - found = true; - continue; - } - else if (result == VK_ERROR_OUT_OF_HOST_MEMORY) { - break; - } - - status = CM_Get_Child(&childID, devID, 0); - if (status != CR_SUCCESS) { - loader_log(inst, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, - "loaderGetRegistryFiles: unable to open child-device error:%d", status); - continue; - } - - do { - char buffer[MAX_DEVICE_ID_LEN]; - CM_Get_Device_ID(childID, buffer, MAX_DEVICE_ID_LEN, 0); - - loader_log(inst, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, - "loaderGetRegistryFiles: Opening child device %d - %s", childID, buffer); - - status = CM_Get_DevNode_Registry_Property(childID, CM_DRP_CLASSGUID, NULL, &childGuid, &childGuidSize, 0); - if (status != CR_SUCCESS) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "loaderGetRegistryFiles: unable to obtain GUID for:%d error:%d", childID, status); - - result = VK_ERROR_INITIALIZATION_FAILED; - continue; - } - - if (strcmp(childGuid, softwareComponentGUID) != 0) { - loader_log(inst, VK_DEBUG_REPORT_DEBUG_BIT_EXT, 0, - "loaderGetRegistryFiles: GUID for %d is not SoftwareComponent skipping", childID); - continue; - } - - if (loaderGetDeviceRegistryEntry(inst, reg_data, reg_data_size, childID, value_name, &result)) { - found = true; - break; // check next-display-device - } - - } while (CM_Get_Sibling(&childID, childID, 0) == CR_SUCCESS); - } - - loader_instance_heap_free(inst, pDeviceNames); - } - - if (!found && result != VK_ERROR_OUT_OF_HOST_MEMORY) { - result = VK_ERROR_INITIALIZATION_FAILED; - } - - return result; -} - -static char *loader_get_next_path(char *path); - -// Find the list of registry files (names within a key) in key "location". -// -// This function looks in the registry (hive = DEFAULT_VK_REGISTRY_HIVE) key as -// given in "location" -// for a list or name/values which are added to a returned list (function return -// value). -// The DWORD values within the key must be 0 or they are skipped. -// Function return is a string with a ';' separated list of filenames. -// Function return is NULL if no valid name/value pairs are found in the key, -// or the key is not found. -// -// *reg_data contains a string list of filenames as pointer. -// When done using the returned string list, the caller should free the pointer. -VkResult loaderGetRegistryFiles(const struct loader_instance *inst, char *location, bool use_secondary_hive, char **reg_data, PDWORD reg_data_size) { - LONG rtn_value; - HKEY hive = DEFAULT_VK_REGISTRY_HIVE, key; - DWORD access_flags; - char name[2048]; - char *loc = location; - char *next; - DWORD idx; - DWORD name_size = sizeof(name); - DWORD value; - DWORD value_size = sizeof(value); - VkResult result = VK_SUCCESS; - bool found = false; - - if (NULL == reg_data) { - result = VK_ERROR_INITIALIZATION_FAILED; - goto out; - } - - while (*loc) { - next = loader_get_next_path(loc); - access_flags = KEY_QUERY_VALUE; - rtn_value = RegOpenKeyEx(hive, loc, 0, access_flags, &key); - if (ERROR_SUCCESS == rtn_value) { - idx = 0; - while ((rtn_value = RegEnumValue(key, idx++, name, &name_size, NULL, NULL, (LPBYTE)&value, &value_size)) == - ERROR_SUCCESS) { - if (value_size == sizeof(value) && value == 0) { - if (NULL == *reg_data) { - *reg_data = loader_instance_heap_alloc(inst, *reg_data_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", name); - RegCloseKey(key); - result = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - *reg_data[0] = '\0'; - } else if (strlen(*reg_data) + name_size + 1 > *reg_data_size) { - void *new_ptr = loader_instance_heap_realloc(inst, *reg_data, *reg_data_size, *reg_data_size * 2, - VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); - if (NULL == new_ptr) { - loader_log( - inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "loaderGetRegistryFiles: Failed to reallocate space for registry value of size %d for key %s", - *reg_data_size * 2, name); - RegCloseKey(key); - result = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - *reg_data = new_ptr; - *reg_data_size *= 2; - } - loader_log( - inst, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, "Located json file \"%s\" from registry \"%s\\%s\"", name, - hive == DEFAULT_VK_REGISTRY_HIVE ? DEFAULT_VK_REGISTRY_HIVE_STR : SECONDARY_VK_REGISTRY_HIVE_STR, location); - if (strlen(*reg_data) == 0) { - (void)snprintf(*reg_data, name_size + 1, "%s", name); - } else { - (void)snprintf(*reg_data + strlen(*reg_data), name_size + 2, "%c%s", PATH_SEPARATOR, name); - } - found = true; - } - name_size = 2048; - } - RegCloseKey(key); - } - - // Advance the location - if the next location is in the secondary hive, then reset the locations and advance the hive - if (use_secondary_hive && (hive == DEFAULT_VK_REGISTRY_HIVE) && (*next == '\0')) { - loc = location; - hive = SECONDARY_VK_REGISTRY_HIVE; - } else { - loc = next; - } - } - - if (!found && result != VK_ERROR_OUT_OF_HOST_MEMORY) { - result = VK_ERROR_INITIALIZATION_FAILED; - } - -out: - - return result; -} - -#endif // WIN32 - -// Combine path elements, separating each element with the platform-specific -// directory separator, and save the combined string to a destination buffer, -// not exceeding the given length. Path elements are given as variable args, -// with a NULL element terminating the list. -// -// \returns the total length of the combined string, not including an ASCII -// NUL termination character. This length may exceed the available storage: -// in this case, the written string will be truncated to avoid a buffer -// overrun, and the return value will greater than or equal to the storage -// size. A NULL argument may be provided as the destination buffer in order -// to determine the required string length without actually writing a string. -static size_t loader_platform_combine_path(char *dest, size_t len, ...) { - size_t required_len = 0; - va_list ap; - const char *component; - - va_start(ap, len); - - while ((component = va_arg(ap, const char *))) { - if (required_len > 0) { - // This path element is not the first non-empty element; prepend - // a directory separator if space allows - if (dest && required_len + 1 < len) { - (void)snprintf(dest + required_len, len - required_len, "%c", DIRECTORY_SYMBOL); - } - required_len++; - } - - if (dest && required_len < len) { - strncpy(dest + required_len, component, len - required_len); - } - required_len += strlen(component); - } - - va_end(ap); - - // strncpy(3) won't add a NUL terminating byte in the event of truncation. - if (dest && required_len >= len) { - dest[len - 1] = '\0'; - } - - return required_len; -} - -// Given string of three part form "maj.min.pat" convert to a vulkan version number. -static uint32_t loader_make_version(char *vers_str) { - uint32_t vers = 0, major = 0, minor = 0, patch = 0; - char *vers_tok; - - if (!vers_str) { - return vers; - } - - vers_tok = strtok(vers_str, ".\"\n\r"); - if (NULL != vers_tok) { - major = (uint16_t)atoi(vers_tok); - vers_tok = strtok(NULL, ".\"\n\r"); - if (NULL != vers_tok) { - minor = (uint16_t)atoi(vers_tok); - vers_tok = strtok(NULL, ".\"\n\r"); - if (NULL != vers_tok) { - patch = (uint16_t)atoi(vers_tok); - } - } - } - - return VK_MAKE_VERSION(major, minor, patch); -} - -bool compare_vk_extension_properties(const VkExtensionProperties *op1, const VkExtensionProperties *op2) { - return strcmp(op1->extensionName, op2->extensionName) == 0 ? true : false; -} - -// Search the given ext_array for an extension matching the given vk_ext_prop -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; - } - return false; -} - -// Search the given ext_list for an extension matching the given vk_ext_prop -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; - } - return false; -} - -// Search the given ext_list for a device extension matching the given ext_prop -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; - } - return false; -} - -// Search the given layer list for a layer matching the given layer name -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]; - } - return NULL; -} - -// Get the next unused layer property in the list. Init the property to zero. -static struct loader_layer_properties *loader_get_next_layer_property(const struct loader_instance *inst, - struct loader_layer_list *layer_list) { - if (layer_list->capacity == 0) { - 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"); - return NULL; - } - memset(layer_list->list, 0, sizeof(struct loader_layer_properties) * 64); - layer_list->capacity = sizeof(struct loader_layer_properties) * 64; - } - - // Ensure enough room to add an entry - if ((layer_list->count + 1) * sizeof(struct loader_layer_properties) > layer_list->capacity) { - void *new_ptr = loader_instance_heap_realloc(inst, layer_list->list, layer_list->capacity, layer_list->capacity * 2, - VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); - if (NULL == new_ptr) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_get_next_layer_property: realloc failed for layer list"); - return NULL; - } - layer_list->list = new_ptr; - layer_list->capacity *= 2; - } - - layer_list->count++; - return &(layer_list->list[layer_list->count - 1]); -} - -// Remove all layer properties entries from the list -void loader_delete_layer_properties(const struct loader_instance *inst, struct loader_layer_list *layer_list) { - uint32_t i, j, k; - struct loader_device_extension_list *dev_ext_list; - struct loader_dev_ext_props *ext_props; - if (!layer_list) return; - - for (i = 0; i < layer_list->count; i++) { - if (NULL != layer_list->list[i].component_layer_names) { - loader_instance_heap_free(inst, layer_list->list[i].component_layer_names); - layer_list->list[i].component_layer_names = NULL; - } - loader_destroy_generic_list(inst, (struct loader_generic_list *)&layer_list->list[i].instance_extension_list); - dev_ext_list = &layer_list->list[i].device_extension_list; - if (dev_ext_list->capacity > 0 && NULL != dev_ext_list->list) { - for (j = 0; j < dev_ext_list->count; j++) { - ext_props = &dev_ext_list->list[j]; - if (ext_props->entrypoint_count > 0) { - for (k = 0; k < ext_props->entrypoint_count; k++) { - loader_instance_heap_free(inst, ext_props->entrypoints[k]); - } - loader_instance_heap_free(inst, ext_props->entrypoints); - } - } - } - loader_destroy_generic_list(inst, (struct loader_generic_list *)dev_ext_list); - } - layer_list->count = 0; - - if (layer_list->capacity > 0) { - layer_list->capacity = 0; - loader_instance_heap_free(inst, layer_list->list); - } -} - -static VkResult loader_add_instance_extensions(const struct loader_instance *inst, - const PFN_vkEnumerateInstanceExtensionProperties fp_get_props, const char *lib_name, - struct loader_extension_list *ext_list) { - uint32_t i, count = 0; - VkExtensionProperties *ext_props; - VkResult res = VK_SUCCESS; - - if (!fp_get_props) { - // No EnumerateInstanceExtensionProperties defined - goto out; - } - - 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", - lib_name); - goto out; - } - - if (count == 0) { - // No ExtensionProperties to report - goto out; - } - - ext_props = loader_stack_alloc(count * sizeof(VkExtensionProperties)); - if (NULL == ext_props) { - res = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - - 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", - lib_name); - goto out; - } - - for (i = 0; i < count; i++) { - char spec_version[64]; - - bool ext_unsupported = wsi_unsupported_instance_extension(&ext_props[i]); - if (!ext_unsupported) { - (void)snprintf(spec_version, sizeof(spec_version), "%d.%d.%d", VK_VERSION_MAJOR(ext_props[i].specVersion), - VK_VERSION_MINOR(ext_props[i].specVersion), VK_VERSION_PATCH(ext_props[i].specVersion)); - loader_log(inst, VK_DEBUG_REPORT_DEBUG_BIT_EXT, 0, "Instance Extension: %s (%s) version %s", ext_props[i].extensionName, - lib_name, spec_version); - - 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", - lib_name); - goto out; - } - } - } - -out: - return res; -} - -// Initialize ext_list with the physical device extensions. -// The extension properties are passed as inputs in count and ext_props. -static VkResult loader_init_device_extensions(const struct loader_instance *inst, struct loader_physical_device_term *phys_dev_term, - uint32_t count, VkExtensionProperties *ext_props, - struct loader_extension_list *ext_list) { - VkResult res; - uint32_t i; - - res = loader_init_generic_list(inst, (struct loader_generic_list *)ext_list, sizeof(VkExtensionProperties)); - if (VK_SUCCESS != res) { - return res; - } - - for (i = 0; i < count; i++) { - char spec_version[64]; - (void)snprintf(spec_version, sizeof(spec_version), "%d.%d.%d", VK_VERSION_MAJOR(ext_props[i].specVersion), - VK_VERSION_MINOR(ext_props[i].specVersion), VK_VERSION_PATCH(ext_props[i].specVersion)); - 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; - } - - return VK_SUCCESS; -} - -VkResult loader_add_device_extensions(const struct loader_instance *inst, - PFN_vkEnumerateDeviceExtensionProperties fpEnumerateDeviceExtensionProperties, - VkPhysicalDevice physical_device, const char *lib_name, - struct loader_extension_list *ext_list) { - uint32_t i, count; - VkResult res; - VkExtensionProperties *ext_props; - - res = fpEnumerateDeviceExtensionProperties(physical_device, NULL, &count, NULL); - 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."); - return VK_ERROR_OUT_OF_HOST_MEMORY; - } - res = fpEnumerateDeviceExtensionProperties(physical_device, NULL, &count, ext_props); - if (res != VK_SUCCESS) { - return res; - } - for (i = 0; i < count; i++) { - char spec_version[64]; - (void)snprintf(spec_version, sizeof(spec_version), "%d.%d.%d", VK_VERSION_MAJOR(ext_props[i].specVersion), - VK_VERSION_MINOR(ext_props[i].specVersion), VK_VERSION_PATCH(ext_props[i].specVersion)); - loader_log(inst, VK_DEBUG_REPORT_DEBUG_BIT_EXT, 0, "Device Extension: %s (%s) version %s", ext_props[i].extensionName, - lib_name, spec_version); - res = loader_add_to_ext_list(inst, ext_list, 1, &ext_props[i]); - if (res != VK_SUCCESS) { - return res; - } - } - } 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", - lib_name); - return res; - } - - return VK_SUCCESS; -} - -VkResult loader_init_generic_list(const struct loader_instance *inst, struct loader_generic_list *list_info, size_t element_size) { - size_t capacity = 32 * element_size; - list_info->count = 0; - 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"); - return VK_ERROR_OUT_OF_HOST_MEMORY; - } - memset(list_info->list, 0, capacity); - list_info->capacity = capacity; - return VK_SUCCESS; -} - -void loader_destroy_generic_list(const struct loader_instance *inst, struct loader_generic_list *list) { - loader_instance_heap_free(inst, list->list); - list->count = 0; - list->capacity = 0; -} - -// Append non-duplicate extension properties defined in props to the given ext_list. -// Return - Vk_SUCCESS on success -VkResult loader_add_to_ext_list(const struct loader_instance *inst, struct loader_extension_list *ext_list, - uint32_t prop_list_count, const VkExtensionProperties *props) { - uint32_t i; - const VkExtensionProperties *cur_ext; - - if (ext_list->list == NULL || ext_list->capacity == 0) { - VkResult res = loader_init_generic_list(inst, (struct loader_generic_list *)ext_list, sizeof(VkExtensionProperties)); - if (VK_SUCCESS != res) { - return res; - } - } - - for (i = 0; i < prop_list_count; i++) { - cur_ext = &props[i]; - - // look for duplicates - if (has_vk_extension_property(cur_ext, ext_list)) { - continue; - } - - // add to list at end - // check for enough capacity - if (ext_list->count * sizeof(VkExtensionProperties) >= ext_list->capacity) { - void *new_ptr = loader_instance_heap_realloc(inst, ext_list->list, ext_list->capacity, ext_list->capacity * 2, - VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); - if (new_ptr == NULL) { - 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; - } - ext_list->list = new_ptr; - - // double capacity - ext_list->capacity *= 2; - } - - memcpy(&ext_list->list[ext_list->count], cur_ext, sizeof(VkExtensionProperties)); - ext_list->count++; - } - return VK_SUCCESS; -} - -// Append one extension property defined in props with entrypoints defined in entries to the given -// ext_list. Do not append if a duplicate. -// Return - Vk_SUCCESS on success -VkResult loader_add_to_dev_ext_list(const struct loader_instance *inst, struct loader_device_extension_list *ext_list, - const VkExtensionProperties *props, uint32_t entry_count, char **entrys) { - uint32_t idx; - if (ext_list->list == NULL || ext_list->capacity == 0) { - VkResult res = loader_init_generic_list(inst, (struct loader_generic_list *)ext_list, sizeof(struct loader_dev_ext_props)); - if (VK_SUCCESS != res) { - return res; - } - } - - // look for duplicates - if (has_vk_dev_ext_property(props, ext_list)) { - return VK_SUCCESS; - } - - idx = ext_list->count; - // add to list at end - // check for enough capacity - if (idx * sizeof(struct loader_dev_ext_props) >= ext_list->capacity) { - void *new_ptr = loader_instance_heap_realloc(inst, ext_list->list, ext_list->capacity, ext_list->capacity * 2, - VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); - - if (NULL == new_ptr) { - 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; - } - ext_list->list = new_ptr; - - // double capacity - ext_list->capacity *= 2; - } - - memcpy(&ext_list->list[idx].props, props, sizeof(*props)); - ext_list->list[idx].entrypoint_count = entry_count; - if (entry_count == 0) { - ext_list->list[idx].entrypoints = NULL; - } else { - 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", - idx); - ext_list->list[idx].entrypoint_count = 0; - return VK_ERROR_OUT_OF_HOST_MEMORY; - } - for (uint32_t i = 0; i < entry_count; i++) { - ext_list->list[idx].entrypoints[i] = - loader_instance_heap_alloc(inst, strlen(entrys[i]) + 1, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); - if (ext_list->list[idx].entrypoints[i] == NULL) { - for (uint32_t j = 0; j < i; j++) { - loader_instance_heap_free(inst, ext_list->list[idx].entrypoints[j]); - } - 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", - i); - return VK_ERROR_OUT_OF_HOST_MEMORY; - } - strcpy(ext_list->list[idx].entrypoints[i], entrys[i]); - } - } - ext_list->count++; - - return VK_SUCCESS; -} - -// Prototype of loader_add_meta_layer function since we use it in the loader_add_implicit_layer, but can also -// call loader_add_implicit_layer from loader_add_meta_layer. -bool loader_add_meta_layer(const struct loader_instance *inst, const struct loader_layer_properties *prop, - struct loader_layer_list *target_list, struct loader_layer_list *expanded_target_list, - const struct loader_layer_list *source_list); - -// Search the given layer list for a list matching the given VkLayerProperties -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; - } - return false; -} - -// Search the given layer list for a layer matching the given name -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; - } - return false; -} - -// Search the given search_list for any layers in the props list. Add these to the -// output layer_list. Don't add duplicates to the output layer_list. -static VkResult loader_add_layer_names_to_list(const struct loader_instance *inst, struct loader_layer_list *output_list, - struct loader_layer_list *expanded_output_list, uint32_t name_count, - const char *const *names, const struct loader_layer_list *source_list) { - struct loader_layer_properties *layer_prop; - VkResult err = VK_SUCCESS; - - for (uint32_t i = 0; i < name_count; i++) { - const char *source_name = names[i]; - layer_prop = loader_get_layer_property(source_name, source_list); - if (NULL == layer_prop) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "loader_add_layer_names_to_list: Unable to find layer" - " %s", - source_name); - err = VK_ERROR_LAYER_NOT_PRESENT; - continue; - } - - // If not a meta-layer, simply add it. - if (0 == (layer_prop->type_flags & VK_LAYER_TYPE_FLAG_META_LAYER)) { - if (!has_vk_layer_property(&layer_prop->info, output_list)) { - loader_add_to_layer_list(inst, output_list, 1, layer_prop); - } - if (!has_vk_layer_property(&layer_prop->info, expanded_output_list)) { - loader_add_to_layer_list(inst, expanded_output_list, 1, layer_prop); - } - } else { - if (!has_vk_layer_property(&layer_prop->info, output_list) || - !has_vk_layer_property(&layer_prop->info, expanded_output_list)) { - loader_add_meta_layer(inst, layer_prop, output_list, expanded_output_list, source_list); - } - } - } - - return err; -} - -// Manage lists of VkLayerProperties -static bool loader_init_layer_list(const struct loader_instance *inst, struct loader_layer_list *list) { - list->capacity = 32 * sizeof(struct loader_layer_properties); - list->list = loader_instance_heap_alloc(inst, list->capacity, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); - if (list->list == NULL) { - return false; - } - memset(list->list, 0, list->capacity); - list->count = 0; - return true; -} - -void loader_destroy_layer_list(const struct loader_instance *inst, struct loader_device *device, - struct loader_layer_list *layer_list) { - if (device) { - loader_device_heap_free(device, layer_list->list); - } else { - loader_instance_heap_free(inst, layer_list->list); - } - layer_list->count = 0; - layer_list->capacity = 0; -} - -// Append non-duplicate layer properties defined in prop_list to the given layer_info list -VkResult loader_add_to_layer_list(const struct loader_instance *inst, struct loader_layer_list *list, uint32_t prop_list_count, - const struct loader_layer_properties *props) { - uint32_t i; - struct loader_layer_properties *layer; - - if (list->list == NULL || list->capacity == 0) { - loader_init_layer_list(inst, list); - } - - if (list->list == NULL) return VK_SUCCESS; - - for (i = 0; i < prop_list_count; i++) { - layer = (struct loader_layer_properties *)&props[i]; - - // Look for duplicates, and skip - if (has_vk_layer_property(&layer->info, list)) { - continue; - } - - // Check for enough capacity - if (((list->count + 1) * sizeof(struct loader_layer_properties)) >= list->capacity) { - size_t new_capacity = list->capacity * 2; - void *new_ptr = - loader_instance_heap_realloc(inst, list->list, list->capacity, new_capacity, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); - if (NULL == new_ptr) { - 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; - } - list->list = new_ptr; - list->capacity = new_capacity; - } - - memcpy(&list->list[list->count], layer, sizeof(struct loader_layer_properties)); - list->count++; - } - - return VK_SUCCESS; -} - -// Check the individual implicit layer for the enable/disable environment variable settings. Only add it after -// every check has passed indicating it should be used. -static void loader_add_implicit_layer(const struct loader_instance *inst, const struct loader_layer_properties *prop, - struct loader_layer_list *target_list, struct loader_layer_list *expanded_target_list, - const struct loader_layer_list *source_list) { - bool enable = loader_is_implicit_layer_enabled(inst, prop); - if (enable) { - if (0 == (prop->type_flags & VK_LAYER_TYPE_FLAG_META_LAYER)) { - if (NULL != target_list && !has_vk_layer_property(&prop->info, target_list)) { - loader_add_to_layer_list(inst, target_list, 1, prop); - } - if (NULL != expanded_target_list && !has_vk_layer_property(&prop->info, expanded_target_list)) { - loader_add_to_layer_list(inst, expanded_target_list, 1, prop); - } - } else { - if (!has_vk_layer_property(&prop->info, target_list) || - (NULL != expanded_target_list && !has_vk_layer_property(&prop->info, expanded_target_list))) { - loader_add_meta_layer(inst, prop, target_list, expanded_target_list, source_list); - } - } - } -} - -// Add the component layers of a meta-layer to the active list of layers -bool loader_add_meta_layer(const struct loader_instance *inst, const struct loader_layer_properties *prop, - struct loader_layer_list *target_list, struct loader_layer_list *expanded_target_list, - const struct loader_layer_list *source_list) { - bool found = true; - - // We need to add all the individual component layers - for (uint32_t comp_layer = 0; comp_layer < prop->num_component_layers; comp_layer++) { - bool found_comp = false; - const struct loader_layer_properties *search_prop = - loader_get_layer_property(prop->component_layer_names[comp_layer], source_list); - if (search_prop != NULL) { - found_comp = true; - - // If the component layer is itself an implicit layer, we need to do the implicit layer enable - // checks - if (0 == (search_prop->type_flags & VK_LAYER_TYPE_FLAG_EXPLICIT_LAYER)) { - loader_add_implicit_layer(inst, search_prop, target_list, expanded_target_list, source_list); - } else { - if (NULL != expanded_target_list && !has_vk_layer_property(&search_prop->info, expanded_target_list)) { - loader_add_to_layer_list(inst, expanded_target_list, 1, search_prop); - } - } - } - if (!found_comp) { - loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, - "loader_add_meta_layer: Failed to find layer name %s component layer " - "%s to activate", - search_prop->info.layerName, prop->component_layer_names[comp_layer]); - found = false; - } - } - - // Add this layer to the overall target list (not the expanded one) - if (found && !has_vk_layer_property(&prop->info, target_list)) { - loader_add_to_layer_list(inst, target_list, 1, prop); - } - - return found; -} - -// Search the source_list for any layer with a name that matches the given name and a type -// that matches the given type. Add all matching layers to the target_list. -// Do not add if found loader_layer_properties is already on the target_list. -void loader_find_layer_name_add_list(const struct loader_instance *inst, const char *name, const enum layer_type_flags type_flags, - const struct loader_layer_list *source_list, struct loader_layer_list *target_list, - struct loader_layer_list *expanded_target_list) { - bool found = false; - for (uint32_t i = 0; i < source_list->count; i++) { - struct loader_layer_properties *source_prop = &source_list->list[i]; - if (0 == strcmp(source_prop->info.layerName, name) && (source_prop->type_flags & type_flags) == type_flags) { - // If not a meta-layer, simply add it. - if (0 == (source_prop->type_flags & VK_LAYER_TYPE_FLAG_META_LAYER)) { - if (NULL != target_list && !has_vk_layer_property(&source_prop->info, target_list) && - VK_SUCCESS == loader_add_to_layer_list(inst, target_list, 1, source_prop)) { - found = true; - } - if (NULL != expanded_target_list && !has_vk_layer_property(&source_prop->info, expanded_target_list) && - VK_SUCCESS == loader_add_to_layer_list(inst, expanded_target_list, 1, source_prop)) { - found = true; - } - } else { - found = loader_add_meta_layer(inst, source_prop, target_list, expanded_target_list, source_list); - } - } - } - 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", 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]; - } - 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; - } - return NULL; -} - -// For Instance extensions implemented within the loader (i.e. DEBUG_REPORT -// the extension must provide two entry points for the loader to use: -// - "trampoline" entry point - this is the address returned by GetProcAddr -// and will always do what's necessary to support a -// global call. -// - "terminator" function - this function will be put at the end of the -// instance chain and will contain the necessary logic -// to call / process the extension for the appropriate -// ICDs that are available. -// There is no generic mechanism for including these functions, the references -// must be placed into the appropriate loader entry points. -// GetInstanceProcAddr: call extension GetInstanceProcAddr to check for GetProcAddr -// requests -// loader_coalesce_extensions(void) - add extension records to the list of global -// extension available to the app. -// instance_disp - add function pointer for terminator function -// to this array. -// The extension itself should be in a separate file that will be linked directly -// with the loader. -VkResult loader_get_icd_loader_instance_extensions(const struct loader_instance *inst, struct loader_icd_tramp_list *icd_tramp_list, - struct loader_extension_list *inst_exts) { - struct loader_extension_list icd_exts; - VkResult res = VK_SUCCESS; - char *env_value; - bool filter_extensions = true; - - loader_log(inst, VK_DEBUG_REPORT_DEBUG_BIT_EXT, 0, "Build ICD instance extension list"); - - // Check if a user wants to disable the instance extension filtering behavior - env_value = loader_getenv("VK_LOADER_DISABLE_INST_EXT_FILTER", inst); - if (NULL != env_value && atoi(env_value) != 0) { - filter_extensions = false; - } - loader_free_getenv(env_value, inst); - - // traverse scanned icd list adding non-duplicate extensions to the list - for (uint32_t i = 0; i < icd_tramp_list->count; i++) { - res = loader_init_generic_list(inst, (struct loader_generic_list *)&icd_exts, sizeof(VkExtensionProperties)); - if (VK_SUCCESS != res) { - goto out; - } - res = loader_add_instance_extensions(inst, icd_tramp_list->scanned_list[i].EnumerateInstanceExtensionProperties, - icd_tramp_list->scanned_list[i].lib_name, &icd_exts); - if (VK_SUCCESS == res) { - if (filter_extensions) { - // 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++) { - if (strcmp(icd_exts.list[j].extensionName, LOADER_INSTANCE_EXTENSIONS[k]) == 0) { - found = true; - break; - } - } - - // If it isn't in the list, remove it - if (!found) { - for (uint32_t k = j + 1; k < icd_exts.count; k++) { - icd_exts.list[k - 1] = icd_exts.list[k]; - } - --icd_exts.count; - --j; - } - } - } - - res = loader_add_to_ext_list(inst, inst_exts, icd_exts.count, icd_exts.list); - } - loader_destroy_generic_list(inst, (struct loader_generic_list *)&icd_exts); - if (VK_SUCCESS != res) { - goto out; - } - }; - - // Traverse loader's extensions, adding non-duplicate extensions to the list - debug_report_add_instance_extensions(inst, inst_exts); - -out: - return res; -} - -struct loader_icd_term *loader_get_icd_and_device(const VkDevice device, struct loader_device **found_dev, uint32_t *icd_index) { - *found_dev = NULL; - for (struct loader_instance *inst = loader.instances; inst; inst = inst->next) { - uint32_t index = 0; - for (struct loader_icd_term *icd_term = inst->icd_terms; icd_term; icd_term = icd_term->next) { - for (struct loader_device *dev = icd_term->logical_device_list; dev; dev = dev->next) - // Value comparison of device prevents object wrapping by layers - if (loader_get_dispatch(dev->icd_device) == loader_get_dispatch(device) || - loader_get_dispatch(dev->chain_device) == loader_get_dispatch(device)) { - *found_dev = dev; - if (NULL != icd_index) { - *icd_index = index; - } - return icd_term; - } - index++; - } - } - return NULL; -} - -void loader_destroy_logical_device(const struct loader_instance *inst, struct loader_device *dev, - const VkAllocationCallbacks *pAllocator) { - if (pAllocator) { - dev->alloc_callbacks = *pAllocator; - } - if (NULL != dev->expanded_activated_layer_list.list) { - loader_deactivate_layers(inst, dev, &dev->expanded_activated_layer_list); - } - if (NULL != dev->app_activated_layer_list.list) { - loader_destroy_layer_list(inst, dev, &dev->app_activated_layer_list); - } - loader_device_heap_free(dev, dev); -} - -struct loader_device *loader_create_logical_device(const struct loader_instance *inst, const VkAllocationCallbacks *pAllocator) { - struct loader_device *new_dev; -#if (DEBUG_DISABLE_APP_ALLOCATORS == 1) - { -#else - if (pAllocator) { - new_dev = (struct loader_device *)pAllocator->pfnAllocation(pAllocator->pUserData, sizeof(struct loader_device), - sizeof(int *), VK_SYSTEM_ALLOCATION_SCOPE_DEVICE); - } else { -#endif - new_dev = (struct loader_device *)malloc(sizeof(struct loader_device)); - } - - if (!new_dev) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "loader_create_logical_device: Failed to alloc struct " - "loader_device"); - return NULL; - } - - memset(new_dev, 0, sizeof(struct loader_device)); - if (pAllocator) { - new_dev->alloc_callbacks = *pAllocator; - } - - return new_dev; -} - -void loader_add_logical_device(const struct loader_instance *inst, struct loader_icd_term *icd_term, struct loader_device *dev) { - dev->next = icd_term->logical_device_list; - icd_term->logical_device_list = dev; -} - -void loader_remove_logical_device(const struct loader_instance *inst, struct loader_icd_term *icd_term, - struct loader_device *found_dev, const VkAllocationCallbacks *pAllocator) { - struct loader_device *dev, *prev_dev; - - if (!icd_term || !found_dev) return; - - prev_dev = NULL; - dev = icd_term->logical_device_list; - while (dev && dev != found_dev) { - prev_dev = dev; - dev = dev->next; - } - - if (prev_dev) - prev_dev->next = found_dev->next; - else - icd_term->logical_device_list = found_dev->next; - loader_destroy_logical_device(inst, found_dev, pAllocator); -} - -static void loader_icd_destroy(struct loader_instance *ptr_inst, struct loader_icd_term *icd_term, - const VkAllocationCallbacks *pAllocator) { - ptr_inst->total_icd_count--; - for (struct loader_device *dev = icd_term->logical_device_list; dev;) { - struct loader_device *next_dev = dev->next; - loader_destroy_logical_device(ptr_inst, dev, pAllocator); - dev = next_dev; - } - - loader_instance_heap_free(ptr_inst, icd_term); -} - -static struct loader_icd_term *loader_icd_create(const struct loader_instance *inst) { - struct loader_icd_term *icd_term; - - icd_term = loader_instance_heap_alloc(inst, sizeof(struct loader_icd_term), VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); - if (!icd_term) { - return NULL; - } - - memset(icd_term, 0, sizeof(struct loader_icd_term)); - - return icd_term; -} - -static struct loader_icd_term *loader_icd_add(struct loader_instance *ptr_inst, const struct loader_scanned_icd *scanned_icd) { - struct loader_icd_term *icd_term; - - icd_term = loader_icd_create(ptr_inst); - if (!icd_term) { - return NULL; - } - - icd_term->scanned_icd = scanned_icd; - icd_term->this_instance = ptr_inst; - - // Prepend to the list - icd_term->next = ptr_inst->icd_terms; - ptr_inst->icd_terms = icd_term; - ptr_inst->total_icd_count++; - - return icd_term; -} - -// Determine the ICD interface version to use. -// @param icd -// @param pVersion Output parameter indicating which version to use or 0 if -// the negotiation API is not supported by the ICD -// @return bool indicating true if the selected interface version is supported -// 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 - *pVersion = 0; - } else { - // ICD supports the negotiation API, so call it with the loader's - // latest version supported - *pVersion = CURRENT_LOADER_ICD_INTERFACE_VERSION; - VkResult result = fp_negotiate_icd_version(pVersion); - - if (result == VK_ERROR_INCOMPATIBLE_DRIVER) { - // ICD no longer supports the loader's latest interface version so - // fail loading the ICD - return false; - } - } - -#if MIN_SUPPORTED_LOADER_ICD_INTERFACE_VERSION > 0 - if (*pVersion < MIN_SUPPORTED_LOADER_ICD_INTERFACE_VERSION) { - // Loader no longer supports the ICD's latest interface version so fail - // loading the ICD - return false; - } -#endif - return true; -} - -void loader_scanned_icd_clear(const struct loader_instance *inst, struct loader_icd_tramp_list *icd_tramp_list) { - if (0 != icd_tramp_list->capacity) { - 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); - } - loader_instance_heap_free(inst, icd_tramp_list->scanned_list); - icd_tramp_list->capacity = 0; - icd_tramp_list->count = 0; - icd_tramp_list->scanned_list = NULL; - } -} - -static VkResult loader_scanned_icd_init(const struct loader_instance *inst, struct loader_icd_tramp_list *icd_tramp_list) { - VkResult err = VK_SUCCESS; - loader_scanned_icd_clear(inst, icd_tramp_list); - 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"); - err = VK_ERROR_OUT_OF_HOST_MEMORY; - } - return err; -} - -static VkResult loader_scanned_icd_add(const struct loader_instance *inst, struct loader_icd_tramp_list *icd_tramp_list, - const char *filename, uint32_t api_version) { - loader_platform_dl_handle handle; - PFN_vkCreateInstance fp_create_inst; - PFN_vkEnumerateInstanceExtensionProperties fp_get_inst_ext_props; - PFN_vkGetInstanceProcAddr fp_get_proc_addr; - PFN_GetPhysicalDeviceProcAddr fp_get_phys_dev_proc_addr = NULL; - PFN_vkNegotiateLoaderICDInterfaceVersion fp_negotiate_icd_version; - struct loader_scanned_icd *new_scanned_icd; - uint32_t interface_vers; - VkResult res = VK_SUCCESS; - - // TODO implement smarter opening/closing of libraries. For now this - // function leaves libraries open and the scanned_icd_clear closes them - handle = loader_platform_open_library(filename); - if (NULL == handle) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, loader_platform_open_library_error(filename)); - goto out; - } - - // Get and settle on an ICD interface version - 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.", - filename); - goto out; - } - - fp_get_proc_addr = loader_platform_get_proc_address(handle, "vk_icdGetInstanceProcAddr"); - if (NULL == fp_get_proc_addr) { - assert(interface_vers == 0); - // 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 retrieve 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", - 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", - 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", - filename); - goto out; - } - } else { - // Use newer interface version 1 or later - if (interface_vers == 0) { - interface_vers = 1; - } - - 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", - 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", - filename); - goto out; - } - fp_get_phys_dev_proc_addr = loader_platform_get_proc_address(handle, "vk_icdGetPhysicalDeviceProcAddr"); - } - - // check for enough capacity - if ((icd_tramp_list->count * sizeof(struct loader_scanned_icd)) >= icd_tramp_list->capacity) { - void *new_ptr = 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 == new_ptr) { - 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", filename); - goto out; - } - icd_tramp_list->scanned_list = new_ptr; - - // double capacity - icd_tramp_list->capacity *= 2; - } - - new_scanned_icd = &(icd_tramp_list->scanned_list[icd_tramp_list->count]); - new_scanned_icd->handle = handle; - new_scanned_icd->api_version = api_version; - new_scanned_icd->GetInstanceProcAddr = fp_get_proc_addr; - new_scanned_icd->GetPhysicalDeviceProcAddr = fp_get_phys_dev_proc_addr; - new_scanned_icd->EnumerateInstanceExtensionProperties = fp_get_inst_ext_props; - new_scanned_icd->CreateInstance = fp_create_inst; - new_scanned_icd->interface_version = interface_vers; - - new_scanned_icd->lib_name = (char *)loader_instance_heap_alloc(inst, strlen(filename) + 1, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); - if (NULL == new_scanned_icd->lib_name) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_scanned_icd_add: Out of memory can't add ICD %s", filename); - res = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - strcpy(new_scanned_icd->lib_name, filename); - icd_tramp_list->count++; - -out: - - return res; -} - -static void loader_debug_init(void) { - char *env, *orig; - - if (g_loader_debug > 0) return; - - g_loader_debug = 0; - - // Parse comma-separated debug options - orig = env = loader_getenv("VK_LOADER_DEBUG", NULL); - while (env) { - char *p = strchr(env, ','); - size_t len; - - if (p) - len = p - env; - else - len = strlen(env); - - if (len > 0) { - if (strncmp(env, "all", len) == 0) { - g_loader_debug = ~0u; - g_loader_log_msgs = ~0u; - } else if (strncmp(env, "warn", len) == 0) { - g_loader_debug |= LOADER_WARN_BIT; - g_loader_log_msgs |= VK_DEBUG_REPORT_WARNING_BIT_EXT; - } else if (strncmp(env, "info", len) == 0) { - g_loader_debug |= LOADER_INFO_BIT; - g_loader_log_msgs |= VK_DEBUG_REPORT_INFORMATION_BIT_EXT; - } else if (strncmp(env, "perf", len) == 0) { - g_loader_debug |= LOADER_PERF_BIT; - g_loader_log_msgs |= VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT; - } else if (strncmp(env, "error", len) == 0) { - g_loader_debug |= LOADER_ERROR_BIT; - g_loader_log_msgs |= VK_DEBUG_REPORT_ERROR_BIT_EXT; - } else if (strncmp(env, "debug", len) == 0) { - g_loader_debug |= LOADER_DEBUG_BIT; - g_loader_log_msgs |= VK_DEBUG_REPORT_DEBUG_BIT_EXT; - } - } - - if (!p) break; - - env = p + 1; - } - - loader_free_getenv(orig, NULL); -} - -void loader_initialize(void) { - // initialize mutexs - loader_platform_thread_create_mutex(&loader_lock); - loader_platform_thread_create_mutex(&loader_json_lock); - - // initialize logging - loader_debug_init(); - - // initial cJSON to use alloc callbacks - cJSON_Hooks alloc_fns = { - .malloc_fn = loader_instance_tls_heap_alloc, .free_fn = loader_instance_tls_heap_free, - }; - cJSON_InitHooks(&alloc_fns); -} - -struct loader_manifest_files { - uint32_t count; - char **filename_list; -}; - -void loader_release() { - // release mutexs - loader_platform_thread_delete_mutex(&loader_lock); - loader_platform_thread_delete_mutex(&loader_json_lock); -} - -// Get next file or dirname given a string list or registry key path -// -// \returns -// A pointer to first char in the next path. -// The next path (or NULL) in the list is returned in next_path. -// Note: input string is modified in some cases. PASS IN A COPY! -static char *loader_get_next_path(char *path) { - uint32_t len; - char *next; - - if (path == NULL) return NULL; - next = strchr(path, PATH_SEPARATOR); - if (next == NULL) { - len = (uint32_t)strlen(path); - next = path + len; - } else { - *next = '\0'; - next++; - } - - return next; -} - -// Given a path which is absolute or relative, expand the path if relative or -// leave the path unmodified if absolute. The base path to prepend to relative -// paths is given in rel_base. -// -// @return - A string in out_fullpath of the full absolute path -static void loader_expand_path(const char *path, const char *rel_base, size_t out_size, char *out_fullpath) { - if (loader_platform_is_path_absolute(path)) { - // do not prepend a base to an absolute path - rel_base = ""; - } - - loader_platform_combine_path(out_fullpath, out_size, rel_base, path, NULL); -} - -// Given a filename (file) and a list of paths (dir), try to find an existing -// file in the paths. If filename already is a path then no searching in the given paths. -// -// @return - A string in out_fullpath of either the full path or file. -static void loader_get_fullpath(const char *file, const char *dirs, size_t out_size, char *out_fullpath) { - if (!loader_platform_is_path(file) && *dirs) { - char *dirs_copy, *dir, *next_dir; - - dirs_copy = loader_stack_alloc(strlen(dirs) + 1); - strcpy(dirs_copy, dirs); - - // find if file exists after prepending paths in given list - for (dir = dirs_copy; *dir && (next_dir = loader_get_next_path(dir)); dir = next_dir) { - loader_platform_combine_path(out_fullpath, out_size, dir, file, NULL); - if (loader_platform_file_exists(out_fullpath)) { - return; - } - } - } - - (void)snprintf(out_fullpath, out_size, "%s", file); -} - -// Read a JSON file into a buffer. -// -// @return - A pointer to a cJSON object representing the JSON parse tree. -// This returned buffer should be freed by caller. -static VkResult loader_get_json(const struct loader_instance *inst, const char *filename, cJSON **json) { - FILE *file = NULL; - char *json_buf; - size_t len; - VkResult res = VK_SUCCESS; - - if (NULL == json) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_get_json: Received invalid JSON file"); - res = VK_ERROR_INITIALIZATION_FAILED; - goto out; - } - - *json = NULL; - - file = fopen(filename, "rb"); - if (!file) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_get_json: Failed to open JSON file %s", filename); - res = VK_ERROR_INITIALIZATION_FAILED; - goto out; - } - fseek(file, 0, SEEK_END); - len = ftell(file); - 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", - filename, len); - res = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - if (fread(json_buf, sizeof(char), len, file) != len) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_get_json: Failed to read JSON file %s.", filename); - res = VK_ERROR_INITIALIZATION_FAILED; - goto out; - } - json_buf[len] = '\0'; - - // 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.", - filename); - res = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - -out: - if (NULL != file) { - fclose(file); - } - - return res; -} - -// Do a deep copy of the loader_layer_properties structure. -VkResult loader_copy_layer_properties(const struct loader_instance *inst, struct loader_layer_properties *dst, - struct loader_layer_properties *src) { - uint32_t cnt, i; - memcpy(dst, src, sizeof(*src)); - 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.", - src->instance_extension_list.count); - return VK_ERROR_OUT_OF_HOST_MEMORY; - } - dst->instance_extension_list.capacity = sizeof(VkExtensionProperties) * src->instance_extension_list.count; - memcpy(dst->instance_extension_list.list, src->instance_extension_list.list, dst->instance_extension_list.capacity); - 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.", - src->device_extension_list.count); - return VK_ERROR_OUT_OF_HOST_MEMORY; - } - memset(dst->device_extension_list.list, 0, sizeof(struct loader_dev_ext_props) * src->device_extension_list.count); - - dst->device_extension_list.capacity = sizeof(struct loader_dev_ext_props) * src->device_extension_list.count; - memcpy(dst->device_extension_list.list, src->device_extension_list.list, dst->device_extension_list.capacity); - if (src->device_extension_list.count > 0 && src->device_extension_list.list->entrypoint_count > 0) { - cnt = src->device_extension_list.list->entrypoint_count; - 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.", - cnt); - return VK_ERROR_OUT_OF_HOST_MEMORY; - } - memset(dst->device_extension_list.list->entrypoints, 0, sizeof(char *) * cnt); - - for (i = 0; i < cnt; i++) { - 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", - i); - return VK_ERROR_OUT_OF_HOST_MEMORY; - } - strcpy(dst->device_extension_list.list->entrypoints[i], src->device_extension_list.list->entrypoints[i]); - } - } - - return VK_SUCCESS; -} - -static bool loader_find_layer_name_list(const char *name, const struct loader_layer_list *layer_list) { - if (NULL == 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; - } - } - 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; - for (uint32_t j = 0; j < layer_count; j++) - if (!strcmp(name, layer_list[j])) return true; - return false; -} - -const char *std_validation_str = "VK_LAYER_LUNARG_standard_validation"; - -// Adds the legacy VK_LAYER_LUNARG_standard_validation as a meta-layer if it -// fails to find it in the list already. This is usually an indication that a -// newer loader is being used with an older layer set. -static bool loader_add_legacy_std_val_layer(const struct loader_instance *inst, struct loader_layer_list *layer_instance_list) { - uint32_t i; - bool success = true; - struct loader_layer_properties *props = loader_get_next_layer_property(inst, layer_instance_list); - const char std_validation_names[6][VK_MAX_EXTENSION_NAME_SIZE] = { - "VK_LAYER_GOOGLE_threading", "VK_LAYER_LUNARG_parameter_validation", "VK_LAYER_LUNARG_object_tracker", - "VK_LAYER_LUNARG_core_validation", "VK_LAYER_GOOGLE_unique_objects"}; - uint32_t layer_count = sizeof(std_validation_names) / sizeof(std_validation_names[0]); - - loader_log(inst, VK_DEBUG_REPORT_DEBUG_BIT_EXT, 0, - "Adding VK_LAYER_LUNARG_standard_validation using the loader legacy path. This is" - " not an error."); - - if (NULL == props) { - goto out; - } - - memset(props, 0, sizeof(struct loader_layer_properties)); - props->type_flags = VK_LAYER_TYPE_FLAG_INSTANCE_LAYER | VK_LAYER_TYPE_FLAG_EXPLICIT_LAYER | VK_LAYER_TYPE_FLAG_META_LAYER; - strncpy(props->info.description, "LunarG Standard Validation Layer", sizeof(props->info.description)); - props->info.implementationVersion = 1; - strncpy(props->info.layerName, std_validation_str, sizeof(props->info.layerName)); - props->info.specVersion = VK_MAKE_VERSION(1, 0, VK_HEADER_VERSION); - - props->component_layer_names = - loader_instance_heap_alloc(inst, sizeof(char[MAX_STRING_SIZE]) * layer_count, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); - if (NULL == props->component_layer_names) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "Failed to allocate space for legacy VK_LAYER_LUNARG_standard_validation" - " meta-layer component_layers information."); - success = false; - goto out; - } - for (i = 0; i < layer_count; i++) { - strncpy(props->component_layer_names[i], std_validation_names[i], MAX_STRING_SIZE - 1); - props->component_layer_names[i][MAX_STRING_SIZE - 1] = '\0'; - } - -out: - - if (!success && NULL != props && NULL != props->component_layer_names) { - loader_instance_heap_free(inst, props->component_layer_names); - props->component_layer_names = NULL; - } - - return success; -} - -// Verify that all component layers in a meta-layer are valid. -static bool verify_meta_layer_comp_layers(const struct loader_instance *inst, struct loader_layer_properties *prop, - struct loader_layer_list *instance_layers) { - bool success = true; - const uint32_t expected_major = VK_VERSION_MAJOR(prop->info.specVersion); - const uint32_t expected_minor = VK_VERSION_MINOR(prop->info.specVersion); - - for (uint32_t comp_layer = 0; comp_layer < prop->num_component_layers; comp_layer++) { - if (!loader_find_layer_name_list(prop->component_layer_names[comp_layer], instance_layers)) { - loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, - "Meta-layer %s can't find component layer %s at index %d." - " Skipping this layer.", - prop->info.layerName, prop->component_layer_names[comp_layer], comp_layer); - success = false; - break; - } else { - struct loader_layer_properties *comp_prop = - loader_get_layer_property(prop->component_layer_names[comp_layer], instance_layers); - if (comp_prop == NULL) { - loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, - "Meta-layer %s can't find property for component layer %s at index %d." - " Skipping this layer.", - prop->info.layerName, prop->component_layer_names[comp_layer], comp_layer); - success = false; - break; - } - - // Check the version of each layer, they need to at least match MAJOR and MINOR - uint32_t cur_major = VK_VERSION_MAJOR(comp_prop->info.specVersion); - uint32_t cur_minor = VK_VERSION_MINOR(comp_prop->info.specVersion); - if (cur_major != expected_major || cur_minor != expected_minor) { - loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, - "Meta-layer uses API version %d.%d, but component layer %d uses API " - "version %d.%d. Skipping this layer.", - expected_major, expected_minor, comp_layer, cur_major, cur_minor); - success = false; - break; - } - - // Make sure the layer isn't using it's own name - if (!strcmp(prop->info.layerName, prop->component_layer_names[comp_layer])) { - loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, - "Meta-layer %s lists itself in its component layer list at index %d." - " Skipping this layer.", - prop->info.layerName, comp_layer); - success = false; - break; - } - if (comp_prop->type_flags & VK_LAYER_TYPE_FLAG_META_LAYER) { - loader_log(inst, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, - "verify_meta_layer_comp_layers: Adding meta-layer %s which also contains meta-layer %s", - prop->info.layerName, comp_prop->info.layerName); - - // Make sure if the layer is using a meta-layer in its component list that we also verify that. - if (!verify_meta_layer_comp_layers(inst, comp_prop, instance_layers)) { - loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, - "Meta-layer %s component layer %s can not find all component layers." - " Skipping this layer.", - prop->info.layerName, prop->component_layer_names[comp_layer]); - success = false; - break; - } - } - - // Add any instance and device extensions from component layers to this layer - // list, so that anyone querying extensions will only need to look at the meta-layer - for (uint32_t ext = 0; ext < comp_prop->instance_extension_list.count; ext++) { - loader_log(inst, VK_DEBUG_REPORT_DEBUG_BIT_EXT, 0, "Meta-layer %s component layer %s adding instance extension %s", - prop->info.layerName, prop->component_layer_names[comp_layer], - comp_prop->instance_extension_list.list[ext].extensionName); - if (!has_vk_extension_property(&comp_prop->instance_extension_list.list[ext], &prop->instance_extension_list)) { - loader_add_to_ext_list(inst, &prop->instance_extension_list, 1, &comp_prop->instance_extension_list.list[ext]); - } - } - - for (uint32_t ext = 0; ext < comp_prop->device_extension_list.count; ext++) { - loader_log(inst, VK_DEBUG_REPORT_DEBUG_BIT_EXT, 0, "Meta-layer %s component layer %s adding device extension %s", - prop->info.layerName, prop->component_layer_names[comp_layer], - comp_prop->device_extension_list.list[ext].props.extensionName); - if (!has_vk_dev_ext_property(&comp_prop->device_extension_list.list[ext].props, &prop->device_extension_list)) { - loader_add_to_dev_ext_list(inst, &prop->device_extension_list, - &comp_prop->device_extension_list.list[ext].props, 0, NULL); - } - } - } - } - if (success) { - loader_log(inst, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, "Meta-layer %s all %d component layers appear to be valid.", - prop->info.layerName, prop->num_component_layers); - } - return success; -} - -// Verify that all meta-layers in a layer list are valid. -static void verify_all_meta_layers(const struct loader_instance *inst, struct loader_layer_list *instance_layers) { - for (int32_t i = 0; i < (int32_t)instance_layers->count; i++) { - struct loader_layer_properties *prop = &instance_layers->list[i]; - - // If this is a meta-layer, make sure it is valid - if ((prop->type_flags & VK_LAYER_TYPE_FLAG_META_LAYER) && !verify_meta_layer_comp_layers(inst, prop, instance_layers)) { - loader_log(inst, VK_DEBUG_REPORT_DEBUG_BIT_EXT, 0, - "Removing meta-layer %s from instance layer list since it appears invalid.", prop->info.layerName); - - // Delete the component layers - loader_instance_heap_free(inst, prop->component_layer_names); - - // Remove the current invalid meta-layer from the layer list. Use memmove since we are - // overlapping the source and destination addresses. - memmove(&instance_layers->list[i], &instance_layers->list[i + 1], - sizeof(struct loader_layer_properties) * (instance_layers->count - 1 - i)); - - // Decrement the count (because we now have one less) and decrement the loop index since we need to - // re-check this index. - instance_layers->count--; - i--; - } - } -} - -// This structure is used to store the json file version -// in a more manageable way. -typedef struct { - uint16_t major; - uint16_t minor; - uint16_t patch; -} layer_json_version; - -static inline bool is_valid_layer_json_version(const layer_json_version *layer_json) { - // Supported versions are: 1.0.0, 1.0.1, 1.1.0, 1.1.1, and 1.1.2. - if ((layer_json->major == 1 && layer_json->minor == 1 && layer_json->patch < 3) || - (layer_json->major == 1 && layer_json->minor == 0 && layer_json->patch < 2)) { - return true; - } - return false; -} - -static inline bool layer_json_supports_layers_tag(const layer_json_version *layer_json) { - // Supported versions started in 1.0.1, so anything newer - if ((layer_json->major > 1 || layer_json->minor > 0 || layer_json->patch > 1)) { - return true; - } - return false; -} - -static inline bool layer_json_supports_pre_instance_tag(const layer_json_version *layer_json) { - // Supported versions started in 1.1.2, so anything newer - return layer_json->major > 1 || layer_json->minor > 1 || (layer_json->minor == 1 && layer_json->patch > 1); -} - -static VkResult loader_read_json_layer(const struct loader_instance *inst, struct loader_layer_list *layer_instance_list, - cJSON *layer_node, layer_json_version version, cJSON *item, cJSON *disable_environment, - bool is_implicit, char *filename) { - char *temp; - char *name, *type, *library_path_str, *api_version; - char *implementation_version, *description; - cJSON *ext_item, *library_path, *component_layers; - VkExtensionProperties ext_prop; - VkResult result = VK_ERROR_INITIALIZATION_FAILED; - struct loader_layer_properties *props = NULL; - int i, j; - -// The following are required in the "layer" object: -// (required) "name" -// (required) "type" -// (required) "library_path" -// (required) "api_version" -// (required) "implementation_version" -// (required) "description" -// (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); \ - goto out; \ - } \ - } -#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); \ - goto out; \ - } \ - 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); \ - result = VK_ERROR_OUT_OF_HOST_MEMORY; \ - goto out; \ - } \ - 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) - GET_JSON_ITEM(layer_node, api_version) - GET_JSON_ITEM(layer_node, implementation_version) - GET_JSON_ITEM(layer_node, description) - - // Add list entry - if (!strcmp(type, "DEVICE")) { - loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, "Device layers are deprecated skipping this layer"); - layer_node = layer_node->next; - goto out; - } - - // Allow either GLOBAL or INSTANCE type interchangeably to handle - // layers that must work with older loaders - if (!strcmp(type, "INSTANCE") || !strcmp(type, "GLOBAL")) { - if (layer_instance_list == NULL) { - layer_node = layer_node->next; - goto out; - } - props = loader_get_next_layer_property(inst, layer_instance_list); - if (NULL == props) { - // Error already triggered in loader_get_next_layer_property. - result = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - props->type_flags = VK_LAYER_TYPE_FLAG_INSTANCE_LAYER; - if (!is_implicit) { - props->type_flags |= VK_LAYER_TYPE_FLAG_EXPLICIT_LAYER; - } - } else { - layer_node = layer_node->next; - goto out; - } - - // Library path no longer required unless component_layers is also not defined - library_path = cJSON_GetObjectItem(layer_node, "library_path"); - component_layers = cJSON_GetObjectItem(layer_node, "component_layers"); - if (NULL != library_path) { - if (NULL != component_layers) { - loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, - "Indicating meta-layer-specific component_layers, but also " - "defining layer library path. Both are not compatible, so " - "skipping this layer"); - goto out; - } - props->num_component_layers = 0; - props->component_layer_names = NULL; - - temp = cJSON_Print(library_path); - if (NULL == temp) { - layer_node = layer_node->next; - loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, - "Problem accessing layer value library_path in manifest JSON " - "file, skipping this layer"); - result = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - temp[strlen(temp) - 1] = '\0'; - library_path_str = loader_stack_alloc(strlen(temp) + 1); - strcpy(library_path_str, &temp[1]); - cJSON_Free(temp); - - char *fullpath = props->lib_name; - char *rel_base; - if (NULL != library_path_str) { - if (loader_platform_is_path(library_path_str)) { - // A relative or absolute path - char *name_copy = loader_stack_alloc(strlen(filename) + 1); - strcpy(name_copy, filename); - rel_base = loader_platform_dirname(name_copy); - loader_expand_path(library_path_str, rel_base, MAX_STRING_SIZE, fullpath); - } else { - // A filename which is assumed in a system directory - loader_get_fullpath(library_path_str, DEFAULT_VK_LAYERS_PATH, MAX_STRING_SIZE, fullpath); - } - } - } else if (NULL != component_layers) { - if (version.major == 1 && (version.minor < 1 || version.patch < 1)) { - loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, - "Indicating meta-layer-specific component_layers, but using older " - "JSON file version."); - } - int count = cJSON_GetArraySize(component_layers); - props->num_component_layers = count; - - // Allocate buffer for layer names - props->component_layer_names = - loader_instance_heap_alloc(inst, sizeof(char[MAX_STRING_SIZE]) * count, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); - if (NULL == props->component_layer_names) { - result = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - - // Copy the component layers into the array - for (i = 0; i < count; i++) { - cJSON *comp_layer = cJSON_GetArrayItem(component_layers, i); - if (NULL != comp_layer) { - temp = cJSON_Print(comp_layer); - if (NULL == temp) { - result = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - temp[strlen(temp) - 1] = '\0'; - strncpy(props->component_layer_names[i], temp + 1, MAX_STRING_SIZE - 1); - props->component_layer_names[i][MAX_STRING_SIZE - 1] = '\0'; - cJSON_Free(temp); - } - } - - // This is now, officially, a meta-layer - props->type_flags |= VK_LAYER_TYPE_FLAG_META_LAYER; - loader_log(inst, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, "Encountered meta-layer %s", name); - - // Make sure we set up other things so we head down the correct branches below - library_path_str = NULL; - } else { - loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, - "Layer missing both library_path and component_layers fields. One or the " - "other MUST be defined. Skipping this layer"); - goto out; - } - - if (is_implicit) { - GET_JSON_OBJECT(layer_node, disable_environment) - } -#undef GET_JSON_ITEM -#undef GET_JSON_OBJECT - - strncpy(props->info.layerName, name, sizeof(props->info.layerName)); - props->info.layerName[sizeof(props->info.layerName) - 1] = '\0'; - props->info.specVersion = loader_make_version(api_version); - props->info.implementationVersion = atoi(implementation_version); - strncpy((char *)props->info.description, description, sizeof(props->info.description)); - 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"); - layer_node = layer_node->next; - goto out; - } - strncpy(props->disable_env_var.name, disable_environment->child->string, sizeof(props->disable_env_var.name)); - props->disable_env_var.name[sizeof(props->disable_env_var.name) - 1] = '\0'; - strncpy(props->disable_env_var.value, disable_environment->child->valuestring, sizeof(props->disable_env_var.value)); - props->disable_env_var.value[sizeof(props->disable_env_var.value) - 1] = '\0'; - } - -// Now get all optional items and objects and put in list: -// functions -// instance_extensions -// device_extensions -// enable_environment (implicit layers only) -#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); \ - } else { \ - result = VK_ERROR_OUT_OF_HOST_MEMORY; \ - goto out; \ - } \ - } \ - } - - cJSON *instance_extensions, *device_extensions, *functions, *enable_environment; - cJSON *entrypoints = NULL; - char *vkGetInstanceProcAddr = NULL; - char *vkGetDeviceProcAddr = NULL; - char *vkNegotiateLoaderLayerInterfaceVersion = NULL; - char *spec_version = NULL; - char **entry_array = NULL; - - // Layer interface functions - // vkGetInstanceProcAddr - // vkGetDeviceProcAddr - // vkNegotiateLoaderLayerInterfaceVersion (starting with JSON file 1.1.0) - GET_JSON_OBJECT(layer_node, functions) - if (functions != NULL) { - if (version.major > 1 || version.minor >= 1) { - GET_JSON_ITEM(functions, vkNegotiateLoaderLayerInterfaceVersion) - if (vkNegotiateLoaderLayerInterfaceVersion != NULL) - strncpy(props->functions.str_negotiate_interface, vkNegotiateLoaderLayerInterfaceVersion, - sizeof(props->functions.str_negotiate_interface)); - props->functions.str_negotiate_interface[sizeof(props->functions.str_negotiate_interface) - 1] = '\0'; - } else { - props->functions.str_negotiate_interface[0] = '\0'; - } - GET_JSON_ITEM(functions, vkGetInstanceProcAddr) - GET_JSON_ITEM(functions, vkGetDeviceProcAddr) - 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"); - } - } - 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"); - } - } - props->functions.str_gdpa[sizeof(props->functions.str_gdpa) - 1] = '\0'; - } - - // instance_extensions - // array of { - // name - // spec_version - // } - GET_JSON_OBJECT(layer_node, instance_extensions) - if (instance_extensions != NULL) { - int count = cJSON_GetArraySize(instance_extensions); - for (i = 0; i < count; i++) { - ext_item = cJSON_GetArrayItem(instance_extensions, i); - GET_JSON_ITEM(ext_item, name) - if (name != NULL) { - strncpy(ext_prop.extensionName, name, sizeof(ext_prop.extensionName)); - ext_prop.extensionName[sizeof(ext_prop.extensionName) - 1] = '\0'; - } - GET_JSON_ITEM(ext_item, spec_version) - if (NULL != spec_version) { - ext_prop.specVersion = atoi(spec_version); - } else { - ext_prop.specVersion = 0; - } - bool ext_unsupported = wsi_unsupported_instance_extension(&ext_prop); - if (!ext_unsupported) { - loader_add_to_ext_list(inst, &props->instance_extension_list, 1, &ext_prop); - } - } - } - - // device_extensions - // array of { - // name - // spec_version - // entrypoints - // } - GET_JSON_OBJECT(layer_node, device_extensions) - if (device_extensions != NULL) { - int count = cJSON_GetArraySize(device_extensions); - for (i = 0; i < count; i++) { - ext_item = cJSON_GetArrayItem(device_extensions, i); - GET_JSON_ITEM(ext_item, name) - GET_JSON_ITEM(ext_item, spec_version) - if (name != NULL) { - strncpy(ext_prop.extensionName, name, sizeof(ext_prop.extensionName)); - ext_prop.extensionName[sizeof(ext_prop.extensionName) - 1] = '\0'; - } - if (NULL != spec_version) { - ext_prop.specVersion = atoi(spec_version); - } else { - ext_prop.specVersion = 0; - } - // entrypoints = cJSON_GetObjectItem(ext_item, "entrypoints"); - GET_JSON_OBJECT(ext_item, entrypoints) - int entry_count; - if (entrypoints == NULL) { - loader_add_to_dev_ext_list(inst, &props->device_extension_list, &ext_prop, 0, NULL); - continue; - } - entry_count = cJSON_GetArraySize(entrypoints); - if (entry_count) { - entry_array = (char **)loader_stack_alloc(sizeof(char *) * entry_count); - } - for (j = 0; j < entry_count; j++) { - ext_item = cJSON_GetArrayItem(entrypoints, j); - if (ext_item != NULL) { - temp = cJSON_Print(ext_item); - if (NULL == temp) { - entry_array[j] = NULL; - result = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - temp[strlen(temp) - 1] = '\0'; - entry_array[j] = loader_stack_alloc(strlen(temp) + 1); - strcpy(entry_array[j], &temp[1]); - cJSON_Free(temp); - } - } - loader_add_to_dev_ext_list(inst, &props->device_extension_list, &ext_prop, entry_count, entry_array); - } - } - if (is_implicit) { - GET_JSON_OBJECT(layer_node, enable_environment) - - // enable_environment is optional - if (enable_environment) { - strncpy(props->enable_env_var.name, enable_environment->child->string, sizeof(props->enable_env_var.name)); - props->enable_env_var.name[sizeof(props->enable_env_var.name) - 1] = '\0'; - strncpy(props->enable_env_var.value, enable_environment->child->valuestring, sizeof(props->enable_env_var.value)); - props->enable_env_var.value[sizeof(props->enable_env_var.value) - 1] = '\0'; - } - } - - // Read in the pre-instance stuff - cJSON *pre_instance = cJSON_GetObjectItem(layer_node, "pre_instance_functions"); - if (pre_instance) { - if (!layer_json_supports_pre_instance_tag(&version)) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "Found pre_instance_functions section in layer from \"%s\". " - "This section is only valid in manifest version 1.1.2 or later. The section will be ignored", - filename); - } else if (!is_implicit) { - loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, - "Found pre_instance_functions section in explicit layer from " - "\"%s\". This section is only valid in implicit layers. The section will be ignored", - filename); - } else { - cJSON *inst_ext_json = cJSON_GetObjectItem(pre_instance, "vkEnumerateInstanceExtensionProperties"); - if (inst_ext_json) { - char *inst_ext_name = cJSON_Print(inst_ext_json); - size_t len = strlen(inst_ext_name) >= MAX_STRING_SIZE ? MAX_STRING_SIZE - 3 : strlen(inst_ext_name) - 2; - strncpy(props->pre_instance_functions.enumerate_instance_extension_properties, inst_ext_name + 1, len); - props->pre_instance_functions.enumerate_instance_extension_properties[len] = '\0'; - cJSON_Free(inst_ext_name); - } - - cJSON *inst_layer_json = cJSON_GetObjectItem(pre_instance, "vkEnumerateInstanceLayerProperties"); - if (inst_layer_json) { - char *inst_layer_name = cJSON_Print(inst_layer_json); - size_t len = strlen(inst_layer_name) >= MAX_STRING_SIZE ? MAX_STRING_SIZE - 3 : strlen(inst_layer_name) - 2; - strncpy(props->pre_instance_functions.enumerate_instance_layer_properties, inst_layer_name + 1, len); - props->pre_instance_functions.enumerate_instance_layer_properties[len] = '\0'; - cJSON_Free(inst_layer_name); - } - } - } - - result = VK_SUCCESS; - -out: - -#undef GET_JSON_ITEM -#undef GET_JSON_OBJECT - - if (VK_SUCCESS != result && NULL != props) { - props->num_component_layers = 0; - if (NULL != props->component_layer_names) { - loader_instance_heap_free(inst, props->component_layer_names); - } - props->component_layer_names = NULL; - } - - return result; -} - -// Given a cJSON struct (json) of the top level JSON object from layer manifest -// file, add entry to the layer_list. Fill out the layer_properties in this list -// entry from the input cJSON object. -// -// \returns -// void -// layer_list has a new entry and initialized accordingly. -// If the json input object does not have all the required fields no entry -// is added to the list. -static VkResult loader_add_layer_properties(const struct loader_instance *inst, struct loader_layer_list *layer_instance_list, - cJSON *json, bool is_implicit, char *filename) { - // The following Fields in layer manifest file that are required: - // - "file_format_version" - // - If more than one "layer" object are used, then the "layers" array is - // required - VkResult result = VK_ERROR_INITIALIZATION_FAILED; - cJSON *item, *layers_node, *layer_node; - layer_json_version json_version = {0, 0, 0}; - char *vers_tok; - cJSON *disable_environment = NULL; - item = cJSON_GetObjectItem(json, "file_format_version"); - if (item == NULL) { - goto out; - } - char *file_vers = cJSON_PrintUnformatted(item); - if (NULL == file_vers) { - goto out; - } - loader_log(inst, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, "Found manifest file %s, version %s", filename, file_vers); - // Get the major/minor/and patch as integers for easier comparison - vers_tok = strtok(file_vers, ".\"\n\r"); - if (NULL != vers_tok) { - json_version.major = (uint16_t)atoi(vers_tok); - vers_tok = strtok(NULL, ".\"\n\r"); - if (NULL != vers_tok) { - json_version.minor = (uint16_t)atoi(vers_tok); - vers_tok = strtok(NULL, ".\"\n\r"); - if (NULL != vers_tok) { - json_version.patch = (uint16_t)atoi(vers_tok); - } - } - } - - 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.", - filename, json_version.major, json_version.minor, json_version.patch); - } - cJSON_Free(file_vers); - - // If "layers" is present, read in the array of layer objects - layers_node = cJSON_GetObjectItem(json, "layers"); - 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", - 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", - curLayer, filename); - goto out; - } - result = loader_read_json_layer(inst, layer_instance_list, layer_node, json_version, item, disable_environment, - is_implicit, filename); - } - } else { - // 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.", - filename); - goto out; - } - // Loop through all "layer" objects in the file to get a count of them - // first. - uint16_t layer_count = 0; - cJSON *tempNode = layer_node; - do { - tempNode = tempNode->next; - layer_count++; - } while (tempNode != NULL); - - // Throw a warning if we encounter multiple "layer" objects in file - // 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.", - filename); - } else { - do { - result = loader_read_json_layer(inst, layer_instance_list, layer_node, json_version, item, disable_environment, - is_implicit, filename); - layer_node = layer_node->next; - } while (layer_node != NULL); - } - } - -out: - - return result; -} - -// Find the Vulkan library manifest files. -// -// This function scans the "location" or "env_override" directories/files -// for a list of JSON manifest files. If env_override is non-NULL -// and has a valid value. Then the location is ignored. Otherwise -// location is used to look for manifest files. The location -// is interpreted as Registry path on Windows and a directory path(s) -// on Linux. "home_location" is an additional directory in the users home -// directory to look at. It is expanded into the dir path -// $XDG_DATA_HOME/home_location or $HOME/.local/share/home_location depending -// on environment variables. This "home_location" is only used on Linux. -// -// \returns -// VKResult -// A string list of manifest files to be opened in out_files param. -// List has a pointer to string for each manifest filename. -// When done using the list in out_files, pointers should be freed. -// Location or override string lists can be either files or directories as -// follows: -// | location | override -// -------------------------------- -// Win ICD | files | files -// Win Layer | files | dirs -// Linux ICD | dirs | files -// Linux Layer| dirs | dirs -static VkResult loader_get_manifest_files(const struct loader_instance *inst, const char *env_override, const char *source_override, - bool is_layer, bool warn_if_not_present, const char *location, - const char *relative_location, struct loader_manifest_files *out_files) { - const char *override = NULL; - char *override_getenv = NULL; - char *loc, *orig_loc = NULL; - char *reg = NULL; - char *file, *next_file, *name; - size_t alloced_count = 64; - char full_path[2048]; - DIR *sysdir = NULL; - bool list_is_dirs = false; - struct dirent *dent; - VkResult res = VK_SUCCESS; - - out_files->count = 0; - out_files->filename_list = NULL; - - if (source_override != NULL) { - override = source_override; - } else if (env_override != NULL) { -#if !defined(_WIN32) - if (geteuid() != getuid() || getegid() != getgid()) { - // Don't allow setuid apps to use the env var: - env_override = NULL; - } -#endif - if (env_override != NULL) { - override = override_getenv = loader_secure_getenv(env_override, inst); - } - } - -#if !defined(_WIN32) - if (relative_location == NULL) { -#else - relative_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", - (env_override != NULL) ? env_override : ""); - res = VK_ERROR_INITIALIZATION_FAILED; - goto out; - } - -#if defined(_WIN32) - list_is_dirs = (is_layer && override != NULL) ? true : false; -#else - list_is_dirs = (override == NULL || is_layer) ? true : false; -#endif - // Make a copy of the input we are using so it is not modified - // Also handle getting the location(s) from registry on Windows - if (override == NULL) { - size_t loc_size = 0; -#if !defined(_WIN32) - const char *xdgconfdirs = loader_secure_getenv("XDG_CONFIG_DIRS", inst); - const char *xdgdatadirs = loader_secure_getenv("XDG_DATA_DIRS", inst); - if (xdgconfdirs == NULL || xdgconfdirs[0] == '\0') xdgconfdirs = FALLBACK_CONFIG_DIRS; - if (xdgdatadirs == NULL || xdgdatadirs[0] == '\0') xdgdatadirs = FALLBACK_DATA_DIRS; - const size_t rel_size = strlen(relative_location); - // Leave space for trailing separators - loc_size += strlen(xdgconfdirs) + strlen(xdgdatadirs) + 2 * rel_size + 2; - for (const char *x = xdgconfdirs; *x; ++x) - if (*x == PATH_SEPARATOR) loc_size += rel_size; - for (const char *x = xdgdatadirs; *x; ++x) - if (*x == PATH_SEPARATOR) loc_size += rel_size; - loc_size += strlen(SYSCONFDIR) + rel_size + 1; -#if defined(EXTRASYSCONFDIR) - loc_size += strlen(EXTRASYSCONFDIR) + rel_size + 1; -#endif -#else - loc_size += strlen(location) + 1; -#endif - loc = loader_stack_alloc(loc_size); - 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.", - loc_size); - res = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - char *loc_write = loc; -#if !defined(_WIN32) - const char *loc_read; - size_t start, stop; - - loc_read = &xdgconfdirs[0]; - start = 0; - while (loc_read[start] != '\0') { - while (loc_read[start] == PATH_SEPARATOR) { - start++; - } - stop = start; - while (loc_read[stop] != PATH_SEPARATOR && loc_read[stop] != '\0') { - stop++; - } - const size_t s = stop - start; - if (s) { - memcpy(loc_write, &loc_read[start], s); - loc_write += s; - memcpy(loc_write, relative_location, rel_size); - loc_write += rel_size; - *loc_write++ = PATH_SEPARATOR; - start = stop; - } - } - - memcpy(loc_write, SYSCONFDIR, strlen(SYSCONFDIR)); - loc_write += strlen(SYSCONFDIR); - memcpy(loc_write, relative_location, rel_size); - loc_write += rel_size; - *loc_write++ = PATH_SEPARATOR; - -#if defined(EXTRASYSCONFDIR) - memcpy(loc_write, EXTRASYSCONFDIR, strlen(EXTRASYSCONFDIR)); - loc_write += strlen(EXTRASYSCONFDIR); - memcpy(loc_write, relative_location, rel_size); - loc_write += rel_size; - *loc_write++ = PATH_SEPARATOR; -#endif - - loc_read = &xdgdatadirs[0]; - start = 0; - while (loc_read[start] != '\0') { - while (loc_read[start] == PATH_SEPARATOR) { - start++; - } - stop = start; - while (loc_read[stop] != PATH_SEPARATOR && loc_read[stop] != '\0') { - stop++; - } - const size_t s = stop - start; - if (s) { - memcpy(loc_write, &loc_read[start], s); - loc_write += s; - memcpy(loc_write, relative_location, rel_size); - loc_write += rel_size; - *loc_write++ = PATH_SEPARATOR; - start = stop; - } - } - - --loc_write; -#else - memcpy(loc_write, location, strlen(location)); - loc_write += strlen(location); -#endif - assert(loc_write - loc < (ptrdiff_t)loc_size); - *loc_write = '\0'; - -#if defined(_WIN32) - VkResult regHKR_result = VK_SUCCESS; - - DWORD reg_size = 4096; - - if (!strncmp(loc, DEFAULT_VK_DRIVERS_INFO, sizeof(DEFAULT_VK_DRIVERS_INFO))) { - regHKR_result = loaderGetDeviceRegistryFiles(inst, ®, ®_size, LoaderPnpDriverRegistry()); - } else if (!strncmp(loc, DEFAULT_VK_ELAYERS_INFO, sizeof(DEFAULT_VK_ELAYERS_INFO))) { - regHKR_result = loaderGetDeviceRegistryFiles(inst, ®, ®_size, LoaderPnpELayerRegistry()); - } else if (!strncmp(loc, DEFAULT_VK_ILAYERS_INFO, sizeof(DEFAULT_VK_ILAYERS_INFO))) { - regHKR_result = loaderGetDeviceRegistryFiles(inst, ®, ®_size, LoaderPnpILayerRegistry()); - } - - VkResult reg_result = loaderGetRegistryFiles(inst, loc, is_layer, ®, ®_size); - - if ((VK_SUCCESS != reg_result && VK_SUCCESS != regHKR_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?"); - if (VK_SUCCESS == regHKR_result || VK_ERROR_OUT_OF_HOST_MEMORY == regHKR_result) { - res = regHKR_result; - } else if (VK_SUCCESS == reg_result || VK_ERROR_OUT_OF_HOST_MEMORY == reg_result) { - res = reg_result; - } else { - res = VK_ERROR_INCOMPATIBLE_DRIVER; - } - } 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."); - } - if (reg_result == VK_ERROR_OUT_OF_HOST_MEMORY) { - res = reg_result; - } else { - // Return success for now since it's not critical for layers - res = VK_SUCCESS; - } - } - goto out; - } - orig_loc = loc; - loc = reg; -#endif - } 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", - strlen(override) + 1); - res = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - strcpy(loc, override); - } - - // Print out the paths being searched if debugging is enabled - loader_log(inst, VK_DEBUG_REPORT_DEBUG_BIT_EXT, 0, "Searching the following paths for manifest files: %s\n", loc); - - file = loc; - while (*file) { - next_file = loader_get_next_path(file); - if (list_is_dirs) { - sysdir = opendir(file); - name = NULL; - if (sysdir) { - dent = readdir(sysdir); - if (dent == NULL) break; - name = &(dent->d_name[0]); - loader_get_fullpath(name, file, sizeof(full_path), full_path); - name = full_path; - } - } else { -#if defined(_WIN32) - name = file; -#else - // only Linux has relative paths - char *dir; - // 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", - strlen(loc) + 1); - goto out; - } - strcpy(dir, loc); - - loader_get_fullpath(file, dir, sizeof(full_path), full_path); - - name = full_path; -#endif - } - while (name) { - // Look for files ending with ".json" suffix - uint32_t nlen = (uint32_t)strlen(name); - const char *suf = name + nlen - 5; - - // Check if the file is already present - bool file_already_loaded = false; - for (uint32_t i = 0; i < out_files->count; ++i) { - if (!strcmp(out_files->filename_list[i], name)) { - file_already_loaded = true; - } - } - - if (!file_already_loaded && (nlen > 5) && !strncmp(suf, ".json", 5)) { - if (out_files->count == 0) { - out_files->filename_list = - loader_instance_heap_alloc(inst, alloced_count * sizeof(char *), VK_SYSTEM_ALLOCATION_SCOPE_COMMAND); - if (NULL == out_files->filename_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; - } - } else if (out_files->count == alloced_count) { - void *new_ptr = - loader_instance_heap_realloc(inst, out_files->filename_list, alloced_count * sizeof(char *), - alloced_count * sizeof(char *) * 2, VK_SYSTEM_ALLOCATION_SCOPE_COMMAND); - if (NULL == new_ptr) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "loader_get_manifest_files: Failed to reallocate space for manifest file name list"); - res = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - out_files->filename_list = new_ptr; - alloced_count *= 2; - } - 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", - out_files->count); - res = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - strcpy(out_files->filename_list[out_files->count], name); - out_files->count++; - } else if(file_already_loaded) { - loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, - "Skipping manifest file %s - The file has already been read once", name); - } else if (!list_is_dirs) { - loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, "Skipping manifest file %s, file name must end in .json", - name); - } - if (list_is_dirs) { - dent = readdir(sysdir); - if (dent == NULL) { - break; - } - name = &(dent->d_name[0]); - loader_get_fullpath(name, file, sizeof(full_path), full_path); - name = full_path; - } else { - break; - } - } - if (sysdir) { - closedir(sysdir); - sysdir = NULL; - } - file = next_file; -#if !defined(_WIN32) - if (relative_location != NULL && (next_file == NULL || *next_file == '\0') && override == NULL) { - char *xdgdatahome = loader_secure_getenv("XDG_DATA_HOME", inst); - size_t len; - if (xdgdatahome != NULL) { - size_t alloc_len = strlen(xdgdatahome) + 2 + strlen(relative_location); - char *home_loc = loader_stack_alloc(alloc_len); - 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"); - res = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - strcpy(home_loc, xdgdatahome); - // Add directory separator if needed - if (relative_location[0] != DIRECTORY_SYMBOL) { - len = strlen(home_loc); - home_loc[len] = DIRECTORY_SYMBOL; - home_loc[len + 1] = '\0'; - } - strncat(home_loc, relative_location, alloc_len); - file = home_loc; - next_file = loader_get_next_path(file); - relative_location = NULL; - - loader_log(inst, VK_DEBUG_REPORT_DEBUG_BIT_EXT, 0, "Searching the following path for manifest files: %s\n", - home_loc); - list_is_dirs = true; - - } else { - char *home = loader_secure_getenv("HOME", inst); - if (home != NULL) { - size_t alloc_len = strlen(home) + 16 + strlen(relative_location); - char *home_loc = loader_stack_alloc(alloc_len); - 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"); - res = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - strncpy(home_loc, home, alloc_len); - - len = strlen(home); - if (home[len] != DIRECTORY_SYMBOL) { - home_loc[len] = DIRECTORY_SYMBOL; - home_loc[len + 1] = '\0'; - } - strncat(home_loc, ".local/share", alloc_len); - - if (relative_location[0] != DIRECTORY_SYMBOL) { - len = strlen(home_loc); - home_loc[len] = DIRECTORY_SYMBOL; - home_loc[len + 1] = '\0'; - } - strncat(home_loc, relative_location, alloc_len); - file = home_loc; - next_file = loader_get_next_path(file); - relative_location = NULL; - - loader_log(inst, VK_DEBUG_REPORT_DEBUG_BIT_EXT, 0, "Searching the following path for manifest files: %s\n", - home_loc); - list_is_dirs = true; - } else { - // without knowing HOME, we just.. give up - } - } - } -#endif - } - -out: - if (VK_SUCCESS != res && NULL != out_files->filename_list) { - for (uint32_t remove = 0; remove < out_files->count; remove++) { - loader_instance_heap_free(inst, out_files->filename_list[remove]); - } - loader_instance_heap_free(inst, out_files->filename_list); - out_files->count = 0; - out_files->filename_list = NULL; - } - - if (NULL != sysdir) { - closedir(sysdir); - } - - if (override_getenv != NULL) { - loader_free_getenv(override_getenv, inst); - } - - if (NULL != reg && reg != orig_loc) { - loader_instance_heap_free(inst, reg); - } - return res; -} - -void loader_init_icd_lib_list() {} - -void loader_destroy_icd_lib_list() {} - -// Try to find the Vulkan ICD driver(s). -// -// This function scans the default system loader path(s) or path -// specified by the \c VK_ICD_FILENAMES environment variable in -// order to find loadable VK ICDs manifest files. From these -// manifest files it finds the ICD libraries. -// -// \returns -// Vulkan result -// (on result == VK_SUCCESS) a list of icds that were discovered -VkResult loader_icd_scan(const struct loader_instance *inst, struct loader_icd_tramp_list *icd_tramp_list) { - char *file_str; - uint16_t file_major_vers = 0; - uint16_t file_minor_vers = 0; - uint16_t file_patch_vers = 0; - char *vers_tok; - struct loader_manifest_files manifest_files; - VkResult res = VK_SUCCESS; - bool lockedMutex = false; - cJSON *json = NULL; - uint32_t num_good_icds = 0; - - memset(&manifest_files, 0, sizeof(struct loader_manifest_files)); - - res = loader_scanned_icd_init(inst, icd_tramp_list); - if (VK_SUCCESS != res) { - goto out; - } - - // Get a list of manifest files for ICDs - res = loader_get_manifest_files(inst, "VK_ICD_FILENAMES", NULL, false, true, DEFAULT_VK_DRIVERS_INFO, RELATIVE_VK_DRIVERS_INFO, - &manifest_files); - if (VK_SUCCESS != res || manifest_files.count == 0) { - goto out; - } - - loader_platform_thread_lock_mutex(&loader_json_lock); - lockedMutex = true; - for (uint32_t i = 0; i < manifest_files.count; i++) { - file_str = manifest_files.filename_list[i]; - if (file_str == NULL) { - continue; - } - - VkResult temp_res = loader_get_json(inst, file_str, &json); - if (NULL == json || temp_res != VK_SUCCESS) { - if (NULL != json) { - cJSON_Delete(json); - json = NULL; - } - // If we haven't already found an ICD, copy this result to - // the returned result. - if (num_good_icds == 0) { - res = temp_res; - } - if (temp_res == VK_ERROR_OUT_OF_HOST_MEMORY) { - break; - } else { - continue; - } - } - res = temp_res; - - cJSON *item, *itemICD; - item = cJSON_GetObjectItem(json, "file_format_version"); - if (item == NULL) { - 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.", - file_str); - cJSON_Delete(json); - json = NULL; - continue; - } - - char *file_vers = cJSON_Print(item); - if (NULL == file_vers) { - // Only reason the print can fail is if there was an allocation issue - 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", - file_str); - cJSON_Delete(json); - json = NULL; - continue; - } - loader_log(inst, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, "Found ICD manifest file %s, version %s", file_str, file_vers); - - // Get the major/minor/and patch as integers for easier comparison - vers_tok = strtok(file_vers, ".\"\n\r"); - if (NULL != vers_tok) { - file_major_vers = (uint16_t)atoi(vers_tok); - vers_tok = strtok(NULL, ".\"\n\r"); - if (NULL != vers_tok) { - file_minor_vers = (uint16_t)atoi(vers_tok); - vers_tok = strtok(NULL, ".\"\n\r"); - if (NULL != vers_tok) { - file_patch_vers = (uint16_t)atoi(vers_tok); - } - } - } - - 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"); - } - cJSON_Free(file_vers); - - itemICD = cJSON_GetObjectItem(json, "ICD"); - if (itemICD != NULL) { - item = cJSON_GetObjectItem(itemICD, "library_path"); - if (item != NULL) { - char *temp = cJSON_Print(item); - if (!temp || strlen(temp) == 0) { - 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.", - file_str); - cJSON_Free(temp); - cJSON_Delete(json); - json = NULL; - continue; - } - // strip out extra quotes - 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.", - file_str); - res = VK_ERROR_OUT_OF_HOST_MEMORY; - cJSON_Free(temp); - cJSON_Delete(json); - json = NULL; - goto out; - } - 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.", - file_str); - cJSON_Delete(json); - json = NULL; - continue; - } - char fullpath[MAX_STRING_SIZE]; - // Print out the paths being searched if debugging is enabled - loader_log(inst, VK_DEBUG_REPORT_DEBUG_BIT_EXT, 0, "Searching for ICD drivers named %s, using default dir %s", - library_path, DEFAULT_VK_DRIVERS_PATH); - if (loader_platform_is_path(library_path)) { - // a relative or absolute path - char *name_copy = loader_stack_alloc(strlen(file_str) + 1); - char *rel_base; - strcpy(name_copy, file_str); - rel_base = loader_platform_dirname(name_copy); - loader_expand_path(library_path, rel_base, sizeof(fullpath), fullpath); - } else { - // a filename which is assumed in a system directory - loader_get_fullpath(library_path, DEFAULT_VK_DRIVERS_PATH, sizeof(fullpath), fullpath); - } - - uint32_t vers = 0; - item = cJSON_GetObjectItem(itemICD, "api_version"); - 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.", - file_str); - - // Only reason the print can fail is if there was an - // allocation issue - if (num_good_icds == 0) { - res = VK_ERROR_OUT_OF_HOST_MEMORY; - } - - cJSON_Free(temp); - cJSON_Delete(json); - json = NULL; - continue; - } - 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.", - 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.", - fullpath); - cJSON_Delete(json); - json = NULL; - 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.", - 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", - file_str); - } - - cJSON_Delete(json); - json = NULL; - } - -out: - - if (NULL != json) { - cJSON_Delete(json); - } - - if (NULL != manifest_files.filename_list) { - for (uint32_t i = 0; i < manifest_files.count; i++) { - if (NULL != manifest_files.filename_list[i]) { - loader_instance_heap_free(inst, manifest_files.filename_list[i]); - } - } - loader_instance_heap_free(inst, manifest_files.filename_list); - } - if (lockedMutex) { - loader_platform_thread_unlock_mutex(&loader_json_lock); - } - - return res; -} - -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 - cJSON *json; - uint32_t implicit; - bool lockedMutex = false; - - memset(manifest_files, 0, sizeof(struct loader_manifest_files) * 2); - - // Get a list of manifest files for explicit layers - if (VK_SUCCESS != loader_get_manifest_files(inst, LAYERS_PATH_ENV, LAYERS_SOURCE_PATH, true, true, DEFAULT_VK_ELAYERS_INFO, - RELATIVE_VK_ELAYERS_INFO, &manifest_files[0])) { - goto out; - } - - // Get a list of manifest files for any implicit layers - // Pass NULL for environment variable override - implicit layers are not - // overridden by LAYERS_PATH_ENV - if (VK_SUCCESS != loader_get_manifest_files(inst, NULL, NULL, true, false, DEFAULT_VK_ILAYERS_INFO, RELATIVE_VK_ILAYERS_INFO, - &manifest_files[1])) { - goto out; - } - - // Make sure we have at least one layer, if not, go ahead and return - if (manifest_files[0].count == 0 && manifest_files[1].count == 0) { - goto out; - } - - // cleanup any previously scanned libraries - loader_delete_layer_properties(inst, instance_layers); - - loader_platform_thread_lock_mutex(&loader_json_lock); - lockedMutex = true; - 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; - - // parse file into JSON struct - VkResult res = loader_get_json(inst, file_str, &json); - if (VK_ERROR_OUT_OF_HOST_MEMORY == res) { - break; - } else if (VK_SUCCESS != res || NULL == json) { - continue; - } - - VkResult local_res = loader_add_layer_properties(inst, instance_layers, json, (implicit == 1), file_str); - cJSON_Delete(json); - - if (VK_SUCCESS != local_res) { - goto out; - } - } - } - - // See if "VK_LAYER_LUNARG_standard_validation" already in list. - bool found_std_val = false; - for (uint32_t i = 0; i < instance_layers->count; i++) { - struct loader_layer_properties *props = &instance_layers->list[i]; - if (strcmp(props->info.layerName, std_validation_str) == 0) { - found_std_val = true; - break; - } - } - - // If we didn't find the VK_LAYER_LUNARG_standard_validation meta-layer in - // the list, then we need to add it manually. This is likely because we're - // dealing with a new loader, but an old layer folder. - if (!found_std_val && !loader_add_legacy_std_val_layer(inst, instance_layers)) { - goto out; - } - - // Verify any meta-layers in the list are valid and all the component layers are - // actually present in the available layer list - verify_all_meta_layers(inst, instance_layers); - -out: - - for (uint32_t manFile = 0; manFile < 2; manFile++) { - if (NULL != manifest_files[manFile].filename_list) { - for (uint32_t i = 0; i < manifest_files[manFile].count; i++) { - if (NULL != manifest_files[manFile].filename_list[i]) { - loader_instance_heap_free(inst, manifest_files[manFile].filename_list[i]); - } - } - loader_instance_heap_free(inst, manifest_files[manFile].filename_list); - } - } - if (lockedMutex) { - loader_platform_thread_unlock_mutex(&loader_json_lock); - } -} - -void loader_implicit_layer_scan(const struct loader_instance *inst, struct loader_layer_list *instance_layers) { - char *file_str; - struct loader_manifest_files manifest_files; - cJSON *json; - uint32_t i; - - // Pass NULL for environment variable override - implicit layers are not - // overridden by LAYERS_PATH_ENV - VkResult res = loader_get_manifest_files(inst, NULL, NULL, true, false, DEFAULT_VK_ILAYERS_INFO, RELATIVE_VK_ILAYERS_INFO, - &manifest_files); - if (VK_SUCCESS != res || manifest_files.count == 0) { - return; - } - - // Cleanup any previously scanned libraries - loader_delete_layer_properties(inst, instance_layers); - - loader_platform_thread_lock_mutex(&loader_json_lock); - - for (i = 0; i < manifest_files.count; i++) { - file_str = manifest_files.filename_list[i]; - if (file_str == NULL) { - continue; - } - - // parse file into JSON struct - res = loader_get_json(inst, file_str, &json); - if (VK_ERROR_OUT_OF_HOST_MEMORY == res) { - break; - } else if (VK_SUCCESS != res || NULL == json) { - continue; - } - - res = loader_add_layer_properties(inst, instance_layers, json, true, file_str); - - loader_instance_heap_free(inst, file_str); - cJSON_Delete(json); - - if (VK_ERROR_OUT_OF_HOST_MEMORY == res) { - break; - } - } - loader_instance_heap_free(inst, manifest_files.filename_list); - loader_platform_thread_unlock_mutex(&loader_json_lock); -} - -// Check if an implicit layer should be enabled. -bool loader_is_implicit_layer_enabled(const struct loader_instance *inst, const struct loader_layer_properties *prop) { - bool enable = false; - char *env_value = NULL; - - // if no enable_environment variable is specified, this implicit layer - // should always be enabled. Otherwise check if the variable is set - if (prop->enable_env_var.name[0] == 0) { - enable = true; - } else { - env_value = loader_secure_getenv(prop->enable_env_var.name, inst); - if (env_value && !strcmp(prop->enable_env_var.value, env_value)) enable = true; - loader_free_getenv(env_value, inst); - } - - // disable_environment has priority, i.e. if both enable and disable - // environment variables are set, the layer is disabled. Implicit - // layers are required to have a disable_environment variables - env_value = loader_secure_getenv(prop->disable_env_var.name, inst); - if (env_value && !strcmp(prop->disable_env_var.value, env_value)) enable = false; - loader_free_getenv(env_value, inst); - - return enable; -} - -static VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL loader_gpdpa_instance_internal(VkInstance inst, const char *pName) { - // inst is not wrapped - if (inst == VK_NULL_HANDLE) { - return NULL; - } - VkLayerInstanceDispatchTable *disp_table = *(VkLayerInstanceDispatchTable **)inst; - void *addr; - - if (disp_table == NULL) return NULL; - - bool found_name; - addr = loader_lookup_instance_dispatch_table(disp_table, pName, &found_name); - if (found_name) { - 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); - return NULL; -} - -static VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL loader_gpdpa_instance_terminator(VkInstance inst, const char *pName) { - // inst is not wrapped - if (inst == VK_NULL_HANDLE) { - return NULL; - } - VkLayerInstanceDispatchTable *disp_table = *(VkLayerInstanceDispatchTable **)inst; - void *addr; - - if (disp_table == NULL) return NULL; - - bool found_name; - addr = loader_lookup_instance_dispatch_table(disp_table, pName, &found_name); - if (found_name) { - return addr; - } - - // Get the terminator, but don't perform checking since it should already - // have been setup if we get here. - if (loader_phys_dev_ext_gpa(loader_get_instance(inst), pName, false, 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_terminator() unrecognized name %s", pName); - return NULL; -} - -static VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL loader_gpa_instance_internal(VkInstance inst, const char *pName) { - if (!strcmp(pName, "vkGetInstanceProcAddr")) { - return (PFN_vkVoidFunction)loader_gpa_instance_internal; - } - if (!strcmp(pName, "vk_layerGetPhysicalDeviceProcAddr")) { - return (PFN_vkVoidFunction)loader_gpdpa_instance_terminator; - } - if (!strcmp(pName, "vkCreateInstance")) { - return (PFN_vkVoidFunction)terminator_CreateInstance; - } - if (!strcmp(pName, "vkCreateDevice")) { - return (PFN_vkVoidFunction)terminator_CreateDevice; - } - - // inst is not wrapped - if (inst == VK_NULL_HANDLE) { - return NULL; - } - VkLayerInstanceDispatchTable *disp_table = *(VkLayerInstanceDispatchTable **)inst; - void *addr; - - if (disp_table == NULL) return NULL; - - bool found_name; - addr = loader_lookup_instance_dispatch_table(disp_table, pName, &found_name); - if (found_name) { - 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_gpa_instance_internal() unrecognized name %s", pName); - return NULL; -} - -VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL loader_gpa_device_internal(VkDevice device, const char *pName) { - struct loader_device *dev; - struct loader_icd_term *icd_term = loader_get_icd_and_device(device, &dev, NULL); - - // Return this function if a layer above here is asking for the vkGetDeviceProcAddr. - // This is so we can properly intercept any device commands needing a terminator. - if (!strcmp(pName, "vkGetDeviceProcAddr")) { - return (PFN_vkVoidFunction)loader_gpa_device_internal; - } - - // NOTE: Device Funcs needing Trampoline/Terminator. - // Overrides for device functions needing a trampoline and - // a terminator because certain device entry-points still need to go - // through a terminator before hitting the ICD. This could be for - // several reasons, but the main one is currently unwrapping an - // object before passing the appropriate info along to the ICD. - // This is why we also have to override the direct ICD call to - // vkGetDeviceProcAddr to intercept those calls. - PFN_vkVoidFunction addr = get_extension_device_proc_terminator(pName); - if (NULL != addr) { - return addr; - } - - return icd_term->dispatch.GetDeviceProcAddr(device, pName); -} - -// Initialize device_ext dispatch table entry as follows: -// If dev == NULL find all logical devices created within this instance and -// init the entry (given by idx) in the ext dispatch table. -// If dev != NULL only initialize the entry in the given dev's dispatch table. -// The initialization value is gotten by calling down the device chain with -// GDPA. -// If GDPA returns NULL then don't initialize the dispatch table entry. -static void loader_init_dispatch_dev_ext_entry(struct loader_instance *inst, struct loader_device *dev, uint32_t idx, - const char *funcName) - -{ - 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; - } 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; - ldev = ldev->next; - } - } - } -} - -// Find all dev extension in the hash table and initialize the dispatch table -// for dev for each of those extension entrypoints found in hash table. -void loader_init_dispatch_dev_ext(struct loader_instance *inst, struct loader_device *dev) { - for (uint32_t i = 0; i < MAX_NUM_UNKNOWN_EXTS; i++) { - if (inst->dev_ext_disp_hash[i].func_name != NULL) - loader_init_dispatch_dev_ext_entry(inst, dev, i, inst->dev_ext_disp_hash[i].func_name); - } -} - -static bool loader_check_icds_for_dev_ext_address(struct loader_instance *inst, const char *funcName) { - struct loader_icd_term *icd_term; - icd_term = inst->icd_terms; - while (NULL != icd_term) { - if (icd_term->scanned_icd->GetInstanceProcAddr(icd_term->instance, funcName)) - // this icd supports funcName - return true; - icd_term = icd_term->next; - } - - return false; -} - -static bool loader_check_layer_list_for_dev_ext_address(const struct loader_layer_list *const layers, const char *funcName) { - // Iterate over the layers. - for (uint32_t layer = 0; layer < layers->count; ++layer) { - // Iterate over the extensions. - const struct loader_device_extension_list *const extensions = &(layers->list[layer].device_extension_list); - for (uint32_t extension = 0; extension < extensions->count; ++extension) { - // Iterate over the entry points. - const struct loader_dev_ext_props *const property = &(extensions->list[extension]); - for (uint32_t entry = 0; entry < property->entrypoint_count; ++entry) { - if (strcmp(property->entrypoints[entry], funcName) == 0) { - return true; - } - } - } - } - - return false; -} - -static void loader_free_dev_ext_table(struct loader_instance *inst) { - for (uint32_t i = 0; i < MAX_NUM_UNKNOWN_EXTS; i++) { - loader_instance_heap_free(inst, inst->dev_ext_disp_hash[i].func_name); - loader_instance_heap_free(inst, inst->dev_ext_disp_hash[i].list.index); - } - memset(inst->dev_ext_disp_hash, 0, sizeof(inst->dev_ext_disp_hash)); -} - -static bool loader_add_dev_ext_table(struct loader_instance *inst, uint32_t *ptr_idx, const char *funcName) { - uint32_t i; - uint32_t idx = *ptr_idx; - struct loader_dispatch_hash_list *list = &inst->dev_ext_disp_hash[idx].list; - - if (!inst->dev_ext_disp_hash[idx].func_name) { - // no entry here at this idx, so use it - assert(list->capacity == 0); - 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", - funcName); - return false; - } - strncpy(inst->dev_ext_disp_hash[idx].func_name, funcName, strlen(funcName) + 1); - return true; - } - - // check for enough capacity - 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", - funcName); - return false; - } - list->capacity = 8 * sizeof(*(list->index)); - } else if (list->capacity < (list->count + 1) * sizeof(*(list->index))) { - void *new_ptr = loader_instance_heap_realloc(inst, list->index, list->capacity, list->capacity * 2, - VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); - if (NULL == new_ptr) { - 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; - } - list->index = new_ptr; - list->capacity *= 2; - } - - // find an unused index in the hash table and use it - i = (idx + 1) % MAX_NUM_UNKNOWN_EXTS; - do { - if (!inst->dev_ext_disp_hash[i].func_name) { - assert(inst->dev_ext_disp_hash[i].list.capacity == 0); - 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", - funcName); - return false; - } - strncpy(inst->dev_ext_disp_hash[i].func_name, funcName, strlen(funcName) + 1); - list->index[list->count] = i; - list->count++; - *ptr_idx = i; - return true; - } - 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?"); - - 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; - - // funcName wasn't at the primary spot in the hash table - // search the list of secondary locations (shallow search, not deep search) - for (uint32_t i = 0; i < inst->dev_ext_disp_hash[*idx].list.count; i++) { - alt_idx = inst->dev_ext_disp_hash[*idx].list.index[i]; - if (!strcmp(inst->dev_ext_disp_hash[*idx].func_name, funcName)) { - *idx = alt_idx; - return true; - } - } - - return false; -} - -// This function returns generic trampoline code address for unknown entry -// points. -// Presumably, these unknown entry points (as given by funcName) are device -// extension entrypoints. A hash table is used to keep a list of unknown entry -// points and their mapping to the device extension dispatch table -// (struct loader_dev_ext_dispatch_table). -// \returns -// For a given entry point string (funcName), if an existing mapping is found -// the -// trampoline address for that mapping is returned. Otherwise, this unknown -// entry point -// has not been seen yet. Next check if a layer or ICD supports it. If so then -// a -// new entry in the hash table is initialized and that trampoline address for -// the new entry is returned. Null is returned if the hash table is full or -// if no discovered layer or ICD returns a non-NULL GetProcAddr for it. -void *loader_dev_ext_gpa(struct loader_instance *inst, const char *funcName) { - uint32_t idx; - uint32_t seed = 0; - - idx = murmurhash(funcName, strlen(funcName), seed) % MAX_NUM_UNKNOWN_EXTS; - - if (loader_name_in_dev_ext_table(inst, &idx, funcName)) - // found funcName already in hash - return loader_get_dev_ext_trampoline(idx); - - // Check if funcName is supported in either ICDs or a layer library - if (!loader_check_icds_for_dev_ext_address(inst, funcName) && - !loader_check_layer_list_for_dev_ext_address(&inst->app_activated_layer_list, funcName)) { - // if support found in layers continue on - return NULL; - } - - if (loader_add_dev_ext_table(inst, &idx, funcName)) { - // successfully added new table entry - // init any dev dispatch table entries as needed - loader_init_dispatch_dev_ext_entry(inst, NULL, idx, funcName); - return loader_get_dev_ext_trampoline(idx); - } - - return NULL; -} - -static bool loader_check_icds_for_phys_dev_ext_address(struct loader_instance *inst, const char *funcName) { - struct loader_icd_term *icd_term; - icd_term = inst->icd_terms; - while (NULL != icd_term) { - if (icd_term->scanned_icd->interface_version >= MIN_PHYS_DEV_EXTENSION_ICD_INTERFACE_VERSION && - icd_term->scanned_icd->GetPhysicalDeviceProcAddr(icd_term->instance, funcName)) - // this icd supports funcName - return true; - icd_term = icd_term->next; - } - - return false; -} - -static bool loader_check_layer_list_for_phys_dev_ext_address(struct loader_instance *inst, const char *funcName) { - struct loader_layer_properties *layer_prop_list = inst->expanded_activated_layer_list.list; - for (uint32_t layer = 0; layer < inst->expanded_activated_layer_list.count; ++layer) { - // If this layer supports the vk_layerGetPhysicalDeviceProcAddr, then call - // it and see if it returns a valid pointer for this function name. - if (layer_prop_list[layer].interface_version > 1) { - const struct loader_layer_functions *const functions = &(layer_prop_list[layer].functions); - if (NULL != functions->get_physical_device_proc_addr && - NULL != functions->get_physical_device_proc_addr((VkInstance)inst->instance, funcName)) { - return true; - } - } - } - - return false; -} - -static void loader_free_phys_dev_ext_table(struct loader_instance *inst) { - for (uint32_t i = 0; i < MAX_NUM_UNKNOWN_EXTS; i++) { - loader_instance_heap_free(inst, inst->phys_dev_ext_disp_hash[i].func_name); - loader_instance_heap_free(inst, inst->phys_dev_ext_disp_hash[i].list.index); - } - memset(inst->phys_dev_ext_disp_hash, 0, sizeof(inst->phys_dev_ext_disp_hash)); -} - -static bool loader_add_phys_dev_ext_table(struct loader_instance *inst, uint32_t *ptr_idx, const char *funcName) { - uint32_t i; - uint32_t idx = *ptr_idx; - struct loader_dispatch_hash_list *list = &inst->phys_dev_ext_disp_hash[idx].list; - - if (!inst->phys_dev_ext_disp_hash[idx].func_name) { - // no entry here at this idx, so use it - assert(list->capacity == 0); - 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"); - return false; - } - strncpy(inst->phys_dev_ext_disp_hash[idx].func_name, funcName, strlen(funcName) + 1); - return true; - } - - // check for enough capacity - 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_phys_dev_ext_table() can't allocate list memory"); - return false; - } - list->capacity = 8 * sizeof(*(list->index)); - } else if (list->capacity < (list->count + 1) * sizeof(*(list->index))) { - void *new_ptr = loader_instance_heap_realloc(inst, list->index, list->capacity, list->capacity * 2, - VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); - if (NULL == new_ptr) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_add_phys_dev_ext_table() can't reallocate list memory"); - return false; - } - list->index = new_ptr; - list->capacity *= 2; - } - - // find an unused index in the hash table and use it - i = (idx + 1) % MAX_NUM_UNKNOWN_EXTS; - do { - if (!inst->phys_dev_ext_disp_hash[i].func_name) { - assert(inst->phys_dev_ext_disp_hash[i].list.capacity == 0); - 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 reallocate " - "func_name memory"); - return false; - } - strncpy(inst->phys_dev_ext_disp_hash[i].func_name, funcName, strlen(funcName) + 1); - list->index[list->count] = i; - list->count++; - *ptr_idx = i; - return true; - } - 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?"); - return false; -} - -static bool loader_name_in_phys_dev_ext_table(struct loader_instance *inst, uint32_t *idx, const char *funcName) { - uint32_t alt_idx; - if (inst->phys_dev_ext_disp_hash[*idx].func_name && !strcmp(inst->phys_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) - for (uint32_t i = 0; i < inst->phys_dev_ext_disp_hash[*idx].list.count; i++) { - alt_idx = inst->phys_dev_ext_disp_hash[*idx].list.index[i]; - if (!strcmp(inst->phys_dev_ext_disp_hash[*idx].func_name, funcName)) { - *idx = alt_idx; - return true; - } - } - - return false; -} - -// This function returns a generic trampoline and/or terminator function -// address for any unknown physical device extension commands. A hash -// table is used to keep a list of unknown entry points and their -// mapping to the physical device extension dispatch table (struct -// loader_phys_dev_ext_dispatch_table). -// For a given entry point string (funcName), if an existing mapping is -// found, then the trampoline address for that mapping is returned in -// tramp_addr (if it is not NULL) and the terminator address for that -// mapping is returned in term_addr (if it is not NULL). Otherwise, -// this unknown entry point has not been seen yet. -// If it has not been seen before, and perform_checking is 'true', -// check if a layer or and ICD supports it. If so then a new entry in -// the hash table is initialized and the trampoline and/or terminator -// addresses are returned. -// Null is returned if the hash table is full or if no discovered layer or -// ICD returns a non-NULL GetProcAddr for it. -bool loader_phys_dev_ext_gpa(struct loader_instance *inst, const char *funcName, bool perform_checking, void **tramp_addr, - void **term_addr) { - uint32_t idx; - uint32_t seed = 0; - bool success = false; - - if (inst == NULL) { - goto out; - } - - if (NULL != tramp_addr) { - *tramp_addr = NULL; - } - if (NULL != term_addr) { - *term_addr = NULL; - } - - // We should always check to see if any ICD supports it. - if (!loader_check_icds_for_phys_dev_ext_address(inst, funcName)) { - // If we're not checking layers, or we are and it's not in a layer, just - // return - if (!perform_checking || !loader_check_layer_list_for_phys_dev_ext_address(inst, funcName)) { - goto out; - } - } - - idx = murmurhash(funcName, strlen(funcName), seed) % MAX_NUM_UNKNOWN_EXTS; - if (perform_checking && !loader_name_in_phys_dev_ext_table(inst, &idx, funcName)) { - uint32_t i; - bool added = false; - - // Only need to add first one to get index in Instance. Others will use - // the same index. - if (!added && loader_add_phys_dev_ext_table(inst, &idx, funcName)) { - added = true; - } - - // Setup the ICD function pointers - struct loader_icd_term *icd_term = inst->icd_terms; - while (NULL != icd_term) { - if (MIN_PHYS_DEV_EXTENSION_ICD_INTERFACE_VERSION <= icd_term->scanned_icd->interface_version && - NULL != icd_term->scanned_icd->GetPhysicalDeviceProcAddr) { - icd_term->phys_dev_ext[idx] = - (PFN_PhysDevExt)icd_term->scanned_icd->GetPhysicalDeviceProcAddr(icd_term->instance, funcName); - - // Make sure we set the instance dispatch to point to the - // loader's terminator now since we can at least handle it - // in one ICD. - inst->disp->phys_dev_ext[idx] = loader_get_phys_dev_ext_termin(idx); - } else { - icd_term->phys_dev_ext[idx] = NULL; - } - - icd_term = icd_term->next; - } - - // Now, search for the first layer attached and query using it to get - // the first entry point. - for (i = 0; i < inst->expanded_activated_layer_list.count; i++) { - struct loader_layer_properties *layer_prop = &inst->expanded_activated_layer_list.list[i]; - if (layer_prop->interface_version > 1 && NULL != layer_prop->functions.get_physical_device_proc_addr) { - inst->disp->phys_dev_ext[idx] = - (PFN_PhysDevExt)layer_prop->functions.get_physical_device_proc_addr((VkInstance)inst->instance, funcName); - if (NULL != inst->disp->phys_dev_ext[idx]) { - break; - } - } - } - } - - if (NULL != tramp_addr) { - *tramp_addr = loader_get_phys_dev_ext_tramp(idx); - } - - if (NULL != term_addr) { - *term_addr = loader_get_phys_dev_ext_termin(idx); - } - - success = true; - -out: - return success; -} - -struct loader_instance *loader_get_instance(const VkInstance instance) { - // look up the loader_instance in our list by comparing dispatch tables, as - // there is no guarantee the instance is still a loader_instance* after any - // layers which wrap the instance object. - const VkLayerInstanceDispatchTable *disp; - struct loader_instance *ptr_instance = NULL; - disp = loader_get_instance_layer_dispatch(instance); - for (struct loader_instance *inst = loader.instances; inst; inst = inst->next) { - if (&inst->disp->layer_inst_disp == disp) { - ptr_instance = inst; - break; - } - } - return ptr_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_platform_open_library_error(prop->lib_name)); - } else { - loader_log(inst, VK_DEBUG_REPORT_DEBUG_BIT_EXT, 0, "Loading layer library %s", prop->lib_name); - } - - return prop->lib_handle; -} - -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); - prop->lib_handle = NULL; - } -} - -void loader_deactivate_layers(const struct loader_instance *instance, struct loader_device *device, - struct loader_layer_list *list) { - // Delete instance list of enabled layers and close any layer libraries - for (uint32_t i = 0; i < list->count; i++) { - struct loader_layer_properties *layer_prop = &list->list[i]; - - loader_close_layer_lib(instance, layer_prop); - } - loader_destroy_layer_list(instance, device, list); -} - -// Go through the search_list and find any layers which match type. If layer -// type match is found in then add it to ext_list. -static void loader_add_implicit_layers(const struct loader_instance *inst, struct loader_layer_list *target_list, - struct loader_layer_list *expanded_target_list, - const struct loader_layer_list *source_list) { - for (uint32_t src_layer = 0; src_layer < source_list->count; src_layer++) { - const struct loader_layer_properties *prop = &source_list->list[src_layer]; - if (0 == (prop->type_flags & VK_LAYER_TYPE_FLAG_EXPLICIT_LAYER)) { - loader_add_implicit_layer(inst, prop, target_list, expanded_target_list, source_list); - } - } -} - -// Get the layer name(s) from the env_name environment variable. If layer is found in -// search_list then add it to layer_list. But only add it to layer_list if type_flags matches. -static void loader_add_env_layers(const struct loader_instance *inst, const enum layer_type_flags type_flags, const char *env_name, - struct loader_layer_list *target_list, struct loader_layer_list *expanded_target_list, - const struct loader_layer_list *source_list) { - char *next, *name; - char *layer_env = loader_secure_getenv(env_name, inst); - if (layer_env == NULL) { - goto out; - } - name = loader_stack_alloc(strlen(layer_env) + 1); - if (name == NULL) { - goto out; - } - strcpy(name, layer_env); - - while (name && *name) { - next = loader_get_next_path(name); - loader_find_layer_name_add_list(inst, name, type_flags, source_list, target_list, expanded_target_list); - name = next; - } - -out: - - if (layer_env != NULL) { - loader_free_getenv(layer_env, inst); - } - - return; -} - -VkResult loader_enable_instance_layers(struct loader_instance *inst, const VkInstanceCreateInfo *pCreateInfo, - const struct loader_layer_list *instance_layers) { - VkResult err; - - assert(inst && "Cannot have null instance"); - - if (!loader_init_layer_list(inst, &inst->app_activated_layer_list)) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "loader_enable_instance_layers: Failed to initialize" - " application version of the layer list"); - return VK_ERROR_OUT_OF_HOST_MEMORY; - } - - if (!loader_init_layer_list(inst, &inst->expanded_activated_layer_list)) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "loader_enable_instance_layers: Failed to initialize" - " expanded version of the layer list"); - return VK_ERROR_OUT_OF_HOST_MEMORY; - } - - // Add any implicit layers first - loader_add_implicit_layers(inst, &inst->app_activated_layer_list, &inst->expanded_activated_layer_list, instance_layers); - - // Add any layers specified via environment variable next - loader_add_env_layers(inst, VK_LAYER_TYPE_FLAG_EXPLICIT_LAYER, ENABLED_LAYERS_ENV, &inst->app_activated_layer_list, - &inst->expanded_activated_layer_list, instance_layers); - - // Add layers specified by the application - err = loader_add_layer_names_to_list(inst, &inst->app_activated_layer_list, &inst->expanded_activated_layer_list, - pCreateInfo->enabledLayerCount, pCreateInfo->ppEnabledLayerNames, instance_layers); - - return err; -} - -// 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)); - interface_struct->sType = LAYER_NEGOTIATE_INTERFACE_STRUCT; - interface_struct->loaderLayerInterfaceVersion = 1; - - if (fp_negotiate_layer_version != NULL) { - // Layer supports the negotiation API, so call it with the loader's - // latest version supported - interface_struct->loaderLayerInterfaceVersion = CURRENT_LOADER_LAYER_INTERFACE_VERSION; - VkResult result = fp_negotiate_layer_version(interface_struct); - - if (result != VK_SUCCESS) { - // Layer no longer supports the loader's latest interface version so - // fail loading the Layer - return false; - } - } - - if (interface_struct->loaderLayerInterfaceVersion < MIN_SUPPORTED_LOADER_LAYER_INTERFACE_VERSION) { - // Loader no longer supports the layer's latest interface version so - // fail loading the layer - return false; - } - - return true; -} - -// Given the list of layers to activate in the loader_instance -// structure. This function will add a VkLayerInstanceCreateInfo -// structure to the VkInstanceCreateInfo.pNext pointer. -// Each activated layer will have it's own VkLayerInstanceLink -// structure that tells the layer what Get*ProcAddr to call to -// get function pointers to the next layer down. -// Once the chain info has been created this function will -// execute the CreateInstance call chain. Each layer will -// then have an opportunity in it's CreateInstance function -// to setup it's dispatch table when the lower layer returns -// successfully. -// Each layer can wrap or not-wrap the returned VkInstance object -// as it sees fit. -// The instance chain is terminated by a loader function -// that will call CreateInstance on all available ICD's and -// cache those VkInstance objects for future use. -VkResult loader_create_instance_chain(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, - struct loader_instance *inst, VkInstance *created_instance) { - uint32_t activated_layers = 0; - VkLayerInstanceCreateInfo chain_info; - VkLayerInstanceLink *layer_instance_link_info = NULL; - VkInstanceCreateInfo loader_create_info; - VkResult res; - - PFN_vkGetInstanceProcAddr next_gipa = loader_gpa_instance_internal; - PFN_vkGetInstanceProcAddr cur_gipa = loader_gpa_instance_internal; - PFN_GetPhysicalDeviceProcAddr next_gpdpa = loader_gpdpa_instance_internal; - PFN_GetPhysicalDeviceProcAddr cur_gpdpa = loader_gpdpa_instance_internal; - - memcpy(&loader_create_info, pCreateInfo, sizeof(VkInstanceCreateInfo)); - - if (inst->expanded_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; - chain_info.function = VK_LAYER_LINK_INFO; - loader_create_info.pNext = &chain_info; - - layer_instance_link_info = loader_stack_alloc(sizeof(VkLayerInstanceLink) * inst->expanded_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"); - return VK_ERROR_OUT_OF_HOST_MEMORY; - } - - // Create instance chain of enabled layers - for (int32_t i = inst->expanded_activated_layer_list.count - 1; i >= 0; i--) { - struct loader_layer_properties *layer_prop = &inst->expanded_activated_layer_list.list[i]; - loader_platform_dl_handle lib_handle; - - lib_handle = loader_open_layer_lib(inst, "instance", layer_prop); - if (!lib_handle) { - continue; - } - - if (NULL == layer_prop->functions.negotiate_layer_interface) { - PFN_vkNegotiateLoaderLayerInterfaceVersion negotiate_interface = NULL; - bool functions_in_interface = false; - if (strlen(layer_prop->functions.str_negotiate_interface) == 0) { - negotiate_interface = (PFN_vkNegotiateLoaderLayerInterfaceVersion)loader_platform_get_proc_address( - lib_handle, "vkNegotiateLoaderLayerInterfaceVersion"); - } else { - negotiate_interface = (PFN_vkNegotiateLoaderLayerInterfaceVersion)loader_platform_get_proc_address( - lib_handle, layer_prop->functions.str_negotiate_interface); - } - - // If we can negotiate an interface version, then we can also - // get everything we need from the one function call, so try - // that first, and see if we can get all the function pointers - // necessary from that one call. - if (NULL != negotiate_interface) { - layer_prop->functions.negotiate_layer_interface = negotiate_interface; - - VkNegotiateLayerInterface interface_struct; - - if (loader_get_layer_interface_version(negotiate_interface, &interface_struct)) { - // Go ahead and set the properties version to the - // correct value. - layer_prop->interface_version = interface_struct.loaderLayerInterfaceVersion; - - // If the interface is 2 or newer, we have access to the - // new GetPhysicalDeviceProcAddr function, so grab it, - // and the other necessary functions, from the - // structure. - if (interface_struct.loaderLayerInterfaceVersion > 1) { - cur_gipa = interface_struct.pfnGetInstanceProcAddr; - cur_gpdpa = interface_struct.pfnGetPhysicalDeviceProcAddr; - if (cur_gipa != NULL) { - // We've set the functions, so make sure we - // don't do the unnecessary calls later. - functions_in_interface = true; - } - } - } - } - - if (!functions_in_interface) { - if ((cur_gipa = layer_prop->functions.get_instance_proc_addr) == NULL) { - if (strlen(layer_prop->functions.str_gipa) == 0) { - cur_gipa = - (PFN_vkGetInstanceProcAddr)loader_platform_get_proc_address(lib_handle, "vkGetInstanceProcAddr"); - layer_prop->functions.get_instance_proc_addr = cur_gipa; - } else { - cur_gipa = (PFN_vkGetInstanceProcAddr)loader_platform_get_proc_address(lib_handle, - layer_prop->functions.str_gipa); - } - - 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", - layer_prop->lib_name); - continue; - } - } - } - } - - layer_instance_link_info[activated_layers].pNext = chain_info.u.pLayerInfo; - layer_instance_link_info[activated_layers].pfnNextGetInstanceProcAddr = next_gipa; - layer_instance_link_info[activated_layers].pfnNextGetPhysicalDeviceProcAddr = next_gpdpa; - next_gipa = cur_gipa; - if (layer_prop->interface_version > 1 && cur_gpdpa != NULL) { - layer_prop->functions.get_physical_device_proc_addr = cur_gpdpa; - next_gpdpa = cur_gpdpa; - } - - chain_info.u.pLayerInfo = &layer_instance_link_info[activated_layers]; - - loader_log(inst, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, "Insert instance layer %s (%s)", layer_prop->info.layerName, - layer_prop->lib_name); - - activated_layers++; - } - } - - PFN_vkCreateInstance fpCreateInstance = (PFN_vkCreateInstance)next_gipa(*created_instance, "vkCreateInstance"); - if (fpCreateInstance) { - VkLayerInstanceCreateInfo create_info_disp; - - create_info_disp.sType = VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO; - create_info_disp.function = VK_LOADER_DATA_CALLBACK; - - create_info_disp.u.pfnSetInstanceLoaderData = vkSetInstanceDispatch; - - create_info_disp.pNext = loader_create_info.pNext; - 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\'"); - // Couldn't find CreateInstance function! - res = VK_ERROR_INITIALIZATION_FAILED; - } - - if (res == VK_SUCCESS) { - loader_init_instance_core_dispatch_table(&inst->disp->layer_inst_disp, next_gipa, *created_instance); - inst->instance = *created_instance; - } - - return res; -} - -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); -} - -VkResult loader_create_device_chain(const struct loader_physical_device_tramp *pd, const VkDeviceCreateInfo *pCreateInfo, - const VkAllocationCallbacks *pAllocator, const struct loader_instance *inst, - struct loader_device *dev) { - uint32_t activated_layers = 0; - VkLayerDeviceLink *layer_device_link_info; - VkLayerDeviceCreateInfo chain_info; - VkDeviceCreateInfo loader_create_info; - VkResult res; - - PFN_vkGetDeviceProcAddr fpGDPA = NULL, nextGDPA = loader_gpa_device_internal; - PFN_vkGetInstanceProcAddr fpGIPA = NULL, nextGIPA = loader_gpa_instance_internal; - - memcpy(&loader_create_info, pCreateInfo, sizeof(VkDeviceCreateInfo)); - - // Before we continue, we need to find out if the KHX_device_group extension is in the enabled list. If it is, we then - // need to look for the corresponding VkDeviceGroupDeviceCreateInfoKHX struct in the device list. This is because we - // need to replace all the incoming physical device values (which are really loader trampoline physical device values) - // with the layer/ICD version. - if (inst->enabled_known_extensions.khx_device_group_creation == 1) { - struct VkStructureHeader *pNext = (struct VkStructureHeader *)loader_create_info.pNext; - struct VkStructureHeader *pPrev = (struct VkStructureHeader *)&loader_create_info; - while (NULL != pNext) { - if (VK_STRUCTURE_TYPE_DEVICE_GROUP_DEVICE_CREATE_INFO_KHX == pNext->sType) { - VkDeviceGroupDeviceCreateInfoKHX *cur_struct = (VkDeviceGroupDeviceCreateInfoKHX *)pNext; - if (0 < cur_struct->physicalDeviceCount && NULL != cur_struct->pPhysicalDevices) { - VkDeviceGroupDeviceCreateInfoKHX *temp_struct = loader_stack_alloc(sizeof(VkDeviceGroupDeviceCreateInfoKHX)); - VkPhysicalDevice *phys_dev_array = NULL; - if (NULL == temp_struct) { - return VK_ERROR_OUT_OF_HOST_MEMORY; - } - memcpy(temp_struct, cur_struct, sizeof(VkDeviceGroupDeviceCreateInfoKHX)); - phys_dev_array = loader_stack_alloc(sizeof(VkPhysicalDevice) * cur_struct->physicalDeviceCount); - if (NULL == phys_dev_array) { - return VK_ERROR_OUT_OF_HOST_MEMORY; - } - - // Before calling down, replace the incoming physical device values (which are really loader trampoline - // physical devices) with the next layer (or possibly even the terminator) physical device values. - struct loader_physical_device_tramp *cur_tramp; - for (uint32_t phys_dev = 0; phys_dev < cur_struct->physicalDeviceCount; phys_dev++) { - cur_tramp = (struct loader_physical_device_tramp *)cur_struct->pPhysicalDevices[phys_dev]; - phys_dev_array[phys_dev] = cur_tramp->phys_dev; - } - temp_struct->pPhysicalDevices = phys_dev_array; - - // Replace the old struct in the pNext chain with this one. - pPrev->pNext = (const void *)temp_struct; - pNext = (struct VkStructureHeader *)(temp_struct); - } - break; - } - - pPrev = pNext; - pNext = (struct VkStructureHeader *)(pPrev->pNext); - } - } - - layer_device_link_info = loader_stack_alloc(sizeof(VkLayerDeviceLink) * dev->expanded_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."); - return VK_ERROR_OUT_OF_HOST_MEMORY; - } - - if (dev->expanded_activated_layer_list.count > 0) { - chain_info.sType = VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO; - chain_info.function = VK_LAYER_LINK_INFO; - chain_info.u.pLayerInfo = NULL; - chain_info.pNext = loader_create_info.pNext; - loader_create_info.pNext = &chain_info; - - // Create instance chain of enabled layers - for (int32_t i = dev->expanded_activated_layer_list.count - 1; i >= 0; i--) { - struct loader_layer_properties *layer_prop = &dev->expanded_activated_layer_list.list[i]; - loader_platform_dl_handle lib_handle; - bool functions_in_interface = false; - - lib_handle = loader_open_layer_lib(inst, "device", layer_prop); - if (!lib_handle) { - continue; - } - - // If we can negotiate an interface version, then we can also get everything we need from the one function - // call, so try that first, and see if we can get all the function pointers necessary from that one call. - if (NULL == layer_prop->functions.negotiate_layer_interface) { - PFN_vkNegotiateLoaderLayerInterfaceVersion negotiate_interface = NULL; - if (strlen(layer_prop->functions.str_negotiate_interface) == 0) { - negotiate_interface = (PFN_vkNegotiateLoaderLayerInterfaceVersion)loader_platform_get_proc_address( - lib_handle, "vkNegotiateLoaderLayerInterfaceVersion"); - } else { - negotiate_interface = (PFN_vkNegotiateLoaderLayerInterfaceVersion)loader_platform_get_proc_address( - lib_handle, layer_prop->functions.str_negotiate_interface); - } - - if (NULL != negotiate_interface) { - layer_prop->functions.negotiate_layer_interface = negotiate_interface; - - VkNegotiateLayerInterface interface_struct; - - if (loader_get_layer_interface_version(negotiate_interface, &interface_struct)) { - // Go ahead and set the properties version to the correct value. - layer_prop->interface_version = interface_struct.loaderLayerInterfaceVersion; - - // If the interface is 2 or newer, we have access to the new GetPhysicalDeviceProcAddr - // function, so grab it, and the other necessary functions, from the structure. - if (interface_struct.loaderLayerInterfaceVersion > 1) { - fpGIPA = interface_struct.pfnGetInstanceProcAddr; - fpGDPA = interface_struct.pfnGetDeviceProcAddr; - if (fpGIPA != NULL && fpGDPA) { - // We've set the functions, so make sure we - // don't do the unnecessary calls later. - functions_in_interface = true; - } - } - } - } - } - - if (!functions_in_interface) { - if ((fpGIPA = layer_prop->functions.get_instance_proc_addr) == NULL) { - if (strlen(layer_prop->functions.str_gipa) == 0) { - fpGIPA = (PFN_vkGetInstanceProcAddr)loader_platform_get_proc_address(lib_handle, "vkGetInstanceProcAddr"); - layer_prop->functions.get_instance_proc_addr = fpGIPA; - } else - 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.", - layer_prop->lib_name); - continue; - } - } - if ((fpGDPA = layer_prop->functions.get_device_proc_addr) == NULL) { - if (strlen(layer_prop->functions.str_gdpa) == 0) { - fpGDPA = (PFN_vkGetDeviceProcAddr)loader_platform_get_proc_address(lib_handle, "vkGetDeviceProcAddr"); - layer_prop->functions.get_device_proc_addr = fpGDPA; - } else - fpGDPA = - (PFN_vkGetDeviceProcAddr)loader_platform_get_proc_address(lib_handle, layer_prop->functions.str_gdpa); - if (!fpGDPA) { - loader_log(inst, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, "Failed to find vkGetDeviceProcAddr in layer %s", - layer_prop->lib_name); - continue; - } - } - } - layer_device_link_info[activated_layers].pNext = chain_info.u.pLayerInfo; - layer_device_link_info[activated_layers].pfnNextGetInstanceProcAddr = nextGIPA; - layer_device_link_info[activated_layers].pfnNextGetDeviceProcAddr = nextGDPA; - chain_info.u.pLayerInfo = &layer_device_link_info[activated_layers]; - nextGIPA = fpGIPA; - nextGDPA = fpGDPA; - - loader_log(inst, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, "Inserted device layer %s (%s)", layer_prop->info.layerName, - layer_prop->lib_name); - - activated_layers++; - } - } - - VkDevice created_device = (VkDevice)dev; - PFN_vkCreateDevice fpCreateDevice = (PFN_vkCreateDevice)nextGIPA(inst->instance, "vkCreateDevice"); - if (fpCreateDevice) { - VkLayerDeviceCreateInfo create_info_disp; - - create_info_disp.sType = VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO; - create_info_disp.function = VK_LOADER_DATA_CALLBACK; - - create_info_disp.u.pfnSetDeviceLoaderData = vkSetDeviceDispatch; - - create_info_disp.pNext = loader_create_info.pNext; - loader_create_info.pNext = &create_info_disp; - res = fpCreateDevice(pd->phys_dev, &loader_create_info, pAllocator, &created_device); - if (res != VK_SUCCESS) { - return res; - } - 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"); - // Couldn't find CreateDevice function! - return VK_ERROR_INITIALIZATION_FAILED; - } - - // Initialize device dispatch table - loader_init_device_dispatch_table(&dev->loader_dispatch, nextGDPA, dev->chain_device); - - return res; -} - -VkResult loader_validate_layers(const struct loader_instance *inst, const uint32_t layer_count, - const char *const *ppEnabledLayerNames, const struct loader_layer_list *list) { - struct loader_layer_properties *prop; - - 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"); - return VK_ERROR_LAYER_NOT_PRESENT; - } - - prop = loader_get_layer_property(ppEnabledLayerNames[i], list); - if (NULL == 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", i); - return VK_ERROR_LAYER_NOT_PRESENT; - } - } - return VK_SUCCESS; -} - -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; - char *env_value; - bool check_if_known = true; - VkResult res = VK_SUCCESS; - - struct loader_layer_list active_layers; - struct loader_layer_list expanded_layers; - memset(&active_layers, 0, sizeof(active_layers)); - memset(&expanded_layers, 0, sizeof(expanded_layers)); - if (!loader_init_layer_list(inst, &active_layers)) { - res = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - if (!loader_init_layer_list(inst, &expanded_layers)) { - res = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - - // Build the lists of active layers (including metalayers) and expanded layers (with metalayers resolved to their components) - loader_add_implicit_layers(inst, &active_layers, &expanded_layers, instance_layers); - loader_add_env_layers(inst, VK_LAYER_TYPE_FLAG_EXPLICIT_LAYER, ENABLED_LAYERS_ENV, &active_layers, &expanded_layers, - instance_layers); - res = loader_add_layer_names_to_list(inst, &active_layers, &expanded_layers, pCreateInfo->enabledLayerCount, - pCreateInfo->ppEnabledLayerNames, instance_layers); - if (VK_SUCCESS != res) { - goto out; - } - - 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"); - res = VK_ERROR_EXTENSION_NOT_PRESENT; - goto out; - } - - // Check if a user wants to disable the instance extension filtering behavior - env_value = loader_getenv("VK_LOADER_DISABLE_INST_EXT_FILTER", inst); - if (NULL != env_value && atoi(env_value) != 0) { - check_if_known = false; - } - loader_free_getenv(env_value, inst); - - if (check_if_known) { - // See if the extension is in the list of supported extensions - bool found = false; - for (uint32_t j = 0; LOADER_INSTANCE_EXTENSIONS[j] != NULL; j++) { - if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], LOADER_INSTANCE_EXTENSIONS[j]) == 0) { - found = true; - break; - } - } - - // 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 %s not found in list of known instance extensions.", - pCreateInfo->ppEnabledExtensionNames[i]); - res = VK_ERROR_EXTENSION_NOT_PRESENT; - goto out; - } - } - - extension_prop = get_extension_property(pCreateInfo->ppEnabledExtensionNames[i], icd_exts); - - if (extension_prop) { - continue; - } - - extension_prop = NULL; - - // Not in global list, search expanded layer extension list - for (uint32_t j = 0; NULL == extension_prop && j < expanded_layers.count; ++j) { - extension_prop = - get_extension_property(pCreateInfo->ppEnabledExtensionNames[i], &expanded_layers.list[j].instance_extension_list); - } - - 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: Instance extension %s not supported by available ICDs or enabled " - "layers.", - pCreateInfo->ppEnabledExtensionNames[i]); - res = VK_ERROR_EXTENSION_NOT_PRESENT; - goto out; - } - } - -out: - loader_destroy_layer_list(inst, NULL, &active_layers); - loader_destroy_layer_list(inst, NULL, &expanded_layers); - return res; -} - -VkResult loader_validate_device_extensions(struct loader_physical_device_tramp *phys_dev, - const struct loader_layer_list *activated_device_layers, - const struct loader_extension_list *icd_exts, const VkDeviceCreateInfo *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(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; - } - - const char *extension_name = pCreateInfo->ppEnabledExtensionNames[i]; - extension_prop = get_extension_property(extension_name, icd_exts); - - if (extension_prop) { - continue; - } - - // Not in global list, search activated layer extension lists - for (uint32_t j = 0; j < activated_device_layers->count; j++) { - layer_prop = &activated_device_layers->list[j]; - - extension_prop = get_dev_extension_property(extension_name, &layer_prop->device_extension_list); - if (extension_prop) { - // Found the extension in one of the layers enabled by the app. - break; - } - } - - 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: Device extension %s not supported by selected physical device " - "or enabled layers.", - pCreateInfo->ppEnabledExtensionNames[i]); - return VK_ERROR_EXTENSION_NOT_PRESENT; - } - } - return VK_SUCCESS; -} - -// Terminator functions for the Instance chain -// All named terminator_ -VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateInstance(const VkInstanceCreateInfo *pCreateInfo, - const VkAllocationCallbacks *pAllocator, VkInstance *pInstance) { - struct loader_icd_term *icd_term; - VkExtensionProperties *prop; - char **filtered_extension_names = NULL; - VkInstanceCreateInfo icd_create_info; - VkResult res = VK_SUCCESS; - bool one_icd_successful = false; - - struct loader_instance *ptr_instance = (struct loader_instance *)*pInstance; - memcpy(&icd_create_info, pCreateInfo, sizeof(icd_create_info)); - - icd_create_info.enabledLayerCount = 0; - icd_create_info.ppEnabledLayerNames = NULL; - - // NOTE: Need to filter the extensions to only those supported by the ICD. - // No ICD will advertise support for layers. An ICD library could - // support a layer, but it would be independent of the actual ICD, - // 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", - pCreateInfo->enabledExtensionCount); - res = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - icd_create_info.ppEnabledExtensionNames = (const char *const *)filtered_extension_names; - - 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.", i); - res = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - - // If any error happens after here, we need to remove the ICD from the list, - // because we've already added it, but haven't validated it - - icd_create_info.enabledExtensionCount = 0; - struct loader_extension_list icd_exts; - - loader_log(ptr_instance, VK_DEBUG_REPORT_DEBUG_BIT_EXT, 0, "Build ICD instance extension list"); - // traverse scanned icd list adding non-duplicate extensions to the list - res = loader_init_generic_list(ptr_instance, (struct loader_generic_list *)&icd_exts, sizeof(VkExtensionProperties)); - if (VK_ERROR_OUT_OF_HOST_MEMORY == res) { - // If out of memory, bail immediately. - goto out; - } else if (VK_SUCCESS != res) { - // Something bad happened with this ICD, so free it and try the - // next. - ptr_instance->icd_terms = icd_term->next; - icd_term->next = NULL; - loader_icd_destroy(ptr_instance, icd_term, pAllocator); - continue; - } - - res = loader_add_instance_extensions(ptr_instance, icd_term->scanned_icd->EnumerateInstanceExtensionProperties, - icd_term->scanned_icd->lib_name, &icd_exts); - if (VK_SUCCESS != res) { - loader_destroy_generic_list(ptr_instance, (struct loader_generic_list *)&icd_exts); - if (VK_ERROR_OUT_OF_HOST_MEMORY == res) { - // If out of memory, bail immediately. - goto out; - } else { - // Something bad happened with this ICD, so free it and try the next. - ptr_instance->icd_terms = icd_term->next; - icd_term->next = NULL; - loader_icd_destroy(ptr_instance, icd_term, pAllocator); - continue; - } - } - - for (uint32_t j = 0; j < pCreateInfo->enabledExtensionCount; j++) { - prop = get_extension_property(pCreateInfo->ppEnabledExtensionNames[j], &icd_exts); - if (prop) { - filtered_extension_names[icd_create_info.enabledExtensionCount] = (char *)pCreateInfo->ppEnabledExtensionNames[j]; - icd_create_info.enabledExtensionCount++; - } - } - - loader_destroy_generic_list(ptr_instance, (struct loader_generic_list *)&icd_exts); - - VkResult icd_result = - ptr_instance->icd_tramp_list.scanned_list[i].CreateInstance(&icd_create_info, pAllocator, &(icd_term->instance)); - if (VK_ERROR_OUT_OF_HOST_MEMORY == icd_result) { - // If out of memory, bail immediately. - 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.", - i); - ptr_instance->icd_terms = icd_term->next; - icd_term->next = NULL; - loader_icd_destroy(ptr_instance, icd_term, pAllocator); - continue; - } - - if (!loader_icd_init_entries(icd_term, icd_term->instance, - ptr_instance->icd_tramp_list.scanned_list[i].GetInstanceProcAddr)) { - loader_log(ptr_instance, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, - "terminator_CreateInstance: Failed to CreateInstance and find " - "entrypoints with ICD. Skipping ICD."); - ptr_instance->icd_terms = icd_term->next; - icd_term->next = NULL; - loader_icd_destroy(ptr_instance, icd_term, pAllocator); - continue; - } - - // If we made it this far, at least one ICD was successful - one_icd_successful = true; - } - - // If no ICDs were added to instance list and res is unchanged from it's initial value, the loader was unable to - // find a suitable ICD. - if (VK_SUCCESS == res && (ptr_instance->icd_terms == NULL || !one_icd_successful)) { - res = VK_ERROR_INCOMPATIBLE_DRIVER; - } - -out: - - if (VK_SUCCESS != res) { - while (NULL != ptr_instance->icd_terms) { - icd_term = ptr_instance->icd_terms; - ptr_instance->icd_terms = icd_term->next; - if (NULL != icd_term->instance) { - icd_term->dispatch.DestroyInstance(icd_term->instance, pAllocator); - } - loader_icd_destroy(ptr_instance, icd_term, pAllocator); - } - } - - return res; -} - -VKAPI_ATTR void VKAPI_CALL terminator_DestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) { - struct loader_instance *ptr_instance = loader_instance(instance); - if (NULL == ptr_instance) { - return; - } - struct loader_icd_term *icd_terms = ptr_instance->icd_terms; - struct loader_icd_term *next_icd_term; - - // Remove this instance from the list of instances: - struct loader_instance *prev = NULL; - struct loader_instance *next = loader.instances; - while (next != NULL) { - if (next == ptr_instance) { - // Remove this instance from the list: - if (prev) - prev->next = next->next; - else - loader.instances = next->next; - break; - } - prev = next; - next = next->next; - } - - while (NULL != icd_terms) { - if (icd_terms->instance) { - icd_terms->dispatch.DestroyInstance(icd_terms->instance, pAllocator); - } - next_icd_term = icd_terms->next; - icd_terms->instance = VK_NULL_HANDLE; - loader_icd_destroy(ptr_instance, icd_terms, pAllocator); - - icd_terms = next_icd_term; - } - - loader_delete_layer_properties(ptr_instance, &ptr_instance->instance_layer_list); - loader_scanned_icd_clear(ptr_instance, &ptr_instance->icd_tramp_list); - loader_destroy_generic_list(ptr_instance, (struct loader_generic_list *)&ptr_instance->ext_list); - if (NULL != ptr_instance->phys_devs_term) { - for (uint32_t i = 0; i < ptr_instance->phys_dev_count_term; i++) { - loader_instance_heap_free(ptr_instance, ptr_instance->phys_devs_term[i]); - } - loader_instance_heap_free(ptr_instance, ptr_instance->phys_devs_term); - } - if (NULL != ptr_instance->phys_dev_groups_term) { - for (uint32_t i = 0; i < ptr_instance->phys_dev_group_count_term; i++) { - loader_instance_heap_free(ptr_instance, ptr_instance->phys_dev_groups_term[i]); - } - loader_instance_heap_free(ptr_instance, ptr_instance->phys_dev_groups_term); - } - loader_free_dev_ext_table(ptr_instance); - loader_free_phys_dev_ext_table(ptr_instance); -} - -VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo, - const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) { - VkResult res = VK_SUCCESS; - struct loader_physical_device_term *phys_dev_term; - phys_dev_term = (struct loader_physical_device_term *)physicalDevice; - struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; - - struct loader_device *dev = (struct loader_device *)*pDevice; - PFN_vkCreateDevice fpCreateDevice = icd_term->dispatch.CreateDevice; - struct loader_extension_list icd_exts; - - struct VkStructureHeader *caller_dgci_container = NULL; - VkDeviceGroupDeviceCreateInfoKHX *caller_dgci = NULL; - - dev->phys_dev_term = phys_dev_term; - - icd_exts.list = NULL; - - if (fpCreateDevice == NULL) { - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "terminator_CreateDevice: No vkCreateDevice command exposed " - "by ICD %s", - icd_term->scanned_icd->lib_name); - res = VK_ERROR_INITIALIZATION_FAILED; - goto out; - } - - VkDeviceCreateInfo localCreateInfo; - memcpy(&localCreateInfo, pCreateInfo, sizeof(localCreateInfo)); - - // NOTE: Need to filter the extensions to only those supported by the ICD. - // No ICD will advertise support for layers. An ICD library could support a layer, - // but it would be independent of the actual ICD, just in the same library. - char **filtered_extension_names = NULL; - if (0 < pCreateInfo->enabledExtensionCount) { - filtered_extension_names = loader_stack_alloc(pCreateInfo->enabledExtensionCount * sizeof(char *)); - if (NULL == filtered_extension_names) { - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "terminator_CreateDevice: Failed to create extension name " - "storage for %d extensions %d", - pCreateInfo->enabledExtensionCount); - return VK_ERROR_OUT_OF_HOST_MEMORY; - } - } - - localCreateInfo.enabledLayerCount = 0; - localCreateInfo.ppEnabledLayerNames = NULL; - - localCreateInfo.enabledExtensionCount = 0; - localCreateInfo.ppEnabledExtensionNames = (const char *const *)filtered_extension_names; - - // Get the physical device (ICD) extensions - res = loader_init_generic_list(icd_term->this_instance, (struct loader_generic_list *)&icd_exts, sizeof(VkExtensionProperties)); - if (VK_SUCCESS != res) { - goto out; - } - - res = loader_add_device_extensions(icd_term->this_instance, icd_term->dispatch.EnumerateDeviceExtensionProperties, - phys_dev_term->phys_dev, icd_term->scanned_icd->lib_name, &icd_exts); - if (res != VK_SUCCESS) { - goto out; - } - - for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { - const char *extension_name = pCreateInfo->ppEnabledExtensionNames[i]; - VkExtensionProperties *prop = get_extension_property(extension_name, &icd_exts); - if (prop) { - filtered_extension_names[localCreateInfo.enabledExtensionCount] = (char *)extension_name; - localCreateInfo.enabledExtensionCount++; - } else { - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_DEBUG_BIT_EXT, 0, - "vkCreateDevice extension %s not available for " - "devices associated with ICD %s", - extension_name, icd_term->scanned_icd->lib_name); - } - } - - // Before we continue, If KHX_device_group is the list of enabled and viable extensions, then we then need to look for the - // corresponding VkDeviceGroupDeviceCreateInfoKHX struct in the device list and replace all the physical device values (which - // are really loader physical device terminator values) with the ICD versions. - if (icd_term->this_instance->enabled_known_extensions.khx_device_group_creation == 1) { - struct VkStructureHeader *pNext = (struct VkStructureHeader *)localCreateInfo.pNext; - struct VkStructureHeader *pPrev = (struct VkStructureHeader *)&localCreateInfo; - while (NULL != pNext) { - if (VK_STRUCTURE_TYPE_DEVICE_GROUP_DEVICE_CREATE_INFO_KHX == pNext->sType) { - VkDeviceGroupDeviceCreateInfoKHX *cur_struct = (VkDeviceGroupDeviceCreateInfoKHX *)pNext; - if (0 < cur_struct->physicalDeviceCount && NULL != cur_struct->pPhysicalDevices) { - VkDeviceGroupDeviceCreateInfoKHX *temp_struct = loader_stack_alloc(sizeof(VkDeviceGroupDeviceCreateInfoKHX)); - VkPhysicalDevice *phys_dev_array = NULL; - if (NULL == temp_struct) { - return VK_ERROR_OUT_OF_HOST_MEMORY; - } - memcpy(temp_struct, cur_struct, sizeof(VkDeviceGroupDeviceCreateInfoKHX)); - phys_dev_array = loader_stack_alloc(sizeof(VkPhysicalDevice) * cur_struct->physicalDeviceCount); - if (NULL == phys_dev_array) { - return VK_ERROR_OUT_OF_HOST_MEMORY; - } - - // Before calling down, replace the incoming physical device values (which are really loader terminator - // physical devices) with the ICDs physical device values. - struct loader_physical_device_term *cur_term; - for (uint32_t phys_dev = 0; phys_dev < cur_struct->physicalDeviceCount; phys_dev++) { - cur_term = (struct loader_physical_device_term *)cur_struct->pPhysicalDevices[phys_dev]; - phys_dev_array[phys_dev] = cur_term->phys_dev; - } - temp_struct->pPhysicalDevices = phys_dev_array; - - // Keep track of pointers to restore pNext chain before returning - caller_dgci_container = pPrev; - caller_dgci = cur_struct; - - // Replace the old struct in the pNext chain with this one. - pPrev->pNext = (const void *)temp_struct; - pNext = (struct VkStructureHeader *)(temp_struct); - } - break; - } - - pPrev = pNext; - pNext = (struct VkStructureHeader *)(pPrev->pNext); - } - } - - // Handle loader emulation for structs that are not supported by the ICD: - // Presently, the emulation leaves the pNext chain alone. This means that the ICD will receive items in the chain which - // are not recognized by the ICD. If this causes the ICD to fail, then the items would have to be removed here. The current - // implementation does not remove them because copying the pNext chain would be impossible if the loader does not recognize - // the any of the struct types, as the loader would not know the size to allocate and copy. - if (icd_term->dispatch.GetPhysicalDeviceFeatures2KHR == NULL) { - const void *pNext = localCreateInfo.pNext; - while (pNext != NULL) { - switch (*(VkStructureType *)pNext) { - case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2_KHR: { - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, - "vkCreateDevice: Emulating handling of VkPhysicalDeviceFeatures2KHR in pNext chain for ICD \"%s\"", - icd_term->scanned_icd->lib_name); - const VkPhysicalDeviceFeatures2KHR *features = pNext; - - // Verify that VK_KHR_get_physical_device_properties2 is enabled - if (icd_term->this_instance->enabled_known_extensions.khr_get_physical_device_properties2) { - localCreateInfo.pEnabledFeatures = &features->features; - } - - // Leave this item in the pNext chain for now - - pNext = features->pNext; - break; - } - - case VK_STRUCTURE_TYPE_DEVICE_GROUP_DEVICE_CREATE_INFO_KHX: { - loader_log( - icd_term->this_instance, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, - "vkCreateDevice: Emulating handling of VkDeviceGroupDeviceCreateInfoKHX in pNext chain for ICD \"%s\"", - icd_term->scanned_icd->lib_name); - const VkDeviceGroupDeviceCreateInfoKHX *group_info = pNext; - - // The group must contain only this one device, since physical device groups aren't actually supported - if (group_info->physicalDeviceCount != 1 || group_info->pPhysicalDevices[0] != physicalDevice) { - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "vkCreateDevice: Emulation failed to create device from device group info"); - res = VK_ERROR_INITIALIZATION_FAILED; - goto out; - } - - // Nothing needs to be done here because we're leaving the item in the pNext chain and because the spec states - // that the physicalDevice argument must be included in the device group, and we've already checked that it is - - pNext = group_info->pNext; - break; - } - - // Multiview properties are also allowed, but since VK_KHX_multiview is a device extension, we'll just let the ICD - // handle that error when the user enables the extension here - default: { - const struct VkStructureHeader *header = pNext; - pNext = header->pNext; - break; - } - } - } - } - - res = fpCreateDevice(phys_dev_term->phys_dev, &localCreateInfo, pAllocator, &dev->icd_device); - if (res != VK_SUCCESS) { - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "terminator_CreateDevice: Failed in ICD %s vkCreateDevice" - "call", - icd_term->scanned_icd->lib_name); - goto out; - } - - *pDevice = dev->icd_device; - loader_add_logical_device(icd_term->this_instance, icd_term, dev); - - // Init dispatch pointer in new device object - loader_init_dispatch(*pDevice, &dev->loader_dispatch); - -out: - if (NULL != icd_exts.list) { - loader_destroy_generic_list(icd_term->this_instance, (struct loader_generic_list *)&icd_exts); - } - - // Restore pNext pointer to old VkDeviceGroupDeviceCreateInfoKHX - // in the chain to maintain consistency for the caller. - if (caller_dgci_container != NULL) { - caller_dgci_container->pNext = caller_dgci; - } - - return res; -} - -VkResult setupLoaderTrampPhysDevs(VkInstance instance) { - VkResult res = VK_SUCCESS; - VkPhysicalDevice *local_phys_devs = NULL; - struct loader_instance *inst; - uint32_t total_count = 0; - struct loader_physical_device_tramp **new_phys_devs = NULL; - - inst = loader_get_instance(instance); - if (NULL == inst) { - res = VK_ERROR_INITIALIZATION_FAILED; - goto out; - } - - // Query how many GPUs there - res = inst->disp->layer_inst_disp.EnumeratePhysicalDevices(instance, &total_count, NULL); - if (res != VK_SUCCESS) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "setupLoaderTrampPhysDevs: Failed during dispatch call " - "of \'vkEnumeratePhysicalDevices\' to lower layers or " - "loader to get count."); - goto out; - } - - // Really use what the total GPU count is since Optimus and other layers may mess - // the count up. - total_count = inst->total_gpu_count; - - // Create an array for the new physical devices, which will be stored - // in the instance for the trampoline code. - 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", - total_count); - res = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - memset(new_phys_devs, 0, total_count * sizeof(struct loader_physical_device_tramp *)); - - // Create a temporary array (on the stack) to keep track of the - // 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", - total_count); - res = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - memset(local_phys_devs, 0, sizeof(VkPhysicalDevice) * total_count); - - 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 to get content."); - 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) { - new_phys_devs[new_idx] = inst->phys_devs_tramp[old_idx]; - break; - } - } - - // If this physical device isn't in the old buffer, create it - if (NULL == new_phys_devs[new_idx]) { - 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", - new_idx); - total_count = new_idx; - res = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - - // Initialize the new physicalDevice object - loader_set_dispatch((void *)new_phys_devs[new_idx], inst->disp); - new_phys_devs[new_idx]->this_instance = inst; - new_phys_devs[new_idx]->phys_dev = local_phys_devs[new_idx]; - } - } - -out: - - if (VK_SUCCESS != res) { - if (NULL != new_phys_devs) { - for (uint32_t i = 0; i < total_count; i++) { - loader_instance_heap_free(inst, new_phys_devs[i]); - } - loader_instance_heap_free(inst, new_phys_devs); - } - total_count = 0; - } else { - // Free everything that didn't carry over to the new array of - // physical devices - if (NULL != inst->phys_devs_tramp) { - for (uint32_t i = 0; i < inst->phys_dev_count_tramp; i++) { - bool found = false; - for (uint32_t j = 0; j < total_count; j++) { - if (inst->phys_devs_tramp[i] == new_phys_devs[j]) { - found = true; - break; - } - } - if (!found) { - loader_instance_heap_free(inst, inst->phys_devs_tramp[i]); - } - } - loader_instance_heap_free(inst, inst->phys_devs_tramp); - } - - // Swap in the new physical device list - inst->phys_dev_count_tramp = total_count; - inst->phys_devs_tramp = new_phys_devs; - } - - return res; -} - -VkResult setupLoaderTermPhysDevs(struct loader_instance *inst) { - VkResult res = VK_SUCCESS; - struct loader_icd_term *icd_term; - struct loader_phys_dev_per_icd *icd_phys_dev_array = NULL; - struct loader_physical_device_term **new_phys_devs = NULL; - - inst->total_gpu_count = 0; - - // Allocate something to store the physical device characteristics - // that we read from each ICD. - 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", - inst->total_gpu_count); - res = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - memset(icd_phys_dev_array, 0, sizeof(struct loader_phys_dev_per_icd) * inst->total_icd_count); - icd_term = inst->icd_terms; - - // For each ICD, query the number of physical devices, and then get an - // internal value for those physical devices. - for (uint32_t icd_idx = 0; NULL != icd_term; icd_term = icd_term->next, icd_idx++) { - res = icd_term->dispatch.EnumeratePhysicalDevices(icd_term->instance, &icd_phys_dev_array[icd_idx].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", - icd_idx, res); - goto out; - } - - icd_phys_dev_array[icd_idx].phys_devs = - (VkPhysicalDevice *)loader_stack_alloc(icd_phys_dev_array[icd_idx].count * sizeof(VkPhysicalDevice)); - if (NULL == icd_phys_dev_array[icd_idx].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", - icd_idx, inst->total_gpu_count); - res = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - - res = icd_term->dispatch.EnumeratePhysicalDevices(icd_term->instance, &(icd_phys_dev_array[icd_idx].count), - icd_phys_dev_array[icd_idx].phys_devs); - if (VK_SUCCESS != res) { - goto out; - } - inst->total_gpu_count += icd_phys_dev_array[icd_idx].count; - icd_phys_dev_array[icd_idx].this_icd_term = icd_term; - } - - 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"); - res = VK_ERROR_INITIALIZATION_FAILED; - goto out; - } - - 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", - inst->total_gpu_count); - res = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - memset(new_phys_devs, 0, sizeof(struct loader_physical_device_term *) * inst->total_gpu_count); - - // Copy or create everything to fill the new array of physical devices - 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++) { - if (icd_phys_dev_array[icd_idx].phys_devs[pd_idx] == inst->phys_devs_term[old_idx]->phys_dev) { - new_phys_devs[idx] = inst->phys_devs_term[old_idx]; - break; - } - } - } - // If this physical device isn't in the old buffer, then we - // need to create it. - if (NULL == new_phys_devs[idx]) { - 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", - idx); - inst->total_gpu_count = idx; - res = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - - loader_set_dispatch((void *)new_phys_devs[idx], inst->disp); - new_phys_devs[idx]->this_icd_term = icd_phys_dev_array[icd_idx].this_icd_term; - new_phys_devs[idx]->icd_index = (uint8_t)(icd_idx); - new_phys_devs[idx]->phys_dev = icd_phys_dev_array[icd_idx].phys_devs[pd_idx]; - } - idx++; - } - } - -out: - - if (VK_SUCCESS != res) { - if (NULL != new_phys_devs) { - // We've encountered an error, so we should free the new buffers. - for (uint32_t i = 0; i < inst->total_gpu_count; i++) { - loader_instance_heap_free(inst, new_phys_devs[i]); - } - loader_instance_heap_free(inst, new_phys_devs); - } - inst->total_gpu_count = 0; - } else { - // Free everything that didn't carry over to the new array of - // physical devices. Everything else will have been copied over - // to the new array. - if (NULL != inst->phys_devs_term) { - for (uint32_t cur_pd = 0; cur_pd < inst->phys_dev_count_term; cur_pd++) { - bool found = false; - for (uint32_t new_pd_idx = 0; new_pd_idx < inst->total_gpu_count; new_pd_idx++) { - if (inst->phys_devs_term[cur_pd] == new_phys_devs[new_pd_idx]) { - found = true; - break; - } - } - if (!found) { - loader_instance_heap_free(inst, inst->phys_devs_term[cur_pd]); - } - } - loader_instance_heap_free(inst, inst->phys_devs_term); - } - - // Swap out old and new devices list - inst->phys_dev_count_term = inst->total_gpu_count; - inst->phys_devs_term = new_phys_devs; - } - - return res; -} - -VKAPI_ATTR VkResult VKAPI_CALL terminator_EnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount, - VkPhysicalDevice *pPhysicalDevices) { - struct loader_instance *inst = (struct loader_instance *)instance; - VkResult res = VK_SUCCESS; - - // Always call the setup loader terminator physical devices because they may - // have changed at any point. - res = setupLoaderTermPhysDevs(inst); - if (VK_SUCCESS != res) { - goto out; - } - - uint32_t copy_count = inst->total_gpu_count; - if (NULL != pPhysicalDevices) { - if (copy_count > *pPhysicalDeviceCount) { - copy_count = *pPhysicalDeviceCount; - res = VK_INCOMPLETE; - } - - for (uint32_t i = 0; i < copy_count; i++) { - pPhysicalDevices[i] = (VkPhysicalDevice)inst->phys_devs_term[i]; - } - } - - *pPhysicalDeviceCount = copy_count; - -out: - - return res; -} - -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice, - VkPhysicalDeviceProperties *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; - if (NULL != icd_term->dispatch.GetPhysicalDeviceProperties) { - icd_term->dispatch.GetPhysicalDeviceProperties(phys_dev_term->phys_dev, pProperties); - } -} - -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice physicalDevice, - uint32_t *pQueueFamilyPropertyCount, - VkQueueFamilyProperties *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; - if (NULL != icd_term->dispatch.GetPhysicalDeviceQueueFamilyProperties) { - icd_term->dispatch.GetPhysicalDeviceQueueFamilyProperties(phys_dev_term->phys_dev, pQueueFamilyPropertyCount, pProperties); - } -} - -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceMemoryProperties(VkPhysicalDevice physicalDevice, - VkPhysicalDeviceMemoryProperties *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; - if (NULL != icd_term->dispatch.GetPhysicalDeviceMemoryProperties) { - icd_term->dispatch.GetPhysicalDeviceMemoryProperties(phys_dev_term->phys_dev, pProperties); - } -} - -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceFeatures(VkPhysicalDevice physicalDevice, - VkPhysicalDeviceFeatures *pFeatures) { - 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; - if (NULL != icd_term->dispatch.GetPhysicalDeviceFeatures) { - icd_term->dispatch.GetPhysicalDeviceFeatures(phys_dev_term->phys_dev, pFeatures); - } -} - -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, - VkFormatProperties *pFormatInfo) { - 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; - if (NULL != icd_term->dispatch.GetPhysicalDeviceFormatProperties) { - icd_term->dispatch.GetPhysicalDeviceFormatProperties(phys_dev_term->phys_dev, format, pFormatInfo); - } -} - -VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, - VkImageType type, VkImageTiling tiling, - VkImageUsageFlags usage, VkImageCreateFlags flags, - VkImageFormatProperties *pImageFormatProperties) { - 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; - if (NULL == icd_term->dispatch.GetPhysicalDeviceImageFormatProperties) { - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "Encountered the vkEnumerateDeviceLayerProperties " - "terminator. This means a layer improperly continued."); - return VK_ERROR_INITIALIZATION_FAILED; - } - return icd_term->dispatch.GetPhysicalDeviceImageFormatProperties(phys_dev_term->phys_dev, format, type, tiling, usage, flags, - pImageFormatProperties); -} - -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceSparseImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, - VkImageType type, VkSampleCountFlagBits samples, - VkImageUsageFlags usage, VkImageTiling tiling, - uint32_t *pNumProperties, - VkSparseImageFormatProperties *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; - if (NULL != icd_term->dispatch.GetPhysicalDeviceSparseImageFormatProperties) { - icd_term->dispatch.GetPhysicalDeviceSparseImageFormatProperties(phys_dev_term->phys_dev, format, type, samples, usage, - tiling, pNumProperties, pProperties); - } -} - -VKAPI_ATTR VkResult VKAPI_CALL terminator_EnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, - const char *pLayerName, uint32_t *pPropertyCount, - VkExtensionProperties *pProperties) { - struct loader_physical_device_term *phys_dev_term; - - struct loader_layer_list implicit_layer_list = {0}; - struct loader_extension_list all_exts = {0}; - struct loader_extension_list icd_exts = {0}; - - assert(pLayerName == NULL || strlen(pLayerName) == 0); - - // Any layer or trampoline wrapping should be removed at this point in time can just cast to the expected - // type for VkPhysicalDevice. - phys_dev_term = (struct loader_physical_device_term *)physicalDevice; - - // This case is during the call down the instance chain with pLayerName == NULL - struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; - uint32_t icd_ext_count = *pPropertyCount; - VkResult res; - - // Get the available device extensions - res = icd_term->dispatch.EnumerateDeviceExtensionProperties(phys_dev_term->phys_dev, NULL, &icd_ext_count, pProperties); - if (res != VK_SUCCESS) { - goto out; - } - - if (!loader_init_layer_list(icd_term->this_instance, &implicit_layer_list)) { - res = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - - loader_add_implicit_layers(icd_term->this_instance, &implicit_layer_list, NULL, &icd_term->this_instance->instance_layer_list); - // We need to determine which implicit layers are active, and then add their extensions. This can't be cached as - // it depends on results of environment variables (which can change). - if (pProperties != NULL) { - // Initialize dev_extension list within the physicalDevice object - res = loader_init_device_extensions(icd_term->this_instance, phys_dev_term, icd_ext_count, pProperties, &icd_exts); - if (res != VK_SUCCESS) { - goto out; - } - - // We need to determine which implicit layers are active, and then add their extensions. This can't be cached as - // it depends on results of environment variables (which can change). - res = loader_add_to_ext_list(icd_term->this_instance, &all_exts, icd_exts.count, icd_exts.list); - if (res != VK_SUCCESS) { - goto out; - } - - loader_add_implicit_layers(icd_term->this_instance, &implicit_layer_list, NULL, - &icd_term->this_instance->instance_layer_list); - - for (uint32_t i = 0; i < implicit_layer_list.count; i++) { - for (uint32_t j = 0; j < implicit_layer_list.list[i].device_extension_list.count; j++) { - res = loader_add_to_ext_list(icd_term->this_instance, &all_exts, 1, - &implicit_layer_list.list[i].device_extension_list.list[j].props); - if (res != VK_SUCCESS) { - goto out; - } - } - } - uint32_t capacity = *pPropertyCount; - VkExtensionProperties *props = pProperties; - - for (uint32_t i = 0; i < all_exts.count && i < capacity; i++) { - props[i] = all_exts.list[i]; - } - - // Wasn't enough space for the extensions, we did partial copy now return VK_INCOMPLETE - if (capacity < all_exts.count) { - res = VK_INCOMPLETE; - } else { - *pPropertyCount = all_exts.count; - } - } else { - // Just return the count; need to add in the count of implicit layer extensions - // don't worry about duplicates being added in the count - *pPropertyCount = icd_ext_count; - - for (uint32_t i = 0; i < implicit_layer_list.count; i++) { - *pPropertyCount += implicit_layer_list.list[i].device_extension_list.count; - } - res = VK_SUCCESS; - } - -out: - - if (NULL != implicit_layer_list.list) { - loader_destroy_generic_list(icd_term->this_instance, (struct loader_generic_list *)&implicit_layer_list); - } - if (NULL != all_exts.list) { - loader_destroy_generic_list(icd_term->this_instance, (struct loader_generic_list *)&all_exts); - } - if (NULL != icd_exts.list) { - loader_destroy_generic_list(icd_term->this_instance, (struct loader_generic_list *)&icd_exts); - } - - return res; -} - -VKAPI_ATTR VkResult VKAPI_CALL terminator_EnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount, - 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."); - // Should never get here this call isn't dispatched down the chain - return VK_ERROR_INITIALIZATION_FAILED; -} - -VkStringErrorFlags vk_string_validate(const int max_length, const char *utf8) { - VkStringErrorFlags result = VK_STRING_ERROR_NONE; - int num_char_bytes = 0; - int i, j; - - for (i = 0; i <= max_length; i++) { - if (utf8[i] == 0) { - break; - } else if (i == max_length) { - result |= VK_STRING_ERROR_LENGTH; - break; - } else if ((utf8[i] >= 0x20) && (utf8[i] < 0x7f)) { - num_char_bytes = 0; - } else if ((utf8[i] & UTF8_ONE_BYTE_MASK) == UTF8_ONE_BYTE_CODE) { - num_char_bytes = 1; - } else if ((utf8[i] & UTF8_TWO_BYTE_MASK) == UTF8_TWO_BYTE_CODE) { - num_char_bytes = 2; - } else if ((utf8[i] & UTF8_THREE_BYTE_MASK) == UTF8_THREE_BYTE_CODE) { - num_char_bytes = 3; - } else { - result = VK_STRING_ERROR_BAD_DATA; - } - - // Validate the following num_char_bytes of data - for (j = 0; (j < num_char_bytes) && (i < max_length); j++) { - if (++i == max_length) { - result |= VK_STRING_ERROR_LENGTH; - break; - } - if ((utf8[i] & UTF8_DATA_BYTE_MASK) != UTF8_DATA_BYTE_CODE) { - result |= VK_STRING_ERROR_BAD_DATA; - } - } - } - return result; -} - -VKAPI_ATTR VkResult VKAPI_CALL -terminator_EnumerateInstanceExtensionProperties(const VkEnumerateInstanceExtensionPropertiesChain *chain, const char *pLayerName, - uint32_t *pPropertyCount, VkExtensionProperties *pProperties) { - struct loader_extension_list *global_ext_list = NULL; - struct loader_layer_list instance_layers; - struct loader_extension_list local_ext_list; - struct loader_icd_tramp_list icd_tramp_list; - uint32_t copy_size; - VkResult res = VK_SUCCESS; - - // tls_instance = NULL; - memset(&local_ext_list, 0, sizeof(local_ext_list)); - memset(&instance_layers, 0, sizeof(instance_layers)); - - // 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"); - res = VK_ERROR_EXTENSION_NOT_PRESENT; - goto out; - } - - loader_layer_scan(NULL, &instance_layers); - for (uint32_t i = 0; i < instance_layers.count; i++) { - struct loader_layer_properties *props = &instance_layers.list[i]; - if (strcmp(props->info.layerName, pLayerName) == 0) { - global_ext_list = &props->instance_extension_list; - break; - } - } - } else { - // Scan/discover all ICD libraries - memset(&icd_tramp_list, 0, sizeof(icd_tramp_list)); - res = loader_icd_scan(NULL, &icd_tramp_list); - if (VK_SUCCESS != res) { - goto out; - } - // Get extensions from all ICD's, merge so no duplicates - res = loader_get_icd_loader_instance_extensions(NULL, &icd_tramp_list, &local_ext_list); - if (VK_SUCCESS != res) { - goto out; - } - loader_scanned_icd_clear(NULL, &icd_tramp_list); - - // Append enabled implicit layers. - loader_implicit_layer_scan(NULL, &instance_layers); - for (uint32_t i = 0; i < instance_layers.count; i++) { - if (!loader_is_implicit_layer_enabled(NULL, &instance_layers.list[i])) { - continue; - } - struct loader_extension_list *ext_list = &instance_layers.list[i].instance_extension_list; - loader_add_to_ext_list(NULL, &local_ext_list, ext_list->count, ext_list->list); - } - - global_ext_list = &local_ext_list; - } - - if (global_ext_list == NULL) { - res = VK_ERROR_LAYER_NOT_PRESENT; - goto out; - } - - if (pProperties == NULL) { - *pPropertyCount = global_ext_list->count; - goto out; - } - - copy_size = *pPropertyCount < global_ext_list->count ? *pPropertyCount : global_ext_list->count; - for (uint32_t i = 0; i < copy_size; i++) { - memcpy(&pProperties[i], &global_ext_list->list[i], sizeof(VkExtensionProperties)); - } - *pPropertyCount = copy_size; - - if (copy_size < global_ext_list->count) { - res = VK_INCOMPLETE; - goto out; - } - -out: - - loader_destroy_generic_list(NULL, (struct loader_generic_list *)&local_ext_list); - loader_delete_layer_properties(NULL, &instance_layers); - return res; -} - -VKAPI_ATTR VkResult VKAPI_CALL terminator_EnumerateInstanceLayerProperties(const VkEnumerateInstanceLayerPropertiesChain *chain, - uint32_t *pPropertyCount, - VkLayerProperties *pProperties) { - VkResult result = VK_SUCCESS; - struct loader_layer_list instance_layer_list; - tls_instance = NULL; - - LOADER_PLATFORM_THREAD_ONCE(&once_init, loader_initialize); - - uint32_t copy_size; - - // Get layer libraries - memset(&instance_layer_list, 0, sizeof(instance_layer_list)); - loader_layer_scan(NULL, &instance_layer_list); - - if (pProperties == NULL) { - *pPropertyCount = instance_layer_list.count; - goto out; - } - - copy_size = (*pPropertyCount < instance_layer_list.count) ? *pPropertyCount : instance_layer_list.count; - for (uint32_t i = 0; i < copy_size; i++) { - memcpy(&pProperties[i], &instance_layer_list.list[i].info, sizeof(VkLayerProperties)); - } - - *pPropertyCount = copy_size; - - if (copy_size < instance_layer_list.count) { - result = VK_INCOMPLETE; - goto out; - } - -out: - - loader_delete_layer_properties(NULL, &instance_layer_list); - return result; -} - -#if defined(_WIN32) && defined(LOADER_DYNAMIC_LIB) -BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID reserved) { - switch (reason) { - case DLL_PROCESS_ATTACH: - loader_initialize(); - break; - case DLL_PROCESS_DETACH: - if (NULL == reserved) { - loader_release(); - } - break; - default: - // Do nothing - break; - } - return TRUE; -} -#elif !defined(_WIN32) -__attribute__((constructor)) void loader_init_library() { loader_initialize(); } - -__attribute__((destructor)) void loader_free_library() { loader_release(); } -#endif diff --git a/third_party/vulkan/loader/loader.h b/third_party/vulkan/loader/loader.h deleted file mode 100644 index 58dfefedc..000000000 --- a/third_party/vulkan/loader/loader.h +++ /dev/null @@ -1,490 +0,0 @@ -/* - * - * Copyright (c) 2014-2017 The Khronos Group Inc. - * Copyright (c) 2014-2017 Valve Corporation - * Copyright (c) 2014-2017 LunarG, Inc. - * Copyright (C) 2015 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Author: Jon Ashburn - * Author: Courtney Goeltzenleuchter - * Author: Chia-I Wu - * Author: Chia-I Wu - * Author: Mark Lobodzinski - * - */ - -#ifndef LOADER_H -#define LOADER_H - -#include -#include "vk_loader_platform.h" -#include "vk_loader_layer.h" -#include -#include -#include -#include "vk_loader_extensions.h" - -#if defined(__GNUC__) && __GNUC__ >= 4 -#define LOADER_EXPORT __attribute__((visibility("default"))) -#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590) -#define LOADER_EXPORT __attribute__((visibility("default"))) -#else -#define LOADER_EXPORT -#endif - -// A debug option to disable allocators at compile time to investigate future issues. -#define DEBUG_DISABLE_APP_ALLOCATORS 0 - -#define MAX_STRING_SIZE 1024 - -// This is defined in vk_layer.h, but if there's problems we need to create the define -// here. -#ifndef MAX_NUM_UNKNOWN_EXTS -#define MAX_NUM_UNKNOWN_EXTS 250 -#endif - -enum layer_type_flags { - VK_LAYER_TYPE_FLAG_INSTANCE_LAYER = 0x1, // If not set, indicates Device layer - VK_LAYER_TYPE_FLAG_EXPLICIT_LAYER = 0x2, // If not set, indicates Implicit layer - VK_LAYER_TYPE_FLAG_META_LAYER = 0x4, // If not set, indicates standard layer -}; - -typedef enum VkStringErrorFlagBits { - VK_STRING_ERROR_NONE = 0x00000000, - VK_STRING_ERROR_LENGTH = 0x00000001, - VK_STRING_ERROR_BAD_DATA = 0x00000002, -} VkStringErrorFlagBits; -typedef VkFlags VkStringErrorFlags; - -static const int MaxLoaderStringLength = 256; -static const char UTF8_ONE_BYTE_CODE = 0xC0; -static const char UTF8_ONE_BYTE_MASK = 0xE0; -static const char UTF8_TWO_BYTE_CODE = 0xE0; -static const char UTF8_TWO_BYTE_MASK = 0xF0; -static const char UTF8_THREE_BYTE_CODE = 0xF0; -static const char UTF8_THREE_BYTE_MASK = 0xF8; -static const char UTF8_DATA_BYTE_CODE = 0x80; -static const char UTF8_DATA_BYTE_MASK = 0xC0; - -struct VkStructureHeader { - VkStructureType sType; - const void *pNext; -}; - -// form of all dynamic lists/arrays -// only the list element should be changed -struct loader_generic_list { - size_t capacity; - uint32_t count; - void *list; -}; - -struct loader_extension_list { - size_t capacity; - uint32_t count; - VkExtensionProperties *list; -}; - -struct loader_dev_ext_props { - VkExtensionProperties props; - uint32_t entrypoint_count; - char **entrypoints; -}; - -struct loader_device_extension_list { - size_t capacity; - uint32_t count; - struct loader_dev_ext_props *list; -}; - -struct loader_name_value { - char name[MAX_STRING_SIZE]; - char value[MAX_STRING_SIZE]; -}; - -struct loader_layer_functions { - char str_gipa[MAX_STRING_SIZE]; - char str_gdpa[MAX_STRING_SIZE]; - char str_negotiate_interface[MAX_STRING_SIZE]; - PFN_vkNegotiateLoaderLayerInterfaceVersion negotiate_layer_interface; - PFN_vkGetInstanceProcAddr get_instance_proc_addr; - PFN_vkGetDeviceProcAddr get_device_proc_addr; - PFN_GetPhysicalDeviceProcAddr get_physical_device_proc_addr; -}; - -struct loader_layer_properties { - VkLayerProperties info; - enum layer_type_flags type_flags; - uint32_t interface_version; // PFN_vkNegotiateLoaderLayerInterfaceVersion - char lib_name[MAX_STRING_SIZE]; - loader_platform_dl_handle lib_handle; - struct loader_layer_functions functions; - struct loader_extension_list instance_extension_list; - struct loader_device_extension_list device_extension_list; - struct loader_name_value disable_env_var; - struct loader_name_value enable_env_var; - uint32_t num_component_layers; - char (*component_layer_names)[MAX_STRING_SIZE]; - struct { - char enumerate_instance_extension_properties[MAX_STRING_SIZE]; - char enumerate_instance_layer_properties[MAX_STRING_SIZE]; - } pre_instance_functions; -}; - -struct loader_layer_list { - size_t capacity; - uint32_t count; - struct loader_layer_properties *list; -}; - -struct loader_dispatch_hash_list { - size_t capacity; - uint32_t count; - uint32_t *index; // index into the dev_ext dispatch table -}; - -// loader_dispatch_hash_entry and loader_dev_ext_dispatch_table.dev_ext have -// one to one correspondence; one loader_dispatch_hash_entry for one dev_ext -// dispatch entry. -// 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 -}; - -typedef void(VKAPI_PTR *PFN_vkDevExt)(VkDevice device); -struct loader_dev_ext_dispatch_table { - PFN_vkDevExt dev_ext[MAX_NUM_UNKNOWN_EXTS]; -}; - -struct loader_dev_dispatch_table { - VkLayerDispatchTable core_dispatch; - struct loader_dev_ext_dispatch_table ext_dispatch; -}; - -// 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 - struct loader_physical_device_term *phys_dev_term; - - // List of activated layers. - // app_ is the version based on exactly what the application asked for. - // This is what must be returned to the application on Enumerate calls. - // expanded_ is the version based on expanding meta-layers into their - // individual component layers. This is what is used internally. - struct loader_layer_list app_activated_layer_list; - struct loader_layer_list expanded_activated_layer_list; - - VkAllocationCallbacks alloc_callbacks; - - struct loader_device *next; -}; - -// Per ICD information - -// Per ICD structure -struct loader_icd_term { - // pointers to find other structs - 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 - struct loader_icd_term_dispatch dispatch; - - struct loader_icd_term *next; - - PFN_PhysDevExt phys_dev_ext[MAX_NUM_UNKNOWN_EXTS]; -}; - -// Per ICD library structure -struct loader_icd_tramp_list { - size_t capacity; - uint32_t count; - struct loader_scanned_icd *scanned_list; -}; - -struct loader_instance_dispatch_table { - 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]; -}; - -// Per instance structure -struct loader_instance { - struct loader_instance_dispatch_table *disp; // must be first entry in structure - - // We need to manually track physical devices over time. If the user - // re-queries the information, we don't want to delete old data or - // create new data unless necessary. - uint32_t total_gpu_count; - uint32_t phys_dev_count_term; - struct loader_physical_device_term **phys_devs_term; - uint32_t phys_dev_count_tramp; - struct loader_physical_device_tramp **phys_devs_tramp; - - // We also need to manually track physical device groups, but we don't need - // loader specific structures since we have that content in the physical - // device stored internal to the public structures. - uint32_t phys_dev_group_count_term; - struct VkPhysicalDeviceGroupPropertiesKHX **phys_dev_groups_term; - uint32_t phys_dev_group_count_tramp; - struct VkPhysicalDeviceGroupPropertiesKHX **phys_dev_groups_tramp; - - struct loader_instance *next; - - uint32_t total_icd_count; - struct loader_icd_term *icd_terms; - struct loader_icd_tramp_list icd_tramp_list; - - struct loader_dispatch_hash_entry dev_ext_disp_hash[MAX_NUM_UNKNOWN_EXTS]; - struct loader_dispatch_hash_entry phys_dev_ext_disp_hash[MAX_NUM_UNKNOWN_EXTS]; - - struct loader_msg_callback_map_entry *icd_msg_callback_map; - - struct loader_layer_list instance_layer_list; - - // List of activated layers. - // app_ is the version based on exactly what the application asked for. - // This is what must be returned to the application on Enumerate calls. - // expanded_ is the version based on expanding meta-layers into their - // individual component layers. This is what is used internally. - struct loader_layer_list app_activated_layer_list; - struct loader_layer_list expanded_activated_layer_list; - - VkInstance instance; // layers/ICD instance returned to trampoline - - struct loader_extension_list ext_list; // icds and loaders extensions - union loader_instance_extension_enables enabled_known_extensions; - - VkLayerDbgFunctionNode *DbgFunctionHead; - uint32_t num_tmp_callbacks; - VkDebugReportCallbackCreateInfoEXT *tmp_dbg_create_infos; - VkDebugReportCallbackEXT *tmp_callbacks; - - VkAllocationCallbacks alloc_callbacks; - - bool wsi_surface_enabled; -#ifdef VK_USE_PLATFORM_WIN32_KHR - bool wsi_win32_surface_enabled; -#endif -#ifdef VK_USE_PLATFORM_MIR_KHR - bool wsi_mir_surface_enabled; -#endif -#ifdef VK_USE_PLATFORM_WAYLAND_KHR - bool wsi_wayland_surface_enabled; -#endif -#ifdef VK_USE_PLATFORM_XCB_KHR - bool wsi_xcb_surface_enabled; -#endif -#ifdef VK_USE_PLATFORM_XLIB_KHR - bool wsi_xlib_surface_enabled; -#endif -#ifdef VK_USE_PLATFORM_ANDROID_KHR - bool wsi_android_surface_enabled; -#endif - bool wsi_display_enabled; -}; - -// VkPhysicalDevice requires special treatment by loader. Firstly, terminator -// code must be able to get the struct loader_icd_term to call into the proper -// driver (multiple ICD/gpu case). This can be accomplished by wrapping the -// created VkPhysicalDevice in loader terminate_EnumeratePhysicalDevices(). -// Secondly, the loader must be able to handle wrapped by layer VkPhysicalDevice -// in trampoline code. This implies, that the loader trampoline code must also -// wrap the VkPhysicalDevice object in trampoline code. Thus, loader has to -// wrap the VkPhysicalDevice created object twice. In trampoline code it can't -// rely on the terminator object wrapping since a layer may also wrap. Since -// trampoline code wraps the VkPhysicalDevice this means all loader trampoline -// code that passes a VkPhysicalDevice should unwrap it. - -// 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 *this_instance; - 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_icd_term *this_icd_term; - uint8_t icd_index; - VkPhysicalDevice phys_dev; // object from ICD -}; - -struct loader_struct { - struct loader_instance *instances; -}; - -struct loader_scanned_icd { - char *lib_name; - loader_platform_dl_handle handle; - uint32_t api_version; - uint32_t interface_version; - PFN_vkGetInstanceProcAddr GetInstanceProcAddr; - PFN_GetPhysicalDeviceProcAddr GetPhysicalDeviceProcAddr; - PFN_vkCreateInstance CreateInstance; - PFN_vkEnumerateInstanceExtensionProperties EnumerateInstanceExtensionProperties; -}; - -static inline struct loader_instance *loader_instance(VkInstance instance) { return (struct loader_instance *)instance; } - -static inline VkPhysicalDevice loader_unwrap_physical_device(VkPhysicalDevice physicalDevice) { - struct loader_physical_device_tramp *phys_dev = (struct loader_physical_device_tramp *)physicalDevice; - return phys_dev->phys_dev; -} - -static inline void loader_set_dispatch(void *obj, const void *data) { *((const void **)obj) = data; } - -static inline VkLayerDispatchTable *loader_get_dispatch(const void *obj) { return *((VkLayerDispatchTable **)obj); } - -static inline struct loader_dev_dispatch_table *loader_get_dev_dispatch(const void *obj) { - return *((struct loader_dev_dispatch_table **)obj); -} - -static inline VkLayerInstanceDispatchTable *loader_get_instance_layer_dispatch(const void *obj) { - return *((VkLayerInstanceDispatchTable **)obj); -} - -static inline struct loader_instance_dispatch_table *loader_get_instance_dispatch(const void *obj) { - return *((struct loader_instance_dispatch_table **)obj); -} - -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."); -#endif - - loader_set_dispatch(obj, data); -} - -// Global variables used across files -extern struct loader_struct loader; -extern THREAD_LOCAL_DECL struct loader_instance *tls_instance; -#if defined(_WIN32) && !defined(LOADER_DYNAMIC_LIB) -extern LOADER_PLATFORM_THREAD_ONCE_DEFINITION(once_init); -#endif -extern loader_platform_thread_mutex loader_lock; -extern loader_platform_thread_mutex loader_json_lock; - -struct loader_msg_callback_map_entry { - VkDebugReportCallbackEXT icd_obj; - VkDebugReportCallbackEXT loader_obj; -}; - -// Helper function definitions -void *loader_instance_heap_alloc(const struct loader_instance *instance, size_t size, VkSystemAllocationScope allocationScope); -void loader_instance_heap_free(const struct loader_instance *instance, void *pMemory); -void *loader_instance_heap_realloc(const struct loader_instance *instance, void *pMemory, size_t orig_size, size_t size, - VkSystemAllocationScope alloc_scope); -void *loader_instance_tls_heap_alloc(size_t size); -void loader_instance_tls_heap_free(void *pMemory); -void *loader_device_heap_alloc(const struct loader_device *device, size_t size, VkSystemAllocationScope allocationScope); -void loader_device_heap_free(const struct loader_device *device, void *pMemory); -void *loader_device_heap_realloc(const struct loader_device *device, void *pMemory, size_t orig_size, size_t size, - VkSystemAllocationScope alloc_scope); - -void loader_log(const struct loader_instance *inst, VkFlags msg_type, int32_t msg_code, const char *format, ...); - -bool compare_vk_extension_properties(const VkExtensionProperties *op1, const VkExtensionProperties *op2); - -VkResult loader_validate_layers(const struct loader_instance *inst, const uint32_t layer_count, - const char *const *ppEnabledLayerNames, const struct loader_layer_list *list); - -VkResult loader_validate_instance_extensions(const struct loader_instance *inst, const struct loader_extension_list *icd_exts, - const struct loader_layer_list *instance_layer, - const VkInstanceCreateInfo *pCreateInfo); - -void loader_initialize(void); -VkResult loader_copy_layer_properties(const struct loader_instance *inst, struct loader_layer_properties *dst, - struct loader_layer_properties *src); -bool has_vk_extension_property_array(const VkExtensionProperties *vk_ext_prop, const uint32_t count, - const VkExtensionProperties *ext_array); -bool has_vk_extension_property(const VkExtensionProperties *vk_ext_prop, const struct loader_extension_list *ext_list); - -VkResult loader_add_to_ext_list(const struct loader_instance *inst, struct loader_extension_list *ext_list, - uint32_t prop_list_count, const VkExtensionProperties *props); -VkResult loader_add_to_dev_ext_list(const struct loader_instance *inst, struct loader_device_extension_list *ext_list, - const VkExtensionProperties *props, uint32_t entry_count, char **entrys); -VkResult loader_add_device_extensions(const struct loader_instance *inst, - PFN_vkEnumerateDeviceExtensionProperties fpEnumerateDeviceExtensionProperties, - VkPhysicalDevice physical_device, const char *lib_name, - struct loader_extension_list *ext_list); -VkResult loader_init_generic_list(const struct loader_instance *inst, struct loader_generic_list *list_info, size_t element_size); -void loader_destroy_generic_list(const struct loader_instance *inst, struct loader_generic_list *list); -void loader_destroy_layer_list(const struct loader_instance *inst, struct loader_device *device, - struct loader_layer_list *layer_list); -void loader_delete_layer_properties(const struct loader_instance *inst, struct loader_layer_list *layer_list); -bool loader_find_layer_name_array(const char *name, uint32_t layer_count, const char layer_list[][VK_MAX_EXTENSION_NAME_SIZE]); -VkResult loader_add_to_layer_list(const struct loader_instance *inst, struct loader_layer_list *list, uint32_t prop_list_count, - const struct loader_layer_properties *props); -void loader_find_layer_name_add_list(const struct loader_instance *inst, const char *name, const enum layer_type_flags type_flags, - const struct loader_layer_list *source_list, struct loader_layer_list *target_list, - struct loader_layer_list *expanded_target_list); -void loader_scanned_icd_clear(const struct loader_instance *inst, struct loader_icd_tramp_list *icd_tramp_list); -VkResult loader_icd_scan(const struct loader_instance *inst, struct loader_icd_tramp_list *icd_tramp_list); -void loader_layer_scan(const struct loader_instance *inst, struct loader_layer_list *instance_layers); -void loader_implicit_layer_scan(const struct loader_instance *inst, struct loader_layer_list *instance_layers); -bool loader_is_implicit_layer_enabled(const struct loader_instance *inst, const struct loader_layer_properties *prop); -VkResult loader_get_icd_loader_instance_extensions(const struct loader_instance *inst, struct loader_icd_tramp_list *icd_tramp_list, - struct loader_extension_list *inst_exts); -struct loader_icd_term *loader_get_icd_and_device(const VkDevice device, struct loader_device **found_dev, uint32_t *icd_index); -void loader_init_dispatch_dev_ext(struct loader_instance *inst, struct loader_device *dev); -void *loader_dev_ext_gpa(struct loader_instance *inst, const char *funcName); -void *loader_get_dev_ext_trampoline(uint32_t index); -bool loader_phys_dev_ext_gpa(struct loader_instance *inst, const char *funcName, bool perform_checking, void **tramp_addr, - void **term_addr); -void *loader_get_phys_dev_ext_tramp(uint32_t index); -void *loader_get_phys_dev_ext_termin(uint32_t index); -struct loader_instance *loader_get_instance(const VkInstance instance); -void loader_deactivate_layers(const struct loader_instance *instance, struct loader_device *device, struct loader_layer_list *list); -struct loader_device *loader_create_logical_device(const struct loader_instance *inst, const VkAllocationCallbacks *pAllocator); -void loader_add_logical_device(const struct loader_instance *inst, struct loader_icd_term *icd_term, - struct loader_device *found_dev); -void loader_remove_logical_device(const struct loader_instance *inst, struct loader_icd_term *icd_term, - struct loader_device *found_dev, const VkAllocationCallbacks *pAllocator); -// NOTE: Outside of loader, this entry-point is only provided for error -// cleanup. -void loader_destroy_logical_device(const struct loader_instance *inst, struct loader_device *dev, - const VkAllocationCallbacks *pAllocator); - -VkResult loader_enable_instance_layers(struct loader_instance *inst, const VkInstanceCreateInfo *pCreateInfo, - const struct loader_layer_list *instance_layers); - -VkResult loader_create_instance_chain(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, - struct loader_instance *inst, VkInstance *created_instance); - -void loader_activate_instance_layer_extensions(struct loader_instance *inst, VkInstance created_inst); - -VkResult loader_create_device_chain(const struct loader_physical_device_tramp *pd, const VkDeviceCreateInfo *pCreateInfo, - const VkAllocationCallbacks *pAllocator, const struct loader_instance *inst, - struct loader_device *dev); - -VkResult loader_validate_device_extensions(struct loader_physical_device_tramp *phys_dev, - const struct loader_layer_list *activated_device_layers, - const struct loader_extension_list *icd_exts, const VkDeviceCreateInfo *pCreateInfo); - -VkResult setupLoaderTrampPhysDevs(VkInstance instance); -VkResult setupLoaderTermPhysDevs(struct loader_instance *inst); - -VkStringErrorFlags vk_string_validate(const int max_length, const char *char_array); - -#endif // LOADER_H diff --git a/third_party/vulkan/loader/loader_cmake_config.h b/third_party/vulkan/loader/loader_cmake_config.h deleted file mode 100644 index 3d89882bd..000000000 --- a/third_party/vulkan/loader/loader_cmake_config.h +++ /dev/null @@ -1,2 +0,0 @@ -/* #undef HAVE_SECURE_GETENV */ -/* #undef HAVE___SECURE_GETENV */ diff --git a/third_party/vulkan/loader/murmurhash.c b/third_party/vulkan/loader/murmurhash.c deleted file mode 100644 index db6276f5a..000000000 --- a/third_party/vulkan/loader/murmurhash.c +++ /dev/null @@ -1,97 +0,0 @@ - -/** - * `murmurhash.h' - murmurhash - * - * copyright (c) 2014 joseph werle - * Copyright (c) 2015-2016 The Khronos Group Inc. - * Copyright (c) 2015-2016 Valve Corporation - * Copyright (c) 2015-2016 LunarG, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and/or associated documentation files (the "Materials"), to - * deal in the Materials without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Materials, and to permit persons to whom the Materials are - * furnished to do so, subject to the following conditions: - * - * The above copyright notice(s) and this permission notice shall be included in - * all copies or substantial portions of the Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE - * USE OR OTHER DEALINGS IN THE MATERIALS. - */ - -#include -#include -#include -#include "murmurhash.h" - -uint32_t murmurhash(const char *key, size_t len, uint32_t seed) { - uint32_t c1 = 0xcc9e2d51; - uint32_t c2 = 0x1b873593; - uint32_t r1 = 15; - uint32_t r2 = 13; - uint32_t m = 5; - uint32_t n = 0xe6546b64; - uint32_t h = 0; - uint32_t k = 0; - 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 - int i = 0; - 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' - - // for each 4 byte chunk of `key' - for (i = -l; i != 0; ++i) { - // next 4 byte chunk of `key' - k = chunks[i]; - - // encode next 4 byte chunk of `key' - k *= c1; - k = (k << r1) | (k >> (32 - r1)); - k *= c2; - - // append to hash - h ^= k; - h = (h << r2) | (h >> (32 - r2)); - h = h * m + n; - } - - k = 0; - - // remainder - 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; - } - - h ^= len; - - h ^= (h >> 16); - h *= 0x85ebca6b; - h ^= (h >> 13); - h *= 0xc2b2ae35; - h ^= (h >> 16); - - return h; -} diff --git a/third_party/vulkan/loader/murmurhash.h b/third_party/vulkan/loader/murmurhash.h deleted file mode 100644 index 775532e8b..000000000 --- a/third_party/vulkan/loader/murmurhash.h +++ /dev/null @@ -1,52 +0,0 @@ - -/** - * `murmurhash.h' - murmurhash - * - * copyright (c) 2014 joseph werle - * Copyright (c) 2015-2016 The Khronos Group Inc. - * Copyright (c) 2015-2016 Valve Corporation - * Copyright (c) 2015-2016 LunarG, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and/or associated documentation files (the "Materials"), to - * deal in the Materials without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Materials, and to permit persons to whom the Materials are - * furnished to do so, subject to the following conditions: - * - * The above copyright notice(s) and this permission notice shall be included in - * all copies or substantial portions of the Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE - * USE OR OTHER DEALINGS IN THE MATERIALS. - */ - -#ifndef MURMURHASH_H -#define MURMURHASH_H 1 - -#include - -#define MURMURHASH_VERSION "0.0.3" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Returns a murmur hash of `key' based on `seed' - * using the MurmurHash3 algorithm - */ - -uint32_t murmurhash(const char *key, size_t len, uint32_t seed); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/third_party/vulkan/loader/phys_dev_ext.c b/third_party/vulkan/loader/phys_dev_ext.c deleted file mode 100644 index 91e0ef8f6..000000000 --- a/third_party/vulkan/loader/phys_dev_ext.c +++ /dev/null @@ -1,1056 +0,0 @@ -/* - * - * Copyright (c) 2016-17 The Khronos Group Inc. - * Copyright (c) 2016-17 Valve Corporation - * Copyright (c) 2016-17 LunarG, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Author: Mark Young - * Author: Lenny Komow - * - */ - -// This code is used to enable generic instance extensions which use a physical device -// as the first parameter. If the extension is already known by the loader, it will -// not use this code, but instead use the more direct route. However, if it is -// 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" - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC optimize(3) // force gcc to use tail-calls -#endif - -// Declarations for the trampoline -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp0(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp1(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp2(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp3(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp4(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp5(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp6(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp7(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp8(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp9(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp10(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp11(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp12(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp13(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp14(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp15(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp16(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp17(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp18(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp19(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp20(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp21(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp22(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp23(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp24(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp25(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp26(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp27(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp28(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp29(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp30(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp31(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp32(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp33(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp34(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp35(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp36(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp37(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp38(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp39(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp40(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp41(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp42(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp43(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp44(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp45(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp46(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp47(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp48(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp49(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp50(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp51(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp52(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp53(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp54(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp55(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp56(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp57(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp58(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp59(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp60(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp61(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp62(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp63(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp64(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp65(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp66(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp67(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp68(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp69(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp70(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp71(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp72(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp73(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp74(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp75(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp76(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp77(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp78(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp79(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp80(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp81(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp82(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp83(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp84(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp85(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp86(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp87(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp88(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp89(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp90(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp91(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp92(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp93(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp94(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp95(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp96(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp97(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp98(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp99(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp100(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp101(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp102(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp103(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp104(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp105(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp106(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp107(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp108(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp109(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp110(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp111(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp112(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp113(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp114(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp115(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp116(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp117(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp118(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp119(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp120(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp121(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp122(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp123(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp124(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp125(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp126(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp127(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp128(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp129(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp130(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp131(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp132(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp133(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp134(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp135(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp136(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp137(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp138(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp139(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp140(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp141(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp142(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp143(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp144(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp145(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp146(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp147(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp148(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp149(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp150(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp151(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp152(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp153(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp154(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp155(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp156(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp157(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp158(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp159(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp160(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp161(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp162(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp163(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp164(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp165(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp166(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp167(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp168(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp169(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp170(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp171(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp172(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp173(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp174(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp175(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp176(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp177(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp178(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp179(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp180(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp181(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp182(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp183(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp184(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp185(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp186(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp187(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp188(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp189(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp190(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp191(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp192(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp193(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp194(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp195(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp196(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp197(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp198(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp199(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp200(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp201(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp202(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp203(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp204(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp205(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp206(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp207(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp208(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp209(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp210(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp211(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp212(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp213(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp214(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp215(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp216(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp217(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp218(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp219(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp220(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp221(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp222(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp223(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp224(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp225(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp226(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp227(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp228(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp229(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp230(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp231(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp232(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp233(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp234(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp235(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp236(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp237(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp238(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp239(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp240(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp241(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp242(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp243(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp244(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp245(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp246(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp247(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp248(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTramp249(VkPhysicalDevice); - -// Disable clang-format for lists of macros -// clang-format off - -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin0(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin1(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin2(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin3(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin4(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin5(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin6(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin7(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin8(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin9(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin10(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin11(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin12(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin13(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin14(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin15(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin16(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin17(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin18(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin19(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin20(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin21(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin22(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin23(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin24(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin25(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin26(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin27(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin28(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin29(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin30(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin31(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin32(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin33(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin34(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin35(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin36(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin37(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin38(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin39(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin40(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin41(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin42(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin43(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin44(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin45(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin46(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin47(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin48(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin49(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin50(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin51(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin52(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin53(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin54(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin55(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin56(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin57(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin58(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin59(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin60(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin61(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin62(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin63(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin64(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin65(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin66(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin67(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin68(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin69(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin70(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin71(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin72(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin73(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin74(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin75(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin76(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin77(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin78(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin79(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin80(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin81(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin82(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin83(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin84(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin85(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin86(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin87(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin88(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin89(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin90(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin91(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin92(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin93(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin94(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin95(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin96(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin97(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin98(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin99(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin100(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin101(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin102(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin103(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin104(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin105(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin106(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin107(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin108(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin109(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin110(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin111(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin112(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin113(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin114(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin115(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin116(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin117(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin118(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin119(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin120(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin121(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin122(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin123(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin124(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin125(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin126(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin127(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin128(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin129(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin130(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin131(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin132(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin133(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin134(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin135(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin136(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin137(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin138(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin139(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin140(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin141(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin142(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin143(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin144(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin145(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin146(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin147(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin148(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin149(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin150(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin151(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin152(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin153(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin154(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin155(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin156(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin157(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin158(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin159(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin160(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin161(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin162(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin163(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin164(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin165(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin166(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin167(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin168(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin169(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin170(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin171(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin172(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin173(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin174(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin175(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin176(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin177(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin178(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin179(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin180(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin181(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin182(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin183(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin184(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin185(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin186(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin187(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin188(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin189(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin190(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin191(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin192(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin193(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin194(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin195(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin196(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin197(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin198(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin199(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin200(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin201(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin202(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin203(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin204(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin205(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin206(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin207(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin208(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin209(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin210(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin211(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin212(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin213(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin214(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin215(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin216(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin217(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin218(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin219(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin220(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin221(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin222(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin223(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin224(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin225(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin226(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin227(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin228(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin229(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin230(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin231(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin232(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin233(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin234(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin235(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin236(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin237(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin238(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin239(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin240(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin241(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin242(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin243(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin244(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin245(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin246(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin247(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin248(VkPhysicalDevice); -VKAPI_ATTR void VKAPI_CALL vkPhysDevExtTermin249(VkPhysicalDevice); - - -void *loader_get_phys_dev_ext_tramp(uint32_t index) { - switch (index) { -#define TRAMP_CASE_HANDLE(num) case num: return vkPhysDevExtTramp##num - TRAMP_CASE_HANDLE(0); - TRAMP_CASE_HANDLE(1); - TRAMP_CASE_HANDLE(2); - TRAMP_CASE_HANDLE(3); - TRAMP_CASE_HANDLE(4); - TRAMP_CASE_HANDLE(5); - TRAMP_CASE_HANDLE(6); - TRAMP_CASE_HANDLE(7); - TRAMP_CASE_HANDLE(8); - TRAMP_CASE_HANDLE(9); - TRAMP_CASE_HANDLE(10); - TRAMP_CASE_HANDLE(11); - TRAMP_CASE_HANDLE(12); - TRAMP_CASE_HANDLE(13); - TRAMP_CASE_HANDLE(14); - TRAMP_CASE_HANDLE(15); - TRAMP_CASE_HANDLE(16); - TRAMP_CASE_HANDLE(17); - TRAMP_CASE_HANDLE(18); - TRAMP_CASE_HANDLE(19); - TRAMP_CASE_HANDLE(20); - TRAMP_CASE_HANDLE(21); - TRAMP_CASE_HANDLE(22); - TRAMP_CASE_HANDLE(23); - TRAMP_CASE_HANDLE(24); - TRAMP_CASE_HANDLE(25); - TRAMP_CASE_HANDLE(26); - TRAMP_CASE_HANDLE(27); - TRAMP_CASE_HANDLE(28); - TRAMP_CASE_HANDLE(29); - TRAMP_CASE_HANDLE(30); - TRAMP_CASE_HANDLE(31); - TRAMP_CASE_HANDLE(32); - TRAMP_CASE_HANDLE(33); - TRAMP_CASE_HANDLE(34); - TRAMP_CASE_HANDLE(35); - TRAMP_CASE_HANDLE(36); - TRAMP_CASE_HANDLE(37); - TRAMP_CASE_HANDLE(38); - TRAMP_CASE_HANDLE(39); - TRAMP_CASE_HANDLE(40); - TRAMP_CASE_HANDLE(41); - TRAMP_CASE_HANDLE(42); - TRAMP_CASE_HANDLE(43); - TRAMP_CASE_HANDLE(44); - TRAMP_CASE_HANDLE(45); - TRAMP_CASE_HANDLE(46); - TRAMP_CASE_HANDLE(47); - TRAMP_CASE_HANDLE(48); - TRAMP_CASE_HANDLE(49); - TRAMP_CASE_HANDLE(50); - TRAMP_CASE_HANDLE(51); - TRAMP_CASE_HANDLE(52); - TRAMP_CASE_HANDLE(53); - TRAMP_CASE_HANDLE(54); - TRAMP_CASE_HANDLE(55); - TRAMP_CASE_HANDLE(56); - TRAMP_CASE_HANDLE(57); - TRAMP_CASE_HANDLE(58); - TRAMP_CASE_HANDLE(59); - TRAMP_CASE_HANDLE(60); - TRAMP_CASE_HANDLE(61); - TRAMP_CASE_HANDLE(62); - TRAMP_CASE_HANDLE(63); - TRAMP_CASE_HANDLE(64); - TRAMP_CASE_HANDLE(65); - TRAMP_CASE_HANDLE(66); - TRAMP_CASE_HANDLE(67); - TRAMP_CASE_HANDLE(68); - TRAMP_CASE_HANDLE(69); - TRAMP_CASE_HANDLE(70); - TRAMP_CASE_HANDLE(71); - TRAMP_CASE_HANDLE(72); - TRAMP_CASE_HANDLE(73); - TRAMP_CASE_HANDLE(74); - TRAMP_CASE_HANDLE(75); - TRAMP_CASE_HANDLE(76); - TRAMP_CASE_HANDLE(77); - TRAMP_CASE_HANDLE(78); - TRAMP_CASE_HANDLE(79); - TRAMP_CASE_HANDLE(80); - TRAMP_CASE_HANDLE(81); - TRAMP_CASE_HANDLE(82); - TRAMP_CASE_HANDLE(83); - TRAMP_CASE_HANDLE(84); - TRAMP_CASE_HANDLE(85); - TRAMP_CASE_HANDLE(86); - TRAMP_CASE_HANDLE(87); - TRAMP_CASE_HANDLE(88); - TRAMP_CASE_HANDLE(89); - TRAMP_CASE_HANDLE(90); - TRAMP_CASE_HANDLE(91); - TRAMP_CASE_HANDLE(92); - TRAMP_CASE_HANDLE(93); - TRAMP_CASE_HANDLE(94); - TRAMP_CASE_HANDLE(95); - TRAMP_CASE_HANDLE(96); - TRAMP_CASE_HANDLE(97); - TRAMP_CASE_HANDLE(98); - TRAMP_CASE_HANDLE(99); - TRAMP_CASE_HANDLE(100); - TRAMP_CASE_HANDLE(101); - TRAMP_CASE_HANDLE(102); - TRAMP_CASE_HANDLE(103); - TRAMP_CASE_HANDLE(104); - TRAMP_CASE_HANDLE(105); - TRAMP_CASE_HANDLE(106); - TRAMP_CASE_HANDLE(107); - TRAMP_CASE_HANDLE(108); - TRAMP_CASE_HANDLE(109); - TRAMP_CASE_HANDLE(110); - TRAMP_CASE_HANDLE(111); - TRAMP_CASE_HANDLE(112); - TRAMP_CASE_HANDLE(113); - TRAMP_CASE_HANDLE(114); - TRAMP_CASE_HANDLE(115); - TRAMP_CASE_HANDLE(116); - TRAMP_CASE_HANDLE(117); - TRAMP_CASE_HANDLE(118); - TRAMP_CASE_HANDLE(119); - TRAMP_CASE_HANDLE(120); - TRAMP_CASE_HANDLE(121); - TRAMP_CASE_HANDLE(122); - TRAMP_CASE_HANDLE(123); - TRAMP_CASE_HANDLE(124); - TRAMP_CASE_HANDLE(125); - TRAMP_CASE_HANDLE(126); - TRAMP_CASE_HANDLE(127); - TRAMP_CASE_HANDLE(128); - TRAMP_CASE_HANDLE(129); - TRAMP_CASE_HANDLE(130); - TRAMP_CASE_HANDLE(131); - TRAMP_CASE_HANDLE(132); - TRAMP_CASE_HANDLE(133); - TRAMP_CASE_HANDLE(134); - TRAMP_CASE_HANDLE(135); - TRAMP_CASE_HANDLE(136); - TRAMP_CASE_HANDLE(137); - TRAMP_CASE_HANDLE(138); - TRAMP_CASE_HANDLE(139); - TRAMP_CASE_HANDLE(140); - TRAMP_CASE_HANDLE(141); - TRAMP_CASE_HANDLE(142); - TRAMP_CASE_HANDLE(143); - TRAMP_CASE_HANDLE(144); - TRAMP_CASE_HANDLE(145); - TRAMP_CASE_HANDLE(146); - TRAMP_CASE_HANDLE(147); - TRAMP_CASE_HANDLE(148); - TRAMP_CASE_HANDLE(149); - TRAMP_CASE_HANDLE(150); - TRAMP_CASE_HANDLE(151); - TRAMP_CASE_HANDLE(152); - TRAMP_CASE_HANDLE(153); - TRAMP_CASE_HANDLE(154); - TRAMP_CASE_HANDLE(155); - TRAMP_CASE_HANDLE(156); - TRAMP_CASE_HANDLE(157); - TRAMP_CASE_HANDLE(158); - TRAMP_CASE_HANDLE(159); - TRAMP_CASE_HANDLE(160); - TRAMP_CASE_HANDLE(161); - TRAMP_CASE_HANDLE(162); - TRAMP_CASE_HANDLE(163); - TRAMP_CASE_HANDLE(164); - TRAMP_CASE_HANDLE(165); - TRAMP_CASE_HANDLE(166); - TRAMP_CASE_HANDLE(167); - TRAMP_CASE_HANDLE(168); - TRAMP_CASE_HANDLE(169); - TRAMP_CASE_HANDLE(170); - TRAMP_CASE_HANDLE(171); - TRAMP_CASE_HANDLE(172); - TRAMP_CASE_HANDLE(173); - TRAMP_CASE_HANDLE(174); - TRAMP_CASE_HANDLE(175); - TRAMP_CASE_HANDLE(176); - TRAMP_CASE_HANDLE(177); - TRAMP_CASE_HANDLE(178); - TRAMP_CASE_HANDLE(179); - TRAMP_CASE_HANDLE(180); - TRAMP_CASE_HANDLE(181); - TRAMP_CASE_HANDLE(182); - TRAMP_CASE_HANDLE(183); - TRAMP_CASE_HANDLE(184); - TRAMP_CASE_HANDLE(185); - TRAMP_CASE_HANDLE(186); - TRAMP_CASE_HANDLE(187); - TRAMP_CASE_HANDLE(188); - TRAMP_CASE_HANDLE(189); - TRAMP_CASE_HANDLE(190); - TRAMP_CASE_HANDLE(191); - TRAMP_CASE_HANDLE(192); - TRAMP_CASE_HANDLE(193); - TRAMP_CASE_HANDLE(194); - TRAMP_CASE_HANDLE(195); - TRAMP_CASE_HANDLE(196); - TRAMP_CASE_HANDLE(197); - TRAMP_CASE_HANDLE(198); - TRAMP_CASE_HANDLE(199); - TRAMP_CASE_HANDLE(200); - TRAMP_CASE_HANDLE(201); - TRAMP_CASE_HANDLE(202); - TRAMP_CASE_HANDLE(203); - TRAMP_CASE_HANDLE(204); - TRAMP_CASE_HANDLE(205); - TRAMP_CASE_HANDLE(206); - TRAMP_CASE_HANDLE(207); - TRAMP_CASE_HANDLE(208); - TRAMP_CASE_HANDLE(209); - TRAMP_CASE_HANDLE(210); - TRAMP_CASE_HANDLE(211); - TRAMP_CASE_HANDLE(212); - TRAMP_CASE_HANDLE(213); - TRAMP_CASE_HANDLE(214); - TRAMP_CASE_HANDLE(215); - TRAMP_CASE_HANDLE(216); - TRAMP_CASE_HANDLE(217); - TRAMP_CASE_HANDLE(218); - TRAMP_CASE_HANDLE(219); - TRAMP_CASE_HANDLE(220); - TRAMP_CASE_HANDLE(221); - TRAMP_CASE_HANDLE(222); - TRAMP_CASE_HANDLE(223); - TRAMP_CASE_HANDLE(224); - TRAMP_CASE_HANDLE(225); - TRAMP_CASE_HANDLE(226); - TRAMP_CASE_HANDLE(227); - TRAMP_CASE_HANDLE(228); - TRAMP_CASE_HANDLE(229); - TRAMP_CASE_HANDLE(230); - TRAMP_CASE_HANDLE(231); - TRAMP_CASE_HANDLE(232); - TRAMP_CASE_HANDLE(233); - TRAMP_CASE_HANDLE(234); - TRAMP_CASE_HANDLE(235); - TRAMP_CASE_HANDLE(236); - TRAMP_CASE_HANDLE(237); - TRAMP_CASE_HANDLE(238); - TRAMP_CASE_HANDLE(239); - TRAMP_CASE_HANDLE(240); - TRAMP_CASE_HANDLE(241); - TRAMP_CASE_HANDLE(242); - TRAMP_CASE_HANDLE(243); - TRAMP_CASE_HANDLE(244); - TRAMP_CASE_HANDLE(245); - TRAMP_CASE_HANDLE(246); - TRAMP_CASE_HANDLE(247); - TRAMP_CASE_HANDLE(248); - TRAMP_CASE_HANDLE(249); - } - return NULL; -} - -void *loader_get_phys_dev_ext_termin(uint32_t index) { - switch (index) { -#define TERM_CASE_HANDLE(num) case num: return vkPhysDevExtTermin##num - TERM_CASE_HANDLE(0); - TERM_CASE_HANDLE(1); - TERM_CASE_HANDLE(2); - TERM_CASE_HANDLE(3); - TERM_CASE_HANDLE(4); - TERM_CASE_HANDLE(5); - TERM_CASE_HANDLE(6); - TERM_CASE_HANDLE(7); - TERM_CASE_HANDLE(8); - TERM_CASE_HANDLE(9); - TERM_CASE_HANDLE(10); - TERM_CASE_HANDLE(11); - TERM_CASE_HANDLE(12); - TERM_CASE_HANDLE(13); - TERM_CASE_HANDLE(14); - TERM_CASE_HANDLE(15); - TERM_CASE_HANDLE(16); - TERM_CASE_HANDLE(17); - TERM_CASE_HANDLE(18); - TERM_CASE_HANDLE(19); - TERM_CASE_HANDLE(20); - TERM_CASE_HANDLE(21); - TERM_CASE_HANDLE(22); - TERM_CASE_HANDLE(23); - TERM_CASE_HANDLE(24); - TERM_CASE_HANDLE(25); - TERM_CASE_HANDLE(26); - TERM_CASE_HANDLE(27); - TERM_CASE_HANDLE(28); - TERM_CASE_HANDLE(29); - TERM_CASE_HANDLE(30); - TERM_CASE_HANDLE(31); - TERM_CASE_HANDLE(32); - TERM_CASE_HANDLE(33); - TERM_CASE_HANDLE(34); - TERM_CASE_HANDLE(35); - TERM_CASE_HANDLE(36); - TERM_CASE_HANDLE(37); - TERM_CASE_HANDLE(38); - TERM_CASE_HANDLE(39); - TERM_CASE_HANDLE(40); - TERM_CASE_HANDLE(41); - TERM_CASE_HANDLE(42); - TERM_CASE_HANDLE(43); - TERM_CASE_HANDLE(44); - TERM_CASE_HANDLE(45); - TERM_CASE_HANDLE(46); - TERM_CASE_HANDLE(47); - TERM_CASE_HANDLE(48); - TERM_CASE_HANDLE(49); - TERM_CASE_HANDLE(50); - TERM_CASE_HANDLE(51); - TERM_CASE_HANDLE(52); - TERM_CASE_HANDLE(53); - TERM_CASE_HANDLE(54); - TERM_CASE_HANDLE(55); - TERM_CASE_HANDLE(56); - TERM_CASE_HANDLE(57); - TERM_CASE_HANDLE(58); - TERM_CASE_HANDLE(59); - TERM_CASE_HANDLE(60); - TERM_CASE_HANDLE(61); - TERM_CASE_HANDLE(62); - TERM_CASE_HANDLE(63); - TERM_CASE_HANDLE(64); - TERM_CASE_HANDLE(65); - TERM_CASE_HANDLE(66); - TERM_CASE_HANDLE(67); - TERM_CASE_HANDLE(68); - TERM_CASE_HANDLE(69); - TERM_CASE_HANDLE(70); - TERM_CASE_HANDLE(71); - TERM_CASE_HANDLE(72); - TERM_CASE_HANDLE(73); - TERM_CASE_HANDLE(74); - TERM_CASE_HANDLE(75); - TERM_CASE_HANDLE(76); - TERM_CASE_HANDLE(77); - TERM_CASE_HANDLE(78); - TERM_CASE_HANDLE(79); - TERM_CASE_HANDLE(80); - TERM_CASE_HANDLE(81); - TERM_CASE_HANDLE(82); - TERM_CASE_HANDLE(83); - TERM_CASE_HANDLE(84); - TERM_CASE_HANDLE(85); - TERM_CASE_HANDLE(86); - TERM_CASE_HANDLE(87); - TERM_CASE_HANDLE(88); - TERM_CASE_HANDLE(89); - TERM_CASE_HANDLE(90); - TERM_CASE_HANDLE(91); - TERM_CASE_HANDLE(92); - TERM_CASE_HANDLE(93); - TERM_CASE_HANDLE(94); - TERM_CASE_HANDLE(95); - TERM_CASE_HANDLE(96); - TERM_CASE_HANDLE(97); - TERM_CASE_HANDLE(98); - TERM_CASE_HANDLE(99); - TERM_CASE_HANDLE(100); - TERM_CASE_HANDLE(101); - TERM_CASE_HANDLE(102); - TERM_CASE_HANDLE(103); - TERM_CASE_HANDLE(104); - TERM_CASE_HANDLE(105); - TERM_CASE_HANDLE(106); - TERM_CASE_HANDLE(107); - TERM_CASE_HANDLE(108); - TERM_CASE_HANDLE(109); - TERM_CASE_HANDLE(110); - TERM_CASE_HANDLE(111); - TERM_CASE_HANDLE(112); - TERM_CASE_HANDLE(113); - TERM_CASE_HANDLE(114); - TERM_CASE_HANDLE(115); - TERM_CASE_HANDLE(116); - TERM_CASE_HANDLE(117); - TERM_CASE_HANDLE(118); - TERM_CASE_HANDLE(119); - TERM_CASE_HANDLE(120); - TERM_CASE_HANDLE(121); - TERM_CASE_HANDLE(122); - TERM_CASE_HANDLE(123); - TERM_CASE_HANDLE(124); - TERM_CASE_HANDLE(125); - TERM_CASE_HANDLE(126); - TERM_CASE_HANDLE(127); - TERM_CASE_HANDLE(128); - TERM_CASE_HANDLE(129); - TERM_CASE_HANDLE(130); - TERM_CASE_HANDLE(131); - TERM_CASE_HANDLE(132); - TERM_CASE_HANDLE(133); - TERM_CASE_HANDLE(134); - TERM_CASE_HANDLE(135); - TERM_CASE_HANDLE(136); - TERM_CASE_HANDLE(137); - TERM_CASE_HANDLE(138); - TERM_CASE_HANDLE(139); - TERM_CASE_HANDLE(140); - TERM_CASE_HANDLE(141); - TERM_CASE_HANDLE(142); - TERM_CASE_HANDLE(143); - TERM_CASE_HANDLE(144); - TERM_CASE_HANDLE(145); - TERM_CASE_HANDLE(146); - TERM_CASE_HANDLE(147); - TERM_CASE_HANDLE(148); - TERM_CASE_HANDLE(149); - TERM_CASE_HANDLE(150); - TERM_CASE_HANDLE(151); - TERM_CASE_HANDLE(152); - TERM_CASE_HANDLE(153); - TERM_CASE_HANDLE(154); - TERM_CASE_HANDLE(155); - TERM_CASE_HANDLE(156); - TERM_CASE_HANDLE(157); - TERM_CASE_HANDLE(158); - TERM_CASE_HANDLE(159); - TERM_CASE_HANDLE(160); - TERM_CASE_HANDLE(161); - TERM_CASE_HANDLE(162); - TERM_CASE_HANDLE(163); - TERM_CASE_HANDLE(164); - TERM_CASE_HANDLE(165); - TERM_CASE_HANDLE(166); - TERM_CASE_HANDLE(167); - TERM_CASE_HANDLE(168); - TERM_CASE_HANDLE(169); - TERM_CASE_HANDLE(170); - TERM_CASE_HANDLE(171); - TERM_CASE_HANDLE(172); - TERM_CASE_HANDLE(173); - TERM_CASE_HANDLE(174); - TERM_CASE_HANDLE(175); - TERM_CASE_HANDLE(176); - TERM_CASE_HANDLE(177); - TERM_CASE_HANDLE(178); - TERM_CASE_HANDLE(179); - TERM_CASE_HANDLE(180); - TERM_CASE_HANDLE(181); - TERM_CASE_HANDLE(182); - TERM_CASE_HANDLE(183); - TERM_CASE_HANDLE(184); - TERM_CASE_HANDLE(185); - TERM_CASE_HANDLE(186); - TERM_CASE_HANDLE(187); - TERM_CASE_HANDLE(188); - TERM_CASE_HANDLE(189); - TERM_CASE_HANDLE(190); - TERM_CASE_HANDLE(191); - TERM_CASE_HANDLE(192); - TERM_CASE_HANDLE(193); - TERM_CASE_HANDLE(194); - TERM_CASE_HANDLE(195); - TERM_CASE_HANDLE(196); - TERM_CASE_HANDLE(197); - TERM_CASE_HANDLE(198); - TERM_CASE_HANDLE(199); - TERM_CASE_HANDLE(200); - TERM_CASE_HANDLE(201); - TERM_CASE_HANDLE(202); - TERM_CASE_HANDLE(203); - TERM_CASE_HANDLE(204); - TERM_CASE_HANDLE(205); - TERM_CASE_HANDLE(206); - TERM_CASE_HANDLE(207); - TERM_CASE_HANDLE(208); - TERM_CASE_HANDLE(209); - TERM_CASE_HANDLE(210); - TERM_CASE_HANDLE(211); - TERM_CASE_HANDLE(212); - TERM_CASE_HANDLE(213); - TERM_CASE_HANDLE(214); - TERM_CASE_HANDLE(215); - TERM_CASE_HANDLE(216); - TERM_CASE_HANDLE(217); - TERM_CASE_HANDLE(218); - TERM_CASE_HANDLE(219); - TERM_CASE_HANDLE(220); - TERM_CASE_HANDLE(221); - TERM_CASE_HANDLE(222); - TERM_CASE_HANDLE(223); - TERM_CASE_HANDLE(224); - TERM_CASE_HANDLE(225); - TERM_CASE_HANDLE(226); - TERM_CASE_HANDLE(227); - TERM_CASE_HANDLE(228); - TERM_CASE_HANDLE(229); - TERM_CASE_HANDLE(230); - TERM_CASE_HANDLE(231); - TERM_CASE_HANDLE(232); - TERM_CASE_HANDLE(233); - TERM_CASE_HANDLE(234); - TERM_CASE_HANDLE(235); - TERM_CASE_HANDLE(236); - TERM_CASE_HANDLE(237); - TERM_CASE_HANDLE(238); - TERM_CASE_HANDLE(239); - TERM_CASE_HANDLE(240); - TERM_CASE_HANDLE(241); - TERM_CASE_HANDLE(242); - TERM_CASE_HANDLE(243); - TERM_CASE_HANDLE(244); - TERM_CASE_HANDLE(245); - TERM_CASE_HANDLE(246); - TERM_CASE_HANDLE(247); - TERM_CASE_HANDLE(248); - TERM_CASE_HANDLE(249); - } - return NULL; -} diff --git a/third_party/vulkan/loader/premake5.lua b/third_party/vulkan/loader/premake5.lua deleted file mode 100644 index 112936c27..000000000 --- a/third_party/vulkan/loader/premake5.lua +++ /dev/null @@ -1,41 +0,0 @@ -group("third_party") -project("vulkan-loader") - uuid("07d77359-1618-43e6-8a4a-0ee9ddc5fa6a") - kind("StaticLib") - language("C") - - defines({ - "_LIB", - "API_NAME=\"vulkan\"", - }) - removedefines({ - "_UNICODE", - "UNICODE", - }) - includedirs({ - ".", - }) - recursive_platform_files() - - -- Included elsewhere - removefiles("vk_loader_extensions.c") - - filter("platforms:Windows") - warnings("Off") -- Too many warnings. - characterset("MBCS") - defines({ - "VK_USE_PLATFORM_WIN32_KHR", - }) - links({ - "Cfgmgr32" - }) - filter("platforms:not Windows") - removefiles("dirent_on_windows.c") - filter("platforms:Linux") - defines({ - "VK_USE_PLATFORM_XCB_KHR", - [[SYSCONFDIR="\"/etc\""]], - [[FALLBACK_CONFIG_DIRS="\"/etc/xdg\""]], - [[DATADIR="\"/usr/share\""]], - [[FALLBACK_DATA_DIRS="\"/usr/share:/usr/local/share\""]], - }) diff --git a/third_party/vulkan/loader/trampoline.c b/third_party/vulkan/loader/trampoline.c deleted file mode 100644 index 607085c69..000000000 --- a/third_party/vulkan/loader/trampoline.c +++ /dev/null @@ -1,1994 +0,0 @@ -/* - * - * Copyright (c) 2015-2016 The Khronos Group Inc. - * Copyright (c) 2015-2016 Valve Corporation - * Copyright (c) 2015-2016 LunarG, Inc. - * Copyright (C) 2015 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Author: Courtney Goeltzenleuchter - * Author: Jon Ashburn - * Author: Tony Barbour - * Author: Chia-I Wu - */ -#define _GNU_SOURCE -#include -#include - -#include "vk_loader_platform.h" -#include "loader.h" -#include "debug_report.h" -#include "wsi.h" -#include "vk_loader_extensions.h" -#include "gpa_helper.h" - -// Trampoline entrypoints are in this file for core Vulkan commands - -// Get an instance level or global level entry point address. -// @param instance -// @param pName -// @return -// If instance == NULL returns a global level functions only -// If instance is valid returns a trampoline entry point for all dispatchable Vulkan -// functions both core and extensions. -LOADER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance, const char *pName) { - void *addr; - - addr = globalGetProcAddr(pName); - if (instance == VK_NULL_HANDLE || addr != NULL) { - return addr; - } - - struct loader_instance *ptr_instance = loader_get_instance(instance); - 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. - // Instance extensions are returned if the extension is enabled and the - // loader or someone else supports the extension - return trampolineGetProcAddr(ptr_instance, pName); -} - -// Get a device level or global level entry point address. -// @param device -// @param pName -// @return -// If device is valid, returns a device relative entry point for device level -// entry points both core and extensions. -// Device relative means call down the device chain. -LOADER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetDeviceProcAddr(VkDevice device, const char *pName) { - void *addr; - - // For entrypoints that loader must handle (ie non-dispatchable or create object) - // make sure the loader entrypoint is returned - addr = loader_non_passthrough_gdpa(pName); - if (addr) { - return addr; - } - - // 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; - - // Return the dispatch table entrypoint for the fastest case - const VkLayerDispatchTable *disp_table = *(VkLayerDispatchTable **)device; - if (disp_table == NULL) return NULL; - - addr = loader_lookup_device_dispatch_table(disp_table, pName); - if (addr) return addr; - - if (disp_table->GetDeviceProcAddr == NULL) return NULL; - return disp_table->GetDeviceProcAddr(device, pName); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceExtensionProperties(const char *pLayerName, - uint32_t *pPropertyCount, - VkExtensionProperties *pProperties) { - tls_instance = NULL; - LOADER_PLATFORM_THREAD_ONCE(&once_init, loader_initialize); - - // We know we need to call at least the terminator - VkResult res = VK_SUCCESS; - VkEnumerateInstanceExtensionPropertiesChain chain_tail = { - .header = - { - .type = VK_CHAIN_TYPE_ENUMERATE_INSTANCE_EXTENSION_PROPERTIES, - .version = VK_CURRENT_CHAIN_VERSION, - .size = sizeof(chain_tail), - }, - .pfnNextLayer = &terminator_EnumerateInstanceExtensionProperties, - .pNextLink = NULL, - }; - VkEnumerateInstanceExtensionPropertiesChain *chain_head = &chain_tail; - - // Get the implicit layers - struct loader_layer_list layers; - memset(&layers, 0, sizeof(layers)); - loader_implicit_layer_scan(NULL, &layers); - - // We'll need to save the dl handles so we can close them later - loader_platform_dl_handle *libs = malloc(sizeof(loader_platform_dl_handle) * layers.count); - if (libs == NULL) { - return VK_ERROR_OUT_OF_HOST_MEMORY; - } - size_t lib_count = 0; - - // Prepend layers onto the chain if they implment this entry point - for (uint32_t i = 0; i < layers.count; ++i) { - if (!loader_is_implicit_layer_enabled(NULL, layers.list + i) || - layers.list[i].pre_instance_functions.enumerate_instance_extension_properties[0] == '\0') { - continue; - } - - loader_platform_dl_handle layer_lib = loader_platform_open_library(layers.list[i].lib_name); - libs[lib_count++] = layer_lib; - void *pfn = loader_platform_get_proc_address(layer_lib, - layers.list[i].pre_instance_functions.enumerate_instance_extension_properties); - if (pfn == NULL) { - loader_log(NULL, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, - "%s: Unable to resolve symbol \"%s\" in implicit layer library \"%s\"", __FUNCTION__, - layers.list[i].pre_instance_functions.enumerate_instance_extension_properties, layers.list[i].lib_name); - continue; - } - - VkEnumerateInstanceExtensionPropertiesChain *chain_link = malloc(sizeof(VkEnumerateInstanceExtensionPropertiesChain)); - if (chain_link == NULL) { - res = VK_ERROR_OUT_OF_HOST_MEMORY; - break; - } - - chain_link->header.type = VK_CHAIN_TYPE_ENUMERATE_INSTANCE_EXTENSION_PROPERTIES; - chain_link->header.version = VK_CURRENT_CHAIN_VERSION; - chain_link->header.size = sizeof(*chain_link); - chain_link->pfnNextLayer = pfn; - chain_link->pNextLink = chain_head; - - chain_head = chain_link; - } - - // Call down the chain - if (res == VK_SUCCESS) { - res = chain_head->pfnNextLayer(chain_head->pNextLink, pLayerName, pPropertyCount, pProperties); - } - - // Free up the layers - loader_delete_layer_properties(NULL, &layers); - - // Tear down the chain - while (chain_head != &chain_tail) { - VkEnumerateInstanceExtensionPropertiesChain *holder = chain_head; - chain_head = (VkEnumerateInstanceExtensionPropertiesChain *)chain_head->pNextLink; - free(holder); - } - - // Close the dl handles - for (size_t i = 0; i < lib_count; ++i) { - loader_platform_close_library(libs[i]); - } - free(libs); - - return res; -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceLayerProperties(uint32_t *pPropertyCount, - VkLayerProperties *pProperties) { - tls_instance = NULL; - LOADER_PLATFORM_THREAD_ONCE(&once_init, loader_initialize); - - // We know we need to call at least the terminator - VkResult res = VK_SUCCESS; - VkEnumerateInstanceLayerPropertiesChain chain_tail = { - .header = - { - .type = VK_CHAIN_TYPE_ENUMERATE_INSTANCE_LAYER_PROPERTIES, - .version = VK_CURRENT_CHAIN_VERSION, - .size = sizeof(chain_tail), - }, - .pfnNextLayer = &terminator_EnumerateInstanceLayerProperties, - .pNextLink = NULL, - }; - VkEnumerateInstanceLayerPropertiesChain *chain_head = &chain_tail; - - // Get the implicit layers - struct loader_layer_list layers; - memset(&layers, 0, sizeof(layers)); - loader_implicit_layer_scan(NULL, &layers); - - // We'll need to save the dl handles so we can close them later - loader_platform_dl_handle *libs = malloc(sizeof(loader_platform_dl_handle) * layers.count); - if (libs == NULL) { - return VK_ERROR_OUT_OF_HOST_MEMORY; - } - size_t lib_count = 0; - - // Prepend layers onto the chain if they implment this entry point - for (uint32_t i = 0; i < layers.count; ++i) { - if (!loader_is_implicit_layer_enabled(NULL, layers.list + i) || - layers.list[i].pre_instance_functions.enumerate_instance_layer_properties[0] == '\0') { - continue; - } - - loader_platform_dl_handle layer_lib = loader_platform_open_library(layers.list[i].lib_name); - libs[lib_count++] = layer_lib; - void *pfn = - loader_platform_get_proc_address(layer_lib, layers.list[i].pre_instance_functions.enumerate_instance_layer_properties); - if (pfn == NULL) { - loader_log(NULL, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, - "%s: Unable to resolve symbol \"%s\" in implicit layer library \"%s\"", __FUNCTION__, - layers.list[i].pre_instance_functions.enumerate_instance_layer_properties, layers.list[i].lib_name); - continue; - } - - VkEnumerateInstanceLayerPropertiesChain *chain_link = malloc(sizeof(VkEnumerateInstanceLayerPropertiesChain)); - if (chain_link == NULL) { - res = VK_ERROR_OUT_OF_HOST_MEMORY; - break; - } - - chain_link->header.type = VK_CHAIN_TYPE_ENUMERATE_INSTANCE_LAYER_PROPERTIES; - chain_link->header.version = VK_CURRENT_CHAIN_VERSION; - chain_link->header.size = sizeof(*chain_link); - chain_link->pfnNextLayer = pfn; - chain_link->pNextLink = chain_head; - - chain_head = chain_link; - } - - // Call down the chain - if (res == VK_SUCCESS) { - res = chain_head->pfnNextLayer(chain_head->pNextLink, pPropertyCount, pProperties); - } - - // Free up the layers - loader_delete_layer_properties(NULL, &layers); - - // Tear down the chain - while (chain_head != &chain_tail) { - VkEnumerateInstanceLayerPropertiesChain *holder = chain_head; - chain_head = (VkEnumerateInstanceLayerPropertiesChain *)chain_head->pNextLink; - free(holder); - } - - // Close the dl handles - for (size_t i = 0; i < lib_count; ++i) { - loader_platform_close_library(libs[i]); - } - free(libs); - - return res; -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(const VkInstanceCreateInfo *pCreateInfo, - const VkAllocationCallbacks *pAllocator, VkInstance *pInstance) { - struct loader_instance *ptr_instance = NULL; - VkInstance created_instance = VK_NULL_HANDLE; - bool loaderLocked = false; - VkResult res = VK_ERROR_INITIALIZATION_FAILED; - - LOADER_PLATFORM_THREAD_ONCE(&once_init, loader_initialize); - - // Fail if the requested Vulkan apiVersion is > 1.0 since the loader only supports 1.0. - // Having pCreateInfo == NULL, pCreateInfo->pApplication == NULL, or - // pCreateInfo->pApplicationInfo->apiVersion == 0 all indicate that the application is - // only requesting a 1.0 instance, which this loader will always support. - uint32_t loader_major_version = 1; - uint32_t loader_minor_version = 0; - if (NULL != pCreateInfo && NULL != pCreateInfo->pApplicationInfo && - pCreateInfo->pApplicationInfo->apiVersion >= VK_MAKE_VERSION(loader_major_version, loader_minor_version + 1, 0)) { - loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "vkCreateInstance: Called with invalid API version %d.%d. Loader only supports %d.%d", - VK_VERSION_MAJOR(pCreateInfo->pApplicationInfo->apiVersion), - VK_VERSION_MINOR(pCreateInfo->pApplicationInfo->apiVersion), loader_major_version, loader_minor_version); - res = VK_ERROR_INCOMPATIBLE_DRIVER; - goto out; - } - -#if (DEBUG_DISABLE_APP_ALLOCATORS == 1) - { -#else - if (pAllocator) { - ptr_instance = (struct loader_instance *)pAllocator->pfnAllocation(pAllocator->pUserData, sizeof(struct loader_instance), - sizeof(int *), VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); - } else { -#endif - ptr_instance = (struct loader_instance *)malloc(sizeof(struct loader_instance)); - } - - VkInstanceCreateInfo ici = *pCreateInfo; - - if (ptr_instance == NULL) { - res = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - - tls_instance = ptr_instance; - loader_platform_thread_lock_mutex(&loader_lock); - loaderLocked = true; - memset(ptr_instance, 0, sizeof(struct loader_instance)); - if (pAllocator) { - ptr_instance->alloc_callbacks = *pAllocator; - } - - // Look for one or more debug report create info structures - // and setup a callback(s) for each one found. - ptr_instance->num_tmp_callbacks = 0; - ptr_instance->tmp_dbg_create_infos = NULL; - ptr_instance->tmp_callbacks = NULL; - if (util_CopyDebugReportCreateInfos(pCreateInfo->pNext, pAllocator, &ptr_instance->num_tmp_callbacks, - &ptr_instance->tmp_dbg_create_infos, &ptr_instance->tmp_callbacks)) { - // One or more were found, but allocation failed. Therefore, clean up - // and fail this function: - res = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } else if (ptr_instance->num_tmp_callbacks > 0) { - // Setup the temporary callback(s) here to catch early issues: - if (util_CreateDebugReportCallbacks(ptr_instance, pAllocator, ptr_instance->num_tmp_callbacks, - ptr_instance->tmp_dbg_create_infos, ptr_instance->tmp_callbacks)) { - // Failure of setting up one or more of the callback. Therefore, - // clean up and fail this function: - res = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - } - - // Due to implicit layers need to get layer list even if - // enabledLayerCount == 0 and VK_INSTANCE_LAYERS is unset. For now always - // get layer list via loader_layer_scan(). - memset(&ptr_instance->instance_layer_list, 0, sizeof(ptr_instance->instance_layer_list)); - loader_layer_scan(ptr_instance, &ptr_instance->instance_layer_list); - - // Validate the app requested layers to be enabled - if (pCreateInfo->enabledLayerCount > 0) { - res = loader_validate_layers(ptr_instance, pCreateInfo->enabledLayerCount, pCreateInfo->ppEnabledLayerNames, - &ptr_instance->instance_layer_list); - if (res != VK_SUCCESS) { - goto out; - } - } - - // Scan/discover all ICD libraries - memset(&ptr_instance->icd_tramp_list, 0, sizeof(ptr_instance->icd_tramp_list)); - res = loader_icd_scan(ptr_instance, &ptr_instance->icd_tramp_list); - if (res != VK_SUCCESS) { - goto out; - } - - // Get extensions from all ICD's, merge so no duplicates, then validate - res = loader_get_icd_loader_instance_extensions(ptr_instance, &ptr_instance->icd_tramp_list, &ptr_instance->ext_list); - if (res != VK_SUCCESS) { - goto out; - } - res = loader_validate_instance_extensions(ptr_instance, &ptr_instance->ext_list, &ptr_instance->instance_layer_list, &ici); - if (res != VK_SUCCESS) { - goto out; - } - - ptr_instance->disp = loader_instance_heap_alloc(ptr_instance, sizeof(struct loader_instance_dispatch_table), - 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 Loader's full Instance dispatch table."); - res = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - memcpy(&ptr_instance->disp->layer_inst_disp, &instance_disp, sizeof(instance_disp)); - - ptr_instance->next = loader.instances; - loader.instances = ptr_instance; - - // Activate any layers on instance chain - res = loader_enable_instance_layers(ptr_instance, &ici, &ptr_instance->instance_layer_list); - if (res != VK_SUCCESS) { - goto out; - } - - created_instance = (VkInstance)ptr_instance; - res = loader_create_instance_chain(&ici, pAllocator, ptr_instance, &created_instance); - - if (res == VK_SUCCESS) { - memset(ptr_instance->enabled_known_extensions.padding, 0, sizeof(uint64_t) * 4); - - wsi_create_instance(ptr_instance, &ici); - debug_report_create_instance(ptr_instance, &ici); - extensions_create_instance(ptr_instance, &ici); - - *pInstance = created_instance; - - // Finally have the layers in place and everyone has seen - // the CreateInstance command go by. This allows the layer's - // GetInstanceProcAddr functions to return valid extension functions - // if enabled. - loader_activate_instance_layer_extensions(ptr_instance, *pInstance); - } - -out: - - if (NULL != ptr_instance) { - if (res != VK_SUCCESS) { - if (NULL != ptr_instance->next) { - loader.instances = ptr_instance->next; - } - if (NULL != ptr_instance->disp) { - loader_instance_heap_free(ptr_instance, ptr_instance->disp); - } - if (ptr_instance->num_tmp_callbacks > 0) { - util_DestroyDebugReportCallbacks(ptr_instance, pAllocator, ptr_instance->num_tmp_callbacks, - ptr_instance->tmp_callbacks); - util_FreeDebugReportCreateInfos(pAllocator, ptr_instance->tmp_dbg_create_infos, ptr_instance->tmp_callbacks); - } - - if (NULL != ptr_instance->expanded_activated_layer_list.list) { - loader_deactivate_layers(ptr_instance, NULL, &ptr_instance->expanded_activated_layer_list); - } - if (NULL != ptr_instance->app_activated_layer_list.list) { - loader_destroy_layer_list(ptr_instance, NULL, &ptr_instance->app_activated_layer_list); - } - - loader_delete_layer_properties(ptr_instance, &ptr_instance->instance_layer_list); - loader_scanned_icd_clear(ptr_instance, &ptr_instance->icd_tramp_list); - loader_destroy_generic_list(ptr_instance, (struct loader_generic_list *)&ptr_instance->ext_list); - - loader_instance_heap_free(ptr_instance, ptr_instance); - } else { - // Remove temporary debug_report callback - util_DestroyDebugReportCallbacks(ptr_instance, pAllocator, ptr_instance->num_tmp_callbacks, - ptr_instance->tmp_callbacks); - } - - if (loaderLocked) { - loader_platform_thread_unlock_mutex(&loader_lock); - } - } - - return res; -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) { - const VkLayerInstanceDispatchTable *disp; - struct loader_instance *ptr_instance = NULL; - bool callback_setup = false; - - if (instance == VK_NULL_HANDLE) { - return; - } - - disp = loader_get_instance_layer_dispatch(instance); - - loader_platform_thread_lock_mutex(&loader_lock); - - ptr_instance = loader_get_instance(instance); - - if (pAllocator) { - ptr_instance->alloc_callbacks = *pAllocator; - } - - if (ptr_instance->num_tmp_callbacks > 0) { - // Setup the temporary callback(s) here to catch cleanup issues: - if (!util_CreateDebugReportCallbacks(ptr_instance, pAllocator, ptr_instance->num_tmp_callbacks, - ptr_instance->tmp_dbg_create_infos, ptr_instance->tmp_callbacks)) { - callback_setup = true; - } - } - - disp->DestroyInstance(instance, pAllocator); - - if (NULL != ptr_instance->expanded_activated_layer_list.list) { - loader_deactivate_layers(ptr_instance, NULL, &ptr_instance->expanded_activated_layer_list); - } - if (NULL != ptr_instance->app_activated_layer_list.list) { - loader_destroy_layer_list(ptr_instance, NULL, &ptr_instance->app_activated_layer_list); - } - - if (ptr_instance->phys_devs_tramp) { - for (uint32_t i = 0; i < ptr_instance->phys_dev_count_tramp; i++) { - loader_instance_heap_free(ptr_instance, ptr_instance->phys_devs_tramp[i]); - } - loader_instance_heap_free(ptr_instance, ptr_instance->phys_devs_tramp); - } - - if (ptr_instance->phys_dev_groups_tramp) { - for (uint32_t i = 0; i < ptr_instance->phys_dev_group_count_tramp; i++) { - loader_instance_heap_free(ptr_instance, ptr_instance->phys_dev_groups_tramp[i]); - } - loader_instance_heap_free(ptr_instance, ptr_instance->phys_dev_groups_tramp); - } - - if (callback_setup) { - util_DestroyDebugReportCallbacks(ptr_instance, pAllocator, ptr_instance->num_tmp_callbacks, ptr_instance->tmp_callbacks); - util_FreeDebugReportCreateInfos(pAllocator, ptr_instance->tmp_dbg_create_infos, ptr_instance->tmp_callbacks); - } - loader_instance_heap_free(ptr_instance, ptr_instance->disp); - loader_instance_heap_free(ptr_instance, ptr_instance); - loader_platform_thread_unlock_mutex(&loader_lock); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount, - VkPhysicalDevice *pPhysicalDevices) { - VkResult res = VK_SUCCESS; - uint32_t count; - uint32_t i; - struct loader_instance *inst; - - loader_platform_thread_lock_mutex(&loader_lock); - - inst = loader_get_instance(instance); - if (NULL == inst) { - res = VK_ERROR_INITIALIZATION_FAILED; - goto out; - } - - if (NULL == pPhysicalDeviceCount) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "vkEnumeratePhysicalDevices: Received NULL pointer for physical device count return value."); - res = VK_ERROR_INITIALIZATION_FAILED; - goto out; - } - - // Setup the trampoline loader physical devices. This will actually - // call down and setup the terminator loader physical devices during the - // process. - VkResult setup_res = setupLoaderTrampPhysDevs(instance); - if (setup_res != VK_SUCCESS && setup_res != VK_INCOMPLETE) { - res = setup_res; - goto out; - } - - count = inst->phys_dev_count_tramp; - - // Wrap the PhysDev object for loader usage, return wrapped objects - if (NULL != pPhysicalDevices) { - if (inst->phys_dev_count_tramp > *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", - inst->phys_dev_count_tramp, *pPhysicalDeviceCount); - count = *pPhysicalDeviceCount; - res = VK_INCOMPLETE; - } - for (i = 0; i < count; i++) { - pPhysicalDevices[i] = (VkPhysicalDevice)inst->phys_devs_tramp[i]; - } - } - - *pPhysicalDeviceCount = count; - -out: - - loader_platform_thread_unlock_mutex(&loader_lock); - return res; -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFeatures(VkPhysicalDevice physicalDevice, - VkPhysicalDeviceFeatures *pFeatures) { - const VkLayerInstanceDispatchTable *disp; - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - disp->GetPhysicalDeviceFeatures(unwrapped_phys_dev, pFeatures); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, - VkFormatProperties *pFormatInfo) { - const VkLayerInstanceDispatchTable *disp; - VkPhysicalDevice unwrapped_pd = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - disp->GetPhysicalDeviceFormatProperties(unwrapped_pd, format, pFormatInfo); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceImageFormatProperties( - VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, - VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties) { - const VkLayerInstanceDispatchTable *disp; - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - return disp->GetPhysicalDeviceImageFormatProperties(unwrapped_phys_dev, format, type, tiling, usage, flags, - pImageFormatProperties); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice, - VkPhysicalDeviceProperties *pProperties) { - const VkLayerInstanceDispatchTable *disp; - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - disp->GetPhysicalDeviceProperties(unwrapped_phys_dev, pProperties); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice physicalDevice, - uint32_t *pQueueFamilyPropertyCount, - VkQueueFamilyProperties *pQueueProperties) { - const VkLayerInstanceDispatchTable *disp; - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - disp->GetPhysicalDeviceQueueFamilyProperties(unwrapped_phys_dev, pQueueFamilyPropertyCount, pQueueProperties); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceMemoryProperties(VkPhysicalDevice physicalDevice, - VkPhysicalDeviceMemoryProperties *pMemoryProperties) { - const VkLayerInstanceDispatchTable *disp; - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - disp->GetPhysicalDeviceMemoryProperties(unwrapped_phys_dev, pMemoryProperties); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo, - const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) { - VkResult res; - struct loader_physical_device_tramp *phys_dev = NULL; - struct loader_device *dev = NULL; - struct loader_instance *inst = NULL; - - assert(pCreateInfo->queueCreateInfoCount >= 1); - - loader_platform_thread_lock_mutex(&loader_lock); - - phys_dev = (struct loader_physical_device_tramp *)physicalDevice; - inst = (struct loader_instance *)phys_dev->this_instance; - - // Get the physical device (ICD) extensions - struct loader_extension_list icd_exts; - icd_exts.list = NULL; - res = loader_init_generic_list(inst, (struct loader_generic_list *)&icd_exts, sizeof(VkExtensionProperties)); - if (VK_SUCCESS != res) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "vkCreateDevice: Failed to create ICD extension list"); - goto out; - } - - res = loader_add_device_extensions(inst, inst->disp->layer_inst_disp.EnumerateDeviceExtensionProperties, phys_dev->phys_dev, - "Unknown", &icd_exts); - if (res != VK_SUCCESS) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "vkCreateDevice: Failed to add extensions to list"); - goto out; - } - - // Make sure requested extensions to be enabled are supported - res = loader_validate_device_extensions(phys_dev, &inst->expanded_activated_layer_list, &icd_exts, pCreateInfo); - if (res != VK_SUCCESS) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "vkCreateDevice: Failed to validate extensions in list"); - goto out; - } - - dev = loader_create_logical_device(inst, pAllocator); - if (dev == NULL) { - res = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - - // Copy the application enabled instance layer list into the device - if (NULL != inst->app_activated_layer_list.list) { - dev->app_activated_layer_list.capacity = inst->app_activated_layer_list.capacity; - dev->app_activated_layer_list.count = inst->app_activated_layer_list.count; - dev->app_activated_layer_list.list = - loader_device_heap_alloc(dev, inst->app_activated_layer_list.capacity, VK_SYSTEM_ALLOCATION_SCOPE_DEVICE); - if (dev->app_activated_layer_list.list == NULL) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "vkCreateDevice: Failed to allocate application activated layer list of size %d.", - inst->app_activated_layer_list.capacity); - res = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - memcpy(dev->app_activated_layer_list.list, inst->app_activated_layer_list.list, - sizeof(*dev->app_activated_layer_list.list) * dev->app_activated_layer_list.count); - } else { - dev->app_activated_layer_list.capacity = 0; - dev->app_activated_layer_list.count = 0; - dev->app_activated_layer_list.list = NULL; - } - - // Copy the expanded enabled instance layer list into the device - if (NULL != inst->expanded_activated_layer_list.list) { - dev->expanded_activated_layer_list.capacity = inst->expanded_activated_layer_list.capacity; - dev->expanded_activated_layer_list.count = inst->expanded_activated_layer_list.count; - dev->expanded_activated_layer_list.list = - loader_device_heap_alloc(dev, inst->expanded_activated_layer_list.capacity, VK_SYSTEM_ALLOCATION_SCOPE_DEVICE); - if (dev->expanded_activated_layer_list.list == NULL) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "vkCreateDevice: Failed to allocate expanded activated layer list of size %d.", - inst->expanded_activated_layer_list.capacity); - res = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - memcpy(dev->expanded_activated_layer_list.list, inst->expanded_activated_layer_list.list, - sizeof(*dev->expanded_activated_layer_list.list) * dev->expanded_activated_layer_list.count); - } else { - dev->expanded_activated_layer_list.capacity = 0; - dev->expanded_activated_layer_list.count = 0; - dev->expanded_activated_layer_list.list = NULL; - } - - res = loader_create_device_chain(phys_dev, pCreateInfo, pAllocator, inst, dev); - if (res != VK_SUCCESS) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "vkCreateDevice: Failed to create device chain."); - goto out; - } - - *pDevice = dev->chain_device; - - // Initialize any device extension dispatch entry's from the instance list - loader_init_dispatch_dev_ext(inst, dev); - - // Initialize WSI device extensions as part of core dispatch since loader - // has dedicated trampoline code for these*/ - loader_init_device_extension_dispatch_table(&dev->loader_dispatch, dev->loader_dispatch.core_dispatch.GetDeviceProcAddr, - *pDevice); - -out: - - // Failure cleanup - if (VK_SUCCESS != res) { - if (NULL != dev) { - loader_destroy_logical_device(inst, dev, pAllocator); - } - } - - if (NULL != icd_exts.list) { - loader_destroy_generic_list(inst, (struct loader_generic_list *)&icd_exts); - } - loader_platform_thread_unlock_mutex(&loader_lock); - return res; -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator) { - const VkLayerDispatchTable *disp; - struct loader_device *dev; - - if (device == VK_NULL_HANDLE) { - return; - } - - loader_platform_thread_lock_mutex(&loader_lock); - - struct loader_icd_term *icd_term = loader_get_icd_and_device(device, &dev, NULL); - const struct loader_instance *inst = icd_term->this_instance; - disp = loader_get_dispatch(device); - - disp->DestroyDevice(device, pAllocator); - dev->chain_device = NULL; - dev->icd_device = NULL; - loader_remove_logical_device(inst, icd_term, dev, pAllocator); - - loader_platform_thread_unlock_mutex(&loader_lock); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, - const char *pLayerName, uint32_t *pPropertyCount, - VkExtensionProperties *pProperties) { - VkResult res = VK_SUCCESS; - struct loader_physical_device_tramp *phys_dev; - phys_dev = (struct loader_physical_device_tramp *)physicalDevice; - - loader_platform_thread_lock_mutex(&loader_lock); - - // If pLayerName == NULL, then querying ICD extensions, pass this call - // down the instance chain which will terminate in the ICD. This allows - // layers to filter the extensions coming back up the chain. - // If pLayerName != NULL then get layer extensions from manifest file. - if (pLayerName == NULL || strlen(pLayerName) == 0) { - const VkLayerInstanceDispatchTable *disp; - - 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; - struct loader_device_extension_list *dev_ext_list = NULL; - struct loader_device_extension_list local_ext_list; - memset(&local_ext_list, 0, sizeof(local_ext_list)); - if (vk_string_validate(MaxLoaderStringLength, pLayerName) == VK_STRING_ERROR_NONE) { - for (uint32_t i = 0; i < inst->instance_layer_list.count; i++) { - struct loader_layer_properties *props = &inst->instance_layer_list.list[i]; - if (strcmp(props->info.layerName, pLayerName) == 0) { - dev_ext_list = &props->device_extension_list; - } - } - - count = (dev_ext_list == NULL) ? 0 : dev_ext_list->count; - if (pProperties == NULL) { - *pPropertyCount = count; - loader_destroy_generic_list(inst, (struct loader_generic_list *)&local_ext_list); - loader_platform_thread_unlock_mutex(&loader_lock); - return VK_SUCCESS; - } - - copy_size = *pPropertyCount < count ? *pPropertyCount : count; - for (uint32_t i = 0; i < copy_size; i++) { - memcpy(&pProperties[i], &dev_ext_list->list[i].props, sizeof(VkExtensionProperties)); - } - *pPropertyCount = copy_size; - - loader_destroy_generic_list(inst, (struct loader_generic_list *)&local_ext_list); - if (copy_size < count) { - loader_platform_thread_unlock_mutex(&loader_lock); - return VK_INCOMPLETE; - } - } else { - 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; - } - } - - loader_platform_thread_unlock_mutex(&loader_lock); - return res; -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, - uint32_t *pPropertyCount, - VkLayerProperties *pProperties) { - uint32_t copy_size; - struct loader_physical_device_tramp *phys_dev; - struct loader_layer_list *enabled_layers, layers_list; - memset(&layers_list, 0, sizeof(layers_list)); - loader_platform_thread_lock_mutex(&loader_lock); - - // Don't dispatch this call down the instance chain, want all device layers - // enumerated and instance chain may not contain all device layers - // TODO re-evaluate the above statement we maybe able to start calling - // down the chain - - phys_dev = (struct loader_physical_device_tramp *)physicalDevice; - const struct loader_instance *inst = phys_dev->this_instance; - - uint32_t count = inst->app_activated_layer_list.count; - if (count == 0 || pProperties == NULL) { - *pPropertyCount = count; - loader_platform_thread_unlock_mutex(&loader_lock); - return VK_SUCCESS; - } - enabled_layers = (struct loader_layer_list *)&inst->app_activated_layer_list; - - copy_size = (*pPropertyCount < count) ? *pPropertyCount : count; - for (uint32_t i = 0; i < copy_size; i++) { - memcpy(&pProperties[i], &(enabled_layers->list[i].info), sizeof(VkLayerProperties)); - } - *pPropertyCount = copy_size; - - if (copy_size < count) { - loader_platform_thread_unlock_mutex(&loader_lock); - return VK_INCOMPLETE; - } - - loader_platform_thread_unlock_mutex(&loader_lock); - return VK_SUCCESS; -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetDeviceQueue(VkDevice device, uint32_t queueNodeIndex, uint32_t queueIndex, - VkQueue *pQueue) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - disp->GetDeviceQueue(device, queueNodeIndex, queueIndex, pQueue); - loader_set_dispatch(*pQueue, disp); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkQueueSubmit(VkQueue queue, uint32_t submitCount, const VkSubmitInfo *pSubmits, - VkFence fence) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(queue); - - return disp->QueueSubmit(queue, submitCount, pSubmits, fence); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkQueueWaitIdle(VkQueue queue) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(queue); - - return disp->QueueWaitIdle(queue); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkDeviceWaitIdle(VkDevice device) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - return disp->DeviceWaitIdle(device); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo, - const VkAllocationCallbacks *pAllocator, VkDeviceMemory *pMemory) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - return disp->AllocateMemory(device, pAllocateInfo, pAllocator, pMemory); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkFreeMemory(VkDevice device, VkDeviceMemory mem, - const VkAllocationCallbacks *pAllocator) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - disp->FreeMemory(device, mem, pAllocator); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkMapMemory(VkDevice device, VkDeviceMemory mem, VkDeviceSize offset, - VkDeviceSize size, VkFlags flags, void **ppData) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - return disp->MapMemory(device, mem, offset, size, flags, ppData); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkUnmapMemory(VkDevice device, VkDeviceMemory mem) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - disp->UnmapMemory(device, mem); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkFlushMappedMemoryRanges(VkDevice device, uint32_t memoryRangeCount, - const VkMappedMemoryRange *pMemoryRanges) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - return disp->FlushMappedMemoryRanges(device, memoryRangeCount, pMemoryRanges); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkInvalidateMappedMemoryRanges(VkDevice device, uint32_t memoryRangeCount, - const VkMappedMemoryRange *pMemoryRanges) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - return disp->InvalidateMappedMemoryRanges(device, memoryRangeCount, pMemoryRanges); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetDeviceMemoryCommitment(VkDevice device, VkDeviceMemory memory, - VkDeviceSize *pCommittedMemoryInBytes) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - disp->GetDeviceMemoryCommitment(device, memory, pCommittedMemoryInBytes); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkBindBufferMemory(VkDevice device, VkBuffer buffer, VkDeviceMemory mem, - VkDeviceSize offset) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - return disp->BindBufferMemory(device, buffer, mem, offset); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkBindImageMemory(VkDevice device, VkImage image, VkDeviceMemory mem, - VkDeviceSize offset) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - return disp->BindImageMemory(device, image, mem, offset); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetBufferMemoryRequirements(VkDevice device, VkBuffer buffer, - VkMemoryRequirements *pMemoryRequirements) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - disp->GetBufferMemoryRequirements(device, buffer, pMemoryRequirements); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetImageMemoryRequirements(VkDevice device, VkImage image, - VkMemoryRequirements *pMemoryRequirements) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - disp->GetImageMemoryRequirements(device, image, pMemoryRequirements); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL -vkGetImageSparseMemoryRequirements(VkDevice device, VkImage image, uint32_t *pSparseMemoryRequirementCount, - VkSparseImageMemoryRequirements *pSparseMemoryRequirements) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - disp->GetImageSparseMemoryRequirements(device, image, pSparseMemoryRequirementCount, pSparseMemoryRequirements); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceSparseImageFormatProperties( - VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkSampleCountFlagBits samples, VkImageUsageFlags usage, - VkImageTiling tiling, uint32_t *pPropertyCount, VkSparseImageFormatProperties *pProperties) { - const VkLayerInstanceDispatchTable *disp; - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - - disp->GetPhysicalDeviceSparseImageFormatProperties(unwrapped_phys_dev, format, type, samples, usage, tiling, pPropertyCount, - pProperties); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkQueueBindSparse(VkQueue queue, uint32_t bindInfoCount, - const VkBindSparseInfo *pBindInfo, VkFence fence) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(queue); - - return disp->QueueBindSparse(queue, bindInfoCount, pBindInfo, fence); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateFence(VkDevice device, const VkFenceCreateInfo *pCreateInfo, - const VkAllocationCallbacks *pAllocator, VkFence *pFence) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - return disp->CreateFence(device, pCreateInfo, pAllocator, pFence); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyFence(VkDevice device, VkFence fence, const VkAllocationCallbacks *pAllocator) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - disp->DestroyFence(device, fence, pAllocator); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkResetFences(VkDevice device, uint32_t fenceCount, const VkFence *pFences) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - return disp->ResetFences(device, fenceCount, pFences); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetFenceStatus(VkDevice device, VkFence fence) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - return disp->GetFenceStatus(device, fence); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkWaitForFences(VkDevice device, uint32_t fenceCount, const VkFence *pFences, - VkBool32 waitAll, uint64_t timeout) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - return disp->WaitForFences(device, fenceCount, pFences, waitAll, timeout); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateSemaphore(VkDevice device, const VkSemaphoreCreateInfo *pCreateInfo, - const VkAllocationCallbacks *pAllocator, VkSemaphore *pSemaphore) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - return disp->CreateSemaphore(device, pCreateInfo, pAllocator, pSemaphore); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroySemaphore(VkDevice device, VkSemaphore semaphore, - const VkAllocationCallbacks *pAllocator) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - disp->DestroySemaphore(device, semaphore, pAllocator); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateEvent(VkDevice device, const VkEventCreateInfo *pCreateInfo, - const VkAllocationCallbacks *pAllocator, VkEvent *pEvent) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - return disp->CreateEvent(device, pCreateInfo, pAllocator, pEvent); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyEvent(VkDevice device, VkEvent event, const VkAllocationCallbacks *pAllocator) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - disp->DestroyEvent(device, event, pAllocator); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetEventStatus(VkDevice device, VkEvent event) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - return disp->GetEventStatus(device, event); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkSetEvent(VkDevice device, VkEvent event) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - return disp->SetEvent(device, event); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkResetEvent(VkDevice device, VkEvent event) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - return disp->ResetEvent(device, event); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo, - const VkAllocationCallbacks *pAllocator, VkQueryPool *pQueryPool) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - return disp->CreateQueryPool(device, pCreateInfo, pAllocator, pQueryPool); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyQueryPool(VkDevice device, VkQueryPool queryPool, - const VkAllocationCallbacks *pAllocator) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - disp->DestroyQueryPool(device, queryPool, pAllocator); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetQueryPoolResults(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery, - uint32_t queryCount, size_t dataSize, void *pData, - VkDeviceSize stride, VkQueryResultFlags flags) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - return disp->GetQueryPoolResults(device, queryPool, firstQuery, queryCount, dataSize, pData, stride, flags); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo, - const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - return disp->CreateBuffer(device, pCreateInfo, pAllocator, pBuffer); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyBuffer(VkDevice device, VkBuffer buffer, - const VkAllocationCallbacks *pAllocator) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - disp->DestroyBuffer(device, buffer, pAllocator); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateBufferView(VkDevice device, const VkBufferViewCreateInfo *pCreateInfo, - const VkAllocationCallbacks *pAllocator, VkBufferView *pView) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - return disp->CreateBufferView(device, pCreateInfo, pAllocator, pView); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyBufferView(VkDevice device, VkBufferView bufferView, - const VkAllocationCallbacks *pAllocator) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - disp->DestroyBufferView(device, bufferView, pAllocator); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo, - const VkAllocationCallbacks *pAllocator, VkImage *pImage) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - return disp->CreateImage(device, pCreateInfo, pAllocator, pImage); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyImage(VkDevice device, VkImage image, const VkAllocationCallbacks *pAllocator) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - disp->DestroyImage(device, image, pAllocator); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetImageSubresourceLayout(VkDevice device, VkImage image, - const VkImageSubresource *pSubresource, - VkSubresourceLayout *pLayout) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - disp->GetImageSubresourceLayout(device, image, pSubresource, pLayout); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo, - const VkAllocationCallbacks *pAllocator, VkImageView *pView) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - return disp->CreateImageView(device, pCreateInfo, pAllocator, pView); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyImageView(VkDevice device, VkImageView imageView, - const VkAllocationCallbacks *pAllocator) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - disp->DestroyImageView(device, imageView, pAllocator); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateShaderModule(VkDevice device, const VkShaderModuleCreateInfo *pCreateInfo, - const VkAllocationCallbacks *pAllocator, - VkShaderModule *pShader) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - return disp->CreateShaderModule(device, pCreateInfo, pAllocator, pShader); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyShaderModule(VkDevice device, VkShaderModule shaderModule, - const VkAllocationCallbacks *pAllocator) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - disp->DestroyShaderModule(device, shaderModule, pAllocator); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreatePipelineCache(VkDevice device, const VkPipelineCacheCreateInfo *pCreateInfo, - const VkAllocationCallbacks *pAllocator, - VkPipelineCache *pPipelineCache) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - return disp->CreatePipelineCache(device, pCreateInfo, pAllocator, pPipelineCache); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyPipelineCache(VkDevice device, VkPipelineCache pipelineCache, - const VkAllocationCallbacks *pAllocator) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - disp->DestroyPipelineCache(device, pipelineCache, pAllocator); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPipelineCacheData(VkDevice device, VkPipelineCache pipelineCache, - size_t *pDataSize, void *pData) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - return disp->GetPipelineCacheData(device, pipelineCache, pDataSize, pData); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkMergePipelineCaches(VkDevice device, VkPipelineCache dstCache, - uint32_t srcCacheCount, const VkPipelineCache *pSrcCaches) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - return disp->MergePipelineCaches(device, dstCache, srcCacheCount, pSrcCaches); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache, - uint32_t createInfoCount, - const VkGraphicsPipelineCreateInfo *pCreateInfos, - const VkAllocationCallbacks *pAllocator, - VkPipeline *pPipelines) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - return disp->CreateGraphicsPipelines(device, pipelineCache, createInfoCount, pCreateInfos, pAllocator, pPipelines); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, - uint32_t createInfoCount, - const VkComputePipelineCreateInfo *pCreateInfos, - const VkAllocationCallbacks *pAllocator, - VkPipeline *pPipelines) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - return disp->CreateComputePipelines(device, pipelineCache, createInfoCount, pCreateInfos, pAllocator, pPipelines); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyPipeline(VkDevice device, VkPipeline pipeline, - const VkAllocationCallbacks *pAllocator) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - disp->DestroyPipeline(device, pipeline, pAllocator); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreatePipelineLayout(VkDevice device, const VkPipelineLayoutCreateInfo *pCreateInfo, - const VkAllocationCallbacks *pAllocator, - VkPipelineLayout *pPipelineLayout) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - return disp->CreatePipelineLayout(device, pCreateInfo, pAllocator, pPipelineLayout); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyPipelineLayout(VkDevice device, VkPipelineLayout pipelineLayout, - const VkAllocationCallbacks *pAllocator) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - disp->DestroyPipelineLayout(device, pipelineLayout, pAllocator); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo, - const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - return disp->CreateSampler(device, pCreateInfo, pAllocator, pSampler); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroySampler(VkDevice device, VkSampler sampler, - const VkAllocationCallbacks *pAllocator) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - disp->DestroySampler(device, sampler, pAllocator); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDescriptorSetLayout(VkDevice device, - const VkDescriptorSetLayoutCreateInfo *pCreateInfo, - const VkAllocationCallbacks *pAllocator, - VkDescriptorSetLayout *pSetLayout) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - return disp->CreateDescriptorSetLayout(device, pCreateInfo, pAllocator, pSetLayout); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyDescriptorSetLayout(VkDevice device, VkDescriptorSetLayout descriptorSetLayout, - const VkAllocationCallbacks *pAllocator) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - disp->DestroyDescriptorSetLayout(device, descriptorSetLayout, pAllocator); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo, - const VkAllocationCallbacks *pAllocator, - VkDescriptorPool *pDescriptorPool) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - return disp->CreateDescriptorPool(device, pCreateInfo, pAllocator, pDescriptorPool); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, - const VkAllocationCallbacks *pAllocator) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - disp->DestroyDescriptorPool(device, descriptorPool, pAllocator); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkResetDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, - VkDescriptorPoolResetFlags flags) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - return disp->ResetDescriptorPool(device, descriptorPool, flags); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkAllocateDescriptorSets(VkDevice device, - const VkDescriptorSetAllocateInfo *pAllocateInfo, - VkDescriptorSet *pDescriptorSets) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - return disp->AllocateDescriptorSets(device, pAllocateInfo, pDescriptorSets); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, - uint32_t descriptorSetCount, - const VkDescriptorSet *pDescriptorSets) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - return disp->FreeDescriptorSets(device, descriptorPool, descriptorSetCount, pDescriptorSets); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount, - const VkWriteDescriptorSet *pDescriptorWrites, - uint32_t descriptorCopyCount, - const VkCopyDescriptorSet *pDescriptorCopies) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - disp->UpdateDescriptorSets(device, descriptorWriteCount, pDescriptorWrites, descriptorCopyCount, pDescriptorCopies); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo, - const VkAllocationCallbacks *pAllocator, - VkFramebuffer *pFramebuffer) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - return disp->CreateFramebuffer(device, pCreateInfo, pAllocator, pFramebuffer); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyFramebuffer(VkDevice device, VkFramebuffer framebuffer, - const VkAllocationCallbacks *pAllocator) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - disp->DestroyFramebuffer(device, framebuffer, pAllocator); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo, - const VkAllocationCallbacks *pAllocator, - VkRenderPass *pRenderPass) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - return disp->CreateRenderPass(device, pCreateInfo, pAllocator, pRenderPass); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyRenderPass(VkDevice device, VkRenderPass renderPass, - const VkAllocationCallbacks *pAllocator) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - disp->DestroyRenderPass(device, renderPass, pAllocator); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetRenderAreaGranularity(VkDevice device, VkRenderPass renderPass, - VkExtent2D *pGranularity) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - disp->GetRenderAreaGranularity(device, renderPass, pGranularity); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateCommandPool(VkDevice device, const VkCommandPoolCreateInfo *pCreateInfo, - const VkAllocationCallbacks *pAllocator, - VkCommandPool *pCommandPool) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - return disp->CreateCommandPool(device, pCreateInfo, pAllocator, pCommandPool); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyCommandPool(VkDevice device, VkCommandPool commandPool, - const VkAllocationCallbacks *pAllocator) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - disp->DestroyCommandPool(device, commandPool, pAllocator); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkResetCommandPool(VkDevice device, VkCommandPool commandPool, - VkCommandPoolResetFlags flags) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - return disp->ResetCommandPool(device, commandPool, flags); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkAllocateCommandBuffers(VkDevice device, - const VkCommandBufferAllocateInfo *pAllocateInfo, - VkCommandBuffer *pCommandBuffers) { - const VkLayerDispatchTable *disp; - VkResult res; - - disp = loader_get_dispatch(device); - - res = disp->AllocateCommandBuffers(device, pAllocateInfo, pCommandBuffers); - if (res == VK_SUCCESS) { - for (uint32_t i = 0; i < pAllocateInfo->commandBufferCount; i++) { - if (pCommandBuffers[i]) { - loader_init_dispatch(pCommandBuffers[i], disp); - } - } - } - - return res; -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, - uint32_t commandBufferCount, const VkCommandBuffer *pCommandBuffers) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(device); - - disp->FreeCommandBuffers(device, commandPool, commandBufferCount, pCommandBuffers); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkBeginCommandBuffer(VkCommandBuffer commandBuffer, - const VkCommandBufferBeginInfo *pBeginInfo) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(commandBuffer); - - return disp->BeginCommandBuffer(commandBuffer, pBeginInfo); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEndCommandBuffer(VkCommandBuffer commandBuffer) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(commandBuffer); - - return disp->EndCommandBuffer(commandBuffer); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkResetCommandBuffer(VkCommandBuffer commandBuffer, VkCommandBufferResetFlags flags) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(commandBuffer); - - return disp->ResetCommandBuffer(commandBuffer, flags); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdBindPipeline(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, - VkPipeline pipeline) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(commandBuffer); - - disp->CmdBindPipeline(commandBuffer, pipelineBindPoint, pipeline); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport, - uint32_t viewportCount, const VkViewport *pViewports) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(commandBuffer); - - disp->CmdSetViewport(commandBuffer, firstViewport, viewportCount, pViewports); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor, - uint32_t scissorCount, const VkRect2D *pScissors) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(commandBuffer); - - disp->CmdSetScissor(commandBuffer, firstScissor, scissorCount, pScissors); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(commandBuffer); - - disp->CmdSetLineWidth(commandBuffer, lineWidth); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthBias(VkCommandBuffer commandBuffer, float depthBiasConstantFactor, - float depthBiasClamp, float depthBiasSlopeFactor) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(commandBuffer); - - disp->CmdSetDepthBias(commandBuffer, depthBiasConstantFactor, depthBiasClamp, depthBiasSlopeFactor); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdSetBlendConstants(VkCommandBuffer commandBuffer, const float blendConstants[4]) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(commandBuffer); - - disp->CmdSetBlendConstants(commandBuffer, blendConstants); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthBounds(VkCommandBuffer commandBuffer, float minDepthBounds, - float maxDepthBounds) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(commandBuffer); - - disp->CmdSetDepthBounds(commandBuffer, minDepthBounds, maxDepthBounds); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdSetStencilCompareMask(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, - uint32_t compareMask) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(commandBuffer); - - disp->CmdSetStencilCompareMask(commandBuffer, faceMask, compareMask); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdSetStencilWriteMask(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, - uint32_t writeMask) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(commandBuffer); - - disp->CmdSetStencilWriteMask(commandBuffer, faceMask, writeMask); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdSetStencilReference(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, - uint32_t reference) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(commandBuffer); - - disp->CmdSetStencilReference(commandBuffer, faceMask, reference); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdBindDescriptorSets(VkCommandBuffer commandBuffer, - VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, - uint32_t firstSet, uint32_t descriptorSetCount, - const VkDescriptorSet *pDescriptorSets, - uint32_t dynamicOffsetCount, const uint32_t *pDynamicOffsets) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(commandBuffer); - - disp->CmdBindDescriptorSets(commandBuffer, pipelineBindPoint, layout, firstSet, descriptorSetCount, pDescriptorSets, - dynamicOffsetCount, pDynamicOffsets); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, - VkIndexType indexType) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(commandBuffer); - - disp->CmdBindIndexBuffer(commandBuffer, buffer, offset, indexType); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding, - uint32_t bindingCount, const VkBuffer *pBuffers, - const VkDeviceSize *pOffsets) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(commandBuffer); - - disp->CmdBindVertexBuffers(commandBuffer, firstBinding, bindingCount, pBuffers, pOffsets); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount, - uint32_t firstVertex, uint32_t firstInstance) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(commandBuffer); - - disp->CmdDraw(commandBuffer, vertexCount, instanceCount, firstVertex, firstInstance); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndexed(VkCommandBuffer commandBuffer, uint32_t indexCount, - uint32_t instanceCount, uint32_t firstIndex, int32_t vertexOffset, - uint32_t firstInstance) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(commandBuffer); - - disp->CmdDrawIndexed(commandBuffer, indexCount, instanceCount, firstIndex, vertexOffset, firstInstance); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, - uint32_t drawCount, uint32_t stride) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(commandBuffer); - - disp->CmdDrawIndirect(commandBuffer, buffer, offset, drawCount, stride); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, - VkDeviceSize offset, uint32_t drawCount, uint32_t stride) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(commandBuffer); - - disp->CmdDrawIndexedIndirect(commandBuffer, buffer, offset, drawCount, stride); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdDispatch(VkCommandBuffer commandBuffer, uint32_t x, uint32_t y, uint32_t z) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(commandBuffer); - - disp->CmdDispatch(commandBuffer, x, y, z); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, - VkDeviceSize offset) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(commandBuffer); - - disp->CmdDispatchIndirect(commandBuffer, buffer, offset); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer, - uint32_t regionCount, const VkBufferCopy *pRegions) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(commandBuffer); - - disp->CmdCopyBuffer(commandBuffer, srcBuffer, dstBuffer, regionCount, pRegions); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage, - VkImageLayout srcImageLayout, VkImage dstImage, - VkImageLayout dstImageLayout, uint32_t regionCount, - const VkImageCopy *pRegions) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(commandBuffer); - - disp->CmdCopyImage(commandBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage, - VkImageLayout srcImageLayout, VkImage dstImage, - VkImageLayout dstImageLayout, uint32_t regionCount, - const VkImageBlit *pRegions, VkFilter filter) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(commandBuffer); - - disp->CmdBlitImage(commandBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions, filter); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkImage dstImage, - VkImageLayout dstImageLayout, uint32_t regionCount, - const VkBufferImageCopy *pRegions) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(commandBuffer); - - disp->CmdCopyBufferToImage(commandBuffer, srcBuffer, dstImage, dstImageLayout, regionCount, pRegions); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage, - VkImageLayout srcImageLayout, VkBuffer dstBuffer, - uint32_t regionCount, const VkBufferImageCopy *pRegions) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(commandBuffer); - - disp->CmdCopyImageToBuffer(commandBuffer, srcImage, srcImageLayout, dstBuffer, regionCount, pRegions); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, - VkDeviceSize dstOffset, VkDeviceSize dataSize, const void *pData) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(commandBuffer); - - disp->CmdUpdateBuffer(commandBuffer, dstBuffer, dstOffset, dataSize, pData); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, - VkDeviceSize size, uint32_t data) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(commandBuffer); - - disp->CmdFillBuffer(commandBuffer, dstBuffer, dstOffset, size, data); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image, - VkImageLayout imageLayout, const VkClearColorValue *pColor, - uint32_t rangeCount, const VkImageSubresourceRange *pRanges) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(commandBuffer); - - disp->CmdClearColorImage(commandBuffer, image, imageLayout, pColor, rangeCount, pRanges); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdClearDepthStencilImage(VkCommandBuffer commandBuffer, VkImage image, - VkImageLayout imageLayout, - const VkClearDepthStencilValue *pDepthStencil, - uint32_t rangeCount, const VkImageSubresourceRange *pRanges) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(commandBuffer); - - disp->CmdClearDepthStencilImage(commandBuffer, image, imageLayout, pDepthStencil, rangeCount, pRanges); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount, - const VkClearAttachment *pAttachments, uint32_t rectCount, - const VkClearRect *pRects) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(commandBuffer); - - disp->CmdClearAttachments(commandBuffer, attachmentCount, pAttachments, rectCount, pRects); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdResolveImage(VkCommandBuffer commandBuffer, VkImage srcImage, - VkImageLayout srcImageLayout, VkImage dstImage, - VkImageLayout dstImageLayout, uint32_t regionCount, - const VkImageResolve *pRegions) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(commandBuffer); - - disp->CmdResolveImage(commandBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdSetEvent(VkCommandBuffer commandBuffer, VkEvent event, - VkPipelineStageFlags stageMask) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(commandBuffer); - - disp->CmdSetEvent(commandBuffer, event, stageMask); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdResetEvent(VkCommandBuffer commandBuffer, VkEvent event, - VkPipelineStageFlags stageMask) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(commandBuffer); - - disp->CmdResetEvent(commandBuffer, event, stageMask); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdWaitEvents(VkCommandBuffer commandBuffer, uint32_t eventCount, const VkEvent *pEvents, - VkPipelineStageFlags sourceStageMask, VkPipelineStageFlags dstStageMask, - uint32_t memoryBarrierCount, const VkMemoryBarrier *pMemoryBarriers, - uint32_t bufferMemoryBarrierCount, - const VkBufferMemoryBarrier *pBufferMemoryBarriers, - uint32_t imageMemoryBarrierCount, - const VkImageMemoryBarrier *pImageMemoryBarriers) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(commandBuffer); - - disp->CmdWaitEvents(commandBuffer, eventCount, pEvents, sourceStageMask, dstStageMask, memoryBarrierCount, pMemoryBarriers, - bufferMemoryBarrierCount, pBufferMemoryBarriers, imageMemoryBarrierCount, pImageMemoryBarriers); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdPipelineBarrier(VkCommandBuffer commandBuffer, VkPipelineStageFlags srcStageMask, - VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, - uint32_t memoryBarrierCount, const VkMemoryBarrier *pMemoryBarriers, - uint32_t bufferMemoryBarrierCount, - const VkBufferMemoryBarrier *pBufferMemoryBarriers, - uint32_t imageMemoryBarrierCount, - const VkImageMemoryBarrier *pImageMemoryBarriers) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(commandBuffer); - - disp->CmdPipelineBarrier(commandBuffer, srcStageMask, dstStageMask, dependencyFlags, memoryBarrierCount, pMemoryBarriers, - bufferMemoryBarrierCount, pBufferMemoryBarriers, imageMemoryBarrierCount, pImageMemoryBarriers); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdBeginQuery(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t slot, - VkFlags flags) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(commandBuffer); - - disp->CmdBeginQuery(commandBuffer, queryPool, slot, flags); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdEndQuery(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t slot) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(commandBuffer); - - disp->CmdEndQuery(commandBuffer, queryPool, slot); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdResetQueryPool(VkCommandBuffer commandBuffer, VkQueryPool queryPool, - uint32_t firstQuery, uint32_t queryCount) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(commandBuffer); - - disp->CmdResetQueryPool(commandBuffer, queryPool, firstQuery, queryCount); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdWriteTimestamp(VkCommandBuffer commandBuffer, VkPipelineStageFlagBits pipelineStage, - VkQueryPool queryPool, uint32_t slot) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(commandBuffer); - - disp->CmdWriteTimestamp(commandBuffer, pipelineStage, queryPool, slot); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdCopyQueryPoolResults(VkCommandBuffer commandBuffer, VkQueryPool queryPool, - uint32_t firstQuery, uint32_t queryCount, VkBuffer dstBuffer, - VkDeviceSize dstOffset, VkDeviceSize stride, VkFlags flags) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(commandBuffer); - - disp->CmdCopyQueryPoolResults(commandBuffer, queryPool, firstQuery, queryCount, dstBuffer, dstOffset, stride, flags); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdPushConstants(VkCommandBuffer commandBuffer, VkPipelineLayout layout, - VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size, - const void *pValues) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(commandBuffer); - - disp->CmdPushConstants(commandBuffer, layout, stageFlags, offset, size, pValues); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdBeginRenderPass(VkCommandBuffer commandBuffer, - const VkRenderPassBeginInfo *pRenderPassBegin, - VkSubpassContents contents) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(commandBuffer); - - disp->CmdBeginRenderPass(commandBuffer, pRenderPassBegin, contents); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdNextSubpass(VkCommandBuffer commandBuffer, VkSubpassContents contents) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(commandBuffer); - - disp->CmdNextSubpass(commandBuffer, contents); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdEndRenderPass(VkCommandBuffer commandBuffer) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(commandBuffer); - - disp->CmdEndRenderPass(commandBuffer); -} - -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdExecuteCommands(VkCommandBuffer commandBuffer, uint32_t commandBuffersCount, - const VkCommandBuffer *pCommandBuffers) { - const VkLayerDispatchTable *disp; - - disp = loader_get_dispatch(commandBuffer); - - disp->CmdExecuteCommands(commandBuffer, commandBuffersCount, pCommandBuffers); -} diff --git a/third_party/vulkan/loader/unknown_ext_chain.c b/third_party/vulkan/loader/unknown_ext_chain.c deleted file mode 100644 index 1c8560dd6..000000000 --- a/third_party/vulkan/loader/unknown_ext_chain.c +++ /dev/null @@ -1,819 +0,0 @@ -/* - * Copyright (c) 2017 The Khronos Group Inc. - * Copyright (c) 2017 Valve Corporation - * Copyright (c) 2017 LunarG, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Author Jon Ashburn - * Author: Lenny Komow - */ - - // 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 "vk_loader_platform.h" - #include "loader.h" - - #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)); \ - } - -// 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); \ - } - -// 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); \ - } - - -// Instantiations of the trampoline -PhysDevExtTramp(0) -PhysDevExtTramp(1) -PhysDevExtTramp(2) -PhysDevExtTramp(3) -PhysDevExtTramp(4) -PhysDevExtTramp(5) -PhysDevExtTramp(6) -PhysDevExtTramp(7) -PhysDevExtTramp(8) -PhysDevExtTramp(9) -PhysDevExtTramp(10) -PhysDevExtTramp(11) -PhysDevExtTramp(12) -PhysDevExtTramp(13) -PhysDevExtTramp(14) -PhysDevExtTramp(15) -PhysDevExtTramp(16) -PhysDevExtTramp(17) -PhysDevExtTramp(18) -PhysDevExtTramp(19) -PhysDevExtTramp(20) -PhysDevExtTramp(21) -PhysDevExtTramp(22) -PhysDevExtTramp(23) -PhysDevExtTramp(24) -PhysDevExtTramp(25) -PhysDevExtTramp(26) -PhysDevExtTramp(27) -PhysDevExtTramp(28) -PhysDevExtTramp(29) -PhysDevExtTramp(30) -PhysDevExtTramp(31) -PhysDevExtTramp(32) -PhysDevExtTramp(33) -PhysDevExtTramp(34) -PhysDevExtTramp(35) -PhysDevExtTramp(36) -PhysDevExtTramp(37) -PhysDevExtTramp(38) -PhysDevExtTramp(39) -PhysDevExtTramp(40) -PhysDevExtTramp(41) -PhysDevExtTramp(42) -PhysDevExtTramp(43) -PhysDevExtTramp(44) -PhysDevExtTramp(45) -PhysDevExtTramp(46) -PhysDevExtTramp(47) -PhysDevExtTramp(48) -PhysDevExtTramp(49) -PhysDevExtTramp(50) -PhysDevExtTramp(51) -PhysDevExtTramp(52) -PhysDevExtTramp(53) -PhysDevExtTramp(54) -PhysDevExtTramp(55) -PhysDevExtTramp(56) -PhysDevExtTramp(57) -PhysDevExtTramp(58) -PhysDevExtTramp(59) -PhysDevExtTramp(60) -PhysDevExtTramp(61) -PhysDevExtTramp(62) -PhysDevExtTramp(63) -PhysDevExtTramp(64) -PhysDevExtTramp(65) -PhysDevExtTramp(66) -PhysDevExtTramp(67) -PhysDevExtTramp(68) -PhysDevExtTramp(69) -PhysDevExtTramp(70) -PhysDevExtTramp(71) -PhysDevExtTramp(72) -PhysDevExtTramp(73) -PhysDevExtTramp(74) -PhysDevExtTramp(75) -PhysDevExtTramp(76) -PhysDevExtTramp(77) -PhysDevExtTramp(78) -PhysDevExtTramp(79) -PhysDevExtTramp(80) -PhysDevExtTramp(81) -PhysDevExtTramp(82) -PhysDevExtTramp(83) -PhysDevExtTramp(84) -PhysDevExtTramp(85) -PhysDevExtTramp(86) -PhysDevExtTramp(87) -PhysDevExtTramp(88) -PhysDevExtTramp(89) -PhysDevExtTramp(90) -PhysDevExtTramp(91) -PhysDevExtTramp(92) -PhysDevExtTramp(93) -PhysDevExtTramp(94) -PhysDevExtTramp(95) -PhysDevExtTramp(96) -PhysDevExtTramp(97) -PhysDevExtTramp(98) -PhysDevExtTramp(99) -PhysDevExtTramp(100) -PhysDevExtTramp(101) -PhysDevExtTramp(102) -PhysDevExtTramp(103) -PhysDevExtTramp(104) -PhysDevExtTramp(105) -PhysDevExtTramp(106) -PhysDevExtTramp(107) -PhysDevExtTramp(108) -PhysDevExtTramp(109) -PhysDevExtTramp(110) -PhysDevExtTramp(111) -PhysDevExtTramp(112) -PhysDevExtTramp(113) -PhysDevExtTramp(114) -PhysDevExtTramp(115) -PhysDevExtTramp(116) -PhysDevExtTramp(117) -PhysDevExtTramp(118) -PhysDevExtTramp(119) -PhysDevExtTramp(120) -PhysDevExtTramp(121) -PhysDevExtTramp(122) -PhysDevExtTramp(123) -PhysDevExtTramp(124) -PhysDevExtTramp(125) -PhysDevExtTramp(126) -PhysDevExtTramp(127) -PhysDevExtTramp(128) -PhysDevExtTramp(129) -PhysDevExtTramp(130) -PhysDevExtTramp(131) -PhysDevExtTramp(132) -PhysDevExtTramp(133) -PhysDevExtTramp(134) -PhysDevExtTramp(135) -PhysDevExtTramp(136) -PhysDevExtTramp(137) -PhysDevExtTramp(138) -PhysDevExtTramp(139) -PhysDevExtTramp(140) -PhysDevExtTramp(141) -PhysDevExtTramp(142) -PhysDevExtTramp(143) -PhysDevExtTramp(144) -PhysDevExtTramp(145) -PhysDevExtTramp(146) -PhysDevExtTramp(147) -PhysDevExtTramp(148) -PhysDevExtTramp(149) -PhysDevExtTramp(150) -PhysDevExtTramp(151) -PhysDevExtTramp(152) -PhysDevExtTramp(153) -PhysDevExtTramp(154) -PhysDevExtTramp(155) -PhysDevExtTramp(156) -PhysDevExtTramp(157) -PhysDevExtTramp(158) -PhysDevExtTramp(159) -PhysDevExtTramp(160) -PhysDevExtTramp(161) -PhysDevExtTramp(162) -PhysDevExtTramp(163) -PhysDevExtTramp(164) -PhysDevExtTramp(165) -PhysDevExtTramp(166) -PhysDevExtTramp(167) -PhysDevExtTramp(168) -PhysDevExtTramp(169) -PhysDevExtTramp(170) -PhysDevExtTramp(171) -PhysDevExtTramp(172) -PhysDevExtTramp(173) -PhysDevExtTramp(174) -PhysDevExtTramp(175) -PhysDevExtTramp(176) -PhysDevExtTramp(177) -PhysDevExtTramp(178) -PhysDevExtTramp(179) -PhysDevExtTramp(180) -PhysDevExtTramp(181) -PhysDevExtTramp(182) -PhysDevExtTramp(183) -PhysDevExtTramp(184) -PhysDevExtTramp(185) -PhysDevExtTramp(186) -PhysDevExtTramp(187) -PhysDevExtTramp(188) -PhysDevExtTramp(189) -PhysDevExtTramp(190) -PhysDevExtTramp(191) -PhysDevExtTramp(192) -PhysDevExtTramp(193) -PhysDevExtTramp(194) -PhysDevExtTramp(195) -PhysDevExtTramp(196) -PhysDevExtTramp(197) -PhysDevExtTramp(198) -PhysDevExtTramp(199) -PhysDevExtTramp(200) -PhysDevExtTramp(201) -PhysDevExtTramp(202) -PhysDevExtTramp(203) -PhysDevExtTramp(204) -PhysDevExtTramp(205) -PhysDevExtTramp(206) -PhysDevExtTramp(207) -PhysDevExtTramp(208) -PhysDevExtTramp(209) -PhysDevExtTramp(210) -PhysDevExtTramp(211) -PhysDevExtTramp(212) -PhysDevExtTramp(213) -PhysDevExtTramp(214) -PhysDevExtTramp(215) -PhysDevExtTramp(216) -PhysDevExtTramp(217) -PhysDevExtTramp(218) -PhysDevExtTramp(219) -PhysDevExtTramp(220) -PhysDevExtTramp(221) -PhysDevExtTramp(222) -PhysDevExtTramp(223) -PhysDevExtTramp(224) -PhysDevExtTramp(225) -PhysDevExtTramp(226) -PhysDevExtTramp(227) -PhysDevExtTramp(228) -PhysDevExtTramp(229) -PhysDevExtTramp(230) -PhysDevExtTramp(231) -PhysDevExtTramp(232) -PhysDevExtTramp(233) -PhysDevExtTramp(234) -PhysDevExtTramp(235) -PhysDevExtTramp(236) -PhysDevExtTramp(237) -PhysDevExtTramp(238) -PhysDevExtTramp(239) -PhysDevExtTramp(240) -PhysDevExtTramp(241) -PhysDevExtTramp(242) -PhysDevExtTramp(243) -PhysDevExtTramp(244) -PhysDevExtTramp(245) -PhysDevExtTramp(246) -PhysDevExtTramp(247) -PhysDevExtTramp(248) -PhysDevExtTramp(249) - -// Instantiations of the terminator -PhysDevExtTermin(0) -PhysDevExtTermin(1) -PhysDevExtTermin(2) -PhysDevExtTermin(3) -PhysDevExtTermin(4) -PhysDevExtTermin(5) -PhysDevExtTermin(6) -PhysDevExtTermin(7) -PhysDevExtTermin(8) -PhysDevExtTermin(9) -PhysDevExtTermin(10) -PhysDevExtTermin(11) -PhysDevExtTermin(12) -PhysDevExtTermin(13) -PhysDevExtTermin(14) -PhysDevExtTermin(15) -PhysDevExtTermin(16) -PhysDevExtTermin(17) -PhysDevExtTermin(18) -PhysDevExtTermin(19) -PhysDevExtTermin(20) -PhysDevExtTermin(21) -PhysDevExtTermin(22) -PhysDevExtTermin(23) -PhysDevExtTermin(24) -PhysDevExtTermin(25) -PhysDevExtTermin(26) -PhysDevExtTermin(27) -PhysDevExtTermin(28) -PhysDevExtTermin(29) -PhysDevExtTermin(30) -PhysDevExtTermin(31) -PhysDevExtTermin(32) -PhysDevExtTermin(33) -PhysDevExtTermin(34) -PhysDevExtTermin(35) -PhysDevExtTermin(36) -PhysDevExtTermin(37) -PhysDevExtTermin(38) -PhysDevExtTermin(39) -PhysDevExtTermin(40) -PhysDevExtTermin(41) -PhysDevExtTermin(42) -PhysDevExtTermin(43) -PhysDevExtTermin(44) -PhysDevExtTermin(45) -PhysDevExtTermin(46) -PhysDevExtTermin(47) -PhysDevExtTermin(48) -PhysDevExtTermin(49) -PhysDevExtTermin(50) -PhysDevExtTermin(51) -PhysDevExtTermin(52) -PhysDevExtTermin(53) -PhysDevExtTermin(54) -PhysDevExtTermin(55) -PhysDevExtTermin(56) -PhysDevExtTermin(57) -PhysDevExtTermin(58) -PhysDevExtTermin(59) -PhysDevExtTermin(60) -PhysDevExtTermin(61) -PhysDevExtTermin(62) -PhysDevExtTermin(63) -PhysDevExtTermin(64) -PhysDevExtTermin(65) -PhysDevExtTermin(66) -PhysDevExtTermin(67) -PhysDevExtTermin(68) -PhysDevExtTermin(69) -PhysDevExtTermin(70) -PhysDevExtTermin(71) -PhysDevExtTermin(72) -PhysDevExtTermin(73) -PhysDevExtTermin(74) -PhysDevExtTermin(75) -PhysDevExtTermin(76) -PhysDevExtTermin(77) -PhysDevExtTermin(78) -PhysDevExtTermin(79) -PhysDevExtTermin(80) -PhysDevExtTermin(81) -PhysDevExtTermin(82) -PhysDevExtTermin(83) -PhysDevExtTermin(84) -PhysDevExtTermin(85) -PhysDevExtTermin(86) -PhysDevExtTermin(87) -PhysDevExtTermin(88) -PhysDevExtTermin(89) -PhysDevExtTermin(90) -PhysDevExtTermin(91) -PhysDevExtTermin(92) -PhysDevExtTermin(93) -PhysDevExtTermin(94) -PhysDevExtTermin(95) -PhysDevExtTermin(96) -PhysDevExtTermin(97) -PhysDevExtTermin(98) -PhysDevExtTermin(99) -PhysDevExtTermin(100) -PhysDevExtTermin(101) -PhysDevExtTermin(102) -PhysDevExtTermin(103) -PhysDevExtTermin(104) -PhysDevExtTermin(105) -PhysDevExtTermin(106) -PhysDevExtTermin(107) -PhysDevExtTermin(108) -PhysDevExtTermin(109) -PhysDevExtTermin(110) -PhysDevExtTermin(111) -PhysDevExtTermin(112) -PhysDevExtTermin(113) -PhysDevExtTermin(114) -PhysDevExtTermin(115) -PhysDevExtTermin(116) -PhysDevExtTermin(117) -PhysDevExtTermin(118) -PhysDevExtTermin(119) -PhysDevExtTermin(120) -PhysDevExtTermin(121) -PhysDevExtTermin(122) -PhysDevExtTermin(123) -PhysDevExtTermin(124) -PhysDevExtTermin(125) -PhysDevExtTermin(126) -PhysDevExtTermin(127) -PhysDevExtTermin(128) -PhysDevExtTermin(129) -PhysDevExtTermin(130) -PhysDevExtTermin(131) -PhysDevExtTermin(132) -PhysDevExtTermin(133) -PhysDevExtTermin(134) -PhysDevExtTermin(135) -PhysDevExtTermin(136) -PhysDevExtTermin(137) -PhysDevExtTermin(138) -PhysDevExtTermin(139) -PhysDevExtTermin(140) -PhysDevExtTermin(141) -PhysDevExtTermin(142) -PhysDevExtTermin(143) -PhysDevExtTermin(144) -PhysDevExtTermin(145) -PhysDevExtTermin(146) -PhysDevExtTermin(147) -PhysDevExtTermin(148) -PhysDevExtTermin(149) -PhysDevExtTermin(150) -PhysDevExtTermin(151) -PhysDevExtTermin(152) -PhysDevExtTermin(153) -PhysDevExtTermin(154) -PhysDevExtTermin(155) -PhysDevExtTermin(156) -PhysDevExtTermin(157) -PhysDevExtTermin(158) -PhysDevExtTermin(159) -PhysDevExtTermin(160) -PhysDevExtTermin(161) -PhysDevExtTermin(162) -PhysDevExtTermin(163) -PhysDevExtTermin(164) -PhysDevExtTermin(165) -PhysDevExtTermin(166) -PhysDevExtTermin(167) -PhysDevExtTermin(168) -PhysDevExtTermin(169) -PhysDevExtTermin(170) -PhysDevExtTermin(171) -PhysDevExtTermin(172) -PhysDevExtTermin(173) -PhysDevExtTermin(174) -PhysDevExtTermin(175) -PhysDevExtTermin(176) -PhysDevExtTermin(177) -PhysDevExtTermin(178) -PhysDevExtTermin(179) -PhysDevExtTermin(180) -PhysDevExtTermin(181) -PhysDevExtTermin(182) -PhysDevExtTermin(183) -PhysDevExtTermin(184) -PhysDevExtTermin(185) -PhysDevExtTermin(186) -PhysDevExtTermin(187) -PhysDevExtTermin(188) -PhysDevExtTermin(189) -PhysDevExtTermin(190) -PhysDevExtTermin(191) -PhysDevExtTermin(192) -PhysDevExtTermin(193) -PhysDevExtTermin(194) -PhysDevExtTermin(195) -PhysDevExtTermin(196) -PhysDevExtTermin(197) -PhysDevExtTermin(198) -PhysDevExtTermin(199) -PhysDevExtTermin(200) -PhysDevExtTermin(201) -PhysDevExtTermin(202) -PhysDevExtTermin(203) -PhysDevExtTermin(204) -PhysDevExtTermin(205) -PhysDevExtTermin(206) -PhysDevExtTermin(207) -PhysDevExtTermin(208) -PhysDevExtTermin(209) -PhysDevExtTermin(210) -PhysDevExtTermin(211) -PhysDevExtTermin(212) -PhysDevExtTermin(213) -PhysDevExtTermin(214) -PhysDevExtTermin(215) -PhysDevExtTermin(216) -PhysDevExtTermin(217) -PhysDevExtTermin(218) -PhysDevExtTermin(219) -PhysDevExtTermin(220) -PhysDevExtTermin(221) -PhysDevExtTermin(222) -PhysDevExtTermin(223) -PhysDevExtTermin(224) -PhysDevExtTermin(225) -PhysDevExtTermin(226) -PhysDevExtTermin(227) -PhysDevExtTermin(228) -PhysDevExtTermin(229) -PhysDevExtTermin(230) -PhysDevExtTermin(231) -PhysDevExtTermin(232) -PhysDevExtTermin(233) -PhysDevExtTermin(234) -PhysDevExtTermin(235) -PhysDevExtTermin(236) -PhysDevExtTermin(237) -PhysDevExtTermin(238) -PhysDevExtTermin(239) -PhysDevExtTermin(240) -PhysDevExtTermin(241) -PhysDevExtTermin(242) -PhysDevExtTermin(243) -PhysDevExtTermin(244) -PhysDevExtTermin(245) -PhysDevExtTermin(246) -PhysDevExtTermin(247) -PhysDevExtTermin(248) -PhysDevExtTermin(249) - -// Instantiations of the device trampoline -DevExtTramp(0) -DevExtTramp(1) -DevExtTramp(2) -DevExtTramp(3) -DevExtTramp(4) -DevExtTramp(5) -DevExtTramp(6) -DevExtTramp(7) -DevExtTramp(8) -DevExtTramp(9) -DevExtTramp(10) -DevExtTramp(11) -DevExtTramp(12) -DevExtTramp(13) -DevExtTramp(14) -DevExtTramp(15) -DevExtTramp(16) -DevExtTramp(17) -DevExtTramp(18) -DevExtTramp(19) -DevExtTramp(20) -DevExtTramp(21) -DevExtTramp(22) -DevExtTramp(23) -DevExtTramp(24) -DevExtTramp(25) -DevExtTramp(26) -DevExtTramp(27) -DevExtTramp(28) -DevExtTramp(29) -DevExtTramp(30) -DevExtTramp(31) -DevExtTramp(32) -DevExtTramp(33) -DevExtTramp(34) -DevExtTramp(35) -DevExtTramp(36) -DevExtTramp(37) -DevExtTramp(38) -DevExtTramp(39) -DevExtTramp(40) -DevExtTramp(41) -DevExtTramp(42) -DevExtTramp(43) -DevExtTramp(44) -DevExtTramp(45) -DevExtTramp(46) -DevExtTramp(47) -DevExtTramp(48) -DevExtTramp(49) -DevExtTramp(50) -DevExtTramp(51) -DevExtTramp(52) -DevExtTramp(53) -DevExtTramp(54) -DevExtTramp(55) -DevExtTramp(56) -DevExtTramp(57) -DevExtTramp(58) -DevExtTramp(59) -DevExtTramp(60) -DevExtTramp(61) -DevExtTramp(62) -DevExtTramp(63) -DevExtTramp(64) -DevExtTramp(65) -DevExtTramp(66) -DevExtTramp(67) -DevExtTramp(68) -DevExtTramp(69) -DevExtTramp(70) -DevExtTramp(71) -DevExtTramp(72) -DevExtTramp(73) -DevExtTramp(74) -DevExtTramp(75) -DevExtTramp(76) -DevExtTramp(77) -DevExtTramp(78) -DevExtTramp(79) -DevExtTramp(80) -DevExtTramp(81) -DevExtTramp(82) -DevExtTramp(83) -DevExtTramp(84) -DevExtTramp(85) -DevExtTramp(86) -DevExtTramp(87) -DevExtTramp(88) -DevExtTramp(89) -DevExtTramp(90) -DevExtTramp(91) -DevExtTramp(92) -DevExtTramp(93) -DevExtTramp(94) -DevExtTramp(95) -DevExtTramp(96) -DevExtTramp(97) -DevExtTramp(98) -DevExtTramp(99) -DevExtTramp(100) -DevExtTramp(101) -DevExtTramp(102) -DevExtTramp(103) -DevExtTramp(104) -DevExtTramp(105) -DevExtTramp(106) -DevExtTramp(107) -DevExtTramp(108) -DevExtTramp(109) -DevExtTramp(110) -DevExtTramp(111) -DevExtTramp(112) -DevExtTramp(113) -DevExtTramp(114) -DevExtTramp(115) -DevExtTramp(116) -DevExtTramp(117) -DevExtTramp(118) -DevExtTramp(119) -DevExtTramp(120) -DevExtTramp(121) -DevExtTramp(122) -DevExtTramp(123) -DevExtTramp(124) -DevExtTramp(125) -DevExtTramp(126) -DevExtTramp(127) -DevExtTramp(128) -DevExtTramp(129) -DevExtTramp(130) -DevExtTramp(131) -DevExtTramp(132) -DevExtTramp(133) -DevExtTramp(134) -DevExtTramp(135) -DevExtTramp(136) -DevExtTramp(137) -DevExtTramp(138) -DevExtTramp(139) -DevExtTramp(140) -DevExtTramp(141) -DevExtTramp(142) -DevExtTramp(143) -DevExtTramp(144) -DevExtTramp(145) -DevExtTramp(146) -DevExtTramp(147) -DevExtTramp(148) -DevExtTramp(149) -DevExtTramp(150) -DevExtTramp(151) -DevExtTramp(152) -DevExtTramp(153) -DevExtTramp(154) -DevExtTramp(155) -DevExtTramp(156) -DevExtTramp(157) -DevExtTramp(158) -DevExtTramp(159) -DevExtTramp(160) -DevExtTramp(161) -DevExtTramp(162) -DevExtTramp(163) -DevExtTramp(164) -DevExtTramp(165) -DevExtTramp(166) -DevExtTramp(167) -DevExtTramp(168) -DevExtTramp(169) -DevExtTramp(170) -DevExtTramp(171) -DevExtTramp(172) -DevExtTramp(173) -DevExtTramp(174) -DevExtTramp(175) -DevExtTramp(176) -DevExtTramp(177) -DevExtTramp(178) -DevExtTramp(179) -DevExtTramp(180) -DevExtTramp(181) -DevExtTramp(182) -DevExtTramp(183) -DevExtTramp(184) -DevExtTramp(185) -DevExtTramp(186) -DevExtTramp(187) -DevExtTramp(188) -DevExtTramp(189) -DevExtTramp(190) -DevExtTramp(191) -DevExtTramp(192) -DevExtTramp(193) -DevExtTramp(194) -DevExtTramp(195) -DevExtTramp(196) -DevExtTramp(197) -DevExtTramp(198) -DevExtTramp(199) -DevExtTramp(200) -DevExtTramp(201) -DevExtTramp(202) -DevExtTramp(203) -DevExtTramp(204) -DevExtTramp(205) -DevExtTramp(206) -DevExtTramp(207) -DevExtTramp(208) -DevExtTramp(209) -DevExtTramp(210) -DevExtTramp(211) -DevExtTramp(212) -DevExtTramp(213) -DevExtTramp(214) -DevExtTramp(215) -DevExtTramp(216) -DevExtTramp(217) -DevExtTramp(218) -DevExtTramp(219) -DevExtTramp(220) -DevExtTramp(221) -DevExtTramp(222) -DevExtTramp(223) -DevExtTramp(224) -DevExtTramp(225) -DevExtTramp(226) -DevExtTramp(227) -DevExtTramp(228) -DevExtTramp(229) -DevExtTramp(230) -DevExtTramp(231) -DevExtTramp(232) -DevExtTramp(233) -DevExtTramp(234) -DevExtTramp(235) -DevExtTramp(236) -DevExtTramp(237) -DevExtTramp(238) -DevExtTramp(239) -DevExtTramp(240) -DevExtTramp(241) -DevExtTramp(242) -DevExtTramp(243) -DevExtTramp(244) -DevExtTramp(245) -DevExtTramp(246) -DevExtTramp(247) -DevExtTramp(248) -DevExtTramp(249) diff --git a/third_party/vulkan/loader/unknown_ext_chain_gas.asm b/third_party/vulkan/loader/unknown_ext_chain_gas.asm deleted file mode 100644 index aca92ea5b..000000000 --- a/third_party/vulkan/loader/unknown_ext_chain_gas.asm +++ /dev/null @@ -1,873 +0,0 @@ -# -# Copyright (c) 2017 The Khronos Group Inc. -# Copyright (c) 2017 Valve Corporation -# Copyright (c) 2017 LunarG, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Author: Lenny Komow -# - -# This code is used to pass on device (including 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 or a dispatchable object it can unwrap the object, possibly overwriting the wrapped physical device, and then -# jump to the next function in the call chain - -.intel_syntax noprefix -.include "gen_defines.asm" - -.ifdef X86_64 - -.macro PhysDevExtTramp num -.global vkPhysDevExtTramp\num -vkPhysDevExtTramp\num: - mov rax, [rdi] - mov rdi, [rdi + PHYS_DEV_OFFSET_PHYS_DEV_TRAMP] - jmp [rax + (PHYS_DEV_OFFSET_INST_DISPATCH + (PTR_SIZE * \num))] -.endm - -.macro PhysDevExtTermin num -.global vkPhysDevExtTermin\num -vkPhysDevExtTermin\num: - mov rax, [rdi + ICD_TERM_OFFSET_PHYS_DEV_TERM] # Store the loader_icd_term* in rax - cmp qword ptr [rax + (DISPATCH_OFFSET_ICD_TERM + (PTR_SIZE * \num))], 0 # Check if the next function in the chain is NULL - je terminError\num # Go to the error section if it is NULL - mov rdi, [rdi + PHYS_DEV_OFFSET_PHYS_DEV_TERM] # Load the unwrapped VkPhysicalDevice into the first arg - jmp [rax + (DISPATCH_OFFSET_ICD_TERM + (PTR_SIZE * \num))] # Jump to the next function in the chain -terminError\num: - sub rsp, 56 # Create the stack frame - mov rdi, [rax + INSTANCE_OFFSET_ICD_TERM] # Load the loader_instance into rdi (first arg) - mov r8, [rdi + (HASH_OFFSET_INSTANCE + (HASH_SIZE * \num) + FUNC_NAME_OFFSET_HASH)] # Load the func name into r8 (fifth arg) - lea rcx, termin_error_string@GOTPCREL # Load the error string into rcx (fourth arg) - xor edx, edx # Set rdx to zero (third arg) - lea esi, [rdx + VK_DEBUG_REPORT_ERROR_BIT_EXT] # Write the error logging bit to rsi (second arg) - call loader_log # Log the error message before we crash - add rsp, 56 # Clean up the stack frame - mov rax, 0 - jmp rax # Crash intentionally by jumping to address zero -.endm - -.macro DevExtTramp num -.global vkdev_ext\num -vkdev_ext\num: - mov rax, [rdi] # Dereference the handle to get the dispatch table - jmp [rax + (EXT_OFFSET_DEVICE_DISPATCH + (PTR_SIZE * \num))] # Jump to the appropriate call chain -.endm - -.else - -.macro PhysDevExtTramp num -.global vkPhysDevExtTramp\num -vkPhysDevExtTramp\num: - mov eax, [esp + 4] # Load the wrapped VkPhysicalDevice into eax - mov ecx, [eax + PHYS_DEV_OFFSET_PHYS_DEV_TRAMP] # Load the unwrapped VkPhysicalDevice into ecx - mov [esp + 4], ecx # Overwrite the wrapped VkPhysicalDevice with the unwrapped one (on the stack) - mov eax, [eax] # Dereference the wrapped VkPhysicalDevice to get the dispatch table in eax - jmp [eax + (PHYS_DEV_OFFSET_INST_DISPATCH + (PTR_SIZE * \num))] # Dereference the wrapped VkPhysicalDevice to get the dispatch table in eax -.endm - -.macro PhysDevExtTermin num -.global vkPhysDevExtTermin\num -vkPhysDevExtTermin\num: - mov ecx, [esp + 4] # Move the wrapped VkPhysicalDevice into ecx - mov eax, [ecx + ICD_TERM_OFFSET_PHYS_DEV_TERM] # Store the loader_icd_term* in eax - cmp dword ptr [eax + (DISPATCH_OFFSET_ICD_TERM + (PTR_SIZE * \num))], 0 # Check if the next function in the chain is NULL - je terminError\num # Go to the error section if it is NULL - mov ecx, [ecx + PHYS_DEV_OFFSET_PHYS_DEV_TERM] # Unwrap the VkPhysicalDevice in ecx - mov [esp + 4], ecx # Copy the unwrapped VkPhysicalDevice into the first arg - jmp [eax + (DISPATCH_OFFSET_ICD_TERM + (PTR_SIZE * \num))] # Jump to the next function in the chain -terminError\num: - mov eax, [eax + INSTANCE_OFFSET_ICD_TERM] # Load the loader_instance into eax - push [eax + (HASH_OFFSET_INSTANCE + (HASH_SIZE * \num) + FUNC_NAME_OFFSET_HASH)] # Push the func name (fifth arg) - push offset termin_error_string@GOT # Push the error string (fourth arg) - push 0 # Push zero (third arg) - push VK_DEBUG_REPORT_ERROR_BIT_EXT # Push the error logging bit (second arg) - push eax # Push the loader_instance (first arg) - call loader_log # Log the error message before we crash - add esp, 20 # Clean up the args - mov eax, 0 - jmp eax # Crash intentionally by jumping to address zero -.endm - -.macro DevExtTramp num -.global vkdev_ext\num -vkdev_ext\num: - mov eax, [esp + 4] # Dereference the handle to get the dispatch table - jmp [eax + (EXT_OFFSET_DEVICE_DISPATCH + (PTR_SIZE * \num))] # Jump to the appropriate call chain -.endm - -.endif - -#if defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif - -.data - -termin_error_string: -.string "Extension %s not supported for this physical device" - -.text - - PhysDevExtTramp 0 - PhysDevExtTramp 1 - PhysDevExtTramp 2 - PhysDevExtTramp 3 - PhysDevExtTramp 4 - PhysDevExtTramp 5 - PhysDevExtTramp 6 - PhysDevExtTramp 7 - PhysDevExtTramp 8 - PhysDevExtTramp 9 - PhysDevExtTramp 10 - PhysDevExtTramp 11 - PhysDevExtTramp 12 - PhysDevExtTramp 13 - PhysDevExtTramp 14 - PhysDevExtTramp 15 - PhysDevExtTramp 16 - PhysDevExtTramp 17 - PhysDevExtTramp 18 - PhysDevExtTramp 19 - PhysDevExtTramp 20 - PhysDevExtTramp 21 - PhysDevExtTramp 22 - PhysDevExtTramp 23 - PhysDevExtTramp 24 - PhysDevExtTramp 25 - PhysDevExtTramp 26 - PhysDevExtTramp 27 - PhysDevExtTramp 28 - PhysDevExtTramp 29 - PhysDevExtTramp 30 - PhysDevExtTramp 31 - PhysDevExtTramp 32 - PhysDevExtTramp 33 - PhysDevExtTramp 34 - PhysDevExtTramp 35 - PhysDevExtTramp 36 - PhysDevExtTramp 37 - PhysDevExtTramp 38 - PhysDevExtTramp 39 - PhysDevExtTramp 40 - PhysDevExtTramp 41 - PhysDevExtTramp 42 - PhysDevExtTramp 43 - PhysDevExtTramp 44 - PhysDevExtTramp 45 - PhysDevExtTramp 46 - PhysDevExtTramp 47 - PhysDevExtTramp 48 - PhysDevExtTramp 49 - PhysDevExtTramp 50 - PhysDevExtTramp 51 - PhysDevExtTramp 52 - PhysDevExtTramp 53 - PhysDevExtTramp 54 - PhysDevExtTramp 55 - PhysDevExtTramp 56 - PhysDevExtTramp 57 - PhysDevExtTramp 58 - PhysDevExtTramp 59 - PhysDevExtTramp 60 - PhysDevExtTramp 61 - PhysDevExtTramp 62 - PhysDevExtTramp 63 - PhysDevExtTramp 64 - PhysDevExtTramp 65 - PhysDevExtTramp 66 - PhysDevExtTramp 67 - PhysDevExtTramp 68 - PhysDevExtTramp 69 - PhysDevExtTramp 70 - PhysDevExtTramp 71 - PhysDevExtTramp 72 - PhysDevExtTramp 73 - PhysDevExtTramp 74 - PhysDevExtTramp 75 - PhysDevExtTramp 76 - PhysDevExtTramp 77 - PhysDevExtTramp 78 - PhysDevExtTramp 79 - PhysDevExtTramp 80 - PhysDevExtTramp 81 - PhysDevExtTramp 82 - PhysDevExtTramp 83 - PhysDevExtTramp 84 - PhysDevExtTramp 85 - PhysDevExtTramp 86 - PhysDevExtTramp 87 - PhysDevExtTramp 88 - PhysDevExtTramp 89 - PhysDevExtTramp 90 - PhysDevExtTramp 91 - PhysDevExtTramp 92 - PhysDevExtTramp 93 - PhysDevExtTramp 94 - PhysDevExtTramp 95 - PhysDevExtTramp 96 - PhysDevExtTramp 97 - PhysDevExtTramp 98 - PhysDevExtTramp 99 - PhysDevExtTramp 100 - PhysDevExtTramp 101 - PhysDevExtTramp 102 - PhysDevExtTramp 103 - PhysDevExtTramp 104 - PhysDevExtTramp 105 - PhysDevExtTramp 106 - PhysDevExtTramp 107 - PhysDevExtTramp 108 - PhysDevExtTramp 109 - PhysDevExtTramp 110 - PhysDevExtTramp 111 - PhysDevExtTramp 112 - PhysDevExtTramp 113 - PhysDevExtTramp 114 - PhysDevExtTramp 115 - PhysDevExtTramp 116 - PhysDevExtTramp 117 - PhysDevExtTramp 118 - PhysDevExtTramp 119 - PhysDevExtTramp 120 - PhysDevExtTramp 121 - PhysDevExtTramp 122 - PhysDevExtTramp 123 - PhysDevExtTramp 124 - PhysDevExtTramp 125 - PhysDevExtTramp 126 - PhysDevExtTramp 127 - PhysDevExtTramp 128 - PhysDevExtTramp 129 - PhysDevExtTramp 130 - PhysDevExtTramp 131 - PhysDevExtTramp 132 - PhysDevExtTramp 133 - PhysDevExtTramp 134 - PhysDevExtTramp 135 - PhysDevExtTramp 136 - PhysDevExtTramp 137 - PhysDevExtTramp 138 - PhysDevExtTramp 139 - PhysDevExtTramp 140 - PhysDevExtTramp 141 - PhysDevExtTramp 142 - PhysDevExtTramp 143 - PhysDevExtTramp 144 - PhysDevExtTramp 145 - PhysDevExtTramp 146 - PhysDevExtTramp 147 - PhysDevExtTramp 148 - PhysDevExtTramp 149 - PhysDevExtTramp 150 - PhysDevExtTramp 151 - PhysDevExtTramp 152 - PhysDevExtTramp 153 - PhysDevExtTramp 154 - PhysDevExtTramp 155 - PhysDevExtTramp 156 - PhysDevExtTramp 157 - PhysDevExtTramp 158 - PhysDevExtTramp 159 - PhysDevExtTramp 160 - PhysDevExtTramp 161 - PhysDevExtTramp 162 - PhysDevExtTramp 163 - PhysDevExtTramp 164 - PhysDevExtTramp 165 - PhysDevExtTramp 166 - PhysDevExtTramp 167 - PhysDevExtTramp 168 - PhysDevExtTramp 169 - PhysDevExtTramp 170 - PhysDevExtTramp 171 - PhysDevExtTramp 172 - PhysDevExtTramp 173 - PhysDevExtTramp 174 - PhysDevExtTramp 175 - PhysDevExtTramp 176 - PhysDevExtTramp 177 - PhysDevExtTramp 178 - PhysDevExtTramp 179 - PhysDevExtTramp 180 - PhysDevExtTramp 181 - PhysDevExtTramp 182 - PhysDevExtTramp 183 - PhysDevExtTramp 184 - PhysDevExtTramp 185 - PhysDevExtTramp 186 - PhysDevExtTramp 187 - PhysDevExtTramp 188 - PhysDevExtTramp 189 - PhysDevExtTramp 190 - PhysDevExtTramp 191 - PhysDevExtTramp 192 - PhysDevExtTramp 193 - PhysDevExtTramp 194 - PhysDevExtTramp 195 - PhysDevExtTramp 196 - PhysDevExtTramp 197 - PhysDevExtTramp 198 - PhysDevExtTramp 199 - PhysDevExtTramp 200 - PhysDevExtTramp 201 - PhysDevExtTramp 202 - PhysDevExtTramp 203 - PhysDevExtTramp 204 - PhysDevExtTramp 205 - PhysDevExtTramp 206 - PhysDevExtTramp 207 - PhysDevExtTramp 208 - PhysDevExtTramp 209 - PhysDevExtTramp 210 - PhysDevExtTramp 211 - PhysDevExtTramp 212 - PhysDevExtTramp 213 - PhysDevExtTramp 214 - PhysDevExtTramp 215 - PhysDevExtTramp 216 - PhysDevExtTramp 217 - PhysDevExtTramp 218 - PhysDevExtTramp 219 - PhysDevExtTramp 220 - PhysDevExtTramp 221 - PhysDevExtTramp 222 - PhysDevExtTramp 223 - PhysDevExtTramp 224 - PhysDevExtTramp 225 - PhysDevExtTramp 226 - PhysDevExtTramp 227 - PhysDevExtTramp 228 - PhysDevExtTramp 229 - PhysDevExtTramp 230 - PhysDevExtTramp 231 - PhysDevExtTramp 232 - PhysDevExtTramp 233 - PhysDevExtTramp 234 - PhysDevExtTramp 235 - PhysDevExtTramp 236 - PhysDevExtTramp 237 - PhysDevExtTramp 238 - PhysDevExtTramp 239 - PhysDevExtTramp 240 - PhysDevExtTramp 241 - PhysDevExtTramp 242 - PhysDevExtTramp 243 - PhysDevExtTramp 244 - PhysDevExtTramp 245 - PhysDevExtTramp 246 - PhysDevExtTramp 247 - PhysDevExtTramp 248 - PhysDevExtTramp 249 - - PhysDevExtTermin 0 - PhysDevExtTermin 1 - PhysDevExtTermin 2 - PhysDevExtTermin 3 - PhysDevExtTermin 4 - PhysDevExtTermin 5 - PhysDevExtTermin 6 - PhysDevExtTermin 7 - PhysDevExtTermin 8 - PhysDevExtTermin 9 - PhysDevExtTermin 10 - PhysDevExtTermin 11 - PhysDevExtTermin 12 - PhysDevExtTermin 13 - PhysDevExtTermin 14 - PhysDevExtTermin 15 - PhysDevExtTermin 16 - PhysDevExtTermin 17 - PhysDevExtTermin 18 - PhysDevExtTermin 19 - PhysDevExtTermin 20 - PhysDevExtTermin 21 - PhysDevExtTermin 22 - PhysDevExtTermin 23 - PhysDevExtTermin 24 - PhysDevExtTermin 25 - PhysDevExtTermin 26 - PhysDevExtTermin 27 - PhysDevExtTermin 28 - PhysDevExtTermin 29 - PhysDevExtTermin 30 - PhysDevExtTermin 31 - PhysDevExtTermin 32 - PhysDevExtTermin 33 - PhysDevExtTermin 34 - PhysDevExtTermin 35 - PhysDevExtTermin 36 - PhysDevExtTermin 37 - PhysDevExtTermin 38 - PhysDevExtTermin 39 - PhysDevExtTermin 40 - PhysDevExtTermin 41 - PhysDevExtTermin 42 - PhysDevExtTermin 43 - PhysDevExtTermin 44 - PhysDevExtTermin 45 - PhysDevExtTermin 46 - PhysDevExtTermin 47 - PhysDevExtTermin 48 - PhysDevExtTermin 49 - PhysDevExtTermin 50 - PhysDevExtTermin 51 - PhysDevExtTermin 52 - PhysDevExtTermin 53 - PhysDevExtTermin 54 - PhysDevExtTermin 55 - PhysDevExtTermin 56 - PhysDevExtTermin 57 - PhysDevExtTermin 58 - PhysDevExtTermin 59 - PhysDevExtTermin 60 - PhysDevExtTermin 61 - PhysDevExtTermin 62 - PhysDevExtTermin 63 - PhysDevExtTermin 64 - PhysDevExtTermin 65 - PhysDevExtTermin 66 - PhysDevExtTermin 67 - PhysDevExtTermin 68 - PhysDevExtTermin 69 - PhysDevExtTermin 70 - PhysDevExtTermin 71 - PhysDevExtTermin 72 - PhysDevExtTermin 73 - PhysDevExtTermin 74 - PhysDevExtTermin 75 - PhysDevExtTermin 76 - PhysDevExtTermin 77 - PhysDevExtTermin 78 - PhysDevExtTermin 79 - PhysDevExtTermin 80 - PhysDevExtTermin 81 - PhysDevExtTermin 82 - PhysDevExtTermin 83 - PhysDevExtTermin 84 - PhysDevExtTermin 85 - PhysDevExtTermin 86 - PhysDevExtTermin 87 - PhysDevExtTermin 88 - PhysDevExtTermin 89 - PhysDevExtTermin 90 - PhysDevExtTermin 91 - PhysDevExtTermin 92 - PhysDevExtTermin 93 - PhysDevExtTermin 94 - PhysDevExtTermin 95 - PhysDevExtTermin 96 - PhysDevExtTermin 97 - PhysDevExtTermin 98 - PhysDevExtTermin 99 - PhysDevExtTermin 100 - PhysDevExtTermin 101 - PhysDevExtTermin 102 - PhysDevExtTermin 103 - PhysDevExtTermin 104 - PhysDevExtTermin 105 - PhysDevExtTermin 106 - PhysDevExtTermin 107 - PhysDevExtTermin 108 - PhysDevExtTermin 109 - PhysDevExtTermin 110 - PhysDevExtTermin 111 - PhysDevExtTermin 112 - PhysDevExtTermin 113 - PhysDevExtTermin 114 - PhysDevExtTermin 115 - PhysDevExtTermin 116 - PhysDevExtTermin 117 - PhysDevExtTermin 118 - PhysDevExtTermin 119 - PhysDevExtTermin 120 - PhysDevExtTermin 121 - PhysDevExtTermin 122 - PhysDevExtTermin 123 - PhysDevExtTermin 124 - PhysDevExtTermin 125 - PhysDevExtTermin 126 - PhysDevExtTermin 127 - PhysDevExtTermin 128 - PhysDevExtTermin 129 - PhysDevExtTermin 130 - PhysDevExtTermin 131 - PhysDevExtTermin 132 - PhysDevExtTermin 133 - PhysDevExtTermin 134 - PhysDevExtTermin 135 - PhysDevExtTermin 136 - PhysDevExtTermin 137 - PhysDevExtTermin 138 - PhysDevExtTermin 139 - PhysDevExtTermin 140 - PhysDevExtTermin 141 - PhysDevExtTermin 142 - PhysDevExtTermin 143 - PhysDevExtTermin 144 - PhysDevExtTermin 145 - PhysDevExtTermin 146 - PhysDevExtTermin 147 - PhysDevExtTermin 148 - PhysDevExtTermin 149 - PhysDevExtTermin 150 - PhysDevExtTermin 151 - PhysDevExtTermin 152 - PhysDevExtTermin 153 - PhysDevExtTermin 154 - PhysDevExtTermin 155 - PhysDevExtTermin 156 - PhysDevExtTermin 157 - PhysDevExtTermin 158 - PhysDevExtTermin 159 - PhysDevExtTermin 160 - PhysDevExtTermin 161 - PhysDevExtTermin 162 - PhysDevExtTermin 163 - PhysDevExtTermin 164 - PhysDevExtTermin 165 - PhysDevExtTermin 166 - PhysDevExtTermin 167 - PhysDevExtTermin 168 - PhysDevExtTermin 169 - PhysDevExtTermin 170 - PhysDevExtTermin 171 - PhysDevExtTermin 172 - PhysDevExtTermin 173 - PhysDevExtTermin 174 - PhysDevExtTermin 175 - PhysDevExtTermin 176 - PhysDevExtTermin 177 - PhysDevExtTermin 178 - PhysDevExtTermin 179 - PhysDevExtTermin 180 - PhysDevExtTermin 181 - PhysDevExtTermin 182 - PhysDevExtTermin 183 - PhysDevExtTermin 184 - PhysDevExtTermin 185 - PhysDevExtTermin 186 - PhysDevExtTermin 187 - PhysDevExtTermin 188 - PhysDevExtTermin 189 - PhysDevExtTermin 190 - PhysDevExtTermin 191 - PhysDevExtTermin 192 - PhysDevExtTermin 193 - PhysDevExtTermin 194 - PhysDevExtTermin 195 - PhysDevExtTermin 196 - PhysDevExtTermin 197 - PhysDevExtTermin 198 - PhysDevExtTermin 199 - PhysDevExtTermin 200 - PhysDevExtTermin 201 - PhysDevExtTermin 202 - PhysDevExtTermin 203 - PhysDevExtTermin 204 - PhysDevExtTermin 205 - PhysDevExtTermin 206 - PhysDevExtTermin 207 - PhysDevExtTermin 208 - PhysDevExtTermin 209 - PhysDevExtTermin 210 - PhysDevExtTermin 211 - PhysDevExtTermin 212 - PhysDevExtTermin 213 - PhysDevExtTermin 214 - PhysDevExtTermin 215 - PhysDevExtTermin 216 - PhysDevExtTermin 217 - PhysDevExtTermin 218 - PhysDevExtTermin 219 - PhysDevExtTermin 220 - PhysDevExtTermin 221 - PhysDevExtTermin 222 - PhysDevExtTermin 223 - PhysDevExtTermin 224 - PhysDevExtTermin 225 - PhysDevExtTermin 226 - PhysDevExtTermin 227 - PhysDevExtTermin 228 - PhysDevExtTermin 229 - PhysDevExtTermin 230 - PhysDevExtTermin 231 - PhysDevExtTermin 232 - PhysDevExtTermin 233 - PhysDevExtTermin 234 - PhysDevExtTermin 235 - PhysDevExtTermin 236 - PhysDevExtTermin 237 - PhysDevExtTermin 238 - PhysDevExtTermin 239 - PhysDevExtTermin 240 - PhysDevExtTermin 241 - PhysDevExtTermin 242 - PhysDevExtTermin 243 - PhysDevExtTermin 244 - PhysDevExtTermin 245 - PhysDevExtTermin 246 - PhysDevExtTermin 247 - PhysDevExtTermin 248 - PhysDevExtTermin 249 - - DevExtTramp 0 - DevExtTramp 1 - DevExtTramp 2 - DevExtTramp 3 - DevExtTramp 4 - DevExtTramp 5 - DevExtTramp 6 - DevExtTramp 7 - DevExtTramp 8 - DevExtTramp 9 - DevExtTramp 10 - DevExtTramp 11 - DevExtTramp 12 - DevExtTramp 13 - DevExtTramp 14 - DevExtTramp 15 - DevExtTramp 16 - DevExtTramp 17 - DevExtTramp 18 - DevExtTramp 19 - DevExtTramp 20 - DevExtTramp 21 - DevExtTramp 22 - DevExtTramp 23 - DevExtTramp 24 - DevExtTramp 25 - DevExtTramp 26 - DevExtTramp 27 - DevExtTramp 28 - DevExtTramp 29 - DevExtTramp 30 - DevExtTramp 31 - DevExtTramp 32 - DevExtTramp 33 - DevExtTramp 34 - DevExtTramp 35 - DevExtTramp 36 - DevExtTramp 37 - DevExtTramp 38 - DevExtTramp 39 - DevExtTramp 40 - DevExtTramp 41 - DevExtTramp 42 - DevExtTramp 43 - DevExtTramp 44 - DevExtTramp 45 - DevExtTramp 46 - DevExtTramp 47 - DevExtTramp 48 - DevExtTramp 49 - DevExtTramp 50 - DevExtTramp 51 - DevExtTramp 52 - DevExtTramp 53 - DevExtTramp 54 - DevExtTramp 55 - DevExtTramp 56 - DevExtTramp 57 - DevExtTramp 58 - DevExtTramp 59 - DevExtTramp 60 - DevExtTramp 61 - DevExtTramp 62 - DevExtTramp 63 - DevExtTramp 64 - DevExtTramp 65 - DevExtTramp 66 - DevExtTramp 67 - DevExtTramp 68 - DevExtTramp 69 - DevExtTramp 70 - DevExtTramp 71 - DevExtTramp 72 - DevExtTramp 73 - DevExtTramp 74 - DevExtTramp 75 - DevExtTramp 76 - DevExtTramp 77 - DevExtTramp 78 - DevExtTramp 79 - DevExtTramp 80 - DevExtTramp 81 - DevExtTramp 82 - DevExtTramp 83 - DevExtTramp 84 - DevExtTramp 85 - DevExtTramp 86 - DevExtTramp 87 - DevExtTramp 88 - DevExtTramp 89 - DevExtTramp 90 - DevExtTramp 91 - DevExtTramp 92 - DevExtTramp 93 - DevExtTramp 94 - DevExtTramp 95 - DevExtTramp 96 - DevExtTramp 97 - DevExtTramp 98 - DevExtTramp 99 - DevExtTramp 100 - DevExtTramp 101 - DevExtTramp 102 - DevExtTramp 103 - DevExtTramp 104 - DevExtTramp 105 - DevExtTramp 106 - DevExtTramp 107 - DevExtTramp 108 - DevExtTramp 109 - DevExtTramp 110 - DevExtTramp 111 - DevExtTramp 112 - DevExtTramp 113 - DevExtTramp 114 - DevExtTramp 115 - DevExtTramp 116 - DevExtTramp 117 - DevExtTramp 118 - DevExtTramp 119 - DevExtTramp 120 - DevExtTramp 121 - DevExtTramp 122 - DevExtTramp 123 - DevExtTramp 124 - DevExtTramp 125 - DevExtTramp 126 - DevExtTramp 127 - DevExtTramp 128 - DevExtTramp 129 - DevExtTramp 130 - DevExtTramp 131 - DevExtTramp 132 - DevExtTramp 133 - DevExtTramp 134 - DevExtTramp 135 - DevExtTramp 136 - DevExtTramp 137 - DevExtTramp 138 - DevExtTramp 139 - DevExtTramp 140 - DevExtTramp 141 - DevExtTramp 142 - DevExtTramp 143 - DevExtTramp 144 - DevExtTramp 145 - DevExtTramp 146 - DevExtTramp 147 - DevExtTramp 148 - DevExtTramp 149 - DevExtTramp 150 - DevExtTramp 151 - DevExtTramp 152 - DevExtTramp 153 - DevExtTramp 154 - DevExtTramp 155 - DevExtTramp 156 - DevExtTramp 157 - DevExtTramp 158 - DevExtTramp 159 - DevExtTramp 160 - DevExtTramp 161 - DevExtTramp 162 - DevExtTramp 163 - DevExtTramp 164 - DevExtTramp 165 - DevExtTramp 166 - DevExtTramp 167 - DevExtTramp 168 - DevExtTramp 169 - DevExtTramp 170 - DevExtTramp 171 - DevExtTramp 172 - DevExtTramp 173 - DevExtTramp 174 - DevExtTramp 175 - DevExtTramp 176 - DevExtTramp 177 - DevExtTramp 178 - DevExtTramp 179 - DevExtTramp 180 - DevExtTramp 181 - DevExtTramp 182 - DevExtTramp 183 - DevExtTramp 184 - DevExtTramp 185 - DevExtTramp 186 - DevExtTramp 187 - DevExtTramp 188 - DevExtTramp 189 - DevExtTramp 190 - DevExtTramp 191 - DevExtTramp 192 - DevExtTramp 193 - DevExtTramp 194 - DevExtTramp 195 - DevExtTramp 196 - DevExtTramp 197 - DevExtTramp 198 - DevExtTramp 199 - DevExtTramp 200 - DevExtTramp 201 - DevExtTramp 202 - DevExtTramp 203 - DevExtTramp 204 - DevExtTramp 205 - DevExtTramp 206 - DevExtTramp 207 - DevExtTramp 208 - DevExtTramp 209 - DevExtTramp 210 - DevExtTramp 211 - DevExtTramp 212 - DevExtTramp 213 - DevExtTramp 214 - DevExtTramp 215 - DevExtTramp 216 - DevExtTramp 217 - DevExtTramp 218 - DevExtTramp 219 - DevExtTramp 220 - DevExtTramp 221 - DevExtTramp 222 - DevExtTramp 223 - DevExtTramp 224 - DevExtTramp 225 - DevExtTramp 226 - DevExtTramp 227 - DevExtTramp 228 - DevExtTramp 229 - DevExtTramp 230 - DevExtTramp 231 - DevExtTramp 232 - DevExtTramp 233 - DevExtTramp 234 - DevExtTramp 235 - DevExtTramp 236 - DevExtTramp 237 - DevExtTramp 238 - DevExtTramp 239 - DevExtTramp 240 - DevExtTramp 241 - DevExtTramp 242 - DevExtTramp 243 - DevExtTramp 244 - DevExtTramp 245 - DevExtTramp 246 - DevExtTramp 247 - DevExtTramp 248 - DevExtTramp 249 diff --git a/third_party/vulkan/loader/unknown_ext_chain_masm.asm b/third_party/vulkan/loader/unknown_ext_chain_masm.asm deleted file mode 100644 index 34bc7c2fc..000000000 --- a/third_party/vulkan/loader/unknown_ext_chain_masm.asm +++ /dev/null @@ -1,883 +0,0 @@ -; -; Copyright (c) 2017 The Khronos Group Inc. -; Copyright (c) 2017 Valve Corporation -; Copyright (c) 2017 LunarG, Inc. -; -; Licensed under the Apache License, Version 2.0 (the "License"); -; you may not use this file except in compliance with the License. -; You may obtain a copy of the License at -; -; http://www.apache.org/licenses/LICENSE-2.0 -; -; Unless required by applicable law or agreed to in writing, software -; distributed under the License is distributed on an "AS IS" BASIS, -; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -; See the License for the specific language governing permissions and -; limitations under the License. -; -; Author: Lenny Komow -; - -; This code is used to pass on device (including 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 or a dispatchable object it can unwrap the object, possibly overwriting the wrapped physical device, and then -; jump to the next function in the call chain - -; Codegen defines a number of values, chiefly offsets of members within structs and sizes of data types within gen_defines.asm. -; Struct member offsets are defined in the format "XX_OFFSET_YY" where XX indicates the member within the struct and YY indicates -; the struct type that it is a member of. Data type sizes are defined in the format "XX_SIZE" where XX indicates the data type. -INCLUDE gen_defines.asm - -; 64-bit values and macro -IFDEF rax - -PhysDevExtTramp macro num:req -public vkPhysDevExtTramp&num& -vkPhysDevExtTramp&num&: - mov rax, qword ptr [rcx] ; Dereference the wrapped VkPhysicalDevice to get the dispatch table in rax - mov rcx, qword ptr [rcx + PHYS_DEV_OFFSET_PHYS_DEV_TRAMP] ; Load the unwrapped VkPhysicalDevice into rcx - jmp qword ptr [rax + (PHYS_DEV_OFFSET_INST_DISPATCH + (PTR_SIZE * num))] ; Jump to the next function in the chain, preserving the args in other registers -endm - -PhysDevExtTermin macro num -public vkPhysDevExtTermin&num& -vkPhysDevExtTermin&num&: - mov rax, qword ptr [rcx + ICD_TERM_OFFSET_PHYS_DEV_TERM] ; Store the loader_icd_term* in rax - cmp qword ptr [rax + (DISPATCH_OFFSET_ICD_TERM + (PTR_SIZE * num))], 0 ; Check if the next function in the chain is NULL - je terminError&num& ; Go to the error section if it is NULL - mov rcx, qword ptr [rcx + PHYS_DEV_OFFSET_PHYS_DEV_TERM] ; Load the unwrapped VkPhysicalDevice into the first arg - jmp qword ptr [rax + (DISPATCH_OFFSET_ICD_TERM + (PTR_SIZE * num))] ; Jump to the next function in the chain -terminError&num&: - sub rsp, 56 ; Create the stack frame - mov rcx, qword ptr [rax + INSTANCE_OFFSET_ICD_TERM] ; Load the loader_instance into rcx (first arg) - mov rax, qword ptr [rcx + (HASH_OFFSET_INSTANCE + (HASH_SIZE * num) + FUNC_NAME_OFFSET_HASH)] ; Load the func name into rax - lea r9, termin_error_string ; Load the error string into r9 (fourth arg) - xor r8d, r8d ; Set r8 to zero (third arg) - mov qword ptr [rsp + 32], rax ; Move the func name onto the stack (fifth arg) - lea edx, [r8 + VK_DEBUG_REPORT_ERROR_BIT_EXT] ; Write the error logging bit to rdx (second arg) - call loader_log ; Log the error message before we crash - add rsp, 56 ; Clean up the stack frame - mov rax, 0 - jmp rax ; Crash intentionally by jumping to address zero -endm - -DevExtTramp macro num -public vkdev_ext&num& -vkdev_ext&num&: - mov rax, qword ptr [rcx] ; Dereference the handle to get the dispatch table - jmp qword ptr [rax + (EXT_OFFSET_DEVICE_DISPATCH + (PTR_SIZE * num))] ; Jump to the appropriate call chain -endm - -; 32-bit values and macro -ELSE - -PhysDevExtTramp macro num -public _vkPhysDevExtTramp&num&@4 -_vkPhysDevExtTramp&num&@4: - mov eax, dword ptr [esp + 4] ; Load the wrapped VkPhysicalDevice into eax - mov ecx, [eax + PHYS_DEV_OFFSET_PHYS_DEV_TRAMP] ; Load the unwrapped VkPhysicalDevice into ecx - mov [esp + 4], ecx ; Overwrite the wrapped VkPhysicalDevice with the unwrapped one (on the stack) - mov eax, [eax] ; Dereference the wrapped VkPhysicalDevice to get the dispatch table in eax - jmp dword ptr [eax + (PHYS_DEV_OFFSET_INST_DISPATCH + (PTR_SIZE * num))] ; Jump to the next function in the chain, preserving the args on the stack -endm - -PhysDevExtTermin macro num -public _vkPhysDevExtTermin&num&@4 -_vkPhysDevExtTermin&num&@4: - mov ecx, dword ptr [esp + 4] ; Move the wrapped VkPhysicalDevice into ecx - mov eax, dword ptr [ecx + ICD_TERM_OFFSET_PHYS_DEV_TERM] ; Store the loader_icd_term* in eax - cmp dword ptr [eax + (DISPATCH_OFFSET_ICD_TERM + (PTR_SIZE * num))], 0 ; Check if the next function in the chain is NULL - je terminError&num& ; Go to the error section if it is NULL - mov ecx, dword ptr [ecx + PHYS_DEV_OFFSET_PHYS_DEV_TERM] ; Unwrap the VkPhysicalDevice in ecx - mov dword ptr [esp + 4], ecx ; Copy the unwrapped VkPhysicalDevice into the first arg - jmp dword ptr [eax + (DISPATCH_OFFSET_ICD_TERM + (PTR_SIZE * num))] ; Jump to the next function in the chain -terminError&num&: - mov eax, dword ptr [eax + INSTANCE_OFFSET_ICD_TERM] ; Load the loader_instance into eax - push dword ptr [eax + (HASH_OFFSET_INSTANCE + (HASH_SIZE * num) + FUNC_NAME_OFFSET_HASH)] ; Push the func name (fifth arg) - push offset termin_error_string ; Push the error string (fourth arg) - push 0 ; Push zero (third arg) - push VK_DEBUG_REPORT_ERROR_BIT_EXT ; Push the error logging bit (second arg) - push eax ; Push the loader_instance (first arg) - call _loader_log ; Log the error message before we crash - add esp, 20 ; Clean up the args - mov eax, 0 - jmp eax ; Crash intentionally by jumping to address zero -endm - -DevExtTramp macro num -public _vkdev_ext&num&@4 -_vkdev_ext&num&@4: - mov eax, dword ptr [esp + 4] ; Dereference the handle to get the dispatch table - jmp dword ptr [eax + (EXT_OFFSET_DEVICE_DISPATCH + (PTR_SIZE * num))] ; Jump to the appropriate call chain -endm - -; This is also needed for 32-bit only -.model flat - -ENDIF - -.const - termin_error_string db 'Extension %s not supported for this physical device', 0 - -.code - -IFDEF rax -extrn loader_log:near -ELSE -extrn _loader_log:near -ENDIF - - PhysDevExtTramp 0 - PhysDevExtTramp 1 - PhysDevExtTramp 2 - PhysDevExtTramp 3 - PhysDevExtTramp 4 - PhysDevExtTramp 5 - PhysDevExtTramp 6 - PhysDevExtTramp 7 - PhysDevExtTramp 8 - PhysDevExtTramp 9 - PhysDevExtTramp 10 - PhysDevExtTramp 11 - PhysDevExtTramp 12 - PhysDevExtTramp 13 - PhysDevExtTramp 14 - PhysDevExtTramp 15 - PhysDevExtTramp 16 - PhysDevExtTramp 17 - PhysDevExtTramp 18 - PhysDevExtTramp 19 - PhysDevExtTramp 20 - PhysDevExtTramp 21 - PhysDevExtTramp 22 - PhysDevExtTramp 23 - PhysDevExtTramp 24 - PhysDevExtTramp 25 - PhysDevExtTramp 26 - PhysDevExtTramp 27 - PhysDevExtTramp 28 - PhysDevExtTramp 29 - PhysDevExtTramp 30 - PhysDevExtTramp 31 - PhysDevExtTramp 32 - PhysDevExtTramp 33 - PhysDevExtTramp 34 - PhysDevExtTramp 35 - PhysDevExtTramp 36 - PhysDevExtTramp 37 - PhysDevExtTramp 38 - PhysDevExtTramp 39 - PhysDevExtTramp 40 - PhysDevExtTramp 41 - PhysDevExtTramp 42 - PhysDevExtTramp 43 - PhysDevExtTramp 44 - PhysDevExtTramp 45 - PhysDevExtTramp 46 - PhysDevExtTramp 47 - PhysDevExtTramp 48 - PhysDevExtTramp 49 - PhysDevExtTramp 50 - PhysDevExtTramp 51 - PhysDevExtTramp 52 - PhysDevExtTramp 53 - PhysDevExtTramp 54 - PhysDevExtTramp 55 - PhysDevExtTramp 56 - PhysDevExtTramp 57 - PhysDevExtTramp 58 - PhysDevExtTramp 59 - PhysDevExtTramp 60 - PhysDevExtTramp 61 - PhysDevExtTramp 62 - PhysDevExtTramp 63 - PhysDevExtTramp 64 - PhysDevExtTramp 65 - PhysDevExtTramp 66 - PhysDevExtTramp 67 - PhysDevExtTramp 68 - PhysDevExtTramp 69 - PhysDevExtTramp 70 - PhysDevExtTramp 71 - PhysDevExtTramp 72 - PhysDevExtTramp 73 - PhysDevExtTramp 74 - PhysDevExtTramp 75 - PhysDevExtTramp 76 - PhysDevExtTramp 77 - PhysDevExtTramp 78 - PhysDevExtTramp 79 - PhysDevExtTramp 80 - PhysDevExtTramp 81 - PhysDevExtTramp 82 - PhysDevExtTramp 83 - PhysDevExtTramp 84 - PhysDevExtTramp 85 - PhysDevExtTramp 86 - PhysDevExtTramp 87 - PhysDevExtTramp 88 - PhysDevExtTramp 89 - PhysDevExtTramp 90 - PhysDevExtTramp 91 - PhysDevExtTramp 92 - PhysDevExtTramp 93 - PhysDevExtTramp 94 - PhysDevExtTramp 95 - PhysDevExtTramp 96 - PhysDevExtTramp 97 - PhysDevExtTramp 98 - PhysDevExtTramp 99 - PhysDevExtTramp 100 - PhysDevExtTramp 101 - PhysDevExtTramp 102 - PhysDevExtTramp 103 - PhysDevExtTramp 104 - PhysDevExtTramp 105 - PhysDevExtTramp 106 - PhysDevExtTramp 107 - PhysDevExtTramp 108 - PhysDevExtTramp 109 - PhysDevExtTramp 110 - PhysDevExtTramp 111 - PhysDevExtTramp 112 - PhysDevExtTramp 113 - PhysDevExtTramp 114 - PhysDevExtTramp 115 - PhysDevExtTramp 116 - PhysDevExtTramp 117 - PhysDevExtTramp 118 - PhysDevExtTramp 119 - PhysDevExtTramp 120 - PhysDevExtTramp 121 - PhysDevExtTramp 122 - PhysDevExtTramp 123 - PhysDevExtTramp 124 - PhysDevExtTramp 125 - PhysDevExtTramp 126 - PhysDevExtTramp 127 - PhysDevExtTramp 128 - PhysDevExtTramp 129 - PhysDevExtTramp 130 - PhysDevExtTramp 131 - PhysDevExtTramp 132 - PhysDevExtTramp 133 - PhysDevExtTramp 134 - PhysDevExtTramp 135 - PhysDevExtTramp 136 - PhysDevExtTramp 137 - PhysDevExtTramp 138 - PhysDevExtTramp 139 - PhysDevExtTramp 140 - PhysDevExtTramp 141 - PhysDevExtTramp 142 - PhysDevExtTramp 143 - PhysDevExtTramp 144 - PhysDevExtTramp 145 - PhysDevExtTramp 146 - PhysDevExtTramp 147 - PhysDevExtTramp 148 - PhysDevExtTramp 149 - PhysDevExtTramp 150 - PhysDevExtTramp 151 - PhysDevExtTramp 152 - PhysDevExtTramp 153 - PhysDevExtTramp 154 - PhysDevExtTramp 155 - PhysDevExtTramp 156 - PhysDevExtTramp 157 - PhysDevExtTramp 158 - PhysDevExtTramp 159 - PhysDevExtTramp 160 - PhysDevExtTramp 161 - PhysDevExtTramp 162 - PhysDevExtTramp 163 - PhysDevExtTramp 164 - PhysDevExtTramp 165 - PhysDevExtTramp 166 - PhysDevExtTramp 167 - PhysDevExtTramp 168 - PhysDevExtTramp 169 - PhysDevExtTramp 170 - PhysDevExtTramp 171 - PhysDevExtTramp 172 - PhysDevExtTramp 173 - PhysDevExtTramp 174 - PhysDevExtTramp 175 - PhysDevExtTramp 176 - PhysDevExtTramp 177 - PhysDevExtTramp 178 - PhysDevExtTramp 179 - PhysDevExtTramp 180 - PhysDevExtTramp 181 - PhysDevExtTramp 182 - PhysDevExtTramp 183 - PhysDevExtTramp 184 - PhysDevExtTramp 185 - PhysDevExtTramp 186 - PhysDevExtTramp 187 - PhysDevExtTramp 188 - PhysDevExtTramp 189 - PhysDevExtTramp 190 - PhysDevExtTramp 191 - PhysDevExtTramp 192 - PhysDevExtTramp 193 - PhysDevExtTramp 194 - PhysDevExtTramp 195 - PhysDevExtTramp 196 - PhysDevExtTramp 197 - PhysDevExtTramp 198 - PhysDevExtTramp 199 - PhysDevExtTramp 200 - PhysDevExtTramp 201 - PhysDevExtTramp 202 - PhysDevExtTramp 203 - PhysDevExtTramp 204 - PhysDevExtTramp 205 - PhysDevExtTramp 206 - PhysDevExtTramp 207 - PhysDevExtTramp 208 - PhysDevExtTramp 209 - PhysDevExtTramp 210 - PhysDevExtTramp 211 - PhysDevExtTramp 212 - PhysDevExtTramp 213 - PhysDevExtTramp 214 - PhysDevExtTramp 215 - PhysDevExtTramp 216 - PhysDevExtTramp 217 - PhysDevExtTramp 218 - PhysDevExtTramp 219 - PhysDevExtTramp 220 - PhysDevExtTramp 221 - PhysDevExtTramp 222 - PhysDevExtTramp 223 - PhysDevExtTramp 224 - PhysDevExtTramp 225 - PhysDevExtTramp 226 - PhysDevExtTramp 227 - PhysDevExtTramp 228 - PhysDevExtTramp 229 - PhysDevExtTramp 230 - PhysDevExtTramp 231 - PhysDevExtTramp 232 - PhysDevExtTramp 233 - PhysDevExtTramp 234 - PhysDevExtTramp 235 - PhysDevExtTramp 236 - PhysDevExtTramp 237 - PhysDevExtTramp 238 - PhysDevExtTramp 239 - PhysDevExtTramp 240 - PhysDevExtTramp 241 - PhysDevExtTramp 242 - PhysDevExtTramp 243 - PhysDevExtTramp 244 - PhysDevExtTramp 245 - PhysDevExtTramp 246 - PhysDevExtTramp 247 - PhysDevExtTramp 248 - PhysDevExtTramp 249 - - PhysDevExtTermin 0 - PhysDevExtTermin 1 - PhysDevExtTermin 2 - PhysDevExtTermin 3 - PhysDevExtTermin 4 - PhysDevExtTermin 5 - PhysDevExtTermin 6 - PhysDevExtTermin 7 - PhysDevExtTermin 8 - PhysDevExtTermin 9 - PhysDevExtTermin 10 - PhysDevExtTermin 11 - PhysDevExtTermin 12 - PhysDevExtTermin 13 - PhysDevExtTermin 14 - PhysDevExtTermin 15 - PhysDevExtTermin 16 - PhysDevExtTermin 17 - PhysDevExtTermin 18 - PhysDevExtTermin 19 - PhysDevExtTermin 20 - PhysDevExtTermin 21 - PhysDevExtTermin 22 - PhysDevExtTermin 23 - PhysDevExtTermin 24 - PhysDevExtTermin 25 - PhysDevExtTermin 26 - PhysDevExtTermin 27 - PhysDevExtTermin 28 - PhysDevExtTermin 29 - PhysDevExtTermin 30 - PhysDevExtTermin 31 - PhysDevExtTermin 32 - PhysDevExtTermin 33 - PhysDevExtTermin 34 - PhysDevExtTermin 35 - PhysDevExtTermin 36 - PhysDevExtTermin 37 - PhysDevExtTermin 38 - PhysDevExtTermin 39 - PhysDevExtTermin 40 - PhysDevExtTermin 41 - PhysDevExtTermin 42 - PhysDevExtTermin 43 - PhysDevExtTermin 44 - PhysDevExtTermin 45 - PhysDevExtTermin 46 - PhysDevExtTermin 47 - PhysDevExtTermin 48 - PhysDevExtTermin 49 - PhysDevExtTermin 50 - PhysDevExtTermin 51 - PhysDevExtTermin 52 - PhysDevExtTermin 53 - PhysDevExtTermin 54 - PhysDevExtTermin 55 - PhysDevExtTermin 56 - PhysDevExtTermin 57 - PhysDevExtTermin 58 - PhysDevExtTermin 59 - PhysDevExtTermin 60 - PhysDevExtTermin 61 - PhysDevExtTermin 62 - PhysDevExtTermin 63 - PhysDevExtTermin 64 - PhysDevExtTermin 65 - PhysDevExtTermin 66 - PhysDevExtTermin 67 - PhysDevExtTermin 68 - PhysDevExtTermin 69 - PhysDevExtTermin 70 - PhysDevExtTermin 71 - PhysDevExtTermin 72 - PhysDevExtTermin 73 - PhysDevExtTermin 74 - PhysDevExtTermin 75 - PhysDevExtTermin 76 - PhysDevExtTermin 77 - PhysDevExtTermin 78 - PhysDevExtTermin 79 - PhysDevExtTermin 80 - PhysDevExtTermin 81 - PhysDevExtTermin 82 - PhysDevExtTermin 83 - PhysDevExtTermin 84 - PhysDevExtTermin 85 - PhysDevExtTermin 86 - PhysDevExtTermin 87 - PhysDevExtTermin 88 - PhysDevExtTermin 89 - PhysDevExtTermin 90 - PhysDevExtTermin 91 - PhysDevExtTermin 92 - PhysDevExtTermin 93 - PhysDevExtTermin 94 - PhysDevExtTermin 95 - PhysDevExtTermin 96 - PhysDevExtTermin 97 - PhysDevExtTermin 98 - PhysDevExtTermin 99 - PhysDevExtTermin 100 - PhysDevExtTermin 101 - PhysDevExtTermin 102 - PhysDevExtTermin 103 - PhysDevExtTermin 104 - PhysDevExtTermin 105 - PhysDevExtTermin 106 - PhysDevExtTermin 107 - PhysDevExtTermin 108 - PhysDevExtTermin 109 - PhysDevExtTermin 110 - PhysDevExtTermin 111 - PhysDevExtTermin 112 - PhysDevExtTermin 113 - PhysDevExtTermin 114 - PhysDevExtTermin 115 - PhysDevExtTermin 116 - PhysDevExtTermin 117 - PhysDevExtTermin 118 - PhysDevExtTermin 119 - PhysDevExtTermin 120 - PhysDevExtTermin 121 - PhysDevExtTermin 122 - PhysDevExtTermin 123 - PhysDevExtTermin 124 - PhysDevExtTermin 125 - PhysDevExtTermin 126 - PhysDevExtTermin 127 - PhysDevExtTermin 128 - PhysDevExtTermin 129 - PhysDevExtTermin 130 - PhysDevExtTermin 131 - PhysDevExtTermin 132 - PhysDevExtTermin 133 - PhysDevExtTermin 134 - PhysDevExtTermin 135 - PhysDevExtTermin 136 - PhysDevExtTermin 137 - PhysDevExtTermin 138 - PhysDevExtTermin 139 - PhysDevExtTermin 140 - PhysDevExtTermin 141 - PhysDevExtTermin 142 - PhysDevExtTermin 143 - PhysDevExtTermin 144 - PhysDevExtTermin 145 - PhysDevExtTermin 146 - PhysDevExtTermin 147 - PhysDevExtTermin 148 - PhysDevExtTermin 149 - PhysDevExtTermin 150 - PhysDevExtTermin 151 - PhysDevExtTermin 152 - PhysDevExtTermin 153 - PhysDevExtTermin 154 - PhysDevExtTermin 155 - PhysDevExtTermin 156 - PhysDevExtTermin 157 - PhysDevExtTermin 158 - PhysDevExtTermin 159 - PhysDevExtTermin 160 - PhysDevExtTermin 161 - PhysDevExtTermin 162 - PhysDevExtTermin 163 - PhysDevExtTermin 164 - PhysDevExtTermin 165 - PhysDevExtTermin 166 - PhysDevExtTermin 167 - PhysDevExtTermin 168 - PhysDevExtTermin 169 - PhysDevExtTermin 170 - PhysDevExtTermin 171 - PhysDevExtTermin 172 - PhysDevExtTermin 173 - PhysDevExtTermin 174 - PhysDevExtTermin 175 - PhysDevExtTermin 176 - PhysDevExtTermin 177 - PhysDevExtTermin 178 - PhysDevExtTermin 179 - PhysDevExtTermin 180 - PhysDevExtTermin 181 - PhysDevExtTermin 182 - PhysDevExtTermin 183 - PhysDevExtTermin 184 - PhysDevExtTermin 185 - PhysDevExtTermin 186 - PhysDevExtTermin 187 - PhysDevExtTermin 188 - PhysDevExtTermin 189 - PhysDevExtTermin 190 - PhysDevExtTermin 191 - PhysDevExtTermin 192 - PhysDevExtTermin 193 - PhysDevExtTermin 194 - PhysDevExtTermin 195 - PhysDevExtTermin 196 - PhysDevExtTermin 197 - PhysDevExtTermin 198 - PhysDevExtTermin 199 - PhysDevExtTermin 200 - PhysDevExtTermin 201 - PhysDevExtTermin 202 - PhysDevExtTermin 203 - PhysDevExtTermin 204 - PhysDevExtTermin 205 - PhysDevExtTermin 206 - PhysDevExtTermin 207 - PhysDevExtTermin 208 - PhysDevExtTermin 209 - PhysDevExtTermin 210 - PhysDevExtTermin 211 - PhysDevExtTermin 212 - PhysDevExtTermin 213 - PhysDevExtTermin 214 - PhysDevExtTermin 215 - PhysDevExtTermin 216 - PhysDevExtTermin 217 - PhysDevExtTermin 218 - PhysDevExtTermin 219 - PhysDevExtTermin 220 - PhysDevExtTermin 221 - PhysDevExtTermin 222 - PhysDevExtTermin 223 - PhysDevExtTermin 224 - PhysDevExtTermin 225 - PhysDevExtTermin 226 - PhysDevExtTermin 227 - PhysDevExtTermin 228 - PhysDevExtTermin 229 - PhysDevExtTermin 230 - PhysDevExtTermin 231 - PhysDevExtTermin 232 - PhysDevExtTermin 233 - PhysDevExtTermin 234 - PhysDevExtTermin 235 - PhysDevExtTermin 236 - PhysDevExtTermin 237 - PhysDevExtTermin 238 - PhysDevExtTermin 239 - PhysDevExtTermin 240 - PhysDevExtTermin 241 - PhysDevExtTermin 242 - PhysDevExtTermin 243 - PhysDevExtTermin 244 - PhysDevExtTermin 245 - PhysDevExtTermin 246 - PhysDevExtTermin 247 - PhysDevExtTermin 248 - PhysDevExtTermin 249 - - DevExtTramp 0 - DevExtTramp 1 - DevExtTramp 2 - DevExtTramp 3 - DevExtTramp 4 - DevExtTramp 5 - DevExtTramp 6 - DevExtTramp 7 - DevExtTramp 8 - DevExtTramp 9 - DevExtTramp 10 - DevExtTramp 11 - DevExtTramp 12 - DevExtTramp 13 - DevExtTramp 14 - DevExtTramp 15 - DevExtTramp 16 - DevExtTramp 17 - DevExtTramp 18 - DevExtTramp 19 - DevExtTramp 20 - DevExtTramp 21 - DevExtTramp 22 - DevExtTramp 23 - DevExtTramp 24 - DevExtTramp 25 - DevExtTramp 26 - DevExtTramp 27 - DevExtTramp 28 - DevExtTramp 29 - DevExtTramp 30 - DevExtTramp 31 - DevExtTramp 32 - DevExtTramp 33 - DevExtTramp 34 - DevExtTramp 35 - DevExtTramp 36 - DevExtTramp 37 - DevExtTramp 38 - DevExtTramp 39 - DevExtTramp 40 - DevExtTramp 41 - DevExtTramp 42 - DevExtTramp 43 - DevExtTramp 44 - DevExtTramp 45 - DevExtTramp 46 - DevExtTramp 47 - DevExtTramp 48 - DevExtTramp 49 - DevExtTramp 50 - DevExtTramp 51 - DevExtTramp 52 - DevExtTramp 53 - DevExtTramp 54 - DevExtTramp 55 - DevExtTramp 56 - DevExtTramp 57 - DevExtTramp 58 - DevExtTramp 59 - DevExtTramp 60 - DevExtTramp 61 - DevExtTramp 62 - DevExtTramp 63 - DevExtTramp 64 - DevExtTramp 65 - DevExtTramp 66 - DevExtTramp 67 - DevExtTramp 68 - DevExtTramp 69 - DevExtTramp 70 - DevExtTramp 71 - DevExtTramp 72 - DevExtTramp 73 - DevExtTramp 74 - DevExtTramp 75 - DevExtTramp 76 - DevExtTramp 77 - DevExtTramp 78 - DevExtTramp 79 - DevExtTramp 80 - DevExtTramp 81 - DevExtTramp 82 - DevExtTramp 83 - DevExtTramp 84 - DevExtTramp 85 - DevExtTramp 86 - DevExtTramp 87 - DevExtTramp 88 - DevExtTramp 89 - DevExtTramp 90 - DevExtTramp 91 - DevExtTramp 92 - DevExtTramp 93 - DevExtTramp 94 - DevExtTramp 95 - DevExtTramp 96 - DevExtTramp 97 - DevExtTramp 98 - DevExtTramp 99 - DevExtTramp 100 - DevExtTramp 101 - DevExtTramp 102 - DevExtTramp 103 - DevExtTramp 104 - DevExtTramp 105 - DevExtTramp 106 - DevExtTramp 107 - DevExtTramp 108 - DevExtTramp 109 - DevExtTramp 110 - DevExtTramp 111 - DevExtTramp 112 - DevExtTramp 113 - DevExtTramp 114 - DevExtTramp 115 - DevExtTramp 116 - DevExtTramp 117 - DevExtTramp 118 - DevExtTramp 119 - DevExtTramp 120 - DevExtTramp 121 - DevExtTramp 122 - DevExtTramp 123 - DevExtTramp 124 - DevExtTramp 125 - DevExtTramp 126 - DevExtTramp 127 - DevExtTramp 128 - DevExtTramp 129 - DevExtTramp 130 - DevExtTramp 131 - DevExtTramp 132 - DevExtTramp 133 - DevExtTramp 134 - DevExtTramp 135 - DevExtTramp 136 - DevExtTramp 137 - DevExtTramp 138 - DevExtTramp 139 - DevExtTramp 140 - DevExtTramp 141 - DevExtTramp 142 - DevExtTramp 143 - DevExtTramp 144 - DevExtTramp 145 - DevExtTramp 146 - DevExtTramp 147 - DevExtTramp 148 - DevExtTramp 149 - DevExtTramp 150 - DevExtTramp 151 - DevExtTramp 152 - DevExtTramp 153 - DevExtTramp 154 - DevExtTramp 155 - DevExtTramp 156 - DevExtTramp 157 - DevExtTramp 158 - DevExtTramp 159 - DevExtTramp 160 - DevExtTramp 161 - DevExtTramp 162 - DevExtTramp 163 - DevExtTramp 164 - DevExtTramp 165 - DevExtTramp 166 - DevExtTramp 167 - DevExtTramp 168 - DevExtTramp 169 - DevExtTramp 170 - DevExtTramp 171 - DevExtTramp 172 - DevExtTramp 173 - DevExtTramp 174 - DevExtTramp 175 - DevExtTramp 176 - DevExtTramp 177 - DevExtTramp 178 - DevExtTramp 179 - DevExtTramp 180 - DevExtTramp 181 - DevExtTramp 182 - DevExtTramp 183 - DevExtTramp 184 - DevExtTramp 185 - DevExtTramp 186 - DevExtTramp 187 - DevExtTramp 188 - DevExtTramp 189 - DevExtTramp 190 - DevExtTramp 191 - DevExtTramp 192 - DevExtTramp 193 - DevExtTramp 194 - DevExtTramp 195 - DevExtTramp 196 - DevExtTramp 197 - DevExtTramp 198 - DevExtTramp 199 - DevExtTramp 200 - DevExtTramp 201 - DevExtTramp 202 - DevExtTramp 203 - DevExtTramp 204 - DevExtTramp 205 - DevExtTramp 206 - DevExtTramp 207 - DevExtTramp 208 - DevExtTramp 209 - DevExtTramp 210 - DevExtTramp 211 - DevExtTramp 212 - DevExtTramp 213 - DevExtTramp 214 - DevExtTramp 215 - DevExtTramp 216 - DevExtTramp 217 - DevExtTramp 218 - DevExtTramp 219 - DevExtTramp 220 - DevExtTramp 221 - DevExtTramp 222 - DevExtTramp 223 - DevExtTramp 224 - DevExtTramp 225 - DevExtTramp 226 - DevExtTramp 227 - DevExtTramp 228 - DevExtTramp 229 - DevExtTramp 230 - DevExtTramp 231 - DevExtTramp 232 - DevExtTramp 233 - DevExtTramp 234 - DevExtTramp 235 - DevExtTramp 236 - DevExtTramp 237 - DevExtTramp 238 - DevExtTramp 239 - DevExtTramp 240 - DevExtTramp 241 - DevExtTramp 242 - DevExtTramp 243 - DevExtTramp 244 - DevExtTramp 245 - DevExtTramp 246 - DevExtTramp 247 - DevExtTramp 248 - DevExtTramp 249 - -end diff --git a/third_party/vulkan/loader/vk_loader_extensions.c b/third_party/vulkan/loader/vk_loader_extensions.c deleted file mode 100644 index 38692e53a..000000000 --- a/third_party/vulkan/loader/vk_loader_extensions.c +++ /dev/null @@ -1,2760 +0,0 @@ -// *** THIS FILE IS GENERATED - DO NOT EDIT *** -// See loader_extension_generator.py for modifications - -/* - * Copyright (c) 2015-2017 The Khronos Group Inc. - * Copyright (c) 2015-2017 Valve Corporation - * Copyright (c) 2015-2017 LunarG, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Author: Mark Lobodzinski - * Author: Mark Young - */ - -#define _GNU_SOURCE -#include -#include -#include -#include "vk_loader_platform.h" -#include "loader.h" -#include "vk_loader_extensions.h" -#include -#include "wsi.h" -#include "debug_report.h" -#include "extension_manual.h" - -// Device extension error function -VKAPI_ATTR VkResult VKAPI_CALL vkDevExtError(VkDevice dev) { - struct loader_device *found_dev; - // The device going in is a trampoline device - struct loader_icd_term *icd_term = loader_get_icd_and_device(dev, &found_dev, NULL); - - if (icd_term) - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "Bad destination in loader trampoline dispatch," - "Are layers and extensions that you are calling enabled?"); - return VK_ERROR_EXTENSION_NOT_PRESENT; -} - -VKAPI_ATTR bool VKAPI_CALL loader_icd_init_entries(struct loader_icd_term *icd_term, VkInstance inst, - const PFN_vkGetInstanceProcAddr fp_gipa) { - -#define LOOKUP_GIPA(func, required) \ - do { \ - icd_term->dispatch.func = (PFN_vk##func)fp_gipa(inst, "vk" #func); \ - if (!icd_term->dispatch.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) - - - // ---- Core 1_0 - LOOKUP_GIPA(DestroyInstance, true); - LOOKUP_GIPA(EnumeratePhysicalDevices, true); - LOOKUP_GIPA(GetPhysicalDeviceFeatures, true); - LOOKUP_GIPA(GetPhysicalDeviceFormatProperties, true); - LOOKUP_GIPA(GetPhysicalDeviceImageFormatProperties, true); - LOOKUP_GIPA(GetPhysicalDeviceProperties, true); - LOOKUP_GIPA(GetPhysicalDeviceQueueFamilyProperties, true); - LOOKUP_GIPA(GetPhysicalDeviceMemoryProperties, true); - LOOKUP_GIPA(GetDeviceProcAddr, true); - LOOKUP_GIPA(CreateDevice, true); - LOOKUP_GIPA(EnumerateDeviceExtensionProperties, true); - LOOKUP_GIPA(GetPhysicalDeviceSparseImageFormatProperties, true); - - // ---- VK_KHR_surface extension commands - LOOKUP_GIPA(DestroySurfaceKHR, false); - LOOKUP_GIPA(GetPhysicalDeviceSurfaceSupportKHR, false); - LOOKUP_GIPA(GetPhysicalDeviceSurfaceCapabilitiesKHR, false); - LOOKUP_GIPA(GetPhysicalDeviceSurfaceFormatsKHR, false); - LOOKUP_GIPA(GetPhysicalDeviceSurfacePresentModesKHR, false); - - // ---- VK_KHR_swapchain extension commands - LOOKUP_GIPA(CreateSwapchainKHR, false); - - // ---- VK_KHR_display extension commands - LOOKUP_GIPA(GetPhysicalDeviceDisplayPropertiesKHR, false); - LOOKUP_GIPA(GetPhysicalDeviceDisplayPlanePropertiesKHR, false); - LOOKUP_GIPA(GetDisplayPlaneSupportedDisplaysKHR, false); - LOOKUP_GIPA(GetDisplayModePropertiesKHR, false); - LOOKUP_GIPA(CreateDisplayModeKHR, false); - LOOKUP_GIPA(GetDisplayPlaneCapabilitiesKHR, false); - LOOKUP_GIPA(CreateDisplayPlaneSurfaceKHR, false); - - // ---- VK_KHR_display_swapchain extension commands - LOOKUP_GIPA(CreateSharedSwapchainsKHR, false); - - // ---- VK_KHR_xlib_surface extension commands -#ifdef VK_USE_PLATFORM_XLIB_KHR - LOOKUP_GIPA(CreateXlibSurfaceKHR, false); -#endif // VK_USE_PLATFORM_XLIB_KHR -#ifdef VK_USE_PLATFORM_XLIB_KHR - LOOKUP_GIPA(GetPhysicalDeviceXlibPresentationSupportKHR, false); -#endif // VK_USE_PLATFORM_XLIB_KHR - - // ---- VK_KHR_xcb_surface extension commands -#ifdef VK_USE_PLATFORM_XCB_KHR - LOOKUP_GIPA(CreateXcbSurfaceKHR, false); -#endif // VK_USE_PLATFORM_XCB_KHR -#ifdef VK_USE_PLATFORM_XCB_KHR - LOOKUP_GIPA(GetPhysicalDeviceXcbPresentationSupportKHR, false); -#endif // VK_USE_PLATFORM_XCB_KHR - - // ---- VK_KHR_wayland_surface extension commands -#ifdef VK_USE_PLATFORM_WAYLAND_KHR - LOOKUP_GIPA(CreateWaylandSurfaceKHR, false); -#endif // VK_USE_PLATFORM_WAYLAND_KHR -#ifdef VK_USE_PLATFORM_WAYLAND_KHR - LOOKUP_GIPA(GetPhysicalDeviceWaylandPresentationSupportKHR, false); -#endif // VK_USE_PLATFORM_WAYLAND_KHR - - // ---- VK_KHR_mir_surface extension commands -#ifdef VK_USE_PLATFORM_MIR_KHR - LOOKUP_GIPA(CreateMirSurfaceKHR, false); -#endif // VK_USE_PLATFORM_MIR_KHR -#ifdef VK_USE_PLATFORM_MIR_KHR - LOOKUP_GIPA(GetPhysicalDeviceMirPresentationSupportKHR, false); -#endif // VK_USE_PLATFORM_MIR_KHR - - // ---- VK_KHR_android_surface extension commands -#ifdef VK_USE_PLATFORM_ANDROID_KHR - LOOKUP_GIPA(CreateAndroidSurfaceKHR, false); -#endif // VK_USE_PLATFORM_ANDROID_KHR - - // ---- VK_KHR_win32_surface extension commands -#ifdef VK_USE_PLATFORM_WIN32_KHR - LOOKUP_GIPA(CreateWin32SurfaceKHR, false); -#endif // VK_USE_PLATFORM_WIN32_KHR -#ifdef VK_USE_PLATFORM_WIN32_KHR - LOOKUP_GIPA(GetPhysicalDeviceWin32PresentationSupportKHR, false); -#endif // VK_USE_PLATFORM_WIN32_KHR - - // ---- VK_KHR_get_physical_device_properties2 extension commands - LOOKUP_GIPA(GetPhysicalDeviceFeatures2KHR, false); - LOOKUP_GIPA(GetPhysicalDeviceProperties2KHR, false); - LOOKUP_GIPA(GetPhysicalDeviceFormatProperties2KHR, false); - LOOKUP_GIPA(GetPhysicalDeviceImageFormatProperties2KHR, false); - LOOKUP_GIPA(GetPhysicalDeviceQueueFamilyProperties2KHR, false); - LOOKUP_GIPA(GetPhysicalDeviceMemoryProperties2KHR, false); - LOOKUP_GIPA(GetPhysicalDeviceSparseImageFormatProperties2KHR, false); - - // ---- VK_KHR_external_memory_capabilities extension commands - LOOKUP_GIPA(GetPhysicalDeviceExternalBufferPropertiesKHR, false); - - // ---- VK_KHR_external_semaphore_capabilities extension commands - LOOKUP_GIPA(GetPhysicalDeviceExternalSemaphorePropertiesKHR, false); - - // ---- VK_KHR_external_fence_capabilities extension commands - LOOKUP_GIPA(GetPhysicalDeviceExternalFencePropertiesKHR, false); - - // ---- VK_KHR_get_surface_capabilities2 extension commands - LOOKUP_GIPA(GetPhysicalDeviceSurfaceCapabilities2KHR, false); - LOOKUP_GIPA(GetPhysicalDeviceSurfaceFormats2KHR, false); - - // ---- VK_EXT_debug_report extension commands - LOOKUP_GIPA(CreateDebugReportCallbackEXT, false); - LOOKUP_GIPA(DestroyDebugReportCallbackEXT, false); - LOOKUP_GIPA(DebugReportMessageEXT, false); - - // ---- VK_EXT_debug_marker extension commands - LOOKUP_GIPA(DebugMarkerSetObjectTagEXT, false); - LOOKUP_GIPA(DebugMarkerSetObjectNameEXT, false); - - // ---- VK_NV_external_memory_capabilities extension commands - LOOKUP_GIPA(GetPhysicalDeviceExternalImageFormatPropertiesNV, false); - - // ---- VK_KHX_device_group extension commands - LOOKUP_GIPA(GetDeviceGroupSurfacePresentModesKHX, false); - LOOKUP_GIPA(GetPhysicalDevicePresentRectanglesKHX, false); - - // ---- VK_NN_vi_surface extension commands -#ifdef VK_USE_PLATFORM_VI_NN - LOOKUP_GIPA(CreateViSurfaceNN, false); -#endif // VK_USE_PLATFORM_VI_NN - - // ---- VK_KHX_device_group_creation extension commands - LOOKUP_GIPA(EnumeratePhysicalDeviceGroupsKHX, false); - - // ---- VK_NVX_device_generated_commands extension commands - LOOKUP_GIPA(GetPhysicalDeviceGeneratedCommandsPropertiesNVX, false); - - // ---- VK_EXT_direct_mode_display extension commands - LOOKUP_GIPA(ReleaseDisplayEXT, false); - - // ---- VK_EXT_acquire_xlib_display extension commands -#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT - LOOKUP_GIPA(AcquireXlibDisplayEXT, false); -#endif // VK_USE_PLATFORM_XLIB_XRANDR_EXT -#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT - LOOKUP_GIPA(GetRandROutputDisplayEXT, false); -#endif // VK_USE_PLATFORM_XLIB_XRANDR_EXT - - // ---- VK_EXT_display_surface_counter extension commands - LOOKUP_GIPA(GetPhysicalDeviceSurfaceCapabilities2EXT, false); - - // ---- VK_MVK_ios_surface extension commands -#ifdef VK_USE_PLATFORM_IOS_MVK - LOOKUP_GIPA(CreateIOSSurfaceMVK, false); -#endif // VK_USE_PLATFORM_IOS_MVK - - // ---- VK_MVK_macos_surface extension commands -#ifdef VK_USE_PLATFORM_MACOS_MVK - LOOKUP_GIPA(CreateMacOSSurfaceMVK, false); -#endif // VK_USE_PLATFORM_MACOS_MVK - - // ---- VK_EXT_sample_locations extension commands - LOOKUP_GIPA(GetPhysicalDeviceMultisamplePropertiesEXT, false); - -#undef LOOKUP_GIPA - - return true; -}; - -// Init Device function pointer dispatch table with core commands -VKAPI_ATTR void VKAPI_CALL 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; - - // ---- Core 1_0 commands - table->GetDeviceProcAddr = gpa; - table->DestroyDevice = (PFN_vkDestroyDevice)gpa(dev, "vkDestroyDevice"); - table->GetDeviceQueue = (PFN_vkGetDeviceQueue)gpa(dev, "vkGetDeviceQueue"); - table->QueueSubmit = (PFN_vkQueueSubmit)gpa(dev, "vkQueueSubmit"); - table->QueueWaitIdle = (PFN_vkQueueWaitIdle)gpa(dev, "vkQueueWaitIdle"); - table->DeviceWaitIdle = (PFN_vkDeviceWaitIdle)gpa(dev, "vkDeviceWaitIdle"); - table->AllocateMemory = (PFN_vkAllocateMemory)gpa(dev, "vkAllocateMemory"); - table->FreeMemory = (PFN_vkFreeMemory)gpa(dev, "vkFreeMemory"); - table->MapMemory = (PFN_vkMapMemory)gpa(dev, "vkMapMemory"); - table->UnmapMemory = (PFN_vkUnmapMemory)gpa(dev, "vkUnmapMemory"); - table->FlushMappedMemoryRanges = (PFN_vkFlushMappedMemoryRanges)gpa(dev, "vkFlushMappedMemoryRanges"); - table->InvalidateMappedMemoryRanges = (PFN_vkInvalidateMappedMemoryRanges)gpa(dev, "vkInvalidateMappedMemoryRanges"); - table->GetDeviceMemoryCommitment = (PFN_vkGetDeviceMemoryCommitment)gpa(dev, "vkGetDeviceMemoryCommitment"); - table->BindBufferMemory = (PFN_vkBindBufferMemory)gpa(dev, "vkBindBufferMemory"); - table->BindImageMemory = (PFN_vkBindImageMemory)gpa(dev, "vkBindImageMemory"); - table->GetBufferMemoryRequirements = (PFN_vkGetBufferMemoryRequirements)gpa(dev, "vkGetBufferMemoryRequirements"); - table->GetImageMemoryRequirements = (PFN_vkGetImageMemoryRequirements)gpa(dev, "vkGetImageMemoryRequirements"); - table->GetImageSparseMemoryRequirements = (PFN_vkGetImageSparseMemoryRequirements)gpa(dev, "vkGetImageSparseMemoryRequirements"); - table->QueueBindSparse = (PFN_vkQueueBindSparse)gpa(dev, "vkQueueBindSparse"); - table->CreateFence = (PFN_vkCreateFence)gpa(dev, "vkCreateFence"); - table->DestroyFence = (PFN_vkDestroyFence)gpa(dev, "vkDestroyFence"); - table->ResetFences = (PFN_vkResetFences)gpa(dev, "vkResetFences"); - table->GetFenceStatus = (PFN_vkGetFenceStatus)gpa(dev, "vkGetFenceStatus"); - table->WaitForFences = (PFN_vkWaitForFences)gpa(dev, "vkWaitForFences"); - table->CreateSemaphore = (PFN_vkCreateSemaphore)gpa(dev, "vkCreateSemaphore"); - table->DestroySemaphore = (PFN_vkDestroySemaphore)gpa(dev, "vkDestroySemaphore"); - table->CreateEvent = (PFN_vkCreateEvent)gpa(dev, "vkCreateEvent"); - table->DestroyEvent = (PFN_vkDestroyEvent)gpa(dev, "vkDestroyEvent"); - table->GetEventStatus = (PFN_vkGetEventStatus)gpa(dev, "vkGetEventStatus"); - table->SetEvent = (PFN_vkSetEvent)gpa(dev, "vkSetEvent"); - table->ResetEvent = (PFN_vkResetEvent)gpa(dev, "vkResetEvent"); - table->CreateQueryPool = (PFN_vkCreateQueryPool)gpa(dev, "vkCreateQueryPool"); - table->DestroyQueryPool = (PFN_vkDestroyQueryPool)gpa(dev, "vkDestroyQueryPool"); - table->GetQueryPoolResults = (PFN_vkGetQueryPoolResults)gpa(dev, "vkGetQueryPoolResults"); - table->CreateBuffer = (PFN_vkCreateBuffer)gpa(dev, "vkCreateBuffer"); - table->DestroyBuffer = (PFN_vkDestroyBuffer)gpa(dev, "vkDestroyBuffer"); - table->CreateBufferView = (PFN_vkCreateBufferView)gpa(dev, "vkCreateBufferView"); - table->DestroyBufferView = (PFN_vkDestroyBufferView)gpa(dev, "vkDestroyBufferView"); - table->CreateImage = (PFN_vkCreateImage)gpa(dev, "vkCreateImage"); - table->DestroyImage = (PFN_vkDestroyImage)gpa(dev, "vkDestroyImage"); - table->GetImageSubresourceLayout = (PFN_vkGetImageSubresourceLayout)gpa(dev, "vkGetImageSubresourceLayout"); - table->CreateImageView = (PFN_vkCreateImageView)gpa(dev, "vkCreateImageView"); - table->DestroyImageView = (PFN_vkDestroyImageView)gpa(dev, "vkDestroyImageView"); - table->CreateShaderModule = (PFN_vkCreateShaderModule)gpa(dev, "vkCreateShaderModule"); - table->DestroyShaderModule = (PFN_vkDestroyShaderModule)gpa(dev, "vkDestroyShaderModule"); - table->CreatePipelineCache = (PFN_vkCreatePipelineCache)gpa(dev, "vkCreatePipelineCache"); - table->DestroyPipelineCache = (PFN_vkDestroyPipelineCache)gpa(dev, "vkDestroyPipelineCache"); - table->GetPipelineCacheData = (PFN_vkGetPipelineCacheData)gpa(dev, "vkGetPipelineCacheData"); - table->MergePipelineCaches = (PFN_vkMergePipelineCaches)gpa(dev, "vkMergePipelineCaches"); - table->CreateGraphicsPipelines = (PFN_vkCreateGraphicsPipelines)gpa(dev, "vkCreateGraphicsPipelines"); - table->CreateComputePipelines = (PFN_vkCreateComputePipelines)gpa(dev, "vkCreateComputePipelines"); - table->DestroyPipeline = (PFN_vkDestroyPipeline)gpa(dev, "vkDestroyPipeline"); - table->CreatePipelineLayout = (PFN_vkCreatePipelineLayout)gpa(dev, "vkCreatePipelineLayout"); - table->DestroyPipelineLayout = (PFN_vkDestroyPipelineLayout)gpa(dev, "vkDestroyPipelineLayout"); - table->CreateSampler = (PFN_vkCreateSampler)gpa(dev, "vkCreateSampler"); - table->DestroySampler = (PFN_vkDestroySampler)gpa(dev, "vkDestroySampler"); - table->CreateDescriptorSetLayout = (PFN_vkCreateDescriptorSetLayout)gpa(dev, "vkCreateDescriptorSetLayout"); - table->DestroyDescriptorSetLayout = (PFN_vkDestroyDescriptorSetLayout)gpa(dev, "vkDestroyDescriptorSetLayout"); - table->CreateDescriptorPool = (PFN_vkCreateDescriptorPool)gpa(dev, "vkCreateDescriptorPool"); - table->DestroyDescriptorPool = (PFN_vkDestroyDescriptorPool)gpa(dev, "vkDestroyDescriptorPool"); - table->ResetDescriptorPool = (PFN_vkResetDescriptorPool)gpa(dev, "vkResetDescriptorPool"); - table->AllocateDescriptorSets = (PFN_vkAllocateDescriptorSets)gpa(dev, "vkAllocateDescriptorSets"); - table->FreeDescriptorSets = (PFN_vkFreeDescriptorSets)gpa(dev, "vkFreeDescriptorSets"); - table->UpdateDescriptorSets = (PFN_vkUpdateDescriptorSets)gpa(dev, "vkUpdateDescriptorSets"); - table->CreateFramebuffer = (PFN_vkCreateFramebuffer)gpa(dev, "vkCreateFramebuffer"); - table->DestroyFramebuffer = (PFN_vkDestroyFramebuffer)gpa(dev, "vkDestroyFramebuffer"); - table->CreateRenderPass = (PFN_vkCreateRenderPass)gpa(dev, "vkCreateRenderPass"); - table->DestroyRenderPass = (PFN_vkDestroyRenderPass)gpa(dev, "vkDestroyRenderPass"); - table->GetRenderAreaGranularity = (PFN_vkGetRenderAreaGranularity)gpa(dev, "vkGetRenderAreaGranularity"); - table->CreateCommandPool = (PFN_vkCreateCommandPool)gpa(dev, "vkCreateCommandPool"); - table->DestroyCommandPool = (PFN_vkDestroyCommandPool)gpa(dev, "vkDestroyCommandPool"); - table->ResetCommandPool = (PFN_vkResetCommandPool)gpa(dev, "vkResetCommandPool"); - table->AllocateCommandBuffers = (PFN_vkAllocateCommandBuffers)gpa(dev, "vkAllocateCommandBuffers"); - table->FreeCommandBuffers = (PFN_vkFreeCommandBuffers)gpa(dev, "vkFreeCommandBuffers"); - table->BeginCommandBuffer = (PFN_vkBeginCommandBuffer)gpa(dev, "vkBeginCommandBuffer"); - table->EndCommandBuffer = (PFN_vkEndCommandBuffer)gpa(dev, "vkEndCommandBuffer"); - table->ResetCommandBuffer = (PFN_vkResetCommandBuffer)gpa(dev, "vkResetCommandBuffer"); - table->CmdBindPipeline = (PFN_vkCmdBindPipeline)gpa(dev, "vkCmdBindPipeline"); - table->CmdSetViewport = (PFN_vkCmdSetViewport)gpa(dev, "vkCmdSetViewport"); - table->CmdSetScissor = (PFN_vkCmdSetScissor)gpa(dev, "vkCmdSetScissor"); - table->CmdSetLineWidth = (PFN_vkCmdSetLineWidth)gpa(dev, "vkCmdSetLineWidth"); - table->CmdSetDepthBias = (PFN_vkCmdSetDepthBias)gpa(dev, "vkCmdSetDepthBias"); - table->CmdSetBlendConstants = (PFN_vkCmdSetBlendConstants)gpa(dev, "vkCmdSetBlendConstants"); - table->CmdSetDepthBounds = (PFN_vkCmdSetDepthBounds)gpa(dev, "vkCmdSetDepthBounds"); - table->CmdSetStencilCompareMask = (PFN_vkCmdSetStencilCompareMask)gpa(dev, "vkCmdSetStencilCompareMask"); - table->CmdSetStencilWriteMask = (PFN_vkCmdSetStencilWriteMask)gpa(dev, "vkCmdSetStencilWriteMask"); - table->CmdSetStencilReference = (PFN_vkCmdSetStencilReference)gpa(dev, "vkCmdSetStencilReference"); - table->CmdBindDescriptorSets = (PFN_vkCmdBindDescriptorSets)gpa(dev, "vkCmdBindDescriptorSets"); - table->CmdBindIndexBuffer = (PFN_vkCmdBindIndexBuffer)gpa(dev, "vkCmdBindIndexBuffer"); - table->CmdBindVertexBuffers = (PFN_vkCmdBindVertexBuffers)gpa(dev, "vkCmdBindVertexBuffers"); - table->CmdDraw = (PFN_vkCmdDraw)gpa(dev, "vkCmdDraw"); - table->CmdDrawIndexed = (PFN_vkCmdDrawIndexed)gpa(dev, "vkCmdDrawIndexed"); - table->CmdDrawIndirect = (PFN_vkCmdDrawIndirect)gpa(dev, "vkCmdDrawIndirect"); - table->CmdDrawIndexedIndirect = (PFN_vkCmdDrawIndexedIndirect)gpa(dev, "vkCmdDrawIndexedIndirect"); - table->CmdDispatch = (PFN_vkCmdDispatch)gpa(dev, "vkCmdDispatch"); - table->CmdDispatchIndirect = (PFN_vkCmdDispatchIndirect)gpa(dev, "vkCmdDispatchIndirect"); - table->CmdCopyBuffer = (PFN_vkCmdCopyBuffer)gpa(dev, "vkCmdCopyBuffer"); - table->CmdCopyImage = (PFN_vkCmdCopyImage)gpa(dev, "vkCmdCopyImage"); - table->CmdBlitImage = (PFN_vkCmdBlitImage)gpa(dev, "vkCmdBlitImage"); - table->CmdCopyBufferToImage = (PFN_vkCmdCopyBufferToImage)gpa(dev, "vkCmdCopyBufferToImage"); - table->CmdCopyImageToBuffer = (PFN_vkCmdCopyImageToBuffer)gpa(dev, "vkCmdCopyImageToBuffer"); - table->CmdUpdateBuffer = (PFN_vkCmdUpdateBuffer)gpa(dev, "vkCmdUpdateBuffer"); - table->CmdFillBuffer = (PFN_vkCmdFillBuffer)gpa(dev, "vkCmdFillBuffer"); - table->CmdClearColorImage = (PFN_vkCmdClearColorImage)gpa(dev, "vkCmdClearColorImage"); - table->CmdClearDepthStencilImage = (PFN_vkCmdClearDepthStencilImage)gpa(dev, "vkCmdClearDepthStencilImage"); - table->CmdClearAttachments = (PFN_vkCmdClearAttachments)gpa(dev, "vkCmdClearAttachments"); - table->CmdResolveImage = (PFN_vkCmdResolveImage)gpa(dev, "vkCmdResolveImage"); - table->CmdSetEvent = (PFN_vkCmdSetEvent)gpa(dev, "vkCmdSetEvent"); - table->CmdResetEvent = (PFN_vkCmdResetEvent)gpa(dev, "vkCmdResetEvent"); - table->CmdWaitEvents = (PFN_vkCmdWaitEvents)gpa(dev, "vkCmdWaitEvents"); - table->CmdPipelineBarrier = (PFN_vkCmdPipelineBarrier)gpa(dev, "vkCmdPipelineBarrier"); - table->CmdBeginQuery = (PFN_vkCmdBeginQuery)gpa(dev, "vkCmdBeginQuery"); - table->CmdEndQuery = (PFN_vkCmdEndQuery)gpa(dev, "vkCmdEndQuery"); - table->CmdResetQueryPool = (PFN_vkCmdResetQueryPool)gpa(dev, "vkCmdResetQueryPool"); - table->CmdWriteTimestamp = (PFN_vkCmdWriteTimestamp)gpa(dev, "vkCmdWriteTimestamp"); - table->CmdCopyQueryPoolResults = (PFN_vkCmdCopyQueryPoolResults)gpa(dev, "vkCmdCopyQueryPoolResults"); - table->CmdPushConstants = (PFN_vkCmdPushConstants)gpa(dev, "vkCmdPushConstants"); - table->CmdBeginRenderPass = (PFN_vkCmdBeginRenderPass)gpa(dev, "vkCmdBeginRenderPass"); - table->CmdNextSubpass = (PFN_vkCmdNextSubpass)gpa(dev, "vkCmdNextSubpass"); - table->CmdEndRenderPass = (PFN_vkCmdEndRenderPass)gpa(dev, "vkCmdEndRenderPass"); - table->CmdExecuteCommands = (PFN_vkCmdExecuteCommands)gpa(dev, "vkCmdExecuteCommands"); -} - -// Init Device function pointer dispatch table with extension commands -VKAPI_ATTR void VKAPI_CALL loader_init_device_extension_dispatch_table(struct loader_dev_dispatch_table *dev_table, - PFN_vkGetDeviceProcAddr gpa, VkDevice dev) { - VkLayerDispatchTable *table = &dev_table->core_dispatch; - - // ---- VK_KHR_swapchain extension commands - table->CreateSwapchainKHR = (PFN_vkCreateSwapchainKHR)gpa(dev, "vkCreateSwapchainKHR"); - table->DestroySwapchainKHR = (PFN_vkDestroySwapchainKHR)gpa(dev, "vkDestroySwapchainKHR"); - table->GetSwapchainImagesKHR = (PFN_vkGetSwapchainImagesKHR)gpa(dev, "vkGetSwapchainImagesKHR"); - table->AcquireNextImageKHR = (PFN_vkAcquireNextImageKHR)gpa(dev, "vkAcquireNextImageKHR"); - table->QueuePresentKHR = (PFN_vkQueuePresentKHR)gpa(dev, "vkQueuePresentKHR"); - - // ---- VK_KHR_display_swapchain extension commands - table->CreateSharedSwapchainsKHR = (PFN_vkCreateSharedSwapchainsKHR)gpa(dev, "vkCreateSharedSwapchainsKHR"); - - // ---- VK_KHR_maintenance1 extension commands - table->TrimCommandPoolKHR = (PFN_vkTrimCommandPoolKHR)gpa(dev, "vkTrimCommandPoolKHR"); - - // ---- VK_KHR_external_memory_win32 extension commands -#ifdef VK_USE_PLATFORM_WIN32_KHR - table->GetMemoryWin32HandleKHR = (PFN_vkGetMemoryWin32HandleKHR)gpa(dev, "vkGetMemoryWin32HandleKHR"); -#endif // VK_USE_PLATFORM_WIN32_KHR -#ifdef VK_USE_PLATFORM_WIN32_KHR - table->GetMemoryWin32HandlePropertiesKHR = (PFN_vkGetMemoryWin32HandlePropertiesKHR)gpa(dev, "vkGetMemoryWin32HandlePropertiesKHR"); -#endif // VK_USE_PLATFORM_WIN32_KHR - - // ---- VK_KHR_external_memory_fd extension commands - table->GetMemoryFdKHR = (PFN_vkGetMemoryFdKHR)gpa(dev, "vkGetMemoryFdKHR"); - table->GetMemoryFdPropertiesKHR = (PFN_vkGetMemoryFdPropertiesKHR)gpa(dev, "vkGetMemoryFdPropertiesKHR"); - - // ---- VK_KHR_external_semaphore_win32 extension commands -#ifdef VK_USE_PLATFORM_WIN32_KHR - table->ImportSemaphoreWin32HandleKHR = (PFN_vkImportSemaphoreWin32HandleKHR)gpa(dev, "vkImportSemaphoreWin32HandleKHR"); -#endif // VK_USE_PLATFORM_WIN32_KHR -#ifdef VK_USE_PLATFORM_WIN32_KHR - table->GetSemaphoreWin32HandleKHR = (PFN_vkGetSemaphoreWin32HandleKHR)gpa(dev, "vkGetSemaphoreWin32HandleKHR"); -#endif // VK_USE_PLATFORM_WIN32_KHR - - // ---- VK_KHR_external_semaphore_fd extension commands - table->ImportSemaphoreFdKHR = (PFN_vkImportSemaphoreFdKHR)gpa(dev, "vkImportSemaphoreFdKHR"); - table->GetSemaphoreFdKHR = (PFN_vkGetSemaphoreFdKHR)gpa(dev, "vkGetSemaphoreFdKHR"); - - // ---- VK_KHR_push_descriptor extension commands - table->CmdPushDescriptorSetKHR = (PFN_vkCmdPushDescriptorSetKHR)gpa(dev, "vkCmdPushDescriptorSetKHR"); - - // ---- VK_KHR_descriptor_update_template extension commands - table->CreateDescriptorUpdateTemplateKHR = (PFN_vkCreateDescriptorUpdateTemplateKHR)gpa(dev, "vkCreateDescriptorUpdateTemplateKHR"); - table->DestroyDescriptorUpdateTemplateKHR = (PFN_vkDestroyDescriptorUpdateTemplateKHR)gpa(dev, "vkDestroyDescriptorUpdateTemplateKHR"); - table->UpdateDescriptorSetWithTemplateKHR = (PFN_vkUpdateDescriptorSetWithTemplateKHR)gpa(dev, "vkUpdateDescriptorSetWithTemplateKHR"); - table->CmdPushDescriptorSetWithTemplateKHR = (PFN_vkCmdPushDescriptorSetWithTemplateKHR)gpa(dev, "vkCmdPushDescriptorSetWithTemplateKHR"); - - // ---- VK_KHR_shared_presentable_image extension commands - table->GetSwapchainStatusKHR = (PFN_vkGetSwapchainStatusKHR)gpa(dev, "vkGetSwapchainStatusKHR"); - - // ---- VK_KHR_external_fence_win32 extension commands -#ifdef VK_USE_PLATFORM_WIN32_KHR - table->ImportFenceWin32HandleKHR = (PFN_vkImportFenceWin32HandleKHR)gpa(dev, "vkImportFenceWin32HandleKHR"); -#endif // VK_USE_PLATFORM_WIN32_KHR -#ifdef VK_USE_PLATFORM_WIN32_KHR - table->GetFenceWin32HandleKHR = (PFN_vkGetFenceWin32HandleKHR)gpa(dev, "vkGetFenceWin32HandleKHR"); -#endif // VK_USE_PLATFORM_WIN32_KHR - - // ---- VK_KHR_external_fence_fd extension commands - table->ImportFenceFdKHR = (PFN_vkImportFenceFdKHR)gpa(dev, "vkImportFenceFdKHR"); - table->GetFenceFdKHR = (PFN_vkGetFenceFdKHR)gpa(dev, "vkGetFenceFdKHR"); - - // ---- VK_KHR_get_memory_requirements2 extension commands - table->GetImageMemoryRequirements2KHR = (PFN_vkGetImageMemoryRequirements2KHR)gpa(dev, "vkGetImageMemoryRequirements2KHR"); - table->GetBufferMemoryRequirements2KHR = (PFN_vkGetBufferMemoryRequirements2KHR)gpa(dev, "vkGetBufferMemoryRequirements2KHR"); - table->GetImageSparseMemoryRequirements2KHR = (PFN_vkGetImageSparseMemoryRequirements2KHR)gpa(dev, "vkGetImageSparseMemoryRequirements2KHR"); - - // ---- VK_KHR_sampler_ycbcr_conversion extension commands - table->CreateSamplerYcbcrConversionKHR = (PFN_vkCreateSamplerYcbcrConversionKHR)gpa(dev, "vkCreateSamplerYcbcrConversionKHR"); - table->DestroySamplerYcbcrConversionKHR = (PFN_vkDestroySamplerYcbcrConversionKHR)gpa(dev, "vkDestroySamplerYcbcrConversionKHR"); - - // ---- VK_KHR_bind_memory2 extension commands - table->BindBufferMemory2KHR = (PFN_vkBindBufferMemory2KHR)gpa(dev, "vkBindBufferMemory2KHR"); - table->BindImageMemory2KHR = (PFN_vkBindImageMemory2KHR)gpa(dev, "vkBindImageMemory2KHR"); - - // ---- VK_EXT_debug_marker extension commands - table->DebugMarkerSetObjectTagEXT = (PFN_vkDebugMarkerSetObjectTagEXT)gpa(dev, "vkDebugMarkerSetObjectTagEXT"); - table->DebugMarkerSetObjectNameEXT = (PFN_vkDebugMarkerSetObjectNameEXT)gpa(dev, "vkDebugMarkerSetObjectNameEXT"); - table->CmdDebugMarkerBeginEXT = (PFN_vkCmdDebugMarkerBeginEXT)gpa(dev, "vkCmdDebugMarkerBeginEXT"); - table->CmdDebugMarkerEndEXT = (PFN_vkCmdDebugMarkerEndEXT)gpa(dev, "vkCmdDebugMarkerEndEXT"); - table->CmdDebugMarkerInsertEXT = (PFN_vkCmdDebugMarkerInsertEXT)gpa(dev, "vkCmdDebugMarkerInsertEXT"); - - // ---- VK_AMD_draw_indirect_count extension commands - table->CmdDrawIndirectCountAMD = (PFN_vkCmdDrawIndirectCountAMD)gpa(dev, "vkCmdDrawIndirectCountAMD"); - table->CmdDrawIndexedIndirectCountAMD = (PFN_vkCmdDrawIndexedIndirectCountAMD)gpa(dev, "vkCmdDrawIndexedIndirectCountAMD"); - - // ---- VK_AMD_shader_info extension commands - table->GetShaderInfoAMD = (PFN_vkGetShaderInfoAMD)gpa(dev, "vkGetShaderInfoAMD"); - - // ---- VK_NV_external_memory_win32 extension commands -#ifdef VK_USE_PLATFORM_WIN32_KHR - table->GetMemoryWin32HandleNV = (PFN_vkGetMemoryWin32HandleNV)gpa(dev, "vkGetMemoryWin32HandleNV"); -#endif // VK_USE_PLATFORM_WIN32_KHR - - // ---- VK_KHX_device_group extension commands - table->GetDeviceGroupPeerMemoryFeaturesKHX = (PFN_vkGetDeviceGroupPeerMemoryFeaturesKHX)gpa(dev, "vkGetDeviceGroupPeerMemoryFeaturesKHX"); - table->CmdSetDeviceMaskKHX = (PFN_vkCmdSetDeviceMaskKHX)gpa(dev, "vkCmdSetDeviceMaskKHX"); - table->CmdDispatchBaseKHX = (PFN_vkCmdDispatchBaseKHX)gpa(dev, "vkCmdDispatchBaseKHX"); - table->GetDeviceGroupPresentCapabilitiesKHX = (PFN_vkGetDeviceGroupPresentCapabilitiesKHX)gpa(dev, "vkGetDeviceGroupPresentCapabilitiesKHX"); - table->GetDeviceGroupSurfacePresentModesKHX = (PFN_vkGetDeviceGroupSurfacePresentModesKHX)gpa(dev, "vkGetDeviceGroupSurfacePresentModesKHX"); - table->AcquireNextImage2KHX = (PFN_vkAcquireNextImage2KHX)gpa(dev, "vkAcquireNextImage2KHX"); - - // ---- VK_NVX_device_generated_commands extension commands - table->CmdProcessCommandsNVX = (PFN_vkCmdProcessCommandsNVX)gpa(dev, "vkCmdProcessCommandsNVX"); - table->CmdReserveSpaceForCommandsNVX = (PFN_vkCmdReserveSpaceForCommandsNVX)gpa(dev, "vkCmdReserveSpaceForCommandsNVX"); - table->CreateIndirectCommandsLayoutNVX = (PFN_vkCreateIndirectCommandsLayoutNVX)gpa(dev, "vkCreateIndirectCommandsLayoutNVX"); - table->DestroyIndirectCommandsLayoutNVX = (PFN_vkDestroyIndirectCommandsLayoutNVX)gpa(dev, "vkDestroyIndirectCommandsLayoutNVX"); - table->CreateObjectTableNVX = (PFN_vkCreateObjectTableNVX)gpa(dev, "vkCreateObjectTableNVX"); - table->DestroyObjectTableNVX = (PFN_vkDestroyObjectTableNVX)gpa(dev, "vkDestroyObjectTableNVX"); - table->RegisterObjectsNVX = (PFN_vkRegisterObjectsNVX)gpa(dev, "vkRegisterObjectsNVX"); - table->UnregisterObjectsNVX = (PFN_vkUnregisterObjectsNVX)gpa(dev, "vkUnregisterObjectsNVX"); - - // ---- VK_NV_clip_space_w_scaling extension commands - table->CmdSetViewportWScalingNV = (PFN_vkCmdSetViewportWScalingNV)gpa(dev, "vkCmdSetViewportWScalingNV"); - - // ---- VK_EXT_display_control extension commands - table->DisplayPowerControlEXT = (PFN_vkDisplayPowerControlEXT)gpa(dev, "vkDisplayPowerControlEXT"); - table->RegisterDeviceEventEXT = (PFN_vkRegisterDeviceEventEXT)gpa(dev, "vkRegisterDeviceEventEXT"); - table->RegisterDisplayEventEXT = (PFN_vkRegisterDisplayEventEXT)gpa(dev, "vkRegisterDisplayEventEXT"); - table->GetSwapchainCounterEXT = (PFN_vkGetSwapchainCounterEXT)gpa(dev, "vkGetSwapchainCounterEXT"); - - // ---- VK_GOOGLE_display_timing extension commands - table->GetRefreshCycleDurationGOOGLE = (PFN_vkGetRefreshCycleDurationGOOGLE)gpa(dev, "vkGetRefreshCycleDurationGOOGLE"); - table->GetPastPresentationTimingGOOGLE = (PFN_vkGetPastPresentationTimingGOOGLE)gpa(dev, "vkGetPastPresentationTimingGOOGLE"); - - // ---- VK_EXT_discard_rectangles extension commands - table->CmdSetDiscardRectangleEXT = (PFN_vkCmdSetDiscardRectangleEXT)gpa(dev, "vkCmdSetDiscardRectangleEXT"); - - // ---- VK_EXT_hdr_metadata extension commands - table->SetHdrMetadataEXT = (PFN_vkSetHdrMetadataEXT)gpa(dev, "vkSetHdrMetadataEXT"); - - // ---- VK_EXT_sample_locations extension commands - table->CmdSetSampleLocationsEXT = (PFN_vkCmdSetSampleLocationsEXT)gpa(dev, "vkCmdSetSampleLocationsEXT"); - - // ---- VK_EXT_validation_cache extension commands - table->CreateValidationCacheEXT = (PFN_vkCreateValidationCacheEXT)gpa(dev, "vkCreateValidationCacheEXT"); - table->DestroyValidationCacheEXT = (PFN_vkDestroyValidationCacheEXT)gpa(dev, "vkDestroyValidationCacheEXT"); - table->MergeValidationCachesEXT = (PFN_vkMergeValidationCachesEXT)gpa(dev, "vkMergeValidationCachesEXT"); - table->GetValidationCacheDataEXT = (PFN_vkGetValidationCacheDataEXT)gpa(dev, "vkGetValidationCacheDataEXT"); - - // ---- VK_EXT_external_memory_host extension commands - table->GetMemoryHostPointerPropertiesEXT = (PFN_vkGetMemoryHostPointerPropertiesEXT)gpa(dev, "vkGetMemoryHostPointerPropertiesEXT"); -} - -// Init Instance function pointer dispatch table with core commands -VKAPI_ATTR void VKAPI_CALL loader_init_instance_core_dispatch_table(VkLayerInstanceDispatchTable *table, PFN_vkGetInstanceProcAddr gpa, - VkInstance inst) { - - // ---- Core 1_0 commands - table->DestroyInstance = (PFN_vkDestroyInstance)gpa(inst, "vkDestroyInstance"); - table->EnumeratePhysicalDevices = (PFN_vkEnumeratePhysicalDevices)gpa(inst, "vkEnumeratePhysicalDevices"); - table->GetPhysicalDeviceFeatures = (PFN_vkGetPhysicalDeviceFeatures)gpa(inst, "vkGetPhysicalDeviceFeatures"); - table->GetPhysicalDeviceFormatProperties = (PFN_vkGetPhysicalDeviceFormatProperties)gpa(inst, "vkGetPhysicalDeviceFormatProperties"); - table->GetPhysicalDeviceImageFormatProperties = (PFN_vkGetPhysicalDeviceImageFormatProperties)gpa(inst, "vkGetPhysicalDeviceImageFormatProperties"); - table->GetPhysicalDeviceProperties = (PFN_vkGetPhysicalDeviceProperties)gpa(inst, "vkGetPhysicalDeviceProperties"); - table->GetPhysicalDeviceQueueFamilyProperties = (PFN_vkGetPhysicalDeviceQueueFamilyProperties)gpa(inst, "vkGetPhysicalDeviceQueueFamilyProperties"); - table->GetPhysicalDeviceMemoryProperties = (PFN_vkGetPhysicalDeviceMemoryProperties)gpa(inst, "vkGetPhysicalDeviceMemoryProperties"); - table->GetInstanceProcAddr = gpa; - table->EnumerateDeviceExtensionProperties = (PFN_vkEnumerateDeviceExtensionProperties)gpa(inst, "vkEnumerateDeviceExtensionProperties"); - table->EnumerateDeviceLayerProperties = (PFN_vkEnumerateDeviceLayerProperties)gpa(inst, "vkEnumerateDeviceLayerProperties"); - table->GetPhysicalDeviceSparseImageFormatProperties = (PFN_vkGetPhysicalDeviceSparseImageFormatProperties)gpa(inst, "vkGetPhysicalDeviceSparseImageFormatProperties"); -} - -// Init Instance function pointer dispatch table with core commands -VKAPI_ATTR void VKAPI_CALL loader_init_instance_extension_dispatch_table(VkLayerInstanceDispatchTable *table, PFN_vkGetInstanceProcAddr gpa, - VkInstance inst) { - - // ---- VK_KHR_surface extension commands - table->DestroySurfaceKHR = (PFN_vkDestroySurfaceKHR)gpa(inst, "vkDestroySurfaceKHR"); - table->GetPhysicalDeviceSurfaceSupportKHR = (PFN_vkGetPhysicalDeviceSurfaceSupportKHR)gpa(inst, "vkGetPhysicalDeviceSurfaceSupportKHR"); - table->GetPhysicalDeviceSurfaceCapabilitiesKHR = (PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR)gpa(inst, "vkGetPhysicalDeviceSurfaceCapabilitiesKHR"); - table->GetPhysicalDeviceSurfaceFormatsKHR = (PFN_vkGetPhysicalDeviceSurfaceFormatsKHR)gpa(inst, "vkGetPhysicalDeviceSurfaceFormatsKHR"); - table->GetPhysicalDeviceSurfacePresentModesKHR = (PFN_vkGetPhysicalDeviceSurfacePresentModesKHR)gpa(inst, "vkGetPhysicalDeviceSurfacePresentModesKHR"); - - // ---- VK_KHR_display extension commands - table->GetPhysicalDeviceDisplayPropertiesKHR = (PFN_vkGetPhysicalDeviceDisplayPropertiesKHR)gpa(inst, "vkGetPhysicalDeviceDisplayPropertiesKHR"); - table->GetPhysicalDeviceDisplayPlanePropertiesKHR = (PFN_vkGetPhysicalDeviceDisplayPlanePropertiesKHR)gpa(inst, "vkGetPhysicalDeviceDisplayPlanePropertiesKHR"); - table->GetDisplayPlaneSupportedDisplaysKHR = (PFN_vkGetDisplayPlaneSupportedDisplaysKHR)gpa(inst, "vkGetDisplayPlaneSupportedDisplaysKHR"); - table->GetDisplayModePropertiesKHR = (PFN_vkGetDisplayModePropertiesKHR)gpa(inst, "vkGetDisplayModePropertiesKHR"); - table->CreateDisplayModeKHR = (PFN_vkCreateDisplayModeKHR)gpa(inst, "vkCreateDisplayModeKHR"); - table->GetDisplayPlaneCapabilitiesKHR = (PFN_vkGetDisplayPlaneCapabilitiesKHR)gpa(inst, "vkGetDisplayPlaneCapabilitiesKHR"); - table->CreateDisplayPlaneSurfaceKHR = (PFN_vkCreateDisplayPlaneSurfaceKHR)gpa(inst, "vkCreateDisplayPlaneSurfaceKHR"); - - // ---- VK_KHR_xlib_surface extension commands -#ifdef VK_USE_PLATFORM_XLIB_KHR - table->CreateXlibSurfaceKHR = (PFN_vkCreateXlibSurfaceKHR)gpa(inst, "vkCreateXlibSurfaceKHR"); -#endif // VK_USE_PLATFORM_XLIB_KHR -#ifdef VK_USE_PLATFORM_XLIB_KHR - table->GetPhysicalDeviceXlibPresentationSupportKHR = (PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR)gpa(inst, "vkGetPhysicalDeviceXlibPresentationSupportKHR"); -#endif // VK_USE_PLATFORM_XLIB_KHR - - // ---- VK_KHR_xcb_surface extension commands -#ifdef VK_USE_PLATFORM_XCB_KHR - table->CreateXcbSurfaceKHR = (PFN_vkCreateXcbSurfaceKHR)gpa(inst, "vkCreateXcbSurfaceKHR"); -#endif // VK_USE_PLATFORM_XCB_KHR -#ifdef VK_USE_PLATFORM_XCB_KHR - table->GetPhysicalDeviceXcbPresentationSupportKHR = (PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR)gpa(inst, "vkGetPhysicalDeviceXcbPresentationSupportKHR"); -#endif // VK_USE_PLATFORM_XCB_KHR - - // ---- VK_KHR_wayland_surface extension commands -#ifdef VK_USE_PLATFORM_WAYLAND_KHR - table->CreateWaylandSurfaceKHR = (PFN_vkCreateWaylandSurfaceKHR)gpa(inst, "vkCreateWaylandSurfaceKHR"); -#endif // VK_USE_PLATFORM_WAYLAND_KHR -#ifdef VK_USE_PLATFORM_WAYLAND_KHR - table->GetPhysicalDeviceWaylandPresentationSupportKHR = (PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR)gpa(inst, "vkGetPhysicalDeviceWaylandPresentationSupportKHR"); -#endif // VK_USE_PLATFORM_WAYLAND_KHR - - // ---- VK_KHR_mir_surface extension commands -#ifdef VK_USE_PLATFORM_MIR_KHR - table->CreateMirSurfaceKHR = (PFN_vkCreateMirSurfaceKHR)gpa(inst, "vkCreateMirSurfaceKHR"); -#endif // VK_USE_PLATFORM_MIR_KHR -#ifdef VK_USE_PLATFORM_MIR_KHR - table->GetPhysicalDeviceMirPresentationSupportKHR = (PFN_vkGetPhysicalDeviceMirPresentationSupportKHR)gpa(inst, "vkGetPhysicalDeviceMirPresentationSupportKHR"); -#endif // VK_USE_PLATFORM_MIR_KHR - - // ---- VK_KHR_android_surface extension commands -#ifdef VK_USE_PLATFORM_ANDROID_KHR - table->CreateAndroidSurfaceKHR = (PFN_vkCreateAndroidSurfaceKHR)gpa(inst, "vkCreateAndroidSurfaceKHR"); -#endif // VK_USE_PLATFORM_ANDROID_KHR - - // ---- VK_KHR_win32_surface extension commands -#ifdef VK_USE_PLATFORM_WIN32_KHR - table->CreateWin32SurfaceKHR = (PFN_vkCreateWin32SurfaceKHR)gpa(inst, "vkCreateWin32SurfaceKHR"); -#endif // VK_USE_PLATFORM_WIN32_KHR -#ifdef VK_USE_PLATFORM_WIN32_KHR - table->GetPhysicalDeviceWin32PresentationSupportKHR = (PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)gpa(inst, "vkGetPhysicalDeviceWin32PresentationSupportKHR"); -#endif // VK_USE_PLATFORM_WIN32_KHR - - // ---- VK_KHR_get_physical_device_properties2 extension commands - table->GetPhysicalDeviceFeatures2KHR = (PFN_vkGetPhysicalDeviceFeatures2KHR)gpa(inst, "vkGetPhysicalDeviceFeatures2KHR"); - table->GetPhysicalDeviceProperties2KHR = (PFN_vkGetPhysicalDeviceProperties2KHR)gpa(inst, "vkGetPhysicalDeviceProperties2KHR"); - table->GetPhysicalDeviceFormatProperties2KHR = (PFN_vkGetPhysicalDeviceFormatProperties2KHR)gpa(inst, "vkGetPhysicalDeviceFormatProperties2KHR"); - table->GetPhysicalDeviceImageFormatProperties2KHR = (PFN_vkGetPhysicalDeviceImageFormatProperties2KHR)gpa(inst, "vkGetPhysicalDeviceImageFormatProperties2KHR"); - table->GetPhysicalDeviceQueueFamilyProperties2KHR = (PFN_vkGetPhysicalDeviceQueueFamilyProperties2KHR)gpa(inst, "vkGetPhysicalDeviceQueueFamilyProperties2KHR"); - table->GetPhysicalDeviceMemoryProperties2KHR = (PFN_vkGetPhysicalDeviceMemoryProperties2KHR)gpa(inst, "vkGetPhysicalDeviceMemoryProperties2KHR"); - table->GetPhysicalDeviceSparseImageFormatProperties2KHR = (PFN_vkGetPhysicalDeviceSparseImageFormatProperties2KHR)gpa(inst, "vkGetPhysicalDeviceSparseImageFormatProperties2KHR"); - - // ---- VK_KHR_external_memory_capabilities extension commands - table->GetPhysicalDeviceExternalBufferPropertiesKHR = (PFN_vkGetPhysicalDeviceExternalBufferPropertiesKHR)gpa(inst, "vkGetPhysicalDeviceExternalBufferPropertiesKHR"); - - // ---- VK_KHR_external_semaphore_capabilities extension commands - table->GetPhysicalDeviceExternalSemaphorePropertiesKHR = (PFN_vkGetPhysicalDeviceExternalSemaphorePropertiesKHR)gpa(inst, "vkGetPhysicalDeviceExternalSemaphorePropertiesKHR"); - - // ---- VK_KHR_external_fence_capabilities extension commands - table->GetPhysicalDeviceExternalFencePropertiesKHR = (PFN_vkGetPhysicalDeviceExternalFencePropertiesKHR)gpa(inst, "vkGetPhysicalDeviceExternalFencePropertiesKHR"); - - // ---- VK_KHR_get_surface_capabilities2 extension commands - table->GetPhysicalDeviceSurfaceCapabilities2KHR = (PFN_vkGetPhysicalDeviceSurfaceCapabilities2KHR)gpa(inst, "vkGetPhysicalDeviceSurfaceCapabilities2KHR"); - table->GetPhysicalDeviceSurfaceFormats2KHR = (PFN_vkGetPhysicalDeviceSurfaceFormats2KHR)gpa(inst, "vkGetPhysicalDeviceSurfaceFormats2KHR"); - - // ---- VK_EXT_debug_report extension commands - table->CreateDebugReportCallbackEXT = (PFN_vkCreateDebugReportCallbackEXT)gpa(inst, "vkCreateDebugReportCallbackEXT"); - table->DestroyDebugReportCallbackEXT = (PFN_vkDestroyDebugReportCallbackEXT)gpa(inst, "vkDestroyDebugReportCallbackEXT"); - table->DebugReportMessageEXT = (PFN_vkDebugReportMessageEXT)gpa(inst, "vkDebugReportMessageEXT"); - - // ---- VK_NV_external_memory_capabilities extension commands - table->GetPhysicalDeviceExternalImageFormatPropertiesNV = (PFN_vkGetPhysicalDeviceExternalImageFormatPropertiesNV)gpa(inst, "vkGetPhysicalDeviceExternalImageFormatPropertiesNV"); - - // ---- VK_KHX_device_group extension commands - table->GetPhysicalDevicePresentRectanglesKHX = (PFN_vkGetPhysicalDevicePresentRectanglesKHX)gpa(inst, "vkGetPhysicalDevicePresentRectanglesKHX"); - - // ---- VK_NN_vi_surface extension commands -#ifdef VK_USE_PLATFORM_VI_NN - table->CreateViSurfaceNN = (PFN_vkCreateViSurfaceNN)gpa(inst, "vkCreateViSurfaceNN"); -#endif // VK_USE_PLATFORM_VI_NN - - // ---- VK_KHX_device_group_creation extension commands - table->EnumeratePhysicalDeviceGroupsKHX = (PFN_vkEnumeratePhysicalDeviceGroupsKHX)gpa(inst, "vkEnumeratePhysicalDeviceGroupsKHX"); - - // ---- VK_NVX_device_generated_commands extension commands - table->GetPhysicalDeviceGeneratedCommandsPropertiesNVX = (PFN_vkGetPhysicalDeviceGeneratedCommandsPropertiesNVX)gpa(inst, "vkGetPhysicalDeviceGeneratedCommandsPropertiesNVX"); - - // ---- VK_EXT_direct_mode_display extension commands - table->ReleaseDisplayEXT = (PFN_vkReleaseDisplayEXT)gpa(inst, "vkReleaseDisplayEXT"); - - // ---- VK_EXT_acquire_xlib_display extension commands -#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT - table->AcquireXlibDisplayEXT = (PFN_vkAcquireXlibDisplayEXT)gpa(inst, "vkAcquireXlibDisplayEXT"); -#endif // VK_USE_PLATFORM_XLIB_XRANDR_EXT -#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT - table->GetRandROutputDisplayEXT = (PFN_vkGetRandROutputDisplayEXT)gpa(inst, "vkGetRandROutputDisplayEXT"); -#endif // VK_USE_PLATFORM_XLIB_XRANDR_EXT - - // ---- VK_EXT_display_surface_counter extension commands - table->GetPhysicalDeviceSurfaceCapabilities2EXT = (PFN_vkGetPhysicalDeviceSurfaceCapabilities2EXT)gpa(inst, "vkGetPhysicalDeviceSurfaceCapabilities2EXT"); - - // ---- VK_MVK_ios_surface extension commands -#ifdef VK_USE_PLATFORM_IOS_MVK - table->CreateIOSSurfaceMVK = (PFN_vkCreateIOSSurfaceMVK)gpa(inst, "vkCreateIOSSurfaceMVK"); -#endif // VK_USE_PLATFORM_IOS_MVK - - // ---- VK_MVK_macos_surface extension commands -#ifdef VK_USE_PLATFORM_MACOS_MVK - table->CreateMacOSSurfaceMVK = (PFN_vkCreateMacOSSurfaceMVK)gpa(inst, "vkCreateMacOSSurfaceMVK"); -#endif // VK_USE_PLATFORM_MACOS_MVK - - // ---- VK_EXT_sample_locations extension commands - table->GetPhysicalDeviceMultisamplePropertiesEXT = (PFN_vkGetPhysicalDeviceMultisamplePropertiesEXT)gpa(inst, "vkGetPhysicalDeviceMultisamplePropertiesEXT"); -} - -// Device command lookup function -VKAPI_ATTR void* VKAPI_CALL loader_lookup_device_dispatch_table(const VkLayerDispatchTable *table, const char *name) { - if (!name || name[0] != 'v' || name[1] != 'k') return NULL; - - name += 2; - - // ---- Core 1_0 commands - 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, "BindBufferMemory")) return (void *)table->BindBufferMemory; - if (!strcmp(name, "BindImageMemory")) return (void *)table->BindImageMemory; - if (!strcmp(name, "GetBufferMemoryRequirements")) return (void *)table->GetBufferMemoryRequirements; - if (!strcmp(name, "GetImageMemoryRequirements")) return (void *)table->GetImageMemoryRequirements; - if (!strcmp(name, "GetImageSparseMemoryRequirements")) return (void *)table->GetImageSparseMemoryRequirements; - 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 *)table->CreatePipelineCache; - if (!strcmp(name, "DestroyPipelineCache")) return (void *)table->DestroyPipelineCache; - if (!strcmp(name, "GetPipelineCacheData")) return (void *)table->GetPipelineCacheData; - if (!strcmp(name, "MergePipelineCaches")) return (void *)table->MergePipelineCaches; - if (!strcmp(name, "CreateGraphicsPipelines")) return (void *)table->CreateGraphicsPipelines; - if (!strcmp(name, "CreateComputePipelines")) return (void *)table->CreateComputePipelines; - 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, "CmdBindIndexBuffer")) return (void *)table->CmdBindIndexBuffer; - if (!strcmp(name, "CmdBindVertexBuffers")) return (void *)table->CmdBindVertexBuffers; - 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; - - // ---- VK_KHR_swapchain extension commands - if (!strcmp(name, "CreateSwapchainKHR")) return (void *)table->CreateSwapchainKHR; - 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; - - // ---- VK_KHR_display_swapchain extension commands - if (!strcmp(name, "CreateSharedSwapchainsKHR")) return (void *)table->CreateSharedSwapchainsKHR; - - // ---- VK_KHR_maintenance1 extension commands - if (!strcmp(name, "TrimCommandPoolKHR")) return (void *)table->TrimCommandPoolKHR; - - // ---- VK_KHR_external_memory_win32 extension commands -#ifdef VK_USE_PLATFORM_WIN32_KHR - if (!strcmp(name, "GetMemoryWin32HandleKHR")) return (void *)table->GetMemoryWin32HandleKHR; -#endif // VK_USE_PLATFORM_WIN32_KHR -#ifdef VK_USE_PLATFORM_WIN32_KHR - if (!strcmp(name, "GetMemoryWin32HandlePropertiesKHR")) return (void *)table->GetMemoryWin32HandlePropertiesKHR; -#endif // VK_USE_PLATFORM_WIN32_KHR - - // ---- VK_KHR_external_memory_fd extension commands - if (!strcmp(name, "GetMemoryFdKHR")) return (void *)table->GetMemoryFdKHR; - if (!strcmp(name, "GetMemoryFdPropertiesKHR")) return (void *)table->GetMemoryFdPropertiesKHR; - - // ---- VK_KHR_external_semaphore_win32 extension commands -#ifdef VK_USE_PLATFORM_WIN32_KHR - if (!strcmp(name, "ImportSemaphoreWin32HandleKHR")) return (void *)table->ImportSemaphoreWin32HandleKHR; -#endif // VK_USE_PLATFORM_WIN32_KHR -#ifdef VK_USE_PLATFORM_WIN32_KHR - if (!strcmp(name, "GetSemaphoreWin32HandleKHR")) return (void *)table->GetSemaphoreWin32HandleKHR; -#endif // VK_USE_PLATFORM_WIN32_KHR - - // ---- VK_KHR_external_semaphore_fd extension commands - if (!strcmp(name, "ImportSemaphoreFdKHR")) return (void *)table->ImportSemaphoreFdKHR; - if (!strcmp(name, "GetSemaphoreFdKHR")) return (void *)table->GetSemaphoreFdKHR; - - // ---- VK_KHR_push_descriptor extension commands - if (!strcmp(name, "CmdPushDescriptorSetKHR")) return (void *)table->CmdPushDescriptorSetKHR; - - // ---- VK_KHR_descriptor_update_template extension commands - if (!strcmp(name, "CreateDescriptorUpdateTemplateKHR")) return (void *)table->CreateDescriptorUpdateTemplateKHR; - if (!strcmp(name, "DestroyDescriptorUpdateTemplateKHR")) return (void *)table->DestroyDescriptorUpdateTemplateKHR; - if (!strcmp(name, "UpdateDescriptorSetWithTemplateKHR")) return (void *)table->UpdateDescriptorSetWithTemplateKHR; - if (!strcmp(name, "CmdPushDescriptorSetWithTemplateKHR")) return (void *)table->CmdPushDescriptorSetWithTemplateKHR; - - // ---- VK_KHR_shared_presentable_image extension commands - if (!strcmp(name, "GetSwapchainStatusKHR")) return (void *)table->GetSwapchainStatusKHR; - - // ---- VK_KHR_external_fence_win32 extension commands -#ifdef VK_USE_PLATFORM_WIN32_KHR - if (!strcmp(name, "ImportFenceWin32HandleKHR")) return (void *)table->ImportFenceWin32HandleKHR; -#endif // VK_USE_PLATFORM_WIN32_KHR -#ifdef VK_USE_PLATFORM_WIN32_KHR - if (!strcmp(name, "GetFenceWin32HandleKHR")) return (void *)table->GetFenceWin32HandleKHR; -#endif // VK_USE_PLATFORM_WIN32_KHR - - // ---- VK_KHR_external_fence_fd extension commands - if (!strcmp(name, "ImportFenceFdKHR")) return (void *)table->ImportFenceFdKHR; - if (!strcmp(name, "GetFenceFdKHR")) return (void *)table->GetFenceFdKHR; - - // ---- VK_KHR_get_memory_requirements2 extension commands - if (!strcmp(name, "GetImageMemoryRequirements2KHR")) return (void *)table->GetImageMemoryRequirements2KHR; - if (!strcmp(name, "GetBufferMemoryRequirements2KHR")) return (void *)table->GetBufferMemoryRequirements2KHR; - if (!strcmp(name, "GetImageSparseMemoryRequirements2KHR")) return (void *)table->GetImageSparseMemoryRequirements2KHR; - - // ---- VK_KHR_sampler_ycbcr_conversion extension commands - if (!strcmp(name, "CreateSamplerYcbcrConversionKHR")) return (void *)table->CreateSamplerYcbcrConversionKHR; - if (!strcmp(name, "DestroySamplerYcbcrConversionKHR")) return (void *)table->DestroySamplerYcbcrConversionKHR; - - // ---- VK_KHR_bind_memory2 extension commands - if (!strcmp(name, "BindBufferMemory2KHR")) return (void *)table->BindBufferMemory2KHR; - if (!strcmp(name, "BindImageMemory2KHR")) return (void *)table->BindImageMemory2KHR; - - // ---- VK_EXT_debug_marker extension commands - if (!strcmp(name, "DebugMarkerSetObjectTagEXT")) return (void *)table->DebugMarkerSetObjectTagEXT; - if (!strcmp(name, "DebugMarkerSetObjectNameEXT")) return (void *)table->DebugMarkerSetObjectNameEXT; - if (!strcmp(name, "CmdDebugMarkerBeginEXT")) return (void *)table->CmdDebugMarkerBeginEXT; - if (!strcmp(name, "CmdDebugMarkerEndEXT")) return (void *)table->CmdDebugMarkerEndEXT; - if (!strcmp(name, "CmdDebugMarkerInsertEXT")) return (void *)table->CmdDebugMarkerInsertEXT; - - // ---- VK_AMD_draw_indirect_count extension commands - if (!strcmp(name, "CmdDrawIndirectCountAMD")) return (void *)table->CmdDrawIndirectCountAMD; - if (!strcmp(name, "CmdDrawIndexedIndirectCountAMD")) return (void *)table->CmdDrawIndexedIndirectCountAMD; - - // ---- VK_AMD_shader_info extension commands - if (!strcmp(name, "GetShaderInfoAMD")) return (void *)table->GetShaderInfoAMD; - - // ---- VK_NV_external_memory_win32 extension commands -#ifdef VK_USE_PLATFORM_WIN32_KHR - if (!strcmp(name, "GetMemoryWin32HandleNV")) return (void *)table->GetMemoryWin32HandleNV; -#endif // VK_USE_PLATFORM_WIN32_KHR - - // ---- VK_KHX_device_group extension commands - if (!strcmp(name, "GetDeviceGroupPeerMemoryFeaturesKHX")) return (void *)table->GetDeviceGroupPeerMemoryFeaturesKHX; - if (!strcmp(name, "CmdSetDeviceMaskKHX")) return (void *)table->CmdSetDeviceMaskKHX; - if (!strcmp(name, "CmdDispatchBaseKHX")) return (void *)table->CmdDispatchBaseKHX; - if (!strcmp(name, "GetDeviceGroupPresentCapabilitiesKHX")) return (void *)table->GetDeviceGroupPresentCapabilitiesKHX; - if (!strcmp(name, "GetDeviceGroupSurfacePresentModesKHX")) return (void *)table->GetDeviceGroupSurfacePresentModesKHX; - if (!strcmp(name, "AcquireNextImage2KHX")) return (void *)table->AcquireNextImage2KHX; - - // ---- VK_NVX_device_generated_commands extension commands - if (!strcmp(name, "CmdProcessCommandsNVX")) return (void *)table->CmdProcessCommandsNVX; - if (!strcmp(name, "CmdReserveSpaceForCommandsNVX")) return (void *)table->CmdReserveSpaceForCommandsNVX; - if (!strcmp(name, "CreateIndirectCommandsLayoutNVX")) return (void *)table->CreateIndirectCommandsLayoutNVX; - if (!strcmp(name, "DestroyIndirectCommandsLayoutNVX")) return (void *)table->DestroyIndirectCommandsLayoutNVX; - if (!strcmp(name, "CreateObjectTableNVX")) return (void *)table->CreateObjectTableNVX; - if (!strcmp(name, "DestroyObjectTableNVX")) return (void *)table->DestroyObjectTableNVX; - if (!strcmp(name, "RegisterObjectsNVX")) return (void *)table->RegisterObjectsNVX; - if (!strcmp(name, "UnregisterObjectsNVX")) return (void *)table->UnregisterObjectsNVX; - - // ---- VK_NV_clip_space_w_scaling extension commands - if (!strcmp(name, "CmdSetViewportWScalingNV")) return (void *)table->CmdSetViewportWScalingNV; - - // ---- VK_EXT_display_control extension commands - if (!strcmp(name, "DisplayPowerControlEXT")) return (void *)table->DisplayPowerControlEXT; - if (!strcmp(name, "RegisterDeviceEventEXT")) return (void *)table->RegisterDeviceEventEXT; - if (!strcmp(name, "RegisterDisplayEventEXT")) return (void *)table->RegisterDisplayEventEXT; - if (!strcmp(name, "GetSwapchainCounterEXT")) return (void *)table->GetSwapchainCounterEXT; - - // ---- VK_GOOGLE_display_timing extension commands - if (!strcmp(name, "GetRefreshCycleDurationGOOGLE")) return (void *)table->GetRefreshCycleDurationGOOGLE; - if (!strcmp(name, "GetPastPresentationTimingGOOGLE")) return (void *)table->GetPastPresentationTimingGOOGLE; - - // ---- VK_EXT_discard_rectangles extension commands - if (!strcmp(name, "CmdSetDiscardRectangleEXT")) return (void *)table->CmdSetDiscardRectangleEXT; - - // ---- VK_EXT_hdr_metadata extension commands - if (!strcmp(name, "SetHdrMetadataEXT")) return (void *)table->SetHdrMetadataEXT; - - // ---- VK_EXT_sample_locations extension commands - if (!strcmp(name, "CmdSetSampleLocationsEXT")) return (void *)table->CmdSetSampleLocationsEXT; - - // ---- VK_EXT_validation_cache extension commands - if (!strcmp(name, "CreateValidationCacheEXT")) return (void *)table->CreateValidationCacheEXT; - if (!strcmp(name, "DestroyValidationCacheEXT")) return (void *)table->DestroyValidationCacheEXT; - if (!strcmp(name, "MergeValidationCachesEXT")) return (void *)table->MergeValidationCachesEXT; - if (!strcmp(name, "GetValidationCacheDataEXT")) return (void *)table->GetValidationCacheDataEXT; - - // ---- VK_EXT_external_memory_host extension commands - if (!strcmp(name, "GetMemoryHostPointerPropertiesEXT")) return (void *)table->GetMemoryHostPointerPropertiesEXT; - - return NULL; -} - -// Instance command lookup function -VKAPI_ATTR void* VKAPI_CALL loader_lookup_instance_dispatch_table(const VkLayerInstanceDispatchTable *table, const char *name, - bool *found_name) { - if (!name || name[0] != 'v' || name[1] != 'k') { - *found_name = false; - return NULL; - } - - *found_name = true; - name += 2; - - // ---- Core 1_0 commands - 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, "GetPhysicalDeviceFormatProperties")) return (void *)table->GetPhysicalDeviceFormatProperties; - if (!strcmp(name, "GetPhysicalDeviceImageFormatProperties")) return (void *)table->GetPhysicalDeviceImageFormatProperties; - 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, "GetPhysicalDeviceSparseImageFormatProperties")) return (void *)table->GetPhysicalDeviceSparseImageFormatProperties; - - // ---- VK_KHR_surface extension commands - 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; - - // ---- VK_KHR_display extension commands - 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; - - // ---- VK_KHR_xlib_surface extension commands -#ifdef VK_USE_PLATFORM_XLIB_KHR - if (!strcmp(name, "CreateXlibSurfaceKHR")) return (void *)table->CreateXlibSurfaceKHR; -#endif // VK_USE_PLATFORM_XLIB_KHR -#ifdef VK_USE_PLATFORM_XLIB_KHR - if (!strcmp(name, "GetPhysicalDeviceXlibPresentationSupportKHR")) return (void *)table->GetPhysicalDeviceXlibPresentationSupportKHR; -#endif // VK_USE_PLATFORM_XLIB_KHR - - // ---- VK_KHR_xcb_surface extension commands -#ifdef VK_USE_PLATFORM_XCB_KHR - if (!strcmp(name, "CreateXcbSurfaceKHR")) return (void *)table->CreateXcbSurfaceKHR; -#endif // VK_USE_PLATFORM_XCB_KHR -#ifdef VK_USE_PLATFORM_XCB_KHR - if (!strcmp(name, "GetPhysicalDeviceXcbPresentationSupportKHR")) return (void *)table->GetPhysicalDeviceXcbPresentationSupportKHR; -#endif // VK_USE_PLATFORM_XCB_KHR - - // ---- VK_KHR_wayland_surface extension commands -#ifdef VK_USE_PLATFORM_WAYLAND_KHR - if (!strcmp(name, "CreateWaylandSurfaceKHR")) return (void *)table->CreateWaylandSurfaceKHR; -#endif // VK_USE_PLATFORM_WAYLAND_KHR -#ifdef VK_USE_PLATFORM_WAYLAND_KHR - if (!strcmp(name, "GetPhysicalDeviceWaylandPresentationSupportKHR")) return (void *)table->GetPhysicalDeviceWaylandPresentationSupportKHR; -#endif // VK_USE_PLATFORM_WAYLAND_KHR - - // ---- VK_KHR_mir_surface extension commands -#ifdef VK_USE_PLATFORM_MIR_KHR - if (!strcmp(name, "CreateMirSurfaceKHR")) return (void *)table->CreateMirSurfaceKHR; -#endif // VK_USE_PLATFORM_MIR_KHR -#ifdef VK_USE_PLATFORM_MIR_KHR - if (!strcmp(name, "GetPhysicalDeviceMirPresentationSupportKHR")) return (void *)table->GetPhysicalDeviceMirPresentationSupportKHR; -#endif // VK_USE_PLATFORM_MIR_KHR - - // ---- VK_KHR_android_surface extension commands -#ifdef VK_USE_PLATFORM_ANDROID_KHR - if (!strcmp(name, "CreateAndroidSurfaceKHR")) return (void *)table->CreateAndroidSurfaceKHR; -#endif // VK_USE_PLATFORM_ANDROID_KHR - - // ---- VK_KHR_win32_surface extension commands -#ifdef VK_USE_PLATFORM_WIN32_KHR - if (!strcmp(name, "CreateWin32SurfaceKHR")) return (void *)table->CreateWin32SurfaceKHR; -#endif // VK_USE_PLATFORM_WIN32_KHR -#ifdef VK_USE_PLATFORM_WIN32_KHR - if (!strcmp(name, "GetPhysicalDeviceWin32PresentationSupportKHR")) return (void *)table->GetPhysicalDeviceWin32PresentationSupportKHR; -#endif // VK_USE_PLATFORM_WIN32_KHR - - // ---- VK_KHR_get_physical_device_properties2 extension commands - 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, "GetPhysicalDeviceSparseImageFormatProperties2KHR")) return (void *)table->GetPhysicalDeviceSparseImageFormatProperties2KHR; - - // ---- VK_KHR_external_memory_capabilities extension commands - if (!strcmp(name, "GetPhysicalDeviceExternalBufferPropertiesKHR")) return (void *)table->GetPhysicalDeviceExternalBufferPropertiesKHR; - - // ---- VK_KHR_external_semaphore_capabilities extension commands - if (!strcmp(name, "GetPhysicalDeviceExternalSemaphorePropertiesKHR")) return (void *)table->GetPhysicalDeviceExternalSemaphorePropertiesKHR; - - // ---- VK_KHR_external_fence_capabilities extension commands - if (!strcmp(name, "GetPhysicalDeviceExternalFencePropertiesKHR")) return (void *)table->GetPhysicalDeviceExternalFencePropertiesKHR; - - // ---- VK_KHR_get_surface_capabilities2 extension commands - if (!strcmp(name, "GetPhysicalDeviceSurfaceCapabilities2KHR")) return (void *)table->GetPhysicalDeviceSurfaceCapabilities2KHR; - if (!strcmp(name, "GetPhysicalDeviceSurfaceFormats2KHR")) return (void *)table->GetPhysicalDeviceSurfaceFormats2KHR; - - // ---- VK_EXT_debug_report extension commands - if (!strcmp(name, "CreateDebugReportCallbackEXT")) return (void *)table->CreateDebugReportCallbackEXT; - if (!strcmp(name, "DestroyDebugReportCallbackEXT")) return (void *)table->DestroyDebugReportCallbackEXT; - if (!strcmp(name, "DebugReportMessageEXT")) return (void *)table->DebugReportMessageEXT; - - // ---- VK_NV_external_memory_capabilities extension commands - if (!strcmp(name, "GetPhysicalDeviceExternalImageFormatPropertiesNV")) return (void *)table->GetPhysicalDeviceExternalImageFormatPropertiesNV; - - // ---- VK_KHX_device_group extension commands - if (!strcmp(name, "GetPhysicalDevicePresentRectanglesKHX")) return (void *)table->GetPhysicalDevicePresentRectanglesKHX; - - // ---- VK_NN_vi_surface extension commands -#ifdef VK_USE_PLATFORM_VI_NN - if (!strcmp(name, "CreateViSurfaceNN")) return (void *)table->CreateViSurfaceNN; -#endif // VK_USE_PLATFORM_VI_NN - - // ---- VK_KHX_device_group_creation extension commands - if (!strcmp(name, "EnumeratePhysicalDeviceGroupsKHX")) return (void *)table->EnumeratePhysicalDeviceGroupsKHX; - - // ---- VK_NVX_device_generated_commands extension commands - if (!strcmp(name, "GetPhysicalDeviceGeneratedCommandsPropertiesNVX")) return (void *)table->GetPhysicalDeviceGeneratedCommandsPropertiesNVX; - - // ---- VK_EXT_direct_mode_display extension commands - if (!strcmp(name, "ReleaseDisplayEXT")) return (void *)table->ReleaseDisplayEXT; - - // ---- VK_EXT_acquire_xlib_display extension commands -#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT - if (!strcmp(name, "AcquireXlibDisplayEXT")) return (void *)table->AcquireXlibDisplayEXT; -#endif // VK_USE_PLATFORM_XLIB_XRANDR_EXT -#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT - if (!strcmp(name, "GetRandROutputDisplayEXT")) return (void *)table->GetRandROutputDisplayEXT; -#endif // VK_USE_PLATFORM_XLIB_XRANDR_EXT - - // ---- VK_EXT_display_surface_counter extension commands - if (!strcmp(name, "GetPhysicalDeviceSurfaceCapabilities2EXT")) return (void *)table->GetPhysicalDeviceSurfaceCapabilities2EXT; - - // ---- VK_MVK_ios_surface extension commands -#ifdef VK_USE_PLATFORM_IOS_MVK - if (!strcmp(name, "CreateIOSSurfaceMVK")) return (void *)table->CreateIOSSurfaceMVK; -#endif // VK_USE_PLATFORM_IOS_MVK - - // ---- VK_MVK_macos_surface extension commands -#ifdef VK_USE_PLATFORM_MACOS_MVK - if (!strcmp(name, "CreateMacOSSurfaceMVK")) return (void *)table->CreateMacOSSurfaceMVK; -#endif // VK_USE_PLATFORM_MACOS_MVK - - // ---- VK_EXT_sample_locations extension commands - if (!strcmp(name, "GetPhysicalDeviceMultisamplePropertiesEXT")) return (void *)table->GetPhysicalDeviceMultisamplePropertiesEXT; - - *found_name = false; - return NULL; -} - - -// ---- VK_KHR_maintenance1 extension trampoline/terminators - -VKAPI_ATTR void VKAPI_CALL TrimCommandPoolKHR( - VkDevice device, - VkCommandPool commandPool, - VkCommandPoolTrimFlagsKHR flags) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - disp->TrimCommandPoolKHR(device, commandPool, flags); -} - - -// ---- VK_KHR_external_memory_win32 extension trampoline/terminators - -#ifdef VK_USE_PLATFORM_WIN32_KHR -VKAPI_ATTR VkResult VKAPI_CALL GetMemoryWin32HandleKHR( - VkDevice device, - const VkMemoryGetWin32HandleInfoKHR* pGetWin32HandleInfo, - HANDLE* pHandle) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - return disp->GetMemoryWin32HandleKHR(device, pGetWin32HandleInfo, pHandle); -} - -#endif // VK_USE_PLATFORM_WIN32_KHR -#ifdef VK_USE_PLATFORM_WIN32_KHR -VKAPI_ATTR VkResult VKAPI_CALL GetMemoryWin32HandlePropertiesKHR( - VkDevice device, - VkExternalMemoryHandleTypeFlagBitsKHR handleType, - HANDLE handle, - VkMemoryWin32HandlePropertiesKHR* pMemoryWin32HandleProperties) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - return disp->GetMemoryWin32HandlePropertiesKHR(device, handleType, handle, pMemoryWin32HandleProperties); -} - -#endif // VK_USE_PLATFORM_WIN32_KHR - -// ---- VK_KHR_external_memory_fd extension trampoline/terminators - -VKAPI_ATTR VkResult VKAPI_CALL GetMemoryFdKHR( - VkDevice device, - const VkMemoryGetFdInfoKHR* pGetFdInfo, - int* pFd) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - return disp->GetMemoryFdKHR(device, pGetFdInfo, pFd); -} - -VKAPI_ATTR VkResult VKAPI_CALL GetMemoryFdPropertiesKHR( - VkDevice device, - VkExternalMemoryHandleTypeFlagBitsKHR handleType, - int fd, - VkMemoryFdPropertiesKHR* pMemoryFdProperties) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - return disp->GetMemoryFdPropertiesKHR(device, handleType, fd, pMemoryFdProperties); -} - - -// ---- VK_KHR_external_semaphore_win32 extension trampoline/terminators - -#ifdef VK_USE_PLATFORM_WIN32_KHR -VKAPI_ATTR VkResult VKAPI_CALL ImportSemaphoreWin32HandleKHR( - VkDevice device, - const VkImportSemaphoreWin32HandleInfoKHR* pImportSemaphoreWin32HandleInfo) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - return disp->ImportSemaphoreWin32HandleKHR(device, pImportSemaphoreWin32HandleInfo); -} - -#endif // VK_USE_PLATFORM_WIN32_KHR -#ifdef VK_USE_PLATFORM_WIN32_KHR -VKAPI_ATTR VkResult VKAPI_CALL GetSemaphoreWin32HandleKHR( - VkDevice device, - const VkSemaphoreGetWin32HandleInfoKHR* pGetWin32HandleInfo, - HANDLE* pHandle) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - return disp->GetSemaphoreWin32HandleKHR(device, pGetWin32HandleInfo, pHandle); -} - -#endif // VK_USE_PLATFORM_WIN32_KHR - -// ---- VK_KHR_external_semaphore_fd extension trampoline/terminators - -VKAPI_ATTR VkResult VKAPI_CALL ImportSemaphoreFdKHR( - VkDevice device, - const VkImportSemaphoreFdInfoKHR* pImportSemaphoreFdInfo) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - return disp->ImportSemaphoreFdKHR(device, pImportSemaphoreFdInfo); -} - -VKAPI_ATTR VkResult VKAPI_CALL GetSemaphoreFdKHR( - VkDevice device, - const VkSemaphoreGetFdInfoKHR* pGetFdInfo, - int* pFd) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - return disp->GetSemaphoreFdKHR(device, pGetFdInfo, pFd); -} - - -// ---- VK_KHR_push_descriptor extension trampoline/terminators - -VKAPI_ATTR void VKAPI_CALL CmdPushDescriptorSetKHR( - VkCommandBuffer commandBuffer, - VkPipelineBindPoint pipelineBindPoint, - VkPipelineLayout layout, - uint32_t set, - uint32_t descriptorWriteCount, - const VkWriteDescriptorSet* pDescriptorWrites) { - const VkLayerDispatchTable *disp = loader_get_dispatch(commandBuffer); - disp->CmdPushDescriptorSetKHR(commandBuffer, pipelineBindPoint, layout, set, descriptorWriteCount, pDescriptorWrites); -} - - -// ---- VK_KHR_descriptor_update_template extension trampoline/terminators - -VKAPI_ATTR VkResult VKAPI_CALL CreateDescriptorUpdateTemplateKHR( - VkDevice device, - const VkDescriptorUpdateTemplateCreateInfoKHR* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkDescriptorUpdateTemplateKHR* pDescriptorUpdateTemplate) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - return disp->CreateDescriptorUpdateTemplateKHR(device, pCreateInfo, pAllocator, pDescriptorUpdateTemplate); -} - -VKAPI_ATTR void VKAPI_CALL DestroyDescriptorUpdateTemplateKHR( - VkDevice device, - VkDescriptorUpdateTemplateKHR descriptorUpdateTemplate, - const VkAllocationCallbacks* pAllocator) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - disp->DestroyDescriptorUpdateTemplateKHR(device, descriptorUpdateTemplate, pAllocator); -} - -VKAPI_ATTR void VKAPI_CALL UpdateDescriptorSetWithTemplateKHR( - VkDevice device, - VkDescriptorSet descriptorSet, - VkDescriptorUpdateTemplateKHR descriptorUpdateTemplate, - const void* pData) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - disp->UpdateDescriptorSetWithTemplateKHR(device, descriptorSet, descriptorUpdateTemplate, pData); -} - -VKAPI_ATTR void VKAPI_CALL CmdPushDescriptorSetWithTemplateKHR( - VkCommandBuffer commandBuffer, - VkDescriptorUpdateTemplateKHR descriptorUpdateTemplate, - VkPipelineLayout layout, - uint32_t set, - const void* pData) { - const VkLayerDispatchTable *disp = loader_get_dispatch(commandBuffer); - disp->CmdPushDescriptorSetWithTemplateKHR(commandBuffer, descriptorUpdateTemplate, layout, set, pData); -} - - -// ---- VK_KHR_shared_presentable_image extension trampoline/terminators - -VKAPI_ATTR VkResult VKAPI_CALL GetSwapchainStatusKHR( - VkDevice device, - VkSwapchainKHR swapchain) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - return disp->GetSwapchainStatusKHR(device, swapchain); -} - - -// ---- VK_KHR_external_fence_win32 extension trampoline/terminators - -#ifdef VK_USE_PLATFORM_WIN32_KHR -VKAPI_ATTR VkResult VKAPI_CALL ImportFenceWin32HandleKHR( - VkDevice device, - const VkImportFenceWin32HandleInfoKHR* pImportFenceWin32HandleInfo) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - return disp->ImportFenceWin32HandleKHR(device, pImportFenceWin32HandleInfo); -} - -#endif // VK_USE_PLATFORM_WIN32_KHR -#ifdef VK_USE_PLATFORM_WIN32_KHR -VKAPI_ATTR VkResult VKAPI_CALL GetFenceWin32HandleKHR( - VkDevice device, - const VkFenceGetWin32HandleInfoKHR* pGetWin32HandleInfo, - HANDLE* pHandle) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - return disp->GetFenceWin32HandleKHR(device, pGetWin32HandleInfo, pHandle); -} - -#endif // VK_USE_PLATFORM_WIN32_KHR - -// ---- VK_KHR_external_fence_fd extension trampoline/terminators - -VKAPI_ATTR VkResult VKAPI_CALL ImportFenceFdKHR( - VkDevice device, - const VkImportFenceFdInfoKHR* pImportFenceFdInfo) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - return disp->ImportFenceFdKHR(device, pImportFenceFdInfo); -} - -VKAPI_ATTR VkResult VKAPI_CALL GetFenceFdKHR( - VkDevice device, - const VkFenceGetFdInfoKHR* pGetFdInfo, - int* pFd) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - return disp->GetFenceFdKHR(device, pGetFdInfo, pFd); -} - - -// ---- VK_KHR_get_memory_requirements2 extension trampoline/terminators - -VKAPI_ATTR void VKAPI_CALL GetImageMemoryRequirements2KHR( - VkDevice device, - const VkImageMemoryRequirementsInfo2KHR* pInfo, - VkMemoryRequirements2KHR* pMemoryRequirements) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - disp->GetImageMemoryRequirements2KHR(device, pInfo, pMemoryRequirements); -} - -VKAPI_ATTR void VKAPI_CALL GetBufferMemoryRequirements2KHR( - VkDevice device, - const VkBufferMemoryRequirementsInfo2KHR* pInfo, - VkMemoryRequirements2KHR* pMemoryRequirements) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - disp->GetBufferMemoryRequirements2KHR(device, pInfo, pMemoryRequirements); -} - -VKAPI_ATTR void VKAPI_CALL GetImageSparseMemoryRequirements2KHR( - VkDevice device, - const VkImageSparseMemoryRequirementsInfo2KHR* pInfo, - uint32_t* pSparseMemoryRequirementCount, - VkSparseImageMemoryRequirements2KHR* pSparseMemoryRequirements) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - disp->GetImageSparseMemoryRequirements2KHR(device, pInfo, pSparseMemoryRequirementCount, pSparseMemoryRequirements); -} - - -// ---- VK_KHR_sampler_ycbcr_conversion extension trampoline/terminators - -VKAPI_ATTR VkResult VKAPI_CALL CreateSamplerYcbcrConversionKHR( - VkDevice device, - const VkSamplerYcbcrConversionCreateInfoKHR* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkSamplerYcbcrConversionKHR* pYcbcrConversion) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - return disp->CreateSamplerYcbcrConversionKHR(device, pCreateInfo, pAllocator, pYcbcrConversion); -} - -VKAPI_ATTR void VKAPI_CALL DestroySamplerYcbcrConversionKHR( - VkDevice device, - VkSamplerYcbcrConversionKHR ycbcrConversion, - const VkAllocationCallbacks* pAllocator) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - disp->DestroySamplerYcbcrConversionKHR(device, ycbcrConversion, pAllocator); -} - - -// ---- VK_KHR_bind_memory2 extension trampoline/terminators - -VKAPI_ATTR VkResult VKAPI_CALL BindBufferMemory2KHR( - VkDevice device, - uint32_t bindInfoCount, - const VkBindBufferMemoryInfoKHR* pBindInfos) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - return disp->BindBufferMemory2KHR(device, bindInfoCount, pBindInfos); -} - -VKAPI_ATTR VkResult VKAPI_CALL BindImageMemory2KHR( - VkDevice device, - uint32_t bindInfoCount, - const VkBindImageMemoryInfoKHR* pBindInfos) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - return disp->BindImageMemory2KHR(device, bindInfoCount, pBindInfos); -} - - -// ---- VK_EXT_debug_marker extension trampoline/terminators - -VKAPI_ATTR VkResult VKAPI_CALL DebugMarkerSetObjectTagEXT( - VkDevice device, - const VkDebugMarkerObjectTagInfoEXT* pTagInfo) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - VkDebugMarkerObjectTagInfoEXT local_tag_info; - memcpy(&local_tag_info, pTagInfo, sizeof(VkDebugMarkerObjectTagInfoEXT)); - // If this is a physical device, we have to replace it with the proper one for the next call. - if (pTagInfo->objectType == VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT) { - struct loader_physical_device_tramp *phys_dev_tramp = (struct loader_physical_device_tramp *)(uintptr_t)pTagInfo->object; - local_tag_info.object = (uint64_t)(uintptr_t)phys_dev_tramp->phys_dev; - } - return disp->DebugMarkerSetObjectTagEXT(device, &local_tag_info); -} - -VKAPI_ATTR VkResult VKAPI_CALL terminator_DebugMarkerSetObjectTagEXT( - VkDevice device, - const VkDebugMarkerObjectTagInfoEXT* pTagInfo) { - uint32_t icd_index = 0; - struct loader_device *dev; - struct loader_icd_term *icd_term = loader_get_icd_and_device(device, &dev, &icd_index); - if (NULL != icd_term && NULL != icd_term->dispatch.DebugMarkerSetObjectTagEXT) { - VkDebugMarkerObjectTagInfoEXT local_tag_info; - memcpy(&local_tag_info, pTagInfo, sizeof(VkDebugMarkerObjectTagInfoEXT)); - // If this is a physical device, we have to replace it with the proper one for the next call. - if (pTagInfo->objectType == VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT) { - struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)(uintptr_t)pTagInfo->object; - local_tag_info.object = (uint64_t)(uintptr_t)phys_dev_term->phys_dev; - // If this is a KHR_surface, and the ICD has created its own, we have to replace it with the proper one for the next call. - } else if (pTagInfo->objectType == VK_DEBUG_REPORT_OBJECT_TYPE_SURFACE_KHR_EXT) { - if (NULL != icd_term && NULL != icd_term->dispatch.CreateSwapchainKHR) { - VkIcdSurface *icd_surface = (VkIcdSurface *)(uintptr_t)pTagInfo->object; - if (NULL != icd_surface->real_icd_surfaces) { - local_tag_info.object = (uint64_t)icd_surface->real_icd_surfaces[icd_index]; - } - } - } - return icd_term->dispatch.DebugMarkerSetObjectTagEXT(device, &local_tag_info); - } else { - return VK_SUCCESS; - } -} - -VKAPI_ATTR VkResult VKAPI_CALL DebugMarkerSetObjectNameEXT( - VkDevice device, - const VkDebugMarkerObjectNameInfoEXT* pNameInfo) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - VkDebugMarkerObjectNameInfoEXT local_name_info; - memcpy(&local_name_info, pNameInfo, sizeof(VkDebugMarkerObjectNameInfoEXT)); - // If this is a physical device, we have to replace it with the proper one for the next call. - if (pNameInfo->objectType == VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT) { - struct loader_physical_device_tramp *phys_dev_tramp = (struct loader_physical_device_tramp *)(uintptr_t)pNameInfo->object; - local_name_info.object = (uint64_t)(uintptr_t)phys_dev_tramp->phys_dev; - } - return disp->DebugMarkerSetObjectNameEXT(device, &local_name_info); -} - -VKAPI_ATTR VkResult VKAPI_CALL terminator_DebugMarkerSetObjectNameEXT( - VkDevice device, - const VkDebugMarkerObjectNameInfoEXT* pNameInfo) { - uint32_t icd_index = 0; - struct loader_device *dev; - struct loader_icd_term *icd_term = loader_get_icd_and_device(device, &dev, &icd_index); - if (NULL != icd_term && NULL != icd_term->dispatch.DebugMarkerSetObjectNameEXT) { - VkDebugMarkerObjectNameInfoEXT local_name_info; - memcpy(&local_name_info, pNameInfo, sizeof(VkDebugMarkerObjectNameInfoEXT)); - // If this is a physical device, we have to replace it with the proper one for the next call. - if (pNameInfo->objectType == VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT) { - struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)(uintptr_t)pNameInfo->object; - local_name_info.object = (uint64_t)(uintptr_t)phys_dev_term->phys_dev; - // If this is a KHR_surface, and the ICD has created its own, we have to replace it with the proper one for the next call. - } else if (pNameInfo->objectType == VK_DEBUG_REPORT_OBJECT_TYPE_SURFACE_KHR_EXT) { - if (NULL != icd_term && NULL != icd_term->dispatch.CreateSwapchainKHR) { - VkIcdSurface *icd_surface = (VkIcdSurface *)(uintptr_t)pNameInfo->object; - if (NULL != icd_surface->real_icd_surfaces) { - local_name_info.object = (uint64_t)icd_surface->real_icd_surfaces[icd_index]; - } - } - } - return icd_term->dispatch.DebugMarkerSetObjectNameEXT(device, &local_name_info); - } else { - return VK_SUCCESS; - } -} - -VKAPI_ATTR void VKAPI_CALL CmdDebugMarkerBeginEXT( - VkCommandBuffer commandBuffer, - const VkDebugMarkerMarkerInfoEXT* pMarkerInfo) { - const VkLayerDispatchTable *disp = loader_get_dispatch(commandBuffer); - disp->CmdDebugMarkerBeginEXT(commandBuffer, pMarkerInfo); -} - -VKAPI_ATTR void VKAPI_CALL CmdDebugMarkerEndEXT( - VkCommandBuffer commandBuffer) { - const VkLayerDispatchTable *disp = loader_get_dispatch(commandBuffer); - disp->CmdDebugMarkerEndEXT(commandBuffer); -} - -VKAPI_ATTR void VKAPI_CALL CmdDebugMarkerInsertEXT( - VkCommandBuffer commandBuffer, - const VkDebugMarkerMarkerInfoEXT* pMarkerInfo) { - const VkLayerDispatchTable *disp = loader_get_dispatch(commandBuffer); - disp->CmdDebugMarkerInsertEXT(commandBuffer, pMarkerInfo); -} - - -// ---- VK_AMD_draw_indirect_count extension trampoline/terminators - -VKAPI_ATTR void VKAPI_CALL CmdDrawIndirectCountAMD( - VkCommandBuffer commandBuffer, - VkBuffer buffer, - VkDeviceSize offset, - VkBuffer countBuffer, - VkDeviceSize countBufferOffset, - uint32_t maxDrawCount, - uint32_t stride) { - const VkLayerDispatchTable *disp = loader_get_dispatch(commandBuffer); - disp->CmdDrawIndirectCountAMD(commandBuffer, buffer, offset, countBuffer, countBufferOffset, maxDrawCount, stride); -} - -VKAPI_ATTR void VKAPI_CALL CmdDrawIndexedIndirectCountAMD( - VkCommandBuffer commandBuffer, - VkBuffer buffer, - VkDeviceSize offset, - VkBuffer countBuffer, - VkDeviceSize countBufferOffset, - uint32_t maxDrawCount, - uint32_t stride) { - const VkLayerDispatchTable *disp = loader_get_dispatch(commandBuffer); - disp->CmdDrawIndexedIndirectCountAMD(commandBuffer, buffer, offset, countBuffer, countBufferOffset, maxDrawCount, stride); -} - - -// ---- VK_AMD_shader_info extension trampoline/terminators - -VKAPI_ATTR VkResult VKAPI_CALL GetShaderInfoAMD( - VkDevice device, - VkPipeline pipeline, - VkShaderStageFlagBits shaderStage, - VkShaderInfoTypeAMD infoType, - size_t* pInfoSize, - void* pInfo) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - return disp->GetShaderInfoAMD(device, pipeline, shaderStage, infoType, pInfoSize, pInfo); -} - - -// ---- VK_NV_external_memory_win32 extension trampoline/terminators - -#ifdef VK_USE_PLATFORM_WIN32_KHR -VKAPI_ATTR VkResult VKAPI_CALL GetMemoryWin32HandleNV( - VkDevice device, - VkDeviceMemory memory, - VkExternalMemoryHandleTypeFlagsNV handleType, - HANDLE* pHandle) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - return disp->GetMemoryWin32HandleNV(device, memory, handleType, pHandle); -} - -#endif // VK_USE_PLATFORM_WIN32_KHR - -// ---- VK_KHX_device_group extension trampoline/terminators - -VKAPI_ATTR void VKAPI_CALL GetDeviceGroupPeerMemoryFeaturesKHX( - VkDevice device, - uint32_t heapIndex, - uint32_t localDeviceIndex, - uint32_t remoteDeviceIndex, - VkPeerMemoryFeatureFlagsKHX* pPeerMemoryFeatures) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - disp->GetDeviceGroupPeerMemoryFeaturesKHX(device, heapIndex, localDeviceIndex, remoteDeviceIndex, pPeerMemoryFeatures); -} - -VKAPI_ATTR void VKAPI_CALL CmdSetDeviceMaskKHX( - VkCommandBuffer commandBuffer, - uint32_t deviceMask) { - const VkLayerDispatchTable *disp = loader_get_dispatch(commandBuffer); - disp->CmdSetDeviceMaskKHX(commandBuffer, deviceMask); -} - -VKAPI_ATTR void VKAPI_CALL CmdDispatchBaseKHX( - VkCommandBuffer commandBuffer, - uint32_t baseGroupX, - uint32_t baseGroupY, - uint32_t baseGroupZ, - uint32_t groupCountX, - uint32_t groupCountY, - uint32_t groupCountZ) { - const VkLayerDispatchTable *disp = loader_get_dispatch(commandBuffer); - disp->CmdDispatchBaseKHX(commandBuffer, baseGroupX, baseGroupY, baseGroupZ, groupCountX, groupCountY, groupCountZ); -} - -VKAPI_ATTR VkResult VKAPI_CALL GetDeviceGroupPresentCapabilitiesKHX( - VkDevice device, - VkDeviceGroupPresentCapabilitiesKHX* pDeviceGroupPresentCapabilities) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - return disp->GetDeviceGroupPresentCapabilitiesKHX(device, pDeviceGroupPresentCapabilities); -} - -VKAPI_ATTR VkResult VKAPI_CALL GetDeviceGroupSurfacePresentModesKHX( - VkDevice device, - VkSurfaceKHR surface, - VkDeviceGroupPresentModeFlagsKHX* pModes) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - return disp->GetDeviceGroupSurfacePresentModesKHX(device, surface, pModes); -} - -VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDeviceGroupSurfacePresentModesKHX( - VkDevice device, - VkSurfaceKHR surface, - VkDeviceGroupPresentModeFlagsKHX* pModes) { - uint32_t icd_index = 0; - struct loader_device *dev; - struct loader_icd_term *icd_term = loader_get_icd_and_device(device, &dev, &icd_index); - if (NULL != icd_term && NULL != icd_term->dispatch.GetDeviceGroupSurfacePresentModesKHX) { - VkIcdSurface *icd_surface = (VkIcdSurface *)(uintptr_t)surface; - if (NULL != icd_surface->real_icd_surfaces && (VkSurfaceKHR)NULL != icd_surface->real_icd_surfaces[icd_index]) { - return icd_term->dispatch.GetDeviceGroupSurfacePresentModesKHX(device, icd_surface->real_icd_surfaces[icd_index], pModes); - } - return icd_term->dispatch.GetDeviceGroupSurfacePresentModesKHX(device, surface, pModes); - } - return VK_SUCCESS; -} - -VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDevicePresentRectanglesKHX( - VkPhysicalDevice physicalDevice, - VkSurfaceKHR surface, - uint32_t* pRectCount, - VkRect2D* pRects) { - const VkLayerInstanceDispatchTable *disp; - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - return disp->GetPhysicalDevicePresentRectanglesKHX(unwrapped_phys_dev, surface, pRectCount, pRects); -} - -VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDevicePresentRectanglesKHX( - VkPhysicalDevice physicalDevice, - VkSurfaceKHR surface, - uint32_t* pRectCount, - VkRect2D* pRects) { - 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; - if (NULL == icd_term->dispatch.GetPhysicalDevicePresentRectanglesKHX) { - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "ICD associated with VkPhysicalDevice does not support GetPhysicalDevicePresentRectanglesKHX"); - } - VkIcdSurface *icd_surface = (VkIcdSurface *)(surface); - uint8_t icd_index = phys_dev_term->icd_index; - if (NULL != icd_surface->real_icd_surfaces && NULL != (void *)icd_surface->real_icd_surfaces[icd_index]) { - return icd_term->dispatch.GetPhysicalDevicePresentRectanglesKHX(phys_dev_term->phys_dev, icd_surface->real_icd_surfaces[icd_index], pRectCount, pRects); - } - return icd_term->dispatch.GetPhysicalDevicePresentRectanglesKHX(phys_dev_term->phys_dev, surface, pRectCount, pRects); -} - -VKAPI_ATTR VkResult VKAPI_CALL AcquireNextImage2KHX( - VkDevice device, - const VkAcquireNextImageInfoKHX* pAcquireInfo, - uint32_t* pImageIndex) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - return disp->AcquireNextImage2KHX(device, pAcquireInfo, pImageIndex); -} - - -// ---- VK_NN_vi_surface extension trampoline/terminators - -#ifdef VK_USE_PLATFORM_VI_NN -VKAPI_ATTR VkResult VKAPI_CALL CreateViSurfaceNN( - VkInstance instance, - const VkViSurfaceCreateInfoNN* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkSurfaceKHR* pSurface) { -#error("Not implemented. Likely needs to be manually generated!"); - return disp->CreateViSurfaceNN(instance, pCreateInfo, pAllocator, pSurface); -} - -VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateViSurfaceNN( - VkInstance instance, - const VkViSurfaceCreateInfoNN* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkSurfaceKHR* pSurface) { -#error("Not implemented. Likely needs to be manually generated!"); -} - -#endif // VK_USE_PLATFORM_VI_NN - -// ---- VK_NVX_device_generated_commands extension trampoline/terminators - -VKAPI_ATTR void VKAPI_CALL CmdProcessCommandsNVX( - VkCommandBuffer commandBuffer, - const VkCmdProcessCommandsInfoNVX* pProcessCommandsInfo) { - const VkLayerDispatchTable *disp = loader_get_dispatch(commandBuffer); - disp->CmdProcessCommandsNVX(commandBuffer, pProcessCommandsInfo); -} - -VKAPI_ATTR void VKAPI_CALL CmdReserveSpaceForCommandsNVX( - VkCommandBuffer commandBuffer, - const VkCmdReserveSpaceForCommandsInfoNVX* pReserveSpaceInfo) { - const VkLayerDispatchTable *disp = loader_get_dispatch(commandBuffer); - disp->CmdReserveSpaceForCommandsNVX(commandBuffer, pReserveSpaceInfo); -} - -VKAPI_ATTR VkResult VKAPI_CALL CreateIndirectCommandsLayoutNVX( - VkDevice device, - const VkIndirectCommandsLayoutCreateInfoNVX* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkIndirectCommandsLayoutNVX* pIndirectCommandsLayout) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - return disp->CreateIndirectCommandsLayoutNVX(device, pCreateInfo, pAllocator, pIndirectCommandsLayout); -} - -VKAPI_ATTR void VKAPI_CALL DestroyIndirectCommandsLayoutNVX( - VkDevice device, - VkIndirectCommandsLayoutNVX indirectCommandsLayout, - const VkAllocationCallbacks* pAllocator) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - disp->DestroyIndirectCommandsLayoutNVX(device, indirectCommandsLayout, pAllocator); -} - -VKAPI_ATTR VkResult VKAPI_CALL CreateObjectTableNVX( - VkDevice device, - const VkObjectTableCreateInfoNVX* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkObjectTableNVX* pObjectTable) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - return disp->CreateObjectTableNVX(device, pCreateInfo, pAllocator, pObjectTable); -} - -VKAPI_ATTR void VKAPI_CALL DestroyObjectTableNVX( - VkDevice device, - VkObjectTableNVX objectTable, - const VkAllocationCallbacks* pAllocator) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - disp->DestroyObjectTableNVX(device, objectTable, pAllocator); -} - -VKAPI_ATTR VkResult VKAPI_CALL RegisterObjectsNVX( - VkDevice device, - VkObjectTableNVX objectTable, - uint32_t objectCount, - const VkObjectTableEntryNVX* const* ppObjectTableEntries, - const uint32_t* pObjectIndices) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - return disp->RegisterObjectsNVX(device, objectTable, objectCount, ppObjectTableEntries, pObjectIndices); -} - -VKAPI_ATTR VkResult VKAPI_CALL UnregisterObjectsNVX( - VkDevice device, - VkObjectTableNVX objectTable, - uint32_t objectCount, - const VkObjectEntryTypeNVX* pObjectEntryTypes, - const uint32_t* pObjectIndices) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - return disp->UnregisterObjectsNVX(device, objectTable, objectCount, pObjectEntryTypes, pObjectIndices); -} - -VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceGeneratedCommandsPropertiesNVX( - VkPhysicalDevice physicalDevice, - VkDeviceGeneratedCommandsFeaturesNVX* pFeatures, - VkDeviceGeneratedCommandsLimitsNVX* pLimits) { - const VkLayerInstanceDispatchTable *disp; - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - disp->GetPhysicalDeviceGeneratedCommandsPropertiesNVX(unwrapped_phys_dev, pFeatures, pLimits); -} - -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceGeneratedCommandsPropertiesNVX( - VkPhysicalDevice physicalDevice, - VkDeviceGeneratedCommandsFeaturesNVX* pFeatures, - VkDeviceGeneratedCommandsLimitsNVX* pLimits) { - 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; - if (NULL == icd_term->dispatch.GetPhysicalDeviceGeneratedCommandsPropertiesNVX) { - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "ICD associated with VkPhysicalDevice does not support GetPhysicalDeviceGeneratedCommandsPropertiesNVX"); - } - icd_term->dispatch.GetPhysicalDeviceGeneratedCommandsPropertiesNVX(phys_dev_term->phys_dev, pFeatures, pLimits); -} - - -// ---- VK_NV_clip_space_w_scaling extension trampoline/terminators - -VKAPI_ATTR void VKAPI_CALL CmdSetViewportWScalingNV( - VkCommandBuffer commandBuffer, - uint32_t firstViewport, - uint32_t viewportCount, - const VkViewportWScalingNV* pViewportWScalings) { - const VkLayerDispatchTable *disp = loader_get_dispatch(commandBuffer); - disp->CmdSetViewportWScalingNV(commandBuffer, firstViewport, viewportCount, pViewportWScalings); -} - - -// ---- VK_EXT_display_control extension trampoline/terminators - -VKAPI_ATTR VkResult VKAPI_CALL DisplayPowerControlEXT( - VkDevice device, - VkDisplayKHR display, - const VkDisplayPowerInfoEXT* pDisplayPowerInfo) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - return disp->DisplayPowerControlEXT(device, display, pDisplayPowerInfo); -} - -VKAPI_ATTR VkResult VKAPI_CALL RegisterDeviceEventEXT( - VkDevice device, - const VkDeviceEventInfoEXT* pDeviceEventInfo, - const VkAllocationCallbacks* pAllocator, - VkFence* pFence) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - return disp->RegisterDeviceEventEXT(device, pDeviceEventInfo, pAllocator, pFence); -} - -VKAPI_ATTR VkResult VKAPI_CALL RegisterDisplayEventEXT( - VkDevice device, - VkDisplayKHR display, - const VkDisplayEventInfoEXT* pDisplayEventInfo, - const VkAllocationCallbacks* pAllocator, - VkFence* pFence) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - return disp->RegisterDisplayEventEXT(device, display, pDisplayEventInfo, pAllocator, pFence); -} - -VKAPI_ATTR VkResult VKAPI_CALL GetSwapchainCounterEXT( - VkDevice device, - VkSwapchainKHR swapchain, - VkSurfaceCounterFlagBitsEXT counter, - uint64_t* pCounterValue) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - return disp->GetSwapchainCounterEXT(device, swapchain, counter, pCounterValue); -} - - -// ---- VK_GOOGLE_display_timing extension trampoline/terminators - -VKAPI_ATTR VkResult VKAPI_CALL GetRefreshCycleDurationGOOGLE( - VkDevice device, - VkSwapchainKHR swapchain, - VkRefreshCycleDurationGOOGLE* pDisplayTimingProperties) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - return disp->GetRefreshCycleDurationGOOGLE(device, swapchain, pDisplayTimingProperties); -} - -VKAPI_ATTR VkResult VKAPI_CALL GetPastPresentationTimingGOOGLE( - VkDevice device, - VkSwapchainKHR swapchain, - uint32_t* pPresentationTimingCount, - VkPastPresentationTimingGOOGLE* pPresentationTimings) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - return disp->GetPastPresentationTimingGOOGLE(device, swapchain, pPresentationTimingCount, pPresentationTimings); -} - - -// ---- VK_EXT_discard_rectangles extension trampoline/terminators - -VKAPI_ATTR void VKAPI_CALL CmdSetDiscardRectangleEXT( - VkCommandBuffer commandBuffer, - uint32_t firstDiscardRectangle, - uint32_t discardRectangleCount, - const VkRect2D* pDiscardRectangles) { - const VkLayerDispatchTable *disp = loader_get_dispatch(commandBuffer); - disp->CmdSetDiscardRectangleEXT(commandBuffer, firstDiscardRectangle, discardRectangleCount, pDiscardRectangles); -} - - -// ---- VK_EXT_hdr_metadata extension trampoline/terminators - -VKAPI_ATTR void VKAPI_CALL SetHdrMetadataEXT( - VkDevice device, - uint32_t swapchainCount, - const VkSwapchainKHR* pSwapchains, - const VkHdrMetadataEXT* pMetadata) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - disp->SetHdrMetadataEXT(device, swapchainCount, pSwapchains, pMetadata); -} - - -// ---- VK_MVK_ios_surface extension trampoline/terminators - -#ifdef VK_USE_PLATFORM_IOS_MVK -VKAPI_ATTR VkResult VKAPI_CALL CreateIOSSurfaceMVK( - VkInstance instance, - const VkIOSSurfaceCreateInfoMVK* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkSurfaceKHR* pSurface) { -#error("Not implemented. Likely needs to be manually generated!"); - return disp->CreateIOSSurfaceMVK(instance, pCreateInfo, pAllocator, pSurface); -} - -VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateIOSSurfaceMVK( - VkInstance instance, - const VkIOSSurfaceCreateInfoMVK* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkSurfaceKHR* pSurface) { -#error("Not implemented. Likely needs to be manually generated!"); -} - -#endif // VK_USE_PLATFORM_IOS_MVK - -// ---- VK_MVK_macos_surface extension trampoline/terminators - -#ifdef VK_USE_PLATFORM_MACOS_MVK -VKAPI_ATTR VkResult VKAPI_CALL CreateMacOSSurfaceMVK( - VkInstance instance, - const VkMacOSSurfaceCreateInfoMVK* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkSurfaceKHR* pSurface) { -#error("Not implemented. Likely needs to be manually generated!"); - return disp->CreateMacOSSurfaceMVK(instance, pCreateInfo, pAllocator, pSurface); -} - -VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateMacOSSurfaceMVK( - VkInstance instance, - const VkMacOSSurfaceCreateInfoMVK* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkSurfaceKHR* pSurface) { -#error("Not implemented. Likely needs to be manually generated!"); -} - -#endif // VK_USE_PLATFORM_MACOS_MVK - -// ---- VK_EXT_sample_locations extension trampoline/terminators - -VKAPI_ATTR void VKAPI_CALL CmdSetSampleLocationsEXT( - VkCommandBuffer commandBuffer, - const VkSampleLocationsInfoEXT* pSampleLocationsInfo) { - const VkLayerDispatchTable *disp = loader_get_dispatch(commandBuffer); - disp->CmdSetSampleLocationsEXT(commandBuffer, pSampleLocationsInfo); -} - -VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceMultisamplePropertiesEXT( - VkPhysicalDevice physicalDevice, - VkSampleCountFlagBits samples, - VkMultisamplePropertiesEXT* pMultisampleProperties) { - const VkLayerInstanceDispatchTable *disp; - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - disp->GetPhysicalDeviceMultisamplePropertiesEXT(unwrapped_phys_dev, samples, pMultisampleProperties); -} - -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceMultisamplePropertiesEXT( - VkPhysicalDevice physicalDevice, - VkSampleCountFlagBits samples, - VkMultisamplePropertiesEXT* pMultisampleProperties) { - 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; - if (NULL == icd_term->dispatch.GetPhysicalDeviceMultisamplePropertiesEXT) { - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "ICD associated with VkPhysicalDevice does not support GetPhysicalDeviceMultisamplePropertiesEXT"); - } - icd_term->dispatch.GetPhysicalDeviceMultisamplePropertiesEXT(phys_dev_term->phys_dev, samples, pMultisampleProperties); -} - - -// ---- VK_EXT_validation_cache extension trampoline/terminators - -VKAPI_ATTR VkResult VKAPI_CALL CreateValidationCacheEXT( - VkDevice device, - const VkValidationCacheCreateInfoEXT* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkValidationCacheEXT* pValidationCache) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - return disp->CreateValidationCacheEXT(device, pCreateInfo, pAllocator, pValidationCache); -} - -VKAPI_ATTR void VKAPI_CALL DestroyValidationCacheEXT( - VkDevice device, - VkValidationCacheEXT validationCache, - const VkAllocationCallbacks* pAllocator) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - disp->DestroyValidationCacheEXT(device, validationCache, pAllocator); -} - -VKAPI_ATTR VkResult VKAPI_CALL MergeValidationCachesEXT( - VkDevice device, - VkValidationCacheEXT dstCache, - uint32_t srcCacheCount, - const VkValidationCacheEXT* pSrcCaches) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - return disp->MergeValidationCachesEXT(device, dstCache, srcCacheCount, pSrcCaches); -} - -VKAPI_ATTR VkResult VKAPI_CALL GetValidationCacheDataEXT( - VkDevice device, - VkValidationCacheEXT validationCache, - size_t* pDataSize, - void* pData) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - return disp->GetValidationCacheDataEXT(device, validationCache, pDataSize, pData); -} - - -// ---- VK_EXT_external_memory_host extension trampoline/terminators - -VKAPI_ATTR VkResult VKAPI_CALL GetMemoryHostPointerPropertiesEXT( - VkDevice device, - VkExternalMemoryHandleTypeFlagBitsKHR handleType, - const void* pHostPointer, - VkMemoryHostPointerPropertiesEXT* pMemoryHostPointerProperties) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - return disp->GetMemoryHostPointerPropertiesEXT(device, handleType, pHostPointer, pMemoryHostPointerProperties); -} - -// GPA helpers for extensions -bool extension_instance_gpa(struct loader_instance *ptr_instance, const char *name, void **addr) { - *addr = NULL; - - - // ---- VK_KHR_get_physical_device_properties2 extension commands - if (!strcmp("vkGetPhysicalDeviceFeatures2KHR", name)) { - *addr = (ptr_instance->enabled_known_extensions.khr_get_physical_device_properties2 == 1) - ? (void *)GetPhysicalDeviceFeatures2KHR - : NULL; - return true; - } - if (!strcmp("vkGetPhysicalDeviceProperties2KHR", name)) { - *addr = (ptr_instance->enabled_known_extensions.khr_get_physical_device_properties2 == 1) - ? (void *)GetPhysicalDeviceProperties2KHR - : NULL; - return true; - } - if (!strcmp("vkGetPhysicalDeviceFormatProperties2KHR", name)) { - *addr = (ptr_instance->enabled_known_extensions.khr_get_physical_device_properties2 == 1) - ? (void *)GetPhysicalDeviceFormatProperties2KHR - : NULL; - return true; - } - if (!strcmp("vkGetPhysicalDeviceImageFormatProperties2KHR", name)) { - *addr = (ptr_instance->enabled_known_extensions.khr_get_physical_device_properties2 == 1) - ? (void *)GetPhysicalDeviceImageFormatProperties2KHR - : NULL; - return true; - } - if (!strcmp("vkGetPhysicalDeviceQueueFamilyProperties2KHR", name)) { - *addr = (ptr_instance->enabled_known_extensions.khr_get_physical_device_properties2 == 1) - ? (void *)GetPhysicalDeviceQueueFamilyProperties2KHR - : NULL; - return true; - } - if (!strcmp("vkGetPhysicalDeviceMemoryProperties2KHR", name)) { - *addr = (ptr_instance->enabled_known_extensions.khr_get_physical_device_properties2 == 1) - ? (void *)GetPhysicalDeviceMemoryProperties2KHR - : NULL; - return true; - } - if (!strcmp("vkGetPhysicalDeviceSparseImageFormatProperties2KHR", name)) { - *addr = (ptr_instance->enabled_known_extensions.khr_get_physical_device_properties2 == 1) - ? (void *)GetPhysicalDeviceSparseImageFormatProperties2KHR - : NULL; - return true; - } - - // ---- VK_KHR_maintenance1 extension commands - if (!strcmp("vkTrimCommandPoolKHR", name)) { - *addr = (void *)TrimCommandPoolKHR; - return true; - } - - // ---- VK_KHR_external_memory_capabilities extension commands - if (!strcmp("vkGetPhysicalDeviceExternalBufferPropertiesKHR", name)) { - *addr = (ptr_instance->enabled_known_extensions.khr_external_memory_capabilities == 1) - ? (void *)GetPhysicalDeviceExternalBufferPropertiesKHR - : NULL; - return true; - } - - // ---- VK_KHR_external_memory_win32 extension commands -#ifdef VK_USE_PLATFORM_WIN32_KHR - if (!strcmp("vkGetMemoryWin32HandleKHR", name)) { - *addr = (void *)GetMemoryWin32HandleKHR; - return true; - } -#endif // VK_USE_PLATFORM_WIN32_KHR -#ifdef VK_USE_PLATFORM_WIN32_KHR - if (!strcmp("vkGetMemoryWin32HandlePropertiesKHR", name)) { - *addr = (void *)GetMemoryWin32HandlePropertiesKHR; - return true; - } -#endif // VK_USE_PLATFORM_WIN32_KHR - - // ---- VK_KHR_external_memory_fd extension commands - if (!strcmp("vkGetMemoryFdKHR", name)) { - *addr = (void *)GetMemoryFdKHR; - return true; - } - if (!strcmp("vkGetMemoryFdPropertiesKHR", name)) { - *addr = (void *)GetMemoryFdPropertiesKHR; - return true; - } - - // ---- VK_KHR_external_semaphore_capabilities extension commands - if (!strcmp("vkGetPhysicalDeviceExternalSemaphorePropertiesKHR", name)) { - *addr = (ptr_instance->enabled_known_extensions.khr_external_semaphore_capabilities == 1) - ? (void *)GetPhysicalDeviceExternalSemaphorePropertiesKHR - : NULL; - return true; - } - - // ---- VK_KHR_external_semaphore_win32 extension commands -#ifdef VK_USE_PLATFORM_WIN32_KHR - if (!strcmp("vkImportSemaphoreWin32HandleKHR", name)) { - *addr = (void *)ImportSemaphoreWin32HandleKHR; - return true; - } -#endif // VK_USE_PLATFORM_WIN32_KHR -#ifdef VK_USE_PLATFORM_WIN32_KHR - if (!strcmp("vkGetSemaphoreWin32HandleKHR", name)) { - *addr = (void *)GetSemaphoreWin32HandleKHR; - return true; - } -#endif // VK_USE_PLATFORM_WIN32_KHR - - // ---- VK_KHR_external_semaphore_fd extension commands - if (!strcmp("vkImportSemaphoreFdKHR", name)) { - *addr = (void *)ImportSemaphoreFdKHR; - return true; - } - if (!strcmp("vkGetSemaphoreFdKHR", name)) { - *addr = (void *)GetSemaphoreFdKHR; - return true; - } - - // ---- VK_KHR_push_descriptor extension commands - if (!strcmp("vkCmdPushDescriptorSetKHR", name)) { - *addr = (void *)CmdPushDescriptorSetKHR; - return true; - } - - // ---- VK_KHR_descriptor_update_template extension commands - if (!strcmp("vkCreateDescriptorUpdateTemplateKHR", name)) { - *addr = (void *)CreateDescriptorUpdateTemplateKHR; - return true; - } - if (!strcmp("vkDestroyDescriptorUpdateTemplateKHR", name)) { - *addr = (void *)DestroyDescriptorUpdateTemplateKHR; - return true; - } - if (!strcmp("vkUpdateDescriptorSetWithTemplateKHR", name)) { - *addr = (void *)UpdateDescriptorSetWithTemplateKHR; - return true; - } - if (!strcmp("vkCmdPushDescriptorSetWithTemplateKHR", name)) { - *addr = (void *)CmdPushDescriptorSetWithTemplateKHR; - return true; - } - - // ---- VK_KHR_shared_presentable_image extension commands - if (!strcmp("vkGetSwapchainStatusKHR", name)) { - *addr = (void *)GetSwapchainStatusKHR; - return true; - } - - // ---- VK_KHR_external_fence_capabilities extension commands - if (!strcmp("vkGetPhysicalDeviceExternalFencePropertiesKHR", name)) { - *addr = (ptr_instance->enabled_known_extensions.khr_external_fence_capabilities == 1) - ? (void *)GetPhysicalDeviceExternalFencePropertiesKHR - : NULL; - return true; - } - - // ---- VK_KHR_external_fence_win32 extension commands -#ifdef VK_USE_PLATFORM_WIN32_KHR - if (!strcmp("vkImportFenceWin32HandleKHR", name)) { - *addr = (void *)ImportFenceWin32HandleKHR; - return true; - } -#endif // VK_USE_PLATFORM_WIN32_KHR -#ifdef VK_USE_PLATFORM_WIN32_KHR - if (!strcmp("vkGetFenceWin32HandleKHR", name)) { - *addr = (void *)GetFenceWin32HandleKHR; - return true; - } -#endif // VK_USE_PLATFORM_WIN32_KHR - - // ---- VK_KHR_external_fence_fd extension commands - if (!strcmp("vkImportFenceFdKHR", name)) { - *addr = (void *)ImportFenceFdKHR; - return true; - } - if (!strcmp("vkGetFenceFdKHR", name)) { - *addr = (void *)GetFenceFdKHR; - return true; - } - - // ---- VK_KHR_get_surface_capabilities2 extension commands - if (!strcmp("vkGetPhysicalDeviceSurfaceCapabilities2KHR", name)) { - *addr = (ptr_instance->enabled_known_extensions.khr_get_surface_capabilities2 == 1) - ? (void *)GetPhysicalDeviceSurfaceCapabilities2KHR - : NULL; - return true; - } - if (!strcmp("vkGetPhysicalDeviceSurfaceFormats2KHR", name)) { - *addr = (ptr_instance->enabled_known_extensions.khr_get_surface_capabilities2 == 1) - ? (void *)GetPhysicalDeviceSurfaceFormats2KHR - : NULL; - return true; - } - - // ---- VK_KHR_get_memory_requirements2 extension commands - if (!strcmp("vkGetImageMemoryRequirements2KHR", name)) { - *addr = (void *)GetImageMemoryRequirements2KHR; - return true; - } - if (!strcmp("vkGetBufferMemoryRequirements2KHR", name)) { - *addr = (void *)GetBufferMemoryRequirements2KHR; - return true; - } - if (!strcmp("vkGetImageSparseMemoryRequirements2KHR", name)) { - *addr = (void *)GetImageSparseMemoryRequirements2KHR; - return true; - } - - // ---- VK_KHR_sampler_ycbcr_conversion extension commands - if (!strcmp("vkCreateSamplerYcbcrConversionKHR", name)) { - *addr = (void *)CreateSamplerYcbcrConversionKHR; - return true; - } - if (!strcmp("vkDestroySamplerYcbcrConversionKHR", name)) { - *addr = (void *)DestroySamplerYcbcrConversionKHR; - return true; - } - - // ---- VK_KHR_bind_memory2 extension commands - if (!strcmp("vkBindBufferMemory2KHR", name)) { - *addr = (void *)BindBufferMemory2KHR; - return true; - } - if (!strcmp("vkBindImageMemory2KHR", name)) { - *addr = (void *)BindImageMemory2KHR; - return true; - } - - // ---- VK_EXT_debug_marker extension commands - if (!strcmp("vkDebugMarkerSetObjectTagEXT", name)) { - *addr = (void *)DebugMarkerSetObjectTagEXT; - return true; - } - if (!strcmp("vkDebugMarkerSetObjectNameEXT", name)) { - *addr = (void *)DebugMarkerSetObjectNameEXT; - return true; - } - if (!strcmp("vkCmdDebugMarkerBeginEXT", name)) { - *addr = (void *)CmdDebugMarkerBeginEXT; - return true; - } - if (!strcmp("vkCmdDebugMarkerEndEXT", name)) { - *addr = (void *)CmdDebugMarkerEndEXT; - return true; - } - if (!strcmp("vkCmdDebugMarkerInsertEXT", name)) { - *addr = (void *)CmdDebugMarkerInsertEXT; - return true; - } - - // ---- VK_AMD_draw_indirect_count extension commands - if (!strcmp("vkCmdDrawIndirectCountAMD", name)) { - *addr = (void *)CmdDrawIndirectCountAMD; - return true; - } - if (!strcmp("vkCmdDrawIndexedIndirectCountAMD", name)) { - *addr = (void *)CmdDrawIndexedIndirectCountAMD; - return true; - } - - // ---- VK_AMD_shader_info extension commands - if (!strcmp("vkGetShaderInfoAMD", name)) { - *addr = (void *)GetShaderInfoAMD; - return true; - } - - // ---- VK_NV_external_memory_capabilities extension commands - if (!strcmp("vkGetPhysicalDeviceExternalImageFormatPropertiesNV", name)) { - *addr = (ptr_instance->enabled_known_extensions.nv_external_memory_capabilities == 1) - ? (void *)GetPhysicalDeviceExternalImageFormatPropertiesNV - : NULL; - return true; - } - - // ---- VK_NV_external_memory_win32 extension commands -#ifdef VK_USE_PLATFORM_WIN32_KHR - if (!strcmp("vkGetMemoryWin32HandleNV", name)) { - *addr = (void *)GetMemoryWin32HandleNV; - return true; - } -#endif // VK_USE_PLATFORM_WIN32_KHR - - // ---- VK_KHX_device_group extension commands - if (!strcmp("vkGetDeviceGroupPeerMemoryFeaturesKHX", name)) { - *addr = (void *)GetDeviceGroupPeerMemoryFeaturesKHX; - return true; - } - if (!strcmp("vkCmdSetDeviceMaskKHX", name)) { - *addr = (void *)CmdSetDeviceMaskKHX; - return true; - } - if (!strcmp("vkCmdDispatchBaseKHX", name)) { - *addr = (void *)CmdDispatchBaseKHX; - return true; - } - if (!strcmp("vkGetDeviceGroupPresentCapabilitiesKHX", name)) { - *addr = (void *)GetDeviceGroupPresentCapabilitiesKHX; - return true; - } - if (!strcmp("vkGetDeviceGroupSurfacePresentModesKHX", name)) { - *addr = (void *)GetDeviceGroupSurfacePresentModesKHX; - return true; - } - if (!strcmp("vkGetPhysicalDevicePresentRectanglesKHX", name)) { - *addr = (void *)GetPhysicalDevicePresentRectanglesKHX; - return true; - } - if (!strcmp("vkAcquireNextImage2KHX", name)) { - *addr = (void *)AcquireNextImage2KHX; - return true; - } - - // ---- VK_NN_vi_surface extension commands -#ifdef VK_USE_PLATFORM_VI_NN - if (!strcmp("vkCreateViSurfaceNN", name)) { - *addr = (ptr_instance->enabled_known_extensions.nn_vi_surface == 1) - ? (void *)CreateViSurfaceNN - : NULL; - return true; - } -#endif // VK_USE_PLATFORM_VI_NN - - // ---- VK_KHX_device_group_creation extension commands - if (!strcmp("vkEnumeratePhysicalDeviceGroupsKHX", name)) { - *addr = (ptr_instance->enabled_known_extensions.khx_device_group_creation == 1) - ? (void *)EnumeratePhysicalDeviceGroupsKHX - : NULL; - return true; - } - - // ---- VK_NVX_device_generated_commands extension commands - if (!strcmp("vkCmdProcessCommandsNVX", name)) { - *addr = (void *)CmdProcessCommandsNVX; - return true; - } - if (!strcmp("vkCmdReserveSpaceForCommandsNVX", name)) { - *addr = (void *)CmdReserveSpaceForCommandsNVX; - return true; - } - if (!strcmp("vkCreateIndirectCommandsLayoutNVX", name)) { - *addr = (void *)CreateIndirectCommandsLayoutNVX; - return true; - } - if (!strcmp("vkDestroyIndirectCommandsLayoutNVX", name)) { - *addr = (void *)DestroyIndirectCommandsLayoutNVX; - return true; - } - if (!strcmp("vkCreateObjectTableNVX", name)) { - *addr = (void *)CreateObjectTableNVX; - return true; - } - if (!strcmp("vkDestroyObjectTableNVX", name)) { - *addr = (void *)DestroyObjectTableNVX; - return true; - } - if (!strcmp("vkRegisterObjectsNVX", name)) { - *addr = (void *)RegisterObjectsNVX; - return true; - } - if (!strcmp("vkUnregisterObjectsNVX", name)) { - *addr = (void *)UnregisterObjectsNVX; - return true; - } - if (!strcmp("vkGetPhysicalDeviceGeneratedCommandsPropertiesNVX", name)) { - *addr = (void *)GetPhysicalDeviceGeneratedCommandsPropertiesNVX; - return true; - } - - // ---- VK_NV_clip_space_w_scaling extension commands - if (!strcmp("vkCmdSetViewportWScalingNV", name)) { - *addr = (void *)CmdSetViewportWScalingNV; - return true; - } - - // ---- VK_EXT_direct_mode_display extension commands - if (!strcmp("vkReleaseDisplayEXT", name)) { - *addr = (ptr_instance->enabled_known_extensions.ext_direct_mode_display == 1) - ? (void *)ReleaseDisplayEXT - : NULL; - return true; - } - - // ---- VK_EXT_acquire_xlib_display extension commands -#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT - if (!strcmp("vkAcquireXlibDisplayEXT", name)) { - *addr = (ptr_instance->enabled_known_extensions.ext_acquire_xlib_display == 1) - ? (void *)AcquireXlibDisplayEXT - : NULL; - return true; - } -#endif // VK_USE_PLATFORM_XLIB_XRANDR_EXT -#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT - if (!strcmp("vkGetRandROutputDisplayEXT", name)) { - *addr = (ptr_instance->enabled_known_extensions.ext_acquire_xlib_display == 1) - ? (void *)GetRandROutputDisplayEXT - : NULL; - return true; - } -#endif // VK_USE_PLATFORM_XLIB_XRANDR_EXT - - // ---- VK_EXT_display_surface_counter extension commands - if (!strcmp("vkGetPhysicalDeviceSurfaceCapabilities2EXT", name)) { - *addr = (ptr_instance->enabled_known_extensions.ext_display_surface_counter == 1) - ? (void *)GetPhysicalDeviceSurfaceCapabilities2EXT - : NULL; - return true; - } - - // ---- VK_EXT_display_control extension commands - if (!strcmp("vkDisplayPowerControlEXT", name)) { - *addr = (void *)DisplayPowerControlEXT; - return true; - } - if (!strcmp("vkRegisterDeviceEventEXT", name)) { - *addr = (void *)RegisterDeviceEventEXT; - return true; - } - if (!strcmp("vkRegisterDisplayEventEXT", name)) { - *addr = (void *)RegisterDisplayEventEXT; - return true; - } - if (!strcmp("vkGetSwapchainCounterEXT", name)) { - *addr = (void *)GetSwapchainCounterEXT; - return true; - } - - // ---- VK_GOOGLE_display_timing extension commands - if (!strcmp("vkGetRefreshCycleDurationGOOGLE", name)) { - *addr = (void *)GetRefreshCycleDurationGOOGLE; - return true; - } - if (!strcmp("vkGetPastPresentationTimingGOOGLE", name)) { - *addr = (void *)GetPastPresentationTimingGOOGLE; - return true; - } - - // ---- VK_EXT_discard_rectangles extension commands - if (!strcmp("vkCmdSetDiscardRectangleEXT", name)) { - *addr = (void *)CmdSetDiscardRectangleEXT; - return true; - } - - // ---- VK_EXT_hdr_metadata extension commands - if (!strcmp("vkSetHdrMetadataEXT", name)) { - *addr = (void *)SetHdrMetadataEXT; - return true; - } - - // ---- VK_MVK_ios_surface extension commands -#ifdef VK_USE_PLATFORM_IOS_MVK - if (!strcmp("vkCreateIOSSurfaceMVK", name)) { - *addr = (ptr_instance->enabled_known_extensions.mvk_ios_surface == 1) - ? (void *)CreateIOSSurfaceMVK - : NULL; - return true; - } -#endif // VK_USE_PLATFORM_IOS_MVK - - // ---- VK_MVK_macos_surface extension commands -#ifdef VK_USE_PLATFORM_MACOS_MVK - if (!strcmp("vkCreateMacOSSurfaceMVK", name)) { - *addr = (ptr_instance->enabled_known_extensions.mvk_macos_surface == 1) - ? (void *)CreateMacOSSurfaceMVK - : NULL; - return true; - } -#endif // VK_USE_PLATFORM_MACOS_MVK - - // ---- VK_EXT_sample_locations extension commands - if (!strcmp("vkCmdSetSampleLocationsEXT", name)) { - *addr = (void *)CmdSetSampleLocationsEXT; - return true; - } - if (!strcmp("vkGetPhysicalDeviceMultisamplePropertiesEXT", name)) { - *addr = (void *)GetPhysicalDeviceMultisamplePropertiesEXT; - return true; - } - - // ---- VK_EXT_validation_cache extension commands - if (!strcmp("vkCreateValidationCacheEXT", name)) { - *addr = (void *)CreateValidationCacheEXT; - return true; - } - if (!strcmp("vkDestroyValidationCacheEXT", name)) { - *addr = (void *)DestroyValidationCacheEXT; - return true; - } - if (!strcmp("vkMergeValidationCachesEXT", name)) { - *addr = (void *)MergeValidationCachesEXT; - return true; - } - if (!strcmp("vkGetValidationCacheDataEXT", name)) { - *addr = (void *)GetValidationCacheDataEXT; - return true; - } - - // ---- VK_EXT_external_memory_host extension commands - if (!strcmp("vkGetMemoryHostPointerPropertiesEXT", name)) { - *addr = (void *)GetMemoryHostPointerPropertiesEXT; - return true; - } - return false; -} - -// A function that can be used to query enabled extensions during a vkCreateInstance call -void extensions_create_instance(struct loader_instance *ptr_instance, const VkInstanceCreateInfo *pCreateInfo) { - for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { - - // ---- VK_KHR_get_physical_device_properties2 extension commands - if (0 == strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME)) { - ptr_instance->enabled_known_extensions.khr_get_physical_device_properties2 = 1; - - // ---- VK_KHR_external_memory_capabilities extension commands - } else if (0 == strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME)) { - ptr_instance->enabled_known_extensions.khr_external_memory_capabilities = 1; - - // ---- VK_KHR_external_semaphore_capabilities extension commands - } else if (0 == strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_EXTERNAL_SEMAPHORE_CAPABILITIES_EXTENSION_NAME)) { - ptr_instance->enabled_known_extensions.khr_external_semaphore_capabilities = 1; - - // ---- VK_KHR_external_fence_capabilities extension commands - } else if (0 == strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_EXTERNAL_FENCE_CAPABILITIES_EXTENSION_NAME)) { - ptr_instance->enabled_known_extensions.khr_external_fence_capabilities = 1; - - // ---- VK_KHR_get_surface_capabilities2 extension commands - } else if (0 == strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME)) { - ptr_instance->enabled_known_extensions.khr_get_surface_capabilities2 = 1; - - // ---- VK_NV_external_memory_capabilities extension commands - } else if (0 == strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_NV_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME)) { - ptr_instance->enabled_known_extensions.nv_external_memory_capabilities = 1; - - // ---- VK_NN_vi_surface extension commands -#ifdef VK_USE_PLATFORM_VI_NN - } else if (0 == strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_NN_VI_SURFACE_EXTENSION_NAME)) { - ptr_instance->enabled_known_extensions.nn_vi_surface = 1; -#endif // VK_USE_PLATFORM_VI_NN - - // ---- VK_KHX_device_group_creation extension commands - } else if (0 == strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHX_DEVICE_GROUP_CREATION_EXTENSION_NAME)) { - ptr_instance->enabled_known_extensions.khx_device_group_creation = 1; - - // ---- VK_EXT_direct_mode_display extension commands - } else if (0 == strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_DIRECT_MODE_DISPLAY_EXTENSION_NAME)) { - ptr_instance->enabled_known_extensions.ext_direct_mode_display = 1; - - // ---- VK_EXT_acquire_xlib_display extension commands -#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT - } else if (0 == strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_ACQUIRE_XLIB_DISPLAY_EXTENSION_NAME)) { - ptr_instance->enabled_known_extensions.ext_acquire_xlib_display = 1; -#endif // VK_USE_PLATFORM_XLIB_XRANDR_EXT - - // ---- VK_EXT_display_surface_counter extension commands - } else if (0 == strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_DISPLAY_SURFACE_COUNTER_EXTENSION_NAME)) { - ptr_instance->enabled_known_extensions.ext_display_surface_counter = 1; - - // ---- VK_MVK_ios_surface extension commands -#ifdef VK_USE_PLATFORM_IOS_MVK - } else if (0 == strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_MVK_IOS_SURFACE_EXTENSION_NAME)) { - ptr_instance->enabled_known_extensions.mvk_ios_surface = 1; -#endif // VK_USE_PLATFORM_IOS_MVK - - // ---- VK_MVK_macos_surface extension commands -#ifdef VK_USE_PLATFORM_MACOS_MVK - } else if (0 == strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_MVK_MACOS_SURFACE_EXTENSION_NAME)) { - ptr_instance->enabled_known_extensions.mvk_macos_surface = 1; -#endif // VK_USE_PLATFORM_MACOS_MVK - } - } -} - -// Some device commands still need a terminator because the loader needs to unwrap something about them. -// In many cases, the item needing unwrapping is a VkPhysicalDevice or VkSurfaceKHR object. But there may be other items -// in the future. -PFN_vkVoidFunction get_extension_device_proc_terminator(const char *pName) { - PFN_vkVoidFunction addr = NULL; - - // ---- VK_KHR_swapchain extension commands - if(!strcmp(pName, "vkCreateSwapchainKHR")) { - addr = (PFN_vkVoidFunction)terminator_CreateSwapchainKHR; - - // ---- VK_KHR_display_swapchain extension commands - } else if(!strcmp(pName, "vkCreateSharedSwapchainsKHR")) { - addr = (PFN_vkVoidFunction)terminator_CreateSharedSwapchainsKHR; - - // ---- VK_EXT_debug_marker extension commands - } else if(!strcmp(pName, "vkDebugMarkerSetObjectTagEXT")) { - addr = (PFN_vkVoidFunction)terminator_DebugMarkerSetObjectTagEXT; - } else if(!strcmp(pName, "vkDebugMarkerSetObjectNameEXT")) { - addr = (PFN_vkVoidFunction)terminator_DebugMarkerSetObjectNameEXT; - - // ---- VK_KHX_device_group extension commands - } else if(!strcmp(pName, "vkGetDeviceGroupSurfacePresentModesKHX")) { - addr = (PFN_vkVoidFunction)terminator_GetDeviceGroupSurfacePresentModesKHX; - } - return addr; -} - -// This table contains the loader's instance dispatch table, which contains -// default functions if no instance layers are activated. This contains -// pointers to "terminator functions". -const VkLayerInstanceDispatchTable instance_disp = { - - // ---- Core 1_0 commands - .DestroyInstance = terminator_DestroyInstance, - .EnumeratePhysicalDevices = terminator_EnumeratePhysicalDevices, - .GetPhysicalDeviceFeatures = terminator_GetPhysicalDeviceFeatures, - .GetPhysicalDeviceFormatProperties = terminator_GetPhysicalDeviceFormatProperties, - .GetPhysicalDeviceImageFormatProperties = terminator_GetPhysicalDeviceImageFormatProperties, - .GetPhysicalDeviceProperties = terminator_GetPhysicalDeviceProperties, - .GetPhysicalDeviceQueueFamilyProperties = terminator_GetPhysicalDeviceQueueFamilyProperties, - .GetPhysicalDeviceMemoryProperties = terminator_GetPhysicalDeviceMemoryProperties, - .GetInstanceProcAddr = vkGetInstanceProcAddr, - .EnumerateDeviceExtensionProperties = terminator_EnumerateDeviceExtensionProperties, - .EnumerateDeviceLayerProperties = terminator_EnumerateDeviceLayerProperties, - .GetPhysicalDeviceSparseImageFormatProperties = terminator_GetPhysicalDeviceSparseImageFormatProperties, - - // ---- VK_KHR_surface extension commands - .DestroySurfaceKHR = terminator_DestroySurfaceKHR, - .GetPhysicalDeviceSurfaceSupportKHR = terminator_GetPhysicalDeviceSurfaceSupportKHR, - .GetPhysicalDeviceSurfaceCapabilitiesKHR = terminator_GetPhysicalDeviceSurfaceCapabilitiesKHR, - .GetPhysicalDeviceSurfaceFormatsKHR = terminator_GetPhysicalDeviceSurfaceFormatsKHR, - .GetPhysicalDeviceSurfacePresentModesKHR = terminator_GetPhysicalDeviceSurfacePresentModesKHR, - - // ---- VK_KHR_display extension commands - .GetPhysicalDeviceDisplayPropertiesKHR = terminator_GetPhysicalDeviceDisplayPropertiesKHR, - .GetPhysicalDeviceDisplayPlanePropertiesKHR = terminator_GetPhysicalDeviceDisplayPlanePropertiesKHR, - .GetDisplayPlaneSupportedDisplaysKHR = terminator_GetDisplayPlaneSupportedDisplaysKHR, - .GetDisplayModePropertiesKHR = terminator_GetDisplayModePropertiesKHR, - .CreateDisplayModeKHR = terminator_CreateDisplayModeKHR, - .GetDisplayPlaneCapabilitiesKHR = terminator_GetDisplayPlaneCapabilitiesKHR, - .CreateDisplayPlaneSurfaceKHR = terminator_CreateDisplayPlaneSurfaceKHR, - - // ---- VK_KHR_xlib_surface extension commands -#ifdef VK_USE_PLATFORM_XLIB_KHR - .CreateXlibSurfaceKHR = terminator_CreateXlibSurfaceKHR, -#endif // VK_USE_PLATFORM_XLIB_KHR -#ifdef VK_USE_PLATFORM_XLIB_KHR - .GetPhysicalDeviceXlibPresentationSupportKHR = terminator_GetPhysicalDeviceXlibPresentationSupportKHR, -#endif // VK_USE_PLATFORM_XLIB_KHR - - // ---- VK_KHR_xcb_surface extension commands -#ifdef VK_USE_PLATFORM_XCB_KHR - .CreateXcbSurfaceKHR = terminator_CreateXcbSurfaceKHR, -#endif // VK_USE_PLATFORM_XCB_KHR -#ifdef VK_USE_PLATFORM_XCB_KHR - .GetPhysicalDeviceXcbPresentationSupportKHR = terminator_GetPhysicalDeviceXcbPresentationSupportKHR, -#endif // VK_USE_PLATFORM_XCB_KHR - - // ---- VK_KHR_wayland_surface extension commands -#ifdef VK_USE_PLATFORM_WAYLAND_KHR - .CreateWaylandSurfaceKHR = terminator_CreateWaylandSurfaceKHR, -#endif // VK_USE_PLATFORM_WAYLAND_KHR -#ifdef VK_USE_PLATFORM_WAYLAND_KHR - .GetPhysicalDeviceWaylandPresentationSupportKHR = terminator_GetPhysicalDeviceWaylandPresentationSupportKHR, -#endif // VK_USE_PLATFORM_WAYLAND_KHR - - // ---- VK_KHR_mir_surface extension commands -#ifdef VK_USE_PLATFORM_MIR_KHR - .CreateMirSurfaceKHR = terminator_CreateMirSurfaceKHR, -#endif // VK_USE_PLATFORM_MIR_KHR -#ifdef VK_USE_PLATFORM_MIR_KHR - .GetPhysicalDeviceMirPresentationSupportKHR = terminator_GetPhysicalDeviceMirPresentationSupportKHR, -#endif // VK_USE_PLATFORM_MIR_KHR - - // ---- VK_KHR_android_surface extension commands -#ifdef VK_USE_PLATFORM_ANDROID_KHR - .CreateAndroidSurfaceKHR = terminator_CreateAndroidSurfaceKHR, -#endif // VK_USE_PLATFORM_ANDROID_KHR - - // ---- VK_KHR_win32_surface extension commands -#ifdef VK_USE_PLATFORM_WIN32_KHR - .CreateWin32SurfaceKHR = terminator_CreateWin32SurfaceKHR, -#endif // VK_USE_PLATFORM_WIN32_KHR -#ifdef VK_USE_PLATFORM_WIN32_KHR - .GetPhysicalDeviceWin32PresentationSupportKHR = terminator_GetPhysicalDeviceWin32PresentationSupportKHR, -#endif // VK_USE_PLATFORM_WIN32_KHR - - // ---- VK_KHR_get_physical_device_properties2 extension commands - .GetPhysicalDeviceFeatures2KHR = terminator_GetPhysicalDeviceFeatures2KHR, - .GetPhysicalDeviceProperties2KHR = terminator_GetPhysicalDeviceProperties2KHR, - .GetPhysicalDeviceFormatProperties2KHR = terminator_GetPhysicalDeviceFormatProperties2KHR, - .GetPhysicalDeviceImageFormatProperties2KHR = terminator_GetPhysicalDeviceImageFormatProperties2KHR, - .GetPhysicalDeviceQueueFamilyProperties2KHR = terminator_GetPhysicalDeviceQueueFamilyProperties2KHR, - .GetPhysicalDeviceMemoryProperties2KHR = terminator_GetPhysicalDeviceMemoryProperties2KHR, - .GetPhysicalDeviceSparseImageFormatProperties2KHR = terminator_GetPhysicalDeviceSparseImageFormatProperties2KHR, - - // ---- VK_KHR_external_memory_capabilities extension commands - .GetPhysicalDeviceExternalBufferPropertiesKHR = terminator_GetPhysicalDeviceExternalBufferPropertiesKHR, - - // ---- VK_KHR_external_semaphore_capabilities extension commands - .GetPhysicalDeviceExternalSemaphorePropertiesKHR = terminator_GetPhysicalDeviceExternalSemaphorePropertiesKHR, - - // ---- VK_KHR_external_fence_capabilities extension commands - .GetPhysicalDeviceExternalFencePropertiesKHR = terminator_GetPhysicalDeviceExternalFencePropertiesKHR, - - // ---- VK_KHR_get_surface_capabilities2 extension commands - .GetPhysicalDeviceSurfaceCapabilities2KHR = terminator_GetPhysicalDeviceSurfaceCapabilities2KHR, - .GetPhysicalDeviceSurfaceFormats2KHR = terminator_GetPhysicalDeviceSurfaceFormats2KHR, - - // ---- VK_EXT_debug_report extension commands - .CreateDebugReportCallbackEXT = terminator_CreateDebugReportCallbackEXT, - .DestroyDebugReportCallbackEXT = terminator_DestroyDebugReportCallbackEXT, - .DebugReportMessageEXT = terminator_DebugReportMessageEXT, - - // ---- VK_NV_external_memory_capabilities extension commands - .GetPhysicalDeviceExternalImageFormatPropertiesNV = terminator_GetPhysicalDeviceExternalImageFormatPropertiesNV, - - // ---- VK_KHX_device_group extension commands - .GetPhysicalDevicePresentRectanglesKHX = terminator_GetPhysicalDevicePresentRectanglesKHX, - - // ---- VK_NN_vi_surface extension commands -#ifdef VK_USE_PLATFORM_VI_NN - .CreateViSurfaceNN = terminator_CreateViSurfaceNN, -#endif // VK_USE_PLATFORM_VI_NN - - // ---- VK_KHX_device_group_creation extension commands - .EnumeratePhysicalDeviceGroupsKHX = terminator_EnumeratePhysicalDeviceGroupsKHX, - - // ---- VK_NVX_device_generated_commands extension commands - .GetPhysicalDeviceGeneratedCommandsPropertiesNVX = terminator_GetPhysicalDeviceGeneratedCommandsPropertiesNVX, - - // ---- VK_EXT_direct_mode_display extension commands - .ReleaseDisplayEXT = terminator_ReleaseDisplayEXT, - - // ---- VK_EXT_acquire_xlib_display extension commands -#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT - .AcquireXlibDisplayEXT = terminator_AcquireXlibDisplayEXT, -#endif // VK_USE_PLATFORM_XLIB_XRANDR_EXT -#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT - .GetRandROutputDisplayEXT = terminator_GetRandROutputDisplayEXT, -#endif // VK_USE_PLATFORM_XLIB_XRANDR_EXT - - // ---- VK_EXT_display_surface_counter extension commands - .GetPhysicalDeviceSurfaceCapabilities2EXT = terminator_GetPhysicalDeviceSurfaceCapabilities2EXT, - - // ---- VK_MVK_ios_surface extension commands -#ifdef VK_USE_PLATFORM_IOS_MVK - .CreateIOSSurfaceMVK = terminator_CreateIOSSurfaceMVK, -#endif // VK_USE_PLATFORM_IOS_MVK - - // ---- VK_MVK_macos_surface extension commands -#ifdef VK_USE_PLATFORM_MACOS_MVK - .CreateMacOSSurfaceMVK = terminator_CreateMacOSSurfaceMVK, -#endif // VK_USE_PLATFORM_MACOS_MVK - - // ---- VK_EXT_sample_locations extension commands - .GetPhysicalDeviceMultisamplePropertiesEXT = terminator_GetPhysicalDeviceMultisamplePropertiesEXT, -}; - -// A null-terminated list of all of the instance extensions supported by the loader. -// If an instance extension name is not in this list, but it is exported by one or more of the -// ICDs detected by the loader, then the extension name not in the list will be filtered out -// before passing the list of extensions to the application. -const char *const LOADER_INSTANCE_EXTENSIONS[] = { - VK_KHR_SURFACE_EXTENSION_NAME, - VK_KHR_DISPLAY_EXTENSION_NAME, -#ifdef VK_USE_PLATFORM_XLIB_KHR - VK_KHR_XLIB_SURFACE_EXTENSION_NAME, -#endif // VK_USE_PLATFORM_XLIB_KHR -#ifdef VK_USE_PLATFORM_XCB_KHR - VK_KHR_XCB_SURFACE_EXTENSION_NAME, -#endif // VK_USE_PLATFORM_XCB_KHR -#ifdef VK_USE_PLATFORM_WAYLAND_KHR - VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME, -#endif // VK_USE_PLATFORM_WAYLAND_KHR -#ifdef VK_USE_PLATFORM_MIR_KHR - VK_KHR_MIR_SURFACE_EXTENSION_NAME, -#endif // VK_USE_PLATFORM_MIR_KHR -#ifdef VK_USE_PLATFORM_WIN32_KHR - VK_KHR_WIN32_SURFACE_EXTENSION_NAME, -#endif // VK_USE_PLATFORM_WIN32_KHR - VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME, - VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME, - VK_KHR_EXTERNAL_SEMAPHORE_CAPABILITIES_EXTENSION_NAME, - VK_KHR_EXTERNAL_FENCE_CAPABILITIES_EXTENSION_NAME, - VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME, - VK_EXT_DEBUG_REPORT_EXTENSION_NAME, - VK_NV_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME, - VK_EXT_VALIDATION_FLAGS_EXTENSION_NAME, -#ifdef VK_USE_PLATFORM_VI_NN - VK_NN_VI_SURFACE_EXTENSION_NAME, -#endif // VK_USE_PLATFORM_VI_NN - VK_KHX_DEVICE_GROUP_CREATION_EXTENSION_NAME, - VK_EXT_DIRECT_MODE_DISPLAY_EXTENSION_NAME, -#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT - VK_EXT_ACQUIRE_XLIB_DISPLAY_EXTENSION_NAME, -#endif // VK_USE_PLATFORM_XLIB_XRANDR_EXT - VK_EXT_DISPLAY_SURFACE_COUNTER_EXTENSION_NAME, - VK_EXT_SWAPCHAIN_COLOR_SPACE_EXTENSION_NAME, -#ifdef VK_USE_PLATFORM_IOS_MVK - VK_MVK_IOS_SURFACE_EXTENSION_NAME, -#endif // VK_USE_PLATFORM_IOS_MVK -#ifdef VK_USE_PLATFORM_MACOS_MVK - VK_MVK_MACOS_SURFACE_EXTENSION_NAME, -#endif // VK_USE_PLATFORM_MACOS_MVK - NULL }; - diff --git a/third_party/vulkan/loader/vk_loader_extensions.h b/third_party/vulkan/loader/vk_loader_extensions.h deleted file mode 100644 index 474adb950..000000000 --- a/third_party/vulkan/loader/vk_loader_extensions.h +++ /dev/null @@ -1,342 +0,0 @@ -// *** THIS FILE IS GENERATED - DO NOT EDIT *** -// See loader_extension_generator.py for modifications - -/* - * Copyright (c) 2015-2017 The Khronos Group Inc. - * Copyright (c) 2015-2017 Valve Corporation - * Copyright (c) 2015-2017 LunarG, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Author: Mark Lobodzinski - * Author: Mark Young - */ - -#pragma once - -// Structures defined externally, but used here -struct loader_instance; -struct loader_icd_term; -struct loader_dev_dispatch_table; - -// Device extension error function -VKAPI_ATTR VkResult VKAPI_CALL vkDevExtError(VkDevice dev); - -// Extension interception for vkGetInstanceProcAddr function, so we can return -// the appropriate information for any instance extensions we know about. -bool extension_instance_gpa(struct loader_instance *ptr_instance, const char *name, void **addr); - -// Extension interception for vkCreateInstance function, so we can properly -// detect and enable any instance extension information for extensions we know -// about. -void extensions_create_instance(struct loader_instance *ptr_instance, const VkInstanceCreateInfo *pCreateInfo); - -// Extension interception for vkGetDeviceProcAddr function, so we can return -// an appropriate terminator if this is one of those few device commands requiring -// a terminator. -PFN_vkVoidFunction get_extension_device_proc_terminator(const char *pName); - -// Dispatch table properly filled in with appropriate terminators for the -// supported extensions. -extern const VkLayerInstanceDispatchTable instance_disp; - -// Array of extension strings for instance extensions we support. -extern const char *const LOADER_INSTANCE_EXTENSIONS[]; - -VKAPI_ATTR bool VKAPI_CALL loader_icd_init_entries(struct loader_icd_term *icd_term, VkInstance inst, - const PFN_vkGetInstanceProcAddr fp_gipa); - -// Init Device function pointer dispatch table with core commands -VKAPI_ATTR void VKAPI_CALL loader_init_device_dispatch_table(struct loader_dev_dispatch_table *dev_table, PFN_vkGetDeviceProcAddr gpa, - VkDevice dev); - -// Init Device function pointer dispatch table with extension commands -VKAPI_ATTR void VKAPI_CALL loader_init_device_extension_dispatch_table(struct loader_dev_dispatch_table *dev_table, - PFN_vkGetDeviceProcAddr gpa, VkDevice dev); - -// Init Instance function pointer dispatch table with core commands -VKAPI_ATTR void VKAPI_CALL loader_init_instance_core_dispatch_table(VkLayerInstanceDispatchTable *table, PFN_vkGetInstanceProcAddr gpa, - VkInstance inst); - -// Init Instance function pointer dispatch table with core commands -VKAPI_ATTR void VKAPI_CALL loader_init_instance_extension_dispatch_table(VkLayerInstanceDispatchTable *table, PFN_vkGetInstanceProcAddr gpa, - VkInstance inst); - -// Device command lookup function -VKAPI_ATTR void* VKAPI_CALL loader_lookup_device_dispatch_table(const VkLayerDispatchTable *table, const char *name); - -// Instance command lookup function -VKAPI_ATTR void* VKAPI_CALL loader_lookup_instance_dispatch_table(const VkLayerInstanceDispatchTable *table, const char *name, - bool *found_name); - -VKAPI_ATTR bool VKAPI_CALL loader_icd_init_entries(struct loader_icd_term *icd_term, VkInstance inst, - const PFN_vkGetInstanceProcAddr fp_gipa); - -// Loader core instance terminators -VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateInstance( - const VkInstanceCreateInfo* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkInstance* pInstance); -VKAPI_ATTR void VKAPI_CALL terminator_DestroyInstance( - VkInstance instance, - const VkAllocationCallbacks* pAllocator); -VKAPI_ATTR VkResult VKAPI_CALL terminator_EnumeratePhysicalDevices( - VkInstance instance, - uint32_t* pPhysicalDeviceCount, - VkPhysicalDevice* pPhysicalDevices); -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceFeatures( - VkPhysicalDevice physicalDevice, - VkPhysicalDeviceFeatures* pFeatures); -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceFormatProperties( - VkPhysicalDevice physicalDevice, - VkFormat format, - VkFormatProperties* pFormatProperties); -VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceImageFormatProperties( - VkPhysicalDevice physicalDevice, - VkFormat format, - VkImageType type, - VkImageTiling tiling, - VkImageUsageFlags usage, - VkImageCreateFlags flags, - VkImageFormatProperties* pImageFormatProperties); -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceProperties( - VkPhysicalDevice physicalDevice, - VkPhysicalDeviceProperties* pProperties); -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceQueueFamilyProperties( - VkPhysicalDevice physicalDevice, - uint32_t* pQueueFamilyPropertyCount, - VkQueueFamilyProperties* pQueueFamilyProperties); -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceMemoryProperties( - VkPhysicalDevice physicalDevice, - VkPhysicalDeviceMemoryProperties* pMemoryProperties); -VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL terminator_GetInstanceProcAddr( - VkInstance instance, - const char* pName); -VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDevice( - VkPhysicalDevice physicalDevice, - const VkDeviceCreateInfo* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkDevice* pDevice); -VKAPI_ATTR VkResult VKAPI_CALL terminator_EnumerateInstanceExtensionProperties( - const VkEnumerateInstanceExtensionPropertiesChain* chain, - const char* pLayerName, - uint32_t* pPropertyCount, - VkExtensionProperties* pProperties); -VKAPI_ATTR VkResult VKAPI_CALL terminator_EnumerateDeviceExtensionProperties( - VkPhysicalDevice physicalDevice, - const char* pLayerName, - uint32_t* pPropertyCount, - VkExtensionProperties* pProperties); -VKAPI_ATTR VkResult VKAPI_CALL terminator_EnumerateInstanceLayerProperties( - const VkEnumerateInstanceLayerPropertiesChain* chain, - uint32_t* pPropertyCount, - VkLayerProperties* pProperties); -VKAPI_ATTR VkResult VKAPI_CALL terminator_EnumerateDeviceLayerProperties( - VkPhysicalDevice physicalDevice, - uint32_t* pPropertyCount, - VkLayerProperties* pProperties); -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceSparseImageFormatProperties( - VkPhysicalDevice physicalDevice, - VkFormat format, - VkImageType type, - VkSampleCountFlagBits samples, - VkImageUsageFlags usage, - VkImageTiling tiling, - uint32_t* pPropertyCount, - VkSparseImageFormatProperties* pProperties); - -// ICD function pointer dispatch table -struct loader_icd_term_dispatch { - - // ---- Core 1_0 commands - PFN_vkCreateInstance CreateInstance; - PFN_vkDestroyInstance DestroyInstance; - PFN_vkEnumeratePhysicalDevices EnumeratePhysicalDevices; - PFN_vkGetPhysicalDeviceFeatures GetPhysicalDeviceFeatures; - PFN_vkGetPhysicalDeviceFormatProperties GetPhysicalDeviceFormatProperties; - PFN_vkGetPhysicalDeviceImageFormatProperties GetPhysicalDeviceImageFormatProperties; - PFN_vkGetPhysicalDeviceProperties GetPhysicalDeviceProperties; - PFN_vkGetPhysicalDeviceQueueFamilyProperties GetPhysicalDeviceQueueFamilyProperties; - PFN_vkGetPhysicalDeviceMemoryProperties GetPhysicalDeviceMemoryProperties; - PFN_vkGetDeviceProcAddr GetDeviceProcAddr; - PFN_vkCreateDevice CreateDevice; - PFN_vkEnumerateInstanceExtensionProperties EnumerateInstanceExtensionProperties; - PFN_vkEnumerateDeviceExtensionProperties EnumerateDeviceExtensionProperties; - PFN_vkEnumerateInstanceLayerProperties EnumerateInstanceLayerProperties; - PFN_vkGetPhysicalDeviceSparseImageFormatProperties GetPhysicalDeviceSparseImageFormatProperties; - - // ---- VK_KHR_surface extension commands - PFN_vkDestroySurfaceKHR DestroySurfaceKHR; - PFN_vkGetPhysicalDeviceSurfaceSupportKHR GetPhysicalDeviceSurfaceSupportKHR; - PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR GetPhysicalDeviceSurfaceCapabilitiesKHR; - PFN_vkGetPhysicalDeviceSurfaceFormatsKHR GetPhysicalDeviceSurfaceFormatsKHR; - PFN_vkGetPhysicalDeviceSurfacePresentModesKHR GetPhysicalDeviceSurfacePresentModesKHR; - - // ---- VK_KHR_swapchain extension commands - PFN_vkCreateSwapchainKHR CreateSwapchainKHR; - - // ---- VK_KHR_display extension commands - PFN_vkGetPhysicalDeviceDisplayPropertiesKHR GetPhysicalDeviceDisplayPropertiesKHR; - PFN_vkGetPhysicalDeviceDisplayPlanePropertiesKHR GetPhysicalDeviceDisplayPlanePropertiesKHR; - PFN_vkGetDisplayPlaneSupportedDisplaysKHR GetDisplayPlaneSupportedDisplaysKHR; - PFN_vkGetDisplayModePropertiesKHR GetDisplayModePropertiesKHR; - PFN_vkCreateDisplayModeKHR CreateDisplayModeKHR; - PFN_vkGetDisplayPlaneCapabilitiesKHR GetDisplayPlaneCapabilitiesKHR; - PFN_vkCreateDisplayPlaneSurfaceKHR CreateDisplayPlaneSurfaceKHR; - - // ---- VK_KHR_display_swapchain extension commands - PFN_vkCreateSharedSwapchainsKHR CreateSharedSwapchainsKHR; - - // ---- VK_KHR_xlib_surface extension commands -#ifdef VK_USE_PLATFORM_XLIB_KHR - PFN_vkCreateXlibSurfaceKHR CreateXlibSurfaceKHR; -#endif // VK_USE_PLATFORM_XLIB_KHR -#ifdef VK_USE_PLATFORM_XLIB_KHR - PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR GetPhysicalDeviceXlibPresentationSupportKHR; -#endif // VK_USE_PLATFORM_XLIB_KHR - - // ---- VK_KHR_xcb_surface extension commands -#ifdef VK_USE_PLATFORM_XCB_KHR - PFN_vkCreateXcbSurfaceKHR CreateXcbSurfaceKHR; -#endif // VK_USE_PLATFORM_XCB_KHR -#ifdef VK_USE_PLATFORM_XCB_KHR - PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR GetPhysicalDeviceXcbPresentationSupportKHR; -#endif // VK_USE_PLATFORM_XCB_KHR - - // ---- VK_KHR_wayland_surface extension commands -#ifdef VK_USE_PLATFORM_WAYLAND_KHR - PFN_vkCreateWaylandSurfaceKHR CreateWaylandSurfaceKHR; -#endif // VK_USE_PLATFORM_WAYLAND_KHR -#ifdef VK_USE_PLATFORM_WAYLAND_KHR - PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR GetPhysicalDeviceWaylandPresentationSupportKHR; -#endif // VK_USE_PLATFORM_WAYLAND_KHR - - // ---- VK_KHR_mir_surface extension commands -#ifdef VK_USE_PLATFORM_MIR_KHR - PFN_vkCreateMirSurfaceKHR CreateMirSurfaceKHR; -#endif // VK_USE_PLATFORM_MIR_KHR -#ifdef VK_USE_PLATFORM_MIR_KHR - PFN_vkGetPhysicalDeviceMirPresentationSupportKHR GetPhysicalDeviceMirPresentationSupportKHR; -#endif // VK_USE_PLATFORM_MIR_KHR - - // ---- VK_KHR_android_surface extension commands -#ifdef VK_USE_PLATFORM_ANDROID_KHR - PFN_vkCreateAndroidSurfaceKHR CreateAndroidSurfaceKHR; -#endif // VK_USE_PLATFORM_ANDROID_KHR - - // ---- VK_KHR_win32_surface extension commands -#ifdef VK_USE_PLATFORM_WIN32_KHR - PFN_vkCreateWin32SurfaceKHR CreateWin32SurfaceKHR; -#endif // VK_USE_PLATFORM_WIN32_KHR -#ifdef VK_USE_PLATFORM_WIN32_KHR - PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR GetPhysicalDeviceWin32PresentationSupportKHR; -#endif // VK_USE_PLATFORM_WIN32_KHR - - // ---- VK_KHR_get_physical_device_properties2 extension commands - PFN_vkGetPhysicalDeviceFeatures2KHR GetPhysicalDeviceFeatures2KHR; - PFN_vkGetPhysicalDeviceProperties2KHR GetPhysicalDeviceProperties2KHR; - PFN_vkGetPhysicalDeviceFormatProperties2KHR GetPhysicalDeviceFormatProperties2KHR; - PFN_vkGetPhysicalDeviceImageFormatProperties2KHR GetPhysicalDeviceImageFormatProperties2KHR; - PFN_vkGetPhysicalDeviceQueueFamilyProperties2KHR GetPhysicalDeviceQueueFamilyProperties2KHR; - PFN_vkGetPhysicalDeviceMemoryProperties2KHR GetPhysicalDeviceMemoryProperties2KHR; - PFN_vkGetPhysicalDeviceSparseImageFormatProperties2KHR GetPhysicalDeviceSparseImageFormatProperties2KHR; - - // ---- VK_KHR_external_memory_capabilities extension commands - PFN_vkGetPhysicalDeviceExternalBufferPropertiesKHR GetPhysicalDeviceExternalBufferPropertiesKHR; - - // ---- VK_KHR_external_semaphore_capabilities extension commands - PFN_vkGetPhysicalDeviceExternalSemaphorePropertiesKHR GetPhysicalDeviceExternalSemaphorePropertiesKHR; - - // ---- VK_KHR_external_fence_capabilities extension commands - PFN_vkGetPhysicalDeviceExternalFencePropertiesKHR GetPhysicalDeviceExternalFencePropertiesKHR; - - // ---- VK_KHR_get_surface_capabilities2 extension commands - PFN_vkGetPhysicalDeviceSurfaceCapabilities2KHR GetPhysicalDeviceSurfaceCapabilities2KHR; - PFN_vkGetPhysicalDeviceSurfaceFormats2KHR GetPhysicalDeviceSurfaceFormats2KHR; - - // ---- VK_EXT_debug_report extension commands - PFN_vkCreateDebugReportCallbackEXT CreateDebugReportCallbackEXT; - PFN_vkDestroyDebugReportCallbackEXT DestroyDebugReportCallbackEXT; - PFN_vkDebugReportMessageEXT DebugReportMessageEXT; - - // ---- VK_EXT_debug_marker extension commands - PFN_vkDebugMarkerSetObjectTagEXT DebugMarkerSetObjectTagEXT; - PFN_vkDebugMarkerSetObjectNameEXT DebugMarkerSetObjectNameEXT; - - // ---- VK_NV_external_memory_capabilities extension commands - PFN_vkGetPhysicalDeviceExternalImageFormatPropertiesNV GetPhysicalDeviceExternalImageFormatPropertiesNV; - - // ---- VK_KHX_device_group extension commands - PFN_vkGetDeviceGroupSurfacePresentModesKHX GetDeviceGroupSurfacePresentModesKHX; - PFN_vkGetPhysicalDevicePresentRectanglesKHX GetPhysicalDevicePresentRectanglesKHX; - - // ---- VK_NN_vi_surface extension commands -#ifdef VK_USE_PLATFORM_VI_NN - PFN_vkCreateViSurfaceNN CreateViSurfaceNN; -#endif // VK_USE_PLATFORM_VI_NN - - // ---- VK_KHX_device_group_creation extension commands - PFN_vkEnumeratePhysicalDeviceGroupsKHX EnumeratePhysicalDeviceGroupsKHX; - - // ---- VK_NVX_device_generated_commands extension commands - PFN_vkGetPhysicalDeviceGeneratedCommandsPropertiesNVX GetPhysicalDeviceGeneratedCommandsPropertiesNVX; - - // ---- VK_EXT_direct_mode_display extension commands - PFN_vkReleaseDisplayEXT ReleaseDisplayEXT; - - // ---- VK_EXT_acquire_xlib_display extension commands -#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT - PFN_vkAcquireXlibDisplayEXT AcquireXlibDisplayEXT; -#endif // VK_USE_PLATFORM_XLIB_XRANDR_EXT -#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT - PFN_vkGetRandROutputDisplayEXT GetRandROutputDisplayEXT; -#endif // VK_USE_PLATFORM_XLIB_XRANDR_EXT - - // ---- VK_EXT_display_surface_counter extension commands - PFN_vkGetPhysicalDeviceSurfaceCapabilities2EXT GetPhysicalDeviceSurfaceCapabilities2EXT; - - // ---- VK_MVK_ios_surface extension commands -#ifdef VK_USE_PLATFORM_IOS_MVK - PFN_vkCreateIOSSurfaceMVK CreateIOSSurfaceMVK; -#endif // VK_USE_PLATFORM_IOS_MVK - - // ---- VK_MVK_macos_surface extension commands -#ifdef VK_USE_PLATFORM_MACOS_MVK - PFN_vkCreateMacOSSurfaceMVK CreateMacOSSurfaceMVK; -#endif // VK_USE_PLATFORM_MACOS_MVK - - // ---- VK_EXT_sample_locations extension commands - PFN_vkGetPhysicalDeviceMultisamplePropertiesEXT GetPhysicalDeviceMultisamplePropertiesEXT; -}; - -union loader_instance_extension_enables { - struct { - uint8_t khr_get_physical_device_properties2 : 1; - uint8_t khr_external_memory_capabilities : 1; - uint8_t khr_external_semaphore_capabilities : 1; - uint8_t khr_external_fence_capabilities : 1; - uint8_t khr_get_surface_capabilities2 : 1; - uint8_t ext_debug_report : 1; - uint8_t nv_external_memory_capabilities : 1; - uint8_t nn_vi_surface : 1; - uint8_t khx_device_group_creation : 1; - uint8_t ext_direct_mode_display : 1; - uint8_t ext_acquire_xlib_display : 1; - uint8_t ext_display_surface_counter : 1; - uint8_t mvk_ios_surface : 1; - uint8_t mvk_macos_surface : 1; - }; - uint64_t padding[4]; -}; - - diff --git a/third_party/vulkan/loader/vk_loader_layer.h b/third_party/vulkan/loader/vk_loader_layer.h deleted file mode 100644 index 425154d82..000000000 --- a/third_party/vulkan/loader/vk_loader_layer.h +++ /dev/null @@ -1,31 +0,0 @@ -/* -* -* Copyright (c) 2016 The Khronos Group Inc. -* Copyright (c) 2016 Valve Corporation -* Copyright (c) 2016 LunarG, Inc. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* Author: Mark Lobodzinski -* -*/ -#pragma once - -// Linked list node for tree of debug callback functions -typedef struct VkLayerDbgFunctionNode_ { - VkDebugReportCallbackEXT msgCallback; - PFN_vkDebugReportCallbackEXT pfnMsgCallback; - VkFlags msgFlags; - void *pUserData; - struct VkLayerDbgFunctionNode_ *pNext; -} VkLayerDbgFunctionNode; diff --git a/third_party/vulkan/loader/vk_loader_platform.h b/third_party/vulkan/loader/vk_loader_platform.h deleted file mode 100644 index 40de844eb..000000000 --- a/third_party/vulkan/loader/vk_loader_platform.h +++ /dev/null @@ -1,359 +0,0 @@ -/* - * - * Copyright (c) 2015-2018 The Khronos Group Inc. - * Copyright (c) 2015-2018 Valve Corporation - * Copyright (c) 2015-2018 LunarG, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Author: Ian Elliot - * Author: Jon Ashburn - * Author: Lenny Komow - * - */ -#pragma once - -#if defined(_WIN32) -// WinSock2.h must be included *BEFORE* windows.h -#include -#endif // _WIN32 - -#include "vulkan/vk_platform.h" -#include "vulkan/vk_sdk_platform.h" - -#if defined(__linux__) -/* Linux-specific common code: */ - -// Headers: -//#define _GNU_SOURCE 1 -// TBD: Are the contents of the following file used? -#include -// Note: The following file is for dynamic loading: -#include -#include -#include -#include -#include -#include -#include - -// VK Library Filenames, Paths, etc.: -#define PATH_SEPARATOR ':' -#define DIRECTORY_SYMBOL '/' - -#define VULKAN_DIR "/vulkan/" -#define VULKAN_ICDCONF_DIR "icd.d" -#define VULKAN_ICD_DIR "icd" -#define VULKAN_ELAYERCONF_DIR "explicit_layer.d" -#define VULKAN_ILAYERCONF_DIR "implicit_layer.d" -#define VULKAN_LAYER_DIR "layer" - -#define DEFAULT_VK_DRIVERS_INFO "" -#define DEFAULT_VK_ELAYERS_INFO "" -#define DEFAULT_VK_ILAYERS_INFO "" - -#define DEFAULT_VK_DRIVERS_PATH "" -#if !defined(DEFAULT_VK_LAYERS_PATH) -#define DEFAULT_VK_LAYERS_PATH "" -#endif - -#if !defined(LAYERS_SOURCE_PATH) -#define LAYERS_SOURCE_PATH NULL -#endif -#define LAYERS_PATH_ENV "VK_LAYER_PATH" -#define ENABLED_LAYERS_ENV "VK_INSTANCE_LAYERS" - -#define RELATIVE_VK_DRIVERS_INFO VULKAN_DIR VULKAN_ICDCONF_DIR -#define RELATIVE_VK_ELAYERS_INFO VULKAN_DIR VULKAN_ELAYERCONF_DIR -#define RELATIVE_VK_ILAYERS_INFO VULKAN_DIR VULKAN_ILAYERCONF_DIR - -// C99: -#define PRINTF_SIZE_T_SPECIFIER "%zu" - -// File IO -static inline bool loader_platform_file_exists(const char *path) { - if (access(path, F_OK)) - return false; - else - return true; -} - -static inline bool loader_platform_is_path_absolute(const char *path) { - if (path[0] == '/') - return true; - else - return false; -} - -static inline char *loader_platform_dirname(char *path) { return dirname(path); } - -// Dynamic Loading of libraries: -typedef void *loader_platform_dl_handle; -static inline loader_platform_dl_handle loader_platform_open_library(const char *libPath) { - // When loading the library, we use RTLD_LAZY so that not all symbols have to be - // resolved at this time (which improves performance). Note that if not all symbols - // can be resolved, this could cause crashes later. Use the LD_BIND_NOW environment - // variable to force all symbols to be resolved here. - return dlopen(libPath, RTLD_LAZY | RTLD_LOCAL); -} -static inline const char *loader_platform_open_library_error(const char *libPath) { return dlerror(); } -static inline void loader_platform_close_library(loader_platform_dl_handle library) { dlclose(library); } -static inline void *loader_platform_get_proc_address(loader_platform_dl_handle library, const char *name) { - assert(library); - assert(name); - return dlsym(library, name); -} -static inline const char *loader_platform_get_proc_address_error(const char *name) { return dlerror(); } - -// Threads: -typedef pthread_t loader_platform_thread; -#define THREAD_LOCAL_DECL __thread - -// The once init functionality is not used on Linux -#define LOADER_PLATFORM_THREAD_ONCE_DECLARATION(var) -#define LOADER_PLATFORM_THREAD_ONCE_DEFINITION(var) -#define LOADER_PLATFORM_THREAD_ONCE(ctl, func) - -// Thread IDs: -typedef pthread_t loader_platform_thread_id; -static inline loader_platform_thread_id loader_platform_get_thread_id() { return pthread_self(); } - -// Thread mutex: -typedef pthread_mutex_t loader_platform_thread_mutex; -static inline void loader_platform_thread_create_mutex(loader_platform_thread_mutex *pMutex) { pthread_mutex_init(pMutex, NULL); } -static inline void loader_platform_thread_lock_mutex(loader_platform_thread_mutex *pMutex) { pthread_mutex_lock(pMutex); } -static inline void loader_platform_thread_unlock_mutex(loader_platform_thread_mutex *pMutex) { pthread_mutex_unlock(pMutex); } -static inline void loader_platform_thread_delete_mutex(loader_platform_thread_mutex *pMutex) { pthread_mutex_destroy(pMutex); } -typedef pthread_cond_t loader_platform_thread_cond; -static inline void loader_platform_thread_init_cond(loader_platform_thread_cond *pCond) { pthread_cond_init(pCond, NULL); } -static inline void loader_platform_thread_cond_wait(loader_platform_thread_cond *pCond, loader_platform_thread_mutex *pMutex) { - pthread_cond_wait(pCond, pMutex); -} -static inline void loader_platform_thread_cond_broadcast(loader_platform_thread_cond *pCond) { pthread_cond_broadcast(pCond); } - -#define loader_stack_alloc(size) alloca(size) - -#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. -#ifdef CreateSemaphore -#undef CreateSemaphore -#endif -#ifdef CreateEvent -#undef CreateEvent -#endif -#include -#include -#include -#include -#include -#include -#ifdef __cplusplus -#include -#include -#endif // __cplusplus - -// VK Library Filenames, Paths, etc.: -#define PATH_SEPARATOR ';' -#define DIRECTORY_SYMBOL '\\' -#define DEFAULT_VK_REGISTRY_HIVE HKEY_LOCAL_MACHINE -#define DEFAULT_VK_REGISTRY_HIVE_STR "HKEY_LOCAL_MACHINE" -#define SECONDARY_VK_REGISTRY_HIVE HKEY_CURRENT_USER -#define SECONDARY_VK_REGISTRY_HIVE_STR "HKEY_CURRENT_USER" -#define DEFAULT_VK_DRIVERS_INFO "SOFTWARE\\Khronos\\" API_NAME "\\Drivers" -#define DEFAULT_VK_DRIVERS_PATH "" -#define DEFAULT_VK_ELAYERS_INFO "SOFTWARE\\Khronos\\" API_NAME "\\ExplicitLayers" -#define DEFAULT_VK_ILAYERS_INFO "SOFTWARE\\Khronos\\" API_NAME "\\ImplicitLayers" -#if !defined(DEFAULT_VK_LAYERS_PATH) -#define DEFAULT_VK_LAYERS_PATH "" -#endif -#if !defined(LAYERS_SOURCE_PATH) -#define LAYERS_SOURCE_PATH NULL -#endif -#define LAYERS_PATH_ENV "VK_LAYER_PATH" -#define ENABLED_LAYERS_ENV "VK_INSTANCE_LAYERS" -#define RELATIVE_VK_DRIVERS_INFO "" -#define RELATIVE_VK_ELAYERS_INFO "" -#define RELATIVE_VK_ILAYERS_INFO "" -#define PRINTF_SIZE_T_SPECIFIER "%Iu" - -#if defined(_WIN32) -// Get the key for the plug n play driver registry -// The string returned by this function should NOT be freed -static inline const char *LoaderPnpDriverRegistry() { - BOOL is_wow; - IsWow64Process(GetCurrentProcess(), &is_wow); - return is_wow ? (API_NAME "DriverNameWow") : (API_NAME "DriverName"); -} - -// Get the key for the plug 'n play explicit layer registry -// The string returned by this function should NOT be freed -static inline const char *LoaderPnpELayerRegistry() { - BOOL is_wow; - IsWow64Process(GetCurrentProcess(), &is_wow); - return is_wow ? (API_NAME "ExplicitLayersWow") : (API_NAME "ExplicitLayers"); -} -// Get the key for the plug 'n play implicit layer registry -// The string returned by this function should NOT be freed - -static inline const char *LoaderPnpILayerRegistry() { - BOOL is_wow; - IsWow64Process(GetCurrentProcess(), &is_wow); - return is_wow ? (API_NAME "ImplicitLayersWow") : (API_NAME "ImplicitLayers"); -} -#endif - -// File IO -static bool loader_platform_file_exists(const char *path) { - if ((_access(path, 0)) == -1) - return false; - else - return true; -} - -static bool loader_platform_is_path_absolute(const char *path) { return !PathIsRelative(path); } - -// WIN32 runtime doesn't have dirname(). -static inline char *loader_platform_dirname(char *path) { - char *current, *next; - - // TODO/TBD: Do we need to deal with the Windows's ":" character? - - for (current = path; *current != '\0'; current = next) { - next = strchr(current, DIRECTORY_SYMBOL); - if (next == NULL) { - if (current != path) *(current - 1) = '\0'; - return path; - } else { - // Point one character past the DIRECTORY_SYMBOL: - next++; - } - } - return path; -} - -// WIN32 runtime doesn't have basename(). -// Microsoft also doesn't have basename(). Paths are different on Windows, and -// so this is just a temporary solution in order to get us compiling, so that we -// can test some scenarios, and develop the correct solution for Windows. -// TODO: Develop a better, permanent solution for Windows, to replace this -// temporary code: -static char *loader_platform_basename(char *pathname) { - char *current, *next; - - // TODO/TBD: Do we need to deal with the Windows's ":" character? - - for (current = pathname; *current != '\0'; current = next) { - next = strchr(current, DIRECTORY_SYMBOL); - if (next == NULL) { - // No more DIRECTORY_SYMBOL's so return p: - return current; - } else { - // Point one character past the DIRECTORY_SYMBOL: - next++; - } - } - // We shouldn't get to here, but this makes the compiler happy: - return current; -} - -// Dynamic Loading: -typedef HMODULE loader_platform_dl_handle; -static loader_platform_dl_handle loader_platform_open_library(const char *lib_path) { - // Try loading the library the original way first. - loader_platform_dl_handle lib_handle = LoadLibrary(lib_path); - if (lib_handle == NULL && GetLastError() == ERROR_MOD_NOT_FOUND && PathFileExists(lib_path)) { - // If that failed, then try loading it with broader search folders. - lib_handle = LoadLibraryEx(lib_path, NULL, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS | LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR); - } - return lib_handle; -} -static char *loader_platform_open_library_error(const char *libPath) { - static char errorMsg[164]; - (void)snprintf(errorMsg, 163, "Failed to open dynamic library \"%s\" with error %lu", libPath, GetLastError()); - return errorMsg; -} -static void loader_platform_close_library(loader_platform_dl_handle library) { FreeLibrary(library); } -static void *loader_platform_get_proc_address(loader_platform_dl_handle library, const char *name) { - assert(library); - assert(name); - return GetProcAddress(library, name); -} -static char *loader_platform_get_proc_address_error(const char *name) { - static char errorMsg[120]; - (void)snprintf(errorMsg, 119, "Failed to find function \"%s\" in dynamic library", name); - return errorMsg; -} - -// Threads: -typedef HANDLE loader_platform_thread; -#define THREAD_LOCAL_DECL __declspec(thread) - -// The once init functionality is not used when building a DLL on Windows. This is because there is no way to clean up the -// resources allocated by anything allocated by once init. This isn't a problem for static libraries, but it is for dynamic -// ones. When building a DLL, we use DllMain() instead to allow properly cleaning up resources. -#if defined(LOADER_DYNAMIC_LIB) -#define LOADER_PLATFORM_THREAD_ONCE_DECLARATION(var) -#define LOADER_PLATFORM_THREAD_ONCE_DEFINITION(var) -#define LOADER_PLATFORM_THREAD_ONCE(ctl, func) -#else -#define LOADER_PLATFORM_THREAD_ONCE_DECLARATION(var) INIT_ONCE var = INIT_ONCE_STATIC_INIT; -#define LOADER_PLATFORM_THREAD_ONCE_DEFINITION(var) INIT_ONCE var; -#define LOADER_PLATFORM_THREAD_ONCE(ctl, func) loader_platform_thread_once_fn(ctl, func) -static BOOL CALLBACK InitFuncWrapper(PINIT_ONCE InitOnce, PVOID Parameter, PVOID *Context) { - void (*func)(void) = (void (*)(void))Parameter; - func(); - return TRUE; -} -static void loader_platform_thread_once_fn(void *ctl, void (*func)(void)) { - assert(func != NULL); - assert(ctl != NULL); - InitOnceExecuteOnce((PINIT_ONCE)ctl, InitFuncWrapper, func, NULL); -} -#endif - -// Thread IDs: -typedef DWORD loader_platform_thread_id; -static loader_platform_thread_id loader_platform_get_thread_id() { return GetCurrentThreadId(); } - -// Thread mutex: -typedef CRITICAL_SECTION loader_platform_thread_mutex; -static void loader_platform_thread_create_mutex(loader_platform_thread_mutex *pMutex) { InitializeCriticalSection(pMutex); } -static void loader_platform_thread_lock_mutex(loader_platform_thread_mutex *pMutex) { EnterCriticalSection(pMutex); } -static void loader_platform_thread_unlock_mutex(loader_platform_thread_mutex *pMutex) { LeaveCriticalSection(pMutex); } -static void loader_platform_thread_delete_mutex(loader_platform_thread_mutex *pMutex) { DeleteCriticalSection(pMutex); } -typedef CONDITION_VARIABLE loader_platform_thread_cond; -static void loader_platform_thread_init_cond(loader_platform_thread_cond *pCond) { InitializeConditionVariable(pCond); } -static void loader_platform_thread_cond_wait(loader_platform_thread_cond *pCond, loader_platform_thread_mutex *pMutex) { - SleepConditionVariableCS(pCond, pMutex, INFINITE); -} -static void loader_platform_thread_cond_broadcast(loader_platform_thread_cond *pCond) { WakeAllConditionVariable(pCond); } - -#define loader_stack_alloc(size) _alloca(size) -#else // defined(_WIN32) - -#error The "loader_platform.h" file must be modified for this OS. - -// NOTE: In order to support another OS, an #elif needs to be added (above the -// "#else // defined(_WIN32)") for that OS, and OS-specific versions of the -// contents of this file must be created. - -// 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) - -// returns true if the given string appears to be a relative or absolute -// path, as opposed to a bare filename. -static inline bool loader_platform_is_path(const char *path) { return strchr(path, DIRECTORY_SYMBOL) != NULL; } diff --git a/third_party/vulkan/loader/wsi.c b/third_party/vulkan/loader/wsi.c deleted file mode 100644 index 131ca5184..000000000 --- a/third_party/vulkan/loader/wsi.c +++ /dev/null @@ -1,1547 +0,0 @@ -/* - * Copyright (c) 2015-2016 The Khronos Group Inc. - * Copyright (c) 2015-2016 Valve Corporation - * Copyright (c) 2015-2016 LunarG, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Author: Ian Elliott - * Author: Jon Ashburn - * Author: Ian Elliott - * Author: Mark Lobodzinski - */ - -#define _GNU_SOURCE -#include -#include -#include -#include "vk_loader_platform.h" -#include "loader.h" -#include "wsi.h" -#include - -// The first ICD/Loader interface that support querying the SurfaceKHR from -// the ICDs. -#define ICD_VER_SUPPORTS_ICD_SURFACE_KHR 3 - -void wsi_create_instance(struct loader_instance *ptr_instance, const VkInstanceCreateInfo *pCreateInfo) { - ptr_instance->wsi_surface_enabled = false; - -#ifdef VK_USE_PLATFORM_WIN32_KHR - ptr_instance->wsi_win32_surface_enabled = false; -#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 -#ifdef VK_USE_PLATFORM_WAYLAND_KHR - ptr_instance->wsi_wayland_surface_enabled = false; -#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 -#ifdef VK_USE_PLATFORM_XLIB_KHR - ptr_instance->wsi_xlib_surface_enabled = false; -#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 - - ptr_instance->wsi_display_enabled = false; - - for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { - if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_SURFACE_EXTENSION_NAME) == 0) { - ptr_instance->wsi_surface_enabled = true; - continue; - } -#ifdef VK_USE_PLATFORM_WIN32_KHR - if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_WIN32_SURFACE_EXTENSION_NAME) == 0) { - ptr_instance->wsi_win32_surface_enabled = true; - continue; - } -#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 -#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 -#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 -#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 -#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 - if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_DISPLAY_EXTENSION_NAME) == 0) { - ptr_instance->wsi_display_enabled = true; - continue; - } - } -} - -// Linux WSI surface extensions are not always compiled into the loader. (Assume -// for Windows the KHR_win32_surface is always compiled into loader). A given -// Linux build environment might not have the headers required for building one -// of the four extensions (Xlib, Xcb, Mir, Wayland). Thus, need to check if -// the built loader actually supports the particular Linux surface extension. -// If not supported by the built loader it will not be included in the list of -// enumerated instance extensions. This solves the issue where an ICD or layer -// advertises support for a given Linux surface extension but the loader was not -// 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 -#ifndef 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 -#ifndef VK_USE_PLATFORM_XLIB_KHR - if (!strcmp(ext_prop->extensionName, "VK_KHR_xlib_surface")) return true; -#endif // VK_USE_PLATFORM_XLIB_KHR - - return false; -} - -// Functions for the VK_KHR_surface extension: - -// This is the trampoline entrypoint for DestroySurfaceKHR -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface, - const VkAllocationCallbacks *pAllocator) { - const VkLayerInstanceDispatchTable *disp; - disp = loader_get_instance_layer_dispatch(instance); - disp->DestroySurfaceKHR(instance, surface, pAllocator); -} - -// TODO probably need to lock around all the loader_get_instance() calls. - -// This is the instance chain terminator function for DestroySurfaceKHR -VKAPI_ATTR void VKAPI_CALL terminator_DestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface, - const VkAllocationCallbacks *pAllocator) { - struct loader_instance *ptr_instance = loader_get_instance(instance); - - VkIcdSurface *icd_surface = (VkIcdSurface *)(uintptr_t)surface; - if (NULL != icd_surface) { - if (NULL != icd_surface->real_icd_surfaces) { - uint32_t i = 0; - for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; icd_term != NULL; icd_term = icd_term->next, i++) { - if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) { - if (NULL != icd_term->dispatch.DestroySurfaceKHR && (VkSurfaceKHR)NULL != icd_surface->real_icd_surfaces[i]) { - icd_term->dispatch.DestroySurfaceKHR(icd_term->instance, icd_surface->real_icd_surfaces[i], pAllocator); - icd_surface->real_icd_surfaces[i] = (VkSurfaceKHR)NULL; - } - } else { - // The real_icd_surface for any ICD not supporting the - // proper interface version should be NULL. If not, then - // we have a problem. - assert((VkSurfaceKHR)NULL == icd_surface->real_icd_surfaces[i]); - } - } - loader_instance_heap_free(ptr_instance, icd_surface->real_icd_surfaces); - } - - loader_instance_heap_free(ptr_instance, (void *)(uintptr_t)surface); - } -} - -// This is the trampoline entrypoint for GetPhysicalDeviceSurfaceSupportKHR -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice physicalDevice, - uint32_t queueFamilyIndex, VkSurfaceKHR surface, - VkBool32 *pSupported) { - const VkLayerInstanceDispatchTable *disp; - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - VkResult res = disp->GetPhysicalDeviceSurfaceSupportKHR(unwrapped_phys_dev, queueFamilyIndex, surface, pSupported); - return res; -} - -// This is the instance chain terminator function for -// GetPhysicalDeviceSurfaceSupportKHR -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_surface extension not enabled. vkGetPhysicalDeviceSurfaceSupportKHR not executed!\n"); - return VK_SUCCESS; - } - - if (NULL == pSupported) { - loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "NULL pointer passed into vkGetPhysicalDeviceSurfaceSupportKHR for pSupported!\n"); - assert(false && "GetPhysicalDeviceSurfaceSupportKHR: Error, null pSupported"); - } - *pSupported = false; - - if (NULL == icd_term->dispatch.GetPhysicalDeviceSurfaceSupportKHR) { - loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "ICD for selected physical device is not exporting vkGetPhysicalDeviceSurfaceSupportKHR!\n"); - assert(false && "loader: null GetPhysicalDeviceSurfaceSupportKHR ICD pointer"); - } - - VkIcdSurface *icd_surface = (VkIcdSurface *)(uintptr_t)surface; - if (NULL != icd_surface->real_icd_surfaces && (VkSurfaceKHR)NULL != icd_surface->real_icd_surfaces[phys_dev_term->icd_index]) { - return icd_term->dispatch.GetPhysicalDeviceSurfaceSupportKHR( - phys_dev_term->phys_dev, queueFamilyIndex, icd_surface->real_icd_surfaces[phys_dev_term->icd_index], pSupported); - } - - return icd_term->dispatch.GetPhysicalDeviceSurfaceSupportKHR(phys_dev_term->phys_dev, queueFamilyIndex, surface, pSupported); -} - -// 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); - VkResult res = disp->GetPhysicalDeviceSurfaceCapabilitiesKHR(unwrapped_phys_dev, surface, pSurfaceCapabilities); - return res; -} - -// This is the instance chain terminator function for -// GetPhysicalDeviceSurfaceCapabilitiesKHR -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"); - return VK_SUCCESS; - } - - if (NULL == pSurfaceCapabilities) { - loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "NULL pointer passed into vkGetPhysicalDeviceSurfaceCapabilitiesKHR for pSurfaceCapabilities!\n"); - assert(false && "GetPhysicalDeviceSurfaceCapabilitiesKHR: Error, null pSurfaceCapabilities"); - } - - if (NULL == icd_term->dispatch.GetPhysicalDeviceSurfaceCapabilitiesKHR) { - loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "ICD for selected physical device is not exporting vkGetPhysicalDeviceSurfaceCapabilitiesKHR!\n"); - assert(false && "loader: null GetPhysicalDeviceSurfaceCapabilitiesKHR ICD pointer"); - } - - VkIcdSurface *icd_surface = (VkIcdSurface *)(uintptr_t)surface; - if (NULL != icd_surface->real_icd_surfaces && (VkSurfaceKHR)NULL != icd_surface->real_icd_surfaces[phys_dev_term->icd_index]) { - return icd_term->dispatch.GetPhysicalDeviceSurfaceCapabilitiesKHR( - phys_dev_term->phys_dev, icd_surface->real_icd_surfaces[phys_dev_term->icd_index], pSurfaceCapabilities); - } - - return icd_term->dispatch.GetPhysicalDeviceSurfaceCapabilitiesKHR(phys_dev_term->phys_dev, surface, pSurfaceCapabilities); -} - -// This is the trampoline entrypoint for GetPhysicalDeviceSurfaceFormatsKHR -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice, - VkSurfaceKHR surface, - uint32_t *pSurfaceFormatCount, - VkSurfaceFormatKHR *pSurfaceFormats) { - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - const VkLayerInstanceDispatchTable *disp; - disp = loader_get_instance_layer_dispatch(physicalDevice); - VkResult res = disp->GetPhysicalDeviceSurfaceFormatsKHR(unwrapped_phys_dev, surface, pSurfaceFormatCount, pSurfaceFormats); - return res; -} - -// This is the instance chain terminator function for -// GetPhysicalDeviceSurfaceFormatsKHR -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"); - return VK_SUCCESS; - } - - if (NULL == pSurfaceFormatCount) { - loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "NULL pointer passed into vkGetPhysicalDeviceSurfaceFormatsKHR for pSurfaceFormatCount!\n"); - assert(false && "GetPhysicalDeviceSurfaceFormatsKHR(: Error, null pSurfaceFormatCount"); - } - - if (NULL == icd_term->dispatch.GetPhysicalDeviceSurfaceFormatsKHR) { - loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "ICD for selected physical device is not exporting vkGetPhysicalDeviceSurfaceCapabilitiesKHR!\n"); - assert(false && "loader: null GetPhysicalDeviceSurfaceFormatsKHR ICD pointer"); - } - - VkIcdSurface *icd_surface = (VkIcdSurface *)(uintptr_t)surface; - if (NULL != icd_surface->real_icd_surfaces && (VkSurfaceKHR)NULL != icd_surface->real_icd_surfaces[phys_dev_term->icd_index]) { - return icd_term->dispatch.GetPhysicalDeviceSurfaceFormatsKHR(phys_dev_term->phys_dev, - icd_surface->real_icd_surfaces[phys_dev_term->icd_index], - pSurfaceFormatCount, pSurfaceFormats); - } - - return icd_term->dispatch.GetPhysicalDeviceSurfaceFormatsKHR(phys_dev_term->phys_dev, surface, pSurfaceFormatCount, - pSurfaceFormats); -} - -// This is the trampoline entrypoint for GetPhysicalDeviceSurfacePresentModesKHR -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice, - VkSurfaceKHR surface, - uint32_t *pPresentModeCount, - VkPresentModeKHR *pPresentModes) { - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - const VkLayerInstanceDispatchTable *disp; - disp = loader_get_instance_layer_dispatch(physicalDevice); - VkResult res = disp->GetPhysicalDeviceSurfacePresentModesKHR(unwrapped_phys_dev, surface, pPresentModeCount, pPresentModes); - return res; -} - -// This is the instance chain terminator function for -// GetPhysicalDeviceSurfacePresentModesKHR -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"); - return VK_SUCCESS; - } - - if (NULL == pPresentModeCount) { - loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "NULL pointer passed into vkGetPhysicalDeviceSurfacePresentModesKHR for pPresentModeCount!\n"); - assert(false && "GetPhysicalDeviceSurfacePresentModesKHR(: Error, null pPresentModeCount"); - } - - if (NULL == icd_term->dispatch.GetPhysicalDeviceSurfacePresentModesKHR) { - loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "ICD for selected physical device is not exporting vkGetPhysicalDeviceSurfacePresentModesKHR!\n"); - assert(false && "loader: null GetPhysicalDeviceSurfacePresentModesKHR ICD pointer"); - } - - VkIcdSurface *icd_surface = (VkIcdSurface *)(uintptr_t)surface; - if (NULL != icd_surface->real_icd_surfaces && (VkSurfaceKHR)NULL != icd_surface->real_icd_surfaces[phys_dev_term->icd_index]) { - return icd_term->dispatch.GetPhysicalDeviceSurfacePresentModesKHR( - phys_dev_term->phys_dev, icd_surface->real_icd_surfaces[phys_dev_term->icd_index], pPresentModeCount, pPresentModes); - } - - return icd_term->dispatch.GetPhysicalDeviceSurfacePresentModesKHR(phys_dev_term->phys_dev, surface, pPresentModeCount, - pPresentModes); -} - -// Functions for the VK_KHR_swapchain extension: - -// This is the trampoline entrypoint for CreateSwapchainKHR -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo, - const VkAllocationCallbacks *pAllocator, - VkSwapchainKHR *pSwapchain) { - const VkLayerDispatchTable *disp; - disp = loader_get_dispatch(device); - return disp->CreateSwapchainKHR(device, pCreateInfo, pAllocator, pSwapchain); -} - -VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo, - const VkAllocationCallbacks *pAllocator, - VkSwapchainKHR *pSwapchain) { - uint32_t icd_index = 0; - struct loader_device *dev; - struct loader_icd_term *icd_term = loader_get_icd_and_device(device, &dev, &icd_index); - if (NULL != icd_term && NULL != icd_term->dispatch.CreateSwapchainKHR) { - VkIcdSurface *icd_surface = (VkIcdSurface *)(uintptr_t)pCreateInfo->surface; - if (NULL != icd_surface->real_icd_surfaces) { - if ((VkSurfaceKHR)NULL != icd_surface->real_icd_surfaces[icd_index]) { - // We found the ICD, and there is an ICD KHR surface - // associated with it, so copy the CreateInfo struct - // and point it at the ICD's surface. - VkSwapchainCreateInfoKHR *pCreateCopy = loader_stack_alloc(sizeof(VkSwapchainCreateInfoKHR)); - if (NULL == pCreateCopy) { - return VK_ERROR_OUT_OF_HOST_MEMORY; - } - memcpy(pCreateCopy, pCreateInfo, sizeof(VkSwapchainCreateInfoKHR)); - pCreateCopy->surface = icd_surface->real_icd_surfaces[icd_index]; - return icd_term->dispatch.CreateSwapchainKHR(device, pCreateCopy, pAllocator, pSwapchain); - } - } - return icd_term->dispatch.CreateSwapchainKHR(device, pCreateInfo, pAllocator, pSwapchain); - } - return VK_SUCCESS; -} - -// This is the trampoline entrypoint for DestroySwapchainKHR -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain, - const VkAllocationCallbacks *pAllocator) { - const VkLayerDispatchTable *disp; - disp = loader_get_dispatch(device); - disp->DestroySwapchainKHR(device, swapchain, pAllocator); -} - -// This is the trampoline entrypoint for GetSwapchainImagesKHR -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain, - uint32_t *pSwapchainImageCount, VkImage *pSwapchainImages) { - const VkLayerDispatchTable *disp; - disp = loader_get_dispatch(device); - return disp->GetSwapchainImagesKHR(device, swapchain, pSwapchainImageCount, pSwapchainImages); -} - -// This is the trampoline entrypoint for AcquireNextImageKHR -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout, - VkSemaphore semaphore, VkFence fence, uint32_t *pImageIndex) { - const VkLayerDispatchTable *disp; - disp = loader_get_dispatch(device); - return disp->AcquireNextImageKHR(device, swapchain, timeout, semaphore, fence, pImageIndex); -} - -// This is the trampoline entrypoint for QueuePresentKHR -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) { - const VkLayerDispatchTable *disp; - disp = loader_get_dispatch(queue); - return disp->QueuePresentKHR(queue, pPresentInfo); -} - -static VkIcdSurface *AllocateIcdSurfaceStruct(struct loader_instance *instance, size_t base_size, size_t platform_size) { - // Next, if so, proceed with the implementation of this function: - VkIcdSurface *pIcdSurface = loader_instance_heap_alloc(instance, sizeof(VkIcdSurface), VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); - if (pIcdSurface != NULL) { - // Setup the new sizes and offsets so we can grow the structures in the - // future without having problems - pIcdSurface->base_size = (uint32_t)base_size; - pIcdSurface->platform_size = (uint32_t)platform_size; - pIcdSurface->non_platform_offset = (uint32_t)((uint8_t *)(&pIcdSurface->base_size) - (uint8_t *)pIcdSurface); - pIcdSurface->entire_size = sizeof(VkIcdSurface); - - pIcdSurface->real_icd_surfaces = loader_instance_heap_alloc(instance, sizeof(VkSurfaceKHR) * instance->total_icd_count, - VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); - if (pIcdSurface->real_icd_surfaces == NULL) { - loader_instance_heap_free(instance, pIcdSurface); - pIcdSurface = NULL; - } else { - memset(pIcdSurface->real_icd_surfaces, 0, sizeof(VkSurfaceKHR) * instance->total_icd_count); - } - } - return pIcdSurface; -} - -#ifdef VK_USE_PLATFORM_WIN32_KHR - -// Functions for the VK_KHR_win32_surface extension: - -// This is the trampoline entrypoint for CreateWin32SurfaceKHR -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateWin32SurfaceKHR(VkInstance instance, - const VkWin32SurfaceCreateInfoKHR *pCreateInfo, - const VkAllocationCallbacks *pAllocator, - VkSurfaceKHR *pSurface) { - const VkLayerInstanceDispatchTable *disp; - disp = loader_get_instance_layer_dispatch(instance); - VkResult res; - - res = disp->CreateWin32SurfaceKHR(instance, pCreateInfo, pAllocator, pSurface); - return res; -} - -// This is the instance chain terminator function for CreateWin32SurfaceKHR -VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateWin32SurfaceKHR(VkInstance instance, const VkWin32SurfaceCreateInfoKHR *pCreateInfo, - const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { - VkResult vkRes = VK_SUCCESS; - VkIcdSurface *pIcdSurface = NULL; - uint32_t i = 0; - - // Initialize pSurface to NULL just to be safe. - *pSurface = VK_NULL_HANDLE; - // 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"); - vkRes = VK_ERROR_EXTENSION_NOT_PRESENT; - goto out; - } - - // Next, if so, proceed with the implementation of this function: - pIcdSurface = AllocateIcdSurfaceStruct(ptr_instance, sizeof(pIcdSurface->win_surf.base), sizeof(pIcdSurface->win_surf)); - if (pIcdSurface == NULL) { - vkRes = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - - pIcdSurface->win_surf.base.platform = VK_ICD_WSI_PLATFORM_WIN32; - pIcdSurface->win_surf.hinstance = pCreateInfo->hinstance; - pIcdSurface->win_surf.hwnd = pCreateInfo->hwnd; - - // Loop through each ICD and determine if they need to create a surface - for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; icd_term != NULL; icd_term = icd_term->next, i++) { - if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) { - if (NULL != icd_term->dispatch.CreateWin32SurfaceKHR) { - vkRes = icd_term->dispatch.CreateWin32SurfaceKHR(icd_term->instance, pCreateInfo, pAllocator, - &pIcdSurface->real_icd_surfaces[i]); - if (VK_SUCCESS != vkRes) { - goto out; - } - } - } - } - - *pSurface = (VkSurfaceKHR)(pIcdSurface); - -out: - - if (VK_SUCCESS != vkRes && NULL != pIcdSurface) { - if (NULL != pIcdSurface->real_icd_surfaces) { - i = 0; - for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; icd_term != NULL; icd_term = icd_term->next, i++) { - if ((VkSurfaceKHR)NULL != pIcdSurface->real_icd_surfaces[i] && NULL != icd_term->dispatch.DestroySurfaceKHR) { - icd_term->dispatch.DestroySurfaceKHR(icd_term->instance, pIcdSurface->real_icd_surfaces[i], pAllocator); - } - } - loader_instance_heap_free(ptr_instance, pIcdSurface->real_icd_surfaces); - } - loader_instance_heap_free(ptr_instance, pIcdSurface); - } - - return vkRes; -} - -// This is the trampoline entrypoint for -// GetPhysicalDeviceWin32PresentationSupportKHR -LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceWin32PresentationSupportKHR(VkPhysicalDevice physicalDevice, - uint32_t queueFamilyIndex) { - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - const VkLayerInstanceDispatchTable *disp; - disp = loader_get_instance_layer_dispatch(physicalDevice); - VkBool32 res = disp->GetPhysicalDeviceWin32PresentationSupportKHR(unwrapped_phys_dev, queueFamilyIndex); - return res; -} - -// This is the instance chain terminator function for -// GetPhysicalDeviceWin32PresentationSupportKHR -VKAPI_ATTR VkBool32 VKAPI_CALL terminator_GetPhysicalDeviceWin32PresentationSupportKHR(VkPhysicalDevice physicalDevice, - uint32_t queueFamilyIndex) { - // 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_win32_surface_enabled) { - loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "VK_KHR_win32_surface extension not enabled. vkGetPhysicalDeviceWin32PresentationSupportKHR not executed!\n"); - return VK_SUCCESS; - } - - if (NULL == icd_term->dispatch.GetPhysicalDeviceWin32PresentationSupportKHR) { - loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "ICD for selected physical device is not exporting vkGetPhysicalDeviceWin32PresentationSupportKHR!\n"); - assert(false && "loader: null GetPhysicalDeviceWin32PresentationSupportKHR ICD pointer"); - } - - return icd_term->dispatch.GetPhysicalDeviceWin32PresentationSupportKHR(phys_dev_term->phys_dev, queueFamilyIndex); -} -#endif // VK_USE_PLATFORM_WIN32_KHR - -#ifdef VK_USE_PLATFORM_MIR_KHR - -// Functions for the VK_KHR_mir_surface extension: - -// This is the trampoline entrypoint for CreateMirSurfaceKHR -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateMirSurfaceKHR(VkInstance instance, - const VkMirSurfaceCreateInfoKHR *pCreateInfo, - const VkAllocationCallbacks *pAllocator, - VkSurfaceKHR *pSurface) { - const VkLayerInstanceDispatchTable *disp; - disp = loader_get_instance_layer_dispatch(instance); - VkResult res; - - res = disp->CreateMirSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface); - return res; -} - -// This is the instance chain terminator function for CreateMirSurfaceKHR -VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateMirSurfaceKHR(VkInstance instance, const VkMirSurfaceCreateInfoKHR *pCreateInfo, - const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { - VkResult vkRes = VK_SUCCESS; - VkIcdSurface *pIcdSurface = NULL; - uint32_t i = 0; - - // 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"); - vkRes = VK_ERROR_EXTENSION_NOT_PRESENT; - goto out; - } - - // Next, if so, proceed with the implementation of this function: - pIcdSurface = AllocateIcdSurfaceStruct(ptr_instance, sizeof(pIcdSurface->mir_surf.base), sizeof(pIcdSurface->mir_surf)); - if (pIcdSurface == NULL) { - vkRes = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - - pIcdSurface->mir_surf.base.platform = VK_ICD_WSI_PLATFORM_MIR; - pIcdSurface->mir_surf.connection = pCreateInfo->connection; - pIcdSurface->mir_surf.mirSurface = pCreateInfo->mirSurface; - - // Loop through each ICD and determine if they need to create a surface - for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; icd_term != NULL; icd_term = icd_term->next, i++) { - if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) { - if (NULL != icd_term->dispatch.CreateMirSurfaceKHR) { - vkRes = icd_term->dispatch.CreateMirSurfaceKHR(icd_term->instance, pCreateInfo, pAllocator, - &pIcdSurface->real_icd_surfaces[i]); - if (VK_SUCCESS != vkRes) { - goto out; - } - } - } - } - - *pSurface = (VkSurfaceKHR)pIcdSurface; - -out: - - if (VK_SUCCESS != vkRes && NULL != pIcdSurface) { - if (NULL != pIcdSurface->real_icd_surfaces) { - i = 0; - for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; icd_term != NULL; icd_term = icd_term->next, i++) { - if ((VkSurfaceKHR)NULL != pIcdSurface->real_icd_surfaces[i] && NULL != icd_term->dispatch.DestroySurfaceKHR) { - icd_term->dispatch.DestroySurfaceKHR(icd_term->instance, pIcdSurface->real_icd_surfaces[i], pAllocator); - } - } - loader_instance_heap_free(ptr_instance, pIcdSurface->real_icd_surfaces); - } - loader_instance_heap_free(ptr_instance, pIcdSurface); - } - - return vkRes; -} - -// This is the trampoline entrypoint for -// GetPhysicalDeviceMirPresentationSupportKHR -LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceMirPresentationSupportKHR(VkPhysicalDevice physicalDevice, - uint32_t queueFamilyIndex, - MirConnection *connection) { - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - const VkLayerInstanceDispatchTable *disp; - disp = loader_get_instance_layer_dispatch(physicalDevice); - VkBool32 res = disp->GetPhysicalDeviceMirPresentationSupportKHR(unwrapped_phys_dev, queueFamilyIndex, connection); - return res; -} - -// This is the instance chain terminator function for -// GetPhysicalDeviceMirPresentationSupportKHR -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"); - return VK_SUCCESS; - } - - if (NULL == icd_term->dispatch.GetPhysicalDeviceMirPresentationSupportKHR) { - loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "ICD for selected physical device is not exporting vkGetPhysicalDeviceMirPresentationSupportKHR!\n"); - assert(false && "loader: null GetPhysicalDeviceMirPresentationSupportKHR ICD pointer"); - } - - return icd_term->dispatch.GetPhysicalDeviceMirPresentationSupportKHR(phys_dev_term->phys_dev, queueFamilyIndex, connection); -} -#endif // VK_USE_PLATFORM_MIR_KHR - -#ifdef VK_USE_PLATFORM_WAYLAND_KHR - -// This is the trampoline entrypoint for CreateWaylandSurfaceKHR -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateWaylandSurfaceKHR(VkInstance instance, - const VkWaylandSurfaceCreateInfoKHR *pCreateInfo, - const VkAllocationCallbacks *pAllocator, - VkSurfaceKHR *pSurface) { - const VkLayerInstanceDispatchTable *disp; - disp = loader_get_instance_layer_dispatch(instance); - VkResult res; - - res = disp->CreateWaylandSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface); - return res; -} - -// This is the instance chain terminator function for CreateWaylandSurfaceKHR -VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateWaylandSurfaceKHR(VkInstance instance, - const VkWaylandSurfaceCreateInfoKHR *pCreateInfo, - const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { - VkResult vkRes = VK_SUCCESS; - VkIcdSurface *pIcdSurface = NULL; - uint32_t i = 0; - - // 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"); - vkRes = VK_ERROR_EXTENSION_NOT_PRESENT; - goto out; - } - - // Next, if so, proceed with the implementation of this function: - pIcdSurface = AllocateIcdSurfaceStruct(ptr_instance, sizeof(pIcdSurface->wayland_surf.base), sizeof(pIcdSurface->wayland_surf)); - if (pIcdSurface == NULL) { - vkRes = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - - pIcdSurface->wayland_surf.base.platform = VK_ICD_WSI_PLATFORM_WAYLAND; - pIcdSurface->wayland_surf.display = pCreateInfo->display; - pIcdSurface->wayland_surf.surface = pCreateInfo->surface; - - // Loop through each ICD and determine if they need to create a surface - for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; icd_term != NULL; icd_term = icd_term->next, i++) { - if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) { - if (NULL != icd_term->dispatch.CreateWaylandSurfaceKHR) { - vkRes = icd_term->dispatch.CreateWaylandSurfaceKHR(icd_term->instance, pCreateInfo, pAllocator, - &pIcdSurface->real_icd_surfaces[i]); - if (VK_SUCCESS != vkRes) { - goto out; - } - } - } - } - - *pSurface = (VkSurfaceKHR)pIcdSurface; - -out: - - if (VK_SUCCESS != vkRes && NULL != pIcdSurface) { - if (NULL != pIcdSurface->real_icd_surfaces) { - i = 0; - for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; icd_term != NULL; icd_term = icd_term->next, i++) { - if ((VkSurfaceKHR)NULL != pIcdSurface->real_icd_surfaces[i] && NULL != icd_term->dispatch.DestroySurfaceKHR) { - icd_term->dispatch.DestroySurfaceKHR(icd_term->instance, pIcdSurface->real_icd_surfaces[i], pAllocator); - } - } - loader_instance_heap_free(ptr_instance, pIcdSurface->real_icd_surfaces); - } - loader_instance_heap_free(ptr_instance, pIcdSurface); - } - - return vkRes; -} - -// This is the trampoline entrypoint for -// GetPhysicalDeviceWaylandPresentationSupportKHR -LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceWaylandPresentationSupportKHR(VkPhysicalDevice physicalDevice, - uint32_t queueFamilyIndex, - struct wl_display *display) { - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - const VkLayerInstanceDispatchTable *disp; - disp = loader_get_instance_layer_dispatch(physicalDevice); - VkBool32 res = disp->GetPhysicalDeviceWaylandPresentationSupportKHR(unwrapped_phys_dev, queueFamilyIndex, display); - return res; -} - -// This is the instance chain terminator function for -// GetPhysicalDeviceWaylandPresentationSupportKHR -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; - struct loader_instance *ptr_instance = (struct loader_instance *)icd_term->this_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. vkGetPhysicalDeviceWaylandPresentationSupportKHR not executed!\n"); - return VK_SUCCESS; - } - - if (NULL == icd_term->dispatch.GetPhysicalDeviceWaylandPresentationSupportKHR) { - loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "ICD for selected physical device is not exporting vkGetPhysicalDeviceWaylandPresentationSupportKHR!\n"); - assert(false && "loader: null GetPhysicalDeviceWaylandPresentationSupportKHR ICD pointer"); - } - - return icd_term->dispatch.GetPhysicalDeviceWaylandPresentationSupportKHR(phys_dev_term->phys_dev, queueFamilyIndex, display); -} -#endif // VK_USE_PLATFORM_WAYLAND_KHR - -#ifdef VK_USE_PLATFORM_XCB_KHR - -// Functions for the VK_KHR_xcb_surface extension: - -// This is the trampoline entrypoint for CreateXcbSurfaceKHR -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateXcbSurfaceKHR(VkInstance instance, - const VkXcbSurfaceCreateInfoKHR *pCreateInfo, - const VkAllocationCallbacks *pAllocator, - VkSurfaceKHR *pSurface) { - const VkLayerInstanceDispatchTable *disp; - disp = loader_get_instance_layer_dispatch(instance); - VkResult res; - - res = disp->CreateXcbSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface); - return res; -} - -// This is the instance chain terminator function for CreateXcbSurfaceKHR -VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateXcbSurfaceKHR(VkInstance instance, const VkXcbSurfaceCreateInfoKHR *pCreateInfo, - const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { - VkResult vkRes = VK_SUCCESS; - VkIcdSurface *pIcdSurface = NULL; - uint32_t i = 0; - - // 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"); - vkRes = VK_ERROR_EXTENSION_NOT_PRESENT; - goto out; - } - - // Next, if so, proceed with the implementation of this function: - pIcdSurface = AllocateIcdSurfaceStruct(ptr_instance, sizeof(pIcdSurface->xcb_surf.base), sizeof(pIcdSurface->xcb_surf)); - if (pIcdSurface == NULL) { - vkRes = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - - pIcdSurface->xcb_surf.base.platform = VK_ICD_WSI_PLATFORM_XCB; - pIcdSurface->xcb_surf.connection = pCreateInfo->connection; - pIcdSurface->xcb_surf.window = pCreateInfo->window; - - // Loop through each ICD and determine if they need to create a surface - for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; icd_term != NULL; icd_term = icd_term->next, i++) { - if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) { - if (NULL != icd_term->dispatch.CreateXcbSurfaceKHR) { - vkRes = icd_term->dispatch.CreateXcbSurfaceKHR(icd_term->instance, pCreateInfo, pAllocator, - &pIcdSurface->real_icd_surfaces[i]); - if (VK_SUCCESS != vkRes) { - goto out; - } - } - } - } - - *pSurface = (VkSurfaceKHR)pIcdSurface; - -out: - - if (VK_SUCCESS != vkRes && NULL != pIcdSurface) { - if (NULL != pIcdSurface->real_icd_surfaces) { - i = 0; - for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; icd_term != NULL; icd_term = icd_term->next, i++) { - if ((VkSurfaceKHR)NULL != pIcdSurface->real_icd_surfaces[i] && NULL != icd_term->dispatch.DestroySurfaceKHR) { - icd_term->dispatch.DestroySurfaceKHR(icd_term->instance, pIcdSurface->real_icd_surfaces[i], pAllocator); - } - } - loader_instance_heap_free(ptr_instance, pIcdSurface->real_icd_surfaces); - } - loader_instance_heap_free(ptr_instance, pIcdSurface); - } - - return vkRes; -} - -// This is the trampoline entrypoint for -// GetPhysicalDeviceXcbPresentationSupportKHR -LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceXcbPresentationSupportKHR(VkPhysicalDevice physicalDevice, - uint32_t queueFamilyIndex, - xcb_connection_t *connection, - xcb_visualid_t visual_id) { - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - const VkLayerInstanceDispatchTable *disp; - disp = loader_get_instance_layer_dispatch(physicalDevice); - VkBool32 res = disp->GetPhysicalDeviceXcbPresentationSupportKHR(unwrapped_phys_dev, queueFamilyIndex, connection, visual_id); - return res; -} - -// This is the instance chain terminator function for -// GetPhysicalDeviceXcbPresentationSupportKHR -VKAPI_ATTR VkBool32 VKAPI_CALL terminator_GetPhysicalDeviceXcbPresentationSupportKHR(VkPhysicalDevice physicalDevice, - 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"); - return VK_SUCCESS; - } - - if (NULL == icd_term->dispatch.GetPhysicalDeviceXcbPresentationSupportKHR) { - loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "ICD for selected physical device is not exporting vkGetPhysicalDeviceXcbPresentationSupportKHR!\n"); - assert(false && "loader: null GetPhysicalDeviceXcbPresentationSupportKHR ICD pointer"); - } - - return icd_term->dispatch.GetPhysicalDeviceXcbPresentationSupportKHR(phys_dev_term->phys_dev, queueFamilyIndex, connection, - visual_id); -} -#endif // VK_USE_PLATFORM_XCB_KHR - -#ifdef VK_USE_PLATFORM_XLIB_KHR - -// Functions for the VK_KHR_xlib_surface extension: - -// This is the trampoline entrypoint for CreateXlibSurfaceKHR -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateXlibSurfaceKHR(VkInstance instance, - const VkXlibSurfaceCreateInfoKHR *pCreateInfo, - const VkAllocationCallbacks *pAllocator, - VkSurfaceKHR *pSurface) { - const VkLayerInstanceDispatchTable *disp; - disp = loader_get_instance_layer_dispatch(instance); - VkResult res; - - res = disp->CreateXlibSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface); - return res; -} - -// This is the instance chain terminator function for CreateXlibSurfaceKHR -VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateXlibSurfaceKHR(VkInstance instance, const VkXlibSurfaceCreateInfoKHR *pCreateInfo, - const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { - VkResult vkRes = VK_SUCCESS; - VkIcdSurface *pIcdSurface = NULL; - uint32_t i = 0; - - // 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"); - vkRes = VK_ERROR_EXTENSION_NOT_PRESENT; - goto out; - } - - // Next, if so, proceed with the implementation of this function: - pIcdSurface = AllocateIcdSurfaceStruct(ptr_instance, sizeof(pIcdSurface->xlib_surf.base), sizeof(pIcdSurface->xlib_surf)); - if (pIcdSurface == NULL) { - vkRes = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - - pIcdSurface->xlib_surf.base.platform = VK_ICD_WSI_PLATFORM_XLIB; - pIcdSurface->xlib_surf.dpy = pCreateInfo->dpy; - pIcdSurface->xlib_surf.window = pCreateInfo->window; - - // Loop through each ICD and determine if they need to create a surface - for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; icd_term != NULL; icd_term = icd_term->next, i++) { - if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) { - if (NULL != icd_term->dispatch.CreateXlibSurfaceKHR) { - vkRes = icd_term->dispatch.CreateXlibSurfaceKHR(icd_term->instance, pCreateInfo, pAllocator, - &pIcdSurface->real_icd_surfaces[i]); - if (VK_SUCCESS != vkRes) { - goto out; - } - } - } - } - - *pSurface = (VkSurfaceKHR)pIcdSurface; - -out: - - if (VK_SUCCESS != vkRes && NULL != pIcdSurface) { - if (NULL != pIcdSurface->real_icd_surfaces) { - i = 0; - for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; icd_term != NULL; icd_term = icd_term->next, i++) { - if ((VkSurfaceKHR)NULL != pIcdSurface->real_icd_surfaces[i] && NULL != icd_term->dispatch.DestroySurfaceKHR) { - icd_term->dispatch.DestroySurfaceKHR(icd_term->instance, pIcdSurface->real_icd_surfaces[i], pAllocator); - } - } - loader_instance_heap_free(ptr_instance, pIcdSurface->real_icd_surfaces); - } - loader_instance_heap_free(ptr_instance, pIcdSurface); - } - - return vkRes; -} - -// This is the trampoline entrypoint for -// GetPhysicalDeviceXlibPresentationSupportKHR -LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceXlibPresentationSupportKHR(VkPhysicalDevice physicalDevice, - uint32_t queueFamilyIndex, Display *dpy, - VisualID visualID) { - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - const VkLayerInstanceDispatchTable *disp; - disp = loader_get_instance_layer_dispatch(physicalDevice); - VkBool32 res = disp->GetPhysicalDeviceXlibPresentationSupportKHR(unwrapped_phys_dev, queueFamilyIndex, dpy, visualID); - return res; -} - -// This is the instance chain terminator function for -// GetPhysicalDeviceXlibPresentationSupportKHR -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"); - return VK_SUCCESS; - } - - if (NULL == icd_term->dispatch.GetPhysicalDeviceXlibPresentationSupportKHR) { - loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "ICD for selected physical device is not exporting vkGetPhysicalDeviceXlibPresentationSupportKHR!\n"); - assert(false && "loader: null GetPhysicalDeviceXlibPresentationSupportKHR ICD pointer"); - } - - return icd_term->dispatch.GetPhysicalDeviceXlibPresentationSupportKHR(phys_dev_term->phys_dev, queueFamilyIndex, dpy, visualID); -} -#endif // VK_USE_PLATFORM_XLIB_KHR - -#ifdef VK_USE_PLATFORM_ANDROID_KHR - -// Functions for the VK_KHR_android_surface extension: - -// This is the trampoline entrypoint for CreateAndroidSurfaceKHR -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateAndroidSurfaceKHR(VkInstance instance, ANativeWindow *window, - const VkAllocationCallbacks *pAllocator, - VkSurfaceKHR *pSurface) { - const VkLayerInstanceDispatchTable *disp; - disp = loader_get_instance_layer_dispatch(instance); - VkResult res; - - res = disp->CreateAndroidSurfaceKHR(instance, window, pAllocator, pSurface); - return res; -} - -// This is the instance chain terminator function for CreateAndroidSurfaceKHR -VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateAndroidSurfaceKHR(VkInstance instance, Window window, - const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { - // 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"); - return VK_ERROR_EXTENSION_NOT_PRESENT; - } - - // Next, if so, proceed with the implementation of this function: - VkIcdSurfaceAndroid *pIcdSurface = - loader_instance_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceAndroid), VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); - if (pIcdSurface == NULL) { - return VK_ERROR_OUT_OF_HOST_MEMORY; - } - - pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_ANDROID; - pIcdSurface->dpy = dpy; - pIcdSurface->window = window; - - *pSurface = (VkSurfaceKHR)pIcdSurface; - - return VK_SUCCESS; -} - -#endif // VK_USE_PLATFORM_ANDROID_KHR - -// Functions for the VK_KHR_display instance extension: -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physicalDevice, - uint32_t *pPropertyCount, - VkDisplayPropertiesKHR *pProperties) { - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - const VkLayerInstanceDispatchTable *disp; - disp = loader_get_instance_layer_dispatch(physicalDevice); - VkResult res = disp->GetPhysicalDeviceDisplayPropertiesKHR(unwrapped_phys_dev, pPropertyCount, pProperties); - return res; -} - -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"); - return VK_SUCCESS; - } - - if (NULL == icd_term->dispatch.GetPhysicalDeviceDisplayPropertiesKHR) { - loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "ICD for selected physical device is not exporting vkGetPhysicalDeviceDisplayPropertiesKHR!\n"); - assert(false && "loader: null GetPhysicalDeviceDisplayPropertiesKHR ICD pointer"); - } - - return icd_term->dispatch.GetPhysicalDeviceDisplayPropertiesKHR(phys_dev_term->phys_dev, pPropertyCount, pProperties); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceDisplayPlanePropertiesKHR( - VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount, VkDisplayPlanePropertiesKHR *pProperties) { - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - const VkLayerInstanceDispatchTable *disp; - disp = loader_get_instance_layer_dispatch(physicalDevice); - VkResult res = disp->GetPhysicalDeviceDisplayPlanePropertiesKHR(unwrapped_phys_dev, pPropertyCount, pProperties); - return res; -} - -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"); - return VK_SUCCESS; - } - - if (NULL == icd_term->dispatch.GetPhysicalDeviceDisplayPlanePropertiesKHR) { - loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "ICD for selected physical device is not exporting vkGetPhysicalDeviceDisplayPlanePropertiesKHR!\n"); - assert(false && "loader: null GetPhysicalDeviceDisplayPlanePropertiesKHR ICD pointer"); - } - - return icd_term->dispatch.GetPhysicalDeviceDisplayPlanePropertiesKHR(phys_dev_term->phys_dev, pPropertyCount, pProperties); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physicalDevice, - uint32_t planeIndex, uint32_t *pDisplayCount, - VkDisplayKHR *pDisplays) { - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - const VkLayerInstanceDispatchTable *disp; - disp = loader_get_instance_layer_dispatch(physicalDevice); - VkResult res = disp->GetDisplayPlaneSupportedDisplaysKHR(unwrapped_phys_dev, planeIndex, pDisplayCount, pDisplays); - return res; -} - -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"); - return VK_SUCCESS; - } - - if (NULL == icd_term->dispatch.GetDisplayPlaneSupportedDisplaysKHR) { - loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "ICD for selected physical device is not exporting vkGetDisplayPlaneSupportedDisplaysKHR!\n"); - assert(false && "loader: null GetDisplayPlaneSupportedDisplaysKHR ICD pointer"); - } - - return icd_term->dispatch.GetDisplayPlaneSupportedDisplaysKHR(phys_dev_term->phys_dev, planeIndex, pDisplayCount, pDisplays); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetDisplayModePropertiesKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, - uint32_t *pPropertyCount, - VkDisplayModePropertiesKHR *pProperties) { - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - const VkLayerInstanceDispatchTable *disp; - disp = loader_get_instance_layer_dispatch(physicalDevice); - VkResult res = disp->GetDisplayModePropertiesKHR(unwrapped_phys_dev, display, pPropertyCount, pProperties); - return res; -} - -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"); - return VK_SUCCESS; - } - - if (NULL == icd_term->dispatch.GetDisplayModePropertiesKHR) { - loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "ICD for selected physical device is not exporting vkGetDisplayModePropertiesKHR!\n"); - assert(false && "loader: null GetDisplayModePropertiesKHR ICD pointer"); - } - - return icd_term->dispatch.GetDisplayModePropertiesKHR(phys_dev_term->phys_dev, display, pPropertyCount, pProperties); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, - const VkDisplayModeCreateInfoKHR *pCreateInfo, - const VkAllocationCallbacks *pAllocator, - VkDisplayModeKHR *pMode) { - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - const VkLayerInstanceDispatchTable *disp; - disp = loader_get_instance_layer_dispatch(physicalDevice); - VkResult res = disp->CreateDisplayModeKHR(unwrapped_phys_dev, display, pCreateInfo, pAllocator, pMode); - return res; -} - -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"); - return VK_ERROR_EXTENSION_NOT_PRESENT; - } - - if (NULL == icd_term->dispatch.CreateDisplayModeKHR) { - loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "ICD for selected physical device is not exporting vkCreateDisplayModeKHR!\n"); - assert(false && "loader: null CreateDisplayModeKHR ICD pointer"); - } - - return icd_term->dispatch.CreateDisplayModeKHR(phys_dev_term->phys_dev, display, pCreateInfo, pAllocator, pMode); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetDisplayPlaneCapabilitiesKHR(VkPhysicalDevice physicalDevice, - VkDisplayModeKHR mode, uint32_t planeIndex, - VkDisplayPlaneCapabilitiesKHR *pCapabilities) { - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - const VkLayerInstanceDispatchTable *disp; - disp = loader_get_instance_layer_dispatch(physicalDevice); - VkResult res = disp->GetDisplayPlaneCapabilitiesKHR(unwrapped_phys_dev, mode, planeIndex, pCapabilities); - return res; -} - -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"); - return VK_SUCCESS; - } - - if (NULL == icd_term->dispatch.GetDisplayPlaneCapabilitiesKHR) { - loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "ICD for selected physical device is not exporting vkGetDisplayPlaneCapabilitiesKHR!\n"); - assert(false && "loader: null GetDisplayPlaneCapabilitiesKHR ICD pointer"); - } - - return icd_term->dispatch.GetDisplayPlaneCapabilitiesKHR(phys_dev_term->phys_dev, mode, planeIndex, pCapabilities); -} - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDisplayPlaneSurfaceKHR(VkInstance instance, - const VkDisplaySurfaceCreateInfoKHR *pCreateInfo, - const VkAllocationCallbacks *pAllocator, - VkSurfaceKHR *pSurface) { - const VkLayerInstanceDispatchTable *disp; - disp = loader_get_instance_layer_dispatch(instance); - VkResult res; - - res = disp->CreateDisplayPlaneSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface); - return res; -} - -VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDisplayPlaneSurfaceKHR(VkInstance instance, - const VkDisplaySurfaceCreateInfoKHR *pCreateInfo, - const VkAllocationCallbacks *pAllocator, - VkSurfaceKHR *pSurface) { - struct loader_instance *inst = loader_get_instance(instance); - VkIcdSurface *pIcdSurface = NULL; - VkResult vkRes = VK_SUCCESS; - 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"); - vkRes = VK_ERROR_EXTENSION_NOT_PRESENT; - goto out; - } - - // Next, if so, proceed with the implementation of this function: - pIcdSurface = AllocateIcdSurfaceStruct(inst, sizeof(pIcdSurface->display_surf.base), sizeof(pIcdSurface->display_surf)); - if (pIcdSurface == NULL) { - vkRes = VK_ERROR_OUT_OF_HOST_MEMORY; - goto out; - } - - pIcdSurface->display_surf.base.platform = VK_ICD_WSI_PLATFORM_DISPLAY; - pIcdSurface->display_surf.displayMode = pCreateInfo->displayMode; - pIcdSurface->display_surf.planeIndex = pCreateInfo->planeIndex; - pIcdSurface->display_surf.planeStackIndex = pCreateInfo->planeStackIndex; - pIcdSurface->display_surf.transform = pCreateInfo->transform; - pIcdSurface->display_surf.globalAlpha = pCreateInfo->globalAlpha; - pIcdSurface->display_surf.alphaMode = pCreateInfo->alphaMode; - pIcdSurface->display_surf.imageExtent = pCreateInfo->imageExtent; - - // Loop through each ICD and determine if they need to create a surface - for (struct loader_icd_term *icd_term = inst->icd_terms; icd_term != NULL; icd_term = icd_term->next, i++) { - if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) { - if (NULL != icd_term->dispatch.CreateDisplayPlaneSurfaceKHR) { - vkRes = icd_term->dispatch.CreateDisplayPlaneSurfaceKHR(icd_term->instance, pCreateInfo, pAllocator, - &pIcdSurface->real_icd_surfaces[i]); - if (VK_SUCCESS != vkRes) { - goto out; - } - } - } - } - - *pSurface = (VkSurfaceKHR)pIcdSurface; - -out: - - if (VK_SUCCESS != vkRes && NULL != pIcdSurface) { - if (NULL != pIcdSurface->real_icd_surfaces) { - i = 0; - for (struct loader_icd_term *icd_term = inst->icd_terms; icd_term != NULL; icd_term = icd_term->next, i++) { - if ((VkSurfaceKHR)NULL != pIcdSurface->real_icd_surfaces[i] && NULL != icd_term->dispatch.DestroySurfaceKHR) { - icd_term->dispatch.DestroySurfaceKHR(icd_term->instance, pIcdSurface->real_icd_surfaces[i], pAllocator); - } - } - loader_instance_heap_free(inst, pIcdSurface->real_icd_surfaces); - } - loader_instance_heap_free(inst, pIcdSurface); - } - - return vkRes; -} - -// EXT_display_swapchain Extension command - -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount, - const VkSwapchainCreateInfoKHR *pCreateInfos, - const VkAllocationCallbacks *pAllocator, - VkSwapchainKHR *pSwapchains) { - const VkLayerDispatchTable *disp; - disp = loader_get_dispatch(device); - return disp->CreateSharedSwapchainsKHR(device, swapchainCount, pCreateInfos, pAllocator, pSwapchains); -} - -VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount, - const VkSwapchainCreateInfoKHR *pCreateInfos, - const VkAllocationCallbacks *pAllocator, - VkSwapchainKHR *pSwapchains) { - uint32_t icd_index = 0; - struct loader_device *dev; - struct loader_icd_term *icd_term = loader_get_icd_and_device(device, &dev, &icd_index); - if (NULL != icd_term && NULL != icd_term->dispatch.CreateSharedSwapchainsKHR) { - VkIcdSurface *icd_surface = (VkIcdSurface *)(uintptr_t)pCreateInfos->surface; - if (NULL != icd_surface->real_icd_surfaces) { - if ((VkSurfaceKHR)NULL != icd_surface->real_icd_surfaces[icd_index]) { - // We found the ICD, and there is an ICD KHR surface - // associated with it, so copy the CreateInfo struct - // and point it at the ICD's surface. - VkSwapchainCreateInfoKHR *pCreateCopy = loader_stack_alloc(sizeof(VkSwapchainCreateInfoKHR) * swapchainCount); - if (NULL == pCreateCopy) { - return VK_ERROR_OUT_OF_HOST_MEMORY; - } - memcpy(pCreateCopy, pCreateInfos, sizeof(VkSwapchainCreateInfoKHR) * swapchainCount); - for (uint32_t sc = 0; sc < swapchainCount; sc++) { - pCreateCopy[sc].surface = icd_surface->real_icd_surfaces[icd_index]; - } - return icd_term->dispatch.CreateSharedSwapchainsKHR(device, swapchainCount, pCreateCopy, pAllocator, pSwapchains); - } - } - return icd_term->dispatch.CreateSharedSwapchainsKHR(device, swapchainCount, pCreateInfos, pAllocator, pSwapchains); - } - return VK_SUCCESS; -} - -bool wsi_swapchain_instance_gpa(struct loader_instance *ptr_instance, const char *name, void **addr) { - *addr = NULL; - - // Functions for the VK_KHR_surface extension: - if (!strcmp("vkDestroySurfaceKHR", name)) { - *addr = ptr_instance->wsi_surface_enabled ? (void *)vkDestroySurfaceKHR : NULL; - return true; - } - if (!strcmp("vkGetPhysicalDeviceSurfaceSupportKHR", name)) { - *addr = ptr_instance->wsi_surface_enabled ? (void *)vkGetPhysicalDeviceSurfaceSupportKHR : NULL; - return true; - } - if (!strcmp("vkGetPhysicalDeviceSurfaceCapabilitiesKHR", name)) { - *addr = ptr_instance->wsi_surface_enabled ? (void *)vkGetPhysicalDeviceSurfaceCapabilitiesKHR : NULL; - return true; - } - if (!strcmp("vkGetPhysicalDeviceSurfaceFormatsKHR", name)) { - *addr = ptr_instance->wsi_surface_enabled ? (void *)vkGetPhysicalDeviceSurfaceFormatsKHR : NULL; - return true; - } - if (!strcmp("vkGetPhysicalDeviceSurfacePresentModesKHR", name)) { - *addr = ptr_instance->wsi_surface_enabled ? (void *)vkGetPhysicalDeviceSurfacePresentModesKHR : NULL; - return true; - } - - // Functions for the VK_KHR_swapchain extension: - - // Note: This is a device extension, and its functions are statically - // exported from the loader. Per Khronos decisions, the loader's GIPA - // function will return the trampoline function for such device-extension - // functions, regardless of whether the extension has been enabled. - if (!strcmp("vkCreateSwapchainKHR", name)) { - *addr = (void *)vkCreateSwapchainKHR; - return true; - } - if (!strcmp("vkDestroySwapchainKHR", name)) { - *addr = (void *)vkDestroySwapchainKHR; - return true; - } - if (!strcmp("vkGetSwapchainImagesKHR", name)) { - *addr = (void *)vkGetSwapchainImagesKHR; - return true; - } - if (!strcmp("vkAcquireNextImageKHR", name)) { - *addr = (void *)vkAcquireNextImageKHR; - return true; - } - if (!strcmp("vkQueuePresentKHR", name)) { - *addr = (void *)vkQueuePresentKHR; - return true; - } - -#ifdef VK_USE_PLATFORM_WIN32_KHR - - // Functions for the VK_KHR_win32_surface extension: - if (!strcmp("vkCreateWin32SurfaceKHR", name)) { - *addr = ptr_instance->wsi_win32_surface_enabled ? (void *)vkCreateWin32SurfaceKHR : NULL; - return true; - } - if (!strcmp("vkGetPhysicalDeviceWin32PresentationSupportKHR", name)) { - *addr = ptr_instance->wsi_win32_surface_enabled ? (void *)vkGetPhysicalDeviceWin32PresentationSupportKHR : NULL; - return true; - } -#endif // VK_USE_PLATFORM_WIN32_KHR -#ifdef VK_USE_PLATFORM_MIR_KHR - - // Functions for the VK_KHR_mir_surface extension: - if (!strcmp("vkCreateMirSurfaceKHR", name)) { - *addr = ptr_instance->wsi_mir_surface_enabled ? (void *)vkCreateMirSurfaceKHR : NULL; - return true; - } - if (!strcmp("vkGetPhysicalDeviceMirPresentationSupportKHR", name)) { - *addr = ptr_instance->wsi_mir_surface_enabled ? (void *)vkGetPhysicalDeviceMirPresentationSupportKHR : NULL; - return true; - } -#endif // VK_USE_PLATFORM_MIR_KHR -#ifdef VK_USE_PLATFORM_WAYLAND_KHR - - // Functions for the VK_KHR_wayland_surface extension: - if (!strcmp("vkCreateWaylandSurfaceKHR", name)) { - *addr = ptr_instance->wsi_wayland_surface_enabled ? (void *)vkCreateWaylandSurfaceKHR : NULL; - return true; - } - if (!strcmp("vkGetPhysicalDeviceWaylandPresentationSupportKHR", name)) { - *addr = ptr_instance->wsi_wayland_surface_enabled ? (void *)vkGetPhysicalDeviceWaylandPresentationSupportKHR : NULL; - return true; - } -#endif // VK_USE_PLATFORM_WAYLAND_KHR -#ifdef VK_USE_PLATFORM_XCB_KHR - - // Functions for the VK_KHR_xcb_surface extension: - if (!strcmp("vkCreateXcbSurfaceKHR", name)) { - *addr = ptr_instance->wsi_xcb_surface_enabled ? (void *)vkCreateXcbSurfaceKHR : NULL; - return true; - } - if (!strcmp("vkGetPhysicalDeviceXcbPresentationSupportKHR", name)) { - *addr = ptr_instance->wsi_xcb_surface_enabled ? (void *)vkGetPhysicalDeviceXcbPresentationSupportKHR : NULL; - return true; - } -#endif // VK_USE_PLATFORM_XCB_KHR -#ifdef VK_USE_PLATFORM_XLIB_KHR - - // Functions for the VK_KHR_xlib_surface extension: - if (!strcmp("vkCreateXlibSurfaceKHR", name)) { - *addr = ptr_instance->wsi_xlib_surface_enabled ? (void *)vkCreateXlibSurfaceKHR : NULL; - return true; - } - if (!strcmp("vkGetPhysicalDeviceXlibPresentationSupportKHR", name)) { - *addr = ptr_instance->wsi_xlib_surface_enabled ? (void *)vkGetPhysicalDeviceXlibPresentationSupportKHR : NULL; - return true; - } -#endif // VK_USE_PLATFORM_XLIB_KHR -#ifdef VK_USE_PLATFORM_ANDROID_KHR - - // Functions for the VK_KHR_android_surface extension: - if (!strcmp("vkCreateAndroidSurfaceKHR", name)) { - *addr = ptr_instance->wsi_xlib_surface_enabled ? (void *)vkCreateAndroidSurfaceKHR : NULL; - return true; - } -#endif // VK_USE_PLATFORM_ANDROID_KHR - - // Functions for VK_KHR_display extension: - if (!strcmp("vkGetPhysicalDeviceDisplayPropertiesKHR", name)) { - *addr = ptr_instance->wsi_display_enabled ? (void *)vkGetPhysicalDeviceDisplayPropertiesKHR : NULL; - return true; - } - if (!strcmp("vkGetPhysicalDeviceDisplayPlanePropertiesKHR", name)) { - *addr = ptr_instance->wsi_display_enabled ? (void *)vkGetPhysicalDeviceDisplayPlanePropertiesKHR : NULL; - return true; - } - if (!strcmp("vkGetDisplayPlaneSupportedDisplaysKHR", name)) { - *addr = ptr_instance->wsi_display_enabled ? (void *)vkGetDisplayPlaneSupportedDisplaysKHR : NULL; - return true; - } - if (!strcmp("vkGetDisplayModePropertiesKHR", name)) { - *addr = ptr_instance->wsi_display_enabled ? (void *)vkGetDisplayModePropertiesKHR : NULL; - return true; - } - if (!strcmp("vkCreateDisplayModeKHR", name)) { - *addr = ptr_instance->wsi_display_enabled ? (void *)vkCreateDisplayModeKHR : NULL; - return true; - } - if (!strcmp("vkGetDisplayPlaneCapabilitiesKHR", name)) { - *addr = ptr_instance->wsi_display_enabled ? (void *)vkGetDisplayPlaneCapabilitiesKHR : NULL; - return true; - } - if (!strcmp("vkCreateDisplayPlaneSurfaceKHR", name)) { - *addr = ptr_instance->wsi_display_enabled ? (void *)vkCreateDisplayPlaneSurfaceKHR : NULL; - return true; - } - - // Functions for KHR_display_swapchain extension: - if (!strcmp("vkCreateSharedSwapchainsKHR", name)) { - *addr = (void *)vkCreateSharedSwapchainsKHR; - return true; - } - - return false; -} diff --git a/third_party/vulkan/loader/wsi.h b/third_party/vulkan/loader/wsi.h deleted file mode 100644 index 519a7aacc..000000000 --- a/third_party/vulkan/loader/wsi.h +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (c) 2015-2016 The Khronos Group Inc. - * Copyright (c) 2015-2016 Valve Corporation - * Copyright (c) 2015-2016 LunarG, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Author: Ian Elliott - * - */ - -#ifndef WSI_H -#define WSI_H - -#include "vk_loader_platform.h" -#include "loader.h" - -typedef struct { - union { -#ifdef VK_USE_PLATFORM_MIR_KHR - VkIcdSurfaceMir mir_surf; -#endif // VK_USE_PLATFORM_MIR_KHR -#ifdef VK_USE_PLATFORM_WAYLAND_KHR - VkIcdSurfaceWayland wayland_surf; -#endif // VK_USE_PLATFORM_WAYLAND_KHR -#ifdef VK_USE_PLATFORM_WIN32_KHR - VkIcdSurfaceWin32 win_surf; -#endif // VK_USE_PLATFORM_WIN32_KHR -#ifdef VK_USE_PLATFORM_XCB_KHR - VkIcdSurfaceXcb xcb_surf; -#endif // VK_USE_PLATFORM_XCB_KHR -#ifdef VK_USE_PLATFORM_XLIB_KHR - VkIcdSurfaceXlib xlib_surf; -#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 - VkSurfaceKHR *real_icd_surfaces; -} VkIcdSurface; - -bool wsi_swapchain_instance_gpa(struct loader_instance *ptr_instance, const char *name, void **addr); - -void wsi_create_instance(struct loader_instance *ptr_instance, const VkInstanceCreateInfo *pCreateInfo); -bool wsi_unsupported_instance_extension(const VkExtensionProperties *ext_prop); - -VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo, - const VkAllocationCallbacks *pAllocator, VkSwapchainKHR *pSwapchain); - -VKAPI_ATTR void VKAPI_CALL terminator_DestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface, - const VkAllocationCallbacks *pAllocator); - -VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice physicalDevice, - uint32_t queueFamilyIndex, VkSurfaceKHR surface, - VkBool32 *pSupported); - -VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceCapabilitiesKHR(VkPhysicalDevice physicalDevice, - VkSurfaceKHR surface, - VkSurfaceCapabilitiesKHR *pSurfaceCapabilities); - -VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, - uint32_t *pSurfaceFormatCount, - VkSurfaceFormatKHR *pSurfaceFormats); - -VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice, - VkSurfaceKHR surface, uint32_t *pPresentModeCount, - VkPresentModeKHR *pPresentModes); - -#ifdef VK_USE_PLATFORM_WIN32_KHR -VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateWin32SurfaceKHR(VkInstance instance, const VkWin32SurfaceCreateInfoKHR *pCreateInfo, - const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface); -VKAPI_ATTR VkBool32 VKAPI_CALL terminator_GetPhysicalDeviceWin32PresentationSupportKHR(VkPhysicalDevice physicalDevice, - uint32_t queueFamilyIndex); -#endif -#ifdef VK_USE_PLATFORM_MIR_KHR -VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateMirSurfaceKHR(VkInstance instance, const VkMirSurfaceCreateInfoKHR *pCreateInfo, - const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface); -VKAPI_ATTR VkBool32 VKAPI_CALL terminator_GetPhysicalDeviceMirPresentationSupportKHR(VkPhysicalDevice physicalDevice, - uint32_t queueFamilyIndex, - MirConnection *connection); -#endif -#ifdef VK_USE_PLATFORM_WAYLAND_KHR -VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateWaylandSurfaceKHR(VkInstance instance, - const VkWaylandSurfaceCreateInfoKHR *pCreateInfo, - const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface); -VKAPI_ATTR VkBool32 VKAPI_CALL terminator_GetPhysicalDeviceWaylandPresentationSupportKHR(VkPhysicalDevice physicalDevice, - uint32_t queueFamilyIndex, - struct wl_display *display); -#endif -#ifdef VK_USE_PLATFORM_XCB_KHR -VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateXcbSurfaceKHR(VkInstance instance, const VkXcbSurfaceCreateInfoKHR *pCreateInfo, - const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface); - -VKAPI_ATTR VkBool32 VKAPI_CALL terminator_GetPhysicalDeviceXcbPresentationSupportKHR(VkPhysicalDevice physicalDevice, - uint32_t queueFamilyIndex, - xcb_connection_t *connection, - xcb_visualid_t visual_id); -#endif -#ifdef VK_USE_PLATFORM_XLIB_KHR -VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateXlibSurfaceKHR(VkInstance instance, const VkXlibSurfaceCreateInfoKHR *pCreateInfo, - const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface); -VKAPI_ATTR VkBool32 VKAPI_CALL terminator_GetPhysicalDeviceXlibPresentationSupportKHR(VkPhysicalDevice physicalDevice, - uint32_t queueFamilyIndex, Display *dpy, - VisualID visualID); -#endif -VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physicalDevice, - uint32_t *pPropertyCount, - VkDisplayPropertiesKHR *pProperties); -VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceDisplayPlanePropertiesKHR(VkPhysicalDevice physicalDevice, - uint32_t *pPropertyCount, - VkDisplayPlanePropertiesKHR *pProperties); -VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physicalDevice, uint32_t planeIndex, - uint32_t *pDisplayCount, VkDisplayKHR *pDisplays); -VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDisplayModePropertiesKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, - uint32_t *pPropertyCount, - VkDisplayModePropertiesKHR *pProperties); -VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, - const VkDisplayModeCreateInfoKHR *pCreateInfo, - const VkAllocationCallbacks *pAllocator, VkDisplayModeKHR *pMode); -VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDisplayPlaneCapabilitiesKHR(VkPhysicalDevice physicalDevice, VkDisplayModeKHR mode, - uint32_t planeIndex, - VkDisplayPlaneCapabilitiesKHR *pCapabilities); -VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDisplayPlaneSurfaceKHR(VkInstance instance, - const VkDisplaySurfaceCreateInfoKHR *pCreateInfo, - const VkAllocationCallbacks *pAllocator, - VkSurfaceKHR *pSurface); - -VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount, - const VkSwapchainCreateInfoKHR *pCreateInfos, - const VkAllocationCallbacks *pAllocator, - VkSwapchainKHR *pSwapchains); - -#endif // WSI_H