swr: [rasterizer core] Fix threadviz support in buckets
authorTim Rowley <timothy.o.rowley@intel.com>
Wed, 27 Apr 2016 19:02:27 +0000 (13:02 -0600)
committerTim Rowley <timothy.o.rowley@intel.com>
Thu, 5 May 2016 19:49:04 +0000 (14:49 -0500)
Need to do lazy eval of the threadviz knob since order of globals
is undefined.

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

index eb038b1d74db700f185c110230666b3d9a46acd9..7163f9d3837bd7e8f7c61b938777cc03e2a83193 100644 (file)
@@ -34,6 +34,18 @@ THREAD UINT tlsThreadId = 0;
 
 void BucketManager::RegisterThread(const std::string& name)
 {
+    // lazy evaluate threadviz knob
+    if (!mThreadViz && KNOB_BUCKETS_ENABLE_THREADVIZ)
+    {
+        uint32_t pid = GetCurrentProcessId();
+        std::stringstream str;
+        str << "threadviz." << pid;
+        mThreadVizDir = str.str();
+        CreateDirectory(mThreadVizDir.c_str(), NULL);
+
+        mThreadViz = true;
+    }
+
     BUCKET_THREAD newThread;
     newThread.name = name;
     newThread.root.children.reserve(mBuckets.size());
index 9dfa7f694d0e87b567c30b8943567874fe221a02..95841163155785ee6f3101a14d706ce30f896261 100644 (file)
@@ -47,17 +47,7 @@ extern THREAD UINT tlsThreadId;
 class BucketManager
 {
 public:
-    BucketManager(bool enableThreadViz) : mThreadViz(enableThreadViz)
-    {
-        if (mThreadViz)
-        {
-            uint32_t pid = GetCurrentProcessId();
-            std::stringstream str;
-            str << "threadviz." << pid;
-            mThreadVizDir = str.str();
-            CreateDirectory(mThreadVizDir.c_str(), NULL);
-        }
-    }
+    BucketManager() { }
 
     // removes all registered thread data
     void ClearThreads()
index df8bad3202372233e778ddaf88e94a515077a869..52c84ee2465615e1cd96bf14e8de9d11208e03f8 100644 (file)
@@ -90,6 +90,6 @@ BUCKET_DESC gCoreBuckets[] = {
 
 /// @todo bucketmanager and mapping should probably be a part of the SWR context
 std::vector<uint32_t> gBucketMap;
-BucketManager gBucketMgr(KNOB_BUCKETS_ENABLE_THREADVIZ);
+BucketManager gBucketMgr;
 
 uint32_t gCurrentFrame = 0;