swr: [rasterizer common] portable threadviz buckets
authorTim Rowley <timothy.o.rowley@intel.com>
Wed, 4 May 2016 15:24:55 +0000 (09:24 -0600)
committerTim Rowley <timothy.o.rowley@intel.com>
Thu, 19 May 2016 21:25:30 +0000 (16:25 -0500)
Output with slashes instead of backslashes for unix/linux.

Reviewed-by: Bruce Cherniak <bruce.cherniak@intel.com>
src/gallium/drivers/swr/rasterizer/common/rdtsc_buckets.cpp

index 7163f9d3837bd7e8f7c61b938777cc03e2a83193..df09f6caadcd8a2ce48959807e83ce7bbb3a5f98 100644 (file)
 #include "rdtsc_buckets.h"
 #include <inttypes.h>
 
+#if defined(_WIN32)
+#define PATH_SEPARATOR "\\"
+#elif defined(__unix__)
+#define PATH_SEPARATOR "/"
+#else
+#error "Unsupported platform"
+#endif
+
 THREAD UINT tlsThreadId = 0;
 
 void BucketManager::RegisterThread(const std::string& name)
@@ -64,7 +72,8 @@ void BucketManager::RegisterThread(const std::string& name)
     if (mThreadViz)
     {
         std::stringstream ss;
-        ss << mThreadVizDir << "\\threadviz_thread." << newThread.id << ".dat";
+        ss << mThreadVizDir << PATH_SEPARATOR;
+        ss << "threadviz_thread." << newThread.id << ".dat";
         newThread.vizFile = fopen(ss.str().c_str(), "wb");
     }
 
@@ -171,7 +180,7 @@ void BucketManager::DumpThreadViz()
 
     // dump bucket descriptions
     std::stringstream ss;
-    ss << mThreadVizDir << "\\threadviz_buckets.dat";
+    ss << mThreadVizDir << PATH_SEPARATOR << "threadviz_buckets.dat";
 
     FILE* f = fopen(ss.str().c_str(), "wb");
     for (auto& bucket : mBuckets)