From a4131c4e8a3027dbda941e43992fa2435801247e Mon Sep 17 00:00:00 2001 From: Courtney Goeltzenleuchter Date: Wed, 8 Apr 2015 15:36:08 -0600 Subject: Stage 1 of rename TODO: re-enable glave build, advance API for glave v2: get rid of outdated code in tri introduced by rebase rename wsi_null.c (olv) --- layers/multi.cpp | 202 +++++++++++++++++++++++++++---------------------------- 1 file changed, 101 insertions(+), 101 deletions(-) (limited to 'layers/multi.cpp') diff --git a/layers/multi.cpp b/layers/multi.cpp index f8c2bc9f..a4856eb0 100644 --- a/layers/multi.cpp +++ b/layers/multi.cpp @@ -1,5 +1,5 @@ /* - * XGL + * Vulkan * * Copyright (C) 2014 LunarG, Inc. * @@ -28,27 +28,27 @@ #include #include #include "loader_platform.h" -#include "xgl_dispatch_table_helper.h" -#include "xglLayer.h" +#include "vk_dispatch_table_helper.h" +#include "vkLayer.h" // The following is #included again to catch certain OS-specific functions // being used: #include "loader_platform.h" -static void initLayerTable(const XGL_BASE_LAYER_OBJECT *gpuw, XGL_LAYER_DISPATCH_TABLE *pTable, const unsigned int layerNum); +static void initLayerTable(const VK_BASE_LAYER_OBJECT *gpuw, VK_LAYER_DISPATCH_TABLE *pTable, const unsigned int layerNum); /******************************** Layer multi1 functions **************************/ -static std::unordered_map tableMap1; +static std::unordered_map tableMap1; static bool layer1_first_activated = false; -static XGL_LAYER_DISPATCH_TABLE * getLayer1Table(const XGL_BASE_LAYER_OBJECT *gpuw) +static VK_LAYER_DISPATCH_TABLE * getLayer1Table(const VK_BASE_LAYER_OBJECT *gpuw) { - XGL_LAYER_DISPATCH_TABLE *pTable; + VK_LAYER_DISPATCH_TABLE *pTable; assert(gpuw); - std::unordered_map::const_iterator it = tableMap1.find((void *) gpuw); + std::unordered_map::const_iterator it = tableMap1.find((void *) gpuw); if (it == tableMap1.end()) { - pTable = new XGL_LAYER_DISPATCH_TABLE; + pTable = new VK_LAYER_DISPATCH_TABLE; tableMap1[(void *) gpuw] = pTable; initLayerTable(gpuw, pTable, 1); return pTable; @@ -62,98 +62,98 @@ extern "C" { #endif -XGL_LAYER_EXPORT XGL_RESULT XGLAPI multi1CreateDevice(XGL_PHYSICAL_GPU gpu, const XGL_DEVICE_CREATE_INFO* pCreateInfo, - XGL_DEVICE* pDevice) +VK_LAYER_EXPORT VK_RESULT VKAPI multi1CreateDevice(VK_PHYSICAL_GPU gpu, const VK_DEVICE_CREATE_INFO* pCreateInfo, + VK_DEVICE* pDevice) { - XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu; - XGL_LAYER_DISPATCH_TABLE* pTable = getLayer1Table(gpuw); + VK_BASE_LAYER_OBJECT* gpuw = (VK_BASE_LAYER_OBJECT *) gpu; + VK_LAYER_DISPATCH_TABLE* pTable = getLayer1Table(gpuw); - printf("At start of multi1 layer xglCreateDevice()\n"); - XGL_RESULT result = pTable->CreateDevice((XGL_PHYSICAL_GPU)gpuw->nextObject, pCreateInfo, pDevice); + printf("At start of multi1 layer vkCreateDevice()\n"); + VK_RESULT result = pTable->CreateDevice((VK_PHYSICAL_GPU)gpuw->nextObject, pCreateInfo, pDevice); // create a mapping for the device object into the dispatch table tableMap1.emplace(*pDevice, pTable); - printf("Completed multi1 layer xglCreateDevice()\n"); + printf("Completed multi1 layer vkCreateDevice()\n"); return result; } -XGL_LAYER_EXPORT XGL_RESULT XGLAPI multi1CreateGraphicsPipeline(XGL_DEVICE device, const XGL_GRAPHICS_PIPELINE_CREATE_INFO* pCreateInfo, - XGL_PIPELINE* pPipeline) +VK_LAYER_EXPORT VK_RESULT VKAPI multi1CreateGraphicsPipeline(VK_DEVICE device, const VK_GRAPHICS_PIPELINE_CREATE_INFO* pCreateInfo, + VK_PIPELINE* pPipeline) { - XGL_LAYER_DISPATCH_TABLE* pTable = tableMap1[device]; + VK_LAYER_DISPATCH_TABLE* pTable = tableMap1[device]; - printf("At start of multi1 layer xglCreateGraphicsPipeline()\n"); - XGL_RESULT result = pTable->CreateGraphicsPipeline(device, pCreateInfo, pPipeline); + printf("At start of multi1 layer vkCreateGraphicsPipeline()\n"); + VK_RESULT result = pTable->CreateGraphicsPipeline(device, pCreateInfo, pPipeline); // create a mapping for the pipeline object into the dispatch table tableMap1.emplace(*pPipeline, pTable); - printf("Completed multi1 layer xglCreateGraphicsPipeline()\n"); + printf("Completed multi1 layer vkCreateGraphicsPipeline()\n"); return result; } -XGL_LAYER_EXPORT XGL_RESULT XGLAPI multi1StorePipeline(XGL_PIPELINE pipeline, size_t* pDataSize, void* pData) +VK_LAYER_EXPORT VK_RESULT VKAPI multi1StorePipeline(VK_PIPELINE pipeline, size_t* pDataSize, void* pData) { - XGL_LAYER_DISPATCH_TABLE* pTable = tableMap1[pipeline]; + VK_LAYER_DISPATCH_TABLE* pTable = tableMap1[pipeline]; - printf("At start of multi1 layer xglStorePipeline()\n"); - XGL_RESULT result = pTable->StorePipeline(pipeline, pDataSize, pData); - printf("Completed multi1 layer xglStorePipeline()\n"); + printf("At start of multi1 layer vkStorePipeline()\n"); + VK_RESULT result = pTable->StorePipeline(pipeline, pDataSize, pData); + printf("Completed multi1 layer vkStorePipeline()\n"); return result; } -XGL_LAYER_EXPORT XGL_RESULT XGLAPI multi1EnumerateLayers(XGL_PHYSICAL_GPU gpu, size_t maxLayerCount, size_t maxStringSize, +VK_LAYER_EXPORT VK_RESULT VKAPI multi1EnumerateLayers(VK_PHYSICAL_GPU gpu, size_t maxLayerCount, size_t maxStringSize, size_t* pOutLayerCount, char* const* pOutLayers, void* pReserved) { if (gpu == NULL) - return xglEnumerateLayers(gpu, maxLayerCount, maxStringSize, pOutLayerCount, pOutLayers, pReserved); + return vkEnumerateLayers(gpu, maxLayerCount, maxStringSize, pOutLayerCount, pOutLayers, pReserved); - XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu; - XGL_LAYER_DISPATCH_TABLE* pTable = getLayer1Table(gpuw); + VK_BASE_LAYER_OBJECT* gpuw = (VK_BASE_LAYER_OBJECT *) gpu; + VK_LAYER_DISPATCH_TABLE* pTable = getLayer1Table(gpuw); - printf("At start of multi1 layer xglEnumerateLayers()\n"); - XGL_RESULT result = pTable->EnumerateLayers((XGL_PHYSICAL_GPU)gpuw->nextObject, maxLayerCount, maxStringSize, pOutLayerCount, pOutLayers, pReserved); - printf("Completed multi1 layer xglEnumerateLayers()\n"); + printf("At start of multi1 layer vkEnumerateLayers()\n"); + VK_RESULT result = pTable->EnumerateLayers((VK_PHYSICAL_GPU)gpuw->nextObject, maxLayerCount, maxStringSize, pOutLayerCount, pOutLayers, pReserved); + printf("Completed multi1 layer vkEnumerateLayers()\n"); return result; } -XGL_LAYER_EXPORT void * XGLAPI multi1GetProcAddr(XGL_PHYSICAL_GPU gpu, const char* pName) +VK_LAYER_EXPORT void * VKAPI multi1GetProcAddr(VK_PHYSICAL_GPU gpu, const char* pName) { - XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu; + VK_BASE_LAYER_OBJECT* gpuw = (VK_BASE_LAYER_OBJECT *) gpu; if (gpu == NULL) return NULL; getLayer1Table(gpuw); - if (!strncmp("xglCreateDevice", pName, sizeof ("xglCreateDevice"))) + if (!strncmp("vkCreateDevice", pName, sizeof ("vkCreateDevice"))) return (void *) multi1CreateDevice; - else if (!strncmp("xglEnumerateLayers", pName, sizeof ("xglEnumerateLayers"))) + else if (!strncmp("vkEnumerateLayers", pName, sizeof ("vkEnumerateLayers"))) return (void *) multi1EnumerateLayers; - else if (!strncmp("xglCreateGraphicsPipeline", pName, sizeof ("xglCreateGraphicsPipeline"))) + else if (!strncmp("vkCreateGraphicsPipeline", pName, sizeof ("vkCreateGraphicsPipeline"))) return (void *) multi1CreateGraphicsPipeline; - else if (!strncmp("xglStorePipeline", pName, sizeof ("xglStorePipeline"))) + else if (!strncmp("vkStorePipeline", pName, sizeof ("vkStorePipeline"))) return (void *) multi1StorePipeline; - else if (!strncmp("xglGetExtensionSupport", pName, sizeof ("xglGetExtensionSupport"))) - return (void *) xglGetExtensionSupport; + else if (!strncmp("vkGetExtensionSupport", pName, sizeof ("vkGetExtensionSupport"))) + return (void *) vkGetExtensionSupport; else { if (gpuw->pGPA == NULL) return NULL; - return gpuw->pGPA((XGL_PHYSICAL_GPU) gpuw->nextObject, pName); + return gpuw->pGPA((VK_PHYSICAL_GPU) gpuw->nextObject, pName); } } /******************************** Layer multi2 functions **************************/ -static std::unordered_map tableMap2; +static std::unordered_map tableMap2; static bool layer2_first_activated = false; -static XGL_LAYER_DISPATCH_TABLE * getLayer2Table(const XGL_BASE_LAYER_OBJECT *gpuw) +static VK_LAYER_DISPATCH_TABLE * getLayer2Table(const VK_BASE_LAYER_OBJECT *gpuw) { - XGL_LAYER_DISPATCH_TABLE *pTable; + VK_LAYER_DISPATCH_TABLE *pTable; assert(gpuw); - std::unordered_map::const_iterator it = tableMap2.find((void *) gpuw); + std::unordered_map::const_iterator it = tableMap2.find((void *) gpuw); if (it == tableMap2.end()) { - pTable = new XGL_LAYER_DISPATCH_TABLE; + pTable = new VK_LAYER_DISPATCH_TABLE; tableMap2[(void *) gpuw] = pTable; initLayerTable(gpuw, pTable, 2); return pTable; @@ -163,138 +163,138 @@ static XGL_LAYER_DISPATCH_TABLE * getLayer2Table(const XGL_BASE_LAYER_OBJECT *gp } } -XGL_LAYER_EXPORT XGL_RESULT XGLAPI multi2CreateDevice(XGL_PHYSICAL_GPU gpu, const XGL_DEVICE_CREATE_INFO* pCreateInfo, - XGL_DEVICE* pDevice) +VK_LAYER_EXPORT VK_RESULT VKAPI multi2CreateDevice(VK_PHYSICAL_GPU gpu, const VK_DEVICE_CREATE_INFO* pCreateInfo, + VK_DEVICE* pDevice) { - XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu; - XGL_LAYER_DISPATCH_TABLE* pTable = getLayer2Table(gpuw); + VK_BASE_LAYER_OBJECT* gpuw = (VK_BASE_LAYER_OBJECT *) gpu; + VK_LAYER_DISPATCH_TABLE* pTable = getLayer2Table(gpuw); - printf("At start of multi2 xglCreateDevice()\n"); - XGL_RESULT result = pTable->CreateDevice((XGL_PHYSICAL_GPU)gpuw->nextObject, pCreateInfo, pDevice); + printf("At start of multi2 vkCreateDevice()\n"); + VK_RESULT result = pTable->CreateDevice((VK_PHYSICAL_GPU)gpuw->nextObject, pCreateInfo, pDevice); // create a mapping for the device object into the dispatch table for layer2 tableMap2.emplace(*pDevice, pTable); - printf("Completed multi2 layer xglCreateDevice()\n"); + printf("Completed multi2 layer vkCreateDevice()\n"); return result; } -XGL_LAYER_EXPORT XGL_RESULT XGLAPI multi2CreateCommandBuffer(XGL_DEVICE device, const XGL_CMD_BUFFER_CREATE_INFO* pCreateInfo, - XGL_CMD_BUFFER* pCmdBuffer) +VK_LAYER_EXPORT VK_RESULT VKAPI multi2CreateCommandBuffer(VK_DEVICE device, const VK_CMD_BUFFER_CREATE_INFO* pCreateInfo, + VK_CMD_BUFFER* pCmdBuffer) { - XGL_LAYER_DISPATCH_TABLE* pTable = tableMap2[device]; + VK_LAYER_DISPATCH_TABLE* pTable = tableMap2[device]; - printf("At start of multi2 layer xglCreateCommandBuffer()\n"); - XGL_RESULT result = pTable->CreateCommandBuffer(device, pCreateInfo, pCmdBuffer); + printf("At start of multi2 layer vkCreateCommandBuffer()\n"); + VK_RESULT result = pTable->CreateCommandBuffer(device, pCreateInfo, pCmdBuffer); // create a mapping for CmdBuffer object into the dispatch table for layer 2 tableMap2.emplace(*pCmdBuffer, pTable); - printf("Completed multi2 layer xglCreateCommandBuffer()\n"); + printf("Completed multi2 layer vkCreateCommandBuffer()\n"); return result; } -XGL_LAYER_EXPORT XGL_RESULT XGLAPI multi2BeginCommandBuffer(XGL_CMD_BUFFER cmdBuffer, const XGL_CMD_BUFFER_BEGIN_INFO* pBeginInfo) +VK_LAYER_EXPORT VK_RESULT VKAPI multi2BeginCommandBuffer(VK_CMD_BUFFER cmdBuffer, const VK_CMD_BUFFER_BEGIN_INFO* pBeginInfo) { - XGL_LAYER_DISPATCH_TABLE* pTable = tableMap2[cmdBuffer]; + VK_LAYER_DISPATCH_TABLE* pTable = tableMap2[cmdBuffer]; - printf("At start of multi2 layer xglBeginCommandBuffer()\n"); - XGL_RESULT result = pTable->BeginCommandBuffer(cmdBuffer, pBeginInfo); - printf("Completed multi2 layer xglBeginCommandBuffer()\n"); + printf("At start of multi2 layer vkBeginCommandBuffer()\n"); + VK_RESULT result = pTable->BeginCommandBuffer(cmdBuffer, pBeginInfo); + printf("Completed multi2 layer vkBeginCommandBuffer()\n"); return result; } -XGL_LAYER_EXPORT XGL_RESULT XGLAPI multi2EnumerateLayers(XGL_PHYSICAL_GPU gpu, size_t maxLayerCount, size_t maxStringSize, +VK_LAYER_EXPORT VK_RESULT VKAPI multi2EnumerateLayers(VK_PHYSICAL_GPU gpu, size_t maxLayerCount, size_t maxStringSize, size_t* pOutLayerCount, char* const* pOutLayers, void* pReserved) { if (gpu == NULL) - return xglEnumerateLayers(gpu, maxLayerCount, maxStringSize, pOutLayerCount, pOutLayers, pReserved); + return vkEnumerateLayers(gpu, maxLayerCount, maxStringSize, pOutLayerCount, pOutLayers, pReserved); - XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu; - XGL_LAYER_DISPATCH_TABLE* pTable = getLayer2Table(gpuw); + VK_BASE_LAYER_OBJECT* gpuw = (VK_BASE_LAYER_OBJECT *) gpu; + VK_LAYER_DISPATCH_TABLE* pTable = getLayer2Table(gpuw); - printf("At start of multi2 layer xglEnumerateLayers()\n"); - XGL_RESULT result = pTable->EnumerateLayers((XGL_PHYSICAL_GPU)gpuw->nextObject, maxLayerCount, maxStringSize, pOutLayerCount, pOutLayers, pReserved); - printf("Completed multi2 layer xglEnumerateLayers()\n"); + printf("At start of multi2 layer vkEnumerateLayers()\n"); + VK_RESULT result = pTable->EnumerateLayers((VK_PHYSICAL_GPU)gpuw->nextObject, maxLayerCount, maxStringSize, pOutLayerCount, pOutLayers, pReserved); + printf("Completed multi2 layer vkEnumerateLayers()\n"); return result; } -XGL_LAYER_EXPORT void * XGLAPI multi2GetProcAddr(XGL_PHYSICAL_GPU gpu, const char* pName) +VK_LAYER_EXPORT void * VKAPI multi2GetProcAddr(VK_PHYSICAL_GPU gpu, const char* pName) { - XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu; + VK_BASE_LAYER_OBJECT* gpuw = (VK_BASE_LAYER_OBJECT *) gpu; if (gpu == NULL) return NULL; getLayer2Table(gpuw); - if (!strncmp("xglCreateDevice", pName, sizeof ("xglCreateDevice"))) + if (!strncmp("vkCreateDevice", pName, sizeof ("vkCreateDevice"))) return (void *) multi2CreateDevice; - else if (!strncmp("xglEnumerateLayers", pName, sizeof ("xglEnumerateLayers"))) + else if (!strncmp("vkEnumerateLayers", pName, sizeof ("vkEnumerateLayers"))) return (void *) multi2EnumerateLayers; - else if (!strncmp("xglCreateCommandBuffer", pName, sizeof ("xglCreateCommandBuffer"))) + else if (!strncmp("vkCreateCommandBuffer", pName, sizeof ("vkCreateCommandBuffer"))) return (void *) multi2CreateCommandBuffer; - else if (!strncmp("xglBeginCommandBuffer", pName, sizeof ("xglBeginCommandBuffer"))) + else if (!strncmp("vkBeginCommandBuffer", pName, sizeof ("vkBeginCommandBuffer"))) return (void *) multi2BeginCommandBuffer; - else if (!strncmp("xglGetExtensionSupport", pName, sizeof ("xglGetExtensionSupport"))) - return (void *) xglGetExtensionSupport; + else if (!strncmp("vkGetExtensionSupport", pName, sizeof ("vkGetExtensionSupport"))) + return (void *) vkGetExtensionSupport; else { if (gpuw->pGPA == NULL) return NULL; - return gpuw->pGPA((XGL_PHYSICAL_GPU) gpuw->nextObject, pName); + return gpuw->pGPA((VK_PHYSICAL_GPU) gpuw->nextObject, pName); } } /********************************* Common functions ********************************/ -XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglEnumerateLayers(XGL_PHYSICAL_GPU gpu, size_t maxLayerCount, size_t maxStringSize, +VK_LAYER_EXPORT VK_RESULT VKAPI vkEnumerateLayers(VK_PHYSICAL_GPU gpu, size_t maxLayerCount, size_t maxStringSize, size_t* pOutLayerCount, char* const* pOutLayers, void* pReserved) { if (pOutLayerCount == NULL || pOutLayers == NULL || pOutLayers[0] == NULL || pOutLayers[1] == NULL || pReserved == NULL) - return XGL_ERROR_INVALID_POINTER; + return VK_ERROR_INVALID_POINTER; if (maxLayerCount < 2) - return XGL_ERROR_INITIALIZATION_FAILED; + return VK_ERROR_INITIALIZATION_FAILED; *pOutLayerCount = 2; strncpy((char *) pOutLayers[0], "multi1", maxStringSize); strncpy((char *) pOutLayers[1], "multi2", maxStringSize); - return XGL_SUCCESS; + return VK_SUCCESS; } -XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetExtensionSupport(XGL_PHYSICAL_GPU gpu, const char* pExtName) +VK_LAYER_EXPORT VK_RESULT VKAPI vkGetExtensionSupport(VK_PHYSICAL_GPU gpu, const char* pExtName) { - XGL_RESULT result; - XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu; + VK_RESULT result; + VK_BASE_LAYER_OBJECT* gpuw = (VK_BASE_LAYER_OBJECT *) gpu; /* This entrypoint is NOT going to init it's own dispatch table since loader calls here early */ if (!strncmp(pExtName, "multi1", strlen("multi1"))) { - result = XGL_SUCCESS; + result = VK_SUCCESS; } else if (!strncmp(pExtName, "multi2", strlen("multi2"))) { - result = XGL_SUCCESS; + result = VK_SUCCESS; } else if (!tableMap1.empty() && (tableMap1.find(gpuw) != tableMap1.end())) { - XGL_LAYER_DISPATCH_TABLE* pTable = tableMap1[gpuw]; - result = pTable->GetExtensionSupport((XGL_PHYSICAL_GPU)gpuw->nextObject, pExtName); + VK_LAYER_DISPATCH_TABLE* pTable = tableMap1[gpuw]; + result = pTable->GetExtensionSupport((VK_PHYSICAL_GPU)gpuw->nextObject, pExtName); } else if (!tableMap2.empty() && (tableMap2.find(gpuw) != tableMap2.end())) { - XGL_LAYER_DISPATCH_TABLE* pTable = tableMap2[gpuw]; - result = pTable->GetExtensionSupport((XGL_PHYSICAL_GPU)gpuw->nextObject, pExtName); + VK_LAYER_DISPATCH_TABLE* pTable = tableMap2[gpuw]; + result = pTable->GetExtensionSupport((VK_PHYSICAL_GPU)gpuw->nextObject, pExtName); } else { - result = XGL_ERROR_INVALID_EXTENSION; + result = VK_ERROR_INVALID_EXTENSION; } return result; } -XGL_LAYER_EXPORT void * XGLAPI xglGetProcAddr(XGL_PHYSICAL_GPU gpu, const char* pName) +VK_LAYER_EXPORT void * VKAPI vkGetProcAddr(VK_PHYSICAL_GPU gpu, const char* pName) { // to find each layers GPA routine Loader will search via "GetProcAddr" if (!strncmp("multi1GetProcAddr", pName, sizeof("multi1GetProcAddr"))) return (void *) multi1GetProcAddr; else if (!strncmp("multi2GetProcAddr", pName, sizeof("multi2GetProcAddr"))) return (void *) multi2GetProcAddr; - else if (!strncmp("xglGetProcAddr", pName, sizeof("xglGetProcAddr"))) - return (void *) xglGetProcAddr; + else if (!strncmp("vkGetProcAddr", pName, sizeof("vkGetProcAddr"))) + return (void *) vkGetProcAddr; // use first layer activated as GPA dispatch table activation happens in order else if (layer1_first_activated) @@ -310,12 +310,12 @@ XGL_LAYER_EXPORT void * XGLAPI xglGetProcAddr(XGL_PHYSICAL_GPU gpu, const char* } //extern "C" #endif -static void initLayerTable(const XGL_BASE_LAYER_OBJECT *gpuw, XGL_LAYER_DISPATCH_TABLE *pTable, const unsigned int layerNum) +static void initLayerTable(const VK_BASE_LAYER_OBJECT *gpuw, VK_LAYER_DISPATCH_TABLE *pTable, const unsigned int layerNum) { if (layerNum == 2 && layer1_first_activated == false) layer2_first_activated = true; if (layerNum == 1 && layer2_first_activated == false) layer1_first_activated = true; - layer_initialize_dispatch_table(pTable, gpuw->pGPA, (XGL_PHYSICAL_GPU) gpuw->nextObject); + layer_initialize_dispatch_table(pTable, gpuw->pGPA, (VK_PHYSICAL_GPU) gpuw->nextObject); } -- cgit v1.2.3