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
4 changes: 2 additions & 2 deletions .github/workflows/.patches/dawn.diff
Original file line number Diff line number Diff line change
Expand Up @@ -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";
+ }
+
Expand Down
42 changes: 21 additions & 21 deletions include/gpgmm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
9 changes: 5 additions & 4 deletions include/gpgmm_d3d12.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@

#define GPGMM_INTERFACE struct

namespace gpgmm {
DEFINE_ENUM_FLAG_OPERATORS(EVENT_RECORD_FLAGS) // Provided by <windows.h>
}

namespace gpgmm::d3d12 {

/** \brief Debug object associates additional information for D3D objects using SetPrivateData.
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/gpgmm/d3d12/JSONSerializerD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/gpgmm/d3d12/JSONSerializerD3D12.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/gpgmm/d3d12/ResidencyManagerD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<TraceEventPhase>(~descriptor.RecordOptions.Flags));

Expand Down Expand Up @@ -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);

Expand Down
6 changes: 3 additions & 3 deletions src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<TraceEventPhase>(~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)
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/tests/D3D12Test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/tests/capture_replay_tests/D3D12EventTraceReplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<gpgmm::EVENT_RECORD_FLAGS>(envParams.CaptureEventMask);
static_cast<gpgmm::EventRecordFlags>(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) {
Expand Down