diff --git a/src/gpgmm/d3d12/CapsD3D12.cpp b/src/gpgmm/d3d12/CapsD3D12.cpp index ea4f65dd0..90ccfc8e2 100644 --- a/src/gpgmm/d3d12/CapsD3D12.cpp +++ b/src/gpgmm/d3d12/CapsD3D12.cpp @@ -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()) { + if (feature.MaxGPUVirtualAddressBitsPerProcess == 0 || + feature.MaxGPUVirtualAddressBitsPerProcess > GetNumOfBits()) { return E_FAIL; } - *sizeOut = (1ull << (feature.MaxGPUVirtualAddressBitsPerResource - 1)) - 1; + *sizeOut = (1ull << (feature.MaxGPUVirtualAddressBitsPerProcess - 1)) - 1; return S_OK; } diff --git a/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp b/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp index c38efe578..f9d3b09c7 100644 --- a/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp +++ b/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp @@ -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) { @@ -496,17 +495,18 @@ namespace gpgmm::d3d12 { std::unique_ptr pooledOrNonPooledAllocator = CreateResourceHeapAllocator(descriptor, heapFlags, heapType, heapAlignment); + const uint64_t maxResourceHeapSize = mCaps->GetMaxResourceHeapSize(); switch (descriptor.SubAllocationAlgorithm) { case ALLOCATOR_ALGORITHM_BUDDY_SYSTEM: { return std::make_unique( - /*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( - /*maxSlabSize*/ PrevPowerOfTwo(mMaxResourceHeapSize), + /*maxSlabSize*/ PrevPowerOfTwo(maxResourceHeapSize), /*minSlabSize*/ std::max(heapAlignment, descriptor.PreferredResourceHeapSize), /*slabAlignment*/ heapAlignment, /*slabFragmentationLimit*/ descriptor.MemoryFragmentationLimit, @@ -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; } @@ -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) { diff --git a/src/gpgmm/d3d12/ResourceAllocatorD3D12.h b/src/gpgmm/d3d12/ResourceAllocatorD3D12.h index bea9d9b6d..78e4b4160 100644 --- a/src/gpgmm/d3d12/ResourceAllocatorD3D12.h +++ b/src/gpgmm/d3d12/ResourceAllocatorD3D12.h @@ -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;