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
10 changes: 5 additions & 5 deletions include/gpgmm_d3d12.h
Original file line number Diff line number Diff line change
Expand Up @@ -1183,10 +1183,10 @@ namespace gpgmm::d3d12 {
ALLOCATOR_FEATURE_RESOURCE_ALLOCATION_SUPPORT,
};

/** \struct RESOURCE_ALLOCATOR_STATS
Additional information about the resource allocator usage.
/** \struct ALLOCATOR_STATS
Additional information about allocator usage.
*/
struct RESOURCE_ALLOCATOR_STATS {
struct ALLOCATOR_STATS {
/** \brief Number of used sub-allocated blocks within the same memory.
*/
uint32_t UsedBlockCount;
Expand Down Expand Up @@ -1313,13 +1313,13 @@ namespace gpgmm::d3d12 {
UsedMemoryUsage. Or the percent of recycled memory is equal to FreeMemoryUsage /
(UsedMemoryUsage + FreeMemoryUsage) * 100%.

@param pResourceAllocatorStats A pointer to a RESOURCE_ALLOCATOR_STATS structure or NULL if
@param pResourceAllocatorStats A pointer to a ALLOCATOR_STATS structure or NULL if
statistics information should only be gathered for recording.

\return Returns S_OK if successful. Returns S_FALSE if statistics information was only
gathered for recording.
*/
virtual HRESULT QueryStats(RESOURCE_ALLOCATOR_STATS * pResourceAllocatorStats) = 0;
virtual HRESULT QueryStats(ALLOCATOR_STATS * pResourceAllocatorStats) = 0;

/** \brief Gets information about the features that are supported by the resource allocator.

Expand Down
4 changes: 2 additions & 2 deletions src/fuzzers/D3D12ResidencyManagerFuzzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ namespace {
: 0;
}

gpgmm::d3d12::RESOURCE_ALLOCATOR_STATS GetStats(
gpgmm::d3d12::ALLOCATOR_STATS GetStats(
ComPtr<gpgmm::d3d12::IResourceAllocator> resourceAllocator) {
gpgmm::d3d12::RESOURCE_ALLOCATOR_STATS stats = {};
gpgmm::d3d12::ALLOCATOR_STATS stats = {};
resourceAllocator->QueryStats(&stats);
return stats;
}
Expand Down
7 changes: 3 additions & 4 deletions src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1133,7 +1133,7 @@ namespace gpgmm::d3d12 {
// If over-budget, only free memory is considered available.
// TODO: Consider optimizing GetStatsInternal().
if (currentVideoInfo->CurrentUsage + request.SizeInBytes > currentVideoInfo->Budget) {
RESOURCE_ALLOCATOR_STATS allocationStats = {};
ALLOCATOR_STATS allocationStats = {};
GPGMM_RETURN_IF_FAILED(QueryStatsInternal(&allocationStats));

request.AvailableForAllocation = allocationStats.FreeHeapUsage;
Expand Down Expand Up @@ -1513,13 +1513,12 @@ namespace gpgmm::d3d12 {
return S_OK;
}

HRESULT ResourceAllocator::QueryStats(RESOURCE_ALLOCATOR_STATS* pResourceAllocatorStats) {
HRESULT ResourceAllocator::QueryStats(ALLOCATOR_STATS* pResourceAllocatorStats) {
std::lock_guard<std::mutex> lock(mMutex);
return QueryStatsInternal(pResourceAllocatorStats);
}

HRESULT ResourceAllocator::QueryStatsInternal(
RESOURCE_ALLOCATOR_STATS* pResourceAllocatorStats) {
HRESULT ResourceAllocator::QueryStatsInternal(ALLOCATOR_STATS* pResourceAllocatorStats) {
GPGMM_TRACE_EVENT_DURATION(TraceEventCategory::kDefault, "ResourceAllocator.QueryStats");

// ResourceAllocator itself could call CreateCommittedResource directly.
Expand Down
4 changes: 2 additions & 2 deletions src/gpgmm/d3d12/ResourceAllocatorD3D12.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ namespace gpgmm::d3d12 {
ID3D12Resource* pCommittedResource,
IResourceAllocation** ppResourceAllocationOut) override;
HRESULT ReleaseResourceHeaps(uint64_t bytesToRelease, uint64_t* pBytesReleased) override;
HRESULT QueryStats(RESOURCE_ALLOCATOR_STATS* pResourceAllocatorStats) override;
HRESULT QueryStats(ALLOCATOR_STATS* pResourceAllocatorStats) override;
HRESULT CheckFeatureSupport(ALLOCATOR_FEATURE feature,
void* pFeatureSupportData,
uint32_t featureSupportDataSize) const override;
Expand Down Expand Up @@ -148,7 +148,7 @@ namespace gpgmm::d3d12 {
// MemoryAllocator interface
void DeallocateMemory(std::unique_ptr<MemoryAllocation> allocation) override;

HRESULT QueryStatsInternal(RESOURCE_ALLOCATOR_STATS* pResourceAllocatorStats);
HRESULT QueryStatsInternal(ALLOCATOR_STATS* pResourceAllocatorStats);

ID3D12Device* mDevice = nullptr;
ComPtr<ResidencyManager> mResidencyManager;
Expand Down
2 changes: 1 addition & 1 deletion src/mvi/gpgmm_d3d12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ namespace gpgmm::d3d12 {
return E_NOTIMPL;
}

HRESULT ResourceAllocator::QueryStats(RESOURCE_ALLOCATOR_STATS* pResourceAllocatorStats) {
HRESULT ResourceAllocator::QueryStats(ALLOCATOR_STATS* pResourceAllocatorStats) {
return E_NOTIMPL;
}

Expand Down
2 changes: 1 addition & 1 deletion src/mvi/gpgmm_d3d12.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ namespace gpgmm::d3d12 {
ID3D12Resource* pCommittedResource,
IResourceAllocation** ppResourceAllocationOut) override;
HRESULT ReleaseResourceHeaps(uint64_t bytesToRelease, uint64_t* pBytesReleased) override;
HRESULT QueryStats(RESOURCE_ALLOCATOR_STATS* pResourceAllocatorStats) override;
HRESULT QueryStats(ALLOCATOR_STATS* pResourceAllocatorStats) override;
HRESULT CheckFeatureSupport(ALLOCATOR_FEATURE feature,
void* pFeatureSupportData,
uint32_t featureSupportDataSize) const override;
Expand Down
4 changes: 2 additions & 2 deletions src/tests/D3D12Test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ namespace gpgmm::d3d12 {
return unknown->Release();
}

RESOURCE_ALLOCATOR_STATS GetStats(ComPtr<IResourceAllocator> resourceAllocator) {
RESOURCE_ALLOCATOR_STATS stats = {};
ALLOCATOR_STATS GetStats(ComPtr<IResourceAllocator> resourceAllocator) {
ALLOCATOR_STATS stats = {};
resourceAllocator->QueryStats(&stats);
return stats;
}
Expand Down
2 changes: 1 addition & 1 deletion src/tests/D3D12Test.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace gpgmm::d3d12 {
D3D12_MESSAGE_SEVERITY GetMessageSeverity(MessageSeverity MessageSeverity);
long GetRefCount(IUnknown* unknown);

RESOURCE_ALLOCATOR_STATS GetStats(ComPtr<IResourceAllocator> resourceAllocator);
ALLOCATOR_STATS GetStats(ComPtr<IResourceAllocator> resourceAllocator);
RESIDENCY_MANAGER_STATS GetStats(ComPtr<IResidencyManager> residencyManager);

class D3D12TestBase : public GPGMMTestBase {
Expand Down
8 changes: 4 additions & 4 deletions src/tests/end2end/D3D12ResourceAllocatorTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1505,7 +1505,7 @@ TEST_F(D3D12ResourceAllocatorTests, CreateBufferStats) {
ASSERT_NE(firstAllocation, nullptr);
EXPECT_EQ(firstAllocation->GetInfo().Method, ALLOCATION_METHOD_STANDALONE);

RESOURCE_ALLOCATOR_STATS stats = GetStats(resourceAllocator);
ALLOCATOR_STATS stats = GetStats(resourceAllocator);
EXPECT_EQ(stats.UsedHeapCount, 1u);
EXPECT_EQ(stats.UsedHeapUsage, kBufferOf4MBAllocationSize);
}
Expand All @@ -1530,7 +1530,7 @@ TEST_F(D3D12ResourceAllocatorTests, CreateBufferStats) {
ASSERT_NE(firstAllocation, nullptr);
EXPECT_EQ(firstAllocation->GetInfo().Method, ALLOCATION_METHOD_STANDALONE);

RESOURCE_ALLOCATOR_STATS stats = GetStats(resourceAllocator);
ALLOCATOR_STATS stats = GetStats(resourceAllocator);
EXPECT_EQ(stats.UsedHeapCount, 1u);
EXPECT_EQ(stats.UsedHeapUsage, kBufferOf4MBAllocationSize);

Expand Down Expand Up @@ -1568,7 +1568,7 @@ TEST_F(D3D12ResourceAllocatorTests, CreateBufferStats) {
// TODO: Consider testing counts by allocator type.
GPGMM_SKIP_TEST_IF(firstAllocation->GetInfo().Method != ALLOCATION_METHOD_SUBALLOCATED);

RESOURCE_ALLOCATOR_STATS stats = GetStats(resourceAllocator);
ALLOCATOR_STATS stats = GetStats(resourceAllocator);
EXPECT_EQ(stats.UsedHeapCount, 1u);
EXPECT_GE(stats.UsedHeapUsage, stats.UsedBlockUsage);
EXPECT_EQ(stats.UsedBlockCount, 1u);
Expand Down Expand Up @@ -1608,7 +1608,7 @@ TEST_F(D3D12ResourceAllocatorTests, CreateBufferStats) {
ASSERT_NE(firstAllocation, nullptr);
EXPECT_EQ(firstAllocation->GetInfo().Method, ALLOCATION_METHOD_SUBALLOCATED_WITHIN);

RESOURCE_ALLOCATOR_STATS stats = GetStats(resourceAllocator);
ALLOCATOR_STATS stats = GetStats(resourceAllocator);
EXPECT_EQ(stats.UsedHeapCount, 1u);
EXPECT_EQ(stats.UsedHeapUsage, 64u * 1024u);
EXPECT_EQ(stats.UsedBlockCount, 1u);
Expand Down