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: 4 additions & 0 deletions src/tests/D3D12Test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
29 changes: 26 additions & 3 deletions src/tests/GPGMMTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ gpgmm::DebugPlatform* GPGMMTestBase::GetDebugPlatform() {
return mDebugPlatform.get();
}

bool GPGMMTestBase::IsDumpResourceAllocatorEnabled() const {
return gTestEnv->IsDumpResourceAllocatorEnabled();
}

// static
std::vector<MEMORY_ALLOCATION_EXPECT> GPGMMTestBase::GenerateTestAllocations(uint64_t alignment) {
return {
Expand Down Expand Up @@ -83,17 +87,36 @@ std::vector<MEMORY_ALLOCATION_EXPECT> 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;
}

void GPGMMTestEnvironment::SetUp() {
}

bool GPGMMTestEnvironment::IsDumpResourceAllocatorEnabled() const {
return mIsDumpResourceAllocatorEnabled;
}
9 changes: 8 additions & 1 deletion src/tests/GPGMMTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,25 @@ class GPGMMTestBase {

gpgmm::DebugPlatform* GetDebugPlatform();

bool IsDumpResourceAllocatorEnabled() const;

static std::vector<MEMORY_ALLOCATION_EXPECT> GenerateTestAllocations(uint64_t alignment);
};

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_
3 changes: 2 additions & 1 deletion src/tests/capture_replay_tests/GPGMMCaptureReplayTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down