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
8 changes: 6 additions & 2 deletions src/gpgmm/common/EventTraceWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,17 @@ namespace gpgmm {
}

void EventTraceWriter::SetConfiguration(const std::string& traceFile,
const TraceEventPhase& ignoreMask) {
const TraceEventPhase& ignoreMask,
bool flushOnDestruct) {
mTraceFile = (traceFile.empty()) ? mTraceFile : traceFile;
mIgnoreMask = ignoreMask;
mFlushOnDestruct = flushOnDestruct;
}

EventTraceWriter::~EventTraceWriter() {
FlushQueuedEventsToDisk();
if (mFlushOnDestruct) {
FlushQueuedEventsToDisk();
}
}

void EventTraceWriter::EnqueueTraceEvent(char phase,
Expand Down
5 changes: 4 additions & 1 deletion src/gpgmm/common/EventTraceWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ namespace gpgmm {
public:
EventTraceWriter();

void SetConfiguration(const std::string& traceFile, const TraceEventPhase& ignoreMask);
void SetConfiguration(const std::string& traceFile,
const TraceEventPhase& ignoreMask,
bool flushOnDestruct);

~EventTraceWriter();

Expand All @@ -54,6 +56,7 @@ namespace gpgmm {
mBufferPerThread;

TraceEventPhase mIgnoreMask;
bool mFlushOnDestruct = true;
};

} // namespace gpgmm
Expand Down
6 changes: 4 additions & 2 deletions src/gpgmm/common/TraceEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ namespace gpgmm {
return gEventTrace.get();
}

void StartupEventTrace(const std::string& traceFile, const TraceEventPhase& ignoreMask) {
void StartupEventTrace(const std::string& traceFile,
const TraceEventPhase& ignoreMask,
bool flushOnDestruct) {
#if defined(GPGMM_DISABLE_TRACING)
gpgmm::WarningLog() << "Event tracing enabled but unable to record due to GPGMM_DISABLE_TRACING.";
#endif

GetInstance()->SetConfiguration(traceFile, ignoreMask);
GetInstance()->SetConfiguration(traceFile, ignoreMask, flushOnDestruct);
TRACE_EVENT_METADATA1(TraceEventCategory::Metadata, "thread_name", "name",
"GPGMM_MainThread");
}
Expand Down
3 changes: 2 additions & 1 deletion src/gpgmm/common/TraceEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ namespace gpgmm {
class PlatformTime;

void StartupEventTrace(const std::string& traceFile,
const TraceEventPhase& ignoreMask);
const TraceEventPhase& ignoreMask,
bool flushOnDestruct);

void ShutdownEventTrace();

Expand Down
6 changes: 4 additions & 2 deletions src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,10 @@ namespace gpgmm::d3d12 {
}

if (newDescriptor.RecordOptions.Flags != ALLOCATOR_RECORD_FLAG_NONE) {
StartupEventTrace(descriptor.RecordOptions.TraceFile,
static_cast<TraceEventPhase>(~newDescriptor.RecordOptions.Flags | 0));
StartupEventTrace(
descriptor.RecordOptions.TraceFile,
static_cast<TraceEventPhase>(~newDescriptor.RecordOptions.Flags | 0),
descriptor.RecordOptions.EventScope & ALLOCATOR_RECORD_SCOPE_PER_PROCESS);

SetEventMessageLevel(GetLogSeverity(newDescriptor.RecordOptions.MinMessageLevel));
}
Expand Down