aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobin Ehlis <tobin@lunarg.com>2014-12-16 17:34:50 -0700
committerTobin Ehlis <tobin@lunarg.com>2014-12-16 17:34:50 -0700
commit3c2edf622c7c16b2abbcd0abffc23acdc48d437c (patch)
treed07ad5d5498c8bd3a9f7c5b3c789d398eca49e29
parentaa6d884237bfa9f4029b878ecff1b483dbcfb44b (diff)
downloadusermoji-3c2edf622c7c16b2abbcd0abffc23acdc48d437c.tar.xz
layers: DrawState layer can now dump png image of dot graph
-rw-r--r--layers/draw_state.c24
-rw-r--r--layers/draw_state.h5
2 files changed, 28 insertions, 1 deletions
diff --git a/layers/draw_state.c b/layers/draw_state.c
index 1e8b1635..b16a5ef8 100644
--- a/layers/draw_state.c
+++ b/layers/draw_state.c
@@ -27,6 +27,7 @@
#include <string.h>
#include <assert.h>
#include <pthread.h>
+#include <unistd.h>
#include "xgl_struct_string_helper.h"
#include "xgl_struct_graphviz_helper.h"
#include "draw_state.h"
@@ -878,6 +879,10 @@ static void synchAndPrintDSConfig()
if (autoDumpOnce) {
autoDumpOnce = 0;
dumpDotFile("pipeline_dump.dot");
+ // Convert dot to png if dot available
+ if(access( "/usr/bin/dot", X_OK) != -1) {
+ system("/usr/bin/dot pipeline_dump.dot -Tpng -o pipeline_dump.png");
+ }
}
}
@@ -2037,6 +2042,23 @@ XGL_VOID drawStateDumpDotFile(char* outFileName)
dumpDotFile(outFileName);
}
+XGL_VOID drawStateDumpPngFile(char* outFileName)
+{
+ char dotExe[32] = "/usr/bin/dot";
+ if( access(dotExe, X_OK) != -1) {
+ dumpDotFile("/tmp/tmp.dot");
+ char dotCmd[1024];
+ sprintf(dotCmd, "%s /tmp/tmp.dot -Tpng -o %s", dotExe, outFileName);
+ system(dotCmd);
+ remove("/tmp/tmp.dot");
+ }
+ else {
+ char str[1024];
+ 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);
+ }
+}
+
XGL_LAYER_EXPORT XGL_VOID* XGLAPI xglGetProcAddr(XGL_PHYSICAL_GPU gpu, const XGL_CHAR* funcName)
{
XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu;
@@ -2071,6 +2093,8 @@ XGL_LAYER_EXPORT XGL_VOID* XGLAPI xglGetProcAddr(XGL_PHYSICAL_GPU gpu, const XGL
return xglDeviceWaitIdle;
else if (!strncmp("drawStateDumpDotFile", (const char *) funcName, sizeof("drawStateDumpDotFile")))
return drawStateDumpDotFile;
+ else if (!strncmp("drawStateDumpPngFile", (const char *) funcName, sizeof("drawStateDumpPngFile")))
+ return drawStateDumpPngFile;
else if (!strncmp("xglGetMemoryHeapCount", (const char *) funcName, sizeof("xglGetMemoryHeapCount")))
return xglGetMemoryHeapCount;
else if (!strncmp("xglGetMemoryHeapInfo", (const char *) funcName, sizeof("xglGetMemoryHeapInfo")))
diff --git a/layers/draw_state.h b/layers/draw_state.h
index d505c46c..73231e5b 100644
--- a/layers/draw_state.h
+++ b/layers/draw_state.h
@@ -44,6 +44,7 @@ typedef enum _DRAW_STATE_ERROR
DRAWSTATE_INVALID_PIPELINE = 16, // Invalid DS referenced
DRAWSTATE_VTX_INDEX_OUT_OF_BOUNDS = 17, // binding in xglCmdBindVertexData() too large for PSO's pVertexBindingDescriptions array
DRAWSTATE_INVALID_DYNAMIC_STATE_OBJECT = 18, // Invalid dyn state object
+ DRAWSTATE_MISSING_DOT_PROGRAM = 19, // No "dot" program in order to generate png image
} DRAW_STATE_ERROR;
typedef enum _DRAW_TYPE
@@ -59,5 +60,7 @@ typedef enum _DRAW_TYPE
//prototypes for extension functions
XGL_VOID drawStateDumpDotFile(char* outFileName);
-// Func ptr typedef
+XGL_VOID drawStateDumpPngFile(char* outFileName);
+// Func ptr typedefs
typedef XGL_VOID (*DRAW_STATE_DUMP_DOT_FILE)(char*);
+typedef XGL_VOID (*DRAW_STATE_DUMP_PNG_FILE)(char*);