swr: [rasterizer core] Fix threadviz support in buckets

Need to do lazy eval of the threadviz knob since order of globals
is undefined.

Reviewed-by: Bruce Cherniak <bruce.cherniak@intel.com>
This commit is contained in:
Tim Rowley 2016-04-27 13:02:27 -06:00
parent 1eb211c4a4
commit c2f5d2daa8
3 changed files with 14 additions and 12 deletions

View 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());

View 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()

View 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;