aboutsummaryrefslogtreecommitdiff
path: root/layers
diff options
context:
space:
mode:
authorIan Elliott <ian@LunarG.com>2015-01-13 17:52:38 -0700
committerCourtney Goeltzenleuchter <courtney@LunarG.com>2015-02-04 17:58:11 -0700
commit08dd2294cf50d9282134bcf968d9f2eb0e3abd67 (patch)
treec663dad2b00a96460a938ab893cde6ec895b0318 /layers
parent50aeba51c159d41c3f3ccfbdd7edb7b5e5e0b162 (diff)
downloadusermoji-08dd2294cf50d9282134bcf968d9f2eb0e3abd67.tar.xz
Can compile "loader" and "layers" on Windows and Linux ...
These directories build and are partially turned-on on Windows, using the "tri" demo (follow-on commit) and a "NULL driver" that was created out of the sample/Intel driver. The GetProcAddress() is not yet finding symbols in the NULL driver. For now: - "C:\Windows\System32" is the default XGL driver directory. The getenv() isn't yet working. I suggest creating your own #define in order to point to where a driver is. - In order to recognize a Windows driver, we must look at both its prefix and suffix (i.e. it is named "XGL_*.dll", e.g. "XGL_i965.dll). - We autogenerate Windows ".def" files for the layers. Additional info is: - This is necessary in order for a DLL to export symbols that can be queried using GetProcAddress(). We can't use the normal Windows approach of declaring these functions using "__declspec(dllexport)", because these functions are declared in "xgl.h". - This involves adding and running the new "xgl-win-def-file-generate.py" file. - NOTE: Layers don't have the xglInitAndEnumerateGpus() entrypoint, just the xglGetProcAddr() entrypoint (and now the xglEnumerateLayers() entrypoint). Generating them is pretty simple. NOTE: In order to build on a 64-bit Windows 7/8 system, I did the following: - Install VisualStudio 2013 Professional - Install CMake from: http://www.cmake.org/cmake/resources/software.html - I let it add itself to the system PATH environment variable. - Install Python 3 from: https://www.python.org/downloads - I let it add itself to the system PATH environment variable. - Obtain the Git repository, checkout the "ian-150127-WinBuild" branch. - Using a Cygwin shell: I did the following: - "cd" to the top-level directory (i.e. the one that contains the ".git" directory). - "mkdir _out64" - "cd _out64" - "cmake -G "Visual Studio 12 Win64" .." - At this point, I used WindowsExplorer to open the "XGL.sln" file. I can build. CMake causes the build shortcut to be "Ctrl-Shift-B" instead of the normal "F7". I had to right-click the "ALL_BUILD" project, go to Properties->Debugging and change the debug Command and Working Directory to point to "tri.exe" and where the executable are. At this point, I can debug (using the normal "F5" shortcut).
Diffstat (limited to 'layers')
-rw-r--r--layers/CMakeLists.txt18
-rw-r--r--layers/basic.cpp1
-rw-r--r--layers/draw_state.c98
-rw-r--r--layers/mem_tracker.c28
-rw-r--r--layers/multi.cpp1
5 files changed, 96 insertions, 50 deletions
diff --git a/layers/CMakeLists.txt b/layers/CMakeLists.txt
index 3971ce5b..4693d4e4 100644
--- a/layers/CMakeLists.txt
+++ b/layers/CMakeLists.txt
@@ -14,13 +14,27 @@ macro(run_xgl_layer_generate subcmd output)
)
endmacro()
-macro(add_xgl_layer target)
+if (WIN32)
+ macro(add_xgl_layer target)
+ add_custom_command(OUTPUT XGLLayer${target}.def
+ COMMAND ${PROJECT_SOURCE_DIR}/xgl-win-def-file-generate.py ${target} > XGLLayer${target}.def
+ DEPENDS ${PROJECT_SOURCE_DIR}/xgl-win-def-file-generate.py
+ )
+ add_library(XGLLayer${target} SHARED ${ARGN} XGLLayer${target}.def)
+ add_dependencies(XGLLayer${target} generate_xgl_layer_helpers)
+ add_dependencies(XGLLayer${target} ${CMAKE_CURRENT_BINARY_DIR}/XGLLayer${target}.def)
+ set_target_properties(XGLLayer${target} PROPERTIES LINK_FLAGS "/DEF:${CMAKE_CURRENT_BINARY_DIR}/XGLLayer${target}.def")
+ endmacro()
+else()
+ macro(add_xgl_layer target)
add_library(XGLLayer${target} SHARED ${ARGN})
add_dependencies(XGLLayer${target} generate_xgl_layer_helpers)
-endmacro()
+ endmacro()
+endif()
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}/../loader
${CMAKE_CURRENT_BINARY_DIR}
)
diff --git a/layers/basic.cpp b/layers/basic.cpp
index ebbc45b6..ac8cf803 100644
--- a/layers/basic.cpp
+++ b/layers/basic.cpp
@@ -25,6 +25,7 @@
#include <stdlib.h>
#include <assert.h>
#include <unordered_map>
+#include "loader_platform.h"
#include "xgl_dispatch_table_helper.h"
#include "xglLayer.h"
diff --git a/layers/draw_state.c b/layers/draw_state.c
index 53e3c461..5e6e6fed 100644
--- a/layers/draw_state.c
+++ b/layers/draw_state.c
@@ -25,9 +25,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <assert.h>
-#include <pthread.h>
-#include <unistd.h>
+#include "loader_platform.h"
#include "xgl_dispatch_table_helper.h"
#include "xgl_generic_intercept_proc_helper.h"
#include "xgl_struct_string_helper.h"
@@ -37,9 +35,9 @@
static XGL_LAYER_DISPATCH_TABLE nextTable;
static XGL_BASE_LAYER_OBJECT *pCurObj;
-static pthread_once_t g_initOnce = PTHREAD_ONCE_INIT;
-// Could be smarter about locking with unique locks for various tasks, but just using one for now
-pthread_mutex_t globalLock = PTHREAD_MUTEX_INITIALIZER;
+static LOADER_PLATFORM_THREAD_ONCE_DECLARATION(g_initOnce);
+static int globalLockInitialized = 0;
+static loader_platform_thread_mutex globalLock;
// Ptr to LL of dbg functions
static XGL_LAYER_DBG_FUNCTION_NODE *g_pDbgFunctionHead = NULL;
@@ -267,7 +265,7 @@ static DYNAMIC_STATE_NODE* g_pLastBoundDynamicState[XGL_NUM_STATE_BIND_POINT] =
static void insertDynamicState(const XGL_DYNAMIC_STATE_OBJECT state, const GENERIC_HEADER* pCreateInfo, XGL_STATE_BIND_POINT bindPoint)
{
- pthread_mutex_lock(&globalLock);
+ loader_platform_thread_lock_mutex(&globalLock);
// Insert new node at head of appropriate LL
DYNAMIC_STATE_NODE* pStateNode = (DYNAMIC_STATE_NODE*)malloc(sizeof(DYNAMIC_STATE_NODE));
pStateNode->pNext = g_pDynamicStateHead[bindPoint];
@@ -275,13 +273,13 @@ static void insertDynamicState(const XGL_DYNAMIC_STATE_OBJECT state, const GENER
pStateNode->stateObj = state;
pStateNode->pCreateInfo = (GENERIC_HEADER*)malloc(dynStateCreateInfoSize(pCreateInfo->sType));
memcpy(pStateNode->pCreateInfo, pCreateInfo, dynStateCreateInfoSize(pCreateInfo->sType));
- pthread_mutex_unlock(&globalLock);
+ loader_platform_thread_unlock_mutex(&globalLock);
}
// Set the last bound dynamic state of given type
// TODO : Need to track this per cmdBuffer and correlate cmdBuffer for Draw w/ last bound for that cmdBuffer?
static void setLastBoundDynamicState(const XGL_DYNAMIC_STATE_OBJECT state, const XGL_STATE_BIND_POINT sType)
{
- pthread_mutex_lock(&globalLock);
+ loader_platform_thread_lock_mutex(&globalLock);
DYNAMIC_STATE_NODE* pTrav = g_pDynamicStateHead[sType];
while (pTrav && (state != pTrav->stateObj)) {
pTrav = pTrav->pNext;
@@ -292,12 +290,12 @@ static void setLastBoundDynamicState(const XGL_DYNAMIC_STATE_OBJECT state, const
layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, state, 0, DRAWSTATE_INVALID_DYNAMIC_STATE_OBJECT, "DS", str);
}
g_pLastBoundDynamicState[sType] = pTrav;
- pthread_mutex_unlock(&globalLock);
+ loader_platform_thread_unlock_mutex(&globalLock);
}
// Print the last bound dynamic state
static void printDynamicState()
{
- pthread_mutex_lock(&globalLock);
+ loader_platform_thread_lock_mutex(&globalLock);
char str[1024];
for (uint32_t i = 0; i < XGL_NUM_STATE_BIND_POINT; i++) {
if (g_pLastBoundDynamicState[i]) {
@@ -318,37 +316,37 @@ static void printDynamicState()
layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", str);
}
}
- pthread_mutex_unlock(&globalLock);
+ loader_platform_thread_unlock_mutex(&globalLock);
}
// Retrieve pipeline node ptr for given pipeline object
static PIPELINE_NODE *getPipeline(XGL_PIPELINE pipeline)
{
- pthread_mutex_lock(&globalLock);
+ loader_platform_thread_lock_mutex(&globalLock);
PIPELINE_NODE *pTrav = g_pPipelineHead;
while (pTrav) {
if (pTrav->pipeline == pipeline) {
- pthread_mutex_unlock(&globalLock);
+ loader_platform_thread_unlock_mutex(&globalLock);
return pTrav;
}
pTrav = pTrav->pNext;
}
- pthread_mutex_unlock(&globalLock);
+ loader_platform_thread_unlock_mutex(&globalLock);
return NULL;
}
// For given sampler, return a ptr to its Create Info struct, or NULL if sampler not found
static XGL_SAMPLER_CREATE_INFO* getSamplerCreateInfo(const XGL_SAMPLER sampler)
{
- pthread_mutex_lock(&globalLock);
+ loader_platform_thread_lock_mutex(&globalLock);
SAMPLER_NODE *pTrav = g_pSamplerHead;
while (pTrav) {
if (sampler == pTrav->sampler) {
- pthread_mutex_unlock(&globalLock);
+ loader_platform_thread_unlock_mutex(&globalLock);
return &pTrav->createInfo;
}
pTrav = pTrav->pNext;
}
- pthread_mutex_unlock(&globalLock);
+ loader_platform_thread_unlock_mutex(&globalLock);
return NULL;
}
@@ -704,16 +702,16 @@ static void clearDescriptorRegion(XGL_DESCRIPTOR_REGION region)
/*
static DS_LL_HEAD* getDS(XGL_DESCRIPTOR_SET ds)
{
- pthread_mutex_lock(&globalLock);
+ loader_platform_thread_lock_mutex(&globalLock);
DS_LL_HEAD *pTrav = pDSHead;
while (pTrav) {
if (pTrav->dsID == ds) {
- pthread_mutex_unlock(&globalLock);
+ loader_platform_thread_unlock_mutex(&globalLock);
return pTrav;
}
pTrav = pTrav->pNextDS;
}
- pthread_mutex_unlock(&globalLock);
+ loader_platform_thread_unlock_mutex(&globalLock);
return NULL;
}
@@ -733,16 +731,16 @@ static bool32_t dsUpdate(XGL_DESCRIPTOR_SET ds)
static bool32_t clearDS(XGL_DESCRIPTOR_SET descriptorSet, uint32_t startSlot, uint32_t slotCount)
{
DS_LL_HEAD *pTrav = getDS(descriptorSet);
- pthread_mutex_lock(&globalLock);
+ loader_platform_thread_lock_mutex(&globalLock);
if (!pTrav || ((startSlot + slotCount) > pTrav->numSlots)) {
// TODO : Log more meaningful error here
- pthread_mutex_unlock(&globalLock);
+ loader_platform_thread_unlock_mutex(&globalLock);
return XGL_FALSE;
}
for (uint32_t i = startSlot; i < slotCount; i++) {
memset((void*)&pTrav->dsSlot[i], 0, sizeof(DS_SLOT));
}
- pthread_mutex_unlock(&globalLock);
+ loader_platform_thread_unlock_mutex(&globalLock);
return XGL_TRUE;
}
@@ -1004,9 +1002,13 @@ static void synchAndPrintDSConfig()
autoDumpOnce = 0;
dumpDotFile("pipeline_dump.dot");
// Convert dot to png if dot available
+#if defined(_WIN32)
+// FIXME: NEED WINDOWS EQUIVALENT
+#else // WIN32
if(access( "/usr/bin/dot", X_OK) != -1) {
system("/usr/bin/dot pipeline_dump.dot -Tpng -o pipeline_dump.png");
}
+#endif // WIN32
}
}
@@ -1042,6 +1044,17 @@ static void initDrawState()
xglGetProcAddrType fpGetProcAddr = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (char *) "xglGetProcAddr");
nextTable.GetProcAddr = fpGetProcAddr;
+
+ if (!globalLockInitialized)
+ {
+ // TODO/TBD: Need to delete this mutex sometime. How??? One
+ // suggestion is to call this during xglCreateInstance(), and then we
+ // can clean it up during xglDestroyInstance(). However, that requires
+ // that the layer have per-instance locks. We need to come back and
+ // address this soon.
+ loader_platform_thread_create_mutex(&globalLock);
+ globalLockInitialized = 1;
+ }
}
XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateInstance(const XGL_APPLICATION_INFO* pAppInfo, const XGL_ALLOC_CALLBACKS* pAllocCb, XGL_INSTANCE* pInstance)
@@ -1066,7 +1079,7 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetGpuInfo(XGL_PHYSICAL_GPU gpu, XGL_PHYSI
{
XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu;
pCurObj = gpuw;
- pthread_once(&g_initOnce, initDrawState);
+ loader_platform_thread_once(&g_initOnce, initDrawState);
XGL_RESULT result = nextTable.GetGpuInfo((XGL_PHYSICAL_GPU)gpuw->nextObject, infoType, pDataSize, pData);
return result;
}
@@ -1075,7 +1088,7 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateDevice(XGL_PHYSICAL_GPU gpu, const X
{
XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu;
pCurObj = gpuw;
- pthread_once(&g_initOnce, initDrawState);
+ loader_platform_thread_once(&g_initOnce, initDrawState);
XGL_RESULT result = nextTable.CreateDevice((XGL_PHYSICAL_GPU)gpuw->nextObject, pCreateInfo, pDevice);
return result;
}
@@ -1090,7 +1103,7 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetExtensionSupport(XGL_PHYSICAL_GPU gpu,
{
XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu;
pCurObj = gpuw;
- pthread_once(&g_initOnce, initDrawState);
+ loader_platform_thread_once(&g_initOnce, initDrawState);
XGL_RESULT result = nextTable.GetExtensionSupport((XGL_PHYSICAL_GPU)gpuw->nextObject, pExtName);
return result;
}
@@ -1101,7 +1114,7 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglEnumerateLayers(XGL_PHYSICAL_GPU gpu, size
{
XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu;
pCurObj = gpuw;
- pthread_once(&g_initOnce, initDrawState);
+ loader_platform_thread_once(&g_initOnce, initDrawState);
XGL_RESULT result = nextTable.EnumerateLayers((XGL_PHYSICAL_GPU)gpuw->nextObject, maxLayerCount, maxStringSize, pOutLayerCount, pOutLayers, pReserved);
return result;
} else
@@ -1185,7 +1198,7 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetMultiGpuCompatibility(XGL_PHYSICAL_GPU
{
XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu0;
pCurObj = gpuw;
- pthread_once(&g_initOnce, initDrawState);
+ loader_platform_thread_once(&g_initOnce, initDrawState);
XGL_RESULT result = nextTable.GetMultiGpuCompatibility((XGL_PHYSICAL_GPU)gpuw->nextObject, gpu1, pInfo);
return result;
}
@@ -1407,7 +1420,7 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateGraphicsPipeline(XGL_DEVICE device,
char str[1024];
sprintf(str, "Created Gfx Pipeline %p", (void*)*pPipeline);
layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, pPipeline, 0, DRAWSTATE_NONE, "DS", str);
- pthread_mutex_lock(&globalLock);
+ loader_platform_thread_lock_mutex(&globalLock);
PIPELINE_NODE *pTrav = g_pPipelineHead;
if (pTrav) {
while (pTrav->pNext)
@@ -1422,7 +1435,7 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateGraphicsPipeline(XGL_DEVICE device,
memset((void*)pTrav, 0, sizeof(PIPELINE_NODE));
pTrav->pipeline = *pPipeline;
initPipeline(pTrav, pCreateInfo);
- pthread_mutex_unlock(&globalLock);
+ loader_platform_thread_unlock_mutex(&globalLock);
return result;
}
@@ -1454,13 +1467,13 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateSampler(XGL_DEVICE device, const XGL
{
XGL_RESULT result = nextTable.CreateSampler(device, pCreateInfo, pSampler);
if (XGL_SUCCESS == result) {
- pthread_mutex_lock(&globalLock);
+ loader_platform_thread_lock_mutex(&globalLock);
SAMPLER_NODE *pNewNode = (SAMPLER_NODE*)malloc(sizeof(SAMPLER_NODE));
pNewNode->sampler = *pSampler;
memcpy(&pNewNode->createInfo, pCreateInfo, sizeof(XGL_SAMPLER_CREATE_INFO));
pNewNode->pNext = g_pSamplerHead;
g_pSamplerHead = pNewNode;
- pthread_mutex_unlock(&globalLock);
+ loader_platform_thread_unlock_mutex(&globalLock);
}
return result;
}
@@ -1743,10 +1756,10 @@ XGL_LAYER_EXPORT void XGLAPI xglCmdBindDescriptorSet(XGL_CMD_BUFFER cmdBuffer, X
sprintf(str, "You must call xglEndDescriptorSetUpdate(%p) before this call to xglCmdBindDescriptorSet()!", (void*)descriptorSet);
layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, descriptorSet, 0, DRAWSTATE_BINDING_DS_NO_END_UPDATE, "DS", str);
}
- pthread_mutex_lock(&globalLock);
+ loader_platform_thread_lock_mutex(&globalLock);
lastBoundDS[index] = descriptorSet;
lastBoundSlotOffset[index] = slotOffset;
- pthread_mutex_unlock(&globalLock);
+ loader_platform_thread_unlock_mutex(&globalLock);
char str[1024];
sprintf(str, "DS %p bound to DS index %u on pipeline %s", (void*)descriptorSet, index, string_XGL_PIPELINE_BIND_POINT(pipelineBindPoint));
layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, descriptorSet, 0, DRAWSTATE_NONE, "DS", str);
@@ -2037,11 +2050,14 @@ XGL_LAYER_EXPORT void XGLAPI xglCmdDbgMarkerEnd(XGL_CMD_BUFFER cmdBuffer)
nextTable.CmdDbgMarkerEnd(cmdBuffer);
}
+#if defined(WIN32)
+// FIXME: NEED WINDOWS EQUIVALENT
+#else // WIN32
XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglWsiX11AssociateConnection(XGL_PHYSICAL_GPU gpu, const XGL_WSI_X11_CONNECTION_INFO* pConnectionInfo)
{
XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu;
pCurObj = gpuw;
- pthread_once(&g_initOnce, initDrawState);
+ loader_platform_thread_once(&g_initOnce, initDrawState);
XGL_RESULT result = nextTable.WsiX11AssociateConnection((XGL_PHYSICAL_GPU)gpuw->nextObject, pConnectionInfo);
return result;
}
@@ -2063,6 +2079,7 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglWsiX11QueuePresent(XGL_QUEUE queue, const
XGL_RESULT result = nextTable.WsiX11QueuePresent(queue, pPresentInfo, fence);
return result;
}
+#endif // WIN32
void drawStateDumpDotFile(char* outFileName)
{
@@ -2071,6 +2088,12 @@ void drawStateDumpDotFile(char* outFileName)
void drawStateDumpPngFile(char* outFileName)
{
+#if defined(_WIN32)
+// FIXME: NEED WINDOWS EQUIVALENT
+ char str[1024];
+ sprintf(str, "Cannot execute dot program yet on Windows.");
+ layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_MISSING_DOT_PROGRAM, "DS", str);
+#else // WIN32
char dotExe[32] = "/usr/bin/dot";
if( access(dotExe, X_OK) != -1) {
dumpDotFile("/tmp/tmp.dot");
@@ -2084,6 +2107,7 @@ void drawStateDumpPngFile(char* outFileName)
sprintf(str, "Cannot execute dot program at (%s) to dump requested %s file.", dotExe, outFileName);
layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_MISSING_DOT_PROGRAM, "DS", str);
}
+#endif // WIN32
}
XGL_LAYER_EXPORT void* XGLAPI xglGetProcAddr(XGL_PHYSICAL_GPU gpu, const char* funcName)
@@ -2094,7 +2118,7 @@ XGL_LAYER_EXPORT void* XGLAPI xglGetProcAddr(XGL_PHYSICAL_GPU gpu, const char* f
if (gpu == NULL)
return NULL;
pCurObj = gpuw;
- pthread_once(&g_initOnce, initDrawState);
+ loader_platform_thread_once(&g_initOnce, initDrawState);
addr = layer_intercept_proc(funcName);
if (addr)
diff --git a/layers/mem_tracker.c b/layers/mem_tracker.c
index a1ad749c..0165cb07 100644
--- a/layers/mem_tracker.c
+++ b/layers/mem_tracker.c
@@ -26,7 +26,7 @@
#include <stdlib.h>
#include <string.h>
#include <assert.h>
-#include <pthread.h>
+#include "loader_platform.h"
#include "xgl_dispatch_table_helper.h"
#include "xgl_generic_intercept_proc_helper.h"
#include "xgl_struct_string_helper.h"
@@ -35,7 +35,7 @@
static XGL_LAYER_DISPATCH_TABLE nextTable;
static XGL_BASE_LAYER_OBJECT *pCurObj;
-static pthread_once_t g_initOnce = PTHREAD_ONCE_INIT;
+static LOADER_PLATFORM_THREAD_ONCE_DECLARATION(g_initOnce);
// Ptr to LL of dbg functions
static XGL_LAYER_DBG_FUNCTION_NODE *g_pDbgFunctionHead = NULL;
@@ -414,8 +414,9 @@ static bool32_t updateCBBinding(const XGL_CMD_BUFFER cb, const XGL_GPU_MEMORY me
}
XGL_RESULT result = insertMiniNode(&pMemTrav->pCmdBufferBindings, cb, &pMemTrav->refCount);
- if (XGL_SUCCESS != result)
+ if (XGL_SUCCESS != result) {
return result;
+ }
// Now update Global CB's Mini Mem binding list
GLOBAL_CB_NODE* pCBTrav = getGlobalCBNode(cb);
@@ -483,8 +484,9 @@ static bool32_t freeCBBindings(const XGL_CMD_BUFFER cb)
// TODO : When should this be called? There's no Destroy of CBs that I see
static bool32_t deleteGlobalCBNode(const XGL_CMD_BUFFER cb)
{
- if (XGL_FALSE == freeCBBindings(cb))
+ if (XGL_FALSE == freeCBBindings(cb)) {
return XGL_FALSE;
+ }
// Delete the Global CB node
GLOBAL_CB_NODE* pCBTrav = getGlobalCBNode(cb);
pCBTrav = pGlobalCBHead;
@@ -990,7 +992,7 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetGpuInfo(XGL_PHYSICAL_GPU gpu, XGL_PHYSI
{
XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu;
pCurObj = gpuw;
- pthread_once(&g_initOnce, initMemTracker);
+ loader_platform_thread_once(&g_initOnce, initMemTracker);
XGL_RESULT result = nextTable.GetGpuInfo((XGL_PHYSICAL_GPU)gpuw->nextObject, infoType, pDataSize, pData);
return result;
}
@@ -999,7 +1001,7 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateDevice(XGL_PHYSICAL_GPU gpu, const X
{
XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu;
pCurObj = gpuw;
- pthread_once(&g_initOnce, initMemTracker);
+ loader_platform_thread_once(&g_initOnce, initMemTracker);
XGL_RESULT result = nextTable.CreateDevice((XGL_PHYSICAL_GPU)gpuw->nextObject, pCreateInfo, pDevice);
// Save off device in case we need it to create Fences
globalDevice = *pDevice;
@@ -1033,7 +1035,7 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetExtensionSupport(XGL_PHYSICAL_GPU gpu,
{
XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu;
pCurObj = gpuw;
- pthread_once(&g_initOnce, initMemTracker);
+ loader_platform_thread_once(&g_initOnce, initMemTracker);
XGL_RESULT result = nextTable.GetExtensionSupport((XGL_PHYSICAL_GPU)gpuw->nextObject, pExtName);
return result;
}
@@ -1044,7 +1046,7 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglEnumerateLayers(XGL_PHYSICAL_GPU gpu, size
{
XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu;
pCurObj = gpuw;
- pthread_once(&g_initOnce, initMemTracker);
+ loader_platform_thread_once(&g_initOnce, initMemTracker);
XGL_RESULT result = nextTable.EnumerateLayers((XGL_PHYSICAL_GPU)gpuw->nextObject, maxLayerCount, maxStringSize, pOutLayerCount, pOutLayers, pReserved);
return result;
} else
@@ -1171,7 +1173,7 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetMultiGpuCompatibility(XGL_PHYSICAL_GPU
{
XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu0;
pCurObj = gpuw;
- pthread_once(&g_initOnce, initMemTracker);
+ loader_platform_thread_once(&g_initOnce, initMemTracker);
XGL_RESULT result = nextTable.GetMultiGpuCompatibility((XGL_PHYSICAL_GPU)gpuw->nextObject, gpu1, pInfo);
return result;
}
@@ -2085,11 +2087,14 @@ XGL_LAYER_EXPORT void XGLAPI xglCmdDbgMarkerEnd(XGL_CMD_BUFFER cmdBuffer)
nextTable.CmdDbgMarkerEnd(cmdBuffer);
}
+#if defined(_WIN32)
+// FIXME: NEED WINDOWS EQUIVALENT
+#else // WIN32
XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglWsiX11AssociateConnection(XGL_PHYSICAL_GPU gpu, const XGL_WSI_X11_CONNECTION_INFO* pConnectionInfo)
{
XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu;
pCurObj = gpuw;
- pthread_once(&g_initOnce, initMemTracker);
+ loader_platform_thread_once(&g_initOnce, initMemTracker);
XGL_RESULT result = nextTable.WsiX11AssociateConnection((XGL_PHYSICAL_GPU)gpuw->nextObject, pConnectionInfo);
return result;
}
@@ -2123,6 +2128,7 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglWsiX11QueuePresent(XGL_QUEUE queue, const
XGL_RESULT result = nextTable.WsiX11QueuePresent(queue, pPresentInfo, fence);
return result;
}
+#endif // WIN32
XGL_LAYER_EXPORT void* XGLAPI xglGetProcAddr(XGL_PHYSICAL_GPU gpu, const char* funcName)
{
@@ -2132,7 +2138,7 @@ XGL_LAYER_EXPORT void* XGLAPI xglGetProcAddr(XGL_PHYSICAL_GPU gpu, const char* f
if (gpu == NULL)
return NULL;
pCurObj = gpuw;
- pthread_once(&g_initOnce, initMemTracker);
+ loader_platform_thread_once(&g_initOnce, initMemTracker);
addr = layer_intercept_proc(funcName);
if (addr)
diff --git a/layers/multi.cpp b/layers/multi.cpp
index 400ef5d4..95514928 100644
--- a/layers/multi.cpp
+++ b/layers/multi.cpp
@@ -27,6 +27,7 @@
#include <stdlib.h>
#include <assert.h>
#include <unordered_map>
+#include "loader_platform.h"
#include "xgl_dispatch_table_helper.h"
#include "xglLayer.h"