aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Ashburn <jon@lunarg.com>2015-02-16 08:46:53 -0700
committerJon Ashburn <jon@lunarg.com>2015-02-17 07:40:28 -0700
commit9763b939bb7bdb18343a4ec24d442a89ec935c2e (patch)
treea1c8a7ed176b9a18f3f9d0368ccaf0f4d66b7974
parentbd3025f9e97f8b310da1373144245aeae9db8414 (diff)
downloadusermoji-9763b939bb7bdb18343a4ec24d442a89ec935c2e.tar.xz
layers: Have DrawState and MemTracker use the common code for reporting
-rw-r--r--layers/draw_state.c68
-rw-r--r--layers/mem_tracker.c66
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;