diff --git a/.github/workflows/.patches/dawn.diff b/.github/workflows/.patches/dawn.diff index eb89d5832..8d1f0ae88 100644 --- a/.github/workflows/.patches/dawn.diff +++ b/.github/workflows/.patches/dawn.diff @@ -509,8 +509,8 @@ index 214fa67f8..d909d4d2a 100644 + } + + if (IsToggleEnabled(Toggle::DumpResourceAllocator)) { -+ residencyDesc.RecordOptions.Flags |= gpgmm::EVENT_RECORD_FLAG_ALL_EVENTS; -+ residencyDesc.RecordOptions.EventScope = gpgmm::EVENT_RECORD_SCOPE_PER_INSTANCE; ++ residencyDesc.RecordOptions.Flags |= gpgmm::EventRecordFlags::kAll; ++ residencyDesc.RecordOptions.EventScope = gpgmm::EventRecordScope::kPerInstance; + residencyDesc.RecordOptions.TraceFile = "dawn_resource_allocator_dump.json"; + } + diff --git a/include/gpgmm.h b/include/gpgmm.h index c84776466..956bc41de 100644 --- a/include/gpgmm.h +++ b/include/gpgmm.h @@ -99,72 +99,72 @@ namespace gpgmm { kSubAllocatedWithin = 3, }; - /** \enum EVENT_RECORD_FLAGS - Represents different event categories to record. - */ - enum EVENT_RECORD_FLAGS { + /** \enum EventRecordFlags + Represents different event categories to record. + */ + enum EventRecordFlags { /** \brief Record nothing. */ - EVENT_RECORD_FLAG_NONE = 0x0, + kNone = 0x0, /** \brief Record lifetimes of API objects created by GPGMM. */ - EVENT_RECORD_FLAG_API_OBJECTS = 0x1, + kApiObjects = 0x1, /** \brief Record API calls made to GPGMM. */ - EVENT_RECORD_FLAG_API_CALLS = 0x2, + kApiCalls = 0x2, /** \brief Record duration of GPGMM API calls. */ - EVENT_RECORD_FLAG_API_TIMINGS = 0x4, + kApiTimings = 0x4, /** \brief Record metrics made to GPGMM API calls. */ - EVENT_RECORD_FLAG_COUNTERS = 0x8, + kCounters = 0x8, /** \brief Record events required for playback. - Bitwise OR'd combination of EVENT_RECORD_FLAG_API_OBJECTS and - EVENT_RECORD_FLAG_API_CALLS. + Bitwise OR'd combination of kApiObjects and + kApiCalls. */ - EVENT_RECORD_FLAG_CAPTURE = 0x3, + kCapture = 0x3, /** \brief Record everything. */ - EVENT_RECORD_FLAG_ALL_EVENTS = 0xFF, + kAll = 0xFF, }; - /** \enum EVENT_RECORD_SCOPE + /** \enum EventRecordScope Represents recording scopes to limit event recording. */ - enum EVENT_RECORD_SCOPE { + enum EventRecordScope { /** \brief Scopes events per process (or multiple instances). */ - EVENT_RECORD_SCOPE_PER_PROCESS = 0, + kPerProcess = 0, /** \brief Scopes events per instance. */ - EVENT_RECORD_SCOPE_PER_INSTANCE = 1, + kPerInstance = 1, }; - /** \struct EVENT_RECORD_OPTIONS + /** \struct EventRecordOptions Represents additional controls for recording. */ - struct EVENT_RECORD_OPTIONS { + struct EventRecordOptions { /** \brief Flags used to decide what to record. Optional parameter. By default, nothing is recorded. */ - EVENT_RECORD_FLAGS Flags; + EventRecordFlags Flags; /** \brief Specifies the scope of the events. Optional parameter. By default, recording is per process. */ - EVENT_RECORD_SCOPE EventScope; + EventRecordScope EventScope; /** \brief Record detailed timing events. diff --git a/include/gpgmm_d3d12.h b/include/gpgmm_d3d12.h index fc549043f..d3f68513f 100644 --- a/include/gpgmm_d3d12.h +++ b/include/gpgmm_d3d12.h @@ -37,10 +37,6 @@ #define GPGMM_INTERFACE struct -namespace gpgmm { - DEFINE_ENUM_FLAG_OPERATORS(EVENT_RECORD_FLAGS) // Provided by -} - namespace gpgmm::d3d12 { /** \brief Debug object associates additional information for D3D objects using SetPrivateData. @@ -280,6 +276,11 @@ namespace gpgmm::d3d12 { virtual HRESULT Reset() = 0; }; + using EVENT_RECORD_FLAGS = EventRecordFlags; + using EVENT_RECORD_OPTIONS = EventRecordOptions; + + DEFINE_ENUM_FLAG_OPERATORS(EVENT_RECORD_FLAGS) + /** \brief Create a residency list or collection of heaps to manage together for residency. @param[out] ppResidencyListOut An optional pointer to a memory block that receives the diff --git a/src/gpgmm/d3d12/JSONSerializerD3D12.cpp b/src/gpgmm/d3d12/JSONSerializerD3D12.cpp index e1a364f65..d269746ee 100644 --- a/src/gpgmm/d3d12/JSONSerializerD3D12.cpp +++ b/src/gpgmm/d3d12/JSONSerializerD3D12.cpp @@ -87,7 +87,7 @@ namespace gpgmm::d3d12 { } // static - JSONDict JSONSerializer::Serialize(const EVENT_RECORD_OPTIONS& desc) { + JSONDict JSONSerializer::Serialize(const EventRecordOptions& desc) { JSONDict dict; dict.AddItem("Flags", desc.Flags); return dict; diff --git a/src/gpgmm/d3d12/JSONSerializerD3D12.h b/src/gpgmm/d3d12/JSONSerializerD3D12.h index 7a01f4837..ef5b4b4df 100644 --- a/src/gpgmm/d3d12/JSONSerializerD3D12.h +++ b/src/gpgmm/d3d12/JSONSerializerD3D12.h @@ -58,7 +58,7 @@ namespace gpgmm::d3d12 { static JSONDict Serialize(const RESIDENCY_DESC& desc); private: - static JSONDict Serialize(const EVENT_RECORD_OPTIONS& desc); + static JSONDict Serialize(const EventRecordOptions& desc); static JSONDict Serialize(const D3D12_DEPTH_STENCIL_VALUE& depthStencilValue); static JSONDict Serialize(const FLOAT rgba[4]); static JSONDict Serialize(const D3D12_CLEAR_VALUE* clearValue); diff --git a/src/gpgmm/d3d12/ResidencyManagerD3D12.cpp b/src/gpgmm/d3d12/ResidencyManagerD3D12.cpp index ad638d78d..db5a5a6cc 100644 --- a/src/gpgmm/d3d12/ResidencyManagerD3D12.cpp +++ b/src/gpgmm/d3d12/ResidencyManagerD3D12.cpp @@ -182,7 +182,7 @@ namespace gpgmm::d3d12 { return E_UNEXPECTED; } - if (descriptor.RecordOptions.Flags != EVENT_RECORD_FLAG_NONE) { + if (descriptor.RecordOptions.Flags != EventRecordFlags::kNone) { StartupEventTrace(descriptor.RecordOptions.TraceFile, static_cast(~descriptor.RecordOptions.Flags)); @@ -271,7 +271,7 @@ namespace gpgmm::d3d12 { mIsBudgetChangeEventsDisabled(descriptor.Flags & RESIDENCY_FLAG_NEVER_UPDATE_BUDGET_ON_WORKER_THREAD), mFlushEventBuffersOnDestruct(descriptor.RecordOptions.EventScope & - EVENT_RECORD_SCOPE_PER_INSTANCE), + EventRecordScope::kPerInstance), mInitialFenceValue(descriptor.InitialFenceValue) { GPGMM_TRACE_EVENT_OBJECT_NEW(this); diff --git a/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp b/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp index acd26f166..519fedc9f 100644 --- a/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp +++ b/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp @@ -528,14 +528,14 @@ namespace gpgmm::d3d12 { } if (pResidencyManager == nullptr && - newDescriptor.RecordOptions.Flags != EVENT_RECORD_FLAG_NONE) { + newDescriptor.RecordOptions.Flags != EventRecordFlags::kNone) { StartupEventTrace(allocatorDescriptor.RecordOptions.TraceFile, static_cast(~newDescriptor.RecordOptions.Flags)); SetEventMessageLevel(GetMessageSeverity(newDescriptor.MinRecordLevel)); } else { // Do not override the event scope from a event trace already enabled. - newDescriptor.RecordOptions.EventScope = EVENT_RECORD_SCOPE_PER_PROCESS; + newDescriptor.RecordOptions.EventScope = EventRecordScope::kPerProcess; } #if defined(GPGMM_ENABLE_DEVICE_LEAK_CHECKS) @@ -574,7 +574,7 @@ namespace gpgmm::d3d12 { mIsAlwaysCommitted(descriptor.Flags & ALLOCATOR_FLAG_ALWAYS_COMMITTED), mIsHeapAlwaysCreatedInBudget(descriptor.Flags & ALLOCATOR_FLAG_ALWAYS_IN_BUDGET), mFlushEventBuffersOnDestruct(descriptor.RecordOptions.EventScope & - EVENT_RECORD_SCOPE_PER_INSTANCE), + EventRecordScope::kPerInstance), mUseDetailedTimingEvents(descriptor.RecordOptions.UseDetailedTimingEvents), mIsCustomHeapsDisabled(descriptor.Flags & ALLOCATOR_FLAG_DISABLE_UNIFIED_MEMORY) { ASSERT(mDevice != nullptr); diff --git a/src/tests/D3D12Test.cpp b/src/tests/D3D12Test.cpp index c2aa13236..309872dbe 100644 --- a/src/tests/D3D12Test.cpp +++ b/src/tests/D3D12Test.cpp @@ -115,7 +115,7 @@ namespace gpgmm::d3d12 { desc.MinLogLevel = GetMessageSeverity(GetLogLevel()); if (IsDumpEventsEnabled()) { - desc.RecordOptions.Flags |= EVENT_RECORD_FLAG_ALL_EVENTS; + desc.RecordOptions.Flags |= EventRecordFlags::kAll; desc.MinRecordLevel = desc.MinLogLevel; desc.RecordOptions.UseDetailedTimingEvents = true; @@ -141,7 +141,7 @@ namespace gpgmm::d3d12 { desc.MinLogLevel = GetMessageSeverity(GetLogLevel()); if (IsDumpEventsEnabled()) { - desc.RecordOptions.Flags |= EVENT_RECORD_FLAG_ALL_EVENTS; + desc.RecordOptions.Flags |= EventRecordFlags::kAll; desc.MinRecordLevel = desc.MinLogLevel; desc.RecordOptions.UseDetailedTimingEvents = true; } diff --git a/src/tests/capture_replay_tests/D3D12EventTraceReplay.cpp b/src/tests/capture_replay_tests/D3D12EventTraceReplay.cpp index 25743fa72..accec041c 100644 --- a/src/tests/capture_replay_tests/D3D12EventTraceReplay.cpp +++ b/src/tests/capture_replay_tests/D3D12EventTraceReplay.cpp @@ -188,14 +188,14 @@ class D3D12EventTraceReplay : public D3D12TestBase, public CaptureReplayTestWith // Captures never store recording options, they must be always specified. baseAllocatorDesc.RecordOptions.Flags |= - static_cast(envParams.CaptureEventMask); + static_cast(envParams.CaptureEventMask); baseAllocatorDesc.RecordOptions.TraceFile = traceFile.path.c_str(); baseAllocatorDesc.MinRecordLevel = baseAllocatorDesc.MinLogLevel; // Keep recording across multiple playback iterations to ensure all // events will be captured instead of overwritten per iteration. if (envParams.Iterations == 1) { - baseAllocatorDesc.RecordOptions.EventScope = gpgmm::EVENT_RECORD_SCOPE_PER_INSTANCE; + baseAllocatorDesc.RecordOptions.EventScope = gpgmm::EventRecordScope::kPerInstance; } if (!envParams.IsPrefetchAllowed) {