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
2 changes: 1 addition & 1 deletion .github/workflows/.patches/dawn.diff
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ index fe99a63ac..353e47b82 100644
-
- return std::move(descriptorHeap);
+ heapDesc.SizeInBytes = mSizeIncrement * descriptorCount;
+ heapDesc.HeapSegmentGroup = DXGI_MEMORY_SEGMENT_GROUP_LOCAL;
+ heapDesc.HeapSegment = DXGI_MEMORY_SEGMENT_GROUP_LOCAL;
+
+ CreateHeapCallback callback(mDevice->GetD3D12Device(), descriptorCount, mHeapType);
+ ComPtr<gpgmm::d3d12::IHeap> descriptorHeap;
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Residency also works for non-resources too:
```cpp
gpgmm::d3d12::HEAP_DESC shaderVisibleHeap = {};
shaderVisibleHeap.SizeInBytes = kHeapSize;
shaderVisibleHeap.HeapSegmentGroup = DXGI_MEMORY_SEGMENT_GROUP_LOCAL;
shaderVisibleHeap.HeapSegment = DXGI_MEMORY_SEGMENT_GROUP_LOCAL;

ComPtr<gpgmm::d3d12::IHeap> descriptorHeap;
CreateHeapContext createHeapContext(heapDesc);
Expand Down
14 changes: 7 additions & 7 deletions include/gpgmm_d3d12.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ namespace gpgmm::d3d12 {

Required parameter.
*/
DXGI_MEMORY_SEGMENT_GROUP HeapSegmentGroup;
DXGI_MEMORY_SEGMENT_GROUP HeapSegment;

/** \brief Specifies heaps options.

Expand Down Expand Up @@ -583,23 +583,23 @@ namespace gpgmm::d3d12 {
A reservation is the lowest amount of physical memory the application need to continue
operation safely.

@param memorySegmentGroup Memory segment to reserve.
@param heapSegment Memory segment to reserve.
@param availableForReservation Amount of memory to reserve, in bytes.
@param[out] pCurrentReservationOut the amount of memory reserved, which may be less then the
|reservation| when under video memory pressure. A value of nullptr will update but not
return the current reservation.
*/
virtual HRESULT SetVideoMemoryReservation(
const DXGI_MEMORY_SEGMENT_GROUP& memorySegmentGroup, uint64_t availableForReservation,
uint64_t* pCurrentReservationOut = nullptr) = 0;
virtual HRESULT SetVideoMemoryReservation(const DXGI_MEMORY_SEGMENT_GROUP& heapSegment,
uint64_t availableForReservation,
uint64_t* pCurrentReservationOut = nullptr) = 0;

/** \brief Get the current budget and memory usage.

@param memorySegmentGroup Memory segment to retrieve info from.
@param heapSegment Memory segment to retrieve info from.
@param[out] pVideoMemoryInfoOut Pointer to DXGI_QUERY_VIDEO_MEMORY_INFO to populate. A value
of nullptr will update but not return the current info.
*/
virtual HRESULT QueryVideoMemoryInfo(const DXGI_MEMORY_SEGMENT_GROUP& memorySegmentGroup,
virtual HRESULT QueryVideoMemoryInfo(const DXGI_MEMORY_SEGMENT_GROUP& heapSegment,
DXGI_QUERY_VIDEO_MEMORY_INFO* pVideoMemoryInfoOut) = 0;

/** \brief Update the residency status of a heap.
Expand Down
6 changes: 3 additions & 3 deletions src/fuzzers/D3D12ResidencyManagerFuzzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ namespace {
std::vector<ComPtr<gpgmm::d3d12::IResourceAllocation>> gAllocationsBelowBudget = {};

uint64_t GetBudgetLeft(gpgmm::d3d12::IResidencyManager* const residencyManager,
const DXGI_MEMORY_SEGMENT_GROUP& memorySegmentGroup) {
const DXGI_MEMORY_SEGMENT_GROUP& heapSegment) {
if (residencyManager == nullptr) {
return 0;
}
DXGI_QUERY_VIDEO_MEMORY_INFO segment = {};
gResidencyManager->QueryVideoMemoryInfo(memorySegmentGroup, &segment);
gResidencyManager->QueryVideoMemoryInfo(heapSegment, &segment);
return (segment.Budget > segment.CurrentUsage) ? (segment.Budget - segment.CurrentUsage)
: 0;
}
Expand Down Expand Up @@ -89,7 +89,7 @@ extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv) {
gDevice->GetCustomHeapProperties(0, allocationDesc.HeapType);

const DXGI_MEMORY_SEGMENT_GROUP bufferMemorySegment =
gpgmm::d3d12::GetMemorySegmentGroup(heapProperties.MemoryPoolPreference, arch.UMA);
gpgmm::d3d12::GetHeapSegment(heapProperties.MemoryPoolPreference, arch.UMA);

constexpr uint64_t kBufferMemorySize = GPGMM_MB_TO_BYTES(1);
const D3D12_RESOURCE_DESC bufferDesc = CreateBufferDesc(kBufferMemorySize);
Expand Down
12 changes: 6 additions & 6 deletions src/gpgmm/d3d12/HeapD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ namespace gpgmm::d3d12 {
// Ensure enough budget exists before creating the heap to avoid an out-of-memory error.
if (!isResidencyDisabled && (descriptor.Flags & HEAP_FLAG_ALWAYS_IN_BUDGET)) {
uint64_t bytesEvicted = descriptor.SizeInBytes;
ReturnIfFailed(residencyManager->EvictInternal(
descriptor.SizeInBytes, descriptor.HeapSegmentGroup, &bytesEvicted));
ReturnIfFailed(residencyManager->EvictInternal(descriptor.SizeInBytes,
descriptor.HeapSegment, &bytesEvicted));

if (bytesEvicted < descriptor.SizeInBytes) {
DXGI_QUERY_VIDEO_MEMORY_INFO currentVideoInfo = {};
if (SUCCEEDED(residencyManager->QueryVideoMemoryInfo(descriptor.HeapSegmentGroup,
if (SUCCEEDED(residencyManager->QueryVideoMemoryInfo(descriptor.HeapSegment,
&currentVideoInfo))) {
gpgmm::ErrorLog(MessageId::kBudgetExceeded)
<< "Unable to create heap because not enough budget exists ("
Expand Down Expand Up @@ -173,7 +173,7 @@ namespace gpgmm::d3d12 {
bool isResidencyDisabled)
: MemoryBase(descriptor.SizeInBytes, descriptor.Alignment),
mPageable(std::move(pageable)),
mMemorySegmentGroup(descriptor.HeapSegmentGroup),
mHeapSegment(descriptor.HeapSegment),
mResidencyLock(0),
mIsResidencyDisabled(isResidencyDisabled),
mState(RESIDENCY_STATUS_UNKNOWN) {
Expand Down Expand Up @@ -214,8 +214,8 @@ namespace gpgmm::d3d12 {
mLastUsedFenceValue = fenceValue;
}

DXGI_MEMORY_SEGMENT_GROUP Heap::GetMemorySegmentGroup() const {
return mMemorySegmentGroup;
DXGI_MEMORY_SEGMENT_GROUP Heap::GetHeapSegment() const {
return mHeapSegment;
}

void Heap::AddResidencyLockRef() {
Expand Down
4 changes: 2 additions & 2 deletions src/gpgmm/d3d12/HeapD3D12.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ namespace gpgmm::d3d12 {
bool IsExternal() const override;

HRESULT SetDebugNameImpl(LPCWSTR name) override;
DXGI_MEMORY_SEGMENT_GROUP GetMemorySegmentGroup() const;
DXGI_MEMORY_SEGMENT_GROUP GetHeapSegment() const;

// The residency manager must know the last fence value that any portion of the pageable was
// submitted to be used so that we can ensure this pageable stays resident in memory at
Expand All @@ -84,7 +84,7 @@ namespace gpgmm::d3d12 {

// mLastUsedFenceValue denotes the last time this pageable was submitted to the GPU.
uint64_t mLastUsedFenceValue = 0;
DXGI_MEMORY_SEGMENT_GROUP mMemorySegmentGroup;
DXGI_MEMORY_SEGMENT_GROUP mHeapSegment;
RefCounted mResidencyLock;
bool mIsResidencyDisabled;
RESIDENCY_STATUS mState;
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 @@ -162,7 +162,7 @@ namespace gpgmm::d3d12 {
JSONDict dict;
dict.AddItem("SizeInBytes", desc.SizeInBytes);
dict.AddItem("Alignment", desc.Alignment);
dict.AddItem("HeapSegmentGroup", desc.HeapSegmentGroup);
dict.AddItem("HeapSegment", desc.HeapSegment);
dict.AddItem("Flags", desc.Flags);
if (desc.DebugName != nullptr) {
dict.AddItem("DebugName", WCharToUTF8(desc.DebugName));
Expand Down
Loading