Skip to content

Commit

Permalink
Remove video from D3D12 API. (#981)
Browse files Browse the repository at this point in the history
Issue: #683
  • Loading branch information
bbernhar authored Feb 1, 2024
1 parent dc52269 commit 46fd45e
Show file tree
Hide file tree
Showing 9 changed files with 133 additions and 132 deletions.
32 changes: 16 additions & 16 deletions include/gpgmm_d3d12.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ namespace gpgmm::d3d12 {
IResidencyHeap serves as a node within the IResidencyManager's residency cache. This node is
inserted into the cache when it is first created, and any time it is scheduled to be used by the
GPU. This node is removed from the cache when it is evicted from video memory due to budget
GPU. This node is removed from the cache when it is evicted from memory due to budget
constraints, or when the memory is released.
*/
GPGMM_INTERFACE IResidencyHeap : public IDebugObject {
Expand Down Expand Up @@ -496,20 +496,20 @@ namespace gpgmm::d3d12 {
*/
RECORD_OPTIONS RecordOptions;

/** \brief Maximum amount of budgeted memory, expressed as a percentage of video memory,
/** \brief Maximum amount of budgeted memory, expressed as a percentage of memory,
that can be budgeted.
If a non-zero MaxBudgetInBytes is specified, MaxPctOfVideoMemoryToBudget is ignored.
If a non-zero MaxBudgetInBytes is specified, MaxPctOfMemoryToBudget is ignored.
Optional parameter. By default, the API will automatically set the budget to 95% of video
memory, leaving 5% for the OS and other applications.
*/
FLOAT MaxPctOfVideoMemoryToBudget;
FLOAT MaxPctOfMemoryToBudget;

/** \brief Lowest amount of budgeted memory, expressed as a percentage, that can be
reserved.
If SetVideoMemoryReservation is used a set a reservation larger then the budget, this amount
If SetMemoryReservation is used a set a reservation larger then the budget, this amount
is used instead so the application can make forward progress.
Optional parameter. By default, the API restricts the residency manager reservation to never
Expand Down Expand Up @@ -600,7 +600,7 @@ namespace gpgmm::d3d12 {

/** \brief Amount of memory, in bytes, that the application has available for reservation.
To reserve memory, the application should call IResidencyManager::SetVideoMemoryReservation.
To reserve memory, the application should call IResidencyManager::SetMemoryReservation.
*/
UINT64 AvailableForReservation;

Expand Down Expand Up @@ -640,29 +640,29 @@ namespace gpgmm::d3d12 {
ID3D12CommandQueue* const pQueue, ID3D12CommandList* const* ppCommandLists,
IResidencyList* const* ppResidencyLists, UINT count) = 0;

/** \brief Sets video memory reservation.
/** \brief Sets memory reservation.
A reservation is the lowest amount of physical memory the application need to continue
operation safely.
@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
|reservation| when under memory pressure. A value of nullptr will update but not
return the current reservation.
*/
virtual HRESULT SetVideoMemoryReservation(const RESIDENCY_HEAP_SEGMENT& heapSegment,
UINT64 availableForReservation,
UINT64* pCurrentReservationOut = nullptr) = 0;
virtual HRESULT SetMemoryReservation(const RESIDENCY_HEAP_SEGMENT& heapSegment,
UINT64 availableForReservation,
UINT64* pCurrentReservationOut = nullptr) = 0;

/** \brief Get the current budget and memory usage.
@param heapSegment Memory segment to retrieve info from.
@param[out] pVideoMemoryInfoOut Pointer to DXGI_QUERY_VIDEO_MEMORY_INFO to populate. A value
@param[out] pMemoryInfoOut Pointer to RESIDENCY_MEMORY_INFO to populate. A value
of nullptr will update but not return the current info.
*/
virtual HRESULT QueryVideoMemoryInfo(const RESIDENCY_HEAP_SEGMENT& heapSegment,
RESIDENCY_MEMORY_INFO* pVideoMemoryInfoOut) = 0;
virtual HRESULT QueryMemoryInfo(const RESIDENCY_HEAP_SEGMENT& heapSegment,
RESIDENCY_MEMORY_INFO* pMemoryInfoOut) = 0;

/** \brief Update the residency status of a heap.
Expand All @@ -688,14 +688,14 @@ namespace gpgmm::d3d12 {
virtual HRESULT QueryStats(RESIDENCY_MANAGER_STATS * pResidencyManagerStats) = 0;
};

/** \brief Create residency residency manager to manage video memory.
/** \brief Create residency residency manager to manage memory.
@param descriptor A reference to RESIDENCY_MANAGER_DESC structure that describes the residency
manager.
@param pDevice device used by this allocator. Required parameter. Use CreateDevice get the
device.
@param pAdapter DXGI adapter used to create the device. Requires DXGI 1.4 due to
IDXGIAdapter3::QueryVideoMemoryInfo. Use EnumAdapters to get the adapter.
IDXGIAdapter3::QueryMemoryInfo. Use EnumAdapters to get the adapter.
@param[out] ppResidencyManagerOut Pointer to a memory block that receives a pointer to the
residency manager. Pass NULL to test if residency Manager creation would succeed, but not
actually create the residency Manager. If NULL is passed and residency manager creating
Expand Down
2 changes: 1 addition & 1 deletion src/fuzzers/D3D12ResidencyManagerFuzzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace {
return 0;
}
gpgmm::d3d12::RESIDENCY_MEMORY_INFO segment = {};
gResidencyManager->QueryVideoMemoryInfo(heapSegment, &segment);
gResidencyManager->QueryMemoryInfo(heapSegment, &segment);
return (segment.Budget > segment.CurrentUsage) ? (segment.Budget - segment.CurrentUsage)
: 0;
}
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 @@ -246,7 +246,7 @@ namespace gpgmm::d3d12 {
dict.AddItem("MinRecordLevel", desc.MinRecordLevel);
dict.AddItem("Flags", desc.Flags);
dict.AddItem("RecordOptions", Serialize(desc.RecordOptions));
dict.AddItem("MaxPctOfVideoMemoryToBudget", desc.MaxPctOfVideoMemoryToBudget);
dict.AddItem("MaxPctOfMemoryToBudget", desc.MaxPctOfMemoryToBudget);
dict.AddItem("MinPctOfBudgetToReserve", desc.MinPctOfBudgetToReserve);
dict.AddItem("MaxBudgetInBytes", desc.MaxBudgetInBytes);
dict.AddItem("EvictSizeInBytes", desc.EvictSizeInBytes);
Expand Down
4 changes: 2 additions & 2 deletions src/gpgmm/d3d12/ResidencyHeapD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,8 @@ namespace gpgmm::d3d12 {

if (bytesEvicted < descriptor.SizeInBytes) {
RESIDENCY_MEMORY_INFO currentVideoInfo = {};
if (SUCCEEDED(residencyManager->QueryVideoMemoryInfo(descriptor.HeapSegment,
&currentVideoInfo))) {
if (SUCCEEDED(residencyManager->QueryMemoryInfo(descriptor.HeapSegment,
&currentVideoInfo))) {
ErrorLog(ErrorCode::kSizeExceeded)
<< "Unable to create heap because not enough budget exists ("
<< GetBytesToSizeInUnits(descriptor.SizeInBytes) << " vs "
Expand Down
Loading

0 comments on commit 46fd45e

Please sign in to comment.