Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/gpgmm/EventTraceWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include "gpgmm/EventTraceWriter.h"

#include "gpgmm/Defaults.h"
#include "gpgmm/common/Assert.h"
#include "gpgmm/common/Log.h"
#include "gpgmm/common/PlatformTime.h"
Expand All @@ -27,14 +28,15 @@

namespace gpgmm {

EventTraceWriter::EventTraceWriter() : mPlatformTime(CreatePlatformTime()) {
EventTraceWriter::EventTraceWriter()
: mTraceFile(kDefaultTraceFile), mPlatformTime(CreatePlatformTime()) {
}

void EventTraceWriter::SetConfiguration(const std::string& traceFile,
bool skipDurationEvents,
bool skipObjectEvents,
bool skipInstantEvents) {
mTraceFile = traceFile;
mTraceFile = (traceFile.empty()) ? mTraceFile : traceFile;
mSkipDurationEvents = skipDurationEvents;
mSkipObjectEvents = skipObjectEvents;
mSkipInstantEvents = skipInstantEvents;
Expand Down
7 changes: 5 additions & 2 deletions src/gpgmm/TraceEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ namespace gpgmm {
}

bool IsEventTraceEnabled() {
return (GetInstance() != nullptr);
std::lock_guard<std::mutex> lock(mMutex);
return gEventTrace != nullptr;
}

TraceEvent::TraceEvent(char phase,
Expand All @@ -75,6 +76,8 @@ namespace gpgmm {
uint64_t id,
uint32_t flags,
const JSONDict& args) {
GetInstance()->EnqueueTraceEvent(phase, category, name, id, flags, args);
if (IsEventTraceEnabled()) {
GetInstance()->EnqueueTraceEvent(phase, category, name, id, flags, args);
}
}
} // namespace gpgmm
7 changes: 2 additions & 5 deletions src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,12 +359,9 @@ namespace gpgmm { namespace d3d12 {
}

if (newDescriptor.RecordOptions.Flags != ALLOCATOR_RECORD_FLAG_NONE) {
const std::string& traceFile = descriptor.RecordOptions.TraceFile.empty()
? std::string(kDefaultTraceFile)
: descriptor.RecordOptions.TraceFile;

StartupEventTrace(
traceFile, !(newDescriptor.RecordOptions.Flags & ALLOCATOR_RECORD_FLAG_API_TIMINGS),
descriptor.RecordOptions.TraceFile,
!(newDescriptor.RecordOptions.Flags & ALLOCATOR_RECORD_FLAG_API_TIMINGS),
!(newDescriptor.RecordOptions.Flags & ALLOCATOR_RECORD_FLAG_API_OBJECTS),
!(newDescriptor.RecordOptions.Flags & ALLOCATOR_RECORD_FLAG_API_CALLS));

Expand Down