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
6 changes: 3 additions & 3 deletions src/gpgmm/d3d12/CapsD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ namespace gpgmm::d3d12 {
device->CheckFeatureSupport(D3D12_FEATURE_GPU_VIRTUAL_ADDRESS_SUPPORT, &feature,
sizeof(D3D12_FEATURE_DATA_GPU_VIRTUAL_ADDRESS_SUPPORT)));
// Check for overflow.
if (feature.MaxGPUVirtualAddressBitsPerResource == 0 ||
feature.MaxGPUVirtualAddressBitsPerResource > GetNumOfBits<uint64_t>()) {
if (feature.MaxGPUVirtualAddressBitsPerProcess == 0 ||
feature.MaxGPUVirtualAddressBitsPerProcess > GetNumOfBits<uint64_t>()) {
return E_FAIL;
}

*sizeOut = (1ull << (feature.MaxGPUVirtualAddressBitsPerResource - 1)) - 1;
*sizeOut = (1ull << (feature.MaxGPUVirtualAddressBitsPerProcess - 1)) - 1;
return S_OK;
}

Expand Down
14 changes: 5 additions & 9 deletions src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,6 @@ namespace gpgmm::d3d12 {
mResourceHeapTier(descriptor.ResourceHeapTier),
mIsAlwaysCommitted(descriptor.Flags & ALLOCATOR_FLAG_ALWAYS_COMMITED),
mIsAlwaysInBudget(descriptor.Flags & ALLOCATOR_FLAG_ALWAYS_IN_BUDGET),
mMaxResourceHeapSize(descriptor.MaxResourceHeapSize),
mFlushEventBuffersOnDestruct(descriptor.RecordOptions.EventScope &
EVENT_RECORD_SCOPE_PER_INSTANCE),
mUseDetailedTimingEvents(descriptor.RecordOptions.UseDetailedTimingEvents) {
Expand Down Expand Up @@ -496,17 +495,18 @@ namespace gpgmm::d3d12 {
std::unique_ptr<MemoryAllocator> pooledOrNonPooledAllocator =
CreateResourceHeapAllocator(descriptor, heapFlags, heapType, heapAlignment);

const uint64_t maxResourceHeapSize = mCaps->GetMaxResourceHeapSize();
switch (descriptor.SubAllocationAlgorithm) {
case ALLOCATOR_ALGORITHM_BUDDY_SYSTEM: {
return std::make_unique<BuddyMemoryAllocator>(
/*systemSize*/ PrevPowerOfTwo(mMaxResourceHeapSize),
/*systemSize*/ PrevPowerOfTwo(maxResourceHeapSize),
/*memorySize*/ std::max(heapAlignment, descriptor.PreferredResourceHeapSize),
/*memoryAlignment*/ heapAlignment,
/*memoryAllocator*/ std::move(pooledOrNonPooledAllocator));
}
case ALLOCATOR_ALGORITHM_SLAB: {
return std::make_unique<SlabCacheAllocator>(
/*maxSlabSize*/ PrevPowerOfTwo(mMaxResourceHeapSize),
/*maxSlabSize*/ PrevPowerOfTwo(maxResourceHeapSize),
/*minSlabSize*/ std::max(heapAlignment, descriptor.PreferredResourceHeapSize),
/*slabAlignment*/ heapAlignment,
/*slabFragmentationLimit*/ descriptor.MemoryFragmentationLimit,
Expand Down Expand Up @@ -735,11 +735,7 @@ namespace gpgmm::d3d12 {
D3D12_RESOURCE_DESC newResourceDesc = resourceDescriptor;
const D3D12_RESOURCE_ALLOCATION_INFO resourceInfo =
GetResourceAllocationInfo(mDevice.Get(), newResourceDesc);
if (resourceInfo.SizeInBytes == kInvalidSize) {
return E_OUTOFMEMORY;
}

if (resourceInfo.SizeInBytes > mMaxResourceHeapSize) {
if (resourceInfo.SizeInBytes > mCaps->GetMaxResourceSize()) {
return E_OUTOFMEMORY;
}

Expand Down Expand Up @@ -789,7 +785,7 @@ namespace gpgmm::d3d12 {
request.AlwaysPrefetch =
(allocationDescriptor.Flags & ALLOCATION_FLAG_ALWAYS_PREFETCH_MEMORY);
request.AlwaysCacheSize = (allocationDescriptor.Flags & ALLOCATION_FLAG_ALWAYS_CACHE_SIZE);
request.AvailableForAllocation = mMaxResourceHeapSize;
request.AvailableForAllocation = mCaps->GetMaxResourceHeapSize();

// Limit available memory to unused budget when residency is enabled.
if (mResidencyManager != nullptr) {
Expand Down
1 change: 0 additions & 1 deletion src/gpgmm/d3d12/ResourceAllocatorD3D12.h
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,6 @@ namespace gpgmm::d3d12 {
const D3D12_RESOURCE_HEAP_TIER mResourceHeapTier;
const bool mIsAlwaysCommitted;
const bool mIsAlwaysInBudget;
const uint64_t mMaxResourceHeapSize;
const bool mFlushEventBuffersOnDestruct;
const bool mUseDetailedTimingEvents;

Expand Down