mirror of
https://gitee.com/openharmony/third_party_vulkan-loader
synced 2024-11-27 09:21:56 +00:00
loader: refactor layer activation function to handle more general inputs
Renamed structure types as well. TODO: verify vk-layer-generate.py v2: fix LoaderEntrypointsSubcommand (olv)
This commit is contained in:
parent
e8df9ac373
commit
37e7f970e7
@ -48,13 +48,6 @@
|
||||
// being used:
|
||||
#include "loader_platform.h"
|
||||
|
||||
struct loader_instance {
|
||||
struct loader_icd *icds;
|
||||
struct loader_instance *next;
|
||||
uint32_t extension_count;
|
||||
char **extension_names;
|
||||
};
|
||||
|
||||
struct loader_layers {
|
||||
loader_platform_dl_handle lib_handle;
|
||||
char name[256];
|
||||
@ -68,12 +61,12 @@ struct layer_name_pair {
|
||||
struct loader_icd {
|
||||
const struct loader_scanned_icds *scanned_icds;
|
||||
|
||||
VK_LAYER_DISPATCH_TABLE *loader_dispatch;
|
||||
VkLayerDispatchTable *loader_dispatch;
|
||||
uint32_t layer_count[VK_MAX_PHYSICAL_GPUS];
|
||||
struct loader_layers layer_libs[VK_MAX_PHYSICAL_GPUS][MAX_LAYER_LIBRARIES];
|
||||
VK_BASE_LAYER_OBJECT *wrappedGpus[VK_MAX_PHYSICAL_GPUS];
|
||||
VkBaseLayerObject *wrappedGpus[VK_MAX_PHYSICAL_GPUS];
|
||||
uint32_t gpu_count;
|
||||
VK_BASE_LAYER_OBJECT *gpus;
|
||||
VkBaseLayerObject *gpus;
|
||||
|
||||
struct loader_icd *next;
|
||||
};
|
||||
@ -517,7 +510,7 @@ static void layer_lib_scan(void)
|
||||
loader.layer_scanned = true;
|
||||
}
|
||||
|
||||
static void loader_init_dispatch_table(VK_LAYER_DISPATCH_TABLE *tab, PFN_vkGetProcAddr fpGPA, VkPhysicalGpu gpu)
|
||||
static void loader_init_dispatch_table(VkLayerDispatchTable *tab, PFN_vkGetProcAddr fpGPA, VkPhysicalGpu gpu)
|
||||
{
|
||||
loader_initialize_dispatch_table(tab, fpGPA, gpu);
|
||||
|
||||
@ -525,7 +518,7 @@ static void loader_init_dispatch_table(VK_LAYER_DISPATCH_TABLE *tab, PFN_vkGetPr
|
||||
tab->EnumerateLayers = vkEnumerateLayers;
|
||||
}
|
||||
|
||||
static struct loader_icd * loader_get_icd(const VK_BASE_LAYER_OBJECT *gpu, uint32_t *gpu_index)
|
||||
extern struct loader_icd * loader_get_icd(const VkBaseLayerObject *gpu, uint32_t *gpu_index)
|
||||
{
|
||||
for (struct loader_instance *inst = loader.instances; inst; inst = inst->next) {
|
||||
for (struct loader_icd *icd = inst->icds; icd; icd = icd->next) {
|
||||
@ -716,7 +709,7 @@ static uint32_t loader_get_layer_env(struct loader_icd *icd, uint32_t gpu_index,
|
||||
return count;
|
||||
}
|
||||
|
||||
static uint32_t loader_get_layer_libs(struct loader_icd *icd, uint32_t gpu_index, const VkDeviceCreateInfo* pCreateInfo, struct layer_name_pair **ppLayerNames)
|
||||
static uint32_t loader_get_layer_libs(struct loader_icd *icd, uint32_t gpu_index, uint32_t ext_count, const char *const* ext_names, struct layer_name_pair **ppLayerNames)
|
||||
{
|
||||
static struct layer_name_pair layerNames[MAX_LAYER_LIBRARIES];
|
||||
const char *lib_name = NULL;
|
||||
@ -726,8 +719,8 @@ static uint32_t loader_get_layer_libs(struct loader_icd *icd, uint32_t gpu_index
|
||||
/* Load any layers specified in the environment first */
|
||||
count = loader_get_layer_env(icd, gpu_index, layerNames);
|
||||
|
||||
for (uint32_t i = 0; i < pCreateInfo->extensionCount; i++) {
|
||||
const char *pExtName = pCreateInfo->ppEnabledExtensionNames[i];
|
||||
for (uint32_t i = 0; i < ext_count; i++) {
|
||||
const char *pExtName = ext_names[i];
|
||||
|
||||
if (find_layer_extension(icd, gpu_index, pExtName, &lib_name) == VK_SUCCESS) {
|
||||
uint32_t len;
|
||||
@ -790,29 +783,28 @@ static void loader_deactivate_layer(const struct loader_instance *instance)
|
||||
}
|
||||
}
|
||||
|
||||
extern uint32_t loader_activate_layers(VkPhysicalGpu gpu, const VkDeviceCreateInfo* pCreateInfo)
|
||||
extern uint32_t loader_activate_layers(struct loader_icd *icd, uint32_t gpu_index, uint32_t ext_count, const char *const* ext_names)
|
||||
{
|
||||
uint32_t gpu_index;
|
||||
uint32_t count;
|
||||
VkBaseLayerObject *gpu;
|
||||
struct layer_name_pair *pLayerNames;
|
||||
struct loader_icd *icd = loader_get_icd((const VK_BASE_LAYER_OBJECT *) gpu, &gpu_index);
|
||||
|
||||
if (!icd)
|
||||
return 0;
|
||||
assert(gpu_index < VK_MAX_PHYSICAL_GPUS);
|
||||
|
||||
gpu = icd->gpus + gpu_index;
|
||||
/* activate any layer libraries */
|
||||
if (!loader_layers_activated(icd, gpu_index)) {
|
||||
VK_BASE_LAYER_OBJECT *gpuObj = (VK_BASE_LAYER_OBJECT *) gpu;
|
||||
VK_BASE_LAYER_OBJECT *nextGpuObj, *baseObj = gpuObj->baseObject;
|
||||
VkBaseLayerObject *gpuObj = gpu;
|
||||
VkBaseLayerObject *nextGpuObj, *baseObj = gpuObj->baseObject;
|
||||
PFN_vkGetProcAddr nextGPA = vkGetProcAddr;
|
||||
|
||||
count = loader_get_layer_libs(icd, gpu_index, pCreateInfo, &pLayerNames);
|
||||
count = loader_get_layer_libs(icd, gpu_index, ext_count, ext_names, &pLayerNames);
|
||||
if (!count)
|
||||
return 0;
|
||||
loader_init_layer_libs(icd, gpu_index, pLayerNames, count);
|
||||
|
||||
icd->wrappedGpus[gpu_index] = malloc(sizeof(VK_BASE_LAYER_OBJECT) * icd->layer_count[gpu_index]);
|
||||
icd->wrappedGpus[gpu_index] = malloc(sizeof(VkBaseLayerObject) * icd->layer_count[gpu_index]);
|
||||
if (! icd->wrappedGpus[gpu_index])
|
||||
loader_log(VK_DBG_MSG_ERROR, 0, "Failed to malloc Gpu objects for layer");
|
||||
for (int32_t i = icd->layer_count[gpu_index] - 1; i >= 0; i--) {
|
||||
@ -834,8 +826,8 @@ extern uint32_t loader_activate_layers(VkPhysicalGpu gpu, const VkDeviceCreateIn
|
||||
if (i == 0) {
|
||||
loader_init_dispatch_table(icd->loader_dispatch + gpu_index, nextGPA, gpuObj);
|
||||
//Insert the new wrapped objects into the list with loader object at head
|
||||
((VK_BASE_LAYER_OBJECT *) gpu)->nextObject = gpuObj;
|
||||
((VK_BASE_LAYER_OBJECT *) gpu)->pGPA = nextGPA;
|
||||
gpu->nextObject = gpuObj;
|
||||
gpu->pGPA = nextGPA;
|
||||
gpuObj = icd->wrappedGpus[gpu_index] + icd->layer_count[gpu_index] - 1;
|
||||
gpuObj->nextObject = baseObj;
|
||||
gpuObj->pGPA = icd->scanned_icds->GetProcAddr;
|
||||
@ -845,7 +837,7 @@ extern uint32_t loader_activate_layers(VkPhysicalGpu gpu, const VkDeviceCreateIn
|
||||
}
|
||||
else {
|
||||
//make sure requested Layers matches currently activated Layers
|
||||
count = loader_get_layer_libs(icd, gpu_index, pCreateInfo, &pLayerNames);
|
||||
count = loader_get_layer_libs(icd, gpu_index, ext_count, ext_names, &pLayerNames);
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
if (strcmp(icd->layer_libs[gpu_index][i].name, pLayerNames[i].layer_name)) {
|
||||
loader_log(VK_DBG_MSG_ERROR, 0, "Layers activated != Layers requested");
|
||||
@ -986,7 +978,7 @@ LOADER_EXPORT VkResult VKAPI vkEnumerateGpus(
|
||||
icd = ptr_instance->icds;
|
||||
while (icd) {
|
||||
VkPhysicalGpu gpus[VK_MAX_PHYSICAL_GPUS];
|
||||
VK_BASE_LAYER_OBJECT * wrapped_gpus;
|
||||
VkBaseLayerObject * wrapped_gpus;
|
||||
PFN_vkGetProcAddr get_proc_addr = icd->scanned_icds->GetProcAddr;
|
||||
uint32_t n, max = maxGpus - count;
|
||||
|
||||
@ -998,12 +990,12 @@ LOADER_EXPORT VkResult VKAPI vkEnumerateGpus(
|
||||
max, &n,
|
||||
gpus);
|
||||
if (res == VK_SUCCESS && n) {
|
||||
wrapped_gpus = (VK_BASE_LAYER_OBJECT*) malloc(n *
|
||||
sizeof(VK_BASE_LAYER_OBJECT));
|
||||
wrapped_gpus = (VkBaseLayerObject*) malloc(n *
|
||||
sizeof(VkBaseLayerObject));
|
||||
icd->gpus = wrapped_gpus;
|
||||
icd->gpu_count = n;
|
||||
icd->loader_dispatch = (VK_LAYER_DISPATCH_TABLE *) malloc(n *
|
||||
sizeof(VK_LAYER_DISPATCH_TABLE));
|
||||
icd->loader_dispatch = (VkLayerDispatchTable *) malloc(n *
|
||||
sizeof(VkLayerDispatchTable));
|
||||
for (unsigned int i = 0; i < n; i++) {
|
||||
(wrapped_gpus + i)->baseObject = gpus[i];
|
||||
(wrapped_gpus + i)->pGPA = get_proc_addr;
|
||||
@ -1019,8 +1011,8 @@ LOADER_EXPORT VkResult VKAPI vkEnumerateGpus(
|
||||
assert(0);
|
||||
}
|
||||
|
||||
const VK_LAYER_DISPATCH_TABLE **disp;
|
||||
disp = (const VK_LAYER_DISPATCH_TABLE **) gpus[i];
|
||||
const VkLayerDispatchTable **disp;
|
||||
disp = (const VkLayerDispatchTable **) gpus[i];
|
||||
*disp = icd->loader_dispatch + i;
|
||||
}
|
||||
|
||||
@ -1044,8 +1036,8 @@ LOADER_EXPORT void * VKAPI vkGetProcAddr(VkPhysicalGpu gpu, const char * pName)
|
||||
if (gpu == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
VK_BASE_LAYER_OBJECT* gpuw = (VK_BASE_LAYER_OBJECT *) gpu;
|
||||
VK_LAYER_DISPATCH_TABLE * disp_table = * (VK_LAYER_DISPATCH_TABLE **) gpuw->baseObject;
|
||||
VkBaseLayerObject* gpuw = (VkBaseLayerObject *) gpu;
|
||||
VkLayerDispatchTable * disp_table = * (VkLayerDispatchTable **) gpuw->baseObject;
|
||||
void *addr;
|
||||
|
||||
if (disp_table == NULL)
|
||||
@ -1064,7 +1056,7 @@ LOADER_EXPORT void * VKAPI vkGetProcAddr(VkPhysicalGpu gpu, const char * pName)
|
||||
LOADER_EXPORT VkResult VKAPI vkGetExtensionSupport(VkPhysicalGpu gpu, const char *pExtName)
|
||||
{
|
||||
uint32_t gpu_index;
|
||||
struct loader_icd *icd = loader_get_icd((const VK_BASE_LAYER_OBJECT *) gpu, &gpu_index);
|
||||
struct loader_icd *icd = loader_get_icd((const VkBaseLayerObject *) gpu, &gpu_index);
|
||||
|
||||
if (!icd)
|
||||
return VK_ERROR_UNAVAILABLE;
|
||||
@ -1077,7 +1069,7 @@ LOADER_EXPORT VkResult VKAPI vkEnumerateLayers(VkPhysicalGpu gpu, size_t maxLaye
|
||||
uint32_t gpu_index;
|
||||
size_t count = 0;
|
||||
char *lib_name;
|
||||
struct loader_icd *icd = loader_get_icd((const VK_BASE_LAYER_OBJECT *) gpu, &gpu_index);
|
||||
struct loader_icd *icd = loader_get_icd((const VkBaseLayerObject *) gpu, &gpu_index);
|
||||
loader_platform_dl_handle handle;
|
||||
PFN_vkEnumerateLayers fpEnumerateLayers;
|
||||
char layer_buf[16][256];
|
||||
|
@ -67,14 +67,22 @@ static inline void loader_init_data(void *obj, const void *data)
|
||||
|
||||
static inline void *loader_unwrap_gpu(VkPhysicalGpu *gpu)
|
||||
{
|
||||
const VK_BASE_LAYER_OBJECT *wrap = (const VK_BASE_LAYER_OBJECT *) *gpu;
|
||||
const VkBaseLayerObject *wrap = (const VkBaseLayerObject *) *gpu;
|
||||
|
||||
*gpu = (VkPhysicalGpu) wrap->nextObject;
|
||||
|
||||
return loader_get_data(wrap->baseObject);
|
||||
}
|
||||
|
||||
extern uint32_t loader_activate_layers(VkPhysicalGpu gpu, const VkDeviceCreateInfo* pCreateInfo);
|
||||
struct loader_instance {
|
||||
struct loader_icd *icds;
|
||||
struct loader_instance *next;
|
||||
uint32_t extension_count;
|
||||
char **extension_names;
|
||||
};
|
||||
|
||||
extern uint32_t loader_activate_layers(struct loader_icd *icd, uint32_t gpu_index, uint32_t ext_count, const char *const* ext_names);
|
||||
extern struct loader_icd * loader_get_icd(const VkBaseLayerObject *gpu, uint32_t *gpu_index);
|
||||
#define MAX_LAYER_LIBRARIES 64
|
||||
|
||||
#endif /* LOADER_H */
|
||||
|
@ -154,15 +154,19 @@ class LoaderEntrypointsSubcommand(Subcommand):
|
||||
func.append("{")
|
||||
|
||||
# declare local variables
|
||||
func.append(" const VK_LAYER_DISPATCH_TABLE *disp;")
|
||||
func.append(" const VkLayerDispatchTable *disp;")
|
||||
if proto.ret != 'void' and obj_setup:
|
||||
func.append(" VkResult res;")
|
||||
func.append("")
|
||||
|
||||
# active layers before dispatching CreateDevice
|
||||
if proto.name == "CreateDevice":
|
||||
func.append(" loader_activate_layers(%s, %s);" %
|
||||
(proto.params[0].name, proto.params[1].name))
|
||||
func.append(" {")
|
||||
func.append(" uint32_t gpu_index;")
|
||||
func.append(" struct loader_icd *icd = loader_get_icd((const VkBaseLayerObject *) gpu, &gpu_index);")
|
||||
func.append(" loader_activate_layers((void *) icd, gpu_index, %s->extensionCount, %s->ppEnabledExtensionNames);"
|
||||
% (proto.params[1].name, proto.params[1].name))
|
||||
func.append(" }")
|
||||
func.append("")
|
||||
|
||||
# get dispatch table and unwrap GPUs
|
||||
@ -235,7 +239,7 @@ class DispatchTableOpsSubcommand(Subcommand):
|
||||
stmts.append("#endif")
|
||||
|
||||
func = []
|
||||
func.append("static inline void %s_initialize_dispatch_table(VK_LAYER_DISPATCH_TABLE *table,"
|
||||
func.append("static inline void %s_initialize_dispatch_table(VkLayerDispatchTable *table,"
|
||||
% self.prefix)
|
||||
func.append("%s PFN_vkGetProcAddr gpa,"
|
||||
% (" " * len(self.prefix)))
|
||||
@ -258,7 +262,7 @@ class DispatchTableOpsSubcommand(Subcommand):
|
||||
lookups.append("#endif")
|
||||
|
||||
func = []
|
||||
func.append("static inline void *%s_lookup_dispatch_table(const VK_LAYER_DISPATCH_TABLE *table,"
|
||||
func.append("static inline void *%s_lookup_dispatch_table(const VkLayerDispatchTable *table,"
|
||||
% self.prefix)
|
||||
func.append("%s const char *name)"
|
||||
% (" " * len(self.prefix)))
|
||||
|
@ -194,6 +194,28 @@ class Subcommand(object):
|
||||
ur_body.append('}')
|
||||
return "\n".join(ur_body)
|
||||
|
||||
def _gen_layer_get_extension_support(self, layer="Generic"):
|
||||
ges_body = []
|
||||
ges_body.append('VK_LAYER_EXPORT VkResult VKAPI vkGetExtensionSupport(VkPhysicalGpu gpu, const char* pExtName)')
|
||||
ges_body.append('{')
|
||||
ges_body.append(' VkResult result;')
|
||||
ges_body.append(' VkBaseLayerObject* gpuw = (VkBaseLayerObject *) gpu;')
|
||||
ges_body.append('')
|
||||
ges_body.append(' /* This entrypoint is NOT going to init its own dispatch table since loader calls here early */')
|
||||
ges_body.append(' if (!strncmp(pExtName, "%s", strlen("%s")))' % (layer, layer))
|
||||
ges_body.append(' {')
|
||||
ges_body.append(' result = VK_SUCCESS;')
|
||||
ges_body.append(' } else if (nextTable.GetExtensionSupport != NULL)')
|
||||
ges_body.append(' {')
|
||||
ges_body.append(' result = nextTable.GetExtensionSupport((VkPhysicalGpu)gpuw->nextObject, pExtName);')
|
||||
ges_body.append(' } else')
|
||||
ges_body.append(' {')
|
||||
ges_body.append(' result = VK_ERROR_INVALID_EXTENSION;')
|
||||
ges_body.append(' }')
|
||||
ges_body.append(' return result;')
|
||||
ges_body.append('}')
|
||||
return "\n".join(ges_body)
|
||||
|
||||
def _gen_layer_get_extension_support(self, layer="Generic"):
|
||||
ges_body = []
|
||||
ges_body.append('VK_LAYER_EXPORT VkResult VKAPI vkGetExtensionSupport(VkPhysicalGpu gpu, const char* pExtName)')
|
||||
@ -296,6 +318,20 @@ class Subcommand(object):
|
||||
exts.append(' return VK_SUCCESS;')
|
||||
exts.append('}')
|
||||
|
||||
def _generate_layer_gpa_function(self, extensions=[]):
|
||||
func_body = []
|
||||
func_body.append("VK_LAYER_EXPORT void* VKAPI vkGetProcAddr(VkPhysicalGpu gpu, const char* funcName)\n"
|
||||
"{\n"
|
||||
" VkBaseLayerObject* gpuw = (VkBaseLayerObject *) gpu;\n"
|
||||
" void* addr;\n"
|
||||
" if (gpu == NULL)\n"
|
||||
" return NULL;\n"
|
||||
" pCurObj = gpuw;\n"
|
||||
" loader_platform_thread_once(&tabOnce, init%s);\n\n"
|
||||
" addr = layer_intercept_proc(funcName);\n"
|
||||
" if (addr)\n"
|
||||
" return addr;" % self.layer_name)
|
||||
|
||||
return "\n".join(exts)
|
||||
|
||||
def _generate_layer_gpa_function(self, extensions=[]):
|
||||
@ -394,7 +430,7 @@ class LayerDispatchSubcommand(Subcommand):
|
||||
|
||||
class GenericLayerSubcommand(Subcommand):
|
||||
def generate_header(self):
|
||||
return '#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include "loader_platform.h"\n#include "vkLayer.h"\n//The following is #included again to catch certain OS-specific functions being used:\n#include "loader_platform.h"\n\n#include "layers_config.h"\n#include "layers_msg.h"\n\nstatic VK_LAYER_DISPATCH_TABLE nextTable;\nstatic VK_BASE_LAYER_OBJECT *pCurObj;\n\nstatic LOADER_PLATFORM_THREAD_ONCE_DECLARATION(tabOnce);'
|
||||
return '#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include "loader_platform.h"\n#include "vkLayer.h"\n//The following is #included again to catch certain OS-specific functions being used:\n#include "loader_platform.h"\n\n#include "layers_config.h"\n#include "layers_msg.h"\n\nstatic VkLayerDispatchTable nextTable;\nstatic VkBaseLayerObject *pCurObj;\n\nstatic LOADER_PLATFORM_THREAD_ONCE_DECLARATION(tabOnce);'
|
||||
|
||||
def generate_intercept(self, proto, qual):
|
||||
if proto.name in [ 'DbgRegisterMsgCallback', 'DbgUnregisterMsgCallback' , 'GetExtensionSupport']:
|
||||
@ -416,7 +452,7 @@ class GenericLayerSubcommand(Subcommand):
|
||||
'{\n'
|
||||
' char str[1024];\n'
|
||||
' if (gpu != NULL) {\n'
|
||||
' VK_BASE_LAYER_OBJECT* gpuw = (VK_BASE_LAYER_OBJECT *) %s;\n'
|
||||
' VkBaseLayerObject* gpuw = (VkBaseLayerObject *) %s;\n'
|
||||
' sprintf(str, "At start of layered %s\\n");\n'
|
||||
' layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, gpu, 0, 0, (char *) "GENERIC", (char *) str);\n'
|
||||
' pCurObj = gpuw;\n'
|
||||
@ -446,7 +482,7 @@ class GenericLayerSubcommand(Subcommand):
|
||||
funcs.append('%s%s\n'
|
||||
'{\n'
|
||||
' char str[1024];'
|
||||
' VK_BASE_LAYER_OBJECT* gpuw = (VK_BASE_LAYER_OBJECT *) %s;\n'
|
||||
' VkBaseLayerObject* gpuw = (VkBaseLayerObject *) %s;\n'
|
||||
' sprintf(str, "At start of layered %s\\n");\n'
|
||||
' layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, gpuw, 0, 0, (char *) "GENERIC", (char *) str);\n'
|
||||
' pCurObj = gpuw;\n'
|
||||
@ -508,8 +544,8 @@ class APIDumpSubcommand(Subcommand):
|
||||
header_txt.append('// The following is #included again to catch certain OS-specific functions being used:')
|
||||
header_txt.append('#include "loader_platform.h"')
|
||||
header_txt.append('')
|
||||
header_txt.append('static VK_LAYER_DISPATCH_TABLE nextTable;')
|
||||
header_txt.append('static VK_BASE_LAYER_OBJECT *pCurObj;')
|
||||
header_txt.append('static VkLayerDispatchTable nextTable;')
|
||||
header_txt.append('static VkBaseLayerObject *pCurObj;')
|
||||
header_txt.append('')
|
||||
header_txt.append('static LOADER_PLATFORM_THREAD_ONCE_DECLARATION(tabOnce);')
|
||||
header_txt.append('static int printLockInitialized = 0;')
|
||||
@ -702,7 +738,7 @@ class APIDumpSubcommand(Subcommand):
|
||||
'{\n'
|
||||
' using namespace StreamControl;\n'
|
||||
' if (gpu != NULL) {\n'
|
||||
' VK_BASE_LAYER_OBJECT* gpuw = (VK_BASE_LAYER_OBJECT *) %s;\n'
|
||||
' VkBaseLayerObject* gpuw = (VkBaseLayerObject *) %s;\n'
|
||||
' pCurObj = gpuw;\n'
|
||||
' loader_platform_thread_once(&tabOnce, init%s);\n'
|
||||
' %snextTable.%s;\n'
|
||||
@ -721,7 +757,7 @@ class APIDumpSubcommand(Subcommand):
|
||||
c_call = proto.c_call().replace("(" + proto.params[0].name, "((VkPhysicalGpu)gpuw->nextObject", 1)
|
||||
funcs.append('%s%s\n'
|
||||
'{\n'
|
||||
' VK_BASE_LAYER_OBJECT* gpuw = (VK_BASE_LAYER_OBJECT *) %s;\n'
|
||||
' VkBaseLayerObject* gpuw = (VkBaseLayerObject *) %s;\n'
|
||||
' VkResult result;\n'
|
||||
' /* This entrypoint is NOT going to init its own dispatch table since loader calls here early */\n'
|
||||
' if (!strncmp(pExtName, "%s", strlen("%s")))\n'
|
||||
@ -745,6 +781,18 @@ class APIDumpSubcommand(Subcommand):
|
||||
' %s%s%s\n'
|
||||
'%s'
|
||||
'}' % (qual, decl, ret_val, proto.c_call(), f_open, log_func, f_close, stmt))
|
||||
else:
|
||||
c_call = proto.c_call().replace("(" + proto.params[0].name, "((VkPhysicalGpu)gpuw->nextObject", 1)
|
||||
funcs.append('%s%s\n'
|
||||
'{\n'
|
||||
' using namespace StreamControl;\n'
|
||||
' VkBaseLayerObject* gpuw = (VkBaseLayerObject *) %s;\n'
|
||||
' pCurObj = gpuw;\n'
|
||||
' loader_platform_thread_once(&tabOnce, init%s);\n'
|
||||
' %snextTable.%s;\n'
|
||||
' %s%s%s\n'
|
||||
'%s'
|
||||
'}' % (qual, decl, ret_val, proto.c_call(), f_open, log_func, f_close, stmt))
|
||||
else:
|
||||
c_call = proto.c_call().replace("(" + proto.params[0].name, "((VkPhysicalGpu)gpuw->nextObject", 1)
|
||||
funcs.append('%s%s\n'
|
||||
@ -777,7 +825,7 @@ class APIDumpSubcommand(Subcommand):
|
||||
# header_txt.append('#include "vkLayer.h"\n#include "vk_struct_string_helper_no_addr_cpp.h"\n')
|
||||
# header_txt.append('// The following is #included again to catch certain OS-specific functions being used:')
|
||||
# header_txt.append('#include "loader_platform.h"')
|
||||
# header_txt.append('static VK_LAYER_DISPATCH_TABLE nextTable;')
|
||||
# header_txt.append('static VkLayerDispatchTable nextTable;')
|
||||
# header_txt.append('static VK_BASE_LAYER_OBJECT *pCurObj;\n')
|
||||
# header_txt.append('static LOADER_PLATFORM_THREAD_ONCE_DECLARATION(tabOnce);')
|
||||
# header_txt.append('static int printLockInitialized = 0;')
|
||||
@ -814,7 +862,7 @@ class ObjectTrackerSubcommand(Subcommand):
|
||||
def generate_header(self):
|
||||
header_txt = []
|
||||
header_txt.append('#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include "loader_platform.h"')
|
||||
header_txt.append('#include "object_track.h"\n\nstatic VK_LAYER_DISPATCH_TABLE nextTable;\nstatic VK_BASE_LAYER_OBJECT *pCurObj;')
|
||||
header_txt.append('#include "object_track.h"\n\nstatic VkLayerDispatchTable nextTable;\nstatic VkBaseLayerObject *pCurObj;')
|
||||
header_txt.append('// The following is #included again to catch certain OS-specific functions being used:')
|
||||
header_txt.append('#include "loader_platform.h"')
|
||||
header_txt.append('#include "layers_config.h"')
|
||||
@ -1352,7 +1400,7 @@ class ObjectTrackerSubcommand(Subcommand):
|
||||
funcs.append('%s%s\n'
|
||||
'{\n'
|
||||
' if (gpu != NULL) {\n'
|
||||
' VK_BASE_LAYER_OBJECT* gpuw = (VK_BASE_LAYER_OBJECT *) %s;\n'
|
||||
' VkBaseLayerObject* gpuw = (VkBaseLayerObject *) %s;\n'
|
||||
' %s'
|
||||
' pCurObj = gpuw;\n'
|
||||
' loader_platform_thread_once(&tabOnce, init%s);\n'
|
||||
@ -1372,7 +1420,7 @@ class ObjectTrackerSubcommand(Subcommand):
|
||||
c_call = proto.c_call().replace("(" + proto.params[0].name, "((VkPhysicalGpu)gpuw->nextObject", 1)
|
||||
funcs.append('%s%s\n'
|
||||
'{\n'
|
||||
' VK_BASE_LAYER_OBJECT* gpuw = (VK_BASE_LAYER_OBJECT *) %s;\n'
|
||||
' VkBaseLayerObject* gpuw = (VkBaseLayerObject *) %s;\n'
|
||||
' VkResult result;\n'
|
||||
' /* This entrypoint is NOT going to init its own dispatch table since loader calls this early */\n'
|
||||
' if (!strncmp(pExtName, "%s", strlen("%s")) ||\n'
|
||||
@ -1409,7 +1457,7 @@ class ObjectTrackerSubcommand(Subcommand):
|
||||
gpu_state += ' }\n'
|
||||
funcs.append('%s%s\n'
|
||||
'{\n'
|
||||
' VK_BASE_LAYER_OBJECT* gpuw = (VK_BASE_LAYER_OBJECT *) %s;\n'
|
||||
' VkBaseLayerObject* gpuw = (VkBaseLayerObject *) %s;\n'
|
||||
'%s'
|
||||
' pCurObj = gpuw;\n'
|
||||
' loader_platform_thread_once(&tabOnce, init%s);\n'
|
||||
|
@ -1024,11 +1024,11 @@ def parse_vk_h(filename):
|
||||
print("core =", str(ext))
|
||||
|
||||
print("")
|
||||
print("typedef struct _VK_LAYER_DISPATCH_TABLE")
|
||||
print("typedef struct VkLayerDispatchTable_")
|
||||
print("{")
|
||||
for proto in ext.protos:
|
||||
print(" vk%sType %s;" % (proto.name, proto.name))
|
||||
print("} VK_LAYER_DISPATCH_TABLE;")
|
||||
print("} VkLayerDispatchTable;")
|
||||
|
||||
if __name__ == "__main__":
|
||||
parse_vk_h("include/vulkan.h")
|
||||
|
Loading…
Reference in New Issue
Block a user