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
5 changes: 5 additions & 0 deletions src/gpgmm/d3d12/ResidencyHeapD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,12 @@ namespace gpgmm::d3d12 {
}

uint64_t ResidencyHeap::GetLastUsedFenceValue() const {
std::lock_guard<std::mutex> lock(mMutex);
return mLastUsedFenceValue;
}

void ResidencyHeap::SetLastUsedFenceValue(uint64_t fenceValue) {
std::lock_guard<std::mutex> lock(mMutex);
mLastUsedFenceValue = fenceValue;
}

Expand All @@ -351,10 +353,12 @@ namespace gpgmm::d3d12 {
}

RESIDENCY_HEAP_INFO ResidencyHeap::GetInfo() const {
std::lock_guard<std::mutex> lock(mMutex);
return {GetSize(), GetAlignment(), IsResidencyLocked(), mState};
}

HRESULT ResidencyHeap::SetDebugNameImpl(LPCWSTR name) {
std::lock_guard<std::mutex> lock(mMutex);
return SetDebugObjectName(mPageable.Get(), name);
}

Expand All @@ -371,6 +375,7 @@ namespace gpgmm::d3d12 {
}

void ResidencyHeap::SetResidencyStatus(RESIDENCY_HEAP_STATUS newStatus) {
std::lock_guard<std::mutex> lock(mMutex);
mState = newStatus;
}

Expand Down
13 changes: 11 additions & 2 deletions src/gpgmm/d3d12/ResidencyHeapD3D12.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,17 @@

#include <gpgmm_d3d12.h>

#include <mutex>

namespace gpgmm::d3d12 {

class ResidencyManager;

RESIDENCY_HEAP_FLAGS GetHeapFlags(D3D12_HEAP_FLAGS heapFlags, bool alwaysCreatedInBudget);

// Thread-safe managed heap type for performing residency operations.
// A ResidencyHeap wraps a ID3D12Pageable that can be temporarily or permanently made
// resident and can be explicitly or implicitly (through allocation) created.
class ResidencyHeap final : public MemoryBase,
public DebugObject,
public LinkNode<ResidencyHeap>,
Expand Down Expand Up @@ -98,11 +103,15 @@ namespace gpgmm::d3d12 {
ComPtr<IResidencyManager> mResidencyManager;
ComPtr<ID3D12Pageable> mPageable;

// mLastUsedFenceValue denotes the last time this pageable was submitted to the GPU.
uint64_t mLastUsedFenceValue = 0;
DXGI_MEMORY_SEGMENT_GROUP mHeapSegment;
RefCounted mResidencyLock;

// Protects thread-access to the mutable members below.
mutable std::mutex mMutex;
RESIDENCY_HEAP_STATUS mState;

// mLastUsedFenceValue denotes the last time this pageable was submitted to the GPU.
uint64_t mLastUsedFenceValue = 0;
};
} // namespace gpgmm::d3d12

Expand Down