Loader only wraps GPU objects for creating a layer chain. After layer activation
layers and loader use unwrapped gpu object returned by the driver.
This is a large simplification.
This fixes a nasty bug where layers intercepting entrypoints with gpu objects
but not all these entrypoints would fail. These would cause non-uniform
unwrapping of gpu objects by the time the driver was called with a gpu object.
Fixes issue in loader_get_icd where it was trying to compare a wrapped GPU
against a non-wrapped GPU.
VkLayerDispatchTable *pTable;
assert(gpuw);
- std::unordered_map<void *, VkLayerDispatchTable *>::const_iterator it = tableMap.find((void *) gpuw);
+ std::unordered_map<void *, VkLayerDispatchTable *>::const_iterator it = tableMap.find((void *) gpuw->baseObject);
if (it == tableMap.end())
{
pTable = new VkLayerDispatchTable;
- tableMap[(void *) gpuw] = pTable;
+ tableMap[(void *) gpuw->baseObject] = pTable;
} else
{
return it->second;
VK_LAYER_EXPORT VkResult VKAPI vkGetExtensionSupport(VkPhysicalGpu gpu, const char* pExtName)
{
VkResult result;
- VkBaseLayerObject* gpuw = (VkBaseLayerObject *) gpu;
/* This entrypoint is NOT going to init it's own dispatch table since loader calls here early */
if (!strncmp(pExtName, "vkLayerExtension1", strlen("vkLayerExtension1")))
} else if (!strncmp(pExtName, "Basic", strlen("Basic")))
{
result = VK_SUCCESS;
- } else if (!tableMap.empty() && (tableMap.find(gpuw) != tableMap.end()))
+ } else if (!tableMap.empty() && (tableMap.find(gpu) != tableMap.end()))
{
printf("At start of wrapped vkGetExtensionSupport() call w/ gpu: %p\n", (void*)gpu);
- VkLayerDispatchTable* pTable = tableMap[gpuw];
- result = pTable->GetExtensionSupport((VkPhysicalGpu)gpuw->nextObject, pExtName);
+ VkLayerDispatchTable* pTable = tableMap[gpu];
+ result = pTable->GetExtensionSupport(gpu, pExtName);
printf("Completed wrapped vkGetExtensionSupport() call w/ gpu: %p\n", (void*)gpu);
} else
{
VK_LAYER_EXPORT VkResult VKAPI vkCreateDevice(VkPhysicalGpu gpu, const VkDeviceCreateInfo* pCreateInfo, VkDevice* pDevice)
{
- VkBaseLayerObject* gpuw = (VkBaseLayerObject *) gpu;
- VkLayerDispatchTable* pTable = tableMap[gpuw];
+ VkLayerDispatchTable* pTable = tableMap[gpu];
printf("At start of wrapped vkCreateDevice() call w/ gpu: %p\n", (void*)gpu);
- VkResult result = pTable->CreateDevice((VkPhysicalGpu)gpuw->nextObject, pCreateInfo, pDevice);
+ VkResult result = pTable->CreateDevice(gpu, pCreateInfo, pDevice);
// create a mapping for the device object into the dispatch table
tableMap.emplace(*pDevice, pTable);
printf("Completed wrapped vkCreateDevice() call w/ pDevice, Device %p: %p\n", (void*)pDevice, (void *) *pDevice);
{
if (gpu != NULL)
{
- VkBaseLayerObject* gpuw = (VkBaseLayerObject *) gpu;
- VkLayerDispatchTable* pTable = initLayerTable(gpuw);
+ VkLayerDispatchTable* pTable = initLayerTable((const VkBaseLayerObject *) gpu);
printf("At start of wrapped vkEnumerateLayers() call w/ gpu: %p\n", gpu);
- VkResult result = pTable->EnumerateLayers((VkPhysicalGpu)gpuw->nextObject, maxLayerCount, maxStringSize, pOutLayerCount, pOutLayers, pReserved);
+ VkResult result = pTable->EnumerateLayers(gpu, maxLayerCount, maxStringSize, pOutLayerCount, pOutLayers, pReserved);
return result;
} else
{
VK_LAYER_EXPORT VkResult VKAPI vkCreateDevice(VkPhysicalGpu gpu, const VkDeviceCreateInfo* pCreateInfo, VkDevice* pDevice)
{
- VkBaseLayerObject* gpuw = (VkBaseLayerObject *) gpu;
- pCurObj = gpuw;
+ pCurObj = (VkBaseLayerObject *) gpu;
loader_platform_thread_once(&g_initOnce, initDrawState);
- VkResult result = nextTable.CreateDevice((VkPhysicalGpu)gpuw->nextObject, pCreateInfo, pDevice);
+ VkResult result = nextTable.CreateDevice(gpu, pCreateInfo, pDevice);
return result;
}
VK_LAYER_EXPORT VkResult VKAPI vkGetExtensionSupport(VkPhysicalGpu gpu, const char* pExtName)
{
- VkBaseLayerObject* gpuw = (VkBaseLayerObject *) gpu;
VkResult result;
+
/* This entrypoint is NOT going to init its own dispatch table since loader calls here early */
if (!strcmp(pExtName, "DrawState") || !strcmp(pExtName, "drawStateDumpDotFile") ||
!strcmp(pExtName, "drawStateDumpCommandBufferDotFile") || !strcmp(pExtName, "drawStateDumpPngFile"))
result = VK_SUCCESS;
} else if (nextTable.GetExtensionSupport != NULL)
{
- result = nextTable.GetExtensionSupport((VkPhysicalGpu)gpuw->nextObject, pExtName);
- } else
- {
+ result = nextTable.GetExtensionSupport(gpu, pExtName);
+ } else {
result = VK_ERROR_INVALID_EXTENSION;
}
return result;
{
if (gpu != NULL)
{
- VkBaseLayerObject* gpuw = (VkBaseLayerObject *) gpu;
- pCurObj = gpuw;
+ pCurObj = (VkBaseLayerObject *) gpu;
loader_platform_thread_once(&g_initOnce, initDrawState);
- VkResult result = nextTable.EnumerateLayers((VkPhysicalGpu)gpuw->nextObject, maxLayerCount, maxStringSize, pOutLayerCount, pOutLayers, pReserved);
+ VkResult result = nextTable.EnumerateLayers(gpu, maxLayerCount, maxStringSize, pOutLayerCount, pOutLayers, pReserved);
return result;
- } else
- {
+ } else {
if (pOutLayerCount == NULL || pOutLayers == NULL || pOutLayers[0] == NULL)
return VK_ERROR_INVALID_POINTER;
// This layer compatible with all GPUs
VK_LAYER_EXPORT VkResult VKAPI vkCreateDevice(VkPhysicalGpu gpu, const VkDeviceCreateInfo* pCreateInfo, VkDevice* pDevice)
{
- VkBaseLayerObject* gpuw = (VkBaseLayerObject *) gpu;
- pCurObj = gpuw;
+ pCurObj = (VkBaseLayerObject *) gpu;
loader_platform_thread_once(&g_initOnce, initMemTracker);
- VkResult result = nextTable.CreateDevice((VkPhysicalGpu)gpuw->nextObject, pCreateInfo, pDevice);
+ VkResult result = nextTable.CreateDevice(gpu, pCreateInfo, pDevice);
// Save off device in case we need it to create Fences
globalDevice = *pDevice;
return result;
VK_LAYER_EXPORT VkResult VKAPI vkGetExtensionSupport(VkPhysicalGpu gpu, const char* pExtName)
{
- VkBaseLayerObject* gpuw = (VkBaseLayerObject *) gpu;
VkResult result;
/* This entrypoint is NOT going to init its own dispatch table since loader calls here early */
if (!strcmp(pExtName, "MemTracker"))
result = VK_SUCCESS;
} else if (nextTable.GetExtensionSupport != NULL)
{
- result = nextTable.GetExtensionSupport((VkPhysicalGpu)gpuw->nextObject, pExtName);
+ result = nextTable.GetExtensionSupport(gpu, pExtName);
} else
{
result = VK_ERROR_INVALID_EXTENSION;
{
if (gpu != NULL)
{
- VkBaseLayerObject* gpuw = (VkBaseLayerObject *) gpu;
- pCurObj = gpuw;
+ pCurObj = (VkBaseLayerObject *) gpu;
loader_platform_thread_once(&g_initOnce, initMemTracker);
- VkResult result = nextTable.EnumerateLayers((VkPhysicalGpu)gpuw->nextObject, maxLayerCount,
+ VkResult result = nextTable.EnumerateLayers(gpu, maxLayerCount,
maxStringSize, pOutLayerCount, pOutLayers, pReserved);
return result;
} else
VkLayerDispatchTable *pTable;
assert(gpuw);
- std::unordered_map<void *, VkLayerDispatchTable *>::const_iterator it = tableMap1.find((void *) gpuw);
+ std::unordered_map<void *, VkLayerDispatchTable *>::const_iterator it = tableMap1.find((void *) gpuw->baseObject);
if (it == tableMap1.end())
{
pTable = new VkLayerDispatchTable;
- tableMap1[(void *) gpuw] = pTable;
+ tableMap1[(void *) gpuw->baseObject] = pTable;
initLayerTable(gpuw, pTable, 1);
return pTable;
} else
VK_LAYER_EXPORT VkResult VKAPI multi1CreateDevice(VkPhysicalGpu gpu, const VkDeviceCreateInfo* pCreateInfo,
VkDevice* pDevice)
{
- VkBaseLayerObject* gpuw = (VkBaseLayerObject *) gpu;
- VkLayerDispatchTable* pTable = getLayer1Table(gpuw);
-
+ VkLayerDispatchTable* pTable = tableMap1[gpu];
printf("At start of multi1 layer vkCreateDevice()\n");
- VkResult result = pTable->CreateDevice((VkPhysicalGpu)gpuw->nextObject, pCreateInfo, pDevice);
+ VkResult result = pTable->CreateDevice(gpu, pCreateInfo, pDevice);
// create a mapping for the device object into the dispatch table
tableMap1.emplace(*pDevice, pTable);
printf("Completed multi1 layer vkCreateDevice()\n");
if (gpu == NULL)
return vkEnumerateLayers(gpu, maxLayerCount, maxStringSize, pOutLayerCount, pOutLayers, pReserved);
- VkBaseLayerObject* gpuw = (VkBaseLayerObject *) gpu;
- VkLayerDispatchTable* pTable = getLayer1Table(gpuw);
-
+ VkLayerDispatchTable* pTable = tableMap1[gpu];
printf("At start of multi1 layer vkEnumerateLayers()\n");
- VkResult result = pTable->EnumerateLayers((VkPhysicalGpu)gpuw->nextObject, maxLayerCount, maxStringSize, pOutLayerCount, pOutLayers, pReserved);
+ VkResult result = pTable->EnumerateLayers(gpu, maxLayerCount, maxStringSize, pOutLayerCount, pOutLayers, pReserved);
printf("Completed multi1 layer vkEnumerateLayers()\n");
return result;
}
+VK_LAYER_EXPORT VkResult VKAPI multi1GetExtensionSupport(VkPhysicalGpu gpu, const char* pExtName)
+{
+ VkResult result;
+
+ if (!tableMap1.empty() && (tableMap1.find(gpu) != tableMap1.end()))
+ {
+ VkLayerDispatchTable* pTable = tableMap1[gpu];
+ result = pTable->GetExtensionSupport(gpu, pExtName);
+ } else
+ {
+ result = VK_ERROR_INVALID_EXTENSION;
+ }
+ return result;
+}
+
VK_LAYER_EXPORT void * VKAPI multi1GetProcAddr(VkPhysicalGpu gpu, const char* pName)
{
VkBaseLayerObject* gpuw = (VkBaseLayerObject *) gpu;
else if (!strncmp("vkStorePipeline", pName, sizeof ("vkStorePipeline")))
return (void *) multi1StorePipeline;
else if (!strncmp("vkGetExtensionSupport", pName, sizeof ("vkGetExtensionSupport")))
- return (void *) vkGetExtensionSupport;
+ return (void *) multi1GetExtensionSupport;
else {
if (gpuw->pGPA == NULL)
return NULL;
VkLayerDispatchTable *pTable;
assert(gpuw);
- std::unordered_map<void *, VkLayerDispatchTable *>::const_iterator it = tableMap2.find((void *) gpuw);
+ std::unordered_map<void *, VkLayerDispatchTable *>::const_iterator it = tableMap2.find((void *) gpuw->baseObject);
if (it == tableMap2.end())
{
pTable = new VkLayerDispatchTable;
- tableMap2[(void *) gpuw] = pTable;
+ tableMap2[(void *) gpuw->baseObject] = pTable;
initLayerTable(gpuw, pTable, 2);
return pTable;
} else
VK_LAYER_EXPORT VkResult VKAPI multi2CreateDevice(VkPhysicalGpu gpu, const VkDeviceCreateInfo* pCreateInfo,
VkDevice* pDevice)
{
- VkBaseLayerObject* gpuw = (VkBaseLayerObject *) gpu;
- VkLayerDispatchTable* pTable = getLayer2Table(gpuw);
+ VkLayerDispatchTable* pTable = tableMap2[gpu];
printf("At start of multi2 vkCreateDevice()\n");
- VkResult result = pTable->CreateDevice((VkPhysicalGpu)gpuw->nextObject, pCreateInfo, pDevice);
+ VkResult result = pTable->CreateDevice(gpu, pCreateInfo, pDevice);
// create a mapping for the device object into the dispatch table for layer2
tableMap2.emplace(*pDevice, pTable);
printf("Completed multi2 layer vkCreateDevice()\n");
if (gpu == NULL)
return vkEnumerateLayers(gpu, maxLayerCount, maxStringSize, pOutLayerCount, pOutLayers, pReserved);
- VkBaseLayerObject* gpuw = (VkBaseLayerObject *) gpu;
- VkLayerDispatchTable* pTable = getLayer2Table(gpuw);
+ VkLayerDispatchTable* pTable = tableMap2[gpu];
printf("At start of multi2 layer vkEnumerateLayers()\n");
- VkResult result = pTable->EnumerateLayers((VkPhysicalGpu)gpuw->nextObject, maxLayerCount, maxStringSize, pOutLayerCount, pOutLayers, pReserved);
+ VkResult result = pTable->EnumerateLayers(gpu, maxLayerCount, maxStringSize, pOutLayerCount, pOutLayers, pReserved);
printf("Completed multi2 layer vkEnumerateLayers()\n");
return result;
}
+VK_LAYER_EXPORT VkResult VKAPI multi2GetExtensionSupport(VkPhysicalGpu gpu, const char* pExtName)
+{
+ VkResult result;
+
+ if (!tableMap2.empty() && (tableMap2.find(gpu) != tableMap2.end()))
+ {
+ VkLayerDispatchTable* pTable = tableMap2[gpu];
+ result = pTable->GetExtensionSupport(gpu, pExtName);
+ } else
+ {
+ result = VK_ERROR_INVALID_EXTENSION;
+ }
+ return result;
+}
+
VK_LAYER_EXPORT void * VKAPI multi2GetProcAddr(VkPhysicalGpu gpu, const char* pName)
{
VkBaseLayerObject* gpuw = (VkBaseLayerObject *) gpu;
else if (!strncmp("vkBeginCommandBuffer", pName, sizeof ("vkBeginCommandBuffer")))
return (void *) multi2BeginCommandBuffer;
else if (!strncmp("vkGetExtensionSupport", pName, sizeof ("vkGetExtensionSupport")))
- return (void *) vkGetExtensionSupport;
+ return (void *) multi2GetExtensionSupport;
else {
if (gpuw->pGPA == NULL)
return NULL;
VK_LAYER_EXPORT VkResult VKAPI vkGetExtensionSupport(VkPhysicalGpu gpu, const char* pExtName)
{
VkResult result;
- VkBaseLayerObject* gpuw = (VkBaseLayerObject *) gpu;
/* This entrypoint is NOT going to init it's own dispatch table since loader calls here early */
if (!strncmp(pExtName, "multi1", strlen("multi1")))
} else if (!strncmp(pExtName, "multi2", strlen("multi2")))
{
result = VK_SUCCESS;
- } else if (!tableMap1.empty() && (tableMap1.find(gpuw) != tableMap1.end()))
+ } else if (!tableMap1.empty() && (tableMap1.find(gpu) != tableMap1.end()))
{
- VkLayerDispatchTable* pTable = tableMap1[gpuw];
- result = pTable->GetExtensionSupport((VkPhysicalGpu)gpuw->nextObject, pExtName);
- } else if (!tableMap2.empty() && (tableMap2.find(gpuw) != tableMap2.end()))
+ VkLayerDispatchTable* pTable = tableMap1[gpu];
+ result = pTable->GetExtensionSupport(gpu, pExtName);
+ } else if (!tableMap2.empty() && (tableMap2.find(gpu) != tableMap2.end()))
{
- VkLayerDispatchTable* pTable = tableMap2[gpuw];
- result = pTable->GetExtensionSupport((VkPhysicalGpu)gpuw->nextObject, pExtName);
+ VkLayerDispatchTable* pTable = tableMap2[gpu];
+ result = pTable->GetExtensionSupport(gpu, pExtName);
} else
{
result = VK_ERROR_INVALID_EXTENSION;
VK_LAYER_EXPORT VkResult VKAPI vkGetGpuInfo(VkPhysicalGpu gpu, VkPhysicalGpuInfoType infoType, size_t* pDataSize, void* pData)
{
- VkBaseLayerObject* gpuw = (VkBaseLayerObject *) gpu;
- pCurObj = gpuw;
+ pCurObj = (VkBaseLayerObject *) gpu;
loader_platform_thread_once(&tabOnce, initParamChecker);
char str[1024];
if (!validate_VkPhysicalGpuInfoType(infoType)) {
sprintf(str, "Parameter infoType to function GetGpuInfo has invalid value of %i.", (int)infoType);
layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, NULL, 0, 1, "PARAMCHECK", str);
}
- VkResult result = nextTable.GetGpuInfo((VkPhysicalGpu)gpuw->nextObject, infoType, pDataSize, pData);
+ VkResult result = nextTable.GetGpuInfo(gpu, infoType, pDataSize, pData);
return result;
}
VK_LAYER_EXPORT VkResult VKAPI vkCreateDevice(VkPhysicalGpu gpu, const VkDeviceCreateInfo* pCreateInfo, VkDevice* pDevice)
{
- VkBaseLayerObject* gpuw = (VkBaseLayerObject *) gpu;
- pCurObj = gpuw;
+ pCurObj = (VkBaseLayerObject *) gpu;
loader_platform_thread_once(&tabOnce, initParamChecker);
PreCreateDevice(gpu, pCreateInfo);
- VkResult result = nextTable.CreateDevice((VkPhysicalGpu)gpuw->nextObject, pCreateInfo, pDevice);
+ VkResult result = nextTable.CreateDevice(gpu, pCreateInfo, pDevice);
PostCreateDevice(result, pDevice);
return result;
}
VK_LAYER_EXPORT VkResult VKAPI vkGetExtensionSupport(VkPhysicalGpu gpu, const char* pExtName)
{
- VkBaseLayerObject* gpuw = (VkBaseLayerObject *) gpu;
- pCurObj = gpuw;
+ pCurObj = (VkBaseLayerObject *) gpu;
loader_platform_thread_once(&tabOnce, initParamChecker);
- VkResult result = nextTable.GetExtensionSupport((VkPhysicalGpu)gpuw->nextObject, pExtName);
+ VkResult result = nextTable.GetExtensionSupport(gpu, pExtName);
return result;
}
{
char str[1024];
if (gpu != NULL) {
- VkBaseLayerObject* gpuw = (VkBaseLayerObject *) gpu;
sprintf(str, "At start of layered EnumerateLayers\n");
layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, nullptr, 0, 0, "PARAMCHECK", str);
- pCurObj = gpuw;
+ pCurObj = (VkBaseLayerObject *) gpu;
loader_platform_thread_once(&tabOnce, initParamChecker);
- VkResult result = nextTable.EnumerateLayers((VkPhysicalGpu)gpuw->nextObject, maxLayerCount, maxStringSize, pOutLayerCount, pOutLayers, pReserved);
+ VkResult result = nextTable.EnumerateLayers(gpu, maxLayerCount, maxStringSize, pOutLayerCount, pOutLayers, pReserved);
sprintf(str, "Completed layered EnumerateLayers\n");
layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, nullptr, 0, 0, "PARAMCHECK", str);
fflush(stdout);
VK_LAYER_EXPORT VkResult VKAPI vkGetMultiGpuCompatibility(VkPhysicalGpu gpu0, VkPhysicalGpu gpu1, VkGpuCompatibilityInfo* pInfo)
{
- VkBaseLayerObject* gpuw = (VkBaseLayerObject *) gpu0;
- pCurObj = gpuw;
+ pCurObj = (VkBaseLayerObject *) gpu0;
loader_platform_thread_once(&tabOnce, initParamChecker);
- VkResult result = nextTable.GetMultiGpuCompatibility((VkPhysicalGpu)gpuw->nextObject, gpu1, pInfo);
+ VkResult result = nextTable.GetMultiGpuCompatibility(gpu0, gpu1, pInfo);
return result;
}
VK_LAYER_EXPORT VkResult VKAPI vkWsiX11AssociateConnection(VkPhysicalGpu gpu, const VK_WSI_X11_CONNECTION_INFO* pConnectionInfo)
{
- VkBaseLayerObject* gpuw = (VkBaseLayerObject *) gpu;
- pCurObj = gpuw;
+ pCurObj = (VkBaseLayerObject *) gpu;
loader_platform_thread_once(&tabOnce, initParamChecker);
- VkResult result = nextTable.WsiX11AssociateConnection((VkPhysicalGpu)gpuw->nextObject, pConnectionInfo);
+ VkResult result = nextTable.WsiX11AssociateConnection(gpu, pConnectionInfo);
return result;
}
extern struct loader_icd * loader_get_icd(const VkBaseLayerObject *gpu, uint32_t *gpu_index)
{
+ /*
+ * NOTE: at this time icd->gpus is pointing to wrapped GPUs, but no where else
+ * are wrapped gpus used. Should go away. The incoming gpu is NOT wrapped so
+ * need to test it against the wrapped GPU's base object.
+ */
for (struct loader_instance *inst = loader.instances; inst; inst = inst->next) {
for (struct loader_icd *icd = inst->icds; icd; icd = icd->next) {
for (uint32_t i = 0; i < icd->gpu_count; i++)
if ((icd->gpus + i) == gpu || (icd->gpus +i)->baseObject ==
- gpu->baseObject) {
+ gpu) {
*gpu_index = i;
return icd;
}
(wrapped_gpus + i)->baseObject = gpus[i];
(wrapped_gpus + i)->pGPA = get_proc_addr;
(wrapped_gpus + i)->nextObject = gpus[i];
- memcpy(pGpus + count, &wrapped_gpus, sizeof(*pGpus));
+ memcpy(pGpus + count, gpus, sizeof(*pGpus));
loader_init_dispatch_table(icd->loader_dispatch + i,
get_proc_addr, gpus[i]);
loader_set_data(obj, data);
}
-static inline void *loader_unwrap_gpu(VkPhysicalGpu *gpu)
-{
- const VkBaseLayerObject *wrap = (const VkBaseLayerObject *) *gpu;
-
- *gpu = (VkPhysicalGpu) wrap->nextObject;
-
- return loader_get_data(wrap->baseObject);
-}
-
struct loader_instance {
struct loader_icd *icds;
struct loader_instance *next;
func.append(" VkResult res;")
func.append("")
- # get dispatch table and unwrap GPUs
- for param in proto.params:
- stmt = ""
- if param.ty == "VkPhysicalGpu":
- stmt = "loader_unwrap_gpu(&%s);" % param.name
- if param == proto.params[0]:
- stmt = "disp = " + stmt
- elif param == proto.params[0]:
- stmt = "disp = loader_get_data(%s);" % param.name
-
- if stmt:
- func.append(" " + stmt)
+ # get dispatch table
+ func.append(" disp = loader_get_data(%s);" %
+ proto.params[0].name)
func.append("")
# dispatch!
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(' 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(' result = nextTable.GetExtensionSupport(gpu, pExtName);')
ges_body.append(' } else')
ges_body.append(' {')
ges_body.append(' result = VK_ERROR_INVALID_EXTENSION;')
if 'WsiX11AssociateConnection' == proto.name:
funcs.append("#if defined(__linux__) || defined(XCB_NVIDIA)")
if proto.name == "EnumerateLayers":
- c_call = proto.c_call().replace("(" + proto.params[0].name, "((VkPhysicalGpu)gpuw->nextObject", 1)
funcs.append('%s%s\n'
'{\n'
' char str[1024];\n'
' if (gpu != NULL) {\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'
+ ' pCurObj = (VkBaseLayerObject *) gpu;\n'
' loader_platform_thread_once(&tabOnce, init%s);\n'
' %snextTable.%s;\n'
' sprintf(str, "Completed layered %s\\n");\n'
' strncpy((char *) pOutLayers[0], "%s", maxStringSize);\n'
' return VK_SUCCESS;\n'
' }\n'
- '}' % (qual, decl, proto.params[0].name, proto.name, self.layer_name, ret_val, c_call, proto.name, stmt, self.layer_name))
- elif proto.params[0].ty != "VkPhysicalGpu":
- funcs.append('%s%s\n'
- '{\n'
- ' %snextTable.%s;\n'
- '%s'
- '}' % (qual, decl, ret_val, proto.c_call(), stmt))
+ '}' % (qual, decl, proto.name, self.layer_name, ret_val, proto.c_call(), proto.name, stmt, self.layer_name))
else:
- c_call = proto.c_call().replace("(" + proto.params[0].name, "((VkPhysicalGpu)gpuw->nextObject", 1)
funcs.append('%s%s\n'
'{\n'
- ' char str[1024];'
- ' 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'
- ' loader_platform_thread_once(&tabOnce, init%s);\n'
' %snextTable.%s;\n'
- ' sprintf(str, "Completed layered %s\\n");\n'
- ' layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, gpuw, 0, 0, (char *) "GENERIC", (char *) str);\n'
- ' fflush(stdout);\n'
'%s'
- '}' % (qual, decl, proto.params[0].name, proto.name, self.layer_name, ret_val, c_call, proto.name, stmt))
+ '}' % (qual, decl, ret_val, proto.c_call(), stmt))
if 'WsiX11QueuePresent' == proto.name:
funcs.append("#endif")
return "\n\n".join(funcs)
'{\n'
' using namespace StreamControl;\n'
' if (gpu != NULL) {\n'
- ' VkBaseLayerObject* gpuw = (VkBaseLayerObject *) %s;\n'
- ' pCurObj = gpuw;\n'
+ ' pCurObj = (VkBaseLayerObject *) gpu;\n'
' loader_platform_thread_once(&tabOnce, init%s);\n'
' %snextTable.%s;\n'
' %s %s %s\n'
' strncpy((char *) pOutLayers[0], "%s", maxStringSize);\n'
' return VK_SUCCESS;\n'
' }\n'
- '}' % (qual, decl, proto.params[0].name, self.layer_name, ret_val, c_call,f_open, log_func, f_close, stmt, self.layer_name))
+ '}' % (qual, decl, self.layer_name, ret_val, proto.c_call(),f_open, log_func, f_close, stmt, self.layer_name))
elif 'GetExtensionSupport' == proto.name:
- c_call = proto.c_call().replace("(" + proto.params[0].name, "((VkPhysicalGpu)gpuw->nextObject", 1)
funcs.append('%s%s\n'
'{\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'
' result = VK_ERROR_INVALID_EXTENSION;\n'
' }\n'
'%s'
- '}' % (qual, decl, proto.params[0].name, self.layer_name, self.layer_name, c_call, f_open, log_func, f_close, stmt))
- elif proto.params[0].ty != "VkPhysicalGpu":
- funcs.append('%s%s\n'
- '{\n'
- ' using namespace StreamControl;\n'
- ' %snextTable.%s;\n'
- ' %s%s%s\n'
- '%s'
- '}' % (qual, decl, ret_val, proto.c_call(), f_open, log_func, f_close, stmt))
+ '}' % (qual, decl, self.layer_name, self.layer_name, 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'
if 'WsiX11AssociateConnection' == proto.name:
funcs.append("#if defined(__linux__) || defined(XCB_NVIDIA)")
if proto.name == "EnumerateLayers":
- c_call = proto.c_call().replace("(" + proto.params[0].name, "((VkPhysicalGpu)gpuw->nextObject", 1)
funcs.append('%s%s\n'
'{\n'
' if (gpu != NULL) {\n'
- ' VkBaseLayerObject* gpuw = (VkBaseLayerObject *) %s;\n'
' %s'
- ' pCurObj = gpuw;\n'
+ ' pCurObj = (VkBaseLayerObject *) gpu;\n'
' loader_platform_thread_once(&tabOnce, init%s);\n'
' %snextTable.%s;\n'
' %s%s'
' strncpy((char *) pOutLayers[0], "%s", maxStringSize);\n'
' return VK_SUCCESS;\n'
' }\n'
- '}' % (qual, decl, proto.params[0].name, using_line, self.layer_name, ret_val, c_call, create_line, destroy_line, stmt, self.layer_name))
+ '}' % (qual, decl, using_line, self.layer_name, ret_val, proto.c_call(), create_line, destroy_line, stmt, self.layer_name))
elif 'GetExtensionSupport' == proto.name:
- c_call = proto.c_call().replace("(" + proto.params[0].name, "((VkPhysicalGpu)gpuw->nextObject", 1)
funcs.append('%s%s\n'
'{\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'
' result = VK_ERROR_INVALID_EXTENSION;\n'
' }\n'
'%s'
- '}' % (qual, decl, proto.params[0].name, self.layer_name, self.layer_name, using_line, c_call, stmt))
- elif proto.params[0].ty != "VkPhysicalGpu":
+ '}' % (qual, decl, self.layer_name, self.layer_name, using_line, proto.c_call(), stmt))
+ elif 'GetGpuInfo' in proto.name:
+ gpu_state = ' if (infoType == VK_INFO_TYPE_PHYSICAL_GPU_QUEUE_PROPERTIES) {\n'
+ gpu_state += ' if (pData != NULL) {\n'
+ gpu_state += ' setGpuQueueInfoState(pData);\n'
+ gpu_state += ' }\n'
+ gpu_state += ' }\n'
funcs.append('%s%s\n'
'{\n'
'%s'
+ ' pCurObj = (VkBaseLayerObject *) gpu;\n'
+ ' loader_platform_thread_once(&tabOnce, init%s);\n'
' %snextTable.%s;\n'
'%s%s'
'%s'
- '}' % (qual, decl, using_line, ret_val, proto.c_call(), create_line, destroy_line, stmt))
+ '%s'
+ '}' % (qual, decl, using_line, self.layer_name, ret_val, proto.c_call(), create_line, destroy_line, gpu_state, stmt))
else:
- c_call = proto.c_call().replace("(" + proto.params[0].name, "((VkPhysicalGpu)gpuw->nextObject", 1)
- gpu_state = ''
- if 'GetGpuInfo' in proto.name:
- gpu_state = ' if (infoType == VK_INFO_TYPE_PHYSICAL_GPU_QUEUE_PROPERTIES) {\n'
- gpu_state += ' if (pData != NULL) {\n'
- gpu_state += ' setGpuQueueInfoState(pData);\n'
- gpu_state += ' }\n'
- gpu_state += ' }\n'
funcs.append('%s%s\n'
'{\n'
- ' VkBaseLayerObject* gpuw = (VkBaseLayerObject *) %s;\n'
'%s'
- ' pCurObj = gpuw;\n'
- ' loader_platform_thread_once(&tabOnce, init%s);\n'
' %snextTable.%s;\n'
'%s%s'
'%s'
- '%s'
- '}' % (qual, decl, proto.params[0].name, using_line, self.layer_name, ret_val, c_call, create_line, destroy_line, gpu_state, stmt))
+ '}' % (qual, decl, using_line, ret_val, proto.c_call(), create_line, destroy_line, stmt))
if 'WsiX11QueuePresent' == proto.name:
funcs.append("#endif")
return "\n\n".join(funcs)