From 9763b939bb7bdb18343a4ec24d442a89ec935c2e Mon Sep 17 00:00:00 2001 From: Jon Ashburn Date: Mon, 16 Feb 2015 08:46:53 -0700 Subject: layers: Have DrawState and MemTracker use the common code for reporting --- layers/draw_state.c | 68 +--------------------------------------------------- layers/mem_tracker.c | 66 +------------------------------------------------- 2 files changed, 2 insertions(+), 132 deletions(-) diff --git a/layers/draw_state.c b/layers/draw_state.c index ceff3b11..c07367f8 100644 --- a/layers/draw_state.c +++ b/layers/draw_state.c @@ -35,79 +35,13 @@ // The following is #included again to catch certain OS-specific functions // being used: #include "loader_platform.h" - +#include "layers_msg.h" static XGL_LAYER_DISPATCH_TABLE nextTable; static XGL_BASE_LAYER_OBJECT *pCurObj; 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; -static XGL_LAYER_DBG_REPORT_LEVEL g_reportingLevel = XGL_DBG_LAYER_LEVEL_INFO; -static XGL_LAYER_DBG_ACTION g_debugAction = XGL_DBG_LAYER_ACTION_LOG_MSG; -static FILE *g_logFile = NULL; - -// Utility function to handle reporting -// If callbacks are enabled, use them, otherwise use printf -static void layerCbMsg(XGL_DBG_MSG_TYPE msgType, - XGL_VALIDATION_LEVEL validationLevel, - XGL_BASE_OBJECT srcObject, - size_t location, - int32_t msgCode, - const char* pLayerPrefix, - const char* pMsg) -{ - if (g_debugAction & (XGL_DBG_LAYER_ACTION_LOG_MSG | XGL_DBG_LAYER_ACTION_CALLBACK)) { - XGL_LAYER_DBG_FUNCTION_NODE *pTrav = g_pDbgFunctionHead; - switch (msgType) { - case XGL_DBG_MSG_ERROR: - if (g_reportingLevel <= XGL_DBG_LAYER_LEVEL_ERROR) { - if (g_debugAction & XGL_DBG_LAYER_ACTION_LOG_MSG) - fprintf(g_logFile, "{%s}ERROR : %s\n", pLayerPrefix, pMsg); - if (g_debugAction & XGL_DBG_LAYER_ACTION_CALLBACK) - while (pTrav) { - pTrav->pfnMsgCallback(msgType, validationLevel, srcObject, location, msgCode, pMsg, pTrav->pUserData); - pTrav = pTrav->pNext; - } - } - break; - case XGL_DBG_MSG_WARNING: - if (g_reportingLevel <= XGL_DBG_LAYER_LEVEL_WARN) { - if (g_debugAction & XGL_DBG_LAYER_ACTION_LOG_MSG) - fprintf(g_logFile, "{%s}WARN : %s\n", pLayerPrefix, pMsg); - if (g_debugAction & XGL_DBG_LAYER_ACTION_CALLBACK) - while (pTrav) { - pTrav->pfnMsgCallback(msgType, validationLevel, srcObject, location, msgCode, pMsg, pTrav->pUserData); - pTrav = pTrav->pNext; - } - } - break; - case XGL_DBG_MSG_PERF_WARNING: - if (g_reportingLevel <= XGL_DBG_LAYER_LEVEL_PERF_WARN) { - if (g_debugAction & XGL_DBG_LAYER_ACTION_LOG_MSG) - fprintf(g_logFile, "{%s}PERF_WARN : %s\n", pLayerPrefix, pMsg); - if (g_debugAction & XGL_DBG_LAYER_ACTION_CALLBACK) - while (pTrav) { - pTrav->pfnMsgCallback(msgType, validationLevel, srcObject, location, msgCode, pMsg, pTrav->pUserData); - pTrav = pTrav->pNext; - } - } - break; - default: - if (g_reportingLevel <= XGL_DBG_LAYER_LEVEL_INFO) { - if (g_debugAction & XGL_DBG_LAYER_ACTION_LOG_MSG) - fprintf(g_logFile, "{%s}INFO : %s\n", pLayerPrefix, pMsg); - if (g_debugAction & XGL_DBG_LAYER_ACTION_CALLBACK) - while (pTrav) { - pTrav->pfnMsgCallback(msgType, validationLevel, srcObject, location, msgCode, pMsg, pTrav->pUserData); - pTrav = pTrav->pNext; - } - } - break; - } - } -} // Return the size of the underlying struct based on struct type static size_t sTypeStructSize(XGL_STRUCTURE_TYPE sType) { diff --git a/layers/mem_tracker.c b/layers/mem_tracker.c index 369131ff..f971c906 100644 --- a/layers/mem_tracker.c +++ b/layers/mem_tracker.c @@ -35,80 +35,16 @@ // The following is #included again to catch certain OS-specific functions // being used: #include "loader_platform.h" +#include "layers_msg.h" static XGL_LAYER_DISPATCH_TABLE nextTable; static XGL_BASE_LAYER_OBJECT *pCurObj; static LOADER_PLATFORM_THREAD_ONCE_DECLARATION(g_initOnce); -// Ptr to LL of dbg functions -static XGL_LAYER_DBG_FUNCTION_NODE *g_pDbgFunctionHead = NULL; -static XGL_LAYER_DBG_REPORT_LEVEL g_reportingLevel = XGL_DBG_LAYER_LEVEL_INFO; -static XGL_LAYER_DBG_ACTION g_debugAction = XGL_DBG_LAYER_ACTION_LOG_MSG; -static FILE *g_logFile = NULL; #define MAX_BINDING 0xFFFFFFFF static uint32_t lastVtxBinding = MAX_BINDING; -// Utility function to handle reporting -static void layerCbMsg(XGL_DBG_MSG_TYPE msgType, - XGL_VALIDATION_LEVEL validationLevel, - XGL_BASE_OBJECT srcObject, - size_t location, - int32_t msgCode, - const char* pLayerPrefix, - const char* pMsg) -{ - if (g_debugAction & (XGL_DBG_LAYER_ACTION_LOG_MSG | XGL_DBG_LAYER_ACTION_CALLBACK)) { - XGL_LAYER_DBG_FUNCTION_NODE *pTrav = g_pDbgFunctionHead; - switch (msgType) { - case XGL_DBG_MSG_ERROR: - if (g_reportingLevel <= XGL_DBG_LAYER_LEVEL_ERROR) { - if (g_debugAction & XGL_DBG_LAYER_ACTION_LOG_MSG) - fprintf(g_logFile, "{%s}ERROR : %s\n", pLayerPrefix, pMsg); - if (g_debugAction & XGL_DBG_LAYER_ACTION_CALLBACK) - while (pTrav) { - pTrav->pfnMsgCallback(msgType, validationLevel, srcObject, location, msgCode, pMsg, pTrav->pUserData); - pTrav = pTrav->pNext; - } - } - break; - case XGL_DBG_MSG_WARNING: - if (g_reportingLevel <= XGL_DBG_LAYER_LEVEL_WARN) { - if (g_debugAction & XGL_DBG_LAYER_ACTION_LOG_MSG) - fprintf(g_logFile, "{%s}WARN : %s\n", pLayerPrefix, pMsg); - if (g_debugAction & XGL_DBG_LAYER_ACTION_CALLBACK) - while (pTrav) { - pTrav->pfnMsgCallback(msgType, validationLevel, srcObject, location, msgCode, pMsg, pTrav->pUserData); - pTrav = pTrav->pNext; - } - } - break; - case XGL_DBG_MSG_PERF_WARNING: - if (g_reportingLevel <= XGL_DBG_LAYER_LEVEL_PERF_WARN) { - if (g_debugAction & XGL_DBG_LAYER_ACTION_LOG_MSG) - fprintf(g_logFile, "{%s}PERF_WARN : %s\n", pLayerPrefix, pMsg); - if (g_debugAction & XGL_DBG_LAYER_ACTION_CALLBACK) - while (pTrav) { - pTrav->pfnMsgCallback(msgType, validationLevel, srcObject, location, msgCode, pMsg, pTrav->pUserData); - pTrav = pTrav->pNext; - } - } - break; - default: - if (g_reportingLevel <= XGL_DBG_LAYER_LEVEL_INFO) { - if (g_debugAction & XGL_DBG_LAYER_ACTION_LOG_MSG) - fprintf(g_logFile, "{%s}INFO : %s\n", pLayerPrefix, pMsg); - if (g_debugAction & XGL_DBG_LAYER_ACTION_CALLBACK) - while (pTrav) { - pTrav->pfnMsgCallback(msgType, validationLevel, srcObject, location, msgCode, pMsg, pTrav->pUserData); - pTrav = pTrav->pNext; - } - } - break; - } - } -} - static GLOBAL_CB_NODE* pGlobalCBHead = NULL; static GLOBAL_MEM_OBJ_NODE* pGlobalMemObjHead = NULL; static GLOBAL_OBJECT_NODE* pGlobalObjectHead = NULL; -- cgit v1.2.3