swr: [rasterizer archrast] add support for stats files
[mesa.git] / src / gallium / drivers / swr / rasterizer / scripts / templates / ar_eventhandlerfile_h.template
index 6264442b0899aac1b4d669212c9107590b6cad73..2e3b5c32464d75c8ef89177a0177189593e3272d 100644 (file)
@@ -32,6 +32,7 @@
 #include "common/os.h"
 #include "${event_header}"
 #include <fstream>
+#include <sstream>
 
 namespace ArchRast
 {
@@ -44,11 +45,19 @@ namespace ArchRast
         EventHandlerFile(uint32_t id)
         {
 #if defined(_WIN32)
+            DWORD pid = GetCurrentProcessId();
+            TCHAR procname[MAX_PATH];
+            GetModuleFileName(NULL, procname, MAX_PATH);
+            const char* pBaseName = strrchr(procname, '\\');
+            std::stringstream outDir;
+            outDir << KNOB_DEBUG_OUTPUT_DIR << pBaseName << "_" << pid << std::ends;
+            CreateDirectory(outDir.str().c_str(), NULL);
+
             char buf[255];
             // There could be multiple threads creating thread pools. We
             // want to make sure they are uniquly identified by adding in
             // the creator's thread id into the filename.
-            sprintf(buf, "\\ar_event%d_%d.bin", GetCurrentThreadId(), id);
+            sprintf(buf, "%s\\ar_event%d_%d.bin", outDir.str().c_str(), GetCurrentThreadId(), id);
             mFilename = std::string(buf);
 #else
             SWR_ASSERT(0);