From 89a7fdd64b9dd3c39205b3654b0ccfba8224f6c5 Mon Sep 17 00:00:00 2001 From: Bryan Bernhart Date: Tue, 3 May 2022 16:05:14 -0700 Subject: [PATCH] Add support to skip counter events. --- src/gpgmm/common/EventTraceWriter.cpp | 8 +++++++- src/gpgmm/common/EventTraceWriter.h | 4 +++- src/gpgmm/common/TraceEvent.cpp | 5 +++-- src/gpgmm/common/TraceEvent.h | 3 ++- src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp | 3 ++- src/gpgmm/d3d12/ResourceAllocatorD3D12.h | 10 ++++------ 6 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/gpgmm/common/EventTraceWriter.cpp b/src/gpgmm/common/EventTraceWriter.cpp index 3662a44ae..4c5b15221 100644 --- a/src/gpgmm/common/EventTraceWriter.cpp +++ b/src/gpgmm/common/EventTraceWriter.cpp @@ -35,11 +35,13 @@ namespace gpgmm { void EventTraceWriter::SetConfiguration(const std::string& traceFile, bool skipDurationEvents, bool skipObjectEvents, - bool skipInstantEvents) { + bool skipInstantEvents, + bool skipCounterEvents) { mTraceFile = (traceFile.empty()) ? mTraceFile : traceFile; mSkipDurationEvents = skipDurationEvents; mSkipObjectEvents = skipObjectEvents; mSkipInstantEvents = skipInstantEvents; + mSkipCounterEvents = skipCounterEvents; } EventTraceWriter::~EventTraceWriter() { @@ -81,6 +83,10 @@ namespace gpgmm { continue; } + if (mSkipCounterEvents && (traceEvent.mPhase == TRACE_EVENT_PHASE_COUNTER)) { + continue; + } + JSONDict eventData; eventData.AddItem("name", traceEvent.mName); diff --git a/src/gpgmm/common/EventTraceWriter.h b/src/gpgmm/common/EventTraceWriter.h index 9f2a668ec..ec2d0b995 100644 --- a/src/gpgmm/common/EventTraceWriter.h +++ b/src/gpgmm/common/EventTraceWriter.h @@ -33,7 +33,8 @@ namespace gpgmm { void SetConfiguration(const std::string& traceFile, bool skipDurationEvents, bool skipObjectEvents, - bool skipInstantEvents); + bool skipInstantEvents, + bool skipCounterEvents); ~EventTraceWriter(); @@ -59,6 +60,7 @@ namespace gpgmm { bool mSkipDurationEvents = false; bool mSkipObjectEvents = false; bool mSkipInstantEvents = false; + bool mSkipCounterEvents = false; }; } // namespace gpgmm diff --git a/src/gpgmm/common/TraceEvent.cpp b/src/gpgmm/common/TraceEvent.cpp index 5e03884d0..34c2709d5 100644 --- a/src/gpgmm/common/TraceEvent.cpp +++ b/src/gpgmm/common/TraceEvent.cpp @@ -35,9 +35,10 @@ namespace gpgmm { void StartupEventTrace(const std::string& traceFile, bool skipDurationEvents, bool skipObjectEvents, - bool skipInstantEvents) { + bool skipInstantEvents, + bool skipCounterEvents) { GetInstance()->SetConfiguration(traceFile, skipDurationEvents, skipObjectEvents, - skipInstantEvents); + skipInstantEvents, skipCounterEvents); TRACE_EVENT_METADATA1(TraceEventCategory::Metadata, "thread_name", "name", "GPGMM_MainThread"); } diff --git a/src/gpgmm/common/TraceEvent.h b/src/gpgmm/common/TraceEvent.h index 343948911..f16048f37 100644 --- a/src/gpgmm/common/TraceEvent.h +++ b/src/gpgmm/common/TraceEvent.h @@ -124,7 +124,8 @@ namespace gpgmm { void StartupEventTrace(const std::string& traceFile, bool skipDurationEvents, bool skipObjectEvents, - bool skipInstantEvents); + bool skipInstantEvents, + bool skipCounterEvents); void ShutdownEventTrace(); diff --git a/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp b/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp index 9031ac631..ded8fb420 100644 --- a/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp +++ b/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp @@ -363,7 +363,8 @@ namespace gpgmm { namespace d3d12 { 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)); + !(newDescriptor.RecordOptions.Flags & ALLOCATOR_RECORD_FLAG_API_CALLS), + !(newDescriptor.RecordOptions.Flags & ALLOCATOR_RECORD_FLAG_COUNTERS)); const LogSeverity& recordMessageMinLevel = static_cast(newDescriptor.RecordOptions.MinMessageLevel); diff --git a/src/gpgmm/d3d12/ResourceAllocatorD3D12.h b/src/gpgmm/d3d12/ResourceAllocatorD3D12.h index f355c5ca6..eaf14ff1e 100644 --- a/src/gpgmm/d3d12/ResourceAllocatorD3D12.h +++ b/src/gpgmm/d3d12/ResourceAllocatorD3D12.h @@ -125,6 +125,10 @@ namespace gpgmm { namespace d3d12 { */ ALLOCATOR_RECORD_FLAG_API_TIMINGS = 0x4, + /** \brief Record metrics made to GPGMM API calls. + */ + ALLOCATOR_RECORD_FLAG_COUNTERS = 0x8, + /** \brief Record events required for playback. Bitwise OR'd combination of ALLOCATOR_RECORD_FLAG_API_OBJECTS and @@ -132,12 +136,6 @@ namespace gpgmm { namespace d3d12 { */ ALLOCATOR_RECORD_FLAG_CAPTURE = 0x3, - /** \brief Record events required for profiling. - - Aliases or equal to ALLOCATOR_RECORD_FLAG_API_TIMINGS. - */ - ALLOCATOR_RECORD_FLAG_PROFILE = 0x4, - /** \brief Record everything. */ ALLOCATOR_RECORD_FLAG_ALL_EVENTS = 0xFF,