Initial vulkan context and immediate drawer.

Extremely rough, just checking in so DrChat can snoop.
This commit is contained in:
Ben Vanik
2016-02-17 17:42:25 -08:00
parent d52d2c4837
commit 9f52f2e819
64 changed files with 24379 additions and 935 deletions

1358
third_party/vulkan/loader/cJSON.c vendored Normal file

File diff suppressed because it is too large Load Diff

189
third_party/vulkan/loader/cJSON.h vendored Normal file
View File

@@ -0,0 +1,189 @@
/*
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);
/* 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

319
third_party/vulkan/loader/debug_report.c vendored Normal file
View File

@@ -0,0 +1,319 @@
/*
* 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.
*
* 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.
*
* Author: Courtney Goeltzenleuchter <courtney@LunarG.com>
* Author: Jon Ashburn <jon@LunarG.com>
*
*/
#define _GNU_SOURCE
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <inttypes.h>
#ifndef WIN32
#include <signal.h>
#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->debug_report_enabled = false;
for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
VK_EXT_DEBUG_REPORT_EXTENSION_NAME) == 0) {
ptr_instance->debug_report_enabled = true;
return;
}
}
}
VkResult
util_CreateDebugReportCallback(struct loader_instance *inst,
VkDebugReportCallbackCreateInfoEXT *pCreateInfo,
const VkAllocationCallbacks *pAllocator,
VkDebugReportCallbackEXT callback) {
VkLayerDbgFunctionNode *pNewDbgFuncNode;
if (pAllocator != NULL) {
pNewDbgFuncNode = (VkLayerDbgFunctionNode *)pAllocator->pfnAllocation(
pAllocator->pUserData, sizeof(VkLayerDbgFunctionNode),
sizeof(int *), VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
} else {
pNewDbgFuncNode = (VkLayerDbgFunctionNode *)loader_heap_alloc(
inst, sizeof(VkLayerDbgFunctionNode),
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
}
if (!pNewDbgFuncNode)
return VK_ERROR_OUT_OF_HOST_MEMORY;
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_CreateDebugReportCallback(
VkInstance instance, VkDebugReportCallbackCreateInfoEXT *pCreateInfo,
VkAllocationCallbacks *pAllocator, VkDebugReportCallbackEXT *pCallback) {
struct loader_instance *inst = loader_get_instance(instance);
loader_platform_thread_lock_mutex(&loader_lock);
VkResult result = inst->disp->CreateDebugReportCallbackEXT(
instance, pCreateInfo, pAllocator, pCallback);
if (result == VK_SUCCESS) {
result = util_CreateDebugReportCallback(inst, 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 (pAllocator != NULL) {
pAllocator->pfnFree(pAllocator->pUserData, pTrav);
} else {
loader_heap_free(inst, pTrav);
}
break;
}
pPrev = pTrav;
pTrav = pTrav->pNext;
}
}
static VKAPI_ATTR void VKAPI_CALL
debug_report_DestroyDebugReportCallback(VkInstance instance,
VkDebugReportCallbackEXT callback,
VkAllocationCallbacks *pAllocator) {
struct loader_instance *inst = loader_get_instance(instance);
loader_platform_thread_lock_mutex(&loader_lock);
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_DebugReportMessage(
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->DebugReportMessageEXT(instance, flags, objType, object,
location, msgCode, pLayerPrefix, pMsg);
}
/*
* This is the instance chain terminator function
* for CreateDebugReportCallback
*/
VKAPI_ATTR VkResult VKAPI_CALL loader_CreateDebugReportCallback(
VkInstance instance, const VkDebugReportCallbackCreateInfoEXT *pCreateInfo,
const VkAllocationCallbacks *pAllocator,
VkDebugReportCallbackEXT *pCallback) {
VkDebugReportCallbackEXT *icd_info;
const struct loader_icd *icd;
struct loader_instance *inst = (struct loader_instance *)instance;
VkResult res;
uint32_t storage_idx;
icd_info = calloc(sizeof(VkDebugReportCallbackEXT), inst->total_icd_count);
if (!icd_info) {
return VK_ERROR_OUT_OF_HOST_MEMORY;
}
storage_idx = 0;
for (icd = inst->icds; icd; icd = icd->next) {
if (!icd->CreateDebugReportCallbackEXT) {
continue;
}
res = icd->CreateDebugReportCallbackEXT(
icd->instance, pCreateInfo, pAllocator, &icd_info[storage_idx]);
if (res != VK_SUCCESS) {
break;
}
storage_idx++;
}
/* roll back on errors */
if (icd) {
storage_idx = 0;
for (icd = inst->icds; icd; icd = icd->next) {
if (icd_info[storage_idx]) {
icd->DestroyDebugReportCallbackEXT(
icd->instance, icd_info[storage_idx], pAllocator);
}
storage_idx++;
}
return res;
}
*(VkDebugReportCallbackEXT **)pCallback = icd_info;
return VK_SUCCESS;
}
/*
* This is the instance chain terminator function
* for DestroyDebugReportCallback
*/
VKAPI_ATTR void VKAPI_CALL
loader_DestroyDebugReportCallback(VkInstance instance,
VkDebugReportCallbackEXT callback,
const VkAllocationCallbacks *pAllocator) {
uint32_t storage_idx;
VkDebugReportCallbackEXT *icd_info;
const struct loader_icd *icd;
struct loader_instance *inst = (struct loader_instance *)instance;
icd_info = *(VkDebugReportCallbackEXT **)&callback;
storage_idx = 0;
for (icd = inst->icds; icd; icd = icd->next) {
if (icd_info[storage_idx]) {
icd->DestroyDebugReportCallbackEXT(
icd->instance, icd_info[storage_idx], pAllocator);
}
storage_idx++;
}
}
/*
* This is the instance chain terminator function
* for DebugReportMessage
*/
VKAPI_ATTR void VKAPI_CALL
loader_DebugReportMessage(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 *icd;
struct loader_instance *inst = (struct loader_instance *)instance;
loader_platform_thread_lock_mutex(&loader_lock);
for (icd = inst->icds; icd; icd = icd->next) {
if (icd->DebugReportMessageEXT != NULL) {
icd->DebugReportMessageEXT(icd->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->debug_report_enabled
? (void *)debug_report_CreateDebugReportCallback
: NULL;
return true;
}
if (!strcmp("vkDestroyDebugReportCallbackEXT", name)) {
*addr = ptr_instance->debug_report_enabled
? (void *)debug_report_DestroyDebugReportCallback
: NULL;
return true;
}
if (!strcmp("vkDebugReportMessageEXT", name)) {
*addr = ptr_instance->debug_report_enabled
? (void *)debug_report_DebugReportMessage
: NULL;
return true;
}
return false;
}

150
third_party/vulkan/loader/debug_report.h vendored Normal file
View File

@@ -0,0 +1,150 @@
/*
* 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.
*
* 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.
*
* Author: Courtney Goeltzenleuchter <courtney@LunarG.com>
* Author: Jon Ashburn <jon@lunarg.com>
*
*/
#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 loader_CreateDebugReportCallback(
VkInstance instance, const VkDebugReportCallbackCreateInfoEXT *pCreateInfo,
const VkAllocationCallbacks *pAllocator,
VkDebugReportCallbackEXT *pCallback);
VKAPI_ATTR void VKAPI_CALL
loader_DestroyDebugReportCallback(VkInstance instance,
VkDebugReportCallbackEXT callback,
const VkAllocationCallbacks *pAllocator);
VKAPI_ATTR void VKAPI_CALL
loader_DebugReportMessage(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);
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);

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,130 @@
/*
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 <errno.h>
#include <io.h> /* _findfirst and _findnext set errno iff they return -1 */
#include <stdlib.h>
#include <string.h>
#include "vk_loader_platform.h"
#include "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_tls_heap_alloc(sizeof *dir)) != 0 &&
(dir->name = (char *)loader_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_tls_heap_free(dir->name);
loader_tls_heap_free(dir);
dir = 0;
}
} else /* rollback */
{
loader_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_tls_heap_free(dir->name);
loader_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.
*/

View File

@@ -0,0 +1,51 @@
#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

379
third_party/vulkan/loader/gpa_helper.h vendored Normal file
View File

@@ -0,0 +1,379 @@
/*
*
* Copyright (c) 2015 The Khronos Group Inc.
* Copyright (c) 2015 Valve Corporation
* Copyright (c) 2015 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.
*
* Author: Jon Ashburn <jon@lunarg.com>
*/
#include <string.h>
#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;
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;
}
/* These functions require special handling by the loader.
* They are not just generic trampoline code entrypoints.
* Thus GPA must return loader entrypoint for these instead of first function
* in the chain. */
static inline void *loader_non_passthrough_gipa(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, "DestroyInstance"))
return (void *)vkDestroyInstance;
if (!strcmp(name, "GetDeviceProcAddr"))
return (void *)vkGetDeviceProcAddr;
// remove once no longer locks
if (!strcmp(name, "EnumeratePhysicalDevices"))
return (void *)vkEnumeratePhysicalDevices;
if (!strcmp(name, "EnumerateDeviceExtensionProperties"))
return (void *)vkEnumerateDeviceExtensionProperties;
if (!strcmp(name, "EnumerateDeviceLayerProperties"))
return (void *)vkEnumerateDeviceLayerProperties;
if (!strcmp(name, "GetInstanceProcAddr"))
return (void *)vkGetInstanceProcAddr;
if (!strcmp(name, "CreateDevice"))
return (void *)vkCreateDevice;
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;
}

4504
third_party/vulkan/loader/loader.c vendored Normal file

File diff suppressed because it is too large Load Diff

551
third_party/vulkan/loader/loader.h vendored Normal file
View File

@@ -0,0 +1,551 @@
/*
*
* Copyright (c) 2014-2016 The Khronos Group Inc.
* Copyright (c) 2014-2016 Valve Corporation
* Copyright (c) 2014-2016 LunarG, Inc.
* Copyright (C) 2015 Google 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.
*
* Author: Jon Ashburn <jon@lunarg.com>
* Author: Courtney Goeltzenleuchter <courtney@LunarG.com>
* Author: Chia-I Wu <olvaffe@gmail.com>
* Author: Chia-I Wu <olv@lunarg.com>
* Author: Mark Lobodzinski <mark@LunarG.com>
*
*/
#ifndef LOADER_H
#define LOADER_H
#include <vulkan/vulkan.h>
#include <vk_loader_platform.h>
#include <vulkan/vk_layer.h>
#include <vulkan/vk_icd.h>
#include <assert.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
#define MAX_STRING_SIZE 1024
#define VK_MAJOR(version) (version >> 22)
#define VK_MINOR(version) ((version >> 12) & 0x3ff)
#define VK_PATCH(version) (version & 0xfff)
enum layer_type {
VK_LAYER_TYPE_DEVICE_EXPLICIT = 0x1,
VK_LAYER_TYPE_INSTANCE_EXPLICIT = 0x2,
VK_LAYER_TYPE_GLOBAL_EXPLICIT = 0x3, // instance and device layer, bitwise
VK_LAYER_TYPE_DEVICE_IMPLICIT = 0x4,
VK_LAYER_TYPE_INSTANCE_IMPLICIT = 0x8,
VK_LAYER_TYPE_GLOBAL_IMPLICIT = 0xc, // instance and device layer, bitwise
VK_LAYER_TYPE_META_EXPLICT = 0x10,
};
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;
static const char std_validation_names[9][VK_MAX_EXTENSION_NAME_SIZE] = {
"VK_LAYER_LUNARG_threading", "VK_LAYER_LUNARG_param_checker",
"VK_LAYER_LUNARG_device_limits", "VK_LAYER_LUNARG_object_tracker",
"VK_LAYER_LUNARG_image", "VK_LAYER_LUNARG_mem_tracker",
"VK_LAYER_LUNARG_draw_state", "VK_LAYER_LUNARG_swapchain",
"VK_LAYER_GOOGLE_unique_objects"};
// 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_lib_info {
char lib_name[MAX_STRING_SIZE];
uint32_t ref_count;
loader_platform_dl_handle lib_handle;
};
struct loader_layer_functions {
char str_gipa[MAX_STRING_SIZE];
char str_gdpa[MAX_STRING_SIZE];
PFN_vkGetInstanceProcAddr get_instance_proc_addr;
PFN_vkGetDeviceProcAddr get_device_proc_addr;
};
struct loader_layer_properties {
VkLayerProperties info;
enum layer_type type;
char lib_name[MAX_STRING_SIZE];
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;
};
struct loader_layer_list {
size_t capacity;
uint32_t count;
struct loader_layer_properties *list;
};
struct loader_layer_library_list {
size_t capacity;
uint32_t count;
struct loader_lib_info *list;
};
struct loader_dispatch_hash_list {
size_t capacity;
uint32_t count;
uint32_t *index; // index into the dev_ext dispatch table
};
#define MAX_NUM_DEV_EXTS 250
// loader_dispatch_hash_entry and loader_dev_ext_dispatch_table.DevExt have one
// to one
// correspondence; one loader_dispatch_hash_entry for one DevExt 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 DevExt[MAX_NUM_DEV_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 device; // device object from the icd
uint32_t app_extension_count;
VkExtensionProperties *app_extension_props;
struct loader_layer_list activated_layer_list;
struct loader_device *next;
};
/* per ICD structure */
struct loader_icd {
// pointers to find other structs
const struct loader_scanned_icds *this_icd_lib;
const struct loader_instance *this_instance;
struct loader_device *logical_device_list;
VkInstance instance; // instance object from the icd
PFN_vkGetDeviceProcAddr GetDeviceProcAddr;
PFN_vkDestroyInstance DestroyInstance;
PFN_vkEnumeratePhysicalDevices EnumeratePhysicalDevices;
PFN_vkGetPhysicalDeviceFeatures GetPhysicalDeviceFeatures;
PFN_vkGetPhysicalDeviceFormatProperties GetPhysicalDeviceFormatProperties;
PFN_vkGetPhysicalDeviceImageFormatProperties
GetPhysicalDeviceImageFormatProperties;
PFN_vkCreateDevice CreateDevice;
PFN_vkGetPhysicalDeviceProperties GetPhysicalDeviceProperties;
PFN_vkGetPhysicalDeviceQueueFamilyProperties
GetPhysicalDeviceQueueFamilyProperties;
PFN_vkGetPhysicalDeviceMemoryProperties GetPhysicalDeviceMemoryProperties;
PFN_vkEnumerateDeviceExtensionProperties EnumerateDeviceExtensionProperties;
PFN_vkGetPhysicalDeviceSparseImageFormatProperties
GetPhysicalDeviceSparseImageFormatProperties;
PFN_vkCreateDebugReportCallbackEXT CreateDebugReportCallbackEXT;
PFN_vkDestroyDebugReportCallbackEXT DestroyDebugReportCallbackEXT;
PFN_vkDebugReportMessageEXT DebugReportMessageEXT;
PFN_vkGetPhysicalDeviceSurfaceSupportKHR GetPhysicalDeviceSurfaceSupportKHR;
PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR
GetPhysicalDeviceSurfaceCapabilitiesKHR;
PFN_vkGetPhysicalDeviceSurfaceFormatsKHR GetPhysicalDeviceSurfaceFormatsKHR;
PFN_vkGetPhysicalDeviceSurfacePresentModesKHR
GetPhysicalDeviceSurfacePresentModesKHR;
#ifdef VK_USE_PLATFORM_WIN32_KHR
PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR
GetPhysicalDeviceWin32PresentationSupportKHR;
#endif
#ifdef VK_USE_PLATFORM_MIR_KHR
PFN_vkGetPhysicalDeviceMirPresentationSupportKHR
GetPhysicalDeviceMirPresentvationSupportKHR;
#endif
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR
GetPhysicalDeviceWaylandPresentationSupportKHR;
#endif
#ifdef VK_USE_PLATFORM_XCB_KHR
PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR
GetPhysicalDeviceXcbPresentationSupportKHR;
#endif
#ifdef VK_USE_PLATFORM_XLIB_KHR
PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR
GetPhysicalDeviceXlibPresentationSupportKHR;
#endif
struct loader_icd *next;
};
/* per ICD library structure */
struct loader_icd_libs {
size_t capacity;
uint32_t count;
struct loader_scanned_icds *list;
};
/* per instance structure */
struct loader_instance {
VkLayerInstanceDispatchTable *disp; // must be first entry in structure
uint32_t total_gpu_count;
struct loader_physical_device *phys_devs;
uint32_t total_icd_count;
struct loader_icd *icds;
struct loader_instance *next;
struct loader_extension_list ext_list; // icds and loaders extensions
struct loader_icd_libs icd_libs;
struct loader_layer_list instance_layer_list;
struct loader_layer_list device_layer_list;
struct loader_dispatch_hash_entry disp_hash[MAX_NUM_DEV_EXTS];
struct loader_msg_callback_map_entry *icd_msg_callback_map;
struct loader_layer_list activated_layer_list;
VkInstance instance;
bool debug_report_enabled;
VkLayerDbgFunctionNode *DbgFunctionHead;
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
};
/* per enumerated PhysicalDevice structure */
struct loader_physical_device {
VkLayerInstanceDispatchTable *disp; // must be first entry in structure
struct loader_instance *this_instance;
struct loader_icd *this_icd;
VkPhysicalDevice phys_dev; // object from ICD
/*
* Fill in the cache of available device extensions from
* this physical device. This cache can be used during CreateDevice
*/
struct loader_extension_list device_extension_cache;
};
struct loader_struct {
struct loader_instance *instances;
unsigned int loaded_layer_lib_count;
size_t loaded_layer_lib_capacity;
struct loader_lib_info *loaded_layer_lib_list;
// TODO add ref counting of ICD libraries
// TODO use this struct loader_layer_library_list scanned_layer_libraries;
// TODO add list of icd libraries for ref counting them for closure
};
struct loader_scanned_icds {
char *lib_name;
loader_platform_dl_handle handle;
uint32_t api_version;
PFN_vkGetInstanceProcAddr GetInstanceProcAddr;
PFN_vkCreateInstance CreateInstance;
PFN_vkEnumerateInstanceExtensionProperties
EnumerateInstanceExtensionProperties;
};
static inline struct loader_instance *loader_instance(VkInstance instance) {
return (struct loader_instance *)instance;
}
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_dispatch(const void *obj) {
return *((VkLayerInstanceDispatchTable **)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;
extern LOADER_PLATFORM_THREAD_ONCE_DEFINITION(once_init);
extern loader_platform_thread_mutex loader_lock;
extern loader_platform_thread_mutex loader_json_lock;
extern const VkLayerInstanceDispatchTable instance_disp;
extern const char *std_validation_str;
struct loader_msg_callback_map_entry {
VkDebugReportCallbackEXT icd_obj;
VkDebugReportCallbackEXT loader_obj;
};
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);
/* instance layer chain termination entrypoint definitions */
VKAPI_ATTR VkResult VKAPI_CALL
loader_CreateInstance(const VkInstanceCreateInfo *pCreateInfo,
const VkAllocationCallbacks *pAllocator,
VkInstance *pInstance);
VKAPI_ATTR void VKAPI_CALL
loader_DestroyInstance(VkInstance instance,
const VkAllocationCallbacks *pAllocator);
VKAPI_ATTR VkResult VKAPI_CALL
loader_EnumeratePhysicalDevices(VkInstance instance,
uint32_t *pPhysicalDeviceCount,
VkPhysicalDevice *pPhysicalDevices);
VKAPI_ATTR void VKAPI_CALL
loader_GetPhysicalDeviceFeatures(VkPhysicalDevice physicalDevice,
VkPhysicalDeviceFeatures *pFeatures);
VKAPI_ATTR void VKAPI_CALL
loader_GetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice,
VkFormat format,
VkFormatProperties *pFormatInfo);
VKAPI_ATTR VkResult VKAPI_CALL loader_GetPhysicalDeviceImageFormatProperties(
VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type,
VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags,
VkImageFormatProperties *pImageFormatProperties);
VKAPI_ATTR void VKAPI_CALL loader_GetPhysicalDeviceSparseImageFormatProperties(
VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type,
VkSampleCountFlagBits samples, VkImageUsageFlags usage,
VkImageTiling tiling, uint32_t *pNumProperties,
VkSparseImageFormatProperties *pProperties);
VKAPI_ATTR void VKAPI_CALL
loader_GetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice,
VkPhysicalDeviceProperties *pProperties);
VKAPI_ATTR VkResult VKAPI_CALL
loader_EnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
const char *pLayerName,
uint32_t *pCount,
VkExtensionProperties *pProperties);
VKAPI_ATTR VkResult VKAPI_CALL
loader_EnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice,
uint32_t *pCount,
VkLayerProperties *pProperties);
VKAPI_ATTR void VKAPI_CALL loader_GetPhysicalDeviceQueueFamilyProperties(
VkPhysicalDevice physicalDevice, uint32_t *pCount,
VkQueueFamilyProperties *pProperties);
VKAPI_ATTR void VKAPI_CALL loader_GetPhysicalDeviceMemoryProperties(
VkPhysicalDevice physicalDevice,
VkPhysicalDeviceMemoryProperties *pProperties);
VKAPI_ATTR VkResult VKAPI_CALL
loader_create_device_terminator(VkPhysicalDevice physicalDevice,
const VkDeviceCreateInfo *pCreateInfo,
const VkAllocationCallbacks *pAllocator,
VkDevice *pDevice);
VKAPI_ATTR VkResult VKAPI_CALL
loader_CreateDevice(VkPhysicalDevice gpu, const VkDeviceCreateInfo *pCreateInfo,
const VkAllocationCallbacks *pAllocator, VkDevice *pDevice);
/* helper function definitions */
void loader_initialize(void);
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);
void loader_destroy_generic_list(const struct loader_instance *inst,
struct loader_generic_list *list);
void loader_delete_layer_properties(const struct loader_instance *inst,
struct loader_layer_list *layer_list);
void loader_expand_layer_names(
const struct loader_instance *inst, const char *key_name,
uint32_t expand_count,
const char expand_names[][VK_MAX_EXTENSION_NAME_SIZE],
uint32_t *layer_count, char ***ppp_layer_names);
void loader_unexpand_dev_layer_names(const struct loader_instance *inst,
uint32_t layer_count, char **layer_names,
char **layer_ptr,
const VkDeviceCreateInfo *pCreateInfo);
void loader_unexpand_inst_layer_names(const struct loader_instance *inst,
uint32_t layer_count, char **layer_names,
char **layer_ptr,
const VkInstanceCreateInfo *pCreateInfo);
void 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_scanned_icd_clear(const struct loader_instance *inst,
struct loader_icd_libs *icd_libs);
void loader_icd_scan(const struct loader_instance *inst,
struct loader_icd_libs *icds);
void loader_layer_scan(const struct loader_instance *inst,
struct loader_layer_list *instance_layers,
struct loader_layer_list *device_layers);
void loader_get_icd_loader_instance_extensions(
const struct loader_instance *inst, struct loader_icd_libs *icd_libs,
struct loader_extension_list *inst_exts);
struct loader_icd *loader_get_icd_and_device(const VkDevice device,
struct loader_device **found_dev);
void *loader_dev_ext_gpa(struct loader_instance *inst, const char *funcName);
void *loader_get_dev_ext_trampoline(uint32_t index);
struct loader_instance *loader_get_instance(const VkInstance instance);
void loader_remove_logical_device(const struct loader_instance *inst,
struct loader_icd *icd,
struct loader_device *found_dev);
VkResult
loader_enable_instance_layers(struct loader_instance *inst,
const VkInstanceCreateInfo *pCreateInfo,
const struct loader_layer_list *instance_layers);
void loader_deactivate_instance_layers(struct loader_instance *instance);
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);
void *loader_heap_alloc(const struct loader_instance *instance, size_t size,
VkSystemAllocationScope allocationScope);
void loader_heap_free(const struct loader_instance *instance, void *pMemory);
void *loader_tls_heap_alloc(size_t size);
void loader_tls_heap_free(void *pMemory);
VkStringErrorFlags vk_string_validate(const int max_length,
const char *char_array);
#endif /* LOADER_H */

97
third_party/vulkan/loader/murmurhash.c vendored Normal file
View File

@@ -0,0 +1,97 @@
/**
* `murmurhash.h' - murmurhash
*
* copyright (c) 2014 joseph werle <joseph.werle@gmail.com>
* 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 <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#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;
}

52
third_party/vulkan/loader/murmurhash.h vendored Normal file
View File

@@ -0,0 +1,52 @@
/**
* `murmurhash.h' - murmurhash
*
* copyright (c) 2014 joseph werle <joseph.werle@gmail.com>
* 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 <stdint.h>
#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

24
third_party/vulkan/loader/premake5.lua vendored Normal file
View File

@@ -0,0 +1,24 @@
group("third_party")
project("vulkan-loader")
uuid("07d77359-1618-43e6-8a4a-0ee9ddc5fa6a")
kind("StaticLib")
language("C++")
defines({
"_LIB",
})
removedefines({
"_UNICODE",
"UNICODE",
})
includedirs({
".",
})
recursive_platform_files()
filter("platforms:Windows")
warnings("Off") -- Too many warnings.
characterset("MBCS")
defines({
"VK_USE_PLATFORM_WIN32_KHR",
})

710
third_party/vulkan/loader/table_ops.h vendored Normal file
View File

@@ -0,0 +1,710 @@
/*
*
* Copyright (c) 2015-2016 The Khronos Group Inc.
* Copyright (c) 2015-2016 Valve Corporation
* Copyright (c) 2015-2016 LunarG, Inc.
* Copyright (C) 2016 Google 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.
*
* Author: Courtney Goeltzenleuchter <courtney@lunarg.com>
* Author: Jon Ashburn <jon@lunarg.com>
* Author: Ian Elliott <ian@LunarG.com>
* Author: Tony Barbour <tony@LunarG.com>
*/
#include <vulkan/vulkan.h>
#include <vulkan/vk_layer.h>
#include <string.h>
#include "loader.h"
#include "vk_loader_platform.h"
static VkResult vkDevExtError(VkDevice dev) {
struct loader_device *found_dev;
struct loader_icd *icd = loader_get_icd_and_device(dev, &found_dev);
if (icd)
loader_log(icd->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;
}
static inline void
loader_init_device_dispatch_table(struct loader_dev_dispatch_table *dev_table,
PFN_vkGetDeviceProcAddr gpa, VkDevice dev) {
VkLayerDispatchTable *table = &dev_table->core_dispatch;
for (uint32_t i = 0; i < MAX_NUM_DEV_EXTS; i++)
dev_table->ext_dispatch.DevExt[i] = (PFN_vkDevExt)vkDevExtError;
table->GetDeviceProcAddr =
(PFN_vkGetDeviceProcAddr)gpa(dev, "vkGetDeviceProcAddr");
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->GetImageSparseMemoryRequirements =
(PFN_vkGetImageSparseMemoryRequirements)gpa(
dev, "vkGetImageSparseMemoryRequirements");
table->GetBufferMemoryRequirements = (PFN_vkGetBufferMemoryRequirements)gpa(
dev, "vkGetBufferMemoryRequirements");
table->GetImageMemoryRequirements = (PFN_vkGetImageMemoryRequirements)gpa(
dev, "vkGetImageMemoryRequirements");
table->BindBufferMemory =
(PFN_vkBindBufferMemory)gpa(dev, "vkBindBufferMemory");
table->BindImageMemory =
(PFN_vkBindImageMemory)gpa(dev, "vkBindImageMemory");
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->CmdBindVertexBuffers =
(PFN_vkCmdBindVertexBuffers)gpa(dev, "vkCmdBindVertexBuffers");
table->CmdBindIndexBuffer =
(PFN_vkCmdBindIndexBuffer)gpa(dev, "vkCmdBindIndexBuffer");
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");
}
static inline void loader_init_device_extension_dispatch_table(
struct loader_dev_dispatch_table *dev_table, PFN_vkGetDeviceProcAddr gpa,
VkDevice dev) {
VkLayerDispatchTable *table = &dev_table->core_dispatch;
table->AcquireNextImageKHR =
(PFN_vkAcquireNextImageKHR)gpa(dev, "vkAcquireNextImageKHR");
table->CreateSwapchainKHR =
(PFN_vkCreateSwapchainKHR)gpa(dev, "vkCreateSwapchainKHR");
table->DestroySwapchainKHR =
(PFN_vkDestroySwapchainKHR)gpa(dev, "vkDestroySwapchainKHR");
table->GetSwapchainImagesKHR =
(PFN_vkGetSwapchainImagesKHR)gpa(dev, "vkGetSwapchainImagesKHR");
table->QueuePresentKHR =
(PFN_vkQueuePresentKHR)gpa(dev, "vkQueuePresentKHR");
}
static inline void *
loader_lookup_device_dispatch_table(const VkLayerDispatchTable *table,
const char *name) {
if (!name || name[0] != 'v' || name[1] != 'k')
return NULL;
name += 2;
if (!strcmp(name, "GetDeviceProcAddr"))
return (void *)table->GetDeviceProcAddr;
if (!strcmp(name, "DestroyDevice"))
return (void *)table->DestroyDevice;
if (!strcmp(name, "GetDeviceQueue"))
return (void *)table->GetDeviceQueue;
if (!strcmp(name, "QueueSubmit"))
return (void *)table->QueueSubmit;
if (!strcmp(name, "QueueWaitIdle"))
return (void *)table->QueueWaitIdle;
if (!strcmp(name, "DeviceWaitIdle"))
return (void *)table->DeviceWaitIdle;
if (!strcmp(name, "AllocateMemory"))
return (void *)table->AllocateMemory;
if (!strcmp(name, "FreeMemory"))
return (void *)table->FreeMemory;
if (!strcmp(name, "MapMemory"))
return (void *)table->MapMemory;
if (!strcmp(name, "UnmapMemory"))
return (void *)table->UnmapMemory;
if (!strcmp(name, "FlushMappedMemoryRanges"))
return (void *)table->FlushMappedMemoryRanges;
if (!strcmp(name, "InvalidateMappedMemoryRanges"))
return (void *)table->InvalidateMappedMemoryRanges;
if (!strcmp(name, "GetDeviceMemoryCommitment"))
return (void *)table->GetDeviceMemoryCommitment;
if (!strcmp(name, "GetImageSparseMemoryRequirements"))
return (void *)table->GetImageSparseMemoryRequirements;
if (!strcmp(name, "GetBufferMemoryRequirements"))
return (void *)table->GetBufferMemoryRequirements;
if (!strcmp(name, "GetImageMemoryRequirements"))
return (void *)table->GetImageMemoryRequirements;
if (!strcmp(name, "BindBufferMemory"))
return (void *)table->BindBufferMemory;
if (!strcmp(name, "BindImageMemory"))
return (void *)table->BindImageMemory;
if (!strcmp(name, "QueueBindSparse"))
return (void *)table->QueueBindSparse;
if (!strcmp(name, "CreateFence"))
return (void *)table->CreateFence;
if (!strcmp(name, "DestroyFence"))
return (void *)table->DestroyFence;
if (!strcmp(name, "ResetFences"))
return (void *)table->ResetFences;
if (!strcmp(name, "GetFenceStatus"))
return (void *)table->GetFenceStatus;
if (!strcmp(name, "WaitForFences"))
return (void *)table->WaitForFences;
if (!strcmp(name, "CreateSemaphore"))
return (void *)table->CreateSemaphore;
if (!strcmp(name, "DestroySemaphore"))
return (void *)table->DestroySemaphore;
if (!strcmp(name, "CreateEvent"))
return (void *)table->CreateEvent;
if (!strcmp(name, "DestroyEvent"))
return (void *)table->DestroyEvent;
if (!strcmp(name, "GetEventStatus"))
return (void *)table->GetEventStatus;
if (!strcmp(name, "SetEvent"))
return (void *)table->SetEvent;
if (!strcmp(name, "ResetEvent"))
return (void *)table->ResetEvent;
if (!strcmp(name, "CreateQueryPool"))
return (void *)table->CreateQueryPool;
if (!strcmp(name, "DestroyQueryPool"))
return (void *)table->DestroyQueryPool;
if (!strcmp(name, "GetQueryPoolResults"))
return (void *)table->GetQueryPoolResults;
if (!strcmp(name, "CreateBuffer"))
return (void *)table->CreateBuffer;
if (!strcmp(name, "DestroyBuffer"))
return (void *)table->DestroyBuffer;
if (!strcmp(name, "CreateBufferView"))
return (void *)table->CreateBufferView;
if (!strcmp(name, "DestroyBufferView"))
return (void *)table->DestroyBufferView;
if (!strcmp(name, "CreateImage"))
return (void *)table->CreateImage;
if (!strcmp(name, "DestroyImage"))
return (void *)table->DestroyImage;
if (!strcmp(name, "GetImageSubresourceLayout"))
return (void *)table->GetImageSubresourceLayout;
if (!strcmp(name, "CreateImageView"))
return (void *)table->CreateImageView;
if (!strcmp(name, "DestroyImageView"))
return (void *)table->DestroyImageView;
if (!strcmp(name, "CreateShaderModule"))
return (void *)table->CreateShaderModule;
if (!strcmp(name, "DestroyShaderModule"))
return (void *)table->DestroyShaderModule;
if (!strcmp(name, "CreatePipelineCache"))
return (void *)vkCreatePipelineCache;
if (!strcmp(name, "DestroyPipelineCache"))
return (void *)vkDestroyPipelineCache;
if (!strcmp(name, "GetPipelineCacheData"))
return (void *)vkGetPipelineCacheData;
if (!strcmp(name, "MergePipelineCaches"))
return (void *)vkMergePipelineCaches;
if (!strcmp(name, "CreateGraphicsPipelines"))
return (void *)vkCreateGraphicsPipelines;
if (!strcmp(name, "CreateComputePipelines"))
return (void *)vkCreateComputePipelines;
if (!strcmp(name, "DestroyPipeline"))
return (void *)table->DestroyPipeline;
if (!strcmp(name, "CreatePipelineLayout"))
return (void *)table->CreatePipelineLayout;
if (!strcmp(name, "DestroyPipelineLayout"))
return (void *)table->DestroyPipelineLayout;
if (!strcmp(name, "CreateSampler"))
return (void *)table->CreateSampler;
if (!strcmp(name, "DestroySampler"))
return (void *)table->DestroySampler;
if (!strcmp(name, "CreateDescriptorSetLayout"))
return (void *)table->CreateDescriptorSetLayout;
if (!strcmp(name, "DestroyDescriptorSetLayout"))
return (void *)table->DestroyDescriptorSetLayout;
if (!strcmp(name, "CreateDescriptorPool"))
return (void *)table->CreateDescriptorPool;
if (!strcmp(name, "DestroyDescriptorPool"))
return (void *)table->DestroyDescriptorPool;
if (!strcmp(name, "ResetDescriptorPool"))
return (void *)table->ResetDescriptorPool;
if (!strcmp(name, "AllocateDescriptorSets"))
return (void *)table->AllocateDescriptorSets;
if (!strcmp(name, "FreeDescriptorSets"))
return (void *)table->FreeDescriptorSets;
if (!strcmp(name, "UpdateDescriptorSets"))
return (void *)table->UpdateDescriptorSets;
if (!strcmp(name, "CreateFramebuffer"))
return (void *)table->CreateFramebuffer;
if (!strcmp(name, "DestroyFramebuffer"))
return (void *)table->DestroyFramebuffer;
if (!strcmp(name, "CreateRenderPass"))
return (void *)table->CreateRenderPass;
if (!strcmp(name, "DestroyRenderPass"))
return (void *)table->DestroyRenderPass;
if (!strcmp(name, "GetRenderAreaGranularity"))
return (void *)table->GetRenderAreaGranularity;
if (!strcmp(name, "CreateCommandPool"))
return (void *)table->CreateCommandPool;
if (!strcmp(name, "DestroyCommandPool"))
return (void *)table->DestroyCommandPool;
if (!strcmp(name, "ResetCommandPool"))
return (void *)table->ResetCommandPool;
if (!strcmp(name, "AllocateCommandBuffers"))
return (void *)table->AllocateCommandBuffers;
if (!strcmp(name, "FreeCommandBuffers"))
return (void *)table->FreeCommandBuffers;
if (!strcmp(name, "BeginCommandBuffer"))
return (void *)table->BeginCommandBuffer;
if (!strcmp(name, "EndCommandBuffer"))
return (void *)table->EndCommandBuffer;
if (!strcmp(name, "ResetCommandBuffer"))
return (void *)table->ResetCommandBuffer;
if (!strcmp(name, "CmdBindPipeline"))
return (void *)table->CmdBindPipeline;
if (!strcmp(name, "CmdSetViewport"))
return (void *)table->CmdSetViewport;
if (!strcmp(name, "CmdSetScissor"))
return (void *)table->CmdSetScissor;
if (!strcmp(name, "CmdSetLineWidth"))
return (void *)table->CmdSetLineWidth;
if (!strcmp(name, "CmdSetDepthBias"))
return (void *)table->CmdSetDepthBias;
if (!strcmp(name, "CmdSetBlendConstants"))
return (void *)table->CmdSetBlendConstants;
if (!strcmp(name, "CmdSetDepthBounds"))
return (void *)table->CmdSetDepthBounds;
if (!strcmp(name, "CmdSetStencilCompareMask"))
return (void *)table->CmdSetStencilCompareMask;
if (!strcmp(name, "CmdSetStencilwriteMask"))
return (void *)table->CmdSetStencilWriteMask;
if (!strcmp(name, "CmdSetStencilReference"))
return (void *)table->CmdSetStencilReference;
if (!strcmp(name, "CmdBindDescriptorSets"))
return (void *)table->CmdBindDescriptorSets;
if (!strcmp(name, "CmdBindVertexBuffers"))
return (void *)table->CmdBindVertexBuffers;
if (!strcmp(name, "CmdBindIndexBuffer"))
return (void *)table->CmdBindIndexBuffer;
if (!strcmp(name, "CmdDraw"))
return (void *)table->CmdDraw;
if (!strcmp(name, "CmdDrawIndexed"))
return (void *)table->CmdDrawIndexed;
if (!strcmp(name, "CmdDrawIndirect"))
return (void *)table->CmdDrawIndirect;
if (!strcmp(name, "CmdDrawIndexedIndirect"))
return (void *)table->CmdDrawIndexedIndirect;
if (!strcmp(name, "CmdDispatch"))
return (void *)table->CmdDispatch;
if (!strcmp(name, "CmdDispatchIndirect"))
return (void *)table->CmdDispatchIndirect;
if (!strcmp(name, "CmdCopyBuffer"))
return (void *)table->CmdCopyBuffer;
if (!strcmp(name, "CmdCopyImage"))
return (void *)table->CmdCopyImage;
if (!strcmp(name, "CmdBlitImage"))
return (void *)table->CmdBlitImage;
if (!strcmp(name, "CmdCopyBufferToImage"))
return (void *)table->CmdCopyBufferToImage;
if (!strcmp(name, "CmdCopyImageToBuffer"))
return (void *)table->CmdCopyImageToBuffer;
if (!strcmp(name, "CmdUpdateBuffer"))
return (void *)table->CmdUpdateBuffer;
if (!strcmp(name, "CmdFillBuffer"))
return (void *)table->CmdFillBuffer;
if (!strcmp(name, "CmdClearColorImage"))
return (void *)table->CmdClearColorImage;
if (!strcmp(name, "CmdClearDepthStencilImage"))
return (void *)table->CmdClearDepthStencilImage;
if (!strcmp(name, "CmdClearAttachments"))
return (void *)table->CmdClearAttachments;
if (!strcmp(name, "CmdResolveImage"))
return (void *)table->CmdResolveImage;
if (!strcmp(name, "CmdSetEvent"))
return (void *)table->CmdSetEvent;
if (!strcmp(name, "CmdResetEvent"))
return (void *)table->CmdResetEvent;
if (!strcmp(name, "CmdWaitEvents"))
return (void *)table->CmdWaitEvents;
if (!strcmp(name, "CmdPipelineBarrier"))
return (void *)table->CmdPipelineBarrier;
if (!strcmp(name, "CmdBeginQuery"))
return (void *)table->CmdBeginQuery;
if (!strcmp(name, "CmdEndQuery"))
return (void *)table->CmdEndQuery;
if (!strcmp(name, "CmdResetQueryPool"))
return (void *)table->CmdResetQueryPool;
if (!strcmp(name, "CmdWriteTimestamp"))
return (void *)table->CmdWriteTimestamp;
if (!strcmp(name, "CmdCopyQueryPoolResults"))
return (void *)table->CmdCopyQueryPoolResults;
if (!strcmp(name, "CmdPushConstants"))
return (void *)table->CmdPushConstants;
if (!strcmp(name, "CmdBeginRenderPass"))
return (void *)table->CmdBeginRenderPass;
if (!strcmp(name, "CmdNextSubpass"))
return (void *)table->CmdNextSubpass;
if (!strcmp(name, "CmdEndRenderPass"))
return (void *)table->CmdEndRenderPass;
if (!strcmp(name, "CmdExecuteCommands"))
return (void *)table->CmdExecuteCommands;
return NULL;
}
static inline void
loader_init_instance_core_dispatch_table(VkLayerInstanceDispatchTable *table,
PFN_vkGetInstanceProcAddr gpa,
VkInstance inst) {
table->GetInstanceProcAddr =
(PFN_vkGetInstanceProcAddr)gpa(inst, "vkGetInstanceProcAddr");
table->DestroyInstance =
(PFN_vkDestroyInstance)gpa(inst, "vkDestroyInstance");
table->EnumeratePhysicalDevices =
(PFN_vkEnumeratePhysicalDevices)gpa(inst, "vkEnumeratePhysicalDevices");
table->GetPhysicalDeviceFeatures = (PFN_vkGetPhysicalDeviceFeatures)gpa(
inst, "vkGetPhysicalDeviceFeatures");
table->GetPhysicalDeviceImageFormatProperties =
(PFN_vkGetPhysicalDeviceImageFormatProperties)gpa(
inst, "vkGetPhysicalDeviceImageFormatProperties");
table->GetPhysicalDeviceFormatProperties =
(PFN_vkGetPhysicalDeviceFormatProperties)gpa(
inst, "vkGetPhysicalDeviceFormatProperties");
table->GetPhysicalDeviceSparseImageFormatProperties =
(PFN_vkGetPhysicalDeviceSparseImageFormatProperties)gpa(
inst, "vkGetPhysicalDeviceSparseImageFormatProperties");
table->GetPhysicalDeviceProperties = (PFN_vkGetPhysicalDeviceProperties)gpa(
inst, "vkGetPhysicalDeviceProperties");
table->GetPhysicalDeviceQueueFamilyProperties =
(PFN_vkGetPhysicalDeviceQueueFamilyProperties)gpa(
inst, "vkGetPhysicalDeviceQueueFamilyProperties");
table->GetPhysicalDeviceMemoryProperties =
(PFN_vkGetPhysicalDeviceMemoryProperties)gpa(
inst, "vkGetPhysicalDeviceMemoryProperties");
table->EnumerateDeviceExtensionProperties =
(PFN_vkEnumerateDeviceExtensionProperties)gpa(
inst, "vkEnumerateDeviceExtensionProperties");
table->EnumerateDeviceLayerProperties =
(PFN_vkEnumerateDeviceLayerProperties)gpa(
inst, "vkEnumerateDeviceLayerProperties");
}
static inline void loader_init_instance_extension_dispatch_table(
VkLayerInstanceDispatchTable *table, PFN_vkGetInstanceProcAddr gpa,
VkInstance inst) {
table->DestroySurfaceKHR =
(PFN_vkDestroySurfaceKHR)gpa(inst, "vkDestroySurfaceKHR");
table->CreateDebugReportCallbackEXT =
(PFN_vkCreateDebugReportCallbackEXT)gpa(
inst, "vkCreateDebugReportCallbackEXT");
table->DestroyDebugReportCallbackEXT =
(PFN_vkDestroyDebugReportCallbackEXT)gpa(
inst, "vkDestroyDebugReportCallbackEXT");
table->DebugReportMessageEXT =
(PFN_vkDebugReportMessageEXT)gpa(inst, "vkDebugReportMessageEXT");
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");
#ifdef VK_USE_PLATFORM_MIR_KHR
table->CreateMirSurfaceKHR =
(PFN_vkCreateMirSurfaceKHR)gpa(inst, "vkCreateMirSurfaceKHR");
table->GetPhysicalDeviceMirPresentationSupportKHR =
(PFN_vkGetPhysicalDeviceMirPresentationSupportKHR)gpa(
inst, "vkGetPhysicalDeviceMirPresentationSupportKHR");
#endif
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
table->CreateWaylandSurfaceKHR =
(PFN_vkCreateWaylandSurfaceKHR)gpa(inst, "vkCreateWaylandSurfaceKHR");
table->GetPhysicalDeviceWaylandPresentationSupportKHR =
(PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR)gpa(
inst, "vkGetPhysicalDeviceWaylandPresentationSupportKHR");
#endif
#ifdef VK_USE_PLATFORM_WIN32_KHR
table->CreateWin32SurfaceKHR =
(PFN_vkCreateWin32SurfaceKHR)gpa(inst, "vkCreateWin32SurfaceKHR");
table->GetPhysicalDeviceWin32PresentationSupportKHR =
(PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)gpa(
inst, "vkGetPhysicalDeviceWin32PresentationSupportKHR");
#endif
#ifdef VK_USE_PLATFORM_XCB_KHR
table->CreateXcbSurfaceKHR =
(PFN_vkCreateXcbSurfaceKHR)gpa(inst, "vkCreateXcbSurfaceKHR");
table->GetPhysicalDeviceXcbPresentationSupportKHR =
(PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR)gpa(
inst, "vkGetPhysicalDeviceXcbPresentationSupportKHR");
#endif
#ifdef VK_USE_PLATFORM_XLIB_KHR
table->CreateXlibSurfaceKHR =
(PFN_vkCreateXlibSurfaceKHR)gpa(inst, "vkCreateXlibSurfaceKHR");
table->GetPhysicalDeviceXlibPresentationSupportKHR =
(PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR)gpa(
inst, "vkGetPhysicalDeviceXlibPresentationSupportKHR");
#endif
}
static inline void *
loader_lookup_instance_dispatch_table(const VkLayerInstanceDispatchTable *table,
const char *name) {
if (!name || name[0] != 'v' || name[1] != 'k')
return NULL;
name += 2;
if (!strcmp(name, "DestroyInstance"))
return (void *)table->DestroyInstance;
if (!strcmp(name, "EnumeratePhysicalDevices"))
return (void *)table->EnumeratePhysicalDevices;
if (!strcmp(name, "GetPhysicalDeviceFeatures"))
return (void *)table->GetPhysicalDeviceFeatures;
if (!strcmp(name, "GetPhysicalDeviceImageFormatProperties"))
return (void *)table->GetPhysicalDeviceImageFormatProperties;
if (!strcmp(name, "GetPhysicalDeviceFormatProperties"))
return (void *)table->GetPhysicalDeviceFormatProperties;
if (!strcmp(name, "GetPhysicalDeviceSparseImageFormatProperties"))
return (void *)table->GetPhysicalDeviceSparseImageFormatProperties;
if (!strcmp(name, "GetPhysicalDeviceProperties"))
return (void *)table->GetPhysicalDeviceProperties;
if (!strcmp(name, "GetPhysicalDeviceQueueFamilyProperties"))
return (void *)table->GetPhysicalDeviceQueueFamilyProperties;
if (!strcmp(name, "GetPhysicalDeviceMemoryProperties"))
return (void *)table->GetPhysicalDeviceMemoryProperties;
if (!strcmp(name, "GetInstanceProcAddr"))
return (void *)table->GetInstanceProcAddr;
if (!strcmp(name, "EnumerateDeviceExtensionProperties"))
return (void *)table->EnumerateDeviceExtensionProperties;
if (!strcmp(name, "EnumerateDeviceLayerProperties"))
return (void *)table->EnumerateDeviceLayerProperties;
if (!strcmp(name, "DestroySurfaceKHR"))
return (void *)table->DestroySurfaceKHR;
if (!strcmp(name, "GetPhysicalDeviceSurfaceSupportKHR"))
return (void *)table->GetPhysicalDeviceSurfaceSupportKHR;
if (!strcmp(name, "GetPhysicalDeviceSurfaceCapabilitiesKHR"))
return (void *)table->GetPhysicalDeviceSurfaceCapabilitiesKHR;
if (!strcmp(name, "GetPhysicalDeviceSurfaceFormatsKHR"))
return (void *)table->GetPhysicalDeviceSurfaceFormatsKHR;
if (!strcmp(name, "GetPhysicalDeviceSurfacePresentModesKHR"))
return (void *)table->GetPhysicalDeviceSurfacePresentModesKHR;
#ifdef VK_USE_PLATFORM_MIR_KHR
if (!strcmp(name, "CreateMirSurfaceKHR"))
return (void *)table->CreateMirSurfaceKHR;
if (!strcmp(name, "GetPhysicalDeviceMirPresentationSupportKHR"))
return (void *)table->GetPhysicalDeviceMirPresentationSupportKHR;
#endif
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
if (!strcmp(name, "CreateWaylandSurfaceKHR"))
return (void *)table->CreateWaylandSurfaceKHR;
if (!strcmp(name, "GetPhysicalDeviceWaylandPresentationSupportKHR"))
return (void *)table->GetPhysicalDeviceWaylandPresentationSupportKHR;
#endif
#ifdef VK_USE_PLATFORM_WIN32_KHR
if (!strcmp(name, "CreateWin32SurfaceKHR"))
return (void *)table->CreateWin32SurfaceKHR;
if (!strcmp(name, "GetPhysicalDeviceWin32PresentationSupportKHR"))
return (void *)table->GetPhysicalDeviceWin32PresentationSupportKHR;
#endif
#ifdef VK_USE_PLATFORM_XCB_KHR
if (!strcmp(name, "CreateXcbSurfaceKHR"))
return (void *)table->CreateXcbSurfaceKHR;
if (!strcmp(name, "GetPhysicalDeviceXcbPresentationSupportKHR"))
return (void *)table->GetPhysicalDeviceXcbPresentationSupportKHR;
#endif
#ifdef VK_USE_PLATFORM_XLIB_KHR
if (!strcmp(name, "CreateXlibSurfaceKHR"))
return (void *)table->CreateXlibSurfaceKHR;
if (!strcmp(name, "GetPhysicalDeviceXlibPresentationSupportKHR"))
return (void *)table->GetPhysicalDeviceXlibPresentationSupportKHR;
#endif
if (!strcmp(name, "CreateDebugReportCallbackEXT"))
return (void *)table->CreateDebugReportCallbackEXT;
if (!strcmp(name, "DestroyDebugReportCallbackEXT"))
return (void *)table->DestroyDebugReportCallbackEXT;
if (!strcmp(name, "DebugReportMessageEXT"))
return (void *)table->DebugReportMessageEXT;
return NULL;
}

1731
third_party/vulkan/loader/trampoline.c vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,449 @@
/*
*
* 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.
*
* Author: Ian Elliot <ian@lunarg.com>
* Author: Jon Ashburn <jon@lunarg.com>
*
*/
#pragma once
#if defined(_WIN32)
// WinSock2.h must be included *BEFORE* windows.h
#include <WinSock2.h>
#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 <unistd.h>
// Note: The following file is for dynamic loading:
#include <dlfcn.h>
#include <pthread.h>
#include <assert.h>
#include <string.h>
#include <stdbool.h>
#include <stdlib.h>
#include <libgen.h>
// VK Library Filenames, Paths, etc.:
#define PATH_SEPERATOR ':'
#define DIRECTORY_SYMBOL '/'
#define VULKAN_ICDCONF_DIR \
"/" \
"vulkan" \
"/" \
"icd.d"
#define VULKAN_ICD_DIR \
"/" \
"vulkan" \
"/" \
"icd"
#define VULKAN_ELAYERCONF_DIR \
"/" \
"vulkan" \
"/" \
"explicit_layer.d"
#define VULKAN_ILAYERCONF_DIR \
"/" \
"vulkan" \
"/" \
"implicit_layer.d"
#define VULKAN_LAYER_DIR \
"/" \
"vulkan" \
"/" \
"layer"
#if defined(LOCALPREFIX)
#define LOCAL_DRIVERS_INFO \
LOCALPREFIX "/" SYSCONFDIR VULKAN_ICDCONF_DIR ":" LOCALPREFIX \
"/" DATADIR VULKAN_ICDCONF_DIR ":"
#define LOCAL_ELAYERS_INFO \
LOCALPREFIX "/" SYSCONFDIR VULKAN_ELAYERCONF_DIR ":" LOCALPREFIX \
"/" DATADIR VULKAN_ELAYERCONF_DIR ":"
#define LOCAL_ILAYERS_INFO \
LOCALPREFIX "/" SYSCONFDIR VULKAN_ILAYERCONF_DIR ":" LOCALPREFIX \
"/" DATADIR VULKAN_ILAYERCONF_DIR ":"
#else
#define LOCAL_DRIVERS_INFO
#define LOCAL_ELAYERS_INFO
#define LOCAL_ILAYERS_INFO
#endif
#define DEFAULT_VK_DRIVERS_INFO \
LOCAL_DRIVERS_INFO \
"/" SYSCONFDIR VULKAN_ICDCONF_DIR ":" \
"/usr/" DATADIR VULKAN_ICDCONF_DIR
#define DEFAULT_VK_DRIVERS_PATH ""
#define DEFAULT_VK_ELAYERS_INFO \
LOCAL_ELAYERS_INFO \
"/" SYSCONFDIR VULKAN_ELAYERCONF_DIR ":" \
"/usr/" DATADIR VULKAN_ELAYERCONF_DIR ":"
#define DEFAULT_VK_ILAYERS_INFO \
LOCAL_ILAYERS_INFO \
"/" SYSCONFDIR VULKAN_ILAYERCONF_DIR ":" \
"/usr/" DATADIR VULKAN_ILAYERCONF_DIR
#define DEFAULT_VK_LAYERS_PATH ""
#define LAYERS_PATH_ENV "VK_LAYER_PATH"
// 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);
}
// Environment variables
static inline char *loader_getenv(const char *name) { return getenv(name); }
static inline void loader_free_getenv(const char *val) {}
// Dynamic Loading of libraries:
typedef void *loader_platform_dl_handle;
static inline loader_platform_dl_handle
loader_platform_open_library(const char *libPath) {
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
#define LOADER_PLATFORM_THREAD_ONCE_DECLARATION(var) \
pthread_once_t var = PTHREAD_ONCE_INIT;
#define LOADER_PLATFORM_THREAD_ONCE_DEFINITION(var) pthread_once_t var;
static inline void loader_platform_thread_once(pthread_once_t *ctl,
void (*func)(void)) {
assert(func != NULL);
assert(ctl != NULL);
pthread_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 <assert.h>
#include <stdio.h>
#include <string.h>
#include <io.h>
#include <stdbool.h>
#include <shlwapi.h>
#ifdef __cplusplus
#include <iostream>
#include <string>
using namespace std;
#endif // __cplusplus
// VK Library Filenames, Paths, etc.:
#define PATH_SEPERATOR ';'
#define DIRECTORY_SYMBOL '\\'
#define DEFAULT_VK_REGISTRY_HIVE HKEY_LOCAL_MACHINE
#define DEFAULT_VK_DRIVERS_INFO "SOFTWARE\\Khronos\\Vulkan\\Drivers"
// TODO: Are these the correct paths
#define DEFAULT_VK_DRIVERS_PATH "C:\\Windows\\System32;C:\\Windows\\SysWow64"
#define DEFAULT_VK_ELAYERS_INFO "SOFTWARE\\Khronos\\Vulkan\\ExplicitLayers"
#define DEFAULT_VK_ILAYERS_INFO "SOFTWARE\\Khronos\\Vulkan\\ImplicitLayers"
#define DEFAULT_VK_LAYERS_PATH "C:\\Windows\\System32;C:\\Windows\\SysWow64"
#define LAYERS_PATH_ENV "VK_LAYER_PATH"
#define PRINTF_SIZE_T_SPECIFIER "%Iu"
// 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;
}
// Environment variables
static inline char *loader_getenv(const char *name) {
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;
// TODO; FIXME This should be using any app defined memory allocation
retVal = (char *)malloc(valSize);
GetEnvironmentVariableA(name, retVal, valSize);
return retVal;
}
static inline void loader_free_getenv(const char *val) { free((void *)val); }
// Dynamic Loading:
typedef HMODULE loader_platform_dl_handle;
static loader_platform_dl_handle
loader_platform_open_library(const char *libPath) {
return LoadLibrary(libPath);
}
static char *loader_platform_open_library_error(const char *libPath) {
static char errorMsg[120];
snprintf(errorMsg, 119, "Failed to open dynamic library \"%s\"", libPath);
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];
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)
#define LOADER_PLATFORM_THREAD_ONCE_DECLARATION(var) \
INIT_ONCE var = INIT_ONCE_STATIC_INIT;
#define LOADER_PLATFORM_THREAD_ONCE_DEFINITION(var) INIT_ONCE var;
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(void *ctl, void (*func)(void)) {
assert(func != NULL);
assert(ctl != NULL);
InitOnceExecuteOnce((PINIT_ONCE)ctl, InitFuncWrapper, func, NULL);
}
// 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);
}
// Windows Registry:
char *loader_get_registry_string(const HKEY hive, const LPCTSTR sub_key,
const char *value);
#define loader_stack_alloc(size) _alloca(size)
#else // defined(_WIN32)
#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;
}

1092
third_party/vulkan/loader/wsi.c vendored Normal file

File diff suppressed because it is too large Load Diff

120
third_party/vulkan/loader/wsi.h vendored Normal file
View File

@@ -0,0 +1,120 @@
/*
* 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.
*
* Author: Ian Elliott <ian@lunarg.com>
*
*/
#include "vk_loader_platform.h"
#include "loader.h"
bool wsi_swapchain_instance_gpa(struct loader_instance *ptr_instance,
const char *name, void **addr);
void wsi_add_instance_extensions(const struct loader_instance *inst,
struct loader_extension_list *ext_list);
void wsi_create_instance(struct loader_instance *ptr_instance,
const VkInstanceCreateInfo *pCreateInfo);
VKAPI_ATTR void VKAPI_CALL
loader_DestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface,
const VkAllocationCallbacks *pAllocator);
VKAPI_ATTR VkResult VKAPI_CALL
loader_GetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice physicalDevice,
uint32_t queueFamilyIndex,
VkSurfaceKHR surface,
VkBool32 *pSupported);
VKAPI_ATTR VkResult VKAPI_CALL loader_GetPhysicalDeviceSurfaceCapabilitiesKHR(
VkPhysicalDevice physicalDevice, VkSurfaceKHR surface,
VkSurfaceCapabilitiesKHR *pSurfaceCapabilities);
VKAPI_ATTR VkResult VKAPI_CALL
loader_GetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice,
VkSurfaceKHR surface,
uint32_t *pSurfaceFormatCount,
VkSurfaceFormatKHR *pSurfaceFormats);
VKAPI_ATTR VkResult VKAPI_CALL
loader_GetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice,
VkSurfaceKHR surface,
uint32_t *pPresentModeCount,
VkPresentModeKHR *pPresentModes);
#ifdef VK_USE_PLATFORM_WIN32_KHR
VKAPI_ATTR VkResult VKAPI_CALL
loader_CreateWin32SurfaceKHR(VkInstance instance,
const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
const VkAllocationCallbacks *pAllocator,
VkSurfaceKHR *pSurface);
VKAPI_ATTR VkBool32 VKAPI_CALL
loader_GetPhysicalDeviceWin32PresentationSupportKHR(
VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex);
#endif
#ifdef VK_USE_PLATFORM_MIR_KHR
VKAPI_ATTR VkResult VKAPI_CALL
loader_CreateMirSurfaceKHR(VkInstance instance,
const VkMirSurfaceCreateInfoKHR *pCreateInfo,
const VkAllocationCallbacks *pAllocator,
VkSurfaceKHR *pSurface);
VKAPI_ATTR VkBool32 VKAPI_CALL
loader_GetPhysicalDeviceMirPresentationSupportKHR(
VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex,
MirConnection *connection);
#endif
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
VKAPI_ATTR VkResult VKAPI_CALL
loader_CreateWaylandSurfaceKHR(VkInstance instance,
const VkWaylandSurfaceCreateInfoKHR *pCreateInfo,
const VkAllocationCallbacks *pAllocator,
VkSurfaceKHR *pSurface);
VKAPI_ATTR VkBool32 VKAPI_CALL
loader_GetPhysicalDeviceWaylandPresentationSupportKHR(
VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex,
struct wl_display *display);
#endif
#ifdef VK_USE_PLATFORM_XCB_KHR
VKAPI_ATTR VkResult VKAPI_CALL
loader_CreateXcbSurfaceKHR(VkInstance instance,
const VkXcbSurfaceCreateInfoKHR *pCreateInfo,
const VkAllocationCallbacks *pAllocator,
VkSurfaceKHR *pSurface);
VKAPI_ATTR VkBool32 VKAPI_CALL
loader_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
loader_CreateXlibSurfaceKHR(VkInstance instance,
const VkXlibSurfaceCreateInfoKHR *pCreateInfo,
const VkAllocationCallbacks *pAllocator,
VkSurfaceKHR *pSurface);
VKAPI_ATTR VkBool32 VKAPI_CALL
loader_GetPhysicalDeviceXlibPresentationSupportKHR(
VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, Display *dpy,
VisualID visualID);
#endif