diff --git a/src/tests/D3D12Test.cpp b/src/tests/D3D12Test.cpp index 5fef409a5..b7bc704cd 100644 --- a/src/tests/D3D12Test.cpp +++ b/src/tests/D3D12Test.cpp @@ -78,6 +78,10 @@ namespace gpgmm { namespace d3d12 { desc.RecordOptions.UseDetailedTimingEvents = true; #endif + if (IsDumpResourceAllocatorEnabled()) { + desc.RecordOptions.Flags |= ALLOCATOR_RECORD_FLAG_ALL_EVENTS; + } + return desc; } diff --git a/src/tests/GPGMMTest.cpp b/src/tests/GPGMMTest.cpp index 19956818f..16b938e68 100644 --- a/src/tests/GPGMMTest.cpp +++ b/src/tests/GPGMMTest.cpp @@ -36,6 +36,10 @@ gpgmm::DebugPlatform* GPGMMTestBase::GetDebugPlatform() { return mDebugPlatform.get(); } +bool GPGMMTestBase::IsDumpResourceAllocatorEnabled() const { + return gTestEnv->IsDumpResourceAllocatorEnabled(); +} + // static std::vector GPGMMTestBase::GenerateTestAllocations(uint64_t alignment) { return { @@ -83,13 +87,28 @@ std::vector GPGMMTestBase::GenerateTestAllocations(uin }; } -// GPGMMTestEnvironment - void InitGPGMMEnd2EndTestEnvironment(int argc, char** argv) { - gTestEnv = new GPGMMTestEnvironment(); + gTestEnv = new GPGMMTestEnvironment(argc, argv); testing::AddGlobalTestEnvironment(gTestEnv); } +// GPGMMTestEnvironment + +GPGMMTestEnvironment::GPGMMTestEnvironment(int argc, char** argv) { + for (int i = 1; i < argc; ++i) { + if (strcmp("--dump", argv[i]) == 0) { + mIsDumpResourceAllocatorEnabled = true; + continue; + } + + if (strcmp("-h", argv[i]) == 0 || strcmp("--help", argv[i]) == 0) { + gpgmm::InfoLog() << "Global options:\n" + << " --dump: Record all events to disk.\n"; + continue; + } + } +} + // static void GPGMMTestEnvironment::SetEnvironment(GPGMMTestEnvironment* env) { gTestEnv = env; @@ -97,3 +116,7 @@ void GPGMMTestEnvironment::SetEnvironment(GPGMMTestEnvironment* env) { void GPGMMTestEnvironment::SetUp() { } + +bool GPGMMTestEnvironment::IsDumpResourceAllocatorEnabled() const { + return mIsDumpResourceAllocatorEnabled; +} diff --git a/src/tests/GPGMMTest.h b/src/tests/GPGMMTest.h index 1504e13a6..feb4fb715 100644 --- a/src/tests/GPGMMTest.h +++ b/src/tests/GPGMMTest.h @@ -61,6 +61,8 @@ class GPGMMTestBase { gpgmm::DebugPlatform* GetDebugPlatform(); + bool IsDumpResourceAllocatorEnabled() const; + static std::vector GenerateTestAllocations(uint64_t alignment); }; @@ -68,11 +70,16 @@ void InitGPGMMEnd2EndTestEnvironment(int argc, char** argv); class GPGMMTestEnvironment : public testing::Environment { public: - GPGMMTestEnvironment() = default; + GPGMMTestEnvironment(int argc, char** argv); static void SetEnvironment(GPGMMTestEnvironment* env); void SetUp() override; + + bool IsDumpResourceAllocatorEnabled() const; + + private: + bool mIsDumpResourceAllocatorEnabled = false; }; #endif // TESTS_GPGMMTEST_H_ diff --git a/src/tests/capture_replay_tests/GPGMMCaptureReplayTests.cpp b/src/tests/capture_replay_tests/GPGMMCaptureReplayTests.cpp index f82575220..650cb684b 100644 --- a/src/tests/capture_replay_tests/GPGMMCaptureReplayTests.cpp +++ b/src/tests/capture_replay_tests/GPGMMCaptureReplayTests.cpp @@ -82,7 +82,8 @@ void InitGPGMMCaptureReplayTestEnvironment(int argc, char** argv) { testing::AddGlobalTestEnvironment(gTestEnv); } -GPGMMCaptureReplayTestEnvironment::GPGMMCaptureReplayTestEnvironment(int argc, char** argv) { +GPGMMCaptureReplayTestEnvironment::GPGMMCaptureReplayTestEnvironment(int argc, char** argv) + : GPGMMTestEnvironment(argc, argv) { for (int i = 1; i < argc; ++i) { constexpr const char kIterationArg[] = "--iterations="; size_t arglen = sizeof(kIterationArg) - 1;